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 __EMAIL_API_NETWORK_H__
24 #define __EMAIL_API_NETWORK_H__
26 #include "email-types.h"
29 * @defgroup EMAIL_SERVICE Email Service
34 * @ingroup EMAIL_SERVICE
35 * @defgroup EMAIL_API_NETWORK Email Network API
41 * This file contains the data structures and interfaces needed for application,
42 * to interact with email-service.
43 * @file email-api-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 "email-api.h"
57 * other_app_invoke_uniform_api_sample(int* error_code)
61 * email_attachment_data_t attachment;
62 * email_option_t option;
65 * int attachment_id = 0;
66 * int err = EMAIL_ERROR_NONE;
70 * printf("Enter mail id\n");
71 * scanf("%d",&mail_id);
72 * option.keep_local_copy = 1;
74 * if(EMAIL_ERROR_NONE == email_send_mail(mail_id, &option, &handle))
79 * // Download header of new emails from mail server
80 * unsigned handle = 0;
82 * mailbox.account_id = account_id;
83 * printf("Enter mailbox id\n");
84 * scanf("%d",&mailbox_id);
85 * if(EMAIL_ERROR_NONE == email_sync_header (account_id, mailbox_id, &handle))
90 * //Sync mail header for all accounts
91 * if(EMAIL_ERROR_NONE == email_sync_header_for_all_account(&handle))
96 * //Download email body from server
98 * if(EMAIL_ERROR_NONE == email_download_body (mail_id,0,&handle))
103 * //Download a email nth-attachment from server
104 * prinf("Enter attachment number\n");
105 * scanf("%d",&attachment_id);
106 * if(EMAIL_ERROR_NONE == email_download_attachment(mail_id, attachment_id, &handle))
112 * if(EMAIL_ERROR_NONE == email_cancel_job(account_id,handle))//canceling download email nth attachment from server job.
113 * //so this handle contains the value return by the email_download_attachment()
117 * //Get pending job listfor an account
119 * printf( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \
120 * " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \
121 * " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \
123 * scanf("%d",&action);
124 * if(EMAIL_ERROR_NONE == email_get_pending_job(action,account_id,mail_id,&status))
129 * //Get Network status
130 * if(EMAIL_ERROR_NONE == email_get_network_status(&sending,&receiving))
136 * if(EMAIL_ERROR_NONE == email_send_report(mail ,&handle))
143 * if(EMAIL_ERROR_NONE == email_add_mail(mail,NULL,0, NULL, 0))
145 * if(EMAIL_ERROR_NONE == email_send_saved(account_id,&option,&handle))
150 * //Get Imap mailbox list
151 * if(EMAIL_ERROR_NONE == email_sync_imap_mailbox_list(account_id, &handle))
167 #endif /* __cplusplus */
171 * @fn email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle)
172 * @brief Send a mail.This function is invoked when user wants to send a composed mail.
174 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
175 * @param[in] mail_id Specifies the mail ID.
176 * @param[in] sending_option Specifies the sending option.
177 * @param[out] handle Specifies the sending handle.
179 * @see email_mailbox_t and email_option_t
182 EXPORT_API int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle);
187 * @fn email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle)
188 * @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails.
190 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
191 * @param[in] input_account_id Specifies the account ID.
192 * @param[in] input_mailbox_id Specifies the mailbox ID.
193 * @param[out] handle Specifies the handle for stopping downloading.
195 * @see email_mailbox_t
198 EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, unsigned* handle);
203 * @fn email_sync_header_for_all_account(unsigned* handle)
204 * @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.
206 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
207 * @param[out] handle Specifies the handle for stopping downloading.
212 EXPORT_API int email_sync_header_for_all_account(unsigned* handle);
217 * @fn email_download_body(int mail_id, int with_attachment, unsigned* handle)
218 * @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
221 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
222 * @param[in] mail_id Specifies the mail ID.
223 * @param[in] with_attachment Specifies the whether attachment is there or not.
224 * @param[out] handle Specifies the handle for stopping downloading.
226 * @see email_mailbox_t
229 EXPORT_API int email_download_body(int mail_id, int with_attachment, unsigned* handle);
238 * @fn email_download_attachment(int mail_id, const char* nth, unsigned* handle);
239 * @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.
241 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
242 * @param[in] mail_id Specifies the mail ID.
243 * @param[in] nth Specifies the attachment number been saved. the minimum number is "1".
244 * @param[out] handle Specifies the handle for stopping downloading.
246 * @see email_mailbox_t
249 EXPORT_API int email_download_attachment(int mail_id, int nth, unsigned* handle);
254 * @fn email_cancel_job(int account_id, int handle);
255 * @brief cancel the ongoing job.This function is invoked if user wants to cancel any ongoing job of a specified account.
257 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
258 * @param[in] input_account_id Specifies the account ID.
259 * @param[in] input_handle Specifies the handle for stopping the operation.
260 * @param[in] input_cancel_type Specifies the type of cancellation.
266 EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_cancelation_type input_cancel_type);
271 * @fn email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status);
272 * @brief get pending job list.This function is invoked if user wants to get the pending job list with status information .
273 * Based on action item of a mail is for a specific account this will give all pending job list.
275 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
276 * @param[in] account_id Specifies the action of the job.
277 * @param[in] account_id Specifies the account ID.
278 * @param[in] mail_id Specifies the mail ID.
279 * @param[out]status Specifies the status of the job.
281 * @see email_action_t and email_event_status_type_t
284 EXPORT_API int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status);
289 * @fn email_get_network_status(int* on_sending, int* on_receiving)
290 * @brief This function gives the current network status.This gives the information to the user whether sending operation is in progress or receiving operation.
292 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
293 * @param[out] on_sending True if sending is in progress.
294 * @param[out] on_receiving True if receivng is in progress.
299 EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving);
303 * @fn email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle)
304 * @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.
305 * This will save the email in draft mailbox and then sends.
307 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
308 * @param[in] account_id Specifies the account ID.
309 * @param[in] sending_option Specifies the sending option.
310 * @param[out] handle Specifies the handle for stopping sending.
312 * @see email_option_t
315 EXPORT_API int email_send_saved(int account_id, email_option_t* sending_option, unsigned* handle);
319 * @fn email_sync_imap_mailbox_list(int account_id, unsigned* handle)
320 * @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
322 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
323 * @param[in] account_id Specifies the account ID.
324 * @param[out] handle Specifies the handle for stopping Network operation.
329 EXPORT_API int email_sync_imap_mailbox_list(int account_id, unsigned* handle);
333 * @fn email_search_mail_on_server(int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle)
334 * @brief Search the mails on server.
336 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
337 * @param[in] account_id Specifies the Account ID
338 * @param[in] mailbox_id Specifies the Mailbox ID
339 * @param[in] search_type Specifies the searching type(EMAIL_SEARCH_FILTER_SUBJECT, EMAIL_SEARCH_FILTER_SENDER, EMAIL_SEARCH_FILTER_RECIPIENT, EMAIL_SEARCH_FILTER_ALL)
340 * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name)
342 * @see email_search_filter_t,
347 EXPORT_API int email_search_mail_on_server(int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle);
349 EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id);
353 #endif /* __cplusplus */
360 #endif /* __EMAIL_API_NETWORK_H__ */