4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include "MsgCppTypes.h"
24 #include "MsgException.h"
25 #include "MsgUtilFile.h"
26 #include "MsgProxyListener.h"
27 #include "MsgGconfWrapper.h"
30 gboolean readSocket(GIOChannel *source, GIOCondition condition, gpointer data)
34 if (G_IO_ERR & condition)
36 MSG_DEBUG("IO Error!!! [%d]", condition);
38 MsgProxyListener::instance()->stop();
42 if (G_IO_HUP & condition)
44 MSG_DEBUG("socket fd Error!!! [%d]", condition);
46 MsgProxyListener::instance()->stop();
50 if (G_IO_NVAL & condition)
52 MSG_DEBUG("Invaild socket Error!!! [%d]", condition);
54 MsgProxyListener::instance()->stop();
61 int n = MsgProxyListener::instance()->readFromSocket(&buf, &len);
65 MSG_DEBUG(">>Receiving %d bytes", n);
66 MsgProxyListener::instance()->handleEvent((MSG_EVENT_S*)buf);
70 MSG_DEBUG("Server closed connection");
71 MsgProxyListener::instance()->stop();
81 MSG_DEBUG("Data is not for Listener");
96 /*==================================================================================================
97 IMPLEMENTATION OF MsgListenerThread - Member Functions
98 ==================================================================================================*/
99 MsgProxyListener* MsgProxyListener::pInstance = NULL;
102 MsgProxyListener::MsgProxyListener() : running(0)
104 sentStatusCBList.clear();
105 newMessageCBList.clear();
106 newMMSConfMessageCBList.clear();
107 newSyncMLMessageCBList.clear();
108 newLBSMessageCBList.clear();
112 MsgProxyListener::~MsgProxyListener()
114 sentStatusCBList.clear();
115 newMessageCBList.clear();
116 newMMSConfMessageCBList.clear();
117 newSyncMLMessageCBList.clear();
118 newLBSMessageCBList.clear();
122 MsgProxyListener* MsgProxyListener::instance()
125 MutexLocker lock(mm);
128 pInstance = new MsgProxyListener();
134 void MsgProxyListener::start()
139 cliSock.connect(MSG_SOCKET_PATH);
140 cv.signal(); // wake up the waiting thread
143 int fd = cliSock.fd();
145 MSG_DEBUG("Socket Fd : %d", fd);
147 channel = g_io_channel_unix_new(fd); // initializes ref_count = 1
149 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
151 MSG_DEBUG("Call g_io_add_watch() : %d", eventSourceId);
155 MSG_DEBUG("add Listener and [%d] are running.", running);
159 void MsgProxyListener::stop()
166 MSG_DEBUG("There are still running Listener. [%d] left.", running);
168 else if (running == 1)
170 MutexLocker lock(mx);
174 g_io_channel_unref(channel); // decrements ref_count = 1
176 g_source_remove(eventSourceId);
180 MSG_DEBUG("client Listener is terminated.");
187 bool MsgProxyListener::regSentStatusEventCB(MsgHandle* pMsgHandle, msg_sent_status_cb pfSentStatus, void *pUserParam)
189 MutexLocker lock(mx);
191 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
193 for (; it != sentStatusCBList.end(); it++)
195 if (it->hAddr == pMsgHandle && it->pfSentStatusCB == pfSentStatus)
197 MSG_DEBUG("msg_sent_status_cb() callback : [%p] is already registered!!!", pfSentStatus);
199 it->userParam = pUserParam;
205 MSG_SENT_STATUS_CB_ITEM_S sentStatusCB = {pMsgHandle, pfSentStatus, pUserParam};
207 sentStatusCBList.push_back(sentStatusCB);
213 bool MsgProxyListener::regMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam)
215 MutexLocker lock(mx);
217 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it = newMessageCBList.begin();
219 for (; it != newMessageCBList.end(); it++)
221 if (it->port == port && it->pfIncomingCB == pfNewMessage)
223 MSG_DEBUG("msg_sms_incoming_cb() callback : Port Number [%d] is already registered!!!", port);
225 it->userParam = pUserParam;
231 MSG_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewMessage, port, pUserParam};
233 newMessageCBList.push_back(incomingCB);
239 bool MsgProxyListener::regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam)
241 MutexLocker lock(mx);
243 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it = newMMSConfMessageCBList.begin();
245 for (; it != newMMSConfMessageCBList.end(); it++)
247 if (it->pfMMSConfIncomingCB == pfNewMMSConfMessage)
252 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback is already registered!!!");
256 else if(!strncmp(it->appId, pAppId, MAX_MMS_JAVA_APPID_LEN))
258 MSG_DEBUG("msg_mms_conf_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
260 it->userParam = pUserParam;
267 MSG_MMS_CONF_INCOMING_CB_ITEM_S incomingConfCB = {pMsgHandle, pfNewMMSConfMessage, {0}, pUserParam};
270 strncpy(incomingConfCB.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
272 newMMSConfMessageCBList.push_back(incomingConfCB);
278 bool MsgProxyListener::regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam)
280 MutexLocker lock(mx);
282 std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it = newPushMessageCBList.begin();
284 for (; it != newPushMessageCBList.end(); it++)
286 if (it->pfPushIncomingCB == pfNewPushMessage)
291 MSG_DEBUG("msg_push_msg_incoming_cb() callback is already registered!!!");
295 else if(!strncmp(it->appId, pAppId, MAX_WAPPUSH_ID_LEN))
297 MSG_DEBUG("msg_push_msg_incoming_cb() callback : AppId [%s] is already registered!!!", pAppId);
299 it->userParam = pUserParam;
306 MSG_PUSH_INCOMING_CB_ITEM_S incomingPushCB = {pMsgHandle, pfNewPushMessage, {0}, pUserParam};
309 strncpy(incomingPushCB.appId, pAppId, MAX_WAPPUSH_ID_LEN);
311 newPushMessageCBList.push_back(incomingPushCB);
316 bool MsgProxyListener::regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam)
318 MutexLocker lock(mx);
320 std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it = newCBMessageCBList.begin();
322 for (; it != newCBMessageCBList.end(); it++)
324 if (it->pfCBIncomingCB == pfNewCBMessage)
326 MSG_DEBUG("msg_CB_incoming_cb() callback : [%p] is already registered!!!", pfNewCBMessage);
329 it->userParam = pUserParam;
335 MSG_CB_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewCBMessage, bSave, pUserParam};
337 newCBMessageCBList.push_back(incomingCB);
342 bool MsgProxyListener::regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam)
344 MutexLocker lock(mx);
346 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it = newSyncMLMessageCBList.begin();
348 for (; it != newSyncMLMessageCBList.end(); it++)
350 if (it->pfSyncMLIncomingCB == pfNewSyncMLMessage)
352 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewSyncMLMessage);
354 it->userParam = pUserParam;
360 MSG_SYNCML_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewSyncMLMessage, pUserParam};
362 newSyncMLMessageCBList.push_back(incomingCB);
368 bool MsgProxyListener::regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam)
370 MutexLocker lock(mx);
372 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it = newLBSMessageCBList.begin();
374 for (; it != newLBSMessageCBList.end(); it++)
376 if (it->pfLBSMsgIncoming == pfNewLBSMsgIncoming)
378 MSG_DEBUG("msg_lbs_msg_incoming_cb() callback : [%p] is already registered!!!", pfNewLBSMsgIncoming);
380 it->userParam = pUserParam;
386 MSG_LBS_INCOMING_CB_ITEM_S incomingCB = {pMsgHandle, pfNewLBSMsgIncoming, pUserParam};
388 newLBSMessageCBList.push_back(incomingCB);
394 bool MsgProxyListener::regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam)
396 MutexLocker lock(mx);
398 std::list<MSG_SYNCML_OPERATION_CB_ITEM_S>::iterator it = operationSyncMLMessageCBList.begin();
400 for (; it != operationSyncMLMessageCBList.end(); it++)
402 if (it->pfSyncMLOperationCB == pfSyncMLMessageOperation)
404 MSG_DEBUG("msg_syncml_msg_incoming_cb() callback : [%p] is already registered!!!", pfSyncMLMessageOperation);
406 it->userParam = pUserParam;
412 MSG_SYNCML_OPERATION_CB_ITEM_S incomingCB = {pMsgHandle, pfSyncMLMessageOperation, pUserParam};
414 operationSyncMLMessageCBList.push_back(incomingCB);
420 bool MsgProxyListener::regStorageChangeEventCB(MsgHandle* pMsgHandle, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam)
422 MutexLocker lock(mx);
424 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it = storageChangeCBList.begin();
426 for (; it != storageChangeCBList.end(); it++)
428 if (it->pfStorageChangeCB == pfStorageChangeOperation)
430 MSG_DEBUG("msg_storage_change_cb() callback : [%p] is already registered!!!", pfStorageChangeOperation);
432 it->userParam = pUserParam;
438 MSG_STORAGE_CHANGE_CB_ITEM_S changeCB = {pMsgHandle, pfStorageChangeOperation, pUserParam};
440 storageChangeCBList.push_back(changeCB);
446 void MsgProxyListener::clearListOfClosedHandle(MsgHandle* pMsgHandle)
450 // sent status CB list
451 std::list<MSG_SENT_STATUS_CB_ITEM_S>::iterator it = sentStatusCBList.begin();
453 for (; it != sentStatusCBList.end(); it++)
455 if (it->hAddr == pMsgHandle)
457 sentStatusCBList.erase(it);
458 it = sentStatusCBList.begin();
460 //Stop client Listener
465 // new message CB list
466 std::list<MSG_INCOMING_CB_ITEM_S>::iterator it2 = newMessageCBList.begin();
468 for (; it2 != newMessageCBList.end(); it2++)
470 if (it2->hAddr == pMsgHandle)
472 newMessageCBList.erase(it2);
473 it2 = newMessageCBList.begin();
475 //Stop client Listener
480 // MMS conf Message CB list
481 std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S>::iterator it3 = newMMSConfMessageCBList.begin();
483 for (; it3 != newMMSConfMessageCBList.end(); it3++)
485 if (it3->hAddr == pMsgHandle)
487 newMMSConfMessageCBList.erase(it3);
488 it3 = newMMSConfMessageCBList.begin();
490 //Stop client Listener
495 // SyncML Message CB list
496 std::list<MSG_SYNCML_INCOMING_CB_ITEM_S>::iterator it4 = newSyncMLMessageCBList.begin();
498 for (; it4 != newSyncMLMessageCBList.end(); it4++)
500 if (it4->hAddr == pMsgHandle)
502 newSyncMLMessageCBList.erase(it4);
503 it4 = newSyncMLMessageCBList.begin();
505 //Stop client Listener
510 // LBS Message CB list
511 std::list<MSG_LBS_INCOMING_CB_ITEM_S>::iterator it5 = newLBSMessageCBList.begin();
513 for (; it5 != newLBSMessageCBList.end(); it5++)
515 if (it5->hAddr == pMsgHandle)
517 newLBSMessageCBList.erase(it5);
518 it5 = newLBSMessageCBList.begin();
520 //Stop client Listener
525 // Push Message CB list
526 std::list<MSG_PUSH_INCOMING_CB_ITEM_S>::iterator it6 = newPushMessageCBList.begin();
528 for (; it6 != newPushMessageCBList.end(); it6++)
530 if (it6->hAddr == pMsgHandle)
532 newPushMessageCBList.erase(it6);
533 it6 = newPushMessageCBList.begin();
535 //Stop client Listener
541 // CB Message CB list
542 std::list<MSG_CB_INCOMING_CB_ITEM_S>::iterator it7 = newCBMessageCBList.begin();
545 for (; it7 != newCBMessageCBList.end(); it7++)
548 if (it7->hAddr == pMsgHandle)
551 newCBMessageCBList.erase(it7);
552 it7 = newCBMessageCBList.begin();
554 //Stop client Listener
559 if(it7->bsave == true)
565 if(MsgSettingSetBool(CB_SAVE, bSave) != MSG_SUCCESS)
566 MSG_DEBUG("MsgSettingSetBool FAIL: CB_SAVE");
568 // Storage change Message CB list
569 std::list<MSG_STORAGE_CHANGE_CB_ITEM_S>::iterator it8 = storageChangeCBList.begin();
571 for (; it8 != storageChangeCBList.end(); it8++)
573 if (it8->hAddr == pMsgHandle)
575 storageChangeCBList.erase(it8);
576 it8 = storageChangeCBList.begin();
578 //Stop client Listener
586 void MsgProxyListener::handleEvent(const MSG_EVENT_S* pMsgEvent)
591 THROW(MsgException::INVALID_PARAM, "pMsgEvent is NULL");
593 if (pMsgEvent->eventType == MSG_EVENT_PLG_SENT_STATUS_CNF)
595 unsigned int chInfo[3] = {0}; //3// reqid, status, object
597 memcpy(&chInfo, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(chInfo));
599 msg_struct_s status = {0,};
600 MSG_SENT_STATUS_S statusData = {(msg_request_id_t)chInfo[0], (msg_network_status_t)chInfo[1]};
602 status.type = MSG_STRUCT_SENT_STATUS_INFO;
603 status.data = (void *)&statusData;
607 MsgSentStatusCBList::iterator it = sentStatusCBList.begin();
609 for( ; it != sentStatusCBList.end() ; it++)
611 MsgHandle* pHandle = it->hAddr;
613 msg_sent_status_cb pfunc = it->pfSentStatusCB;
615 void* param = it->userParam;
617 pfunc((msg_handle_t)pHandle, (msg_struct_t)&status, param);
622 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MSG_IND )
624 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
625 int portKey = (pMsgInfo->msgPort.valid)? pMsgInfo->msgPort.dstPort: 0;
629 MsgNewMessageCBList::iterator it = newMessageCBList.begin();
630 MsgNewMessageCBList matchList;
632 for( ; it != newMessageCBList.end() ; it++)
634 if( portKey == it->port)
636 matchList.push_back(*it);
642 it = matchList.begin();
644 for( ; it != matchList.end(); it++ )
646 MsgHandle* pHandle = it->hAddr;
648 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
649 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
651 msgHidden.pData = NULL;
652 msgHidden.pMmsData = NULL;
654 /* Allocate memory for address list of message */
655 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
657 addr_list->nCount = 0;
658 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
660 msg_struct_s *pTmp = NULL;
662 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
663 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
664 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
665 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
666 pTmp->data = new MSG_ADDRESS_INFO_S;
667 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
669 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
672 msgHidden.addr_list = addr_list;
674 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
676 msg_struct_s msg = {0,};
677 msg.type = MSG_STRUCT_MESSAGE_INFO;
678 msg.data = &msgHidden;
680 msg_sms_incoming_cb pfunc = it->pfIncomingCB;
682 void* param = it->userParam;
684 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
686 delete [] (char*)msgHidden.pData;
687 if (msgHidden.pMmsData != NULL)
688 delete [] (char*)msgHidden.pMmsData;
690 // address Memory Free
691 if (msgHidden.addr_list!= NULL)
693 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
694 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
695 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
696 addrInfo->data = NULL;
697 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
698 msgHidden.addr_list->msg_struct_info[i] = NULL;
701 delete [] msgHidden.addr_list->msg_struct_info;
703 delete msgHidden.addr_list;
704 msgHidden.addr_list = NULL;
710 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_MMS_CONF )
712 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
713 MMS_RECV_DATA_S* pMmsRecvData = ( MMS_RECV_DATA_S*)pMsgInfo->msgData;
715 char* appIdKey = (pMmsRecvData->msgAppId.valid)? pMmsRecvData->msgAppId.appId: NULL;
719 MsgNewMMSConfMessageCBList::iterator it = newMMSConfMessageCBList.begin();
720 MsgNewMMSConfMessageCBList matchList;
722 for( ; it != newMMSConfMessageCBList.end() ; it++)
726 if(!strcmp(appIdKey, it->appId))
727 matchList.push_back(*it);
729 else//(appIdKey == NULL && it->appId[0] == 0)
731 if(it->appId[0] == 0)
732 matchList.push_back(*it);
738 // Contents of msgData removed and replaced to retrievedFilePath for convertMsgStruct
739 // it is moved from UpdateMessage in MmsPluginStorage.cpp
740 char tempFileName[MSG_FILENAME_LEN_MAX+1] = {0}; // check MSG_FILENAME_LEN_MAX
742 strncpy(tempFileName, pMmsRecvData->retrievedFilePath, MSG_FILENAME_LEN_MAX);
744 memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN+1);
745 memcpy(pMsgInfo->msgData, tempFileName + strlen(MSG_DATA_PATH), MAX_MSG_DATA_LEN);
747 it = matchList.begin();
749 for( ; it != matchList.end() ; it++)
751 MsgHandle* pHandle = it->hAddr;
753 MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)pMsgEvent->data;
754 MSG_MESSAGE_HIDDEN_S msgHidden = {0,};
756 msgHidden.pData = NULL;
757 msgHidden.pMmsData = NULL;
759 /* Allocate memory for address list of message */
760 msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s;
762 addr_list->nCount = 0;
763 addr_list->msg_struct_info = (msg_struct_t *)new char[sizeof(MSG_ADDRESS_INFO_S *)*MAX_TO_ADDRESS_CNT];
765 msg_struct_s *pTmp = NULL;
767 for (int i = 0; i < MAX_TO_ADDRESS_CNT; i++) {
768 addr_list->msg_struct_info[i] = (msg_struct_t)new char[sizeof(msg_struct_s)];
769 pTmp = (msg_struct_s *)addr_list->msg_struct_info[i];
770 pTmp->type = MSG_STRUCT_ADDRESS_INFO;
771 pTmp->data = new MSG_ADDRESS_INFO_S;
772 memset(pTmp->data, 0x00, sizeof(MSG_ADDRESS_INFO_S));
774 addr_list->msg_struct_info[i] = (msg_struct_t)pTmp;
777 msgHidden.addr_list = addr_list;
779 pHandle->convertMsgStruct(pMsgInfo, &msgHidden);
781 msg_struct_s msg = {0,};
782 msg.type = MSG_STRUCT_MESSAGE_INFO;
783 msg.data = &msgHidden;
785 msg_mms_conf_msg_incoming_cb pfunc = it->pfMMSConfIncomingCB;
787 void* param = it->userParam;
788 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
790 delete [] (char*)msgHidden.pData;
791 if (msgHidden.pMmsData != NULL)
792 delete [] (char*)msgHidden.pMmsData;
794 // address Memory Free
795 if (msgHidden.addr_list!= NULL)
797 for(int i=0; i<MAX_TO_ADDRESS_CNT; i++) {
798 msg_struct_s * addrInfo = (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
799 delete (MSG_ADDRESS_INFO_S *)addrInfo->data;
800 addrInfo->data = NULL;
801 delete (msg_struct_s *)msgHidden.addr_list->msg_struct_info[i];
802 msgHidden.addr_list->msg_struct_info[i] = NULL;
805 delete [] msgHidden.addr_list->msg_struct_info;
807 delete msgHidden.addr_list;
808 msgHidden.addr_list = NULL;
811 // Here the retrieved message will be deleted from native storage.
812 // as of now, msg which have appId is considered as JAVA MMS message and it will be sent and handled in JAVA app.
815 MSG_DEBUG("delete received JAVA MMS message:%s from native storage",tempFileName);
816 pHandle->deleteMessage(pMsgInfo->msgId);
820 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_SYNCML_MSG_IND )
822 MSG_SYNCML_MESSAGE_DATA_S* pSyncMLData = (MSG_SYNCML_MESSAGE_DATA_S *)pMsgEvent->data;
824 MSG_DEBUG("msgType [%d]", pSyncMLData->syncmlType);
828 MsgNewSyncMLMessageCBList::iterator it = newSyncMLMessageCBList.begin();
830 for( ; it != newSyncMLMessageCBList.end() ; it++)
832 MsgHandle* pHandle = it->hAddr;
834 msg_syncml_msg_incoming_cb pfunc = it->pfSyncMLIncomingCB;
836 void* param = it->userParam;
838 pfunc((msg_handle_t)pHandle, pSyncMLData->syncmlType, pSyncMLData->pushBody, pSyncMLData->pushBodyLen, pSyncMLData->wspHeader, pSyncMLData->wspHeaderLen, param);
843 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_LBS_MSG_IND )
845 MSG_LBS_MESSAGE_DATA_S* pLBSData = (MSG_LBS_MESSAGE_DATA_S *)pMsgEvent->data;
849 MsgNewLBSMessageCBList::iterator it = newLBSMessageCBList.begin();
851 for( ; it != newLBSMessageCBList.end() ; it++)
853 MsgHandle* pHandle = it->hAddr;
855 msg_lbs_msg_incoming_cb pfunc = it->pfLBSMsgIncoming;
857 void* param = it->userParam;
859 pfunc((msg_handle_t)pHandle, pLBSData->pushHeader, pLBSData->pushBody, pLBSData->pushBodyLen, param);
864 else if ( pMsgEvent->eventType == MSG_EVENT_SYNCML_OPERATION )
869 memcpy(&msgId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(int));
870 memcpy(&extId, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(int)), sizeof(int));
872 MSG_DEBUG("msgId [%d]", msgId);
873 MSG_DEBUG("extId [%d]", extId);
877 MsgOperationSyncMLMessageCBList::iterator it = operationSyncMLMessageCBList.begin();
879 for( ; it != operationSyncMLMessageCBList.end() ; it++)
881 MsgHandle* pHandle = it->hAddr;
883 msg_syncml_msg_operation_cb pfunc = it->pfSyncMLOperationCB;
885 void* param = it->userParam;
887 pfunc((msg_handle_t)pHandle, msgId, extId, param);
892 else if (pMsgEvent->eventType == MSG_EVENT_PLG_STORAGE_CHANGE_IND)
894 msg_storage_change_type_t storageChangeType;
895 msg_id_list_s msgIdList;
896 memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
899 memcpy(&storageChangeType, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)), sizeof(msg_storage_change_type_t));
900 memcpy(&msgIdList.nCount, (void*)((char*)pMsgEvent+sizeof(MSG_EVENT_TYPE_T)+sizeof(msg_error_t)+sizeof(msg_storage_change_type_t)), sizeof(int));
902 if(msgIdList.nCount > 0)
903 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));
905 msgIdList.msgIdList = NULL;
907 MSG_DEBUG("storageChangeType [%d], msgIdList.nCount [%d]", storageChangeType, msgIdList.nCount);
911 MsgStorageChangeCBList::iterator it = storageChangeCBList.begin();
913 for( ; it != storageChangeCBList.end() ; it++)
915 MsgHandle* pHandle = it->hAddr;
917 msg_storage_change_cb pfunc = it->pfStorageChangeCB;
919 void* param = it->userParam;
921 pfunc((msg_handle_t)pHandle, storageChangeType, (msg_id_list_s*)&msgIdList, param);
927 else if (pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_CB_MSG_IND)
929 MSG_CB_MSG_S *pCbMsg = (MSG_CB_MSG_S *)pMsgEvent->data;
933 MsgNewCBMessageCBList::iterator it = newCBMessageCBList.begin();
935 for( ; it != newCBMessageCBList.end() ; it++)
937 MsgHandle* pHandle = it->hAddr;
938 msg_struct_s msg = {0,};
940 msg.type = MSG_STRUCT_CB_MSG;
943 msg_cb_incoming_cb pfunc = it->pfCBIncomingCB;
945 void* param = it->userParam;
947 pfunc((msg_handle_t)pHandle, (msg_struct_t) &msg, param);
953 else if ( pMsgEvent->eventType == MSG_EVENT_PLG_INCOMING_PUSH_MSG_IND )
955 MSG_PUSH_MESSAGE_DATA_S* pPushData = (MSG_PUSH_MESSAGE_DATA_S *)pMsgEvent->data;
959 MsgNewPushMessageCBList::iterator it = newPushMessageCBList.begin();
961 for( ; it != newPushMessageCBList.end() ; it++)
963 MsgHandle* pHandle = it->hAddr;
965 msg_push_msg_incoming_cb pfunc = it->pfPushIncomingCB;
967 void* param = it->userParam;
969 pfunc((msg_handle_t)pHandle, pPushData->pushHeader, pPushData->pushBody, pPushData->pushBodyLen, param);
979 int MsgProxyListener::getRemoteFd()
981 int tmpFd = cliSock.getRemoteFd();
983 MSG_DEBUG("listener fd [%d]", tmpFd);
989 int MsgProxyListener::readFromSocket(char** buf, unsigned int* len)
991 return cliSock.read(buf, len);
994 #ifdef CHECK_SENT_STATUS_CALLBACK
995 int MsgProxyListener::getSentStatusCbCnt()
999 cbCnt = sentStatusCBList.size();
1001 MSG_DEBUG("registered sent status callback count : [%d]", cbCnt);