2 * dbus_network_object.c
4 * Copyright(C) 2007,2008 Ixonos Plc
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
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., 59 Temple Place, Boston, MA 02111.
31 #include "dbus_network_object.h"
32 #include "dbus_network_glue.h"
33 #include "dbus_marshal.h"
34 #include "dbus_objects.h"
35 #include "network_interface.h"
38 #include <dbus/dbus-glib-bindings.h>
39 #include <dbus/dbus-glib.h>
40 #include <dbus/dbus-glib-lowlevel.h>
43 #define GSMD_NETWORK_LISTPROVIDER_TYPE (dbus_g_type_get_struct ("GValueArray", \
50 G_DEFINE_TYPE(DBusNetworkObject
, dbus_network_object
, G_TYPE_OBJECT
)
55 dbus_network_object_class_init(DBusNetworkObjectClass
*klass
)
57 /* Make the local system aware of our kind */
59 /** Register our signals so that they can be emitted */
60 klass
->status
= g_signal_new("status",
61 G_OBJECT_CLASS_TYPE (klass
),
62 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
63 0, NULL
, NULL
, g_cclosure_marshal_VOID__POINTER
,
64 G_TYPE_NONE
, 1, dbus_g_type_get_map ("GHashTable",
65 G_TYPE_STRING
, G_TYPE_VALUE
));
68 klass
->subscriber_numbers
= g_signal_new ("subscriber_numbers",
69 G_OBJECT_CLASS_TYPE (klass
),
70 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
71 0, NULL
, NULL
, g_cclosure_marshal_VOID__STRING
,
72 G_TYPE_NONE
, 1, G_TYPE_STRING
);
76 static void dbus_network_object_init(DBusNetworkObject
*gsm
)
78 dbus_g_object_type_install_info (DBUS_NETWORK_TYPE_OBJECT
,
79 &dbus_glib_smartphone_network_object_info
);
83 void dbus_network_object_finalize(GObject
*obj
)
85 //G_OBJECT_CLASS (parent_class)->finalize (obj);
86 //DBusNetworkObject *gsm = (DBusNetworkObject *) obj;
91 void gsmd_dbus_network_uninitialize(DBusNetworkObject
*obj
)
98 /*********************Signal functions***********************/
101 void smartphone_network_status (NetworkIPCInterface
*network_ipc
,
104 DBusNetworkObject
*obj
= (DBusNetworkObject
*)network_ipc
->priv
;
106 DBUS_NETWORK_OBJECT_GET_CLASS(obj
)->status
,
110 void smartphone_network_subscriber_numbers (NetworkIPCInterface
*network_ipc
,
111 const gchar
** number
)
113 DBusNetworkObject
*obj
= (DBusNetworkObject
*)network_ipc
->priv
;
115 DBUS_NETWORK_OBJECT_GET_CLASS(obj
)->subscriber_numbers
,
122 /*****************************Methods******************************************/
124 gboolean
smartphone_network_get_country_code(DBusNetworkObject
*obj
,
125 DBusGMethodInvocation
*method_context
)
127 obj
->network
->get_country_code(obj
->network
, method_context
);
132 gboolean
smartphone_network_register(DBusNetworkObject
*obj
,
133 DBusGMethodInvocation
*method_context
)
135 obj
->network
->register_network(obj
->network
, method_context
);
139 gboolean
smartphone_network_unregister(DBusNetworkObject
*obj
,
140 DBusGMethodInvocation
*method_context
)
142 obj
->network
->unregister(obj
->network
, method_context
);
147 gboolean
smartphone_network_get_status(DBusNetworkObject
*obj
,
148 DBusGMethodInvocation
*method_context
)
150 obj
->network
->get_status(obj
->network
,
155 gboolean
smartphone_network_list_providers(DBusNetworkObject
*obj
,
156 DBusGMethodInvocation
*method_context
)
158 obj
->network
->list_providers(obj
->network
,
164 gboolean
smartphone_network_register_with_provider(DBusNetworkObject
*obj
,
166 DBusGMethodInvocation
*method_context
)
168 obj
->network
->register_with_provider(obj
->network
,
177 /*****************************Method replies***********************************/
178 void smartphone_network_get_country_code_reply(NetworkIPCInterface
*network_ipc
,
180 const char *dial_code
)
182 g_debug("%s", __func__
);
184 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
,
188 void smartphone_network_unregister_reply(NetworkIPCInterface
*network_ipc
,
191 g_debug("%s", __func__
);
193 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
);
196 void smartphone_network_get_home_country_code_reply(NetworkIPCInterface
*network_ipc
,
198 const char *dial_code
)
200 g_debug("%s", __func__
);
202 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
,
206 void smartphone_network_register_reply(NetworkIPCInterface
*network_ipc
, gpointer ipc_data
)
208 g_debug("%s", __func__
);
210 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
);
213 void smartphone_network_get_status_reply(NetworkIPCInterface
*network_ipc
,
219 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
,
226 void smartphone_network_list_providers_reply(NetworkIPCInterface
*network_ipc
,
230 g_debug("%s", __func__
);
231 GPtrArray
*result
= NULL
;
233 NetworkProvider
*provider
= NULL
;
235 result
= g_ptr_array_sized_new (providers
->len
);
237 for (i
= 0; i
< providers
->len
; i
++) {
238 provider
= g_array_index(providers
,NetworkProvider
*,i
);
239 GValue entry
= { 0, };
242 g_value_init (&entry
, GSMD_NETWORK_LISTPROVIDER_TYPE
);
243 g_value_take_boxed (&entry
,
244 dbus_g_type_specialized_construct (GSMD_NETWORK_LISTPROVIDER_TYPE
));
246 dbus_g_type_struct_set (&entry
,
250 3, provider
->nickname
,
253 g_ptr_array_add (result
, g_value_get_boxed (&entry
));
257 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
, result
);
258 g_ptr_array_free (result
, TRUE
);
262 void smartphone_network_register_with_provider_reply(NetworkIPCInterface
*network_ipc
,
265 g_debug("%s", __func__
);
267 dbus_g_method_return((DBusGMethodInvocation
*) ipc_data
);
272 /**************************Method error replies********************************/
273 void smartphone_network_get_country_code_error(NetworkIPCInterface
*network_ipc
,
277 g_debug("%s", __func__
);
279 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
282 void smartphone_network_get_home_country_code_error(NetworkIPCInterface
*network_ipc
,
286 g_debug("%s", __func__
);
288 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
291 void smartphone_network_register_error(NetworkIPCInterface
*network_ipc
,
295 g_debug("%s", __func__
);
297 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
300 void smartphone_network_unregister_error(NetworkIPCInterface
*network_ipc
,
304 g_debug("%s", __func__
);
306 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
309 void smartphone_network_get_status_error(NetworkIPCInterface
*network_ipc
,
313 g_debug("%s", __func__
);
315 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
318 void smartphone_network_list_providers_error(NetworkIPCInterface
*network_ipc
,
322 g_debug("%s", __func__
);
324 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
327 void smartphone_network_register_with_provider_error(NetworkIPCInterface
*network_ipc
,
331 g_debug("%s", __func__
);
333 dbus_g_method_return_error((DBusGMethodInvocation
*) ipc_data
,error
);
340 DBusNetworkObject
*gsmd_dbus_network_initialize ( NetworkIPCInterface
*network_ipc
,
341 NetworkInterface
*network
)
343 DBusNetworkObject
*obj
= g_object_new (DBUS_NETWORK_TYPE_OBJECT
, NULL
);
344 network_ipc
->priv
= obj
;
345 obj
->network
= network
;
348 network_ipc
->status
= &smartphone_network_status
;
349 network_ipc
->subscriber_numbers
= &smartphone_network_subscriber_numbers
;
352 network_ipc
->register_network_reply
= &smartphone_network_register_reply
;
353 network_ipc
->unregister_reply
= &smartphone_network_unregister_reply
;
354 network_ipc
->get_status_reply
= &smartphone_network_get_status_reply
;
355 network_ipc
->list_providers_reply
= &smartphone_network_list_providers_reply
;
356 network_ipc
->register_with_provider_reply
= &smartphone_network_register_with_provider_reply
;
357 network_ipc
->get_country_code_reply
= &smartphone_network_get_country_code_reply
;
360 network_ipc
->register_network_error
= &smartphone_network_register_error
;
361 network_ipc
->unregister_error
= &smartphone_network_unregister_error
;
362 network_ipc
->get_status_error
= &smartphone_network_get_status_error
;
363 network_ipc
->list_providers_error
= &smartphone_network_list_providers_error
;
364 network_ipc
->register_with_provider_error
= &smartphone_network_register_with_provider_error
;
365 network_ipc
->get_country_code_error
= &smartphone_network_get_country_code_error
;