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_SmsMessageImpl.h
19 * @brief This is the header file for _SmsMessageImpl class.
21 * This header file contains the declarations of _SmsMessageImpl class.
25 #ifndef _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
26 #define _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
29 #include <FBaseObject.h>
30 #include <FBaseString.h>
31 #include <FBaseDateTime.h>
32 #include <FMsgTypes.h>
33 #include <FMsgRecipientList.h>
34 #include "FMsg_Types.h"
36 namespace Tizen { namespace Messaging
39 // forward declaration
44 * @class _SmsMessageImpl
45 * @brief This class provides methods for handling an SMS message.
48 * This class provides methods for handling SMS messages. @n
49 * A user can set and get an SMS body text.
52 : public Tizen::Base::Object
57 * This is the default constructor for this class.
61 _SmsMessageImpl(void);
64 * This is the destructor for this class.
68 virtual ~_SmsMessageImpl(void);
71 * This is the copy constructor for this class.
74 * @param[in] value An instance of _SmsMessageImpl
76 _SmsMessageImpl(const _SmsMessageImpl& value);
80 * This assignment operator copies SMS message from the specified instance of _SmsMessageImpl to the calling instance of SmsMessage.
83 * @return A reference to this instance
84 * @param[in] rhs A reference to the SmsMessage instance to be copied
86 _SmsMessageImpl& operator =(const _SmsMessageImpl& rhs);
90 * Gets the hash value of the current instance.
93 * @return The hash value of the current instance
94 * @remarks Two equal instances should return the same hash value. For better performance,
95 * the used hash function must generate a random distribution for all inputs.
97 virtual int GetHashCode(void) const;
100 * Compares the specified instance with the calling instance.
103 * @return @c true if both instances are equal @n
104 * @c false, otherwise
105 * @param[in] value An instance of _SmsMessageImpl
107 virtual bool Equals(const Tizen::Base::Object& value) const;
112 * Sets the body of the message.
115 * @return An error code
116 * @param[in] text The body text of the message
117 * @exception E_SUCCESS The method was successful.
118 * @exception E_MAX_EXCEEDED The body length of the message is exceeding the maximum limit (Maximum 80 characters).
121 result SetText(const Tizen::Base::String& text);
124 * Gets the body text of the message.
127 * @return The body text of the message
128 * @remarks If the message is from the Inbox, Sentbox, or Outbox, it may contain only 160 bytes for the body text. @n
129 * To check whether the message contains more than 160 bytes for the body text, use the HasMoreText() method.
130 * To get the full body text, use the SmsManager::GetFullText() method with its message ID.
131 * @see SetText(), HasMoreText(), GetId(), SmsManager::GetFullText()
133 Tizen::Base::String GetText(void) const;
136 * Gets the sender address of the message.
140 * @privgroup http://tizen.org/privilege/messaging.sms
142 * @return The sender address of the message
143 * @exception E_SUCCESS The method was successful.
144 * @exception E_INVALID_OPERATION This operation is only allowed to the incoming message or the message from the Inbox.
145 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
146 * @remarks The specific error code can be accessed using the GetLastResult() method.
148 Tizen::Base::String GetSenderAddress(void) const;
151 * Gets the received time of the message.
155 * @privgroup http://tizen.org/privilege/messaging.sms
157 * @return The received time of the message
158 * @exception E_SUCCESS The method was successful.
159 * @exception E_INVALID_OPERATION This operation is only allowed to the incoming message or the message from the Inbox.
160 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
161 * @remarks The specific error code can be accessed using the GetLastResult() method.
162 * @remarks In case of an error, this method returns the instance denoting 00:00:00, January 1, 1.
164 Tizen::Base::DateTime GetReceivedTime(void) const;
167 * Gets the unique ID of the message.
171 * @privgroup http://tizen.org/privilege/messaging.sms
173 * @return The unique ID of the message
174 * @exception E_SUCCESS The method was successful.
175 * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
176 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
177 * @remarks In case of an error, this method returns the negative value (-1).
178 * @remarks The specific error code can be accessed using the GetLastResult() method.
180 int GetId(void) const;
183 * Gets the sent time of the message.
187 * @privgroup http://tizen.org/privilege/messaging.sms
189 * @return The sent time of the message
190 * @exception E_SUCCESS The method was successful.
191 * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Sentbox or Outbox.
192 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
193 * @remarks The specific error code can be accessed using the GetLastResult() method.
194 * @remarks In case of an error, this method returns the instance denoting 00:00:00, January 1, 1.
196 Tizen::Base::DateTime GetSentTime(void) const;
199 * Gets the type of the message box.
203 * @privgroup http://tizen.org/privilege/messaging.sms
205 * @return The type of the message box
206 * @exception E_SUCCESS The method was successful.
207 * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
208 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
209 * @remarks In case of an error, this method returns the SMS_MESSAGE_BOX_TYPE_NONE value.
210 * @remarks The specific error code can be accessed using the GetLastResult() method.
212 SmsMessageBoxType GetMessageBoxType(void) const;
215 * Gets the list of the recipients.
219 * @privgroup http://tizen.org/privilege/messaging.sms
221 * @return The list of the recipient
222 * @exception E_SUCCESS The method was successful.
223 * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Sentbox or Outbox.
224 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
225 * @remarks The specific error code can be accessed using the GetLastResult() method.
227 RecipientList GetRecipientList(void) const;
230 * Checks whether the message contains more than 160 bytes for the body text.
235 * @privgroup http://tizen.org/privilege/messaging.sms
237 * @return @c true if this message contains more than 160 bytes for the body text, @n
239 * @exception E_SUCCESS The method was successful.
240 * @exception E_INVALID_OPERATION This operation is allowed only when the message is from the Inbox, Sentbox, or Outbox.
241 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
242 * @remarks If the return value is @c true, the SMS message contains more than 160 bytes for the body text. To get the full body text, use SmsManager::GetFullText().
243 * @remarks The specific error code can be accessed using the GetLastResult() method.
245 bool HasMoreText(void) const;
248 // private - used only for the incoming message
249 void SetIncomingMessage(const Tizen::Base::String& text, const Tizen::Base::String& senderAddress, const Tizen::Base::DateTime& receivedTime);
251 // private - used only for the messages in the inbox
252 void SetInboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText, const Tizen::Base::String& senderAddress, const Tizen::Base::DateTime& receivedTime);
254 // private - used for the messages in the sentbox or outbox
255 void SetSentboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText, const Tizen::Messaging::RecipientList& recipientList, const Tizen::Base::DateTime& sentTime);
257 // private - used for the messages in the sentbox or outbox
258 void SetOutboxMessage(int messageId, const Tizen::Base::String& text, bool hasMoreText, const Tizen::Messaging::RecipientList& recipientList, const Tizen::Base::DateTime& sentTime);
262 * Gets the Impl instance.
265 * @return The pointer to _SmsMessageImpl
266 * @param[in] smsMessage An instance of SmsMessage
268 static _SmsMessageImpl* GetInstance(SmsMessage& smsMessage);
271 * Gets the Impl instance.
274 * @return The pointer to _SmsMessageImpl
275 * @param[in] smsMessage An instance of SmsMessage
277 static const _SmsMessageImpl* GetInstance(const SmsMessage& smsMessage);
281 Tizen::Base::String __text;
283 SmsMessageBoxType __messageBoxType;
284 Tizen::Base::DateTime __time; // received or sent time
285 Tizen::Base::String __senderAddress; // for receiving a message and retrieving an inbox
286 RecipientList __recipientList; // for retrieving sentbox and outbox
287 bool __hasMoreText; // for checking the SMS message has more text or not. (currently the size retrieved SMS message limited to 160 bytes)
289 friend class SmsMessage;
290 }; // _SmsMessageImpl
293 #endif // _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_