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.
26 * This file contains the data structures and interfaces needed for application,
27 * to interact with email-service.
28 * @file email_api_mailbox.c
29 * @brief This file contains the data structures and interfaces of mailbox related Functionality provided by
33 #include "email-api.h"
35 #include "email-convert.h"
36 #include "email-storage.h"
37 #include "email-core-utils.h"
38 #include "email-utilities.h"
39 #include "email-ipc.h"
42 /* API - Create a mailbox */
44 EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, unsigned* handle)
46 EM_DEBUG_FUNC_BEGIN();
49 int err = EMAIL_ERROR_NONE;
50 char* local_mailbox_stream = NULL;
51 email_account_server_t account_server_type;
53 ASNotiData as_noti_data;
55 memset(&as_noti_data, 0x00, sizeof(ASNotiData));
57 EM_IF_NULL_RETURN_VALUE(new_mailbox, EMAIL_ERROR_INVALID_PARAM);
59 /* check account bind type and branch off */
60 if ( em_get_account_server_type_by_account_id(new_mailbox->account_id, &account_server_type, false, &err) == false ) {
61 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
62 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
66 if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && on_server) {
69 if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
70 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
71 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
75 /* noti to active sync */
76 as_noti_data.add_mailbox.handle = as_handle;
77 as_noti_data.add_mailbox.account_id = new_mailbox->account_id;
78 as_noti_data.add_mailbox.mailbox_alias = new_mailbox->alias;
79 as_noti_data.add_mailbox.mailbox_path = new_mailbox->mailbox_name;
81 if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_ADD_MAILBOX, &as_noti_data) == false) {
82 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
83 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
91 hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAILBOX);
93 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
95 local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
97 EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
99 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
100 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
101 EM_SAFE_FREE(local_mailbox_stream);
102 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
105 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
106 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
107 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
110 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
111 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
112 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
115 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
116 EM_DEBUG_LOG(" >>>>> error VALUE [%d]", err);
119 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
120 EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle);
123 emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &(new_mailbox->mailbox_id));
124 EM_DEBUG_LOG(" >>>>> new_mailbox->mailbox_id [%d]", new_mailbox->mailbox_id);
126 emipc_destroy_email_api(hAPI);
131 EM_DEBUG_FUNC_END("err [%d]", err);
135 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)
137 EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_name [%p], input_mailbox_alias [%p], input_on_server [%d], output_handle [%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_on_server, output_handle);
139 int err = EMAIL_ERROR_NONE;
140 email_account_server_t account_server_type;
141 HIPC_API hAPI = NULL;
142 ASNotiData as_noti_data;
143 emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
145 EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
146 EM_IF_NULL_RETURN_VALUE(input_mailbox_name, EMAIL_ERROR_INVALID_PARAM);
147 EM_IF_NULL_RETURN_VALUE(input_mailbox_alias, EMAIL_ERROR_INVALID_PARAM);
149 if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
150 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
154 /* check account bind type and branch off */
155 if ( em_get_account_server_type_by_account_id(mailbox_tbl->account_id, &account_server_type, false, &err) == false ) {
156 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
157 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
161 if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
164 if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
165 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
166 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
170 /* noti to active sync */
171 as_noti_data.rename_mailbox.handle = as_handle;
172 as_noti_data.rename_mailbox.account_id = mailbox_tbl->account_id;
173 as_noti_data.rename_mailbox.mailbox_id = input_mailbox_id;
174 as_noti_data.rename_mailbox.mailbox_name = input_mailbox_name;
175 as_noti_data.rename_mailbox.mailbox_alias = input_mailbox_alias;
177 if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_RENAME_MAILBOX, &as_noti_data) == false) {
178 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
179 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
184 *output_handle = as_handle;
187 hAPI = emipc_create_email_api(_EMAIL_API_RENAME_MAILBOX);
189 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
190 EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_id failed");
191 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
194 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, strlen(input_mailbox_name)+1 )) {
195 EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_path failed");
196 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
199 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, strlen(input_mailbox_alias)+1 )) {
200 EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_alias failed");
201 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
204 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
205 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
206 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
209 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
210 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
211 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
214 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
216 EM_DEBUG_LOG("error VALUE [%d]", err);
217 emipc_destroy_email_api(hAPI);
221 emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
223 EM_DEBUG_FUNC_END("err [%d]", err);
228 /* API - Delete a mailbox */
230 EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle)
232 EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
234 int err = EMAIL_ERROR_NONE;
235 email_account_server_t account_server_type;
236 emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
237 HIPC_API hAPI = NULL;
238 ASNotiData as_noti_data;
240 EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
242 if ( (err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
243 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed[%d]", err);
247 /* check account bind type and branch off */
248 if ( em_get_account_server_type_by_account_id(mailbox_tbl->account_id, &account_server_type, false, &err) == false ) {
249 EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
250 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
254 if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
257 if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
258 EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
259 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
263 /* noti to active sync */
264 as_noti_data.delete_mailbox.handle = as_handle;
265 as_noti_data.delete_mailbox.account_id = mailbox_tbl->account_id;
266 as_noti_data.delete_mailbox.mailbox_id = input_mailbox_id;
268 if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DELETE_MAILBOX, &as_noti_data) == false) {
269 EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
270 err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
275 *output_handle = as_handle;
278 hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAILBOX);
280 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
282 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
283 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
284 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
287 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
288 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
289 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
292 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
293 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
294 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
297 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
298 EM_DEBUG_LOG("error VALUE [%d]", err);
300 if(input_on_server) {
301 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
302 EM_DEBUG_LOG("output_handle [%d]", output_handle);
305 emipc_destroy_email_api(hAPI);
310 emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
313 EM_DEBUG_FUNC_END("err [%d]", err);
317 EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type)
319 EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_type [%d]", input_mailbox_id, input_mailbox_type);
320 int err = EMAIL_ERROR_NONE;
322 EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
324 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAILBOX_TYPE);
326 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
328 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
329 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
330 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
333 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_type, sizeof(int))) {
334 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
335 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
338 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
339 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
340 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
343 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
345 EM_DEBUG_LOG("error VALUE [%d]", err);
346 emipc_destroy_email_api(hAPI);
349 EM_DEBUG_FUNC_END("err [%d]", err);
356 EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count)
358 EM_DEBUG_FUNC_BEGIN();
359 int mailbox_count = 0;
360 int err = EMAIL_ERROR_NONE ;
362 emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
364 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
365 EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
366 EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
368 if (!emstorage_get_mailbox_list(account_id, 0, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
369 EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
374 err = EMAIL_ERROR_NONE;
376 if (mailbox_count > 0) {
377 if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) {
378 EM_DEBUG_EXCEPTION("malloc failed...");
379 err= EMAIL_ERROR_OUT_OF_MEMORY;
382 for (i = 0; i < mailbox_count; i++)
383 em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
385 *mailbox_list = NULL;
387 *count = mailbox_count;
390 if (mailbox_tbl_list != NULL)
391 emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
392 EM_DEBUG_FUNC_END("err [%d]", err);
397 EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count)
399 EM_DEBUG_FUNC_BEGIN();
401 int mailbox_count = 0;
402 emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
403 int err =EMAIL_ERROR_NONE;
406 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
407 EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
408 EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
410 if (!emstorage_get_mailbox_list(account_id, mailbox_sync_type, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
411 EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
415 err = EMAIL_ERROR_NONE;
417 if (mailbox_count > 0) {
418 if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) {
419 EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
420 err= EMAIL_ERROR_OUT_OF_MEMORY;
424 for (i = 0; i < mailbox_count; i++)
425 em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
427 *mailbox_list = NULL;
429 *count = mailbox_count;
432 if (mailbox_tbl_list != NULL)
433 emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
435 EM_DEBUG_FUNC_END("err [%d]", err);
441 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)
443 EM_DEBUG_FUNC_BEGIN();
445 int mailbox_count = 0;
446 emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
447 int err =EMAIL_ERROR_NONE;
450 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
451 EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
452 EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
454 if (!emstorage_get_mailbox_list_ex(account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) {
455 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_list_ex failed [%d]", err);
459 err = EMAIL_ERROR_NONE;
461 if (mailbox_count > 0) {
462 if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) {
463 EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
464 err= EMAIL_ERROR_OUT_OF_MEMORY;
468 for (i = 0; i < mailbox_count; i++)
469 em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
472 *mailbox_list = NULL;
475 *count = mailbox_count;
478 if (mailbox_tbl_list != NULL)
479 emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
481 EM_DEBUG_FUNC_END("err [%d]", err);
486 /* sowmya.kr, 05-Apr-2010, new MAPI*/
488 EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t** mailbox)
490 EM_DEBUG_FUNC_BEGIN();
492 int err = EMAIL_ERROR_NONE;
493 email_mailbox_t* curr_mailbox = NULL;
494 emstorage_mailbox_tbl_t* local_mailbox = NULL;
496 EM_IF_NULL_RETURN_VALUE(mailbox, EMAIL_ERROR_INVALID_PARAM);
497 EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM) ;
500 if(mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS)
501 return EMAIL_ERROR_INVALID_PARAM;
502 if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &local_mailbox, true, &err)) {
503 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
507 err = EMAIL_ERROR_NONE;
508 curr_mailbox = em_malloc(sizeof(email_mailbox_t));
509 memset(curr_mailbox, 0x00, sizeof(email_mailbox_t));
510 em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox);
513 *mailbox = curr_mailbox;
517 emstorage_free_mailbox(&local_mailbox, 1, NULL);
518 EM_DEBUG_FUNC_END("err [%d]", err);
522 EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox)
524 EM_DEBUG_FUNC_BEGIN();
526 int err = EMAIL_ERROR_NONE;
527 email_mailbox_t* curr_mailbox = NULL;
528 emstorage_mailbox_tbl_t* local_mailbox = NULL;
530 EM_IF_NULL_RETURN_VALUE(output_mailbox, EMAIL_ERROR_INVALID_PARAM);
532 if ( (err = emstorage_get_mailbox_by_id(input_mailbox_id, &local_mailbox)) != EMAIL_ERROR_NONE) {
533 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
536 curr_mailbox = em_malloc(sizeof(email_mailbox_t));
538 memset(curr_mailbox, 0x00, sizeof(email_mailbox_t));
540 em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox);
543 *output_mailbox = curr_mailbox;
545 emstorage_free_mailbox(&local_mailbox, 1, &err);
547 EM_DEBUG_FUNC_END("err [%d]", err);
551 EXPORT_API int email_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size)
553 EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], new_slot_size[%d]", account_id, mailbox_id, new_slot_size);
555 int err = EMAIL_ERROR_NONE, *handle = NULL;
557 if(new_slot_size < 0) {
558 EM_DEBUG_EXCEPTION("new_slot_size should be greater than 0 or should be equal to 0");
559 return EMAIL_ERROR_INVALID_PARAM;
562 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE);
564 EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
567 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
568 EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
569 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
572 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &mailbox_id, sizeof(int))) {
573 EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
574 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
577 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &new_slot_size, sizeof(int))) {
578 EM_DEBUG_EXCEPTION(" emipc_add_parameter for new_slot_size failed");
579 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
582 if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
583 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
584 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
587 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
588 EM_DEBUG_LOG("email_set_mail_slot_size error VALUE [%d]", err);
590 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
591 EM_DEBUG_LOG("email_set_mail_slot_size handle VALUE [%d]", handle);
593 emipc_destroy_email_api(hAPI);
597 EM_DEBUG_FUNC_END("err [%d]", err);
601 EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id)
603 EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d]", input_mailbox_id);
605 int err = EMAIL_ERROR_NONE;
607 EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
609 err = emstorage_stamp_last_sync_time_of_mailbox(input_mailbox_id, 1);
611 EM_DEBUG_FUNC_END("err [%d]", err);
615 EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count)
617 EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d]", mailbox_list, count);
618 int err = EMAIL_ERROR_NONE;
620 if (count <= 0 || !mailbox_list || !*mailbox_list) {
621 EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
622 err = EMAIL_ERROR_INVALID_PARAM;
626 email_mailbox_t *p = *mailbox_list;
629 for (i = 0; i < count; i++) {
630 EM_SAFE_FREE(p[i].mailbox_name);
631 EM_SAFE_FREE(p[i].alias);
635 *mailbox_list = NULL;
638 EM_DEBUG_FUNC_END("err [%d]", err);