Initialize Tizen 2.3
[framework/osp/messaging.git] / src / FMsg_SmsMessageImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18  * @file        FMsg_SmsMessageImpl.h
19  * @brief               This is the header file for _SmsMessageImpl class.
20  *
21  * This header file contains the declarations of _SmsMessageImpl class.
22  */
23
24
25 #ifndef _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
26 #define _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_
27
28 // Includes
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"
35
36 namespace Tizen { namespace Messaging
37 {
38
39 // forward declaration
40 class RecipientList;
41 class SmsMessage;
42
43 /**
44 * @class        _SmsMessageImpl
45 * @brief        This class provides methods for handling an SMS message.
46 * @since        1.0
47 *
48 * This class provides methods for handling SMS messages. @n
49 * A user can set and get an SMS body text.
50 */
51 class _SmsMessageImpl
52         : public Tizen::Base::Object
53 {
54         // Life cycle
55 public:
56         /**
57         * This is the default constructor for this class.
58         *
59         * @since        1.0
60         */
61         _SmsMessageImpl(void);
62
63         /**
64         *       This is the destructor for this class.
65         *
66         * @since        1.0
67         */
68         virtual ~_SmsMessageImpl(void);
69
70         /**
71         * This is the copy constructor for this class.
72         *
73         * @since                        1.0
74         * @param[in]    value   An instance of _SmsMessageImpl
75         */
76         _SmsMessageImpl(const _SmsMessageImpl& value);
77
78 public:
79         /**
80         * This assignment operator copies SMS message from the specified instance of _SmsMessageImpl to the calling instance of SmsMessage.
81         *
82         * @since                        1.0
83         * @return                       A reference to this instance
84         * @param[in]    rhs             A reference to the SmsMessage instance to be copied
85         */
86         _SmsMessageImpl& operator =(const _SmsMessageImpl& rhs);
87
88 public:
89         /**
90         *       Gets the hash value of the current instance.
91         *
92         * @since                1.0
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.
96         */
97         virtual int GetHashCode(void) const;
98
99         /**
100         * Compares the specified instance with the calling instance.
101         *
102         * @since                        1.0
103         * @return                       @c true if both instances are equal @n
104         *                                               @c false, otherwise
105         * @param[in]            value           An instance of _SmsMessageImpl
106         */
107         virtual bool Equals(const Tizen::Base::Object& value) const;
108
109         // Operation
110 public:
111         /**
112         * Sets the body of the message.
113         *
114         * @since                        1.0
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).
119         * @see                  GetText()
120         */
121         result SetText(const Tizen::Base::String& text);
122
123         /**
124         * Gets the body text of the message.
125         *
126         * @since                1.0
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()
132         */
133         Tizen::Base::String GetText(void) const;
134
135         /**
136         * Gets the sender address of the message.
137         *
138         * @since                2.0
139         * @privlevel    SYSTEM
140         * @privgroup    http://tizen.org/privilege/messaging.sms
141         *
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.
147         */
148         Tizen::Base::String GetSenderAddress(void) const;
149
150         /**
151         * Gets the received time of the message.
152         *
153         * @since                        2.0
154         * @privlevel    SYSTEM
155         * @privgroup    http://tizen.org/privilege/messaging.sms
156         *
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.
163         */
164         Tizen::Base::DateTime GetReceivedTime(void) const;
165
166         /**
167         * Gets the unique ID of the message.
168         *
169         * @since                2.0
170         * @privlevel    SYSTEM
171         * @privgroup    http://tizen.org/privilege/messaging.sms
172         *
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.
179         */
180         int GetId(void) const;
181
182         /**
183         * Gets the sent time of the message.
184         *
185         * @since                2.0
186         * @privlevel    SYSTEM
187         * @privgroup    http://tizen.org/privilege/messaging.sms
188         *
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.
195         */
196         Tizen::Base::DateTime GetSentTime(void) const;
197
198         /**
199         * Gets the type of the message box.
200         *
201         * @since                2.0
202         * @privlevel    SYSTEM
203         * @privgroup    http://tizen.org/privilege/messaging.sms
204         *
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.
211         */
212         SmsMessageBoxType GetMessageBoxType(void) const;
213
214         /**
215         * Gets the list of the recipients.
216         *
217         * @since                2.0
218         * @privlevel    SYSTEM
219         * @privgroup    http://tizen.org/privilege/messaging.sms
220         *
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.
226         */
227         RecipientList GetRecipientList(void) const;
228
229         /**
230         * Checks whether the message contains more than 160 bytes for the body text.
231         *
232         * @since        2.0
233         *
234         * @privlevel    SYSTEM
235         * @privgroup    http://tizen.org/privilege/messaging.sms
236         *
237         * @return               @c true if this message contains more than 160 bytes for the body text, @n
238         *                               else @c false
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.
244         */
245         bool HasMoreText(void) const;
246
247 //      private:
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);
250
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);
253
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);
256
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);
259
260 public:
261     /**
262      * Gets the Impl instance.
263      *
264      * @since 2.1
265      * @return              The pointer to _SmsMessageImpl
266      * @param[in]   smsMessage            An instance of SmsMessage
267      */
268         static _SmsMessageImpl* GetInstance(SmsMessage& smsMessage);
269
270     /**
271      * Gets the Impl instance.
272      *
273      * @since 2.1
274      * @return              The pointer to  _SmsMessageImpl
275      * @param[in]   smsMessage     An instance of SmsMessage
276      */
277         static const _SmsMessageImpl* GetInstance(const SmsMessage& smsMessage);
278
279
280 private:
281         Tizen::Base::String __text;
282         int __messageId;
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)
288
289         friend class SmsMessage;
290 }; // _SmsMessageImpl
291 } }
292
293 #endif // _FMSG_INTERNAL_SMS_MESSAGE_IMPL_H_