From 7231641e5c53a9d1c255e06a7a134fa60a919f88 Mon Sep 17 00:00:00 2001 From: Trent Lloyd Date: Thu, 11 Aug 2005 07:31:07 +0000 Subject: * Work on avahi-client - Support for connecting and registering services works - Needs some more error handling (DBus Errors from the daemon) - Needs browser support yet * Fix avahi-utils to pass make dist-check * Add new error codes git-svn-id: file:///home/lennart/svn/public/avahi/trunk@288 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-client/client-test.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'avahi-client/client-test.c') diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 530394f..64ad9a5 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -20,41 +20,71 @@ ***/ #include +#include #include #include +void +avahi_client_callback (AvahiClient *c, AvahiClientState state, void *user_data) +{ + printf ("XXX: Callback on client, state -> %d, data -> %s\n", state, (char*)user_data); +} + +void +avahi_entry_group_callback (AvahiClient *c, AvahiEntryGroup *g, AvahiEntryGroupState state, void *user_data) +{ + printf ("Callback on %s, state -> %d, data -> %s\n", avahi_entry_group_get_path (g), state, (char*)user_data); +} + int main (int argc, char *argv[]) { GMainLoop *loop; AvahiClient *avahi; + AvahiEntryGroup *group; + AvahiStringList *txt; char *ret; loop = g_main_loop_new (NULL, FALSE); - avahi = avahi_client_new (); + avahi = avahi_client_new (avahi_client_callback, "omghai2u"); g_assert (avahi != NULL); ret = avahi_client_get_version_string (avahi); - printf ("Avahi Server Version: %s\n", ret); + printf ("Avahi Server Version: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); g_free (ret); ret = avahi_client_get_host_name (avahi); - printf ("Host Name: %s\n", ret); + printf ("Host Name: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); g_free (ret); ret = avahi_client_get_domain_name (avahi); - printf ("Domain Name: %s\n", ret); + printf ("Domain Name: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); g_free (ret); ret = avahi_client_get_host_name_fqdn (avahi); - printf ("FQDN: %s\n", ret); + printf ("FQDN: %s (Error Return: %s)\n", ret, avahi_strerror (avahi_client_errno (avahi))); g_free (ret); + + group = avahi_entry_group_new (avahi, avahi_entry_group_callback, "omghai"); - g_free (avahi); + printf ("Creating entry group: %s\n", avahi_strerror (avahi_client_errno (avahi))); + + if (group == NULL) + printf ("Failed to create entry group object\n"); + else + printf ("Sucessfully created entry group, path %s\n", avahi_entry_group_get_path (group)); + + txt = avahi_string_list_new ("foo=bar", NULL); + + avahi_entry_group_add_service (group, AVAHI_IF_UNSPEC, AF_UNSPEC, "Lathiat's Site", "_http._tcp", "", "", 80, txt); + + avahi_entry_group_commit (group); g_main_loop_run (loop); + g_free (avahi); + return 0; } -- cgit