tizen beta release
[framework/web/wrt-plugins-common.git] / src / modules / 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  * @file       Sms.h
20  * @author     Pawel Misiak (p.misiak@samsung.com)
21  * @version    0.1
22  * @brief
23  */
24 #ifndef SMS_H
25 #define SMS_H
26
27 #include <API/Messaging/ISms.h>
28 #include "ISendingObserver.h"
29 #include <queue>
30
31 extern "C" {
32 #include <MapiTransport.h>
33 #include <MapiControl.h>
34 }
35
36 namespace WrtDeviceApis {
37 namespace Messaging {
38 class Sms : public Api::ISms,
39     public ISendingObserver,
40     public DPL::Event::Controller<DPL::TypeListDecl<int>::Type >
41 {
42   public:
43     explicit Sms(const std::string& id = "");
44
45     virtual ~Sms();
46
47     // implementation of interface of IMessage class
48     virtual void update(bool draftsOnly = false);
49
50     virtual void readAllData();
51
52     virtual void moveToFolder(const Api::FolderType newFolder);
53
54     virtual void moveToFolder(const std::string& newFolder);
55
56     virtual void copyToFolder(const Api::FolderType newFolder);
57
58     virtual void copyToFolder(const std::string& newFolder);
59
60     virtual void remove();
61
62     virtual void send();
63
64     virtual void sendCancel()
65     {
66     }
67
68     virtual void sendingCallback(MSG_SENT_STATUS_S *sent_status);
69
70     virtual void OnEventReceived(const int& /*event*/);
71
72     static Api::FolderType toFolder(const std::string &folder);
73
74   private:
75     void sendSubMessage();
76
77     void setSendingStatusOk();
78
79     void setSendingStatusFailed();
80
81     void createNewMessage();
82
83     void readExistingMessage();
84
85     void updateBody();
86
87     void updateTo();
88
89     void updateFrom();
90
91     void updateSourceAddress();
92
93     void updateReadStatus();
94
95     void readRecipientList(msg_message_t& messageData);
96
97     void readBody(msg_message_t& messageData);
98
99     void readFolder(msg_message_t& messageData);
100
101     void readDateTime(msg_message_t& messageData);
102
103     void readReadStatus(msg_message_t& messageData);
104
105     void readSize(msg_message_t& messageData);
106
107     std::queue<msg_message_t>& currentQueue()
108     {
109         return m_sendRequests.front().queue;
110     }
111
112     msg_message_t createNewCopyOfPLatformMsg(const msg_message_t src) const;
113
114   private:
115     msg_message_t m_messageData;
116     bool m_sendingFailed;
117     DPL::Mutex m_mutex;
118
119     struct SendRequest
120     {
121         // queue of sub messages for each recipient
122         std::queue<msg_message_t> queue;
123         bool failed;
124
125         SendRequest() : failed(false)
126         {
127         }
128     };
129     // queue of send requests
130     std::queue<SendRequest> m_sendRequests;
131 };
132 }
133 }
134
135 #endif