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_MAILBOX_H__
24 #define __EMAIL_API_MAILBOX_H__
26 #include "email-types.h"
29 * @defgroup EMAIL_SERVICE Email Service
35 * @ingroup EMAIL_SERVICE
36 * @defgroup EMAIL_API_MAILBOX Email Mailbox API
42 * This file contains the data structures and interfaces needed for application,
43 * to interact with email-service.
44 * @file email-api-mailbox.h
45 * @author Kyuho Jo <kyuho.jo@samsung.com>
46 * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
48 * @brief This file contains the data structures and interfaces of mailbox provided by
53 * #include "email_api_mailbox.h"
55 * bool other_app_invoke_uniform_api_sample(int *error_code)
57 * email_mailbox_t mailbox;
58 * email_mailbox_t *new_mailbox =NULL;
59 * email_mailbox_t *mailbox_list = NULL;
62 * unsigned handle = 0;
64 * char *pParentMailbox;
66 * memset(&mailbox,0x00,sizeof(email_mailbox_t));
67 * mailbox.mailbox_name = strdup("test");
68 * mailbox.alias = strdup("Personal");
69 * mailbox.account_id = 1;
70 * printf("Enter local_yn(1/0)");
71 * scanf("%d",&local_yn);
72 * mailbox.local=local_yn;
73 * mailbox.mailbox_type = 7;
75 * //create new mailbox
77 * if(EMAIL_ERR_NONE != email_add_mailbox(&mailbox,local_yn,&handle))
78 * printf("email_add_mailbox failed\n");
80 * printf("email_add_mailbox success");
84 * if(EMAIL_ERROR_NONE != email_delete_mailbox(mailbox,local_yn,&handle))
85 * printf("email_delete_mailbox failed\n");
87 * printf("email_delete_mailbox success\n");
90 * email_free_mailbox("new_mailbox,1");
93 * if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,local_yn,&mailbox_list,&count))
98 * //Get mailbox by name
99 * pMailboxName = strdup("test");
100 * if(EMAIL_ERROR_NONE != email_get_mailbox_by_name(account_id,pMailboxName,&mailbox_list))
105 * //Get child mailbox list
106 * pParentMailbox = strdup("test");
107 * if(EMAIL_ERROR_NONE != email_get_child_mailbox_list(account_id, paerent_mailbox,&mailbox_list,&count))
112 * //Get mailbox by mailbox_type
113 * printf("Enter mailbox_type\n");
114 * scanf("%d",&mailbox_type);
115 * if(EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox_list))
131 #endif /* __cplusplus */
136 * @fn int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle)
137 * @brief Create a new mailbox or mailbox.This function is invoked when user wants to create a new mailbox for the specified account.
138 * If On_server is true then it will create the mailbox on server as well as in local also.
140 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
141 * @param[in] new_mailbox Specifies the pointer of creating mailbox information.
142 * @param[in] on_server Specifies the creating mailbox on server.
143 * @param[out] handle Specifies the sending handle.
145 * @see email_mailbox_t
148 EXPORT_API int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, unsigned* handle);
151 * @fn int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias)
152 * @brief Change mailbox name. This function is invoked when user wants to change the name of existing mail box.
154 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
155 * @param[in] input_mailbox_id Specifies the id of the mailbox.
156 * @param[in] input_mailbox_name Specifies the name of the mailbox.
157 * @param[in] input_mailbox_alias Specifies the alias of the mailbox.
158 * @param[in] input_on_server Specifies the moving mailbox on server.
159 * @param[out] output_handle Specifies the handle to manage tasks.
161 * @exception see email-errors.h
162 * @see email_mailbox_t, email_mailbox_type_e
165 EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, unsigned *output_handle);
169 * @fn int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle)
170 * @brief Delete a mailbox or mailbox.This function deletes the existing mailbox for specified account based on the option on_server.
171 * If the on_server is true then it deletes mailbox from server as well as locally.
173 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
174 * @param[in] input_mailbox_id Specifies the id of target mailbox .
175 * @param[in] input_on_server Specifies the deleting mailbox on server.
176 * @param[out] output_handle Specifies the sending handle.
177 * @exception see email-errors.h
178 * @see email_mailbox_t
181 EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle);
184 * @fn int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type)
185 * @brief Change the mailbox type. This function is invoked when user wants to change the mailbox type.
187 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
188 * @param[in] input_mailbox_id Specifies the id of the mailbox.
189 * @param[in] input_mailbox_type Specifies the mailbox type.
190 * @exception see email-errors.h
191 * @see email_mailbox_type_e
194 EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
199 * @fn email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count)
200 * @brief Get all mailboxes from account.
202 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
203 * @param[in] account_id Specifies the account ID.
204 * @param[in] mailbox_sync_type Specifies the sync type.
205 * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL)
206 * @param[out] count The mailbox count is saved here.(possibly 0)
208 * @see email_mailbox_t
211 * #include "email-api-mailbox.h"
213 * _api_sample_get_mailbox_list()
215 * int account_id =0,count = 0;
216 * int mailbox_sync_type;
217 * int error_code = EMAIL_ERROR_NONE;
218 * email_mailbox_t *mailbox_list=NULL;
220 * printf("\n > Enter account id: ");
221 * scanf("%d", &account_id);
222 * printf("\n > Enter mailbox_sync_type: ");
223 * scanf("%d", &mailbox_sync_type);
225 * if((EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count)))
227 * printf(" Error\n");
231 * printf("Success\n");
232 * email_free_mailbox(&mailbox_list,count);
238 EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count);
240 EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, email_mailbox_t** mailbox_list, int* count);
244 * @fn email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox)
245 * @brief Get mailbox by mailbox_type.This function is invoked when user wants to know the mailbox information by mailbox_type for the given account.
247 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
248 * @param[in] account_id Specifies the account ID.
249 * @param[in] mailbox_type Specifies the mailbox type.
250 * @param[out] mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL)
252 * @see email_mailbox_t
255 EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox);
259 * @fn email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox)
260 * @brief Get mailbox by mailbox_id. This function is invoked when user wants to know the mailbox information by mailbox id.
262 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
263 * @param[in] input_mailbox_id Specifies the mailbox id.
264 * @param[out] output_mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL)
266 * @see email_mailbox_t
269 EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox);
273 * @fn email_set_mail_slot_size(int input_account_id, int input_mailbox_id, int input_new_slot_size)
274 * @brief Set mail slot size.This function is invoked when user wants to set the size of mail slot.
276 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
277 * @param[in] input_account_id Specifies the account ID.
278 * @param[in] input_mailbox_id Specifies the mailbox id.
279 * @param[in] input_new_slot_size Specifies the mail slot size.
281 * @see email_mailbox_t
284 EXPORT_API int email_set_mail_slot_size(int input_account_id, int input_mailbox_id, int input_new_slot_size);
288 * @fn email_stamp_sync_time_of_mailbox(int input_mailbox_id)
289 * @brief Stamp sync time of mailbox. This function is invoked when user wants to set the sync time of the mailbox.
291 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
292 * @param[in] input_mailbox_id Specifies the mailbox id.
294 * @see email_mailbox_t
297 EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id);
302 * @fn email_free_mailbox(email_mailbox_t** mailbox_list, int count)
303 * @brief Free allocated memory for mailbox information.
305 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
306 * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer.
307 * @param[in] count Specifies the count of mailboxes.
309 * @see email_mailbox_t
312 * #include "email-api-mailbox.h"
314 * _api_sample_free_mailbox_info()
316 * email_mailbox_t *mailbox;
318 * //fill the mailbox structure
319 * //count - number of mailbox structure user want to free
320 * if(EMAIL_ERROR_NONE == email_free_mailbox(&mailbox,count))
330 EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count);
334 #endif /* __cplusplus */
340 #endif /* __EMAIL_API_MAILBOX_H__ */