Fix types for 64bit
[platform/core/messaging/msg-service.git] / proxy / MsgHandleControl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 #include <errno.h>
18 #include <stdlib.h>
19
20 #include "MsgDebug.h"
21 #include "MsgCppTypes.h"
22 #include "MsgException.h"
23 #include "MsgContact.h"
24 #include "MsgUtilFile.h"
25 #include "MsgGconfWrapper.h"
26 #include "MsgProxyListener.h"
27 #include "MsgHandle.h"
28 #include "MsgSqliteWrapper.h"
29
30 /*==================================================================================================
31                                      IMPLEMENTATION OF MsgHandle - Control Member Functions
32 ==================================================================================================*/
33 MsgHandle::MsgHandle() : mCounter(0), mClientSock()
34 {
35         memset(mConnectionId, 0x00, sizeof(mConnectionId));
36         memset(mCookie, 0x00, sizeof(mCookie));
37 }
38
39
40 MsgHandle::~MsgHandle()
41 {
42
43 }
44
45
46 void MsgHandle::openHandle()
47 {
48         bool bReady = false;
49
50         // server is currently booting and service is not available until the end of booting
51         MsgSettingGetBool(VCONFKEY_MSG_SERVER_READY, &bReady);
52
53         if (bReady == false) {
54                 THROW(MsgException::SERVER_READY_ERROR, "Msg Server is not ready !!!!!");
55         } else {
56                 MSG_INFO("Msg Server is ready !!!!!");
57         }
58
59         // Open Socket IPC
60         connectSocket();
61 }
62
63
64 void MsgHandle::closeHandle(MsgHandle* pHandle)
65 {
66         MSG_BEGIN();
67
68         //Remove CB List of closing Handle
69         MsgProxyListener* eventListener = MsgProxyListener::instance();
70
71         eventListener->clearListOfClosedHandle(pHandle);
72         //eventListener->stop();
73
74         // Close Socket IPC
75         disconnectSocket();
76
77 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
78         // Close Contact Service
79         if (MsgCloseContactSvc() != MSG_SUCCESS) {
80                 MSG_DEBUG("Fail to close contact service.");
81         }
82 #endif // MSG_CONTACTS_SERVICE_NOT_SUPPORTED
83         removeDbHandle(); /* unregister db handler */
84
85         MSG_END();
86 }
87
88
89 void MsgHandle::connectSocket()
90 {
91         mClientSock.connect(MSG_SOCKET_PATH);
92 }
93
94
95 void MsgHandle::disconnectSocket()
96 {
97         mClientSock.close();
98 }
99
100
101 void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent)
102 {
103         if (pCmdData == NULL || ppEvent == NULL) {
104                 THROW(MsgException::INVALID_PARAM, "Param is NULL");
105         }
106
107         int ret = 0;
108
109         // Send Command to MSG FW
110         ret = mClientSock.write(pCmdData, cmdSize);
111         if (ret < 0)
112                 THROW(MsgException::IPC_ERROR, "IPC write error");
113
114         char *tmpEvent = NULL;
115
116         while(1)
117         {
118                 // Receive Result from MSG FW
119                 read(&tmpEvent);
120
121                 if(tmpEvent == NULL) {
122                         MSG_DEBUG("Event Data is NULL!!");
123                         break;
124                 }
125
126                 if(!CheckEventData(tmpEvent)) {
127                         delete [] tmpEvent;
128                         tmpEvent = NULL;
129                 } else {
130                         *ppEvent = tmpEvent;
131                         break;
132                 }
133         }
134 }
135
136
137 void MsgHandle::read(char **ppEvent)
138 {
139         unsigned int dataSize = 0;
140
141         int ret = mClientSock.read(ppEvent, &dataSize);
142
143         if (ret == CLOSE_CONNECTION_BY_SIGNAL) {
144                 THROW(MsgException::IPC_ERROR, "Server closed connection");
145         }
146 }
147
148
149 void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_INFO_S *pDest)
150 {
151         MSG_BEGIN();
152
153         pDest->msgId = pSrc->msgId;
154         pDest->threadId = pSrc->threadId;
155         pDest->folderId = pSrc->folderId;
156         pDest->msgType.mainType = pSrc->mainType;
157         pDest->msgType.subType = pSrc->subType;
158         pDest->msgType.classType= pSrc->classType;
159         pDest->storageId = pSrc->storageId;
160
161         if (g_list_length(pSrc->addressList) > 0) {
162                 msg_struct_s *addr_info = NULL;
163                 MSG_ADDRESS_INFO_S *address = NULL;
164
165                 pDest->nAddressCnt = g_list_length(pSrc->addressList);
166                 pDest->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * pDest->nAddressCnt];
167                 memset(pDest->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S) * pDest->nAddressCnt);
168
169                 for (int i = 0; i < pDest->nAddressCnt; i++) {
170                         addr_info = (msg_struct_s *)g_list_nth_data(pSrc->addressList,(guint)i);
171                         address = (MSG_ADDRESS_INFO_S *)addr_info->data;
172
173                         pDest->addressList[i].addressType = address->addressType;
174                         pDest->addressList[i].recipientType = address->recipientType;
175                         pDest->addressList[i].contactId = address->contactId;
176                         strncpy(pDest->addressList[i].addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN);
177                         strncpy(pDest->addressList[i].displayName, address->displayName, MAX_DISPLAY_NAME_LEN);
178                 }
179         } else {
180
181                 msg_struct_list_s *addr_info_s = pSrc->addr_list;
182
183                 if (addr_info_s && (addr_info_s->nCount > 0)) {
184                         msg_struct_s *addr_info = NULL;
185                         MSG_ADDRESS_INFO_S *address = NULL;
186
187                         pDest->nAddressCnt = addr_info_s->nCount;
188
189                         pDest->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * addr_info_s->nCount];
190                         memset(pDest->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S) * addr_info_s->nCount);
191
192                         for (int i = 0; i < addr_info_s->nCount; i++) {
193                                 addr_info = (msg_struct_s *)addr_info_s->msg_struct_info[i];
194
195                                 address = (MSG_ADDRESS_INFO_S *)addr_info->data;
196
197                                 pDest->addressList[i].addressType = address->addressType;
198                                 pDest->addressList[i].recipientType = address->recipientType;
199                                 pDest->addressList[i].contactId = address->contactId;
200                                 strncpy(pDest->addressList[i].addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN);
201                                 strncpy(pDest->addressList[i].displayName, address->displayName, MAX_DISPLAY_NAME_LEN);
202                         }
203                 }
204         }
205
206         strncpy(pDest->replyAddress, pSrc->replyAddress, MAX_PHONE_NUMBER_LEN);
207         strncpy(pDest->subject, pSrc->subject, MAX_SUBJECT_LEN);
208
209         pDest->displayTime = pSrc->displayTime;
210         pDest->networkStatus = pSrc->networkStatus;
211         pDest->encodeType = pSrc->encodeType;
212         pDest->bRead = pSrc->bRead;
213         pDest->bProtected = pSrc->bProtected;
214         pDest->bBackup = pSrc->bBackup;
215         pDest->priority = pSrc->priority;
216         pDest->direction = pSrc->direction;
217
218         // Set Port Info.
219         pDest->msgPort.valid = pSrc->bPortValid;
220
221         if (pDest->msgPort.valid == true) {
222                 pDest->msgPort.dstPort = pSrc->dstPort;
223                 pDest->msgPort.srcPort = pSrc->srcPort;
224         }
225
226         MSG_DEBUG("nSize = %d",  pSrc->dataSize);
227
228         if (pSrc->mainType == MSG_SMS_TYPE){
229                 if (pSrc->pData != NULL) {
230                         pDest->bTextSms = true;
231                         pDest->dataSize = pSrc->dataSize;
232
233                         memset(pDest->msgText, 0x00, sizeof(pDest->msgText));
234
235                         if (pSrc->dataSize > MAX_MSG_TEXT_LEN) {
236                                 // Save Message Data into File
237                                 char fileName[MSG_FILENAME_LEN_MAX+1];
238                                 memset(fileName, 0x00, sizeof(fileName));
239
240                                 if(MsgCreateFileName(fileName) == false)
241                                         THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
242
243                                 MSG_SEC_DEBUG("Save pSrc->pData into file : size[%d] name[%s]", pDest->dataSize, fileName);
244
245                                 if (MsgWriteIpcFile(fileName, (char*)pSrc->pData, pSrc->dataSize) == false)
246                                         THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
247
248                                 memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
249                                 strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
250
251                                 pDest->bTextSms = false;
252
253                         } else {
254                                 if (pDest->encodeType == MSG_ENCODE_8BIT)
255                                         memcpy(pDest->msgText, pSrc->pData, pSrc->dataSize);
256                                 else
257                                         strncpy(pDest->msgText, (char*)pSrc->pData, pSrc->dataSize);
258                         }
259
260                         MSG_DEBUG("pData = %s", pSrc->pData);
261                 } else {
262                         MSG_DEBUG("pSrc->pData is NULL.");
263                         pDest->bTextSms = true;
264                         pDest->dataSize = 0;
265                 }
266
267                 MSG_SEC_DEBUG("msgText = %s", pDest->msgText);
268         } else if (pSrc->mainType == MSG_MMS_TYPE) {
269
270                 pDest->bTextSms = false;
271                 pDest->dataSize = pSrc->dataSize;
272
273                 if(pSrc->subType == MSG_READREPLY_MMS) {
274                         memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
275
276                         if (pSrc->mmsDataSize < MAX_MSG_DATA_LEN)
277                                 memcpy(pDest->msgData, pSrc->pMmsData, pSrc->mmsDataSize);
278                         else
279                                 memcpy(pDest->msgData, pSrc->pMmsData, MAX_MSG_DATA_LEN);
280
281                 } else {
282                         // Save Message Data into File
283                         char fileName[MSG_FILENAME_LEN_MAX+1];
284                         memset(fileName, 0x00, sizeof(fileName));
285
286                         if(MsgCreateFileName(fileName) == false)
287                                 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
288
289                         // change file extension in case of java MMS msg
290                         if (pSrc->subType == MSG_SENDREQ_JAVA_MMS) {
291                                 char* pFileNameExt = NULL;
292                                 pFileNameExt = strstr(fileName,"DATA");
293                                 if (pFileNameExt)
294                                         snprintf(pFileNameExt, strlen("JAVA")+1, "JAVA");
295                         }
296
297                         MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]", pSrc->mmsDataSize, fileName);
298                         if (MsgWriteIpcFile(fileName, (char*)pSrc->pMmsData, pSrc->mmsDataSize) == false)
299                                 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
300
301                         memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
302                         strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
303                         if (pSrc->pData) {
304                                 strncpy(pDest->msgText, (char*)pSrc->pData, MAX_MSG_TEXT_LEN);
305                         }
306
307                         if (strlen(pSrc->thumbPath) > 0) {
308                                 memset(pDest->thumbPath, 0x00, sizeof(pDest->thumbPath));
309                                 memcpy(pDest->thumbPath, pSrc->thumbPath, sizeof(pDest->thumbPath));
310                         }
311                 }
312         }
313
314         pDest->sim_idx = pSrc->simIndex;
315
316         MSG_END();
317 }
318
319
320 void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HIDDEN_S *pDest)
321 {
322         MSG_BEGIN();
323
324         pDest->msgId = pSrc->msgId;
325         pDest->threadId = pSrc->threadId;
326         pDest->folderId = pSrc->folderId;
327         pDest->mainType = pSrc->msgType.mainType;
328         pDest->subType = pSrc->msgType.subType;
329         pDest->storageId = pSrc->storageId;
330
331         strncpy(pDest->replyAddress, pSrc->replyAddress, MAX_PHONE_NUMBER_LEN);
332         strncpy(pDest->subject, pSrc->subject, MAX_SUBJECT_LEN);
333
334         pDest->displayTime = pSrc->displayTime;
335         pDest->networkStatus = pSrc->networkStatus;
336         pDest->encodeType = pSrc->encodeType;
337         pDest->bRead = pSrc->bRead;
338         pDest->bProtected = pSrc->bProtected;
339         pDest->bBackup = pSrc->bBackup;
340         pDest->priority = pSrc->priority;
341         pDest->direction = pSrc->direction;
342         pDest->simIndex = pSrc->sim_idx;
343
344         // Set Port Info.
345         pDest->bPortValid = pSrc->msgPort.valid;
346
347         if (pDest->bPortValid == true) {
348                 pDest->dstPort = pSrc->msgPort.dstPort;
349                 pDest->srcPort = pSrc->msgPort.srcPort;
350         }
351
352         if(pSrc->thumbPath[0] != '\0')
353                 strncpy(pDest->thumbPath, pSrc->thumbPath, MSG_FILEPATH_LEN_MAX);
354
355         int maxCnt = (pSrc->nAddressCnt > 10)? MAX_TO_ADDRESS_CNT: pSrc->nAddressCnt;
356
357         pDest->addr_list->nCount = maxCnt;
358
359         msg_struct_s *addr_info_s = NULL;
360         MSG_ADDRESS_INFO_S *addr_info = NULL;
361
362         for (int i = 0; i < maxCnt; i++) {
363                 addr_info_s = (msg_struct_s *)pDest->addr_list->msg_struct_info[i];
364                 addr_info = (MSG_ADDRESS_INFO_S *)addr_info_s->data;
365
366                 addr_info->addressType = pSrc->addressList[i].addressType;
367                 addr_info->recipientType = pSrc->addressList[i].recipientType;
368                 addr_info->contactId = pSrc->addressList[i].contactId;
369                 strncpy(addr_info->addressVal, pSrc->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
370                 strncpy(addr_info->displayName, pSrc->addressList[i].displayName, MAX_DISPLAY_NAME_LEN);
371                 addr_info->displayName[MAX_DISPLAY_NAME_LEN] = '\0';
372         }
373
374         for (int i = 0; i < pSrc->nAddressCnt; i++) {
375                 addr_info_s = new msg_struct_s;
376                 memset(addr_info_s, 0x00, sizeof(msg_struct_s));
377
378                 addr_info_s->type = MSG_STRUCT_ADDRESS_INFO;
379                 addr_info_s->data = new MSG_ADDRESS_INFO_S;
380                 memset(addr_info_s->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
381
382                 addr_info = (MSG_ADDRESS_INFO_S *)addr_info_s->data;
383
384                 addr_info->addressType = pSrc->addressList[i].addressType;
385                 addr_info->recipientType = pSrc->addressList[i].recipientType;
386                 addr_info->contactId = pSrc->addressList[i].contactId;
387                 strncpy(addr_info->addressVal, pSrc->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
388                 strncpy(addr_info->displayName, pSrc->addressList[i].displayName, MAX_DISPLAY_NAME_LEN);
389                 addr_info->displayName[MAX_DISPLAY_NAME_LEN] = '\0';
390
391                 pDest->addressList = g_list_append(pDest->addressList, addr_info_s);
392         }
393
394
395         if (pSrc->bTextSms == false) {
396                 int fileSize = 0;
397
398                 char* pFileData = NULL;
399                 unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
400
401                 pDest->dataSize = pSrc->dataSize;
402
403                 // Get Message Data from File
404                 if (MsgOpenAndReadFile(pSrc->msgData, &pFileData, &fileSize) == false)
405                         THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
406
407                 if (pSrc->msgType.mainType == MSG_SMS_TYPE) {
408                         if (pDest->encodeType == MSG_ENCODE_8BIT) {
409                                 pDest->pData = (void*)new char[fileSize];
410                                 memset(pDest->pData, 0x00, fileSize);
411                                 memcpy(pDest->pData, pFileData, fileSize);
412                         } else {
413                                 pDest->pData = (void*)new char[fileSize+1];
414                                 memset(pDest->pData, 0x00, fileSize+1);
415                                 strncpy((char*)pDest->pData, pFileData, fileSize);
416                         }
417                 } else {
418                         if (pSrc->msgText[0] != '\0') {
419                                 pDest->pData = (void*)new char[strlen(pSrc->msgText)+1];
420                                 memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1);
421                                 strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText));
422                         }
423                         pDest->mmsDataSize = fileSize;
424                         pDest->pMmsData = (void*)new char[fileSize];
425                         memset(pDest->pMmsData, 0x00, fileSize);
426                         memcpy(pDest->pMmsData, pFileData, fileSize);
427                         MSG_SEC_DEBUG("Get Message Data from file : size[%d] name[%s]", pDest->mmsDataSize, pSrc->msgData);
428                 }
429
430         } else {
431                 pDest->dataSize = pSrc->dataSize;
432
433                 if (pSrc->msgType.mainType == MSG_SMS_TYPE) {
434                         if (pDest->encodeType == MSG_ENCODE_8BIT || pSrc->msgType.subType == MSG_ETWS_SMS) {
435                                 pDest->pData = (void*)new char[pDest->dataSize];
436                                 memset(pDest->pData, 0x00, pDest->dataSize);
437                                 memcpy(pDest->pData, pSrc->msgText, pDest->dataSize);
438                         } else {
439                                 pDest->pData = (void*)new char[pDest->dataSize+1];
440                                 memset(pDest->pData, 0x00, pDest->dataSize+1);
441                                 strncpy((char*)pDest->pData, pSrc->msgText, pDest->dataSize);
442                         }
443                 } else {
444                         if (pSrc->msgText[0] != '\0') {
445                                 pDest->pData = (void*)new char[strlen(pSrc->msgText)+1];
446                                 memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1);
447                                 strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText));
448                         }
449
450                         pDest->mmsDataSize = pDest->dataSize;
451                         pDest->pMmsData = (void*)new char[pDest->dataSize];
452                         memset(pDest->pMmsData, 0x00, pDest->dataSize);
453                         memcpy(pDest->pMmsData, pSrc->msgData, pDest->dataSize);
454                 }
455         }
456
457         MSG_END();
458 }
459
460
461 void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_S* pSrc, MSG_SENDINGOPT_INFO_S* pDest, MSG_MESSAGE_TYPE_S msgType)
462 {
463         MSG_BEGIN();
464
465         pDest->bSetting = pSrc->bSetting;
466
467         if (pSrc->bSetting == false) {
468                 MSG_DEBUG("No Sending Option");
469                 return;
470         }
471
472         pDest->bDeliverReq = pSrc->bDeliverReq;
473         pDest->bKeepCopy = pSrc->bKeepCopy;
474
475         MSG_DEBUG("pDest->bSetting = %d", pDest->bSetting);
476         MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
477         MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
478
479         if (msgType.mainType == MSG_SMS_TYPE) {
480                 msg_struct_s *pStruct = (msg_struct_s *)pSrc->smsSendOpt;
481                 if(pStruct)
482                 {
483                         SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
484                         if(pSms)
485                         {
486                                 pDest->option.smsSendOptInfo.bReplyPath = pSms->bReplyPath;
487                         }
488                 }
489         } else if (msgType.mainType == MSG_MMS_TYPE) {
490                 msg_struct_s *pStruct = (msg_struct_s *)pSrc->mmsSendOpt;
491                 if(pStruct)
492                 {
493                         MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
494                         if(pMms)
495                         {
496                                 pDest->option.mmsSendOptInfo.priority = pMms->priority;
497                                 pDest->option.mmsSendOptInfo.bReadReq = pMms->bReadReq;
498
499                                 MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pMms->priority);
500                                 MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pMms->bReadReq);
501
502                                 if (pMms->expiryTime == 0) {
503                                         pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_NONE;
504                                         pDest->option.mmsSendOptInfo.expiryTime.time = pMms->expiryTime;
505                                 } else {
506                                         pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_RELATIVE;
507                                         pDest->option.mmsSendOptInfo.expiryTime.time = pMms->expiryTime;
508                                 }
509
510                                 if (pMms->bUseDeliveryCustomTime == true) {
511                                         pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = true;
512                                 } else {
513                                         pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = false;
514                                 }
515                                 pDest->option.mmsSendOptInfo.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
516                                 pDest->option.mmsSendOptInfo.deliveryTime.time = pMms->deliveryTime;
517
518                                 MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pDest->option.mmsSendOptInfo.expiryTime.time);
519                         }
520                 }
521         }
522
523         MSG_END();
524 }
525
526
527 void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_INFO_S* pSrc, MSG_SENDINGOPT_S* pDest, MSG_MESSAGE_TYPE_S msgType)
528 {
529         MSG_BEGIN();
530
531         pDest->bDeliverReq = pSrc->bDeliverReq;
532         pDest->bKeepCopy = pSrc->bKeepCopy;
533
534         MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
535         MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
536
537         if (msgType.mainType == MSG_SMS_TYPE) {
538                 msg_struct_s *pStruct = (msg_struct_s *)pDest->smsSendOpt;
539                 SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
540                 pSms->bReplyPath = pSrc->option.smsSendOptInfo.bReplyPath;
541         } else if (msgType.mainType == MSG_MMS_TYPE) {
542                 msg_struct_s *pStruct = (msg_struct_s *)pDest->mmsSendOpt;
543                 MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
544                 pMms->priority = pSrc->option.mmsSendOptInfo.priority;
545                 pMms->bReadReq = pSrc->option.mmsSendOptInfo.bReadReq;
546                 pMms->expiryTime = pSrc->option.mmsSendOptInfo.expiryTime.time;
547                 pMms->deliveryTime = pSrc->option.mmsSendOptInfo.deliveryTime.time;
548
549                 MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pMms->priority);
550                 MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pMms->bReadReq);
551                 MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pMms->expiryTime);
552         }
553
554         MSG_END();
555 }
556
557
558 int MsgHandle::getSettingCmdSize(MSG_OPTION_TYPE_T optionType)
559 {
560         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
561
562         switch (optionType)
563         {
564                 case MSG_GENERAL_OPT :
565                         cmdSize += sizeof(MSG_GENERAL_OPT_S);
566                 break;
567                 case MSG_SMS_SENDOPT :
568                         cmdSize += sizeof(MSG_SMS_SENDOPT_S);
569                 break;
570                 case MSG_SMSC_LIST :
571                         cmdSize += sizeof(MSG_SMSC_LIST_S);
572                 break;
573                 case MSG_MMS_SENDOPT :
574                         cmdSize += sizeof(MSG_MMS_SENDOPT_S);
575                 break;
576                 case MSG_MMS_RECVOPT :
577                         cmdSize += sizeof(MSG_MMS_RECVOPT_S);
578                 break;
579                 case MSG_MMS_STYLEOPT :
580                         cmdSize += sizeof(MSG_MMS_STYLEOPT_S);
581                 break;
582                 case MSG_PUSHMSG_OPT :
583                         cmdSize += sizeof(MSG_PUSHMSG_OPT_S);
584                 break;
585                 case MSG_CBMSG_OPT :
586                         cmdSize += sizeof(MSG_CBMSG_OPT_S);
587                 break;
588                 case MSG_VOICEMAIL_OPT :
589                         cmdSize += sizeof(MSG_VOICEMAIL_OPT_S);
590                 break;
591                 case MSG_MSGSIZE_OPT :
592                         cmdSize += sizeof(MSG_MSGSIZE_OPT_S);
593                 break;
594         }
595
596         return cmdSize;
597 }
598
599
600 bool MsgHandle::CheckEventData(char *pEventData)
601 {
602         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
603
604         switch (pEvent->eventType)
605         {
606         case MSG_EVENT_PLG_SENT_STATUS_CNF :
607         case MSG_EVENT_PLG_INCOMING_MSG_IND :
608         case MSG_EVENT_PLG_INCOMING_MMS_CONF :
609         case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND :
610         case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND :
611         case MSG_EVENT_PLG_STORAGE_CHANGE_IND :
612         case MSG_EVENT_PLG_INCOMING_CB_MSG_IND :
613         case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND :
614         case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND :
615                 return false;
616                 break;
617         default :
618                 return true;
619                 break;
620         }
621
622         return true;
623 }