2012-04-19 16:02:21

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH v2 2/6] gdbus: do not call memset for terminating NUL

---
gdbus/object.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index 7a94156..e378074 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -72,7 +72,6 @@ static void print_arguments(GString *gstr, const char *sig,

complete = FALSE;
struct_level = dict_level = 0;
- memset(type, 0, sizeof(type));

/* Gather enough data to have a single complete type */
for (len = 0; len < (sizeof(type) - 1) && sig[i]; len++, i++) {
@@ -107,6 +106,8 @@ static void print_arguments(GString *gstr, const char *sig,
break;
}

+ type[len + 1] = '\0';
+
if (!complete) {
error("Unexpected signature: %s", sig);
return;
--
1.7.10



2012-04-20 04:28:54

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH v3] gdbus: save copy of undecorated signature

---

v3: fix undecorate signature generating wrong data

gdbus/object.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)

diff --git a/gdbus/object.c b/gdbus/object.c
index e378074..6133d8c 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -25,6 +25,7 @@
#include <config.h>
#endif

+#include <assert.h>
#include <stdio.h>
#include <string.h>

@@ -46,7 +47,10 @@ struct generic_data {
struct interface_data {
char *name;
const GDBusMethodTable *methods;
+ char **method_signatures;
+ char **reply_signatures;
const GDBusSignalTable *signals;
+ char **signal_signatures;
const GDBusPropertyTable *properties;
void *user_data;
GDBusDestroyFunction destroy;
@@ -501,6 +505,79 @@ static GDBusMethodTable introspect_methods[] = {
{ }
};

+static char *undecorate_signature(const char *src)
+{
+ GString *dst = g_string_new(NULL);
+ size_t len;
+
+ for (len = 0; *src; src++) {
+ switch (*src) {
+ case '[':
+ assert(len > 0);
+ g_string_append_len(dst, src - len, len);
+
+ while (*src && *src != ']')
+ src++;
+
+ /* end of string without matching ']' */
+ assert(*src == ']');
+ len = 0;
+ break;
+ case ']':
+ /* ']' without '[' */
+ assert(0);
+ break;
+ default:
+ len++;
+ }
+ }
+
+ g_string_append_len(dst, src, len);
+
+ return g_string_free(dst, FALSE);
+}
+
+static void undecorate_signals(struct interface_data *iface)
+{
+ const GDBusSignalTable *s;
+ size_t n, i;
+ char **sigs;
+
+ for (s = iface->signals, n = 0; s && s->name; s++)
+ n++;
+
+ sigs = g_new(char *, n + 1);
+ sigs[n] = NULL;
+
+ for (s = iface->signals, i = 0; s && s->name; s++, i++)
+ sigs[i] = undecorate_signature(s->signature);
+
+ iface->signal_signatures = sigs;
+}
+
+static void undecorate_methods(struct interface_data *iface)
+{
+ const GDBusMethodTable *m;
+ size_t n, i;
+ char **sigs, **reply_sigs;
+
+ for (m = iface->methods, n = 0; m && m->name; m++)
+ n++;
+
+ sigs = g_new(char *, n + 1);
+ reply_sigs = g_new(char *, n + 1);
+ sigs[n] = NULL;
+ reply_sigs[n] = NULL;
+
+ for (m = iface->methods, i = 0; m && m->name; m++, i++) {
+ sigs[i] = undecorate_signature(m->signature);
+ reply_sigs[i] = undecorate_signature(m->reply);
+ }
+
+ iface->method_signatures = sigs;
+ iface->reply_signatures = reply_sigs;
+}
+
static void add_interface(struct generic_data *data, const char *name,
const GDBusMethodTable *methods,
const GDBusSignalTable *signals,
@@ -513,7 +590,9 @@ static void add_interface(struct generic_data *data, const char *name,
iface = g_new0(struct interface_data, 1);
iface->name = g_strdup(name);
iface->methods = methods;
+ undecorate_methods(iface);
iface->signals = signals;
+ undecorate_signals(iface);
iface->properties = properties;
iface->user_data = user_data;
iface->destroy = destroy;
@@ -568,6 +647,9 @@ static gboolean remove_interface(struct generic_data *data, const char *name)
iface->destroy(iface->user_data);

g_free(iface->name);
+ g_strfreev(iface->method_signatures);
+ g_strfreev(iface->reply_signatures);
+ g_strfreev(iface->signal_signatures);
g_free(iface);

return TRUE;
--
1.7.10


2012-04-19 16:02:25

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH v2 6/6] gdbus: add decorated signature to return values

---
attrib/client.c | 4 ++--
audio/device.c | 2 +-
audio/gateway.c | 2 +-
audio/headset.c | 6 +++---
audio/sink.c | 2 +-
audio/source.c | 2 +-
audio/transport.c | 4 ++--
gdbus/object.c | 2 +-
health/hdp.c | 10 +++++-----
input/device.c | 2 +-
network/connection.c | 4 ++--
plugins/dbusoob.c | 2 +-
proximity/monitor.c | 2 +-
proximity/reporter.c | 2 +-
sap/server.c | 2 +-
serial/port.c | 4 ++--
serial/proxy.c | 6 +++---
src/adapter.c | 10 +++++-----
src/device.c | 4 ++--
src/manager.c | 8 ++++----
thermometer/thermometer.c | 2 +-
21 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 0a5904d..7d3c3a5 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -516,7 +516,7 @@ static DBusMessage *set_property(DBusConnection *conn,
}

static GDBusMethodTable char_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}[properties]", get_properties },
{ "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC},
{ }
@@ -1022,7 +1022,7 @@ static GDBusMethodTable prim_methods[] = {
register_watcher },
{ "UnregisterCharacteristicsWatcher", "o[agent]", "",
unregister_watcher },
- { "GetProperties", "", "a{sv}",prim_get_properties },
+ { "GetProperties", "", "a{sv}[properties]",prim_get_properties },
{ }
};

diff --git a/audio/device.c b/audio/device.c
index 3875319..09cc0b1 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -622,7 +622,7 @@ static GDBusMethodTable dev_methods[] = {
{ "Connect", "", "", dev_connect,
G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", dev_disconnect },
- { "GetProperties", "", "a{sv}",dev_get_properties },
+ { "GetProperties", "", "a{sv}[properties]",dev_get_properties },
{ NULL, NULL, NULL, NULL }
};

diff --git a/audio/gateway.c b/audio/gateway.c
index 1e8943a..742db0e 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -715,7 +715,7 @@ done:
static GDBusMethodTable gateway_methods[] = {
{ "Connect", "", "", ag_connect, G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", ag_disconnect, G_DBUS_METHOD_FLAG_ASYNC },
- { "GetProperties", "", "a{sv}", ag_get_properties },
+ { "GetProperties", "", "a{sv}[properties]", ag_get_properties },
{ "RegisterAgent", "o[agent]", "", register_agent },
{ "UnregisterAgent", "o[agent]", "", unregister_agent },
{ NULL, NULL, NULL, NULL }
diff --git a/audio/headset.c b/audio/headset.c
index 61e09cb..2e465c9 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -2068,15 +2068,15 @@ static GDBusMethodTable headset_methods[] = {
{ "Stop", "", "", hs_stop },
{ "IsPlaying", "", "b", hs_is_playing,
G_DBUS_METHOD_FLAG_DEPRECATED },
- { "GetSpeakerGain", "", "q", hs_get_speaker_gain,
+ { "GetSpeakerGain", "", "q[gain]", hs_get_speaker_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
- { "GetMicrophoneGain", "", "q", hs_get_mic_gain,
+ { "GetMicrophoneGain", "", "q[gain]", hs_get_mic_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
{ "SetSpeakerGain", "q[gain]", "", hs_set_speaker_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
{ "SetMicrophoneGain", "q[gain]", "", hs_set_mic_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
- { "GetProperties", "", "a{sv}",hs_get_properties },
+ { "GetProperties", "", "a{sv}[properties]",hs_get_properties },
{ "SetProperty", "s[name]v[value]", "", hs_set_property },
{ NULL, NULL, NULL, NULL }
};
diff --git a/audio/sink.c b/audio/sink.c
index 790aad4..c33e7ee 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -562,7 +562,7 @@ static GDBusMethodTable sink_methods[] = {
G_DBUS_METHOD_FLAG_ASYNC },
{ "IsConnected", "", "b", sink_is_connected,
G_DBUS_METHOD_FLAG_DEPRECATED },
- { "GetProperties", "", "a{sv}",sink_get_properties },
+ { "GetProperties", "", "a{sv}[properties]",sink_get_properties },
{ NULL, NULL, NULL, NULL }
};

diff --git a/audio/source.c b/audio/source.c
index b9c7b77..b7bdf44 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -481,7 +481,7 @@ static GDBusMethodTable source_methods[] = {
G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", source_disconnect,
G_DBUS_METHOD_FLAG_ASYNC },
- { "GetProperties", "", "a{sv}",source_get_properties },
+ { "GetProperties", "", "a{sv}[properties]",source_get_properties },
{ NULL, NULL, NULL, NULL }
};

diff --git a/audio/transport.c b/audio/transport.c
index ae2c3f9..3b5ed47 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -915,8 +915,8 @@ static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable transport_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
- { "Acquire", "s[accesstype]", "hqq", acquire,
+ { "GetProperties", "", "a{sv}[properties]", get_properties },
+ { "Acquire", "s[accesstype]", "h[fd]q[mtu_r]q[mtu_w]", acquire,
G_DBUS_METHOD_FLAG_ASYNC},
{ "Release", "s[accesstype]", "", release,
G_DBUS_METHOD_FLAG_ASYNC},
diff --git a/gdbus/object.c b/gdbus/object.c
index a2df77e..a4ab13d 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -529,7 +529,7 @@ done:
}

static GDBusMethodTable introspect_methods[] = {
- { "Introspect", "", "s", introspect },
+ { "Introspect", "", "s[xml]", introspect },
{ }
};

diff --git a/health/hdp.c b/health/hdp.c
index 2723910..fc144cc 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -425,7 +425,7 @@ static void manager_path_unregister(gpointer data)
}

static GDBusMethodTable health_manager_methods[] = {
- {"CreateApplication", "a{sv}[config]", "o", manager_create_application},
+ {"CreateApplication", "a{sv}[config]", "o[application]", manager_create_application},
{"DestroyApplication", "o[application]", "", manager_destroy_application},
{ NULL }
};
@@ -732,8 +732,8 @@ end:
}

static GDBusMethodTable health_channels_methods[] = {
- {"GetProperties","", "a{sv}", channel_get_properties },
- {"Acquire", "", "h", channel_acquire,
+ {"GetProperties","", "a{sv}[properties]", channel_get_properties },
+ {"Acquire", "", "h[fd]", channel_acquire,
G_DBUS_METHOD_FLAG_ASYNC },
{"Release", "", "", channel_release },
{ NULL }
@@ -2096,11 +2096,11 @@ static void health_device_destroy(void *data)
static GDBusMethodTable health_device_methods[] = {
{"Echo", "", "b", device_echo,
G_DBUS_METHOD_FLAG_ASYNC },
- {"CreateChannel", "o[application]s[configuration]", "o", device_create_channel,
+ {"CreateChannel", "o[application]s[configuration]", "o[channel]", device_create_channel,
G_DBUS_METHOD_FLAG_ASYNC },
{"DestroyChannel", "o[channel]", "", device_destroy_channel,
G_DBUS_METHOD_FLAG_ASYNC },
- {"GetProperties", "", "a{sv}", device_get_properties},
+ {"GetProperties", "", "a{sv}[properties]", device_get_properties},
{ NULL }
};

diff --git a/input/device.c b/input/device.c
index a30e0e5..602d7c5 100644
--- a/input/device.c
+++ b/input/device.c
@@ -1023,7 +1023,7 @@ static GDBusMethodTable device_methods[] = {
{ "Connect", "", "", input_device_connect,
G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", input_device_disconnect },
- { "GetProperties", "", "a{sv}",input_device_get_properties },
+ { "GetProperties", "", "a{sv}[properties]", input_device_get_properties },
{ }
};

diff --git a/network/connection.c b/network/connection.c
index b4c3288..282234e 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -553,10 +553,10 @@ static void path_unregister(void *data)
}

static GDBusMethodTable connection_methods[] = {
- { "Connect", "s[uuid]", "s", connection_connect,
+ { "Connect", "s[uuid]", "s[interface_name]", connection_connect,
G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", connection_disconnect },
- { "GetProperties", "", "a{sv}",connection_get_properties },
+ { "GetProperties", "", "a{sv}[properties]",connection_get_properties },
{ }
};

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 1612fab..d147b1b 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -178,7 +178,7 @@ static DBusMessage *remove_remote_data(DBusConnection *conn, DBusMessage *msg,
static GDBusMethodTable oob_methods[] = {
{"AddRemoteData", "s[address]ay[hash]ay[randomizer]", "", add_remote_data},
{"RemoveRemoteData", "s[address]", "", remove_remote_data},
- {"ReadLocalData", "", "ayay", read_local_data,
+ {"ReadLocalData", "", "ay[hash]ay[randomizer]", read_local_data,
G_DBUS_METHOD_FLAG_ASYNC},
{}
};
diff --git a/proximity/monitor.c b/proximity/monitor.c
index 903ab69..a2f1479 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -547,7 +547,7 @@ static DBusMessage *set_property(DBusConnection *conn,
}

static GDBusMethodTable monitor_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}[properties]", get_properties },
{ "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC},
{ }
diff --git a/proximity/reporter.c b/proximity/reporter.c
index ac32ef7..cc4920c 100644
--- a/proximity/reporter.c
+++ b/proximity/reporter.c
@@ -181,7 +181,7 @@ err:
}

static GDBusMethodTable reporter_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}[properties]", get_properties },
{ }
};

diff --git a/sap/server.c b/sap/server.c
index e0fcd9b..fdedd83 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -1304,7 +1304,7 @@ static DBusMessage *get_properties(DBusConnection *c,
}

static GDBusMethodTable server_methods[] = {
- {"GetProperties", "", "a{sv}", get_properties},
+ {"GetProperties", "", "a{sv}[properties]", get_properties},
{"Disconnect", "", "", disconnect},
{ }
};
diff --git a/serial/port.c b/serial/port.c
index e7ec22b..e6b6957 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -568,8 +568,8 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
}

static GDBusMethodTable port_methods[] = {
- { "Connect", "s[pattern]", "s", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
- { "ConnectFD", "s[pattern]", "h", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
+ { "Connect", "s[pattern]", "s[tty]", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
+ { "ConnectFD", "s[pattern]", "h[fd]", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "s[device]", "", port_disconnect },
{ }
};
diff --git a/serial/proxy.c b/serial/proxy.c
index b5631c7..3dd9fbf 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -731,7 +731,7 @@ static DBusMessage *proxy_set_serial_params(DBusConnection *conn,
static GDBusMethodTable proxy_methods[] = {
{ "Enable", "", "", proxy_enable },
{ "Disable", "", "", proxy_disable },
- { "GetInfo", "", "a{sv}",proxy_get_info },
+ { "GetInfo", "", "a{sv}[properties]", proxy_get_info },
{ "SetSerialParameters", "s[rate]y[data]y[stop]s[parity]", "", proxy_set_serial_params },
{ },
};
@@ -1112,8 +1112,8 @@ static void manager_path_unregister(void *data)
}

static GDBusMethodTable manager_methods[] = {
- { "CreateProxy", "s[pattern]s[address]", "s", create_proxy },
- { "ListProxies", "", "as", list_proxies },
+ { "CreateProxy", "s[pattern]s[address]", "s[path]", create_proxy },
+ { "ListProxies", "", "as[paths]", list_proxies },
{ "RemoveProxy", "s[path]", "", remove_proxy },
{ },
};
diff --git a/src/adapter.c b/src/adapter.c
index eb015f6..2a1052a 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1660,7 +1660,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable adapter_methods[] = {
- { "GetProperties", "", "a{sv}",get_properties },
+ { "GetProperties", "", "a{sv}[properties]",get_properties },
{ "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC},
{ "RequestSession", "", "", request_session,
@@ -1669,17 +1669,17 @@ static GDBusMethodTable adapter_methods[] = {
{ "StartDiscovery", "", "", adapter_start_discovery },
{ "StopDiscovery", "", "", adapter_stop_discovery,
G_DBUS_METHOD_FLAG_ASYNC},
- { "ListDevices", "", "ao", list_devices,
+ { "ListDevices", "", "ao[devices]", list_devices,
G_DBUS_METHOD_FLAG_DEPRECATED},
- { "CreateDevice", "s[address]", "o", create_device,
+ { "CreateDevice", "s[address]", "o[device]", create_device,
G_DBUS_METHOD_FLAG_ASYNC},
- { "CreatePairedDevice", "s[address]o[agent]s[capability]", "o",
+ { "CreatePairedDevice", "s[address]o[agent]s[capability]", "o[device]",
create_paired_device, G_DBUS_METHOD_FLAG_ASYNC},
{ "CancelDeviceCreation","s[address]", "", cancel_device_creation,
G_DBUS_METHOD_FLAG_ASYNC},
{ "RemoveDevice", "o[device]", "", remove_device,
G_DBUS_METHOD_FLAG_ASYNC},
- { "FindDevice", "s[address]", "o", find_device },
+ { "FindDevice", "s[address]", "o[device]", find_device },
{ "RegisterAgent", "o[agent]s[capability]", "", register_agent },
{ "UnregisterAgent", "o[agent]", "", unregister_agent },
{ }
diff --git a/src/device.c b/src/device.c
index 493077a..fdee598 100644
--- a/src/device.c
+++ b/src/device.c
@@ -878,9 +878,9 @@ static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable device_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}[properties]", get_properties },
{ "SetProperty", "s[name]v[value]", "", set_property },
- { "DiscoverServices", "s[pattern]", "a{us}", discover_services,
+ { "DiscoverServices", "s[pattern]", "a{us}[services]", discover_services,
G_DBUS_METHOD_FLAG_ASYNC},
{ "CancelDiscovery", "", "", cancel_discover },
{ "Disconnect", "", "", disconnect,
diff --git a/src/manager.c b/src/manager.c
index 258f966..57833f0 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -197,10 +197,10 @@ static DBusMessage *get_properties(DBusConnection *conn,
}

static GDBusMethodTable manager_methods[] = {
- { "GetProperties", "", "a{sv}",get_properties },
- { "DefaultAdapter", "", "o", default_adapter },
- { "FindAdapter", "s[pattern]", "o", find_adapter },
- { "ListAdapters", "", "ao", list_adapters,
+ { "GetProperties", "", "a{sv}[properties]",get_properties },
+ { "DefaultAdapter", "", "o[adapter]", default_adapter },
+ { "FindAdapter", "s[pattern]", "o[adapter]", find_adapter },
+ { "ListAdapters", "", "ao[adapters]", list_adapters,
G_DBUS_METHOD_FLAG_DEPRECATED},
{ }
};
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 6fbb528..09760fd 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -960,7 +960,7 @@ static DBusMessage *disable_intermediate(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable thermometer_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}[properties]", get_properties },
{ "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC },
{ "RegisterWatcher", "o[agent]", "", register_watcher },
--
1.7.10


2012-04-19 16:02:24

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH v2 5/6] gdbus: add decorated signature to arguments

---
attrib/client.c | 6 +++---
audio/control.c | 2 +-
audio/device.c | 2 +-
audio/gateway.c | 6 +++---
audio/headset.c | 12 ++++++------
audio/media.c | 8 ++++----
audio/sink.c | 2 +-
audio/source.c | 2 +-
audio/telephony-dummy.c | 14 +++++++-------
audio/telephony-maemo5.c | 2 +-
audio/transport.c | 8 ++++----
doc/serial-api.txt | 2 +-
health/hdp.c | 14 +++++++-------
input/device.c | 2 +-
network/connection.c | 4 ++--
network/server.c | 4 ++--
plugins/dbusoob.c | 4 ++--
plugins/service.c | 8 ++++----
proximity/monitor.c | 4 ++--
proximity/reporter.c | 2 +-
sap/sap-dummy.c | 6 +++---
sap/server.c | 2 +-
serial/port.c | 6 +++---
serial/proxy.c | 12 ++++++------
src/adapter.c | 28 ++++++++++++++--------------
src/device.c | 6 +++---
src/manager.c | 10 +++++-----
thermometer/thermometer.c | 14 +++++++-------
28 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 35f1c90..0a5904d 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -517,7 +517,7 @@ static DBusMessage *set_property(DBusConnection *conn,

static GDBusMethodTable char_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property,
+ { "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC},
{ }
};
@@ -1018,9 +1018,9 @@ static DBusMessage *prim_get_properties(DBusConnection *conn, DBusMessage *msg,
static GDBusMethodTable prim_methods[] = {
{ "DiscoverCharacteristics", "", "ao", discover_char,
G_DBUS_METHOD_FLAG_ASYNC },
- { "RegisterCharacteristicsWatcher", "o", "",
+ { "RegisterCharacteristicsWatcher", "o[agent]", "",
register_watcher },
- { "UnregisterCharacteristicsWatcher", "o", "",
+ { "UnregisterCharacteristicsWatcher", "o[agent]", "",
unregister_watcher },
{ "GetProperties", "", "a{sv}",prim_get_properties },
{ }
diff --git a/audio/control.c b/audio/control.c
index a75e992..23bca56 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -209,7 +209,7 @@ static GDBusMethodTable control_methods[] = {
static GDBusSignalTable control_signals[] = {
{ "Connected", "", G_DBUS_SIGNAL_FLAG_DEPRECATED},
{ "Disconnected", "", G_DBUS_SIGNAL_FLAG_DEPRECATED},
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ NULL, NULL }
};

diff --git a/audio/device.c b/audio/device.c
index a9d35f9..3875319 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -627,7 +627,7 @@ static GDBusMethodTable dev_methods[] = {
};

static GDBusSignalTable dev_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ NULL, NULL }
};

diff --git a/audio/gateway.c b/audio/gateway.c
index 7b9347d..1e8943a 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -716,13 +716,13 @@ static GDBusMethodTable gateway_methods[] = {
{ "Connect", "", "", ag_connect, G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", ag_disconnect, G_DBUS_METHOD_FLAG_ASYNC },
{ "GetProperties", "", "a{sv}", ag_get_properties },
- { "RegisterAgent", "o", "", register_agent },
- { "UnregisterAgent", "o", "", unregister_agent },
+ { "RegisterAgent", "o[agent]", "", register_agent },
+ { "UnregisterAgent", "o[agent]", "", unregister_agent },
{ NULL, NULL, NULL, NULL }
};

static GDBusSignalTable gateway_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ NULL, NULL }
};

diff --git a/audio/headset.c b/audio/headset.c
index f15951d..61e09cb 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -2072,12 +2072,12 @@ static GDBusMethodTable headset_methods[] = {
G_DBUS_METHOD_FLAG_DEPRECATED },
{ "GetMicrophoneGain", "", "q", hs_get_mic_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
- { "SetSpeakerGain", "q", "", hs_set_speaker_gain,
+ { "SetSpeakerGain", "q[gain]", "", hs_set_speaker_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
- { "SetMicrophoneGain", "q", "", hs_set_mic_gain,
+ { "SetMicrophoneGain", "q[gain]", "", hs_set_mic_gain,
G_DBUS_METHOD_FLAG_DEPRECATED },
{ "GetProperties", "", "a{sv}",hs_get_properties },
- { "SetProperty", "sv", "", hs_set_property },
+ { "SetProperty", "s[name]v[value]", "", hs_set_property },
{ NULL, NULL, NULL, NULL }
};

@@ -2087,10 +2087,10 @@ static GDBusSignalTable headset_signals[] = {
{ "AnswerRequested", "" },
{ "Stopped", "", G_DBUS_SIGNAL_FLAG_DEPRECATED },
{ "Playing", "", G_DBUS_SIGNAL_FLAG_DEPRECATED },
- { "SpeakerGainChanged", "q", G_DBUS_SIGNAL_FLAG_DEPRECATED },
- { "MicrophoneGainChanged", "q", G_DBUS_SIGNAL_FLAG_DEPRECATED },
+ { "SpeakerGainChanged", "q[gain]", G_DBUS_SIGNAL_FLAG_DEPRECATED },
+ { "MicrophoneGainChanged", "q[gain]", G_DBUS_SIGNAL_FLAG_DEPRECATED },
{ "CallTerminated", "" },
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ NULL, NULL }
};

diff --git a/audio/media.c b/audio/media.c
index c0fd0c3..6607230 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1706,10 +1706,10 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable media_methods[] = {
- { "RegisterEndpoint", "oa{sv}", "", register_endpoint },
- { "UnregisterEndpoint", "o", "", unregister_endpoint },
- { "RegisterPlayer", "oa{sv}a{sv}","", register_player },
- { "UnregisterPlayer", "o", "", unregister_player },
+ { "RegisterEndpoint", "o[endpoint]a{sv}[properties]", "", register_endpoint },
+ { "UnregisterEndpoint", "o[endpoint]", "", unregister_endpoint },
+ { "RegisterPlayer", "o[player]a{sv}[properties]a{sv}[metadata]", "", register_player },
+ { "UnregisterPlayer", "o[player]", "", unregister_player },
{ },
};

diff --git a/audio/sink.c b/audio/sink.c
index 52f70a9..790aad4 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -571,7 +571,7 @@ static GDBusSignalTable sink_signals[] = {
{ "Disconnected", "", G_DBUS_SIGNAL_FLAG_DEPRECATED },
{ "Playing", "", G_DBUS_SIGNAL_FLAG_DEPRECATED },
{ "Stopped", "", G_DBUS_SIGNAL_FLAG_DEPRECATED },
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ NULL, NULL }
};

diff --git a/audio/source.c b/audio/source.c
index 4c6e2d0..b9c7b77 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -486,7 +486,7 @@ static GDBusMethodTable source_methods[] = {
};

static GDBusSignalTable source_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ NULL, NULL }
};

diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c
index 1f89079..ec94d17 100644
--- a/audio/telephony-dummy.c
+++ b/audio/telephony-dummy.c
@@ -379,14 +379,14 @@ static DBusMessage *set_subscriber_number(DBusConnection *conn,
}

static GDBusMethodTable dummy_methods[] = {
- { "OutgoingCall", "s", "", outgoing_call },
- { "IncomingCall", "s", "", incoming_call },
+ { "OutgoingCall", "s[number]", "", outgoing_call },
+ { "IncomingCall", "s[number]", "", incoming_call },
{ "CancelCall", "", "", cancel_call },
- { "SignalStrength", "u", "", signal_strength },
- { "BatteryLevel", "u", "", battery_level },
- { "RoamingStatus", "b", "", roaming_status },
- { "RegistrationStatus", "b", "", registration_status },
- { "SetSubscriberNumber","s", "", set_subscriber_number },
+ { "SignalStrength", "u[strength]","", signal_strength },
+ { "BatteryLevel", "u[level]", "", battery_level },
+ { "RoamingStatus", "b[roaming]", "", roaming_status },
+ { "RegistrationStatus", "b[registration]", "", registration_status },
+ { "SetSubscriberNumber","s[number]", "", set_subscriber_number },
{ }
};

diff --git a/audio/telephony-maemo5.c b/audio/telephony-maemo5.c
index 49230f1..4ee0f24 100644
--- a/audio/telephony-maemo5.c
+++ b/audio/telephony-maemo5.c
@@ -1952,7 +1952,7 @@ static DBusMessage *set_callerid(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable telephony_maemo_methods[] = {
- {"SetCallerId", "s", "", set_callerid,
+ {"SetCallerId", "s[id]", "", set_callerid,
G_DBUS_METHOD_FLAG_ASYNC},
{ }
};
diff --git a/audio/transport.c b/audio/transport.c
index 7bf7309..ae2c3f9 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -916,16 +916,16 @@ static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg,

static GDBusMethodTable transport_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
- { "Acquire", "s", "hqq", acquire,
+ { "Acquire", "s[accesstype]", "hqq", acquire,
G_DBUS_METHOD_FLAG_ASYNC},
- { "Release", "s", "", release,
+ { "Release", "s[accesstype]", "", release,
G_DBUS_METHOD_FLAG_ASYNC},
- { "SetProperty", "sv", "", set_property },
+ { "SetProperty", "s[name]v[value]", "", set_property },
{ },
};

static GDBusSignalTable transport_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ }
};

diff --git a/doc/serial-api.txt b/doc/serial-api.txt
index 0bdbdcd..e6319cf 100644
--- a/doc/serial-api.txt
+++ b/doc/serial-api.txt
@@ -26,7 +26,7 @@ Methods string Connect(string pattern)
org.bluez.Error.ConnectionAttemptFailed
org.bluez.Error.NotSupported

-Methods fd ConnectFD(string pattern) [experimental]
+ fd ConnectFD(string pattern) [experimental]

Connects to a specific RFCOMM based service on a
remote device and returns a file descriptor to talk
diff --git a/health/hdp.c b/health/hdp.c
index 455240c..2723910 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -425,8 +425,8 @@ static void manager_path_unregister(gpointer data)
}

static GDBusMethodTable health_manager_methods[] = {
- {"CreateApplication", "a{sv}", "o", manager_create_application},
- {"DestroyApplication", "o", "", manager_destroy_application},
+ {"CreateApplication", "a{sv}[config]", "o", manager_create_application},
+ {"DestroyApplication", "o[application]", "", manager_destroy_application},
{ NULL }
};

@@ -2096,18 +2096,18 @@ static void health_device_destroy(void *data)
static GDBusMethodTable health_device_methods[] = {
{"Echo", "", "b", device_echo,
G_DBUS_METHOD_FLAG_ASYNC },
- {"CreateChannel", "os", "o", device_create_channel,
+ {"CreateChannel", "o[application]s[configuration]", "o", device_create_channel,
G_DBUS_METHOD_FLAG_ASYNC },
- {"DestroyChannel", "o", "", device_destroy_channel,
+ {"DestroyChannel", "o[channel]", "", device_destroy_channel,
G_DBUS_METHOD_FLAG_ASYNC },
{"GetProperties", "", "a{sv}", device_get_properties},
{ NULL }
};

static GDBusSignalTable health_device_signals[] = {
- {"ChannelConnected", "o" },
- {"ChannelDeleted", "o" },
- {"PropertyChanged", "sv" },
+ {"ChannelConnected", "o[channel]" },
+ {"ChannelDeleted", "o[channel]" },
+ {"PropertyChanged", "s[name]v[value]" },
{ NULL }
};

diff --git a/input/device.c b/input/device.c
index 59388d8..a30e0e5 100644
--- a/input/device.c
+++ b/input/device.c
@@ -1028,7 +1028,7 @@ static GDBusMethodTable device_methods[] = {
};

static GDBusSignalTable device_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ }
};

diff --git a/network/connection.c b/network/connection.c
index 36b51a7..b4c3288 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -553,7 +553,7 @@ static void path_unregister(void *data)
}

static GDBusMethodTable connection_methods[] = {
- { "Connect", "s", "s", connection_connect,
+ { "Connect", "s[uuid]", "s", connection_connect,
G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", connection_disconnect },
{ "GetProperties", "", "a{sv}",connection_get_properties },
@@ -561,7 +561,7 @@ static GDBusMethodTable connection_methods[] = {
};

static GDBusSignalTable connection_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ }
};

diff --git a/network/server.c b/network/server.c
index 58c7297..6cf9e18 100644
--- a/network/server.c
+++ b/network/server.c
@@ -686,8 +686,8 @@ static void path_unregister(void *data)
}

static GDBusMethodTable server_methods[] = {
- { "Register", "ss", "", register_server },
- { "Unregister", "s", "", unregister_server },
+ { "Register", "s[uuid]s[bridge]", "", register_server },
+ { "Unregister", "s[uuid]", "", unregister_server },
{ }
};

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 2c03780..1612fab 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -176,8 +176,8 @@ static DBusMessage *remove_remote_data(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable oob_methods[] = {
- {"AddRemoteData", "sayay", "", add_remote_data},
- {"RemoveRemoteData", "s", "", remove_remote_data},
+ {"AddRemoteData", "s[address]ay[hash]ay[randomizer]", "", add_remote_data},
+ {"RemoveRemoteData", "s[address]", "", remove_remote_data},
{"ReadLocalData", "", "ayay", read_local_data,
G_DBUS_METHOD_FLAG_ASYNC},
{}
diff --git a/plugins/service.c b/plugins/service.c
index 14a5cb6..19fe666 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -697,10 +697,10 @@ done:
}

static GDBusMethodTable service_methods[] = {
- { "AddRecord", "s", "u", add_service_record },
- { "UpdateRecord", "us", "", update_service_record },
- { "RemoveRecord", "u", "", remove_service_record },
- { "RequestAuthorization","su", "", request_authorization,
+ { "AddRecord", "s[record]", "u", add_service_record },
+ { "UpdateRecord", "u[handle]s[record]", "", update_service_record },
+ { "RemoveRecord", "u[handle]", "", remove_service_record },
+ { "RequestAuthorization","s[address]u[handle]", "", request_authorization,
G_DBUS_METHOD_FLAG_ASYNC},
{ "CancelAuthorization", "", "", cancel_authorization },
{ }
diff --git a/proximity/monitor.c b/proximity/monitor.c
index 687b41c..903ab69 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -548,13 +548,13 @@ static DBusMessage *set_property(DBusConnection *conn,

static GDBusMethodTable monitor_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property,
+ { "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC},
{ }
};

static GDBusSignalTable monitor_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ }
};

diff --git a/proximity/reporter.c b/proximity/reporter.c
index cb30da5..ac32ef7 100644
--- a/proximity/reporter.c
+++ b/proximity/reporter.c
@@ -186,7 +186,7 @@ static GDBusMethodTable reporter_methods[] = {
};

static GDBusSignalTable reporter_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ }
};

diff --git a/sap/sap-dummy.c b/sap/sap-dummy.c
index acdec77..6c4af62 100644
--- a/sap/sap-dummy.c
+++ b/sap/sap-dummy.c
@@ -316,10 +316,10 @@ static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable dummy_methods[] = {
- { "OngoingCall", "b", "", ongoing_call},
- { "MaxMessageSize", "u", "", max_msg_size},
+ { "OngoingCall", "b[ongoing]", "", ongoing_call},
+ { "MaxMessageSize", "u[size]", "", max_msg_size},
{ "DisconnectImmediate", "", "", disconnect_immediate},
- { "CardStatus", "u", "", card_status},
+ { "CardStatus", "u[status]", "", card_status},
{ }
};

diff --git a/sap/server.c b/sap/server.c
index eaf9d86..e0fcd9b 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -1310,7 +1310,7 @@ static GDBusMethodTable server_methods[] = {
};

static GDBusSignalTable server_signals[] = {
- { "PropertyChanged", "sv"},
+ { "PropertyChanged", "s[name]v[value]"},
{ }
};

diff --git a/serial/port.c b/serial/port.c
index ea45c7a..e7ec22b 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -568,9 +568,9 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
}

static GDBusMethodTable port_methods[] = {
- { "Connect", "s", "s", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
- { "ConnectFD", "s", "h", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
- { "Disconnect", "s", "", port_disconnect },
+ { "Connect", "s[pattern]", "s", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
+ { "ConnectFD", "s[pattern]", "h", port_connect, G_DBUS_METHOD_FLAG_ASYNC },
+ { "Disconnect", "s[device]", "", port_disconnect },
{ }
};

diff --git a/serial/proxy.c b/serial/proxy.c
index ea5c29f..b5631c7 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -732,7 +732,7 @@ static GDBusMethodTable proxy_methods[] = {
{ "Enable", "", "", proxy_enable },
{ "Disable", "", "", proxy_disable },
{ "GetInfo", "", "a{sv}",proxy_get_info },
- { "SetSerialParameters", "syys", "", proxy_set_serial_params },
+ { "SetSerialParameters", "s[rate]y[data]y[stop]s[parity]", "", proxy_set_serial_params },
{ },
};

@@ -1112,15 +1112,15 @@ static void manager_path_unregister(void *data)
}

static GDBusMethodTable manager_methods[] = {
- { "CreateProxy", "ss", "s", create_proxy },
- { "ListProxies", "", "as", list_proxies },
- { "RemoveProxy", "s", "", remove_proxy },
+ { "CreateProxy", "s[pattern]s[address]", "s", create_proxy },
+ { "ListProxies", "", "as", list_proxies },
+ { "RemoveProxy", "s[path]", "", remove_proxy },
{ },
};

static GDBusSignalTable manager_signals[] = {
- { "ProxyCreated", "s" },
- { "ProxyRemoved", "s" },
+ { "ProxyCreated", "s[path]" },
+ { "ProxyRemoved", "s[path]" },
{ }
};

diff --git a/src/adapter.c b/src/adapter.c
index 12b6aeb..eb015f6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1661,7 +1661,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn, DBusMessage *msg,

static GDBusMethodTable adapter_methods[] = {
{ "GetProperties", "", "a{sv}",get_properties },
- { "SetProperty", "sv", "", set_property,
+ { "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC},
{ "RequestSession", "", "", request_session,
G_DBUS_METHOD_FLAG_ASYNC},
@@ -1671,26 +1671,26 @@ static GDBusMethodTable adapter_methods[] = {
G_DBUS_METHOD_FLAG_ASYNC},
{ "ListDevices", "", "ao", list_devices,
G_DBUS_METHOD_FLAG_DEPRECATED},
- { "CreateDevice", "s", "o", create_device,
+ { "CreateDevice", "s[address]", "o", create_device,
G_DBUS_METHOD_FLAG_ASYNC},
- { "CreatePairedDevice", "sos", "o", create_paired_device,
+ { "CreatePairedDevice", "s[address]o[agent]s[capability]", "o",
+ create_paired_device, G_DBUS_METHOD_FLAG_ASYNC},
+ { "CancelDeviceCreation","s[address]", "", cancel_device_creation,
G_DBUS_METHOD_FLAG_ASYNC},
- { "CancelDeviceCreation","s", "", cancel_device_creation,
+ { "RemoveDevice", "o[device]", "", remove_device,
G_DBUS_METHOD_FLAG_ASYNC},
- { "RemoveDevice", "o", "", remove_device,
- G_DBUS_METHOD_FLAG_ASYNC},
- { "FindDevice", "s", "o", find_device },
- { "RegisterAgent", "os", "", register_agent },
- { "UnregisterAgent", "o", "", unregister_agent },
+ { "FindDevice", "s[address]", "o", find_device },
+ { "RegisterAgent", "o[agent]s[capability]", "", register_agent },
+ { "UnregisterAgent", "o[agent]", "", unregister_agent },
{ }
};

static GDBusSignalTable adapter_signals[] = {
- { "PropertyChanged", "sv" },
- { "DeviceCreated", "o" },
- { "DeviceRemoved", "o" },
- { "DeviceFound", "sa{sv}" },
- { "DeviceDisappeared", "s" },
+ { "PropertyChanged", "s[name]v[value]" },
+ { "DeviceCreated", "o[device]" },
+ { "DeviceRemoved", "o[device]" },
+ { "DeviceFound", "s[address]a{sv}[values]" },
+ { "DeviceDisappeared", "s[address]" },
{ }
};

diff --git a/src/device.c b/src/device.c
index ea6fec2..493077a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -879,8 +879,8 @@ static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,

static GDBusMethodTable device_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property },
- { "DiscoverServices", "s", "a{us}", discover_services,
+ { "SetProperty", "s[name]v[value]", "", set_property },
+ { "DiscoverServices", "s[pattern]", "a{us}", discover_services,
G_DBUS_METHOD_FLAG_ASYNC},
{ "CancelDiscovery", "", "", cancel_discover },
{ "Disconnect", "", "", disconnect,
@@ -889,7 +889,7 @@ static GDBusMethodTable device_methods[] = {
};

static GDBusSignalTable device_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ "DisconnectRequested", "" },
{ }
};
diff --git a/src/manager.c b/src/manager.c
index 6244516..258f966 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -199,17 +199,17 @@ static DBusMessage *get_properties(DBusConnection *conn,
static GDBusMethodTable manager_methods[] = {
{ "GetProperties", "", "a{sv}",get_properties },
{ "DefaultAdapter", "", "o", default_adapter },
- { "FindAdapter", "s", "o", find_adapter },
+ { "FindAdapter", "s[pattern]", "o", find_adapter },
{ "ListAdapters", "", "ao", list_adapters,
G_DBUS_METHOD_FLAG_DEPRECATED},
{ }
};

static GDBusSignalTable manager_signals[] = {
- { "PropertyChanged", "sv" },
- { "AdapterAdded", "o" },
- { "AdapterRemoved", "o" },
- { "DefaultAdapterChanged", "o" },
+ { "PropertyChanged", "s[name]v[value]" },
+ { "AdapterAdded", "o[adapter]" },
+ { "AdapterRemoved", "o[adapter]" },
+ { "DefaultAdapterChanged", "o[adapter]" },
{ }
};

diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 92c0225..6fbb528 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -960,18 +960,18 @@ static DBusMessage *disable_intermediate(DBusConnection *conn, DBusMessage *msg,
}

static GDBusMethodTable thermometer_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property,
+ { "GetProperties", "", "a{sv}", get_properties },
+ { "SetProperty", "s[name]v[value]", "", set_property,
G_DBUS_METHOD_FLAG_ASYNC },
- { "RegisterWatcher", "o", "", register_watcher },
- { "UnregisterWatcher", "o", "", unregister_watcher },
- { "EnableIntermediateMeasurement", "o", "", enable_intermediate },
- { "DisableIntermediateMeasurement","o", "", disable_intermediate },
+ { "RegisterWatcher", "o[agent]", "", register_watcher },
+ { "UnregisterWatcher", "o[agent]", "", unregister_watcher },
+ { "EnableIntermediateMeasurement", "o[agent]", "", enable_intermediate },
+ { "DisableIntermediateMeasurement","o[agent]", "", disable_intermediate },
{ }
};

static GDBusSignalTable thermometer_signals[] = {
- { "PropertyChanged", "sv" },
+ { "PropertyChanged", "s[name]v[value]" },
{ }
};

--
1.7.10


2012-04-19 16:02:23

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH v2 4/6] gdbus: use argument name in method introspection

---
gdbus/gdbus.h | 6 ++---
gdbus/object.c | 70 ++++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index a0583e6..a5843e0 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -84,8 +84,8 @@ typedef enum {

typedef struct {
const char *name;
- const char *signature;
- const char *reply;
+ const char *decorated_signature;
+ const char *decorated_reply;
GDBusMethodFunction function;
GDBusMethodFlags flags;
unsigned int privilege;
@@ -93,7 +93,7 @@ typedef struct {

typedef struct {
const char *name;
- const char *signature;
+ const char *decorated_signature;
GDBusSignalFlags flags;
} GDBusSignalTable;

diff --git a/gdbus/object.c b/gdbus/object.c
index 0ac2b30..a2df77e 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -69,6 +69,7 @@ static void print_arguments(GString *gstr, const char *sig,
int i;

for (i = 0; sig[i]; i++) {
+ const char *name;
char type[32];
int struct_level, dict_level;
unsigned int len;
@@ -112,19 +113,44 @@ static void print_arguments(GString *gstr, const char *sig,

type[len + 1] = '\0';

+ /* Check if there is an arg name and parse it */
+ if (sig[i + 1] == '[') {
+ const char *name_end = name = &sig[i + 2];
+
+ for (;;) {
+ if (*name_end == '\0') {
+ error("Unexpected signature: %s", sig);
+ return;
+ }
+
+ if (*name_end == ']')
+ break;
+
+ name_end++;
+ }
+
+ len = name_end - name;
+ i += len + 2;
+ } else
+ name = NULL;
+
if (!complete) {
error("Unexpected signature: %s", sig);
return;
}

+ g_string_append_printf(gstr, "\t\t\t<arg type=\"%s\"", type);
+
if (direction)
- g_string_append_printf(gstr,
- "\t\t\t<arg type=\"%s\" direction=\"%s\"/>\n",
- type, direction);
- else
- g_string_append_printf(gstr,
- "\t\t\t<arg type=\"%s\"/>\n",
- type);
+ g_string_append_printf(gstr, " direction=\"%s\"",
+ direction);
+
+ if (name)
+ g_string_append_printf(gstr, " name=\"%.*s\"",
+ len, name);
+
+
+ g_string_append_printf(gstr,"/>\n");
}
}

@@ -134,26 +160,27 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
const GDBusSignalTable *signal;

for (method = iface->methods; method && method->name; method++) {
- if (!strlen(method->signature) && !strlen(method->reply))
+ if (!strlen(method->decorated_signature) &&
+ !strlen(method->decorated_reply))
g_string_append_printf(gstr, "\t\t<method name=\"%s\"/>\n",
method->name);
else {
g_string_append_printf(gstr, "\t\t<method name=\"%s\">\n",
method->name);
- print_arguments(gstr, method->signature, "in");
- print_arguments(gstr, method->reply, "out");
+ print_arguments(gstr, method->decorated_signature, "in");
+ print_arguments(gstr, method->decorated_reply, "out");
g_string_append_printf(gstr, "\t\t</method>\n");
}
}

for (signal = iface->signals; signal && signal->name; signal++) {
- if (!strlen(signal->signature))
+ if (!strlen(signal->decorated_signature))
g_string_append_printf(gstr, "\t\t<signal name=\"%s\"/>\n",
signal->name);
else {
g_string_append_printf(gstr, "\t\t<signal name=\"%s\">\n",
signal->name);
- print_arguments(gstr, signal->signature, NULL);
+ print_arguments(gstr, signal->decorated_signature, NULL);
g_string_append_printf(gstr, "\t\t</signal>\n");
}
}
@@ -432,6 +459,7 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
struct interface_data *iface;
const GDBusMethodTable *method;
const char *interface;
+ size_t i;

interface = dbus_message_get_interface(message);

@@ -439,14 +467,14 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
if (iface == NULL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

- for (method = iface->methods; method &&
- method->name && method->function; method++) {
+ for (method = iface->methods, i = 0; method &&
+ method->name && method->function; method++, i++) {
if (dbus_message_is_method_call(message, iface->name,
method->name) == FALSE)
continue;

if (dbus_message_has_signature(message,
- method->signature) == FALSE)
+ iface->method_signatures[i]) == FALSE)
continue;

if (check_privilege(connection, message, method,
@@ -550,7 +578,7 @@ static void undecorate_signals(struct interface_data *iface)
sigs[n] = NULL;

for (s = iface->signals, i = 0; s && s->name; s++, i++)
- sigs[i] = undecorate_signature(s->signature);
+ sigs[i] = undecorate_signature(s->decorated_signature);

iface->signal_signatures = sigs;
}
@@ -570,8 +598,8 @@ static void undecorate_methods(struct interface_data *iface)
reply_sigs[n] = NULL;

for (m = iface->methods, i = 0; m && m->name; m++, i++) {
- sigs[i] = undecorate_signature(m->signature);
- reply_sigs[i] = undecorate_signature(m->reply);
+ sigs[i] = undecorate_signature(m->decorated_signature);
+ reply_sigs[i] = undecorate_signature(m->decorated_reply);
}

iface->method_signatures = sigs;
@@ -685,6 +713,7 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
struct generic_data *data = NULL;
struct interface_data *iface;
const GDBusSignalTable *signal;
+ size_t i;

*args = NULL;
if (!dbus_connection_get_object_path_data(conn, path,
@@ -701,9 +730,10 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
return FALSE;
}

- for (signal = iface->signals; signal && signal->name; signal++) {
+ for (signal = iface->signals, i = 0; signal && signal->name;
+ signal++, i++) {
if (!strcmp(signal->name, name)) {
- *args = signal->signature;
+ *args = iface->signal_signatures[i];
break;
}
}
--
1.7.10


2012-04-19 16:02:22

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH v2 3/6] gdbus: save copy of undecorated signature

---
gdbus/object.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)

diff --git a/gdbus/object.c b/gdbus/object.c
index e378074..0ac2b30 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -25,6 +25,7 @@
#include <config.h>
#endif

+#include <assert.h>
#include <stdio.h>
#include <string.h>

@@ -46,7 +47,10 @@ struct generic_data {
struct interface_data {
char *name;
const GDBusMethodTable *methods;
+ char **method_signatures;
+ char **reply_signatures;
const GDBusSignalTable *signals;
+ char **signal_signatures;
const GDBusPropertyTable *properties;
void *user_data;
GDBusDestroyFunction destroy;
@@ -501,6 +505,79 @@ static GDBusMethodTable introspect_methods[] = {
{ }
};

+static char *undecorate_signature(const char *src)
+{
+ GString *dst = g_string_new(NULL);
+ size_t len;
+
+ for (len = 0; *src; src++) {
+ switch (*src) {
+ case '[':
+ assert(len > 0);
+ g_string_append_len(dst, src, len);
+
+ while (*src && *src != ']')
+ src++;
+
+ /* end of string without matching ']' */
+ assert(*src == ']');
+ len = 0;
+ break;
+ case ']':
+ /* ']' without '[' */
+ assert(0);
+ break;
+ default:
+ len++;
+ }
+ }
+
+ g_string_append_len(dst, src, len);
+
+ return g_string_free(dst, FALSE);
+}
+
+static void undecorate_signals(struct interface_data *iface)
+{
+ const GDBusSignalTable *s;
+ size_t n, i;
+ char **sigs;
+
+ for (s = iface->signals, n = 0; s && s->name; s++)
+ n++;
+
+ sigs = g_new(char *, n + 1);
+ sigs[n] = NULL;
+
+ for (s = iface->signals, i = 0; s && s->name; s++, i++)
+ sigs[i] = undecorate_signature(s->signature);
+
+ iface->signal_signatures = sigs;
+}
+
+static void undecorate_methods(struct interface_data *iface)
+{
+ const GDBusMethodTable *m;
+ size_t n, i;
+ char **sigs, **reply_sigs;
+
+ for (m = iface->methods, n = 0; m && m->name; m++)
+ n++;
+
+ sigs = g_new(char *, n + 1);
+ reply_sigs = g_new(char *, n + 1);
+ sigs[n] = NULL;
+ reply_sigs[n] = NULL;
+
+ for (m = iface->methods, i = 0; m && m->name; m++, i++) {
+ sigs[i] = undecorate_signature(m->signature);
+ reply_sigs[i] = undecorate_signature(m->reply);
+ }
+
+ iface->method_signatures = sigs;
+ iface->reply_signatures = reply_sigs;
+}
+
static void add_interface(struct generic_data *data, const char *name,
const GDBusMethodTable *methods,
const GDBusSignalTable *signals,
@@ -513,7 +590,9 @@ static void add_interface(struct generic_data *data, const char *name,
iface = g_new0(struct interface_data, 1);
iface->name = g_strdup(name);
iface->methods = methods;
+ undecorate_methods(iface);
iface->signals = signals;
+ undecorate_signals(iface);
iface->properties = properties;
iface->user_data = user_data;
iface->destroy = destroy;
@@ -568,6 +647,9 @@ static gboolean remove_interface(struct generic_data *data, const char *name)
iface->destroy(iface->user_data);

g_free(iface->name);
+ g_strfreev(iface->method_signatures);
+ g_strfreev(iface->reply_signatures);
+ g_strfreev(iface->signal_signatures);
g_free(iface);

return TRUE;
--
1.7.10