Tizen 2.0 Release
[platform/core/messaging/email-service.git] / email-core / include / email-core-mailbox-sync.h
1 /*
2 *  email-service
3 *
4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5 *
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
7
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21
22
23 /******************************************************************************
24  * File :  email-core-mailbox_sync.h
25  * Desc :  Mail Header Sync Header
26  *
27  * Auth : 
28  *
29  * History : 
30  *    2006.08.16  :  created
31  *****************************************************************************/
32 #ifndef __EMAIL_CORE_MAILBOX_SYNC_H__
33 #define __EMAIL_CORE_MAILBOX_SYNC_H__
34
35 #include "email-types.h"
36 #include "email-storage.h"
37 #include "c-client.h"
38
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif /* __cplusplus */
43
44 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
45
46 #define IMAGE_DISPLAY_PARTIAL_BODY_COUNT 30
47 typedef struct 
48 {
49         char  image_file_name[100];
50         char *text_image;
51         char *content_id;
52         int   dec_len;
53         char *mime_type;
54 } email_image_data;
55
56 typedef struct 
57 {
58         char *header;
59         int header_len;
60         char *body;
61         int body_len;
62 } email_partial_buffer;
63
64 #endif
65
66 typedef struct emcore_uid_elem {
67         int msgno;
68         char *uid;
69         email_mail_flag_t flag;
70         struct emcore_uid_elem *next;
71 } emcore_uid_list; 
72
73 int pop3_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *err_code);
74 int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *err_code);
75
76 int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *err_code);
77 int imap4_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *err_code);
78
79 int emcore_check_rule(const char *input_full_address_from, const char *input_subject, emstorage_rule_tbl_t *rule, int rule_len, int *matched, int *err_code);
80
81 int emcore_make_mail_tbl_data_from_envelope(MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data,  int *err_code);
82
83 int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id);
84
85 /**
86  * Download unread all headers from mail server.
87  *
88  * @param[in] input_mailbox_tbl Specifies the mailbox to contain target mailbox name.
89  *                      if the mailbox name is NULL, headers are downloaded from all synchronous mailbox.
90  *                      the mailbox name is unused in POP3 case.
91  * @param[in] input_mailbox_tbl_spam    Mailbox information of Spambox for filtering blocked mails.
92  * @param[in] stream_recycle Stream to reuse.
93  * @param[out] err_code Specifies the error code returned.
94  * @remarks N/A
95  * @return This function returns true on success or false on failure.
96  */
97 INTERNAL_FUNC int emcore_sync_header(emstorage_mailbox_tbl_t *input_mailbox_tbl, emstorage_mailbox_tbl_t *input_mailbox_tbl_spam, void *stream_recycle, emcore_uid_list **input_uid_list, int *unread_mail, int *err_code);
98
99 typedef enum
100 {
101         EM_CORE_GET_UIDS_FOR_NO_DELETE = 0, 
102         EM_CORE_GET_UIDS_FOR_DELETE, 
103 } emcore_get_uids_for_delete_t;
104 /**
105  * Download UID list from mail server. 
106  *
107  * @param[in] mailbox     Specifies the mailbox to contain target mailbox name.
108  *                        the mailbox name is unused in POP3 case.
109  * @param[out] uid_list The returned UID list is saved in a memory. this argument points to the list.
110  * @param[out] total      Specifies the count of the uid_list.
111  * @param[in] read_mail_uids Specifies the array of the uids have the seen flag.
112  * @param[in] count               Specifies the count of read_mail_uids.
113  * @param[in] for_delete  Specifies the flag for deleting. (0 = for downloading or retrieving body, 1 = for deleting message)
114  * @param[out] err_code   Specifies the error code returned.
115  * @remarks N/A
116  * @return This function returns true on success or false on failure.
117  */
118 int emcore_download_uid_all(email_internal_mailbox_t *mailbox,
119                                                         emcore_uid_list         **uid_list,
120                                                         int                                                     *total,
121                                                         emstorage_read_mail_uid_tbl_t *read_mail_uids, 
122                                                         int                           count, 
123                                                         emcore_get_uids_for_delete_t  for_delete, 
124                                                         int                                                     *err_code);
125
126
127
128 /**
129  * Search a UID from mail server. this function is supported for only IMAP account.
130  *
131  * @param[in] mailbox   Specifies the mailbox to contain target mailbox name.
132  * @param[in] uid               Specifies the mail uid.
133  * @param[out] msgno    The message number to be related to uid is saved here.
134  * @param[out] err_code Specifies the error code returned.
135  * @remarks N/A
136  * @return This function returns true on success or false on failure.
137  */
138 int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code);
139
140 /**
141  * Get a message number to be related to uid.
142  *
143  * @param[in] uid_list Specifies the uid list.
144  * @param[in] uid                Specifies the mail uid.
145  * @param[out] msgno     The message number to be related to uid is saved here.
146  * @param[out] err_code  Specifies the error code returned.
147  * @remarks The uid list must be already saved in fpath before this fucntion is called.
148  * @return This function returns true on success or false on failure.
149  */
150 int emcore_get_msgno(emcore_uid_list *uid_list, char *uid, int *msgno, int *err_code);
151
152 /**
153  * Get a uid to be related to a message number.
154  *
155  * @param[in] uid_list Specifies the uid list.
156  * @param[in] msgno              Specifies the message number.
157  * @param[out] uid               The message uid is saved here.
158  * @param[out] err_code  Specifies the error code returned.
159  * @remarks The uid list must be already saved in fpath before this fucntion is called.
160  * @return This function returns true on success or false on failure.
161  */
162 int emcore_get_uid(emcore_uid_list *uid_list, int msgno, char **uid, int *err_code);
163
164 /**
165  * free fetch list.
166  *
167  * @param[in] uid_list Specifies the fetch data.
168  * @param[out] err_code Specifies the error code returned.
169  * @return This function returns true on success or false on failure.
170  */
171 int emcore_free_uids(emcore_uid_list *uid_list, int *err_code);
172
173 INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id);
174
175 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
176 INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, email_event_partial_body_thd *pbd_event, int count, int *error);
177 #endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
178
179
180 #ifdef __cplusplus
181 }
182 #endif /* __cplusplus */
183
184 #endif