summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--client/data_manager.c4
-rw-r--r--client/dbus.c80
-rw-r--r--client/dbus.h27
-rw-r--r--client/services.c4
-rw-r--r--client/technology.c3
6 files changed, 114 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index e8865a3b..40d6479e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -224,8 +224,7 @@ noinst_PROGRAMS += client/connmanctl
MANUAL_PAGES += doc/connmanctl.1
client_connmanctl_SOURCES = $(gdbus_sources) src/connman.h \
- include/log.h src/log.c \
- include/dbus.h src/dbus.c \
+ client/dbus.h client/dbus.c \
client/data_manager.h client/data_manager.c \
client/services.h client/services.c \
client/technology.h client/technology.c \
diff --git a/client/data_manager.c b/client/data_manager.c
index 29060458..f11a385d 100644
--- a/client/data_manager.c
+++ b/client/data_manager.c
@@ -38,7 +38,7 @@
#include "client/technology.h"
#include "client/data_manager.h"
#include "gdbus/gdbus.h"
-#include "include/dbus.h"
+#include "dbus.h"
static void extract_manager_properties(DBusMessage *message)
{
@@ -211,7 +211,7 @@ int set_manager(DBusConnection *connection, char *key, dbus_bool_t value)
return -ENOMEM;
dbus_message_iter_init_append(message, &iter);
- connman_dbus_property_append_basic(&iter, (const char *) key,
+ dbus_property_append_basic(&iter, (const char *) key,
DBUS_TYPE_BOOLEAN, &value);
dbus_connection_send(connection, message, NULL);
dbus_connection_flush(connection);
diff --git a/client/dbus.c b/client/dbus.c
new file mode 100644
index 00000000..002d858f
--- /dev/null
+++ b/client/dbus.c
@@ -0,0 +1,80 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <dbus/dbus.h>
+
+#include "dbus.h"
+
+void dbus_property_append_basic(DBusMessageIter *iter,
+ const char *key, int type, void *val)
+{
+ DBusMessageIter value;
+ const char *signature;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key);
+
+ switch (type) {
+ case DBUS_TYPE_BOOLEAN:
+ signature = DBUS_TYPE_BOOLEAN_AS_STRING;
+ break;
+ case DBUS_TYPE_STRING:
+ signature = DBUS_TYPE_STRING_AS_STRING;
+ break;
+ case DBUS_TYPE_BYTE:
+ signature = DBUS_TYPE_BYTE_AS_STRING;
+ break;
+ case DBUS_TYPE_UINT16:
+ signature = DBUS_TYPE_UINT16_AS_STRING;
+ break;
+ case DBUS_TYPE_INT16:
+ signature = DBUS_TYPE_INT16_AS_STRING;
+ break;
+ case DBUS_TYPE_UINT32:
+ signature = DBUS_TYPE_UINT32_AS_STRING;
+ break;
+ case DBUS_TYPE_INT32:
+ signature = DBUS_TYPE_INT32_AS_STRING;
+ break;
+ case DBUS_TYPE_UINT64:
+ signature = DBUS_TYPE_UINT64_AS_STRING;
+ break;
+ case DBUS_TYPE_INT64:
+ signature = DBUS_TYPE_INT64_AS_STRING;
+ break;
+ case DBUS_TYPE_OBJECT_PATH:
+ signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
+ break;
+ default:
+ signature = DBUS_TYPE_VARIANT_AS_STRING;
+ break;
+ }
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
+ signature, &value);
+ dbus_message_iter_append_basic(&value, type, val);
+ dbus_message_iter_close_container(iter, &value);
+}
+
diff --git a/client/dbus.h b/client/dbus.h
new file mode 100644
index 00000000..27f7c5a0
--- /dev/null
+++ b/client/dbus.h
@@ -0,0 +1,27 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <dbus/dbus.h>
+
+void dbus_property_append_basic(DBusMessageIter *iter,
+ const char *key, int type, void *val);
+
diff --git a/client/services.c b/client/services.c
index 139637b0..99b15079 100644
--- a/client/services.c
+++ b/client/services.c
@@ -33,6 +33,7 @@
#include "client/services.h"
#include "src/connman.h"
+#include "dbus.h"
static void append_property_array(DBusMessageIter *iter, char *property,
char **data, int num_args)
@@ -482,8 +483,7 @@ int set_service_property(DBusConnection *connection, DBusMessage *message,
dbus_message_iter_init_append(message_send, &iter);
if (strcmp(property, "AutoConnect") == 0)
- connman_dbus_property_append_basic(&iter,
- (const char *) property,
+ dbus_property_append_basic(&iter, (const char *) property,
DBUS_TYPE_BOOLEAN, data);
else if ((strcmp(property, "Domains.Configuration") == 0)
|| (strcmp(property, "Timeservers.Configuration") == 0)
diff --git a/client/technology.c b/client/technology.c
index 93035513..3211aec8 100644
--- a/client/technology.c
+++ b/client/technology.c
@@ -32,6 +32,7 @@
#include "client/technology.h"
#include "src/connman.h"
+#include "dbus.h"
void extract_properties(DBusMessageIter *dict)
{
@@ -175,7 +176,7 @@ int set_technology(DBusConnection *connection, DBusMessage *message, char *key,
return -ENOMEM;
dbus_message_iter_init_append(message_send, &iter);
- connman_dbus_property_append_basic(&iter, (const char *) key,
+ dbus_property_append_basic(&iter, (const char *) key,
DBUS_TYPE_BOOLEAN, &value);
dbus_connection_send(connection, message_send, NULL);
dbus_connection_flush(connection);