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 /******************************************************************************
25 * Desc: email-daemon Account
30 * 2006.08.16 : created
31 *****************************************************************************/
37 #include "email-daemon.h"
38 #include "email-storage.h"
40 #include "email-debug-log.h"
41 #include "email-daemon-account.h"
42 #include "email-daemon-auto-poll.h"
44 #include <contacts_internal.h>
45 #include "email-types.h"
46 #include "email-core-account.h"
47 #include "email-core-event.h"
48 #include "email-core-utils.h"
49 #include "email-core-imap-idle.h"
50 #include "email-utilities.h"
51 #include "email-convert.h"
53 static int emdaemon_check_filter_id(char *multi_user_name, int filter_id, int* err_code)
55 EM_DEBUG_FUNC_BEGIN("filter_id[%d], err_code[%p]", filter_id, err_code);
57 if (filter_id <= 0) { /* only global rule supported. */
58 EM_DEBUG_EXCEPTION("filter_id[%d]", filter_id);
61 *err_code = EMAIL_ERROR_INVALID_PARAM;
66 int err = EMAIL_ERROR_NONE;
67 emstorage_rule_tbl_t* filter = NULL;
69 if (!emstorage_get_rule_by_id(multi_user_name, filter_id, &filter, true, &err)) {
70 EM_DEBUG_EXCEPTION(" emstorage_get_rule_by_id failed [%d]", err);
78 emstorage_free_rule(&filter, 1, NULL);
87 INTERNAL_FUNC int emdaemon_create_account(char *multi_user_name, email_account_t* account, int* err_code)
90 int err = EMAIL_ERROR_NONE;
92 if (!emcore_create_account(multi_user_name, account, false, &err)) {
93 EM_DEBUG_EXCEPTION(" emcore_account_add failed [%d]", err);
106 INTERNAL_FUNC int emdaemon_delete_account(char *multi_user_name, int account_id, int* err_code)
108 EM_DEBUG_FUNC_BEGIN("account_id[%d] err_code[%p]", account_id, err_code);
111 ret = emcore_delete_account(multi_user_name, account_id, false, err_code);
113 EM_DEBUG_FUNC_END("ret[%d]", ret);
117 static email_account_t* duplicate_account(email_account_t *src)
120 EM_DEBUG_EXCEPTION("INVALID_PARAM");
123 email_account_t *dst = (email_account_t *)em_malloc(sizeof(email_account_t));
125 EM_DEBUG_EXCEPTION(" malloc failed...");
130 memcpy(dst, src, sizeof(email_account_t));
131 dst->account_name = EM_SAFE_STRDUP(src->account_name);
132 dst->incoming_server_address = EM_SAFE_STRDUP(src->incoming_server_address);
133 dst->user_email_address = EM_SAFE_STRDUP(src->user_email_address);
134 dst->incoming_server_user_name = EM_SAFE_STRDUP(src->incoming_server_user_name);
135 dst->incoming_server_password = EM_SAFE_STRDUP(src->incoming_server_password);
136 dst->outgoing_server_address = EM_SAFE_STRDUP(src->outgoing_server_address);
137 dst->outgoing_server_user_name = EM_SAFE_STRDUP(src->outgoing_server_user_name);
138 dst->outgoing_server_password = EM_SAFE_STRDUP(src->outgoing_server_password);
139 dst->user_display_name = EM_SAFE_STRDUP(src->user_display_name);
140 dst->reply_to_address = EM_SAFE_STRDUP(src->reply_to_address);
141 dst->return_address = EM_SAFE_STRDUP(src->return_address);
142 dst->logo_icon_path = EM_SAFE_STRDUP(src->logo_icon_path);
143 dst->certificate_path = EM_SAFE_STRDUP(src->certificate_path);
144 dst->options.display_name_from = EM_SAFE_STRDUP(src->options.display_name_from);
145 dst->options.signature = EM_SAFE_STRDUP(src->options.signature);
146 dst->user_data = (void*) em_malloc(src->user_data_length);
147 if( !dst->user_data ) {
148 EM_DEBUG_EXCEPTION("em_malloc failed");
149 emcore_free_account(dst);
154 memcpy(dst->user_data, src->user_data, src->user_data_length);
159 INTERNAL_FUNC int emdaemon_validate_account(char *multi_user_name, int account_id, int *handle, int* err_code)
161 EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p], err_code[%p]", account_id, handle, err_code);
164 int err = EMAIL_ERROR_NONE;
165 email_event_t *event_data = NULL;
166 email_account_t *ref_account = NULL;
168 if (account_id < 1) {
169 EM_DEBUG_EXCEPTION(" account_id[%d]", account_id);
170 err = EMAIL_ERROR_INVALID_PARAM;
174 if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
175 EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed [%d]", account_id);
176 err = EMAIL_ERROR_INVALID_ACCOUNT;
180 event_data = em_malloc(sizeof(email_event_t));
181 event_data->type = EMAIL_EVENT_VALIDATE_ACCOUNT;
182 event_data->event_param_data_1 = NULL;
183 event_data->event_param_data_3 = NULL;
184 event_data->account_id = account_id;
185 event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
187 if (!emcore_insert_event(event_data, (int*)handle, &err)) {
188 EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
197 emcore_free_account(ref_account);
198 EM_SAFE_FREE(ref_account);
201 if (ret == false && event_data) {
202 emcore_free_event(event_data);
203 EM_SAFE_FREE(event_data);
214 INTERNAL_FUNC int emdaemon_validate_account_ex(char *multi_user_name, email_account_t* input_account, int *output_handle)
216 EM_DEBUG_FUNC_BEGIN("input_account[%p], output_handle[%p]", input_account, output_handle);
219 int err = EMAIL_ERROR_NONE;
220 email_event_t *event_data = NULL;
222 event_data = em_malloc(sizeof(email_event_t));
224 if(!event_data) { /*prevent 53095*/
225 EM_DEBUG_EXCEPTION("em_malloc failed");
226 err = EMAIL_ERROR_OUT_OF_MEMORY;
230 event_data->type = EMAIL_EVENT_VALIDATE_ACCOUNT_EX;
231 event_data->event_param_data_1 = (void*)input_account;
232 event_data->event_param_data_3 = NULL;
233 event_data->account_id = NEW_ACCOUNT_ID;
234 event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
236 if (!emcore_insert_event(event_data, (int*)output_handle, &err)) {
237 EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
245 if (ret == false && event_data) {
246 emcore_free_event(event_data);
247 EM_SAFE_FREE(event_data);
250 EM_DEBUG_FUNC_END("err [%d]", err);
255 INTERNAL_FUNC int emdaemon_validate_account_and_create(char *multi_user_name, email_account_t* new_account, int *handle, int* err_code)
257 EM_DEBUG_FUNC_BEGIN("account[%p], handle[%p], err_code[%p]", new_account, handle, err_code);
260 int err = EMAIL_ERROR_NONE;
261 email_event_t *event_data = NULL;
263 event_data = em_malloc(sizeof(email_event_t));
265 if(!event_data) { /*prevent 53093*/
266 EM_DEBUG_EXCEPTION("em_malloc failed");
267 err = EMAIL_ERROR_OUT_OF_MEMORY;
271 event_data->type = EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT;
272 event_data->event_param_data_1 = (void *)new_account;
273 event_data->event_param_data_3 = NULL;
274 event_data->account_id = NEW_ACCOUNT_ID;
275 event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
277 if (!emcore_insert_event(event_data, (int*)handle, &err)) {
278 EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
286 if (ret == false && event_data) {
287 emcore_free_event(event_data);
288 EM_SAFE_FREE(event_data);
300 INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id, email_account_t* new_account, int* err_code)
302 EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p], err_code[%p]", account_id, new_account, err_code);
304 /* default variable */
306 int err = EMAIL_ERROR_NONE;
307 emstorage_account_tbl_t *new_account_tbl = NULL;
308 email_account_t *old_account_info = NULL;
310 if ((account_id <= 0) || !new_account) {
311 EM_DEBUG_EXCEPTION("Invalid Parameters.");
312 err = EMAIL_ERROR_INVALID_PARAM;
316 if((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
317 EM_DEBUG_EXCEPTION("emcore_get_account_reference failed ");
321 if(new_account->user_email_address) {
322 if ((err = em_verify_email_address (new_account->user_email_address)) != EMAIL_ERROR_NONE) {
323 EM_DEBUG_EXCEPTION("em_verify_email_address error [%d]", err);
328 if (EM_SAFE_STRCMP(new_account->incoming_server_password, old_account_info->incoming_server_password) == 0) {
329 EM_SAFE_FREE(new_account->incoming_server_password);
332 if (EM_SAFE_STRCMP(new_account->outgoing_server_password, old_account_info->outgoing_server_password) == 0) {
333 EM_SAFE_FREE(new_account->outgoing_server_password);
336 new_account_tbl = em_malloc(sizeof(emstorage_account_tbl_t));
337 if(!new_account_tbl) {
338 EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
342 em_convert_account_to_account_tbl(new_account, new_account_tbl);
344 if (!emstorage_update_account(multi_user_name, account_id, new_account_tbl, true, &err)) {
345 EM_DEBUG_EXCEPTION("emstorage_update_account failed [%d]", err);
349 #ifdef __FEATURE_AUTO_POLLING__
350 int change_in_auto_polling_option = 0;
352 change_in_auto_polling_option = (old_account_info->check_interval != new_account->check_interval) ||
353 (old_account_info->peak_interval != new_account->peak_interval) ||
354 (old_account_info->peak_start_time != new_account->peak_start_time) ||
355 (old_account_info->peak_end_time != new_account->peak_end_time);
357 EM_DEBUG_LOG("change_in_auto_polling_option [%d]", change_in_auto_polling_option);
361 #ifdef __FEATURE_AUTO_POLLING__
362 if(change_in_auto_polling_option) {
363 if(!emdaemon_remove_polling_alarm(account_id))
364 EM_DEBUG_LOG("emdaemon_remove_polling_alarm failed");
366 if(!emdaemon_add_polling_alarm(multi_user_name, account_id))
367 EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm failed");
369 #ifdef __FEATURE_IMAP_IDLE__
370 emcore_refresh_imap_idle_thread();
371 #endif /* __FEATURE_IMAP_IDLE__ */
380 emstorage_free_account(&new_account_tbl, 1, NULL);
382 if (old_account_info) {
383 emcore_free_account(old_account_info);
384 EM_SAFE_FREE(old_account_info);
394 INTERNAL_FUNC int emdaemon_validate_account_and_update(char *multi_user_name, int old_account_id, email_account_t* new_account_info, int *handle,int *err_code)
396 EM_DEBUG_FUNC_BEGIN("account[%d], new_account_info[%p], handle[%p], err_code[%p]", old_account_id, new_account_info, handle, err_code);
399 int err = EMAIL_ERROR_NONE;
400 email_event_t *event_data = NULL;
402 event_data = em_malloc(sizeof(email_event_t));
404 if(!event_data) { /*prevent 53094*/
405 EM_DEBUG_EXCEPTION("em_malloc failed");
406 err = EMAIL_ERROR_OUT_OF_MEMORY;
410 event_data->type = EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT;
411 event_data->event_param_data_1 = (char *) duplicate_account(new_account_info);
412 event_data->event_param_data_3 = NULL;
413 event_data->account_id = old_account_id;
414 event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
417 email_account_t *pAccount = (email_account_t *)em_malloc(sizeof(email_account_t));
418 if (pAccount == NULL) {
419 EM_DEBUG_EXCEPTION(" malloc failed...");
420 err = EMAIL_ERROR_OUT_OF_MEMORY;
425 memcpy(pAccount, new_account_info, sizeof(email_account_t));
426 pAccount->account_name = EM_SAFE_STRDUP(new_account_info->account_name);
427 pAccount->incoming_server_address = EM_SAFE_STRDUP(new_account_info->incoming_server_address);
428 pAccount->user_email_address = EM_SAFE_STRDUP(new_account_info->user_email_address);
429 pAccount->incoming_server_user_name = EM_SAFE_STRDUP(new_account_info->user_email_address);
430 pAccount->incoming_server_password = EM_SAFE_STRDUP(new_account_info->incoming_server_password);
431 pAccount->outgoing_server_address = EM_SAFE_STRDUP(new_account_info->incoming_server_password);
432 pAccount->outgoing_server_user_name = EM_SAFE_STRDUP(new_account_info->outgoing_server_user_name);
433 pAccount->outgoing_server_password = EM_SAFE_STRDUP(new_account_info->outgoing_server_password);
434 pAccount->user_display_name = EM_SAFE_STRDUP(new_account_info->user_display_name);
435 pAccount->reply_to_address = EM_SAFE_STRDUP(new_account_info->reply_to_address);
436 pAccount->return_address = EM_SAFE_STRDUP(new_account_info->return_address);
437 pAccount->logo_icon_path = EM_SAFE_STRDUP(new_account_info->logo_icon_path);
438 pAccount->certificate_path = EM_SAFE_STRDUP(new_account_info->certificate_path);
439 pAccount->options.display_name_from = EM_SAFE_STRDUP(new_account_info->options.display_name_from);
440 pAccount->options.signature = EM_SAFE_STRDUP(new_account_info->options.signature);
441 memcpy(pAccount->user_data, new_account_info->user_data, new_account_info->user_data_length);
444 if (!emcore_insert_event(event_data, (int*)handle, &err)) {
445 EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err);
453 if (ret == false && event_data) {
454 emcore_free_event(event_data);
455 EM_SAFE_FREE(event_data);
467 INTERNAL_FUNC int emdaemon_get_account(char *multi_user_name, int account_id, int pulloption, email_account_t* account, int* err_code)
469 EM_DEBUG_FUNC_BEGIN("account_id[%d], pulloption [%d], account[%p], err_code[%p]", account_id, pulloption, account, err_code);
471 /* default variable */
473 int err = EMAIL_ERROR_NONE;
474 emstorage_account_tbl_t *account_tbl = NULL;
477 EM_DEBUG_EXCEPTION("account_id[%d], account[%p]", account_id, account);
478 err = EMAIL_ERROR_INVALID_PARAM;
482 if (!emstorage_get_account_by_id(multi_user_name, account_id, pulloption, &account_tbl, true, &err)) {
483 EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
487 em_convert_account_tbl_to_account(account_tbl, account);
493 emstorage_free_account(&account_tbl, 1, NULL);
496 EM_DEBUG_FUNC_END("ret [%d]", ret);
500 INTERNAL_FUNC int emdaemon_get_account_list(char *multi_user_name, email_account_t** account_list, int* count, int* err_code)
502 EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%p], err_code[%p]", account_list, count, err_code);
504 int ret = false, err = EMAIL_ERROR_NONE, i = 0;
505 emstorage_account_tbl_t *account_tbl_array = NULL;
507 if (!account_list || !count) {
508 err = EMAIL_ERROR_INVALID_PARAM;
514 if (!emstorage_get_account_list(multi_user_name, count, &account_tbl_array, true, true, &err)) {
515 EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
519 if(account_tbl_array && (*count) > 0) {
520 *account_list = (email_account_t*)em_malloc(sizeof(email_account_t) * (*count));
522 EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
526 for(i = 0 ; i < (*count); i++)
527 em_convert_account_tbl_to_account(account_tbl_array + i, (*account_list) + i);
533 if(account_tbl_array)
534 emstorage_free_account(&account_tbl_array, (*count), NULL);
536 if (err_code != NULL)
538 EM_DEBUG_FUNC_END("ret [%d]", ret);
543 INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int count, int* err_code)
545 EM_DEBUG_FUNC_BEGIN();
546 return emcore_free_account_list(account_list, count, err_code);
550 INTERNAL_FUNC int emdaemon_get_filter(char *multi_user_name, int filter_id, email_rule_t** filter_info, int* err_code)
552 EM_DEBUG_FUNC_BEGIN("filter_id[%d], filter_info[%p], err_code[%p]", filter_id, filter_info, err_code);
555 EM_DEBUG_EXCEPTION("filter_id[%d], filter_info[%p]", filter_id, filter_info);
557 if (err_code != NULL)
558 *err_code = EMAIL_ERROR_INVALID_PARAM;
562 /* default variable */
564 int err = EMAIL_ERROR_NONE;
566 if (!emstorage_get_rule_by_id(multi_user_name, filter_id, (emstorage_rule_tbl_t**)filter_info, true, &err)) {
567 EM_DEBUG_EXCEPTION(" emstorage_get_rule_by_id failed [%d]", err);
581 INTERNAL_FUNC int emdaemon_get_filter_list(char *multi_user_name, email_rule_t** filter_info, int* count, int* err_code)
583 EM_DEBUG_FUNC_BEGIN("filter_info[%p], count[%p], err_code[%p]", filter_info, count, err_code);
585 /* default variable */
587 int err = EMAIL_ERROR_NONE;
590 if (!filter_info || !count) {
591 EM_DEBUG_EXCEPTION(" filter_info[%p], count[%p]", filter_info, count);
592 err = EMAIL_ERROR_INVALID_PARAM;
598 if (!emstorage_get_rule(multi_user_name, ALL_ACCOUNT, 0, 0, count, &is_completed, (emstorage_rule_tbl_t**)filter_info, true, &err)) {
599 EM_DEBUG_EXCEPTION(" emstorage_get_rule failed [%d]", err);
612 INTERNAL_FUNC int emdaemon_find_filter(char *multi_user_name, email_rule_t* filter_info, int* err_code)
614 EM_DEBUG_FUNC_BEGIN("filter_info[%p], err_code[%p]", filter_info, err_code);
616 /* default variable */
618 int err = EMAIL_ERROR_NONE;
621 EM_DEBUG_EXCEPTION(" filter_info[%p]", filter_info);
622 err = EMAIL_ERROR_INVALID_PARAM;
626 if (filter_info->faction == EMAIL_FILTER_MOVE && filter_info->target_mailbox_id <= 0) {
627 EM_DEBUG_EXCEPTION("filter_info->faction[%d], filter_info->target_mailbox_id[%d]", filter_info->faction, filter_info->target_mailbox_id);
628 err = EMAIL_ERROR_INVALID_FILTER;
632 filter_info->account_id = ALL_ACCOUNT; /* MUST BE */
634 if (!emstorage_find_rule(multi_user_name, (emstorage_rule_tbl_t*)filter_info, true, &err)) {
635 EM_DEBUG_EXCEPTION("emstorage_find_rule failed [%d]", err);
638 if (err == EMAIL_ERROR_FILTER_NOT_FOUND) {
639 EM_DEBUG_LOG("EMAIL_ERROR_FILTER_NOT_FOUND");
640 err = EMAIL_ERROR_FILTER_NOT_FOUND;
655 INTERNAL_FUNC int emdaemon_add_filter(char *multi_user_name, email_rule_t* filter_info)
657 EM_DEBUG_FUNC_BEGIN("filter_info[%p]", filter_info);
659 /* default variable */
660 int err = EMAIL_ERROR_NONE;
662 EM_DEBUG_EXCEPTION("filter_info[%p]", filter_info);
663 err = EMAIL_ERROR_INVALID_PARAM;
667 err = emcore_add_rule(multi_user_name, filter_info);
668 if (err != EMAIL_ERROR_NONE) {
669 EM_DEBUG_EXCEPTION("emcore_add_rule failed : [%d]", err);
679 INTERNAL_FUNC int emdaemon_update_filter(char *multi_user_name, int filter_id, email_rule_t* filter_info, int* err_code)
681 EM_DEBUG_FUNC_BEGIN("filter_id[%d], filter_info[%p], err_code[%p]", filter_id, filter_info, err_code);
683 /* default variable */
685 int err = EMAIL_ERROR_NONE;
687 if ((filter_id <= 0) || !filter_info) {
688 EM_DEBUG_EXCEPTION("filter_id[%d], filter_info[%p]", filter_id, filter_info);
689 err = EMAIL_ERROR_INVALID_PARAM;
693 if (!emdaemon_check_filter_id(multi_user_name, filter_id, &err)) {
694 EM_DEBUG_EXCEPTION("emdaemon_check_filter_id falied [%d]", err);
698 err = emcore_update_rule(multi_user_name, filter_id, filter_info);
699 if (err != EMAIL_ERROR_NONE) {
700 EM_DEBUG_EXCEPTION("emcore_update_rule failed : [%d]", err);
713 INTERNAL_FUNC int emdaemon_delete_filter(char *multi_user_name, int filter_id, int* err_code)
715 EM_DEBUG_FUNC_BEGIN("filter_id[%d, err_code[%p]", filter_id, err_code);
717 /* default variable */
719 int err = EMAIL_ERROR_NONE;
721 if (filter_id <= 0) {
722 EM_DEBUG_EXCEPTION(" fliter_id[%d]", filter_id);
723 err = EMAIL_ERROR_INVALID_PARAM;
727 err = emcore_delete_rule(multi_user_name, filter_id);
728 if (err != EMAIL_ERROR_NONE) {
729 EM_DEBUG_EXCEPTION("emcore_delete_rule failed : [%d]", err);
744 INTERNAL_FUNC int emdaemon_free_filter(email_rule_t** filter_info, int count, int* err_code)
746 EM_DEBUG_FUNC_BEGIN("filter_info[%p], count[%d], err_code[%p]", filter_info, count, err_code);
748 /* default variable */
750 int err = EMAIL_ERROR_NONE;
753 if (!filter_info || !*filter_info) {
754 EM_DEBUG_EXCEPTION(" filter_info[%p], count[%d]", filter_info, count);
755 err = EMAIL_ERROR_INVALID_PARAM;
759 email_rule_t* p = *filter_info;
762 for (i = 0; i < count; i++) {
763 EM_SAFE_FREE(p[i].value);
766 EM_SAFE_FREE(p); *filter_info = NULL;
778 INTERNAL_FUNC int emdaemon_apply_filter(char *multi_user_name, int filter_id, int *err_code)
780 EM_DEBUG_FUNC_BEGIN("filter_id[%d, err_code[%p]", filter_id, err_code);
782 /* default variable */
784 int err = EMAIL_ERROR_NONE;
785 emstorage_rule_tbl_t *filter_info = NULL;
787 if (filter_id <= 0) {
788 EM_DEBUG_EXCEPTION(" fliter_id[%d]", filter_id);
789 err = EMAIL_ERROR_INVALID_PARAM;
793 if (!emstorage_get_rule_by_id(multi_user_name, filter_id, &filter_info, false, &err)) {
794 EM_DEBUG_EXCEPTION("emstorage_get_rule_by_id failed : [%d]", err);
798 if (!emcore_mail_filter_by_rule(multi_user_name, (email_rule_t *)filter_info, &err)) {
799 EM_DEBUG_EXCEPTION(" emstorage_mail_filter_by_rule failed [%d]", err);
813 /* ----- internal functions --------------------------------------------*/
815 INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* account)
817 EM_DEBUG_FUNC_BEGIN();
827 INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_account, email_account_t* new_account)
829 EM_DEBUG_FUNC_BEGIN();
831 if(!old_account || !new_account)
839 INTERNAL_FUNC int emdaemon_query_smtp_mail_size_limit(char *multi_user_name, int account_id, int *handle, int* err_code)
841 EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p], err_code[%p]", account_id, handle, err_code);
844 int err = EMAIL_ERROR_NONE;
845 email_event_t *event_data = NULL;
847 if (account_id < 1) {
848 EM_DEBUG_EXCEPTION(" account_id[%d]", account_id);
849 err = EMAIL_ERROR_INVALID_PARAM;
853 event_data = em_malloc(sizeof(email_event_t));
854 event_data->type = EMAIL_EVENT_QUERY_SMTP_MAIL_SIZE_LIMIT;
855 event_data->event_param_data_1 = NULL;
856 event_data->event_param_data_3 = NULL;
857 event_data->account_id = account_id;
858 event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
860 if (!emcore_insert_event(event_data, (int*)handle, &err)) {
861 EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
869 if (ret == false && event_data) {
870 emcore_free_event(event_data);
871 EM_SAFE_FREE(event_data);