4 * @defgroup EMAILSVC Email Service
6 <h1 class="pg">Introduction</h1>
7 <h2 class="pg">Overview </h2>
8 Electronic mail, most commonly abbreviated email or e-mail, is a method of exchanging digital messages. E-mail systems are based on a store-and-forward model in which e-mail server computer systems accept, forward, deliver and store messages on behalf of users, who only need to connect to the e-mail infrastructure, typically an e-mail server, with a network-enabled device for the duration of message submission or retrieval.
10 <h2 class="pg">Purpose of Programming Guide</h2>
11 This document is mainly aimed at the core functionality of the Email Service. The EMail Service component is implemented by Samsung to provide EMail service to applications that make use of EMail Engine. Email Engine provides functionality for the user like composing mail, saving mail, sending mail, and creating user mailbox according to the settings. Mobile subscribers can use the Email Engine to perform storage opearations such as save, update, get, delete and transport operations such as send, download and other email operations.
13 This programming guide is prepared for application developers who will use the email-service. It contains:
14 - List of features offered by email-service
15 - Information on How to use APIs provided by the email-service
18 <h2 class="pg">Target Domain / Application</h2>
19 The Email Service Layer can be utilized by any component in the application layer which allow the end user to perform the email related operations such as save, send, download email message and others.
21 For Example, the Email Service APIs shall be invoked by
22 @li Multimedia application when user opts to send media file through email
23 @li Email application when user tries to send an email message
25 <h2 class="pg">Terminology & Acronyms</h2>
27 <tr><th>Terminology</th><th>Description</th></tr>
28 <tr><td>Email </td><td>Electronic mail</td></tr>
29 <tr><td>IMAP</td><td>Internet Message Access Protocol</td></tr>
30 <tr><td>SMTP</td><td>Simple mail transfer protocol for sending mails</td></tr>
31 <tr><td>POP3</td><td>Post office protocol for receiving mails</td></tr>
32 <tr><td>RFC822</td><td>Describes mail header, to address, cc, bcc etc. formats and decoding and encoding standards. </td></tr>
33 <tr><td>OMA </td><td>Open Moblie Alliance</td></tr>
39 @defgroup Email_Architecture 1. Email Service Architecture
42 <h1 class="pg">Email-service Architecture</h1>
43 <h2 class="pg">System Architecture</h2>
44 @image html email_image001.png
46 <h2 class="pg">Process Architecture</h2>
47 @image html email_image002.png email-service Process view
49 @image html email_image003.png email-service Process architecture
51 Whenever an application wants to use email-service, it will call APIs from Email MAPI layer. Email MAPI layer APIs will internally call APIs provided by email framework module.
54 @defgroup Email_Feature 2. Email Service Feature
57 <h1 class="pg">Email-service Features</h1>
59 <tr><th>Feature </th><th>API Reference</th></tr>
60 <tr><td>Account Operation</td>
62 @n email_add_account()
63 @n email_delete_account()
64 @n email_update_account()
65 @n email_get_account()
66 @n email_get_account_list()
67 @n email_free_account()
68 @n email_validate_account()
71 <tr><td>mailbox Operation </td>
73 @n email_add_mailbox()
74 @n email_delete_mailbox()
75 @n email_update_mailbox()
76 @n email_get_mailbox_list()
77 @n email_get_mailbox_by_name()
78 @n email_get_child_mailbox_list()
79 @n email_get_mailbox_by_mailbox_type()
82 <tr><td>Message Operation </td>
84 @n email_add_message()
85 @n email_update_message()
87 @n email_delete_mail()
88 @n email_delete_all_mails_in_mailbox()
89 @n email_clear_mail_data()
90 @n email_add_attachment()
91 @n email_delete_attachment()
93 @n email_free_mail_info()
94 @n email_get_header_info()
95 @n email_free_header_info()
96 @n email_get_body_info()
97 @n email_free_body_info()
98 @n email_get_attachment_data()
99 @n email_free_attachment_info()
101 @n email_modify_mail_flag()
102 @n email_modify_seen_flag()
103 @n email_modify_extra_mail_flag()
104 @n email_move_mail_to_mailbox()
105 @n email_move_all_mails_to_mailbox()
106 @n email_count_message_with_draft_flag()
107 @n email_count_message_on_sending()
108 @n email_get_mailbox_list()
109 @n email_free_mailbox()
111 @n email_get_mail_flag()
112 @n email_free_mail_list()
113 @n email_release_mail()
114 @n email_retry_sending_mail()
115 @n email_make_db_full()
116 @n email_get_mailbox_name_by_mail_id()
117 @n email_cancel_sending_mail()
118 @n email_count_message_all_mailboxes()
119 @n email_get_latest_unread_mail_id()
120 @n email_get_max_mail_count()
121 @n email_get_disk_space_usage()
124 <tr><td>Network Operation </td>
127 @n email_sync_header()
128 @n email_download_body()
129 @n email_download_attachment()
130 @n email_cancel_job()
131 @n email_get_pending_job()
132 @n email_get_network_status()
133 @n email_send_report()
134 @n email_send_saved()
135 @n email_sync_imap_mailbox_list()
136 @n email_sync_local_activity()
139 <tr><td>Rule Operation </td>
142 @n email_get_rule_list()
144 @n email_update_rule()
145 @n email_delete_rule()
149 <tr><td>Control Operation </td>
151 @n email_init_storage()
154 @n email_service_begin()
155 @n email_service_end()
162 @defgroup Use_Case1_account Account Operation
163 @ingroup EMAIL_USECASES
165 <h2 class="pg">Account Operation </h2>
166 Account Operations are a set of operations to manage email accounts like add, update, delete or get account related details.
169 email_account_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
172 <td>Return Value / Exceptions</td></tr>
174 <tr><td>int email_add_account(email_account_t* account)</td>
175 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_account_t* account should be allocated and deallocated by Application</td></tr>
177 <tr><td>int email_delete_account(int account_id) </td>
178 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
180 <tr><td>int email_update_account(int account_id , email_account_t* new_account) </td>
181 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_account_t* new_account should be allocated and deallocated by Application</td></tr>
183 <tr><td>int email_get_account(int account_id, int pulloption, email_account_t** account) </td>
184 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param account will happen in email_get_account (). To free this memory, application should call email_free_account ()</td></tr>
186 <tr><td>int email_get_account_list(email_account_t** account_list, int* count) </td>
187 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: Memory allocation for param ccount_list will happen in email_get_account_list (). To free this memory, application should call email_free_account () </td></tr>
189 <tr><td>int email_free_account(email_account_t** account_list, int count) </td>
190 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
192 <tr><td>int email_validate_account(int account_id, unsigned* handle)</td>
193 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
201 /* Assign values for new account */
202 email_account_t *account = NULL;
204 account = malloc(sizeof(email_account_t));
205 memset(account, 0x00, sizeof(email_account_t));
207 account->retrieval_mode = 1;
208 account->incoming_server_secure_connection = 1;
209 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
210 account->outgoing_server_port_number = EMAIL_SMTP_PORT;
211 account->outgoing_server_need_authentication = 1;
212 account->account_name = strdup("gmail");
213 account->display_name = strdup("Tom");
214 account->user_email_address = strdup("tom@gmail.com");
215 account->reply_to_addr = strdup("tom@gmail.com");
216 account->return_addr = strdup("tom@gmail.com");
217 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
218 account->incoming_server_address = strdup("pop3.gmail.com");
219 account->incoming_server_port_number = 995;
220 account->incoming_server_secure_connection = 1;
221 account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL;
222 account->incoming_server_user_name = strdup("tom");
223 account->password = strdup("tioimi");
224 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
225 account->outgoing_server_address = strdup("smtp.gmail.com");
226 account->outgoing_server_port_number = 587;
227 account->outgoing_server_secure_connection = 0x02;
228 account->outgoing_server_need_authentication = 1;
229 account->outgoing_server_user_name = strdup("tom@gmail.com");
230 account->sending_password = strdup("tioimi");
231 account->pop_before_smtp = 0;
232 account->incoming_server_requires_apop = 0;
235 account->is_preset_account = 1;
236 account->logo_icon_path = strdup("Logo Icon Path");
237 account->options.priority = 3;
238 account->options.keep_local_copy = 0;
239 account->options.req_delivery_receipt = 0;
240 account->options.req_read_receipt = 0;
241 account->options.download_limit = 0;
242 account->options.block_address = 0;
243 account->options.block_subject = 0;
244 account->options.display_name_from = strdup("Display name from");
245 account->options.reply_with_body = 0;
246 account->options.forward_with_files = 0;
247 account->options.add_myname_card = 0;
248 account->options.add_signature = 0;
249 account->options.signature = strdup("Signature");
250 account->check_interval = 0;
252 if(EMAIL_ERROR_NONE != email_add_account(account))
258 *account_id = account->account_id; /* Use this returned account id when calling APIs which need it */
262 email_free_account(&account, 1);
270 email_account_t *account = NULL;
271 int account_id = 1; /* account id to be gotten */
273 if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account))
279 email_free_account(&account, 1);
287 email_account_t *new_account = NULL;
288 int account_id = 1; /* account id to be updated */
290 /* Get account to be updated */
291 if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&new_account))
296 /* Set the new values */
297 new_account->flag1 = 1;
298 new_account->account_name = strdup("gmail");
299 new_account->display_name = strdup("Tom001");
300 new_account->options.keep_local_copy = 1;
301 new_account->check_interval = 55;
303 if(EMAIL_ERROR_NONE != email_update_account(account_id,new_account))
309 email_free_account(&new_account, 1);
317 int account_id = 1; /* account id to be deleted */
319 if(EMAIL_ERROR_NONE != email_delete_account(account_id))
327 @li Get list of accounts
329 /* Get list of accounts */
331 email_account_t *account_list = NULL;
335 if(EMAIL_ERROR_NONE != email_get_account_list(&account_list,&count))
340 for ( i = 0; i < count; i++ )
342 /* Do something with each account */
343 printf("account id : %d\n", account_list[i].account_id);
348 email_free_account(&account_list,count);
352 @li Validate account - try to connect to server
354 /* Validate account - try to connect to server */
355 unsigned account_handle = 0;
358 if(EMAIL_ERROR_NONE != email_validate_account(account_id,&account_handle))
365 @image html email_image004.png
368 @defgroup Use_Case2_folder mailbox Operation
369 @ingroup EMAIL_USECASES
371 <h2 class="pg">mailbox Operation </h2>
372 mailbox Operations are a set of operations to manage email mailboxes like add, update, delete or get mailbox related details.
375 email_mailbox_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
378 <tr><td>API</td><td>Return Value / Exceptions</td></tr>
380 <tr><td>int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle) </td>
381 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* new_mailbox should be allocated and deallocated by Application </td></tr>
383 <tr><td>int email_delete_mailbox(email_mailbox_t* mailbox, int on_server, unsigned* handle) </td>
384 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
386 <tr><td>int email_update_mailbox(email_mailbox_t*old_mailbox, email_mailbox_t* new_mailbox)</td>
387 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* old_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
389 <tr><td>int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t** mailbox_list, int* count)</td>
390 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_list (). To free this memory application should call email_free_mailbox</td></tr>
392 <tr><td>int email_get_mailbox_by_name(int account_id, const char *pMailboxName, email_mailbox_t **pMailbox)</td>
393 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param pMailbox will happen in email_get_mailbox_by_name (). To free this memory application should call email_free_mailbox</td></tr>
395 <tr><td>int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, email_mailbox_t** mailbox_list, int* count)</td>
396 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_child_mailbox_list (). To free this memory application should call email_free_mailbox</td></tr>
398 <tr><td>int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox)</td>
399 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_by_mailbox_type (). To free this memory application should call email_free_mailbox</td></tr>
404 @li Create new mailbox
406 email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
410 mailbox = malloc(sizeof(email_mailbox_t));
411 memset(mailbox, 0x00, sizeof(email_mailbox_t));
413 mailbox->mailbox_name = strdup("Personal");
414 mailbox->alias = strdup("selfuse");
415 mailbox->account_id = 1;
416 mailbox->local = on_server;
417 mailbox->mailbox_type = 7;
419 /* create new mailbox */
420 if(EMAIL_ERROR_NONE != email_add_mailbox(mailbox,on_server,&handle))
428 @li Update and Delete mailbox
430 email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
434 new_mailbox = malloc(sizeof(email_mailbox_t));
435 memset(new_mailbox, 0x00, sizeof(email_mailbox_t));
437 new_mailbox->mailbox_name = strdup("Personal001");
440 if(EMAIL_ERROR_NONE != email_update_mailbox(mailbox,new_mailbox))
446 if(EMAIL_ERROR_NONE != email_delete_mailbox(mailbox,on_server,&handle))
451 email_free_mailbox(&mailbox, 1);
452 email_free_mailbox(&new_mailbox, 1);
456 @li Get list of mailboxes
460 email_mailbox_t* mailbox_list = NULL;
463 /*get list of mailboxes */
464 if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, local_yn, &mailbox_list, &count))
469 email_free_mailbox(&mailbox_list,count);
474 @image html email_image005.png
477 @defgroup Use_Case3_message Message Operation
478 @ingroup EMAIL_USECASES
480 <h2 class="pg">Message Operation </h2>
481 Message Operations are a set of operations to manage email messages like add, update, delete or get message related details.
487 <td>Return Value / Exceptions</td></tr>
489 <tr><td>int email_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) </td>
490 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application</td></tr>
492 <tr><td>int email_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) </td>
493 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application</td></tr>
495 <tr><td>int email_count_mail(email_mailbox_t* mailbox, int* total, int* unseen) </td>
496 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
498 <tr><td>int email_delete_mail(email_mailbox_t* mailbox, int *mail_ids, int num, int from_server) </td>
499 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and mf_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
501 <tr><td>int email_delete_all_mails_in_mailbox(email_mailbox_t* mailbox, int from_server) </td>
502 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
504 <tr><td>int email_clear_mail_data() </td>
505 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
507 <tr><td>int email_add_attachment(email_mailbox_t* mailbox, int mail_id, email_attachment_data_t* attachment)</td>
508 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox and mf_attachment_info_t* attachment hould be allocated and deallocated by Application</td></tr>
510 <tr><td>int email_delete_attachment(email_mailbox_t * mailbox, int mail_id, const char * attachment_id)</td>
511 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
513 <tr><td>int email_get_attachment_data(email_mailbox_t* mailbox, int mail_id, const char* attachment_id, email_attachment_data_t** attachment)</td>
514 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.@n Remarks:
515 -# Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
516 -# Memory allocation for param email_attachment_data_t** attachment will happen in email_get_attachment_data (). To free this memory, application should call email_free_attachment_info () </td></tr>
518 <tr><td>int email_free_attachment_info(email_attachment_data_t** atch_info) </td>
519 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
521 <tr><td>int email_modify_mail_flag(int mail_id, email_mail_flag_t new_flag, int onserver) </td>
522 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
524 <tr><td>int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver) </td>
525 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param int *mail_ids should be allocated and deallocated by Application</td></tr>
527 <tr><td>int email_modify_extra_mail_flag(int mail_id, email_extra_flag_t new_flag) </td>
528 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
530 <tr><td>int email_move_mail_to_mailbox(int *mail_ids, int num, email_mailbox_t* new_mailbox) </td>
531 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
533 <tr><td>int email_move_all_mails_to_mailbox(email_mailbox_t* src_mailbox, email_mailbox_t* new_mailbox) </td>
534 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* src_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
536 <tr><td>int email_count_message_with_draft_flag(email_mailbox_t* mailbox, int* total) </td>
537 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
539 <tr><td>int email_count_message_on_sending(email_mailbox_t* mailbox, int* total) </td>
540 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
542 <tr><td>int email_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count ) </td>
543 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param email_mailbox_t** mailbox_list will happen in email_get_mailbox_list (). To free this memory, application should call email_free_mailbox ()</td></tr>
545 <tr><td>int email_free_mailbox(email_mailbox_t** mailbox_list, int count) </td>
546 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
548 <tr><td>int email_get_mail_flag(int account_id, int mail_id, email_mail_flag_t* mail_flag) </td>
549 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
551 <tr><td>int email_retry_sending_mail( int mail_id, int timeout_in_sec) </td>
552 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
554 <tr><td>int email_make_db_full()</td>
555 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
557 <tr><td>int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)</td>
558 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
560 <tr><td>int email_cancel_sending_mail( int mail_id) </td>
561 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
563 <tr><td>int email_count_message_all_mailboxes(email_mailbox_t* mailbox, int* total, int* unseen) </td>
564 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
566 <tr><td>int email_get_latest_unread_mail_id(int account_id, int *pMailID) </td>
567 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
569 <tr><td>int email_get_max_mail_count(int *Count) </td>
570 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
572 <tr><td>int email_get_disk_space_usage(unsigned long *total_size)</td>
573 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
578 @li Add, Update, Count and Delete message
580 email_mailbox_t *mailbox = NULL;
581 int on_server = 0, account_id = 0, mail_id = 0;
582 char *pFilePath = "/tmp/mail.txt";
586 int attachment_count = 0;
587 int err = EMAIL_ERROR_NONE;
588 char arg[50] = { 0 , };
589 char *body_file_path = "/opt/data/email/.emfdata/tmp/mail.txt";
590 email_mailbox_t *mailbox_data = NULL;
591 email_mail_data_t *test_mail_data = NULL;
592 email_attachment_data_t *attachment_data = NULL;
593 email_meeting_request_t *meeting_req = NULL;
596 printf("\n > Enter account id : ");
597 scanf("%d", &account_id);
599 memset(arg, 0x00, 50);
600 printf("\n > Enter mailbox name : ");
603 email_get_mailbox_by_name(account_id, arg, &mailbox_data);
605 test_mail_data = malloc(sizeof(email_mail_data_t));
606 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
608 printf("\n From EAS? [0/1]> ");
609 scanf("%d", &from_eas);
611 test_mail_data->account_id = account_id;
612 test_mail_data->save_status = 1;
613 test_mail_data->flags_seen_field = 1;
614 test_mail_data->file_path_plain = strdup(body_file_path);
615 test_mail_data->mailbox_name = strdup(mailbox_data->mailbox_name);
616 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
617 test_mail_data->full_address_from = strdup("<test1@test.com>");
618 test_mail_data->full_address_to = strdup("<test2@test.com>");
619 test_mail_data->full_address_cc = strdup("<test3@test.com>");
620 test_mail_data->full_address_bcc = strdup("<test4@test.com>");
621 test_mail_data->subject = strdup("Meeting request mail");
623 body_file = fopen(body_file_path, "w");
625 for(i = 0; i < 500; i++)
626 fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2");
631 if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE)
632 printf("email_add_mail failed. [%d]\n", err);
634 printf("email_add_mail success.\n");
637 /* variable 'mail' should be filled with data on DB. */
638 /* And change values you want to update. */
639 mail->head->subject = strdup("save.mailbox again...");
641 if(EMAIL_ERROR_NONE != email_update_message(mail_id,mail))
647 int total = 0, unseen = 0;
649 /* Get the total number of mails and the number of unseen mails */
650 if(EMAIL_ERROR_NONE != email_count_mail(mailbox,&total,&unseen))
656 int *mail_ids, num = 0;
658 if(EMAIL_ERROR_NONE != email_delete_mail(mailbox,mail_ids,num,on_server))
664 @li Delete all message in a specific mailbox
666 /* Delete all message in mailbox */
667 email_mailbox_t *mailbox = NULL;
670 mailbox = malloc(sizeof(email_mailbox_t));
671 memset(mailbox, 0x00, sizeof(email_mailbox_t));
673 mailbox->account_id = 1;
674 mailbox->mailbox_name = strdup("INBOX");
676 if( EMAIL_ERROR_NONE != email_delete_all_mails_in_mailbox(mailbox, on_server))
684 @li Clear all messages
686 /* clear mail data */
687 if(EMAIL_ERROR_NONE != email_clear_mail_data())
695 email_mail_flag_t newflag = {0};
699 /* Modify mail flag*/
700 if(EMAIL_ERROR_NONE != email_modify_mail_flag(mail_id,newflag,on_server))
705 int mail_ids[] = {1, 2};
710 /* Modify seen flag*/
711 if(EMAIL_ERROR_NONE != email_modify_seen_flag(mail_ids, num, seen_flag,on_server))
716 /* Modify extra flag*/
718 if(EMAIL_ERROR_NONE != email_modify_extra_mail_flag(mail_id, newflag))
727 int mail_id[],account_id = 1;
728 email_mailbox_t *mailbox = NULL;
729 char *mailbox_name = "INBOX";
731 mailbox = malloc(sizeof(email_mailbox_t));
732 memset(mailbox, 0x00, sizeof(email_mailbox_t));
734 mailbox->account_id = account_id;
735 mailbox->mailbox_name = mailbox_name;
737 /* Move mail to given mailbox*/
738 if(EMAIL_ERROR_NONE != email_move_mail_to_mailbox(/*mail_id*/,/*num*/,mailbox))
744 email_free_mailbox(&mailbox,1);
746 email_mailbox_t *src_mailbox = NULL,*dest_mailbox = NULL;
747 int src_account_id = 0, dest_account_id = 0;
748 char * src_mailbox_name = NULL, *dest_mailbox_name = NULL;
750 src_mailbox = malloc(sizeof(email_mailbox_t));
751 memset(src_mailbox, 0x00, sizeof(email_mailbox_t));
753 dest_mailbox = malloc(sizeof(email_mailbox_t));
754 memset(dest_mailbox, 0x00, sizeof(email_mailbox_t));
756 src_mailbox->account_id = /*src_account_id*/;
757 src_mailbox->mailbox_name = /*src_mailbox_name*/
759 dest_mailbox->account_id = /*dest_account_id*/;
760 dest_mailbox->mailbox_name = /*dest_mailbox_name*/
762 /*move all mails to given mailbox*/
763 if(EMAIL_ERROR_NONE != email_move_all_mails_to_mailbox(src_mailbox,dest_mailbox))
769 email_free_mailbox(&src_mailbox,1);
770 email_free_mailbox(&dest_mailbox,1);
772 int account_id = 0, total = 0;
773 email_mailbox_t *mailbox = NULL;
774 char *mailbox_name = NULL;
776 mailbox = malloc(sizeof(email_mailbox_t));
777 memset(mailbox, 0x00, sizeof(email_mailbox_t));
779 mailbox->account_id = /*account_id*/;
780 mailbox->mailbox_name = /*mailbox_name*/
782 /*count of draft msgs*/
783 if(EMAIL_ERROR_NONE != email_count_message_with_draft_flag(mailbox,&total))
789 email_free_mailbox(&mailbox,1);
792 @li Count of msgs sent from given folde
794 int account_id = 0, total = 0;
795 email_mailbox_t *mailbox = NULL;
796 char *mailbox_name = NULL;
798 mailbox = malloc(sizeof(email_mailbox_t));
799 memset(mailbox, 0x00, sizeof(email_mailbox_t));
801 mailbox->account_id = /*account_id*/;
802 mailbox->mailbox_name = /*mailbox_name*/
804 /*count of msgs sent from given mailbox*/
805 if(EMAIL_ERROR_NONE != email_count_message_on_sending(mailbox,&total))
811 email_free_mailbox(&mailbox,1);
819 email_mailbox_t* mailbox_list = NULL;
820 int account_id = 1, count = 0;
822 /* Get mailbox list*/
823 if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,&mailbox_list,&count))
828 /* free mailbox list*/
829 email_free_mailbox(&mailbox,count);
833 @li Get mailBox name by mailID
835 /* Get mailBox name by mailID*/
837 char *pMailbox_name=strdup("INBOX");
838 err = email_get_mailbox_name_by_mail_id(mail_id,&pMailbox_name);
845 @li Cancel sending mail
848 /* email_cancel_sending_mail*/
849 int mail_id = 1; /* mail id of a mail which is on sending */
850 err = email_cancel_sending_mail(mail_id);
856 @li Get the Total count and Unread count of all mailboxes
858 /* Get the Total count and Unread count of all mailboxes */
859 email_mailbox_t* mailbox = NULL;
860 int account_id = 1, total = 0, unseen = 0;
861 char *mailbox_name = NULL;
863 mailbox = malloc(sizeof(email_mailbox_t));
864 memset(mailbox, 0x00, sizeof(email_mailbox_t));
866 mailbox->account_id = /*account_id*/;
867 mailbox->mailbox_name = /*mailbox_name*/
869 err = email_count_message_all_mailboxes(mailbox,&total,&unseen);
874 @image html email_image006.png
876 @image html email_image007.png
878 @image html email_image008.png
881 @defgroup Use_Case4_network Network Operation
882 @ingroup EMAIL_USECASES
884 <h2 class="pg">Network Operation </h2>
885 Network Operations are a set of operations to manage email send, receive and cancel related details.
888 email_option_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
891 <td>Return Value / Exceptions</td></tr>
893 <tr><td>int email_send_mail( email_mailbox_t* mailbox, int mail_id, email_option_t* sending_option, unsigned* handle)</td>
894 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
895 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
897 <tr><td>int email_sync_header(email_mailbox_t* mailbox, unsigned* handle)</td>
898 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
899 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
901 <tr><td>int email_download_body(email_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle) </td>
902 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
903 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
905 <tr><td>int email_download_attachment(email_mailbox_t* mailbox, int mail_id, const char* nth, unsigned* handle)</td>
906 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
908 <tr><td>int email_cancel_job(int account_id, int handle)</td>
909 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
911 <tr><td>int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status)</td>
912 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
914 <tr><td>void email_get_network_status(int* on_sending, int* on_receiving) </td>
915 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
917 <tr><td>int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle)</td>
918 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
919 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
921 <tr><td>int email_sync_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle)</td>
922 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
924 <tr><td>int email_sync_local_activity(int account_id)</td>
925 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
931 /* TODO : Write sample to send a mail. */
934 @li Download header of new emails from mail server
936 /* Download header of new emails from mail server*/
937 email_mailbox_t mailbox;
939 int err = EMAIL_ERROR_NONE;
942 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
944 mailbox.account_id = account_id;
945 mailbox.mailbox_name = strdup("INBOX");
946 err = email_sync_header (&mailbox,&handle);
950 @li Download email body from server
953 /*Download email body from server*/
954 email_mailbox_t mailbox;
958 int err = EMAIL_ERROR_NONE;
960 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
961 mailbox.account_id = account_id;
962 mailbox.mailbox_name = strdup("INBOX");
963 err= email_download_body (&mailbox,mail_id,0,&handle);
965 @li Download a email nth-attachment from server
967 /*Download a email nth-attachment from server*/
968 email_mailbox_t mailbox;
971 char arg[50]; /* Input attachment number need to be download */
973 int err = EMAIL_ERROR_NONE;
975 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
976 mailbox.mailbox_name = "INBOX";
977 mailbox.account_id = account_id;
978 err=email_download_attachment(&mailbox,mail_id,arg,&handle);
982 @image html email_image009.png
985 @defgroup Use_Case5_rule Rule Operation
986 @ingroup EMAIL_USECASES
988 <h2 class="pg">Rule Operation</h2>
989 Rule Operations are a set of operations to manage email rules like add, get, delete or update rule related details.
992 email_rule_t- refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
995 <td>Return Value / Exceptions</td></tr>
997 <tr><td>int email_get_rule(int filter_id, email_rule_t** filtering_set)</td>
998 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
999 -# Memory allocation for the param email_rule_t** filtering_set will be done in this api.
1000 -# De-allocation is to be done by application.</td></tr>
1002 <tr><td>int email_get_rule_list(email_rule_t** filtering_set, int* count)</td>
1003 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
1004 -# Memory allocation for the param email_rule_t** filtering_set will be done in this api.
1005 -# De-allocation is to be done by application.</td></tr>
1007 <tr><td>int email_add_rule(email_rule_t* filtering_set) </td>
1008 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
1009 -# Memory allocation and de-allocation is to be done by application.
1010 -# Use email_free_rule to free allocated memory.</td></tr>
1012 <tr><td>int email_update_rule(int filter_id, email_rule_t* new_set) </td>
1013 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
1014 -# Memory allocation and de-allocation is to be done by application.</td></tr>
1015 -# Use email_free_rule to free allocated memory.
1017 <tr><td>int email_delete_rule(int filter_id)</td>
1018 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
1020 <tr><td>int email_free_rule(email_rule_t** filtering_set, int count)</td>
1021 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
1025 @li Filter Operation
1027 int err = EMAIL_ERROR_NONE;
1028 email_rule_t* rule = NULL;
1031 /* Get a information of filtering*/
1032 err = email_get_rule (filter_id,&rule);
1033 err = email_free_rule (&rule,1);
1035 /* Get all filterings */
1037 err = email_get_rule_list(&rule,&count);
1040 /* Add a filter information */
1041 err = email_add_rule (rule);
1042 err = email_free_rule (&rule,1);
1044 /* Change a filter information */
1045 err = email_update_rule (filter_id,rule);
1046 err = email_free_rule (&rule,1);
1048 /* Delete a filter information*/
1049 err = email_delete_rule (filter_id);
1051 /* Free allocated memory */
1052 err = email_free_rule (&rule,1);
1056 @image html email_image010.png
1059 @defgroup Use_Case6_control Control Operation
1060 @ingroup EMAIL_USECASES
1062 <h2 class="pg">Control Operation</h2>
1063 Control Operations are a set of operations to manage Email MAPI Layer initialization.
1064 The Application which will use the MAPIs MUST initialize IPC proxy and conntect to Email FW database before calling other APIs.
1065 And it MUST finalize IPC proxy and disconnect to the DB if the application doesn't use APIs.
1069 <td>Return Value / Exceptions</td></tr>
1071 <tr><td>int email_init_storage(void)</td>
1072 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
1074 <tr><td>int email_open_db(void)</td>
1075 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
1077 @n Application should call email_close_db once db operation is over</td></tr>
1079 <tr><td>int email_close_db(void)</td>
1080 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
1082 @n This API should be called only if email_open_db () is called.</td></tr>
1084 <tr><td>int email_service_begin(void)</td>
1085 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
1087 <tr><td>int email_service_end(void)</td>
1088 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
1090 @n This API should be called only if email_service_begin () is called.</td></tr>
1094 @li Initialize and Finalize Email MAPI Layer
1096 int err = EMAIL_ERROR_NONE;
1098 /* Initialize Email MAPI Layer before calling other MAPIs */
1099 if(EMAIL_ERROR_NONE == email_service_begin())
1101 if(EMAIL_ERROR_NONE != email_open_db())
1105 if(EMAIL_ERROR_NONE != email_init_storage())
1111 /* Call other MAPIs */
1115 /* Finalize Email MAPI Layer when finishing application */
1116 err = email_close_db();
1117 err = email_service_end();
1121 @image html email_image011.png
1124 @addtogroup Email_Feature
1126 <h1 class="pg">System Configuration</h1>
1127 <h2 class="pg">Files to be included</h2>
1131 <h2 class="pg">System Initialization and De-Initialization</h2>
1132 email_service_begin is used to initialize email-service at boot time.
1133 @n email_service_end is used to deinitialize email-service at shutdown.
1134 @n These two are separate executables.
1136 <h2 class="pg">Variable Configuration</h2>
1139 <h2 class="pg">Build Environment</h2>
1140 If the Application wants to use email-service Module, make sure that the following package should be included in the Makefile.
1144 <h2 class="pg">Runtime Environment</h2>
1148 @defgroup EMAL_Appendix 4. Reference
1151 <h1 class="pg">Appendix</h1>
1152 <h2 class="pg">Email</h2>
1153 @image html email_image012.png
1155 - Alice composed a message using MUA (Mail User Agent). Alice enters the e-mail address of her correspondent, and hits the "send" button.
1156 - MUA format the message using MIME and uses Simple mail Transfer Protocol to send the message to local MTA (Mail Transfer Agent) i,e smtp.a.org run by Alices ISP (Internet Service provider).
1157 - The MTA looks at the destination address provided in the SMTP protocol i,e bob@b.org. An Internet e-mail address is a string of the form localpart@exampledomain. The part before the @ sign is the local part of the address, often the username of the recipient, and the part after the @ sign is a domain name. The MTA resolves a domain name to determine the fully qualified domain name of the mail exchange server in the Domain Name System (DNS).
1158 - The DNS Server for the b.org domain, ns.b.org, responds with an MX Records listing the mail exchange servers for that domain, in this case mx.b.org, a server run by Bob's ISP.
1159 - smtp.a.org sends the message to mx.b.org using SMTP, which delivers it to the mailbox of the user bob.
1160 - Bob presses the "get mail" button in his MUA, which picks up the message using the Post Office Protocol (POP3).
1162 <h2 class="pg">RFC</h2>
1163 -# RFC 2821-SMTP(Simple Mail Transfer Protocol)
1164 -# RFC 1939-POP3(Post Office Protocol)
1165 -# RFC 3501-IMAP4(Internate message protocol)
1171 * @defgroup EMAILSVC
1173 * @defgroup EMAIL_USECASES 3. API Description
1176 <h1 class="pg">API Description</h1>
1177 This section describes APIs and shows the example of using them.