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.
30 #include <user_request.h>
33 #include "generated-code.h"
34 #include "dtapi_common.h"
37 * Error message to application (DBUS)
39 #define DBUS_SIM_STATUS_ERROR "SIM STATUS ERROR"
40 #define DBUS_SIM_NOT_FOUND "SIM NOT FOUND"
41 #define DBUS_SIM_PERM_BLOCKED "SIM PERM BLOCKED"
42 #define DBUS_SIM_CARD_ERROR "SIM CARD ERROR"
43 #define DBUS_SIM_NOT_INITIALIZED "SIM NOT INITIALIZED"
44 #define DBUS_SIM_INIT_COMPLETED "SIM INIT COMPLETED"
45 #define DBUS_SIM_LOCKED "SIM LOCKED"
46 #define DBUS_SIM_NOT_READY "SIM NOT READY"
47 #define DBUS_SIM_RESPONSE_DATA_ERROR "SIM RESPONSE DATA ERROR"
48 #define DBUS_SIM_SERVICE_IS_DISABLED "SIM SERVICE IS DISABLED"
49 #define DBUS_SIM_SERVICE_NOT_SUPPORTED_FOR_NVSIM "SERVICE NOT SUPPORTED FOR NVSIM"
51 #define DBUS_SIM_GET_COSIM(invocation, co_sim, server) do { \
52 co_sim = __get_sim_co_by_cp_name(server, GET_CP_NAME(invocation)); \
54 err("[%s] SIM Core object is NULL", GET_CP_NAME(invocation)); \
55 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); \
60 #define DBUS_SIM_CHECK_SIM_STATUS(invocation, op_type, co_sim) do { \
61 if (__check_sim_state(op_type, tcore_sim_get_status(co_sim)) == FALSE) { \
62 err("[%s] Invalid SIM status", GET_CP_NAME(invocation)); \
63 __return_fail_response(invocation, tcore_sim_get_status(co_sim)); \
68 #define DBUS_SIM_CHECK_SIM_TYPE(co_sim, request) do { \
69 if (tcore_sim_get_type(co_sim) == SIM_TYPE_NVSIM) { \
70 err("[%s] is not supported for NVSIM", request); \
71 FAIL_RESPONSE(invocation, DBUS_SIM_SERVICE_NOT_SUPPORTED_FOR_NVSIM); \
76 #define DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, op_type, co_sim) do { \
77 gboolean b_cphs = FALSE; \
78 b_cphs = tcore_sim_get_cphs_status(co_sim); \
79 if (b_cphs && op_type != GET_MSISDN) { \
80 dbg("[%s] CPHS SIM... Do not check SST", GET_CP_NAME(invocation)); \
82 struct tel_sim_service_table* svct = tcore_sim_get_service_table(co_sim); \
84 if (__check_sim_service_table(op_type, svct) == FALSE) { \
85 err("[%s] 'Service' is disabled in SST", GET_CP_NAME(invocation)); \
86 FAIL_RESPONSE(invocation, DBUS_SIM_SERVICE_IS_DISABLED); \
90 dbg("[%s] Request to modem", GET_CP_NAME(invocation)); \
97 #define DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation) do { \
98 if (ret != TCORE_RETURN_SUCCESS) { \
99 if (ret == TCORE_RETURN_SIM_DISABLED_IN_SST) { \
100 err("[%s] 'Service' is disabled in SST", GET_CP_NAME(invocation)); \
101 FAIL_RESPONSE(invocation, DBUS_SIM_SERVICE_IS_DISABLED); \
103 err("[%s] Dispatch request failed: [0x%x]", GET_CP_NAME(invocation), ret); \
104 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); \
109 enum dbus_tapi_sim_gdbus_method_name {
120 GET_MESSAGE_WAITING = 10,
137 ENABLE_FACILITY = 25,
142 GET_FIELDS = 30, /* for get various data at once */
150 GET_ISIM_SERVICE_TABLE,
157 static gboolean __is_sim_status_valid(enum tel_sim_status sim_status)
159 switch (sim_status) {
160 case SIM_STATUS_INIT_COMPLETED:
161 case SIM_STATUS_INITIALIZING:
162 case SIM_STATUS_PIN_REQUIRED:
163 case SIM_STATUS_PUK_REQUIRED:
164 case SIM_STATUS_LOCK_REQUIRED:
165 case SIM_STATUS_CARD_BLOCKED:
166 case SIM_STATUS_NCK_REQUIRED:
167 case SIM_STATUS_NSCK_REQUIRED:
168 case SIM_STATUS_SPCK_REQUIRED:
169 case SIM_STATUS_CCK_REQUIRED:
176 static CoreObject *__get_sim_co_by_cp_name(Server *server, char *cp_name)
181 err("server is NULL");
185 plugin = tcore_server_find_plugin(server, cp_name);
186 return tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
189 static CoreObject* __get_sim_co_from_ur(Server *server, UserRequest *ur)
194 modem_name = tcore_user_request_get_modem_name(ur);
196 err("Modem name is NULL");
200 co_sim = __get_sim_co_by_cp_name(server, modem_name);
206 static gboolean __check_sim_state(enum dbus_tapi_sim_gdbus_method_name method,
207 enum tel_sim_status sim_status)
211 if ((int)sim_status < SIM_STATUS_CARD_ERROR) {
212 err("SIM status is NOT valid");
226 /* Regarding Lock facilities */
228 case ENABLE_FACILITY:
229 case DISABLE_FACILITY:
234 switch (sim_status) {
235 case SIM_STATUS_CARD_ERROR: /* FALLTHROUGH */
236 case SIM_STATUS_CARD_BLOCKED: /* FALLTHROUGH */
237 case SIM_STATUS_CARD_NOT_PRESENT: /* FALLTHROUGH */
238 case SIM_STATUS_CARD_REMOVED: /* FALLTHROUGH */
239 case SIM_STATUS_UNKNOWN: /* FALLTHROUGH */
240 case SIM_STATUS_CARD_POWEROFF:
253 case GET_CPHS_NET_NAME:
254 case GET_CALL_FORWARDING:
255 case SET_CALL_FORWARDING:
256 case GET_MESSAGE_WAITING:
257 case SET_MESSAGE_WAITING:
268 case GET_ISIM_SERVICE_TABLE:
269 if (sim_status != SIM_STATUS_INIT_COMPLETED)
274 switch (sim_status) {
275 case SIM_STATUS_INIT_COMPLETED: /* FALLTHROUGH */
276 case SIM_STATUS_INITIALIZING: /* FALLTHROUGH */
277 case SIM_STATUS_PIN_REQUIRED: /* FALLTHROUGH */
278 case SIM_STATUS_CARD_BLOCKED: /* FALLTHROUGH */
279 case SIM_STATUS_CARD_POWEROFF:
288 case GET_INIT_STATUS:
292 err("Unhandled/Unknown operation: [%d]", method);
299 static gboolean __check_sim_service_table(enum dbus_tapi_sim_gdbus_method_name method,
300 struct tel_sim_service_table *svct)
302 enum tel_sim_type sim_type = svct->sim_type;
308 if (!(sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_MSISDN])
309 && !(sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_MSISDN]))
313 case GET_CALL_FORWARDING:
314 case SET_CALL_FORWARDING:
315 if (!(sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_CFIS])
316 && !(sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_CFIS]))
320 case GET_MESSAGE_WAITING:
321 case SET_MESSAGE_WAITING:
322 if (!(sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_MWIS])
323 && !(sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_MWIS]))
329 if (!(sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_MBDN]) &&
330 !(sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_MBDN]))
335 err("Unhandled/Unknown operation: [%d]", method);
342 static void __return_fail_response(GDBusMethodInvocation *invocation,
343 enum tel_sim_status sim_status)
345 dbg("[%s] SIM Status: [%d]", GET_CP_NAME(invocation), sim_status);
347 switch (sim_status) {
348 case SIM_STATUS_CARD_NOT_PRESENT:
349 case SIM_STATUS_CARD_REMOVED:
350 FAIL_RESPONSE(invocation, DBUS_SIM_NOT_FOUND);
353 case SIM_STATUS_CARD_BLOCKED:
354 FAIL_RESPONSE(invocation, DBUS_SIM_PERM_BLOCKED);
357 case SIM_STATUS_CARD_ERROR:
358 case SIM_STATUS_CARD_CRASHED:
359 FAIL_RESPONSE(invocation, DBUS_SIM_CARD_ERROR);
362 case SIM_STATUS_INITIALIZING:
363 FAIL_RESPONSE(invocation, DBUS_SIM_NOT_INITIALIZED);
366 case SIM_STATUS_INIT_COMPLETED:
367 FAIL_RESPONSE(invocation, DBUS_SIM_INIT_COMPLETED);
370 case SIM_STATUS_PIN_REQUIRED:
371 case SIM_STATUS_PUK_REQUIRED:
372 case SIM_STATUS_NCK_REQUIRED:
373 case SIM_STATUS_NSCK_REQUIRED:
374 case SIM_STATUS_SPCK_REQUIRED:
375 case SIM_STATUS_CCK_REQUIRED:
376 case SIM_STATUS_LOCK_REQUIRED:
377 FAIL_RESPONSE(invocation, DBUS_SIM_LOCKED);
380 case SIM_STATUS_UNKNOWN:
381 FAIL_RESPONSE(invocation, DBUS_SIM_NOT_READY);
385 dbg("Unhandled/Unknown status: [%d]", sim_status);
386 FAIL_RESPONSE(invocation, DBUS_SIM_STATUS_ERROR);
391 static gboolean on_sim_get_init_status(TelephonySim *sim,
392 GDBusMethodInvocation *invocation, gpointer user_data)
394 struct custom_data *ctx = user_data;
395 enum tel_sim_status sim_status = SIM_STATUS_UNKNOWN;
396 gboolean sim_changed = FALSE;
397 CoreObject *co_sim = NULL;
398 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
400 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
403 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
405 sim_status = tcore_sim_get_status(co_sim);
406 sim_changed = tcore_sim_get_identification(co_sim);
407 dbg("[%s] SIM - Status: [%d] Changed: [%s]",
408 GET_CP_NAME(invocation),
409 sim_status, (sim_changed ? "YES" : "NO"));
411 telephony_sim_complete_get_init_status(sim,
412 invocation, sim_status, sim_changed);
417 static gboolean on_sim_get_card_type(TelephonySim *sim,
418 GDBusMethodInvocation *invocation, gpointer user_data)
420 struct custom_data *ctx = user_data;
421 enum tel_sim_type sim_type = SIM_TYPE_UNKNOWN;
422 CoreObject *co_sim = NULL;
423 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
425 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
428 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
429 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_CARD_TYPE, co_sim);
431 sim_type = tcore_sim_get_type(co_sim);
432 dbg("[%s] SIM Card type: [%s]", GET_CP_NAME(invocation),
433 (sim_type == SIM_TYPE_GSM ? "GSM" :
434 (sim_type == SIM_TYPE_USIM ? "USIM" :
435 (sim_type == SIM_TYPE_RUIM ? "RUIM" :
436 (sim_type == SIM_TYPE_NVSIM ? "NVSIM" :
437 (sim_type == SIM_TYPE_ISIM ? "ISIM" :
440 telephony_sim_complete_get_card_type(sim,
441 invocation, sim_type);
446 static gboolean on_sim_get_imsi(TelephonySim *sim,
447 GDBusMethodInvocation *invocation, gpointer user_data)
449 struct custom_data *ctx = user_data;
450 struct tel_sim_imsi *imsi;
451 CoreObject *co_sim = NULL;
452 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
454 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
457 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
458 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_IMSI, co_sim);
460 imsi = tcore_sim_get_imsi(co_sim);
462 FAIL_RESPONSE(invocation, DBUS_SIM_RESPONSE_DATA_ERROR);
464 dbg("[%s] IMSI - PLMN: [%s] MSIN: [%s]", GET_CP_NAME(invocation),
465 imsi->plmn, imsi->msin);
467 telephony_sim_complete_get_imsi(sim,
468 invocation, imsi->plmn, imsi->msin);
476 static gboolean on_sim_get_ecc(TelephonySim *sim,
477 GDBusMethodInvocation *invocation, gpointer user_data)
479 struct custom_data *ctx = user_data;
480 CoreObject *co_sim = NULL;
481 struct tel_sim_ecc_list *ecc_list = NULL;
482 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
484 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
487 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
488 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_ECC, co_sim);
489 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get ECC");
491 ecc_list = tcore_sim_get_ecc_list(co_sim);
493 struct custom_data *ctx = user_data;
495 dbg("[%s] ECC list is NULL - Request to Modem.", GET_CP_NAME(invocation));
497 /* Dispatch request */
498 dtapi_dispatch_request(ctx, sim, invocation,
506 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
507 for (i = 0; i < ecc_list->ecc_count; i++) {
508 dbg("[%s] ECC[%d] - Category: [0x%x] Number: [%s] String: [%s]",
509 GET_CP_NAME(invocation), i,
510 ecc_list->ecc[i].ecc_category,
511 ecc_list->ecc[i].ecc_num,
512 ecc_list->ecc[i].ecc_string);
513 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
514 g_variant_builder_add(&b, "{sv}", "category",
515 g_variant_new_int32(ecc_list->ecc[i].ecc_category));
516 g_variant_builder_add(&b, "{sv}", "number",
517 g_variant_new_string(ecc_list->ecc[i].ecc_num));
518 g_variant_builder_add(&b, "{sv}", "name",
519 g_variant_new_string(ecc_list->ecc[i].ecc_string));
520 g_variant_builder_close(&b);
522 gv = g_variant_builder_end(&b);
524 err("ecc gv is NULL");
526 telephony_sim_complete_get_ecc(sim,
535 static gboolean on_sim_get_iccid(TelephonySim *sim,
536 GDBusMethodInvocation *invocation, gpointer user_data)
538 struct custom_data *ctx = user_data;
539 CoreObject *co_sim = NULL;
540 struct tel_sim_iccid* iccid = NULL;
541 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
543 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
546 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
547 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_ICCID, co_sim);
548 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get ICCID");
550 iccid = tcore_sim_get_iccid(co_sim);
552 /* Dispatch request */
553 dtapi_dispatch_request(ctx, sim, invocation,
557 dbg("[%s] ICCID: [%s]", GET_CP_NAME(invocation),
560 telephony_sim_complete_get_iccid(sim,
561 invocation, SIM_ACCESS_SUCCESS, iccid->iccid);
569 static gboolean on_sim_get_language(TelephonySim *sim,
570 GDBusMethodInvocation *invocation, gpointer user_data)
572 struct custom_data *ctx = user_data;
573 CoreObject *co_sim = NULL;
574 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
576 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
579 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
580 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_LANGUAGE, co_sim);
581 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Language");
583 /* Dispatch request */
584 dtapi_dispatch_request(ctx, sim, invocation,
585 TREQ_SIM_GET_LANGUAGE,
591 static gboolean on_sim_set_language(TelephonySim *sim,
592 GDBusMethodInvocation *invocation, gint language, gpointer user_data)
594 struct custom_data *ctx = user_data;
595 CoreObject *co_sim = NULL;
596 struct treq_sim_set_language req;
597 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
599 if (!check_access_control(p_cynara, invocation, AC_SIM, "w"))
602 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
603 DBUS_SIM_CHECK_SIM_STATUS(invocation, SET_LANGUAGE, co_sim);
604 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Language");
606 memset(&req, 0x0, sizeof(struct treq_sim_set_language));
608 req.language = language;
610 dbg("[%s] Language: [0x%02x]", GET_CP_NAME(invocation),
613 /* Dispatch request */
614 dtapi_dispatch_request(ctx, sim, invocation,
615 TREQ_SIM_SET_LANGUAGE,
616 &req, sizeof(struct treq_sim_set_language));
621 static gboolean on_sim_get_call_forwarding(TelephonySim *sim,
622 GDBusMethodInvocation *invocation, gpointer user_data)
624 struct custom_data *ctx = user_data;
625 CoreObject *co_sim = NULL;
627 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
629 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
632 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
633 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_CALL_FORWARDING, co_sim);
634 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Call Forwarding");
635 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, GET_CALL_FORWARDING, co_sim);
637 /* Dispatch request */
638 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
639 TREQ_SIM_GET_CALLFORWARDING,
641 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
646 static gboolean on_sim_set_call_forwarding(TelephonySim *sim,
647 GDBusMethodInvocation *invocation,
652 gint ton, gint npi, const gchar *number,
653 gint cc2_id, gint ext7_id,
654 gboolean cphs_line1, gboolean cphs_line2,
655 gboolean cphs_fax, gboolean cphs_data, gpointer user_data)
657 struct custom_data *ctx = user_data;
658 CoreObject *co_sim = NULL;
659 struct treq_sim_set_callforwarding req;
661 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
663 if (!check_access_control(p_cynara, invocation, AC_SIM, "w"))
666 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
667 DBUS_SIM_CHECK_SIM_STATUS(invocation, SET_CALL_FORWARDING, co_sim);
668 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Call Forwarding");
669 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, SET_CALL_FORWARDING, co_sim);
671 memset(&req, 0x0, sizeof(struct treq_sim_set_callforwarding));
675 req.cphs_cf.b_line1 = cphs_line1;
676 req.cphs_cf.b_line2 = cphs_line2;
677 req.cphs_cf.b_fax = cphs_fax;
678 req.cphs_cf.b_data = cphs_data;
680 dbg("[%s] b_line1: [%d] b_line2: [%d] b_fax: [%d] b_data: [%d]",
681 GET_CP_NAME(invocation),
682 req.cphs_cf.b_line1, req.cphs_cf.b_line2,
683 req.cphs_cf.b_fax, req.cphs_cf.b_data);
685 req.cf.rec_index = rec_index;
686 req.cf.msp_num = msp_num;
687 req.cf.cfu_status = cfu_status;
690 memcpy(&req.cf.cfu_num, number, strlen(number));
691 req.cf.cc2_id = cc2_id;
692 req.cf.ext7_id = ext7_id;
694 dbg("[%s] rec_index: [%d] msp_num: [%d] cfu_status: [0x%x] " \
695 "ton: [%d] npi: [%d] cfu_num: [%s] cc2_id: [%d] ext7_id: [%d]",
696 GET_CP_NAME(invocation), req.cf.rec_index,
697 req.cf.msp_num, req.cf.cfu_status, req.cf.ton,
698 req.cf.npi, req.cf.cfu_num, req.cf.cc2_id, req.cf.ext7_id);
701 /* Dispatch request */
702 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
703 TREQ_SIM_SET_CALLFORWARDING,
704 &req, sizeof(struct treq_sim_set_callforwarding));
705 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
710 static gboolean on_sim_get_message_waiting(TelephonySim *sim,
711 GDBusMethodInvocation *invocation, gpointer user_data)
713 struct custom_data *ctx = user_data;
714 CoreObject *co_sim = NULL;
716 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
718 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
721 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
722 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_MESSAGE_WAITING, co_sim);
723 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Message Waiting");
724 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, GET_MESSAGE_WAITING, co_sim);
726 /* Dispatch request */
727 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
728 TREQ_SIM_GET_MESSAGEWAITING,
730 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
735 static gboolean on_sim_set_message_waiting(TelephonySim *sim,
736 GDBusMethodInvocation *invocation,
739 guchar indicator_status,
740 gint voice_cnt, gint fax_cnt,
741 gint email_cnt, gint other_cnt,
743 gboolean cphs_voice1, gboolean cphs_voice2,
744 gboolean cphs_fax, gboolean cphs_data, gpointer user_data)
746 struct custom_data *ctx = user_data;
748 CoreObject *co_sim = NULL;
749 struct treq_sim_set_messagewaiting req;
750 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
752 if (!check_access_control(p_cynara, invocation, AC_SIM, "w"))
755 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
756 DBUS_SIM_CHECK_SIM_STATUS(invocation, SET_MESSAGE_WAITING, co_sim);
757 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Message Waiting");
758 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, SET_MESSAGE_WAITING, co_sim);
760 memset(&req, 0x0, sizeof(struct treq_sim_set_messagewaiting));
765 req.cphs_mw.b_voice1 = cphs_voice1;
766 req.cphs_mw.b_voice2 = cphs_voice2;
767 req.cphs_mw.b_fax = cphs_fax;
768 req.cphs_mw.b_data = cphs_data;
770 dbg("[%s] b_voice1: [%d] b_voice2: [%d] b_fax: [%d] b_data:[%d]",
771 GET_CP_NAME(invocation),
772 req.cphs_mw.b_voice1, req.cphs_mw.b_voice2,
773 req.cphs_mw.b_fax, req.cphs_mw.b_data);
775 req.mw.rec_index = rec_index;
776 req.mw.indicator_status = indicator_status;
777 req.mw.voice_count = voice_cnt;
778 req.mw.fax_count = fax_cnt;
779 req.mw.email_count = email_cnt;
780 req.mw.other_count = other_cnt;
781 req.mw.video_count = video_cnt;
783 dbg("[%s] rec_index: [%d] indicator_status: [0x%x] voice_count: [%d] " \
784 "fax_count: [%d] email_count: [%d] other_count: [%d] video_count: [%d]",
785 GET_CP_NAME(invocation),
786 req.mw.rec_index, req.mw.indicator_status,
787 req.mw.voice_count, req.mw.fax_count,
788 req.mw.email_count, req.mw.other_count,
792 /* Dispatch request */
793 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
794 TREQ_SIM_SET_MESSAGEWAITING,
795 &req, sizeof(struct treq_sim_set_messagewaiting));
796 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
801 static gboolean on_sim_get_mailbox(TelephonySim *sim,
802 GDBusMethodInvocation *invocation, gpointer user_data)
804 struct custom_data *ctx = user_data;
806 CoreObject *co_sim = NULL;
807 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
809 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
812 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
813 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_MAILBOX, co_sim);
814 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Mailbox");
815 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, GET_MAILBOX, co_sim);
817 /* Dispatch request */
818 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
819 TREQ_SIM_GET_MAILBOX,
821 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
826 static gboolean on_sim_set_mailbox(TelephonySim *sim,
827 GDBusMethodInvocation *invocation,
829 gint mb_type, gint rec_index,
831 gint alpha_id_max_len, const gchar *alpha_id,
832 gint ton, gint npi, const gchar *number,
833 gint cc_id, gint ext1_id, gpointer user_data)
835 struct custom_data *ctx = user_data;
837 CoreObject *co_sim = NULL;
838 struct treq_sim_set_mailbox req;
839 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
841 if (!check_access_control(p_cynara, invocation, AC_SIM, "w"))
844 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
845 DBUS_SIM_CHECK_SIM_STATUS(invocation, SET_MAILBOX, co_sim);
846 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Mailbox");
847 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, SET_MAILBOX, co_sim);
849 memset(&req, 0x0, sizeof(struct treq_sim_set_mailbox));
853 req.mb_info.mb_type = mb_type;
854 req.mb_info.rec_index = rec_index;
855 req.mb_info.profile_number = profile_number;
856 req.mb_info.number_info.alpha_id_max_len = alpha_id_max_len;
857 if (strlen(alpha_id))
858 memcpy(&req.mb_info.number_info.alpha_id, alpha_id, strlen(alpha_id));
859 req.mb_info.number_info.ton = ton;
860 req.mb_info.number_info.npi = npi;
862 memcpy(&req.mb_info.number_info.num, number, strlen(number));
863 req.mb_info.number_info.cc_id = cc_id;
864 req.mb_info.number_info.ext1_id = ext1_id;
866 dbg("[%s] b_cphs: [%d] mb_type: [%d] rec_index: [%d] " \
867 "profile_number: [%d] alpha_id_max_len: [%d] alpha_id: [%s] " \
868 "ton: [%d] npi: [%d] num: [%s] cc_id: [%d] ext1_id: [%d]",
869 GET_CP_NAME(invocation),
871 req.mb_info.mb_type, req.mb_info.rec_index,
872 req.mb_info.profile_number,
873 req.mb_info.number_info.alpha_id_max_len,
874 req.mb_info.number_info.alpha_id,
875 req.mb_info.number_info.ton, req.mb_info.number_info.npi,
876 req.mb_info.number_info.num,
877 req.mb_info.number_info.cc_id, req.mb_info.number_info.ext1_id);
879 /* Dispatch request */
880 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
881 TREQ_SIM_SET_MAILBOX,
882 &req, sizeof(struct treq_sim_set_mailbox));
883 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
888 static gboolean on_sim_get_cphsinfo(TelephonySim *sim,
889 GDBusMethodInvocation *invocation, gpointer user_data)
891 struct custom_data *ctx = user_data;
892 CoreObject *co_sim = NULL;
893 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
895 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
898 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
899 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_CPHS_INFO, co_sim);
900 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get CPHS Info");
902 /* Dispatch request */
903 dtapi_dispatch_request(ctx, sim, invocation,
904 TREQ_SIM_GET_CPHS_INFO,
910 static gboolean on_sim_get_service_table(TelephonySim *sim,
911 GDBusMethodInvocation *invocation, gpointer user_data)
913 struct custom_data *ctx = user_data;
914 CoreObject *co_sim = NULL;
915 struct tel_sim_service_table *svct = NULL;
916 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
918 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
921 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
922 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_SVCT, co_sim);
923 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get SVCT");
925 svct = tcore_sim_get_service_table(co_sim);
927 struct custom_data *ctx = user_data;
929 dbg("[%s] NOT cached - Request to modem",
930 GET_CP_NAME(invocation));
932 /* Dispatch request */
933 dtapi_dispatch_request(ctx, sim, invocation,
934 TREQ_SIM_GET_SERVICE_TABLE,
937 GVariantBuilder builder;
938 GVariant * inner_gv = NULL;
939 GVariant *svct_gv = NULL;
942 dbg("[%s] GET_SERVICE_TABLE", GET_CP_NAME(invocation));
944 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
945 if (svct->sim_type == SIM_TYPE_GSM) {
946 for (i = 0; i < SIM_SST_SERVICE_CNT_MAX; i++)
947 g_variant_builder_add(&builder, "y",
948 svct->table.sst.service[i]);
949 } else if (svct->sim_type == SIM_TYPE_USIM) {
950 for (i = 0; i < SIM_UST_SERVICE_CNT_MAX; i++)
951 g_variant_builder_add(&builder, "y",
952 svct->table.ust.service[i]);
953 } else if (svct->sim_type == SIM_TYPE_RUIM) {
954 if (SIM_CDMA_SVC_TABLE == svct->table.cst.cdma_svc_table) {
955 for (i = 0; i < SIM_CDMA_ST_SERVICE_CNT_MAX; i++)
956 g_variant_builder_add(&builder, "iy",
957 svct->table.cst.cdma_svc_table,
958 svct->table.cst.service.cdma_service[i]);
959 } else if (SIM_CSIM_SVC_TABLE == svct->table.cst.cdma_svc_table) {
960 for (i = 0; i < SIM_CSIM_ST_SERVICE_CNT_MAX; i++)
961 g_variant_builder_add(&builder, "iy",
962 svct->table.cst.cdma_svc_table,
963 svct->table.cst.service.csim_service[i]);
965 err("Invalid cdma_svc_table: [%d]", svct->table.cst.cdma_svc_table);
968 err("[%s] Unknown SIM type: [%d]", GET_CP_NAME(invocation), svct->sim_type);
970 inner_gv = g_variant_builder_end(&builder);
971 svct_gv = g_variant_new("v", inner_gv);
973 telephony_sim_complete_get_service_table(sim,
974 invocation, SIM_ACCESS_SUCCESS, svct->sim_type, svct_gv);
982 static gboolean on_sim_get_msisdn(TelephonySim *sim,
983 GDBusMethodInvocation *invocation, gpointer user_data)
985 struct custom_data *ctx = user_data;
986 CoreObject *co_sim = NULL;
987 struct tel_sim_msisdn_list *msisdn_list = NULL;
988 gboolean read_from_modem = FALSE;
989 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
991 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
994 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
995 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_MSISDN, co_sim);
996 DBUS_SIM_CHECK_SIM_SERVICE_TABLE(invocation, GET_MSISDN, co_sim);
998 if (SIM_TYPE_NVSIM == tcore_sim_get_type(co_sim)) {
999 dbg("NV SIM, don't use cached MSISDN");
1000 read_from_modem = TRUE;
1002 msisdn_list = tcore_sim_get_msisdn_list(co_sim);
1004 read_from_modem = FALSE;
1006 read_from_modem = TRUE;
1009 if (read_from_modem) {
1012 dbg("[%s] NOT cached - Request to modem", GET_CP_NAME(invocation));
1014 /* Dispatch request */
1015 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
1016 TREQ_SIM_GET_MSISDN,
1018 DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation);
1020 GVariant *gv = NULL;
1024 dbg("[%s] MSISDN count: [%d]",
1025 GET_CP_NAME(invocation), msisdn_list->count);
1027 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
1028 for (i = 0; i < msisdn_list->count; i++) {
1029 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
1030 g_variant_builder_add(&b, "{sv}", "name",
1031 g_variant_new_string((const gchar *)msisdn_list->msisdn[i].name));
1032 if (msisdn_list->msisdn[i].ton == SIM_TON_INTERNATIONAL) {
1033 unsigned char *tmp = (unsigned char *)calloc(SIM_MSISDN_NUMBER_LEN_MAX + 1, 1);
1037 strncpy((char *)tmp+1,
1038 (const char*)msisdn_list->msisdn[i].num,
1039 SIM_MSISDN_NUMBER_LEN_MAX - 1);
1040 tmp[SIM_MSISDN_NUMBER_LEN_MAX] = '\0';
1042 g_variant_builder_add(&b, "{sv}", "number",
1043 g_variant_new_string((const gchar *)tmp));
1047 warn("Memory allocation failed");
1048 g_variant_builder_add(&b, "{sv}", "number",
1049 g_variant_new_string((const gchar *)msisdn_list->msisdn[i].num));
1052 g_variant_builder_add(&b, "{sv}", "number",
1053 g_variant_new_string((const gchar *)msisdn_list->msisdn[i].num));
1055 g_variant_builder_close(&b);
1057 gv = g_variant_builder_end(&b);
1059 telephony_sim_complete_get_msisdn(sim,
1060 invocation, SIM_ACCESS_SUCCESS, gv);
1062 g_free(msisdn_list);
1068 static gboolean on_sim_get_oplmnwact(TelephonySim *sim,
1069 GDBusMethodInvocation *invocation, gpointer user_data)
1071 struct custom_data *ctx = user_data;
1072 CoreObject *co_sim = NULL;
1073 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1075 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1078 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1079 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_OPLMWACT, co_sim);
1080 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get OPLMNWACT");
1082 /* Dispatch request */
1083 dtapi_dispatch_request(ctx, sim, invocation,
1084 TREQ_SIM_GET_OPLMNWACT,
1090 static gboolean on_sim_get_spn(TelephonySim *sim,
1091 GDBusMethodInvocation *invocation, gpointer user_data)
1093 struct custom_data *ctx = user_data;
1094 CoreObject *co_sim = NULL;
1095 struct tel_sim_spn* spn = NULL;
1096 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1098 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1101 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1102 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_SPN, co_sim);
1103 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get SPN");
1105 spn = tcore_sim_get_spn(co_sim);
1107 dbg("[%s] NOT cached - Request to modem", GET_CP_NAME(invocation));
1109 /* Dispatch request */
1110 dtapi_dispatch_request(ctx, sim, invocation,
1114 dbg("[%s] Display condition: [%d] SPN: [%s]",
1115 GET_CP_NAME(invocation),
1116 spn->display_condition, (const gchar *)spn->spn);
1118 telephony_sim_complete_get_spn(sim, invocation, SIM_ACCESS_SUCCESS,
1119 spn->display_condition, (const gchar *)spn->spn);
1126 static gboolean on_sim_get_cphs_netname(TelephonySim *sim,
1127 GDBusMethodInvocation *invocation, gpointer user_data)
1129 struct custom_data *ctx = user_data;
1130 CoreObject *co_sim = NULL;
1131 struct tel_sim_cphs_netname *cphs_netname = NULL;
1132 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1134 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1137 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1138 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_CPHS_NET_NAME, co_sim);
1139 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get CPHS Net Name");
1141 cphs_netname = tcore_sim_get_cphs_netname(co_sim);
1142 if (!cphs_netname) {
1143 dbg("[%s] NOT cached - Request to modem", GET_CP_NAME(invocation));
1145 /* Dispatch request */
1146 dtapi_dispatch_request(ctx, sim, invocation,
1147 TREQ_SIM_GET_CPHS_NETNAME,
1150 dbg("[%s] Full name: [%s] Short name: [%s]",
1151 GET_CP_NAME(invocation),
1152 (const gchar *)cphs_netname->full_name,
1153 (const gchar *)cphs_netname->short_name);
1155 telephony_sim_complete_get_cphs_net_name(sim,
1156 invocation, SIM_ACCESS_SUCCESS,
1157 (const gchar *)cphs_netname->full_name,
1158 (const gchar *)cphs_netname->short_name);
1160 g_free(cphs_netname);
1166 static gboolean on_sim_get_gid(TelephonySim *sim,
1167 GDBusMethodInvocation *invocation, gpointer user_data)
1169 struct custom_data *ctx = user_data;
1170 CoreObject *co_sim = NULL;
1171 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1173 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1176 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1177 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_GID, co_sim);
1178 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get GID");
1180 /* Dispatch request */
1181 dtapi_dispatch_request(ctx, sim, invocation,
1188 static gboolean on_sim_authentication(TelephonySim *sim,
1189 GDBusMethodInvocation *invocation, gint auth_type,
1190 GVariant *rand, GVariant *autn, gpointer user_data)
1192 struct custom_data *ctx = user_data;
1193 GVariantIter *iter = NULL;
1194 GVariant *rand_gv = NULL;
1195 GVariant *autn_gv = NULL;
1199 CoreObject *co_sim = NULL;
1200 struct treq_sim_req_authentication req;
1201 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1203 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1206 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1207 DBUS_SIM_CHECK_SIM_STATUS(invocation, AUTHENTICATION, co_sim);
1209 memset(&req, 0x0, sizeof(struct treq_sim_req_authentication));
1211 req.auth_type = auth_type;
1213 rand_gv = g_variant_get_variant(rand);
1214 g_variant_get(rand_gv, "ay", &iter);
1215 while (g_variant_iter_loop(iter, "y", &rt_i)) {
1216 req.rand_data[i] = rt_i;
1219 g_variant_iter_free(iter);
1220 g_variant_unref(rand_gv);
1222 req.rand_length = (unsigned int)i;
1225 autn_gv = g_variant_get_variant(autn);
1226 g_variant_get(autn_gv, "ay", &iter);
1227 while (g_variant_iter_loop(iter, "y", &rt_i)) {
1228 req.autn_data[i] = rt_i;
1231 g_variant_iter_free(iter);
1232 g_variant_unref(autn_gv);
1234 req.autn_length = (unsigned int)i;
1236 dbg("[%s] Authentication - type: [0x%02x] RAND len: [%d] AUTN len: [%d]",
1237 GET_CP_NAME(invocation),
1238 req.auth_type, req.rand_length, req.autn_length);
1240 /* Dispatch request */
1241 ret = dtapi_dispatch_request_ex(ctx, sim, invocation,
1242 TREQ_SIM_REQ_AUTHENTICATION,
1243 &req, sizeof(struct treq_sim_req_authentication));
1244 if (ret != TCORE_RETURN_SUCCESS) {
1245 GVariantBuilder builder;
1246 GVariant *ak = NULL;
1247 GVariant *cp = NULL;
1248 GVariant *it = NULL;
1249 GVariant *resp = NULL;
1250 GVariant *ak_gv = NULL;
1251 GVariant *cp_gv = NULL;
1252 GVariant *it_gv = NULL;
1253 GVariant *resp_gv = NULL;
1255 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
1256 ak = g_variant_builder_end(&builder);
1257 ak_gv = g_variant_new("v", ak);
1259 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
1260 cp = g_variant_builder_end(&builder);
1261 cp_gv = g_variant_new("v", cp);
1263 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
1264 it = g_variant_builder_end(&builder);
1265 it_gv = g_variant_new("v", it);
1267 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
1268 resp = g_variant_builder_end(&builder);
1269 resp_gv = g_variant_new("v", resp);
1271 telephony_sim_complete_authentication(sim,
1272 invocation, SIM_ACCESS_FAILED,
1273 0, 0, ak_gv, cp_gv, it_gv, resp_gv);
1279 static gboolean on_sim_verify_sec(TelephonySim *sim,
1280 GDBusMethodInvocation *invocation,
1281 gint pin_type, const gchar *pin, gpointer user_data)
1283 struct custom_data *ctx = user_data;
1284 CoreObject *co_sim = NULL;
1285 struct treq_sim_verify_pins req;
1286 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1288 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1291 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1292 DBUS_SIM_CHECK_SIM_STATUS(invocation, VERIFY_SEC, co_sim);
1293 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Verify Sec");
1295 memset(&req, 0x0, sizeof(struct treq_sim_verify_pins));
1297 req.pin_type = pin_type;
1298 req.pin_length = strlen(pin);
1299 memcpy(req.pin, pin, req.pin_length);
1301 dbg("[%s] PIN - type: [0x%02x] len: [%d]",
1302 GET_CP_NAME(invocation),
1303 req.pin_type, req.pin_length);
1305 /* Dispatch request */
1306 dtapi_dispatch_request(ctx, sim, invocation,
1307 TREQ_SIM_VERIFY_PINS,
1308 &req, sizeof(struct treq_sim_verify_pins));
1313 static gboolean on_sim_verify_puk(TelephonySim *sim,
1314 GDBusMethodInvocation *invocation,
1315 gint puk_type, const gchar *puk,
1316 const gchar *new_pin, gpointer user_data)
1318 struct custom_data *ctx = user_data;
1319 CoreObject *co_sim = NULL;
1320 struct treq_sim_verify_puks req;
1321 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1323 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1326 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1327 DBUS_SIM_CHECK_SIM_STATUS(invocation, VERIFY_PUK, co_sim);
1328 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Verify PUK");
1330 memset(&req, 0x0, sizeof(struct treq_sim_verify_puks));
1332 req.puk_type = puk_type;
1333 req.puk_length = strlen(puk);
1334 memcpy(req.puk, puk, req.puk_length);
1335 req.pin_length = strlen(new_pin);
1336 memcpy(req.pin, new_pin, req.pin_length);
1338 dbg("[%s] PUK - type: [0x%02x] len: [%d] PIN len: [%d]",
1339 GET_CP_NAME(invocation), req.puk_type,
1340 req.puk_length, req.pin_length);
1342 /* Dispatch request */
1343 dtapi_dispatch_request(ctx, sim, invocation,
1344 TREQ_SIM_VERIFY_PUKS,
1345 &req, sizeof(struct treq_sim_verify_puks));
1350 static gboolean on_sim_change_pin(TelephonySim *sim,
1351 GDBusMethodInvocation *invocation,
1352 gint pin_type, const gchar *old_pin, const gchar *new_pin,
1355 struct custom_data *ctx = user_data;
1356 CoreObject *co_sim = NULL;
1357 struct treq_sim_change_pins req;
1358 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1360 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1363 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1364 DBUS_SIM_CHECK_SIM_STATUS(invocation, CHANGE_PIN, co_sim);
1365 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Change PIN");
1367 memset(&req, 0x0, sizeof(struct treq_sim_change_pins));
1369 req.type = pin_type;
1370 req.old_pin_length = strlen(old_pin);
1371 memcpy(req.old_pin, old_pin, req.old_pin_length);
1372 req.new_pin_length = strlen(new_pin);
1373 memcpy(req.new_pin, new_pin, req.new_pin_length);
1375 dbg("[%s] PIN - type: [0x%02x] Old PIN len: [%d] New PIN len: [%d]",
1376 GET_CP_NAME(invocation), req.type,
1377 req.old_pin_length, req.new_pin_length);
1379 /* Dispatch request */
1380 dtapi_dispatch_request(ctx, sim, invocation,
1381 TREQ_SIM_CHANGE_PINS,
1382 &req, sizeof(struct treq_sim_change_pins));
1387 static gboolean on_sim_disable_facility(TelephonySim *sim,
1388 GDBusMethodInvocation *invocation,
1389 gint facility_type, const gchar *password, gpointer user_data)
1391 struct custom_data *ctx = user_data;
1392 struct treq_sim_disable_facility req;
1393 CoreObject *co_sim = NULL;
1394 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1396 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1399 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1400 DBUS_SIM_CHECK_SIM_STATUS(invocation, DISABLE_FACILITY, co_sim);
1401 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Diable Facility");
1403 memset(&req, 0x0, sizeof(struct treq_sim_disable_facility));
1405 dbg("[%s] facility_type: [%d]", GET_CP_NAME(invocation), facility_type);
1406 switch (facility_type) {
1408 req.type = SIM_FACILITY_PS;
1412 req.type = SIM_FACILITY_SC;
1416 req.type = SIM_FACILITY_FD;
1420 req.type = SIM_FACILITY_PN;
1424 req.type = SIM_FACILITY_PU;
1428 req.type = SIM_FACILITY_PP;
1432 req.type = SIM_FACILITY_PC;
1436 err("Unhandled/Unknown Facility type: [0x%x]", facility_type);
1438 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
1443 req.password_length = strlen(password);
1444 memcpy(req.password, password, req.password_length);
1446 dbg("[%s] Facility - type: [0x%02x] Passowrd len: [%d]",
1447 GET_CP_NAME(invocation),
1448 req.type, req.password_length);
1450 /* Dispatch request */
1451 dtapi_dispatch_request(ctx, sim, invocation,
1452 TREQ_SIM_DISABLE_FACILITY,
1453 &req, sizeof(struct treq_sim_disable_facility));
1458 static gboolean on_sim_enable_facility(TelephonySim *sim, GDBusMethodInvocation *invocation,
1460 const gchar *password,
1463 struct custom_data *ctx = user_data;
1464 struct treq_sim_enable_facility req;
1465 CoreObject *co_sim = NULL;
1466 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1468 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1471 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1472 DBUS_SIM_CHECK_SIM_STATUS(invocation, ENABLE_FACILITY, co_sim);
1473 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Enable Facility");
1475 memset(&req, 0x0, sizeof(struct treq_sim_enable_facility));
1477 dbg("[%s] facility_type: [%d]", GET_CP_NAME(invocation), facility_type);
1478 switch (facility_type) {
1480 req.type = SIM_FACILITY_PS;
1484 req.type = SIM_FACILITY_SC;
1488 req.type = SIM_FACILITY_FD;
1492 req.type = SIM_FACILITY_PN;
1496 req.type = SIM_FACILITY_PU;
1500 req.type = SIM_FACILITY_PP;
1504 req.type = SIM_FACILITY_PC;
1508 err("Unhandled/Unknown Facility type: [0x%x]", facility_type);
1510 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
1515 req.password_length = strlen(password);
1516 memcpy(req.password, password, req.password_length);
1518 dbg("[%s] Facility - type: [0x%02x] Passowrd len: [%d]",
1519 GET_CP_NAME(invocation),
1520 req.type, req.password_length);
1522 /* Dispatch request */
1523 dtapi_dispatch_request(ctx, sim, invocation,
1524 TREQ_SIM_ENABLE_FACILITY,
1525 &req, sizeof(struct treq_sim_enable_facility));
1530 static gboolean on_sim_get_facility(TelephonySim *sim,
1531 GDBusMethodInvocation *invocation,
1532 gint facility_type, gpointer user_data)
1534 struct custom_data *ctx = user_data;
1535 struct treq_sim_get_facility_status req;
1536 CoreObject *co_sim = NULL;
1537 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1539 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1542 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1543 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_FACILITY, co_sim);
1544 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Facility");
1546 memset(&req, 0x0, sizeof(struct treq_sim_get_facility_status));
1548 dbg("[%s] facility_type: [%d]", GET_CP_NAME(invocation), facility_type);
1550 switch (facility_type) {
1552 req.type = SIM_FACILITY_PS;
1556 req.type = SIM_FACILITY_SC;
1560 req.type = SIM_FACILITY_FD;
1564 req.type = SIM_FACILITY_PN;
1568 req.type = SIM_FACILITY_PU;
1572 req.type = SIM_FACILITY_PP;
1576 req.type = SIM_FACILITY_PC;
1580 err("Unhandled/Unknown Facility type: [0x%x]", facility_type);
1582 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
1587 /* Dispatch request */
1588 dtapi_dispatch_request(ctx, sim, invocation,
1589 TREQ_SIM_GET_FACILITY_STATUS,
1590 &req, sizeof(struct treq_sim_get_facility_status));
1595 static gboolean on_sim_get_lock_info(TelephonySim *sim,
1596 GDBusMethodInvocation *invocation,
1597 gint facility_type, gpointer user_data)
1599 struct custom_data *ctx = user_data;
1600 CoreObject *co_sim = NULL;
1601 struct treq_sim_get_lock_info req;
1602 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1604 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1607 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1608 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_LOCK_INFO, co_sim);
1609 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Lock Info");
1611 memset(&req, 0x0, sizeof(struct treq_sim_get_lock_info));
1613 dbg("[%s] facility_type: [%d]", GET_CP_NAME(invocation), facility_type);
1614 switch (facility_type) {
1616 req.type = SIM_FACILITY_PS;
1620 req.type = SIM_FACILITY_SC;
1624 req.type = SIM_FACILITY_FD;
1628 req.type = SIM_FACILITY_PN;
1632 req.type = SIM_FACILITY_PU;
1636 req.type = SIM_FACILITY_PP;
1640 req.type = SIM_FACILITY_PC;
1644 err("Unhandled/Unknown Facility type: [0x%x]", facility_type);
1646 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
1651 /* Dispatch request */
1652 dtapi_dispatch_request(ctx, sim, invocation,
1653 TREQ_SIM_GET_LOCK_INFO,
1654 &req, sizeof(struct treq_sim_get_lock_info));
1659 static gboolean on_sim_transfer_apdu(TelephonySim *sim,
1660 GDBusMethodInvocation *invocation,
1661 GVariant *apdu, gpointer user_data)
1663 struct custom_data *ctx = user_data;
1664 struct treq_sim_transmit_apdu req;
1665 GVariantIter *iter = NULL;
1666 GVariant *inner_gv = NULL;
1668 CoreObject *co_sim = NULL;
1670 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1672 if (!check_access_control(p_cynara, invocation, AC_SIM, "x"))
1675 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1676 DBUS_SIM_CHECK_SIM_STATUS(invocation, TRANSFER_APDU, co_sim);
1677 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Transfer APDU");
1679 memset(&req, 0x0, sizeof(struct treq_sim_transmit_apdu));
1681 inner_gv = g_variant_get_variant(apdu);
1683 g_variant_get(inner_gv, "ay", &iter);
1684 while (g_variant_iter_loop(iter, "y", &rt_i)) {
1688 req.apdu_length = (unsigned int)i;
1689 g_variant_iter_free(iter);
1690 g_variant_unref(inner_gv);
1691 g_variant_unref(apdu);
1693 tcore_util_hex_dump("[APDU_REQ] ", req.apdu_length, req.apdu);
1695 /* Dispatch request */
1696 dtapi_dispatch_request(ctx, sim, invocation,
1697 TREQ_SIM_TRANSMIT_APDU,
1698 &req, sizeof(struct treq_sim_transmit_apdu));
1703 static gboolean on_sim_get_atr(TelephonySim *sim,
1704 GDBusMethodInvocation *invocation, gpointer user_data)
1706 struct custom_data *ctx = user_data;
1707 CoreObject *co_sim = NULL;
1708 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1710 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1713 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1714 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_ATR, co_sim);
1715 DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get ATR");
1717 /* Dispatch request */
1718 dtapi_dispatch_request(ctx, sim, invocation,
1725 static gboolean on_sim_get_fields(TelephonySim *sim,
1726 GDBusMethodInvocation *invocation, gpointer user_data)
1728 struct custom_data *ctx = user_data;
1729 struct tel_sim_imsi *n_imsi = NULL;
1730 CoreObject *co_sim = NULL;
1732 GVariant *gv_fields = NULL;
1733 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1735 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1738 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1740 g_variant_builder_init(&b, G_VARIANT_TYPE("a{svv}}"));
1742 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_IMSI, co_sim);
1744 n_imsi = tcore_sim_get_imsi(co_sim);
1745 if (n_imsi != NULL) {
1746 g_variant_builder_add(&b, "{svv}", "imsi",
1747 g_variant_new_string("plmn"),
1748 g_variant_new_string(n_imsi->plmn));
1749 g_variant_builder_add(&b, "{svv}", "imsi",
1750 g_variant_new_string("msin"),
1751 g_variant_new_string(n_imsi->msin));
1755 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_ICCID, co_sim);
1756 g_variant_builder_add(&b, "{svv}", "iccid",
1757 g_variant_new_string(""), g_variant_new_string(""));
1759 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_MSISDN, co_sim);
1760 g_variant_builder_add(&b, "{svv}", "msisdn",
1761 g_variant_new_string("name"), g_variant_new_string("number"));
1763 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_SPN, co_sim);
1764 g_variant_builder_add(&b, "{svv}", "spn",
1765 g_variant_new_uint16(255), g_variant_new_string("network name"));
1767 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_INIT_STATUS, co_sim);
1768 g_variant_builder_add(&b, "{svv}", "init_status",
1769 g_variant_new_uint16(0), g_variant_new_boolean(TRUE));
1771 gv_fields = g_variant_builder_end(&b);
1773 telephony_sim_complete_get_fields(sim,
1774 invocation, 0, gv_fields);
1779 static gboolean on_sim_set_power_state(TelephonySim *sim,
1780 GDBusMethodInvocation *invocation, gint state, gpointer user_data)
1782 struct custom_data *ctx = user_data;
1783 CoreObject *co_sim = NULL;
1784 struct treq_sim_set_powerstate req;
1785 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1787 if (!check_access_control(p_cynara, invocation, AC_SIM, "w"))
1790 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1791 DBUS_SIM_CHECK_SIM_STATUS(invocation, SET_POWERSTATE, co_sim);
1793 memset(&req, 0x0, sizeof(struct treq_sim_set_powerstate));
1797 dbg("[%s] SIM Power state: [%d]",
1798 GET_CP_NAME(invocation), req.state);
1800 /* Dispatch request */
1801 dtapi_dispatch_request(ctx, sim, invocation,
1802 TREQ_SIM_SET_POWERSTATE,
1803 &req, sizeof(struct treq_sim_set_powerstate));
1808 static gboolean on_sim_get_impi(TelephonySim *sim,
1809 GDBusMethodInvocation *invocation, gpointer user_data)
1811 struct custom_data *ctx = user_data;
1812 CoreObject *co_sim = NULL;
1813 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1815 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1818 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1819 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_IMPI, co_sim);
1821 /* Dispatch request */
1822 dtapi_dispatch_request(ctx, sim, invocation,
1829 static gboolean on_sim_get_impu(TelephonySim *sim,
1830 GDBusMethodInvocation *invocation, gpointer user_data)
1832 struct custom_data *ctx = user_data;
1833 CoreObject *co_sim = NULL;
1834 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1836 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1839 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1840 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_IMPU, co_sim);
1842 /* Dispatch request */
1843 dtapi_dispatch_request(ctx, sim, invocation,
1850 static gboolean on_sim_get_domain(TelephonySim *sim,
1851 GDBusMethodInvocation *invocation, gpointer user_data)
1853 struct custom_data *ctx = user_data;
1854 CoreObject *co_sim = NULL;
1855 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1857 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1860 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1861 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_DOMAIN, co_sim);
1863 /* Dispatch request */
1864 dtapi_dispatch_request(ctx, sim, invocation,
1865 TREQ_SIM_GET_DOMAIN,
1871 static gboolean on_sim_get_pcscf(TelephonySim *sim,
1872 GDBusMethodInvocation *invocation, gpointer user_data)
1874 struct custom_data *ctx = user_data;
1875 CoreObject *co_sim = NULL;
1876 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1878 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1881 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1882 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_PCSCF, co_sim);
1884 /* Dispatch request */
1885 dtapi_dispatch_request(ctx, sim, invocation,
1892 static gboolean on_sim_get_app_list(TelephonySim *sim,
1893 GDBusMethodInvocation *invocation, gpointer user_data)
1895 struct custom_data *ctx = user_data;
1896 CoreObject *co_sim = NULL;
1897 unsigned char app_list = 0;
1898 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1900 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1903 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1904 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_APP_LIST, co_sim);
1906 app_list = tcore_sim_get_app_list(co_sim);
1908 telephony_sim_complete_get_app_list(sim,
1909 invocation, app_list);
1914 static gboolean on_sim_get_isim_service_table(TelephonySim *sim,
1915 GDBusMethodInvocation *invocation, gpointer user_data)
1917 struct custom_data *ctx = user_data;
1918 struct tel_sim_ist *ist = NULL;
1919 CoreObject *co_sim = NULL;
1920 cynara *p_cynara = (ctx) ? ctx->p_cynara : NULL;
1922 if (!check_access_control(p_cynara, invocation, AC_SIM, "r"))
1925 DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server);
1926 DBUS_SIM_CHECK_SIM_STATUS(invocation, GET_ISIM_SERVICE_TABLE, co_sim);
1928 ist = tcore_sim_get_isim_service_table(co_sim);
1930 GVariantBuilder builder;
1931 GVariant *ist_gv = NULL;
1932 GVariant *inner_gv = NULL;
1935 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
1936 for (i = 0; i < SIM_IST_SERVICE_CNT_MAX; i++)
1937 g_variant_builder_add(&builder, "y", ist->service[i]);
1938 inner_gv = g_variant_builder_end(&builder);
1939 ist_gv = g_variant_new("v", inner_gv);
1941 telephony_sim_complete_get_isim_service_table(sim, invocation,
1942 SIM_ACCESS_SUCCESS, ist_gv);
1946 /* Dispatch request */
1947 dtapi_dispatch_request(ctx, sim, invocation,
1948 TREQ_SIM_GET_ISIM_SERVICE_TABLE,
1955 gboolean dbus_plugin_setup_sim_interface(TelephonyObjectSkeleton *object,
1956 struct custom_data *ctx)
1960 sim = telephony_sim_skeleton_new();
1961 telephony_object_skeleton_set_sim(object, sim);
1962 g_object_unref(sim);
1964 dbg("sim = %p", sim);
1967 * Register signal handlers for SIM interface
1969 g_signal_connect(sim,
1970 "handle-get-init-status",
1971 G_CALLBACK(on_sim_get_init_status), ctx);
1973 g_signal_connect(sim,
1974 "handle-get-card-type",
1975 G_CALLBACK(on_sim_get_card_type), ctx);
1977 g_signal_connect(sim,
1979 G_CALLBACK(on_sim_get_imsi), ctx);
1981 g_signal_connect(sim,
1983 G_CALLBACK(on_sim_get_ecc), ctx);
1985 g_signal_connect(sim,
1987 G_CALLBACK(on_sim_get_iccid), ctx);
1989 g_signal_connect(sim,
1990 "handle-get-language",
1991 G_CALLBACK(on_sim_get_language), ctx);
1993 g_signal_connect(sim,
1994 "handle-set-language",
1995 G_CALLBACK(on_sim_set_language), ctx);
1997 g_signal_connect(sim,
1998 "handle-get-call-forwarding",
1999 G_CALLBACK(on_sim_get_call_forwarding), ctx);
2001 g_signal_connect(sim,
2002 "handle-set-call-forwarding",
2003 G_CALLBACK(on_sim_set_call_forwarding), ctx);
2005 g_signal_connect(sim,
2006 "handle-get-message-waiting",
2007 G_CALLBACK(on_sim_get_message_waiting), ctx);
2009 g_signal_connect(sim,
2010 "handle-set-message-waiting",
2011 G_CALLBACK(on_sim_set_message_waiting), ctx);
2013 g_signal_connect(sim,
2014 "handle-get-mailbox",
2015 G_CALLBACK(on_sim_get_mailbox), ctx);
2017 g_signal_connect(sim,
2018 "handle-set-mailbox",
2019 G_CALLBACK(on_sim_set_mailbox), ctx);
2021 g_signal_connect(sim,
2022 "handle-get-cphsinfo",
2023 G_CALLBACK(on_sim_get_cphsinfo), ctx);
2025 g_signal_connect(sim,
2026 "handle-get-service-table",
2027 G_CALLBACK(on_sim_get_service_table), ctx);
2029 g_signal_connect(sim,
2030 "handle-get-msisdn",
2031 G_CALLBACK(on_sim_get_msisdn), ctx);
2033 g_signal_connect(sim,
2034 "handle-get-oplmnwact",
2035 G_CALLBACK(on_sim_get_oplmnwact), ctx);
2037 g_signal_connect(sim,
2039 G_CALLBACK(on_sim_get_spn), ctx);
2041 g_signal_connect(sim,
2042 "handle-get-cphs-net-name",
2043 G_CALLBACK(on_sim_get_cphs_netname), ctx);
2045 g_signal_connect(sim,
2047 G_CALLBACK(on_sim_get_gid), ctx);
2049 g_signal_connect(sim,
2050 "handle-authentication",
2051 G_CALLBACK(on_sim_authentication), ctx);
2053 g_signal_connect(sim,
2054 "handle-verify-sec",
2055 G_CALLBACK(on_sim_verify_sec), ctx);
2057 g_signal_connect(sim,
2058 "handle-verify-puk",
2059 G_CALLBACK(on_sim_verify_puk), ctx);
2061 g_signal_connect(sim,
2062 "handle-change-pin",
2063 G_CALLBACK(on_sim_change_pin), ctx);
2065 g_signal_connect(sim,
2066 "handle-disable-facility",
2067 G_CALLBACK(on_sim_disable_facility), ctx);
2069 g_signal_connect(sim,
2070 "handle-enable-facility",
2071 G_CALLBACK(on_sim_enable_facility), ctx);
2073 g_signal_connect(sim,
2074 "handle-get-facility",
2075 G_CALLBACK(on_sim_get_facility), ctx);
2077 g_signal_connect(sim,
2078 "handle-get-lock-info",
2079 G_CALLBACK(on_sim_get_lock_info), ctx);
2081 g_signal_connect(sim,
2082 "handle-transfer-apdu",
2083 G_CALLBACK(on_sim_transfer_apdu), ctx);
2085 g_signal_connect(sim,
2087 G_CALLBACK(on_sim_get_atr), ctx);
2089 g_signal_connect(sim,
2090 "handle-get-fields",
2091 G_CALLBACK(on_sim_get_fields), ctx);
2093 g_signal_connect(sim,
2094 "handle-set-powerstate",
2095 G_CALLBACK(on_sim_set_power_state), ctx);
2097 g_signal_connect(sim,
2099 G_CALLBACK(on_sim_get_impi), ctx);
2101 g_signal_connect(sim,
2103 G_CALLBACK(on_sim_get_impu), ctx);
2105 g_signal_connect(sim,
2106 "handle-get-domain",
2107 G_CALLBACK(on_sim_get_domain), ctx);
2109 g_signal_connect(sim,
2111 G_CALLBACK(on_sim_get_pcscf), ctx);
2113 g_signal_connect(sim,
2114 "handle-get-app-list",
2115 G_CALLBACK(on_sim_get_app_list), ctx);
2117 g_signal_connect(sim,
2118 "handle-get-isim-service-table",
2119 G_CALLBACK(on_sim_get_isim_service_table), ctx);
2122 * Initialize DBUS property
2124 telephony_sim_set_cf_state(sim, FALSE);
2129 gboolean dbus_plugin_sim_response(struct custom_data *ctx,
2130 UserRequest *ur, struct dbus_request_info *dbus_info,
2131 enum tcore_response_command command, unsigned int data_len, const void *data)
2133 char *cpname = dbus_info ? GET_CP_NAME(dbus_info->invocation) : "";
2136 case TRESP_SIM_GET_ECC: {
2137 const struct tresp_sim_read *resp_read = data;
2138 CoreObject *co_sim = NULL;
2139 GVariant *gv = NULL;
2143 dbg("[%s] SIM_GET_ECC - Result: [%s])", cpname,
2144 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2146 co_sim = __get_sim_co_from_ur(ctx->server, ur);
2148 err("SIM Core object is NULL");
2152 if (resp_read->result == SIM_ACCESS_SUCCESS)
2153 tcore_sim_set_ecc_list(co_sim, &resp_read->data.ecc);
2154 else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND)
2155 tcore_sim_set_ecc_list(co_sim, NULL);
2157 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2158 for (i = 0; i < resp_read->data.ecc.ecc_count; i++) {
2159 dbg("[%s] ecc[%d] : ecc_category=[0x%x], ecc_num=[%s], " \
2160 "ecc_string=[%s]", cpname, i,
2161 resp_read->data.ecc.ecc[i].ecc_category,
2162 resp_read->data.ecc.ecc[i].ecc_num,
2163 resp_read->data.ecc.ecc[i].ecc_string);
2165 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
2166 g_variant_builder_add(&b, "{sv}", "category",
2167 g_variant_new_int32(resp_read->data.ecc.ecc[i].ecc_category));
2168 g_variant_builder_add(&b, "{sv}", "number",
2169 g_variant_new_string(resp_read->data.ecc.ecc[i].ecc_num));
2170 g_variant_builder_add(&b, "{sv}", "name",
2171 g_variant_new_string(resp_read->data.ecc.ecc[i].ecc_string));
2172 g_variant_builder_close(&b);
2174 gv = g_variant_builder_end(&b);
2176 telephony_sim_complete_get_ecc(dbus_info->interface_object,
2177 dbus_info->invocation, gv);
2181 case TRESP_SIM_GET_ICCID: {
2182 const struct tresp_sim_read *resp_read = data;
2183 CoreObject *co_sim = NULL;
2185 dbg("[%s] SIM_GET_ICCID - Result: [%s] ICCID: [%s])", cpname,
2186 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"),
2187 resp_read->data.iccid.iccid);
2189 co_sim = __get_sim_co_from_ur(ctx->server, ur);
2191 err("SIM Core object is NULL");
2195 if (resp_read->result == SIM_ACCESS_SUCCESS)
2196 tcore_sim_set_iccid(co_sim, &resp_read->data.iccid);
2197 else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND)
2198 tcore_sim_set_iccid(co_sim, NULL);
2200 telephony_sim_complete_get_iccid(dbus_info->interface_object,
2201 dbus_info->invocation, resp_read->result,
2202 resp_read->data.iccid.iccid);
2206 case TRESP_SIM_GET_LANGUAGE: {
2207 const struct tresp_sim_read *resp_read = data;
2209 dbg("[%s] SIM_GET_LANGUAGE - Result: [%s] Language: [0x%2x]", cpname,
2210 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"),
2211 resp_read->data.language.language[0]);
2213 telephony_sim_complete_get_language(dbus_info->interface_object,
2214 dbus_info->invocation, resp_read->result,
2215 resp_read->data.language.language[0]);
2219 case TRESP_SIM_SET_LANGUAGE: {
2220 const struct tresp_sim_set_data *resp_set_data = data;
2222 dbg("[%s] SIM_SET_LANGUAGE - Result: [%s]", cpname,
2223 (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2225 telephony_sim_complete_set_language(dbus_info->interface_object,
2226 dbus_info->invocation, resp_set_data->result);
2230 case TRESP_SIM_GET_CALLFORWARDING: {
2231 const struct tresp_sim_read *resp_read = data;
2232 GVariant *gv_cf = NULL;
2233 GVariant *gv_cphs_cf = NULL;
2236 dbg("[%s] SIM_GET_CALLFORWARDING - Result: [%s] CPHS: [%s]",
2237 cpname, (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"),
2238 (resp_read->data.cf.b_cphs ? "Yes" : "No"));
2240 if (resp_read->data.cf.b_cphs) {
2241 dbg("[%s] b_line1[%d], b_line2[%d], b_fax[%d], b_data[%d]",
2242 cpname, resp_read->data.cf.cphs_cf.b_line1,
2243 resp_read->data.cf.cphs_cf.b_line2,
2244 resp_read->data.cf.cphs_cf.b_fax,
2245 resp_read->data.cf.cphs_cf.b_data);
2247 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
2248 g_variant_builder_add(&b, "{sv}", "b_line1",
2249 g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_line1));
2250 g_variant_builder_add(&b, "{sv}", "b_line2",
2251 g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_line2));
2252 g_variant_builder_add(&b, "{sv}", "b_fax",
2253 g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_fax));
2254 g_variant_builder_add(&b, "{sv}", "b_data",
2255 g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_data));
2256 gv_cphs_cf = g_variant_builder_end(&b);
2258 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2259 gv_cf = g_variant_builder_end(&b);
2264 dbg("[%s] Profile count: [%d]", cpname, resp_read->data.cf.cf_list.profile_count);
2266 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2267 for (i = 0; i < resp_read->data.cf.cf_list.profile_count; i++) {
2268 dbg("[%s] [%d] : rec_index[0x%x], msp_num[0x%x], " \
2269 "cfu_status[0x%x], cfu_num[%s], ton[0x%x], " \
2270 "npi[0x%x], cc2_id[0x%x], ext7_id[0x%x]", cpname, i,
2271 resp_read->data.cf.cf_list.cf[i].rec_index,
2272 resp_read->data.cf.cf_list.cf[i].msp_num,
2273 resp_read->data.cf.cf_list.cf[i].cfu_status,
2274 resp_read->data.cf.cf_list.cf[i].cfu_num,
2275 resp_read->data.cf.cf_list.cf[i].ton,
2276 resp_read->data.cf.cf_list.cf[i].npi,
2277 resp_read->data.cf.cf_list.cf[i].cc2_id,
2278 resp_read->data.cf.cf_list.cf[i].ext7_id);
2280 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
2281 g_variant_builder_add(&b, "{sv}", "rec_index",
2282 g_variant_new_int32(resp_read->data.cf.cf_list.cf[i].rec_index));
2283 g_variant_builder_add(&b, "{sv}", "msp_num",
2284 g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].msp_num));
2285 g_variant_builder_add(&b, "{sv}", "cfu_status",
2286 g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].cfu_status));
2287 g_variant_builder_add(&b, "{sv}", "cfu_num",
2288 g_variant_new_string(resp_read->data.cf.cf_list.cf[i].cfu_num));
2289 g_variant_builder_add(&b, "{sv}", "ton",
2290 g_variant_new_int32(resp_read->data.cf.cf_list.cf[i].ton));
2291 g_variant_builder_add(&b, "{sv}", "npi",
2292 g_variant_new_int32(resp_read->data.cf.cf_list.cf[i].npi));
2293 g_variant_builder_add(&b, "{sv}", "cc2_id",
2294 g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].cc2_id));
2295 g_variant_builder_add(&b, "{sv}", "ext7_id",
2296 g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].ext7_id));
2297 g_variant_builder_close(&b);
2299 gv_cf = g_variant_builder_end(&b);
2301 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
2302 gv_cphs_cf = g_variant_builder_end(&b);
2305 telephony_sim_complete_get_call_forwarding(dbus_info->interface_object,
2306 dbus_info->invocation, resp_read->result,
2307 resp_read->data.cf.b_cphs, gv_cf, gv_cphs_cf);
2311 case TRESP_SIM_SET_CALLFORWARDING: {
2312 const struct tresp_sim_set_data *resp_set_data = data;
2314 dbg("[%s] SIM_SET_CALLFORWARDING - Result: [%s]", cpname,
2315 (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2317 telephony_sim_complete_set_call_forwarding(dbus_info->interface_object,
2318 dbus_info->invocation, resp_set_data->result);
2322 case TRESP_SIM_GET_MESSAGEWAITING: {
2323 const struct tresp_sim_read *resp_read = data;
2324 GVariant *gv_mw = NULL;
2325 GVariant *gv_cphs_mw = NULL;
2328 dbg("[%s] SIM_GET_MESSAGEWAITING - Result: [%s] CPHS: [%s]",
2329 cpname, (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"),
2330 (resp_read->data.mw.b_cphs ? "Yes" : "No"));
2332 if (resp_read->data.mw.b_cphs) {
2333 dbg("[%s] b_voice1[%d], b_voice2[%d], b_fax[%d], b_data[%d]",
2334 cpname, resp_read->data.mw.cphs_mw.b_voice1,
2335 resp_read->data.mw.cphs_mw.b_voice2,
2336 resp_read->data.mw.cphs_mw.b_fax,
2337 resp_read->data.mw.cphs_mw.b_data);
2339 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
2340 g_variant_builder_add(&b, "{sv}", "b_voice1",
2341 g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_voice1));
2342 g_variant_builder_add(&b, "{sv}", "b_voice2",
2343 g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_voice2));
2344 g_variant_builder_add(&b, "{sv}", "b_fax",
2345 g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_fax));
2346 g_variant_builder_add(&b, "{sv}", "b_data",
2347 g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_data));
2348 gv_cphs_mw = g_variant_builder_end(&b);
2350 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2351 gv_mw = g_variant_builder_end(&b);
2356 dbg("[%s] Profile count: [%d]", cpname,
2357 resp_read->data.mw.mw_list.profile_count);
2359 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2360 for (i = 0; i < resp_read->data.mw.mw_list.profile_count; i++) {
2361 dbg("[%s] mw[%d] : rec_index[0x%x], indicator_status[0x%x], " \
2362 "voice_count[0x%x], fax_count[0x%x] email_count[0x%x], " \
2363 "other_count[0x%x], video_count[0x%x]", cpname, i,
2364 resp_read->data.mw.mw_list.mw[i].rec_index,
2365 resp_read->data.mw.mw_list.mw[i].indicator_status,
2366 resp_read->data.mw.mw_list.mw[i].voice_count,
2367 resp_read->data.mw.mw_list.mw[i].fax_count,
2368 resp_read->data.mw.mw_list.mw[i].email_count,
2369 resp_read->data.mw.mw_list.mw[i].other_count,
2370 resp_read->data.mw.mw_list.mw[i].video_count);
2372 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
2373 g_variant_builder_add(&b, "{sv}", "rec_index",
2374 g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].rec_index));
2375 g_variant_builder_add(&b, "{sv}", "indicator_status",
2376 g_variant_new_byte(resp_read->data.mw.mw_list.mw[i].indicator_status));
2377 g_variant_builder_add(&b, "{sv}", "voice_count",
2378 g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].voice_count));
2379 g_variant_builder_add(&b, "{sv}", "fax_count",
2380 g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].fax_count));
2381 g_variant_builder_add(&b, "{sv}", "email_count",
2382 g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].email_count));
2383 g_variant_builder_add(&b, "{sv}", "other_count",
2384 g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].other_count));
2385 g_variant_builder_add(&b, "{sv}", "video_count",
2386 g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].video_count));
2387 g_variant_builder_close(&b);
2389 gv_mw = g_variant_builder_end(&b);
2390 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
2391 gv_cphs_mw = g_variant_builder_end(&b);
2394 telephony_sim_complete_get_message_waiting(dbus_info->interface_object,
2395 dbus_info->invocation, resp_read->result,
2396 resp_read->data.mw.b_cphs, gv_mw, gv_cphs_mw);
2400 case TRESP_SIM_SET_MESSAGEWAITING: {
2401 const struct tresp_sim_set_data *resp_set_data = data;
2403 dbg("[%s] SIM_SET_MESSAGEWAITING - Result: [%s]",
2404 cpname, (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2406 telephony_sim_complete_set_message_waiting(dbus_info->interface_object,
2407 dbus_info->invocation, resp_set_data->result);
2411 case TRESP_SIM_GET_MAILBOX: {
2412 const struct tresp_sim_read *resp_read = data;
2413 GVariant *gv = NULL;
2417 dbg("[%s] SIM_GET_MAILBOX - Result: [%s] CPHS: [%s] Count: [%d])",
2418 cpname, (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"),
2419 (resp_read->data.mb.b_cphs ? "Yes" : "No"),
2420 resp_read->data.mb.count);
2422 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2423 for (i = 0; i < resp_read->data.mb.count; i++) {
2424 dbg("[%s] mb[%d] : rec_index[%d], profile_number[%d], mb_type[%d], " \
2425 "alpha_id_max_len[%d]alpha_id[%s], ton[%d], npi[%d], num[%s], " \
2426 "cc_id[%d], ext1_id[%d]", cpname, i,
2427 resp_read->data.mb.mb[i].rec_index, resp_read->data.mb.mb[i].profile_number,
2428 resp_read->data.mb.mb[i].mb_type, resp_read->data.mb.mb[i].number_info.alpha_id_max_len,
2429 resp_read->data.mb.mb[i].number_info.alpha_id, resp_read->data.mb.mb[i].number_info.ton,
2430 resp_read->data.mb.mb[i].number_info.npi, resp_read->data.mb.mb[i].number_info.num,
2431 resp_read->data.mb.mb[i].number_info.cc_id, resp_read->data.mb.mb[i].number_info.ext1_id);
2433 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
2434 g_variant_builder_add(&b, "{sv}", "rec_index",
2435 g_variant_new_int32(resp_read->data.mb.mb[i].rec_index));
2436 g_variant_builder_add(&b, "{sv}", "profile_num",
2437 g_variant_new_int32(resp_read->data.mb.mb[i].profile_number));
2438 g_variant_builder_add(&b, "{sv}", "mb_type",
2439 g_variant_new_int32(resp_read->data.mb.mb[i].mb_type));
2440 g_variant_builder_add(&b, "{sv}", "alpha_id_max_len",
2441 g_variant_new_int32(resp_read->data.mb.mb[i].number_info.alpha_id_max_len));
2442 g_variant_builder_add(&b, "{sv}", "alpha_id",
2443 g_variant_new_string(resp_read->data.mb.mb[i].number_info.alpha_id));
2444 g_variant_builder_add(&b, "{sv}", "ton",
2445 g_variant_new_int32(resp_read->data.mb.mb[i].number_info.ton));
2446 g_variant_builder_add(&b, "{sv}", "npi",
2447 g_variant_new_int32(resp_read->data.mb.mb[i].number_info.npi));
2448 g_variant_builder_add(&b, "{sv}", "num",
2449 g_variant_new_string(resp_read->data.mb.mb[i].number_info.num));
2450 g_variant_builder_add(&b, "{sv}", "cc_id",
2451 g_variant_new_byte(resp_read->data.mb.mb[i].number_info.cc_id));
2452 g_variant_builder_add(&b, "{sv}", "ext1_id",
2453 g_variant_new_byte(resp_read->data.mb.mb[i].number_info.ext1_id));
2454 g_variant_builder_close(&b);
2457 gv = g_variant_builder_end(&b);
2459 telephony_sim_complete_get_mailbox(dbus_info->interface_object, dbus_info->invocation,
2460 resp_read->result, resp_read->data.mb.b_cphs, gv);
2464 case TRESP_SIM_SET_MAILBOX: {
2465 const struct tresp_sim_set_data *resp_set_data = data;
2467 dbg("[%s] SIM_SET_MAILBOX - Result: [%s]", cpname,
2468 (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2470 telephony_sim_complete_set_mailbox(dbus_info->interface_object,
2471 dbus_info->invocation, resp_set_data->result);
2475 case TRESP_SIM_GET_CPHS_INFO: {
2476 const struct tresp_sim_read *resp_read = data;
2478 dbg("[%s] SIM_GET_CPHS_INFO - Result: [%s]", cpname,
2479 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2481 telephony_sim_complete_get_cphsinfo(dbus_info->interface_object,
2482 dbus_info->invocation, resp_read->result,
2483 resp_read->data.cphs.CphsPhase,
2484 resp_read->data.cphs.CphsServiceTable.bOperatorNameShortForm,
2485 resp_read->data.cphs.CphsServiceTable.bMailBoxNumbers,
2486 resp_read->data.cphs.CphsServiceTable.bServiceStringTable,
2487 resp_read->data.cphs.CphsServiceTable.bCustomerServiceProfile,
2488 resp_read->data.cphs.CphsServiceTable.bInformationNumbers);
2492 case TRESP_SIM_GET_SERVICE_TABLE: {
2493 const struct tresp_sim_read *resp_read = data;
2494 CoreObject *co_sim = NULL;
2495 GVariantBuilder builder;
2496 GVariant * inner_gv = NULL;
2497 GVariant *svct_gv = NULL;
2500 dbg("[%s] SIM_GET_SERVICE_TABLE - Result: [%s]", cpname,
2501 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2503 co_sim = __get_sim_co_from_ur(ctx->server, ur);
2505 err("SIM Core object is NULL");
2509 if (resp_read->result == SIM_ACCESS_SUCCESS)
2510 tcore_sim_set_service_table(co_sim, &resp_read->data.svct);
2511 else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND)
2512 tcore_sim_set_service_table(co_sim, NULL);
2514 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
2515 if (resp_read->data.svct.sim_type == SIM_TYPE_GSM) {
2516 for (i = 0; i < SIM_SST_SERVICE_CNT_MAX; i++)
2517 g_variant_builder_add(&builder, "y",
2518 resp_read->data.svct.table.sst.service[i]);
2519 } else if (resp_read->data.svct.sim_type == SIM_TYPE_USIM) {
2520 for (i = 0; i < SIM_UST_SERVICE_CNT_MAX; i++)
2521 g_variant_builder_add(&builder, "y",
2522 resp_read->data.svct.table.ust.service[i]);
2523 } else if (resp_read->data.svct.sim_type == SIM_TYPE_RUIM) {
2524 if (SIM_CDMA_SVC_TABLE == resp_read->data.svct.table.cst.cdma_svc_table) {
2525 for (i = 0; i < SIM_CDMA_ST_SERVICE_CNT_MAX; i++) {
2526 g_variant_builder_add(&builder, "iy",
2527 resp_read->data.svct.table.cst.cdma_svc_table,
2528 resp_read->data.svct.table.cst.service.cdma_service[i]);
2530 } else if (SIM_CSIM_SVC_TABLE == resp_read->data.svct.table.cst.cdma_svc_table) {
2531 for (i = 0; i < SIM_CSIM_ST_SERVICE_CNT_MAX; i++) {
2532 g_variant_builder_add(&builder, "iy",
2533 resp_read->data.svct.table.cst.cdma_svc_table,
2534 resp_read->data.svct.table.cst.service.csim_service[i]);
2537 err("Invalid cdma_svc_table:[%d]", resp_read->data.svct.table.cst.cdma_svc_table);
2540 dbg("unknown sim type.");
2542 inner_gv = g_variant_builder_end(&builder);
2543 svct_gv = g_variant_new("v", inner_gv);
2545 telephony_sim_complete_get_service_table(dbus_info->interface_object,
2546 dbus_info->invocation, resp_read->result,
2547 resp_read->data.svct.sim_type, svct_gv);
2551 case TRESP_SIM_GET_SPN: {
2552 const struct tresp_sim_read *resp_read = data;
2553 CoreObject *co_sim = NULL;
2555 dbg("[%s] SIM_GET_SPN - Result: [%s] Display condition: [%d] SPN: [%s]",
2556 cpname, (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"),
2557 resp_read->data.spn.display_condition, (const gchar *)resp_read->data.spn.spn);
2559 co_sim = __get_sim_co_from_ur(ctx->server, ur);
2561 err("SIM Core object is NULL");
2565 if (resp_read->result == SIM_ACCESS_SUCCESS)
2566 tcore_sim_set_spn(co_sim, &resp_read->data.spn);
2567 else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND)
2568 tcore_sim_set_spn(co_sim, NULL);
2570 telephony_sim_complete_get_spn(dbus_info->interface_object,
2571 dbus_info->invocation, resp_read->result,
2572 resp_read->data.spn.display_condition,
2573 (const gchar *)resp_read->data.spn.spn);
2577 case TRESP_SIM_GET_CPHS_NETNAME: {
2578 const struct tresp_sim_read *resp_read = data;
2579 CoreObject *co_sim = NULL;
2581 dbg("[%s] SIM_GET_CPHS_NETNAME - Result: [%s]", cpname,
2582 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2584 co_sim = __get_sim_co_from_ur(ctx->server, ur);
2586 err("SIM Core object is NULL");
2590 if (resp_read->result == SIM_ACCESS_SUCCESS)
2591 tcore_sim_set_cphs_netname(co_sim, &resp_read->data.cphs_net);
2592 else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND)
2593 tcore_sim_set_cphs_netname(co_sim, NULL);
2595 telephony_sim_complete_get_cphs_net_name(dbus_info->interface_object,
2596 dbus_info->invocation, resp_read->result,
2597 (const gchar *)resp_read->data.cphs_net.full_name,
2598 (const gchar *)resp_read->data.cphs_net.short_name);
2602 case TRESP_SIM_GET_GID: {
2603 const struct tresp_sim_read *resp_read = data;
2604 GVariantBuilder builder;
2605 GVariant *inner_gv = NULL;
2606 GVariant *gid_gv = NULL;
2609 dbg("[%s] SIM_GET_GID - Result: [%s]", cpname,
2610 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2612 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
2613 for (i = 0; i < resp_read->data.gid.GroupIdentifierLen; i++)
2614 g_variant_builder_add(&builder, "y", resp_read->data.gid.szGroupIdentifier[i]);
2615 inner_gv = g_variant_builder_end(&builder);
2616 gid_gv = g_variant_new("v", inner_gv);
2618 telephony_sim_complete_get_gid(dbus_info->interface_object,
2619 dbus_info->invocation, resp_read->result,
2620 resp_read->data.gid.GroupIdentifierLen, gid_gv);
2624 case TRESP_SIM_GET_MSISDN:{
2625 const struct tresp_sim_read *resp_read = data;
2626 CoreObject *co_sim = NULL;
2627 GVariant *gv = NULL;
2631 dbg("[%s] SIM_GET_MSISDN - Result: [%s]", cpname,
2632 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2634 co_sim = __get_sim_co_from_ur(ctx->server, ur);
2636 err("SIM Core object is NULL");
2640 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2641 if (resp_read->result == SIM_ACCESS_SUCCESS)
2642 tcore_sim_set_msisdn_list(co_sim, &resp_read->data.msisdn_list);
2643 else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND)
2644 tcore_sim_set_msisdn_list(co_sim, NULL);
2646 for (i = 0; i < resp_read->data.msisdn_list.count; i++) {
2647 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
2648 g_variant_builder_add(&b, "{sv}", "name",
2649 g_variant_new_string((const gchar *)resp_read->data.msisdn_list.msisdn[i].name));
2650 if (resp_read->data.msisdn_list.msisdn[i].ton == SIM_TON_INTERNATIONAL) {
2651 unsigned char *tmp = (unsigned char *)calloc(SIM_MSISDN_NUMBER_LEN_MAX + 1, 1);
2655 strncpy((char *)tmp + 1,
2656 (const char*)resp_read->data.msisdn_list.msisdn[i].num,
2657 SIM_MSISDN_NUMBER_LEN_MAX - 1);
2658 tmp[SIM_MSISDN_NUMBER_LEN_MAX] = '\0';
2660 g_variant_builder_add(&b, "{sv}", "number",
2661 g_variant_new_string((const gchar *)tmp));
2664 dbg("Memory allocation failed");
2666 g_variant_builder_add(&b, "{sv}", "number",
2667 g_variant_new_string((const gchar *)resp_read->data.msisdn_list.msisdn[i].num));
2670 g_variant_builder_add(&b, "{sv}", "number",
2671 g_variant_new_string((const gchar *)resp_read->data.msisdn_list.msisdn[i].num));
2673 g_variant_builder_close(&b);
2675 gv = g_variant_builder_end(&b);
2677 telephony_sim_complete_get_msisdn(dbus_info->interface_object,
2678 dbus_info->invocation, resp_read->result, gv);
2682 case TRESP_SIM_GET_OPLMNWACT: {
2683 const struct tresp_sim_read *resp_read = data;
2684 GVariant *gv = NULL;
2688 dbg("[%s] SIM_GET_OPLMNWACT - Result: [%s]", cpname,
2689 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2691 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
2692 for (i = 0; i < resp_read->data.opwa.opwa_count; i++) {
2693 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
2694 g_variant_builder_add(&b, "{sv}", "plmn",
2695 g_variant_new_string((const gchar *)resp_read->data.opwa.opwa[i].plmn));
2696 g_variant_builder_add(&b, "{sv}", "b_umts",
2697 g_variant_new_boolean(resp_read->data.opwa.opwa[i].b_umts));
2698 g_variant_builder_add(&b, "{sv}", "b_gsm",
2699 g_variant_new_boolean(resp_read->data.opwa.opwa[i].b_gsm));
2700 g_variant_builder_close(&b);
2702 gv = g_variant_builder_end(&b);
2704 telephony_sim_complete_get_oplmnwact(dbus_info->interface_object,
2705 dbus_info->invocation, resp_read->result, gv);
2709 case TRESP_SIM_REQ_AUTHENTICATION: {
2710 const struct tresp_sim_req_authentication *resp_auth = data;
2711 GVariantBuilder builder;
2712 GVariant *ak = NULL;
2713 GVariant *cp = NULL;
2714 GVariant *it = NULL;
2715 GVariant *resp = NULL;
2716 GVariant *ak_gv = NULL;
2717 GVariant *cp_gv = NULL;
2718 GVariant *it_gv = NULL;
2719 GVariant *resp_gv = NULL;
2722 dbg("[%s] SIM_REQ_AUTHENTICATION - Result: [%s]", cpname,
2723 (resp_auth->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
2725 tcore_util_hex_dump("[AUTH_KEY] ",
2726 resp_auth->authentication_key_length, resp_auth->authentication_key);
2727 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
2728 for (i = 0; i < (int)resp_auth->authentication_key_length; i++)
2729 g_variant_builder_add(&builder, "y", resp_auth->authentication_key[i]);
2730 ak = g_variant_builder_end(&builder);
2731 ak_gv = g_variant_new("v", ak);
2733 tcore_util_hex_dump("[CIPHER_DATA] ",
2734 resp_auth->cipher_length, resp_auth->cipher_data);
2735 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
2736 for (i = 0; i < (int)resp_auth->cipher_length; i++)
2737 g_variant_builder_add(&builder, "y", resp_auth->cipher_data[i]);
2738 cp = g_variant_builder_end(&builder);
2739 cp_gv = g_variant_new("v", cp);
2741 tcore_util_hex_dump("[INTEGRITY_DATA] ",
2742 resp_auth->integrity_length, resp_auth->integrity_data);
2743 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
2744 for (i = 0; i < (int)resp_auth->integrity_length; i++)
2745 g_variant_builder_add(&builder, "y", resp_auth->integrity_data[i]);
2746 it = g_variant_builder_end(&builder);
2747 it_gv = g_variant_new("v", it);
2749 tcore_util_hex_dump("[RESP_DATA] ",
2750 resp_auth->resp_length, resp_auth->resp_data);
2751 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
2752 for (i = 0; i < (int)resp_auth->resp_length; i++)
2753 g_variant_builder_add(&builder, "y", resp_auth->resp_data[i]);
2754 resp = g_variant_builder_end(&builder);
2755 resp_gv = g_variant_new("v", resp);
2757 telephony_sim_complete_authentication(dbus_info->interface_object,
2758 dbus_info->invocation, resp_auth->result,
2759 resp_auth->auth_type, resp_auth->auth_result,
2760 ak_gv, cp_gv, it_gv, resp_gv);
2764 case TRESP_SIM_VERIFY_PINS: {
2765 const struct tresp_sim_verify_pins *resp_verify_pins = data;
2767 dbg("[%s] SIM_VERIFY_PINS - Result: [%s] PIN Type: [%d] Re-try count: [%d]",
2768 cpname, (resp_verify_pins->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2769 resp_verify_pins->pin_type, resp_verify_pins->retry_count);
2771 telephony_sim_complete_verify_sec(dbus_info->interface_object,
2772 dbus_info->invocation, resp_verify_pins->result,
2773 resp_verify_pins->pin_type, resp_verify_pins->retry_count);
2777 case TRESP_SIM_VERIFY_PUKS: {
2778 const struct tresp_sim_verify_puks *resp_verify_puks = data;
2780 dbg("[%s] SIM_VERIFY_PUKS - Result: [%s] PIN Type: [%d] Re-try count: [%d]",
2781 cpname, (resp_verify_puks->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2782 resp_verify_puks->pin_type, resp_verify_puks->retry_count);
2784 telephony_sim_complete_verify_puk(dbus_info->interface_object,
2785 dbus_info->invocation, resp_verify_puks->result,
2786 resp_verify_puks->pin_type, resp_verify_puks->retry_count);
2790 case TRESP_SIM_CHANGE_PINS: {
2791 const struct tresp_sim_change_pins *resp_change_pins = data;
2793 dbg("[%s] SIM_CHANGE_PINS - Result: [%s] PIN Type: [%d] Re-try count: [%d]",
2794 cpname, (resp_change_pins->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2795 resp_change_pins->pin_type, resp_change_pins->retry_count);
2797 telephony_sim_complete_change_pin(dbus_info->interface_object,
2798 dbus_info->invocation, resp_change_pins->result,
2799 resp_change_pins->pin_type, resp_change_pins->retry_count);
2803 case TRESP_SIM_DISABLE_FACILITY: {
2804 const struct tresp_sim_disable_facility *resp_dis_facility = data;
2807 dbg("[%s] SIM_DISABLE_FACILITY - Result: [%s] Type: [%d] Re-try count: [%d]",
2808 cpname, (resp_dis_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2809 resp_dis_facility->type, resp_dis_facility->retry_count);
2811 switch (resp_dis_facility->type) {
2812 case SIM_FACILITY_PS:
2816 case SIM_FACILITY_SC:
2820 case SIM_FACILITY_FD:
2824 case SIM_FACILITY_PN:
2828 case SIM_FACILITY_PU:
2832 case SIM_FACILITY_PP:
2836 case SIM_FACILITY_PC:
2841 err("Unhandled/Unknown Facility type: [0x%x]", resp_dis_facility->type);
2845 telephony_sim_complete_disable_facility(dbus_info->interface_object,
2846 dbus_info->invocation, resp_dis_facility->result,
2847 f_type, resp_dis_facility->retry_count);
2851 case TRESP_SIM_ENABLE_FACILITY: {
2852 const struct tresp_sim_enable_facility *resp_en_facility = data;
2855 dbg("[%s] SIM_ENABLE_FACILITY - Result: [%s] Type: [%d] Re-try count: [%d]",
2856 cpname, (resp_en_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2857 resp_en_facility->type, resp_en_facility->retry_count);
2859 switch (resp_en_facility->type) {
2860 case SIM_FACILITY_PS:
2864 case SIM_FACILITY_SC:
2868 case SIM_FACILITY_FD:
2872 case SIM_FACILITY_PN:
2876 case SIM_FACILITY_PU:
2880 case SIM_FACILITY_PP:
2884 case SIM_FACILITY_PC:
2889 err("Unhandled/Unknown Facility type: [0x%x]", resp_en_facility->type);
2893 telephony_sim_complete_enable_facility(dbus_info->interface_object,
2894 dbus_info->invocation, resp_en_facility->result,
2895 f_type, resp_en_facility->retry_count);
2899 case TRESP_SIM_GET_FACILITY_STATUS: {
2900 const struct tresp_sim_get_facility_status *resp_get_facility = data;
2903 dbg("[%s] SIM_GET_FACILITY_STATUS - Result: [%s] Type: [%d] Enable: [%s]",
2904 cpname, (resp_get_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2905 resp_get_facility->type,
2906 (resp_get_facility->b_enable ? "Yes" : "No"));
2908 switch (resp_get_facility->type) {
2909 case SIM_FACILITY_PS:
2913 case SIM_FACILITY_SC:
2917 case SIM_FACILITY_FD:
2921 case SIM_FACILITY_PN:
2925 case SIM_FACILITY_PU:
2929 case SIM_FACILITY_PP:
2933 case SIM_FACILITY_PC:
2938 err("Unhandled/Unknown Facility type: [0x%x]", resp_get_facility->type);
2942 telephony_sim_complete_get_facility(dbus_info->interface_object,
2943 dbus_info->invocation, resp_get_facility->result,
2944 f_type, resp_get_facility->b_enable);
2948 case TRESP_SIM_GET_LOCK_INFO: {
2949 const struct tresp_sim_get_lock_info *resp_lock = data;
2952 dbg("[%s] SIM_GET_LOCK_INFO - Result: [%s] Type: [%d] Re-try count: [%d]",
2953 cpname, (resp_lock->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"),
2954 resp_lock->type, resp_lock->retry_count);
2956 switch (resp_lock->type) {
2957 case SIM_FACILITY_PS:
2961 case SIM_FACILITY_SC:
2965 case SIM_FACILITY_FD:
2969 case SIM_FACILITY_PN:
2973 case SIM_FACILITY_PU:
2977 case SIM_FACILITY_PP:
2981 case SIM_FACILITY_PC:
2986 err("Unhandled/Unknown Lock type: [0x%x]", resp_lock->type);
2990 telephony_sim_complete_get_lock_info(dbus_info->interface_object,
2991 dbus_info->invocation, resp_lock->result,
2992 f_type, resp_lock->lock_status, resp_lock->retry_count);
2996 case TRESP_SIM_TRANSMIT_APDU: {
2997 const struct tresp_sim_transmit_apdu *resp_apdu = data;
2998 GVariantBuilder builder;
2999 GVariant * apdu_gv = NULL;
3000 GVariant *inner_gv = NULL;
3003 dbg("[%s] SIM_TRANSMIT_APDU - Result: [%s]", cpname,
3004 (resp_apdu->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3006 tcore_util_hex_dump("[APDU_RESP] ",
3007 resp_apdu->apdu_resp_length, resp_apdu->apdu_resp);
3009 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
3010 for (i = 0; i < (int)resp_apdu->apdu_resp_length; i++)
3011 g_variant_builder_add(&builder, "y", resp_apdu->apdu_resp[i]);
3012 inner_gv = g_variant_builder_end(&builder);
3013 apdu_gv = g_variant_new("v", inner_gv);
3015 telephony_sim_complete_transfer_apdu(dbus_info->interface_object,
3016 dbus_info->invocation, resp_apdu->result, apdu_gv);
3020 case TRESP_SIM_GET_ATR:{
3021 const struct tresp_sim_get_atr *resp_get_atr = data;
3022 GVariantBuilder builder;
3023 GVariant * atr_gv = NULL;
3024 GVariant *inner_gv = NULL;
3027 dbg("[%s] SIM_GET_ATR - Result: [%s]", cpname,
3028 (resp_get_atr->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3030 tcore_util_hex_dump("[ATR_RESP] ",
3031 resp_get_atr->atr_length, resp_get_atr->atr);
3033 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
3034 for (i = 0; i < (int)resp_get_atr->atr_length; i++)
3035 g_variant_builder_add(&builder, "y", resp_get_atr->atr[i]);
3036 inner_gv = g_variant_builder_end(&builder);
3037 atr_gv = g_variant_new("v", inner_gv);
3039 telephony_sim_complete_get_atr(dbus_info->interface_object,
3040 dbus_info->invocation, resp_get_atr->result, atr_gv);
3044 case TRESP_SIM_SET_POWERSTATE: {
3045 const struct tresp_sim_set_powerstate *resp_power = data;
3047 info("[%s] SIM_SET_POWERSTATE - Result: [%s]", cpname,
3048 (resp_power->result == SIM_POWER_SET_SUCCESS ? "Success" : "Fail"));
3050 telephony_sim_complete_set_powerstate(dbus_info->interface_object,
3051 dbus_info->invocation, resp_power->result);
3055 case TRESP_SIM_GET_IMPI: {
3056 const struct tresp_sim_read *resp_read = data;
3058 dbg("[%s] SIM_GET_IMPI - Result: [%s]", cpname,
3059 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3061 telephony_sim_complete_get_impi(dbus_info->interface_object,
3062 dbus_info->invocation, resp_read->result,
3063 resp_read->data.impi.impi);
3067 case TRESP_SIM_GET_IMPU: {
3068 const struct tresp_sim_read *resp_read = data;
3069 GVariant *gv = NULL;
3073 dbg("[%s] SIM_GET_IMPU - Result: [%s]", cpname,
3074 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3076 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
3077 for (i = 0; i < resp_read->data.impu_list.count; i++) {
3078 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
3079 g_variant_builder_add(&b, "{sv}", "impu",
3080 g_variant_new_string(resp_read->data.impu_list.impu[i].impu));
3081 g_variant_builder_close(&b);
3083 gv = g_variant_builder_end(&b);
3085 telephony_sim_complete_get_impu(dbus_info->interface_object,
3086 dbus_info->invocation, resp_read->result, gv);
3090 case TRESP_SIM_GET_DOMAIN: {
3091 const struct tresp_sim_read *resp_read = data;
3093 dbg("[%s] SIM_GET_DOMAIN - Result: [%s]", cpname,
3094 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3096 telephony_sim_complete_get_domain(dbus_info->interface_object,
3097 dbus_info->invocation, resp_read->result,
3098 resp_read->data.domain.domain);
3102 case TRESP_SIM_GET_PCSCF: {
3103 const struct tresp_sim_read *resp_read = data;
3104 GVariant *gv = NULL;
3108 dbg("[%s] SIM_GET_PCSCF - Result: [%s]", cpname,
3109 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3111 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
3112 for (i = 0; i < resp_read->data.pcscf_list.count; i++) {
3113 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
3114 g_variant_builder_add(&b, "{sv}", "type",
3115 g_variant_new_int32(resp_read->data.pcscf_list.pcscf[i].type));
3116 g_variant_builder_add(&b, "{sv}", "pcscf",
3117 g_variant_new_string(resp_read->data.pcscf_list.pcscf[i].pcscf));
3118 g_variant_builder_close(&b);
3120 gv = g_variant_builder_end(&b);
3122 telephony_sim_complete_get_pcscf(dbus_info->interface_object,
3123 dbus_info->invocation, resp_read->result, gv);
3127 case TRESP_SIM_GET_ISIM_SERVICE_TABLE: {
3128 const struct tresp_sim_read *resp_read = data;
3129 GVariantBuilder builder;
3130 GVariant *ist_gv = NULL;
3131 GVariant *inner_gv = NULL;
3134 dbg("[%s] SIM_GET_ISIM_SERVICE_TABLE - Result: [%s]", cpname,
3135 (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"));
3137 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
3138 for (i = 0; i < SIM_IST_SERVICE_CNT_MAX; i++)
3139 g_variant_builder_add(&builder, "y", resp_read->data.ist.service[i]);
3140 inner_gv = g_variant_builder_end(&builder);
3141 ist_gv = g_variant_new("v", inner_gv);
3143 telephony_sim_complete_get_isim_service_table(dbus_info->interface_object,
3144 dbus_info->invocation, resp_read->result, ist_gv);
3149 err("Unhandled/Unknown Response: [0x%x]", command);
3156 gboolean dbus_plugin_sim_notification(struct custom_data *ctx,
3157 CoreObject *source, TelephonyObjectSkeleton *object,
3158 enum tcore_notification_command command, unsigned int data_len, const void *data)
3161 const char *cp_name;
3162 enum dbus_tapi_sim_slot_id slot_id = SIM_SLOT_PRIMARY;
3164 cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
3166 sim = telephony_object_peek_sim(TELEPHONY_OBJECT(object));
3168 err("sim object is NULL!!!");
3173 case TNOTI_SIM_STATUS: {
3174 const struct tnoti_sim_status *n_sim_status = data;
3177 info("[%s] SIM_STATUS - [%d]", cp_name,
3178 n_sim_status->sim_status);
3180 #ifdef ENABLE_KPI_LOGS
3181 if (n_sim_status->sim_status == SIM_STATUS_INIT_COMPLETED)
3182 TIME_CHECK("[%s] SIM Initialized", cp_name);
3185 telephony_sim_emit_status(sim, n_sim_status->sim_status);
3187 slot_id = get_sim_slot_id_by_cp_name(cp_name);
3188 if (slot_id == SIM_SLOT_PRIMARY)
3189 ctx->sim1_status = n_sim_status->sim_status;
3190 else if (slot_id == SIM_SLOT_SECONDARY)
3191 ctx->sim2_status = n_sim_status->sim_status;
3193 warn("NOT handled Slot ID: [%d]", slot_id);
3195 if (__is_sim_status_valid(ctx->sim1_status))
3198 if (__is_sim_status_valid(ctx->sim2_status))
3201 if (ctx->valid_sim_count != count) {
3202 ctx->valid_sim_count = count;
3204 telephony_manager_emit_sim_inserted(ctx->mgr, count);
3209 case TNOTI_SIM_REFRESHED: {
3210 const struct tnoti_sim_refreshed *n_sim_refreshed = data;
3212 info("[%s] SIM_REFRESHED - b_full_file_changed: [%s] changed_file_count: [%d]",
3213 cp_name, (n_sim_refreshed->b_full_file_changed ? "YES" : "NO"),
3214 n_sim_refreshed->file_list.file_count);
3216 telephony_sim_emit_refreshed(sim, n_sim_refreshed->cmd_type);
3220 case TNOTI_SIM_CALL_FORWARD_STATE: {
3221 const struct tnoti_sim_call_forward_state *info = data;
3223 info("[%s] SIM_CALL_FORWARD_STATE - Call Forwarding: [%s]",
3224 cp_name, info->b_forward ? "ON" : "OFF");
3226 telephony_sim_set_cf_state(sim, info->b_forward);
3231 err("Unhandled/Unknown Notification: [0x%x]", command);