b9ee5f14d5afbbe3055626e9f61618fcd8880e5f
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Messaging / Email.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       Email.h
22  * @author     Pawel Misiak (p.misiak@samsung.com)
23  * @version    0.1
24  * @brief
25  */
26 #ifndef EMAIL_H
27 #define EMAIL_H
28
29 #include <string>
30 #include <dpl/mutex.h>
31 #include <API/Messaging/IEmail.h>
32 #include <API/Messaging/IMessagingTypes.h>
33 #include <API/Messaging/EmailAccountInfo.h>
34
35 #include "ScopedMail.h"
36 #include "ScopedMailbox.h"
37
38 // The email service library
39 extern "C" {
40 //temporary solution for email-service problem (compilation break)
41 #ifndef NOW_REVERT
42 //#define NOW_REVERT
43 #endif
44 #ifndef SUPPORT_CONTACT_ON_SIM
45 //#define SUPPORT_CONTACT_ON_SIM
46 #endif
47 #ifndef _A_PROJECT_
48 #define _A_PROJECT_
49 #endif
50
51 #ifndef _PREVIEW_IN_MAILIST
52 #define _PREVIEW_IN_MAILIST
53 #endif
54 }
55
56 namespace TizenApis {
57 namespace Platform {
58 namespace Messaging {
59
60 class Email : public Api::Messaging::IEmail
61 {
62   public:
63     explicit Email(const std::string& id = std::string());
64
65     explicit Email(const std::string& id, int accountId);
66
67     explicit Email( Api::Messaging::EmailAccountInfo& account);
68
69     virtual ~Email();
70
71     virtual int send();
72
73     virtual void sendCancel(int handle);
74
75         virtual int downloadBody();
76
77         virtual void downloadBodyCancel( int handle );
78
79         virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment);
80
81     // implementation of interface of IMessage class
82     virtual void update(bool draftsOnly = false);
83
84     virtual void readAllData();
85
86     virtual void moveToFolder(const Api::Messaging::FolderType newFolder);
87
88     virtual void moveToFolder(const std::string& newFolder);
89
90     virtual void copyToFolder(const Api::Messaging::FolderType newFolder);
91
92     virtual void copyToFolder(const std::string& newFolder);
93
94     virtual void remove();
95
96     virtual int getAccountID();
97
98     virtual int getUID();
99
100     virtual int isBodyDownloaded();
101
102   private:
103     void create();
104
105     void create( Api::Messaging::EmailAccountInfo& account );
106
107     void reload();
108
109     void readHeader();
110
111     void readBody();
112
113     void readInfo();
114
115     void updateBody();
116
117     void updateRecipients();
118
119     void updateFrom();
120         
121     void updateAttachments();
122
123     void updateSubject();
124
125     void updateReadStatus();
126
127     void updateIsRead();
128         
129     void addMessageToDraft();
130         
131     void updatePriority();
132
133     int getIntId() const;
134
135   private:
136     DPL::Mutex m_updateMutex;
137     int m_accountId;
138     ScopedMail m_mail;
139     ScopedMailbox m_mailbox;
140 };
141 }
142 }
143 }
144 #endif