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
31 void __connman_profile_list(DBusMessageIter *iter)
33 const char *path = "/profile/default";
37 dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
40 static void append_string(DBusMessageIter *dict, const char *key, void *val)
42 DBusMessageIter entry, value;
44 dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
47 dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
49 dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
50 DBUS_TYPE_STRING_AS_STRING, &value);
51 dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, val);
52 dbus_message_iter_close_container(&entry, &value);
54 dbus_message_iter_close_container(dict, &entry);
57 static DBusMessage *get_properties(DBusConnection *conn,
58 DBusMessage *msg, void *data)
60 const char *name = "Default";
62 DBusMessageIter array, dict;
66 reply = dbus_message_new_method_return(msg);
70 dbus_message_iter_init_append(reply, &array);
72 dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
73 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
74 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
75 DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
77 append_string(&dict, "Name", &name);
79 dbus_message_iter_close_container(&array, &dict);
84 static GDBusMethodTable profile_methods[] = {
85 { "GetProperties", "", "a{sv}", get_properties },
89 static DBusConnection *connection = NULL;
91 int __connman_profile_init(DBusConnection *conn)
95 connection = dbus_connection_ref(conn);
96 if (connection == NULL)
99 g_dbus_register_interface(connection, "/profile/default",
100 CONNMAN_PROFILE_INTERFACE,
102 NULL, NULL, NULL, NULL);
107 void __connman_profile_cleanup(void)
109 DBG("conn %p", connection);
111 g_dbus_unregister_interface(connection, "/profile/default",
112 CONNMAN_PROFILE_INTERFACE);
114 if (connection == NULL)
117 dbus_connection_unref(connection);