d10aa33acc75ea3367c92fe82b48cc686ae24d59
[framework/web/wrt-plugins-common.git] / src / modules / tizen / Messaging / EmailService.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  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
18  */
19
20 #ifndef WAC_MESSAGING_EMAILSERVICE_H_
21 #define WAC_MESSAGING_EMAILSERVICE_H_
22
23 #include <cstring>
24 #include <cstdlib>
25 #include <new>
26
27 #include <emf-types.h>
28
29 #include <API/Messaging/EmailAccountInfo.h>
30
31 namespace WrtDeviceApis {
32 namespace Messaging {
33 namespace EmailService {
34
35 template<typename T>
36 T* alloc()
37 {
38     T* result = static_cast<T*>(::malloc(sizeof(T)));
39     if (NULL == result) {
40         throw std::bad_alloc();
41     }
42     ::memset(result, 0, sizeof(*result));
43     return result;
44 }
45
46 emf_mail_t* createMail(const WrtDeviceApis::Messaging::Api::EmailAccountInfo& account);
47
48 emf_mail_t* readMail(int accountId,
49         int mailId);
50
51 emf_mailbox_t* getMailboxByType(int accountId,
52         emf_mailbox_type_e type);
53
54 int addMailToMailbox(emf_mail_t* mail,
55         emf_mailbox_t* mailbox);
56
57 void deleteMail(int accountId,
58         int mailId);
59
60 void freeAttachment(emf_attachment_info_t* attachment);
61
62 emf_mailbox_t* createMailbox(int accountId,
63         const char* name);
64
65 emf_mail_t* cloneMail(const emf_mail_t* mail);
66
67 emf_mailbox_t* getMailboxByMailId(int accountId,
68         int mailId);
69 }
70 }
71 }
72
73 #endif