X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-client%2Fentrygroup.c;h=dc0994a231cef8780e9cead0110c4a54dbd20b7b;hb=c75a6b480b047abc73ee7afd912aef249e9da8e3;hp=c22d8a6722a757951b8436714572449414d0bf74;hpb=dad41109f1726a876dd918290187d0a5296b267d;p=catta diff --git a/avahi-client/entrygroup.c b/avahi-client/entrygroup.c index c22d8a6..dc0994a 100644 --- a/avahi-client/entrygroup.c +++ b/avahi-client/entrygroup.c @@ -125,6 +125,7 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall group->callback = callback; group->userdata = userdata; group->state = AVAHI_ENTRY_GROUP_UNCOMMITED; + group->path = NULL; AVAHI_LLIST_PREPEND(AvahiEntryGroup, groups, client->groups, group); if (!(message = dbus_message_new_method_call( @@ -156,7 +157,6 @@ AvahiEntryGroup* avahi_entry_group_new (AvahiClient *client, AvahiEntryGroupCall goto fail; } - if (retrieve_state(group) < 0) goto fail; @@ -184,7 +184,7 @@ fail: } static int entry_group_simple_method_call(AvahiEntryGroup *group, const char *method) { - DBusMessage *message, *reply; + DBusMessage *message = NULL, *reply = NULL; DBusError error; int r = AVAHI_OK; AvahiClient *client; @@ -288,6 +288,9 @@ int avahi_entry_group_is_empty (AvahiEntryGroup *group) { assert(group); client = group->client; + if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + dbus_error_init(&error); if (!(message = dbus_message_new_method_call(AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "IsEmpty"))) { @@ -344,6 +347,7 @@ int avahi_entry_group_add_service_strlst( int reverse = 0, r = AVAHI_OK; DBusError error; AvahiClient *client; + int32_t i_interface, i_protocol; assert(group); assert(name); @@ -351,6 +355,15 @@ int avahi_entry_group_add_service_strlst( client = group->client; + if (!group->path || group->client->state == AVAHI_CLIENT_DISCONNECTED) + return avahi_client_set_errno(group->client, AVAHI_ERR_BAD_STATE); + + if (!domain) + domain = ""; + + if (!host) + host = ""; + dbus_error_init(&error); if (!(message = dbus_message_new_method_call (AVAHI_DBUS_NAME, group->path, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService"))) { @@ -358,10 +371,13 @@ int avahi_entry_group_add_service_strlst( goto fail; } + i_interface = (int32_t) interface; + i_protocol = (int32_t) protocol; + if (!dbus_message_append_args( message, - DBUS_TYPE_INT32, &interface, - DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_INT32, &i_interface, + DBUS_TYPE_INT32, &i_protocol, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &type, DBUS_TYPE_STRING, &domain, @@ -485,8 +501,3 @@ int avahi_entry_group_add_service_va( return r; } -const char* avahi_entry_group_get_dbus_path(AvahiEntryGroup *group) { - assert(group); - - return group->path; -}