5 * Copyright (C) 2007-2008 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
26 #include <connman/dbus.h>
28 void connman_dbus_dict_append_array(DBusMessageIter *dict,
29 const char *key, int type, void *val, int len)
31 DBusMessageIter entry, value, array;
32 const char *variant_sig, *array_sig;
36 variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING;
37 array_sig = DBUS_TYPE_BYTE_AS_STRING;
43 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
46 dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
48 dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
51 dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
53 dbus_message_iter_append_fixed_array(&array, type, val, len);
54 dbus_message_iter_close_container(&value, &array);
56 dbus_message_iter_close_container(&entry, &value);
58 dbus_message_iter_close_container(dict, &entry);
61 void connman_dbus_dict_append_variant(DBusMessageIter *dict,
62 const char *key, int type, void *val)
64 DBusMessageIter entry, value;
65 const char *signature;
67 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
70 dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
73 case DBUS_TYPE_BOOLEAN:
74 signature = DBUS_TYPE_BOOLEAN_AS_STRING;
76 case DBUS_TYPE_STRING:
77 signature = DBUS_TYPE_STRING_AS_STRING;
79 case DBUS_TYPE_UINT16:
80 signature = DBUS_TYPE_UINT16_AS_STRING;
82 case DBUS_TYPE_UINT32:
83 signature = DBUS_TYPE_UINT32_AS_STRING;
85 case DBUS_TYPE_OBJECT_PATH:
86 signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
89 signature = DBUS_TYPE_VARIANT_AS_STRING;
93 dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
95 dbus_message_iter_append_basic(&value, type, val);
96 dbus_message_iter_close_container(&entry, &value);
98 dbus_message_iter_close_container(dict, &entry);