add exception code for g_variant_iter_free()
[profile/ivi/tel-plugin-dbus_tapi.git] / src / sms.c
1 /*
2  * tel-plugin-socket-communicator
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 #include <stdio.h>
22 #include <string.h>
23 #include <pthread.h>
24 #include <unistd.h>
25 #include <stdlib.h>
26 #include <time.h>
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <gio/gio.h>
30
31 #include <tcore.h>
32 #include <server.h>
33 #include <plugin.h>
34 #include <hal.h>
35 #include <communicator.h>
36 #include <storage.h>
37 #include <queue.h>
38 #include <user_request.h>
39 #include <co_sms.h>
40
41 #include "generated-code.h"
42 #include "common.h"
43
44 TReturn ret = TCORE_RETURN_SUCCESS;
45
46 static gboolean
47 on_sms_send_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
48         const gchar *sca,
49         gint tpdu_length,
50         const gchar *tpdu_data,
51         gint moreMsg,
52         gpointer user_data)
53 {
54         struct treq_sms_send_umts_msg sendUmtsMsg;
55         struct custom_data *ctx = user_data;
56         UserRequest *ur = NULL;
57
58         gsize length;
59         guchar *decoded_sca = NULL;
60         guchar *decoded_tpdu = NULL;
61
62         memset(&sendUmtsMsg, 0 , sizeof(struct treq_sms_send_umts_msg));
63
64         decoded_sca = g_base64_decode(sca, &length);
65         memcpy(&(sendUmtsMsg.msgDataPackage.sca[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN);
66
67         sendUmtsMsg.msgDataPackage.msgLength = tpdu_length;
68         dbg("tpdu_length = 0x%x", tpdu_length);
69
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;
73
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);
77
78         if(decoded_sca)
79                 g_free(decoded_sca);
80         
81         if(decoded_tpdu)
82                 g_free(decoded_tpdu);
83
84         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
85         if (ret != TCORE_RETURN_SUCCESS) {
86                 // api_err = TAPI_API_OPERATION_FAILED;
87                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
88                 return  FALSE;
89         }
90                 
91         return  TRUE;
92 }
93 /*
94
95 static gboolean
96 on_sms_send_cdma_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
97         const gchar *sca,
98         gint tpdu_length,
99         const gchar *tpdu_data,
100         gint moreMsg,
101         gpointer user_data)
102 {
103 #if 0
104         cdmaMsg.more = sipc_util_marshal_object_get_int(in_obj, "More");
105         cdmaMsg.cdmaMsgInfo.ParamMask = sipc_util_marshal_object_get_int(in_obj, "ParamMask");
106         cdmaMsg.cdmaMsgInfo.MsgType = sipc_util_marshal_object_get_int(in_obj, "MsgType");
107
108         switch(cdmaMsg.cdmaMsgInfo.MsgType)
109         {
110                 case SMS_MESSAGETYPE_SUBMIT: {
111                         gchar *dstAddr_szAddress;
112                         gchar *dstSubAddr_szAddress;
113                         gchar *szData;
114                         gchar *callBackNumer_szAddress;
115
116                          Origination address
117                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstAddr.Digit = sipc_util_marshal_object_get_int(in_obj, "DstAddr.Digit");
118                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstAddr.NumberMode = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberMode");
119                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstAddr.NumberType = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberType");
120                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstAddr.NumberPlan = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberPlan");
121                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstAddr.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "DstAddr.szAddrLength");
122                         dstAddr_szAddress = sipc_util_marshal_object_get_string(in_obj, "DstAddr.szAddress");
123                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstAddr.szAddress[0]), dstAddr_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
124
125                          Origination subaddress
126                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstSubAddr.SubType = sipc_util_marshal_object_get_int(in_obj, "DstSubAddr.SubType");
127                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstSubAddr.Odd = sipc_util_marshal_object_get_char(in_obj, "DstSubAddr.Odd");
128                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstSubAddr.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "DstSubAddr.szAddrLength");
129                         dstSubAddr_szAddress = sipc_util_marshal_object_get_string(in_obj, "DstSubAddr.szAddress");
130                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DstSubAddr.szAddress[0]), dstSubAddr_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
131
132                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.TeleService = sipc_util_marshal_object_get_int(in_obj, "TeleService");
133                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.bBearerReplySeqRequest = sipc_util_marshal_object_get_int(in_obj, "bBearerReplySeqRequest");
134                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ReplySeqNumber = sipc_util_marshal_object_get_char(in_obj, "ReplySeqNumber");
135                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.MsgId = sipc_util_marshal_object_get_int(in_obj, "MsgId");
136                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.MsgEncoding = sipc_util_marshal_object_get_int(in_obj, "MsgEncoding");
137                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.MsgLength = sipc_util_marshal_object_get_int(in_obj, "MsgLength");
138                         szData = sipc_util_marshal_object_get_string(in_obj, "szData");
139                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.szData[0]), szData, SMS_MAXLENGTH_SMS_MO_USER_DATA);
140
141                          Validity period - Absolute
142                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodAbs.year = sipc_util_marshal_object_get_int(in_obj, "ValidityPeriodAbs.year");
143                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodAbs.month = sipc_util_marshal_object_get_int(in_obj, "ValidityPeriodAbs.month");
144                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodAbs.day = sipc_util_marshal_object_get_int(in_obj, "ValidityPeriodAbs.day");
145                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodAbs.hours = sipc_util_marshal_object_get_int(in_obj, "ValidityPeriodAbs.hours");
146                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodAbs.minutes = sipc_util_marshal_object_get_int(in_obj, "ValidityPeriodAbs.minutes");
147                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodAbs.seconds = sipc_util_marshal_object_get_int(in_obj, "ValidityPeriodAbs.seconds");
148
149                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.ValidityPeriodRel = sipc_util_marshal_object_get_char(in_obj, "ValidityPeriodRel");
150
151                          Deferred delivery time - Absolute (not supported)
152                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeAbs.year = sipc_util_marshal_object_get_int(in_obj, "DeferredDelTimeAbs.year");
153                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeAbs.month = sipc_util_marshal_object_get_int(in_obj, "DeferredDelTimeAbs.month");
154                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeAbs.day = sipc_util_marshal_object_get_int(in_obj, "DeferredDelTimeAbs.day");
155                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeAbs.hours = sipc_util_marshal_object_get_int(in_obj, "DeferredDelTimeAbs.hours");
156                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeAbs.minutes = sipc_util_marshal_object_get_int(in_obj, "DeferredDelTimeAbs.minutes");
157                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeAbs.seconds = sipc_util_marshal_object_get_int(in_obj, "DeferredDelTimeAbs.seconds");
158
159                          Deferred delivery time - Relative (not supported)
160                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.DeferredDelTimeRel = sipc_util_marshal_object_get_char(in_obj, "DeferredDelTimeRel");
161
162                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.Priority = sipc_util_marshal_object_get_int(in_obj, "Priority");
163                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.Privacy = sipc_util_marshal_object_get_int(in_obj, "Privacy");
164                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.bUserAckRequest = sipc_util_marshal_object_get_int(in_obj, "bUserAckRequest");
165                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.bDeliveryAckRequest = sipc_util_marshal_object_get_int(in_obj, "bDeliveryAckRequest");
166                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.AlertPriority= sipc_util_marshal_object_get_int(in_obj, "AlertPriority");
167                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.MsgLang= sipc_util_marshal_object_get_int(in_obj, "MsgLang");
168
169                          Callback number address
170                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.CallBackNumber.Digit = sipc_util_marshal_object_get_int(in_obj, "CallBackNumer.Digit");
171                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.CallBackNumber.NumberMode = sipc_util_marshal_object_get_int(in_obj, "CallBackNumer.NumberMode");
172                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.CallBackNumber.NumberType = sipc_util_marshal_object_get_int(in_obj, "CallBackNumer.NumberType");
173                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.CallBackNumber.NumberPlan = sipc_util_marshal_object_get_int(in_obj, "CallBackNumer.NumberPlan");
174                         cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.CallBackNumber.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "CallBackNumer.szAddrLength");
175                         callBackNumer_szAddress = sipc_util_marshal_object_get_string(in_obj, "CallBackNumer.szAddress");
176                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outSubmit.CallBackNumber.szAddress[0]), callBackNumer_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
177
178                         }
179                         break;
180
181                 case SMS_MESSAGETYPE_CANCEL: {
182                         gchar *dstAddr_szAddress;
183                         gchar *dstSubAddr_szAddress;
184
185                          Origination address
186                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstAddr.Digit = sipc_util_marshal_object_get_int(in_obj, "DstAddr.Digit");
187                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstAddr.NumberMode = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberMode");
188                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstAddr.NumberType = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberType");
189                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstAddr.NumberPlan = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberPlan");
190                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstAddr.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "DstAddr.szAddrLength");
191                         dstAddr_szAddress = sipc_util_marshal_object_get_string(in_obj, "DstAddr.szAddress");
192                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstAddr.szAddress[0]), dstAddr_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
193
194                          Origination subaddress
195                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstSubAddr.SubType = sipc_util_marshal_object_get_int(in_obj, "DstSubAddr.SubType");
196                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstSubAddr.Odd = sipc_util_marshal_object_get_char(in_obj, "DstSubAddr.Odd");
197                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstSubAddr.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "DstSubAddr.szAddrLength");
198                         dstSubAddr_szAddress = sipc_util_marshal_object_get_string(in_obj, "DstSubAddr.szAddress");
199                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outCancel.DstSubAddr.szAddress[0]), dstSubAddr_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
200
201                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.TeleService = sipc_util_marshal_object_get_int(in_obj, "TeleService");
202                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.bBearerReplySeqRequest = sipc_util_marshal_object_get_int(in_obj, "bBearerReplySeqRequest");
203                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.ReplySeqNumber = sipc_util_marshal_object_get_char(in_obj, "ReplySeqNumber");
204                         cdmaMsg.cdmaMsgInfo.MsgData.outCancel.MsgId = sipc_util_marshal_object_get_int(in_obj, "MsgId");
205
206                         }
207                         break;
208
209                 case SMS_MESSAGETYPE_USER_ACK: {
210                         gchar *dstAddr_szAddress;
211                         gchar *dstSubAddr_szAddress;
212                         gchar *szData;
213
214                          Origination address
215                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstAddr.Digit = sipc_util_marshal_object_get_int(in_obj, "DstAddr.Digit");
216                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstAddr.NumberMode = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberMode");
217                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstAddr.NumberType = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberType");
218                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstAddr.NumberPlan = sipc_util_marshal_object_get_int(in_obj, "DstAddr.NumberPlan");
219                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstAddr.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "DstAddr.szAddrLength");
220                         dstAddr_szAddress = sipc_util_marshal_object_get_string(in_obj, "DstAddr.szAddress");
221                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstAddr.szAddress[0]), dstAddr_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
222
223                          Origination subaddress
224                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstSubAddr.SubType = sipc_util_marshal_object_get_int(in_obj, "DstSubAddr.SubType");
225                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstSubAddr.Odd = sipc_util_marshal_object_get_char(in_obj, "DstSubAddr.Odd");
226                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstSubAddr.szAddrLength = sipc_util_marshal_object_get_char(in_obj, "DstSubAddr.szAddrLength");
227                         dstSubAddr_szAddress = sipc_util_marshal_object_get_string(in_obj, "DstSubAddr.szAddress");
228                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outAck.DstSubAddr.szAddress[0]), dstSubAddr_szAddress, SMS_MAXLENGTH_SMS_ADDRESS);
229
230                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.TeleService = sipc_util_marshal_object_get_int(in_obj, "TeleService");
231                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.bBearerReplySeqRequest = sipc_util_marshal_object_get_int(in_obj, "bBearerReplySeqRequest");
232                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.ReplySeqNumber = sipc_util_marshal_object_get_char(in_obj, "ReplySeqNumber");
233                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.MsgId = sipc_util_marshal_object_get_int(in_obj, "MsgId");
234                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.MsgEncoding = sipc_util_marshal_object_get_int(in_obj, "MsgEncoding");
235                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.MsgLength = sipc_util_marshal_object_get_int(in_obj, "MsgLength");
236                         szData = sipc_util_marshal_object_get_string(in_obj, "szData");
237                         memcpy(&(cdmaMsg.cdmaMsgInfo.MsgData.outAck.szData[0]), szData, SMS_MAXLENGTH_SMS_MO_USER_DATA);
238                         cdmaMsg.cdmaMsgInfo.MsgData.outAck.UserResponseCode = sipc_util_marshal_object_get_char(in_obj, "UserResponseCode");
239
240                         }
241                         break;
242                 default:
243                         break;
244         }
245
246         tcore_user_request_set_data(ur, sizeof(struct treq_sms_send_cdma_msg), &cdmaMsg);
247         tcore_user_request_set_command(ur, TREQ_SMS_SEND_CDMA_MSG);
248
249         ret = tcore_communicator_dispatch_request(comm, ur);
250         if (ret != TCORE_RETURN_SUCCESS) {
251                 // api_err = TAPI_API_OPERATION_FAILED;
252                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
253                 return  FALSE;
254         }
255 #endif
256         return TRUE;
257 }
258
259 */
260
261 static gboolean
262 on_sms_read_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
263         gint arg_index,
264         gpointer user_data)
265 {
266         struct treq_sms_read_msg readMsg = {0,};
267         struct custom_data *ctx = user_data;
268         UserRequest *ur = NULL;
269
270         readMsg.index = arg_index;
271
272         ur = MAKE_UR(ctx, sms, invocation);
273         tcore_user_request_set_data(ur, sizeof(struct treq_sms_read_msg), &readMsg);
274         tcore_user_request_set_command(ur, TREQ_SMS_READ_MSG);
275
276         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
277         if (ret != TCORE_RETURN_SUCCESS) {
278                 // api_err = TAPI_API_OPERATION_FAILED;
279                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
280         }
281
282         return TRUE;
283 }
284
285 static gboolean
286 on_sms_save_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
287         gint arg_msg_status,
288         const gchar * arg_sca,
289         gint arg_tpdu_length,
290         const gchar * arg_tpdu_data,
291         gpointer user_data)
292 {
293         struct treq_sms_save_msg saveMsg = {0,};
294         struct custom_data *ctx = user_data;
295         UserRequest *ur = NULL;
296
297         gsize length;
298         guchar *decoded_sca = NULL;
299         guchar *decoded_tpdu = NULL;
300         
301         saveMsg.msgStatus = arg_msg_status;
302
303         decoded_sca = g_base64_decode(arg_sca, &length);
304         memcpy(&(saveMsg.msgDataPackage.sca[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN);
305
306         saveMsg.msgDataPackage.msgLength = arg_tpdu_length;
307
308         decoded_tpdu = g_base64_decode(arg_tpdu_data, &length);
309         memcpy(&(saveMsg.msgDataPackage.tpduData[0]), decoded_tpdu, SMS_SMDATA_SIZE_MAX + 1);
310
311         ur = MAKE_UR(ctx, sms, invocation);
312         tcore_user_request_set_data(ur, sizeof(struct treq_sms_save_msg), &saveMsg);
313         tcore_user_request_set_command(ur, TREQ_SMS_SAVE_MSG);
314
315         if(decoded_sca)
316                 g_free(decoded_sca);
317         
318         if(decoded_tpdu)
319                 g_free(decoded_tpdu);
320         
321         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
322         if (ret != TCORE_RETURN_SUCCESS) {
323                 // api_err = TAPI_API_OPERATION_FAILED;
324                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
325         }
326
327         return TRUE;
328 }
329
330 static gboolean
331 on_sms_delete_msg(TelephonySms *sms, GDBusMethodInvocation *invocation,
332         gint arg_index,
333         gpointer user_data)
334 {
335         struct treq_sms_delete_msg deleteMsg = {0,};
336         struct custom_data *ctx = user_data;
337         UserRequest *ur = NULL;
338
339         deleteMsg.index = arg_index;
340
341         ur = MAKE_UR(ctx, sms, invocation);
342         tcore_user_request_set_data(ur, sizeof(struct treq_sms_delete_msg), &deleteMsg);
343         tcore_user_request_set_command(ur, TREQ_SMS_DELETE_MSG);
344
345         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
346         if (ret != TCORE_RETURN_SUCCESS) {
347                 // api_err = TAPI_API_OPERATION_FAILED;
348                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
349         }
350
351         return TRUE;
352 }
353
354 static gboolean
355 on_sms_get_msg_count(TelephonySms *sms, GDBusMethodInvocation *invocation,
356         gpointer user_data)
357 {
358         struct treq_sms_get_msg_count getMsgCnt;
359         struct custom_data *ctx = user_data;
360         UserRequest *ur = NULL;
361
362         ur = MAKE_UR(ctx, sms, invocation);
363         tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_msg_count), &getMsgCnt);
364         tcore_user_request_set_command(ur, TREQ_SMS_GET_COUNT);
365
366         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
367         if (ret != TCORE_RETURN_SUCCESS) {
368                 // api_err = TAPI_API_OPERATION_FAILED;
369                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
370         }
371
372         return TRUE;
373 }
374
375 static gboolean
376 on_sms_get_sca(TelephonySms *sms, GDBusMethodInvocation *invocation,
377         gint arg_index,
378         gpointer user_data)
379 {
380         struct treq_sms_get_sca getSca = {0,};
381         struct custom_data *ctx = user_data;
382         UserRequest *ur = NULL;
383
384         getSca.index = arg_index;
385
386         ur = MAKE_UR(ctx, sms, invocation);
387         tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_sca), &getSca);
388         tcore_user_request_set_command(ur, TREQ_SMS_GET_SCA);
389
390         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
391         if (ret != TCORE_RETURN_SUCCESS) {
392                 // api_err = TAPI_API_OPERATION_FAILED;
393                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
394                 return  FALSE;
395         }
396
397         return TRUE;
398 }
399
400 static gboolean
401 on_sms_set_sca(TelephonySms *sms, GDBusMethodInvocation *invocation,
402         gint arg_index,
403         gint arg_ton,
404         gint arg_npi,
405         gint arg_dialNumberLength,
406         const gchar *arg_dialNumber,
407         gpointer user_data)
408 {
409         struct treq_sms_set_sca setSca;
410         struct custom_data *ctx = user_data;
411         UserRequest *ur = NULL;
412
413         memset(&setSca, 0, sizeof(struct treq_sms_set_sca));
414
415         setSca.index = arg_index;
416         setSca.scaInfo.dialNumLen = arg_dialNumberLength;
417         setSca.scaInfo.typeOfNum = arg_ton;
418         setSca.scaInfo.numPlanId = arg_npi;
419
420         if ((setSca.scaInfo.dialNumLen <= 0) || (setSca.scaInfo.dialNumLen > (SMS_MAX_SMS_SERVICE_CENTER_ADDR + 1)))
421         {
422                 err("[tcore_SMS] TAPI_API_INVALID_INPUT !!!");
423                 return  FALSE;
424         }
425         else if(setSca.index != 0)
426         {
427                 err("[tcore_SMS] Index except 0 is supported");
428                 // api_err = TAPI_API_NOT_SUPPORTED;
429                 return  FALSE;
430         }
431         else
432         {
433                 gsize length;
434                 guchar *decoded_sca = NULL;
435         
436                 decoded_sca = g_base64_decode(arg_dialNumber, &length);
437                 memcpy(&(setSca.scaInfo.diallingNum[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN + 1);
438
439                 ur = MAKE_UR(ctx, sms, invocation);
440                 tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_sca), &setSca);
441                 tcore_user_request_set_command(ur, TREQ_SMS_SET_SCA);
442
443                 if(decoded_sca)
444                         g_free(decoded_sca);
445                 
446                 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
447                 if (ret != TCORE_RETURN_SUCCESS) {
448                         //api_err = TAPI_API_OPERATION_FAILED;
449                         err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
450                         return  FALSE;
451                 }
452         }
453
454         return TRUE;
455 }
456
457 static gboolean
458 on_sms_get_cb_config(TelephonySms *sms, GDBusMethodInvocation *invocation,
459         gpointer user_data)
460 {
461         struct treq_sms_get_cb_config getCbConfig;
462         struct custom_data *ctx = user_data;
463         UserRequest *ur = NULL;
464
465         ur = MAKE_UR(ctx, sms, invocation);
466         tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_cb_config), &getCbConfig);
467         tcore_user_request_set_command(ur, TREQ_SMS_GET_CB_CONFIG);
468
469         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
470         if (ret != TCORE_RETURN_SUCCESS) {
471                 //api_err = TAPI_API_OPERATION_FAILED;
472                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
473                 return  FALSE;
474         }
475
476         return TRUE;
477 }
478
479 static gboolean
480 on_sms_set_cb_config(TelephonySms *sms, GDBusMethodInvocation *invocation,
481         gboolean arg_cbEnable,
482         gint arg_slectedId,
483         gint arg_msgIdMaxCount,
484         gint arg_msgIdCount,
485         const gchar *arg_msgId,
486         gpointer user_data)
487 {
488         struct treq_sms_set_cb_config setCbConfig = {0,};
489         struct custom_data *ctx = user_data;
490         UserRequest *ur = NULL;
491
492         gsize length;
493         guchar *decoded_msgId = NULL;
494
495         setCbConfig.bCBEnabled = arg_cbEnable;
496         setCbConfig.selectedId = arg_slectedId;
497         setCbConfig.msgIdMaxCount = arg_msgIdMaxCount;
498         setCbConfig.msgIdCount = arg_msgIdCount;
499
500         decoded_msgId = g_base64_decode(arg_msgId, &length);
501         memcpy(&(setCbConfig.msgIDs[0]), decoded_msgId, SMS_GSM_SMS_CBMI_LIST_SIZE_MAX);
502
503         ur = MAKE_UR(ctx, sms, invocation);
504         tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_cb_config), &setCbConfig);
505         tcore_user_request_set_command(ur, TREQ_SMS_SET_CB_CONFIG);
506
507         if(decoded_msgId)
508                 g_free(decoded_msgId);
509         
510         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
511         if (ret != TCORE_RETURN_SUCCESS) {
512                 //api_err = TAPI_API_OPERATION_FAILED;
513                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
514                 return  FALSE;
515         }
516
517         return TRUE;
518 }
519
520 static gboolean
521 on_sms_set_mem_status(TelephonySms *sms, GDBusMethodInvocation *invocation,
522         gint arg_memoryStatus,
523         gpointer user_data)
524 {
525         struct treq_sms_set_mem_status memStatus = {0,};
526         struct custom_data *ctx = user_data;
527         UserRequest *ur = NULL;
528
529         memStatus.memory_status = arg_memoryStatus;
530
531         ur = MAKE_UR(ctx, sms, invocation);
532         tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_mem_status), &memStatus);
533         tcore_user_request_set_command(ur, TREQ_SMS_SET_MEM_STATUS);
534
535         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
536         if (ret != TCORE_RETURN_SUCCESS) {
537                 //api_err = TAPI_API_OPERATION_FAILED;
538                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
539                 return  FALSE;
540         }
541
542         return TRUE;
543 }
544
545 static gboolean
546 on_sms_get_pref_bearer(TelephonySms *sms, GDBusMethodInvocation *invocation,
547         gpointer user_data)
548 {
549         struct treq_sms_get_pref_bearer getPrefBearer;
550         struct custom_data *ctx = user_data;
551         UserRequest *ur = NULL;
552
553         ur = MAKE_UR(ctx, sms, invocation);
554         tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_pref_bearer), &getPrefBearer);
555         tcore_user_request_set_command(ur, TREQ_SMS_GET_PREF_BEARER);
556
557         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
558         if (ret != TCORE_RETURN_SUCCESS) {
559                 //api_err = TAPI_API_OPERATION_FAILED;
560                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
561                 return  FALSE;
562         }
563         return TRUE;
564 }
565
566 static gboolean
567 on_sms_set_pref_bearer(TelephonySms *sms, GDBusMethodInvocation *invocation,
568         gint arg_bearerType,
569         gpointer user_data)
570 {
571         struct treq_sms_set_pref_bearer setPrefBearer = {0,};
572         struct custom_data *ctx = user_data;
573         UserRequest *ur = NULL;
574
575         setPrefBearer.svc = arg_bearerType;
576
577         ur = MAKE_UR(ctx, sms, invocation);
578         tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_pref_bearer), &setPrefBearer);
579         tcore_user_request_set_command(ur, TREQ_SMS_SET_PREF_BEARER);
580
581         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
582         if (ret != TCORE_RETURN_SUCCESS) {
583                 //api_err = TAPI_API_OPERATION_FAILED;
584                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
585                 return  FALSE;
586         }
587
588         return TRUE;
589 }
590
591 static gboolean
592 on_sms_set_delivery_report(TelephonySms *sms, GDBusMethodInvocation *invocation,
593         const gchar *arg_sca,
594         gint arg_tpdu_length,
595         const gchar *arg_tpdu_data,
596         gint arg_rpCause,
597         gpointer user_data)
598 {
599         struct treq_sms_set_delivery_report deliveryReport;
600         struct custom_data *ctx = user_data;
601         UserRequest *ur = NULL;
602
603         gsize length;
604         guchar *decoded_sca = NULL;
605         guchar *decoded_tpdu = NULL;
606         
607         memset(&deliveryReport, 0, sizeof(struct treq_sms_set_delivery_report));
608
609         decoded_sca = g_base64_decode(arg_sca, &length);
610         memcpy(&(deliveryReport.dataInfo.sca[0]), decoded_sca, SMS_SMSP_ADDRESS_LEN);
611
612         deliveryReport.dataInfo.msgLength = arg_tpdu_length;
613
614         decoded_tpdu = g_base64_decode(arg_tpdu_data, &length);
615         memcpy(&(deliveryReport.dataInfo.tpduData[0]), decoded_tpdu, SMS_SMDATA_SIZE_MAX + 1);
616
617         deliveryReport.rspType = arg_rpCause;
618
619         ur = MAKE_UR(ctx, sms, invocation);
620         tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_delivery_report), &deliveryReport);
621         tcore_user_request_set_command(ur, TREQ_SMS_SET_DELIVERY_REPORT);
622
623         if(decoded_sca)
624                 g_free(decoded_sca);
625
626         if(decoded_tpdu)
627                 g_free(decoded_tpdu);
628
629         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
630         if (ret != TCORE_RETURN_SUCCESS) {
631                 //api_err = TAPI_API_OPERATION_FAILED;
632                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
633                 return  FALSE;
634         }
635
636         return TRUE;
637 }
638
639 static gboolean
640 on_sms_set_msg_status(TelephonySms *sms, GDBusMethodInvocation *invocation,
641         gint arg_index,
642         gint arg_msgStatus,
643         gpointer user_data)
644 {
645         struct treq_sms_set_msg_status msgStatus = {0,};
646         struct custom_data *ctx = user_data;
647         UserRequest *ur = NULL;
648
649         msgStatus.index = arg_index;
650         msgStatus.msgStatus = arg_msgStatus;
651
652         ur = MAKE_UR(ctx, sms, invocation);
653         tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_msg_status), &msgStatus);
654         tcore_user_request_set_command(ur, TREQ_SMS_SET_MSG_STATUS);
655
656         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
657         if (ret != TCORE_RETURN_SUCCESS) {
658                 //api_err = TAPI_API_OPERATION_FAILED;
659                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
660                 return  FALSE;
661         }
662
663         return TRUE;
664 }
665
666 static gboolean
667 on_sms_get_sms_params(TelephonySms *sms, GDBusMethodInvocation *invocation,
668         gint arg_index,
669         gpointer user_data)
670 {
671         struct treq_sms_get_params getParams = {0,};
672         struct custom_data *ctx = user_data;
673         UserRequest *ur = NULL;
674
675         getParams.index = arg_index;
676
677         ur = MAKE_UR(ctx, sms, invocation);
678         tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_params), &getParams);
679         tcore_user_request_set_command(ur, TREQ_SMS_GET_PARAMS);
680
681         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
682         if (ret != TCORE_RETURN_SUCCESS) {
683                 //api_err = TAPI_API_OPERATION_FAILED;
684                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
685                 return  FALSE;
686         }
687
688         return TRUE;
689 }
690
691 static gboolean
692 on_sms_set_sms_params(TelephonySms *sms, GDBusMethodInvocation *invocation,
693         gint arg_recordIndex,
694         gint arg_recordLen,
695         gint arg_alphaIdLen,
696         const gchar *arg_alphaId,
697         gint arg_paramIndicator,
698         gint arg_destAddr_DialNumLen,
699         gint arg_destAddr_Ton,
700         gint arg_destAddr_Npi,
701         const gchar *arg_destAddr_DiallingNum,
702         gint arg_svcCntrAddr_DialNumLen,
703         gint arg_SvcCntrAddr_Ton,
704         gint arg_svcCntrAddr_Npi,
705         const gchar *arg_svcCntrAddr_DialNum,
706         gint arg_protocolId,
707         gint arg_dataCodingScheme,
708         gint arg_validityPeriod,
709         gpointer user_data)
710 {
711         struct treq_sms_set_params setParams;
712         struct custom_data *ctx = user_data;
713         UserRequest *ur = NULL;
714
715         gsize length;
716         guchar *decoded_alphaId = NULL;
717         guchar *decoded_destDialNum = NULL;
718         guchar *decoded_scaDialNum = NULL;
719
720         memset(&setParams, 0, sizeof(struct treq_sms_set_params));
721
722         setParams.params.recordIndex = arg_recordIndex;
723         setParams.params.recordLen = arg_recordLen;
724         setParams.params.alphaIdLen = arg_alphaIdLen;
725         decoded_alphaId = g_base64_decode(arg_alphaId, &length);
726         memcpy(&(setParams.params.szAlphaId[0]), decoded_alphaId, SMS_SMSP_ALPHA_ID_LEN_MAX + 1);
727         setParams.params.paramIndicator = arg_paramIndicator;
728
729         setParams.params.tpDestAddr.dialNumLen = arg_destAddr_DialNumLen;
730         setParams.params.tpDestAddr.typeOfNum = arg_destAddr_Ton;
731         setParams.params.tpDestAddr.numPlanId = arg_destAddr_Npi;
732         decoded_destDialNum = g_base64_decode(arg_destAddr_DiallingNum, &length);
733         memcpy(&(setParams.params.tpDestAddr.diallingNum[0]), decoded_destDialNum, SMS_SMSP_ADDRESS_LEN + 1);
734
735         setParams.params.tpSvcCntrAddr.dialNumLen = arg_svcCntrAddr_DialNumLen;
736         setParams.params.tpSvcCntrAddr.typeOfNum = arg_SvcCntrAddr_Ton;
737         setParams.params.tpSvcCntrAddr.numPlanId = arg_svcCntrAddr_Npi;
738         decoded_scaDialNum = g_base64_decode(arg_svcCntrAddr_DialNum, &length); 
739         memcpy(&(setParams.params.tpSvcCntrAddr.diallingNum[0]), decoded_scaDialNum, SMS_SMSP_ADDRESS_LEN + 1);
740
741         setParams.params.tpProtocolId = arg_protocolId;
742         setParams.params.tpDataCodingScheme = arg_dataCodingScheme;
743         setParams.params.tpValidityPeriod = arg_validityPeriod;
744
745         ur = MAKE_UR(ctx, sms, invocation);
746         tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_params), &setParams);
747         tcore_user_request_set_command(ur, TREQ_SMS_SET_PARAMS);
748
749         if(decoded_alphaId)
750                 g_free(decoded_alphaId);
751
752         if(decoded_destDialNum)
753                 g_free(decoded_destDialNum);
754
755         if(decoded_scaDialNum)
756                 g_free(decoded_scaDialNum);
757
758         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
759         if (ret != TCORE_RETURN_SUCCESS) {
760                 //api_err = TAPI_API_OPERATION_FAILED;
761                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
762                 return  FALSE;
763         }
764
765         return TRUE;
766 }
767
768 static gboolean
769 on_sms_get_sms_param_cnt(TelephonySms *sms, GDBusMethodInvocation *invocation,
770         gpointer user_data)
771 {
772         struct treq_sms_get_paramcnt getParamCnt;
773         struct custom_data *ctx = user_data;
774         UserRequest *ur = NULL;
775
776         ur = MAKE_UR(ctx, sms, invocation);
777         tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_paramcnt), &getParamCnt);
778         tcore_user_request_set_command(ur, TREQ_SMS_GET_PARAMCNT);
779
780         ret = tcore_communicator_dispatch_request(ctx->comm, ur);
781         if (ret != TCORE_RETURN_SUCCESS) {
782                 //api_err = TAPI_API_OPERATION_FAILED;
783                 err("[tcore_SMS] communicator_dispatch_request is fail [0x%x] !!!", ret);
784                 return  FALSE;
785         }
786
787         return TRUE;
788 }
789
790 static gboolean
791 on_sms_get_sms_ready_status(TelephonySms *sms, GDBusMethodInvocation *invocation,
792         gpointer user_data)
793 {
794         struct custom_data *ctx = user_data;
795         GSList *co_list = NULL;
796         CoreObject *co_sms = NULL;
797         TcorePlugin *plugin = NULL;
798
799         dbg("Func Entrance");
800
801         plugin = tcore_server_find_plugin(ctx->server, TCORE_PLUGIN_DEFAULT);
802         co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_SMS);
803         if (!co_list) {
804                 dbg("error- co_list is NULL");
805                 return FALSE;
806         }
807
808         co_sms = (CoreObject *)co_list->data;
809         g_slist_free(co_list);
810
811         if (!co_sms) {
812                 dbg("error- co_sms is NULL");
813                 return FALSE;
814         }
815         
816         telephony_sms_complete_get_sms_ready_status(sms, invocation, tcore_sms_get_ready_status(co_sms));
817
818         return TRUE;
819 }
820
821 gboolean dbus_plugin_setup_sms_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx)
822 {
823         TelephonySms *sms;
824
825         sms = telephony_sms_skeleton_new();
826         telephony_object_skeleton_set_sms(object, sms);
827         g_object_unref(sms);
828
829         g_signal_connect(sms, "handle-send-msg", G_CALLBACK (on_sms_send_msg), ctx);
830         g_signal_connect(sms, "handle-read-msg", G_CALLBACK (on_sms_read_msg), ctx);
831         g_signal_connect(sms, "handle-save-msg", G_CALLBACK (on_sms_save_msg), ctx);
832         g_signal_connect(sms, "handle-delete-msg", G_CALLBACK (on_sms_delete_msg), ctx);
833         g_signal_connect(sms, "handle-get-msg-count", G_CALLBACK (on_sms_get_msg_count), ctx);
834         g_signal_connect(sms, "handle-get-sca", G_CALLBACK (on_sms_get_sca), ctx);
835         g_signal_connect(sms, "handle-set-sca", G_CALLBACK (on_sms_set_sca), ctx);
836         g_signal_connect(sms, "handle-get-cb-config", G_CALLBACK (on_sms_get_cb_config), ctx);
837         g_signal_connect(sms, "handle-set-cb-config", G_CALLBACK (on_sms_set_cb_config), ctx);
838         g_signal_connect(sms, "handle-set-mem-status", G_CALLBACK (on_sms_set_mem_status), ctx);
839         g_signal_connect(sms, "handle-get-pref-bearer", G_CALLBACK (on_sms_get_pref_bearer), ctx);
840         g_signal_connect(sms, "handle-set-pref-bearer", G_CALLBACK (on_sms_set_pref_bearer), ctx);
841         g_signal_connect(sms, "handle-set-delivery-report", G_CALLBACK (on_sms_set_delivery_report), ctx);
842         g_signal_connect(sms, "handle-set-msg-status", G_CALLBACK (on_sms_set_msg_status), ctx);
843         g_signal_connect(sms, "handle-get-sms-params", G_CALLBACK (on_sms_get_sms_params), ctx);
844         g_signal_connect(sms, "handle-set-sms-params", G_CALLBACK (on_sms_set_sms_params), ctx);
845         g_signal_connect(sms, "handle-get-sms-param-cnt", G_CALLBACK (on_sms_get_sms_param_cnt), ctx);
846         g_signal_connect(sms, "handle-get-sms-ready-status", G_CALLBACK (on_sms_get_sms_ready_status), ctx);    
847
848         return TRUE;
849 }
850
851 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)
852 {
853         GSList *co_list;
854         CoreObject *co_sms;
855         char *modem_name = NULL;
856         TcorePlugin *p = NULL;
857
858         modem_name = tcore_user_request_get_modem_name(ur);
859         if (!modem_name)
860                 return FALSE;
861
862         p = tcore_server_find_plugin(ctx->server, modem_name);
863         free(modem_name);
864         if (!p)
865                 return FALSE;
866
867         co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SMS);
868         if (!co_list) {
869                 return FALSE;
870         }
871
872         co_sms = (CoreObject *)co_list->data;
873         g_slist_free(co_list);
874
875         if (!co_sms) {
876                 return FALSE;
877         }
878
879         switch (command) {
880                 case TRESP_SMS_SEND_UMTS_MSG: {
881                         const struct tresp_sms_send_umts_msg *resp = data;
882
883
884                         dbg("receive TRESP_SMS_SEND_UMTS_MSG");
885                         dbg("resp->result = 0x%x", resp->result);
886
887                         telephony_sms_complete_send_msg(dbus_info->interface_object, dbus_info->invocation, resp->result);
888
889                         }
890                         break;
891
892                 case TRESP_SMS_SEND_CDMA_MSG: {
893                         const struct tresp_sms_send_cdma_msg *resp = data;
894
895                         dbg("receive TRESP_SMS_SEND_CDMA_MSG");
896                         dbg("resp->result = 0x%x", resp->result);
897 #if 0
898                         resp->result
899                         resp->causeCode.ReplySeqNumber
900                         resp->causeCode.ErrClass
901                         resp->causeCode.Cause
902 #endif
903                         }
904                         break;
905
906                 case TRESP_SMS_READ_MSG: {
907                         const struct tresp_sms_read_msg *resp = data;
908                         gchar *sca = NULL;
909                         gchar *tpdu = NULL;                     
910
911                         dbg("receive TRESP_SMS_READ_MSG");
912                         dbg("resp->result = 0x%x", resp->result);
913
914                         sca = g_base64_encode((const guchar *)&(resp->dataInfo.smsData.sca[0]), SMS_SMSP_ADDRESS_LEN);
915                         if (sca == NULL) {
916                                 dbg("g_base64_encode: Failed to Enocde the SCA.");
917                                 sca = "";
918                         }
919
920                         tpdu = g_base64_encode((const guchar *)&(resp->dataInfo.smsData.tpduData[0]), SMS_SMDATA_SIZE_MAX + 1);
921                         if (sca == NULL) {
922                                 dbg("g_base64_encode: Failed to Enocde the SCA.");
923                                 tpdu = "";
924                         }
925
926                         telephony_sms_complete_read_msg(dbus_info->interface_object, dbus_info->invocation, 
927                                 resp->result, 
928                                 resp->dataInfo.msgStatus, 
929                                 sca, 
930                                 resp->dataInfo.smsData.msgLength, 
931                                 tpdu);
932
933                         if (sca)
934                                 g_free(sca);
935
936                         if (tpdu)
937                                 g_free(tpdu);
938
939                         }
940                         break;
941
942                 case TRESP_SMS_SAVE_MSG: {
943                         const struct tresp_sms_save_msg *resp = data;
944
945                         dbg("receive TRESP_SMS_SAVE_MSG");
946                         dbg("resp->result = 0x%x", resp->result);
947
948                         telephony_sms_complete_save_msg (dbus_info->interface_object, dbus_info->invocation,
949                                 resp->result,
950                                 resp->index);
951                         }
952                         break;
953
954                 case TRESP_SMS_DELETE_MSG: {
955                         const struct tresp_sms_delete_msg *resp = data;
956
957                         dbg("receive TRESP_SMS_DELETE_MSG");
958                         dbg("resp->result = 0x%x", resp->result);
959
960                         telephony_sms_complete_delete_msg(dbus_info->interface_object, dbus_info->invocation,
961                                 resp->result);
962
963                         }
964                         break;
965
966                 case TRESP_SMS_GET_STORED_MSG_COUNT: {
967                         const struct tresp_sms_get_storedMsgCnt *resp = data;
968                         gchar *msgCnt = NULL;
969
970                         dbg("receive TRESP_SMS_GET_STORED_MSG_COUNT");
971                         dbg("resp->result = 0x%x", resp->result);
972
973                         msgCnt = g_base64_encode((const guchar *)&(resp->storedMsgCnt.indexList[0]), SMS_GSM_SMS_MSG_NUM_MAX + 1);
974                         if (msgCnt == NULL) {
975                                 dbg("g_base64_encode: Failed to Enocde storedMsgCnt.indexList");
976                                 msgCnt = "";
977                         }
978
979                         telephony_sms_complete_get_msg_count(dbus_info->interface_object, dbus_info->invocation,
980                                 resp->result,
981                                 resp->storedMsgCnt.totalCount,
982                                 resp->storedMsgCnt.usedCount,
983                                 msgCnt);
984
985                         if (msgCnt)
986                                 g_free(msgCnt);
987                         }
988
989                         break;
990
991                 case TRESP_SMS_GET_SCA: {
992                         const struct tresp_sms_get_sca *resp = data;
993                         gchar *sca = NULL;
994
995                         dbg("receive TRESP_SMS_GET_SCA");
996                         dbg("resp->result = 0x%x", resp->result);
997
998                         sca = g_base64_encode((const guchar *)&(resp->scaAddress.diallingNum[0]), SMS_SMSP_ADDRESS_LEN + 1);
999                         if (sca == NULL) {
1000                                 dbg("g_base64_encode: Failed to Enocde scaAddress.diallingNum");
1001                                 sca = "";
1002                         }
1003                         
1004                         telephony_sms_complete_get_sca(dbus_info->interface_object, dbus_info->invocation,
1005                                 resp->result,
1006                                 resp->scaAddress.typeOfNum,
1007                                 resp->scaAddress.numPlanId,
1008                                 resp->scaAddress.dialNumLen,
1009                                 sca);
1010
1011                         if (sca)
1012                                 g_free(sca);
1013
1014                         }
1015                         break;
1016
1017                 case TRESP_SMS_SET_SCA: {
1018                         const struct tresp_sms_set_sca *resp = data;
1019
1020                         dbg("receive TRESP_SMS_SET_SCA");
1021                         dbg("resp->result = 0x%x", resp->result);
1022
1023                         telephony_sms_complete_set_sca(dbus_info->interface_object, dbus_info->invocation,
1024                                 resp->result);
1025
1026                         }
1027                         break;
1028
1029                 case TRESP_SMS_GET_CB_CONFIG: {
1030                         const struct tresp_sms_get_cb_config *resp = data;
1031                         gchar *msgIDs = NULL;
1032
1033                         dbg("receive TRESP_SMS_GET_CB_CONFIG");
1034                         dbg("resp->result = 0x%x", resp->result);
1035
1036                         msgIDs = g_base64_encode((const guchar *)&(resp->cbConfig.msgIDs[0]), SMS_GSM_SMS_CBMI_LIST_SIZE_MAX);
1037                         if (msgIDs == NULL) {
1038                                 dbg("g_base64_encode: Failed to Enocde cbConfig.msgIDs");
1039                                 msgIDs = "";
1040                         }
1041                         
1042                         telephony_sms_complete_get_cb_config(dbus_info->interface_object, dbus_info->invocation,
1043                                 resp->result,
1044                                 resp->cbConfig.bCBEnabled,
1045                                 resp->cbConfig.selectedId,
1046                                 resp->cbConfig.msgIdMaxCount,
1047                                 resp->cbConfig.msgIdCount,
1048                                 msgIDs);
1049
1050                         if(msgIDs)
1051                                 g_free(msgIDs);
1052
1053                         }
1054                         break;
1055
1056                 case TRESP_SMS_SET_CB_CONFIG: {
1057                         const struct tresp_sms_set_cb_config *resp = data;
1058
1059                         dbg("receive TRESP_SMS_SET_CB_CONFIG");
1060                         dbg("resp->result = 0x%x", resp->result);
1061
1062                         telephony_sms_complete_set_cb_config(dbus_info->interface_object, dbus_info->invocation,
1063                                 resp->result);
1064
1065                         }
1066                         break;
1067
1068                 case TRESP_SMS_SET_MEM_STATUS: {
1069                         const struct tresp_sms_set_mem_status *resp = data;
1070
1071                         dbg("receive TRESP_SMS_SET_MEM_STATUS");
1072                         dbg("resp->result = 0x%x", resp->result);
1073
1074                         telephony_sms_complete_set_mem_status(dbus_info->interface_object, dbus_info->invocation,
1075                                 resp->result);
1076
1077                         }
1078                         break;
1079                 case TRESP_SMS_GET_PREF_BEARER: {
1080                         const struct tresp_sms_get_pref_bearer *resp = data;
1081
1082                         dbg("receive TRESP_SMS_GET_PREF_BEARER");
1083                         dbg("resp->result = 0x%x", resp->result);
1084
1085                         telephony_sms_complete_get_pref_bearer(dbus_info->interface_object, dbus_info->invocation,
1086                                 resp->result);
1087
1088                         }
1089                         break;
1090
1091                 case TRESP_SMS_SET_PREF_BEARER: {
1092                         const struct tresp_sms_set_pref_bearer *resp = data;
1093
1094                         dbg("receive TRESP_SMS_SET_PREF_BEARER");
1095                         dbg("resp->result = 0x%x", resp->result);
1096
1097                         telephony_sms_complete_set_pref_bearer(dbus_info->interface_object, dbus_info->invocation,
1098                                 resp->result);
1099
1100                         }
1101                         break;
1102
1103                 case TRESP_SMS_SET_DELIVERY_REPORT: {
1104                         const struct tresp_sms_set_delivery_report *resp = data;
1105
1106                         dbg("receive TRESP_SMS_SET_DELIVERY_REPORT");
1107                         dbg("resp->result = 0x%x", resp->result);
1108
1109                         telephony_sms_complete_set_delivery_report(dbus_info->interface_object, dbus_info->invocation,
1110                                 resp->result);
1111
1112                         }
1113                         break;
1114
1115                 case TRESP_SMS_SET_MSG_STATUS: {
1116                         const struct tresp_sms_set_mem_status *resp = data;
1117
1118                         dbg("receive TRESP_SMS_SET_MSG_STATUS");
1119                         dbg("resp->result = 0x%x", resp->result);
1120
1121                         telephony_sms_complete_set_msg_status(dbus_info->interface_object, dbus_info->invocation,
1122                                 resp->result);
1123
1124                         }
1125                         break;
1126
1127                 case TRESP_SMS_GET_PARAMS: {
1128                         const struct tresp_sms_get_params *resp = data;
1129                         gchar *alphaId = NULL;
1130                         gchar *destDialNum = NULL;
1131                         gchar *scaDialNum = NULL;
1132
1133                         dbg("receive TRESP_SMS_GET_PARAMS");
1134                         dbg("resp->result = 0x%x", resp->result);
1135
1136                         alphaId = g_base64_encode((const guchar *)&(resp->paramsInfo.szAlphaId[0]), SMS_SMSP_ALPHA_ID_LEN_MAX + 1);
1137                         if (alphaId == NULL) {
1138                                 dbg("g_base64_encode: Failed to Enocde paramsInfo.szAlphaId");
1139                                 alphaId = "";
1140                         }
1141
1142                         destDialNum = g_base64_encode((const guchar *)&(resp->paramsInfo.tpDestAddr.diallingNum[0]), SMS_SMSP_ADDRESS_LEN + 1);
1143                         if (alphaId == NULL) {
1144                                 dbg("g_base64_encode: Failed to Enocde paramsInfo.tpDestAddr.diallingNum");
1145                                 alphaId = "";
1146                         }
1147
1148                         scaDialNum = g_base64_encode((const guchar *)&(resp->paramsInfo.tpSvcCntrAddr.diallingNum[0]), SMS_SMSP_ADDRESS_LEN + 1);
1149                         if (alphaId == NULL) {
1150                                 dbg("g_base64_encode: Failed to Enocde paramsInfo.tpSvcCntrAddr.diallingNum");
1151                                 alphaId = "";
1152                         }
1153
1154                         telephony_sms_complete_get_sms_params(dbus_info->interface_object, dbus_info->invocation,
1155                                 resp->result,
1156                                 resp->paramsInfo.recordIndex,
1157                                 resp->paramsInfo.recordLen,
1158                                 resp->paramsInfo.alphaIdLen,
1159                                 alphaId,
1160                                 resp->paramsInfo.paramIndicator,
1161                                 resp->paramsInfo.tpDestAddr.dialNumLen,
1162                                 resp->paramsInfo.tpDestAddr.typeOfNum,
1163                                 resp->paramsInfo.tpDestAddr.numPlanId,
1164                                 destDialNum,
1165                                 resp->paramsInfo.tpSvcCntrAddr.dialNumLen,
1166                                 resp->paramsInfo.tpSvcCntrAddr.typeOfNum,
1167                                 resp->paramsInfo.tpSvcCntrAddr.numPlanId,
1168                                 scaDialNum,
1169                                 resp->paramsInfo.tpProtocolId,
1170                                 resp->paramsInfo.tpDataCodingScheme,
1171                                 resp->paramsInfo.tpValidityPeriod);
1172
1173                         if(alphaId)
1174                                 g_free(alphaId);
1175
1176                         if(destDialNum)
1177                                 g_free(destDialNum);
1178
1179                         if(scaDialNum)
1180                                 g_free(scaDialNum);
1181                         
1182                         }
1183                         break;
1184
1185                 case TRESP_SMS_SET_PARAMS:{
1186                         const struct tresp_sms_set_params *resp = data;
1187
1188                         dbg("receive TRESP_SMS_SET_PARAMS");
1189                         dbg("resp->result = 0x%x", resp->result);
1190
1191                         telephony_sms_complete_set_sms_params(dbus_info->interface_object, dbus_info->invocation,
1192                                 resp->result);
1193
1194                         }
1195                         break;
1196
1197                 case TRESP_SMS_GET_PARAMCNT: {
1198                         const struct tresp_sms_get_paramcnt *resp = data;
1199
1200                         dbg("receive TRESP_SMS_GET_PARAMCNT");
1201                         dbg("resp->result = 0x%x", resp->result);
1202
1203                         telephony_sms_complete_get_sms_param_cnt(dbus_info->interface_object, dbus_info->invocation,
1204                                 resp->result,
1205                                 resp->recordCount);
1206
1207                         }
1208                         break;
1209
1210                 default:
1211                         break;
1212         }
1213
1214         return TRUE;
1215 }
1216
1217 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)
1218 {
1219         TelephonySms *sms;
1220
1221         if (!object)
1222         {
1223                 dbg("object is NULL");
1224                 return FALSE;
1225         }
1226
1227         sms = telephony_object_peek_sms(TELEPHONY_OBJECT(object));
1228         dbg("sms = %p", sms);
1229
1230         dbg("[tcore_SMS]notification !!! (command = 0x%x, data_len = %d)", command, data_len);
1231
1232         switch (command) {
1233                 case TNOTI_SMS_INCOM_MSG: {
1234                         const struct tnoti_sms_umts_msg *noti = data;
1235
1236                         gchar *sca = NULL;
1237                         gchar *tpdu = NULL;                     
1238
1239                         sca = g_base64_encode((const guchar *)&(noti->msgInfo.sca[0]), SMS_SMSP_ADDRESS_LEN);
1240                         if (sca == NULL) {
1241                                 dbg("g_base64_encode: Failed to Enocde msgInfo.sca");
1242                                 sca = "";
1243                         }
1244
1245                         tpdu = g_base64_encode((const guchar *)&(noti->msgInfo.tpduData[0]), SMS_SMDATA_SIZE_MAX + 1);
1246                         if (tpdu == NULL) {
1247                                 dbg("g_base64_encode: Failed to Enocde msgInfo.tpduData");
1248                                 tpdu = "";
1249                         }
1250                         
1251                         telephony_sms_emit_incomming_msg(sms,
1252                                 sca,
1253                                 noti->msgInfo.msgLength,
1254                                 tpdu);
1255
1256                         if(sca)
1257                                 g_free(sca);
1258
1259                         if(tpdu)
1260                                 g_free(tpdu);
1261
1262                         }
1263                         break;
1264
1265                 case TNOTI_SMS_CB_INCOM_MSG: {
1266                         const struct tnoti_sms_cellBroadcast_msg *noti = data;
1267                         gchar *msgData = NULL;
1268                         
1269                         msgData = g_base64_encode((const guchar *)&(noti->cbMsg.msgData[0]), SMS_SMSP_ADDRESS_LEN);
1270                         if (msgData == NULL) {
1271                                 dbg("g_base64_encode: Failed to Enocde cbMsg.msgData");
1272                                 msgData = "";
1273                         }
1274
1275                         telephony_sms_emit_incomming_cb_msg(sms,
1276                                 noti->cbMsg.cbMsgType,
1277                                 noti->cbMsg.length,
1278                                 msgData);
1279
1280                         if(msgData)
1281                                 g_free(msgData);
1282
1283                         }
1284                         break;
1285
1286                 case TNOTI_SMS_INCOM_EX_MSG: {
1287 #if 0
1288                         noti->cdmaMsg.ParamMask), SIPC_MARSHAL_DATA_INT_TYPE);
1289                         noti->cdmaMsg.MsgType), SIPC_MARSHAL_DATA_INT_TYPE);
1290
1291                         switch(noti->cdmaMsg.MsgType)
1292                         {
1293                                 case SMS_MESSAGETYPE_DELIVER:
1294                                         /* Origination address */
1295                                         noti->cdmaMsg.MsgData.inDeliver.OrigAddr.Digit), SIPC_MARSHAL_DATA_INT_TYPE);
1296                                         noti->cdmaMsg.MsgData.inDeliver.OrigAddr.NumberMode), SIPC_MARSHAL_DATA_INT_TYPE);
1297                                         noti->cdmaMsg.MsgData.inDeliver.OrigAddr.NumberType), SIPC_MARSHAL_DATA_INT_TYPE);
1298                                         noti->cdmaMsg.MsgData.inDeliver.OrigAddr.NumberPlan), SIPC_MARSHAL_DATA_INT_TYPE);
1299                                         noti->cdmaMsg.MsgData.inDeliver.OrigAddr.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1300                                         noti->cdmaMsg.MsgData.inDeliver.OrigAddr.szAddress[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1301
1302                                         /* Origination subaddress */
1303                                         noti->cdmaMsg.MsgData.inDeliver.OrigSubAddr.SubType), SIPC_MARSHAL_DATA_INT_TYPE);
1304                                         noti->cdmaMsg.MsgData.inDeliver.OrigSubAddr.Odd), SIPC_MARSHAL_DATA_CHAR_TYPE);
1305                                         noti->cdmaMsg.MsgData.inDeliver.OrigSubAddr.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1306                                         noti->cdmaMsg.MsgData.inDeliver.OrigSubAddr.szAddress[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1307
1308                                         noti->cdmaMsg.MsgData.inDeliver.TeleService), SIPC_MARSHAL_DATA_INT_TYPE);
1309                                         noti->cdmaMsg.MsgData.inDeliver.bBearerReplySeqRequest), SIPC_MARSHAL_DATA_INT_TYPE);
1310                                         noti->cdmaMsg.MsgData.inDeliver.ReplySeqNumber), SIPC_MARSHAL_DATA_CHAR_TYPE);
1311                                         noti->cdmaMsg.MsgData.inDeliver.MsgId), SIPC_MARSHAL_DATA_INT_TYPE);
1312                                         noti->cdmaMsg.MsgData.inDeliver.MsgEncoding), SIPC_MARSHAL_DATA_INT_TYPE);
1313                                         noti->cdmaMsg.MsgData.inDeliver.MsgLength), SIPC_MARSHAL_DATA_INT_TYPE);
1314                                         noti->cdmaMsg.MsgData.inDeliver.szData[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1315
1316                                         /* Message center time stamp */
1317                                         void *)&(noti->cdmaMsg.MsgData.inDeliver.MessageCenterTimeStamp.year), SIPC_MARSHAL_DATA_INT_TYPE);
1318                                         noti->cdmaMsg.MsgData.inDeliver.MessageCenterTimeStamp.month), SIPC_MARSHAL_DATA_INT_TYPE);
1319                                         noti->cdmaMsg.MsgData.inDeliver.MessageCenterTimeStamp.day), SIPC_MARSHAL_DATA_INT_TYPE);
1320                                         noti->cdmaMsg.MsgData.inDeliver.MessageCenterTimeStamp.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1321                                         noti->cdmaMsg.MsgData.inDeliver.MessageCenterTimeStamp.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1322                                         noti->cdmaMsg.MsgData.inDeliver.MessageCenterTimeStamp.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1323
1324                                         /* Validity period - Absolute */
1325                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodAbs.year), SIPC_MARSHAL_DATA_INT_TYPE);
1326                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodAbs.month), SIPC_MARSHAL_DATA_INT_TYPE);
1327                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodAbs.day), SIPC_MARSHAL_DATA_INT_TYPE);
1328                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodAbs.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1329                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodAbs.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1330                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodAbs.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1331
1332                                         noti->cdmaMsg.MsgData.inDeliver.ValidityPeriodRel), SIPC_MARSHAL_DATA_CHAR_TYPE);
1333
1334                                         /* Deferred delivery time - Absolute (not supported) */
1335                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeAbs.year), SIPC_MARSHAL_DATA_INT_TYPE);
1336                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeAbs.month), SIPC_MARSHAL_DATA_INT_TYPE);
1337                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeAbs.day), SIPC_MARSHAL_DATA_INT_TYPE);
1338                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeAbs.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1339                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeAbs.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1340                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeAbs.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1341
1342                                         /* Deferred delivery time - Relative (not supported) */
1343                                         noti->cdmaMsg.MsgData.inDeliver.DeferredDelTimeRel), SIPC_MARSHAL_DATA_CHAR_TYPE);
1344
1345                                         noti->cdmaMsg.MsgData.inDeliver.Priority), SIPC_MARSHAL_DATA_INT_TYPE);
1346                                         noti->cdmaMsg.MsgData.inDeliver.Privacy), SIPC_MARSHAL_DATA_INT_TYPE);
1347                                         noti->cdmaMsg.MsgData.inDeliver.NumMsg), SIPC_MARSHAL_DATA_CHAR_TYPE);
1348                                         noti->cdmaMsg.MsgData.inDeliver.bUserAckRequest), SIPC_MARSHAL_DATA_INT_TYPE);
1349                                         noti->cdmaMsg.MsgData.inDeliver.bDeliveryAckRequest), SIPC_MARSHAL_DATA_INT_TYPE);
1350                                         noti->cdmaMsg.MsgData.inDeliver.AlertPriority), SIPC_MARSHAL_DATA_INT_TYPE);
1351                                         noti->cdmaMsg.MsgData.inDeliver.MsgLang), SIPC_MARSHAL_DATA_INT_TYPE);
1352
1353                                         /* Callback number address */
1354                                         noti->cdmaMsg.MsgData.inDeliver.CallBackNumer.Digit), SIPC_MARSHAL_DATA_INT_TYPE);
1355                                         noti->cdmaMsg.MsgData.inDeliver.CallBackNumer.NumberMode), SIPC_MARSHAL_DATA_INT_TYPE);
1356                                         noti->cdmaMsg.MsgData.inDeliver.CallBackNumer.NumberType), SIPC_MARSHAL_DATA_INT_TYPE);
1357                                         noti->cdmaMsg.MsgData.inDeliver.CallBackNumer.NumberPlan), SIPC_MARSHAL_DATA_INT_TYPE);
1358                                         noti->cdmaMsg.MsgData.inDeliver.CallBackNumer.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1359                                         noti->cdmaMsg.MsgData.inDeliver.CallBackNumer.szAddress[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1360
1361                                         noti->cdmaMsg.MsgData.inDeliver.Display), SIPC_MARSHAL_DATA_INT_TYPE);
1362
1363                                         break;
1364
1365                                 case SMS_MESSAGETYPE_DELIVERY_ACK:
1366                                         /* Origination address */
1367                                         noti->cdmaMsg.MsgData.inAck.OrigAddr.Digit), SIPC_MARSHAL_DATA_INT_TYPE);
1368                                         noti->cdmaMsg.MsgData.inAck.OrigAddr.NumberMode), SIPC_MARSHAL_DATA_INT_TYPE);
1369                                         noti->cdmaMsg.MsgData.inAck.OrigAddr.NumberType), SIPC_MARSHAL_DATA_INT_TYPE);
1370                                         noti->cdmaMsg.MsgData.inAck.OrigAddr.NumberPlan), SIPC_MARSHAL_DATA_INT_TYPE);
1371                                         noti->cdmaMsg.MsgData.inAck.OrigAddr.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1372                                         noti->cdmaMsg.MsgData.inAck.OrigAddr.szAddress[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1373
1374                                         /* Origination subaddress */
1375                                         noti->cdmaMsg.MsgData.inAck.OrigSubAddr.SubType), SIPC_MARSHAL_DATA_INT_TYPE);
1376                                         noti->cdmaMsg.MsgData.inAck.OrigSubAddr.Odd), SIPC_MARSHAL_DATA_CHAR_TYPE);
1377                                         noti->cdmaMsg.MsgData.inAck.OrigSubAddr.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1378                                         noti->cdmaMsg.MsgData.inAck.OrigSubAddr.szAddress), SIPC_MARSHAL_DATA_CHAR_TYPE);
1379
1380                                         noti->cdmaMsg.MsgData.inAck.TeleService), SIPC_MARSHAL_DATA_INT_TYPE);
1381                                         noti->cdmaMsg.MsgData.inAck.bBearerReplySeqRequest), SIPC_MARSHAL_DATA_INT_TYPE);
1382                                         noti->cdmaMsg.MsgData.inAck.ReplySeqNumber), SIPC_MARSHAL_DATA_CHAR_TYPE);
1383                                         noti->cdmaMsg.MsgData.inAck.MsgId), SIPC_MARSHAL_DATA_INT_TYPE);
1384                                         noti->cdmaMsg.MsgData.inAck.MsgEncoding), SIPC_MARSHAL_DATA_INT_TYPE);
1385                                         noti->cdmaMsg.MsgData.inAck.MsgLength), SIPC_MARSHAL_DATA_INT_TYPE);
1386                                         noti->cdmaMsg.MsgData.inAck.szData[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1387
1388                                         noti->cdmaMsg.MsgData.inAck.UserResponseCode), SIPC_MARSHAL_DATA_CHAR_TYPE);
1389
1390                                         /* Message center time stamp */
1391                                         noti->cdmaMsg.MsgData.inAck.MessageCenterTimeStamp.year), SIPC_MARSHAL_DATA_INT_TYPE);
1392                                         noti->cdmaMsg.MsgData.inAck.MessageCenterTimeStamp.month), SIPC_MARSHAL_DATA_INT_TYPE);
1393                                         noti->cdmaMsg.MsgData.inAck.MessageCenterTimeStamp.day), SIPC_MARSHAL_DATA_INT_TYPE);
1394                                         noti->cdmaMsg.MsgData.inAck.MessageCenterTimeStamp.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1395                                         noti->cdmaMsg.MsgData.inAck.MessageCenterTimeStamp.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1396                                         noti->cdmaMsg.MsgData.inAck.MessageCenterTimeStamp.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1397
1398                                         break;
1399
1400                                 case SMS_MESSAGETYPE_USER_ACK:
1401                                         /* Origination address */
1402                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigAddr.Digit), SIPC_MARSHAL_DATA_INT_TYPE);
1403                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigAddr.NumberMode), SIPC_MARSHAL_DATA_INT_TYPE);
1404                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigAddr.NumberType), SIPC_MARSHAL_DATA_INT_TYPE);
1405                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigAddr.NumberPlan), SIPC_MARSHAL_DATA_INT_TYPE);
1406                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigAddr.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1407                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigAddr.szAddress[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1408
1409                                         /* Origination subaddress */
1410                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigSubAddr.SubType), SIPC_MARSHAL_DATA_INT_TYPE);
1411                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigSubAddr.Odd), SIPC_MARSHAL_DATA_CHAR_TYPE);
1412                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigSubAddr.szAddrLength), SIPC_MARSHAL_DATA_CHAR_TYPE);
1413                                         noti->cdmaMsg.MsgData.inDeliverAck.OrigSubAddr.szAddress), SIPC_MARSHAL_DATA_CHAR_TYPE);
1414
1415                                         noti->cdmaMsg.MsgData.inDeliverAck.TeleService), SIPC_MARSHAL_DATA_INT_TYPE);
1416                                         noti->cdmaMsg.MsgData.inDeliverAck.bBearerReplySeqRequest), SIPC_MARSHAL_DATA_INT_TYPE);
1417                                         noti->cdmaMsg.MsgData.inDeliverAck.ReplySeqNumber), SIPC_MARSHAL_DATA_CHAR_TYPE);
1418                                         noti->cdmaMsg.MsgData.inDeliverAck.MsgId), SIPC_MARSHAL_DATA_INT_TYPE);
1419                                         noti->cdmaMsg.MsgData.inDeliverAck.MsgEncoding), SIPC_MARSHAL_DATA_INT_TYPE);
1420                                         noti->cdmaMsg.MsgData.inDeliverAck.MsgLength), SIPC_MARSHAL_DATA_INT_TYPE);
1421                                         noti->cdmaMsg.MsgData.inDeliverAck.szData[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1422
1423                                         /* Message center time stamp */
1424                                         noti->cdmaMsg.MsgData.inDeliverAck.MessageCenterTimeStamp.year), SIPC_MARSHAL_DATA_INT_TYPE);
1425                                         noti->cdmaMsg.MsgData.inDeliverAck.MessageCenterTimeStamp.month), SIPC_MARSHAL_DATA_INT_TYPE);
1426                                         noti->cdmaMsg.MsgData.inDeliverAck.MessageCenterTimeStamp.day), SIPC_MARSHAL_DATA_INT_TYPE);
1427                                         noti->cdmaMsg.MsgData.inDeliverAck.MessageCenterTimeStamp.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1428                                         noti->cdmaMsg.MsgData.inDeliverAck.MessageCenterTimeStamp.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1429                                         noti->cdmaMsg.MsgData.inDeliverAck.MessageCenterTimeStamp.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1430
1431                                         break;
1432                                 default:
1433                                         break;
1434                         }
1435 #endif
1436                         }
1437                         break;
1438
1439                 case TNOTI_SMS_CB_INCOM_EX_MSG: {
1440 #if 0
1441                         noti->cdmaMsg.MsgData.inBc.ServiceCategory), SIPC_MARSHAL_DATA_INT_TYPE);
1442
1443                         noti->cdmaMsg.MsgData.inBc.MsgId), SIPC_MARSHAL_DATA_INT_TYPE);
1444                         noti->cdmaMsg.MsgData.inBc.bBearerReplySeqRequest), SIPC_MARSHAL_DATA_INT_TYPE);
1445                         noti->cdmaMsg.MsgData.inBc.ReplySeqNumber), SIPC_MARSHAL_DATA_CHAR_TYPE);
1446                         noti->cdmaMsg.MsgData.inBc.MsgEncoding), SIPC_MARSHAL_DATA_INT_TYPE);
1447                         noti->cdmaMsg.MsgData.inBc.MsgLength), SIPC_MARSHAL_DATA_INT_TYPE);
1448                         noti->cdmaMsg.MsgData.inBc.szData[0]), SIPC_MARSHAL_DATA_STRING_TYPE);
1449
1450                         /* Message center time stamp */
1451                         noti->cdmaMsg.MsgData.inBc.MessageCenterTimeStamp.year), SIPC_MARSHAL_DATA_INT_TYPE);
1452                         noti->cdmaMsg.MsgData.inBc.MessageCenterTimeStamp.month), SIPC_MARSHAL_DATA_INT_TYPE);
1453                         noti->cdmaMsg.MsgData.inBc.MessageCenterTimeStamp.day), SIPC_MARSHAL_DATA_INT_TYPE);
1454                         noti->cdmaMsg.MsgData.inBc.MessageCenterTimeStamp.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1455                         noti->cdmaMsg.MsgData.inBc.MessageCenterTimeStamp.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1456                         noti->cdmaMsg.MsgData.inBc.MessageCenterTimeStamp.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1457
1458                         /* Validity period - Absolute */
1459                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodAbs.year), SIPC_MARSHAL_DATA_INT_TYPE);
1460                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodAbs.month), SIPC_MARSHAL_DATA_INT_TYPE);
1461                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodAbs.day), SIPC_MARSHAL_DATA_INT_TYPE);
1462                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodAbs.hours), SIPC_MARSHAL_DATA_INT_TYPE);
1463                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodAbs.minutes), SIPC_MARSHAL_DATA_INT_TYPE);
1464                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodAbs.seconds), SIPC_MARSHAL_DATA_INT_TYPE);
1465
1466                         noti->cdmaMsg.MsgData.inBc.ValidityPeriodRel), SIPC_MARSHAL_DATA_CHAR_TYPE);
1467
1468                         noti->cdmaMsg.MsgData.inBc.Priority), SIPC_MARSHAL_DATA_INT_TYPE);
1469                         noti->cdmaMsg.MsgData.inBc.AlertPriority), SIPC_MARSHAL_DATA_INT_TYPE);
1470                         noti->cdmaMsg.MsgData.inBc.MsgLang), SIPC_MARSHAL_DATA_INT_TYPE);
1471                         noti->cdmaMsg.MsgData.inBc.Display), SIPC_MARSHAL_DATA_INT_TYPE);
1472
1473 #endif
1474                         }
1475                         break;
1476
1477                 case TNOTI_SMS_MEMORY_STATUS: {
1478                         const struct tnoti_sms_memory_status *noti = data;
1479
1480                         telephony_sms_emit_memory_status(sms, noti->status);
1481
1482                         }
1483                         break;
1484
1485                 case TNOTI_SMS_DEVICE_READY: {
1486                         const struct tnoti_sms_ready_status *noti = data;
1487
1488                         telephony_sms_emit_sms_ready(sms, noti->status);
1489
1490                         }
1491                         break;
1492
1493                 default:
1494                         dbg("unknown notification");
1495                         return FALSE;
1496                         break;
1497         }
1498
1499         return TRUE;
1500 }