]> git.meshlink.io Git - catta/commitdiff
wrap avahi_server_add_service_subtype() for DBUS
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Oct 2005 01:22:48 +0000 (01:22 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Oct 2005 01:22:48 +0000 (01:22 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@720 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-daemon/EntryGroup.introspect
avahi-daemon/dbus-protocol.c

index 51cddf675f5531c497ee00b2553115118ac564eb..ef3fb5f4f6ab7884cf03ed6526396f0640b34702 100644 (file)
       <arg name="txt" type="aay" direction="in"/>
     </method>
 
+    <method name="AddServiceSubtype">
+      <arg name="interface" type="i" direction="in"/>
+      <arg name="protocol" type="i" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="name" type="s" direction="in"/>
+      <arg name="type" type="s" direction="in"/>
+      <arg name="domain" type="s" direction="in"/>
+      <arg name="subtype" type="s" direction="in"/>
+    </method>
+
     <method name="AddAddress">
       <arg name="interface" type="i" direction="in"/>
       <arg name="protocol" type="i" direction="in"/>
index 9270168a448e4125793a21654bb87dace657e340..96d011803004b15f3a7a96824aa743140a3ec095 100644 (file)
@@ -859,13 +859,48 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
         if (avahi_server_add_service_strlst(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, host, port, strlst) < 0) {
             avahi_string_list_free(strlst);
             return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
-        } else
-            i->n_entries ++;
-        
+        }
+
+        i->n_entries ++;
         avahi_string_list_free(strlst);
         
         return respond_ok(c, m);
         
+    } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype")) {
+
+        int32_t interface, protocol;
+        uint32_t flags;
+        char *type, *name, *domain, *subtype;
+        
+        if (!dbus_message_get_args(
+                m, &error,
+                DBUS_TYPE_INT32, &interface,
+                DBUS_TYPE_INT32, &protocol,
+                DBUS_TYPE_UINT32, &flags,
+                DBUS_TYPE_STRING, &name,
+                DBUS_TYPE_STRING, &type,
+                DBUS_TYPE_STRING, &domain,
+                DBUS_TYPE_STRING, &subtype,
+                DBUS_TYPE_INVALID) || !type || !name || !subtype) {
+            avahi_log_warn("Error parsing EntryGroup::AddServiceSubtype message");
+            goto fail;
+        }
+
+        if (i->n_entries >= MAX_ENTRIES_PER_ENTRY_GROUP) {
+            avahi_log_warn("Too many entries per entry group, client request failed.");
+            return respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL);
+        }
+
+        if (domain && !*domain)
+            domain = NULL;
+
+        if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0) 
+            return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
+
+        i->n_entries ++;
+        
+        return respond_ok(c, m);
+        
     } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) {
         int32_t interface, protocol;
         uint32_t flags;
@@ -895,11 +930,11 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
 
         if (avahi_server_add_address(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, &a) < 0)
             return respond_error(c, m, avahi_server_errno(avahi_server), NULL);
-        else
-            i->n_entries ++;
+
+        i->n_entries ++;
         
         return respond_ok(c, m);
-    }
+    } 
     
     avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m));