4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@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.
34 #include <communicator.h>
37 #include <user_request.h>
38 #include <co_network.h>
42 #include "generated-code.h"
45 static int __convert_act_to_systemtype(enum telephony_network_access_technology act)
48 case NETWORK_ACT_UNKNOWN:
54 case NETWORK_ACT_GPRS:
57 case NETWORK_ACT_EGPRS:
60 case NETWORK_ACT_UMTS:
63 case NETWORK_ACT_GSM_UTRAN:
66 case NETWORK_ACT_IS95A:
69 case NETWORK_ACT_IS95B:
72 case NETWORK_ACT_CDMA_1X:
75 case NETWORK_ACT_EVDO_REV0:
78 case NETWORK_ACT_CDMA_1X_EVDO_REV0:
81 case NETWORK_ACT_EVDO_REVA:
84 case NETWORK_ACT_CDMA_1X_EVDO_REVA:
87 case NETWORK_ACT_EVDV:
100 static void __update_network_name (TelephonyNetwork *network, CoreObject *o, const char *cp_name)
102 char *spnname = NULL, *nwname = NULL;
103 enum telephony_network_service_type svc_type;
104 enum telephony_network_access_technology svc_act;
105 enum tcore_network_name_priority network_name_priority;
107 tcore_network_get_service_type (o, &svc_type);
108 if (svc_type != NETWORK_SERVICE_TYPE_3G) {
109 telephony_network_set_ps_type (network, TELEPHONY_HSDPA_OFF);
112 tcore_network_get_access_technology (o, &svc_act);
113 telephony_network_set_access_technology (network, __convert_act_to_systemtype(svc_act));
115 tcore_network_get_network_name_priority (o, &network_name_priority);
116 switch (network_name_priority) {
117 case TCORE_NETWORK_NAME_PRIORITY_SPN:
118 telephony_network_set_name_option (network, NETWORK_NAME_OPTION_SPN);
121 case TCORE_NETWORK_NAME_PRIORITY_NETWORK:
122 telephony_network_set_name_option (network, NETWORK_NAME_OPTION_OPERATOR);
125 case TCORE_NETWORK_NAME_PRIORITY_ANY:
126 telephony_network_set_name_option (network, NETWORK_NAME_OPTION_ANY);
130 telephony_network_set_name_option (network, NETWORK_NAME_OPTION_NONE);
136 spnname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SPN);
138 telephony_network_set_spn_name (network, spnname);
142 nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_FULL);
143 if (nwname && strlen(nwname) > 0) {
144 info("[DBUSINFO][%s] SPN:[%s] FULL:[%s] prio:[%d] act:[%d] svc_type:[%d]",
145 cp_name, spnname?spnname:"", nwname, network_name_priority, svc_act, svc_type);
146 telephony_network_set_network_name (network, nwname);
151 nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SHORT);
153 info("[DBUSINFO][%s] SPN:[%s] SHORT:[%s] prio:[%d] act:[%d] svc_type:[%d]",
154 cp_name, spnname?spnname:"", nwname, network_name_priority, svc_act, svc_type);
155 telephony_network_set_network_name (network, nwname);
159 info("[DBUSINFO][%s] NW name is not fixed yet. SPN:[%s] prio:[%d] act:[%d] svc_type:[%d]",
160 cp_name, spnname?spnname:"", network_name_priority, svc_act, svc_type);
166 static enum tcore_hook_return on_hook_ps_protocol_status(Server *s,
167 CoreObject *source, enum tcore_notification_command command,
168 unsigned int data_len, void *data, void *user_data)
170 const struct tnoti_ps_protocol_status *protocol_status = data;
172 TelephonyObjectSkeleton *object;
173 TelephonyNetwork *network = NULL;
174 struct custom_data *ctx = user_data;
178 enum telephony_ps_protocol_status ps_protocol_status = TELEPHONY_HSDPA_OFF;
180 cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
181 if (cp_name == NULL) {
182 err("CP name is NULL");
183 return TCORE_HOOK_RETURN_CONTINUE;
186 info("[DBUSINFO][%s] PS_PROTOCOL_STATUS (status:[%d])", cp_name, protocol_status->status);
188 path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name);
190 /* Look-up Hash table for Object */
191 object = g_hash_table_lookup(ctx->objects, path);
193 if (object == NULL) {
194 err("Object is NOT defined!!!");
195 return TCORE_HOOK_RETURN_CONTINUE;
198 network = telephony_object_peek_network(TELEPHONY_OBJECT(object));
199 if (network == NULL) {
200 err("Network object is NULL!!!");
201 return TCORE_HOOK_RETURN_CONTINUE;
204 if (telephony_network_get_service_type (network) < NETWORK_SERVICE_TYPE_2G) {
205 telephony_network_set_ps_type(network, TELEPHONY_HSDPA_OFF);
206 return TCORE_HOOK_RETURN_CONTINUE;
209 switch (protocol_status->status) {
210 case TELEPHONY_HSDPA_OFF:
211 ps_protocol_status = TELEPHONY_HSDPA_OFF;
214 case TELEPHONY_HSDPA_ON:
215 ps_protocol_status = TELEPHONY_HSDPA_ON;
218 case TELEPHONY_HSUPA_ON:
219 ps_protocol_status = TELEPHONY_HSUPA_ON;
222 case TELEPHONY_HSPA_ON:
223 ps_protocol_status = TELEPHONY_HSPA_ON;
226 case TELEPHONY_HSPAP_ON:
227 ps_protocol_status = TELEPHONY_HSPAP_ON;
230 err("Unhandled protocol status!");
234 /* Check and Set - To avoid double update */
235 if (telephony_network_get_ps_type(network) != (gint)ps_protocol_status)
236 telephony_network_set_ps_type(network, ps_protocol_status);
238 return TCORE_HOOK_RETURN_CONTINUE;
242 on_network_search (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
245 struct custom_data *ctx = user_data;
246 UserRequest *ur = NULL;
249 if (!check_access_control (invocation, AC_NETWORK, "x"))
252 ur = MAKE_UR(ctx, network, invocation);
254 tcore_user_request_set_command(ur, TREQ_NETWORK_SEARCH);
255 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
256 if (ret != TCORE_RETURN_SUCCESS) {
257 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
258 tcore_user_request_unref(ur);
265 on_network_search_cancel (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
268 struct custom_data *ctx = user_data;
269 UserRequest *ur = NULL;
272 if (!check_access_control (invocation, AC_NETWORK, "x"))
275 ur = MAKE_UR(ctx, network, invocation);
277 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH);
278 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
279 if (ret != TCORE_RETURN_SUCCESS) {
280 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
281 tcore_user_request_unref(ur);
288 on_network_get_selection_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
291 struct custom_data *ctx = user_data;
292 UserRequest *ur = NULL;
295 if (!check_access_control (invocation, AC_NETWORK, "r"))
298 ur = MAKE_UR(ctx, network, invocation);
300 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_PLMN_SELECTION_MODE);
301 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
302 if (ret != TCORE_RETURN_SUCCESS) {
303 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
304 tcore_user_request_unref(ur);
311 on_network_set_selection_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
312 gint mode, const gchar *plmn, gint act, gpointer user_data)
314 struct treq_network_set_plmn_selection_mode req;
315 struct custom_data *ctx = user_data;
316 UserRequest *ur = NULL;
319 if (!check_access_control (invocation, AC_NETWORK, "w"))
322 memset(&req, 0, sizeof(struct treq_network_set_plmn_selection_mode));
324 if (mode == 0) { /* Automatic */
325 req.mode = NETWORK_SELECT_MODE_AUTOMATIC;
327 else if (mode == 1) { /* Manual */
328 req.mode = NETWORK_SELECT_MODE_MANUAL;
329 snprintf(req.plmn, 7, "%s", plmn);
333 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
336 dbg("Mode: [%d] PLMN: [%s] AcT: [%d]", req.mode, req.plmn, req.act);
338 ur = MAKE_UR(ctx, network, invocation);
340 tcore_user_request_set_data(ur, sizeof(struct treq_network_set_plmn_selection_mode), &req);
341 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_PLMN_SELECTION_MODE);
342 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
343 if (ret != TCORE_RETURN_SUCCESS) {
344 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
345 tcore_user_request_unref(ur);
353 on_network_set_service_domain (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
354 gint domain, gpointer user_data)
356 struct treq_network_set_service_domain req;
357 struct custom_data *ctx = user_data;
358 UserRequest *ur = NULL;
361 if (!check_access_control (invocation, AC_NETWORK, "w"))
364 ur = MAKE_UR(ctx, network, invocation);
368 tcore_user_request_set_data(ur, sizeof(struct treq_network_set_service_domain), &req);
369 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_SERVICE_DOMAIN);
370 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
371 if (ret != TCORE_RETURN_SUCCESS) {
372 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
373 tcore_user_request_unref(ur);
380 on_network_get_service_domain (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
383 struct custom_data *ctx = user_data;
384 UserRequest *ur = NULL;
387 if (!check_access_control (invocation, AC_NETWORK, "r"))
390 ur = MAKE_UR(ctx, network, invocation);
392 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_SERVICE_DOMAIN);
393 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
394 if (ret != TCORE_RETURN_SUCCESS) {
395 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
396 tcore_user_request_unref(ur);
403 on_network_set_band (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
404 gint band, gint mode, gpointer user_data)
406 struct treq_network_set_band req;
407 struct custom_data *ctx = user_data;
408 UserRequest *ur = NULL;
411 if (!check_access_control (invocation, AC_NETWORK, "w"))
414 ur = MAKE_UR(ctx, network, invocation);
419 tcore_user_request_set_data(ur, sizeof(struct treq_network_set_band), &req);
420 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_BAND);
421 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
422 if (ret != TCORE_RETURN_SUCCESS) {
423 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
424 tcore_user_request_unref(ur);
431 on_network_get_band (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
434 struct custom_data *ctx = user_data;
435 UserRequest *ur = NULL;
438 if (!check_access_control (invocation, AC_NETWORK, "r"))
441 ur = MAKE_UR(ctx, network, invocation);
443 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_BAND);
444 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
445 if (ret != TCORE_RETURN_SUCCESS) {
446 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
447 tcore_user_request_unref(ur);
454 on_network_set_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
455 gint mode, gpointer user_data)
457 struct treq_network_set_mode req;
458 struct custom_data *ctx = user_data;
459 UserRequest *ur = NULL;
462 if (!check_access_control (invocation, AC_NETWORK, "w"))
465 ur = MAKE_UR(ctx, network, invocation);
469 tcore_user_request_set_data(ur, sizeof(struct treq_network_set_mode), &req);
470 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_MODE);
471 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
472 if (ret != TCORE_RETURN_SUCCESS) {
473 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
474 tcore_user_request_unref(ur);
481 on_network_get_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
484 struct custom_data *ctx = user_data;
485 UserRequest *ur = NULL;
488 if (!check_access_control (invocation, AC_NETWORK, "r"))
491 ur = MAKE_UR(ctx, network, invocation);
493 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_MODE);
494 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
495 if (ret != TCORE_RETURN_SUCCESS) {
496 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
497 tcore_user_request_unref(ur);
504 on_network_set_preferred_plmn (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
505 gint mode, gint ef_index, gint act, const gchar *plmn, gpointer user_data)
507 struct treq_network_set_preferred_plmn req;
508 struct custom_data *ctx = user_data;
509 UserRequest *ur = NULL;
512 if (!check_access_control (invocation, AC_NETWORK, "w"))
515 ur = MAKE_UR(ctx, network, invocation);
517 req.operation = mode;
518 req.ef_index = ef_index;
521 memcpy(req.plmn, plmn, 6);
523 if (strlen(plmn) <= 5) {
527 tcore_user_request_set_data(ur, sizeof(struct treq_network_set_preferred_plmn), &req);
528 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_PREFERRED_PLMN);
529 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
530 if (ret != TCORE_RETURN_SUCCESS) {
531 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
532 tcore_user_request_unref(ur);
539 on_network_get_preferred_plmn (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
542 struct custom_data *ctx = user_data;
543 UserRequest *ur = NULL;
546 if (!check_access_control (invocation, AC_NETWORK, "r"))
549 ur = MAKE_UR(ctx, network, invocation);
551 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_PREFERRED_PLMN);
552 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
553 if (ret != TCORE_RETURN_SUCCESS) {
554 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
555 tcore_user_request_unref(ur);
562 on_network_get_serving_network (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
565 struct custom_data *ctx = user_data;
566 UserRequest *ur = NULL;
569 if (!check_access_control (invocation, AC_NETWORK, "r"))
572 ur = MAKE_UR(ctx, network, invocation);
574 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_SERVING_NETWORK);
575 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
576 if (ret != TCORE_RETURN_SUCCESS) {
577 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
578 tcore_user_request_unref(ur);
585 on_network_get_neighboring_cell_info (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
588 struct custom_data *ctx = user_data;
589 UserRequest *ur = NULL;
592 if (!check_access_control (invocation, AC_NETWORK, "r"))
595 ur = MAKE_UR(ctx, network, invocation);
597 tcore_user_request_set_command(ur, TREQ_NETWORK_GET_NEIGHBORING_CELL_INFO);
598 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
599 if (ret != TCORE_RETURN_SUCCESS) {
600 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
601 tcore_user_request_unref(ur);
608 on_network_set_default_data_subscription (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
611 struct custom_data *ctx = user_data;
612 UserRequest *ur = NULL;
615 if (!check_access_control (invocation, AC_NETWORK, "w"))
618 ur = MAKE_UR(ctx, network, invocation);
620 tcore_user_request_set_command(ur, TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION);
621 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
622 if (ret != TCORE_RETURN_SUCCESS) {
623 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
624 tcore_user_request_unref(ur);
631 on_network_get_default_data_subscription (TelephonyNetwork *network, GDBusMethodInvocation *invocation,
634 struct custom_data *ctx = user_data;
635 UserRequest *ur = NULL;
638 if (!check_access_control (invocation, AC_NETWORK, "r"))
641 ur = MAKE_UR(ctx, network, invocation);
643 tcore_user_request_set_command( ur, TREQ_NETWORK_GET_DEFAULT_DATA_SUBSCRIPTION );
644 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
645 if (ret != TCORE_RETURN_SUCCESS) {
646 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
647 tcore_user_request_unref(ur);
653 static gboolean on_network_set_default_subs(TelephonyNetwork *network, GDBusMethodInvocation *invocation,
654 gint preferred_subscription, gpointer user_data)
656 struct custom_data *ctx = user_data;
660 if (!check_access_control (invocation, AC_NETWORK, "w"))
663 ur = MAKE_UR(ctx, network, invocation);
665 tcore_user_request_set_command( ur, TREQ_NETWORK_SET_DEFAULT_SUBSCRIPTION );
666 ret = tcore_communicator_dispatch_request( ctx->comm, ur );
667 if ( ret != TCORE_RETURN_SUCCESS ) {
668 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
669 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
670 tcore_user_request_unref(ur);
676 static gboolean on_network_get_default_subs(TelephonyNetwork *network, GDBusMethodInvocation *invocation,
679 struct custom_data *ctx = user_data;
683 if (!check_access_control (invocation, AC_NETWORK, "r"))
686 ur = MAKE_UR(ctx, network, invocation);
688 tcore_user_request_set_command( ur, TREQ_NETWORK_GET_DEFAULT_SUBSCRIPTION );
689 ret = tcore_communicator_dispatch_request( ctx->comm, ur );
690 if ( ret != TCORE_RETURN_SUCCESS ) {
691 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
692 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
693 tcore_user_request_unref(ur);
699 gboolean dbus_plugin_setup_network_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx)
701 TelephonyNetwork *network;
703 network = telephony_network_skeleton_new();
704 telephony_object_skeleton_set_network(object, network);
705 g_object_unref(network);
707 g_signal_connect (network,
709 G_CALLBACK (on_network_search),
712 g_signal_connect (network,
713 "handle-search-cancel",
714 G_CALLBACK (on_network_search_cancel),
717 g_signal_connect (network,
718 "handle-set-selection-mode",
719 G_CALLBACK (on_network_set_selection_mode),
722 g_signal_connect (network,
723 "handle-get-selection-mode",
724 G_CALLBACK (on_network_get_selection_mode),
727 g_signal_connect (network,
728 "handle-set-service-domain",
729 G_CALLBACK (on_network_set_service_domain),
732 g_signal_connect (network,
733 "handle-get-service-domain",
734 G_CALLBACK (on_network_get_service_domain),
737 g_signal_connect (network,
739 G_CALLBACK (on_network_set_band),
742 g_signal_connect (network,
744 G_CALLBACK (on_network_get_band),
747 g_signal_connect (network,
749 G_CALLBACK (on_network_set_mode),
752 g_signal_connect (network,
754 G_CALLBACK (on_network_get_mode),
757 g_signal_connect (network,
758 "handle-set-preferred-plmn",
759 G_CALLBACK (on_network_set_preferred_plmn),
762 g_signal_connect (network,
763 "handle-get-preferred-plmn",
764 G_CALLBACK (on_network_get_preferred_plmn),
767 g_signal_connect (network,
768 "handle-get-serving-network",
769 G_CALLBACK (on_network_get_serving_network),
772 g_signal_connect (network,
773 "handle-get-ngbr-cell-info",
774 G_CALLBACK (on_network_get_neighboring_cell_info),
777 g_signal_connect (network,
778 "handle-set-default-data-subscription",
779 G_CALLBACK (on_network_set_default_data_subscription),
782 g_signal_connect (network,
783 "handle-get-default-data-subscription",
784 G_CALLBACK (on_network_get_default_data_subscription),
787 g_signal_connect (network,
788 "handle-set-default-subscription",
789 G_CALLBACK (on_network_set_default_subs),
792 g_signal_connect (network,
793 "handle-get-default-subscription",
794 G_CALLBACK (on_network_get_default_subs),
797 tcore_server_add_notification_hook(ctx->server,
798 TNOTI_PS_PROTOCOL_STATUS, on_hook_ps_protocol_status, ctx);
803 gboolean dbus_plugin_network_response(struct custom_data *ctx, UserRequest *ur,
804 struct dbus_request_info *dbus_info, enum tcore_response_command command,
805 unsigned int data_len, const void *data)
807 dbg("Response!!! Command: [0x%x] CP Name: [%s]",
808 command, GET_CP_NAME(dbus_info->invocation));
811 case TRESP_NETWORK_SEARCH: {
812 const struct tresp_network_search *resp_network_search = data;
813 GVariant *network_search_result = NULL;
817 dbg("TRESP_NETWORK_SEARCH - Result: [%s] Count: [%d]",
818 (resp_network_search->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
819 resp_network_search->list_count);
821 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
822 for (i = 0; i < resp_network_search->list_count; i++) {
823 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
825 g_variant_builder_add(&b, "{sv}", "plmn", g_variant_new_string(resp_network_search->list[i].plmn));
826 g_variant_builder_add(&b, "{sv}", "act", g_variant_new_int32(resp_network_search->list[i].act));
827 g_variant_builder_add(&b, "{sv}", "type", g_variant_new_int32(resp_network_search->list[i].status));
828 g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string(resp_network_search->list[i].name));
830 g_variant_builder_close(&b);
832 network_search_result = g_variant_builder_end(&b);
834 telephony_network_complete_search(dbus_info->interface_object, dbus_info->invocation,
835 network_search_result, resp_network_search->result);
839 case TRESP_NETWORK_SET_PLMN_SELECTION_MODE: {
840 const struct tresp_network_set_plmn_selection_mode *resp_set_plmn_selection_mode = data;
842 dbg("TRESP_SET_PLMN_SELECTION_MODE - Result: [%s]",
843 (resp_set_plmn_selection_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
845 telephony_network_complete_set_selection_mode(dbus_info->interface_object, dbus_info->invocation,
846 resp_set_plmn_selection_mode->result);
850 case TRESP_NETWORK_GET_PLMN_SELECTION_MODE: {
851 const struct tresp_network_get_plmn_selection_mode *resp_get_plmn_selection_mode = data;
853 dbg("TRESP_GET_PLMN_SELECTION_MODE - Result: [%s] Mode: [%s]",
854 (resp_get_plmn_selection_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
855 (resp_get_plmn_selection_mode->mode == NETWORK_SELECT_MODE_AUTOMATIC ? "Auto" :
856 (resp_get_plmn_selection_mode->mode == NETWORK_SELECT_MODE_MANUAL ? "Manual" :
859 switch (resp_get_plmn_selection_mode->mode) {
860 case NETWORK_SELECT_MODE_AUTOMATIC:
861 telephony_network_complete_get_selection_mode(dbus_info->interface_object, dbus_info->invocation,
862 0, resp_get_plmn_selection_mode->result);
865 case NETWORK_SELECT_MODE_MANUAL:
866 telephony_network_complete_get_selection_mode(dbus_info->interface_object, dbus_info->invocation,
867 1, resp_get_plmn_selection_mode->result);
871 telephony_network_complete_get_selection_mode(dbus_info->interface_object, dbus_info->invocation,
872 -1, resp_get_plmn_selection_mode->result);
878 case TRESP_NETWORK_SET_SERVICE_DOMAIN: {
879 const struct tresp_network_set_service_domain *resp_set_service_domain = data;
881 dbg("TRESP_NETWORK_SET_SERVICE_DOMAIN - Result: [%s]",
882 (resp_set_service_domain->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
884 telephony_network_complete_set_service_domain(dbus_info->interface_object, dbus_info->invocation,
885 resp_set_service_domain->result);
889 case TRESP_NETWORK_GET_SERVICE_DOMAIN: {
890 const struct tresp_network_get_service_domain *resp_get_service_domain = data;
892 dbg("TRESP_NETWORK_GET_SERVICE_DOMAIN - Result: [%s] Domain: [%d]",
893 (resp_get_service_domain->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
894 resp_get_service_domain->domain);
896 telephony_network_complete_get_service_domain(dbus_info->interface_object, dbus_info->invocation,
897 resp_get_service_domain->domain, resp_get_service_domain->result);
901 case TRESP_NETWORK_SET_BAND: {
902 const struct tresp_network_set_band *resp_set_band = data;
904 dbg("TRESP_NETWORK_SET_BAND - Result: [%s]",
905 (resp_set_band->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
907 telephony_network_complete_set_band(dbus_info->interface_object, dbus_info->invocation,
908 resp_set_band->result);
912 case TRESP_NETWORK_GET_BAND: {
913 const struct tresp_network_get_band *resp_get_band = data;
915 dbg("TRESP_NETWORK_GET_BAND - Result: [%s] Mode: [%s] Band: [%d]",
916 (resp_get_band->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
917 (resp_get_band->mode == NETWORK_BAND_MODE_PREFERRED ? "Preferred" :
918 (resp_get_band->mode == NETWORK_BAND_MODE_ONLY ? "Only" :
919 "Unknown")), resp_get_band->band);
921 telephony_network_complete_get_band(dbus_info->interface_object, dbus_info->invocation,
922 resp_get_band->band, resp_get_band->mode, resp_get_band->result);
926 case TRESP_NETWORK_SET_MODE: {
927 const struct tresp_network_set_mode *resp_set_mode = data;
929 dbg("TRESP_NETWORK_SET_MODE - Result: [%s]",
930 (resp_set_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
932 telephony_network_complete_set_mode(dbus_info->interface_object, dbus_info->invocation,
933 resp_set_mode->result);
937 case TRESP_NETWORK_GET_MODE: {
938 const struct tresp_network_get_mode *resp_get_mode = data;
940 dbg("TRESP_NETWORK_GET_MODE - Result: [%s] Mode: [%d]",
941 (resp_get_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
942 resp_get_mode->mode);
944 telephony_network_complete_get_mode(dbus_info->interface_object, dbus_info->invocation,
945 resp_get_mode->mode, resp_get_mode->result);
949 case TRESP_NETWORK_GET_NEIGHBORING_CELL_INFO: {
950 const struct tresp_network_get_neighboring_cell_info *resp_get_ngbr_cell_info = data;
951 GVariant *neighboring_cell_info_result = NULL;
952 GVariant *value = NULL;
954 enum telephony_network_access_technology act;
957 dbg("TRESP_NETWORK_GET_NEIGHBORING_CELL_INFO - Result: [%s]",
958 (resp_get_ngbr_cell_info->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
960 act = resp_get_ngbr_cell_info->info.serving.act;
962 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
964 /* Fill Serving cell parameter */
965 value = g_variant_new("(iii)",
966 resp_get_ngbr_cell_info->info.serving.act,
967 resp_get_ngbr_cell_info->info.serving.mcc,
968 resp_get_ngbr_cell_info->info.serving.mnc);
969 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
970 g_variant_builder_add(&b, "{sv}", "serving", value);
971 g_variant_builder_close(&b);
973 if (act >= NETWORK_ACT_GSM && act <= NETWORK_ACT_EGPRS) {
974 value = g_variant_new("(iiiii)",
975 resp_get_ngbr_cell_info->info.serving.cell.geran.cell_id,
976 resp_get_ngbr_cell_info->info.serving.cell.geran.lac,
977 resp_get_ngbr_cell_info->info.serving.cell.geran.bcch,
978 resp_get_ngbr_cell_info->info.serving.cell.geran.bsic,
979 resp_get_ngbr_cell_info->info.serving.cell.geran.rxlev);
980 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
981 g_variant_builder_add(&b, "{sv}", "g_serving", value);
982 g_variant_builder_close(&b);
985 else if (act >= NETWORK_ACT_UMTS && act <= NETWORK_ACT_GSM_UTRAN) {
986 value = g_variant_new("(iiiii)",
987 resp_get_ngbr_cell_info->info.serving.cell.umts.cell_id,
988 resp_get_ngbr_cell_info->info.serving.cell.umts.lac,
989 resp_get_ngbr_cell_info->info.serving.cell.umts.arfcn,
990 resp_get_ngbr_cell_info->info.serving.cell.umts.psc,
991 resp_get_ngbr_cell_info->info.serving.cell.umts.rscp);
992 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
993 g_variant_builder_add(&b, "{sv}", "u_serving", value);
994 g_variant_builder_close(&b);
996 else if (act == NETWORK_ACT_LTE) {
997 value = g_variant_new("(iiiii)",
998 resp_get_ngbr_cell_info->info.serving.cell.lte.cell_id,
999 resp_get_ngbr_cell_info->info.serving.cell.lte.lac,
1000 resp_get_ngbr_cell_info->info.serving.cell.lte.earfcn,
1001 resp_get_ngbr_cell_info->info.serving.cell.lte.tac,
1002 resp_get_ngbr_cell_info->info.serving.cell.lte.rssi);
1003 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
1004 g_variant_builder_add(&b, "{sv}", "l_serving", value);
1005 g_variant_builder_close(&b);
1008 /* Fill GERAN neighbor cell parameter */
1009 for (i = 0; i < resp_get_ngbr_cell_info->info.geran_list_count; i++) {
1010 value = g_variant_new("(iiiii)",
1011 resp_get_ngbr_cell_info->info.geran_list[i].cell_id,
1012 resp_get_ngbr_cell_info->info.geran_list[i].lac,
1013 resp_get_ngbr_cell_info->info.geran_list[i].bcch,
1014 resp_get_ngbr_cell_info->info.geran_list[i].bsic,
1015 resp_get_ngbr_cell_info->info.geran_list[i].rxlev);
1016 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
1017 g_variant_builder_add(&b, "{sv}", "geran", value);
1018 g_variant_builder_close(&b);
1021 /* Fill UMTS neighbor cell parameter */
1022 for (i = 0; i < resp_get_ngbr_cell_info->info.umts_list_count; i++) {
1023 value = g_variant_new("(iiiii)",
1024 resp_get_ngbr_cell_info->info.umts_list[i].cell_id,
1025 resp_get_ngbr_cell_info->info.umts_list[i].lac,
1026 resp_get_ngbr_cell_info->info.umts_list[i].arfcn,
1027 resp_get_ngbr_cell_info->info.umts_list[i].psc,
1028 resp_get_ngbr_cell_info->info.umts_list[i].rscp);
1029 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
1030 g_variant_builder_add(&b, "{sv}", "umts", value);
1031 g_variant_builder_close(&b);
1033 neighboring_cell_info_result = g_variant_builder_end(&b);
1035 telephony_network_complete_get_ngbr_cell_info(dbus_info->interface_object, dbus_info->invocation,
1036 neighboring_cell_info_result, resp_get_ngbr_cell_info->result);
1040 case TRESP_NETWORK_SET_PREFERRED_PLMN: {
1041 const struct tresp_network_set_preferred_plmn *resp_set_preferred_plmn = data;
1043 dbg("TRESP_NETWORK_SET_PREFERRED_PLMN - Result: [%s]",
1044 (resp_set_preferred_plmn->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
1046 telephony_network_complete_set_preferred_plmn(dbus_info->interface_object, dbus_info->invocation,
1047 resp_set_preferred_plmn->result);
1051 case TRESP_NETWORK_GET_PREFERRED_PLMN: {
1052 const struct tresp_network_get_preferred_plmn *resp_get_preferred_plmn = data;
1053 GVariant *preferred_plmn_result = NULL;
1057 dbg("TRESP_NETWORK_GET_PREFERRED_PLMN - Result: [%s] Count: [%d]",
1058 (resp_get_preferred_plmn->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
1059 resp_get_preferred_plmn->list_count);
1061 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
1062 for (i = 0; i < resp_get_preferred_plmn->list_count; i++) {
1063 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
1065 g_variant_builder_add(&b, "{sv}", "plmn",
1066 g_variant_new_string(resp_get_preferred_plmn->list[i].plmn));
1067 g_variant_builder_add(&b, "{sv}", "act", g_variant_new_int32(resp_get_preferred_plmn->list[i].act));
1068 g_variant_builder_add(&b, "{sv}", "index",
1069 g_variant_new_int32(resp_get_preferred_plmn->list[i].ef_index));
1070 g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string(resp_get_preferred_plmn->list[i].name));
1072 g_variant_builder_close(&b);
1074 preferred_plmn_result = g_variant_builder_end(&b);
1076 telephony_network_complete_get_preferred_plmn(dbus_info->interface_object, dbus_info->invocation,
1077 preferred_plmn_result, resp_get_preferred_plmn->result);
1081 case TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH: {
1082 const struct tresp_network_set_cancel_manual_search *resp_set_cancel_manual_search = data;
1084 dbg("TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH - Result: [%s]",
1085 (resp_set_cancel_manual_search->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
1087 telephony_network_complete_search_cancel(dbus_info->interface_object, dbus_info->invocation,
1088 resp_set_cancel_manual_search->result);
1092 case TRESP_NETWORK_GET_SERVING_NETWORK: {
1093 const struct tresp_network_get_serving_network *resp_get_serving_network = data;
1095 dbg("TRESP_NETWORK_GET_SERVING_NETWORK - Result: [%s] AcT: [%d] PLMN: [%s] LAC: [%d])",
1096 (resp_get_serving_network->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
1097 resp_get_serving_network->act, resp_get_serving_network->plmn, resp_get_serving_network->gsm.lac);
1099 telephony_network_complete_get_serving_network(dbus_info->interface_object, dbus_info->invocation,
1100 resp_get_serving_network->act, resp_get_serving_network->plmn,
1101 resp_get_serving_network->gsm.lac, resp_get_serving_network->result);
1105 case TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION: {
1106 const struct tresp_network_set_default_data_subscription *resp_set_default_data_subs = data;
1108 dbg("TRESP_NETWORK_SET_DEFAULT_SUBSCRIPTION - Result: [%s]",
1109 (resp_set_default_data_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
1111 telephony_network_complete_set_default_data_subscription(dbus_info->interface_object, dbus_info->invocation,
1112 resp_set_default_data_subs->result);
1116 case TRESP_NETWORK_GET_DEFAULT_DATA_SUBSCRIPTION: {
1117 const struct tresp_network_get_default_data_subs *resp_get_default_data_subs = data;
1119 dbg("TRESP_NETWORK_GET_DEFAULT_SUBSCRIPTION - Result: [%s] 'default' Data subscription: [%s]",
1120 (resp_get_default_data_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
1121 (resp_get_default_data_subs->default_subs == NETWORK_DEFAULT_DATA_SUBS_SIM1 ? "SIM1" :
1122 (resp_get_default_data_subs->default_subs == NETWORK_DEFAULT_DATA_SUBS_SIM2 ? "SIM2" :
1125 telephony_network_complete_get_default_data_subscription(dbus_info->interface_object, dbus_info->invocation,
1126 resp_get_default_data_subs->default_subs, resp_get_default_data_subs->result);
1130 case TRESP_NETWORK_SET_DEFAULT_SUBSCRIPTION: {
1131 const struct tresp_network_set_default_subs *resp_set_default_subs = data;
1133 dbg("TRESP_NETWORK_SET_DEFAULT_SUBSCRIPTION - Result: [%s]",
1134 (resp_set_default_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"));
1136 telephony_network_complete_set_default_subscription(dbus_info->interface_object, dbus_info->invocation,
1137 resp_set_default_subs->result );
1141 case TRESP_NETWORK_GET_DEFAULT_SUBSCRIPTION: {
1142 const struct tresp_network_get_default_subs *resp_get_default_subs = data;
1144 dbg("TRESP_NETWORK_GET_DEFAULT_SUBSCRIPTION - Result: [%s] 'default' subscription: [%s]",
1145 (resp_get_default_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"),
1146 (resp_get_default_subs->default_subs == NETWORK_DEFAULT_SUBS_SIM1 ? "SIM1" :
1147 (resp_get_default_subs->default_subs == NETWORK_DEFAULT_SUBS_SIM2 ? "SIM2" :
1150 telephony_network_complete_get_default_subscription(dbus_info->interface_object, dbus_info->invocation,
1151 resp_get_default_subs->default_subs, resp_get_default_subs->result );
1156 err("Unhandled/Unknown Response!!!");
1163 gboolean dbus_plugin_network_notification(struct custom_data *ctx, CoreObject *source,
1164 TelephonyObjectSkeleton *object, enum tcore_notification_command command,
1165 unsigned int data_len, const void *data)
1167 TelephonyNetwork *network;
1168 const char *cp_name;
1170 cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
1172 network = telephony_object_peek_network(TELEPHONY_OBJECT(object));
1173 if (network == NULL) {
1174 err("Network object is NULL!!!");
1179 case TNOTI_NETWORK_REGISTRATION_STATUS: {
1180 const struct tnoti_network_registration_status *reg = data;
1182 info("[DBUSINFO][%s] NET_REGI_STATUS. (cs:[%d] ps:[%d] svc:[%d] roam:[%d])",
1183 cp_name, reg->cs_domain_status, reg->ps_domain_status, reg->service_type, reg->roaming_status);
1185 #ifdef ENABLE_KPI_LOGS
1186 /* We ignore No SIM present case for KPI */
1187 if (reg->cs_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL
1188 && telephony_network_get_circuit_status(network) != NETWORK_SERVICE_DOMAIN_STATUS_FULL)
1189 TIME_CHECK("[%s] CS Network Full", cp_name);
1191 if (reg->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL
1192 && telephony_network_get_packet_status(network) != NETWORK_SERVICE_DOMAIN_STATUS_FULL)
1193 TIME_CHECK("[%s] PS Network Full", cp_name);
1196 /* Update properties */
1197 telephony_network_set_circuit_status (network, reg->cs_domain_status);
1198 telephony_network_set_packet_status (network, reg->ps_domain_status);
1199 telephony_network_set_service_type (network, reg->service_type);
1200 telephony_network_set_roaming_status (network, reg->roaming_status);
1202 /* Update Network name */
1203 __update_network_name(network, source, cp_name);
1206 telephony_network_emit_registration_status(network,
1207 reg->cs_domain_status,
1208 reg->ps_domain_status,
1210 reg->roaming_status);
1214 case TNOTI_NETWORK_CHANGE: {
1215 const struct tnoti_network_change *change = data;
1217 info("[DBUSINFO][%s] NET_CHANGE. (plmn:[%s] lac:[%d])",
1218 cp_name, change->plmn, change->gsm.lac);
1220 /* Update properties */
1221 telephony_network_set_plmn (network, change->plmn);
1222 telephony_network_set_lac (network, change->gsm.lac);
1224 /* Update Network name */
1225 __update_network_name(network, source, cp_name);
1228 telephony_network_emit_change(network,
1234 case TNOTI_NETWORK_TIMEINFO: {
1235 const struct tnoti_network_timeinfo *time_info = data;
1237 info("[DBUSINFO][%s] NET_TIMEINFO", cp_name);
1240 telephony_network_emit_time_info(network,
1255 case TNOTI_NETWORK_ICON_INFO: {
1256 const struct tnoti_network_icon_info *icon_info = data;
1258 /* Update property */
1259 if (icon_info->type & NETWORK_ICON_INFO_RSSI) {
1260 info("[DBUSINFO][%s] NET_ICON_INFO (Ant:[%d])", cp_name, icon_info->rssi);
1261 telephony_network_set_sig_level (network, icon_info->rssi);
1266 case TNOTI_NETWORK_IDENTITY: {
1267 const struct tnoti_network_identity *identity = data;
1269 info("[DBUSINFO][%s] NET_IDENTITY (long:[%s] short:[%s] plmn:[%s])",
1270 cp_name, identity->full_name, identity->short_name, identity->plmn);
1272 /* Update properties */
1273 telephony_network_set_plmn (network, identity->plmn);
1275 /* Update Network name */
1276 __update_network_name (network, source, cp_name);
1279 telephony_network_emit_identity(network,
1281 identity->short_name,
1282 identity->full_name);
1286 case TNOTI_NETWORK_LOCATION_CELLINFO: {
1287 const struct tnoti_network_location_cellinfo *location = data;
1289 info("[DBUSINFO][%s] NET_LOCATION_CELLINFO (lac:[%d] cell_id:[%d])",
1290 cp_name, location->lac, location->cell_id);
1292 /* Update properties */
1293 telephony_network_set_lac (network, location->lac);
1294 telephony_network_set_cell_id (network, location->cell_id);
1297 telephony_network_emit_cell_info(network,
1303 case TNOTI_NETWORK_SIGNAL_STRENGTH: {
1304 const struct tnoti_network_signal_strength *signal_strength = data;
1306 info("[DBUSINFO][%s] NET_SIGNAL_STRENGTH (dbm:[%d])", cp_name, signal_strength->dbm);
1308 /* Update properties */
1309 telephony_network_set_sig_dbm (network, signal_strength->dbm);
1312 telephony_network_emit_signal_strength(network,
1313 signal_strength->dbm);
1317 case TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION: {
1318 const struct tnoti_network_default_data_subs *default_data_subs_info = data;
1320 info("[DBUSINFO][%s] NET_DEFAULT_DATA_SUBSCRIPTION (default:[%d])", cp_name, default_data_subs_info->default_subs);
1323 telephony_network_emit_default_data_subscription(network,
1324 default_data_subs_info->default_subs);
1328 case TNOTI_NETWORK_DEFAULT_SUBSCRIPTION: {
1329 const struct tnoti_network_default_subs *default_subs_info = data;
1331 info("[DBUSINFO][%s] NET_DEFAULT_SUBSCRIPTION (default:[%d])", cp_name, default_subs_info->default_subs);
1334 telephony_network_emit_default_subscription(network,
1335 default_subs_info->default_subs);
1340 err("Unhandled/Unknown Notification!!!");