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(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle)
46 EM_DEBUG_FUNC_BEGIN();
48 char* local_mailbox_stream = NULL;
50 int err = EMF_ERROR_NONE;
51 EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM);
53 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAILBOX);
55 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
57 local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
59 EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
61 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
62 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
63 EM_SAFE_FREE(local_mailbox_stream);
64 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
67 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
68 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
69 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
72 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
73 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
74 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
77 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
78 EM_DEBUG_LOG(" >>>>> error VALUE [%d]", err);
81 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
82 EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle);
86 emipc_destroy_email_api(hAPI);
88 EM_DEBUG_FUNC_END("err [%d]", err);
93 /* API - Delete a mailbox */
95 EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle)
97 EM_DEBUG_FUNC_BEGIN("mailbox[%p]", mailbox);
99 char* local_mailbox_stream = NULL;
100 int err = EMF_ERROR_NONE;
103 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
104 EM_IF_NULL_RETURN_VALUE(mailbox->account_id, EMF_ERROR_INVALID_PARAM) ;
106 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAILBOX);
108 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
110 local_mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
112 EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
114 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
115 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
116 EM_SAFE_FREE(local_mailbox_stream);
117 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
120 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
121 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
122 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
125 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
126 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
127 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
130 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
131 EM_DEBUG_LOG("error VALUE [%d]", err);
134 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
135 EM_DEBUG_LOG("Handle [%d]", handle);
138 emipc_destroy_email_api(hAPI);
140 EM_DEBUG_FUNC_END("err [%d]", err);
144 /* API - Update a mailbox */
147 EXPORT_API int email_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox)
149 EM_DEBUG_FUNC_BEGIN();
151 char* local_mailbox_stream = NULL;
152 int err = EMF_ERROR_NONE;
155 EM_DEBUG_LOG(" old_mailbox[%p], new_mailbox[%p]", old_mailbox, new_mailbox);
157 EM_IF_NULL_RETURN_VALUE(old_mailbox, EMF_ERROR_INVALID_PARAM);
158 EM_IF_NULL_RETURN_VALUE(old_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
159 EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM);
160 EM_IF_ACCOUNT_ID_NULL(new_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
162 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAILBOX);
164 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
167 local_mailbox_stream = em_convert_mailbox_to_byte_stream(old_mailbox, &size);
169 EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
171 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
172 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
173 EM_SAFE_FREE(local_mailbox_stream);
174 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
177 local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
179 EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
181 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
182 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
183 EM_SAFE_FREE(local_mailbox_stream);
184 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
187 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
188 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
189 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
192 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
193 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
194 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
197 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
199 EM_DEBUG_LOG("error VALUE [%d]", err);
200 emipc_destroy_email_api(hAPI);
203 EM_DEBUG_FUNC_END("err [%d]", err);
208 EXPORT_API int email_get_sync_mailbox_list(int account_id, emf_mailbox_t** mailbox_list, int* count)
210 EM_DEBUG_FUNC_BEGIN();
212 emstorage_mailbox_tbl_t* mailbox = NULL;
213 int err = EMF_ERROR_NONE ;
215 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
216 EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
217 EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
219 if (!emstorage_get_mailbox(account_id, 0, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &counter, &mailbox, true, &err)) {
220 EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
225 err = EMF_ERROR_NONE;
228 if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * counter))) {
229 EM_DEBUG_EXCEPTION("malloc failed...");
230 err= EMF_ERROR_OUT_OF_MEMORY;
234 *mailbox_list = NULL;
240 emstorage_free_mailbox(&mailbox, counter, NULL);
241 EM_DEBUG_FUNC_END("err [%d]", err);
246 EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, emf_mailbox_t** mailbox_list, int* count)
248 EM_DEBUG_FUNC_BEGIN();
250 int mailbox_count = 0;
251 emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
252 int err =EMF_ERROR_NONE;
255 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
256 EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
257 EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
259 if (!emstorage_get_mailbox(account_id, mailbox_sync_type, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
260 EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
264 err = EMF_ERROR_NONE;
266 if (mailbox_count > 0) {
267 if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * mailbox_count))) {
268 EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
269 err= EMF_ERROR_OUT_OF_MEMORY;
273 for (i = 0; i < mailbox_count; i++) {
274 (*mailbox_list)[i].mailbox_id = mailbox_tbl_list[i].mailbox_id;
275 (*mailbox_list)[i].account_id = account_id;
276 (*mailbox_list)[i].name = mailbox_tbl_list[i].mailbox_name;
277 mailbox_tbl_list[i].mailbox_name = NULL;
278 (*mailbox_list)[i].alias = mailbox_tbl_list[i].alias;
279 mailbox_tbl_list[i].alias = NULL;
280 (*mailbox_list)[i].local = mailbox_tbl_list[i].local_yn;
281 (*mailbox_list)[i].mailbox_type = mailbox_tbl_list[i].mailbox_type;
282 (*mailbox_list)[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn;
283 (*mailbox_list)[i].unread_count = mailbox_tbl_list[i].unread_count;
284 (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local;
285 (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server;
286 (*mailbox_list)[i].has_archived_mails = mailbox_tbl_list[i].has_archived_mails;
287 (*mailbox_list)[i].mail_slot_size = mailbox_tbl_list[i].mail_slot_size;
290 *mailbox_list = NULL;
292 *count = mailbox_count;
295 if (mailbox_tbl_list != NULL)
296 emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
298 EM_DEBUG_FUNC_END("err [%d]", err);
304 EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, emf_mailbox_t** mailbox_list, int* count)
306 EM_DEBUG_FUNC_BEGIN();
308 int mailbox_count = 0;
309 emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
310 int err =EMF_ERROR_NONE;
313 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
314 EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
315 EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
317 if (!emstorage_get_mailbox_ex(account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) {
318 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_ex failed [%d]", err);
322 err = EMF_ERROR_NONE;
324 if (mailbox_count > 0) {
325 if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * mailbox_count))) {
326 EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
327 err= EMF_ERROR_OUT_OF_MEMORY;
331 for (i = 0; i < mailbox_count; i++) {
332 (*mailbox_list)[i].mailbox_id = mailbox_tbl_list[i].mailbox_id;
333 (*mailbox_list)[i].account_id = account_id;
334 (*mailbox_list)[i].name = mailbox_tbl_list[i].mailbox_name;
335 mailbox_tbl_list[i].mailbox_name = NULL;
336 (*mailbox_list)[i].alias = mailbox_tbl_list[i].alias;
337 mailbox_tbl_list[i].alias = NULL;
338 (*mailbox_list)[i].local = mailbox_tbl_list[i].local_yn;
339 (*mailbox_list)[i].mailbox_type = mailbox_tbl_list[i].mailbox_type;
340 (*mailbox_list)[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn;
341 (*mailbox_list)[i].unread_count = mailbox_tbl_list[i].unread_count;
342 (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local;
343 (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server;
344 (*mailbox_list)[i].has_archived_mails = mailbox_tbl_list[i].has_archived_mails;
345 (*mailbox_list)[i].mail_slot_size = mailbox_tbl_list[i].mail_slot_size;
348 *mailbox_list = NULL;
351 *count = mailbox_count;
354 if (mailbox_tbl_list != NULL)
355 emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
357 EM_DEBUG_FUNC_END("err [%d]", err);
362 EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox)
364 EM_DEBUG_FUNC_BEGIN();
366 int err = EMF_ERROR_NONE;
367 emf_mailbox_t* curr_mailbox = NULL;
368 emstorage_mailbox_tbl_t* local_mailbox = NULL;
370 EM_IF_NULL_RETURN_VALUE(pMailbox, EMF_ERROR_INVALID_PARAM);
372 return EMF_ERROR_INVALID_PARAM;
374 if (!emstorage_get_mailbox_by_name(account_id, -1, (char*)pMailboxName, &local_mailbox, true, &err)) {
375 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
378 curr_mailbox = em_malloc(sizeof(emf_mailbox_t));
379 memset(curr_mailbox, 0x00, sizeof(emf_mailbox_t));
381 curr_mailbox->account_id = local_mailbox->account_id;
382 if(local_mailbox->mailbox_name)
383 curr_mailbox->name = strdup(local_mailbox->mailbox_name);
384 curr_mailbox->local = local_mailbox->local_yn;
385 if(local_mailbox->alias)
386 curr_mailbox->alias= strdup(local_mailbox->alias);
387 curr_mailbox->synchronous = local_mailbox->sync_with_server_yn;
388 curr_mailbox->mailbox_type = local_mailbox->mailbox_type;
389 curr_mailbox->unread_count = local_mailbox->unread_count;
390 curr_mailbox->total_mail_count_on_local= local_mailbox->total_mail_count_on_local;
391 curr_mailbox->total_mail_count_on_server= local_mailbox->total_mail_count_on_server;
392 curr_mailbox->has_archived_mails = local_mailbox->has_archived_mails;
393 curr_mailbox->mail_slot_size = local_mailbox->mail_slot_size;
396 *pMailbox = curr_mailbox;
398 emstorage_free_mailbox(&local_mailbox, 1, &err);
399 EM_DEBUG_FUNC_END("err [%d]", err);
404 EXPORT_API int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count)
406 EM_DEBUG_FUNC_BEGIN("account_id[%d], parent_mailbox[%p], mailbox_list[%p], count[%p]", account_id, parent_mailbox, mailbox_list, count);
408 int err = EMF_ERROR_NONE;
410 emstorage_mailbox_tbl_t* mailbox_tbl = NULL;
413 EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM);
414 EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
415 EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
417 *mailbox_list = NULL;
420 if (!emstorage_get_child_mailbox_list(account_id,(char*)parent_mailbox, &counter, &mailbox_tbl, true, &err)) {
421 EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed[%d]", err);
426 err = EMF_ERROR_NONE;
429 if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * counter))) {
430 EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
432 err= EMF_ERROR_OUT_OF_MEMORY;
436 memset(*mailbox_list, 0x00, (sizeof(emf_mailbox_t) * counter));
438 for (i = 0; i < counter; i++) {
439 (*mailbox_list)[i].mailbox_id = mailbox_tbl[i].mailbox_id;
440 (*mailbox_list)[i].account_id = account_id;
441 (*mailbox_list)[i].name = mailbox_tbl[i].mailbox_name; mailbox_tbl[i].mailbox_name = NULL;
442 (*mailbox_list)[i].alias = mailbox_tbl[i].alias; mailbox_tbl[i].alias = NULL;
443 (*mailbox_list)[i].local = mailbox_tbl[i].local_yn;
444 (*mailbox_list)[i].mailbox_type = mailbox_tbl[i].mailbox_type;
445 (*mailbox_list)[i].synchronous = mailbox_tbl[i].sync_with_server_yn;
446 (*mailbox_list)[i].unread_count = mailbox_tbl[i].unread_count;
447 (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl[i].total_mail_count_on_local;
448 (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl[i].total_mail_count_on_server;
449 (*mailbox_list)[i].has_archived_mails = mailbox_tbl[i].has_archived_mails;
450 (*mailbox_list)[i].mail_slot_size = mailbox_tbl[i].mail_slot_size;
453 *mailbox_list = NULL;
458 if (mailbox_tbl != NULL)
459 emstorage_free_mailbox(&mailbox_tbl, counter, NULL);
460 EM_DEBUG_FUNC_END("err [%d]", err);
464 /* sowmya.kr, 05-Apr-2010, new MAPI*/
466 EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox)
468 EM_DEBUG_FUNC_BEGIN();
470 int err = EMF_ERROR_NONE;
471 emf_mailbox_t* curr_mailbox = NULL;
472 emstorage_mailbox_tbl_t* local_mailbox = NULL;
474 EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
475 EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM) ;
478 if(mailbox_type < EMF_MAILBOX_TYPE_INBOX || mailbox_type > EMF_MAILBOX_TYPE_ALL_EMAILS)
479 return EMF_ERROR_INVALID_PARAM;
480 if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &local_mailbox, true, &err)) {
481 EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
485 err = EMF_ERROR_NONE;
486 curr_mailbox = em_malloc(sizeof(emf_mailbox_t));
487 memset(curr_mailbox, 0x00, sizeof(emf_mailbox_t));
489 curr_mailbox->account_id = local_mailbox->account_id;
490 if(local_mailbox->mailbox_name)
491 curr_mailbox->name = strdup(local_mailbox->mailbox_name);
492 curr_mailbox->local = local_mailbox->local_yn;
493 if(local_mailbox->alias)
494 curr_mailbox->alias= strdup(local_mailbox->alias);
495 curr_mailbox->synchronous = 1;
496 curr_mailbox->mailbox_type = local_mailbox->mailbox_type;
497 curr_mailbox->unread_count = local_mailbox->unread_count;
498 curr_mailbox->total_mail_count_on_local = local_mailbox->total_mail_count_on_local;
499 curr_mailbox->total_mail_count_on_server = local_mailbox->total_mail_count_on_server;
500 curr_mailbox->has_archived_mails = local_mailbox->has_archived_mails;
501 curr_mailbox->mail_slot_size = local_mailbox->mail_slot_size;
504 *mailbox = curr_mailbox;
508 emstorage_free_mailbox(&local_mailbox, 1, NULL);
509 EM_DEBUG_FUNC_END("err [%d]", err);
513 EXPORT_API int email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size/*, unsigned* handle*/)
515 EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], new_slot_size[%d]", account_id, mailbox_name, new_slot_size);
517 int err = EMF_ERROR_NONE, *handle = NULL;
519 if(new_slot_size < 0) {
520 EM_DEBUG_EXCEPTION("new_slot_size should be greater than 0 or should be equal to 0");
521 return EMF_ERROR_INVALID_PARAM;
524 HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE);
526 EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
529 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
530 EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
531 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
534 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &new_slot_size, sizeof(int))) {
535 EM_DEBUG_EXCEPTION(" emipc_add_parameter for new_slot_size failed");
536 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
540 if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_name, strlen(mailbox_name) )) {
541 EM_DEBUG_EXCEPTION(" emipc_add_parameter for mailbox_name failed");
542 EM_SAFE_FREE(mailbox_name);
543 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
547 if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
548 EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
549 EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
552 emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
553 EM_DEBUG_LOG("email_set_mail_slot_size error VALUE [%d]", err);
555 emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
556 EM_DEBUG_LOG("email_set_mail_slot_size handle VALUE [%d]", handle);
558 emipc_destroy_email_api(hAPI);
562 EM_DEBUG_FUNC_END("err [%d]", err);
566 EXPORT_API int email_free_mailbox(emf_mailbox_t** mailbox_list, int count)
568 EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d]", mailbox_list, count);
569 int err = EMF_ERROR_NONE;
571 if (count <= 0 || !mailbox_list || !*mailbox_list) {
572 EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
573 err = EMF_ERROR_INVALID_PARAM;
577 emf_mailbox_t *p = *mailbox_list;
580 for (i = 0; i < count; i++) {
581 EM_SAFE_FREE(p[i].name);
582 EM_SAFE_FREE(p[i].alias);
583 EM_SAFE_FREE(p[i].account_name);
587 *mailbox_list = NULL;
590 EM_DEBUG_FUNC_END("err [%d]", err);