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_SmsManagerImpl.h
19 * @brief This is the header file for the _SmsManagerImpl class.
21 * This header file contains the declarations of the _SmsManagerImpl class.
24 #ifndef _FMSG_INTERNAL_SMS_MANAGER_IMPL_H_
25 #define _FMSG_INTERNAL_SMS_MANAGER_IMPL_H_
27 #include "FMsg_Types.h"
29 namespace Tizen { namespace Messaging
33 * @class _SmsManagerImpl
34 * @brief This class provides methods to use the SMS messaging service.
37 * This class provides methods to use the SMS messaging service. @n
40 // forward declaration
45 : public Tizen::Base::Object
50 * This is the default constructor for this class.
52 _SmsManagerImpl(void);
55 * This is the destructor for this class.
57 virtual ~_SmsManagerImpl(void);
60 _SmsManagerImpl(const _SmsManagerImpl& value);
61 _SmsManagerImpl& operator =(const _SmsManagerImpl& rhs);
67 * Initializes this instance of _SmsManagerImpl with the specified listener.
69 * @return An error code
70 * @param[in] listener The listener to receive a send result asynchronously
71 * @exception E_SUCCESS The method was successful.
73 result Construct(const ISmsListener& listener);
76 * Adds the event listener for receiving SMS messages.
78 * @return An error code
79 * @param[in] port A port number
80 * @param[in] eventListener The listener to receive SMS messages
81 * @exception E_SUCCESS The method was successful.
82 * @exception E_OBJ_ALREADY_EXIST The port number was already registered.
83 * @exception E_FAILURE The port number was already used in other applications.
84 * @exception E_INVALID_ARG The value of the specified @c port is invalid. @n
85 * The port number should range from 1 to 9999 (1 <= port <= 9999).
86 * @see ISmsEventListener, RemoveSmsEventListener()
88 result AddSmsEventListener(int port, ISmsEventListener& eventListener);
91 * Removes the event listener for receiving SMS messages.
93 * @return An error code
94 * @param[in] port A port number
95 * @param[in] eventListener The listener to receive SMS messages
96 * @exception E_SUCCESS The method was successful.
97 * @exception E_OBJ_NOT_FOUND The listener was not found.
98 * @exception E_SYSTEM A system error occurred.
99 * @exception E_INVALID_ARG The value of the specified @c port is invalid. @n
100 * The port number should range from 1 to 9999 (1 <= port <= 9999).
101 * @see ISmsEventListener, AddSmsEventListener()
103 result RemoveSmsEventListener(int port, ISmsEventListener& eventListener);
106 * Adds the event listener for receiving SMS messages.
108 * @return An error code
109 * @param[in] eventListener The listener to receive SMS messages
110 * @exception E_SUCCESS The method was successful.
111 * @exception E_OUT_OF_MEMORY Insufficient memory.
112 * @see ISmsMessageEventListener, RemoveSmsMessageEventListener()
114 result AddSmsMessageEventListener(const ISmsMessageEventListener& eventListener);
117 * Removes the event listener for receiving SMS messages.
119 * @return An error code
120 * @param[in] eventListener The listener to receive SMS messages
121 * @exception E_SUCCESS The method was successful.
122 * @exception E_OBJ_NOT_FOUND The listener was not found.
123 * @exception E_SYSTEM A system error occurred.
124 * @see ISmsMessageEventListener, AddSmsMessageEventListener()
126 result RemoveSmsMessageEventListener(const ISmsMessageEventListener& eventListener);
129 * Sends the SMS message.
131 * @return An error code
132 * @param[in] message The message to be sent
133 * @param[in] recipientList The list of recipients
134 * @param[in] saveToSentBox Set to @c true to save the message in the Sentbox, @n
136 * @exception E_SUCCESS The method was successful.
137 * @exception E_ON_INITIALIZING The mailbox is not completely loaded yet.
138 * @exception E_STORAGE_FULL The storage is full.
139 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
140 * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
141 * @exception E_INVALID_ADDRESS The address is invalid.
142 * @exception E_FDN_MODE The FDN mode has been activated.
143 * @exception E_INVALID_ARG The number of recipients is @c 0.
144 * @exception E_MAX_EXCEEDED The number of recipients crossed the limit (Maximum 10).
145 * @see ISmsListener::OnSmsMessageSent()
147 result Send(const SmsMessage& message, const RecipientList& recipientList, bool saveToSentBox);
150 * Gets the total number of SMS messages in the specified message box.
152 * @return The total number of SMS messages in the specified message box
153 * @param[in] type The type of message box
154 * @exception E_SUCCESS The method was successful.
155 * @exception E_INVALID_ARG The value of specified @c type is invalid.
156 * @exception E_SYSTEM A system error occurred.
157 * @remarks In case of an error, this method returns the negative value (-1).
158 * @remarks The specific error code can be accessed using the GetLastResult() method.
160 int GetTotalMessageCount(SmsMessageBoxType type) const;
163 * Searches the SMS messages by keyword and|or sender address in the Inbox.
165 * @return The list of the SmsMessage class instances
166 * @param[in] pKeyword A part of the body text as a keyword (partial match) @n
167 * In case of @c null or an empty string, this method searches all SMS messages in the Inbox regardless of the keyword.
168 * @param[in] pSenderAddress A telephone number as a sender address (exact match) @n
169 * In case of @c null or an empty string, this method searches all SMS messages in the Inbox regardless of the sender address.
170 * @param[in] startIndex The start index (base 0)
171 * @param[in] count The count of SMS messages to search
172 * @param[out] totalResultCount The total count of the searched result
173 * @exception E_SUCCESS The method was successful.
174 * @exception E_INVALID_ARG Either of the following of the conditions has occurred: @n
175 * -- The specified @c pKeyword string length is less than @c 2 or greater than @c 30. @n
176 * -- The specified @c pSenderAddress string length is less than @c 3 or greater than @c 41. @n
177 * -- The specified @c startIndex value is less than @c o. @n
178 * -- The specified @c count value is less than @c 0 or greater than @c 20.
179 * @exception E_SYSTEM A system error occurred.
180 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
181 * @remarks The search with the specified keywords searches using only the first 50 characters of the body text.
182 * @remarks The SMS messages in the searched result contain only 160 bytes for the body text. @n
183 * To check whether there is additional text, use the SmsMessage::HasMoreText() method. @n
184 * To get the full body text, use GetFullText() with its message ID.
185 * @see SmsMessage, GetFullText()
187 Tizen::Base::Collection::IList* SearchInboxN(const Tizen::Base::String* pKeyword, const Tizen::Base::String* pSenderAddress, int startIndex, int count, int& totalResultCount) const;
190 * Searches the SMS messages by keyword in the specified message box.
192 * @return The list of the SmsMessage class instances
193 * @param[in] type The type of message box
194 * @param[in] pKeyword A part of the body text as a keyword (partial match) @n
195 * In case of @c null or an empty string, this method searches all SMS messages in the specified message box.
196 * @param[in] startIndex The start index (base 0)
197 * @param[in] count The count of SMS messages to search
198 * @param[out] totalResultCount The total count of the searched result
199 * @exception E_SUCCESS The method was successful.
200 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
201 * -- The value of specified @c type is invalid. @n
202 * -- The specified @c pKeyword string length is less than @c 2 or greater than @c 30. @n
203 * -- The specified @c startIndex value is less than @c 0. @n
204 * -- The specified @c count value is less than @c 0 or greater than @c 20.
205 * @exception E_SYSTEM A system error occurred.
206 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
207 * @remarks The search with the specified keywords searches using only the first 50 characters of the body text.
208 * @remarks The SMS messages in the searched result contain only 160 bytes for the body text. @n
209 * To check whether there is additional text, use the SmsMessage::HasMoreText() method. @n
210 * To get the full body text, use the GetFullText() method with its message ID.
211 * @see SmsMessage, GetFullText()
213 Tizen::Base::Collection::IList* SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::String* pKeyword, int startIndex, int count, int& totalResultCount) const;
216 * Gets the full text of the SMS message in the message box using the message ID.
218 * @return The full text of the specified SMS message
219 * @param[in] messageId The unique ID of the message
220 * @exception E_SUCCESS The method was successful.
221 * @exception E_INVALID_ARG The value of the specified @c messageId is invalid, or @c messageId should be greater than or equal to @c 0.
222 * @exception E_OBJ_NOT_FOUND The SMS message with the specified @c messageId was not found.
223 * @exception E_SYSTEM A system error occurred.
224 * @remarks The specific error code can be accessed using the GetLastResult() method.
225 * @remarks In case of an error, this method returns an empty string.
226 * @see SmsMessage::HasMoreText()
228 Tizen::Base::String GetFullText(int messageId) const;
231 * Sets the event listener for receiving CB messages.
233 * @return An error code
234 * @param[in] pListener The listener to receive CB messages
235 * @exception E_SUCCESS The method is successful.
236 * @exception E_SYSTEM A system error has occurred.
237 * @see ICbsMessageEventListener
239 result SetCbsMessageEventListener(ICbsMessageEventListener* pListener);
242 * Sets the event listener for receiving ETWS primary notification.
244 * @return An error code
245 * @param[in] pListener The listener to receive ETWS primary notification
246 * @exception E_SUCCESS The method is successful.
247 * @exception E_SYSTEM A system error has occurred.
248 * @see IEtwsPrimaryNotificationEventListener
250 result SetEtwsPrimaryNotificationEventListener(IEtwsPrimaryNotificationEventListener* pListener);
253 * Enables or disables the save option for CBS message to the CbsBox
255 * @return An error code
256 * @param[in] enable Set to @c true to save the message in the CbsBox, @n
258 * @exception E_SUCCESS The method is successful.
259 * @exception E_SYSTEM A system error has occurred.
261 result SetSavingToCbsBoxEnabled(bool enable);
264 * Checks whether the CB service is enabled.
266 * @return @c true if the CB service is enabled, @n
268 * @see SetCbsEnabled()
270 bool IsCbsEnabled(void) const;
273 * Enables or disables the CB service.
275 * @return An error code
276 * @param[in] enable Set to @c true to enable the CB service, @n
278 * @exception E_SUCCESS The method is successful.
279 * @exception E_SYSTEM A system error has occurred.
280 * @see IsCbsEnabled()
282 result SetCbsEnabled(bool enable);
285 * Adds a CBS channel with specified parameters.
287 * @return An error code
288 * @param[in] from The starting index of the message ID of the channel.
289 * @param[in] to The last index of the message ID of the channel.
290 * @param[in] name The name of the channel. (can be an empty string)
291 * @param[in] activate Set to @c true to activate the channel, @n
293 * @exception E_SUCCESS The method is successful.
294 * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n
295 * The specified @c to or @c from parameter is a negative value. @n
296 * The specified @c to parameter exceeds the limit (0xFFFF). @n
297 * The range (@c to - @c from) exceeds the limit (0xFFFF).
298 * The specified @c name string length is greater than @c 32. @n
299 * @exception E_ALREADY_SET The channel range (@c from ~ @c to) is already set.
300 * @exception E_ILLEGAL_ACCESS The application does not have the permission to add the CBS channel.
301 * @exception E_SYSTEM A system error has occurred.
302 * @see RemoveCbsChannel()
304 result AddCbsChannel(int from, int to, Tizen::Base::String& name, bool activate = true);
307 * Removes a CBS channel.
309 * @return An error code
310 * @param[in] from The starting index of the message ID of the channel.
311 * @param[in] to The last index of the message ID of the channel.
312 * @exception E_SUCCESS The method is successful.
313 * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n
314 * The specified @c to or @c from parameter is a negative value. @n
315 * The specified @c to parameter exceeds the limit (0xFFFF). @n
316 * The range (@c to - @c from) exceeds the limit (0xFFFF).
317 * @exception E_OBJ_NOT_FOUND The channel range (@c from ~ @c to) is not found.
318 * @exception E_ILLEGAL_ACCESS The application does not have the permission to remove the CBS channel.
319 * @exception E_SYSTEM A system error has occurred.
320 * @see AddCbsChannel()
322 result RemoveCbsChannel(int from, int to);
325 * Gets a CBS channel with specified range.
327 * @return A pointer to the CBS channel with specific range.
328 * @param[in] from The starting index of the message ID of the channel.
329 * @param[in] to The last index of the message ID of the channel.
330 * @exception E_SUCCESS The method is successful.
331 * @exception E_INVALID_ARG The specified @c to parameter is smaller than @c from. @n
332 * The specified @c to or @c from parameter is a negative value. @n
333 * The specified @c to parameter exceeds the limit (0xFFFF). @n
334 * The range (@c to - @c from) exceeds the limit (0xFFFF).
335 * @exception E_SYSTEM A system error has occurred.
336 * @remarks The specific error code can be accessed using the GetLastResult() method.
337 * @see AddCbsChannel(), RemoveCbsChannel()
339 CbsChannel* GetCbsChannelN(int from, int to) const;
342 * Gets the CBS channel list.
344 * @return A pointer to the list of CBS channel
345 * @exception E_SUCCESS The method is successful.
346 * @exception E_SYSTEM A system error has occurred.
347 * @remarks The specific error code can be accessed using the GetLastResult() method.
348 * @see AddCbsChannel(), RemoveCbsChannel(), CbsChannel
350 Tizen::Base::Collection::IList* GetCbsChannelListN(void);
354 * Gets the Impl instance.
356 * @return The pointer to _SmsManagerImpl
357 * @param[in] smsManager An instance of SmsManager
359 static _SmsManagerImpl* GetInstance(SmsManager& smsManager);
362 * Gets the Impl instance.
364 * @return The pointer to _SmsManagerImpl
365 * @param[in] smsManager An instance of SmsManager
367 static const _SmsManagerImpl* GetInstance(const SmsManager& smsManager);
371 result ConvertException(int err) const;
374 bool __isConstructed;
375 bool __isCbsSaveEnabled;
376 std::unique_ptr<_SmsEvent> __pSmsEvent;
377 _SmsEvent* __pSmsReceiveEvent;
378 _SmsEvent* __pCbsReceiveEvent;
379 _SmsEvent* __pEtwsReceiveEvent;
380 Tizen::Base::Collection::ArrayList* __pSmsTriggerEventList;
381 msg_handle_t __msgHandle;
382 msg_struct_t __cbsSettingsHandle;
383 ICbsMessageEventListener* __pCbsListener;
384 IEtwsPrimaryNotificationEventListener* __pEtwsListener;
385 }; // _SmsManagerImpl
386 } } // Tizen::Messaging
388 #endif // _FMSG_INTERNAL_SMS_MANAGER_IMPL_H_