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.
25 * This file defines all APIs of Email Framework.
26 * @file email-daemon.h
27 * @author Kyu-ho Jo(kyuho.jo@samsung.com)
29 * @brief This file is the header file of email-engine library.
31 #ifndef __EMAIL_DAEMON_H__
32 #define __EMAIL_DAEMON_H__
35 * @defgroup EMAIL_SERVICE EmailFW
40 * @ingroup EMAIL_SERVICE
41 * @defgroup EMAIL_SERVICE Email Service
45 #include "email-types.h"
46 #include "email-internal-types.h"
53 #endif /* __cplusplus */
55 /*****************************************************************************/
57 /*****************************************************************************/
59 * Initialize Email-engine.
61 * @param[out] err_code Specifies the error code returned.
63 * @return This function returns true on success or false on failure.
65 INTERNAL_FUNC int emdaemon_initialize(int* err_code);
68 * Finalize Email-engine.
70 * @param[out] err_code Specifies the error code returned.
72 * @return This function returns true on success or false on failure.
74 INTERNAL_FUNC int emdaemon_finalize(int* err_code);
77 /*****************************************************************************/
79 /*****************************************************************************/
81 * Create a new email account.
83 * @param[in] account Specifies the structure pointer of account.
84 * @param[out] err_code Specifies the error code returned.
86 * @return This function returns true on success or false on failure.
88 INTERNAL_FUNC int emdaemon_create_account(email_account_t* account, int* err_code);
91 * Delete a email account.
93 * @param[in] account_id Specifies the account ID.
94 * @param[out] err_code Specifies the error code returned.
96 * @return This function returns true on success or false on failure.
98 INTERNAL_FUNC int emdaemon_delete_account(int account_id, int* err_code);
101 * Validate a email account.
103 * @param[in] account_id Specifies the account ID.
104 * @param[out] err_code Specifies the error code returned.
106 * @return This function returns true on success or false on failure.
108 INTERNAL_FUNC int emdaemon_validate_account(int account_id, int *handle, int* err_code);
111 * Change the information of a email account.
113 * @param[in] account_id Specifies the orignal account ID.
114 * @param[in] new_account Specifies the information of new account.
115 * @param[out] err_code Specifies the error code returned.
117 * @return This function returns true on success or false on failure.
119 INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_account, int* err_code);
122 * Change the information of a email account after validation
124 * @param[in] old_account_id Specifies the orignal account ID.
125 * @param[in] new_account_info Specifies the information of new account.
126 * @param[in] handle Specifies the handle for stopping validation.
127 * @param[out] err_code Specifies the error code returned.
129 * @return This function returns true on success or false on failure.
131 INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, int *handle,int *err_code);
134 * Get a email account by ID.
136 * @param[in] account_id Specifies the account ID.
137 * @param[in] pulloption Specifies the pulloption.
138 * @param[out] acount The returned account is saved here.
139 * @param[out] err_code Specifies the error code returned.
141 * @return This function returns true on success or false on failure.
143 INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_account_t* acount, int* err_code);
148 * @param[out] acount_list The returned accounts are saved here.(possibly NULL)
149 * @param[out] count The count of returned accounts is saved here.(possibly 0)
150 * @param[out] err_code Specifies the error code returned.
152 * @return This function returns true on success or false on failure.
154 INTERNAL_FUNC int emdaemon_get_account_list(email_account_t** acount_list, int* count, int* err_code);
157 * Free allocated memory.
159 * @param[in] account_list Specifies the structure pointer of account.
160 * @param[in] count Specifies the count of accounts.
161 * @param[out] err_code Specifies the error code returned.
163 * @return This function returns true on success or false on failure.
165 INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int count, int* err_code);
168 * Get a information of filtering.
170 * @param[in] filter_id Specifies the filter ID.
171 * @param[out] filtering_set The returned information of filter are saved here.
172 * @param[out] err_code Specifies the error code returned.
174 * @return This function returns true on success or false on failure.
176 INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filtering_set, int* err_code);
179 * Get all filterings.
181 * @param[out] filtering_set The returned filterings are saved here.(possibly NULL)
182 * @param[out] count The count of returned filters is saved here.(possibly 0)
183 * @param[out] err_code Specifies the error code returned.
185 * @return This function returns true on success or false on failure.
187 INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filtering_set, int* count, int* err_code);
190 * find a filter already exists.
192 * @param[in] filtering_set Specifies the pointer of adding filter structure.
193 * @param[out] err_code Specifies the error code returned.
195 * @return This function returns true if enable add filter, else returns false.
197 INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code);
200 * Add a filter information.
202 * @param[in] filtering_set Specifies the pointer of adding filter structure.
204 * @return This function returns true on success or false on failure.(only EMAIL_FILTER_BLOCK supported.)
206 INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filtering_set);
209 * Change a filter information.
211 * @param[in] filter_id Specifies the original filter ID.
212 * @param[in] new_set Specifies the information of new filter.
213 * @param[out] err_code Specifies the error code returned.
215 * @return This function returns true on success or false on failure.
217 INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* new_set, int* err_code);
220 * Delete a filter information.
222 * @param[in] filter_id Specifies the filter ID.
223 * @param[out] err_code Specifies the error code returned.
225 * @return This function returns true on success or false on failure.
227 INTERNAL_FUNC int emdaemon_delete_filter(int filter_id, int* err_code);
230 * Free allocated memory.
232 * @param[in] filtering_set Specifies the pointer of pointer of filter structure for memory free.
233 * @param[in] count Specifies the count of filter.
234 * @param[out] err_code Specifies the error code returned.
236 * @return This function returns true on success or false on failure.
238 INTERNAL_FUNC int emdaemon_free_filter (email_rule_t** filtering_set, int count, int* err_code);
241 /*****************************************************************************/
243 /*****************************************************************************/
248 * @param[in] mail_id Specifies the mail ID.
249 * @param[in] callback Specifies the callback function for retrieving sending information.
250 * @param[in] handle Specifies the handle for stopping sending.
251 * @param[out] err_code Specifies the error code returned.
253 * @return This function returns true on success or false on failure.
255 INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code);
258 * Send all mails to been saved in Offline-mode.
260 * @param[in] account_id Specifies the account ID.
261 * @param[in] callback Specifies the callback function for retrieving sending information.
262 * @param[in] handle Specifies the handle for stopping sending.
263 * @param[out] err_code Specifies the error code returned.
265 * @return This function returns true on success or false on failure.
267 INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err_code);
269 INTERNAL_FUNC int emdaemon_add_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 input_from_eas);
271 INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code);
274 * Delete a mail or multiple mails.
276 * @param[in] mailbox_id Specifies the mailbox.
277 * @param[in] mail_id Specifies the arrary of mail id.
278 * @param[in] num Specifies the number of mail id.
279 * @param[in] from_server Specifies whether mails are deleted from server.
280 * @param[in] callback Specifies the callback function for retrieving deleting information.
281 * @param[in] handle Reserved.
282 * @param[out] err_code Specifies the error code returned.
284 * @return This function returns true on success or false on failure.
287 INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
290 * Delete all mail from a mailbox.
292 * @param[in] input_mailbox_id Specifies the id of target mailbox.
293 * @param[in] input_from_server Specifies whether mails are also deleted from server.
294 * @param[in] output_handle Reserved.
295 * @param[out] output_err_code Specifies the error code returned.
297 * @return This function returns true on success or false on failure.
299 INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code);
302 * Move a email to another mailbox.
305 * @param[in] mail_id Specifies the mail ID.
306 * @param[in] dst_mailbox_id Specifies the mailbox ID for moving email.
307 * @param[in] noti_param_1 Specifies first parameter of result notification.
308 * @param[in] noti_param_2 Specifies second parameter of result notification.
309 * @param[out] err_code Specifies the error code returned.
311 * @return This function returns true on success or false on failure.
313 INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int* err_code);
316 * Move all email to another mailbox.
319 * @param[in] src_mailbox_id Specifies the source mailbox ID for moving email.
320 * @param[in] dst_mailbox_id Specifies the destination mailbox ID for moving email.
321 * @param[out] err_code Specifies the error code returned.
323 * @return This function returns true on success or false on failure.
325 INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailbox_id, int* err_code);
329 * Update a existing email information.
331 * @param[in] input_mail_data Specifies the structure of mail data.
332 * @param[in] input_attachment_data_list Specifies the structure of mail data.
333 * @param[in] input_attachment_count Specifies the pointer of attachment structure.
334 * @param[in] input_meeting_request Specifies the number of attachment data.
335 * @param[in] input_from_eas Specifies whether the mail is from EAS.
337 * @return This function returns EMAIL_ERROR_NONE on success or error code on failure.
339 INTERNAL_FUNC int emdaemon_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 input_from_eas);
343 * Callback for mail resend
345 * @param[in] data Specifies the pointer to mail_id.
347 * @return This function returns void.
349 INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data );
352 * Download email body from server.
354 * @param[in] account_id Specifies the account ID.
355 * @param[in] mail_id Specifies the mail ID.
356 * @param[in] callback Specifies the callback function for retrieving download status.
357 * @param[in] handle Specifies the handle for stopping downloading.
358 * @param[out] err_code Specifies the error code returned.
360 * @return This function returns true on success or false on failure.
362 INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code);
365 * Get a mail attachment.
367 * @param[in] mail_id Specifies the mail ID.
368 * @param[in] attachment_id Specifies the attachment ID.
369 * @param[out] attachment The returned attachment is save here.
370 * @param[out] err_code Specifies the error code returned.
372 * @return This function returns true on success or false on failure.
374 INTERNAL_FUNC int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachment, int* err_code);
377 * Download a email nth-attachment from server.
379 * @param[in] account_id Specifies the account ID.
380 * @param[in] mail_id Specifies the mail ID.
381 * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1".
382 * @param[in] callback Specifies the callback function for retrieving download status.
383 * @param[in] handle Specifies the handle for stopping downloading.
384 * @param[out] err_code Specifies the error code returned.
386 * @return This function returns true on success or false on failure.
388 INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, int *handle, int* err_code);
392 * Append a attachment to email.
394 * @param[in] mail_id Specifies the mail ID.
395 * @param[in] attachment Specifies the structure of attachment.
396 * @param[out] err_code Specifies the error code returned.
398 * @return This function returns true on success or false on failure.
400 INTERNAL_FUNC int emdaemon_add_attachment(int mail_id, email_attachment_data_t* attachment, int* err_code);
403 * Delete a attachment from email.
405 * @param[in] mail_id Specifies the mail id.
406 * @param[in] attachment_id Specifies the attachment id.
407 * @param[out] err_code Specifies the error code returned.
409 * @return This function returns true on success or false on failure.
411 INTERNAL_FUNC int emdaemon_delete_mail_attachment(int attachment_id, int* err_code);
414 * Free allocated memroy for email attachment.
416 * @param[in] atch_info Specifies the pointer of mail attachment structure pointer.
417 * @param[out] err_code Specifies the error code returned.
419 * @return This function returns true on success or false on failure.
421 INTERNAL_FUNC int emdaemon_free_attachment_data(email_attachment_data_t** atch_info, int* err_code);
424 * Change email read/unread flag.
425 * @param[in] account_id Specifies the account id.
426 * @param[in] mail_ids Specifies the array of mail ID.
427 * @param[in] num Specifies the numbers of mail ID.
428 * @param[in] field_type Specifies the field type what you want to set. Refer email_flags_field_type.
429 * @param[in] value Specifies the value what you want to set.
430 * @param[in] onserver Specifies the mail on server.
431 * @param[out] err_code Specifies the error code returned.
433 * @return This function returns true on success or false on failure.
435 INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int onserver, int* err_code);
437 /*****************************************************************************/
439 /*****************************************************************************/
440 INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, int *handle, int* err_code);
443 * Download header of new emails from mail server.
445 * @param[in] input_account_id Specifies the account ID.
446 * @param[in] input_mailbox_id Specifies the mailbox ID.
447 * @param[out] handle Specifies the handle for stopping downloading.
448 * @param[out] err_code Specifies the error code returned.
450 * @return This function returns true on success or false on failure.
452 INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, int *handle, int* err_code);
456 * Get mail count from mailbox.
458 * @param[in] mailbox Specifies the pointer of mailbox structure.
459 * @param[out] total Total email count is saved here.
460 * @param[out] unseen Unread email count is saved here.
461 * @param[out] err_code Specifies the error code returned.
463 * @return This function returns true on success or false on failure.
465 INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, int* total, int* unseen, int* err_code);
468 * Get all mailboxes from account.
470 * @param[in] account_id Specifies the account ID.
471 * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL)
472 * @param[out] count The mailbox count is saved here.(possibly 0)
473 * @param[out] err_code Specifies the error code returned.
475 * @return This function returns true on success or false on failure.
477 INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code);
480 * Create a new mailbox.
482 * @param[in] new_mailbox Specifies the pointer of creating mailbox information.
483 * @param[out] handle Specifies the handle for stopping creating mailbox.
484 * @param[out] err_code Specifies the error code returned.
486 * @return This function returns true on success or false on failure.
488 INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
493 * @param[in] input_mailbox_id Specifies the input_mailbox_id of deleting mailbox information.
494 * @param[out] handle Specifies the handle for stopping creating mailbox.
495 * @param[out] err_code Specifies the error code returned.
497 * @return This function returns true on success or false on failure.
499 INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, int *handle, int* err_code);
502 * Delete all sub-mailboxes from a specific mailbox.
504 * @param[in] mailbox Specifies the pointer of mailbox information.
505 * @param[out] err_code Specifies the error code returned.
507 * @return This function returns true on success or false on failure.
509 INTERNAL_FUNC int emdaemon_delete_mailbox_all(email_mailbox_t* mailbox, int* err_code);
512 * Free allocated memory for mailbox information.
514 * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer.
515 * @param[in] count Specifies the count of mailboxes.
516 * @param[out] err_code Specifies the error code returned.
518 * @return This function returns true on success or false on failure.
520 INTERNAL_FUNC int emdaemon_free_mailbox(email_mailbox_t** mailbox_list, int count, int* err_code);
522 /*****************************************************************************/
524 /*****************************************************************************/
528 * Register a callback for event processing.
530 * @param[in] action Kind of event callback.
531 * @param[in] callback Function which will be called during processing event.
532 * @param[in] event_data Event data which will be passed to the callback.
534 * @return This function returns true on success or false on failure.
536 INTERNAL_FUNC int emdaemon_register_event_callback(email_action_t action, email_event_callback callback, void* event_data);
539 * Unregister a callback for event processing.
541 * @param[in] action Kind of event callback.
542 * @param[in] callback Function which will be called during processing event.
544 * @return This function returns true on success or false on failure.
546 INTERNAL_FUNC int emdaemon_unregister_event_callback(email_action_t action, email_event_callback callback);
549 * Get current event queue status.
551 * @param[out] on_sending True if sending is in progress.
552 * @param[out] on_receiving True if receiving is in progress.
555 INTERNAL_FUNC void emdaemon_get_event_queue_status(int* on_sending, int* on_receiving);
558 * Get the handle of a pending job.
560 * @param[in] action Specifies kind of the job.
561 * @param[in] account_id Specifies the account ID.
562 * @param[in] mail_id Specifies the mail ID.
564 * @return This function return its handle if a pending job exists, otherwise -1.
566 INTERNAL_FUNC int emdaemon_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t* status);
569 * Cancel a progressive work.
571 * @param[in] account_id Specifies the account ID.
572 * @param[in] handle Specifies the ID of cancelling work.
573 * @param[out] err_code Specifies the error code returned.
575 * @return This function returns true on success or false on failure.
577 INTERNAL_FUNC int emdaemon_cancel_job(int account_id, int handle, int* err_code);
582 * Cancel a progressive send mail job.
584 * @param[in] account_id Specifies the account ID.
585 * @param[in] mail_id Specifies the Mail ID of cancelling send mail.
586 * @param[out] err_code Specifies the error code returned.
588 * @return This function returns true on success or false on failure.
590 INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, int* err_code);
595 * @param[in] option Specifies the email options.
596 * @param[out] err_code Specifies the error code returned.
598 * @return This function returns true on success or false on failure.
600 INTERNAL_FUNC int emdaemon_set_option(email_option_t* option, int* err_code);
605 * @param[out] option Specifies the email options.
606 * @param[out] err_code Specifies the error code returned.
608 * @return This function returns true on success or false on failure.
610 INTERNAL_FUNC int emdaemon_get_option(email_option_t* option, int* err_code);
613 * Sync the Local activity
616 * @param[in] account_id Specifies the Account ID.
617 * @param[out] err_code Specifies the error code returned.
619 * @return This function returns true on success or false on failure.
621 INTERNAL_FUNC int emdaemon_sync_local_activity(int account_id, int *err_code);
624 #ifdef __FEATURE_AUTO_POLLING__
625 INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code);
626 #endif /* __FEATURE_AUTO_POLLING__ */
628 INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* account);
630 INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_account, email_account_t* new_account);
632 INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
634 INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
636 INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox);
638 INTERNAL_FUNC int emdaemon_search_mail_on_server(int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, unsigned int *output_handle, int *err_code);
640 INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code);
642 INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code);
644 INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, int *handle, int* err_code);
646 INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code);
648 INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, int input_on_server, int *output_handle);
650 INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag, int *err_code);
652 INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, int *handle, int *err_code);
654 INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, int *handle, int *err_code);
656 INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle);
660 #endif /* __cplusplus */
666 #endif /* __EMAIL_DAEMON_H__ */