2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __MSG_PROXY_LISTENER_H__
18 #define __MSG_PROXY_LISTENER_H__
21 /*==================================================================================================
23 ==================================================================================================*/
24 #include "MsgIpcSocket.h"
27 #include "MsgHandle.h"
34 /*==================================================================================================
36 ==================================================================================================*/
40 msg_sent_status_cb pfSentStatusCB;
42 } MSG_SENT_STATUS_CB_ITEM_S;
48 msg_sms_incoming_cb pfIncomingCB;
51 } MSG_INCOMING_CB_ITEM_S;
57 msg_mms_conf_msg_incoming_cb pfMMSConfIncomingCB;
58 char appId[MAX_MMS_JAVA_APPID_LEN+1];
60 } MSG_MMS_CONF_INCOMING_CB_ITEM_S;
66 msg_push_msg_incoming_cb pfPushIncomingCB;
67 char appId[MAX_WAPPUSH_ID_LEN+1];
69 } MSG_PUSH_INCOMING_CB_ITEM_S;
75 msg_cb_incoming_cb pfCBIncomingCB;
78 } MSG_CB_INCOMING_CB_ITEM_S;
84 msg_syncml_msg_incoming_cb pfSyncMLIncomingCB;
86 } MSG_SYNCML_INCOMING_CB_ITEM_S;
92 msg_lbs_msg_incoming_cb pfLBSMsgIncoming;
94 } MSG_LBS_INCOMING_CB_ITEM_S;
100 msg_syncml_msg_operation_cb pfSyncMLOperationCB;
102 } MSG_SYNCML_OPERATION_CB_ITEM_S;
108 msg_storage_change_cb pfStorageChangeCB;
110 } MSG_STORAGE_CHANGE_CB_ITEM_S;
116 msg_report_msg_incoming_cb pfReportMsgIncomingCB;
118 } MSG_REPORT_INCOMING_CB_ITEM_S;
121 typedef std::list<MSG_SENT_STATUS_CB_ITEM_S> MsgSentStatusCBList;
122 typedef std::list<MSG_INCOMING_CB_ITEM_S> MsgNewMessageCBList;
123 typedef std::list<MSG_MMS_CONF_INCOMING_CB_ITEM_S> MsgNewMMSConfMessageCBList;
124 typedef std::list<MSG_PUSH_INCOMING_CB_ITEM_S> MsgNewPushMessageCBList;
125 typedef std::list<MSG_CB_INCOMING_CB_ITEM_S> MsgNewCBMessageCBList;
126 typedef std::list<MSG_SYNCML_INCOMING_CB_ITEM_S> MsgNewSyncMLMessageCBList;
127 typedef std::list<MSG_LBS_INCOMING_CB_ITEM_S> MsgNewLBSMessageCBList;
128 typedef std::list<MSG_SYNCML_OPERATION_CB_ITEM_S> MsgOperationSyncMLMessageCBList;
129 typedef std::list<MSG_STORAGE_CHANGE_CB_ITEM_S> MsgStorageChangeCBList;
130 typedef std::list<MSG_REPORT_INCOMING_CB_ITEM_S> MsgReportMessageCBList;
131 typedef std::set<MsgHandle*> handle_set;
133 /*==================================================================================================
135 ==================================================================================================*/
136 class MsgProxyListener
139 static MsgProxyListener* instance();
141 void start(MsgHandle* pMsgHandle);
144 bool regSentStatusEventCB(MsgHandle* pMsgHandle, int fd, msg_sent_status_cb pfSentStatus, void *pUserParam);
145 bool regMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_sms_incoming_cb pfNewMessage, int port, void *pUserParam);
146 bool regMMSConfMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_mms_conf_msg_incoming_cb pfNewMMSConfMessage, const char *pAppId, void *pUserParam);
147 bool regPushMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_push_msg_incoming_cb pfNewPushMessage, const char *pAppId, void *pUserParam);
148 bool regCBMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_cb_incoming_cb pfNewCBMessage, bool bSave, void *pUserParam);
149 bool regSyncMLMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_syncml_msg_incoming_cb pfNewSyncMLMessage, void *pUserParam);
150 bool regLBSMessageIncomingEventCB(MsgHandle* pMsgHandle, int fd, msg_lbs_msg_incoming_cb pfNewLBSMsgIncoming, void *pUserParam);
151 bool regSyncMLMessageOperationEventCB(MsgHandle* pMsgHandle, int fd, msg_syncml_msg_operation_cb pfSyncMLMessageOperation, void *pUserParam);
152 bool regStorageChangeEventCB(MsgHandle* pMsgHandle, int fd, msg_storage_change_cb pfStorageChangeOperation, void *pUserParam);
153 bool regReportMsgIncomingCB(MsgHandle* pMsgHandle, int fd, msg_report_msg_incoming_cb pfReportMessage, void *pUserParam);
155 void clearListOfClosedHandle(MsgHandle* pMsgHandle);
156 void refreshListOfOpenedHandle(MsgHandle* pMsgHandle);
158 void handleEvent(const MSG_EVENT_S* ptr);
161 int readFromSocket(char** buf, unsigned int* len);
162 void resetProxyListener();
163 void refreshProxyListener();
164 void clearProxyCBLists();
165 void insertOpenHandleSet(MsgHandle* pMsgHandle);
166 void clearOpenHandleSet();
167 #ifdef CHECK_SENT_STATUS_CALLBACK
168 int getSentStatusCbCnt();
175 static MsgProxyListener* pInstance;
177 unsigned int running;
179 handle_set openHandleSet;
181 MsgIpcClientSocket cliSock;
186 MsgSentStatusCBList sentStatusCBList;
187 MsgNewMessageCBList newMessageCBList;
188 MsgNewMMSConfMessageCBList newMMSConfMessageCBList;
189 MsgNewPushMessageCBList newPushMessageCBList;
190 MsgNewCBMessageCBList newCBMessageCBList;
191 MsgNewSyncMLMessageCBList newSyncMLMessageCBList;
192 MsgNewLBSMessageCBList newLBSMessageCBList;
193 MsgOperationSyncMLMessageCBList operationSyncMLMessageCBList;
194 MsgStorageChangeCBList storageChangeCBList;
195 MsgReportMessageCBList reportMessageCBList;
201 #endif /* __MSG_PROXY_LISTENER_H__ */