2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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"
30 /*==================================================================================================
31 IMPLEMENTATION OF MsgHandle - Control Member Functions
32 ==================================================================================================*/
33 MsgHandle::MsgHandle() : mCounter(0), mClientSock()
35 memset(mConnectionId, 0x00, sizeof(mConnectionId));
36 memset(mCookie, 0x00, sizeof(mCookie));
40 MsgHandle::~MsgHandle()
45 void MsgHandle::openHandle()
48 msg_error_t error = MSG_SUCCESS;
50 MsgProxyListener::instance()->insertOpenHandleSet(this);
52 /* server is currently booting and service is not available until the end of booting */
53 error = MsgSettingGetBool(VCONFKEY_MSG_SERVER_READY, &bReady);
54 if (error != MSG_SUCCESS) {
55 MSG_INFO("MsgSettingGetBool() is failed");
56 if (error == MSG_ERR_PERMISSION_DENIED)
57 THROW(MsgException::SECURITY_ERROR, "Client doesn't have permission");
60 if (bReady == false) {
61 THROW(MsgException::SERVER_READY_ERROR, "Msg Server is not ready !!!!!");
63 MSG_INFO("Msg Server is ready !!!!!");
69 /* Check cynara permission */
70 if (checkPermission() == MSG_ERR_PERMISSION_DENIED) {
71 THROW(MsgException::SECURITY_ERROR, "Client doesn't have permission");
76 void MsgHandle::closeHandle(MsgHandle* pHandle)
80 /* Remove CB List of closing Handle */
81 MsgProxyListener* eventListener = MsgProxyListener::instance();
83 eventListener->clearListOfClosedHandle(pHandle);
84 /* eventListener->stop(); */
86 /* Close Socket IPC */
89 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
90 /* Close Contact Service */
91 if (MsgCloseContactSvc() != MSG_SUCCESS) {
92 MSG_WARN("Fail to close contact service.");
94 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
95 removeDbHandle(); /* unregister db handler */
101 void MsgHandle::connectSocket()
103 mClientSock.connect(MSG_SOCKET_PATH);
107 void MsgHandle::disconnectSocket()
113 void MsgHandle::write(const char *pCmdData, int cmdSize, char **ppEvent)
115 if (pCmdData == NULL || ppEvent == NULL) {
116 THROW(MsgException::INVALID_PARAM, "Param is NULL");
121 /* Send Command to MSG FW */
122 MsgMutexLocker lock(mx);
123 ret = mClientSock.write(pCmdData, cmdSize);
125 THROW(MsgException::IPC_ERROR, "IPC write error");
127 char *tmpEvent = NULL;
130 /* Receive Result from MSG FW */
133 if (tmpEvent == NULL) {
134 MSG_DEBUG("Event Data is NULL!!");
138 if (!checkEventData(tmpEvent)) {
149 void MsgHandle::read(char **ppEvent)
151 unsigned int dataSize = 0;
153 int ret = mClientSock.read(ppEvent, &dataSize);
155 if (ret == CLOSE_CONNECTION_BY_SIGNAL) {
156 THROW(MsgException::IPC_ERROR, "Server closed connection");
161 void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_INFO_S *pDest)
165 pDest->msgId = pSrc->msgId;
166 pDest->threadId = pSrc->threadId;
167 pDest->folderId = pSrc->folderId;
168 pDest->msgType.mainType = pSrc->mainType;
169 pDest->msgType.subType = pSrc->subType;
170 pDest->msgType.classType = pSrc->classType;
171 pDest->storageId = pSrc->storageId;
173 if (g_list_length(pSrc->addressList) > 0) {
174 msg_struct_s *addr_info = NULL;
175 MSG_ADDRESS_INFO_S *address = NULL;
177 pDest->nAddressCnt = g_list_length(pSrc->addressList);
178 pDest->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * pDest->nAddressCnt];
179 memset(pDest->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S) * pDest->nAddressCnt);
181 for (int i = 0; i < pDest->nAddressCnt; i++) {
182 addr_info = (msg_struct_s *)g_list_nth_data(pSrc->addressList, (guint)i);
183 address = (MSG_ADDRESS_INFO_S *)addr_info->data;
185 pDest->addressList[i].addressType = address->addressType;
186 pDest->addressList[i].recipientType = address->recipientType;
187 pDest->addressList[i].contactId = address->contactId;
188 strncpy(pDest->addressList[i].addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN);
189 strncpy(pDest->addressList[i].displayName, address->displayName, MAX_DISPLAY_NAME_LEN);
192 msg_struct_list_s *addr_info_s = pSrc->addr_list;
194 if (addr_info_s && (addr_info_s->nCount > 0)) {
195 msg_struct_s *addr_info = NULL;
196 MSG_ADDRESS_INFO_S *address = NULL;
198 pDest->nAddressCnt = addr_info_s->nCount;
200 pDest->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * addr_info_s->nCount];
201 memset(pDest->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S) * addr_info_s->nCount);
203 for (int i = 0; i < addr_info_s->nCount; i++) {
204 addr_info = (msg_struct_s *)addr_info_s->msg_struct_info[i];
206 address = (MSG_ADDRESS_INFO_S *)addr_info->data;
208 pDest->addressList[i].addressType = address->addressType;
209 pDest->addressList[i].recipientType = address->recipientType;
210 pDest->addressList[i].contactId = address->contactId;
211 strncpy(pDest->addressList[i].addressVal, address->addressVal, MAX_ADDRESS_VAL_LEN);
212 strncpy(pDest->addressList[i].displayName, address->displayName, MAX_DISPLAY_NAME_LEN);
217 strncpy(pDest->replyAddress, pSrc->replyAddress, MAX_PHONE_NUMBER_LEN);
218 strncpy(pDest->subject, pSrc->subject, MAX_SUBJECT_LEN);
220 pDest->displayTime = pSrc->displayTime;
221 pDest->networkStatus = pSrc->networkStatus;
222 pDest->encodeType = pSrc->encodeType;
223 pDest->bRead = pSrc->bRead;
224 pDest->bProtected = pSrc->bProtected;
225 pDest->bBackup = pSrc->bBackup;
226 pDest->priority = pSrc->priority;
227 pDest->direction = pSrc->direction;
230 pDest->msgPort.valid = pSrc->bPortValid;
232 if (pDest->msgPort.valid == true) {
233 pDest->msgPort.dstPort = pSrc->dstPort;
234 pDest->msgPort.srcPort = pSrc->srcPort;
237 MSG_DEBUG("nSize = %d", pSrc->dataSize);
238 MSG_DEBUG("mainType = %d", pSrc->mainType);
240 if (pSrc->mainType == MSG_SMS_TYPE) {
241 if (pSrc->pData != NULL) {
242 pDest->bTextSms = true;
243 pDest->dataSize = pSrc->dataSize;
245 memset(pDest->msgText, 0x00, sizeof(pDest->msgText));
247 if (pSrc->dataSize > MAX_MSG_TEXT_LEN) {
248 /* Save Message Data into File */
249 char fileName[MSG_FILENAME_LEN_MAX+1];
250 memset(fileName, 0x00, sizeof(fileName));
252 if (MsgCreateFileName(fileName) == false)
253 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
255 MSG_SEC_DEBUG("Save pSrc->pData into file : size[%d] name[%s]", pDest->dataSize, fileName);
257 if (MsgWriteIpcFile(fileName, (char*)pSrc->pData, pSrc->dataSize) == false)
258 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
260 memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
261 strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
263 pDest->bTextSms = false;
266 if (pDest->encodeType == MSG_ENCODE_8BIT)
267 memcpy(pDest->msgText, pSrc->pData, pSrc->dataSize);
269 strncpy(pDest->msgText, (char*)pSrc->pData, pSrc->dataSize);
272 MSG_DEBUG("pData = %s", pSrc->pData);
274 MSG_DEBUG("pSrc->pData is NULL.");
275 pDest->bTextSms = true;
279 MSG_SEC_DEBUG("msgText = %s", pDest->msgText);
280 } else if (pSrc->mainType == MSG_MMS_TYPE) {
281 pDest->bTextSms = false;
282 pDest->dataSize = pSrc->dataSize;
284 if (pSrc->subType == MSG_READREPLY_MMS) {
285 memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
287 if (pSrc->mmsDataSize < MAX_MSG_DATA_LEN)
288 memcpy(pDest->msgData, pSrc->pMmsData, pSrc->mmsDataSize);
290 memcpy(pDest->msgData, pSrc->pMmsData, MAX_MSG_DATA_LEN);
293 /* Save Message Data into File */
294 char fileName[MSG_FILENAME_LEN_MAX+1];
295 memset(fileName, 0x00, sizeof(fileName));
297 if (MsgCreateFileName(fileName) == false)
298 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
300 /* change file extension in case of java MMS msg */
301 if (pSrc->subType == MSG_SENDREQ_JAVA_MMS) {
302 char* pFileNameExt = NULL;
303 pFileNameExt = strstr(fileName, "DATA");
305 snprintf(pFileNameExt, strlen("JAVA")+1, "JAVA");
308 MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]", pSrc->mmsDataSize, fileName);
309 if (MsgWriteIpcFile(fileName, (char*)pSrc->pMmsData, pSrc->mmsDataSize) == false)
310 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
312 memset(pDest->msgData, 0x00, sizeof(pDest->msgData));
313 strncpy(pDest->msgData, fileName, MAX_MSG_DATA_LEN);
315 strncpy(pDest->msgText, (char*)pSrc->pData, MAX_MSG_TEXT_LEN);
318 if (strlen(pSrc->thumbPath) > 0) {
319 memset(pDest->thumbPath, 0x00, sizeof(pDest->thumbPath));
320 memcpy(pDest->thumbPath, pSrc->thumbPath, sizeof(pDest->thumbPath));
325 pDest->sim_idx = pSrc->simIndex;
326 pDest->bRestricted = pSrc->bRestricted;
332 void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HIDDEN_S *pDest)
336 pDest->msgId = pSrc->msgId;
337 pDest->threadId = pSrc->threadId;
338 pDest->folderId = pSrc->folderId;
339 pDest->mainType = pSrc->msgType.mainType;
340 pDest->subType = pSrc->msgType.subType;
341 pDest->storageId = pSrc->storageId;
343 strncpy(pDest->replyAddress, pSrc->replyAddress, MAX_PHONE_NUMBER_LEN);
344 strncpy(pDest->subject, pSrc->subject, MAX_SUBJECT_LEN);
346 pDest->displayTime = pSrc->displayTime;
347 pDest->networkStatus = pSrc->networkStatus;
348 pDest->encodeType = pSrc->encodeType;
349 pDest->bRead = pSrc->bRead;
350 pDest->bProtected = pSrc->bProtected;
351 pDest->bBackup = pSrc->bBackup;
352 pDest->priority = pSrc->priority;
353 pDest->direction = pSrc->direction;
354 pDest->simIndex = pSrc->sim_idx;
355 pDest->bRestricted = pSrc->bRestricted;
358 pDest->bPortValid = pSrc->msgPort.valid;
360 if (pDest->bPortValid == true) {
361 pDest->dstPort = pSrc->msgPort.dstPort;
362 pDest->srcPort = pSrc->msgPort.srcPort;
365 if (pSrc->thumbPath[0] != '\0')
366 strncpy(pDest->thumbPath, pSrc->thumbPath, MSG_FILEPATH_LEN_MAX);
368 int maxCnt = (pSrc->nAddressCnt > 10)? MAX_TO_ADDRESS_CNT: pSrc->nAddressCnt;
370 pDest->addr_list->nCount = maxCnt;
372 msg_struct_s *addr_info_s = NULL;
373 MSG_ADDRESS_INFO_S *addr_info = NULL;
375 for (int i = 0; i < maxCnt; i++) {
376 addr_info_s = (msg_struct_s *)pDest->addr_list->msg_struct_info[i];
377 addr_info = (MSG_ADDRESS_INFO_S *)addr_info_s->data;
379 addr_info->addressType = pSrc->addressList[i].addressType;
380 addr_info->recipientType = pSrc->addressList[i].recipientType;
381 addr_info->contactId = pSrc->addressList[i].contactId;
382 strncpy(addr_info->addressVal, pSrc->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
383 strncpy(addr_info->displayName, pSrc->addressList[i].displayName, MAX_DISPLAY_NAME_LEN);
384 addr_info->displayName[MAX_DISPLAY_NAME_LEN] = '\0';
387 for (int i = 0; i < pSrc->nAddressCnt; i++) {
388 addr_info_s = new msg_struct_s;
389 memset(addr_info_s, 0x00, sizeof(msg_struct_s));
391 addr_info_s->type = MSG_STRUCT_ADDRESS_INFO;
392 addr_info_s->data = new MSG_ADDRESS_INFO_S;
393 memset(addr_info_s->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
395 addr_info = (MSG_ADDRESS_INFO_S *)addr_info_s->data;
397 addr_info->addressType = pSrc->addressList[i].addressType;
398 addr_info->recipientType = pSrc->addressList[i].recipientType;
399 addr_info->contactId = pSrc->addressList[i].contactId;
400 strncpy(addr_info->addressVal, pSrc->addressList[i].addressVal, MAX_ADDRESS_VAL_LEN);
401 strncpy(addr_info->displayName, pSrc->addressList[i].displayName, MAX_DISPLAY_NAME_LEN);
402 addr_info->displayName[MAX_DISPLAY_NAME_LEN] = '\0';
404 pDest->addressList = g_list_append(pDest->addressList, addr_info_s);
408 if (pSrc->bTextSms == false) {
411 char* pFileData = NULL;
412 unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
414 pDest->dataSize = pSrc->dataSize;
416 /* Get Message Data from File */
417 if (MsgOpenAndReadFile(pSrc->msgData, &pFileData, &fileSize) == false)
418 THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
420 if (pSrc->msgType.mainType == MSG_SMS_TYPE) {
421 if (pDest->encodeType == MSG_ENCODE_8BIT) {
422 pDest->pData = (void*)new char[fileSize];
423 memset(pDest->pData, 0x00, fileSize);
424 memcpy(pDest->pData, pFileData, fileSize);
426 pDest->pData = (void*)new char[fileSize+1];
427 memset(pDest->pData, 0x00, fileSize+1);
428 strncpy((char*)pDest->pData, pFileData, fileSize);
431 if (pSrc->msgText[0] != '\0') {
432 pDest->pData = (void*)new char[strlen(pSrc->msgText)+1];
433 memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1);
434 strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText));
436 pDest->mmsDataSize = fileSize;
437 pDest->pMmsData = (void*)new char[fileSize];
438 memset(pDest->pMmsData, 0x00, fileSize);
439 memcpy(pDest->pMmsData, pFileData, fileSize);
440 MSG_SEC_DEBUG("Get Message Data from file : size[%d] name[%s]", pDest->mmsDataSize, pSrc->msgData);
444 pDest->dataSize = pSrc->dataSize;
446 if (pSrc->msgType.mainType == MSG_SMS_TYPE) {
447 if (pDest->encodeType == MSG_ENCODE_8BIT || pSrc->msgType.subType == MSG_ETWS_SMS) {
448 pDest->pData = (void*)new char[pDest->dataSize];
449 memset(pDest->pData, 0x00, pDest->dataSize);
450 memcpy(pDest->pData, pSrc->msgText, pDest->dataSize);
452 pDest->pData = (void*)new char[pDest->dataSize+1];
453 memset(pDest->pData, 0x00, pDest->dataSize+1);
454 strncpy((char*)pDest->pData, pSrc->msgText, pDest->dataSize);
457 if (pSrc->msgText[0] != '\0') {
458 pDest->pData = (void*)new char[strlen(pSrc->msgText)+1];
459 memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1);
460 strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText));
463 pDest->mmsDataSize = pDest->dataSize;
464 pDest->pMmsData = (void*)new char[pDest->dataSize];
465 memset(pDest->pMmsData, 0x00, pDest->dataSize);
466 memcpy(pDest->pMmsData, pSrc->msgData, pDest->dataSize);
474 void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_S* pSrc, MSG_SENDINGOPT_INFO_S* pDest, MSG_MESSAGE_TYPE_S msgType)
478 pDest->bSetting = pSrc->bSetting;
480 if (pSrc->bSetting == false) {
481 MSG_DEBUG("No Sending Option");
485 pDest->bDeliverReq = pSrc->bDeliverReq;
486 pDest->bKeepCopy = pSrc->bKeepCopy;
488 MSG_DEBUG("pDest->bSetting = %d", pDest->bSetting);
489 MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
490 MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
492 if (msgType.mainType == MSG_SMS_TYPE) {
493 msg_struct_s *pStruct = (msg_struct_s *)pSrc->smsSendOpt;
495 SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
497 pDest->option.smsSendOptInfo.bReplyPath = pSms->bReplyPath;
500 } else if (msgType.mainType == MSG_MMS_TYPE) {
501 msg_struct_s *pStruct = (msg_struct_s *)pSrc->mmsSendOpt;
503 MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
505 pDest->option.mmsSendOptInfo.priority = pMms->priority;
506 pDest->option.mmsSendOptInfo.bReadReq = pMms->bReadReq;
508 MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pMms->priority);
509 MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pMms->bReadReq);
511 if (pMms->expiryTime == 0) {
512 pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_NONE;
513 pDest->option.mmsSendOptInfo.expiryTime.time = pMms->expiryTime;
515 pDest->option.mmsSendOptInfo.expiryTime.type = MMS_TIMETYPE_RELATIVE;
516 pDest->option.mmsSendOptInfo.expiryTime.time = pMms->expiryTime;
519 if (pMms->bUseDeliveryCustomTime == true) {
520 pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = true;
522 pDest->option.mmsSendOptInfo.bUseDeliveryCustomTime = false;
524 pDest->option.mmsSendOptInfo.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
525 pDest->option.mmsSendOptInfo.deliveryTime.time = pMms->deliveryTime;
527 MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pDest->option.mmsSendOptInfo.expiryTime.time);
536 void MsgHandle::convertSendOptStruct(const MSG_SENDINGOPT_INFO_S* pSrc, MSG_SENDINGOPT_S* pDest, MSG_MESSAGE_TYPE_S msgType)
540 pDest->bDeliverReq = pSrc->bDeliverReq;
541 pDest->bKeepCopy = pSrc->bKeepCopy;
543 MSG_DEBUG("pDest->bDeliverReq = %d", pDest->bDeliverReq);
544 MSG_DEBUG("pDest->bKeepCopy = %d", pDest->bKeepCopy);
546 if (msgType.mainType == MSG_SMS_TYPE) {
547 msg_struct_s *pStruct = (msg_struct_s *)pDest->smsSendOpt;
548 SMS_SENDINGOPT_S *pSms = (SMS_SENDINGOPT_S *)pStruct->data;
549 pSms->bReplyPath = pSrc->option.smsSendOptInfo.bReplyPath;
550 } else if (msgType.mainType == MSG_MMS_TYPE) {
551 msg_struct_s *pStruct = (msg_struct_s *)pDest->mmsSendOpt;
552 MMS_SENDINGOPT_S *pMms = (MMS_SENDINGOPT_S *)pStruct->data;
553 pMms->priority = pSrc->option.mmsSendOptInfo.priority;
554 pMms->bReadReq = pSrc->option.mmsSendOptInfo.bReadReq;
555 pMms->expiryTime = pSrc->option.mmsSendOptInfo.expiryTime.time;
556 pMms->deliveryTime = pSrc->option.mmsSendOptInfo.deliveryTime.time;
558 MSG_DEBUG("pDest->option.mmsSendOpt.priority = %d", pMms->priority);
559 MSG_DEBUG("pDest->option.mmsSendOpt.bReadReq = %d", pMms->bReadReq);
560 MSG_DEBUG("pDest->option.mmsSendOpt.expiryTime = %d", pMms->expiryTime);
567 int MsgHandle::getSettingCmdSize(MSG_OPTION_TYPE_T optionType)
569 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
571 switch (optionType) {
572 case MSG_GENERAL_OPT:
573 cmdSize += sizeof(MSG_GENERAL_OPT_S);
575 case MSG_SMS_SENDOPT:
576 cmdSize += sizeof(MSG_SMS_SENDOPT_S);
579 cmdSize += sizeof(MSG_SMSC_LIST_S);
581 case MSG_MMS_SENDOPT:
582 cmdSize += sizeof(MSG_MMS_SENDOPT_S);
584 case MSG_MMS_RECVOPT:
585 cmdSize += sizeof(MSG_MMS_RECVOPT_S);
587 case MSG_MMS_STYLEOPT:
588 cmdSize += sizeof(MSG_MMS_STYLEOPT_S);
590 case MSG_PUSHMSG_OPT:
591 cmdSize += sizeof(MSG_PUSHMSG_OPT_S);
594 cmdSize += sizeof(MSG_CBMSG_OPT_S);
596 case MSG_VOICEMAIL_OPT:
597 cmdSize += sizeof(MSG_VOICEMAIL_OPT_S);
599 case MSG_MSGSIZE_OPT:
600 cmdSize += sizeof(MSG_MSGSIZE_OPT_S);
608 bool MsgHandle::checkEventData(char *pEventData)
610 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
612 switch (pEvent->eventType) {
613 case MSG_EVENT_PLG_SENT_STATUS_CNF:
614 case MSG_EVENT_PLG_INCOMING_MSG_IND:
615 case MSG_EVENT_PLG_INCOMING_MMS_CONF:
616 case MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND:
617 case MSG_EVENT_PLG_INCOMING_LBS_MSG_IND:
618 case MSG_EVENT_PLG_STORAGE_CHANGE_IND:
619 case MSG_EVENT_PLG_INCOMING_CB_MSG_IND:
620 case MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND:
621 case MSG_EVENT_PLG_REPORT_MSG_INCOMING_IND:
632 msg_error_t MsgHandle::checkPermission(void)
634 /* Allocate Memory to Command Data */
635 int cmdSize = sizeof(MSG_CMD_S);
637 char cmdBuf[cmdSize];
638 bzero(cmdBuf, cmdSize);
639 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
641 /* Set Command Parameters */
642 pCmd->cmdType = MSG_CMD_CHECK_PERMISSION;
644 /* Send Command to Messaging FW */
645 char* pEventData = NULL;
646 unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
648 write((char*)pCmd, cmdSize, &pEventData);
650 /* Get Return Data */
651 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
654 THROW(MsgException::INVALID_RESULT, "Event is NULL");
656 if (pEvent->eventType != MSG_EVENT_CHECK_PERMISSION) {
657 THROW(MsgException::INVALID_RESULT, "Event Data Error");
660 return pEvent->result;