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);
110 INTERNAL_FUNC int emdaemon_validate_account_ex(email_account_t* account, int *handle);
113 * Change the information of a email account.
115 * @param[in] account_id Specifies the orignal account ID.
116 * @param[in] new_account Specifies the information of new account.
117 * @param[out] err_code Specifies the error code returned.
119 * @return This function returns true on success or false on failure.
121 INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_account, int* err_code);
124 * Change the information of a email account after validation
126 * @param[in] old_account_id Specifies the orignal account ID.
127 * @param[in] new_account_info Specifies the information of new account.
128 * @param[in] handle Specifies the handle for stopping validation.
129 * @param[out] err_code Specifies the error code returned.
131 * @return This function returns true on success or false on failure.
133 INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, int *handle,int *err_code);
136 * Get a email account by ID.
138 * @param[in] account_id Specifies the account ID.
139 * @param[in] pulloption Specifies the pulloption.
140 * @param[out] acount The returned account is saved here.
141 * @param[out] err_code Specifies the error code returned.
143 * @return This function returns true on success or false on failure.
145 INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_account_t* acount, int* err_code);
150 * @param[out] acount_list The returned accounts are saved here.(possibly NULL)
151 * @param[out] count The count of returned accounts is saved here.(possibly 0)
152 * @param[out] err_code Specifies the error code returned.
154 * @return This function returns true on success or false on failure.
156 INTERNAL_FUNC int emdaemon_get_account_list(email_account_t** acount_list, int* count, int* err_code);
159 * Free allocated memory.
161 * @param[in] account_list Specifies the structure pointer of account.
162 * @param[in] count Specifies the count of accounts.
163 * @param[out] err_code Specifies the error code returned.
165 * @return This function returns true on success or false on failure.
167 INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int count, int* err_code);
170 * Get a information of filtering.
172 * @param[in] filter_id Specifies the filter ID.
173 * @param[out] filtering_set The returned information of filter are saved here.
174 * @param[out] err_code Specifies the error code returned.
176 * @return This function returns true on success or false on failure.
178 INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filtering_set, int* err_code);
181 * Get all filterings.
183 * @param[out] filtering_set The returned filterings are saved here.(possibly NULL)
184 * @param[out] count The count of returned filters is saved here.(possibly 0)
185 * @param[out] err_code Specifies the error code returned.
187 * @return This function returns true on success or false on failure.
189 INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filtering_set, int* count, int* err_code);
192 * find a filter already exists.
194 * @param[in] filtering_set Specifies the pointer of adding filter structure.
195 * @param[out] err_code Specifies the error code returned.
197 * @return This function returns true if enable add filter, else returns false.
199 INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code);
202 * Add a filter information.
204 * @param[in] filtering_set Specifies the pointer of adding filter structure.
206 * @return This function returns true on success or false on failure.(only EMAIL_FILTER_BLOCK supported.)
208 INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filtering_set);
211 * Change a filter information.
213 * @param[in] filter_id Specifies the original filter ID.
214 * @param[in] new_set Specifies the information of new filter.
215 * @param[out] err_code Specifies the error code returned.
217 * @return This function returns true on success or false on failure.
219 INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* new_set, int* err_code);
222 * Delete a filter information.
224 * @param[in] filter_id Specifies the filter ID.
225 * @param[out] err_code Specifies the error code returned.
227 * @return This function returns true on success or false on failure.
229 INTERNAL_FUNC int emdaemon_delete_filter(int filter_id, int* err_code);
232 * Free allocated memory.
234 * @param[in] filtering_set Specifies the pointer of pointer of filter structure for memory free.
235 * @param[in] count Specifies the count of filter.
236 * @param[out] err_code Specifies the error code returned.
238 * @return This function returns true on success or false on failure.
240 INTERNAL_FUNC int emdaemon_free_filter (email_rule_t** filtering_set, int count, int* err_code);
243 * Apply a filter information.
245 * @param[in] filter_id Specifies the filter ID.
246 * @param[out] err_code Specifies the error code returned.
248 * @return This function returns true on success or false on failure.
250 INTERNAL_FUNC int emdaemon_apply_filter(int filter_id, int* err_code);
252 /*****************************************************************************/
254 /*****************************************************************************/
259 * @param[in] mail_id Specifies the mail ID.
260 * @param[in] callback Specifies the callback function for retrieving sending information.
261 * @param[in] handle Specifies the handle for stopping sending.
262 * @param[out] err_code Specifies the error code returned.
264 * @return This function returns true on success or false on failure.
266 INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code);
269 * Send all mails to been saved in Offline-mode.
271 * @param[in] account_id Specifies the account ID.
272 * @param[in] callback Specifies the callback function for retrieving sending information.
273 * @param[in] handle Specifies the handle for stopping sending.
274 * @param[out] err_code Specifies the error code returned.
276 * @return This function returns true on success or false on failure.
278 INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err_code);
280 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);
282 INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code);
285 * Delete a mail or multiple mails.
287 * @param[in] mailbox_id Specifies the mailbox.
288 * @param[in] mail_id Specifies the arrary of mail id.
289 * @param[in] num Specifies the number of mail id.
290 * @param[in] from_server Specifies whether mails are deleted from server.
291 * @param[in] callback Specifies the callback function for retrieving deleting information.
292 * @param[in] handle Reserved.
293 * @param[out] err_code Specifies the error code returned.
295 * @return This function returns true on success or false on failure.
298 INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
301 * Delete all mail from a mailbox.
303 * @param[in] input_mailbox_id Specifies the id of target mailbox.
304 * @param[in] input_from_server Specifies whether mails are also deleted from server.
305 * @param[in] output_handle Reserved.
306 * @param[out] output_err_code Specifies the error code returned.
308 * @return This function returns true on success or false on failure.
310 INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code);
313 * Move a email to another mailbox.
316 * @param[in] mail_id Specifies the mail ID.
317 * @param[in] dst_mailbox_id Specifies the mailbox ID for moving email.
318 * @param[in] noti_param_1 Specifies first parameter of result notification.
319 * @param[in] noti_param_2 Specifies second parameter of result notification.
320 * @param[out] err_code Specifies the error code returned.
322 * @return This function returns true on success or false on failure.
324 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);
327 * Move all email to another mailbox.
330 * @param[in] src_mailbox_id Specifies the source mailbox ID for moving email.
331 * @param[in] dst_mailbox_id Specifies the destination mailbox ID for moving email.
332 * @param[out] err_code Specifies the error code returned.
334 * @return This function returns true on success or false on failure.
336 INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailbox_id, int* err_code);
340 * Update a existing email information.
342 * @param[in] input_mail_data Specifies the structure of mail data.
343 * @param[in] input_attachment_data_list Specifies the structure of mail data.
344 * @param[in] input_attachment_count Specifies the pointer of attachment structure.
345 * @param[in] input_meeting_request Specifies the number of attachment data.
346 * @param[in] input_from_eas Specifies whether the mail is from EAS.
348 * @return This function returns EMAIL_ERROR_NONE on success or error code on failure.
350 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);
354 * Callback for mail resend
356 * @param[in] data Specifies the pointer to mail_id.
358 * @return This function returns void.
360 INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data );
363 * Download email body from server.
365 * @param[in] account_id Specifies the account ID.
366 * @param[in] mail_id Specifies the mail ID.
367 * @param[in] callback Specifies the callback function for retrieving download status.
368 * @param[in] handle Specifies the handle for stopping downloading.
369 * @param[out] err_code Specifies the error code returned.
371 * @return This function returns true on success or false on failure.
373 INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code);
376 * Get a mail attachment.
378 * @param[in] mail_id Specifies the mail ID.
379 * @param[in] attachment_id Specifies the attachment ID.
380 * @param[out] attachment The returned attachment is save here.
381 * @param[out] err_code Specifies the error code returned.
383 * @return This function returns true on success or false on failure.
385 INTERNAL_FUNC int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachment, int* err_code);
388 * Download a email nth-attachment from server.
390 * @param[in] account_id Specifies the account ID.
391 * @param[in] mail_id Specifies the mail ID.
392 * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1".
393 * @param[in] callback Specifies the callback function for retrieving download status.
394 * @param[in] handle Specifies the handle for stopping downloading.
395 * @param[out] err_code Specifies the error code returned.
397 * @return This function returns true on success or false on failure.
399 INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, int *handle, int* err_code);
403 * Append a attachment to email.
405 * @param[in] mail_id Specifies the mail ID.
406 * @param[in] attachment Specifies the structure of attachment.
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_add_attachment(int mail_id, email_attachment_data_t* attachment, int* err_code);
414 * Delete a attachment from email.
416 * @param[in] mail_id Specifies the mail id.
417 * @param[in] attachment_id Specifies the attachment id.
418 * @param[out] err_code Specifies the error code returned.
420 * @return This function returns true on success or false on failure.
422 INTERNAL_FUNC int emdaemon_delete_mail_attachment(int attachment_id, int* err_code);
425 * Free allocated memroy for email attachment.
427 * @param[in] atch_info Specifies the pointer of mail attachment structure pointer.
428 * @param[out] err_code Specifies the error code returned.
430 * @return This function returns true on success or false on failure.
432 INTERNAL_FUNC int emdaemon_free_attachment_data(email_attachment_data_t** atch_info, int* err_code);
435 * Change email read/unread flag.
436 * @param[in] account_id Specifies the account id.
437 * @param[in] mail_ids Specifies the array of mail ID.
438 * @param[in] num Specifies the numbers of mail ID.
439 * @param[in] field_type Specifies the field type what you want to set. Refer email_flags_field_type.
440 * @param[in] value Specifies the value what you want to set.
441 * @param[in] onserver Specifies the mail on server.
442 * @param[out] err_code Specifies the error code returned.
444 * @return This function returns true on success or false on failure.
446 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);
448 /*****************************************************************************/
450 /*****************************************************************************/
451 INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, int *handle, int* err_code);
454 * Download header of new emails from mail server.
456 * @param[in] input_account_id Specifies the account ID.
457 * @param[in] input_mailbox_id Specifies the mailbox ID.
458 * @param[out] handle Specifies the handle for stopping downloading.
459 * @param[out] err_code Specifies the error code returned.
461 * @return This function returns true on success or false on failure.
463 INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, int *handle, int* err_code);
467 * Get mail count from mailbox.
469 * @param[in] mailbox Specifies the pointer of mailbox structure.
470 * @param[out] total Total email count is saved here.
471 * @param[out] unseen Unread email count is saved here.
472 * @param[out] err_code Specifies the error code returned.
474 * @return This function returns true on success or false on failure.
476 INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, int* total, int* unseen, int* err_code);
479 * Get all mailboxes from account.
481 * @param[in] account_id Specifies the account ID.
482 * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL)
483 * @param[out] count The mailbox count is saved here.(possibly 0)
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_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code);
491 * Create a new mailbox.
493 * @param[in] new_mailbox Specifies the pointer of creating 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_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
504 * @param[in] input_mailbox_id Specifies the input_mailbox_id of deleting mailbox information.
505 * @param[out] handle Specifies the handle for stopping creating mailbox.
506 * @param[out] err_code Specifies the error code returned.
508 * @return This function returns true on success or false on failure.
510 INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, int *handle, int* err_code);
513 * Delete all sub-mailboxes from a specific mailbox.
515 * @param[in] mailbox Specifies the pointer of mailbox information.
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_delete_mailbox_all(email_mailbox_t* mailbox, int* err_code);
523 * Free allocated memory for mailbox information.
525 * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer.
526 * @param[in] count Specifies the count of mailboxes.
527 * @param[out] err_code Specifies the error code returned.
529 * @return This function returns true on success or false on failure.
531 INTERNAL_FUNC int emdaemon_free_mailbox(email_mailbox_t** mailbox_list, int count, int* err_code);
533 /*****************************************************************************/
535 /*****************************************************************************/
539 * Register 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.
543 * @param[in] event_data Event data which will be passed to the callback.
545 * @return This function returns true on success or false on failure.
547 INTERNAL_FUNC int emdaemon_register_event_callback(email_action_t action, email_event_callback callback, void* event_data);
550 * Unregister a callback for event processing.
552 * @param[in] action Kind of event callback.
553 * @param[in] callback Function which will be called during processing event.
555 * @return This function returns true on success or false on failure.
557 INTERNAL_FUNC int emdaemon_unregister_event_callback(email_action_t action, email_event_callback callback);
560 * Get current event queue status.
562 * @param[out] on_sending True if sending is in progress.
563 * @param[out] on_receiving True if receiving is in progress.
566 INTERNAL_FUNC void emdaemon_get_event_queue_status(int* on_sending, int* on_receiving);
569 * Get the handle of a pending job.
571 * @param[in] action Specifies kind of the job.
572 * @param[in] account_id Specifies the account ID.
573 * @param[in] mail_id Specifies the mail ID.
575 * @return This function return its handle if a pending job exists, otherwise -1.
577 INTERNAL_FUNC int emdaemon_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t* status);
580 * Cancel a progressive work.
582 * @param[in] account_id Specifies the account ID.
583 * @param[in] handle Specifies the ID of cancelling work.
584 * @param[out] err_code Specifies the error code returned.
586 * @return This function returns true on success or false on failure.
588 INTERNAL_FUNC int emdaemon_cancel_job(int account_id, int handle, int* err_code);
593 * Cancel a progressive send mail job.
595 * @param[in] account_id Specifies the account ID.
596 * @param[in] mail_id Specifies the Mail ID of cancelling send mail.
597 * @param[out] err_code Specifies the error code returned.
599 * @return This function returns true on success or false on failure.
601 INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, int* err_code);
606 * @param[in] option Specifies the email options.
607 * @param[out] err_code Specifies the error code returned.
609 * @return This function returns true on success or false on failure.
611 INTERNAL_FUNC int emdaemon_set_option(email_option_t* option, int* err_code);
616 * @param[out] option Specifies the email options.
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_get_option(email_option_t* option, int* err_code);
624 * Sync the Local activity
627 * @param[in] account_id Specifies the Account ID.
628 * @param[out] err_code Specifies the error code returned.
630 * @return This function returns true on success or false on failure.
632 INTERNAL_FUNC int emdaemon_sync_local_activity(int account_id, int *err_code);
635 #ifdef __FEATURE_AUTO_POLLING__
636 INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code);
637 #endif /* __FEATURE_AUTO_POLLING__ */
639 INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* account);
641 INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_account, email_account_t* new_account);
643 INTERNAL_FUNC int emdaemon_update_mailbox(email_mailbox_t* old_mailbox, email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
645 INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
647 INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox);
649 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);
651 INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code);
653 INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code);
655 INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, int *handle, int* err_code);
657 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);
659 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);
661 INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag, int *err_code);
663 INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, int *handle, int *err_code);
665 INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, int *handle, int *err_code);
667 INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle);
671 #endif /* __cplusplus */
677 #endif /* __EMAIL_DAEMON_H__ */