2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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 "MsgUtilFile.h"
22 #include "MsgException.h"
23 #include "MsgIpcSocket.h"
24 #include "MsgCmdTypes.h"
25 #include "MsgGconfWrapper.h"
26 #include "MsgPluginManager.h"
27 #include "MsgMmsTypes.h"
30 /*==================================================================================================
31 FUNCTION IMPLEMENTATION
32 ==================================================================================================*/
33 void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus)
37 MSG_DEBUG("SENT STATUS %d, %d", pSentStatus->reqId, pSentStatus->status);
39 // establish connection to msgfw daemon
40 MsgIpcClientSocket client;
41 client.connect(MSG_SOCKET_PATH);
44 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SENT_STATUS_S); // cmd type, MSG_SENT_STATUS
47 bzero(cmdBuf, cmdSize);
49 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
51 // Set Command Parameters
52 pCmd->cmdType = MSG_CMD_PLG_SENT_STATUS_CNF;
54 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
56 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSentStatus, sizeof(MSG_SENT_STATUS_S));
58 // Send Command to Transaction Manager
59 client.write(cmdBuf, cmdSize);
61 // Receive result from Transaction Manager
62 MSG_DEBUG("Waiting result for SENT STATUS");
65 AutoPtr<char> wrap(&temp);
67 client.read(&temp, &len);
69 // close connection to msgfw daemon
76 void MsgStorageChangeListener(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
80 MSG_DEBUG("StorageChangeType : [%d], msg ID : [%d]", storageChangeType, pMsgInfo->msgId);
82 // establish connection to msgfw daemon
83 MsgIpcClientSocket client;
84 client.connect(MSG_SOCKET_PATH);
87 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(msg_storage_change_type_t);
90 bzero(cmdBuf, cmdSize);
92 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
94 // Set Command Parameters
95 pCmd->cmdType = MSG_CMD_PLG_STORAGE_CHANGE_IND;
97 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
99 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
100 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &storageChangeType, sizeof(msg_storage_change_type_t));
102 // Send Command to Transaction Manager
103 client.write(cmdBuf, cmdSize);
105 // Receive result from Transaction Manager
106 MSG_DEBUG("Waiting result for STORAGE CHANGE");
109 AutoPtr<char> wrap(&temp);
111 client.read(&temp, &len);
113 // close connection to msgfw daemon
120 msg_error_t MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg)
124 // establish connection to msgfw daemon
125 MsgIpcClientSocket client;
126 client.connect(MSG_SOCKET_PATH);
128 // Check Invalid Message Structure
131 MSG_DEBUG("pMsg is NULL !!");
133 return MSG_ERR_NULL_MESSAGE;
137 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S); // cmd type, MSG_MESSAGE_INFO_S
139 MSG_DEBUG("cmdSize: %d", cmdSize);
141 char cmdBuf[cmdSize];
142 bzero(cmdBuf, cmdSize);
144 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
146 // Set Command Parameters
147 pCmd->cmdType = MSG_CMD_PLG_INCOMING_MSG_IND;
149 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
151 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S));
153 // Send Command to Messaging FW
154 client.write(cmdBuf, cmdSize);
157 AutoPtr<char> wrap(&retBuf);
158 unsigned int retSize;
160 client.read(&retBuf, &retSize);
162 // close connection to msgfw daemon
165 // Decoding the result from FW and Returning it to plugin
166 // the result is used for making delivery report
167 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
169 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_MSG_IND)
170 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
174 return (pEvent->result);
178 msg_error_t MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLData)
182 // establish connection to msgfw daemon
183 MsgIpcClientSocket client;
184 client.connect(MSG_SOCKET_PATH);
187 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SYNCML_MESSAGE_DATA_S); // cmd type, MSG_SYNCML_MESSAGE_DATA_S
189 MSG_DEBUG("cmdSize: %d", cmdSize);
191 char cmdBuf[cmdSize];
192 bzero(cmdBuf, cmdSize);
193 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
195 // Set Command Parameters
196 pCmd->cmdType = MSG_CMD_PLG_INCOMING_SYNCML_IND;
198 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
200 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSyncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
202 // Send Command to Messaging FW
203 client.write(cmdBuf, cmdSize);
205 // Receive result from Transaction Manager
207 AutoPtr<char> wrap(&retBuf);
208 unsigned int retSize;
209 client.read(&retBuf, &retSize);
211 // close connection to msgfw daemon
214 // Decoding the result from FW and Returning it to plugin
215 // the result is used for making delivery report
216 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
218 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND)
219 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
223 return (pEvent->result);
226 msg_error_t MsgIncomingPushMessageListener(MSG_PUSH_MESSAGE_DATA_S *pPushData)
230 // establish connection to msgfw daemon
231 MsgIpcClientSocket client;
232 client.connect(MSG_SOCKET_PATH);
235 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_PUSH_MESSAGE_DATA_S); // cmd type, MSG_SYNCML_MESSAGE_DATA_S
237 MSG_DEBUG("cmdSize: %d", cmdSize);
239 char cmdBuf[cmdSize];
240 bzero(cmdBuf, cmdSize);
241 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
243 // Set Command Parameters
244 pCmd->cmdType = MSG_CMD_PLG_INCOMING_PUSH_IND;
246 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
248 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pPushData, sizeof(MSG_PUSH_MESSAGE_DATA_S));
250 // Send Command to Messaging FW
251 client.write(cmdBuf, cmdSize);
253 // Receive result from Transaction Manager
255 AutoPtr<char> wrap(&retBuf);
256 unsigned int retSize;
257 client.read(&retBuf, &retSize);
259 // close connection to msgfw daemon
262 // Decoding the result from FW and Returning it to plugin
263 // the result is used for making delivery report
264 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
266 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND)
267 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
271 return (pEvent->result);
275 msg_error_t MsgIncomingCBMessageListener(MSG_CB_MSG_S *pCbMsg)
279 // establish connection to msgfw daemon
280 MsgIpcClientSocket client;
281 client.connect(MSG_SOCKET_PATH);
283 // Check Invalid Message Structure
286 MSG_DEBUG("pMsg is NULL !!");
288 return MSG_ERR_NULL_MESSAGE;
292 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CB_MSG_S); // cmd type, MSG_CB_MSG_S
294 MSG_DEBUG("cmdSize: %d", cmdSize);
296 char cmdBuf[cmdSize];
297 bzero(cmdBuf, cmdSize);
299 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
301 // Set Command Parameters
302 pCmd->cmdType = MSG_CMD_PLG_INCOMING_CB_IND;
304 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
306 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pCbMsg, sizeof(MSG_CB_MSG_S));
308 // Send Command to Messaging FW
309 client.write(cmdBuf, cmdSize);
312 AutoPtr<char> wrap(&retBuf);
313 unsigned int retSize;
315 client.read(&retBuf, &retSize);
317 // close connection to msgfw daemon
320 // Decoding the result from FW and Returning it to plugin
321 // the result is used for making delivery report
322 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
324 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_CB_MSG_IND)
325 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
329 return (pEvent->result);
333 msg_error_t MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData)
337 // establish connection to msgfw daemon
338 MsgIpcClientSocket client;
339 client.connect(MSG_SOCKET_PATH);
342 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_LBS_MESSAGE_DATA_S); // cmd type, MSG_LBS_MESSAGE_DATA_S
344 MSG_DEBUG("cmdSize: %d", cmdSize);
346 char cmdBuf[cmdSize];
347 bzero(cmdBuf, cmdSize);
348 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
350 // Set Command Parameters
351 pCmd->cmdType = MSG_CMD_PLG_INCOMING_LBS_IND;
353 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
355 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pLBSData, sizeof(MSG_LBS_MESSAGE_DATA_S));
357 // Send Command to Messaging FW
358 client.write(cmdBuf, cmdSize);
360 // Receive result from Transaction Manager
362 AutoPtr<char> wrap(&retBuf);
363 unsigned int retSize;
364 client.read(&retBuf, &retSize);
366 // close connection to msgfw daemon
369 // Decoding the result from FW and Returning it to plugin
370 // the result is used for making delivery report
371 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
373 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_LBS_MSG_IND)
374 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
378 return (pEvent->result);
382 msg_error_t MsgInitSimBySatListener()
386 // establish connection to msgfw daemon
387 MsgIpcClientSocket client;
388 client.connect(MSG_SOCKET_PATH);
391 int cmdSize = sizeof(MSG_CMD_S);
393 char cmdBuf[cmdSize];
394 bzero(cmdBuf, cmdSize);
396 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
398 // Set Command Parameters
399 pCmd->cmdType = MSG_CMD_PLG_INIT_SIM_BY_SAT;
401 // Send Command to Transaction Manager
402 client.write(cmdBuf, cmdSize);
404 // Receive result from Transaction Manager
406 AutoPtr<char> wrap(&retBuf);
407 unsigned int retSize;
408 client.read(&retBuf, &retSize);
410 // close connection to msgfw daemon
413 // Decoding the result from FW and Returning it to plugin
414 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
416 if (pEvent->eventType != MSG_EVENT_PLG_INIT_SIM_BY_SAT)
417 THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
421 return (pEvent->result);
424 /* MMS_Incoming_listener */
425 msg_error_t MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, msg_request_id_t *pReqId)
428 MSG_DEBUG("pMsg = %s, pReqId = %d ", pMsg->msgData, *pReqId);
430 // establish connection to msgfw daemon
431 MsgIpcClientSocket client;
432 client.connect(MSG_SOCKET_PATH);
435 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(msg_request_id_t); // cmd type, MSG_MESSAGE_INFO_S, msg_request_id_t
436 MSG_DEBUG("cmdSize : %d", cmdSize);
438 char cmdBuf[cmdSize];
439 bzero(cmdBuf, cmdSize);
441 MSG_CMD_S *pCmd = (MSG_CMD_S *)cmdBuf;
443 // Set Command Parameters
444 pCmd->cmdType = MSG_CMD_PLG_INCOMING_MMS_CONF; // cmd type
446 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); // cmd cookie
449 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S));
450 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), pReqId, sizeof(msg_request_id_t));
452 // Send Command to Messaging FW
453 client.write(cmdBuf, cmdSize);
455 // Receive result from Transaction Manager
457 AutoPtr<char> wrap(&retBuf);
458 unsigned int retSize = 0;
459 client.read(&retBuf, &retSize);
461 // close connection to msgfw daemon
464 //Decoding the result from FW and Returning it to plugin
465 // the result is used for making delivery report
466 MSG_EVENT_S *pEvent = (MSG_EVENT_S *)retBuf;
468 if(pEvent->eventType != MSG_EVENT_PLG_INCOMING_MMS_CONF && pEvent->eventType != MSG_EVENT_PLG_SENT_STATUS_CNF)
469 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
473 return (pEvent->result);
476 /*==================================================================================================
477 IMPLEMENTATION OF MsgPlugin - Member Functions
478 ==================================================================================================*/
479 MsgPlugin::MsgPlugin(MSG_MAIN_TYPE_T mainType, const char *libPath): mSupportedMsg(mainType)
481 MSG_DEBUG("msg type : [%d] library path : [%s]", mainType, libPath);
483 bzero(&mPlgHandler, sizeof(mPlgHandler));
486 THROW(MsgException::INVALID_PARAM, "libPath NULL");
490 mLibHandler = dlopen(libPath, RTLD_NOW);
493 THROW(MsgException::PLUGIN_ERROR, "ERROR dlopen library : [%s] [%s]", libPath, dlerror());
498 // assign the c function pointers
499 msg_error_t(*pFunc)(MSG_PLUGIN_HANDLER_S*) = NULL;
501 pFunc = (msg_error_t(*)(MSG_PLUGIN_HANDLER_S*))dlsym(mLibHandler, "MsgPlgCreateHandle");
503 char *error = dlerror();
506 THROW(MsgException::PLUGIN_ERROR, "ERROR dlsym library : [%s]", dlerror());
508 if ((*pFunc)(&mPlgHandler) != MSG_SUCCESS)
509 THROW(MsgException::PLUGIN_ERROR, "ERROR to create plugin handle");
511 // Initialize Plug-in
512 if (initialize() != MSG_SUCCESS)
513 THROW(MsgException::PLUGIN_ERROR, "ERROR to initialize plugin");
515 MSG_PLUGIN_LISTENER_S fwListener = {0};
516 fwListener.pfSentStatusCb = &MsgSentStatusListener;
517 fwListener.pfStorageChangeCb = &MsgStorageChangeListener;
518 fwListener.pfMsgIncomingCb = &MsgIncomingMessageListener;
519 fwListener.pfInitSimBySatCb = &MsgInitSimBySatListener;
520 fwListener.pfSyncMLMsgIncomingCb = &MsgIncomingSyncMLMessageListener;
521 fwListener.pfLBSMsgIncomingCb = &MsgIncomingLBSMessageListener;
522 fwListener.pfMmsConfIncomingCb = &MsgMmsConfIncomingListener;
523 fwListener.pfPushMsgIncomingCb = &MsgIncomingPushMessageListener;
524 fwListener.pfCBMsgIncomingCb = &MsgIncomingCBMessageListener;
526 if (registerListener(&fwListener) != MSG_SUCCESS)
527 THROW(MsgException::PLUGIN_ERROR, "ERROR to register listener");
532 MsgPlugin::~MsgPlugin()
535 // close mLibHandler.
536 if (mLibHandler != NULL)
537 dlclose(mLibHandler);
541 msg_error_t MsgPlugin::initialize()
543 if ( mPlgHandler.pfInitialize != NULL)
544 return mPlgHandler.pfInitialize();
546 return MSG_ERR_INVALID_PLUGIN_HANDLE;
550 void MsgPlugin::finalize()
552 if (mPlgHandler.pfFinalize != NULL)
553 mPlgHandler.pfFinalize();
557 msg_error_t MsgPlugin::submitReq(MSG_REQUEST_INFO_S *pReqInfo)
559 if (mPlgHandler.pfSubmitRequest != NULL)
560 return mPlgHandler.pfSubmitRequest(pReqInfo);
562 return MSG_ERR_INVALID_PLUGIN_HANDLE;
566 msg_error_t MsgPlugin::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
568 if (mPlgHandler.pfRegisterListener != NULL)
569 return mPlgHandler.pfRegisterListener(pListener);
571 return MSG_ERR_INVALID_PLUGIN_HANDLE;
575 msg_error_t MsgPlugin::checkSimStatus(MSG_SIM_STATUS_T *pStatus)
577 if (mPlgHandler.pfRegisterListener != NULL)
578 return mPlgHandler.pfCheckSimStatus(pStatus);
580 return MSG_ERR_INVALID_PLUGIN_HANDLE;
584 msg_error_t MsgPlugin::checkDeviceStatus()
586 if (mPlgHandler.pfRegisterListener != NULL)
587 return mPlgHandler.pfCheckDeviceStatus();
589 return MSG_ERR_INVALID_PLUGIN_HANDLE;
593 msg_error_t MsgPlugin::initSimMessage()
595 if (mPlgHandler.pfInitSimMessage != NULL)
596 return mPlgHandler.pfInitSimMessage();
598 return MSG_ERR_INVALID_PLUGIN_HANDLE;
602 msg_error_t MsgPlugin::saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
604 if (mPlgHandler.pfSaveSimMessage != NULL)
605 return mPlgHandler.pfSaveSimMessage(pMsgInfo, pSimIdList);
607 return MSG_ERR_INVALID_PLUGIN_HANDLE;
611 msg_error_t MsgPlugin::deleteSimMessage(msg_sim_id_t SimMsgId)
613 if (mPlgHandler.pfDeleteSimMessage != NULL)
614 return mPlgHandler.pfDeleteSimMessage(SimMsgId);
616 return MSG_ERR_INVALID_PLUGIN_HANDLE;
620 msg_error_t MsgPlugin::setReadStatus(msg_sim_id_t SimMsgId)
622 if (mPlgHandler.pfSetReadStatus != NULL)
623 return mPlgHandler.pfSetReadStatus(SimMsgId);
625 return MSG_ERR_INVALID_PLUGIN_HANDLE;
629 msg_error_t MsgPlugin::setMemoryStatus(msg_error_t Error)
631 if (mPlgHandler.pfSetMemoryStatus != NULL)
632 return mPlgHandler.pfSetMemoryStatus(Error);
634 return MSG_ERR_INVALID_PLUGIN_HANDLE;
638 msg_error_t MsgPlugin::initConfigData(MSG_SIM_STATUS_T SimStatus)
640 if (mPlgHandler.pfInitConfigData != NULL)
641 return mPlgHandler.pfInitConfigData(SimStatus);
643 return MSG_ERR_INVALID_PLUGIN_HANDLE;
647 msg_error_t MsgPlugin::setConfigData(const MSG_SETTING_S *pSetting)
649 if (mPlgHandler.pfSetConfigData != NULL)
650 return mPlgHandler.pfSetConfigData(pSetting);
652 return MSG_ERR_INVALID_PLUGIN_HANDLE;
656 msg_error_t MsgPlugin::getConfigData(MSG_SETTING_S *pSetting)
658 if (mPlgHandler.pfGetConfigData != NULL)
659 return mPlgHandler.pfGetConfigData(pSetting);
661 return MSG_ERR_INVALID_PLUGIN_HANDLE;
664 msg_error_t MsgPlugin::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
666 if (mPlgHandler.pfAddMessage != NULL) {
667 return mPlgHandler.pfAddMessage(pMsgInfo, pSendOptInfo, pFileData);
669 return MSG_ERR_INVALID_PLUGIN_HANDLE;
673 msg_error_t MsgPlugin::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
675 if (mPlgHandler.pfUpdateMessage != NULL) {
676 return mPlgHandler.pfUpdateMessage(pMsgInfo, pSendOptInfo, pFileData);
678 return MSG_ERR_INVALID_PLUGIN_HANDLE;
683 msg_error_t MsgPlugin::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
685 if (mPlgHandler.pfProcessReceivedInd != NULL) {
686 return mPlgHandler.pfProcessReceivedInd(pMsgInfo, pRequest, bReject);
688 return MSG_ERR_INVALID_PLUGIN_HANDLE;
693 msg_error_t MsgPlugin::getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg)
695 if (mPlgHandler.pfGetMmsMessage != NULL) {
696 return mPlgHandler.pfGetMmsMessage(pMsg, pSendOptInfo, pMmsMsg, pDestMsg);
698 return MSG_ERR_INVALID_PLUGIN_HANDLE;
703 msg_error_t MsgPlugin::updateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
705 if (mPlgHandler.pfUpdateRejectStatus != NULL) {
706 return mPlgHandler.pfUpdateRejectStatus(pMsgInfo);
708 return MSG_ERR_INVALID_PLUGIN_HANDLE;
713 msg_error_t MsgPlugin::composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
715 if (mPlgHandler.pfComposeReadReport != NULL) {
716 return mPlgHandler.pfComposeReadReport(pMsgInfo);
718 return MSG_ERR_INVALID_PLUGIN_HANDLE;
723 msg_error_t MsgPlugin::restoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char* pRecvBody, int rcvdBodyLen, char* filePath)
725 if (mPlgHandler.pfRestoreMsg != NULL)
726 return mPlgHandler.pfRestoreMsg(pMsgInfo,pRecvBody, rcvdBodyLen, filePath);
728 return MSG_ERR_INVALID_PLUGIN_HANDLE;
732 /*==================================================================================================
733 IMPLEMENTATION OF MsgPluginManager - Member Functions
734 ==================================================================================================*/
735 MsgPluginManager* MsgPluginManager::pInstance = NULL;
738 MsgPluginManager* MsgPluginManager::instance()
740 if (pInstance == NULL)
741 pInstance = new MsgPluginManager();
747 MsgPluginManager::MsgPluginManager()
753 void MsgPluginManager::initialize()
757 memset(path, 0x00, sizeof(path));
758 snprintf(path, sizeof(path), "%s%s", MSG_PLUGIN_CFG_PATH, MSG_PLUGIN_CFG_NAME);
764 void MsgPluginManager::finalize()
766 MsgPluginMap::iterator it;
768 for (it = plgMap.begin(); it != plgMap.end(); it++)
770 MsgPlugin *temp = it->second;
778 void MsgPluginManager::loadPlugins(const char* path)
780 /* read plugins from configuration file */
781 FILE* fp = MsgOpenFile(path, "rt");
783 MsgPlgConfig plgConf = MsgPlgConfig(fp);
785 for (int i=0; i < plgConf.titleCount(); i++)
789 plgConf.token(i, 0, tok);
790 const char* content = tok.getVal();
792 MSG_MAIN_TYPE_T mainType = strstr(content,"sms")? MSG_SMS_TYPE:
793 (strstr(content,"mms")? MSG_MMS_TYPE: MSG_UNKNOWN_TYPE);
795 plgConf.token(i, 1, tok);
796 const char* libPath = tok.getVal();
798 MsgPlugin* pDupPlgCheck = getPlugin(mainType);
801 THROW(MsgException::PLUGIN_ERROR, "Plugin for type %d is duplicated", mainType);
803 MsgPlugin *newPlg = new MsgPlugin(mainType, libPath);
805 plgMap.insert(make_pair(mainType, newPlg));
812 MsgPlugin* MsgPluginManager::getPlugin(MSG_MAIN_TYPE_T mainType)
814 /* Implementing the content */
815 MsgPluginMap::iterator it = plgMap.find(mainType);
817 if (it == plgMap.end())