X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fdbus-protocol.c;h=0631f729f92d2656d4bf50c1efe2ef17020aad7d;hb=32260f5d2ca0370b07da494b60c01a3a861a0c20;hp=4e67281da57c2a14f8e60eb1386184cd77793851;hpb=522fb5c25acf2af440e5203e41d07f5fc97ad0a6;p=catta diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index 4e67281..0631f72 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -308,6 +308,47 @@ static DBusHandlerResult respond_path(DBusConnection *c, DBusMessage *m, const g return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult handle_introspect(DBusConnection *c, DBusMessage *m, const gchar *fname) { + gchar *path = NULL; + gchar *contents; + GError *gerror = NULL; + DBusError error; + + g_assert(c); + g_assert(m); + g_assert(fname); + + dbus_error_init(&error); + + if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { + avahi_log_warn("Error parsing Introspect message: %s", error.message); + goto fail; + } + + path = g_strdup_printf("%s/%s", AVAHI_DBUS_INTROSPECTION_DIR, fname); + + if (!(g_file_get_contents(path, &contents, NULL, &gerror))) { + avahi_log_warn("Failed to load introspection data: %s", gerror->message); + g_error_free(gerror); + g_free(path); + goto fail; + } + + g_free(path); + + respond_string(c, m, contents); + g_free(contents); + + return DBUS_HANDLER_RESULT_HANDLED; + +fail: + if (dbus_error_is_set(&error)) + dbus_error_free(&error); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + +} + static DBusHandlerResult msg_signal_filter_impl(DBusConnection *c, DBusMessage *m, void *userdata) { GMainLoop *loop = userdata; DBusError error; @@ -395,6 +436,10 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, dbus_message_get_path(m), dbus_message_get_member(m)); + /* Introspection */ + if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + return handle_introspect(c, m, "EntryGroup.introspect"); + /* Access control */ if (strcmp(dbus_message_get_sender(m), i->client->name)) return respond_error(c, m, DBUS_ERROR_ACCESS_DENIED, NULL); @@ -610,6 +655,10 @@ static DBusHandlerResult msg_domain_browser_impl(DBusConnection *c, DBusMessage dbus_message_get_path(m), dbus_message_get_member(m)); + /* Introspection */ + if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + return handle_introspect(c, m, "DomainBrowser.introspect"); + /* Access control */ if (strcmp(dbus_message_get_sender(m), i->client->name)) return respond_error(c, m, DBUS_ERROR_ACCESS_DENIED, NULL); @@ -674,6 +723,10 @@ static DBusHandlerResult msg_service_type_browser_impl(DBusConnection *c, DBusMe dbus_message_get_path(m), dbus_message_get_member(m)); + /* Introspection */ + if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + return handle_introspect(c, m, "ServiceTypeBrowser.introspect"); + /* Access control */ if (strcmp(dbus_message_get_sender(m), i->client->name)) return respond_error(c, m, DBUS_ERROR_ACCESS_DENIED, NULL); @@ -740,6 +793,10 @@ static DBusHandlerResult msg_service_browser_impl(DBusConnection *c, DBusMessage dbus_message_get_path(m), dbus_message_get_member(m)); + /* Introspection */ + if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + return handle_introspect(c, m, "ServiceBrowser.introspect"); + /* Access control */ if (strcmp(dbus_message_get_sender(m), i->client->name)) return respond_error(c, m, DBUS_ERROR_ACCESS_DENIED, NULL); @@ -811,7 +868,6 @@ static void service_resolver_callback( DBusMessage *reply; g_assert(r); - g_assert(host_name); g_assert(i); if (event == AVAHI_RESOLVER_FOUND) { @@ -821,6 +877,8 @@ static void service_resolver_callback( guint n, j; AvahiStringList *p; + g_assert(host_name); + g_assert(a); avahi_address_snprint(t, sizeof(t), a); @@ -863,6 +921,7 @@ static void service_resolver_callback( service_resolver_free(i); } + static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void *userdata) { DBusError error; @@ -873,7 +932,10 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void dbus_message_get_path(m), dbus_message_get_member(m)); - if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) { + if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + return handle_introspect(c, m, "Server.introspect"); + + else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_SERVER, "GetHostName")) { if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) { avahi_log_warn("Error parsing Server::GetHostName message"); @@ -977,7 +1039,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void i = g_new(EntryGroupInfo, 1); i->id = ++client->current_id; i->client = client; - i->path = g_strdup_printf("/org/freedesktop/Avahi/Client%u/EntryGroup%u", client->id, i->id); + i->path = g_strdup_printf("/Client%u/EntryGroup%u", client->id, i->id); AVAHI_LLIST_PREPEND(EntryGroupInfo, entry_groups, client->entry_groups, i); if (!(i->entry_group = avahi_entry_group_new(avahi_server, entry_group_callback, i))) { @@ -1093,7 +1155,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void i = g_new(DomainBrowserInfo, 1); i->id = ++client->current_id; i->client = client; - i->path = g_strdup_printf("/org/freedesktop/Avahi/Client%u/DomainBrowser%u", client->id, i->id); + i->path = g_strdup_printf("/Client%u/DomainBrowser%u", client->id, i->id); AVAHI_LLIST_PREPEND(DomainBrowserInfo, domain_browsers, client->domain_browsers, i); @@ -1138,7 +1200,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void i = g_new(ServiceTypeBrowserInfo, 1); i->id = ++client->current_id; i->client = client; - i->path = g_strdup_printf("/org/freedesktop/Avahi/Client%u/ServiceTypeBrowser%u", client->id, i->id); + i->path = g_strdup_printf("/Client%u/ServiceTypeBrowser%u", client->id, i->id); AVAHI_LLIST_PREPEND(ServiceTypeBrowserInfo, service_type_browsers, client->service_type_browsers, i); @@ -1184,7 +1246,7 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void i = g_new(ServiceBrowserInfo, 1); i->id = ++client->current_id; i->client = client; - i->path = g_strdup_printf("/org/freedesktop/Avahi/Client%u/ServiceBrowser%u", client->id, i->id); + i->path = g_strdup_printf("/Client%u/ServiceBrowser%u", client->id, i->id); AVAHI_LLIST_PREPEND(ServiceBrowserInfo, service_browsers, client->service_browsers, i); @@ -1237,7 +1299,6 @@ static DBusHandlerResult msg_server_impl(DBusConnection *c, DBusMessage *m, void avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); - fail: if (dbus_error_is_set(&error)) dbus_error_free(&error);