4 * Copyright (c) 2012 - 2013 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;
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 */
135 * @fn int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle)
136 * @brief Create a new mailbox or mailbox.This function is invoked when user wants to create a new mailbox for the specified account.
137 * If On_server is true then it will create the mailbox on server as well as in local also.
139 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
140 * @param[in] new_mailbox Specifies the pointer of creating mailbox information.
141 * @param[in] on_server Specifies the creating mailbox on server.
142 * @param[out] handle Specifies the sending handle.
144 * @see email_mailbox_t
147 EXPORT_API int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, int *handle);
150 * @fn int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias)
151 * @brief Change mailbox name. This function is invoked when user wants to change the name of existing mail box.
153 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
154 * @param[in] input_mailbox_id Specifies the id of the mailbox.
155 * @param[in] input_mailbox_name Specifies the name of the mailbox.
156 * @param[in] input_mailbox_alias Specifies the alias of the mailbox.
157 * @param[in] input_on_server Specifies the moving mailbox on server.
158 * @param[out] output_handle Specifies the handle to manage tasks.
160 * @exception see email-errors.h
161 * @see email_mailbox_t, email_mailbox_type_e
164 EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, int *output_handle);
167 * @fn int email_delete_mailbox(int input_mailbox_id, int input_on_server, int *output_handle)
168 * @brief Delete a mailbox or mailbox.This function deletes the existing mailbox for specified account based on the option on_server.
169 * If the on_server is true then it deletes mailbox from server as well as locally.
171 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
172 * @param[in] input_mailbox_id Specifies the id of target mailbox .
173 * @param[in] input_on_server Specifies the deleting mailbox on server.
174 * @param[out] output_handle Specifies the sending handle.
175 * @exception see email-errors.h
176 * @see email_mailbox_t
179 EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, int *output_handle);
181 EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int *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);
198 * @fn int email_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox)
199 * @brief Change the attribute 'local' of email_mailbox_t. This function is invoked when user wants to change the attribute 'local'.
201 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
202 * @param[in] input_mailbox_id Specifies the id of the mailbox.
203 * @param[in] input_is_local_mailbox Specifies the value of the attribute 'local' of email_mailbox_t.
204 * @exception see email-errors.h
208 EXPORT_API int email_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox);
211 * @fn email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count)
212 * @brief Get all mailboxes from account.
214 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
215 * @param[in] account_id Specifies the account ID.
216 * @param[in] mailbox_sync_type Specifies the sync type.
217 * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL)
218 * @param[out] count The mailbox count is saved here.(possibly 0)
220 * @see email_mailbox_t
223 * #include "email-api-mailbox.h"
225 * _api_sample_get_mailbox_list()
227 * int account_id =0,count = 0;
228 * int mailbox_sync_type;
229 * int error_code = EMAIL_ERROR_NONE;
230 * email_mailbox_t *mailbox_list=NULL;
232 * printf("\n > Enter account id: ");
233 * scanf("%d", &account_id);
234 * printf("\n > Enter mailbox_sync_type: ");
235 * scanf("%d", &mailbox_sync_type);
237 * if((EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count)))
239 * printf(" Error\n");
243 * printf("Success\n");
244 * email_free_mailbox(&mailbox_list,count);
250 EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count);
252 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);
255 * @fn email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox)
256 * @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.
258 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
259 * @param[in] account_id Specifies the account ID.
260 * @param[in] mailbox_type Specifies the mailbox type.
261 * @param[out] mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL)
263 * @see email_mailbox_t
266 EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox);
269 * @fn email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox)
270 * @brief Get mailbox by mailbox_id. This function is invoked when user wants to know the mailbox information by mailbox id.
272 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
273 * @param[in] input_mailbox_id Specifies the mailbox id.
274 * @param[out] output_mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL)
276 * @see email_mailbox_t
279 EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox);
282 * @fn email_set_mail_slot_size(int input_account_id, int input_mailbox_id, int input_new_slot_size)
283 * @brief Set mail slot size.This function is invoked when user wants to set the size of mail slot.
285 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
286 * @param[in] input_account_id Specifies the account ID.
287 * @param[in] input_mailbox_id Specifies the mailbox id.
288 * @param[in] input_new_slot_size Specifies the mail slot size.
290 * @see email_mailbox_t
293 EXPORT_API int email_set_mail_slot_size(int input_account_id, int input_mailbox_id, int input_new_slot_size);
296 * @fn email_stamp_sync_time_of_mailbox(int input_mailbox_id)
297 * @brief Stamp sync time of mailbox. This function is invoked when user wants to set the sync time of the mailbox.
299 * @return This function returns EMAIL_ERROR_NONE on success or error code(refer to EMAIL_ERROR_XXX) on failure.
300 * @param[in] input_mailbox_id Specifies the mailbox id.
302 * @see email_mailbox_t
305 EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id);
309 * @fn email_free_mailbox(email_mailbox_t** mailbox_list, int count)
310 * @brief Free allocated memory for mailbox information.
312 * @return This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR_XXX) on failure.
313 * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer.
314 * @param[in] count Specifies the count of mailboxes.
316 * @see email_mailbox_t
319 * #include "email-api-mailbox.h"
321 * _api_sample_free_mailbox_info()
323 * email_mailbox_t *mailbox;
325 * //fill the mailbox structure
326 * //count - number of mailbox structure user want to free
327 * if(EMAIL_ERROR_NONE == email_free_mailbox(&mailbox,count))
337 EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count);
341 #endif /* __cplusplus */
347 #endif /* __EMAIL_API_MAILBOX_H__ */