client: Use D-Bus helpers for Technology Scan method call
[platform/upstream/connman.git] / client / dbus.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2012  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <dbus/dbus.h>
28
29 #include "dbus.h"
30
31 void dbus_property_append_basic(DBusMessageIter *iter,
32                                         const char *key, int type, void *val)
33 {
34         DBusMessageIter value;
35         const char *signature;
36
37         dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key);
38
39         switch (type) {
40         case DBUS_TYPE_BOOLEAN:
41                 signature = DBUS_TYPE_BOOLEAN_AS_STRING;
42                 break;
43         case DBUS_TYPE_STRING:
44                 signature = DBUS_TYPE_STRING_AS_STRING;
45                 break;
46         case DBUS_TYPE_BYTE:
47                 signature = DBUS_TYPE_BYTE_AS_STRING;
48                 break;
49         case DBUS_TYPE_UINT16:
50                 signature = DBUS_TYPE_UINT16_AS_STRING;
51                 break;
52         case DBUS_TYPE_INT16:
53                 signature = DBUS_TYPE_INT16_AS_STRING;
54                 break;
55         case DBUS_TYPE_UINT32:
56                 signature = DBUS_TYPE_UINT32_AS_STRING;
57                 break;
58         case DBUS_TYPE_INT32:
59                 signature = DBUS_TYPE_INT32_AS_STRING;
60                 break;
61         case DBUS_TYPE_UINT64:
62                 signature = DBUS_TYPE_UINT64_AS_STRING;
63                 break;
64         case DBUS_TYPE_INT64:
65                 signature = DBUS_TYPE_INT64_AS_STRING;
66                 break;
67         case DBUS_TYPE_OBJECT_PATH:
68                 signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
69                 break;
70         default:
71                 signature = DBUS_TYPE_VARIANT_AS_STRING;
72                 break;
73         }
74
75         dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
76                                                         signature, &value);
77         dbus_message_iter_append_basic(&value, type, val);
78         dbus_message_iter_close_container(iter, &value);
79 }
80