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.
32 #include <user_request.h>
33 #include <core_object.h>
35 #include <communicator.h>
36 #include <co_phonebook.h>
38 #include <TapiCommon.h>
41 #include "tel_cs_conn.h"
43 #include "ts_utility.h"
44 #include "ts_common.h"
45 #include "ts_svr_req.h"
50 static gboolean dbus_sim_data_request(struct custom_data *ctx, CoreObject *co, enum tel_sim_status sim_status )
52 UserRequest *ur = NULL;
53 TcorePlugin *plugin = NULL;
56 case SIM_STATUS_INITIALIZING :
57 case SIM_STATUS_PIN_REQUIRED :
58 case SIM_STATUS_PUK_REQUIRED :
59 case SIM_STATUS_CARD_BLOCKED :
60 case SIM_STATUS_NCK_REQUIRED :
61 case SIM_STATUS_NSCK_REQUIRED :
62 case SIM_STATUS_SPCK_REQUIRED :
63 case SIM_STATUS_CCK_REQUIRED :
64 case SIM_STATUS_LOCK_REQUIRED :
65 if(ctx->b_recv_first_status == FALSE){
66 dbg("received sim status at first time");
67 plugin = tcore_server_find_plugin(ctx->server, TCORE_PLUGIN_DEFAULT);
68 dbg("req - TREQ_SIM_GET_LANGUAGE ");
69 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
70 tcore_user_request_set_command(ur, TREQ_SIM_GET_LANGUAGE);
71 tcore_communicator_dispatch_request(ctx->comm, ur);
73 dbg("req - TREQ_SIM_GET_ICCID ");
74 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
75 tcore_user_request_set_command(ur, TREQ_SIM_GET_ICCID);
76 tcore_communicator_dispatch_request(ctx->comm, ur);
78 dbg("req - TREQ_SIM_GET_MSISDN ");
79 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
80 tcore_user_request_set_command(ur, TREQ_SIM_GET_MSISDN);
81 tcore_communicator_dispatch_request(ctx->comm, ur);
83 dbg("req - TREQ_SIM_GET_ECC ");
84 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
85 tcore_user_request_set_command(ur, TREQ_SIM_GET_ECC);
86 tcore_communicator_dispatch_request(ctx->comm, ur);
87 ctx->b_recv_first_status = TRUE;
97 static gboolean dbus_sim_security_request(struct custom_data *ctx, CoreObject *co)
99 UserRequest *ur = NULL;
100 TcorePlugin *plugin = NULL;
101 struct treq_sim_get_facility_status req_facility;
103 plugin = tcore_server_find_plugin(ctx->server, TCORE_PLUGIN_DEFAULT);
105 dbg("req - SIM_FACILITY_PS ");
106 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
107 req_facility.type = SIM_FACILITY_PS;
108 tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_facility_status), &req_facility);
109 tcore_user_request_set_command(ur, TREQ_SIM_GET_FACILITY_STATUS);
110 tcore_communicator_dispatch_request(ctx->comm, ur);
112 dbg("req - SIM_FACILITY_SC ");
113 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
114 req_facility.type = SIM_FACILITY_SC;
115 tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_facility_status), &req_facility);
116 tcore_user_request_set_command(ur, TREQ_SIM_GET_FACILITY_STATUS);
117 tcore_communicator_dispatch_request(ctx->comm, ur);
119 dbg("req - SIM_FACILITY_FD ");
120 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
121 req_facility.type = SIM_FACILITY_FD;
122 tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_facility_status), &req_facility);
123 tcore_user_request_set_command(ur, TREQ_SIM_GET_FACILITY_STATUS);
124 tcore_communicator_dispatch_request(ctx->comm, ur);
129 static gboolean dbus_sim_security_update(struct custom_data *ctx, enum tel_sim_facility_type type, enum tel_sim_pin_operation_result result, gboolean b_enable)
131 dbg("current ctx addr[0x%x], facility[%d], op result[%d], b_enable[%d]", ctx, type, result, b_enable);
133 case SIM_FACILITY_PS :
134 if(result == SIM_PUK_REQUIRED)
135 ctx->sim_lock = TAPI_SIM_PIN_STATUS_BLOCKED;
136 else if(result == SIM_CARD_ERROR)
137 ctx->sim_lock = TAPI_SIM_PIN_STATUS_PUK_BLOCKED;
138 else if(result == SIM_PIN_OPERATION_SUCCESS)
139 ctx->sim_lock = b_enable;
141 case SIM_FACILITY_SC :
142 if(result == SIM_PUK_REQUIRED)
143 ctx->pin_lock = TAPI_SIM_PIN_STATUS_BLOCKED;
144 else if(result == SIM_CARD_ERROR)
145 ctx->pin_lock = TAPI_SIM_PIN_STATUS_PUK_BLOCKED;
146 else if(result == SIM_PIN_OPERATION_SUCCESS)
147 ctx->pin_lock = b_enable;
149 case SIM_FACILITY_FD :
150 if( result == SIM_PIN_OPERATION_SUCCESS )
151 ctx->fdn_lock = b_enable;
159 void dbus_request_sim(struct custom_data *ctx, TcorePlugin *plugin, int tapi_service_function, GArray* in_param1,
160 GArray* in_param2, GArray* in_param3, GArray* in_param4, GArray** out_param1, GArray** out_param2,
161 GArray** out_param3, GArray** out_param4, GError** error)
163 int api_err = TAPI_API_SUCCESS;
165 tapi_dbus_connection_name conn_name;
167 * Legacy : SIM data, security part
169 TelSimCardStatus_t tmp_cardstatus = 0xff;
170 gboolean b_changed = FALSE;
171 TelSimImsiInfo_t imsi = { 0, };
172 TelSimIccIdInfo_t iccid_data = { 0, };
173 TelSimEccData_t ecc_data;
174 int fdn_status = FALSE;
175 TelSimLanguageInfo_t lang_data = { 0, };
176 TelSimCardType_t card_type = TAPI_SIM_CARD_TYPE_UNKNOWN;
177 enum tel_sim_type type = SIM_TYPE_UNKNOWN;
178 TelSimSecPw_t pin_data = { 0, };
179 TelSimSecPw_t puk_data = { 0, };
180 TelSimSecPw_t old_pin = { 0, };
181 TelSimSecPw_t new_pin = { 0, };
182 TelSimPinStatus_t status = 0;
183 TelSimPersPw_t pers_data = { 0, };
184 unsigned char* pin2 = NULL;
185 unsigned int pin2_len = 0;
186 TelSimApdu_t apdu_data = { 0, };
188 TelSimAuthenticationData_t AuthenticationData = {0,};
189 TelSimCphsLocalInfo_t cphs_local = {0,};
192 * NEW : SIM data, security part
194 struct tel_sim_imsi *n_imsi;
195 struct treq_sim_verify_pins verify_pins = { 0, };
196 struct treq_sim_verify_puks verify_puks = { 0, };
197 struct treq_sim_change_pins change_pins = { 0, };
198 struct treq_sim_get_facility_status facility = { 0, };
199 struct treq_sim_disable_facility dis_facility = { 0, };
200 struct treq_sim_enable_facility en_facility = { 0, };
201 struct treq_sim_transmit_apdu send_apdu = { 0, };
202 struct treq_sim_set_language set_language = { 0, };
203 struct treq_sim_req_authentication req_auth = { 0, };
205 * Legacy : SIM Phonebook part
207 TelSimPbFileType_t lsp_pb_type = TAPI_SIM_PB_ADN; //default value
208 unsigned short lsp_index = 0;
209 int lsp_first_index = 0;
210 int lsp_init_completed = 0;
211 TelSimPbList_t lsp_supported_pb_list = { 0, };
213 * New : SIM Phonebook part
215 struct tel_phonebook_support_list *pb_list = NULL;
216 struct treq_phonebook_get_count pb_count;
217 struct treq_phonebook_get_info pb_info;
218 struct treq_phonebook_get_usim_info pb_usim;
219 struct treq_phonebook_read_record pb_read;
220 struct treq_phonebook_update_record pb_update;
221 struct treq_phonebook_delete_record pb_delete;
224 * Legacy : SIM SAP part
226 TelSimSapConnect_t lsa_conn_req = { 0, };
227 TelSimSapApduData_t lsa_apdu_data = { 0, };
228 TelSimSapProtocol_t lsa_protocol = TAPI_SIM_SAP_PROTOCOL_T0;
229 TelSimSapMsgId_t lsa_msg_id = 0x00;
233 struct treq_sap_req_connect req_conn;
234 struct treq_sap_req_status req_status;
235 struct treq_sap_req_atr req_atr;
236 struct treq_sap_transfer_apdu t_apdu;
237 struct treq_sap_set_protocol set_protocol;
238 struct treq_sap_set_power set_power;
241 GSList *co_list = NULL;
242 CoreObject *co_sim = NULL;
243 CoreObject *co_pb = NULL;
244 UserRequest *ur = NULL;
245 struct tcore_user_info ui = { 0, 0, 0, NULL };
247 conn_name = g_array_index(in_param4, tapi_dbus_connection_name, 0);
249 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_SIM);
251 api_err = TAPI_API_NOT_SUPPORTED;
254 co_sim = (CoreObject *)co_list->data;
255 g_slist_free(co_list);
258 api_err = TAPI_API_NOT_SUPPORTED;
262 ur = tcore_user_request_new(ctx->comm, tcore_plugin_get_description(plugin)->name);
264 api_err = TAPI_API_SERVER_FAILURE;
268 ui.appname = conn_name.name;
269 tcore_user_request_set_user_info(ur, &ui);
271 switch (tapi_service_function) {
272 case TAPI_CS_SIM_GETIMSIINFO:
273 dbg("TAPI_CS_SIM_GETIMSIINFO");
274 n_imsi = tcore_sim_get_imsi(co_sim);
275 dbg("n_imsi->plmn[%s]", n_imsi->plmn);
276 if (n_imsi != NULL) {
278 memcpy(&imsi.szMcc, n_imsi->plmn, 3);
279 imsi.szMcc[3] = '\0';
280 memcpy(&imsi.szMnc, n_imsi->plmn + 3, 2);
281 imsi.szMnc[2] = '\0';
282 memcpy(&imsi.szMsin, n_imsi->msin, 10);
283 imsi.szMsin[10] = '\0';
284 dbg("imsi.valid=%d, mcc=%s, mnc=%s, msin=%s",
285 imsi.bValid, imsi.szMcc, imsi.szMnc, imsi.szMsin);
287 g_array_append_vals(*out_param2, &imsi, sizeof(TelSimImsiInfo_t));
290 case TAPI_CS_SIM_GETFDNSTATUS:
291 dbg("TAPI_CS_SIM_GETFDNSTATUS");
292 fdn_status = ctx->fdn_lock;
293 g_array_append_vals(*out_param2, &fdn_status, sizeof(int));
296 case TAPI_CS_SIM_GETECCINFO:
297 dbg("TAPI_CS_SIM_GETECCINFO");
298 ecc_count = ctx->ecc_count;
299 memcpy(&ecc_data, &ctx->ecc, sizeof(TelSimEccData_t));
300 g_array_append_vals(*out_param2, &ecc_data, sizeof(TelSimEccData_t));
301 g_array_append_vals(*out_param3, &ecc_count, sizeof(int));
304 case TAPI_CS_SIM_GETICCIDINFO:
305 dbg("TAPI_CS_SIM_GETICCIDINFO");
306 memcpy(&iccid_data, &ctx->iccid, sizeof(TelSimIccIdInfo_t));
307 g_array_append_vals(*out_param2, &iccid_data, sizeof(TelSimIccIdInfo_t));
310 case TAPI_CS_SIM_SETLANGUAGE: //NOT USED FROM APP NOW
311 g_array_append_vals(*out_param2, &request_id, sizeof(int));
312 tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_language), &set_language);
313 tcore_user_request_set_command(ur, TREQ_SIM_SET_LANGUAGE);
314 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
315 if (ret != TCORE_RETURN_SUCCESS) {
316 api_err = TAPI_API_OPERATION_FAILED;
318 dbg("ret = 0x%x", ret);
321 case TAPI_CS_SIM_RSIMACCESS: //NOT USED FROM APP NOW
322 dbg("TAPI_CS_SIM_RSIMACCESS");
323 api_err = TAPI_API_NOT_SUPPORTED;
325 case TAPI_CS_SIM_GETCFINFO: //NOT USED FROM APP NOW
326 dbg("TAPI_CS_SIM_GETCFINFO");
327 api_err = TAPI_API_NOT_SUPPORTED;
329 case TAPI_CS_SIM_GETMWINFO: //NOT USED FROM APP NOW
330 dbg("TAPI_CS_SIM_GETMWINFO");
331 api_err = TAPI_API_NOT_SUPPORTED;
333 case TAPI_CS_SIM_GETCPHSINFO:
334 dbg("TAPI_CS_SIM_GETCPHSINFO");
335 g_array_append_vals(*out_param2, &cphs_local, sizeof(TelSimCphsLocalInfo_t));
337 case TAPI_CS_SIM_GETMBINFO:
338 dbg("TAPI_CS_SIM_GETMBINFO");
339 api_err = TAPI_API_NOT_SUPPORTED;
341 case TAPI_CS_SIM_GETLANGUAGEINFO:
342 dbg("TAPI_CS_SIM_GETLANGUAGEINFO");
343 memcpy(&lang_data, &ctx->language, sizeof(TelSimLanguageInfo_t));
344 g_array_append_vals (*out_param2, &lang_data,sizeof(TelSimLanguageInfo_t));
346 case TAPI_CS_SIM_GETCARDTYPE: /* 0x1000225 */
347 dbg("TAPI_CS_SIM_GETCARDTYPE");
348 type = tcore_sim_get_type(co_sim);
350 case SIM_TYPE_UNKNOWN:
351 card_type = TAPI_SIM_CARD_TYPE_UNKNOWN;
354 card_type = TAPI_SIM_CARD_TYPE_GSM;
357 card_type = TAPI_SIM_CARD_TYPE_USIM;
360 card_type = TAPI_SIM_CARD_TYPE_UNKNOWN;
363 card_type = TAPI_SIM_CARD_TYPE_UNKNOWN;
368 dbg("card_type = %d", card_type);
369 g_array_append_vals(*out_param2, &card_type, sizeof(TelSimCardType_t));
372 case TAPI_CS_SIM_GETSIMINITINFO:
373 dbg("TAPI_CS_SIM_GETSIMINITINFO");
374 tmp_cardstatus = tcore_sim_get_status(co_sim);
375 b_changed = tcore_sim_get_identification(co_sim);
376 dbg("sim init info - cardstatus[%d],changed[%d]", tmp_cardstatus, b_changed);
377 g_array_append_vals(*out_param2, &tmp_cardstatus, sizeof(TelSimCardStatus_t));
378 g_array_append_vals(*out_param3, &b_changed, sizeof(int));
381 case TAPI_CS_SIM_AUTHENTICATION:
382 dbg("TAPI_CS_SIM_AUTHENTICATION");
383 g_array_append_vals(*out_param2, &request_id, sizeof(int));
384 AuthenticationData = g_array_index(in_param1, TelSimAuthenticationData_t, 0);
385 req_auth.auth_type = AuthenticationData.auth_type;
386 req_auth.autn_length = AuthenticationData.autn_length;
387 if(req_auth.autn_length)
388 memcpy(req_auth.autn_data, AuthenticationData.autn_data, req_auth.autn_length);
389 req_auth.rand_length = AuthenticationData.rand_length;
390 if(req_auth.autn_length)
391 memcpy(req_auth.rand_data, AuthenticationData.rand_data, req_auth.rand_length);
392 tcore_user_request_set_data(ur, sizeof(struct treq_sim_req_authentication), &req_auth);
393 tcore_user_request_set_command(ur, TREQ_SIM_REQ_AUTHENTICATION);
394 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
395 if (ret != TCORE_RETURN_SUCCESS) {
396 api_err = TAPI_API_OPERATION_FAILED;
398 dbg("ret = 0x%x", ret);
401 case TAPI_CS_SIM_VERIFYSEC:
402 dbg("TAPI_CS_SIM_VERIFYSEC");
403 g_array_append_vals(*out_param2, &request_id, sizeof(int));
404 pin_data = g_array_index(in_param1, TelSimSecPw_t, 0);
405 pin_data.pw =(unsigned char*)&g_array_index(in_param2, unsigned char, 0);
406 verify_pins.pin_type = pin_data.type;
407 verify_pins.pin_length = pin_data.pw_len;
408 memcpy(verify_pins.pin, pin_data.pw, verify_pins.pin_length);
409 tcore_user_request_set_data(ur, sizeof(struct treq_sim_verify_pins), &verify_pins);
410 tcore_user_request_set_command(ur, TREQ_SIM_VERIFY_PINS);
411 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
412 if (ret != TCORE_RETURN_SUCCESS) {
413 api_err = TAPI_API_OPERATION_FAILED;
415 dbg("ret = 0x%x", ret);
418 case TAPI_CS_SIM_VERIFYPUK:
419 dbg("TAPI_CS_SIM_VERIFYPUK");
420 g_array_append_vals(*out_param2, &request_id, sizeof(int));
421 puk_data = g_array_index(in_param1, TelSimSecPw_t, 0);
422 pin_data = g_array_index(in_param1, TelSimSecPw_t, 1);
423 puk_data.pw = (unsigned char*)&g_array_index(in_param2, unsigned char, 0);
424 pin_data.pw = (unsigned char*)&g_array_index(in_param3, unsigned char, 0);
425 verify_puks.puk_type = puk_data.type;
426 verify_puks.puk_length = puk_data.pw_len;
427 memcpy(verify_puks.puk, puk_data.pw, verify_puks.puk_length);
428 verify_puks.pin_length = pin_data.pw_len;
429 memcpy(verify_puks.pin, pin_data.pw, verify_puks.pin_length);
430 tcore_user_request_set_data(ur, sizeof(struct treq_sim_verify_puks), &verify_puks);
431 tcore_user_request_set_command(ur, TREQ_SIM_VERIFY_PUKS);
432 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
433 if (ret != TCORE_RETURN_SUCCESS) {
434 api_err = TAPI_API_OPERATION_FAILED;
436 dbg("ret = 0x%x", ret);
439 case TAPI_CS_SIM_CHANGEPIN:
440 dbg("TAPI_CS_SIM_CHANGEPIN");
441 g_array_append_vals(*out_param2, &request_id, sizeof(int));
442 old_pin = g_array_index(in_param1, TelSimSecPw_t, 0);
443 new_pin = g_array_index(in_param1, TelSimSecPw_t, 1);
444 old_pin.pw = (unsigned char*)&g_array_index(in_param2, unsigned char, 0);
445 new_pin.pw = (unsigned char*)&g_array_index(in_param3, unsigned char, 0);
446 change_pins.type = old_pin.type;
447 change_pins.old_pin_length = old_pin.pw_len;
448 memcpy(change_pins.old_pin, old_pin.pw, change_pins.old_pin_length);
449 change_pins.new_pin_length = new_pin.pw_len;
450 memcpy(change_pins.new_pin, new_pin.pw, change_pins.new_pin_length);
451 tcore_user_request_set_data(ur, sizeof(struct treq_sim_change_pins), &change_pins);
452 tcore_user_request_set_command(ur, TREQ_SIM_CHANGE_PINS);
453 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
454 if (ret != TCORE_RETURN_SUCCESS) {
455 api_err = TAPI_API_OPERATION_FAILED;
457 dbg("ret = 0x%x", ret);
460 case TAPI_CS_SIM_DISABLESEC:
461 dbg("TAPI_CS_SIM_DISABLESEC");
462 g_array_append_vals(*out_param2, &request_id, sizeof(int));
463 pin_data= g_array_index(in_param1, TelSimSecPw_t, 0);
464 pin_data.pw = (unsigned char*)&g_array_index(in_param2, unsigned char, 0);
465 if(pin_data.type == TAPI_SIM_PTYPE_PIN1) {
466 dis_facility.type = SIM_FACILITY_SC;
467 } else if (pin_data.type == TAPI_SIM_PTYPE_SIM) {
468 dis_facility.type = SIM_FACILITY_PS;
470 api_err = TAPI_API_INVALID_INPUT;
471 g_array_append_vals(*out_param2, &request_id, sizeof(int));
474 dis_facility.password_length = pin_data.pw_len;
475 memcpy(dis_facility.password, pin_data.pw, dis_facility.password_length);
476 tcore_user_request_set_data(ur, sizeof(struct treq_sim_disable_facility), &dis_facility);
477 tcore_user_request_set_command(ur, TREQ_SIM_DISABLE_FACILITY);
478 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
479 if (ret != TCORE_RETURN_SUCCESS) {
480 api_err = TAPI_API_OPERATION_FAILED;
482 dbg("ret = 0x%x", ret);
485 case TAPI_CS_SIM_ENABLESEC:
486 dbg("TAPI_CS_SIM_ENABLESEC");
487 g_array_append_vals(*out_param2, &request_id, sizeof(int));
488 pin_data= g_array_index(in_param1, TelSimSecPw_t, 0);
489 pin_data.pw = (unsigned char*)&g_array_index(in_param2, unsigned char, 0);
490 if(pin_data.type == TAPI_SIM_PTYPE_PIN1) {
491 en_facility.type = SIM_FACILITY_SC;
492 } else if (pin_data.type == TAPI_SIM_PTYPE_SIM) {
493 en_facility.type = SIM_FACILITY_PS;
495 api_err = TAPI_API_INVALID_INPUT;
496 g_array_append_vals(*out_param2, &request_id, sizeof(int));
499 en_facility.password_length = pin_data.pw_len;
500 memcpy(en_facility.password, pin_data.pw, en_facility.password_length);
501 tcore_user_request_set_data(ur, sizeof(struct treq_sim_enable_facility), &en_facility);
502 tcore_user_request_set_command(ur, TREQ_SIM_ENABLE_FACILITY);
503 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
504 if (ret != TCORE_RETURN_SUCCESS) {
505 api_err = TAPI_API_OPERATION_FAILED;
507 dbg("ret = 0x%x", ret);
510 case TAPI_CS_SIM_GETPERSSTATUS:
511 dbg("TAPI_CS_SIM_GETPERSSTATUS");
512 g_array_append_vals(*out_param2, &request_id, sizeof(int));
513 type = g_array_index(in_param1, TelSimPersType_t, 0);
515 case TAPI_SIM_PERS_NET:
516 facility.type = SIM_FACILITY_PN;
518 case TAPI_SIM_PERS_NS:
519 facility.type = SIM_FACILITY_PU;
521 case TAPI_SIM_PERS_SP:
522 facility.type = SIM_FACILITY_PP;
524 case TAPI_SIM_PERS_CP:
525 facility.type = SIM_FACILITY_PC;
528 api_err = TAPI_API_INVALID_INPUT;
532 tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_facility_status), &facility);
533 tcore_user_request_set_command(ur, TREQ_SIM_GET_FACILITY_STATUS);
534 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
535 if (ret != TCORE_RETURN_SUCCESS) {
536 api_err = TAPI_API_OPERATION_FAILED;
538 dbg("ret = 0x%x", ret);
541 case TAPI_CS_SIM_DISABLEPERS:
542 dbg("TAPI_CS_SIM_DISABLEPERS");
543 g_array_append_vals(*out_param2, &request_id, sizeof(int));
544 pers_data= g_array_index(in_param1, TelSimPersPw_t, 0);
545 pers_data.pw = (unsigned char*)&g_array_index(in_param2, unsigned char, 0);
546 switch(pers_data.type) {
547 case TAPI_SIM_PERS_NET:
548 dis_facility.type = SIM_FACILITY_PN;
550 case TAPI_SIM_PERS_NS:
551 dis_facility.type = SIM_FACILITY_PU;
553 case TAPI_SIM_PERS_SP:
554 dis_facility.type = SIM_FACILITY_PP;
556 case TAPI_SIM_PERS_CP:
557 dis_facility.type = SIM_FACILITY_PC;
560 api_err = TAPI_API_INVALID_INPUT;
564 dis_facility.password_length = pers_data.pw_len;
565 memcpy(dis_facility.password, pers_data.pw, dis_facility.password_length);
566 tcore_user_request_set_data(ur, sizeof(struct treq_sim_disable_facility), &dis_facility);
567 tcore_user_request_set_command(ur, TREQ_SIM_DISABLE_FACILITY);
568 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
569 if (ret != TCORE_RETURN_SUCCESS) {
570 api_err = TAPI_API_OPERATION_FAILED;
572 dbg("ret = 0x%x", ret);
575 case TAPI_CS_SIM_ENABLEPERS:
576 dbg("TAPI_CS_SIM_ENABLEPERS");
577 g_array_append_vals(*out_param2, &request_id, sizeof(int));
578 pers_data= g_array_index(in_param1, TelSimPersPw_t, 0);
579 pers_data.pw = (unsigned char*)&g_array_index(in_param2, unsigned char, 0);
580 switch(pers_data.type) {
581 case TAPI_SIM_PERS_NET:
582 en_facility.type = SIM_FACILITY_PN;
584 case TAPI_SIM_PERS_NS:
585 en_facility.type = SIM_FACILITY_PU;
587 case TAPI_SIM_PERS_SP:
588 en_facility.type = SIM_FACILITY_PP;
590 case TAPI_SIM_PERS_CP:
591 en_facility.type = SIM_FACILITY_PC;
594 api_err = TAPI_API_INVALID_INPUT;
598 en_facility.password_length = pers_data.pw_len;
599 memcpy(en_facility.password, pers_data.pw, en_facility.password_length);
600 tcore_user_request_set_data(ur, sizeof(struct treq_sim_enable_facility), &en_facility);
601 tcore_user_request_set_command(ur, TREQ_SIM_ENABLE_FACILITY);
602 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
603 if (ret != TCORE_RETURN_SUCCESS) {
604 api_err = TAPI_API_OPERATION_FAILED;
606 dbg("ret = 0x%x", ret);
609 case TAPI_CS_SIM_DISABLEFDN: //NOT USED FROM APP NOW
610 dbg("TAPI_CS_SIM_DISABLEFDN");
611 g_array_append_vals(*out_param2, &request_id, sizeof(int));
612 pin2 = (unsigned char*)&g_array_index(in_param1, unsigned char, 0);
613 pin2_len = g_array_index(in_param2, unsigned int, 0);
614 dis_facility.type = SIM_FACILITY_FD;
615 dis_facility.password_length = pin2_len;
616 memcpy(dis_facility.password, pin2, dis_facility.password_length);
617 tcore_user_request_set_data(ur, sizeof(struct treq_sim_disable_facility), &dis_facility);
618 tcore_user_request_set_command(ur, TREQ_SIM_DISABLE_FACILITY);
619 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
620 if (ret != TCORE_RETURN_SUCCESS) {
621 api_err = TAPI_API_OPERATION_FAILED;
623 dbg("ret = 0x%x", ret);
626 case TAPI_CS_SIM_ENABLEFDN: //NOT USED FROM APP NOW
627 dbg("TAPI_CS_SIM_ENABLEFDN");
628 g_array_append_vals(*out_param2, &request_id, sizeof(int));
629 pin2 = (unsigned char*)&g_array_index(in_param1, unsigned char, 0);
630 pin2_len = g_array_index(in_param2, unsigned int, 0);
631 en_facility.type = SIM_FACILITY_FD;
632 en_facility.password_length = pin2_len;
633 memcpy(en_facility.password, pin2, en_facility.password_length);
634 tcore_user_request_set_data(ur, sizeof(struct treq_sim_enable_facility), &en_facility);
635 tcore_user_request_set_command(ur, TREQ_SIM_ENABLE_FACILITY);
636 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
637 if (ret != TCORE_RETURN_SUCCESS) {
638 api_err = TAPI_API_OPERATION_FAILED;
640 dbg("ret = 0x%x", ret);
643 case TAPI_CS_SIM_APDU:
644 dbg("TAPI_CS_SIM_APDU");
645 g_array_append_vals(*out_param2, &request_id, sizeof(int));
646 apdu_data = g_array_index(in_param1, TelSimApdu_t, 0);
647 apdu_data.apdu =(unsigned char*)&g_array_index(in_param2, unsigned char, 0);
648 send_apdu.apdu_length = apdu_data.apdu_len;
649 memcpy(send_apdu.apdu, apdu_data.apdu, send_apdu.apdu_length);
650 tcore_user_request_set_data(ur, sizeof(struct treq_sim_transmit_apdu), &send_apdu);
651 tcore_user_request_set_command(ur, TREQ_SIM_TRANSMIT_APDU);
652 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
653 if (ret != TCORE_RETURN_SUCCESS) {
654 api_err = TAPI_API_OPERATION_FAILED;
656 dbg("ret = 0x%x", ret);
659 case TAPI_CS_SIM_ATR:
660 dbg("TAPI_CS_SIM_ATR");
661 g_array_append_vals(*out_param2, &request_id, sizeof(int));
662 tcore_user_request_set_command(ur, TREQ_SIM_GET_ATR);
663 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
664 if (ret != TCORE_RETURN_SUCCESS) {
665 api_err = TAPI_API_OPERATION_FAILED;
667 dbg("ret = 0x%x", ret);
670 case TAPI_CS_SIM_GETSECSTATUS :
671 dbg("TAPI_CS_SIM_GETSECSTATUS");
672 type = g_array_index(in_param1, TelSimPinType_t, 0);
673 if((int)type == TAPI_SIM_PTYPE_PIN1)
674 status = ctx->pin_lock;
675 else if((int)type == TAPI_SIM_PTYPE_PIN2)
676 status = TAPI_SIM_PIN_STATUS_ENABLED;
677 else if((int)type == TAPI_SIM_PTYPE_SIM)
678 status = ctx->sim_lock;
680 status = TAPI_SIM_PIN_STATUS_UNKNOWN;
682 g_array_append_vals (*out_param2, &status, sizeof(TelSimPinStatus_t));
685 case TAPI_CS_SIM_GETPBINITINFO:
686 dbg("TAPI_CS_SIM_GETPBINITINFO");
687 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
689 api_err = TAPI_API_NOT_SUPPORTED;
692 co_pb = (CoreObject *)co_list->data;
693 g_slist_free(co_list);
696 api_err = TAPI_API_NOT_SUPPORTED;
699 lsp_init_completed = tcore_phonebook_get_status(co_pb);
700 pb_list = (struct tel_phonebook_support_list*)tcore_phonebook_get_support_list(co_pb);
701 memcpy(&lsp_supported_pb_list, pb_list, sizeof(struct tel_phonebook_support_list));
702 g_array_append_vals (*out_param2, &lsp_init_completed,sizeof(int));
703 g_array_append_vals (*out_param3, &lsp_supported_pb_list,sizeof(TelSimPbList_t));
704 g_array_append_vals (*out_param4, &lsp_first_index,sizeof(int));
707 case TAPI_CS_SIM_PB_GETCOUNT:
708 dbg("TAPI_CS_SIM_PB_GETCOUNT");
709 g_array_append_vals(*out_param2, &request_id, sizeof(int));
710 lsp_pb_type = g_array_index(in_param1, TelSimPbFileType_t, 0);
712 case TAPI_SIM_PB_FDN :
713 pb_count.phonebook_type = PB_TYPE_FDN;
715 case TAPI_SIM_PB_ADN :
716 pb_count.phonebook_type = PB_TYPE_ADN;
718 case TAPI_SIM_PB_SDN :
719 pb_count.phonebook_type = PB_TYPE_SDN;
721 case TAPI_SIM_PB_3GSIM :
722 pb_count.phonebook_type = PB_TYPE_USIM;
724 case TAPI_SIM_PB_AAS :
725 pb_count.phonebook_type = PB_TYPE_AAS;
727 case TAPI_SIM_PB_GAS :
728 pb_count.phonebook_type = PB_TYPE_GAS;
733 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_count), &pb_count);
734 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETCOUNT);
735 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
736 if (ret != TCORE_RETURN_SUCCESS) {
737 api_err = TAPI_API_OPERATION_FAILED;
739 dbg("ret = 0x%x", ret);
742 case TAPI_CS_SIM_PB_GETMETAINFO: //NOT USED FROM APP NOW
743 dbg("TAPI_CS_SIM_PB_GETMETAINFO");
744 g_array_append_vals(*out_param2, &request_id, sizeof(int));
745 lsp_pb_type = g_array_index(in_param1, TelSimPbFileType_t, 0);
747 case TAPI_SIM_PB_FDN :
748 pb_info.phonebook_type = PB_TYPE_FDN;
750 case TAPI_SIM_PB_ADN :
751 pb_info.phonebook_type = PB_TYPE_ADN;
753 case TAPI_SIM_PB_SDN :
754 pb_info.phonebook_type = PB_TYPE_SDN;
756 case TAPI_SIM_PB_3GSIM :
757 pb_info.phonebook_type = PB_TYPE_USIM;
759 case TAPI_SIM_PB_AAS :
760 pb_info.phonebook_type = PB_TYPE_AAS;
762 case TAPI_SIM_PB_GAS :
763 pb_info.phonebook_type = PB_TYPE_GAS;
768 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_info), &pb_info);
769 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETMETAINFO);
770 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
771 if (ret != TCORE_RETURN_SUCCESS) {
772 api_err = TAPI_API_OPERATION_FAILED;
774 dbg("ret = 0x%x", ret);
777 case TAPI_CS_SIM_PB_READRECORD:
778 dbg("TAPI_CS_SIM_PB_READRECORD");
779 g_array_append_vals(*out_param2, &request_id, sizeof(int));
780 lsp_pb_type = g_array_index(in_param1, TelSimPbFileType_t, 0);
782 case TAPI_SIM_PB_FDN :
783 pb_read.phonebook_type = PB_TYPE_FDN;
785 case TAPI_SIM_PB_ADN :
786 pb_read.phonebook_type = PB_TYPE_ADN;
788 case TAPI_SIM_PB_SDN :
789 pb_read.phonebook_type = PB_TYPE_SDN;
791 case TAPI_SIM_PB_3GSIM :
792 pb_read.phonebook_type = PB_TYPE_USIM;
794 case TAPI_SIM_PB_AAS :
795 pb_read.phonebook_type = PB_TYPE_AAS;
797 case TAPI_SIM_PB_GAS :
798 pb_read.phonebook_type = PB_TYPE_GAS;
803 lsp_index = g_array_index(in_param2, unsigned short, 0);
804 pb_read.index = lsp_index;
805 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_read_record), &pb_read);
806 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_READRECORD);
807 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
808 if (ret != TCORE_RETURN_SUCCESS) {
809 api_err = TAPI_API_OPERATION_FAILED;
811 dbg("ret = 0x%x", ret);
814 case TAPI_CS_SIM_PB_UPDATERECORD: //NOT USED FROM APP NOW
815 dbg("TAPI_CS_SIM_PB_UPDATERECORD");
816 g_array_append_vals(*out_param2, &request_id, sizeof(int));
817 lsp_pb_type = g_array_index(in_param1, TelSimPbFileType_t, 0);
819 case TAPI_SIM_PB_FDN :
820 pb_update.phonebook_type = PB_TYPE_FDN;
822 case TAPI_SIM_PB_ADN :
823 pb_update.phonebook_type = PB_TYPE_ADN;
825 case TAPI_SIM_PB_SDN :
826 pb_update.phonebook_type = PB_TYPE_SDN;
828 case TAPI_SIM_PB_3GSIM :
829 pb_update.phonebook_type = PB_TYPE_USIM;
831 case TAPI_SIM_PB_AAS :
832 pb_update.phonebook_type = PB_TYPE_AAS;
834 case TAPI_SIM_PB_GAS :
835 pb_update.phonebook_type = PB_TYPE_GAS;
840 lsp_index = g_array_index(in_param2, unsigned short, 0);
841 pb_update.index = lsp_index;
843 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_update_record), &pb_update);
844 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_UPDATERECORD);
845 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
846 if (ret != TCORE_RETURN_SUCCESS) {
847 api_err = TAPI_API_OPERATION_FAILED;
849 dbg("ret = 0x%x", ret);
852 case TAPI_CS_SIM_PB_DELETERECORD: //NOT USED FROM APP NOW
853 dbg("TAPI_CS_SIM_PB_DELETERECORD");
854 g_array_append_vals(*out_param2, &request_id, sizeof(int));
855 lsp_pb_type = g_array_index(in_param1, TelSimPbFileType_t, 0);
857 case TAPI_SIM_PB_FDN :
858 pb_delete.phonebook_type = PB_TYPE_FDN;
860 case TAPI_SIM_PB_ADN :
861 pb_delete.phonebook_type = PB_TYPE_ADN;
863 case TAPI_SIM_PB_SDN :
864 pb_delete.phonebook_type = PB_TYPE_SDN;
866 case TAPI_SIM_PB_3GSIM :
867 pb_delete.phonebook_type = PB_TYPE_USIM;
869 case TAPI_SIM_PB_AAS :
870 pb_delete.phonebook_type = PB_TYPE_AAS;
872 case TAPI_SIM_PB_GAS :
873 pb_delete.phonebook_type = PB_TYPE_GAS;
878 lsp_index = g_array_index(in_param2, unsigned short, 0);
879 pb_delete.index = lsp_index;
880 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_delete_record), &pb_delete);
881 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_DELETERECORD);
882 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
883 if (ret != TCORE_RETURN_SUCCESS) {
884 api_err = TAPI_API_OPERATION_FAILED;
886 dbg("ret = 0x%x", ret);
889 case TAPI_CS_SIM_GETPBCAPABILITYINFO: //NOT USED FROM APP NOW
890 dbg("TAPI_CS_SIM_GETPBCAPABILITYINFO");
891 g_array_append_vals(*out_param2, &request_id, sizeof(int));
892 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_usim_info), &pb_usim);
893 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETUSIMINFO);
894 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
895 if (ret != TCORE_RETURN_SUCCESS) {
896 api_err = TAPI_API_OPERATION_FAILED;
898 dbg("ret = 0x%x", ret);
901 case TAPI_CS_SIM_SAPCONNECTREQUEST:
902 g_array_append_vals(*out_param2, &request_id, sizeof(int));
903 lsa_conn_req = g_array_index(in_param1, TelSimSapConnect_t, 0);
904 if (lsa_conn_req.MsgId == TAPI_SIM_SAP_CONNECT_REQ) {
905 req_conn.max_msg_size = lsa_conn_req.MaxMsgSize;
906 tcore_user_request_set_data(ur, sizeof(struct treq_sap_req_connect), &req_conn);
907 tcore_user_request_set_command(ur, TREQ_SAP_REQ_CONNECT);
908 }else if(lsa_conn_req.MsgId == TAPI_SIM_SAP_DISCONNECT_REQ){
909 tcore_user_request_set_data(ur, sizeof(struct treq_sap_req_disconnect), &req_conn);
910 tcore_user_request_set_command(ur, TREQ_SAP_REQ_DISCONNECT);
914 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
915 if (ret != TCORE_RETURN_SUCCESS) {
916 api_err = TAPI_API_OPERATION_FAILED;
918 dbg("ret = 0x%x", ret);
921 case TAPI_CS_SIM_SAPCONNECTSTATUS:
922 g_array_append_vals(*out_param2, &request_id, sizeof(int));
923 tcore_user_request_set_data(ur, sizeof(struct treq_sap_req_status), &req_status);
924 tcore_user_request_set_command(ur, TREQ_SAP_REQ_STATUS);
925 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
926 if (ret != TCORE_RETURN_SUCCESS) {
927 api_err = TAPI_API_OPERATION_FAILED;
929 dbg("ret = 0x%x", ret);
932 case TAPI_CS_SIM_SAPATRREQUEST:
933 g_array_append_vals(*out_param2, &request_id, sizeof(int));
934 tcore_user_request_set_data(ur, sizeof(struct treq_sap_req_atr), &req_atr);
935 tcore_user_request_set_command(ur, TREQ_SAP_REQ_ATR);
936 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
937 if (ret != TCORE_RETURN_SUCCESS) {
938 api_err = TAPI_API_OPERATION_FAILED;
940 dbg("ret = 0x%x", ret);
943 case TAPI_CS_SIM_SAPTRANSFERAPDU:
944 g_array_append_vals(*out_param2, &request_id, sizeof(int));
945 lsa_apdu_data = g_array_index(in_param1, TelSimSapApduData_t, 0);
946 t_apdu.apdu_length = lsa_apdu_data.ApduLength;
947 memcpy(t_apdu.apdu_data, lsa_apdu_data.Apdu, lsa_apdu_data.ApduLength);
949 tcore_user_request_set_data(ur, sizeof(struct treq_sap_transfer_apdu), &t_apdu);
950 tcore_user_request_set_command(ur, TREQ_SAP_TRANSFER_APDU);
951 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
952 if (ret != TCORE_RETURN_SUCCESS) {
953 api_err = TAPI_API_OPERATION_FAILED;
955 dbg("ret = 0x%x", ret);
958 case TAPI_CS_SIM_SAPSETPROTOCOL:
959 g_array_append_vals(*out_param2, &request_id, sizeof(int));
960 lsa_protocol = g_array_index(in_param1, TelSimSapProtocol_t, 0);
961 set_protocol.protocol = lsa_protocol;
963 tcore_user_request_set_data(ur, sizeof(struct treq_sap_set_protocol), &set_protocol);
964 tcore_user_request_set_command(ur, TREQ_SAP_SET_PROTOCOL);
965 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
966 if (ret != TCORE_RETURN_SUCCESS) {
967 api_err = TAPI_API_OPERATION_FAILED;
969 dbg("ret = 0x%x", ret);
972 case TAPI_CS_SIM_SAPSETSIMPOWER:
973 g_array_append_vals(*out_param2, &request_id, sizeof(int));
974 lsa_msg_id = g_array_index(in_param1, TelSimSapMsgId_t, 0);
975 if (lsa_msg_id == TAPI_SIM_SAP_POWER_SIM_OFF_REQ) {
976 set_power.mode = SAP_POWER_OFF;
977 } else if (lsa_msg_id == TAPI_SIM_SAP_POWER_SIM_ON_REQ) {
978 set_power.mode = SAP_POWER_ON;
979 } else if (lsa_msg_id == TAPI_SIM_SAP_RESET_SIM_REQ) {
980 set_power.mode = SAP_POWER_RESET;
985 tcore_user_request_set_data(ur, sizeof(struct treq_sap_set_power), &req_conn);
986 tcore_user_request_set_command(ur, TREQ_SAP_SET_POWER);
987 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
988 if (ret != TCORE_RETURN_SUCCESS) {
989 api_err = TAPI_API_OPERATION_FAILED;
991 dbg("ret = 0x%x", ret);
994 case TAPI_CS_SIM_SAPCARDREADERSTATUS:
995 g_array_append_vals(*out_param2, &request_id, sizeof(int));
996 tcore_user_request_set_data(ur, sizeof(struct treq_sap_req_cardreaderstatus), &req_conn);
997 tcore_user_request_set_command(ur, TREQ_SAP_REQ_CARDREADERSTATUS);
998 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
999 if (ret != TCORE_RETURN_SUCCESS) {
1000 api_err = TAPI_API_OPERATION_FAILED;
1002 dbg("ret = 0x%x", ret);
1006 api_err = TAPI_API_NOT_SUPPORTED;
1011 if (api_err != TAPI_API_SUCCESS) {
1012 tcore_user_request_free(ur);
1014 dbg("api_err[%d]",api_err);
1015 g_array_append_vals(*out_param1, &api_err, sizeof(int));
1018 TReturn dbus_response_sim(struct custom_data *ctx, UserRequest *ur, const char *appname,
1019 enum tcore_response_command command, unsigned int data_len, const void *data)
1021 const struct tresp_sim_verify_pins *resp_verify_pins = data;
1022 const struct tresp_sim_verify_puks *resp_verify_puks = data;
1023 const struct tresp_sim_change_pins *resp_change_pins = data;
1024 const struct tresp_sim_get_facility_status *resp_get_facility = data;
1025 const struct tresp_sim_disable_facility *resp_dis_facility = data;
1026 const struct tresp_sim_enable_facility *resp_en_facility = data;
1027 const struct tresp_sim_transmit_apdu *resp_apdu = data;
1028 const struct tresp_sim_get_atr *resp_get_atr = data;
1029 const struct tresp_sim_read *resp_read = data;
1030 const struct tresp_sim_req_authentication *resp_auth = data;
1031 const struct tresp_sim_set_language *resp_set_language = data;
1033 TelSimSecResult_t sec_rt = {0,};
1034 TelSimPersStatus_t pers_rt = {0,};
1035 TelSimApduResp_t apdu_resp = {0,};
1036 TelSimAtrResp_t atr_resp = {0,};
1037 TelSimAuthenticationResponse_t auth_resp = {0,};
1039 const struct tresp_phonebook_get_count *resp_pbcnt = data;
1040 const struct tresp_phonebook_get_info *resp_entry = data;
1041 const struct tresp_phonebook_get_usim_info *resp_capa = data;
1042 const struct tresp_phonebook_read_record *resp_pbread = data;
1043 const struct tresp_phonebook_update_record *resp_pbupdate = data;
1044 const struct tresp_phonebook_delete_record *resp_pbdelete = data;
1046 TelSimPbCapabilityInfo_t lpb_capa = {0,};
1047 TelSimPbStorageInfo_t lpb_cnt = {0,};
1048 TelSimPbEntryInfo_t lpb_entry = {0,};
1049 //TelSimPbRecordData_t lpb_data = {0,};
1050 TelSimPbRecord_t lcpb_data = {0,};
1052 const struct tresp_sap_req_connect *sap_conn = data;
1053 const struct tresp_sap_req_status *sap_status = data;
1054 const struct tresp_sap_req_atr *sap_atr = data;
1055 const struct tresp_sap_transfer_apdu *sap_apdu = data;
1056 const struct tresp_sap_set_protocol *sap_protocol = data;
1057 const struct tresp_sap_set_power *sap_power = data;
1058 const struct tresp_sap_req_cardreaderstatus *sap_reader = data;
1060 TelSimSapConnect_t lsa_conn = { 0, };
1061 TelSimSapConnect_t lsa_disconn = { 0, };
1062 unsigned int lsa_status = 0;
1063 TelSimSapAtrInfo_t lsa_atr = { 0, };
1064 TelSimSapApduData_t lsa_apdu = { 0, };
1065 TelSimSapResultCode_t lsa_result_code = 0;
1066 TelSimSapPower_t lsa_power = { 0, };
1067 TelSimCardReaderStatus_t lsa_reader = { 0, };
1069 int request_id = 0, i =0;
1073 char *modem_name = NULL;
1074 TcorePlugin *p = NULL;
1077 Storage *strg = NULL;
1079 char *tmp_msisdn = NULL;
1081 modem_name = tcore_user_request_get_modem_name(ur);
1085 p = tcore_server_find_plugin(ctx->server, modem_name);
1090 co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SIM);
1095 co_sim = (CoreObject *)co_list->data;
1096 g_slist_free(co_list);
1102 s = tcore_plugin_ref_server(p);
1104 dbg("there is no valid server at this point");
1108 strg = (Storage*)tcore_server_find_storage(s, "vconf");
1110 dbg("there is no valid storage plugin");
1115 case TRESP_SIM_VERIFY_PINS:
1116 dbg("dbus comm - TRESP_SIM_VERIFY_PINS");
1117 sec_rt.retry_count = resp_verify_pins->retry_count;
1118 sec_rt.type = resp_verify_pins->pin_type;
1119 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1120 TAPI_EVENT_SIM_VERIFY_SEC_CNF, appname, request_id, resp_verify_pins->result,
1121 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1124 case TRESP_SIM_VERIFY_PUKS:
1125 dbg("dbus comm - TRESP_SIM_VERIFY_PUKS");
1126 sec_rt.retry_count = resp_verify_puks->retry_count;
1127 sec_rt.type = resp_verify_puks->pin_type;
1128 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1129 TAPI_EVENT_SIM_VERIFY_PUK_CNF, appname, request_id, resp_verify_puks->result,
1130 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1133 case TRESP_SIM_CHANGE_PINS:
1134 dbg("dbus comm - TRESP_SIM_CHANGE_PINS");
1135 sec_rt.retry_count = resp_change_pins->retry_count;
1136 sec_rt.type = resp_change_pins->pin_type;
1137 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1138 TAPI_EVENT_SIM_CHANGE_PINS_CNF, appname, request_id, resp_change_pins->result,
1139 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1142 case TRESP_SIM_GET_FACILITY_STATUS:
1143 dbg("dbus comm - TRESP_SIM_GET_FACILITY_STATUS");
1144 switch(resp_get_facility->type){
1145 case SIM_FACILITY_PN:
1146 pers_rt.type = TAPI_SIM_PERS_NET;
1148 case SIM_FACILITY_PU:
1149 pers_rt.type = TAPI_SIM_PERS_NS;
1151 case SIM_FACILITY_PP:
1152 pers_rt.type = TAPI_SIM_PERS_SP;
1154 case SIM_FACILITY_PC:
1155 pers_rt.type = TAPI_SIM_PERS_CP;
1157 case SIM_FACILITY_PS:
1158 case SIM_FACILITY_SC:
1159 case SIM_FACILITY_FD:
1160 return dbus_sim_security_update(ctx, resp_get_facility->type, resp_get_facility->result, resp_get_facility->b_enable);
1165 pers_rt.mode = resp_get_facility->b_enable;
1166 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1167 TAPI_EVENT_SIM_PERS_STATUS_CNF, appname, request_id, resp_get_facility->result,
1168 sizeof(TelSimPersStatus_t), (void*) &pers_rt);
1171 case TRESP_SIM_DISABLE_FACILITY:
1172 dbg("dbus comm - TRESP_SIM_DISABLE_FACILITY");
1173 dbus_sim_security_update(ctx, resp_en_facility->type, resp_en_facility->result, 0);
1174 sec_rt.retry_count = resp_dis_facility->retry_count;
1175 switch(resp_dis_facility->type){
1176 case SIM_FACILITY_PS :
1177 sec_rt.type = TAPI_SIM_PTYPE_SIM;
1178 case SIM_FACILITY_SC:
1179 sec_rt.type = TAPI_SIM_PTYPE_PIN1;
1180 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1181 TAPI_EVENT_SIM_DISABLE_SEC_CNF, appname, request_id, resp_dis_facility->result,
1182 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1185 case SIM_FACILITY_FD:
1186 sec_rt.type = TAPI_SIM_PTYPE_PIN2;
1187 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1188 TAPI_EVENT_SIM_DISABLE_FDNMODE_CNF, appname, request_id, resp_dis_facility->result,
1189 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1192 case SIM_FACILITY_PN:
1193 sec_rt.type = TAPI_SIM_PERS_NET;
1194 case SIM_FACILITY_PU:
1195 sec_rt.type = TAPI_SIM_PERS_NS;
1196 case SIM_FACILITY_PP:
1197 pers_rt.type = TAPI_SIM_PERS_SP;
1198 case SIM_FACILITY_PC:
1199 pers_rt.type = TAPI_SIM_PERS_CP;
1200 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1201 TAPI_EVENT_SIM_DISABLE_PERS_CNF, appname, request_id, resp_dis_facility->result, 0, NULL);
1208 case TRESP_SIM_ENABLE_FACILITY:
1209 dbg("dbus comm - TRESP_SIM_ENABLE_FACILITY");
1210 sec_rt.retry_count = resp_en_facility->retry_count;
1211 dbus_sim_security_update(ctx, resp_en_facility->type, resp_en_facility->result, 1);
1212 switch(resp_en_facility->type){
1213 case SIM_FACILITY_PS :
1214 sec_rt.type = TAPI_SIM_PTYPE_SIM;
1215 case SIM_FACILITY_SC:
1216 sec_rt.type = TAPI_SIM_PTYPE_PIN1;
1217 dbg("result[%d], sec_rt type[%d],retry cnt[%d]",resp_en_facility->result, sec_rt.type, sec_rt.retry_count);
1218 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1219 TAPI_EVENT_SIM_ENABLE_SEC_CNF, appname, request_id, resp_en_facility->result,
1220 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1223 case SIM_FACILITY_FD:
1224 sec_rt.type = TAPI_SIM_PTYPE_PIN2;
1225 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1226 TAPI_EVENT_SIM_ENABLE_FDNMODE_CNF, appname, request_id, resp_en_facility->result,
1227 sizeof(TelSimSecResult_t), (void*) &sec_rt);
1230 case SIM_FACILITY_PN:
1231 sec_rt.type = TAPI_SIM_PERS_NET;
1232 case SIM_FACILITY_PU:
1233 sec_rt.type = TAPI_SIM_PERS_NS;
1234 case SIM_FACILITY_PP:
1235 pers_rt.type = TAPI_SIM_PERS_SP;
1236 case SIM_FACILITY_PC:
1237 pers_rt.type = TAPI_SIM_PERS_CP;
1238 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1239 TAPI_EVENT_SIM_ENABLE_PERS_CNF, appname, request_id, resp_en_facility->result, 0, NULL);
1246 case TRESP_SIM_TRANSMIT_APDU:
1247 dbg("dbus comm - TRESP_SIM_TRANSMIT_APDU");
1248 apdu_resp.apdu_resp_len = resp_apdu->apdu_resp_length;
1249 memcpy(apdu_resp.apdu_resp, resp_apdu->apdu_resp, apdu_resp.apdu_resp_len);
1250 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1251 TAPI_EVENT_SIM_APDU_CNF, appname, request_id, resp_apdu->result,
1252 sizeof(TelSimApduResp_t), (void*)&apdu_resp);
1255 case TRESP_SIM_GET_ATR:
1256 dbg("dbus comm - TRESP_SIM_GET_ATR");
1257 atr_resp.atr_resp_len = resp_get_atr->atr_length;
1258 memcpy(atr_resp.atr_resp, resp_get_atr->atr, atr_resp.atr_resp_len);
1259 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1260 TAPI_EVENT_SIM_ATR_CNF, appname, request_id, resp_get_atr->result,
1261 sizeof(TelSimAtrResp_t), (void*)&atr_resp);
1264 case TRESP_SIM_REQ_AUTHENTICATION:
1265 dbg("dbus comm - TRESP_SIM_REQ_AUTHENTICATION");
1266 auth_resp.auth_result = resp_auth->auth_result;
1267 auth_resp.auth_type = resp_auth->auth_type;
1268 if(resp_auth->authentication_key_length) {
1269 auth_resp.authentication_key_length = resp_auth->authentication_key_length;
1270 memcpy(auth_resp.authentication_key, resp_auth->authentication_key, auth_resp.authentication_key_length);
1272 if(resp_auth->cipher_length) {
1273 auth_resp.cipher_length = resp_auth->cipher_length;
1274 memcpy(auth_resp.cipher_data, resp_auth->cipher_data, auth_resp.cipher_length);
1276 if(resp_auth->integrity_length) {
1277 auth_resp.integrity_length = resp_auth->integrity_length;
1278 memcpy(auth_resp.integrity_data, resp_auth->integrity_data, auth_resp.integrity_length);
1280 if(resp_auth->resp_length) {
1281 auth_resp.resp_length = resp_auth->resp_length;
1282 memcpy(auth_resp.resp_data, resp_auth->resp_data, auth_resp.resp_length);
1284 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM, TAPI_EVENT_SIM_AUTHENTICATION_CNF,
1285 appname, request_id, resp_auth->result, sizeof(TelSimAuthenticationResponse_t),
1286 (void*) &auth_resp);
1289 case TRESP_SIM_SET_LANGUAGE:
1290 dbg("dbus comm - TRESP_SIM_SET_LANGUAGE");
1291 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM, TAPI_EVENT_SIM_SET_LANGUAGE_CNF,
1292 appname, request_id, resp_set_language->result, 0,NULL);
1295 case TRESP_SIM_GET_ECC:
1296 dbg("dbus comm - TRESP_SIM_GET_ECC");
1297 dbg("resp_read->result[%x]",resp_read->result);
1298 if (tcore_sim_get_type(co_sim) == SIM_TYPE_GSM) {
1299 ctx->ecc_count = resp_read->data.ecc.ecc_count;
1300 if (strlen(resp_read->data.ecc.ecc[0].ecc_num))
1301 snprintf(ctx->ecc.EccInfo.szEcc1, TAPI_SIM_ECC_CODE_LEN * 2 + 1, "%s", resp_read->data.ecc.ecc[0].ecc_num);
1302 if (strlen(resp_read->data.ecc.ecc[1].ecc_num))
1303 snprintf(ctx->ecc.EccInfo.szEcc2, TAPI_SIM_ECC_CODE_LEN * 2 + 1, "%s", resp_read->data.ecc.ecc[1].ecc_num);
1304 if (strlen(resp_read->data.ecc.ecc[2].ecc_num))
1305 snprintf(ctx->ecc.EccInfo.szEcc3, TAPI_SIM_ECC_CODE_LEN * 2 + 1, "%s", resp_read->data.ecc.ecc[2].ecc_num);
1306 if (strlen(resp_read->data.ecc.ecc[3].ecc_num))
1307 snprintf(ctx->ecc.EccInfo.szEcc4, TAPI_SIM_ECC_CODE_LEN * 2 + 1, "%s", resp_read->data.ecc.ecc[3].ecc_num);
1308 if (strlen(resp_read->data.ecc.ecc[4].ecc_num))
1309 snprintf(ctx->ecc.EccInfo.szEcc5, TAPI_SIM_ECC_CODE_LEN * 2 + 1, "%s", resp_read->data.ecc.ecc[4].ecc_num);
1310 } else if (tcore_sim_get_type(co_sim) == SIM_TYPE_USIM) {
1311 ctx->ecc_count = resp_read->data.ecc.ecc_count;
1312 for (i = 0; i < resp_read->data.ecc.ecc_count; i++) {
1313 ctx->ecc.UeccInfo[i].EccLen = strlen(resp_read->data.ecc.ecc[i].ecc_num);
1314 if (ctx->ecc.UeccInfo[i].EccLen) {
1315 snprintf(ctx->ecc.UeccInfo[i].szEcc, ctx->ecc.UeccInfo[i].EccLen + 1, "%s", resp_read->data.ecc.ecc[i].ecc_num);
1316 ctx->ecc.UeccInfo[i].bUsed = 1;
1318 if (strlen(resp_read->data.ecc.ecc[i].ecc_string))
1319 snprintf( ctx->ecc.UeccInfo[i].szEccAlphaIdentifier, strlen(resp_read->data.ecc.ecc[i].ecc_string) + 1, "%s", resp_read->data.ecc.ecc[i].ecc_string);
1320 ctx->ecc.UeccInfo[i].EccEmergencyServiceInfo = resp_read->data.ecc.ecc[i].ecc_category;
1325 case TRESP_SIM_GET_LANGUAGE:
1326 dbg("dbus comm - TRESP_SIM_GET_LANGUAGE");
1327 dbg("resp_read->result[%x]",resp_read->result);
1328 ctx->language.LpCount = resp_read->data.language.language_count;
1329 for(i=0; i < (int)ctx->language.LpCount; i++)
1330 ctx->language.Lp[i] = resp_read->data.language.language[i];
1333 case TRESP_SIM_GET_ICCID:
1334 dbg("dbus comm - TRESP_SIM_GET_ICCID");
1335 dbg("resp_read->result[%x]",resp_read->result);
1336 ctx->iccid.icc_length = strlen(resp_read->data.iccid.iccid);
1337 if(ctx->iccid.icc_length > 0)
1338 memcpy(ctx->iccid.icc_num, resp_read->data.iccid.iccid, ctx->iccid.icc_length);
1341 case TRESP_SIM_GET_MSISDN:
1342 dbg("dbus comm - TRESP_SIM_GET_MSISDN");
1343 dbg("resp_read->result[%x]",resp_read->result);
1344 if(resp_read->data.msisdn_list.count > 0) {
1345 dbg("resp_read->data.msisdn_list.msisdn[0].name[%s]",resp_read->data.msisdn_list.msisdn[0].name);
1346 dbg("resp_read->data.msisdn_list.msisdn[0].num[%s]",resp_read->data.msisdn_list.msisdn[0].num);
1347 tmp_msisdn = calloc(strlen((char *)resp_read->data.msisdn_list.msisdn[0].num)+2,1);
1348 if(resp_read->data.msisdn_list.msisdn[0].ton == SIM_TON_INTERNATIONAL){
1349 dbg("current msisdn is international number");
1350 tmp_msisdn[0] = '+';
1351 snprintf(&tmp_msisdn[1], strlen((char *)resp_read->data.msisdn_list.msisdn[0].num)+1, "%s", resp_read->data.msisdn_list.msisdn[0].num);
1353 snprintf(tmp_msisdn, strlen((char *)resp_read->data.msisdn_list.msisdn[0].num)+1, "%s", resp_read->data.msisdn_list.msisdn[0].num);
1355 if (tcore_storage_set_string(strg, STORAGE_KEY_TELEPHONY_SUBSCRIBER_NAME, (const char*) &resp_read->data.msisdn_list.msisdn[0].name) == FALSE )
1356 dbg("[FAIL] UPDATE STORAGE_KEY_TELEPHONY_SUBSCRIBER_NAME");
1357 if (tcore_storage_set_string(strg, STORAGE_KEY_TELEPHONY_SUBSCRIBER_NUMBER, (const char*) tmp_msisdn) == FALSE )
1358 dbg("[FAIL] UPDATE STORAGE_KEY_TELEPHONY_SUBSCRIBER_NUMBER");
1366 case TRESP_SIM_GET_MAILBOX:
1367 case TRESP_SIM_GET_CALLFORWARDING:
1368 case TRESP_SIM_GET_MESSAGEWAITING:
1369 case TRESP_SIM_GET_CPHS_INFO:
1370 case TRESP_SIM_GET_OPLMNWACT:
1373 case TRESP_PHONEBOOK_GETCOUNT:
1374 dbg("dbus comm - TRESP_PHONEBOOK_GETCOUNT");
1375 switch(resp_pbcnt->type){
1377 lpb_cnt.StorageFileType = TAPI_SIM_PB_FDN;
1380 lpb_cnt.StorageFileType = TAPI_SIM_PB_ADN;
1383 lpb_cnt.StorageFileType = TAPI_SIM_PB_SDN;
1386 lpb_cnt.StorageFileType = TAPI_SIM_PB_3GSIM;
1389 lpb_cnt.StorageFileType = TAPI_SIM_PB_AAS;
1392 lpb_cnt.StorageFileType = TAPI_SIM_PB_GAS;
1395 dbg("not handled type[%d]",resp_pbcnt->type);
1398 lpb_cnt.UsedRecordCount = resp_pbcnt->used_count;
1399 lpb_cnt.TotalRecordCount = resp_pbcnt->total_count;
1400 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1401 TAPI_EVENT_SIM_PB_STORAGE_COUNT_CNF, appname, request_id, resp_pbcnt->result,
1402 sizeof(TelSimPbStorageInfo_t), (void*) &lpb_cnt);
1405 case TRESP_PHONEBOOK_GETMETAINFO:
1406 dbg("dbus comm - TRESP_PHONEBOOK_GETMETAINFO");
1407 switch(resp_entry->type){
1409 lpb_entry.StorageFileType = TAPI_SIM_PB_FDN;
1412 lpb_entry.StorageFileType = TAPI_SIM_PB_ADN;
1415 lpb_entry.StorageFileType = TAPI_SIM_PB_SDN;
1418 lpb_entry.StorageFileType = TAPI_SIM_PB_3GSIM;
1421 lpb_entry.StorageFileType = TAPI_SIM_PB_AAS;
1424 lpb_entry.StorageFileType = TAPI_SIM_PB_GAS;
1427 dbg("not handled type[%d]",resp_entry->type);
1430 lpb_entry.PbIndexMax = resp_entry->index_max;
1431 lpb_entry.PbIndexMin = resp_entry->index_min;
1432 lpb_entry.PbNumLenMax = resp_entry->number_length_max;
1433 lpb_entry.PbTextLenMax = resp_entry->text_length_max;
1434 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1435 TAPI_EVENT_SIM_PB_ENTRY_INFO_CNF, appname, request_id, resp_entry->result,
1436 sizeof(TelSimPbEntryInfo_t), (void*) &lpb_entry);
1439 case TRESP_PHONEBOOK_GETUSIMINFO:
1440 dbg("dbus comm - TRESP_PHONEBOOK_GETUSIMINFO");
1441 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1442 TAPI_EVENT_SIM_PB_CAPABILITY_INFO_CNF, appname, request_id, resp_capa->result,
1443 sizeof(TelSimPbCapabilityInfo_t), (void*) &lpb_capa);
1446 case TRESP_PHONEBOOK_READRECORD:
1447 dbg("dbus comm - TRESP_PHONEBOOK_READRECORD");
1448 lcpb_data.index = resp_pbread->index;
1449 lcpb_data.next_index = resp_pbread->next_index;
1451 switch(resp_pbread->phonebook_type){
1453 lcpb_data.phonebook_type = TAPI_SIM_PB_FDN;
1456 lcpb_data.phonebook_type = TAPI_SIM_PB_ADN;
1459 lcpb_data.phonebook_type = TAPI_SIM_PB_SDN;
1462 lcpb_data.phonebook_type = TAPI_SIM_PB_3GSIM;
1465 lcpb_data.phonebook_type = TAPI_SIM_PB_AAS;
1468 lcpb_data.phonebook_type = TAPI_SIM_PB_GAS;
1471 dbg("not handled type[%d]",resp_pbread->phonebook_type);
1474 if(strlen((char*)resp_pbread->name)) {
1475 snprintf((char *)lcpb_data.name, strlen((char*)resp_pbread->name)+1, "%s", resp_pbread->name);
1476 switch( resp_pbread->dcs ){
1477 case PB_TEXT_ASCII :
1478 lcpb_data.dcs = TAPI_SIM_TEXT_ENC_ASCII;
1480 case PB_TEXT_GSM7BIT :
1481 lcpb_data.dcs = TAPI_SIM_TEXT_ENC_GSM7BIT;
1484 lcpb_data.dcs = TAPI_SIM_TEXT_ENC_UCS2;
1487 lcpb_data.dcs = TAPI_SIM_TEXT_ENC_HEX;
1490 dbg("not handled pb type[%d]", resp_pbread->dcs);
1494 if(strlen((char*)resp_pbread->number)) {
1495 snprintf((char *)lcpb_data.number, strlen((char*)resp_pbread->number)+1, "%s", resp_pbread->number);
1496 switch( resp_pbread->ton ){
1497 case PB_TON_UNKNOWN :
1498 lcpb_data.ton = TAPI_SIM_TON_UNKNOWN;
1500 case PB_TON_INTERNATIONAL :
1501 lcpb_data.ton = TAPI_SIM_TON_INTERNATIONAL;
1503 case PB_TON_NATIONAL :
1504 lcpb_data.ton = TAPI_SIM_TON_NATIONAL;
1506 case PB_TON_NETWORK_SPECIFIC :
1507 lcpb_data.ton = TAPI_SIM_TON_NETWORK_SPECIFIC;
1509 case PB_TON_DEDICATED_ACCESS :
1510 lcpb_data.ton = TAPI_SIM_TON_DEDICATED_ACCESS;
1512 case PB_TON_ALPHA_NUMERIC :
1513 lcpb_data.ton = TAPI_SIM_TON_ALPHA_NUMERIC;
1515 case PB_TON_ABBREVIATED_NUMBER :
1516 lcpb_data.ton = TAPI_SIM_TON_ABBREVIATED_NUMBER;
1518 case PB_TON_RESERVED_FOR_EXT :
1519 lcpb_data.ton = TAPI_SIM_TON_RESERVED_FOR_EXT;
1522 dbg("not handled pb ton[%d]", resp_pbread->ton);
1527 if(strlen((char*)resp_pbread->anr1)) {
1528 snprintf((char *)lcpb_data.anr1, strlen((char*)resp_pbread->anr1)+1, "%s", resp_pbread->anr1);
1529 switch( resp_pbread->anr1_ton ){
1530 case PB_TON_UNKNOWN :
1531 lcpb_data.anr1_ton = TAPI_SIM_TON_UNKNOWN;
1533 case PB_TON_INTERNATIONAL :
1534 lcpb_data.anr1_ton = TAPI_SIM_TON_INTERNATIONAL;
1536 case PB_TON_NATIONAL :
1537 lcpb_data.anr1_ton = TAPI_SIM_TON_NATIONAL;
1539 case PB_TON_NETWORK_SPECIFIC :
1540 lcpb_data.anr1_ton = TAPI_SIM_TON_NETWORK_SPECIFIC;
1542 case PB_TON_DEDICATED_ACCESS :
1543 lcpb_data.anr1_ton = TAPI_SIM_TON_DEDICATED_ACCESS;
1545 case PB_TON_ALPHA_NUMERIC :
1546 lcpb_data.anr1_ton = TAPI_SIM_TON_ALPHA_NUMERIC;
1548 case PB_TON_ABBREVIATED_NUMBER :
1549 lcpb_data.anr1_ton = TAPI_SIM_TON_ABBREVIATED_NUMBER;
1551 case PB_TON_RESERVED_FOR_EXT :
1552 lcpb_data.anr1_ton = TAPI_SIM_TON_RESERVED_FOR_EXT;
1555 dbg("not handled pb anr1_ton[%d]", resp_pbread->anr1_ton);
1560 if(strlen((char*)resp_pbread->anr2)) {
1561 snprintf((char *)lcpb_data.anr2, strlen((char*)resp_pbread->anr2)+1, "%s", resp_pbread->anr2);
1562 switch( resp_pbread->anr2_ton ){
1563 case PB_TON_UNKNOWN :
1564 lcpb_data.anr2_ton = TAPI_SIM_TON_UNKNOWN;
1566 case PB_TON_INTERNATIONAL :
1567 lcpb_data.anr2_ton = TAPI_SIM_TON_INTERNATIONAL;
1569 case PB_TON_NATIONAL :
1570 lcpb_data.anr2_ton = TAPI_SIM_TON_NATIONAL;
1572 case PB_TON_NETWORK_SPECIFIC :
1573 lcpb_data.anr2_ton = TAPI_SIM_TON_NETWORK_SPECIFIC;
1575 case PB_TON_DEDICATED_ACCESS :
1576 lcpb_data.anr2_ton = TAPI_SIM_TON_DEDICATED_ACCESS;
1578 case PB_TON_ALPHA_NUMERIC :
1579 lcpb_data.anr2_ton = TAPI_SIM_TON_ALPHA_NUMERIC;
1581 case PB_TON_ABBREVIATED_NUMBER :
1582 lcpb_data.anr2_ton = TAPI_SIM_TON_ABBREVIATED_NUMBER;
1584 case PB_TON_RESERVED_FOR_EXT :
1585 lcpb_data.anr2_ton = TAPI_SIM_TON_RESERVED_FOR_EXT;
1588 dbg("not handled pb anr2_ton[%d]", resp_pbread->anr2_ton);
1593 if(strlen((char*)resp_pbread->anr3)) {
1594 snprintf((char *)lcpb_data.anr3, strlen((char*)resp_pbread->anr3)+1, "%s", resp_pbread->anr3);
1595 switch( resp_pbread->anr3_ton ){
1596 case PB_TON_UNKNOWN :
1597 lcpb_data.anr3_ton = TAPI_SIM_TON_UNKNOWN;
1599 case PB_TON_INTERNATIONAL :
1600 lcpb_data.anr3_ton = TAPI_SIM_TON_INTERNATIONAL;
1602 case PB_TON_NATIONAL :
1603 lcpb_data.anr3_ton = TAPI_SIM_TON_NATIONAL;
1605 case PB_TON_NETWORK_SPECIFIC :
1606 lcpb_data.anr3_ton = TAPI_SIM_TON_NETWORK_SPECIFIC;
1608 case PB_TON_DEDICATED_ACCESS :
1609 lcpb_data.anr3_ton = TAPI_SIM_TON_DEDICATED_ACCESS;
1611 case PB_TON_ALPHA_NUMERIC :
1612 lcpb_data.anr3_ton = TAPI_SIM_TON_ALPHA_NUMERIC;
1614 case PB_TON_ABBREVIATED_NUMBER :
1615 lcpb_data.anr3_ton = TAPI_SIM_TON_ABBREVIATED_NUMBER;
1617 case PB_TON_RESERVED_FOR_EXT :
1618 lcpb_data.anr3_ton = TAPI_SIM_TON_RESERVED_FOR_EXT;
1621 dbg("not handled pb anr3_ton[%d]", resp_pbread->anr3_ton);
1626 if(strlen((char*)resp_pbread->email1))
1627 snprintf((char *)lcpb_data.email1, strlen((char*)resp_pbread->email1)+1, "%s", resp_pbread->email1);
1628 if(strlen((char*)resp_pbread->email2))
1629 snprintf((char *)lcpb_data.email2, strlen((char*)resp_pbread->email2)+1, "%s", resp_pbread->email2);
1630 if(strlen((char*)resp_pbread->email3))
1631 snprintf((char *)lcpb_data.email3, strlen((char*)resp_pbread->email3)+1, "%s", resp_pbread->email3);
1632 if(strlen((char*)resp_pbread->email4))
1633 snprintf((char *)lcpb_data.email4, strlen((char*)resp_pbread->email4)+1, "%s", resp_pbread->email4);
1635 lcpb_data.group_index = resp_pbread->group_index;
1636 lcpb_data.pb_control = resp_pbread->pb_control;
1638 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1639 TAPI_EVENT_SIM_PB_ACCESS_READ_CNF, appname, request_id, resp_pbread->result,
1640 sizeof(TelSimPbRecordData_t), (void*) &lcpb_data);
1643 case TRESP_PHONEBOOK_UPDATERECORD:
1644 dbg("dbus comm - TRESP_PHONEBOOK_UPDATERECORD");
1645 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1646 TAPI_EVENT_SIM_PB_UPDATE_CNF, appname, request_id, resp_pbupdate->result,
1650 case TRESP_PHONEBOOK_DELETERECORD:
1651 dbg("dbus comm - TRESP_PHONEBOOK_DELETERECORD");
1652 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1653 TAPI_EVENT_SIM_PB_DELETE_CNF, appname, request_id, resp_pbdelete->result,
1657 case TRESP_SAP_REQ_CONNECT:
1658 lsa_conn.ConnectionStatus = sap_conn->status;
1659 lsa_conn.MaxMsgSize = sap_conn->max_msg_size;
1660 lsa_conn.MsgId = TAPI_SIM_SAP_CONNECT_RESP;
1661 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1662 TAPI_EVENT_SIM_SAP_CONNECT_CNF, appname, request_id, TAPI_SIM_ACCESS_SUCCESS,
1663 sizeof(TelSimSapConnect_t), (void*) &lsa_conn);
1666 case TRESP_SAP_REQ_DISCONNECT:
1667 lsa_disconn.MsgId = TAPI_SIM_SAP_DISCONNECT_RESP;
1668 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1669 TAPI_EVENT_SIM_SAP_CONNECT_CNF, appname, request_id, TAPI_SIM_ACCESS_SUCCESS,
1670 sizeof(TelSimSapConnect_t), (void*) &lsa_disconn);
1673 case TRESP_SAP_REQ_STATUS:
1674 lsa_status = sap_status->status;
1675 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1676 TAPI_EVENT_SIM_SAP_CONNECT_STATUS_CNF, appname, request_id,
1677 TAPI_SIM_ACCESS_SUCCESS, sizeof(unsigned int), (void*) &lsa_status);
1680 case TRESP_SAP_REQ_ATR:
1681 lsa_atr.AtrResult = sap_atr->result;
1682 lsa_atr.AtrLength = sap_atr->atr_length;
1683 memcpy(lsa_atr.AtrData, sap_atr->atr, lsa_atr.AtrLength);
1684 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1685 TAPI_EVENT_SIM_SAP_TRANSFER_ATR_CNF, appname, request_id,
1686 TAPI_SIM_ACCESS_SUCCESS, sizeof(TelSimSapAtrInfo_t), (void*) &lsa_atr);
1689 case TRESP_SAP_TRANSFER_APDU:
1690 lsa_apdu.ApduLength = sap_apdu->resp_apdu_length;
1691 memcpy(lsa_apdu.Apdu, sap_apdu->resp_adpdu, lsa_apdu.ApduLength);
1692 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1693 TAPI_EVENT_SIM_SAP_TRANSFER_APDU_CNF, appname, request_id,
1694 TAPI_SIM_ACCESS_SUCCESS, sizeof(TelSimSapApduData_t), (void*) &lsa_apdu);
1697 case TRESP_SAP_SET_PROTOCOL:
1698 lsa_result_code = sap_protocol->result;
1699 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1700 TAPI_EVENT_SIM_SAP_SET_PROTOCOL_CNF, appname, request_id,
1701 TAPI_SIM_ACCESS_SUCCESS, sizeof(TelSimSapResultCode_t),
1702 (void*) &lsa_result_code);
1705 case TRESP_SAP_SET_POWER:
1706 lsa_power.SimPowerResult = sap_power->result;
1707 lsa_power.MsgId = 0; //NOT SUPPORTED FROM NOW
1708 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1709 TAPI_EVENT_SIM_SAP_SET_SIM_POWER_CNF, appname, request_id,
1710 TAPI_SIM_ACCESS_SUCCESS, sizeof(TelSimSapPower_t), (void*) &lsa_power);
1713 case TRESP_SAP_REQ_CARDREADERSTATUS:
1714 lsa_reader.CardReaderResult = sap_reader->result;
1715 lsa_reader.CardReaderStatus = sap_reader->reader_status;
1716 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM,
1717 TAPI_EVENT_SIM_SAP_CARD_READER_STATUS_CNF, appname, request_id,
1718 TAPI_SIM_ACCESS_SUCCESS, sizeof(TelSimCardReaderStatus_t), (void*) &lsa_reader);
1727 TReturn dbus_notification_sim(struct custom_data *ctx, CoreObject *source, enum tcore_notification_command command,
1728 unsigned int data_len, const void *data)
1730 const struct tnoti_sap_status_changed *n_sap_status = data;
1731 const struct tnoti_sap_disconnect *n_sap_disconn = data;
1732 const struct tnoti_sim_status *n_sim_status = data;
1735 case TNOTI_SIM_STATUS:
1736 dbg("notified sim_status[%d]", n_sim_status->sim_status);
1737 dbus_sim_data_request(ctx, source,n_sim_status->sim_status);
1738 if(n_sim_status->sim_status == SIM_STATUS_INIT_COMPLETED)
1739 dbus_sim_security_request(ctx, source);
1740 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM, TAPI_EVENT_SIM_STATUS_IND,
1741 NULL, TAPI_SIM_REQUEST_ID_FOR_NOTI, n_sim_status->sim_status, 0, NULL);
1744 case TNOTI_SAP_STATUS:
1745 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM, TAPI_EVENT_SIM_SAP_CONNECT_STATUS_CNF,
1746 NULL, TAPI_SIM_REQUEST_ID_FOR_NOTI, TAPI_SIM_ACCESS_SUCCESS, sizeof(enum tel_sap_status_change), (void*)&n_sap_status->status);
1749 case TNOTI_SAP_DISCONNECT:
1750 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM, TAPI_EVENT_SIM_SAP_CONNECT_NOTI,
1751 NULL, TAPI_SIM_REQUEST_ID_FOR_NOTI, TAPI_SIM_ACCESS_SUCCESS, sizeof(enum tel_sap_disconnect_type), (void*)&n_sap_disconn->type);
1754 case TNOTI_PHONEBOOK_STATUS :
1755 return ts_delivery_event(ctx->EvtDeliveryHandle, TAPI_EVENT_CLASS_SIM, TAPI_EVENT_SIM_FDN_STATUS_IND,
1756 NULL, TAPI_SIM_REQUEST_ID_FOR_NOTI, TAPI_SIM_PB_SUCCESS, 0, NULL);