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"
26 gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
30 if (G_IO_ERR & condition)
32 MSG_DEBUG("IO Error!!! [%d]", condition);
34 MsgProxyListener::instance()->stop();
38 if (G_IO_HUP & condition)
40 MSG_DEBUG("socket fd Error!!! [%d]", condition);
42 MsgProxyListener::instance()->stop();
46 if (G_IO_NVAL & condition)
48 MSG_DEBUG("Invaild socket Error!!! [%d]", condition);
50 MsgProxyListener::instance()->stop();
57 int n = MsgProxyListener::instance()->readFromSocket(&buf, &len);
61 MSG_DEBUG(">>Receiving %d bytes", n);
62 MsgProxyListener::instance()->handleEvent((MSG_EVENT_S*)buf);
66 MSG_DEBUG("Server closed connection");
67 MsgProxyListener::instance()->stop();
72 MSG_DEBUG("Data is not for Listener");
87 /*==================================================================================================
88 IMPLEMENTATION OF MsgListenerThread - Member Functions
89 ==================================================================================================*/
90 MsgProxyListener* MsgProxyListener::pInstance = NULL;
93 MsgProxyListener::MsgProxyListener() : running(0)
95 sentStatusCBList.clear();
96 newMessageCBList.clear();
97 newMMSConfMessageCBList.clear();
98 newSyncMLMessageCBList.clear();
99 newLBSMessageCBList.clear();
103 MsgProxyListener::~MsgProxyListener()
105 sentStatusCBList.clear();
106 newMessageCBList.clear();
107 newMMSConfMessageCBList.clear();
108 newSyncMLMessageCBList.clear();
109 newLBSMessageCBList.clear();
113 MsgProxyListener* MsgProxyListener::instance()
116 MutexLocker lock(mm);
119 pInstance = new MsgProxyListener();
125 void MsgProxyListener::start()
130 cliSock.connect(MSG_SOCKET_PATH);
131 cv.signal(); // wake up the waiting thread
134 int fd = cliSock.fd();
136 MSG_DEBUG("Socket Fd : %d", fd);
138 channel = g_io_channel_unix_new(fd); // initializes ref_count = 1
140 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
142 MSG_DEBUG("Call g_io_add_watch() : %d", eventSourceId);
146 MSG_DEBUG("add Listener and [%d] are running.", running);
150 void MsgProxyListener::stop()
157 MSG_DEBUG("There are still running Listener. [%d] left.", running);
159 else if (running == 1)
161 MutexLocker lock(mx);
165 g_io_channel_unref(channel); // decrements ref_count = 1
167 g_source_remove(eventSourceId);
171 MSG_DEBUG("client Listener is terminated.");
178 bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam)
180 MutexLocker lock(mx);
182 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
184 for (; it != sentStatusCBList.end(); it++)
186 if (it->hAddr == pMsgHandle && it->pfSentStatusCB == pfSentStatus)
188 MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
190 it->userParam = pUserParam;
196 MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, pfSentStatus, pUserParam};
198 sentStatusCBList.push_back(sentStatusCB);
204 bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
206 MutexLocker lock(mx);
208 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it = newMessageCBList.begin();
210 for (; it != newMessageCBList.end(); it++)
212 if (it->port == port && it->pfIncomingCB == pfNewMessage)
214 MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
216 it->userParam = pUserParam;
222 MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewMessage, port, pUserParam};
224 newMessageCBList.push_back(incomingCB);
230 bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
232 MutexLocker lock(mx);
234 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it = newMMSConfMessageCBList.begin();
236 for (; it != newMMSConfMessageCBList.end(); it++)
238 if (it->pfMMSConfIncomingCB == pfNewMMSConfMessage)
243 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
247 else if(!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN))
249 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
251 it->userParam = pUserParam;
258 MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, pfNewMMSConfMessage, {0}, pUserParam};
261 strncpy(incomingConfCB.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
263 newMMSConfMessageCBList.push_back(incomingConfCB);
269 bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
271 MutexLocker lock(mx);
273 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it = newSyncMLMessageCBList.begin();
275 for (; it != newSyncMLMessageCBList.end(); it++)
277 if (it->pfSyncMLIncomingCB == pfNewSyncMLMessage)
279 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
281 it->userParam = pUserParam;
287 MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewSyncMLMessage, pUserParam};
289 newSyncMLMessageCBList.push_back(incomingCB);
295 bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
297 MutexLocker lock(mx);
299 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it = newLBSMessageCBList.begin();
301 for (; it != newLBSMessageCBList.end(); it++)
303 if (it->pfLBSMsgIncoming == pfNewLBSMsgIncoming)
305 MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
307 it->userParam = pUserParam;
313 MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewLBSMsgIncoming, pUserParam};
315 newLBSMessageCBList.push_back(incomingCB);
321 bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
323 MutexLocker lock(mx);
325 std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it = operationSyncMLMessageCBList.begin();
327 for (; it != operationSyncMLMessageCBList.end(); it++)
329 if (it->pfSyncMLOperationCB == pfSyncMLMessageOperation)
331 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
333 it->userParam = pUserParam;
339 MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, pfSyncMLMessageOperation, pUserParam};
341 operationSyncMLMessageCBList.push_back(incomingCB);
347 bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
349 MutexLocker lock(mx);
351 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it = storageChangeCBList.begin();
353 for (; it != storageChangeCBList.end(); it++)
355 if (it->pfStorageChangeCB == pfStorageChangeOperation)
357 MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
359 it->userParam = pUserParam;
365 MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, pfStorageChangeOperation, pUserParam};
367 storageChangeCBList.push_back(changeCB);
373 void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
377 // sent status CB list
378 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
380 for (; it != sentStatusCBList.end(); it++)
382 if (it->hAddr == pMsgHandle)
384 sentStatusCBList.erase(it);
385 it = sentStatusCBList.begin();
387 //Stop client Listener
392 // new message CB list
393 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
395 for (; it2 != newMessageCBList.end(); it2++)
397 if (it2->hAddr == pMsgHandle)
399 newMessageCBList.erase(it2);
400 it2 = newMessageCBList.begin();
402 //Stop client Listener
407 // MMS conf Message CB list
408 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
410 for (; it3 != newMMSConfMessageCBList.end(); it3++)
412 if (it3->hAddr == pMsgHandle)
414 newMMSConfMessageCBList.erase(it3);
415 it3 = newMMSConfMessageCBList.begin();
417 //Stop client Listener
422 // SyncML Message CB list
423 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
425 for (; it4 != newSyncMLMessageCBList.end(); it4++)
427 if (it4->hAddr == pMsgHandle)
429 newSyncMLMessageCBList.erase(it4);
430 it4 = newSyncMLMessageCBList.begin();
432 //Stop client Listener
437 // LBS Message CB list
438 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
440 for (; it5 != newLBSMessageCBList.end(); it5++)
442 if (it5->hAddr == pMsgHandle)
444 newLBSMessageCBList.erase(it5);
445 it5 = newLBSMessageCBList.begin();
447 //Stop client Listener
452 // Storage change Message CB list
453 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it6 = storageChangeCBList.begin();
455 for (; it6 != storageChangeCBList.end(); it6++)
457 if (it6->hAddr == pMsgHandle)
459 storageChangeCBList.erase(it6);
460 it6 = storageChangeCBList.begin();
462 //Stop client Listener
470 void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
475 THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
477 if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
479 unsigned int chInfo[3] = {0}; //3// reqid, status, object
481 memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(chInfo));
483 msg_struct_s status = {0,};
484 MSG_SENT_STATUS_S statusData = {(msg_request_id_t)chInfo[0], (msg_network_status_t)chInfo[1]};
486 status.type = MSG_STRUCT_SENT_STATUS_INFO;
487 status.data = (void *)&statusData;
491 MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
493 for( ; it != sentStatusCBList.end() ; it++)
495 MsgHandle* pHandle = it->hAddr;
497 msg_sent_status_cb pfunc = it->pfSentStatusCB;
499 void* param = it->userParam;
501 pfunc((msg_handle_t)pHandle, (msg_struct_t)&status, param);
506 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
508 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
509 int portKey = (pMsgInfo->msgPort.valid)? pMsgInfo->msgPort.dstPort: 0;
513 MsgNewMessageCBList::iterator it = newMessageCBList.begin();
514 MsgNewMessageCBList matchList;
516 for( ; it != newMessageCBList.end() ; it++)
518 if( portKey == it->port)
520 matchList.push_back(*it);
526 it = matchList.begin();
528 for( ; it != matchList.end(); it++ )
530 MsgHandle* pHandle = it->hAddr;
532 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
533 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
535 msgHidden.pData = NULL;
536 msgHidden.pMmsData = NULL;
538 /* Allocate memory for address list of message */
539 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
541 addr_list->nCount = 0;
542 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
544 msg_struct_s *pTmp = NULL;
546 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
547 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
548 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
549 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
550 pTmp->data = new MSG_ADDRESS_INFO_S;
551 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
553 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
556 msgHidden.addr_list = addr_list;
558 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
560 msg_struct_s msg = {0,};
561 msg.type = MSG_STRUCT_MESSAGE_INFO;
562 msg.data = &msgHidden;
564 msg_sms_incoming_cb pfunc = it->pfIncomingCB;
566 void* param = it->userParam;
568 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
570 delete [] (char*)msgHidden.pData;
571 if (msgHidden.pMmsData != NULL)
572 delete [] (char*)msgHidden.pMmsData;
574 // address Memory Free
575 if (msgHidden.addr_list!= NULL)
577 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
578 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
579 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
580 addrInfo->data = NULL;
581 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
582 msgHidden.addr_list->msg_struct_info[i] = NULL;
585 delete [] msgHidden.addr_list->msg_struct_info;
587 delete msgHidden.addr_list;
588 msgHidden.addr_list = NULL;
594 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
596 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
597 MMS_RECV_DATA_S* pMmsRecvData = ( MMS_RECV_DATA_S*)pMsgInfo->msgData;
599 char* appIdKey = (pMmsRecvData->msgAppId.valid)? pMmsRecvData->msgAppId.appId: NULL;
603 MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
604 MsgNewMMSConfMessageCBList matchList;
606 for( ; it != newMMSConfMessageCBList.end() ; it++)
610 if(!strcmp(appIdKey, it->appId))
611 matchList.push_back(*it);
613 else//(appIdKey == NULL && it->appId[0] == 0)
615 if(it->appId[0] == 0)
616 matchList.push_back(*it);
622 // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
623 // it is moved from UpdateMessage in MmsPluginStorage.cpp
624 char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; // check MSG_FILENAME_LEN_MAX
626 strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
628 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN+1);
629 memcpy(pMsgInfo->msgData, tempFileName + strlen(MSG_DATA_PATH), strlen(tempFileName));
631 it = matchList.begin();
633 for( ; it != matchList.end() ; it++)
635 MsgHandle* pHandle = it->hAddr;
637 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
638 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
640 msgHidden.pData = NULL;
641 msgHidden.pMmsData = NULL;
643 /* Allocate memory for address list of message */
644 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
646 addr_list->nCount = 0;
647 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
649 msg_struct_s *pTmp = NULL;
651 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
652 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
653 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
654 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
655 pTmp->data = new MSG_ADDRESS_INFO_S;
656 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
658 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
661 msgHidden.addr_list = addr_list;
663 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
665 msg_struct_s msg = {0,};
666 msg.type = MSG_STRUCT_MESSAGE_INFO;
667 msg.data = &msgHidden;
669 msg_mms_conf_msg_incoming_cb pfunc = it->pfMMSConfIncomingCB;
671 void* param = it->userParam;
672 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
674 delete [] (char*)msgHidden.pData;
675 if (msgHidden.pMmsData != NULL)
676 delete [] (char*)msgHidden.pMmsData;
678 // address Memory Free
679 if (msgHidden.addr_list!= NULL)
681 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
682 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
683 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
684 addrInfo->data = NULL;
685 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
686 msgHidden.addr_list->msg_struct_info[i] = NULL;
689 delete [] msgHidden.addr_list->msg_struct_info;
691 delete msgHidden.addr_list;
692 msgHidden.addr_list = NULL;
695 // Here the retrieved message will be deleted from native storage.
696 // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
699 MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
700 pHandle->deleteMessage(pMsgInfo->msgId);
704 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
706 MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
708 MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
712 MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
714 for( ; it != newSyncMLMessageCBList.end() ; it++)
716 MsgHandle* pHandle = it->hAddr;
718 msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
720 void* param = it->userParam;
722 pfunc((msg_handle_t)pHandle, pSyncMLData->syncmlType, pSyncMLData->pushBody, pSyncMLData->pushBodyLen, pSyncMLData->wspHeader, pSyncMLData->wspHeaderLen, param);
727 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
729 MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
733 MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
735 for( ; it != newLBSMessageCBList.end() ; it++)
737 MsgHandle* pHandle = it->hAddr;
739 msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
741 void* param = it->userParam;
743 pfunc((msg_handle_t)pHandle, pLBSData->pushHeader, pLBSData->pushBody, pLBSData->pushBodyLen, param);
748 else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
753 memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
754 memcpy(&extId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(int)), sizeof(int));
756 MSG_DEBUG("msgId [%d]", msgId);
757 MSG_DEBUG("extId [%d]", extId);
761 MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
763 for( ; it != operationSyncMLMessageCBList.end() ; it++)
765 MsgHandle* pHandle = it->hAddr;
767 msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
769 void* param = it->userParam;
771 pfunc((msg_handle_t)pHandle, msgId, extId, param);
776 else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
778 msg_storage_change_type_t storageChangeType;
779 msg_id_list_s msgIdList;
780 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
783 memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_storage_change_type_t));
784 memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)), sizeof(int));
786 if(msgIdList.nCount > 0)
787 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));
789 msgIdList.msgIdList = NULL;
791 MSG_DEBUG("storageChangeType [%d], msgIdList.nCount [%d]", storageChangeType, msgIdList.nCount);
795 MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
797 for( ; it != storageChangeCBList.end() ; it++)
799 MsgHandle* pHandle = it->hAddr;
801 msg_storage_change_cb pfunc = it->pfStorageChangeCB;
803 void* param = it->userParam;
805 pfunc((msg_handle_t)pHandle, storageChangeType, (msg_id_list_s*)&msgIdList, param);
815 int MsgProxyListener::getRemoteFd()
817 MutexLocker lock(mx);
819 int tmpFd = cliSock.getRemoteFd();
821 MSG_DEBUG("listener fd [%d]", tmpFd);
825 cv.wait(mx.pMutex());
828 return cliSock.getRemoteFd();
832 int MsgProxyListener::readFromSocket(char** buf, int* len)
834 return cliSock.read(buf, len);