4 * Copyright (c) 2000 - 2011 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 #ifndef __EMF_MAPI_NETWORK_H__
24 #define __EMF_MAPI_NETWORK_H__
26 #include "emf-types.h"
29 * @defgroup EMAIL_FRAMEWORK Email Service
34 * @ingroup EMAIL_FRAMEWORK
35 * @defgroup EMAIL_MAPI_NETWORK Email Network API
41 * This file contains the data structures and interfaces needed for application,
42 * to interact with Email Engine.
43 * @file Emf_Mapi_Network.h
44 * @author Kyuho Jo <kyuho.jo@samsung.com>
45 * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
47 * @brief This file contains the data structures and interfaces of Network related Functionality provided by
54 * #include "Emf_Mapi_Network.h"
57 * other_app_invoke_uniform_api_sample(int* error_code)
62 * emf_mail_t *mail = NULL;
63 * emf_mail_head_t *head =NULL;
64 * emf_mail_body_t *body =NULL;
65 * emf_attachment_info_t attachment;
66 * emf_option_t option;
68 * int err = EMF_ERROR_NONE;
70 * char arg[50]; //Input attachment number need to be download
71 * emf_event_status_type_t status;
74 * int on_receiving = 0;
76 * mail =( emf_mail_t *)malloc(sizeof(emf_mail_t));
77 * head =( emf_mail_head_t *)malloc(sizeof(emf_mail_head_t));
78 * body =( emf_mail_body_t *)malloc(sizeof(emf_mail_body_t));
79 * mail->info =( emf_mail_info_t*) malloc(sizeof(emf_mail_info_t));
80 * memset(mail->info, 0x00, sizeof(emf_mail_info_t));
82 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
83 * memset(&option, 0x00, sizeof(emf_option_t));
84 * memset(mail, 0x00, sizeof(emf_mail_t));
85 * memset(head, 0x00, sizeof(emf_mail_head_t));
86 * memset(body, 0x00, sizeof(emf_mail_body_t));
87 * memset(&attachment, 0x00, sizeof(emf_attachment_info_t));
89 * option.keep_local_copy = 1;
91 * mbox.account_id = account_id;
92 * mbox.name = strdup("OUTBOX");
93 * head->to=strdup("test@test.com");
94 * head->subject =strdup("test");
95 * body->plain = strdup("/tmp/mail.txt");
97 * mail->info->account_id = account_id;
98 * mail->info->flags.draft = 1;
102 * attachment.name = strdup("attach");
103 * attachment.savename = strdup("/tmp/mail.txt");
104 * attachment.next = NULL;
105 * mail->body->attachment = &attachment;
106 * mail->body->attachment_num = 1;
107 * if(EMF_ERROR_NONE == email_add_message(mail,&mbox,1))
109 * if(EMF_ERROR_NONE == email_send_mail(&mbox, mail->info->uid,&option,&handle))
115 * // Download header of new emails from mail server
116 * unsigned handle = 0;
118 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
120 * mbox.account_id = account_id;
121 * mbox.name = strdup("INBOX");
122 * if(EMF_ERROR_NONE == email_sync_header (&mbox,&handle))
127 * //Sync mail header for all accounts
128 * if(EMF_ERROR_NONE == email_sync_header_for_all_account(&handle))
133 * //Download email body from server
135 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
136 * mbox.account_id = account_id;
137 * mbox.name = strdup("INBOX");
138 * if(EMF_ERROR_NONE == email_download_body (&mbox,mail_id,0,&handle))
143 * //Download a email nth-attachment from server
144 * prinf("Enter attachment number\n");
146 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
147 * mbox.name = strdup("INBOX");
148 * mbox.account_id = account_id;
149 * if(EMF_ERROR_NONE == email_download_attachment(&mailbox,mail_id,arg,&handle))
155 * if(EMF_ERROR_NONE == email_cancel_job(account_id,handle))//canceling download email nth attachment from server job.
156 * //so this handle contains the value return by the email_download_attachment()
160 * //Get pending job listfor an account
162 * printf( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \
163 * " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \
164 * " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \
166 * scanf("%d",&action);
167 * if(EMF_ERROR_NONE == email_get_pending_job(action,account_id,mail_id,&status))
172 * //Get Network status
173 * if(EMF_ERROR_NONE == email_get_network_status(&sending,&receiving))
179 * if(EMF_ERROR_NONE == email_send_report(mail ,&handle))
185 * mbox.account_id = account_id;
186 * mbox.name = strdup("DRAFTBOX");
188 * if(EMF_ERROR_NONE == email_add_message(mail,&mbox,1))
190 * if(EMF_ERROR_NONE == email_send_saved(account_id,&option,&handle))
195 * //Get Imap mailbox list
196 * printf("\n > Enter server name:\n");
198 * if(EMF_ERROR_NONE == email_get_imap_mailbox_list(account_id , arg , &handle))
203 * //sync local activity
204 * if(EMF_ERROR_NONE == email_sync_local_activity(account_id))
219 #endif /* __cplusplus */
223 * @fn email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle)
224 * @brief Send a mail.This function is invoked when user wants to send a composed mail.
226 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
227 * @param[in] mailbox Specifies the mailbox to consist a sending email.
228 * @param[in] mail_id Specifies the mail ID.
229 * @param[in] sending_option Specifies the sending option.
230 * @param[out] handle Specifies the sending handle.
232 * @see emf_mailbox_t and emf_option_t
235 EXPORT_API int email_send_mail( emf_mailbox_t* mailbox,
237 emf_option_t* sending_option,
243 * @fn email_sync_header(emf_mailbox_t* mailbox, unsigned* handle)
244 * @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails.
246 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
247 * @param[in] mailbox Specifies the structure of mailbox.
248 * @param[out] handle Specifies the handle for stopping downloading.
253 EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle);
258 * @fn email_sync_header_for_all_account(unsigned* handle)
259 * @brief Download header of new emails from mail server for all emails.This function is invoked when user wants to download header of new mails for all accounts.
261 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
262 * @param[out] handle Specifies the handle for stopping downloading.
267 EXPORT_API int email_sync_header_for_all_account(unsigned* handle);
272 * @fn email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle)
273 * @brief Download email body from server.This function is invoked when user wants to download email body with/without attachment based on the option with_attachment
276 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
277 * @param[in] mailbox Specifies the structure of mailbox.
278 * @param[in] mail_id Specifies the mail ID.
279 * @param[in] with_attachment Specifies the whether attachment is there or not.
280 * @param[out] handle Specifies the handle for stopping downloading.
285 EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle);
294 * @fn email_download_attachment(emf_mailbox_t* mailbox, int mail_id, char* nth, unsigned* handle);
295 * @brief Download a email nth-attachment from server.This function is invoked if user wants to download only specific attachment of a mail whose body is already downloaded.
297 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
298 * @param[in] mailbox Reserved.
299 * @param[in] mail_id Specifies the mail ID.
300 * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1".
301 * @param[out] handle Specifies the handle for stopping downloading.
306 EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,
314 * @fn email_cancel_job(int account_id, int handle);
315 * @brief cancel the ongoing job.This function is invoked if user wants to cancel any ongoing job of a specified account.
317 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
318 * @param[in] account_id Specifies the account ID.
319 * @param[in] handle Specifies the handle for stopping the operation.
325 EXPORT_API int email_cancel_job(int account_id, int handle);
330 * @fn email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status);
331 * @brief get pending job list.This function is invoked if user wants to get the pending job list with status information .
332 * Based on action item of a mail is for a specific account this will give all pending job list.
334 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
335 * @param[in] account_id Specifies the action of the job.
336 * @param[in] account_id Specifies the account ID.
337 * @param[in] mail_id Specifies the mail ID.
338 * @param[out]status Specifies the status of the job.
340 * @see emf_action_t and emf_event_status_type_t
343 EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status);
348 * @fn email_get_network_status(int* on_sending, int* on_receiving)
349 * @brief This function gives the current network status.This gives the information to the user whether sending operation is in progress or receiving operation.
351 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
352 * @param[out] on_sending True if sending is in progress.
353 * @param[out] on_receiving True if receivng is in progress.
358 EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving);
363 * @fn email_send_report(emf_mail_t* mail, unsigned* handle)
364 * @brief Send a read receipt mail.This function is invoked when user receives a mail with read report enable and wants to send a read report for the same.
366 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
367 * @param[in] mail Specifies the mail to been read.
368 * @param[out] handle Specifies the handle for stopping sending.
373 EXPORT_API int email_send_report(emf_mail_t* mail, unsigned* handle);
378 * @fn email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle)
379 * @brief Send all mails to been saved in Offline-mode.This function is invoked when user wants to send an email and after saving it.
380 * This will save the email in draft mailbox and then sends.
382 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
383 * @param[in] account_id Specifies the account ID.
384 * @param[in] sending_option Specifies the sending option.
385 * @param[out] handle Specifies the handle for stopping sending.
390 EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle);
393 EXPORT_API int email_download_mail_from_server(emf_mailbox_t * mailbox, const char * server_mail_id, unsigned* handle) DEPRECATED;
398 * @fn email_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle)
399 * @brief fetch all the mailbox names from server and store the non-existing mailboxes in DB.This function is invoked when user wants to download all server mailboxes from IMAP server
401 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
402 * @param[in] account_id Specifies the account ID.
403 * @param[in] mailbox Specifies the mailbox name.
404 * @param[out] handle Specifies the handle for stopping Network operation.
409 EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle);
415 * @fn email_sync_local_activity(int account_id)
416 * @brief sync local activity
418 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
419 * @param[in] account_id Specifies the account ID.
424 EXPORT_API int email_sync_local_activity(int account_id);
429 * @fn email_find_mail_on_server(int account_id, const char *mailbox_name, int search_type, char *search_value)
430 * @brief Search the mails on server.
432 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
433 * @param[in] account_id Specifies the Account ID
434 * @param[in] mailbox_name Specifies the Mailbox Name
435 * @param[in] search_type Specifies the searching type(EMF_SEARCH_FILTER_SUBJECT, EMF_SEARCH_FILTER_SENDER, EMF_SEARCH_FILTER_RECIPIENT, EMF_SEARCH_FILTER_ALL)
436 * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name)
443 EXPORT_API int email_find_mail_on_server(int input_account_id, const char *input_mailbox_name, int input_search_type, char *input_search_value, unsigned *output_handle);
447 #endif /* __cplusplus */
454 #endif /* __EMF_MAPI_NETWORK_H__ */