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();
73 MSG_DEBUG("Data is not for Listener");
88 /*==================================================================================================
89 IMPLEMENTATION OF MsgListenerThread - Member Functions
90 ==================================================================================================*/
91 MsgProxyListener* MsgProxyListener::pInstance = NULL;
94 MsgProxyListener::MsgProxyListener() : running(0)
96 sentStatusCBList.clear();
97 newMessageCBList.clear();
98 newMMSConfMessageCBList.clear();
99 newSyncMLMessageCBList.clear();
100 newLBSMessageCBList.clear();
104 MsgProxyListener::~MsgProxyListener()
106 sentStatusCBList.clear();
107 newMessageCBList.clear();
108 newMMSConfMessageCBList.clear();
109 newSyncMLMessageCBList.clear();
110 newLBSMessageCBList.clear();
114 MsgProxyListener* MsgProxyListener::instance()
117 MutexLocker lock(mm);
120 pInstance = new MsgProxyListener();
126 void MsgProxyListener::start()
131 cliSock.connect(MSG_SOCKET_PATH);
132 cv.signal(); // wake up the waiting thread
135 int fd = cliSock.fd();
137 MSG_DEBUG("Socket Fd : %d", fd);
139 channel = g_io_channel_unix_new(fd); // initializes ref_count = 1
141 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
143 MSG_DEBUG("Call g_io_add_watch() : %d", eventSourceId);
147 MSG_DEBUG("add Listener and [%d] are running.", running);
151 void MsgProxyListener::stop()
158 MSG_DEBUG("There are still running Listener. [%d] left.", running);
160 else if (running == 1)
162 MutexLocker lock(mx);
166 g_io_channel_unref(channel); // decrements ref_count = 1
168 g_source_remove(eventSourceId);
172 MSG_DEBUG("client Listener is terminated.");
179 bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam)
181 MutexLocker lock(mx);
183 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
185 for (; it != sentStatusCBList.end(); it++)
187 if (it->hAddr == pMsgHandle && it->pfSentStatusCB == pfSentStatus)
189 MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
191 it->userParam = pUserParam;
197 MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, pfSentStatus, pUserParam};
199 sentStatusCBList.push_back(sentStatusCB);
205 bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
207 MutexLocker lock(mx);
209 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it = newMessageCBList.begin();
211 for (; it != newMessageCBList.end(); it++)
213 if (it->port == port && it->pfIncomingCB == pfNewMessage)
215 MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
217 it->userParam = pUserParam;
223 MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewMessage, port, pUserParam};
225 newMessageCBList.push_back(incomingCB);
231 bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
233 MutexLocker lock(mx);
235 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it = newMMSConfMessageCBList.begin();
237 for (; it != newMMSConfMessageCBList.end(); it++)
239 if (it->pfMMSConfIncomingCB == pfNewMMSConfMessage)
244 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
248 else if(!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN))
250 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
252 it->userParam = pUserParam;
259 MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, pfNewMMSConfMessage, {0}, pUserParam};
262 strncpy(incomingConfCB.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
264 newMMSConfMessageCBList.push_back(incomingConfCB);
270 bool MsgProxyListener::regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam)
272 MutexLocker lock(mx);
274 std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it = newPushMessageCBList.begin();
276 for (; it != newPushMessageCBList.end(); it++)
278 if (it->pfPushIncomingCB == pfNewPushMessage)
283 MSG_DEBUG("msg_push_msg_incoming_cb() callback is already registered!!!");
287 else if(!strncmp(it->appId, pAppId, MAX_WAPPUSH_ID_LEN))
289 MSG_DEBUG("msg_push_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
291 it->userParam = pUserParam;
298 MSG_PUSH_INCOMING_CB_ITEM_S incomingPushCB = {pMsgHandle, pfNewPushMessage, {0}, pUserParam};
301 strncpy(incomingPushCB.appId, pAppId, MAX_WAPPUSH_ID_LEN);
303 newPushMessageCBList.push_back(incomingPushCB);
308 bool MsgProxyListener::regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam)
310 MutexLocker lock(mx);
312 std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it = newCBMessageCBList.begin();
314 for (; it != newCBMessageCBList.end(); it++)
316 if (it->pfCBIncomingCB == pfNewCBMessage)
318 MSG_DEBUG("msg_CB_incoming_cb() callback : [%p] is already registered!!!", pfNewCBMessage);
321 it->userParam = pUserParam;
327 MSG_CB_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewCBMessage, bSave, pUserParam};
329 newCBMessageCBList.push_back(incomingCB);
334 bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
336 MutexLocker lock(mx);
338 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it = newSyncMLMessageCBList.begin();
340 for (; it != newSyncMLMessageCBList.end(); it++)
342 if (it->pfSyncMLIncomingCB == pfNewSyncMLMessage)
344 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
346 it->userParam = pUserParam;
352 MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewSyncMLMessage, pUserParam};
354 newSyncMLMessageCBList.push_back(incomingCB);
360 bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
362 MutexLocker lock(mx);
364 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it = newLBSMessageCBList.begin();
366 for (; it != newLBSMessageCBList.end(); it++)
368 if (it->pfLBSMsgIncoming == pfNewLBSMsgIncoming)
370 MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
372 it->userParam = pUserParam;
378 MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewLBSMsgIncoming, pUserParam};
380 newLBSMessageCBList.push_back(incomingCB);
386 bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
388 MutexLocker lock(mx);
390 std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it = operationSyncMLMessageCBList.begin();
392 for (; it != operationSyncMLMessageCBList.end(); it++)
394 if (it->pfSyncMLOperationCB == pfSyncMLMessageOperation)
396 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
398 it->userParam = pUserParam;
404 MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, pfSyncMLMessageOperation, pUserParam};
406 operationSyncMLMessageCBList.push_back(incomingCB);
412 bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
414 MutexLocker lock(mx);
416 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it = storageChangeCBList.begin();
418 for (; it != storageChangeCBList.end(); it++)
420 if (it->pfStorageChangeCB == pfStorageChangeOperation)
422 MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
424 it->userParam = pUserParam;
430 MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, pfStorageChangeOperation, pUserParam};
432 storageChangeCBList.push_back(changeCB);
438 void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
442 // sent status CB list
443 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
445 for (; it != sentStatusCBList.end(); it++)
447 if (it->hAddr == pMsgHandle)
449 sentStatusCBList.erase(it);
450 it = sentStatusCBList.begin();
452 //Stop client Listener
457 // new message CB list
458 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
460 for (; it2 != newMessageCBList.end(); it2++)
462 if (it2->hAddr == pMsgHandle)
464 newMessageCBList.erase(it2);
465 it2 = newMessageCBList.begin();
467 //Stop client Listener
472 // MMS conf Message CB list
473 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
475 for (; it3 != newMMSConfMessageCBList.end(); it3++)
477 if (it3->hAddr == pMsgHandle)
479 newMMSConfMessageCBList.erase(it3);
480 it3 = newMMSConfMessageCBList.begin();
482 //Stop client Listener
487 // SyncML Message CB list
488 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
490 for (; it4 != newSyncMLMessageCBList.end(); it4++)
492 if (it4->hAddr == pMsgHandle)
494 newSyncMLMessageCBList.erase(it4);
495 it4 = newSyncMLMessageCBList.begin();
497 //Stop client Listener
502 // LBS Message CB list
503 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
505 for (; it5 != newLBSMessageCBList.end(); it5++)
507 if (it5->hAddr == pMsgHandle)
509 newLBSMessageCBList.erase(it5);
510 it5 = newLBSMessageCBList.begin();
512 //Stop client Listener
517 // Push Message CB list
518 std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it6 = newPushMessageCBList.begin();
520 for (; it6 != newPushMessageCBList.end(); it6++)
522 if (it6->hAddr == pMsgHandle)
524 newPushMessageCBList.erase(it6);
525 it6 = newPushMessageCBList.begin();
527 //Stop client Listener
533 // CB Message CB list
534 std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it7 = newCBMessageCBList.begin();
537 for (; it7 != newCBMessageCBList.end(); it7++)
540 if (it7->hAddr == pMsgHandle)
543 newCBMessageCBList.erase(it7);
544 it7 = newCBMessageCBList.begin();
546 //Stop client Listener
551 if(it7->bsave == true)
557 MsgSettingSetBool(CB_SAVE, bSave);
559 // Storage change Message CB list
560 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it8 = storageChangeCBList.begin();
562 for (; it8 != storageChangeCBList.end(); it8++)
564 if (it8->hAddr == pMsgHandle)
566 storageChangeCBList.erase(it8);
567 it8 = storageChangeCBList.begin();
569 //Stop client Listener
577 void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
582 THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
584 if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
586 unsigned int chInfo[3] = {0}; //3// reqid, status, object
588 memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(chInfo));
590 msg_struct_s status = {0,};
591 MSG_SENT_STATUS_S statusData = {(msg_request_id_t)chInfo[0], (msg_network_status_t)chInfo[1]};
593 status.type = MSG_STRUCT_SENT_STATUS_INFO;
594 status.data = (void *)&statusData;
598 MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
600 for( ; it != sentStatusCBList.end() ; it++)
602 MsgHandle* pHandle = it->hAddr;
604 msg_sent_status_cb pfunc = it->pfSentStatusCB;
606 void* param = it->userParam;
608 pfunc((msg_handle_t)pHandle, (msg_struct_t)&status, param);
613 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
615 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
616 int portKey = (pMsgInfo->msgPort.valid)? pMsgInfo->msgPort.dstPort: 0;
620 MsgNewMessageCBList::iterator it = newMessageCBList.begin();
621 MsgNewMessageCBList matchList;
623 for( ; it != newMessageCBList.end() ; it++)
625 if( portKey == it->port)
627 matchList.push_back(*it);
633 it = matchList.begin();
635 for( ; it != matchList.end(); it++ )
637 MsgHandle* pHandle = it->hAddr;
639 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
640 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
642 msgHidden.pData = NULL;
643 msgHidden.pMmsData = NULL;
645 /* Allocate memory for address list of message */
646 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
648 addr_list->nCount = 0;
649 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
651 msg_struct_s *pTmp = NULL;
653 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
654 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
655 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
656 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
657 pTmp->data = new MSG_ADDRESS_INFO_S;
658 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
660 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
663 msgHidden.addr_list = addr_list;
665 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
667 msg_struct_s msg = {0,};
668 msg.type = MSG_STRUCT_MESSAGE_INFO;
669 msg.data = &msgHidden;
671 msg_sms_incoming_cb pfunc = it->pfIncomingCB;
673 void* param = it->userParam;
675 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
677 delete [] (char*)msgHidden.pData;
678 if (msgHidden.pMmsData != NULL)
679 delete [] (char*)msgHidden.pMmsData;
681 // address Memory Free
682 if (msgHidden.addr_list!= NULL)
684 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
685 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
686 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
687 addrInfo->data = NULL;
688 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
689 msgHidden.addr_list->msg_struct_info[i] = NULL;
692 delete [] msgHidden.addr_list->msg_struct_info;
694 delete msgHidden.addr_list;
695 msgHidden.addr_list = NULL;
701 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
703 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
704 MMS_RECV_DATA_S* pMmsRecvData = ( MMS_RECV_DATA_S*)pMsgInfo->msgData;
706 char* appIdKey = (pMmsRecvData->msgAppId.valid)? pMmsRecvData->msgAppId.appId: NULL;
710 MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
711 MsgNewMMSConfMessageCBList matchList;
713 for( ; it != newMMSConfMessageCBList.end() ; it++)
717 if(!strcmp(appIdKey, it->appId))
718 matchList.push_back(*it);
720 else//(appIdKey == NULL && it->appId[0] == 0)
722 if(it->appId[0] == 0)
723 matchList.push_back(*it);
729 // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
730 // it is moved from UpdateMessage in MmsPluginStorage.cpp
731 char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; // check MSG_FILENAME_LEN_MAX
733 strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
735 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN+1);
736 memcpy(pMsgInfo->msgData, tempFileName + strlen(MSG_DATA_PATH), strlen(tempFileName));
738 it = matchList.begin();
740 for( ; it != matchList.end() ; it++)
742 MsgHandle* pHandle = it->hAddr;
744 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
745 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
747 msgHidden.pData = NULL;
748 msgHidden.pMmsData = NULL;
750 /* Allocate memory for address list of message */
751 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
753 addr_list->nCount = 0;
754 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
756 msg_struct_s *pTmp = NULL;
758 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
759 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
760 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
761 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
762 pTmp->data = new MSG_ADDRESS_INFO_S;
763 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
765 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
768 msgHidden.addr_list = addr_list;
770 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
772 msg_struct_s msg = {0,};
773 msg.type = MSG_STRUCT_MESSAGE_INFO;
774 msg.data = &msgHidden;
776 msg_mms_conf_msg_incoming_cb pfunc = it->pfMMSConfIncomingCB;
778 void* param = it->userParam;
779 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
781 delete [] (char*)msgHidden.pData;
782 if (msgHidden.pMmsData != NULL)
783 delete [] (char*)msgHidden.pMmsData;
785 // address Memory Free
786 if (msgHidden.addr_list!= NULL)
788 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
789 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
790 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
791 addrInfo->data = NULL;
792 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
793 msgHidden.addr_list->msg_struct_info[i] = NULL;
796 delete [] msgHidden.addr_list->msg_struct_info;
798 delete msgHidden.addr_list;
799 msgHidden.addr_list = NULL;
802 // Here the retrieved message will be deleted from native storage.
803 // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
806 MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
807 pHandle->deleteMessage(pMsgInfo->msgId);
811 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
813 MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
815 MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
819 MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
821 for( ; it != newSyncMLMessageCBList.end() ; it++)
823 MsgHandle* pHandle = it->hAddr;
825 msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
827 void* param = it->userParam;
829 pfunc((msg_handle_t)pHandle, pSyncMLData->syncmlType, pSyncMLData->pushBody, pSyncMLData->pushBodyLen, pSyncMLData->wspHeader, pSyncMLData->wspHeaderLen, param);
834 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
836 MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
840 MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
842 for( ; it != newLBSMessageCBList.end() ; it++)
844 MsgHandle* pHandle = it->hAddr;
846 msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
848 void* param = it->userParam;
850 pfunc((msg_handle_t)pHandle, pLBSData->pushHeader, pLBSData->pushBody, pLBSData->pushBodyLen, param);
855 else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
860 memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
861 memcpy(&extId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(int)), sizeof(int));
863 MSG_DEBUG("msgId [%d]", msgId);
864 MSG_DEBUG("extId [%d]", extId);
868 MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
870 for( ; it != operationSyncMLMessageCBList.end() ; it++)
872 MsgHandle* pHandle = it->hAddr;
874 msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
876 void* param = it->userParam;
878 pfunc((msg_handle_t)pHandle, msgId, extId, param);
883 else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
885 msg_storage_change_type_t storageChangeType;
886 msg_id_list_s msgIdList;
887 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
890 memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_storage_change_type_t));
891 memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)), sizeof(int));
893 if(msgIdList.nCount > 0)
894 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));
896 msgIdList.msgIdList = NULL;
898 MSG_DEBUG("storageChangeType [%d], msgIdList.nCount [%d]", storageChangeType, msgIdList.nCount);
902 MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
904 for( ; it != storageChangeCBList.end() ; it++)
906 MsgHandle* pHandle = it->hAddr;
908 msg_storage_change_cb pfunc = it->pfStorageChangeCB;
910 void* param = it->userParam;
912 pfunc((msg_handle_t)pHandle, storageChangeType, (msg_id_list_s*)&msgIdList, param);
918 else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_CB_MSG_IND)
920 MSG_CB_MSG_S *pCbMsg = (MSG_CB_MSG_S *)pMsgEvent->data;
924 MsgNewCBMessageCBList::iterator it = newCBMessageCBList.begin();
926 for( ; it != newCBMessageCBList.end() ; it++)
928 MsgHandle* pHandle = it->hAddr;
929 msg_struct_s msg = {0,};
931 msg.type = MSG_STRUCT_CB_MSG;
934 msg_cb_incoming_cb pfunc = it->pfCBIncomingCB;
936 void* param = it->userParam;
938 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
944 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND )
946 MSG_PUSH_MESSAGE_DATA_S* pPushData = (MSG_PUSH_MESSAGE_DATA_S *)pMsgEvent->data;
950 MsgNewPushMessageCBList::iterator it = newPushMessageCBList.begin();
952 for( ; it != newPushMessageCBList.end() ; it++)
954 MsgHandle* pHandle = it->hAddr;
956 msg_push_msg_incoming_cb pfunc = it->pfPushIncomingCB;
958 void* param = it->userParam;
960 pfunc((msg_handle_t)pHandle, pPushData->pushHeader, pPushData->pushBody, pPushData->pushBodyLen, param);
970 int MsgProxyListener::getRemoteFd()
972 MutexLocker lock(mx);
974 int tmpFd = cliSock.getRemoteFd();
976 MSG_DEBUG("listener fd [%d]", tmpFd);
980 cv.wait(mx.pMutex());
983 return cliSock.getRemoteFd();
987 int MsgProxyListener::readFromSocket(char** buf, int* len)
989 return cliSock.read(buf, len);