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.
28 #include <glib-object.h>
35 #include <communicator.h>
38 #include <user_request.h>
41 #include "generated-code.h"
44 TReturn ret = TCORE_RETURN_SUCCESS;
47 on_sms_send_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
50 const gchar *tpdu_data,
54 struct treq_sms_send_umts_msg sendUmtsMsg;
55 struct custom_data *ctx = user_data;
56 UserRequest *ur = NULL;
59 guchar *decoded_sca = NULL;
60 guchar *decoded_tpdu = NULL;
62 memset(&sendUmtsMsg, 0 , sizeof(struct treq_sms_send_umts_msg));
64 decoded_sca = g_base64_decode(sca, &length);
65 memcpy(&(sendUmtsMsg.msgDataPackage.sca[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN);
67 sendUmtsMsg.msgDataPackage.msgLength = tpdu_length;
68 dbg("tpdu_length = 0x%x", tpdu_length);
70 decoded_tpdu = g_base64_decode(tpdu_data, &length);
71 memcpy(&(sendUmtsMsg.msgDataPackage.tpduData[0]), decoded_tpdu, SMS_SMDATA_SIZE_MAX + 1);
72 sendUmtsMsg.more = moreMsg;
74 ur = MAKE_UR(ctx, sms, invocation);
75 tcore_user_request_set_data(ur, sizeof(struct treq_sms_send_umts_msg), &sendUmtsMsg);
76 tcore_user_request_set_command(ur, TREQ_SMS_SEND_UMTS_MSG);
81 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
82 if (ret != TCORE_RETURN_SUCCESS) {
83 telephony_sms_complete_send_msg(sms, invocation, SMS_DEVICE_FAILURE);
84 tcore_user_request_unref(ur);
91 on_sms_read_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
95 struct treq_sms_read_msg readMsg = {0,};
96 struct custom_data *ctx = user_data;
97 UserRequest *ur = NULL;
99 readMsg.index = arg_index;
101 ur = MAKE_UR(ctx, sms, invocation);
102 tcore_user_request_set_data(ur, sizeof(struct treq_sms_read_msg), &readMsg);
103 tcore_user_request_set_command(ur, TREQ_SMS_READ_MSG);
105 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
106 if (ret != TCORE_RETURN_SUCCESS) {
107 telephony_sms_complete_read_msg(sms, invocation, SMS_DEVICE_FAILURE, -1, -1, NULL, 0, NULL);
108 tcore_user_request_unref(ur);
115 on_sms_save_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
117 const gchar * arg_sca,
118 gint arg_tpdu_length,
119 const gchar * arg_tpdu_data,
122 struct treq_sms_save_msg saveMsg = {0,};
123 struct custom_data *ctx = user_data;
124 UserRequest *ur = NULL;
127 guchar *decoded_sca = NULL;
128 guchar *decoded_tpdu = NULL;
130 saveMsg.simIndex = 0xffff;
131 saveMsg.msgStatus = arg_msg_status;
133 decoded_sca = g_base64_decode(arg_sca, &length);
134 memcpy(&(saveMsg.msgDataPackage.sca[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN);
136 saveMsg.msgDataPackage.msgLength = arg_tpdu_length;
138 decoded_tpdu = g_base64_decode(arg_tpdu_data, &length);
139 memcpy(&(saveMsg.msgDataPackage.tpduData[0]), decoded_tpdu, SMS_SMDATA_SIZE_MAX + 1);
141 ur = MAKE_UR(ctx, sms, invocation);
142 tcore_user_request_set_data(ur, sizeof(struct treq_sms_save_msg), &saveMsg);
143 tcore_user_request_set_command(ur, TREQ_SMS_SAVE_MSG);
146 g_free(decoded_tpdu);
148 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
149 if (ret != TCORE_RETURN_SUCCESS) {
150 telephony_sms_complete_save_msg(sms, invocation, SMS_DEVICE_FAILURE, -1);
151 tcore_user_request_unref(ur);
158 on_sms_delete_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
162 struct treq_sms_delete_msg deleteMsg = {0,};
163 struct custom_data *ctx = user_data;
164 UserRequest *ur = NULL;
166 deleteMsg.index = arg_index;
168 ur = MAKE_UR(ctx, sms, invocation);
169 tcore_user_request_set_data(ur, sizeof(struct treq_sms_delete_msg), &deleteMsg);
170 tcore_user_request_set_command(ur, TREQ_SMS_DELETE_MSG);
172 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
173 if (ret != TCORE_RETURN_SUCCESS) {
174 telephony_sms_complete_delete_msg(sms, invocation, SMS_DEVICE_FAILURE, -1);
175 tcore_user_request_unref(ur);
182 on_sms_get_msg_count(TelephonySms *sms, GDBusMethodInvocation *invocation,
185 struct treq_sms_get_msg_count getMsgCnt;
186 struct custom_data *ctx = user_data;
187 UserRequest *ur = NULL;
189 ur = MAKE_UR(ctx, sms, invocation);
190 tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_msg_count), &getMsgCnt);
191 tcore_user_request_set_command(ur, TREQ_SMS_GET_COUNT);
193 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
194 if (ret != TCORE_RETURN_SUCCESS) {
195 telephony_sms_complete_get_msg_count(sms, invocation, SMS_DEVICE_FAILURE, 0, -1, NULL);
196 tcore_user_request_unref(ur);
203 on_sms_get_sca(TelephonySms *sms, GDBusMethodInvocation *invocation,
207 struct treq_sms_get_sca getSca = {0,};
208 struct custom_data *ctx = user_data;
209 UserRequest *ur = NULL;
211 getSca.index = arg_index;
213 ur = MAKE_UR(ctx, sms, invocation);
214 tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_sca), &getSca);
215 tcore_user_request_set_command(ur, TREQ_SMS_GET_SCA);
217 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
218 if (ret != TCORE_RETURN_SUCCESS) {
219 telephony_sms_complete_get_sca(sms, invocation, SMS_DEVICE_FAILURE, -1, -1, 0, NULL);
220 tcore_user_request_unref(ur);
227 on_sms_set_sca(TelephonySms *sms, GDBusMethodInvocation *invocation,
231 gint arg_dialNumberLength,
232 const gchar *arg_dialNumber,
235 struct treq_sms_set_sca setSca;
236 struct custom_data *ctx = user_data;
237 UserRequest *ur = NULL;
239 memset(&setSca, 0, sizeof(struct treq_sms_set_sca));
241 setSca.index = arg_index;
242 setSca.scaInfo.dialNumLen = arg_dialNumberLength;
243 setSca.scaInfo.typeOfNum = arg_ton;
244 setSca.scaInfo.numPlanId = arg_npi;
246 if ((setSca.scaInfo.dialNumLen <= 0)
247 || (setSca.scaInfo.dialNumLen > SMS_SMSP_ADDRESS_LEN)) {
248 err("[tcore_SMS] TAPI_API_INVALID_INPUT !!!");
251 else if(setSca.index != 0) {
252 err("[tcore_SMS] Index except 0 is supported");
253 // api_err = TAPI_API_NOT_SUPPORTED;
257 guchar *decoded_sca = NULL;
259 decoded_sca = g_base64_decode(arg_dialNumber, &length);
260 memcpy(&(setSca.scaInfo.diallingNum[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN + 1);
262 ur = MAKE_UR(ctx, sms, invocation);
263 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_sca), &setSca);
264 tcore_user_request_set_command(ur, TREQ_SMS_SET_SCA);
268 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
269 if (ret != TCORE_RETURN_SUCCESS) {
270 telephony_sms_complete_set_sca(sms, invocation, SMS_DEVICE_FAILURE);
271 tcore_user_request_unref(ur);
279 on_sms_get_cb_config(TelephonySms *sms, GDBusMethodInvocation *invocation,
282 struct treq_sms_get_cb_config getCbConfig;
283 struct custom_data *ctx = user_data;
284 UserRequest *ur = NULL;
286 ur = MAKE_UR(ctx, sms, invocation);
287 tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_cb_config), &getCbConfig);
288 tcore_user_request_set_command(ur, TREQ_SMS_GET_CB_CONFIG);
290 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
291 if (ret != TCORE_RETURN_SUCCESS) {
294 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
295 gv = g_variant_builder_end(&b);
296 telephony_sms_complete_get_cb_config(sms, invocation, SMS_DEVICE_FAILURE, -1, -1, 0, 0, gv);
298 tcore_user_request_unref(ur);
305 on_sms_set_cb_config(TelephonySms *sms, GDBusMethodInvocation *invocation,
306 gint arg_net3gppType,
307 gboolean arg_cbEnable,
308 gint arg_msgIdMaxCount,
309 gint arg_msgIdRangeCount,
310 const gchar *arg_msgId,
313 struct treq_sms_set_cb_config setCbConfig = {0,};
314 struct custom_data *ctx = user_data;
315 UserRequest *ur = NULL;
318 guchar *decoded_msgId = NULL;
320 setCbConfig.net3gppType = arg_net3gppType;
321 setCbConfig.cbEnabled = arg_cbEnable;
322 setCbConfig.msgIdMaxCount = arg_msgIdMaxCount;
323 setCbConfig.msgIdRangeCount = arg_msgIdRangeCount;
325 decoded_msgId = g_base64_decode(arg_msgId, &length);
326 memcpy(&(setCbConfig.msgIDs[0]), decoded_msgId, SMS_GSM_SMS_CBMI_LIST_SIZE_MAX*5);
328 ur = MAKE_UR(ctx, sms, invocation);
329 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_cb_config), &setCbConfig);
330 tcore_user_request_set_command(ur, TREQ_SMS_SET_CB_CONFIG);
332 g_free(decoded_msgId);
334 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
335 if (ret != TCORE_RETURN_SUCCESS) {
336 telephony_sms_complete_set_cb_config(sms, invocation, SMS_DEVICE_FAILURE);
337 tcore_user_request_unref(ur);
344 on_sms_set_mem_status(TelephonySms *sms, GDBusMethodInvocation *invocation,
345 gint arg_memoryStatus,
348 struct treq_sms_set_mem_status memStatus = {0,};
349 struct custom_data *ctx = user_data;
350 UserRequest *ur = NULL;
352 memStatus.memory_status = arg_memoryStatus;
354 ur = MAKE_UR(ctx, sms, invocation);
355 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_mem_status), &memStatus);
356 tcore_user_request_set_command(ur, TREQ_SMS_SET_MEM_STATUS);
358 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
359 if (ret != TCORE_RETURN_SUCCESS) {
360 telephony_sms_complete_set_mem_status(sms, invocation, SMS_DEVICE_FAILURE);
361 tcore_user_request_unref(ur);
368 on_sms_get_pref_bearer(TelephonySms *sms, GDBusMethodInvocation *invocation,
371 struct treq_sms_get_pref_bearer getPrefBearer;
372 struct custom_data *ctx = user_data;
373 UserRequest *ur = NULL;
375 ur = MAKE_UR(ctx, sms, invocation);
376 tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_pref_bearer), &getPrefBearer);
377 tcore_user_request_set_command(ur, TREQ_SMS_GET_PREF_BEARER);
379 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
380 if (ret != TCORE_RETURN_SUCCESS) {
381 telephony_sms_complete_get_pref_bearer(sms, invocation, SMS_DEVICE_FAILURE);
382 tcore_user_request_unref(ur);
389 on_sms_set_pref_bearer(TelephonySms *sms, GDBusMethodInvocation *invocation,
393 struct treq_sms_set_pref_bearer setPrefBearer = {0,};
394 struct custom_data *ctx = user_data;
395 UserRequest *ur = NULL;
397 setPrefBearer.svc = arg_bearerType;
399 ur = MAKE_UR(ctx, sms, invocation);
400 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_pref_bearer), &setPrefBearer);
401 tcore_user_request_set_command(ur, TREQ_SMS_SET_PREF_BEARER);
403 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
404 if (ret != TCORE_RETURN_SUCCESS) {
405 telephony_sms_complete_set_pref_bearer(sms, invocation, SMS_DEVICE_FAILURE);
406 tcore_user_request_unref(ur);
413 on_sms_set_delivery_report(TelephonySms *sms, GDBusMethodInvocation *invocation,
414 const gchar *arg_sca,
415 gint arg_tpdu_length,
416 const gchar *arg_tpdu_data,
420 struct treq_sms_set_delivery_report deliveryReport;
421 struct custom_data *ctx = user_data;
422 UserRequest *ur = NULL;
425 guchar *decoded_sca = NULL;
426 guchar *decoded_tpdu = NULL;
428 memset(&deliveryReport, 0, sizeof(struct treq_sms_set_delivery_report));
430 decoded_sca = g_base64_decode(arg_sca, &length);
431 memcpy(&(deliveryReport.dataInfo.sca[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN);
433 deliveryReport.dataInfo.msgLength = arg_tpdu_length;
435 decoded_tpdu = g_base64_decode(arg_tpdu_data, &length);
436 memcpy(&(deliveryReport.dataInfo.tpduData[0]), decoded_tpdu, SMS_SMDATA_SIZE_MAX + 1);
438 deliveryReport.rspType = arg_rpCause;
440 ur = MAKE_UR(ctx, sms, invocation);
441 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_delivery_report), &deliveryReport);
442 tcore_user_request_set_command(ur, TREQ_SMS_SET_DELIVERY_REPORT);
445 g_free(decoded_tpdu);
447 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
448 if (ret != TCORE_RETURN_SUCCESS) {
449 telephony_sms_complete_set_delivery_report(sms, invocation, SMS_DEVICE_FAILURE);
450 tcore_user_request_unref(ur);
457 on_sms_set_msg_status(TelephonySms *sms, GDBusMethodInvocation *invocation,
462 struct treq_sms_set_msg_status msgStatus = {0,};
463 struct custom_data *ctx = user_data;
464 UserRequest *ur = NULL;
466 msgStatus.index = arg_index;
467 msgStatus.msgStatus = arg_msgStatus;
469 ur = MAKE_UR(ctx, sms, invocation);
470 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_msg_status), &msgStatus);
471 tcore_user_request_set_command(ur, TREQ_SMS_SET_MSG_STATUS);
473 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
474 if (ret != TCORE_RETURN_SUCCESS) {
475 telephony_sms_complete_set_msg_status(sms, invocation, SMS_DEVICE_FAILURE);
476 tcore_user_request_unref(ur);
483 on_sms_get_sms_params(TelephonySms *sms, GDBusMethodInvocation *invocation,
487 struct treq_sms_get_params getParams = {0,};
488 struct custom_data *ctx = user_data;
489 UserRequest *ur = NULL;
491 getParams.index = arg_index;
493 ur = MAKE_UR(ctx, sms, invocation);
494 tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_params), &getParams);
495 tcore_user_request_set_command(ur, TREQ_SMS_GET_PARAMS);
497 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
498 if (ret != TCORE_RETURN_SUCCESS) {
499 telephony_sms_complete_get_sms_params(sms, invocation, SMS_DEVICE_FAILURE,
500 0, 0, 0, NULL, 0, 0, -1, -1, NULL, 0, -1, -1, NULL, 0, 0, 0);
501 tcore_user_request_unref(ur);
508 on_sms_set_sms_params(TelephonySms *sms, GDBusMethodInvocation *invocation,
509 gint arg_recordIndex,
512 const gchar *arg_alphaId,
513 gint arg_paramIndicator,
514 gint arg_destAddr_DialNumLen,
515 gint arg_destAddr_Ton,
516 gint arg_destAddr_Npi,
517 const gchar *arg_destAddr_DiallingNum,
518 gint arg_svcCntrAddr_DialNumLen,
519 gint arg_SvcCntrAddr_Ton,
520 gint arg_svcCntrAddr_Npi,
521 const gchar *arg_svcCntrAddr_DialNum,
523 gint arg_dataCodingScheme,
524 gint arg_validityPeriod,
527 struct treq_sms_set_params setParams;
528 struct custom_data *ctx = user_data;
529 UserRequest *ur = NULL;
532 guchar *decoded_alphaId = NULL;
533 guchar *decoded_destDialNum = NULL;
534 guchar *decoded_scaDialNum = NULL;
536 memset(&setParams, 0, sizeof(struct treq_sms_set_params));
538 setParams.params.recordIndex = arg_recordIndex;
539 setParams.params.recordLen = arg_recordLen;
540 setParams.params.alphaIdLen = arg_alphaIdLen;
541 decoded_alphaId = g_base64_decode(arg_alphaId, &length);
542 memcpy(&(setParams.params.szAlphaId[0]), decoded_alphaId, SMS_SMSP_ALPHA_ID_LEN_MAX + 1);
543 setParams.params.paramIndicator = arg_paramIndicator;
545 setParams.params.tpDestAddr.dialNumLen = arg_destAddr_DialNumLen;
546 setParams.params.tpDestAddr.typeOfNum = arg_destAddr_Ton;
547 setParams.params.tpDestAddr.numPlanId = arg_destAddr_Npi;
548 decoded_destDialNum = g_base64_decode(arg_destAddr_DiallingNum, &length);
549 memcpy(&(setParams.params.tpDestAddr.diallingNum[0]), decoded_destDialNum, SMS_SMSP_ADDRESS_LEN + 1);
551 setParams.params.tpSvcCntrAddr.dialNumLen = arg_svcCntrAddr_DialNumLen;
552 setParams.params.tpSvcCntrAddr.typeOfNum = arg_SvcCntrAddr_Ton;
553 setParams.params.tpSvcCntrAddr.numPlanId = arg_svcCntrAddr_Npi;
554 decoded_scaDialNum = g_base64_decode(arg_svcCntrAddr_DialNum, &length);
555 memcpy(&(setParams.params.tpSvcCntrAddr.diallingNum[0]), decoded_scaDialNum, SMS_SMSP_ADDRESS_LEN + 1);
557 setParams.params.tpProtocolId = arg_protocolId;
558 setParams.params.tpDataCodingScheme = arg_dataCodingScheme;
559 setParams.params.tpValidityPeriod = arg_validityPeriod;
561 ur = MAKE_UR(ctx, sms, invocation);
562 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_params), &setParams);
563 tcore_user_request_set_command(ur, TREQ_SMS_SET_PARAMS);
565 g_free(decoded_alphaId);
566 g_free(decoded_destDialNum);
567 g_free(decoded_scaDialNum);
569 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
570 if (ret != TCORE_RETURN_SUCCESS) {
571 telephony_sms_complete_set_sms_params(sms, invocation, SMS_DEVICE_FAILURE);
572 tcore_user_request_unref(ur);
579 on_sms_get_sms_param_cnt(TelephonySms *sms, GDBusMethodInvocation *invocation,
582 struct treq_sms_get_paramcnt getParamCnt;
583 struct custom_data *ctx = user_data;
584 UserRequest *ur = NULL;
586 ur = MAKE_UR(ctx, sms, invocation);
587 tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_paramcnt), &getParamCnt);
588 tcore_user_request_set_command(ur, TREQ_SMS_GET_PARAMCNT);
590 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
591 if (ret != TCORE_RETURN_SUCCESS) {
592 telephony_sms_complete_get_sms_param_cnt(sms, invocation, SMS_DEVICE_FAILURE, -1);
593 tcore_user_request_unref(ur);
600 on_sms_get_sms_ready_status(TelephonySms *sms, GDBusMethodInvocation *invocation,
603 struct custom_data *ctx = user_data;
604 CoreObject *co_sms = NULL;
605 TcorePlugin *plugin = NULL;
606 char *cp_name = GET_PLUGIN_NAME(invocation);
608 dbg("Func Entrance");
610 plugin = tcore_server_find_plugin(ctx->server, cp_name);
611 co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
613 dbg("error- co_sms is NULL");
617 telephony_sms_complete_get_sms_ready_status(sms, invocation, tcore_sms_get_ready_status(co_sms));
622 gboolean dbus_plugin_setup_sms_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx)
626 sms = telephony_sms_skeleton_new();
627 telephony_object_skeleton_set_sms(object, sms);
630 dbg("sms = %p", sms);
632 g_signal_connect(sms, "handle-send-msg", G_CALLBACK (on_sms_send_msg), ctx);
633 g_signal_connect(sms, "handle-read-msg", G_CALLBACK (on_sms_read_msg), ctx);
634 g_signal_connect(sms, "handle-save-msg", G_CALLBACK (on_sms_save_msg), ctx);
635 g_signal_connect(sms, "handle-delete-msg", G_CALLBACK (on_sms_delete_msg), ctx);
636 g_signal_connect(sms, "handle-get-msg-count", G_CALLBACK (on_sms_get_msg_count), ctx);
637 g_signal_connect(sms, "handle-get-sca", G_CALLBACK (on_sms_get_sca), ctx);
638 g_signal_connect(sms, "handle-set-sca", G_CALLBACK (on_sms_set_sca), ctx);
639 g_signal_connect(sms, "handle-get-cb-config", G_CALLBACK (on_sms_get_cb_config), ctx);
640 g_signal_connect(sms, "handle-set-cb-config", G_CALLBACK (on_sms_set_cb_config), ctx);
641 g_signal_connect(sms, "handle-set-mem-status", G_CALLBACK (on_sms_set_mem_status), ctx);
642 g_signal_connect(sms, "handle-get-pref-bearer", G_CALLBACK (on_sms_get_pref_bearer), ctx);
643 g_signal_connect(sms, "handle-set-pref-bearer", G_CALLBACK (on_sms_set_pref_bearer), ctx);
644 g_signal_connect(sms, "handle-set-delivery-report", G_CALLBACK (on_sms_set_delivery_report), ctx);
645 g_signal_connect(sms, "handle-set-msg-status", G_CALLBACK (on_sms_set_msg_status), ctx);
646 g_signal_connect(sms, "handle-get-sms-params", G_CALLBACK (on_sms_get_sms_params), ctx);
647 g_signal_connect(sms, "handle-set-sms-params", G_CALLBACK (on_sms_set_sms_params), ctx);
648 g_signal_connect(sms, "handle-get-sms-param-cnt", G_CALLBACK (on_sms_get_sms_param_cnt), ctx);
649 g_signal_connect(sms, "handle-get-sms-ready-status", G_CALLBACK (on_sms_get_sms_ready_status), ctx);
654 gboolean dbus_plugin_sms_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data)
657 char *modem_name = NULL;
658 TcorePlugin *p = NULL;
661 modem_name = tcore_user_request_get_modem_name(ur);
665 p = tcore_server_find_plugin(ctx->server, modem_name);
670 co_sms = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_SMS);
675 case TRESP_SMS_SEND_UMTS_MSG: {
676 const struct tresp_sms_send_umts_msg *resp = data;
679 dbg("receive TRESP_SMS_SEND_UMTS_MSG");
680 dbg("resp->result = 0x%x", resp->result);
682 telephony_sms_complete_send_msg(dbus_info->interface_object, dbus_info->invocation, resp->result);
687 case TRESP_SMS_READ_MSG: {
688 const struct tresp_sms_read_msg *resp = data;
692 dbg("receive TRESP_SMS_READ_MSG");
693 dbg("resp->result = 0x%x", resp->result);
695 sca = g_base64_encode((const guchar *)&(resp->dataInfo.smsData.sca[0]), SMS_SMSP_ADDRESS_LEN);
697 dbg("g_base64_encode: Failed to Enocde the SCA.");
701 tpdu = g_base64_encode((const guchar *)&(resp->dataInfo.smsData.tpduData[0]), SMS_SMDATA_SIZE_MAX + 1);
703 dbg("g_base64_encode: Failed to Enocde the SCA.");
707 telephony_sms_complete_read_msg(dbus_info->interface_object, dbus_info->invocation,
709 resp->dataInfo.simIndex,
710 resp->dataInfo.msgStatus,
712 resp->dataInfo.smsData.msgLength,
724 case TRESP_SMS_SAVE_MSG: {
725 const struct tresp_sms_save_msg *resp = data;
727 dbg("receive TRESP_SMS_SAVE_MSG");
728 dbg("resp->result = 0x%x", resp->result);
730 telephony_sms_complete_save_msg (dbus_info->interface_object, dbus_info->invocation,
736 case TRESP_SMS_DELETE_MSG: {
737 const struct tresp_sms_delete_msg *resp = data;
739 dbg("receive TRESP_SMS_DELETE_MSG");
740 dbg("resp->result = 0x%x", resp->result);
742 telephony_sms_complete_delete_msg(dbus_info->interface_object, dbus_info->invocation,
743 resp->result, resp->index);
748 case TRESP_SMS_GET_STORED_MSG_COUNT: {
749 const struct tresp_sms_get_storedMsgCnt *resp = data;
750 gchar *msgCnt = NULL;
752 dbg("receive TRESP_SMS_GET_STORED_MSG_COUNT");
753 dbg("resp->result = 0x%x", resp->result);
755 msgCnt = g_base64_encode((const guchar *)&(resp->storedMsgCnt.indexList[0]), SMS_GSM_SMS_MSG_NUM_MAX + 1);
756 if (msgCnt == NULL) {
757 dbg("g_base64_encode: Failed to Enocde storedMsgCnt.indexList");
758 msgCnt = g_strdup("");
761 telephony_sms_complete_get_msg_count(dbus_info->interface_object, dbus_info->invocation,
763 resp->storedMsgCnt.totalCount,
764 resp->storedMsgCnt.usedCount,
773 case TRESP_SMS_GET_SCA: {
774 const struct tresp_sms_get_sca *resp = data;
777 dbg("receive TRESP_SMS_GET_SCA");
778 dbg("resp->result = 0x%x", resp->result);
780 sca = g_base64_encode((const guchar *)&(resp->scaAddress.diallingNum[0]), SMS_SMSP_ADDRESS_LEN + 1);
782 dbg("g_base64_encode: Failed to Enocde scaAddress.diallingNum");
786 telephony_sms_complete_get_sca(dbus_info->interface_object, dbus_info->invocation,
788 resp->scaAddress.typeOfNum,
789 resp->scaAddress.numPlanId,
790 resp->scaAddress.dialNumLen,
799 case TRESP_SMS_SET_SCA: {
800 const struct tresp_sms_set_sca *resp = data;
802 dbg("receive TRESP_SMS_SET_SCA");
803 dbg("resp->result = 0x%x", resp->result);
805 telephony_sms_complete_set_sca(dbus_info->interface_object, dbus_info->invocation,
811 case TRESP_SMS_GET_CB_CONFIG: {
812 const struct tresp_sms_get_cb_config *resp = data;
813 GVariant *result = NULL;
816 dbg("receive TRESP_SMS_GET_CB_CONFIG");
817 dbg("resp->result = 0x%x", resp->result);
819 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
821 for (i = 0; i < resp->cbConfig.msgIdRangeCount; i++) {
822 g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
824 if( resp->cbConfig.net3gppType == SMS_NETTYPE_3GPP ) {
825 g_variant_builder_add(&b, "{sv}", "FromMsgId", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp.fromMsgId));
826 g_variant_builder_add(&b, "{sv}", "ToMsgId", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp.toMsgId));
827 } else if( resp->cbConfig.net3gppType == SMS_NETTYPE_3GPP2) {
828 g_variant_builder_add(&b, "{sv}", "CBCategory", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp2.cbCategory));
829 g_variant_builder_add(&b, "{sv}", "CBLanguage", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp2.cbLanguage));
831 dbg("Unknown 3gpp type");
835 g_variant_builder_add(&b, "{sv}", "Selected", g_variant_new_byte(resp->cbConfig.msgIDs[i].net3gpp.selected));
837 g_variant_builder_close(&b);
840 result = g_variant_builder_end(&b);
842 telephony_sms_complete_get_cb_config(dbus_info->interface_object, dbus_info->invocation,
844 resp->cbConfig.net3gppType,
845 resp->cbConfig.cbEnabled,
846 resp->cbConfig.msgIdMaxCount,
847 resp->cbConfig.msgIdRangeCount,
852 case TRESP_SMS_SET_CB_CONFIG: {
853 const struct tresp_sms_set_cb_config *resp = data;
855 dbg("receive TRESP_SMS_SET_CB_CONFIG");
856 dbg("resp->result = 0x%x", resp->result);
858 telephony_sms_complete_set_cb_config(dbus_info->interface_object, dbus_info->invocation,
864 case TRESP_SMS_SET_MEM_STATUS: {
865 const struct tresp_sms_set_mem_status *resp = data;
867 dbg("receive TRESP_SMS_SET_MEM_STATUS");
868 dbg("resp->result = 0x%x", resp->result);
870 telephony_sms_complete_set_mem_status(dbus_info->interface_object, dbus_info->invocation,
875 case TRESP_SMS_GET_PREF_BEARER: {
876 const struct tresp_sms_get_pref_bearer *resp = data;
878 dbg("receive TRESP_SMS_GET_PREF_BEARER");
879 dbg("resp->result = 0x%x", resp->result);
881 telephony_sms_complete_get_pref_bearer(dbus_info->interface_object, dbus_info->invocation,
887 case TRESP_SMS_SET_PREF_BEARER: {
888 const struct tresp_sms_set_pref_bearer *resp = data;
890 dbg("receive TRESP_SMS_SET_PREF_BEARER");
891 dbg("resp->result = 0x%x", resp->result);
893 telephony_sms_complete_set_pref_bearer(dbus_info->interface_object, dbus_info->invocation,
899 case TRESP_SMS_SET_DELIVERY_REPORT: {
900 const struct tresp_sms_set_delivery_report *resp = data;
902 dbg("receive TRESP_SMS_SET_DELIVERY_REPORT");
903 dbg("resp->result = 0x%x", resp->result);
905 telephony_sms_complete_set_delivery_report(dbus_info->interface_object, dbus_info->invocation,
911 case TRESP_SMS_SET_MSG_STATUS: {
912 const struct tresp_sms_set_mem_status *resp = data;
914 dbg("receive TRESP_SMS_SET_MSG_STATUS");
915 dbg("resp->result = 0x%x", resp->result);
917 telephony_sms_complete_set_msg_status(dbus_info->interface_object, dbus_info->invocation,
923 case TRESP_SMS_GET_PARAMS: {
924 const struct tresp_sms_get_params *resp = data;
925 gchar *alphaId = NULL;
926 gchar *destDialNum = NULL;
927 gchar *scaDialNum = NULL;
929 dbg("receive TRESP_SMS_GET_PARAMS");
930 dbg("resp->result = 0x%x", resp->result);
932 alphaId = g_base64_encode((const guchar *)&(resp->paramsInfo.szAlphaId[0]), SMS_SMSP_ALPHA_ID_LEN_MAX + 1);
933 if (alphaId == NULL) {
934 dbg("g_base64_encode: Failed to Enocde paramsInfo.szAlphaId");
935 alphaId = g_strdup("");
938 destDialNum = g_base64_encode((const guchar *)&(resp->paramsInfo.tpDestAddr.diallingNum[0]), SMS_SMSP_ADDRESS_LEN + 1);
939 if (destDialNum == NULL) {
940 dbg("g_base64_encode: Failed to Enocde paramsInfo.tpDestAddr.diallingNum");
941 destDialNum = g_strdup("");
944 scaDialNum = g_base64_encode((const guchar *)&(resp->paramsInfo.tpSvcCntrAddr.diallingNum[0]), SMS_SMSP_ADDRESS_LEN + 1);
945 if (scaDialNum == NULL) {
946 dbg("g_base64_encode: Failed to Enocde paramsInfo.tpSvcCntrAddr.diallingNum");
947 scaDialNum = g_strdup("");
950 telephony_sms_complete_get_sms_params(dbus_info->interface_object, dbus_info->invocation,
952 resp->paramsInfo.recordIndex,
953 resp->paramsInfo.recordLen,
954 resp->paramsInfo.alphaIdLen,
956 resp->paramsInfo.paramIndicator,
957 resp->paramsInfo.tpDestAddr.dialNumLen,
958 resp->paramsInfo.tpDestAddr.typeOfNum,
959 resp->paramsInfo.tpDestAddr.numPlanId,
961 resp->paramsInfo.tpSvcCntrAddr.dialNumLen,
962 resp->paramsInfo.tpSvcCntrAddr.typeOfNum,
963 resp->paramsInfo.tpSvcCntrAddr.numPlanId,
965 resp->paramsInfo.tpProtocolId,
966 resp->paramsInfo.tpDataCodingScheme,
967 resp->paramsInfo.tpValidityPeriod);
981 case TRESP_SMS_SET_PARAMS:{
982 const struct tresp_sms_set_params *resp = data;
984 dbg("receive TRESP_SMS_SET_PARAMS");
985 dbg("resp->result = 0x%x", resp->result);
987 telephony_sms_complete_set_sms_params(dbus_info->interface_object, dbus_info->invocation,
993 case TRESP_SMS_GET_PARAMCNT: {
994 const struct tresp_sms_get_paramcnt *resp = data;
996 dbg("receive TRESP_SMS_GET_PARAMCNT");
997 dbg("resp->result = 0x%x", resp->result);
999 telephony_sms_complete_get_sms_param_cnt(dbus_info->interface_object, dbus_info->invocation,
1013 gboolean dbus_plugin_sms_notification(struct custom_data *ctx, const char *plugin_name, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data)
1019 dbg("object is NULL");
1023 sms = telephony_object_peek_sms(TELEPHONY_OBJECT(object));
1024 dbg("sms = %p", sms);
1026 dbg("[tcore_SMS]notification !!! (command = 0x%x, data_len = %d)", command, data_len);
1029 case TNOTI_SMS_INCOM_MSG: {
1030 const struct tnoti_sms_umts_msg *noti = data;
1035 sca = g_base64_encode((const guchar *)&(noti->msgInfo.sca[0]), SMS_ENCODED_SCA_LEN_MAX);
1037 dbg("g_base64_encode: Failed to Enocde msgInfo.sca");
1041 tpdu = g_base64_encode((const guchar *)&(noti->msgInfo.tpduData[0]), SMS_SMDATA_SIZE_MAX + 1);
1043 dbg("g_base64_encode: Failed to Enocde msgInfo.tpduData");
1044 tpdu = g_strdup("");
1047 telephony_sms_emit_incomming_msg(sms,
1049 noti->msgInfo.msgLength,
1061 case TNOTI_SMS_CB_INCOM_MSG: {
1062 const struct tnoti_sms_cellBroadcast_msg *noti = data;
1063 gchar *msgData = NULL;
1065 msgData = g_base64_encode((const guchar *)&(noti->cbMsg.msgData[0]), SMS_CB_SIZE_MAX + 1);
1066 if (msgData == NULL) {
1067 dbg("g_base64_encode: Failed to Enocde cbMsg.msgData");
1068 msgData = g_strdup("");
1071 telephony_sms_emit_incomming_cb_msg(sms,
1072 noti->cbMsg.cbMsgType,
1082 case TNOTI_SMS_ETWS_INCOM_MSG: {
1083 const struct tnoti_sms_etws_msg *noti = data;
1084 gchar *msgData = NULL;
1086 msgData = g_base64_encode((const guchar *)&(noti->etwsMsg.msgData[0]), SMS_ETWS_SIZE_MAX + 1);
1087 if (msgData == NULL) {
1088 dbg("g_base64_encode: Failed to Enocde etwsMsg.msgData");
1089 msgData = g_strdup("");
1092 telephony_sms_emit_incomming_etws_msg(sms,
1093 noti->etwsMsg.etwsMsgType,
1094 noti->etwsMsg.length,
1102 case TNOTI_SMS_INCOM_EX_MSG:
1105 case TNOTI_SMS_CB_INCOM_EX_MSG:
1108 case TNOTI_SMS_MEMORY_STATUS: {
1109 const struct tnoti_sms_memory_status *noti = data;
1111 telephony_sms_emit_memory_status(sms, noti->status);
1116 case TNOTI_SMS_DEVICE_READY: {
1117 const struct tnoti_sms_ready_status *noti = data;
1119 dbg("SMS Device Ready: [%s]", (noti->status ? "YES" : "NO"));
1121 telephony_sms_emit_sms_ready(sms, noti->status);
1127 dbg("unknown notification");