diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-08-14 22:11:35 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-08-14 22:11:35 +0000 |
commit | 769c00f228ba0d37217aaf1424dedde390e7a01c (patch) | |
tree | e641d94f918a133f59e0eeb8e07109247d4d7aab /avahi-client/client.c | |
parent | a4acfaf4f942f702606e660990c873c9ff5b0395 (diff) |
* add new priority parameter to avahi_glib_poll_new()
* beef up AvahiPoll a little to contain real timeout events
* cleanups in avahi-client
* drop glib dependency
* port to AvahiPoll system
* put some "const"s and "static"s in to make gcc shut up
* change all uses of malloc/free to avahi_malloc/avahi_new/avahi_free
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@324 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-client/client.c')
-rw-r--r-- | avahi-client/client.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/avahi-client/client.c b/avahi-client/client.c index ad64946..7edc469 100644 --- a/avahi-client/client.c +++ b/avahi-client/client.c @@ -27,15 +27,16 @@ #include <avahi-common/dbus.h> #include <avahi-common/llist.h> #include <avahi-common/error.h> +#include <avahi-common/malloc.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> #include <stdlib.h> +#include "dbus-watch-glue.h" #include "client.h" #include "internal.h" @@ -58,7 +59,7 @@ void avahi_client_state_change (AvahiClient *client, int state) client->callback (client, state, client->user_data); } -void +static void avahi_client_state_request_callback (DBusPendingCall *call, void *data) { AvahiClient *client = data; @@ -87,7 +88,7 @@ avahi_client_state_request_callback (DBusPendingCall *call, void *data) dbus_pending_call_unref (call); } -void +static void avahi_client_schedule_state_request (AvahiClient *client) { DBusMessage *message; @@ -116,7 +117,7 @@ filter_func (DBusConnection *bus, DBusMessage *message, void *data) dbus_error_init (&error); if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { - gchar *name, *old, *new; + char *name, *old, *new; dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &old, DBUS_TYPE_STRING, &new, DBUS_TYPE_INVALID); if (dbus_error_is_set (&error)) { @@ -181,14 +182,14 @@ out: } AvahiClient * -avahi_client_new (AvahiClientCallback callback, void *user_data) +avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *user_data) { AvahiClient *tmp = NULL; DBusError error; dbus_error_init (&error); - if (!(tmp = malloc(sizeof(AvahiClient)))) + if (!(tmp = avahi_new(AvahiClient, 1))) goto fail; AVAHI_LLIST_HEAD_INIT(AvahiEntryGroup, tmp->groups); @@ -196,14 +197,18 @@ avahi_client_new (AvahiClientCallback callback, void *user_data) AVAHI_LLIST_HEAD_INIT(AvahiServiceBrowser, tmp->service_browsers); AVAHI_LLIST_HEAD_INIT(AvahiServiceTypeBrowser, tmp->service_type_browsers); + tmp->poll_api = poll_api; tmp->bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error); if (dbus_error_is_set (&error)) { goto fail; } - dbus_connection_setup_with_g_main (tmp->bus, NULL); - dbus_connection_set_exit_on_disconnect (tmp->bus, FALSE); +/* dbus_connection_setup_with_g_main (tmp->bus, NULL); */ +/* dbus_connection_set_exit_on_disconnect (tmp->bus, FALSE); */ + + if (avahi_dbus_connection_glue(tmp->bus, poll_api) < 0) + goto fail; if (!dbus_connection_add_filter (tmp->bus, filter_func, tmp, NULL)) { @@ -243,7 +248,7 @@ avahi_client_new (AvahiClientCallback callback, void *user_data) return tmp; fail: - free (tmp); + avahi_free (tmp); if (dbus_error_is_set(&error)) dbus_error_free(&error); @@ -252,7 +257,7 @@ fail: } static char* -avahi_client_get_string_reply_and_block (AvahiClient *client, char *method, char *param) +avahi_client_get_string_reply_and_block (AvahiClient *client, const char *method, const char *param) { DBusMessage *message; DBusMessage *reply; @@ -303,7 +308,7 @@ avahi_client_get_string_reply_and_block (AvahiClient *client, char *method, char return NULL; } - new = strdup (ret); + new = avahi_strdup (ret); avahi_client_set_errno (client, AVAHI_OK); return new; |