2 * tel-plugin-socket-communicator
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.
25 #include <glib-object.h>
31 #include <communicator.h>
32 #include <core_object.h>
34 #include <user_request.h>
39 #include "tapi_common.h"
40 #include "module_req.h"
42 gboolean scomm_service_reqeust_sim(unsigned int ch_id, Communicator *c, TcorePlugin *plugin, tapi_service_command_e cmd, gchar *data, void **outparam)
44 GSList *co_list = NULL;
45 CoreObject *co_sim = NULL;
46 UserRequest *ur = NULL;
47 struct tcore_user_info ui = { 0, 0, 0, NULL,0,0, NULL };
52 struct _tapi_service_object out_o = {0,};
53 struct _sipc_marshal_object *in_o;
55 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_SIM);
57 dbg("err-no sim core object list in current plugin");
61 co_sim = (CoreObject *)co_list->data;
63 dbg("err-no sim core object in current plugin");
67 g_slist_free(co_list);
69 if (cmd == TAPI_SERVICE_SIM_GET_SIMINITINFO || cmd == TAPI_SERVICE_SIM_GET_TYPE
70 || cmd == TAPI_SERVICE_SIM_GET_IMSI ) {
71 /*synchronous data return case*/
73 out_o.mo = sipc_util_marshal_object_create();
75 /*asynchronous data return case*/
76 ur = tcore_user_request_new(c, tcore_plugin_get_description(plugin)->name);
78 dbg("err - ur creation failed");
82 ui.channel_id = ch_id;
84 tcore_user_request_set_user_info(ur, &ui);
86 in_o = sipc_util_marshal_object_deserializer(data);
88 dbg("err - data deserializer failed");
94 case TAPI_SERVICE_SIM_GET_SIMINITINFO : {
95 enum tel_sim_status sim_status = SIM_STATUS_UNKNOWN;
96 gboolean sim_changed = FALSE;
97 sim_status = tcore_sim_get_status(co_sim);
98 sipc_util_marshal_object_add_data(out_o.mo, "status", &sim_status,
99 SIPC_MARSHAL_DATA_INT_TYPE);
100 sipc_util_marshal_object_add_data(out_o.mo, "new_sim", &sim_changed,
101 SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
102 tmp = sipc_util_marshal_object_serializer(out_o.mo);
103 tmp_len = strlen(tmp);
104 *outparam = g_new0(char, tmp_len+1);
105 memcpy(*outparam, tmp, tmp_len);
110 case TAPI_SERVICE_SIM_GET_TYPE : {
111 enum tel_sim_type type = SIM_TYPE_UNKNOWN;
112 type = tcore_sim_get_type(co_sim);
113 sipc_util_marshal_object_add_data(out_o.mo, "type", &type,
114 SIPC_MARSHAL_DATA_INT_TYPE);
115 tmp = sipc_util_marshal_object_serializer(out_o.mo);
116 tmp_len = strlen(tmp);
117 *outparam = g_new0(char, tmp_len+1);
118 memcpy(*outparam, tmp, tmp_len);
123 case TAPI_SERVICE_SIM_GET_IMSI : {
124 struct tel_sim_imsi *n_imsi = NULL;
125 n_imsi = tcore_sim_get_imsi(co_sim);
126 if (n_imsi != NULL) {
127 dbg("n_imsi->plmn[%s]", n_imsi->plmn);
128 sipc_util_marshal_object_add_data(out_o.mo, "mcc", n_imsi->plmn,
129 SIPC_MARSHAL_DATA_STRING_TYPE);
130 sipc_util_marshal_object_add_data(out_o.mo, "mnc", n_imsi->plmn + 3,
131 SIPC_MARSHAL_DATA_STRING_TYPE);
132 sipc_util_marshal_object_add_data(out_o.mo, "msin", n_imsi->msin,
133 SIPC_MARSHAL_DATA_STRING_TYPE);
134 tmp = sipc_util_marshal_object_serializer(out_o.mo);
135 tmp_len = strlen(tmp);
136 *outparam = g_new0(char, tmp_len+1);
137 memcpy(*outparam, tmp, tmp_len);
143 case TAPI_SERVICE_SIM_GET_ECC :
144 tcore_user_request_set_command(ur, TREQ_SIM_GET_ECC);
147 case TAPI_SERVICE_SIM_GET_ICCID :
148 tcore_user_request_set_command(ur, TREQ_SIM_GET_ICCID);
151 case TAPI_SERVICE_SIM_GET_LANGUAGE :
152 tcore_user_request_set_command(ur, TREQ_SIM_GET_LANGUAGE);
155 case TAPI_SERVICE_SIM_SET_LANGUAGE : {
156 struct treq_sim_set_language set_language = { 0, };
157 enum tel_sim_language_type g_language;
158 g_language = sipc_util_marshal_object_get_int(in_o, "language");
160 set_language.language = g_language;
162 tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_language), &set_language);
163 tcore_user_request_set_command(ur, TREQ_SIM_SET_LANGUAGE);
167 case TAPI_SERVICE_SIM_GET_CF :
168 tcore_user_request_set_command(ur, TREQ_SIM_GET_CALLFORWARDING);
171 case TAPI_SERVICE_SIM_SET_CF :
172 /*not defined value yet*/
175 case TAPI_SERVICE_SIM_GET_MW :
176 tcore_user_request_set_command(ur, TREQ_SIM_GET_MESSAGEWAITING);
179 case TAPI_SERVICE_SIM_SET_MW :
180 /*not defined value yet*/
183 case TAPI_SERVICE_SIM_GET_MB :
184 tcore_user_request_set_command(ur, TREQ_SIM_GET_MAILBOX);
187 case TAPI_SERVICE_SIM_SET_MB :
188 /*not defined value yet*/
191 case TAPI_SERVICE_SIM_GET_CPHSINFO :
192 tcore_user_request_set_command(ur, TREQ_SIM_GET_CPHS_INFO);
195 case TAPI_SERVICE_SIM_AUTHENTICATION : {
196 struct treq_sim_req_authentication req_auth = { 0, };
197 enum tel_sim_auth_type g_auth_type;
198 unsigned int g_autn_length;
199 unsigned char *g_autn_data;
200 unsigned int g_rand_length;
201 unsigned char *g_rand_data;
202 g_auth_type = sipc_util_marshal_object_get_int(in_o, "type");
203 g_autn_data = sipc_util_marshal_object_get_string(in_o, "autn_data");
204 g_autn_length = strlen(g_autn_data);
205 g_rand_data = sipc_util_marshal_object_get_string(in_o, "rand_data");
206 g_rand_length = strlen(g_rand_data);
208 req_auth.auth_type = g_auth_type;
209 req_auth.autn_length = g_autn_length;
210 if(req_auth.autn_length)
211 memcpy(req_auth.autn_data, g_autn_data, req_auth.autn_length);
212 req_auth.rand_length = g_rand_length;
213 if(req_auth.rand_length)
214 memcpy(req_auth.rand_data, g_rand_data, req_auth.rand_length);
216 tcore_user_request_set_data(ur, sizeof(struct treq_sim_req_authentication), &req_auth);
217 tcore_user_request_set_command(ur, TREQ_SIM_REQ_AUTHENTICATION);
221 case TAPI_SERVICE_SIM_VERIFYSEC : {
222 struct treq_sim_verify_pins verify_pins = { 0, };
223 enum tel_sim_pin_type g_pin_type;
224 unsigned int g_pin_length;
225 unsigned char *g_pin;
226 g_pin_type = sipc_util_marshal_object_get_int(in_o, "type");
227 g_pin = sipc_util_marshal_object_get_string(in_o, "pw");
228 g_pin_length = strlen(g_pin);
230 verify_pins.pin_type = g_pin_type;
231 verify_pins.pin_length = g_pin_length;
232 memcpy(verify_pins.pin, g_pin, verify_pins.pin_length);
234 tcore_user_request_set_data(ur, sizeof(struct treq_sim_verify_pins), &verify_pins);
235 tcore_user_request_set_command(ur, TREQ_SIM_VERIFY_PINS);
239 case TAPI_SERVICE_SIM_VERIFYPUK : {
240 struct treq_sim_verify_puks verify_puks = { 0, };
241 enum tel_sim_pin_type g_puk_type;
242 unsigned int g_puk_length;
243 unsigned char *g_puk;
244 unsigned int g_pin_length;
245 unsigned char *g_pin;
246 g_puk_type = sipc_util_marshal_object_get_int(in_o, "type");
247 g_puk = sipc_util_marshal_object_get_string(in_o, "puk");
248 g_puk_length = strlen(g_puk);
249 g_pin = sipc_util_marshal_object_get_string(in_o, "pin");
250 g_pin_length = strlen(g_pin);
252 verify_puks.puk_type = g_puk_type;
253 verify_puks.puk_length = g_puk_length;
254 memcpy(verify_puks.puk, g_puk, verify_puks.puk_length);
255 verify_puks.pin_length = g_pin_length;
256 memcpy(verify_puks.pin, g_pin, verify_puks.pin_length);
258 tcore_user_request_set_data(ur, sizeof(struct treq_sim_verify_puks), &verify_puks);
259 tcore_user_request_set_command(ur, TREQ_SIM_VERIFY_PUKS);
263 case TAPI_SERVICE_SIM_CHANGEPIN : {
264 struct treq_sim_change_pins change_pins = { 0, };
265 enum tel_sim_pin_type g_type;
266 unsigned int g_old_pw_length;
267 unsigned char *g_old_pw;
268 unsigned int g_new_pw_length;
269 unsigned char *g_new_pw;
270 g_type = sipc_util_marshal_object_get_int(in_o, "type");
271 g_old_pw = sipc_util_marshal_object_get_string(in_o, "old_pw");
272 g_old_pw_length = strlen(g_old_pw);
273 g_new_pw = sipc_util_marshal_object_get_string(in_o, "new_pw");
274 g_new_pw_length = strlen(g_new_pw);
276 change_pins.type = g_type;
277 change_pins.old_pin_length = g_old_pw_length;
278 memcpy(change_pins.old_pin, g_old_pw, change_pins.old_pin_length);
279 change_pins.new_pin_length = g_new_pw_length;
280 memcpy(change_pins.new_pin, g_new_pw, change_pins.new_pin_length);
282 tcore_user_request_set_data(ur, sizeof(struct treq_sim_change_pins), &change_pins);
283 tcore_user_request_set_command(ur, TREQ_SIM_CHANGE_PINS);
287 case TAPI_SERVICE_SIM_DISABLE_FACILITY : {
288 struct treq_sim_disable_facility dis_facility = { 0, };
289 enum tel_sim_facility_type g_dis_type;
290 unsigned int g_dis_pw_length;
291 unsigned char *g_dis_pw;
292 g_dis_type = sipc_util_marshal_object_get_int(in_o, "type");
293 g_dis_pw = sipc_util_marshal_object_get_string(in_o, "pw");
294 g_dis_pw_length = strlen(g_dis_pw);
296 dis_facility.type = g_dis_type;
297 dis_facility.password_length = g_dis_pw_length;
298 memcpy(dis_facility.password, g_dis_pw, dis_facility.password_length);
300 tcore_user_request_set_data(ur, sizeof(struct treq_sim_disable_facility), &dis_facility);
301 tcore_user_request_set_command(ur, TREQ_SIM_DISABLE_FACILITY);
305 case TAPI_SERVICE_SIM_ENABLE_FACILITY : {
306 struct treq_sim_enable_facility en_facility = { 0, };
307 enum tel_sim_facility_type g_en_type;
308 unsigned int g_en_pw_length;
309 unsigned char *g_en_pw;
310 g_en_type = sipc_util_marshal_object_get_int(in_o, "type");
311 g_en_pw = sipc_util_marshal_object_get_string(in_o, "pw");
312 g_en_pw_length = strlen(g_en_pw);
314 en_facility.type = g_en_type;
315 en_facility.password_length = g_en_pw_length;
316 memcpy(en_facility.password, g_en_pw, en_facility.password_length);
318 tcore_user_request_set_data(ur, sizeof(struct treq_sim_enable_facility), &en_facility);
319 tcore_user_request_set_command(ur, TREQ_SIM_ENABLE_FACILITY);
323 case TAPI_SERVICE_SIM_GET_FACILITY : {
324 struct treq_sim_get_facility_status facility = { 0, };
325 enum tel_sim_facility_type g_facility_type;
326 sipc_util_marshal_object_get_data(in_o, "type", (void **)&g_facility_type, TAPI_OBJECT_DATA_TYPE_INT);
328 facility.type = g_facility_type;
330 tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_facility_status), &facility);
331 tcore_user_request_set_command(ur, TREQ_SIM_GET_FACILITY_STATUS);
335 case TAPI_SERVICE_SIM_APDU : {
336 struct treq_sim_transmit_apdu send_apdu ={ 0, };
339 g_apdu = sipc_util_marshal_object_get_string(in_o, "apdu");
340 g_apdu_length = strlen(g_apdu);
342 send_apdu.apdu_length = (unsigned int)g_apdu_length;
343 memcpy(send_apdu.apdu, g_apdu, send_apdu.apdu_length);
345 tcore_user_request_set_data(ur, sizeof(struct treq_sim_transmit_apdu), &send_apdu);
346 tcore_user_request_set_command(ur, TREQ_SIM_TRANSMIT_APDU);
350 case TAPI_SERVICE_SIM_ATR :
351 tcore_user_request_set_command(ur, TREQ_SIM_GET_ATR);
355 dbg("not handled command [%d] here",cmd);
359 if (cmd == TAPI_SERVICE_SIM_GET_SIMINITINFO || cmd == TAPI_SERVICE_SIM_GET_TYPE
360 || cmd == TAPI_SERVICE_SIM_GET_IMSI ) {
361 /*synchronous data return case*/
364 /*asynchronous data return case*/
365 ret = tcore_communicator_dispatch_request(c, ur);
366 if (ret != TCORE_RETURN_SUCCESS) {
374 gboolean scomm_service_response_sim(Communicator *comm, UserRequest *ur, enum tcore_response_command command,
375 unsigned int data_len, const void *data)
377 const struct tresp_sim_verify_pins *resp_verify_pins = data;
378 const struct tresp_sim_verify_puks *resp_verify_puks = data;
379 const struct tresp_sim_change_pins *resp_change_pins = data;
380 const struct tresp_sim_get_facility_status *resp_get_facility = data;
381 const struct tresp_sim_disable_facility *resp_dis_facility = data;
382 const struct tresp_sim_enable_facility *resp_en_facility = data;
383 const struct tresp_sim_transmit_apdu *resp_apdu = data;
384 const struct tresp_sim_get_atr *resp_get_atr = data;
385 const struct tresp_sim_read *resp_read = data;
386 const struct tresp_sim_req_authentication *resp_auth = data;
387 const struct tresp_sim_set_language *resp_set_language = data;
390 gchar *out_d= NULL, *serial_d = NULL;
391 gchar *entry_key = NULL;
392 struct custom_data *ctx = NULL;
393 const struct tcore_user_info *ui;
394 sipc_server_t *s = NULL;
395 struct _tapi_header hdr;
396 struct _sipc_marshal_object* out_o = NULL;
397 struct _sipc_marshal_object* entry_o = NULL;
399 memset(&hdr, 0, sizeof(struct _tapi_header));
401 ctx = tcore_communicator_ref_user_data(comm);
403 dbg("user_data is NULL");
407 ui = tcore_user_request_ref_user_info(ur);
410 dbg("application channel id(%d), Command = [0x%x], data_len = %d", ui->channel_id, command, data_len);
411 hdr.cmd = (tapi_service_command_e)ui->client_cmd;
413 out_o = sipc_util_marshal_object_create();
416 case TRESP_SIM_VERIFY_PINS:
417 dbg("resp comm - TRESP_SIM_VERIFY_PINS");
418 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_verify_pins->result, SIPC_MARSHAL_DATA_INT_TYPE);
419 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_verify_pins->pin_type, SIPC_MARSHAL_DATA_INT_TYPE);
420 sipc_util_marshal_object_add_data(out_o, "remain_count", (void*)&resp_verify_pins->retry_count, SIPC_MARSHAL_DATA_INT_TYPE);
423 case TRESP_SIM_VERIFY_PUKS:
424 dbg("resp comm - TRESP_SIM_VERIFY_PUKS");
425 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_verify_puks->result, SIPC_MARSHAL_DATA_INT_TYPE);
426 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_verify_puks->pin_type, SIPC_MARSHAL_DATA_INT_TYPE);
427 sipc_util_marshal_object_add_data(out_o, "remain_count", (void*)&resp_verify_puks->retry_count, SIPC_MARSHAL_DATA_INT_TYPE);
430 case TRESP_SIM_CHANGE_PINS:
431 dbg("resp comm - TRESP_SIM_CHANGE_PINS");
432 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_change_pins->result, SIPC_MARSHAL_DATA_INT_TYPE);
433 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_change_pins->pin_type, SIPC_MARSHAL_DATA_INT_TYPE);
434 sipc_util_marshal_object_add_data(out_o, "remain_count", (void*)&resp_change_pins->retry_count, SIPC_MARSHAL_DATA_INT_TYPE);
437 case TRESP_SIM_GET_FACILITY_STATUS:
438 dbg("resp comm - TRESP_SIM_GET_FACILITY_STATUS");
439 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_get_facility->result, SIPC_MARSHAL_DATA_INT_TYPE);
440 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_get_facility->type, SIPC_MARSHAL_DATA_INT_TYPE);
441 sipc_util_marshal_object_add_data(out_o, "enabled", (void*)&resp_get_facility->b_enable, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
444 case TRESP_SIM_DISABLE_FACILITY:
445 dbg("resp comm - TRESP_SIM_DISABLE_FACILITY");
446 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_dis_facility->result, SIPC_MARSHAL_DATA_INT_TYPE);
447 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_dis_facility->type, SIPC_MARSHAL_DATA_INT_TYPE);
448 sipc_util_marshal_object_add_data(out_o, "remain_count", (void*)&resp_dis_facility->retry_count, SIPC_MARSHAL_DATA_INT_TYPE);
451 case TRESP_SIM_ENABLE_FACILITY:
452 dbg("resp comm - TRESP_SIM_ENABLE_FACILITY");
453 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_en_facility->result, SIPC_MARSHAL_DATA_INT_TYPE);
454 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_en_facility->type, SIPC_MARSHAL_DATA_INT_TYPE);
455 sipc_util_marshal_object_add_data(out_o, "remain_count", (void*)&resp_en_facility->retry_count, SIPC_MARSHAL_DATA_INT_TYPE);
458 case TRESP_SIM_TRANSMIT_APDU:
459 dbg("resp comm - TRESP_SIM_TRANSMIT_APDU");
460 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_apdu->result, SIPC_MARSHAL_DATA_INT_TYPE);
461 sipc_util_marshal_object_add_data(out_o, "apdu", (void*)&resp_apdu->apdu_resp, SIPC_MARSHAL_DATA_STRING_TYPE);
464 case TRESP_SIM_GET_ATR:
465 dbg("resp comm - TRESP_SIM_GET_ATR");
466 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_get_atr->result, SIPC_MARSHAL_DATA_INT_TYPE);
467 sipc_util_marshal_object_add_data(out_o, "atr", (void*)&resp_get_atr->atr, SIPC_MARSHAL_DATA_STRING_TYPE);
470 case TRESP_SIM_REQ_AUTHENTICATION:
471 dbg("resp comm - TRESP_SIM_REQ_AUTHENTICATION");
472 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_auth->auth_result, SIPC_MARSHAL_DATA_INT_TYPE);
473 sipc_util_marshal_object_add_data(out_o, "type", (void*)&resp_auth->auth_type, SIPC_MARSHAL_DATA_STRING_TYPE);
474 if(resp_auth->authentication_key_length)
475 sipc_util_marshal_object_add_data(out_o, "authentication_key", (void*)&resp_auth->authentication_key, SIPC_MARSHAL_DATA_STRING_TYPE);
476 if(resp_auth->cipher_length)
477 sipc_util_marshal_object_add_data(out_o, "cipher_data", (void*)&resp_auth->cipher_data, SIPC_MARSHAL_DATA_STRING_TYPE);
478 if(resp_auth->integrity_length)
479 sipc_util_marshal_object_add_data(out_o, "integrity_data", (void*)&resp_auth->integrity_data, SIPC_MARSHAL_DATA_STRING_TYPE);
480 if(resp_auth->resp_length)
481 sipc_util_marshal_object_add_data(out_o, "resp_data", (void*)&resp_auth->resp_data, SIPC_MARSHAL_DATA_STRING_TYPE);
484 case TRESP_SIM_SET_LANGUAGE:
485 dbg("resp comm - TRESP_SIM_SET_LANGUAGE");
486 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_set_language->result, SIPC_MARSHAL_DATA_INT_TYPE);
489 case TRESP_SIM_GET_ECC:
490 dbg("resp comm - TRESP_SIM_GET_ECC");
491 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
492 sipc_util_marshal_object_add_data(out_o, "count", (void*)&resp_read->data.ecc.ecc_count, SIPC_MARSHAL_DATA_INT_TYPE);
493 entry_o = sipc_util_marshal_object_create();
494 for(i=0;i < resp_read->data.ecc.ecc_count; i++){
495 gchar *entry_key = NULL;
496 sipc_util_marshal_object_add_data(entry_o, "name", (void*)&resp_read->data.ecc.ecc[i].ecc_string, SIPC_MARSHAL_DATA_STRING_TYPE);
497 sipc_util_marshal_object_add_data(entry_o, "number", (void*)&resp_read->data.ecc.ecc[i].ecc_num, SIPC_MARSHAL_DATA_STRING_TYPE);
498 sipc_util_marshal_object_add_data(entry_o, "category", (void*)&resp_read->data.ecc.ecc[i].ecc_category, SIPC_MARSHAL_DATA_INT_TYPE);
499 entry_key = g_strdup_printf("%d", i);
500 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
504 case TRESP_SIM_GET_LANGUAGE:
505 dbg("resp comm - TRESP_SIM_GET_LANGUAGE");
506 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
507 sipc_util_marshal_object_add_data(out_o, "language", (void*)&resp_read->data.language.language[0] , SIPC_MARSHAL_DATA_INT_TYPE);
510 case TRESP_SIM_GET_ICCID:
511 dbg("resp comm - TRESP_SIM_GET_ICCID");
512 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
513 sipc_util_marshal_object_add_data(out_o, "iccid", (void*)&resp_read->data.iccid.iccid , SIPC_MARSHAL_DATA_STRING_TYPE);
516 case TRESP_SIM_GET_MAILBOX:
517 dbg("resp comm - TRESP_SIM_GET_MAILBOX");
518 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
519 entry_o = sipc_util_marshal_object_create();
520 if(resp_read->data.mailbox.voice1.DiallingnumLength){
522 sipc_util_marshal_object_add_data(entry_o, "type", "voice1", SIPC_MARSHAL_DATA_STRING_TYPE);
523 sipc_util_marshal_object_add_data(entry_o, "name", (void*)&resp_read->data.mailbox.voice1.AlphaId, SIPC_MARSHAL_DATA_STRING_TYPE);
524 sipc_util_marshal_object_add_data(entry_o, "number", (void*)&resp_read->data.mailbox.voice1.DiallingNum , SIPC_MARSHAL_DATA_STRING_TYPE);
525 sipc_util_marshal_object_add_data(entry_o, "ton", (void*)&resp_read->data.mailbox.voice1.TypeOfNumber , SIPC_MARSHAL_DATA_INT_TYPE);
526 sipc_util_marshal_object_add_data(entry_o, "npi", (void*)&resp_read->data.mailbox.voice1.NumberingPlanIdent , SIPC_MARSHAL_DATA_INT_TYPE);
527 entry_key = g_strdup_printf("%d", count);
528 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
531 if(resp_read->data.mailbox.voice2.DiallingnumLength){
533 sipc_util_marshal_object_add_data(entry_o, "type", "voice2", SIPC_MARSHAL_DATA_STRING_TYPE);
534 sipc_util_marshal_object_add_data(entry_o, "name", (void*)&resp_read->data.mailbox.voice2.AlphaId, SIPC_MARSHAL_DATA_STRING_TYPE);
535 sipc_util_marshal_object_add_data(entry_o, "number", (void*)&resp_read->data.mailbox.voice2.DiallingNum , SIPC_MARSHAL_DATA_STRING_TYPE);
536 sipc_util_marshal_object_add_data(entry_o, "ton", (void*)&resp_read->data.mailbox.voice2.TypeOfNumber , SIPC_MARSHAL_DATA_INT_TYPE);
537 sipc_util_marshal_object_add_data(entry_o, "npi", (void*)&resp_read->data.mailbox.voice2.NumberingPlanIdent , SIPC_MARSHAL_DATA_INT_TYPE);
538 entry_key = g_strdup_printf("%d", count);
539 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
542 if(resp_read->data.mailbox.fax.DiallingnumLength){
544 sipc_util_marshal_object_add_data(entry_o, "type", "fax", SIPC_MARSHAL_DATA_STRING_TYPE);
545 sipc_util_marshal_object_add_data(entry_o, "name", (void*)&resp_read->data.mailbox.fax.AlphaId, SIPC_MARSHAL_DATA_STRING_TYPE);
546 sipc_util_marshal_object_add_data(entry_o, "number", (void*)&resp_read->data.mailbox.fax.DiallingNum , SIPC_MARSHAL_DATA_STRING_TYPE);
547 sipc_util_marshal_object_add_data(entry_o, "ton", (void*)&resp_read->data.mailbox.fax.TypeOfNumber , SIPC_MARSHAL_DATA_INT_TYPE);
548 sipc_util_marshal_object_add_data(entry_o, "npi", (void*)&resp_read->data.mailbox.fax.NumberingPlanIdent , SIPC_MARSHAL_DATA_INT_TYPE);
549 entry_key = g_strdup_printf("%d", count);
550 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
553 if(resp_read->data.mailbox.video.DiallingnumLength){
555 sipc_util_marshal_object_add_data(entry_o, "type", "video", SIPC_MARSHAL_DATA_STRING_TYPE);
556 sipc_util_marshal_object_add_data(entry_o, "name", (void*)&resp_read->data.mailbox.video.AlphaId, SIPC_MARSHAL_DATA_STRING_TYPE);
557 sipc_util_marshal_object_add_data(entry_o, "number", (void*)&resp_read->data.mailbox.video.DiallingNum , SIPC_MARSHAL_DATA_STRING_TYPE);
558 sipc_util_marshal_object_add_data(entry_o, "ton", (void*)&resp_read->data.mailbox.video.TypeOfNumber , SIPC_MARSHAL_DATA_INT_TYPE);
559 sipc_util_marshal_object_add_data(entry_o, "npi", (void*)&resp_read->data.mailbox.video.NumberingPlanIdent , SIPC_MARSHAL_DATA_INT_TYPE);
560 entry_key = g_strdup_printf("%d", count);
561 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
565 case TRESP_SIM_GET_CALLFORWARDING:
566 dbg("resp comm - TRESP_SIM_GET_CALLFORWARDING");
567 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
568 sipc_util_marshal_object_add_data(out_o, "line1_status", (void*)&resp_read->data.cf.voice1, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
569 sipc_util_marshal_object_add_data(out_o, "line2_status", (void*)&resp_read->data.cf.voice2, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
572 case TRESP_SIM_GET_MESSAGEWAITING:
573 dbg("resp comm - TRESP_SIM_GET_MESSAGEWAITING");
574 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
575 if (resp_read->data.mw.b_cphs) {
576 sipc_util_marshal_object_add_data(out_o, "line1_count", (void*)&resp_read->data.mw.mw_data_u.cphs_mw.b_voice1, SIPC_MARSHAL_DATA_INT_TYPE);
577 sipc_util_marshal_object_add_data(out_o, "line2_count", (void*)&resp_read->data.mw.mw_data_u.cphs_mw.b_voice2, SIPC_MARSHAL_DATA_INT_TYPE);
578 sipc_util_marshal_object_add_data(out_o, "fax_count", (void*)&resp_read->data.mw.mw_data_u.cphs_mw.b_fax, SIPC_MARSHAL_DATA_INT_TYPE);
579 sipc_util_marshal_object_add_data(out_o, "video_count", (void*)&resp_read->data.mw.mw_data_u.cphs_mw.b_data, SIPC_MARSHAL_DATA_INT_TYPE);
581 sipc_util_marshal_object_add_data(out_o, "line1_count", (void*)&resp_read->data.mw.mw_data_u.mw.voice_count, SIPC_MARSHAL_DATA_INT_TYPE);
582 /* sipc_util_marshal_object_add_data(out_o, "line2_count", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);*/
583 sipc_util_marshal_object_add_data(out_o, "fax_count", (void*)&resp_read->data.mw.mw_data_u.mw.fax_count, SIPC_MARSHAL_DATA_INT_TYPE);
584 sipc_util_marshal_object_add_data(out_o, "video_count", (void*)&resp_read->data.mw.mw_data_u.mw.video_count, SIPC_MARSHAL_DATA_INT_TYPE);
588 case TRESP_SIM_GET_CPHS_INFO:
589 dbg("resp comm - TRESP_SIM_GET_CPHS_INFO");
590 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
593 case TRESP_SIM_GET_MSISDN:
594 dbg("resp comm - TRESP_SIM_GET_MSISDN");
595 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
596 sipc_util_marshal_object_add_data(out_o, "count", (void*)&resp_read->data.msisdn_list.count, SIPC_MARSHAL_DATA_INT_TYPE);
597 entry_o = sipc_util_marshal_object_create();
598 for(i=0;i < resp_read->data.msisdn_list.count; i++){
599 gchar *entry_key = NULL;
600 sipc_util_marshal_object_add_data(entry_o, "name", (void*)&resp_read->data.msisdn_list.msisdn[i].name, SIPC_MARSHAL_DATA_STRING_TYPE);
601 sipc_util_marshal_object_add_data(entry_o, "number", (void*)&resp_read->data.msisdn_list.msisdn[i].num, SIPC_MARSHAL_DATA_STRING_TYPE);
602 entry_key = g_strdup_printf("%d", i);
603 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
607 case TRESP_SIM_GET_OPLMNWACT:
608 dbg("resp comm - TRESP_SIM_GET_OPLMNWACT");
609 sipc_util_marshal_object_add_data(out_o, "result", (void*)&resp_read->result, SIPC_MARSHAL_DATA_INT_TYPE);
610 sipc_util_marshal_object_add_data(out_o, "count", (void*)&resp_read->data.opwa.opwa_count, SIPC_MARSHAL_DATA_INT_TYPE);
611 entry_o = sipc_util_marshal_object_create();
612 for(i=0;i < resp_read->data.opwa.opwa_count; i++){
613 gchar *entry_key = NULL;
614 sipc_util_marshal_object_add_data(entry_o, "plmn", (void*)&resp_read->data.opwa.opwa[i].plmn, SIPC_MARSHAL_DATA_STRING_TYPE);
615 sipc_util_marshal_object_add_data(entry_o, "b_umts", (void*)&resp_read->data.opwa.opwa[i].b_umts, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
616 sipc_util_marshal_object_add_data(entry_o, "b_gsm", (void*)&resp_read->data.opwa.opwa[i].b_gsm, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
617 entry_key = g_strdup_printf("%d", i);
618 sipc_util_marshal_object_add_data(out_o, entry_key, entry_o, SIPC_MARSHAL_DATA_OBJECT_TYPE);
623 dbg("not handled command [%d] here",command);
628 serial_d = sipc_util_marshal_object_serializer(out_o);
629 hdr.data_len = strlen(serial_d);
630 sipc_util_marshal_object_destory(out_o);
633 out_d = g_new0(char, sizeof(struct _tapi_header)+hdr.data_len);
634 memcpy(out_d, &hdr, sizeof(struct _tapi_header));
636 memcpy(out_d+sizeof(struct _tapi_header), serial_d, hdr.data_len);
640 ret = sipc_server_send(s, ui->channel_id, out_d, sizeof(struct _tapi_header)+hdr.data_len, SIPC_SEND_DATA_ASYNC);
651 gboolean scomm_service_notification_sim(Communicator *comm, CoreObject *source, enum tcore_notification_command command,
652 unsigned int data_len, const void *data)
654 const struct tnoti_sim_status *n_sim_status = data;
656 gchar *out_d = NULL, *serial_d = NULL;
658 struct custom_data *ctx = NULL;
659 sipc_server_t *s = NULL;
661 struct _tapi_header hdr;
662 struct _sipc_marshal_object* out_o = NULL;
664 memset(&hdr, 0, sizeof(struct _tapi_header));
666 ctx = tcore_communicator_ref_user_data(comm);
668 dbg("user_data is NULL");
673 dbg("notification !!! (command = 0x%x, data_len = %d)", command, data_len);
675 out_o = sipc_util_marshal_object_create();
678 case TNOTI_SIM_STATUS :
679 dbg("notified sim_status[%d]", n_sim_status->sim_status);
680 sipc_util_marshal_object_add_data(out_o, "status", (void*)&n_sim_status->sim_status, SIPC_MARSHAL_DATA_INT_TYPE);
681 sipc_util_marshal_object_add_data(out_o, "new_sim", (void*)&n_sim_status->b_changed, SIPC_MARSHAL_DATA_BOOLEAN_TYPE);
685 dbg("not handled command [%d] here",command);
690 serial_d = sipc_util_marshal_object_serializer(out_o);
691 hdr.data_len = strlen(serial_d);
692 sipc_util_marshal_object_destory(out_o);
695 out_d = g_new0(char, sizeof(struct _tapi_header)+hdr.data_len);
696 memcpy(out_d, &hdr, sizeof(struct _tapi_header));
698 memcpy(out_d+sizeof(struct _tapi_header), serial_d, hdr.data_len);
702 ret = sipc_server_broadcast(s, out_d, sizeof(struct _tapi_header)+hdr.data_len);