5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 void connman_dbus_property_append_variant(DBusMessageIter *iter,
29 const char *key, int type, void *val)
31 DBusMessageIter value;
32 const char *signature;
34 dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key);
37 case DBUS_TYPE_BOOLEAN:
38 signature = DBUS_TYPE_BOOLEAN_AS_STRING;
40 case DBUS_TYPE_STRING:
41 signature = DBUS_TYPE_STRING_AS_STRING;
44 signature = DBUS_TYPE_BYTE_AS_STRING;
46 case DBUS_TYPE_UINT16:
47 signature = DBUS_TYPE_UINT16_AS_STRING;
50 signature = DBUS_TYPE_INT16_AS_STRING;
52 case DBUS_TYPE_UINT32:
53 signature = DBUS_TYPE_UINT32_AS_STRING;
56 signature = DBUS_TYPE_INT32_AS_STRING;
58 case DBUS_TYPE_OBJECT_PATH:
59 signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
62 signature = DBUS_TYPE_VARIANT_AS_STRING;
66 dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
68 dbus_message_iter_append_basic(&value, type, val);
69 dbus_message_iter_close_container(iter, &value);
72 void connman_dbus_dict_append_array(DBusMessageIter *dict,
73 const char *key, int type, void *val, int len)
75 DBusMessageIter entry, value, array;
76 const char *variant_sig, *array_sig;
80 variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING;
81 array_sig = DBUS_TYPE_BYTE_AS_STRING;
87 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
90 dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
92 dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
95 dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
97 dbus_message_iter_append_fixed_array(&array, type, val, len);
98 dbus_message_iter_close_container(&value, &array);
100 dbus_message_iter_close_container(&entry, &value);
102 dbus_message_iter_close_container(dict, &entry);
105 void connman_dbus_dict_append_variant(DBusMessageIter *dict,
106 const char *key, int type, void *val)
108 DBusMessageIter entry;
110 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
113 connman_dbus_property_append_variant(&entry, key, type, val);
115 dbus_message_iter_close_container(dict, &entry);
118 static DBusConnection *connection = NULL;
120 DBusConnection *connman_dbus_get_connection(void)
122 if (connection == NULL)
125 return dbus_connection_ref(connection);
128 int __connman_dbus_init(DBusConnection *conn)
135 void __connman_dbus_cleanup(void)