4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 /******************************************************************************
24 * File : email-core-mail.h
25 * Desc : Mail Operation Header
30 * 2006.08.16 : created
31 *****************************************************************************/
32 #ifndef __EMAIL_CORE_MESSAGE_H__
33 #define __EMAIL_CORE_MESSAGE_H__
37 #endif /* __cplusplus */
39 #include "email-storage.h"
41 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
43 #define MAX_SUBSET_STRING_SIZE 260
44 #define MAX_IMAP_COMMAND_LENGTH 1000
45 #define MAX_TAG_SIZE 16
48 typedef struct _emf_uid_range_set
51 unsigned long lowest_uid;
52 unsigned long highest_uid;
54 struct _emf_uid_range_set *next;
56 } email_uid_range_set;
60 struct attachment_info
62 int type; /* 1 : inline 2 : attachment */
63 char *name; /* attachment filename */
64 int size; /* attachment size */
65 char *save; /* content saving filename */
66 int drm; /* 0 : none 1 : object 2 : rights 3 : dcf */
67 int drm2; /* 0 : none 1 : FL 2 : CD 3 : SSD 4 : SD */
68 char *attachment_mime_type; /* attachment mime type */
69 char *content_id; /* mime content id */
71 #ifdef __ATTACHMENT_OPTI__
72 int encoding; /* encoding */
73 char *section; /* section number */
75 struct attachment_info *next;
79 MIME Structure Example
81 (part 0) multipart/mixed
82 (part 1) multipart/alternative
83 (part 1.1) text/plain <- text message
84 (part 1.2) text/html <- html message
85 (part 2) text/plain <- text attachment
88 (part 0) multipart/related
89 (part 1) multipart/alternative
90 (part 1.1) text/plain <- text message
91 (part 1.2) text/html <- html message
92 (part 2) image/png <- inline image
93 (part 2) image/png <- inline image
96 (part 0) multipart/mixed
97 (part 1.1) multipart/related
98 (part 2.1) multipart/alternative
99 (part 3.1) text/plain(body) <- text message
100 (part 3.2) text/html(body) <- html message
101 (part 2.2) image/png(related) <- inline image
102 (part 1.2) image/png(attachment) <- image attachment
105 /* Text and Attachment Holde */
106 /* struct _m_content_info */
107 /* int grab_type; */ /* 1 : text and attachment list */
109 /* int file_no; */ /* attachment sequence to be downloaded (min : 1 */
110 /* struct text_data */
111 /* char *plain; */ /* body plain tex */
112 /* char *plain_charset */ /* charset of plai */
113 /* char *html; */ /* body html tex */
116 /* struct attachment_info */
117 /* int type; */ /* 1 : inline 2 : attachmen */
118 /* char *name; */ /* attachment filenam */
119 /* int size; */ /* attachment siz */
120 /* char *save; */ /* content saving filenam */
121 /* struct attachment_info *next */
125 /* --------------------- MIME Structure --------------------------------- */
126 /* MIME Header Parameter (Content-Type, Content-Disposition, ... */
128 char *name; /* parameter name */
129 char *value; /* parameter value */
130 struct _parameter *next; /* next paramete */
133 /* Content-Disposition */
134 struct _disposition {
135 char *type; /* "inline" "attachment */
136 struct _parameter *parameter; /* "filename", .. */
140 struct _rfc822header {
141 char *return_path; /* error return path */
159 /* MIME Part Header */
160 struct _m_part_header {
161 char *type; /* text, image, audio, video, application, multipart, message */
162 char *subtype; /* plain, html, jpeg, .. */
163 char *encoding; /* encoding typ */
164 struct _parameter *parameter; /* content-type parameter : "boundary" "charset" .. */
165 char *desc; /* description */
166 char *disp_type; /* disposition type : "inline" "attachment", */
167 struct _parameter *disp_parameter; /* disposition parameter : "filename", .. */
168 char *content_id; /* content id : it is inline */
169 char *content_location; /* content location : "inline" location */
170 char *priority; /* Priority : 1, 3, 5 */
171 char *ms_priority; /* MS-Priority : HIGH, NORMAL, LOW */
174 /* MIME Message Header */
175 struct _m_mesg_header {
176 char *version; /* MIME Version */
177 struct _m_part_header *part_header; /* MIME Part Header */
178 /* char *message_context; */ /* Message-Context : Voice-message, Video-message, Fax-message... */
179 /* int content_duration; */ /* Content-Duration */
180 /* int x_content_pages; */ /* X-Content-Pages */
181 /* char *sensitivity; */ /* Sensitivity */
184 /* MIME Multipart Body linked list */
185 typedef struct _m_body _m_body_t;
187 _m_body_t *body; /* part body */
188 struct _m_part *next; /* the next found part */
191 /* MIME Multipart Body */
193 struct _m_part_header *part_header; /* MIME Part Header */
194 struct _m_part nested; /* nested structure if contain multipart */
195 char *text; /* text if not contain multipart */
196 int size; /* text size if not contain multipart */
202 struct _rfc822header *rfc822header; /* RFC822 Header */
203 struct _m_mesg_header *header; /* MIME Message Header */
204 struct _m_part nested; /* nested structure if contain multipart */
205 char *text; /* text if not contain multipart */
206 int size; /* text size if not contain multipart */
209 struct _m_content_info
211 int grab_type; /* 1 : download text and get attachment names (no saving attachment) -
212 #define GRAB_TYPE_TEXT retrieve text and attachment names */
213 /* 2 : download attachment - #define GRAB_TYPE_ATTACHMENT retrieve only attachment */
214 int file_no; /* attachment no to be download (min : 1) */
215 int report; /* 0 : Non 1 : DSN mail 2 : MDN mail 3 : mail to require MDN */
218 int total_attachment_size;
220 int content_type; /* 1 : signed */
225 int plain_save_status;
226 char *plain; /* body plain text */
227 char *plain_charset; /* charset of body text */
228 int html_save_status;
229 char *html; /* body html text */
230 char *html_charset; /* charset of html text */
234 struct attachment_info *file;
235 struct attachment_info *inline_file; /* only used for IMAP partial body download */
248 * Download a email nth-attachment from server.
250 * @param[in] mailbox Specifies the mailbox to contain account ID.
251 * @param[in] mail_id Specifies the mail ID.
252 * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1".
253 * @param[in] callback Specifies the callback function for retrieving download status.
254 * @param[in] handle Specifies the handle for stopping downloading.
255 * @param[out] err_code Specifies the error code returned.
256 * @remarks This function is used for only IMAP mail.
257 * @return This function returns true on success or false on failure.
259 INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, email_attachment_data_t *attachment, int *err_code); /* TODO : Remove duplicated function */
260 INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_mail_id, email_attachment_data_t *input_attachment_data); /* TODO : Remove duplicated function */
261 INTERNAL_FUNC int emcore_delete_mail_attachment(char *multi_user_name, int attachment_id, int *err_code);
262 INTERNAL_FUNC int emcore_get_attachment_info(char *multi_user_name, int attachment_id, email_attachment_data_t **attachment, int *err_code);
263 INTERNAL_FUNC int emcore_get_attachment_data_list(char *multi_user_name, int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
264 INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code);
266 INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int mail_id, int nth,
267 int cancellable, int event_handle, int auto_download, int *err_code);
269 INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name, void *mail_stream,
270 int account_id, int mail_id, int with_attach, int limited_size,
271 int event_handle, int cancellable, int auto_download, int *err_code);
273 INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int *err_code);
275 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
276 INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local_activity, int *activity_id, int *err_code) ;
277 INTERNAL_FUNC int emcore_delete_pbd_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int *err_code);
280 INTERNAL_FUNC int emcore_get_mail_contact_info(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int *err_code);
281 INTERNAL_FUNC int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code);
282 INTERNAL_FUNC int emcore_free_contact_info(email_mail_contact_info_t *contact_info, int *err_code);
283 INTERNAL_FUNC int emcore_sync_contact_info(char *multi_user_name, int mail_id, int *err_code);
284 INTERNAL_FUNC GList *emcore_get_recipients_list(char *multi_user_name, GList *old_recipients_list, char *full_address, int *err_code);
285 INTERNAL_FUNC int emcore_get_mail_address_info_list(char *multi_user_name, int mail_id, email_address_info_list_t **address_info_list, int *err_code);
287 INTERNAL_FUNC int emcore_set_sent_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data);
288 INTERNAL_FUNC int emcore_set_received_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data);
289 INTERNAL_FUNC int emcore_delete_contacts_log(char *multi_user_name, int input_account_id);
292 INTERNAL_FUNC int emcore_get_mail_display_name(char *multi_user_name, char *email_address, char **contact_display_name);
293 INTERNAL_FUNC int emcore_get_mail_display_name_internal(char *multi_user_name, char *email_address, char **contact_display_name);
294 INTERNAL_FUNC int emcore_get_mail_data(char *multi_user_name, int input_mail_id, email_mail_data_t **output_mail_data);
296 INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, 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);
298 INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name, int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code);
299 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);
300 INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(char *multi_user_name, int input_mailbox_id);
301 INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *multi_user_name, int input_account_id, int input_mailbox_id);
306 * @param[in] account_id Specifies the account id.
307 * @param[in] mail_id Specifies the array for mail id.
308 * @param[in] num Specifies the number of id.
309 * @param[in] from_server Specifies whether mails is deleted from server.
310 * @param[in] callback Specifies the callback function for delivering status during deleting.
311 * @param[in] noti_param_1 Specifies the first parameter for notification.
312 * @param[in] noti_param_2 Specifies the second parameter for notification.
313 * @param[out] err_code Specifies the error code returned.
315 * @return This function returns true on success or false on failure.
317 INTERNAL_FUNC int emcore_delete_mail(char *multi_user_name, int account_id, int mail_id[], int num, int from_server, int noti_param_1, int noti_param_2, int *err_code);
322 * @param[in] input_mailbox_id Specifies the id of mailbox.
323 * @param[in] input_from_server Specifies whether mails is also deleted from server.
324 * @param[out] err_code Specifies the error code returned.
326 * @return This function returns true on success or false on failure.
328 INTERNAL_FUNC int emcore_delete_all_mails_of_acount(char *multi_user_name, int input_account_id);
329 INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name, int input_account_id, int input_mailbox_id, int input_from_server, int *err_code);
331 INTERNAL_FUNC void emcore_free_mail_data_list(email_mail_data_t **mail_list, int count);
332 INTERNAL_FUNC void emcore_free_mail_data(email_mail_data_t *mail);
333 INTERNAL_FUNC void emcore_free_content_info(struct _m_content_info *cnt_info);
334 INTERNAL_FUNC void emcore_free_attachment_info(struct attachment_info *attchment);
336 INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_id, int src_mailbox_id, int mail_ids[], int num, char *dest_mailbox, int *error_code);
337 INTERNAL_FUNC int emcore_move_mail_on_server_by_server_mail_id(void *mail_stream, char *server_mail_id, char *dest_mailbox_name);
338 INTERNAL_FUNC int emcore_move_mail_to_another_account(char *multi_user_name, int input_mail_id, int input_source_mailbox_id, int input_target_mailbox_id, int input_task_id);
339 INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_id, int event_handle, int *err_code);
340 INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int mail_ids[], int num, int event_handle, int *err_code);
342 INTERNAL_FUNC int emcore_set_flags_field(char *multi_user_name, int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
343 INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type);
344 INTERNAL_FUNC int emcore_save_mail_file(char *multi_user_name, int account_id, int mail_id, int attachment_id, char *src_file_path, char *file_name, char *full_path, char *virtual_path, int *err_code);
346 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
347 INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
348 INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name, int account_id, int src_mailbox_id, int mail_ids[], int num, int dest_mailbox_id, int *error_code);
351 #ifdef __ATTACHMENT_OPTI__
352 INTERNAL_FUNC int emcore_download_attachment_bulk(/*email_mailbox_t *mailbox, */ int account_id, int mail_id, char *nth, int event_handle, int *err_code);
354 INTERNAL_FUNC int emcore_mail_filter_by_rule(char *multi_user_name, email_rule_t *filter_info, int *err_code);
355 INTERNAL_FUNC int emcore_add_rule(char *multi_user_name, email_rule_t *filter_info);
356 INTERNAL_FUNC int emcore_update_rule(char *multi_user_name, int filter_id, email_rule_t *filter_info);
357 INTERNAL_FUNC int emcore_delete_rule(char *multi_user_name, int filter_id);
360 * Search the mails on server
362 * @param[in] account_id Specifies the id of account
363 * @param[in] mailbox_id Specifies the id of mailbox
364 * @param[in] input_search_filter Specifies the filter list for searching field
365 * @param[in] input_search_filter_count Specifies the filter count
366 * @param[in] handle Specifies the handle for searching mails
368 * @return EMAIL_ERROR_NONE on success or an error code (refer to EMAIL_ERROR_XXX) on failure
371 INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id, int mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, int handle_to_be_published);
374 #endif /* __cplusplus */
377 #define EMAIL_SIGNAL_FILE_DELETED 1
378 #define EMAIL_SIGNAL_DB_DELETED 2
379 INTERNAL_FUNC int *emcore_init_pipe_for_del_account ();
380 INTERNAL_FUNC void emcore_send_signal_for_del_account (int signal);