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.
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 MsgSettingSetBool(CB_SAVE, bSave);
564 // Storage change Message CB list
565 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it8 = storageChangeCBList.begin();
567 for (; it8 != storageChangeCBList.end(); it8++)
569 if (it8->hAddr == pMsgHandle)
571 storageChangeCBList.erase(it8);
572 it8 = storageChangeCBList.begin();
574 //Stop client Listener
582 void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
587 THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
589 if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
591 unsigned int chInfo[3] = {0}; //3// reqid, status, object
593 memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(chInfo));
595 msg_struct_s status = {0,};
596 MSG_SENT_STATUS_S statusData = {(msg_request_id_t)chInfo[0], (msg_network_status_t)chInfo[1]};
598 status.type = MSG_STRUCT_SENT_STATUS_INFO;
599 status.data = (void *)&statusData;
603 MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
605 for( ; it != sentStatusCBList.end() ; it++)
607 MsgHandle* pHandle = it->hAddr;
609 msg_sent_status_cb pfunc = it->pfSentStatusCB;
611 void* param = it->userParam;
613 pfunc((msg_handle_t)pHandle, (msg_struct_t)&status, param);
618 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
620 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
621 int portKey = (pMsgInfo->msgPort.valid)? pMsgInfo->msgPort.dstPort: 0;
625 MsgNewMessageCBList::iterator it = newMessageCBList.begin();
626 MsgNewMessageCBList matchList;
628 for( ; it != newMessageCBList.end() ; it++)
630 if( portKey == it->port)
632 matchList.push_back(*it);
638 it = matchList.begin();
640 for( ; it != matchList.end(); it++ )
642 MsgHandle* pHandle = it->hAddr;
644 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
645 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
647 msgHidden.pData = NULL;
648 msgHidden.pMmsData = NULL;
650 /* Allocate memory for address list of message */
651 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
653 addr_list->nCount = 0;
654 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
656 msg_struct_s *pTmp = NULL;
658 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
659 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
660 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
661 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
662 pTmp->data = new MSG_ADDRESS_INFO_S;
663 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
665 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
668 msgHidden.addr_list = addr_list;
670 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
672 msg_struct_s msg = {0,};
673 msg.type = MSG_STRUCT_MESSAGE_INFO;
674 msg.data = &msgHidden;
676 msg_sms_incoming_cb pfunc = it->pfIncomingCB;
678 void* param = it->userParam;
680 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
682 delete [] (char*)msgHidden.pData;
683 if (msgHidden.pMmsData != NULL)
684 delete [] (char*)msgHidden.pMmsData;
686 // address Memory Free
687 if (msgHidden.addr_list!= NULL)
689 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
690 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
691 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
692 addrInfo->data = NULL;
693 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
694 msgHidden.addr_list->msg_struct_info[i] = NULL;
697 delete [] msgHidden.addr_list->msg_struct_info;
699 delete msgHidden.addr_list;
700 msgHidden.addr_list = NULL;
706 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
708 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
709 MMS_RECV_DATA_S* pMmsRecvData = ( MMS_RECV_DATA_S*)pMsgInfo->msgData;
711 char* appIdKey = (pMmsRecvData->msgAppId.valid)? pMmsRecvData->msgAppId.appId: NULL;
715 MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
716 MsgNewMMSConfMessageCBList matchList;
718 for( ; it != newMMSConfMessageCBList.end() ; it++)
722 if(!strcmp(appIdKey, it->appId))
723 matchList.push_back(*it);
725 else//(appIdKey == NULL && it->appId[0] == 0)
727 if(it->appId[0] == 0)
728 matchList.push_back(*it);
734 // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
735 // it is moved from UpdateMessage in MmsPluginStorage.cpp
736 char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; // check MSG_FILENAME_LEN_MAX
738 strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
740 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN+1);
741 memcpy(pMsgInfo->msgData, tempFileName + strlen(MSG_DATA_PATH), strlen(tempFileName));
743 it = matchList.begin();
745 for( ; it != matchList.end() ; it++)
747 MsgHandle* pHandle = it->hAddr;
749 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
750 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
752 msgHidden.pData = NULL;
753 msgHidden.pMmsData = NULL;
755 /* Allocate memory for address list of message */
756 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
758 addr_list->nCount = 0;
759 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
761 msg_struct_s *pTmp = NULL;
763 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
764 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
765 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
766 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
767 pTmp->data = new MSG_ADDRESS_INFO_S;
768 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
770 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
773 msgHidden.addr_list = addr_list;
775 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
777 msg_struct_s msg = {0,};
778 msg.type = MSG_STRUCT_MESSAGE_INFO;
779 msg.data = &msgHidden;
781 msg_mms_conf_msg_incoming_cb pfunc = it->pfMMSConfIncomingCB;
783 void* param = it->userParam;
784 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
786 delete [] (char*)msgHidden.pData;
787 if (msgHidden.pMmsData != NULL)
788 delete [] (char*)msgHidden.pMmsData;
790 // address Memory Free
791 if (msgHidden.addr_list!= NULL)
793 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
794 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
795 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
796 addrInfo->data = NULL;
797 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
798 msgHidden.addr_list->msg_struct_info[i] = NULL;
801 delete [] msgHidden.addr_list->msg_struct_info;
803 delete msgHidden.addr_list;
804 msgHidden.addr_list = NULL;
807 // Here the retrieved message will be deleted from native storage.
808 // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
811 MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
812 pHandle->deleteMessage(pMsgInfo->msgId);
816 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
818 MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
820 MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
824 MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
826 for( ; it != newSyncMLMessageCBList.end() ; it++)
828 MsgHandle* pHandle = it->hAddr;
830 msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
832 void* param = it->userParam;
834 pfunc((msg_handle_t)pHandle, pSyncMLData->syncmlType, pSyncMLData->pushBody, pSyncMLData->pushBodyLen, pSyncMLData->wspHeader, pSyncMLData->wspHeaderLen, param);
839 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
841 MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
845 MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
847 for( ; it != newLBSMessageCBList.end() ; it++)
849 MsgHandle* pHandle = it->hAddr;
851 msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
853 void* param = it->userParam;
855 pfunc((msg_handle_t)pHandle, pLBSData->pushHeader, pLBSData->pushBody, pLBSData->pushBodyLen, param);
860 else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
865 memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
866 memcpy(&extId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(int)), sizeof(int));
868 MSG_DEBUG("msgId [%d]", msgId);
869 MSG_DEBUG("extId [%d]", extId);
873 MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
875 for( ; it != operationSyncMLMessageCBList.end() ; it++)
877 MsgHandle* pHandle = it->hAddr;
879 msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
881 void* param = it->userParam;
883 pfunc((msg_handle_t)pHandle, msgId, extId, param);
888 else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
890 msg_storage_change_type_t storageChangeType;
891 msg_id_list_s msgIdList;
892 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
895 memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_storage_change_type_t));
896 memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)), sizeof(int));
898 if(msgIdList.nCount > 0)
899 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));
901 msgIdList.msgIdList = NULL;
903 MSG_DEBUG("storageChangeType [%d], msgIdList.nCount [%d]", storageChangeType, msgIdList.nCount);
907 MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
909 for( ; it != storageChangeCBList.end() ; it++)
911 MsgHandle* pHandle = it->hAddr;
913 msg_storage_change_cb pfunc = it->pfStorageChangeCB;
915 void* param = it->userParam;
917 pfunc((msg_handle_t)pHandle, storageChangeType, (msg_id_list_s*)&msgIdList, param);
923 else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_CB_MSG_IND)
925 MSG_CB_MSG_S *pCbMsg = (MSG_CB_MSG_S *)pMsgEvent->data;
929 MsgNewCBMessageCBList::iterator it = newCBMessageCBList.begin();
931 for( ; it != newCBMessageCBList.end() ; it++)
933 MsgHandle* pHandle = it->hAddr;
934 msg_struct_s msg = {0,};
936 msg.type = MSG_STRUCT_CB_MSG;
939 msg_cb_incoming_cb pfunc = it->pfCBIncomingCB;
941 void* param = it->userParam;
943 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
949 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND )
951 MSG_PUSH_MESSAGE_DATA_S* pPushData = (MSG_PUSH_MESSAGE_DATA_S *)pMsgEvent->data;
955 MsgNewPushMessageCBList::iterator it = newPushMessageCBList.begin();
957 for( ; it != newPushMessageCBList.end() ; it++)
959 MsgHandle* pHandle = it->hAddr;
961 msg_push_msg_incoming_cb pfunc = it->pfPushIncomingCB;
963 void* param = it->userParam;
965 pfunc((msg_handle_t)pHandle, pPushData->pushHeader, pPushData->pushBody, pPushData->pushBodyLen, param);
975 int MsgProxyListener::getRemoteFd()
977 MutexLocker lock(mx);
979 int tmpFd = cliSock.getRemoteFd();
981 MSG_DEBUG("listener fd [%d]", tmpFd);
985 cv.wait(mx.pMutex());
988 return cliSock.getRemoteFd();
992 int MsgProxyListener::readFromSocket(char** buf, unsigned int* len)
994 return cliSock.read(buf, len);
997 #ifdef CHECK_SENT_STATUS_CALLBACK
998 int MsgProxyListener::getSentStatusCbCnt()
1002 cbCnt = sentStatusCBList.size();
1004 MSG_DEBUG("registered sent status callback count : [%d]", cbCnt);