Add skeleton for profile/service integration
[connman] / src / profile.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  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 version 2 as
9  *  published by the Free Software Foundation.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <glib.h>
27 #include <gdbus.h>
28
29 #include "connman.h"
30
31 int __connman_profile_add_device(struct connman_device *device)
32 {
33         DBG("device %p", device);
34
35         return 0;
36 }
37
38 int __connman_profile_remove_device(struct connman_device *device)
39 {
40         DBG("device %p", device);
41
42         return 0;
43 }
44
45 int __connman_profile_add_network(struct connman_network *network)
46 {
47         DBG("network %p", network);
48
49         return 0;
50 }
51
52 int __connman_profile_remove_network(struct connman_network *network)
53 {
54         DBG("network %p", network);
55
56         return 0;
57 }
58
59 void __connman_profile_list(DBusMessageIter *iter)
60 {
61         const char *path = "/profile/default";
62
63         DBG("");
64
65         dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
66 }
67
68 static DBusMessage *get_properties(DBusConnection *conn,
69                                         DBusMessage *msg, void *data)
70 {
71         const char *name = "Default";
72         DBusMessage *reply;
73         DBusMessageIter array, dict;
74
75         DBG("conn %p", conn);
76
77         reply = dbus_message_new_method_return(msg);
78         if (reply == NULL)
79                 return NULL;
80
81         dbus_message_iter_init_append(reply, &array);
82
83         dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
84                         DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
85                         DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
86                         DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
87
88         connman_dbus_dict_append_variant(&dict, "Name",
89                                                 DBUS_TYPE_STRING, &name);
90
91         dbus_message_iter_close_container(&array, &dict);
92
93         return reply;
94 }
95
96 static GDBusMethodTable profile_methods[] = {
97         { "GetProperties", "", "a{sv}", get_properties },
98         { },
99 };
100
101 static DBusConnection *connection = NULL;
102
103 int __connman_profile_init(DBusConnection *conn)
104 {
105         DBG("conn %p", conn);
106
107         connection = dbus_connection_ref(conn);
108         if (connection == NULL)
109                 return -1;
110
111         g_dbus_register_interface(connection, "/profile/default",
112                                                 CONNMAN_PROFILE_INTERFACE,
113                                                 profile_methods,
114                                                 NULL, NULL, NULL, NULL);
115
116         return 0;
117 }
118
119 void __connman_profile_cleanup(void)
120 {
121         DBG("conn %p", connection);
122
123         g_dbus_unregister_interface(connection, "/profile/default",
124                                                 CONNMAN_PROFILE_INTERFACE);
125
126         if (connection == NULL)
127                 return;
128
129         dbus_connection_unref(connection);
130 }