2 * Copyright 2012-2013 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://floralicense.org
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.
20 #include "MsgCppTypes.h"
21 #include "MsgException.h"
22 #include "MsgUtilFile.h"
23 #include "MsgProxyListener.h"
24 #include "MsgGconfWrapper.h"
27 gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
31 if (G_IO_ERR & condition)
33 MSG_DEBUG("IO Error!!! [%d]", condition);
35 MsgProxyListener::instance()->stop();
39 if (G_IO_HUP & condition)
41 MSG_DEBUG("socket fd Error!!! [%d]", condition);
43 MsgProxyListener::instance()->stop();
47 if (G_IO_NVAL & condition)
49 MSG_DEBUG("Invaild socket Error!!! [%d]", condition);
51 MsgProxyListener::instance()->stop();
58 int n = MsgProxyListener::instance()->readFromSocket(&buf, &len);
62 MSG_DEBUG(">>Receiving %d bytes", n);
63 MsgProxyListener::instance()->handleEvent((MSG_EVENT_S*)buf);
67 MSG_DEBUG("Server closed connection");
68 MsgProxyListener::instance()->stop();
78 MSG_DEBUG("Data is not for Listener");
93 /*==================================================================================================
94 IMPLEMENTATION OF MsgListenerThread - Member Functions
95 ==================================================================================================*/
96 MsgProxyListener* MsgProxyListener::pInstance = NULL;
99 MsgProxyListener::MsgProxyListener() : running(0)
101 sentStatusCBList.clear();
102 newMessageCBList.clear();
103 newMMSConfMessageCBList.clear();
104 newSyncMLMessageCBList.clear();
105 newLBSMessageCBList.clear();
109 MsgProxyListener::~MsgProxyListener()
111 sentStatusCBList.clear();
112 newMessageCBList.clear();
113 newMMSConfMessageCBList.clear();
114 newSyncMLMessageCBList.clear();
115 newLBSMessageCBList.clear();
119 MsgProxyListener* MsgProxyListener::instance()
122 MutexLocker lock(mm);
125 pInstance = new MsgProxyListener();
131 void MsgProxyListener::start()
136 cliSock.connect(MSG_SOCKET_PATH);
137 cv.signal(); // wake up the waiting thread
140 int fd = cliSock.fd();
142 MSG_DEBUG("Socket Fd : %d", fd);
144 channel = g_io_channel_unix_new(fd); // initializes ref_count = 1
146 eventSourceId = g_io_add_watch(channel, (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL), &readSocket, NULL); // increments ref_count =2
148 MSG_DEBUG("Call g_io_add_watch() : %d", eventSourceId);
152 MSG_DEBUG("add Listener and [%d] are running.", running);
156 void MsgProxyListener::stop()
163 MSG_DEBUG("There are still running Listener. [%d] left.", running);
165 else if (running == 1)
167 MutexLocker lock(mx);
171 g_io_channel_unref(channel); // decrements ref_count = 1
173 g_source_remove(eventSourceId);
177 MSG_DEBUG("client Listener is terminated.");
184 bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam)
186 MutexLocker lock(mx);
188 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
190 for (; it != sentStatusCBList.end(); it++)
192 if (it->hAddr == pMsgHandle && it->pfSentStatusCB == pfSentStatus)
194 MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
196 it->userParam = pUserParam;
202 MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, pfSentStatus, pUserParam};
204 sentStatusCBList.push_back(sentStatusCB);
210 bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
212 MutexLocker lock(mx);
214 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it = newMessageCBList.begin();
216 for (; it != newMessageCBList.end(); it++)
218 if (it->port == port && it->pfIncomingCB == pfNewMessage)
220 MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
222 it->userParam = pUserParam;
228 MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewMessage, port, pUserParam};
230 newMessageCBList.push_back(incomingCB);
236 bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
238 MutexLocker lock(mx);
240 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it = newMMSConfMessageCBList.begin();
242 for (; it != newMMSConfMessageCBList.end(); it++)
244 if (it->pfMMSConfIncomingCB == pfNewMMSConfMessage)
249 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
253 else if(!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN))
255 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
257 it->userParam = pUserParam;
264 MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, pfNewMMSConfMessage, {0}, pUserParam};
267 strncpy(incomingConfCB.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
269 newMMSConfMessageCBList.push_back(incomingConfCB);
275 bool MsgProxyListener::regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam)
277 MutexLocker lock(mx);
279 std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it = newPushMessageCBList.begin();
281 for (; it != newPushMessageCBList.end(); it++)
283 if (it->pfPushIncomingCB == pfNewPushMessage)
288 MSG_DEBUG("msg_push_msg_incoming_cb() callback is already registered!!!");
292 else if(!strncmp(it->appId, pAppId, MAX_WAPPUSH_ID_LEN))
294 MSG_DEBUG("msg_push_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
296 it->userParam = pUserParam;
303 MSG_PUSH_INCOMING_CB_ITEM_S incomingPushCB = {pMsgHandle, pfNewPushMessage, {0}, pUserParam};
306 strncpy(incomingPushCB.appId, pAppId, MAX_WAPPUSH_ID_LEN);
308 newPushMessageCBList.push_back(incomingPushCB);
313 bool MsgProxyListener::regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam)
315 MutexLocker lock(mx);
317 std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it = newCBMessageCBList.begin();
319 for (; it != newCBMessageCBList.end(); it++)
321 if (it->pfCBIncomingCB == pfNewCBMessage)
323 MSG_DEBUG("msg_CB_incoming_cb() callback : [%p] is already registered!!!", pfNewCBMessage);
326 it->userParam = pUserParam;
332 MSG_CB_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewCBMessage, bSave, pUserParam};
334 newCBMessageCBList.push_back(incomingCB);
339 bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
341 MutexLocker lock(mx);
343 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it = newSyncMLMessageCBList.begin();
345 for (; it != newSyncMLMessageCBList.end(); it++)
347 if (it->pfSyncMLIncomingCB == pfNewSyncMLMessage)
349 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
351 it->userParam = pUserParam;
357 MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewSyncMLMessage, pUserParam};
359 newSyncMLMessageCBList.push_back(incomingCB);
365 bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
367 MutexLocker lock(mx);
369 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it = newLBSMessageCBList.begin();
371 for (; it != newLBSMessageCBList.end(); it++)
373 if (it->pfLBSMsgIncoming == pfNewLBSMsgIncoming)
375 MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
377 it->userParam = pUserParam;
383 MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewLBSMsgIncoming, pUserParam};
385 newLBSMessageCBList.push_back(incomingCB);
391 bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
393 MutexLocker lock(mx);
395 std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it = operationSyncMLMessageCBList.begin();
397 for (; it != operationSyncMLMessageCBList.end(); it++)
399 if (it->pfSyncMLOperationCB == pfSyncMLMessageOperation)
401 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
403 it->userParam = pUserParam;
409 MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, pfSyncMLMessageOperation, pUserParam};
411 operationSyncMLMessageCBList.push_back(incomingCB);
417 bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
419 MutexLocker lock(mx);
421 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it = storageChangeCBList.begin();
423 for (; it != storageChangeCBList.end(); it++)
425 if (it->pfStorageChangeCB == pfStorageChangeOperation)
427 MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
429 it->userParam = pUserParam;
435 MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, pfStorageChangeOperation, pUserParam};
437 storageChangeCBList.push_back(changeCB);
443 void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
447 // sent status CB list
448 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
450 for (; it != sentStatusCBList.end(); it++)
452 if (it->hAddr == pMsgHandle)
454 sentStatusCBList.erase(it);
455 it = sentStatusCBList.begin();
457 //Stop client Listener
462 // new message CB list
463 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
465 for (; it2 != newMessageCBList.end(); it2++)
467 if (it2->hAddr == pMsgHandle)
469 newMessageCBList.erase(it2);
470 it2 = newMessageCBList.begin();
472 //Stop client Listener
477 // MMS conf Message CB list
478 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
480 for (; it3 != newMMSConfMessageCBList.end(); it3++)
482 if (it3->hAddr == pMsgHandle)
484 newMMSConfMessageCBList.erase(it3);
485 it3 = newMMSConfMessageCBList.begin();
487 //Stop client Listener
492 // SyncML Message CB list
493 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
495 for (; it4 != newSyncMLMessageCBList.end(); it4++)
497 if (it4->hAddr == pMsgHandle)
499 newSyncMLMessageCBList.erase(it4);
500 it4 = newSyncMLMessageCBList.begin();
502 //Stop client Listener
507 // LBS Message CB list
508 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
510 for (; it5 != newLBSMessageCBList.end(); it5++)
512 if (it5->hAddr == pMsgHandle)
514 newLBSMessageCBList.erase(it5);
515 it5 = newLBSMessageCBList.begin();
517 //Stop client Listener
522 // Push Message CB list
523 std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it6 = newPushMessageCBList.begin();
525 for (; it6 != newPushMessageCBList.end(); it6++)
527 if (it6->hAddr == pMsgHandle)
529 newPushMessageCBList.erase(it6);
530 it6 = newPushMessageCBList.begin();
532 //Stop client Listener
538 // CB Message CB list
539 std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it7 = newCBMessageCBList.begin();
542 for (; it7 != newCBMessageCBList.end(); it7++)
545 if (it7->hAddr == pMsgHandle)
548 newCBMessageCBList.erase(it7);
549 it7 = newCBMessageCBList.begin();
551 //Stop client Listener
556 if(it7->bsave == true)
562 if(MsgSettingSetBool(CB_SAVE, bSave) != MSG_SUCCESS)
563 MSG_DEBUG("MsgSettingSetBool FAIL: CB_SAVE");
565 // Storage change Message CB list
566 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it8 = storageChangeCBList.begin();
568 for (; it8 != storageChangeCBList.end(); it8++)
570 if (it8->hAddr == pMsgHandle)
572 storageChangeCBList.erase(it8);
573 it8 = storageChangeCBList.begin();
575 //Stop client Listener
583 void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
588 THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
590 if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
592 unsigned int chInfo[3] = {0}; //3// reqid, status, object
594 memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(chInfo));
596 msg_struct_s status = {0,};
597 MSG_SENT_STATUS_S statusData = {(msg_request_id_t)chInfo[0], (msg_network_status_t)chInfo[1]};
599 status.type = MSG_STRUCT_SENT_STATUS_INFO;
600 status.data = (void *)&statusData;
604 MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
606 for( ; it != sentStatusCBList.end() ; it++)
608 MsgHandle* pHandle = it->hAddr;
610 msg_sent_status_cb pfunc = it->pfSentStatusCB;
612 void* param = it->userParam;
614 pfunc((msg_handle_t)pHandle, (msg_struct_t)&status, param);
619 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
621 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
622 int portKey = (pMsgInfo->msgPort.valid)? pMsgInfo->msgPort.dstPort: 0;
626 MsgNewMessageCBList::iterator it = newMessageCBList.begin();
627 MsgNewMessageCBList matchList;
629 for( ; it != newMessageCBList.end() ; it++)
631 if( portKey == it->port)
633 matchList.push_back(*it);
639 it = matchList.begin();
641 for( ; it != matchList.end(); it++ )
643 MsgHandle* pHandle = it->hAddr;
645 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
646 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
648 msgHidden.pData = NULL;
649 msgHidden.pMmsData = NULL;
651 /* Allocate memory for address list of message */
652 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
654 addr_list->nCount = 0;
655 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
657 msg_struct_s *pTmp = NULL;
659 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
660 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
661 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
662 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
663 pTmp->data = new MSG_ADDRESS_INFO_S;
664 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
666 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
669 msgHidden.addr_list = addr_list;
671 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
673 msg_struct_s msg = {0,};
674 msg.type = MSG_STRUCT_MESSAGE_INFO;
675 msg.data = &msgHidden;
677 msg_sms_incoming_cb pfunc = it->pfIncomingCB;
679 void* param = it->userParam;
681 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
683 delete [] (char*)msgHidden.pData;
684 if (msgHidden.pMmsData != NULL)
685 delete [] (char*)msgHidden.pMmsData;
687 // address Memory Free
688 if (msgHidden.addr_list!= NULL)
690 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
691 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
692 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
693 addrInfo->data = NULL;
694 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
695 msgHidden.addr_list->msg_struct_info[i] = NULL;
698 delete [] msgHidden.addr_list->msg_struct_info;
700 delete msgHidden.addr_list;
701 msgHidden.addr_list = NULL;
707 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
709 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
710 MMS_RECV_DATA_S* pMmsRecvData = ( MMS_RECV_DATA_S*)pMsgInfo->msgData;
712 char* appIdKey = (pMmsRecvData->msgAppId.valid)? pMmsRecvData->msgAppId.appId: NULL;
716 MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
717 MsgNewMMSConfMessageCBList matchList;
719 for( ; it != newMMSConfMessageCBList.end() ; it++)
723 if(!strcmp(appIdKey, it->appId))
724 matchList.push_back(*it);
726 else//(appIdKey == NULL && it->appId[0] == 0)
728 if(it->appId[0] == 0)
729 matchList.push_back(*it);
735 // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
736 // it is moved from UpdateMessage in MmsPluginStorage.cpp
737 char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; // check MSG_FILENAME_LEN_MAX
739 strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
741 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN+1);
742 memcpy(pMsgInfo->msgData, tempFileName + strlen(MSG_DATA_PATH), MAX_MSG_DATA_LEN);
744 it = matchList.begin();
746 for( ; it != matchList.end() ; it++)
748 MsgHandle* pHandle = it->hAddr;
750 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
751 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
753 msgHidden.pData = NULL;
754 msgHidden.pMmsData = NULL;
756 /* Allocate memory for address list of message */
757 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
759 addr_list->nCount = 0;
760 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
762 msg_struct_s *pTmp = NULL;
764 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
765 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
766 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
767 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
768 pTmp->data = new MSG_ADDRESS_INFO_S;
769 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
771 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
774 msgHidden.addr_list = addr_list;
776 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
778 msg_struct_s msg = {0,};
779 msg.type = MSG_STRUCT_MESSAGE_INFO;
780 msg.data = &msgHidden;
782 msg_mms_conf_msg_incoming_cb pfunc = it->pfMMSConfIncomingCB;
784 void* param = it->userParam;
785 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
787 delete [] (char*)msgHidden.pData;
788 if (msgHidden.pMmsData != NULL)
789 delete [] (char*)msgHidden.pMmsData;
791 // address Memory Free
792 if (msgHidden.addr_list!= NULL)
794 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
795 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
796 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
797 addrInfo->data = NULL;
798 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
799 msgHidden.addr_list->msg_struct_info[i] = NULL;
802 delete [] msgHidden.addr_list->msg_struct_info;
804 delete msgHidden.addr_list;
805 msgHidden.addr_list = NULL;
808 // Here the retrieved message will be deleted from native storage.
809 // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
812 MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
813 pHandle->deleteMessage(pMsgInfo->msgId);
817 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
819 MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
821 MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
825 MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
827 for( ; it != newSyncMLMessageCBList.end() ; it++)
829 MsgHandle* pHandle = it->hAddr;
831 msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
833 void* param = it->userParam;
835 pfunc((msg_handle_t)pHandle, pSyncMLData->syncmlType, pSyncMLData->pushBody, pSyncMLData->pushBodyLen, pSyncMLData->wspHeader, pSyncMLData->wspHeaderLen, param);
840 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
842 MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
846 MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
848 for( ; it != newLBSMessageCBList.end() ; it++)
850 MsgHandle* pHandle = it->hAddr;
852 msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
854 void* param = it->userParam;
856 pfunc((msg_handle_t)pHandle, pLBSData->pushHeader, pLBSData->pushBody, pLBSData->pushBodyLen, param);
861 else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
866 memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
867 memcpy(&extId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(int)), sizeof(int));
869 MSG_DEBUG("msgId [%d]", msgId);
870 MSG_DEBUG("extId [%d]", extId);
874 MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
876 for( ; it != operationSyncMLMessageCBList.end() ; it++)
878 MsgHandle* pHandle = it->hAddr;
880 msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
882 void* param = it->userParam;
884 pfunc((msg_handle_t)pHandle, msgId, extId, param);
889 else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
891 msg_storage_change_type_t storageChangeType;
892 msg_id_list_s msgIdList;
893 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
896 memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_storage_change_type_t));
897 memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)), sizeof(int));
899 if(msgIdList.nCount > 0)
900 msgIdList.msgIdList = (msg_message_id_t*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)+sizeof(int));
902 msgIdList.msgIdList = NULL;
904 MSG_DEBUG("storageChangeType [%d], msgIdList.nCount [%d]", storageChangeType, msgIdList.nCount);
908 MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
910 for( ; it != storageChangeCBList.end() ; it++)
912 MsgHandle* pHandle = it->hAddr;
914 msg_storage_change_cb pfunc = it->pfStorageChangeCB;
916 void* param = it->userParam;
918 pfunc((msg_handle_t)pHandle, storageChangeType, (msg_id_list_s*)&msgIdList, param);
924 else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_CB_MSG_IND)
926 MSG_CB_MSG_S *pCbMsg = (MSG_CB_MSG_S *)pMsgEvent->data;
930 MsgNewCBMessageCBList::iterator it = newCBMessageCBList.begin();
932 for( ; it != newCBMessageCBList.end() ; it++)
934 MsgHandle* pHandle = it->hAddr;
935 msg_struct_s msg = {0,};
937 msg.type = MSG_STRUCT_CB_MSG;
940 msg_cb_incoming_cb pfunc = it->pfCBIncomingCB;
942 void* param = it->userParam;
944 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
950 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND )
952 MSG_PUSH_MESSAGE_DATA_S* pPushData = (MSG_PUSH_MESSAGE_DATA_S *)pMsgEvent->data;
956 MsgNewPushMessageCBList::iterator it = newPushMessageCBList.begin();
958 for( ; it != newPushMessageCBList.end() ; it++)
960 MsgHandle* pHandle = it->hAddr;
962 msg_push_msg_incoming_cb pfunc = it->pfPushIncomingCB;
964 void* param = it->userParam;
966 pfunc((msg_handle_t)pHandle, pPushData->pushHeader, pPushData->pushBody, pPushData->pushBodyLen, param);
976 int MsgProxyListener::getRemoteFd()
978 int tmpFd = cliSock.getRemoteFd();
980 MSG_DEBUG("listener fd [%d]", tmpFd);
986 int MsgProxyListener::readFromSocket(char** buf, unsigned int* len)
988 return cliSock.read(buf, len);
991 #ifdef CHECK_SENT_STATUS_CALLBACK
992 int MsgProxyListener::getSentStatusCbCnt()
996 cbCnt = sentStatusCBList.size();
998 MSG_DEBUG("registered sent status callback count : [%d]", cbCnt);