modify code to get contact info on proxy side for search_msg and get_message_list
[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 void MsgHandle::openHandle()
46 {
47         bool bReady = false;
48
49         MsgProxyListener::instance()->insertOpenHandleSet(this);
50
51         /* server is currently booting and service is not available until the end of booting */
52         MsgSettingGetBool(VCONFKEY_MSG_SERVER_READY, &bReady);
53
54         if (bReady == false) {
55                 THROW(MsgException::SERVER_READY_ERROR, "Msg Server is not ready !!!!!");
56         } else {
57                 MSG_INFO("Msg Server is ready !!!!!");
58         }
59
60         /* Open Socket IPC */
61         connectSocket();
62 }
63
64
65 void MsgHandle::closeHandle(MsgHandle* pHandle)
66 {
67         MSG_BEGIN();
68
69         /* Remove CB List of closing Handle */
70         MsgProxyListener* eventListener = MsgProxyListener::instance();
71
72         eventListener->clearListOfClosedHandle(pHandle);
73         /* eventListener->stop(); */
74
75         /* Close Socket IPC */
76         disconnectSocket();
77
78 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
79         /* Close Contact Service */
80         if (MsgCloseContactSvc() != MSG_SUCCESS) {
81                 MSG_WARN("Fail to close contact service.");
82         }
83 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
84         removeDbHandle(); /* unregister db handler */
85
86         MSG_END();
87 }
88
89
90 void MsgHandle::connectSocket()
91 {
92         mClientSock.connect(MSG_SOCKET_PATH);
93 }
94
95
96 void MsgHandle::disconnectSocket()
97 {
98         mClientSock.close();
99 }
100
101
102 void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent)
103 {
104         if (pCmdData == NULL || ppEvent == NULL) {
105                 THROW(MsgException::INVALID_PARAM, "Param is NULL");
106         }
107
108         int ret = 0;
109
110         /* Send Command to MSG FW */
111         MutexLocker lock(mx);
112         ret = mClientSock.write(pCmdData, cmdSize);
113         if (ret < 0)
114                 THROW(MsgException::IPC_ERROR, "IPC write error");
115
116         char *tmpEvent = NULL;
117
118         while (1) {
119                 /* Receive Result from MSG FW */
120                 read(&tmpEvent);
121
122                 if (tmpEvent == NULL) {
123                         MSG_DEBUG("Event Data is NULL!!");
124                         break;
125                 }
126
127                 if (!CheckEventData(tmpEvent)) {
128                         delete [] tmpEvent;
129                         tmpEvent = NULL;
130                 } else {
131                         *ppEvent = tmpEvent;
132                         break;
133                 }
134         }
135 }
136
137
138 void MsgHandle::read(char **ppEvent)
139 {
140         unsigned int dataSize = 0;
141
142         int ret = mClientSock.read(ppEvent, &dataSize);
143
144         if (ret == CLOSE_CONNECTION_BY_SIGNAL) {
145                 THROW(MsgException::IPC_ERROR, "Server closed connection");
146         }
147 }
148
149
150 void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_INFO_S *pDest)
151 {
152         MSG_BEGIN();
153
154         pDest->msgId = pSrc->msgId;
155         pDest->threadId = pSrc->threadId;
156         pDest->folderId = pSrc->folderId;
157         pDest->msgType.mainType = pSrc->mainType;
158         pDest->msgType.subType = pSrc->subType;
159         pDest->msgType.classType = pSrc->classType;
160         pDest->storageId = pSrc->storageId;
161
162         if (g_list_length(pSrc->addressList) > 0) {
163                 msg_struct_s *addr_info = NULL;
164                 MSG_ADDRESS_INFO_S *address = NULL;
165
166                 pDest->nAddressCnt = g_list_length(pSrc->addressList);
167                 pDest->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * pDest->nAddressCnt];
168                 memset(pDest->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S) * pDest->nAddressCnt);
169
170                 for (int i = 0; i < pDest->nAddressCnt; i++) {
171                         addr_info = (msg_struct_s *)g_list_nth_data(pSrc->addressList, (guint)i);
172                         address = (MSG_ADDRESS_INFO_S *)addr_info->data;
173
174                         pDest->addressList[i].addressType = address->addressType;
175                         pDest->addressList[i].recipientType = address->recipientType;
176                         pDest->addressList[i].contactId = address->contactId;
177                         strncpy(pDest->addressList[i].addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN);
178                         strncpy(pDest->addressList[i].displayName, address->displayName, MAX_DISPLAY_NAME_LEN);
179                 }
180         } else {
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         MSG_DEBUG("mainType = %d",  pSrc->mainType);
228
229         if (pSrc->mainType == MSG_SMS_TYPE) {
230                 if (pSrc->pData != NULL) {
231                         pDest->bTextSms = true;
232                         pDest->dataSize = pSrc->dataSize;
233
234                         memset(pDest->msgText, 0x00, sizeof(pDest->msgText));
235
236                         if (pSrc->dataSize > MAX_MSG_TEXT_LEN) {
237                                 /* Save Message Data into File */
238                                 char fileName[MSG_FILENAME_LEN_MAX+1];
239                                 memset(fileName, 0x00, sizeof(fileName));
240
241                                 if (MsgCreateFileName(fileName) == false)
242                                         THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
243
244                                 MSG_SEC_DEBUG("Save pSrc->pData into file : size[%d] name[%s]", pDest->dataSize, fileName);
245
246                                 if (MsgWriteIpcFile(fileName, (char*)pSrc->pData, pSrc->dataSize) == false)
247                                         THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
248
249                                 memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
250                                 strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
251
252                                 pDest->bTextSms = false;
253
254                         } else {
255                                 if (pDest->encodeType == MSG_ENCODE_8BIT)
256                                         memcpy(pDest->msgText, pSrc->pData, pSrc->dataSize);
257                                 else
258                                         strncpy(pDest->msgText, (char*)pSrc->pData, pSrc->dataSize);
259                         }
260
261                         MSG_DEBUG("pData = %s", pSrc->pData);
262                 } else {
263                         MSG_DEBUG("pSrc->pData is NULL.");
264                         pDest->bTextSms = true;
265                         pDest->dataSize = 0;
266                 }
267
268                 MSG_SEC_DEBUG("msgText = %s", pDest->msgText);
269         } else if (pSrc->mainType == MSG_MMS_TYPE) {
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                         SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
483                         if (pSms) {
484                                 pDest->option.smsSendOptInfo.bReplyPath = pSms->bReplyPath;
485                         }
486                 }
487         } else if (msgType.mainType == MSG_MMS_TYPE) {
488                 msg_struct_s *pStruct = (msg_struct_s *)pSrc->mmsSendOpt;
489                 if (pStruct) {
490                         MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
491                         if (pMms) {
492                                 pDest->option.mmsSendOptInfo.priority = pMms->priority;
493                                 pDest->option.mmsSendOptInfo.bReadReq = pMms->bReadReq;
494
495                                 MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pMms->priority);
496                                 MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pMms->bReadReq);
497
498                                 if (pMms->expiryTime == 0) {
499                                         pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_NONE;
500                                         pDest->option.mmsSendOptInfo.expiryTime.time = pMms->expiryTime;
501                                 } else {
502                                         pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_RELATIVE;
503                                         pDest->option.mmsSendOptInfo.expiryTime.time = pMms->expiryTime;
504                                 }
505
506                                 if (pMms->bUseDeliveryCustomTime == true) {
507                                         pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = true;
508                                 } else {
509                                         pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = false;
510                                 }
511                                 pDest->option.mmsSendOptInfo.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
512                                 pDest->option.mmsSendOptInfo.deliveryTime.time = pMms->deliveryTime;
513
514                                 MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pDest->option.mmsSendOptInfo.expiryTime.time);
515                         }
516                 }
517         }
518
519         MSG_END();
520 }
521
522
523 void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_INFO_S* pSrc, MSG_SENDINGOPT_S* pDest, MSG_MESSAGE_TYPE_S msgType)
524 {
525         MSG_BEGIN();
526
527         pDest->bDeliverReq = pSrc->bDeliverReq;
528         pDest->bKeepCopy = pSrc->bKeepCopy;
529
530         MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
531         MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
532
533         if (msgType.mainType == MSG_SMS_TYPE) {
534                 msg_struct_s *pStruct = (msg_struct_s *)pDest->smsSendOpt;
535                 SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
536                 pSms->bReplyPath = pSrc->option.smsSendOptInfo.bReplyPath;
537         } else if (msgType.mainType == MSG_MMS_TYPE) {
538                 msg_struct_s *pStruct = (msg_struct_s *)pDest->mmsSendOpt;
539                 MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
540                 pMms->priority = pSrc->option.mmsSendOptInfo.priority;
541                 pMms->bReadReq = pSrc->option.mmsSendOptInfo.bReadReq;
542                 pMms->expiryTime = pSrc->option.mmsSendOptInfo.expiryTime.time;
543                 pMms->deliveryTime = pSrc->option.mmsSendOptInfo.deliveryTime.time;
544
545                 MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pMms->priority);
546                 MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pMms->bReadReq);
547                 MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pMms->expiryTime);
548         }
549
550         MSG_END();
551 }
552
553
554 int MsgHandle::getSettingCmdSize(MSG_OPTION_TYPE_T optionType)
555 {
556         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
557
558         switch (optionType) {
559         case MSG_GENERAL_OPT:
560                 cmdSize += sizeof(MSG_GENERAL_OPT_S);
561         break;
562         case MSG_SMS_SENDOPT:
563                 cmdSize += sizeof(MSG_SMS_SENDOPT_S);
564         break;
565         case MSG_SMSC_LIST:
566                 cmdSize += sizeof(MSG_SMSC_LIST_S);
567         break;
568         case MSG_MMS_SENDOPT:
569                 cmdSize += sizeof(MSG_MMS_SENDOPT_S);
570         break;
571         case MSG_MMS_RECVOPT:
572                 cmdSize += sizeof(MSG_MMS_RECVOPT_S);
573         break;
574         case MSG_MMS_STYLEOPT:
575                 cmdSize += sizeof(MSG_MMS_STYLEOPT_S);
576         break;
577         case MSG_PUSHMSG_OPT:
578                 cmdSize += sizeof(MSG_PUSHMSG_OPT_S);
579         break;
580         case MSG_CBMSG_OPT:
581                 cmdSize += sizeof(MSG_CBMSG_OPT_S);
582         break;
583         case MSG_VOICEMAIL_OPT:
584                 cmdSize += sizeof(MSG_VOICEMAIL_OPT_S);
585         break;
586         case MSG_MSGSIZE_OPT:
587                 cmdSize += sizeof(MSG_MSGSIZE_OPT_S);
588         break;
589         }
590
591         return cmdSize;
592 }
593
594
595 bool MsgHandle::CheckEventData(char *pEventData)
596 {
597         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
598
599         switch (pEvent->eventType) {
600         case MSG_EVENT_PLG_SENT_STATUS_CNF:
601         case MSG_EVENT_PLG_INCOMING_MSG_IND:
602         case MSG_EVENT_PLG_INCOMING_MMS_CONF:
603         case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND:
604         case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND:
605         case MSG_EVENT_PLG_STORAGE_CHANGE_IND:
606         case MSG_EVENT_PLG_INCOMING_CB_MSG_IND:
607         case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND:
608         case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND:
609                 return false;
610                 break;
611         default :
612                 return true;
613                 break;
614         }
615
616         return true;
617 }