4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
23 #ifndef __EMAIL_API_NETWORK_H__
\r
24 #define __EMAIL_API_NETWORK_H__
\r
26 #include "email-types.h"
\r
29 * @defgroup EMAIL_SERVICE Email Service
\r
34 * @ingroup EMAIL_SERVICE
\r
35 * @defgroup EMAIL_API_NETWORK Email Network API
\r
41 * This file contains the data structures and interfaces needed for application,
\r
42 * to interact with email-service.
\r
43 * @file email-api-network.h
\r
44 * @author Kyuho Jo <kyuho.jo@samsung.com>
\r
45 * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
\r
47 * @brief This file contains the data structures and interfaces of Network related Functionality provided by
\r
54 * #include "email-api.h"
\r
57 * other_app_invoke_uniform_api_sample(int* error_code)
\r
61 * emf_mailbox_t mbox;
\r
62 * emf_attachment_info_t attachment;
\r
63 * emf_option_t option;
\r
64 * int account_id = 1;
\r
65 * int err = EMF_ERROR_NONE;
\r
67 * char arg[50]; //Input attachment number need to be download
\r
68 * emf_event_status_type_t status;
\r
70 * int on_sending = 0;
\r
71 * int on_receiving = 0;
\r
73 * printf("Enter mailbox name\n");
\r
74 * scanf("%s",&mbox.mailbox_name);
\r
75 * printf("Enter mail id\n");
\r
76 * scanf("%d",&mail_id);
\r
77 * option.keep_local_copy = 1;
\r
79 * if(EMF_ERROR_NONE == email_send_mail(&mbox, mail_id, &option, &handle))
\r
84 * // Download header of new emails from mail server
\r
85 * unsigned handle = 0;
\r
87 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
\r
89 * mbox.account_id = account_id;
\r
90 * mbox.name = strdup("INBOX");
\r
91 * if(EMF_ERROR_NONE == email_sync_header (&mbox,&handle))
\r
96 * //Sync mail header for all accounts
\r
97 * if(EMF_ERROR_NONE == email_sync_header_for_all_account(&handle))
\r
102 * //Download email body from server
\r
104 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
\r
105 * mbox.account_id = account_id;
\r
106 * mbox.name = strdup("INBOX");
\r
107 * if(EMF_ERROR_NONE == email_download_body (&mbox,mail_id,0,&handle))
\r
112 * //Download a email nth-attachment from server
\r
113 * prinf("Enter attachment number\n");
\r
115 * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
\r
116 * mbox.name = strdup("INBOX");
\r
117 * mbox.account_id = account_id;
\r
118 * if(EMF_ERROR_NONE == email_download_attachment(&mailbox,mail_id,arg,&handle))
\r
124 * if(EMF_ERROR_NONE == email_cancel_job(account_id,handle))//canceling download email nth attachment from server job.
\r
125 * //so this handle contains the value return by the email_download_attachment()
\r
129 * //Get pending job listfor an account
\r
131 * printf( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \
\r
132 * " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \
\r
133 * " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \
\r
135 * scanf("%d",&action);
\r
136 * if(EMF_ERROR_NONE == email_get_pending_job(action,account_id,mail_id,&status))
\r
141 * //Get Network status
\r
142 * if(EMF_ERROR_NONE == email_get_network_status(&sending,&receiving))
\r
147 * //Send read report
\r
148 * if(EMF_ERROR_NONE == email_send_report(mail ,&handle))
\r
154 * mbox.account_id = account_id;
\r
155 * mbox.name = strdup("DRAFTBOX");
\r
157 * if(EMF_ERROR_NONE == email_add_message(mail,&mbox,1))
\r
159 * if(EMF_ERROR_NONE == email_send_saved(account_id,&option,&handle))
\r
164 * //Get Imap mailbox list
\r
165 * printf("\n > Enter server name:\n");
\r
167 * if(EMF_ERROR_NONE == email_get_imap_mailbox_list(account_id , arg , &handle))
\r
172 * //sync local activity
\r
173 * if(EMF_ERROR_NONE == email_sync_local_activity(account_id))
\r
188 #endif /* __cplusplus */
\r
192 * @fn email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle)
\r
193 * @brief Send a mail.This function is invoked when user wants to send a composed mail.
\r
195 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
196 * @param[in] mailbox Specifies the mailbox to consist a sending email.
\r
197 * @param[in] mail_id Specifies the mail ID.
\r
198 * @param[in] sending_option Specifies the sending option.
\r
199 * @param[out] handle Specifies the sending handle.
\r
201 * @see emf_mailbox_t and emf_option_t
\r
204 EXPORT_API int email_send_mail( emf_mailbox_t* mailbox,
\r
206 emf_option_t* sending_option,
\r
212 * @fn email_sync_header(emf_mailbox_t* mailbox, unsigned* handle)
\r
213 * @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails.
\r
215 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
216 * @param[in] mailbox Specifies the structure of mailbox.
\r
217 * @param[out] handle Specifies the handle for stopping downloading.
\r
219 * @see emf_mailbox_t
\r
222 EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle);
\r
227 * @fn email_sync_header_for_all_account(unsigned* handle)
\r
228 * @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.
\r
230 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
231 * @param[out] handle Specifies the handle for stopping downloading.
\r
236 EXPORT_API int email_sync_header_for_all_account(unsigned* handle);
\r
241 * @fn email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle)
\r
242 * @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
\r
245 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
246 * @param[in] mailbox Specifies the structure of mailbox.
\r
247 * @param[in] mail_id Specifies the mail ID.
\r
248 * @param[in] with_attachment Specifies the whether attachment is there or not.
\r
249 * @param[out] handle Specifies the handle for stopping downloading.
\r
251 * @see emf_mailbox_t
\r
254 EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle);
\r
263 * @fn email_download_attachment(emf_mailbox_t* mailbox, int mail_id, char* nth, unsigned* handle);
\r
264 * @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.
\r
266 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
267 * @param[in] mailbox Reserved.
\r
268 * @param[in] mail_id Specifies the mail ID.
\r
269 * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1".
\r
270 * @param[out] handle Specifies the handle for stopping downloading.
\r
272 * @see emf_mailbox_t
\r
275 EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,
\r
283 * @fn email_cancel_job(int account_id, int handle);
\r
284 * @brief cancel the ongoing job.This function is invoked if user wants to cancel any ongoing job of a specified account.
\r
286 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
287 * @param[in] account_id Specifies the account ID.
\r
288 * @param[in] handle Specifies the handle for stopping the operation.
\r
294 EXPORT_API int email_cancel_job(int account_id, int handle);
\r
299 * @fn email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status);
\r
300 * @brief get pending job list.This function is invoked if user wants to get the pending job list with status information .
\r
301 * Based on action item of a mail is for a specific account this will give all pending job list.
\r
303 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
304 * @param[in] account_id Specifies the action of the job.
\r
305 * @param[in] account_id Specifies the account ID.
\r
306 * @param[in] mail_id Specifies the mail ID.
\r
307 * @param[out]status Specifies the status of the job.
\r
309 * @see emf_action_t and emf_event_status_type_t
\r
312 EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status);
\r
317 * @fn email_get_network_status(int* on_sending, int* on_receiving)
\r
318 * @brief This function gives the current network status.This gives the information to the user whether sending operation is in progress or receiving operation.
\r
320 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
321 * @param[out] on_sending True if sending is in progress.
\r
322 * @param[out] on_receiving True if receivng is in progress.
\r
327 EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving);
\r
331 * @fn email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle)
\r
332 * @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.
\r
333 * This will save the email in draft mailbox and then sends.
\r
335 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
336 * @param[in] account_id Specifies the account ID.
\r
337 * @param[in] sending_option Specifies the sending option.
\r
338 * @param[out] handle Specifies the handle for stopping sending.
\r
340 * @see emf_option_t
\r
343 EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle);
\r
347 * @fn email_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle)
\r
348 * @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
\r
350 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
351 * @param[in] account_id Specifies the account ID.
\r
352 * @param[in] mailbox Specifies the mailbox name.
\r
353 * @param[out] handle Specifies the handle for stopping Network operation.
\r
358 EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle);
\r
364 * @fn email_sync_local_activity(int account_id)
\r
365 * @brief sync local activity
\r
367 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
368 * @param[in] account_id Specifies the account ID.
\r
373 EXPORT_API int email_sync_local_activity(int account_id);
\r
378 * @fn email_search_mail_on_server(int account_id, const char *mailbox_name, int search_type, char *search_value)
\r
379 * @brief Search the mails on server.
\r
381 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
\r
382 * @param[in] account_id Specifies the Account ID
\r
383 * @param[in] mailbox_name Specifies the Mailbox Name
\r
384 * @param[in] search_type Specifies the searching type(EMF_SEARCH_FILTER_SUBJECT, EMF_SEARCH_FILTER_SENDER, EMF_SEARCH_FILTER_RECIPIENT, EMF_SEARCH_FILTER_ALL)
\r
385 * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name)
\r
392 EXPORT_API int email_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle);
\r
396 #endif /* __cplusplus */
\r
403 #endif /* __EMAIL_API_NETWORK_H__ */
\r