2 * Copyright (c) 2011 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.
20 * @author Pawel Misiak (p.misiak@samsung.com)
29 #include <dpl/shared_ptr.h>
30 #include <dpl/enable_shared_from_this.h>
31 #include "IMessagingTypes.h"
32 #include "ToRecipient.h"
35 #include "SourceAddress.h"
36 #include "MessagePriority.h"
37 #include "CallbackNumber.h"
38 #include "ValidityPeriodHours.h"
40 #include "EventOnSendingFailed.h"
42 namespace WrtDeviceApis {
45 class EventSendMessage;
46 typedef DPL::SharedPtr<EventSendMessage> EventSendMessagePtr;
48 //--------------------------------------------------------------------------
51 typedef DPL::SharedPtr<IMessage> IMessagePtr;
53 //--------------------------------------------------------------------------
55 class ReqReceiverMessage;
57 //--------------------------------------------------------------------------
60 public DPL::EnableSharedFromThis<IMessage>,
65 public MessagePriority,
66 public CallbackNumber,
67 public ValidityPeriodHours,
80 const MessageType m_msgType;
83 * Message creation date time
93 * Read status validity.
95 bool m_validReadStatus;
98 * Message size in bytes
103 * Message current folder
110 std::string m_userFolderName;
113 * Event emitter. Used when there is one global callback function
115 EventOnSendingFailedEmitterPtr m_emitter;
118 * Request receiver. Used when there are callback funtions assigned at function executing scope
120 ReqReceiverMessage *m_requestReceiver;
123 * SendMessage event. Used when there are callback funtions assigned at function executing scope
125 EventSendMessagePtr m_sendMessageEvent;
128 void setSize(int size);
133 * constructor of abstraction message
134 * @param[in] msgType - type of message according to MessageType
135 * @param[in] id - id of message, if id is empty, new message will be
136 * created, othercase message will be read from low
139 explicit IMessage(const MessageType msgType,
140 const std::string& id = "");
145 * method is used to send message specyfied type
146 * @throw PlatformException Thrown when sending fail
148 virtual void send() = 0;
151 * method is used to cancel sending message
152 * @throw PlatformException Thrown when sending fail
154 virtual void sendCancel() = 0;
157 * method used to update all fields in lower level
158 * @param[in] draftsOnly - if true only draft messages can be
159 * fully updated. Other messages can only have read flag changed
160 * @throw PlatformException Thrown when update fail
162 virtual void update(bool draftsOnly = false) = 0;
165 * method used to read all data from low level message
166 * @throw PlatformException Thrown when reading message fail
168 virtual void readAllData() = 0;
171 * method used to get current storage folder
173 virtual FolderType getCurrentFolder() const;
176 * method used to get current user folder name
178 virtual std::string getCurrentUserFolder() const;
181 * method used to set current user folder name
183 void setCurrentUserFolder(const std::string& arg);
186 * method used to move message to new folder
187 * @param[in] newFolder - destination folder
188 * @throw PlatformException Thrown when move message to folder fail
190 virtual void moveToFolder(const FolderType newFolder) = 0;
193 * method used to move message to user defined new folder
194 * @param[in] newFolder - users destination folder
195 * @throw PlatformException Thrown when move message to folder fail
197 virtual void moveToFolder(const std::string& newFolder) = 0;
200 * method used to copy message to new folder (create new message with
202 * @param[in] newFolder - destination folder
203 * @throw PlatformException Thrown when copy message to folder fail
205 virtual void copyToFolder(const FolderType newFolder) = 0;
208 * method used to copy message to user defined new folder
209 * @param[in] newFolder - users destination folder
210 * @throw PlatformException Thrown when move message to folder fail
212 virtual void copyToFolder(const std::string& newFolder) = 0;
215 * method used to identify message type
217 MessageType getMessageType() const;
220 * method used to get message id
222 std::string getId() const;
225 * method used to get message size
230 * method used to get message id
232 virtual const std::string& getIdRef() const;
235 * used for get tm struct
237 struct tm getDateTime() const;
240 * Is message already been read
242 virtual bool isRead() const;
245 * Is message already been read
247 virtual void setReadStatus(bool state);
250 * Returns true if read status is valid
252 bool isReadStatusValid() const;
255 * Sets read status validity
257 void setReadStatusValidity(bool valid);
261 * @throw PlatformException Thrown when remove message fail
263 virtual void remove() = 0;
266 * convert id from int to string
268 virtual std::string convertId(int arg) const;
271 * convert id from string to int
273 virtual int convertId(const std::string& arg) const;
278 void setId(const std::string& id);
283 void setDateTime(const tm dateTime);
288 virtual void setFolderType(FolderType folder);
291 * validate phone number, if fail return false
292 * if number contains wrong characters, then cut them
294 bool validatePhoneNumber(std::string& number);
297 * validate email address, if fail return false
299 bool validateEmailAddr(const Recipients& addr);
302 * validate email address, if fail return false
304 bool validateEmailAddr(const std::string& email);
309 void setEmitter(const EventOnSendingFailedEmitterPtr& emitter);
314 EventOnSendingFailedEmitterPtr getEmitter() const;
316 void setSendMessageEvent(const EventSendMessagePtr &event);
318 EventSendMessagePtr getSendMessageEvent() const;
320 void setRequestReceiver(ReqReceiverMessage* reqReceiver);
322 ReqReceiverMessage* getRequestReceiver() const;