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