Update change log and spec for wrt-plugins-tizen_0.2.73
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Messaging / Sms.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 /**
19  *
20  *
21  * @file       Sms.h
22  * @author     Pawel Misiak (p.misiak@samsung.com)
23  * @version    0.1
24  * @brief
25  */
26 #ifndef SMS_H
27 #define SMS_H
28
29 #include <API/Messaging/ISms.h>
30 #include "ISendingObserver.h"
31 #include <queue>
32
33 extern "C" {
34 #include <msg_transport.h>
35 #include <msg.h>
36 }
37
38 namespace TizenApis {
39 namespace Platform {
40 namespace Messaging {
41
42 class Sms : public Api::Messaging::ISms,
43     public ISendingObserver,
44         public DPL::Event::Controller<DPL::TypeListDecl<int>::Type >
45 {
46   public:
47     explicit Sms(const std::string& id = "");
48
49     explicit Sms(const std::string& id, const msg_struct_t msg_data);
50
51     virtual ~Sms();
52
53     // implementation of interface of IMessage class
54     virtual void update(bool draftsOnly = false);
55
56     virtual void readAllData();
57
58     virtual void moveToFolder(const Api::Messaging::FolderType newFolder);
59
60     virtual void moveToFolder(const std::string& newFolder);
61
62     virtual void copyToFolder(const Api::Messaging::FolderType newFolder);
63
64     virtual void copyToFolder(const std::string& newFolder);
65
66     virtual void remove();
67
68     virtual int send();
69
70     virtual void sendCancel(int handle)
71     {
72     }
73
74     virtual void sendingCallback(msg_struct_t sent_status);
75
76     virtual void OnEventReceived(const int& /*event*/);
77
78     static Api::Messaging::FolderType toFolder(const std::string &folder);
79
80   private:
81     void sendSubMessage();
82
83     void setSendingStatusOk(const std::string &recipient = std::string());
84
85     void setSendingStatusFailed(const std::string &recipient = std::string());
86
87     void createNewMessage();
88
89     void readExistingMessage();
90
91     void updateBody();
92
93     void updateTo();
94
95     void updateFrom();
96
97     void updateSourceAddress();
98
99     void updateReadStatus();
100
101     void updateIsRead();
102
103     void updateMessage();
104         
105     void addMessageToDraft();
106
107     void createSendMessage();
108
109     void readRecipientList(msg_struct_t& messageData);
110
111     void readBody(msg_struct_t& messageData);
112
113     void readFolder(msg_struct_t& messageData);
114
115     void readDateTime(msg_struct_t& messageData);
116
117     void readReadStatus(msg_struct_t& messageData);
118
119     void readSize(msg_struct_t& messageData);
120
121     std::queue<msg_struct_t>& currentQueue()
122     {
123         return m_sendRequests.front().queue;
124     }
125
126     msg_struct_t createNewCopyOfPLatformMsg(const msg_struct_t src) const;
127
128   private:
129     msg_struct_t m_messageData;
130     bool m_sendingFailed;
131     DPL::Mutex m_mutex;
132
133     struct SendRequest
134     {
135         // queue of sub messages for each recipient
136         std::queue<msg_struct_t> queue;
137         bool failed;
138
139         SendRequest() : failed(false)
140         {
141         }
142     };
143     // queue of send requests
144     std::queue<SendRequest> m_sendRequests;
145 };
146 }
147 }
148 }
149 #endif