2 * tel-plugin-packetservice
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: DongHoo Park <donghoo.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include "ps-service.h"
27 #include <core_object.h>
30 #define PROP_DEFAULT FALSE
31 #define PROP_DEFAULT_STR NULL
32 #define BOOL2STRING(a) ((a==TRUE) ? ("TRUE"):("FALSE"))
34 #define TIMEOUT_DEFAULT 5
35 #define TIMEOUT_MAX 1280
37 guint connection_timeout;
49 PROP_SERVICE_CO_NETWORK,
54 SIG_SERVICE_CONTEXT_ADDED,
55 SIG_SERVICE_CONTEXT_REMOVED,
56 SIG_SERVICE_PROPERTY_CHANGED,
60 static guint32 signals[SIG_SERVICE_LAST] = {0,};
62 struct PsServiceClass {
66 void (*context_added)(PsService *service, gchar *context_path);
67 void (*context_removed)(PsService *service, gchar *context_path);
68 void (*property_changed)(PsService *service, GHashTable *service_property);
76 DBusGConnection *conn;
78 CoreObject *co_network;
83 enum telephony_network_access_technology act;
88 G_DEFINE_TYPE(PsService, ps_service, G_TYPE_OBJECT);
90 /*Function Declaration*/
91 static void __ps_service_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
92 static void __ps_service_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
94 gboolean ps_iface_service_get_properties(PsService *service, DBusGMethodInvocation *context);
95 gboolean ps_iface_service_get_contexts(PsService *service, DBusGMethodInvocation *context);
97 static void __ps_service_emit_property_changed_signal(PsService *service);
98 static void __ps_service_emit_context_added_signal(PsService *service, gpointer context);
99 static void __ps_service_emit_context_removed_signal(PsService *service, gpointer context);
101 static void __remove_context(gpointer data);
102 static char *__ps_service_act2string(enum telephony_network_access_technology act);
103 static gboolean __ps_service_check_connection_option(gpointer service);
104 static gboolean __ps_service_connetion_timeout_handler(gpointer user_data);
106 #include "ps-iface-service-glue.h"
108 static void ps_service_init(PsService *service)
110 dbg("service initialize");
112 service->path = PROP_DEFAULT_STR;
114 service->conn = NULL;
115 service->p_modem = NULL;
116 service->co_network = NULL;
117 service->co_ps = NULL;
119 service->ps_attached = PROP_DEFAULT;
120 service->roaming = PROP_DEFAULT;
121 service->act = NETWORK_ACT_UNKNOWN;
123 service->contexts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __remove_context);
127 static void ps_service_class_init(PsServiceClass *klass)
129 GObjectClass *object_class = G_OBJECT_CLASS(klass);
134 object_class->get_property = __ps_service_get_property;
135 object_class->set_property = __ps_service_set_property;
138 dbus_g_object_type_install_info(PS_TYPE_SERVICE, &dbus_glib_ps_iface_service_object_info);
141 g_object_class_install_property(
144 g_param_spec_string("path", "PATH", "Technology Path", NULL,
145 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
147 g_object_class_install_property(
149 PROP_SERVICE_P_MODEM,
150 g_param_spec_pointer("p_modem", "MODEM", "Parent Modem Object",
151 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
153 g_object_class_install_property(
156 g_param_spec_pointer("plg", "PLUGIN", "Plug in Object",
157 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
159 g_object_class_install_property(
161 PROP_SERVICE_CO_NETWORK,
162 g_param_spec_pointer("co_network", "COREOBJECT NETWORK", "CoreObject of Network",
163 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
165 g_object_class_install_property(
168 g_param_spec_pointer("co_ps", "COREOBJECTPS", "CoreObject of PS",
169 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
171 g_object_class_install_property(
174 g_param_spec_boxed("conn", "CONNECTION", "DBus connection", DBUS_TYPE_G_CONNECTION,
175 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
178 signals[SIG_SERVICE_CONTEXT_ADDED] = g_signal_new("context-added", G_OBJECT_CLASS_TYPE(klass),
179 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(PsServiceClass, context_added), NULL, NULL,
180 g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
182 signals[SIG_SERVICE_CONTEXT_REMOVED] = g_signal_new("context-removed",
183 G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,
184 G_STRUCT_OFFSET(PsServiceClass, context_removed), NULL, NULL,
185 g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, DBUS_TYPE_G_OBJECT_PATH);
187 signals[SIG_SERVICE_PROPERTY_CHANGED] = g_signal_new("property-changed",
188 G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST,
189 G_STRUCT_OFFSET(PsServiceClass, property_changed), NULL, NULL,
190 g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
195 static void __ps_service_get_property(GObject *object, guint prop_id, GValue *value,
201 static void __ps_service_set_property(GObject *object, guint prop_id, const GValue *value,
204 PsService *service = PS_SERVICE(object);
207 case PROP_SERVICE_PATH: {
208 if (service->path) g_free(service->path);
209 service->path = g_value_dup_string(value);
210 msg("service(%p) set path(%s)", service, service->path);
213 case PROP_SERVICE_P_MODEM: {
214 service->p_modem = g_value_get_pointer(value);
215 msg("service(%p) set modem(%p)", service, service->p_modem);
218 case PROP_SERVICE_PLUGIN: {
219 service->plg = g_value_get_pointer(value);
220 msg("service(%p) set plg(%p)", service, service->plg);
223 case PROP_SERVICE_CO_NETWORK: {
224 service->co_network = g_value_get_pointer(value);
225 msg("service(%p) set co_network(%p)", service, service->co_network);
228 case PROP_SERVICE_CO_PS: {
229 service->co_ps = g_value_get_pointer(value);
230 msg("service(%p) set co_ps(%p)", service, service->co_ps);
233 case PROP_SERVICE_CONN: {
234 service->conn = g_value_get_boxed(value);
235 msg("service(%p) set conn(%p)", service, service->conn);
239 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
246 gboolean ps_iface_service_get_properties(PsService *service, DBusGMethodInvocation *context)
248 GError *error = NULL;
250 GHashTable *properties = NULL;
252 dbg("get service properties");
254 properties = g_hash_table_new(g_str_hash, g_str_equal);
255 rv = _ps_service_get_properties(service, properties);
257 g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties service(%p)",
259 dbus_g_method_return_error(context, error);
260 g_hash_table_destroy(properties);
264 dbus_g_method_return(context, properties);
265 g_hash_table_destroy(properties);
269 gboolean ps_iface_service_get_contexts(PsService *service, DBusGMethodInvocation *context)
271 GError *error = NULL;
274 GHashTable *contexts;
276 dbg("service get contexts interface");
278 if (service->contexts == NULL) {
279 g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "service(%p) does not have contexts",
281 dbus_g_method_return_error(context, error);
285 contexts = g_hash_table_new_full(g_direct_hash, g_str_equal, g_free,
286 (GDestroyNotify) g_hash_table_destroy);
288 g_hash_table_iter_init(&iter, service->contexts);
289 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
292 GHashTable *properties = NULL;
294 properties = g_hash_table_new(g_str_hash, g_str_equal);
295 rv = _ps_context_get_properties(value, properties);
297 g_set_error(&error, PS_ERROR, PS_ERR_INTERNAL, "fail to get properties context(%p)",
299 dbus_g_method_return_error(context, error);
300 g_hash_table_destroy(properties);
301 g_hash_table_destroy(contexts);
305 path = _ps_context_ref_path(value);
306 g_hash_table_insert(contexts, g_strdup(path), properties);
307 dbg("service (%p) inserted into hash", value);
310 dbus_g_method_return(context, contexts);
311 g_hash_table_destroy(contexts);
316 static void __ps_service_emit_property_changed_signal(PsService *service)
318 GHashTable *properties = NULL;
320 properties = g_hash_table_new(g_str_hash, g_str_equal);
321 _ps_service_get_properties(service, properties);
322 g_signal_emit(service, signals[SIG_SERVICE_PROPERTY_CHANGED], 0, properties);
323 dbg("service (%p) emit property changed signal", service);
324 g_hash_table_destroy(properties);
329 static void __ps_service_emit_context_added_signal(PsService *service, gpointer context)
331 GHashTable *properties = NULL;
333 properties = g_hash_table_new(g_str_hash, g_str_equal);
334 _ps_context_get_properties(context, properties);
335 g_signal_emit(service, signals[SIG_SERVICE_CONTEXT_ADDED], 0, properties);
336 dbg("service (%p) emit the context(%p) added signal", service, context);
337 g_hash_table_destroy(properties);
341 static void __ps_service_emit_context_removed_signal(PsService *service, gpointer context)
343 g_signal_emit(service, signals[SIG_SERVICE_CONTEXT_REMOVED], 0, _ps_context_ref_path(context));
344 dbg("service (%p) emit the context(%p) removed signal", service, context);
348 static void __remove_context(gpointer data)
353 static char *__ps_service_act2string(enum telephony_network_access_technology act)
356 case NETWORK_ACT_GSM:
357 case NETWORK_ACT_GPRS:
358 case NETWORK_ACT_EGPRS:
359 case NETWORK_ACT_UMTS:
360 case NETWORK_ACT_GSM_UTRAN:
362 case NETWORK_ACT_IS95A:
363 case NETWORK_ACT_IS95B:
364 case NETWORK_ACT_CDMA_1X:
365 case NETWORK_ACT_EVDO_REV0:
366 case NETWORK_ACT_CDMA_1X_EVDO_REV0:
367 case NETWORK_ACT_EVDO_REVA:
368 case NETWORK_ACT_CDMA_1X_EVDO_REVA:
369 case NETWORK_ACT_EVDV:
371 case NETWORK_ACT_LTE:
373 case NETWORK_ACT_UNKNOWN:
381 static gboolean __ps_service_check_connection_option(gpointer object)
383 gboolean b_connect = TRUE;
384 gboolean power, sim, data, flight;
385 PsService *service = object;
387 if(service->roaming){
388 b_connect &=_ps_modem_get_data_roaming_allowed(service->p_modem);
391 power = _ps_modem_get_power(service->p_modem);
392 sim = _ps_modem_get_sim_init(service->p_modem);
393 data = _ps_modem_get_data_allowed(service->p_modem);
394 flight = _ps_modem_get_flght_mode(service->p_modem);
398 b_connect &= !flight;
399 dbg("power(%d), sim init(%d), data allowed(%d), filght mode(%d)", power, sim, data, flight);
404 static gboolean __ps_service_connetion_timeout_handler(gpointer context)
407 PsService *service = NULL;
409 service = _ps_context_ref_service(context);
410 rv = _ps_service_activate_context(service, context);
411 dbg("return rv(%d)", rv);
416 gpointer _ps_service_create_service(DBusGConnection *conn, TcorePlugin *p, gpointer p_modem,
417 CoreObject *co_network, CoreObject *co_ps, gchar* path)
422 GError *error = NULL;
424 dbg("service object create");
425 g_return_val_if_fail(conn != NULL, NULL);
426 g_return_val_if_fail(p_modem != NULL, NULL);
428 proxy = dbus_g_proxy_new_for_name(conn, "org.freedesktop.DBus", "/org/freedesktop/DBus",
429 "org.freedesktop.DBus");
431 if (!dbus_g_proxy_call(proxy, "RequestName", &error, G_TYPE_STRING, PS_DBUS_SERVICE,
432 G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &rv, G_TYPE_INVALID)) {
433 err("Failed to acquire context(%s) error(%s)", PS_DBUS_SERVICE, error->message);
437 object = g_object_new(PS_TYPE_SERVICE, "conn", conn, "plg", p, "p_modem", p_modem, "co_network",
438 co_network, "co_ps", co_ps, "path", path, NULL);
440 _ps_hook_co_network_event(object);
441 _ps_get_co_network_values(object);
442 _ps_hook_co_ps_event(object);
444 dbus_g_connection_register_g_object(conn, path, object);
445 msg("service(%p) register dbus path(%s)", object, path);
450 gboolean _ps_service_ref_context(gpointer object, gpointer context)
453 gchar *s_path = NULL;
454 PsService *service = object;
456 dbg("service refer to context");
457 g_return_val_if_fail(service != NULL, FALSE);
459 s_path = _ps_context_ref_path(context);
460 tmp = g_hash_table_lookup(service->contexts, s_path);
462 dbg("context(%p) already existed", tmp);
466 _ps_context_set_service(context, service);
467 tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(context));
468 g_hash_table_insert(service->contexts, g_strdup(s_path), context);
470 dbg("context(%p) insert to hash", context);
471 __ps_service_emit_context_added_signal(service, context);
473 //_ps_service_connect_default_context(service);
477 gboolean _ps_service_ref_contexts(gpointer object, GHashTable *contexts, gchar *operator)
481 PsService *service = object;
485 dbg("service refer to contexts");
486 g_return_val_if_fail(service != NULL, FALSE);
488 g_hash_table_iter_init(&iter, contexts);
489 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
490 gchar *s_path = NULL;
492 gboolean f_awo = FALSE;
494 s_path = _ps_context_ref_path(value);
495 tmp = g_hash_table_lookup(service->contexts, s_path);
497 dbg("context(%p) already existed", tmp);
501 _ps_context_set_service(value, service);
502 tcore_ps_add_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(value));
503 g_hash_table_insert(service->contexts, g_strdup(s_path), value);
505 dbg("context(%p) insert to hash", value);
506 __ps_service_emit_context_added_signal(service, value);
508 f_awo = _ps_context_get_alwayson_enable(value);
510 rv = _ps_service_define_context(service, value);
511 dbg("return rv(%d)", rv);
515 _ps_update_cellular_state_key(service);
516 //_ps_service_connect_default_context(service);
520 gboolean _ps_service_unref_context(gpointer object, gpointer context)
522 PsService *service = object;
524 dbg("service unref contexts");
525 g_return_val_if_fail(service != NULL, FALSE);
526 g_return_val_if_fail(context != NULL, FALSE);
528 dbg("remove context(%p) from service(%p)", context, service);
529 tcore_ps_remove_context(service->co_ps, (CoreObject *) _ps_context_ref_co_context(context));
530 g_hash_table_remove(service->contexts, _ps_context_ref_path(context));
531 __ps_service_emit_context_removed_signal(service, context);
536 gboolean _ps_service_get_properties(gpointer object, GHashTable *properties)
538 PsService *service = object;
540 dbg("get service properties");
541 g_return_val_if_fail(service != NULL, FALSE);
542 g_return_val_if_fail(properties != NULL, FALSE);
544 g_hash_table_insert(properties, "path", g_strdup(service->path));
545 g_hash_table_insert(properties, "ps_attached", BOOL2STRING(service->ps_attached));
546 g_hash_table_insert(properties, "roaming", BOOL2STRING(service->roaming));
547 g_hash_table_insert(properties, "act", __ps_service_act2string(service->act));
552 gchar* _ps_service_ref_path(gpointer object)
554 PsService *service = object;
555 g_return_val_if_fail(service != NULL, NULL);
557 return service->path;
560 gpointer _ps_service_ref_plugin(gpointer object)
562 PsService *service = object;
563 g_return_val_if_fail(service != NULL, NULL);
568 gpointer _ps_service_ref_co_network(gpointer object)
570 PsService *service = object;
571 g_return_val_if_fail(service != NULL, NULL);
573 return service->co_network;
576 gpointer _ps_service_ref_co_ps(gpointer object)
578 PsService *service = object;
579 g_return_val_if_fail(service != NULL, NULL);
581 return service->co_ps;
584 gboolean _ps_service_set_context_info(gpointer object, struct tnoti_ps_pdp_ipconfiguration *devinfo)
586 GSList* contexts = NULL;
587 PsService *service = object;
589 dbg("set context info");
590 g_return_val_if_fail(service != NULL, FALSE);
592 contexts = tcore_ps_ref_context_by_id(service->co_ps, devinfo->context_id);
594 if (NULL == contexts) {
595 dbg("fail to ref context by cid.");
599 for (; contexts != NULL; contexts = g_slist_next(contexts)) {
600 CoreObject *co_context = NULL;
602 co_context = contexts->data;
603 if (NULL == co_context)
606 tcore_context_set_devinfo(co_context, devinfo);
612 int _ps_service_define_context(gpointer object, gpointer context)
614 PsService *service = object;
615 CoreObject *co_context = NULL;
616 gboolean b_connect = TRUE;
618 dbg("define context(%p)", context);
619 g_return_val_if_fail(service != NULL, FALSE);
621 co_context = (CoreObject *)_ps_context_ref_co_context(context);
623 b_connect = __ps_service_check_connection_option(service);
625 return TCORE_RETURN_EPERM;
627 return tcore_ps_define_context(service->co_ps, co_context, NULL);
630 int _ps_service_activate_context(gpointer object, gpointer context)
632 PsService *service = object;
633 CoreObject *co_context = NULL;
634 gboolean b_connect = TRUE;
636 int ret = TCORE_RETURN_FAILURE;
638 dbg("activate context(%p)", context);
639 g_return_val_if_fail(service != NULL, FALSE);
641 co_context = (CoreObject *)_ps_context_ref_co_context(context);
643 b_connect = __ps_service_check_connection_option(service);
644 b_connect &= service->ps_attached;
646 return TCORE_RETURN_EPERM;
648 ps_defined = _ps_context_get_ps_defined(context);
650 dbg("pdp profile is not defined yet, define first. ");
651 ret = tcore_ps_define_context(service->co_ps, co_context, NULL);
654 dbg("pdp profile is defined, activate context. ");
655 ret = tcore_ps_activate_context(service->co_ps, co_context, NULL);
661 gboolean _ps_service_deactivate_context(gpointer object, gpointer context)
663 PsService *service = object;
664 CoreObject *co_context = NULL;
666 dbg("deactivate context(%p)", context);
667 g_return_val_if_fail(service != NULL, FALSE);
669 co_context = (CoreObject *)_ps_context_ref_co_context(context);
671 return tcore_ps_deactivate_context(service->co_ps, co_context, NULL);
674 void _ps_service_connection_timer(gpointer object, gpointer context)
676 gboolean f_awo = FALSE;
678 f_awo = _ps_context_get_alwayson_enable(context);
682 timer_src = g_timeout_add_seconds(connection_timeout, __ps_service_connetion_timeout_handler, context);
684 dbg("cellular service timer started timer src(%d), timeout(%d)", timer_src, connection_timeout);
685 connection_timeout = connection_timeout*2;
686 if(connection_timeout > TIMEOUT_MAX)
687 connection_timeout = TIMEOUT_MAX;
692 void _ps_service_reset_connection_timer(gpointer context)
694 gboolean f_awo = FALSE;
696 f_awo = _ps_context_get_alwayson_enable(context);
700 connection_timeout = TIMEOUT_DEFAULT;
702 if (timer_src != 0) {
703 dbg("remove connection retry timer (%d)", timer_src);
704 g_source_remove(timer_src);
711 void _ps_service_remove_contexts(gpointer object)
715 PsService *service = object;
717 dbg("service remove all contexts");
718 g_return_if_fail(service != NULL);
720 g_hash_table_iter_init(&iter, service->contexts);
721 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
722 gpointer co_context = NULL;
724 dbg("key(%s), value(%p) context", key, value);
725 co_context = _ps_context_ref_co_context(value);
727 _ps_service_reset_connection_timer(value);
728 _ps_context_set_alwayson_enable(value, FALSE);
729 _ps_service_deactivate_context(service, value);
730 _ps_context_set_connected(value, FALSE);
731 tcore_ps_remove_context(service->co_ps, co_context);
732 tcore_context_free(co_context);
734 __ps_service_emit_context_removed_signal(service, value);
735 _ps_context_remove_context(value);
738 g_hash_table_remove_all(service->contexts);
742 void _ps_service_disconnect_contexts(gpointer object)
746 PsService *service = object;
748 dbg("service disconnect all contexts");
749 g_return_if_fail(service != NULL);
751 g_hash_table_iter_init(&iter, service->contexts);
752 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
753 _ps_service_reset_connection_timer(value);
754 _ps_service_deactivate_context(service, value);
760 void _ps_service_connect_default_context(gpointer object)
764 PsService *service = object;
766 dbg("service connect default context");
767 g_return_if_fail(service != NULL);
769 g_hash_table_iter_init(&iter, service->contexts);
770 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
771 gboolean f_awo = FALSE;
772 f_awo = _ps_context_get_alwayson_enable(value);
776 _ps_service_reset_connection_timer(value);
777 rv = _ps_service_activate_context(service, value);
778 dbg("return rv(%d)", rv);
786 gpointer _ps_service_return_default_context(gpointer object)
790 PsService *service = object;
792 g_return_val_if_fail(service != NULL, NULL);
794 g_hash_table_iter_init(&iter, service->contexts);
795 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
796 gboolean b_default = FALSE;
797 b_default = _ps_context_get_default_internet(value);
807 gboolean _ps_service_processing_network_event(gpointer object, gboolean ps_attached, gboolean roaming)
809 PsService *service = object;
810 g_return_val_if_fail(service != NULL, FALSE);
812 _ps_update_cellular_state_key(service);
813 if(service->ps_attached == ps_attached && service->roaming == roaming)
816 _ps_service_set_ps_attached(service, ps_attached);
817 _ps_service_set_roaming(service, roaming);
819 if(service->ps_attached)
820 _ps_service_connect_default_context(service);
825 gboolean _ps_service_set_connected(gpointer object, int context_id, gboolean enabled)
829 PsService *service = NULL;
831 service = (PsService *) object;
832 g_hash_table_iter_init(&iter, service->contexts);
833 while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
834 CoreObject *context = NULL;
837 context = _ps_context_ref_co_context(value);
838 tmp_cid = tcore_context_get_id(context);
840 if (tmp_cid != context_id) continue;
843 tcore_ps_clear_context_id(service->co_ps, context);
845 _ps_context_set_connected(value, enabled);
851 void _ps_service_set_ps_defined(gpointer *object, gboolean value, int cid)
853 PsService *service = (PsService*)object;
857 g_return_if_fail(service != NULL);
859 g_hash_table_iter_init(&iter, service->contexts);
860 while (g_hash_table_iter_next(&iter, &key, &out) == TRUE) {
861 gboolean r_actvate = 0;
862 r_actvate = _ps_context_set_ps_defined(out, value, cid);
866 dbg("define is complete, activate context for cid(%d)", cid);
867 rv = _ps_service_activate_context(service, out);
876 gboolean _ps_service_set_ps_attached(gpointer object, gboolean value)
878 PsService *service = object;
879 g_return_val_if_fail(service != NULL, FALSE);
881 service->ps_attached = value;
882 dbg("service(%p) ps_attached(%d)", service, service->ps_attached);
887 gboolean _ps_service_get_roaming(gpointer object)
889 PsService *service = object;
890 g_return_val_if_fail(service != NULL, FALSE);
892 return service->roaming;
895 gboolean _ps_service_set_roaming(gpointer object, gboolean value)
897 PsService *service = object;
898 g_return_val_if_fail(service != NULL, FALSE);
900 service->roaming = value;
901 dbg("service(%p) roaming(%d)", service, service->roaming);
902 __ps_service_emit_property_changed_signal(service);
907 gboolean _ps_service_set_access_technology(gpointer object,
908 enum telephony_network_access_technology value)
910 PsService *service = object;
911 g_return_val_if_fail(service != NULL, FALSE);
913 service->act = value;
914 dbg("service(%p) Access Technology(%d)", service, service->act);
916 if(service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED){
917 _ps_update_cellular_state_key(service);
918 _ps_service_connect_default_context(service);
924 enum telephony_ps_state _ps_service_check_cellular_state(gpointer object)
926 gboolean state = FALSE;
927 PsService *service = object;
928 g_return_val_if_fail(service != NULL, TELEPHONY_PS_NO_SERVICE);
930 state = _ps_modem_get_power(service->p_modem);
932 return TELEPHONY_PS_NO_SERVICE;
935 state = _ps_modem_get_sim_init(service->p_modem);
937 return TELEPHONY_PS_NO_SERVICE;
940 if(!service->ps_attached){
941 return TELEPHONY_PS_NO_SERVICE;
944 state = _ps_modem_get_flght_mode(service->p_modem);
946 return TELEPHONY_PS_FLIGHT_MODE;
949 state = _ps_modem_get_data_roaming_allowed(service->p_modem);
950 if(service->roaming && !state){
951 return TELEPHONY_PS_ROAMING_OFF;
954 state = _ps_modem_get_data_allowed(service->p_modem);
956 return TELEPHONY_PS_3G_OFF;
959 return TELEPHONY_PS_ON;