summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-05-03 10:58:08 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-05-03 10:58:08 +0000
commit30957bc2890f3db99907178304046610e77c7efa (patch)
treec2ce494805a1527314e7e7f79d2596be8a695b38
parent367cd9ae48f8393cdc68c25441dc8daac75909ff (diff)
generic introspection cleanup & small additions
-rw-r--r--common/dbus-helper.c39
-rw-r--r--common/dbus-helper.h13
-rw-r--r--daemon/database.c2
-rw-r--r--daemon/manager.c2
-rw-r--r--daemon/service.c2
5 files changed, 42 insertions, 16 deletions
diff --git a/common/dbus-helper.c b/common/dbus-helper.c
index d0082451..b5a4ccc7 100644
--- a/common/dbus-helper.c
+++ b/common/dbus-helper.c
@@ -44,8 +44,10 @@ struct generic_data {
};
struct interface_data {
- const char *interface;
+ char *name;
DBusMethodVTable *methods;
+ DBusSignalVTable *signals;
+ DBusPropertyVTable *properties;
};
DBusHandlerResult dbus_connection_send_and_unref(DBusConnection *connection,
@@ -94,13 +96,13 @@ static void generic_unregister(DBusConnection *connection, void *user_data)
}
static struct interface_data *find_interface(GSList *interfaces,
- const char *interface)
+ const char *name)
{
GSList *list;
for (list = interfaces; list; list = list->next) {
struct interface_data *iface = list->data;
- if (!strcmp(interface, iface->interface))
+ if (!strcmp(name, iface->name))
return iface;
}
@@ -128,7 +130,7 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
for (current = iface->methods;
current->name && current->message_function; current++) {
if (dbus_message_is_method_call(message,
- iface->interface, current->name) == FALSE)
+ iface->name, current->name) == FALSE)
continue;
if (dbus_message_has_signature(message,
@@ -177,13 +179,16 @@ dbus_bool_t dbus_connection_destroy_object_path(DBusConnection *connection,
}
dbus_bool_t dbus_connection_register_interface(DBusConnection *connection,
- const char *path, const char *interface,
+ const char *path, const char *name,
DBusMethodVTable *methods,
+ DBusSignalVTable *signals,
DBusPropertyVTable *properties)
{
struct generic_data *data;
struct interface_data *iface;
- DBusMethodVTable *current;
+ DBusMethodVTable *method;
+ DBusSignalVTable *signal;
+ DBusPropertyVTable *property;
if (dbus_connection_get_object_path_data(connection, path,
(void *) &data) == FALSE)
@@ -191,12 +196,24 @@ dbus_bool_t dbus_connection_register_interface(DBusConnection *connection,
iface = g_new0(struct interface_data, 1);
- iface->interface = interface;
+ iface->name = g_strdup(name);
iface->methods = methods;
+ iface->signals = signals;
+ iface->properties = properties;
+
+ for (method = iface->methods; method && method->name; method++) {
+ debug("Adding introspection data for method %s.%s",
+ iface->name, method->name);
+ }
+
+ for (signal = iface->signals; signal && signal->name; signal++) {
+ debug("Adding introspection data for signal %s.%s",
+ iface->name, signal->name);
+ }
- for (current = iface->methods; current->name; current++) {
- debug("Adding introspection data for %s.%s",
- interface, current->name);
+ for (property = iface->properties; property && property->name; property++) {
+ debug("Adding introspection data for property %s.%s",
+ iface->name, property->name);
}
data->interfaces = g_slist_append(data->interfaces, iface);
@@ -205,7 +222,7 @@ dbus_bool_t dbus_connection_register_interface(DBusConnection *connection,
}
dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection,
- const char *path, const char *interface)
+ const char *path, const char *name)
{
return TRUE;
}
diff --git a/common/dbus-helper.h b/common/dbus-helper.h
index 312ab9b5..1c3809d7 100644
--- a/common/dbus-helper.h
+++ b/common/dbus-helper.h
@@ -43,18 +43,27 @@ struct DBusMethodVTable {
const char *reply;
};
+typedef struct DBusSignalVTable DBusSignalVTable;
+
+struct DBusSignalVTable {
+ const char *name;
+ const char *signature;
+};
+
typedef struct DBusPropertyVTable DBusPropertyVTable;
struct DBusPropertyVTable {
+ const char *name;
};
dbus_bool_t dbus_connection_register_interface(DBusConnection *connection,
- const char *path, const char *interface,
+ const char *path, const char *name,
DBusMethodVTable *methods,
+ DBusSignalVTable *signals,
DBusPropertyVTable *properties);
dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection,
- const char *path, const char *interface);
+ const char *path, const char *name);
void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
const char *key, int type, void *val);
diff --git a/daemon/database.c b/daemon/database.c
index 231000c0..643f50d9 100644
--- a/daemon/database.c
+++ b/daemon/database.c
@@ -207,7 +207,7 @@ int database_init(DBusConnection *conn)
info("Starting database interface");
if (dbus_connection_register_interface(connection, SYSTEM_PATH,
- DATABASE_INTERFACE, database_table, NULL) == FALSE) {
+ DATABASE_INTERFACE, database_table, NULL, NULL) == FALSE) {
error("Database interface registration failed");
dbus_connection_unref(connection);
return -1;
diff --git a/daemon/manager.c b/daemon/manager.c
index 8693486c..d2976e13 100644
--- a/daemon/manager.c
+++ b/daemon/manager.c
@@ -80,7 +80,7 @@ int manager_init(DBusConnection *conn)
info("Starting manager interface");
if (dbus_connection_register_interface(connection, SYSTEM_PATH,
- MANAGER_INTERFACE, manager_table, NULL) == FALSE) {
+ MANAGER_INTERFACE, manager_table, NULL, NULL) == FALSE) {
error("Manager interface registration failed");
dbus_connection_unref(connection);
return -1;
diff --git a/daemon/service.c b/daemon/service.c
index 1886da52..2f982f4a 100644
--- a/daemon/service.c
+++ b/daemon/service.c
@@ -304,7 +304,7 @@ int service_init(DBusConnection *conn)
}
if (dbus_connection_register_interface(connection, "/org/bluez/service",
- SERVICE_INTERFACE, service_table, NULL) == FALSE) {
+ SERVICE_INTERFACE, service_table, NULL, NULL) == FALSE) {
error("Service interface registration failed");
dbus_connection_destroy_object_path(connection, "/org/bluez/service");
dbus_connection_unref(connection);