2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FMsg_SmsMmsCallbackHandler.h
19 * @brief This is the header file for _SmsMmsCallbackHandler class.
21 * This header file contains declaration of _SmsMmsCallbackHandler class
24 #ifndef _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
25 #define _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_
28 #include <FBaseObject.h>
29 #include <FBaseColMultiHashMap.h>
30 #include "FMsg_Types.h"
32 namespace Tizen { namespace Messaging
36 * @class _SmsMmsCallbackHandler
37 * @brief This class provides methods to use the SMS/MMS call back Handler service
40 * This class provides methods to use the SMS/MMS call back Handler service . @n
43 // forward declaration
45 class _SmsMmsCallbackHandler
46 : public Tizen::Base::Object
50 * This is the destructor for this class.
54 virtual ~_SmsMmsCallbackHandler(void);
57 * Initializes the Messaging Hash Map table
60 * @return An error code
61 * @exception E_SUCCESS The method was successful.
62 * @exception E_INVALID_ARG Input parameter is NULL.
63 * @exception E_OUT_OF_MEMORY Memory error.
65 result Construct(void);
70 * Gets the instance of SmsMmsCallbackHandler class.
73 * @return instance of SmsMmsCallbackHandler class
75 static _SmsMmsCallbackHandler* GetInstance(void);
78 * gets the Message Handle for SMS/MMS operation.
81 * @return An error code
82 * @param[in] messageHandle message Handle
83 * @exception MSG_SUCCESS The method was successful.
84 * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
85 * @exception MSG_ERR_MEMORY_ERROR Memory error.
87 int OpenMessageHandle(msg_handle_t& messageHandle);
90 * gets the Message Handle for Cbs message operation.
93 * @return An error code
94 * @param[in] cbsSettingsHandle cbs message Handle
95 * @exception MSG_SUCCESS The method was successful.
96 * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
97 * @exception MSG_ERR_MEMORY_ERROR Memory error.
99 int OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle);
101 // Adds a CBS channel with specified parameters.
102 result AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate);
104 // Removes a CBS channel with specified parameters.
105 result RemoveCbsChannel(int from, int to);
107 // Searches a CBS channel with specified parameters and returns index of channel found.
108 result SearchCbsChannel(int from, int to, int& index);
110 // Updates a CBS channel with specified parameters.
111 result UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate);
113 // Gets a CBS channel data with specified index.
114 result GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate);
116 // Gets a CBS channel count.
117 result GetCbsChannelsCount(int& count);
120 * loads the Cbs channels list.
123 * @return An error code
124 * @exception E_SUCCESS The method was successful.
125 * @exception E_INVALID_ARG Input parameter is NULL.
126 * @exception E_OUT_OF_MEMORY Memory error.
128 result LoadCbsSettings();
131 * saves the Cbs channels list.
134 * @return An error code
135 * @exception E_SUCCESS The method was successful.
136 * @exception E_INVALID_ARG Input parameter is NULL.
137 * @exception E_OUT_OF_MEMORY Memory error.
139 result SaveCbsSettings();
142 * closes the CBS Message Handle.
145 * @return An error code
146 * @exception MSG_SUCCESS The method was successful.
147 * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
148 * @exception MSG_ERR_MEMORY_ERROR Memory error.
150 int CloseCbsSettingsHandle(void);
153 * closes the Message Handle for SMS/MMS operation.
156 * @return An error code
157 * @exception MSG_SUCCESS The method was successful.
158 * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
159 * @exception MSG_ERR_MEMORY_ERROR Memory error.
161 int CloseMessageHandle(void);
164 * Registers the Message call back for SMS/MMS operation.
167 * @return An error code
168 * @exception MSG_SUCCESS The method was successful.
169 * @exception MSG_ERR_NULL_POINTER Input parameter is NULL.
170 * @exception MSG_ERR_MEMORY_ERROR Memory error.
172 int RegisterMessageCallback(void);
175 * Adds the message requestId/Message Type/Message Event to Message Hash Map table
178 * @return An error code
179 * @param[in] reqId SMS/MMS message requestId
180 * @param[in] msgType message type
181 * @param[in] pEvent message Event
182 * @exception E_SUCCESS The method was successful.
183 * @exception E_INVALID_ARG Input parameter is NULL.
184 * @exception E_OUT_OF_MEMORY Memory error.
186 result AddToMessageMap(int reqId, _MessageType msgType, Tizen::Base::Object* pEvent);
189 * Gets the Message Type and Message Event based on the message requestId. Also removes the Hashmap elements for the requestId
192 * @return An error code
193 * @param[in] reqId SMS/MMS message requestId
194 * @param[in] msgType message type
195 * @param[in] pEvent message Event
196 * @exception E_SUCCESS The method was successful.
197 * @exception E_INVALID_ARG Input parameter is NULL.
198 * @exception E_OUT_OF_MEMORY Memory error.
200 result GetAndRemoveFromMessageMap(int reqId, _MessageType& msgType, Tizen::Base::Object** pEvent);
202 // for SMS and MMS sent status
203 static void SentMessageStatusCallback(msg_handle_t hMsgHandle, msg_struct_t msgStatus, void* pUserParam);
206 static void IncomingSmsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam);
209 * Sets the __incomingSmsCallbackRegistered flag.
212 * @param[in] incomingSmsCallbackRegistered SMS registered flag
214 void SetInComingSmsCallback(bool incomingSmsCallbackRegistered);
217 * Sets the Cbs And Etws UserEvent.
220 * @param[in] msgType message type
221 * @param[in] pEvent message Event
223 void SetCbsAndEtwsUserEvent(_MessageType msgType, Tizen::Base::Object* pEvent);
225 // for incoming CBS/Etws
226 static void IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam);
228 // for incoming Wap push
229 static void IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam);
231 //get cb message language type
232 static Tizen::Base::String GetCbsLanguageType(byte codingScheme);
237 * This is the default constructor for this class.
241 _SmsMmsCallbackHandler(void);
243 result ConvertException(int err) const;
246 static _SmsMmsCallbackHandler* __pMessageCallbackHandler;
247 msg_handle_t __msgHandle;
248 msg_struct_t __cbsSettingsHandle;
249 msg_struct_list_s* __pCbsChannelList;
250 Tizen::Base::Collection::ArrayList* __pTempCbsChannelList;
251 bool __callbackRegistered;
252 bool __incomingSmsCallbackRegistered;
253 Tizen::Base::Collection::MultiHashMap __messageMap;
254 Tizen::Base::Runtime::Mutex __msgMutex;
255 Tizen::Base::Object* __pCbsUserEvent;
256 Tizen::Base::Object* __pEtwsUserEvent;
257 }; // _SmsMmsCallbackHandler
259 } } // Tizen::Messaging
261 #endif // _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_