summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gdbus/gdbus.h13
-rw-r--r--gdbus/object.c117
-rw-r--r--hcid/dbus-common.c104
-rw-r--r--hcid/dbus-common.h9
-rw-r--r--network/connection.c2
-rw-r--r--network/server.c2
-rw-r--r--serial/manager.c2
-rw-r--r--serial/manager.h2
-rw-r--r--serial/port.c3
9 files changed, 124 insertions, 130 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index ffa5cf19..eefd3734 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -40,15 +40,6 @@ gboolean g_dbus_set_disconnect_function(DBusConnection *connection,
GDBusWatchFunction function,
void *user_data, DBusFreeFunction destroy);
-void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
- const char *key, int type, void *val);
-
-dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn,
- const char *path,
- const char *interface,
- const char *name,
- int type, void *value);
-
typedef void (* GDBusDestroyFunction) (void *user_data);
typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection,
@@ -100,10 +91,10 @@ gboolean g_dbus_unregister_interface(DBusConnection *connection,
gboolean g_dbus_unregister_all_interfaces(DBusConnection *connection,
const char *path);
-DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
- const char *format, va_list args);
DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name,
const char *format, ...);
+DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
+ const char *format, va_list args);
DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...);
DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
int type, va_list args);
diff --git a/gdbus/object.c b/gdbus/object.c
index 8e362be5..09a841e5 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -373,81 +373,6 @@ static void object_path_unref(DBusConnection *connection, const char *path)
dbus_connection_unregister_object_path(connection, path);
}
-static void dbus_message_iter_append_variant(DBusMessageIter *iter,
- int type, void *val)
-{
- DBusMessageIter value;
- DBusMessageIter array;
- char *sig;
-
- switch (type) {
- case DBUS_TYPE_STRING:
- sig = DBUS_TYPE_STRING_AS_STRING;
- break;
- case DBUS_TYPE_BYTE:
- sig = DBUS_TYPE_BYTE_AS_STRING;
- break;
- case DBUS_TYPE_INT16:
- sig = DBUS_TYPE_INT16_AS_STRING;
- break;
- case DBUS_TYPE_UINT16:
- sig = DBUS_TYPE_UINT16_AS_STRING;
- break;
- case DBUS_TYPE_INT32:
- sig = DBUS_TYPE_INT32_AS_STRING;
- break;
- case DBUS_TYPE_UINT32:
- sig = DBUS_TYPE_UINT32_AS_STRING;
- break;
- case DBUS_TYPE_BOOLEAN:
- sig = DBUS_TYPE_BOOLEAN_AS_STRING;
- break;
- case DBUS_TYPE_ARRAY:
- sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING;
- break;
- case DBUS_TYPE_OBJECT_PATH:
- sig = DBUS_TYPE_OBJECT_PATH_AS_STRING;
- break;
- default:
- error("Could not append variant with type %d", type);
- return;
- }
-
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
-
- if (type == DBUS_TYPE_ARRAY) {
- int i;
- const char ***str_array = val;
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING_AS_STRING, &array);
-
- for (i = 0; (*str_array)[i]; i++)
- dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING,
- &((*str_array)[i]));
-
- dbus_message_iter_close_container(&value, &array);
- } else
- dbus_message_iter_append_basic(&value, type, val);
-
- dbus_message_iter_close_container(iter, &value);
-}
-
-void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
- const char *key, int type, void *val)
-{
- DBusMessageIter entry;
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_append_variant(&entry, type, val);
-
- dbus_message_iter_close_container(dict, &entry);
-}
-
static gboolean check_signal(DBusConnection *conn, const char *path,
const char *interface, const char *name,
const char **args)
@@ -527,48 +452,6 @@ fail:
return ret;
}
-dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn,
- const char *path,
- const char *interface,
- const char *name,
- int type, void *value)
-{
- DBusMessage *signal;
- DBusMessageIter iter;
- gboolean ret;
- const char *signature, *args;
-
- if (!check_signal(conn, path, interface, "PropertyChanged", &args))
- return FALSE;
-
- signal = dbus_message_new_signal(path, interface, "PropertyChanged");
-
- if (!signal) {
- error("Unable to allocate new %s.PropertyChanged signal",
- interface);
- return FALSE;
- }
-
- dbus_message_iter_init_append(signal, &iter);
-
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
- dbus_message_iter_append_variant(&iter, type, value);
-
- signature = dbus_message_get_signature(signal);
- if (strcmp(args, signature) != 0) {
- error("%s.%s: expected signature'%s' but got '%s'",
- interface, name, args, signature);
- ret = FALSE;
- goto fail;
- }
-
- ret = dbus_connection_send(conn, signal, NULL);
-
-fail:
- dbus_message_unref(signal);
- return ret;
-}
-
gboolean g_dbus_register_interface(DBusConnection *connection,
const char *path, const char *name,
GDBusMethodTable *methods,
diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c
index 1270a002..734e2100 100644
--- a/hcid/dbus-common.c
+++ b/hcid/dbus-common.c
@@ -337,3 +337,107 @@ int hcid_dbus_init(void)
return 0;
}
+
+static void dbus_message_iter_append_variant(DBusMessageIter *iter,
+ int type, void *val)
+{
+ DBusMessageIter value;
+ DBusMessageIter array;
+ char *sig;
+
+ switch (type) {
+ case DBUS_TYPE_STRING:
+ sig = DBUS_TYPE_STRING_AS_STRING;
+ break;
+ case DBUS_TYPE_BYTE:
+ sig = DBUS_TYPE_BYTE_AS_STRING;
+ break;
+ case DBUS_TYPE_INT16:
+ sig = DBUS_TYPE_INT16_AS_STRING;
+ break;
+ case DBUS_TYPE_UINT16:
+ sig = DBUS_TYPE_UINT16_AS_STRING;
+ break;
+ case DBUS_TYPE_INT32:
+ sig = DBUS_TYPE_INT32_AS_STRING;
+ break;
+ case DBUS_TYPE_UINT32:
+ sig = DBUS_TYPE_UINT32_AS_STRING;
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ sig = DBUS_TYPE_BOOLEAN_AS_STRING;
+ break;
+ case DBUS_TYPE_ARRAY:
+ sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING;
+ break;
+ case DBUS_TYPE_OBJECT_PATH:
+ sig = DBUS_TYPE_OBJECT_PATH_AS_STRING;
+ break;
+ default:
+ error("Could not append variant with type %d", type);
+ return;
+ }
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
+
+ if (type == DBUS_TYPE_ARRAY) {
+ int i;
+ const char ***str_array = val;
+
+ dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array);
+
+ for (i = 0; (*str_array)[i]; i++)
+ dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING,
+ &((*str_array)[i]));
+
+ dbus_message_iter_close_container(&value, &array);
+ } else
+ dbus_message_iter_append_basic(&value, type, val);
+
+ dbus_message_iter_close_container(iter, &value);
+}
+
+void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
+ const char *key, int type, void *val)
+{
+ DBusMessageIter entry;
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+ NULL, &entry);
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+ dbus_message_iter_append_variant(&entry, type, val);
+
+ dbus_message_iter_close_container(dict, &entry);
+}
+
+dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn,
+ const char *path,
+ const char *interface,
+ const char *name,
+ int type, void *value)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter;
+ gboolean ret;
+
+ signal = dbus_message_new_signal(path, interface, "PropertyChanged");
+
+ if (!signal) {
+ error("Unable to allocate new %s.PropertyChanged signal",
+ interface);
+ return FALSE;
+ }
+
+ dbus_message_iter_init_append(signal, &iter);
+
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
+ dbus_message_iter_append_variant(&iter, type, value);
+
+ ret = dbus_connection_send(conn, signal, NULL);
+
+ dbus_message_unref(signal);
+ return ret;
+}
diff --git a/hcid/dbus-common.h b/hcid/dbus-common.h
index 54148f8f..26af83ee 100644
--- a/hcid/dbus-common.h
+++ b/hcid/dbus-common.h
@@ -37,3 +37,12 @@ int find_conn(int s, int dev_id, long arg);
void hcid_dbus_exit(void);
int hcid_dbus_init(void);
+
+void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
+ const char *key, int type, void *val);
+
+dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn,
+ const char *path,
+ const char *interface,
+ const char *name,
+ int type, void *value);
diff --git a/network/connection.c b/network/connection.c
index 1ddfc4cf..d2fd85c2 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -42,6 +42,8 @@
#include <glib.h>
#include <gdbus.h>
+#include "../hcid/dbus-common.h"
+
#include "logging.h"
#include "textfile.h"
#include "glib-helper.h"
diff --git a/network/server.c b/network/server.c
index 4d046602..8c0a84cf 100644
--- a/network/server.c
+++ b/network/server.c
@@ -46,6 +46,8 @@
#include <glib.h>
#include <gdbus.h>
+#include "../hcid/dbus-common.h"
+
#include "logging.h"
#include "error.h"
#include "textfile.h"
diff --git a/serial/manager.c b/serial/manager.c
index cad09e7e..f097b330 100644
--- a/serial/manager.c
+++ b/serial/manager.c
@@ -51,6 +51,8 @@
#include <glib.h>
#include <gdbus.h>
+#include "../hcid/dbus-common.h"
+
#include "logging.h"
#include "textfile.h"
diff --git a/serial/manager.h b/serial/manager.h
index 8a870101..b25c2686 100644
--- a/serial/manager.h
+++ b/serial/manager.h
@@ -24,8 +24,6 @@
#define SERIAL_MANAGER_PATH "/org/bluez/serial"
#define SERIAL_MANAGER_INTERFACE "org.bluez.serial.Manager"
-#define MAX_PATH_LENGTH 32
-
int serial_manager_init(DBusConnection *conn);
void serial_manager_exit(void);
int rfcomm_release(int16_t id);
diff --git a/serial/port.c b/serial/port.c
index 522f7c01..f0563244 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -38,10 +38,13 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
+#include <bluetooth/sdp.h>
#include <glib.h>
#include <gdbus.h>
+#include "../hcid/dbus-common.h"
+
#include "logging.h"
#include "error.h"