3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
35 #include "MsgUtilFile.h"
36 #include "MsgException.h"
37 #include "MsgIpcSocket.h"
38 #include "MsgCmdTypes.h"
39 #include "MsgGconfWrapper.h"
40 #include "MsgPluginManager.h"
41 #include "MsgMmsTypes.h"
44 /*==================================================================================================
45 FUNCTION IMPLEMENTATION
46 ==================================================================================================*/
47 void MsgSentStatusListener(MSG_SENT_STATUS_S *pSentStatus)
51 MSG_DEBUG("SENT STATUS %d, %d", pSentStatus->reqId, pSentStatus->status);
53 // establish connection to msgfw daemon
54 MsgIpcClientSocket client;
55 client.connect(MSG_SOCKET_PATH);
58 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SENT_STATUS_S); // cmd type, MSG_SENT_STATUS
61 bzero(cmdBuf, cmdSize);
63 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
65 // Set Command Parameters
66 pCmd->cmdType = MSG_CMD_PLG_SENT_STATUS_CNF;
68 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
70 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSentStatus, sizeof(MSG_SENT_STATUS_S));
72 // Send Command to Transaction Manager
73 client.write(cmdBuf, cmdSize);
75 // Receive result from Transaction Manager
76 MSG_DEBUG("Waiting result for SENT STATUS");
79 AutoPtr<char> wrap(&temp);
81 client.read(&temp, &len);
83 // close connection to msgfw daemon
90 void MsgStorageChangeListener(MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
94 MSG_DEBUG("StorageChangeType : [%d], msg ID : [%d]", storageChangeType, pMsgInfo->msgId);
96 // establish connection to msgfw daemon
97 MsgIpcClientSocket client;
98 client.connect(MSG_SOCKET_PATH);
101 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S) + sizeof(MSG_STORAGE_CHANGE_TYPE_T);
103 char cmdBuf[cmdSize];
104 bzero(cmdBuf, cmdSize);
106 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
108 // Set Command Parameters
109 pCmd->cmdType = MSG_CMD_PLG_STORAGE_CHANGE_IND;
111 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
113 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
114 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), &storageChangeType, sizeof(MSG_STORAGE_CHANGE_TYPE_T));
116 // Send Command to Transaction Manager
117 client.write(cmdBuf, cmdSize);
119 // Receive result from Transaction Manager
120 MSG_DEBUG("Waiting result for STORAGE CHANGE");
123 AutoPtr<char> wrap(&temp);
125 client.read(&temp, &len);
127 // close connection to msgfw daemon
134 MSG_ERROR_T MsgIncomingMessageListener(MSG_MESSAGE_INFO_S *pMsg)
138 // establish connection to msgfw daemon
139 MsgIpcClientSocket client;
140 client.connect(MSG_SOCKET_PATH);
142 // Check Invalid Message Structure
145 MSG_DEBUG("pMsg is NULL !!");
147 return MSG_ERR_NULL_MESSAGE;
151 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_INFO_S); // cmd type, MSG_MESSAGE_INFO_S
153 MSG_DEBUG("cmdSize: %d", cmdSize);
155 char cmdBuf[cmdSize];
156 bzero(cmdBuf, cmdSize);
158 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
160 // Set Command Parameters
161 pCmd->cmdType = MSG_CMD_PLG_INCOMING_MSG_IND;
163 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
165 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S));
167 // Send Command to Messaging FW
168 client.write(cmdBuf, cmdSize);
171 AutoPtr<char> wrap(&retBuf);
174 client.read(&retBuf, &retSize);
176 // close connection to msgfw daemon
179 // Decoding the result from FW and Returning it to plugin
180 // the result is used for making delivery report
181 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
183 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_MSG_IND)
184 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
188 return (pEvent->result);
192 MSG_ERROR_T MsgIncomingSyncMLMessageListener(MSG_SYNCML_MESSAGE_DATA_S *pSyncMLData)
196 // establish connection to msgfw daemon
197 MsgIpcClientSocket client;
198 client.connect(MSG_SOCKET_PATH);
201 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_SYNCML_MESSAGE_DATA_S); // cmd type, MSG_SYNCML_MESSAGE_DATA_S
203 MSG_DEBUG("cmdSize: %d", cmdSize);
205 char cmdBuf[cmdSize];
206 bzero(cmdBuf, cmdSize);
207 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
209 // Set Command Parameters
210 pCmd->cmdType = MSG_CMD_PLG_INCOMING_SYNCML_IND;
212 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
214 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pSyncMLData, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
216 // Send Command to Messaging FW
217 client.write(cmdBuf, cmdSize);
219 // Receive result from Transaction Manager
221 AutoPtr<char> wrap(&retBuf);
223 client.read(&retBuf, &retSize);
225 // close connection to msgfw daemon
228 // Decoding the result from FW and Returning it to plugin
229 // the result is used for making delivery report
230 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
232 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND)
233 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
237 return (pEvent->result);
241 MSG_ERROR_T MsgIncomingLBSMessageListener(MSG_LBS_MESSAGE_DATA_S *pLBSData)
245 // establish connection to msgfw daemon
246 MsgIpcClientSocket client;
247 client.connect(MSG_SOCKET_PATH);
250 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_LBS_MESSAGE_DATA_S); // cmd type, MSG_LBS_MESSAGE_DATA_S
252 MSG_DEBUG("cmdSize: %d", cmdSize);
254 char cmdBuf[cmdSize];
255 bzero(cmdBuf, cmdSize);
256 MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
258 // Set Command Parameters
259 pCmd->cmdType = MSG_CMD_PLG_INCOMING_LBS_IND;
261 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
263 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pLBSData, sizeof(MSG_LBS_MESSAGE_DATA_S));
265 // Send Command to Messaging FW
266 client.write(cmdBuf, cmdSize);
268 // Receive result from Transaction Manager
270 AutoPtr<char> wrap(&retBuf);
272 client.read(&retBuf, &retSize);
274 // close connection to msgfw daemon
277 // Decoding the result from FW and Returning it to plugin
278 // the result is used for making delivery report
279 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
281 if (pEvent->eventType != MSG_EVENT_PLG_INCOMING_LBS_MSG_IND)
282 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
286 return (pEvent->result);
290 MSG_ERROR_T MsgInitSimBySatListener()
294 // establish connection to msgfw daemon
295 MsgIpcClientSocket client;
296 client.connect(MSG_SOCKET_PATH);
299 int cmdSize = sizeof(MSG_CMD_S);
301 char cmdBuf[cmdSize];
302 bzero(cmdBuf, cmdSize);
304 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
306 // Set Command Parameters
307 pCmd->cmdType = MSG_CMD_PLG_INIT_SIM_BY_SAT;
309 // Send Command to Transaction Manager
310 client.write(cmdBuf, cmdSize);
312 // Receive result from Transaction Manager
314 AutoPtr<char> wrap(&retBuf);
316 client.read(&retBuf, &retSize);
318 // close connection to msgfw daemon
321 // Decoding the result from FW and Returning it to plugin
322 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)retBuf;
324 if (pEvent->eventType != MSG_EVENT_PLG_INIT_SIM_BY_SAT)
325 THROW(MsgException::INVALID_RESULT, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
329 return (pEvent->result);
332 /* MMS_Incoming_listener */
333 MSG_ERROR_T MsgMmsConfIncomingListener(MSG_MESSAGE_INFO_S *pMsg, MSG_REQUEST_ID_T *pReqId)
336 MSG_DEBUG("pMsg = %s, pReqId = %d ", pMsg->msgData, *pReqId);
338 // establish connection to msgfw daemon
339 MsgIpcClientSocket client;
340 client.connect(MSG_SOCKET_PATH);
343 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
344 MSG_DEBUG("cmdSize : %d", cmdSize);
346 char cmdBuf[cmdSize];
347 bzero(cmdBuf, cmdSize);
349 MSG_CMD_S *pCmd = (MSG_CMD_S *)cmdBuf;
351 // Set Command Parameters
352 pCmd->cmdType = MSG_CMD_PLG_INCOMING_MMS_CONF; // cmd type
354 memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN); // cmd cookie
357 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), pMsg, sizeof(MSG_MESSAGE_INFO_S));
358 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_MESSAGE_INFO_S)), pReqId, sizeof(MSG_REQUEST_ID_T));
360 // Send Command to Messaging FW
361 client.write(cmdBuf, cmdSize);
363 // Receive result from Transaction Manager
365 AutoPtr<char> wrap(&retBuf);
367 client.read(&retBuf, &retSize);
369 // close connection to msgfw daemon
372 //Decoding the result from FW and Returning it to plugin
373 // the result is used for making delivery report
374 MSG_EVENT_S *pEvent = (MSG_EVENT_S *)retBuf;
376 if(pEvent->eventType != MSG_EVENT_PLG_INCOMING_MMS_CONF && pEvent->eventType != MSG_EVENT_PLG_SENT_STATUS_CNF)
377 THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
381 return (pEvent->result);
384 /*==================================================================================================
385 IMPLEMENTATION OF MsgPlugin - Member Functions
386 ==================================================================================================*/
387 MsgPlugin::MsgPlugin(MSG_MAIN_TYPE_T mainType, const char *libPath): mSupportedMsg(mainType)
389 MSG_DEBUG("msg type : [%d] library path : [%s]", mainType, libPath);
391 bzero(&mPlgHandler, sizeof(mPlgHandler));
394 THROW(MsgException::INVALID_PARAM, "libPath NULL");
396 void* libHandle = NULL;
398 libHandle = dlopen(libPath, RTLD_NOW);
401 THROW(MsgException::PLUGIN_ERROR, "ERROR dlopen library : [%s] [%s]", libPath, dlerror());
406 // assign the c function pointers
407 MSG_ERROR_T(*pFunc)(MSG_PLUGIN_HANDLER_S*) = NULL;
409 pFunc = (MSG_ERROR_T(*)(MSG_PLUGIN_HANDLER_S*))dlsym(libHandle, "MsgPlgCreateHandle");
411 char *error = dlerror();
414 THROW(MsgException::PLUGIN_ERROR, "ERROR dlsym library : [%s]", dlerror());
416 if ((*pFunc)(&mPlgHandler) != MSG_SUCCESS)
417 THROW(MsgException::PLUGIN_ERROR, "ERROR to create plugin handle");
419 // Initialize Plug-in
420 if (initialize() != MSG_SUCCESS)
421 THROW(MsgException::PLUGIN_ERROR, "ERROR to initialize plugin");
423 MSG_PLUGIN_LISTENER_S fwListener = {0};
424 fwListener.pfSentStatusCb = &MsgSentStatusListener;
425 fwListener.pfStorageChangeCb = &MsgStorageChangeListener;
426 fwListener.pfMsgIncomingCb = &MsgIncomingMessageListener;
427 fwListener.pfInitSimBySatCb = &MsgInitSimBySatListener;
428 fwListener.pfSyncMLMsgIncomingCb = &MsgIncomingSyncMLMessageListener;
429 fwListener.pfLBSMsgIncomingCb = &MsgIncomingLBSMessageListener;
430 fwListener.pfMmsConfIncomingCb = &MsgMmsConfIncomingListener;
432 if (registerListener(&fwListener) != MSG_SUCCESS)
433 THROW(MsgException::PLUGIN_ERROR, "ERROR to register listener");
435 // dlclose(libHandle);
439 MsgPlugin::~MsgPlugin()
446 MSG_ERROR_T MsgPlugin::initialize()
448 if ( mPlgHandler.pfInitialize != NULL)
449 return mPlgHandler.pfInitialize();
451 return MSG_ERR_INVALID_PLUGIN_HANDLE;
455 void MsgPlugin::finalize()
457 if (mPlgHandler.pfFinalize != NULL)
458 mPlgHandler.pfFinalize();
462 MSG_ERROR_T MsgPlugin::submitReq(MSG_REQUEST_INFO_S *pReqInfo, bool bReqCb)
464 if (mPlgHandler.pfSubmitRequest != NULL)
465 return mPlgHandler.pfSubmitRequest(pReqInfo, bReqCb);
467 return MSG_ERR_INVALID_PLUGIN_HANDLE;
471 MSG_ERROR_T MsgPlugin::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
473 if (mPlgHandler.pfRegisterListener != NULL)
474 return mPlgHandler.pfRegisterListener(pListener);
476 return MSG_ERR_INVALID_PLUGIN_HANDLE;
480 MSG_ERROR_T MsgPlugin::checkSimStatus(MSG_SIM_STATUS_T *pStatus)
482 if (mPlgHandler.pfRegisterListener != NULL)
483 return mPlgHandler.pfCheckSimStatus(pStatus);
485 return MSG_ERR_INVALID_PLUGIN_HANDLE;
489 MSG_ERROR_T MsgPlugin::checkDeviceStatus()
491 if (mPlgHandler.pfRegisterListener != NULL)
492 return mPlgHandler.pfCheckDeviceStatus();
494 return MSG_ERR_INVALID_PLUGIN_HANDLE;
498 MSG_ERROR_T MsgPlugin::initSimMessage()
500 if (mPlgHandler.pfInitSimMessage != NULL)
501 return mPlgHandler.pfInitSimMessage();
503 return MSG_ERR_INVALID_PLUGIN_HANDLE;
507 MSG_ERROR_T MsgPlugin::saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
509 if (mPlgHandler.pfSaveSimMessage != NULL)
510 return mPlgHandler.pfSaveSimMessage(pMsgInfo, pSimIdList);
512 return MSG_ERR_INVALID_PLUGIN_HANDLE;
516 MSG_ERROR_T MsgPlugin::deleteSimMessage(MSG_SIM_ID_T SimMsgId)
518 if (mPlgHandler.pfDeleteSimMessage != NULL)
519 return mPlgHandler.pfDeleteSimMessage(SimMsgId);
521 return MSG_ERR_INVALID_PLUGIN_HANDLE;
525 MSG_ERROR_T MsgPlugin::setReadStatus(MSG_SIM_ID_T SimMsgId)
527 if (mPlgHandler.pfSetReadStatus != NULL)
528 return mPlgHandler.pfSetReadStatus(SimMsgId);
530 return MSG_ERR_INVALID_PLUGIN_HANDLE;
534 MSG_ERROR_T MsgPlugin::setMemoryStatus(MSG_ERROR_T Error)
536 if (mPlgHandler.pfSetMemoryStatus != NULL)
537 return mPlgHandler.pfSetMemoryStatus(Error);
539 return MSG_ERR_INVALID_PLUGIN_HANDLE;
543 MSG_ERROR_T MsgPlugin::initConfigData(MSG_SIM_STATUS_T SimStatus)
545 if (mPlgHandler.pfInitConfigData != NULL)
546 return mPlgHandler.pfInitConfigData(SimStatus);
548 return MSG_ERR_INVALID_PLUGIN_HANDLE;
552 MSG_ERROR_T MsgPlugin::setConfigData(const MSG_SETTING_S *pSetting)
554 if (mPlgHandler.pfSetConfigData != NULL)
555 return mPlgHandler.pfSetConfigData(pSetting);
557 return MSG_ERR_INVALID_PLUGIN_HANDLE;
561 MSG_ERROR_T MsgPlugin::getConfigData(MSG_SETTING_S *pSetting)
563 if (mPlgHandler.pfGetConfigData != NULL)
564 return mPlgHandler.pfGetConfigData(pSetting);
566 return MSG_ERR_INVALID_PLUGIN_HANDLE;
569 MSG_ERROR_T MsgPlugin::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
571 if (mPlgHandler.pfAddMessage != NULL) {
572 return mPlgHandler.pfAddMessage(pMsgInfo, pSendOptInfo, pFileData);
574 return MSG_ERR_INVALID_PLUGIN_HANDLE;
578 MSG_ERROR_T MsgPlugin::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
580 if (mPlgHandler.pfUpdateMessage != NULL) {
581 return mPlgHandler.pfUpdateMessage(pMsgInfo, pSendOptInfo, pFileData);
583 return MSG_ERR_INVALID_PLUGIN_HANDLE;
588 MSG_ERROR_T MsgPlugin::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
590 if (mPlgHandler.pfProcessReceivedInd != NULL) {
591 return mPlgHandler.pfProcessReceivedInd(pMsgInfo, pRequest, bReject);
593 return MSG_ERR_INVALID_PLUGIN_HANDLE;
598 MSG_ERROR_T MsgPlugin::getMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg)
600 if (mPlgHandler.pfGetMmsMessage != NULL) {
601 return mPlgHandler.pfGetMmsMessage(pMsg, pSendOptInfo, pMmsMsg, pDestMsg);
603 return MSG_ERR_INVALID_PLUGIN_HANDLE;
608 MSG_ERROR_T MsgPlugin::updateRejectStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
610 if (mPlgHandler.pfUpdateRejectStatus != NULL) {
611 return mPlgHandler.pfUpdateRejectStatus(pMsgInfo);
613 return MSG_ERR_INVALID_PLUGIN_HANDLE;
618 MSG_ERROR_T MsgPlugin::composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
620 if (mPlgHandler.pfComposeReadReport != NULL) {
621 return mPlgHandler.pfComposeReadReport(pMsgInfo);
623 return MSG_ERR_INVALID_PLUGIN_HANDLE;
628 MSG_ERROR_T MsgPlugin::restoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char* pRecvBody, int rcvdBodyLen, char* filePath)
630 if (mPlgHandler.pfRestoreMsg != NULL)
631 return mPlgHandler.pfRestoreMsg(pMsgInfo,pRecvBody, rcvdBodyLen, filePath);
633 return MSG_ERR_INVALID_PLUGIN_HANDLE;
637 /*==================================================================================================
638 IMPLEMENTATION OF MsgPluginManager - Member Functions
639 ==================================================================================================*/
640 MsgPluginManager* MsgPluginManager::pInstance = NULL;
643 MsgPluginManager* MsgPluginManager::instance()
645 if (pInstance == NULL)
646 pInstance = new MsgPluginManager();
652 MsgPluginManager::MsgPluginManager()
658 void MsgPluginManager::initialize()
662 memset(path, 0x00, sizeof(path));
663 snprintf(path, sizeof(path), "%s%s", MSG_PLUGIN_CFG_PATH, MSG_PLUGIN_CFG_NAME);
669 void MsgPluginManager::finalize()
671 MsgPluginMap::iterator it;
673 for (it = plgMap.begin(); it != plgMap.end(); it++)
675 MsgPlugin temp = it->second;
683 void MsgPluginManager::loadPlugins(const char* path)
685 /* read plugins from configuration file */
686 FILE* fp = MsgOpenFile(path, "rt");
688 MsgPlgConfig plgConf = MsgPlgConfig(fp);
690 for (int i=0; i < plgConf.titleCount(); i++)
694 plgConf.token(i, 0, tok);
695 const char* content = tok.getVal();
697 MSG_MAIN_TYPE_T mainType = strstr(content,"sms")? MSG_SMS_TYPE:
698 (strstr(content,"mms")? MSG_MMS_TYPE: MSG_UNKNOWN_TYPE);
700 plgConf.token(i, 1, tok);
701 const char* libPath = tok.getVal();
703 MsgPlugin* pDupPlgCheck = getPlugin(mainType);
706 THROW(MsgException::PLUGIN_ERROR, "Plugin for type %d is duplicated", mainType);
708 MsgPlugin newPlg(mainType, libPath);
710 plgMap.insert(make_pair(mainType, newPlg));
717 MsgPlugin* MsgPluginManager::getPlugin(MSG_MAIN_TYPE_T mainType)
719 /* Implementing the content */
720 MsgPluginMap::iterator it = plgMap.find(mainType);
722 if (it == plgMap.end())
725 return &(it->second);