]> git.meshlink.io Git - catta/commitdiff
* add service type browser
authorLennart Poettering <lennart@poettering.net>
Sun, 22 May 2005 14:40:39 +0000 (14:40 +0000)
committerLennart Poettering <lennart@poettering.net>
Sun, 22 May 2005 14:40:39 +0000 (14:40 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@85 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-core/Makefile.am
avahi-core/avahi-test.c
avahi-core/core.h
avahi-core/server.c
avahi-core/server.h

index 95eeea77c890d7a2c93a2ef23e2bb52a8a7564ce..39d784401f6878401354ea53bd55d9342bba62eb 100644 (file)
@@ -60,7 +60,8 @@ libavahi_core_la_SOURCES = \
        alternative.c alternative.h \
        resolve-host-name.c \
        resolve-address.c \
-       browse-domain.c
+       browse-domain.c \
+       browse-service-type.c
 
 prioq_test_SOURCES = \
        prioq-test.c  \
index 45a37f2840fd3a6a617e3ebeb519bb3b78eb091f..56034819e69cb33cbd509b8de5f0c2a7a6bec054 100644 (file)
@@ -144,6 +144,11 @@ static void db_callback(AvahiDomainBrowser *b, gint iface, guchar protocol, Avah
     g_message("DB: (%i.%i) %s [%s]", iface, protocol, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
 }
 
+static void stb_callback(AvahiServiceTypeBrowser *b, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *service_type, const gchar *domain, gpointer userdata) {
+
+    g_message("STB: (%i.%i) %s in %s [%s]", iface, protocol, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
+}
+    
 int main(int argc, char *argv[]) {
     GMainLoop *loop = NULL;
     AvahiRecordBrowser *r;
@@ -153,6 +158,7 @@ int main(int argc, char *argv[]) {
     AvahiServerConfig config;
     AvahiAddress a;
     AvahiDomainBrowser *db;
+    AvahiServiceTypeBrowser *stb;
 
     avahi_server_config_init(&config);
 /*     config.host_name = g_strdup("test"); */
@@ -160,14 +166,16 @@ int main(int argc, char *argv[]) {
     avahi_server_config_free(&config);
 
     k = avahi_key_new("_http._tcp.local", AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
-    r = avahi_record_browser_new(server, 0, AF_UNSPEC, k, record_browser_callback, NULL);
+    r = avahi_record_browser_new(server, -1, AF_UNSPEC, k, record_browser_callback, NULL);
     avahi_key_unref(k);
 
-    hnr = avahi_host_name_resolver_new(server, 0, AF_UNSPEC, "codes-CompUTER.local", AF_UNSPEC, hnr_callback, NULL);
+    hnr = avahi_host_name_resolver_new(server, -1, AF_UNSPEC, "codes-CompUTER.local", AF_UNSPEC, hnr_callback, NULL);
+
+    ar = avahi_address_resolver_new(server, -1, AF_UNSPEC, avahi_address_parse("192.168.50.15", AF_INET, &a), ar_callback, NULL);
 
-    ar = avahi_address_resolver_new(server, 0, AF_UNSPEC, avahi_address_parse("192.168.50.15", AF_INET, &a), ar_callback, NULL);
+    db = avahi_domain_browser_new(server, -1, AF_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, db_callback, NULL);
 
-    db = avahi_domain_browser_new(server, 0, AF_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, db_callback, NULL);
+    stb = avahi_service_type_browser_new(server, -1, AF_UNSPEC, NULL, stb_callback, NULL);
     
     loop = g_main_loop_new(NULL, FALSE);
     
@@ -180,6 +188,7 @@ int main(int argc, char *argv[]) {
     avahi_record_browser_free(r);
     avahi_host_name_resolver_free(hnr);
     avahi_address_resolver_free(ar);
+    avahi_service_type_browser_free(stb);
 
     if (group)
         avahi_entry_group_free(group);   
index 4f981e034b24e5eceac4fb48a54391b6a76a74b9..2c3dafd0ef4cc0d9447b49210bdcfd76af3e7f81 100644 (file)
@@ -244,8 +244,14 @@ typedef void (*AvahiDomainBrowserCallback)(AvahiDomainBrowser *b, gint interface
 AvahiDomainBrowser *avahi_domain_browser_new(AvahiServer *server, gint interface, guchar protocol, const gchar *domain, AvahiDomainBrowserType type, AvahiDomainBrowserCallback callback, gpointer userdata);
 void avahi_domain_browser_free(AvahiDomainBrowser *b);
 
-/* not yet implemented */
 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
+typedef void (*AvahiServiceTypeBrowserCallback)(AvahiServiceTypeBrowser *b, gint interface, guchar protocol, AvahiBrowserEvent event, const gchar *type, const gchar *domain, gpointer userdata);
+AvahiServiceTypeBrowser *avahi_service_type_browser_new(AvahiServer *server, gint interface, guchar protocol, const gchar *domain, AvahiServiceTypeBrowserCallback callback, gpointer userdata);
+void avahi_service_type_browser_free(AvahiServiceTypeBrowser *b);
+
+
+/* Not yet implemented */
+
 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
 typedef struct AvahiServiceResolver AvahiServiceResolver;
 
index b00e4ee054832a560f8d645d0dec4bf15b431d6d..83bec157a00ddb6a7a46f9a7653170f51c298a17 100644 (file)
@@ -965,6 +965,7 @@ AvahiServer *avahi_server_new(GMainContext *c, const AvahiServerConfig *sc, Avah
     AVAHI_LLIST_HEAD_INIT(AvahiHostNameResolver, s->host_name_resolvers);
     AVAHI_LLIST_HEAD_INIT(AvahiAddressResolver, s->address_resolvers);
     AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, s->domain_browsers);
+    AVAHI_LLIST_HEAD_INIT(AvahiServiceTypeBrowser, s->service_type_browsers);
 
     /* Get host name */
     s->host_name = s->config.host_name ? avahi_normalize_name(s->config.host_name) : avahi_get_host_name();
@@ -1009,6 +1010,8 @@ void avahi_server_free(AvahiServer* s) {
         avahi_address_resolver_free(s->address_resolvers);
     while (s->domain_browsers)
         avahi_domain_browser_free(s->domain_browsers);
+    while (s->service_type_browsers)
+        avahi_service_type_browser_free(s->service_type_browsers);
     while (s->record_browsers)
         avahi_record_browser_destroy(s->record_browsers);
     g_hash_table_destroy(s->record_browser_hashtable);
index 472617445d524c6e8adabd711c89aa449b5bbb4c..60737cea4d999af3db9adf1ffd3510a5a8da462b 100644 (file)
@@ -80,6 +80,7 @@ struct AvahiServer {
     AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers);
     AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers);
     AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers);
+    AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers);
 
     gboolean need_entry_cleanup, need_group_cleanup, need_browser_cleanup;