Tizen 2.0 Release
[platform/core/messaging/email-service.git] / email-core / include / email-core-mail.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-mail.h
25  * Desc :  Mail Operation Header
26  *
27  * Auth : 
28  *
29  * History : 
30  *    2006.08.16  :  created
31  *****************************************************************************/
32 #ifndef __EMAIL_CORE_MESSAGE_H__
33 #define __EMAIL_CORE_MESSAGE_H__
34
35 #include "email-storage.h"
36 #include <contacts.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41
42 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
43
44 #define MAX_SUBSET_STRING_SIZE 260      
45 #define MAX_IMAP_COMMAND_LENGTH 1000
46 #define MAX_TAG_SIZE 16
47
48
49 typedef struct _emf_uid_range_set
50 {
51         char *uid_range;
52         unsigned long lowest_uid;
53         unsigned long highest_uid;
54         
55         struct _emf_uid_range_set *next;
56         
57 } email_uid_range_set;
58
59 #endif
60
61
62 struct _m_content_info 
63 {
64         int grab_type;              /*  1 :  download text and get attachment names (no saving attachment) - #define GRAB_TYPE_TEXT       retrieve text and attachment names */
65                               /*  2 :  download attachment - #define GRAB_TYPE_ATTACHMENT retrieve only attachment */
66         int file_no;                /*  attachment no to be download (min : 1) */
67         int report;                 /*  0 : Non 1 : DSN mail 2 : MDN mail 3 : mail to require MDN */
68
69         struct text_data 
70         {
71                 char *plain;            /*  body plain text */
72                 char *plain_charset;    /*  charset of body text */
73                 char *html;             /*  body html text */
74                 char *html_charset;     /*  charset of html text */
75         } text;
76
77         struct attachment_info 
78         {
79                 int   type;                 /*  1 : inline 2 : attachment */
80                 char *name;                 /*  attachment filename */
81                 int   size;                 /*  attachment size */
82                 char *save;                 /*  content saving filename */
83                 int   drm;                  /*  0 : none 1 : object 2 : rights 3 : dcf */
84                 int   drm2;                 /*  0 : none 1 : FL 2 : CD 3 : SSD 4 : SD */
85                 char *attachment_mime_type; /*  attachment mime type */
86                 char *content_id;           /*  mime content id */
87 #ifdef __ATTACHMENT_OPTI__
88                 int   encoding;         /*  encoding  */
89                 char *section;          /*  section number */
90 #endif
91                 struct attachment_info *next;
92         } *file;
93 };
94
95 /**
96  * Download email body from server.
97  *
98  * @param[in] mail_stream       Specifies the mail_stream.
99  * @param[in] mailbox           Specifies the mailbox to contain account ID.
100  * @param[in] mail_id           Specifies the mail ID.
101  * @param[in] callback          Specifies the callback function for retrieving download status.
102  * @param[in] with_attach       Specifies the flag for downloading attachments.
103  * @param[in] limited_size      Specifies the size to be downloaded.
104  * @param[out] err_code         Specifies the error code returned.
105  * @remarks In POP3 case, body and attachment are downloaded in this function.
106  *          In IMAP case, body and attachment list are downloaded and 
107  *          attachments must be downloaded in emcore_download_attachment.
108  * @return This function returns true on success or false on failure.
109  */
110
111 INTERNAL_FUNC int emcore_download_body_multi_sections_bulk(void *mail_stream, int account_id, int mail_id, int verbose, int with_attach, int limited_size, int event_handle , int *err_code);
112
113
114 /**
115  * Download a email nth-attachment from server.
116  *
117  * @param[in] mailbox           Specifies the mailbox to contain account ID.
118  * @param[in] mail_id                   Specifies the mail ID.
119  * @param[in] nth                               Specifies the buffer that a attachment number been saved. the minimum number is "1".
120  * @param[in] callback          Specifies the callback function for retrieving download status.
121  * @param[in] handle                    Specifies the handle for stopping downloading.
122  * @param[out] err_code Specifies the error code returned.
123  * @remarks This function is used for only IMAP mail.
124  * @return This function returns true on success or false on failure.
125  */
126 INTERNAL_FUNC int emcore_download_attachment(int acconut_id, int mail_id, int nth, int *err_code);
127 INTERNAL_FUNC int emcore_mail_add_attachment(int mail_id, email_attachment_data_t *attachment, int *err_code);        /* TODO : Remove duplicated function */
128 INTERNAL_FUNC int emcore_mail_add_attachment_data(int input_mail_id, email_attachment_data_t *input_attachment_data); /* TODO : Remove duplicated function */
129 INTERNAL_FUNC int emcore_delete_mail_attachment(int attachment_id, int *err_code);
130 INTERNAL_FUNC int emcore_get_attachment_info(int attachment_id, email_attachment_data_t **attachment, int *err_code);
131 INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
132 INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code);
133
134
135 INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int *err_code);
136
137 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
138 INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local_activity, int *activity_id, int *err_code) ;
139 INTERNAL_FUNC int emcore_delete_pbd_activity(int account_id, int mail_id, int activity_id, int *err_code);
140 #endif 
141
142 INTERNAL_FUNC int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *full_address, int *err_code);
143 INTERNAL_FUNC int emcore_get_mail_contact_info_with_update(email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code);
144 INTERNAL_FUNC int emcore_free_contact_info(email_mail_contact_info_t *contact_info, int *err_code);
145 INTERNAL_FUNC int emcore_sync_contact_info(int mail_id, int *err_code);
146 INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char *full_address, int *err_code);
147 INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, email_address_info_list_t **address_info_list, int *err_code);
148
149 INTERNAL_FUNC int emcore_set_sent_contacts_log(emstorage_mail_tbl_t *input_mail_data);
150 INTERNAL_FUNC int emcore_set_received_contacts_log(emstorage_mail_tbl_t *input_mail_data);
151 INTERNAL_FUNC int emcore_delete_contacts_log(int input_account_id);
152
153 INTERNAL_FUNC int emcore_get_mail_display_name(char *email_address, char **contact_display_name, int *err_code);
154 INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data);
155
156 INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int sync_server);
157
158 INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code);
159 INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(email_account_t *account, email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code);
160 INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int input_mailbox_id);
161 INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(int input_account_id, int input_mailbox_id);
162
163 /**
164  * Delete mails.
165  *
166  * @param[in] account_id      Specifies the account id.
167  * @param[in] mail_id         Specifies the array for mail id.
168  * @param[in] num             Specifies the number of id.
169  * @param[in] from_server     Specifies whether mails is deleted from server.
170  * @param[in] callback        Specifies the callback function for delivering status during deleting.
171  * @param[in] noti_param_1    Specifies the first parameter for notification.
172  * @param[in] noti_param_2    Specifies the second parameter for notification.
173  * @param[out] err_code       Specifies the error code returned.
174  * @remarks N/A
175  * @return This function returns true on success or false on failure.
176  */
177 INTERNAL_FUNC int emcore_delete_mail(int account_id, int mail_id[], int num, int from_server, int noti_param_1, int noti_param_2, int *err_code);
178
179 /**
180  * Delete mails.
181  *
182  * @param[in] input_mailbox_id  Specifies the id of mailbox.
183  * @param[in] input_from_server Specifies whether mails is also deleted from server.
184  * @param[out] err_code         Specifies the error code returned.
185  * @remarks N/A
186  * @return This function returns true on success or false on failure.
187  */
188 INTERNAL_FUNC int   emcore_delete_all_mails_of_acount(int input_account_id);
189 INTERNAL_FUNC int   emcore_delete_all_mails_of_mailbox(int input_account_id, int input_mailbox_id, int input_from_server, int *err_code);
190
191 INTERNAL_FUNC void  emcore_free_mail_data_list(email_mail_data_t **mail_list, int count);
192 INTERNAL_FUNC void  emcore_free_mail_data(email_mail_data_t *mail);
193 INTERNAL_FUNC void  emcore_free_content_info(struct _m_content_info *cnt_info);
194 INTERNAL_FUNC void  emcore_free_attachment_info(struct attachment_info *attchment);
195
196 INTERNAL_FUNC int   emcore_move_mail_on_server(int account_id, int src_mailbox_id,  int mail_ids[], int num, char *dest_mailbox, int *error_code);
197 INTERNAL_FUNC int   emcore_move_mail_to_another_account(int input_mail_id, int input_source_mailbox_id, int input_target_mailbox_id, int input_task_id);
198 INTERNAL_FUNC int   emcore_sync_flag_with_server(int mail_id, int *err_code);
199 INTERNAL_FUNC int   emcore_sync_seen_flag_with_server(int mail_ids[], int num, int *err_code);
200
201 INTERNAL_FUNC int   emcore_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
202 INTERNAL_FUNC char* emcore_convert_mutf7_to_utf8(char *mailbox_name); 
203 INTERNAL_FUNC int   emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type);
204 INTERNAL_FUNC int   emcore_save_mail_file(int account_id, int mail_id, int attachment_id, char *src_file_path, char *file_name, char *full_path, int *err_code);
205
206 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
207 INTERNAL_FUNC int   emcore_sync_flags_field_with_server(int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
208 INTERNAL_FUNC int   emcore_move_mail_on_server_ex(int account_id, int src_mailbox_id,  int mail_ids[], int num, int dest_mailbox_id, int *error_code);
209 #endif
210
211 #ifdef __ATTACHMENT_OPTI__
212 INTERNAL_FUNC int emcore_download_attachment_bulk(/*email_mailbox_t *mailbox, */ int account_id, int mail_id, char *nth,  int *err_code);
213 #endif
214 INTERNAL_FUNC int   emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err_code);
215 #ifdef __cplusplus
216 }
217 #endif /* __cplusplus */
218
219 #endif
220 /* EOF */