summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Orlenko <zxteam@gmail.com>2010-07-13 20:52:33 +1100
committerAlexander Orlenko <zxteam@gmail.com>2010-07-13 20:52:33 +1100
commit499a706c529a9e821cb7dcb54f63dfa50117ba39 (patch)
tree2f447807ec77d5f969061c24665487bd843d5b97
parentc0da8ea7173fcdd5b5abd0a6c1430850f6fc69f6 (diff)
downloadbluez-tools-499a706c529a9e821cb7dcb54f63dfa50117ba39.tar.gz
Added getting of dbus introspection data xml to check interface existence
-rwxr-xr-xcontrib/gen-dbus-gobject.pl80
-rw-r--r--src/lib/adapter.c94
-rw-r--r--src/lib/audio.c52
-rw-r--r--src/lib/device.c73
-rw-r--r--src/lib/input.c52
-rw-r--r--src/lib/manager.c39
-rw-r--r--src/lib/network.c52
-rw-r--r--src/lib/network_hub.c66
-rw-r--r--src/lib/network_peer.c66
-rw-r--r--src/lib/network_router.c66
-rw-r--r--src/lib/serial.c48
11 files changed, 519 insertions, 169 deletions
diff --git a/contrib/gen-dbus-gobject.pl b/contrib/gen-dbus-gobject.pl
index 0d4f461..3a31650 100755
--- a/contrib/gen-dbus-gobject.pl
+++ b/contrib/gen-dbus-gobject.pl
@@ -318,6 +318,8 @@ sub generate_source {
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "{\$object}.h"
@@ -329,6 +331,10 @@ sub generate_source {
struct _{\$Object}Private {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
{IF_PROPERTIES}
/* Properties */
{PRIV_PROPERTIES}
@@ -382,6 +388,10 @@ static void {\$object}_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS({\$object}_parent_class)->dispose(gobject);
}
@@ -420,9 +430,24 @@ static void {\$object}_init({\$Object} *self)
g_assert(conn != NULL);
{IF_INIT}
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_{\$OBJECT}_PATH, BLUEZ_DBUS_{\$OBJECT}_INTERFACE);
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_{\$OBJECT}_PATH, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, "\\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \\"%s\\" does not exist in \\"%s\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, BLUEZ_DBUS_{\$OBJECT}_PATH);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
- g_assert(self->priv->dbus_g_proxy != NULL);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_{\$OBJECT}_PATH, BLUEZ_DBUS_{\$OBJECT}_INTERFACE);
{IF_SIGNALS}
/* DBus signals connection */
@@ -438,9 +463,29 @@ static void {\$object}_init({\$Object} *self)
}
{IF_POST_INIT}
-static void {\$object}_post_init({\$Object} *self)
+static void {\$object}_post_init({\$Object} *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, "\\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \\"%s\\" does not exist in \\"%s\\"", BLUEZ_DBUS_{\$OBJECT}_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_{\$OBJECT}_INTERFACE);
{IF_SIGNALS}
/* DBus signals connection */
@@ -471,6 +516,7 @@ static void _{\$object}_get_property(GObject *object, guint property_id, GValue
static void _{\$object}_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
{\$Object} *self = {\$OBJECT}(object);
+ GError *error = NULL;
switch (property_id) {
{SET_PROPERTIES}
@@ -479,6 +525,11 @@ static void _{\$object}_set_property(GObject *object, guint property_id, const G
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
{IF_ASYNC_CALLS}
@@ -654,8 +705,10 @@ EOT
my $set_properties = "";
my $properties_access_methods = "";
my $properties_init =
- "\tGError *error = NULL;\n".
"\tGHashTable *properties = {\$object}_get_properties(self, &error);\n".
+ "\tif (error != NULL) {\n".
+ "\t\tg_critical(\"%s\", error->message);\n".
+ "\t}\n".
"\tg_assert(error == NULL);\n".
"\tg_assert(properties != NULL);\n\n";
my $properties_free = "";
@@ -674,13 +727,7 @@ EOT
$set_properties .=
"\tcase PROP_DBUS_OBJECT_PATH:\n".
- "\t{\n".
- "\t\tconst gchar *dbus_object_path = g_value_get_string(value);\n".
- "\t\tg_assert(dbus_object_path != NULL);\n".
- "\t\tg_assert(self->priv->dbus_g_proxy == NULL);\n".
- "\t\tself->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_{\$OBJECT}_INTERFACE);\n".
- "\t\t{\$object}_post_init(self);\n".
- "\t}\n".
+ "\t\t{\$object}_post_init(self, g_value_get_string(value));\n".
"\t\tbreak;\n\n";
$properties_access_methods .=
@@ -796,11 +843,7 @@ EOT
if ($p{'mode'} eq 'readwrite') {
$set_properties .=
"\tcase $enum:\n".
- "\t{\n".
- "\t\tGError *error = NULL;\n".
- "\t\t{\$object}_set_property(self, \"$property\", value, &error);\n".
- "\t\tg_assert(error == NULL);\n".
- "\t}\n".
+ "\t\t{\$object}_set_property(self, \"$property\", value, &error);\n".
"\t\tbreak;\n\n";
$properties_access_methods .=
@@ -822,6 +865,9 @@ EOT
))."(&t, value);\n".
"\t{\$object}_set_property(self, \"$property\", &t, &error);\n".
"\tg_value_unset(&t);\n\n".
+ "\tif (error != NULL) {\n".
+ "\t\tg_critical(\"%s\", error->message);\n".
+ "\t}\n".
"\tg_assert(error == NULL);\n".
"}\n\n";
}
diff --git a/src/lib/adapter.c b/src/lib/adapter.c
index 7cbd4af..228ce81 100644
--- a/src/lib/adapter.c
+++ b/src/lib/adapter.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "adapter.h"
@@ -36,6 +38,10 @@
struct _AdapterPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gchar *address;
guint32 class;
@@ -113,6 +119,10 @@ static void adapter_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(adapter_parent_class)->dispose(gobject);
}
@@ -226,9 +236,29 @@ static void adapter_init(Adapter *self)
g_assert(conn != NULL);
}
-static void adapter_post_init(Adapter *self)
+static void adapter_post_init(Adapter *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_ADAPTER_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_ADAPTER_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_ADAPTER_INTERFACE);
/* DBus signals connection */
@@ -253,8 +283,10 @@ static void adapter_post_init(Adapter *self)
dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL);
/* Properties init */
- GError *error = NULL;
GHashTable *properties = adapter_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -401,70 +433,46 @@ static void _adapter_get_property(GObject *object, guint property_id, GValue *va
static void _adapter_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Adapter *self = ADAPTER(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_ADAPTER_INTERFACE);
- adapter_post_init(self);
- }
+ adapter_post_init(self, g_value_get_string(value));
break;
case PROP_DISCOVERABLE:
- {
- GError *error = NULL;
adapter_set_property(self, "Discoverable", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_DISCOVERABLE_TIMEOUT:
- {
- GError *error = NULL;
adapter_set_property(self, "DiscoverableTimeout", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_NAME:
- {
- GError *error = NULL;
adapter_set_property(self, "Name", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_PAIRABLE:
- {
- GError *error = NULL;
adapter_set_property(self, "Pairable", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_PAIRABLE_TIMEOUT:
- {
- GError *error = NULL;
adapter_set_property(self, "PairableTimeout", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_POWERED:
- {
- GError *error = NULL;
adapter_set_property(self, "Powered", value, &error);
- g_assert(error == NULL);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
static void adapter_async_notify_callback(DBusGProxy *proxy, DBusGProxyCall *call, gpointer data)
@@ -655,6 +663,9 @@ void adapter_set_discoverable(Adapter *self, const gboolean value)
adapter_set_property(self, "Discoverable", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -677,6 +688,9 @@ void adapter_set_discoverable_timeout(Adapter *self, const guint32 value)
adapter_set_property(self, "DiscoverableTimeout", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -706,6 +720,9 @@ void adapter_set_name(Adapter *self, const gchar *value)
adapter_set_property(self, "Name", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -728,6 +745,9 @@ void adapter_set_pairable(Adapter *self, const gboolean value)
adapter_set_property(self, "Pairable", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -750,6 +770,9 @@ void adapter_set_pairable_timeout(Adapter *self, const guint32 value)
adapter_set_property(self, "PairableTimeout", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -772,6 +795,9 @@ void adapter_set_powered(Adapter *self, const gboolean value)
adapter_set_property(self, "Powered", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
diff --git a/src/lib/audio.c b/src/lib/audio.c
index b30f053..019df16 100644
--- a/src/lib/audio.c
+++ b/src/lib/audio.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "audio.h"
@@ -36,6 +38,10 @@
struct _AudioPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gchar *state;
};
@@ -75,6 +81,10 @@ static void audio_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(audio_parent_class)->dispose(gobject);
}
@@ -117,9 +127,29 @@ static void audio_init(Audio *self)
g_assert(conn != NULL);
}
-static void audio_post_init(Audio *self)
+static void audio_post_init(Audio *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_AUDIO_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_AUDIO_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_AUDIO_INTERFACE);
/* DBus signals connection */
@@ -128,8 +158,10 @@ static void audio_post_init(Audio *self)
dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL);
/* Properties init */
- GError *error = NULL;
GHashTable *properties = audio_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -165,22 +197,22 @@ static void _audio_get_property(GObject *object, guint property_id, GValue *valu
static void _audio_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Audio *self = AUDIO(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_AUDIO_INTERFACE);
- audio_post_init(self);
- }
+ audio_post_init(self, g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
diff --git a/src/lib/device.c b/src/lib/device.c
index a96d59c..7fc2797 100644
--- a/src/lib/device.c
+++ b/src/lib/device.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "device.h"
@@ -36,6 +38,10 @@
struct _DevicePrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gchar *adapter;
gchar *address;
@@ -114,6 +120,10 @@ static void device_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(device_parent_class)->dispose(gobject);
}
@@ -225,9 +235,29 @@ static void device_init(Device *self)
g_assert(conn != NULL);
}
-static void device_post_init(Device *self)
+static void device_post_init(Device *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_DEVICE_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_DEVICE_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_DEVICE_INTERFACE);
/* DBus signals connection */
@@ -248,8 +278,10 @@ static void device_post_init(Device *self)
dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL);
/* Properties init */
- GError *error = NULL;
GHashTable *properties = device_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -418,46 +450,34 @@ static void _device_get_property(GObject *object, guint property_id, GValue *val
static void _device_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Device *self = DEVICE(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_DEVICE_INTERFACE);
- device_post_init(self);
- }
+ device_post_init(self, g_value_get_string(value));
break;
case PROP_ALIAS:
- {
- GError *error = NULL;
device_set_property(self, "Alias", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_BLOCKED:
- {
- GError *error = NULL;
device_set_property(self, "Blocked", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_TRUSTED:
- {
- GError *error = NULL;
device_set_property(self, "Trusted", value, &error);
- g_assert(error == NULL);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
@@ -568,6 +588,9 @@ void device_set_alias(Device *self, const gchar *value)
device_set_property(self, "Alias", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -590,6 +613,9 @@ void device_set_blocked(Device *self, const gboolean value)
device_set_property(self, "Blocked", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -661,6 +687,9 @@ void device_set_trusted(Device *self, const gboolean value)
device_set_property(self, "Trusted", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
diff --git a/src/lib/input.c b/src/lib/input.c
index f3fb9f2..d11f650 100644
--- a/src/lib/input.c
+++ b/src/lib/input.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "input.h"
@@ -36,6 +38,10 @@
struct _InputPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gboolean connected;
};
@@ -75,6 +81,10 @@ static void input_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(input_parent_class)->dispose(gobject);
}
@@ -117,9 +127,29 @@ static void input_init(Input *self)
g_assert(conn != NULL);
}
-static void input_post_init(Input *self)
+static void input_post_init(Input *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_INPUT_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_INPUT_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_INPUT_INTERFACE);
/* DBus signals connection */
@@ -128,8 +158,10 @@ static void input_post_init(Input *self)
dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL);
/* Properties init */
- GError *error = NULL;
GHashTable *properties = input_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -165,22 +197,22 @@ static void _input_get_property(GObject *object, guint property_id, GValue *valu
static void _input_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Input *self = INPUT(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_INPUT_INTERFACE);
- input_post_init(self);
- }
+ input_post_init(self, g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
diff --git a/src/lib/manager.c b/src/lib/manager.c
index 0fb1623..2713e43 100644
--- a/src/lib/manager.c
+++ b/src/lib/manager.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "manager.h"
@@ -37,6 +39,10 @@
struct _ManagerPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
GPtrArray *adapters;
};
@@ -84,6 +90,10 @@ static void manager_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(manager_parent_class)->dispose(gobject);
}
@@ -142,9 +152,24 @@ static void manager_init(Manager *self)
g_assert(conn != NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_MANAGER_PATH, BLUEZ_DBUS_MANAGER_INTERFACE);
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_MANAGER_PATH, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_MANAGER_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_MANAGER_INTERFACE, BLUEZ_DBUS_MANAGER_PATH);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
- g_assert(self->priv->dbus_g_proxy != NULL);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, BLUEZ_DBUS_MANAGER_PATH, BLUEZ_DBUS_MANAGER_INTERFACE);
/* DBus signals connection */
@@ -165,8 +190,10 @@ static void manager_init(Manager *self)
dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL);
/* Properties init */
- GError *error = NULL;
GHashTable *properties = manager_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -198,12 +225,18 @@ static void _manager_get_property(GObject *object, guint property_id, GValue *va
static void _manager_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Manager *self = MANAGER(object);
+ GError *error = NULL;
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
diff --git a/src/lib/network.c b/src/lib/network.c
index 34e5629..94e7b67 100644
--- a/src/lib/network.c
+++ b/src/lib/network.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "network.h"
@@ -36,6 +38,10 @@
struct _NetworkPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gboolean connected;
gchar *interface;
@@ -80,6 +86,10 @@ static void network_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(network_parent_class)->dispose(gobject);
}
@@ -130,9 +140,29 @@ static void network_init(Network *self)
g_assert(conn != NULL);
}
-static void network_post_init(Network *self)
+static void network_post_init(Network *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_NETWORK_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_INTERFACE);
/* DBus signals connection */
@@ -141,8 +171,10 @@ static void network_post_init(Network *self)
dbus_g_proxy_connect_signal(self->priv->dbus_g_proxy, "PropertyChanged", G_CALLBACK(property_changed_handler), self, NULL);
/* Properties init */
- GError *error = NULL;
GHashTable *properties = network_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -200,22 +232,22 @@ static void _network_get_property(GObject *object, guint property_id, GValue *va
static void _network_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Network *self = NETWORK(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_INTERFACE);
- network_post_init(self);
- }
+ network_post_init(self, g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
diff --git a/src/lib/network_hub.c b/src/lib/network_hub.c
index 7ab2843..3c09582 100644
--- a/src/lib/network_hub.c
+++ b/src/lib/network_hub.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "network_hub.h"
@@ -36,6 +38,10 @@
struct _NetworkHubPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gboolean enabled;
gchar *name;
@@ -67,6 +73,10 @@ static void network_hub_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(network_hub_parent_class)->dispose(gobject);
}
@@ -109,13 +119,35 @@ static void network_hub_init(NetworkHub *self)
g_assert(conn != NULL);
}
-static void network_hub_post_init(NetworkHub *self)
+static void network_hub_post_init(NetworkHub *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
- /* Properties init */
GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_HUB_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_NETWORK_HUB_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_HUB_INTERFACE);
+
+ /* Properties init */
GHashTable *properties = network_hub_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -173,38 +205,30 @@ static void _network_hub_get_property(GObject *object, guint property_id, GValue
static void _network_hub_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
NetworkHub *self = NETWORK_HUB(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_HUB_INTERFACE);
- network_hub_post_init(self);
- }
+ network_hub_post_init(self, g_value_get_string(value));
break;
case PROP_ENABLED:
- {
- GError *error = NULL;
network_hub_set_property(self, "Enabled", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_NAME:
- {
- GError *error = NULL;
network_hub_set_property(self, "Name", value, &error);
- g_assert(error == NULL);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
@@ -255,6 +279,9 @@ void network_hub_set_enabled(NetworkHub *self, const gboolean value)
network_hub_set_property(self, "Enabled", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -277,6 +304,9 @@ void network_hub_set_name(NetworkHub *self, const gchar *value)
network_hub_set_property(self, "Name", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
diff --git a/src/lib/network_peer.c b/src/lib/network_peer.c
index 56aa40f..918371a 100644
--- a/src/lib/network_peer.c
+++ b/src/lib/network_peer.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "network_peer.h"
@@ -36,6 +38,10 @@
struct _NetworkPeerPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gboolean enabled;
gchar *name;
@@ -67,6 +73,10 @@ static void network_peer_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(network_peer_parent_class)->dispose(gobject);
}
@@ -109,13 +119,35 @@ static void network_peer_init(NetworkPeer *self)
g_assert(conn != NULL);
}
-static void network_peer_post_init(NetworkPeer *self)
+static void network_peer_post_init(NetworkPeer *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
- /* Properties init */
GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_PEER_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_NETWORK_PEER_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_PEER_INTERFACE);
+
+ /* Properties init */
GHashTable *properties = network_peer_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -173,38 +205,30 @@ static void _network_peer_get_property(GObject *object, guint property_id, GValu
static void _network_peer_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
NetworkPeer *self = NETWORK_PEER(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_PEER_INTERFACE);
- network_peer_post_init(self);
- }
+ network_peer_post_init(self, g_value_get_string(value));
break;
case PROP_ENABLED:
- {
- GError *error = NULL;
network_peer_set_property(self, "Enabled", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_NAME:
- {
- GError *error = NULL;
network_peer_set_property(self, "Name", value, &error);
- g_assert(error == NULL);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
@@ -255,6 +279,9 @@ void network_peer_set_enabled(NetworkPeer *self, const gboolean value)
network_peer_set_property(self, "Enabled", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -277,6 +304,9 @@ void network_peer_set_name(NetworkPeer *self, const gchar *value)
network_peer_set_property(self, "Name", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
diff --git a/src/lib/network_router.c b/src/lib/network_router.c
index 696ba15..f196b6a 100644
--- a/src/lib/network_router.c
+++ b/src/lib/network_router.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "network_router.h"
@@ -36,6 +38,10 @@
struct _NetworkRouterPrivate {
DBusGProxy *dbus_g_proxy;
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
+
/* Properties */
gboolean enabled;
gchar *name;
@@ -67,6 +73,10 @@ static void network_router_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(network_router_parent_class)->dispose(gobject);
}
@@ -109,13 +119,35 @@ static void network_router_init(NetworkRouter *self)
g_assert(conn != NULL);
}
-static void network_router_post_init(NetworkRouter *self)
+static void network_router_post_init(NetworkRouter *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
- /* Properties init */
GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE);
+
+ /* Properties init */
GHashTable *properties = network_router_get_properties(self, &error);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
g_assert(properties != NULL);
@@ -173,38 +205,30 @@ static void _network_router_get_property(GObject *object, guint property_id, GVa
static void _network_router_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
NetworkRouter *self = NETWORK_ROUTER(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_NETWORK_ROUTER_INTERFACE);
- network_router_post_init(self);
- }
+ network_router_post_init(self, g_value_get_string(value));
break;
case PROP_ENABLED:
- {
- GError *error = NULL;
network_router_set_property(self, "Enabled", value, &error);
- g_assert(error == NULL);
- }
break;
case PROP_NAME:
- {
- GError *error = NULL;
network_router_set_property(self, "Name", value, &error);
- g_assert(error == NULL);
- }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */
@@ -255,6 +279,9 @@ void network_router_set_enabled(NetworkRouter *self, const gboolean value)
network_router_set_property(self, "Enabled", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
@@ -277,6 +304,9 @@ void network_router_set_name(NetworkRouter *self, const gchar *value)
network_router_set_property(self, "Name", &t, &error);
g_value_unset(&t);
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
g_assert(error == NULL);
}
diff --git a/src/lib/serial.c b/src/lib/serial.c
index fa5af9c..ce0ef67 100644
--- a/src/lib/serial.c
+++ b/src/lib/serial.c
@@ -25,6 +25,8 @@
#include <config.h>
#endif
+#include <string.h>
+
#include "dbus-common.h"
#include "marshallers.h"
#include "serial.h"
@@ -35,6 +37,10 @@
struct _SerialPrivate {
DBusGProxy *dbus_g_proxy;
+
+ /* Introspection data */
+ DBusGProxy *introspection_g_proxy;
+ gchar *introspection_xml;
};
G_DEFINE_TYPE(Serial, serial, G_TYPE_OBJECT);
@@ -55,6 +61,10 @@ static void serial_dispose(GObject *gobject)
/* Proxy free */
g_object_unref(self->priv->dbus_g_proxy);
+ /* Introspection data free */
+ g_free(self->priv->introspection_xml);
+ g_object_unref(self->priv->introspection_g_proxy);
+
/* Chain up to the parent class */
G_OBJECT_CLASS(serial_parent_class)->dispose(gobject);
}
@@ -85,9 +95,29 @@ static void serial_init(Serial *self)
g_assert(conn != NULL);
}
-static void serial_post_init(Serial *self)
+static void serial_post_init(Serial *self, const gchar *dbus_object_path)
{
- g_assert(self->priv->dbus_g_proxy != NULL);
+ g_assert(dbus_object_path != NULL);
+ g_assert(strlen(dbus_object_path) > 0);
+ g_assert(self->priv->dbus_g_proxy == NULL);
+
+ GError *error = NULL;
+
+ /* Getting introspection XML */
+ self->priv->introspection_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, "org.freedesktop.DBus.Introspectable");
+ self->priv->introspection_xml = NULL;
+ if (!dbus_g_proxy_call(self->priv->introspection_g_proxy, "Introspect", &error, G_TYPE_INVALID, G_TYPE_STRING, &self->priv->introspection_xml, G_TYPE_INVALID)) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
+
+ gchar *test_intf_regex_str = g_strconcat("<interface name=\"", BLUEZ_DBUS_SERIAL_INTERFACE, "\">");
+ if (!g_regex_match_simple(test_intf_regex_str, self->priv->introspection_xml, 0, 0)) {
+ g_critical("Interface \"%s\" does not exist in \"%s\"", BLUEZ_DBUS_SERIAL_INTERFACE, dbus_object_path);
+ g_assert(FALSE);
+ }
+ g_free(test_intf_regex_str);
+ self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_SERIAL_INTERFACE);
}
static void _serial_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
@@ -108,22 +138,22 @@ static void _serial_get_property(GObject *object, guint property_id, GValue *val
static void _serial_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
Serial *self = SERIAL(object);
+ GError *error = NULL;
switch (property_id) {
case PROP_DBUS_OBJECT_PATH:
- {
- const gchar *dbus_object_path = g_value_get_string(value);
- g_assert(dbus_object_path != NULL);
- g_assert(self->priv->dbus_g_proxy == NULL);
- self->priv->dbus_g_proxy = dbus_g_proxy_new_for_name(conn, BLUEZ_DBUS_NAME, dbus_object_path, BLUEZ_DBUS_SERIAL_INTERFACE);
- serial_post_init(self);
- }
+ serial_post_init(self, g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
+
+ if (error != NULL) {
+ g_critical("%s", error->message);
+ }
+ g_assert(error == NULL);
}
/* Methods */