502a9aef0dd3df17032dcc91e430450c282287fc
[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     explicit Email(const Api::Messaging::FolderType folder);    
70
71     virtual ~Email();
72
73     virtual int send();
74
75     virtual void sendCancel(int handle);
76
77         virtual int downloadBody();
78
79         virtual void downloadBodyCancel( int handle );
80
81         virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment);
82
83     // implementation of interface of IMessage class
84     virtual void update(bool draftsOnly = false);
85
86     virtual void readAllData();
87
88     virtual void moveToFolder(const Api::Messaging::FolderType newFolder);
89
90     virtual void moveToFolder(const std::string& newFolder);
91
92     virtual void copyToFolder(const Api::Messaging::FolderType newFolder);
93
94     virtual void copyToFolder(const std::string& newFolder);
95
96     virtual void remove();
97
98     virtual int getAccountID();
99
100     virtual int getUID();
101
102     virtual int isBodyDownloaded();
103
104     virtual bool hasAttachment();
105
106   private:
107     void create();
108
109     void create( Api::Messaging::EmailAccountInfo& account );
110
111     void reload();
112
113     void readHeader();
114
115     void readBody();
116
117     void readInfo();
118
119     void updateBody();
120
121     void updateRecipients();
122
123     void updateFrom();
124         
125     void updateAttachments();
126
127     void updateSubject();
128
129     void updateReadStatus();
130
131     void updateIsRead();
132         
133     void addMessageToDraft();
134         
135     void updatePriority();
136
137     int getIntId() const;
138
139   private:
140     DPL::Mutex m_updateMutex;
141     int m_accountId;
142     ScopedMail m_mail;
143     ScopedMailbox m_mailbox;
144 };
145 }
146 }
147 }
148 #endif