diff options
author | Susnata <s.sovalin@samsung.com> | 2018-03-21 02:50:33 -0400 |
---|---|---|
committer | Susnata Sovalin <s.sovalin@samsung.com> | 2018-04-11 11:26:21 +0530 |
commit | f8389f0b0317bd9a07bfa1489ce57aa2169f0f02 (patch) | |
tree | caff2e1e4c5ec15e2b2955e9cfec0972d3b843ff | |
parent | 19913c6b3d1ecfabd53ec7c81f8d65b2f13e11ff (diff) | |
download | email-service-f8389f0b0317bd9a07bfa1489ce57aa2169f0f02.tar.gz email-service-f8389f0b0317bd9a07bfa1489ce57aa2169f0f02.tar.bz2 email-service-f8389f0b0317bd9a07bfa1489ce57aa2169f0f02.zip |
Fix Svace issuessubmit/tizen/20180420.052935
Signed-off-by: Susnata <s.sovalin@samsung.com>
Change-Id: I106f21ef4bcff81874301fb09736f1b90ae14a52
-rwxr-xr-x | email-core/email-core-cert.c | 2 | ||||
-rwxr-xr-x | email-core/email-core-cynara.c | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | email-core/email-core-key-manager.c | 25 | ||||
-rwxr-xr-x | email-core/email-core-mime.c | 151 | ||||
-rwxr-xr-x | email-core/email-core-mm-callbacks.c | 2 | ||||
-rwxr-xr-x | email-core/email-core-smtp.c | 10 | ||||
-rwxr-xr-x | email-core/email-core-utils.c | 9 | ||||
-rwxr-xr-x | email-core/email-storage/email-storage.c | 73 | ||||
-rwxr-xr-x[-rw-r--r--] | test/testapp-mail.c | 4485 |
9 files changed, 2360 insertions, 2403 deletions
diff --git a/email-core/email-core-cert.c b/email-core/email-core-cert.c index 0adb2af..9971506 100755 --- a/email-core/email-core-cert.c +++ b/email-core/email-core-cert.c @@ -266,7 +266,7 @@ INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity /* Open input data file */ bio_indata = BIO_new_file(mime_entity, INMODE); - if (!bio_p7s) { + if (!bio_indata) { EM_DEBUG_EXCEPTION("File open failed"); err = EMAIL_ERROR_SYSTEM_FAILURE; goto FINISH_OFF; diff --git a/email-core/email-core-cynara.c b/email-core/email-core-cynara.c index b6ca561..dbe3924 100755 --- a/email-core/email-core-cynara.c +++ b/email-core/email-core-cynara.c @@ -133,12 +133,6 @@ INTERNAL_FUNC int emcore_check_privilege(unsigned int socket_fd) int err = EMAIL_ERROR_NONE; char errno_buf[ERRNO_BUF_SIZE] = {0}; - if (socket_fd < 0) { - EM_DEBUG_EXCEPTION("Invalid parameter"); - err = EMAIL_ERROR_INVALID_PARAM; - return err; - } - if (cynara_info->email_cynara == NULL) { err = emcore_init_cynara(); if (err != EMAIL_ERROR_NONE) { diff --git a/email-core/email-core-key-manager.c b/email-core/email-core-key-manager.c index 6615dad..d6fdec2 100644..100755 --- a/email-core/email-core-key-manager.c +++ b/email-core/email-core-key-manager.c @@ -472,22 +472,21 @@ INTERNAL_FUNC int emcore_decryption_data_from_file_in_key_manager(const char *da EM_DEBUG_EXCEPTION("em_open failed : [%d] [%s]", err, file_path); goto FINISH_OFF; } - - - buffer_length = st_buf.st_size; - EM_DEBUG_LOG("account buffer_length[%d]", buffer_length); - - + buffer_length = st_buf.st_size; + EM_DEBUG_LOG("account buffer_length[%d]", buffer_length); encrypted = (ckmc_raw_buffer_s*)malloc(sizeof(ckmc_raw_buffer_s)); - if ((encrypted->data = (unsigned char *)em_malloc(buffer_length + 1)) == NULL) { - EM_DEBUG_EXCEPTION("em_malloc failed..."); - err = EMAIL_ERROR_OUT_OF_MEMORY; - goto FINISH_OFF; - - } - + if (!encrypted) { + EM_DEBUG_EXCEPTION("malloc failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } + if ((encrypted->data = (unsigned char *)em_malloc(buffer_length + 1)) == NULL) { + EM_DEBUG_EXCEPTION("em_malloc failed..."); + err = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } if (read(fd, encrypted->data, buffer_length) < 0) { EM_DEBUG_EXCEPTION("read failed : [%s]", EM_STRERROR(errno_buf)); err = EMAIL_ERROR_SYSTEM_FAILURE; diff --git a/email-core/email-core-mime.c b/email-core/email-core-mime.c index 3762393..8f25874 100755 --- a/email-core/email-core-mime.c +++ b/email-core/email-core-mime.c @@ -181,11 +181,6 @@ char *em_split_file_path(char *str) char *temp_cid_data = NULL; char *temp_cid = NULL; - if (str == NULL) { - EM_DEBUG_EXCEPTION("Invalid parameter"); - return NULL; - } - temp_str = g_strdup(str); buf_length = EM_SAFE_STRLEN(str) + 1024; buf = em_malloc(buf_length); @@ -262,22 +257,22 @@ INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_ty *dec_len = enc_len; switch (enc_type) { - case ENCQUOTEDPRINTABLE: + case ENCQUOTEDPRINTABLE: - content = rfc822_qprint((unsigned char *)enc_buf, (unsigned long)enc_len, (unsigned long *)dec_len); - break; + content = rfc822_qprint((unsigned char *)enc_buf, (unsigned long)enc_len, (unsigned long *)dec_len); + break; - case ENCBASE64: + case ENCBASE64: - content = rfc822_base64((unsigned char *)enc_buf, (unsigned long)enc_len, (unsigned long *)dec_len); - break; + content = rfc822_base64((unsigned char *)enc_buf, (unsigned long)enc_len, (unsigned long *)dec_len); + break; - case ENC7BIT: - case ENC8BIT: - case ENCBINARY: - case ENCOTHER: - default: - break; + case ENC7BIT: + case ENC8BIT: + case ENCBINARY: + case ENCOTHER: + default: + break; } if (content) { @@ -691,38 +686,38 @@ INTERNAL_FUNC int emcore_get_content_type_from_mail_bodystruct(BODY *input_body, em_lower_string(subtype_string); switch (input_body->type) { - case TYPETEXT: - SNPRINTF(output_content_type, input_buffer_length, "text/%s", subtype_string); - break; - case TYPEMULTIPART: - SNPRINTF(output_content_type, input_buffer_length, "multipart/%s", subtype_string); - break; - case TYPEMESSAGE: - SNPRINTF(output_content_type, input_buffer_length, "message/%s", subtype_string); - break; - case TYPEAPPLICATION: - SNPRINTF(output_content_type, input_buffer_length, "application/%s", subtype_string); - break; - case TYPEAUDIO: - SNPRINTF(output_content_type, input_buffer_length, "audio/%s", subtype_string); - break; - case TYPEIMAGE: - SNPRINTF(output_content_type, input_buffer_length, "image/%s", subtype_string); - break; - case TYPEVIDEO: - SNPRINTF(output_content_type, input_buffer_length, "video/%s", subtype_string); - break; - case TYPEMODEL: - SNPRINTF(output_content_type, input_buffer_length, "model/%s", subtype_string); - break; - case TYPEOTHER: - SNPRINTF(output_content_type, input_buffer_length, "other/%s", subtype_string); - break; - default: - EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); - err = EMAIL_ERROR_INVALID_PARAM; - goto FINISH_OFF; - break; + case TYPETEXT: + SNPRINTF(output_content_type, input_buffer_length, "text/%s", subtype_string); + break; + case TYPEMULTIPART: + SNPRINTF(output_content_type, input_buffer_length, "multipart/%s", subtype_string); + break; + case TYPEMESSAGE: + SNPRINTF(output_content_type, input_buffer_length, "message/%s", subtype_string); + break; + case TYPEAPPLICATION: + SNPRINTF(output_content_type, input_buffer_length, "application/%s", subtype_string); + break; + case TYPEAUDIO: + SNPRINTF(output_content_type, input_buffer_length, "audio/%s", subtype_string); + break; + case TYPEIMAGE: + SNPRINTF(output_content_type, input_buffer_length, "image/%s", subtype_string); + break; + case TYPEVIDEO: + SNPRINTF(output_content_type, input_buffer_length, "video/%s", subtype_string); + break; + case TYPEMODEL: + SNPRINTF(output_content_type, input_buffer_length, "model/%s", subtype_string); + break; + case TYPEOTHER: + SNPRINTF(output_content_type, input_buffer_length, "other/%s", subtype_string); + break; + default: + EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); + err = EMAIL_ERROR_INVALID_PARAM; + goto FINISH_OFF; + break; } EM_DEBUG_LOG_SEC("output_content_type [%s]", output_content_type); @@ -945,10 +940,8 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s ADDRESS *return_path = NULL; ADDRESS *reply_to = NULL; MESSAGECACHE mail_cache_element = {0, }; - - memset(&mail_cache_element, 0x00, sizeof(MESSAGECACHE)); + memset(&mail_cache_element, 0x00, sizeof(MESSAGECACHE)); memset((void *)&temp_time_info, 0, sizeof(struct tm)); - /* Set the smime_type */ if (mmsg->rfc822header && mmsg->rfc822header->content_type) { if (strcasestr(mmsg->rfc822header->content_type, "pkcs7-mime")) { @@ -1122,9 +1115,8 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s if (reply_to) mail_free_address(&reply_to); - - EM_DEBUG_FUNC_END("err : [%d]", err); - return err; + EM_DEBUG_FUNC_END("err : [%d]", err); + return err; } INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, @@ -1146,8 +1138,8 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, char move_buf[512]; char path_buf[512]; char html_body[MAX_PATH] = {0, }; - char *multi_user_name = NULL; - struct timeval tv; + char *multi_user_name = NULL; + struct timeval tv; struct attachment_info *ai = NULL; email_attachment_data_t *attachment = NULL; email_mail_data_t *p_mail_data = NULL; @@ -1182,9 +1174,8 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, EM_DEBUG_LOG("cnt_info->text.plain [%s], cnt_info->text.html [%s]", cnt_info->text.plain, cnt_info->text.html); if (cnt_info->text.plain) { - memset(move_buf, 0x00, sizeof(move_buf)); - memset(path_buf, 0x00, sizeof(path_buf)); - + memset(move_buf, 0x00, sizeof(move_buf)); + memset(path_buf, 0x00, sizeof(path_buf)); EM_DEBUG_LOG("cnt_info->text.plain [%s]", cnt_info->text.plain); if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) { EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); @@ -1208,9 +1199,8 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, } if (cnt_info->text.html) { - memset(move_buf, 0x00, sizeof(move_buf)); - memset(path_buf, 0x00, sizeof(path_buf)); - + memset(move_buf, 0x00, sizeof(move_buf)); + memset(path_buf, 0x00, sizeof(path_buf)); if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) { EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); goto FINISH_OFF; @@ -1263,10 +1253,10 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, } if ((err = emcore_get_preview_text_from_file(multi_user_name, - p_mail_data->file_path_plain, - p_mail_data->file_path_html, - MAX_PREVIEW_TEXT_LENGTH, - &p_mail_data->preview_text)) != EMAIL_ERROR_NONE) + p_mail_data->file_path_plain, + p_mail_data->file_path_html, + MAX_PREVIEW_TEXT_LENGTH, + &p_mail_data->preview_text)) != EMAIL_ERROR_NONE) EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file error [%d]", err); for (ai = cnt_info->file; ai; ai = ai->next, local_attachment_count++) {} @@ -1306,10 +1296,10 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, EM_DEBUG_LOG("attachment[%d].attachment_mime_type : [%s]", i, attachment[i].attachment_mime_type); if (ai->save) { - memset(move_buf, 0x00, sizeof(move_buf)); - memset(path_buf, 0x00, sizeof(path_buf)); + memset(move_buf, 0x00, sizeof(move_buf)); + memset(path_buf, 0x00, sizeof(path_buf)); - if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, i + 1, &err)) { + if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, i + 1, &err)) { EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); goto FINISH_OFF; } @@ -1369,8 +1359,8 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, EM_DEBUG_LOG("attachment[%d].attachment_mime_type : [%s]", i, attachment[i].attachment_mime_type); if (ai->save) { - memset(move_buf, 0x00, sizeof(move_buf)); - memset(path_buf, 0x00, sizeof(path_buf)); + memset(move_buf, 0x00, sizeof(move_buf)); + memset(path_buf, 0x00, sizeof(path_buf)); if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) { EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err); @@ -1541,7 +1531,7 @@ INTERNAL_FUNC int emcore_delete_parsed_data(char *multi_user_name, email_mail_da int err = EMAIL_ERROR_NONE; int ret = false; char buf[MAX_PATH] = {0}; - char *prefix_path = NULL; + char *prefix_path = NULL; if (!input_mail_data) { EM_DEBUG_EXCEPTION("Invliad parameter"); @@ -1554,8 +1544,7 @@ INTERNAL_FUNC int emcore_delete_parsed_data(char *multi_user_name, email_mail_da err = EMAIL_ERROR_INVALID_PARAM; goto FINISH_OFF; } - - if (EM_SAFE_STRLEN(multi_user_name) > 0) { + if (EM_SAFE_STRLEN(multi_user_name) > 0) { err = emcore_get_container_path(multi_user_name, &prefix_path); if (err != EMAIL_ERROR_NONE) { EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err); @@ -1573,13 +1562,13 @@ INTERNAL_FUNC int emcore_delete_parsed_data(char *multi_user_name, email_mail_da if (!emstorage_delete_dir(buf, &err)) { EM_DEBUG_LOG("emstorage_delete_dir failed : buf[%s]", buf); - memset(buf, 0x00, sizeof(buf)); - SNPRINTF(buf, sizeof(buf), "%s%s%d", MAIL_HOME, DIR_SEPERATOR, input_mail_data->account_id); + memset(buf, 0x00, sizeof(buf)); + SNPRINTF(buf, sizeof(buf), "%s%s%d", MAIL_HOME, DIR_SEPERATOR, input_mail_data->account_id); - if (!emstorage_delete_dir(buf, &err)) { - EM_DEBUG_EXCEPTION("emstorage_delete_dir failed : buf[%s]", buf); - goto FINISH_OFF; - } + if (!emstorage_delete_dir(buf, &err)) { + EM_DEBUG_EXCEPTION("emstorage_delete_dir failed : buf[%s]", buf); + goto FINISH_OFF; + } err = EMAIL_ERROR_NONE; } diff --git a/email-core/email-core-mm-callbacks.c b/email-core/email-core-mm-callbacks.c index 8d9208b..eb61708 100755 --- a/email-core/email-core-mm-callbacks.c +++ b/email-core/email-core-mm-callbacks.c @@ -438,8 +438,6 @@ INTERNAL_FUNC void mm_get_error(char *string, int *err_code) *err_code = EMAIL_ERROR_CONNECTION_FAILURE; else if (strstr(string, "Certificate failure")) *err_code = EMAIL_ERROR_CERTIFICATE_FAILURE; - else if (strstr(string, "ESMTP failure")) - *err_code = EMAIL_ERROR_INVALID_PARAM; else if (strstr(string, "No such host")) *err_code = EMAIL_ERROR_NO_SUCH_HOST; else if (strstr(string, "host") || strstr(string, "Host")) diff --git a/email-core/email-core-smtp.c b/email-core/email-core-smtp.c index 8e41b93..539b0f1 100755 --- a/email-core/email-core-smtp.c +++ b/email-core/email-core-smtp.c @@ -1859,10 +1859,12 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_ if (opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON || (mail_tbl_data->report_status & EMAIL_MAIL_REQUEST_DSN)) { EM_DEBUG_LOG("DSN is required."); - (*send_stream)->protocol.esmtp.dsn.want = 1; - (*send_stream)->protocol.esmtp.dsn.full = 0; - (*send_stream)->protocol.esmtp.dsn.notify.failure = 1; - (*send_stream)->protocol.esmtp.dsn.notify.success = 1; + if (*send_stream) { + (*send_stream)->protocol.esmtp.dsn.want = 1; + (*send_stream)->protocol.esmtp.dsn.full = 0; + (*send_stream)->protocol.esmtp.dsn.notify.failure = 1; + (*send_stream)->protocol.esmtp.dsn.notify.success = 1; + } } mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING; diff --git a/email-core/email-core-utils.c b/email-core/email-core-utils.c index 01b57a0..1b4ee99 100755 --- a/email-core/email-core-utils.c +++ b/email-core/email-core-utils.c @@ -2515,7 +2515,7 @@ INTERNAL_FUNC char* emcore_get_mail_field_name_by_attribute_type(email_mail_attr { EM_DEBUG_FUNC_BEGIN("input_attribute_type [%d]", input_attribute_type); - if (input_attribute_type > EMAIL_MAIL_ATTRIBUTE_EAS_DATA_TYPE || input_attribute_type < 0) { + if (input_attribute_type > EMAIL_MAIL_ATTRIBUTE_EAS_DATA_TYPE) { EM_DEBUG_EXCEPTION("Invalid input_attribute_type [%d]", input_attribute_type); return NULL; } @@ -3067,7 +3067,7 @@ INTERNAL_FUNC int reg_replace(char *input_source_text, char *input_old_pattern_s n = pmatch[0].rm_eo - pmatch[0].rm_so; pos += pmatch[0].rm_so; memmove(pos + EM_SAFE_STRLEN(input_new_string), pos + n, EM_SAFE_STRLEN(pos) - n + 1); - memmove(pos, input_new_string, EM_SAFE_STRLEN(input_new_string)); + memmove(pos, input_new_string, EM_SAFE_STRLEN(input_new_string)+1); pos += EM_SAFE_STRLEN(input_new_string); n_count++; } @@ -4228,6 +4228,11 @@ INTERNAL_FUNC int emcore_load_query_from_file(char *file_path, char ***query_arr } *query_array = (char **)calloc(vector_len, sizeof(char *)); + if (*query_array == NULL) { + EM_DEBUG_EXCEPTION("calloc failed"); + error = EMAIL_ERROR_OUT_OF_MEMORY; + goto FINISH_OFF; + } for (i = 0; i < vector_len; i++) { if (result_vector[i]) { diff --git a/email-core/email-storage/email-storage.c b/email-core/email-storage/email-storage.c index 5c2c152..7ffde9c 100755 --- a/email-core/email-storage/email-storage.c +++ b/email-core/email-storage/email-storage.c @@ -413,7 +413,7 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name) return EMAIL_ERROR_SYSTEM_FAILURE; } - fchmod(fd, 0666); + fchmod(fd, 0644); EM_DEBUG_LOG("** Create SHM FILE **"); if (ftruncate(fd, sizeof(mmapped_t)) != 0) { EM_DEBUG_EXCEPTION("ftruncate errno [%d]", errno); @@ -480,7 +480,7 @@ int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, mmapped_ } } - fchmod((*param_shm_fd), 0666); + fchmod((*param_shm_fd), 0644); EM_DEBUG_LOG("** Create SHM FILE **"); if (ftruncate((*param_shm_fd), sizeof(mmapped_t)) != 0) { EM_DEBUG_EXCEPTION("ftruncate errno [%d]", errno); @@ -1142,7 +1142,7 @@ static int _get_table_field_data_string(char **table, char **buf, int ucs2, int EM_DEBUG_EXCEPTION("malloc is failed"); goto FINISH_OFF; } - strncpy(*buf, pTemp, sLen); + strncpy(*buf, pTemp, sLen+1); (*buf)[sLen] = '\0'; } else *buf = NULL; @@ -1504,7 +1504,7 @@ char *cpy_str(char *src) EM_DEBUG_EXCEPTION("mailoc failed..."); return NULL; } - strncpy(p, src, EM_SAFE_STRLEN(src)); + strncpy(p, src, EM_SAFE_STRLEN(src)+1); } return p; @@ -3870,7 +3870,7 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, int m " ORDER BY flags_seen_field ASC, date_time DESC" /* case EMAIL_SORT_SEEN_FLAG_LOW: */ }; - if (sorting < EMAIL_SORT_END && sorting >= 0) + if (sorting < EMAIL_SORT_END) cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size, " %s", sorting_str[sorting]); else EM_DEBUG_LOG(" Invalid Sorting order "); @@ -6316,7 +6316,7 @@ INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name); EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error); - EM_SAFE_STRCPY(sql_query_string, "SELECT max(rowid) FROM mail_box_tbl;"); + EM_SAFE_STRNCPY(sql_query_string, "SELECT max(rowid) FROM mail_box_tbl;", sizeof(sql_query_string)); EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc); EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; }, @@ -8250,13 +8250,6 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_ error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; } - - if (rc == SQLITE_DONE) { - EM_DEBUG_LOG("no matched mail found..."); - error = EMAIL_ERROR_MAIL_NOT_FOUND; - goto FINISH_OFF; - } - EM_DEBUG_LOG("item_count [%d]", item_count); if (number_of_mails != item_count) { @@ -11490,7 +11483,7 @@ INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transacti mkdir(MAIL_HOME, DIRECTORY_PERMISSION); mkdir(MAIL_TEMP, DIRECTORY_PERMISSION); - chmod(MAIL_TEMP, 0777); + chmod(MAIL_TEMP, 0644); /* first clear index. */ while (indexes->object_name) { @@ -11757,7 +11750,7 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in } if (account_id == EML_FOLDER) { - chmod(buf, 0777); + chmod(buf, 0644); } } } @@ -11796,7 +11789,7 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in } if (account_id == EML_FOLDER) { - chmod(buf, 0777); + chmod(buf, 0644); } } } @@ -11826,7 +11819,7 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in } if (account_id == EML_FOLDER) { - chmod(buf, 0777); + chmod(buf, 0644); } } } @@ -11949,7 +11942,7 @@ INTERNAL_FUNC void emstorage_create_dir_if_delete() mkdir(EMAIL_PATH, DIRECTORY_PERMISSION); mkdir(MAIL_HOME, DIRECTORY_PERMISSION); mkdir(MAIL_TEMP, DIRECTORY_PERMISSION); - chmod(MAIL_TEMP, 0777); + chmod(MAIL_TEMP, 0644); EM_DEBUG_FUNC_END(); } @@ -12056,9 +12049,9 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in goto FINISH_OFF; } - strncat(low_char_set, char_set, EM_SAFE_STRLEN(char_set)); + strncat(low_char_set, char_set, sizeof(low_char_set)-EM_SAFE_STRLEN(low_char_set)-1); EM_DEBUG_LOG(">>>> CHAR SET [ %s ] ", low_char_set); - strncat(low_char_set, " \" /></head>", strlen(" \" /></head>")); /*prevent 34359*/ + strncat(low_char_set, " \" /></head>", sizeof(low_char_set)-EM_SAFE_STRLEN(low_char_set)-1); /*prevent 34359*/ EM_DEBUG_LOG(">>> CHARSET [ %s ] ", low_char_set); match_str = strstr(buf, CONTENT_TYPE_DATA); @@ -12072,9 +12065,9 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in buf1 = (char *)calloc(1, data_count_to_written); if (buf1) { - strncat(buf1, CONTENT_DATA, strlen(CONTENT_DATA)); /*prevent 34359*/ + strncat(buf1, CONTENT_DATA, sizeof(buf1)-EM_SAFE_STRLEN(buf1)-1); /*prevent 34359*/ EM_DEBUG_LOG(">>>>> BUF 1 [ %s ] ", buf1); - strncat(buf1, low_char_set, EM_SAFE_STRLEN(low_char_set)); + strncat(buf1, low_char_set, sizeof(buf1)-EM_SAFE_STRLEN(buf1)-1); EM_DEBUG_LOG(">>>> HTML TAG DATA [ %s ] ", buf1); /* 1. Create a temporary file name */ @@ -12946,8 +12939,8 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name, if (account_id > 0) EM_SAFE_STRNCAT(sql_query_string, sql_account, query_size - EM_SAFE_STRLEN(sql_query_string) - 1); - strcat(sql_query_string, sql_format_order_by); - strcat(sql_query_string, ";"); + EM_SAFE_STRNCAT(sql_query_string, sql_format_order_by, query_size - EM_SAFE_STRLEN(sql_query_string) - 1); + EM_SAFE_STRNCAT(sql_query_string, ";", query_size - EM_SAFE_STRLEN(sql_query_string) - 1); EM_DEBUG_LOG_SEC("Query : %s", sql_query_string); @@ -12991,12 +12984,12 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name, *result_latest_mail_id_in_thread = mail_tbl->mail_id; search_thread = true; - break; } if (search_thread) { EM_DEBUG_LOG("latest_mail_id_in_thread [%d], mail_id [%d]", latest_mail_id_in_thread, mail_tbl->mail_id); + break; } else { result_thread_id = -1; count = 0; @@ -13088,10 +13081,9 @@ INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, in sqlite3_snprintf(query_size, sql_query_string, sql_format, stripped_subject, mailbox_id); if (account_id > 0) - strcat(sql_query_string, sql_account); - - strcat(sql_query_string, sql_format_order_by); - strcat(sql_query_string, ";"); + EM_SAFE_STRNCAT(sql_query_string, sql_account, query_size - EM_SAFE_STRLEN(sql_query_string) - 1); + EM_SAFE_STRNCAT(sql_query_string, sql_format_order_by, query_size - EM_SAFE_STRLEN(sql_query_string) - 1); + EM_SAFE_STRNCAT(sql_query_string, ";", query_size - EM_SAFE_STRLEN(sql_query_string) - 1); EM_DEBUG_LOG_SEC("Query : %s", sql_query_string); @@ -14423,8 +14415,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco /* prevent 34361 */ if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE) - strcat(sql_query_string, where_pararaph); - + EM_SAFE_STRNCAT(sql_query_string, where_pararaph, QUERY_SIZE - EM_SAFE_STRLEN(sql_query_string) - 1); EM_DEBUG_LOG_SEC("query[%s]", sql_query_string); /* rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL); */ @@ -14475,7 +14466,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco } /* prevent 34361 */ if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE) - strcat(sql_query_string, where_pararaph); + EM_SAFE_STRNCAT(sql_query_string, where_pararaph, QUERY_SIZE - EM_SAFE_STRLEN(sql_query_string) - 1); error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string); if (error != EMAIL_ERROR_NONE) { @@ -14489,7 +14480,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco memset(sql_query_string, 0x00, QUERY_SIZE); SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_text_tbl SET mailbox_id = %d ", dest_mailbox_id); if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE) - strcat(sql_query_string, where_pararaph); + EM_SAFE_STRNCAT(sql_query_string, where_pararaph, QUERY_SIZE - EM_SAFE_STRLEN(sql_query_string) - 1); EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string); error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string); @@ -14576,7 +14567,7 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(char *multi_user_name, int accoun SNPRINTF(where_pararaph + EM_SAFE_STRLEN(where_pararaph), where_pararaph_length - EM_SAFE_STRLEN(where_pararaph), " %s total_mail_count_on_server > mail_slot_size ", (and ? "AND" : "WHERE")); if (strlen(sql_query_string) + EM_SAFE_STRLEN(where_pararaph) < QUERY_SIZE) /* prevent 34363 */ - strcat(sql_query_string, where_pararaph); + EM_SAFE_STRNCAT(sql_query_string, where_pararaph, QUERY_SIZE - EM_SAFE_STRLEN(sql_query_string) - 1); else { EM_DEBUG_EXCEPTION("Query buffer overflowed !!!"); err = EMAIL_ERROR_OUT_OF_MEMORY; @@ -16309,7 +16300,7 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul if (input_sorting_rule->force_boolean_check) { SNPRINTF(result_rule_string, QUERY_SIZE, "%s = 0 ", emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute)); } else - EM_SAFE_STRCPY(result_rule_string, emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute)); + EM_SAFE_STRNCPY(result_rule_string, emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute), QUERY_SIZE - EM_SAFE_STRLEN(result_rule_string) - 1 ); switch (input_sorting_rule->sort_order) { case EMAIL_SORT_ORDER_ASCEND: @@ -16499,13 +16490,13 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char query_size = new_query_size; } - strcat(conditional_clause_string, result_string_for_a_item); + EM_SAFE_STRNCAT(conditional_clause_string, result_string_for_a_item , QUERY_SIZE - EM_SAFE_STRLEN(conditional_clause_string) - 1); EM_SAFE_FREE(result_string_for_a_item); } } if (input_sorting_rule_count > 0) { - strcat(conditional_clause_string, "ORDER BY "); + EM_SAFE_STRNCAT(conditional_clause_string, "ORDER BY ", QUERY_SIZE - EM_SAFE_STRLEN(conditional_clause_string) - 1); for (i = 0; i < input_sorting_rule_count; i++) { if ((ret = _make_order_rule_string(multi_user_name, &input_sorting_rule_list[i], &result_string_for_a_item)) != EMAIL_ERROR_NONE) { @@ -16513,8 +16504,8 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char goto FINISH_OFF; } if (i > 0) - strcat(conditional_clause_string, ", "); - strcat(conditional_clause_string, result_string_for_a_item); + EM_SAFE_STRNCAT(conditional_clause_string, ", " , QUERY_SIZE - EM_SAFE_STRLEN(conditional_clause_string) - 1); + EM_SAFE_STRNCAT(conditional_clause_string, result_string_for_a_item , QUERY_SIZE - EM_SAFE_STRLEN(conditional_clause_string) - 1); EM_SAFE_FREE(result_string_for_a_item); } } @@ -16886,7 +16877,7 @@ INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *mult sqlite3_snprintf(where_pararaph_length, where_pararaph, "WHERE mailbox_type = %d AND message_id like '%q'", input_mailbox_type, message_id); if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE) - strcat(sql_query_string, where_pararaph); + EM_SAFE_STRNCAT(sql_query_string, where_pararaph , QUERY_SIZE - EM_SAFE_STRLEN(sql_query_string) - 1); EM_DEBUG_LOG_SEC("query[%s]", sql_query_string); @@ -16905,7 +16896,7 @@ INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *mult sqlite3_snprintf(sizeof(sql_query_string), sql_query_string, "UPDATE mail_tbl set server_mail_id = '%q'", server_uid); if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE) - strcat(sql_query_string, where_pararaph); + EM_SAFE_STRNCAT(sql_query_string, where_pararaph ,QUERY_SIZE - EM_SAFE_STRLEN(sql_query_string) -1 ); err = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string); if (err != EMAIL_ERROR_NONE) { diff --git a/test/testapp-mail.c b/test/testapp-mail.c index 1bef6c7..ce72ba6 100644..100755 --- a/test/testapp-mail.c +++ b/test/testapp-mail.c @@ -51,61 +51,59 @@ /* static void testapp_test_print_sorting_menu() { - testapp_print(" EMAIL_SORT_DATETIME_HIGH = 0\n"); - testapp_print(" EMAIL_SORT_DATETIME_LOW = 1\n"); - testapp_print(" EMAIL_SORT_SENDER_HIGH = 2\n"); - testapp_print(" EMAIL_SORT_SENDER_LOW = 3\n"); - testapp_print(" EMAIL_SORT_RCPT_HIGH = 4\n"); - testapp_print(" EMAIL_SORT_RCPT_LOW = 5\n"); - testapp_print(" EMAIL_SORT_SUBJECT_HIGH = 6\n"); - testapp_print(" EMAIL_SORT_SUBJECT_LOW = 7\n"); - testapp_print(" EMAIL_SORT_PRIORITY_HIGH = 8\n"); - testapp_print(" EMAIL_SORT_PRIORITY_LOW = 9\n"); - testapp_print(" EMAIL_SORT_ATTACHMENT_HIGH = 10\n"); - testapp_print(" EMAIL_SORT_ATTACHMENT_LOW = 11\n"); - testapp_print(" EMAIL_SORT_FAVORITE_HIGH = 12\n"); - testapp_print(" EMAIL_SORT_FAVORITE_LOW = 13\n"); + testapp_print(" EMAIL_SORT_DATETIME_HIGH = 0\n"); + testapp_print(" EMAIL_SORT_DATETIME_LOW = 1\n"); + testapp_print(" EMAIL_SORT_SENDER_HIGH = 2\n"); + testapp_print(" EMAIL_SORT_SENDER_LOW = 3\n"); + testapp_print(" EMAIL_SORT_RCPT_HIGH = 4\n"); + testapp_print(" EMAIL_SORT_RCPT_LOW = 5\n"); + testapp_print(" EMAIL_SORT_SUBJECT_HIGH = 6\n"); + testapp_print(" EMAIL_SORT_SUBJECT_LOW = 7\n"); + testapp_print(" EMAIL_SORT_PRIORITY_HIGH = 8\n"); + testapp_print(" EMAIL_SORT_PRIORITY_LOW = 9\n"); + testapp_print(" EMAIL_SORT_ATTACHMENT_HIGH = 10\n"); + testapp_print(" EMAIL_SORT_ATTACHMENT_LOW = 11\n"); + testapp_print(" EMAIL_SORT_FAVORITE_HIGH = 12\n"); + testapp_print(" EMAIL_SORT_FAVORITE_LOW = 13\n"); } static void testapp_test_print_mail_list_item(email_mail_list_item_t *mail_list_item, int count) { - int i; - - testapp_print("\n>>>>> Print mail list items: count[%d]\n", count); - for (i=0; i< count; i++) { - testapp_print("\n[%d]\n", i); - testapp_print(" >>> Mailbox Name [ %s ] \n", mail_list_item[i].mailbox_name); - testapp_print(" >>> Mail ID [ %d ] \n", mail_list_item[i].mail_id); - testapp_print(" >>> Account ID [ %d ] \n", mail_list_item[i].account_id); - if (mail_list_item[i].from!= NULL) { - testapp_print(" >>> From [ %s ] \n", mail_list_item[i].from); - } - if (mail_list_item[i].from_email_address != NULL) { - testapp_print(" >>> from_email_address [ %s ] \n", mail_list_item[i].from_email_address); - } - if (mail_list_item[i].recipients!= NULL) { - testapp_print(" >>> recipients [ %s ] \n", mail_list_item[i].recipients); - } - if (mail_list_item[i].subject != NULL) { - testapp_print(" >>> subject [ %s ] \n", mail_list_item[i].subject); - } - testapp_print(" >>> text_download_yn [ %d ] \n", mail_list_item[i].body_download_status); - testapp_print(" >>> date_time [ %d ] \n", mail_list_item[i].date_time); - testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list_item[i].flags_seen_field); - testapp_print(" >>> priority [ %d ] \n", mail_list_item[i].priority); - testapp_print(" >>> save_status [ %d ] \n", mail_list_item[i].save_status); - testapp_print(" >>> lock [ %d ] \n", mail_list_item[i].lock_status); - testapp_print(" >>> report_status [ %d ] \n", mail_list_item[i].report_status); - testapp_print(" >>> recipients_count [ %d ] \n", mail_list_item[i].recipients_count); - testapp_print(" >>> attachment_count [ %d ] \n", mail_list_item[i].attachment_count); - testapp_print(" >>> DRM_status [ %d ] \n", mail_list_item[i].DRM_status); - - if (mail_list_item[i].preview_text != NULL) { - testapp_print(" >>> preview_text [ %s ] \n", mail_list_item[i].preview_text); - } - - testapp_print(" >>> thread_id [ %d ] \n", mail_list_item[i].thread_id); - testapp_print(" >>> thread_item_count [ %d ] \n", mail_list_item[i].thread_item_count); + int i; + + testapp_print("\n>>>>> Print mail list items: count[%d]\n", count); + for (i=0; i< count; i++) { + testapp_print("\n[%d]\n", i); + testapp_print(" >>> Mailbox Name [ %s ] \n", mail_list_item[i].mailbox_name); + testapp_print(" >>> Mail ID [ %d ] \n", mail_list_item[i].mail_id); + testapp_print(" >>> Account ID [ %d ] \n", mail_list_item[i].account_id); + if (mail_list_item[i].from!= NULL) { + testapp_print(" >>> From [ %s ] \n", mail_list_item[i].from); + } + if (mail_list_item[i].from_email_address != NULL) { + testapp_print(" >>> from_email_address [ %s ] \n", mail_list_item[i].from_email_address); + } + if (mail_list_item[i].recipients!= NULL) { + testapp_print(" >>> recipients [ %s ] \n", mail_list_item[i].recipients); + } + if (mail_list_item[i].subject != NULL) { + testapp_print(" >>> subject [ %s ] \n", mail_list_item[i].subject); + } + testapp_print(" >>> text_download_yn [ %d ] \n", mail_list_item[i].body_download_status); + testapp_print(" >>> date_time [ %d ] \n", mail_list_item[i].date_time); + testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list_item[i].flags_seen_field); + testapp_print(" >>> priority [ %d ] \n", mail_list_item[i].priority); + testapp_print(" >>> save_status [ %d ] \n", mail_list_item[i].save_status); + testapp_print(" >>> lock [ %d ] \n", mail_list_item[i].lock_status); + testapp_print(" >>> report_status [ %d ] \n", mail_list_item[i].report_status); + testapp_print(" >>> recipients_count [ %d ] \n", mail_list_item[i].recipients_count); + testapp_print(" >>> attachment_count [ %d ] \n", mail_list_item[i].attachment_count); + testapp_print(" >>> DRM_status [ %d ] \n", mail_list_item[i].DRM_status); + if (mail_list_item[i].preview_text != NULL) { + testapp_print(" >>> preview_text [ %s ] \n", mail_list_item[i].preview_text) + } + testapp_print(" >>> thread_id [ %d ] \n", mail_list_item[i].thread_id); + testapp_print(" >>> thread_item_count [ %d ] \n", mail_list_item[i].thread_item_count); } } */ @@ -120,29 +118,21 @@ static gboolean testapp_add_mail_for_sending(int *result_mail_id) char from_address[300] = { 0 , }; char passpharse[300] = {0, }; const char *body_file_path = MAIL_TEMP_BODY; - email_account_t *account_data = NULL; email_mailbox_t *mailbox_data = NULL; email_mail_data_t *test_mail_data = NULL; FILE *body_file; - testapp_print("\n > Enter account id : "); if (0 >= scanf("%d", &account_id)) testapp_print("Invalid input. "); - testapp_print("\n > Enter recipient address : "); if (0 >= scanf("%s", recipient_address)) testapp_print("Invalid input. "); - email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data); - email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data); - test_mail_data = malloc(sizeof(email_mail_data_t)); memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); - SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address); - test_mail_data->account_id = account_id; test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED; test_mail_data->body_download_status = 1; @@ -155,1066 +145,1063 @@ static gboolean testapp_add_mail_for_sending(int *result_mail_id) test_mail_data->subject = strdup("Read receipt request from TIZEN"); test_mail_data->remaining_resend_times = 3; test_mail_data->report_status = EMAIL_MAIL_REQUEST_DSN | EMAIL_MAIL_REQUEST_MDN; - body_file = fopen(body_file_path, "w"); testapp_print("\n body_file [%p]\n", body_file); - if (body_file == NULL) { testapp_print("\n fopen [%s]failed\n", body_file_path); return FALSE; } - for (i = 0; i < 100; i++) fprintf(body_file, "Mail sending Test. [%d]\n", i); - fflush(body_file); fclose(body_file); - testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrpyt, 3: sing + encrypt, 4: pgp sign, 5: pgp encrypted, 6: pgp sign + encrypt] : "); - if (0 >= scanf("%d", &smime_type)) - testapp_print("Invalid input. "); - test_mail_data->smime_type = smime_type; + testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrpyt, 3: sing + encrypt, 4: pgp sign, 5: pgp encrypted, 6: pgp sign + encrypt] : "); + if (0 >= scanf("%d", &smime_type)) + testapp_print("Invalid input. "); + test_mail_data->smime_type = smime_type; - if (smime_type >= EMAIL_PGP_SIGNED) { - testapp_print(" > passpharse : "); - if (0 >= scanf("%s", passpharse)) - testapp_print("Invalid input. "); - test_mail_data->pgp_password = strdup(passpharse); - } + if (smime_type >= EMAIL_PGP_SIGNED) { + testapp_print(" > passpharse : "); + if (0 >= scanf("%s", passpharse)) + testapp_print("Invalid input. "); + test_mail_data->pgp_password = strdup(passpharse); + } - if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) - testapp_print("email_add_mail failed. [%d]\n", err); - else - testapp_print("email_add_mail success.\n"); + if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) + testapp_print("email_add_mail failed. [%d]\n", err); + else + testapp_print("email_add_mail success.\n"); - testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); + testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); - if (result_mail_id) - *result_mail_id = test_mail_data->mail_id; + if (result_mail_id) + *result_mail_id = test_mail_data->mail_id; - email_free_mail_data(&test_mail_data, 1); - email_free_mailbox(&mailbox_data, 1); - email_free_account(&account_data, 1); + email_free_mail_data(&test_mail_data, 1); + email_free_mailbox(&mailbox_data, 1); + email_free_account(&account_data, 1); - return FALSE; + return FALSE; } static gboolean testapp_test_add_mail(int *result_mail_id) { - int i = 0; - int account_id = 0; - int mailbox_id = 0; - int from_eas = 0; - int attachment_count = 0; - int err = EMAIL_ERROR_NONE; - int smime_type = 0; - char arg[50] = { 0 , }; - const char *body_file_path = MAIL_TEMP_BODY; - email_mailbox_t *mailbox_data = NULL; - email_mail_data_t *test_mail_data = NULL; - email_attachment_data_t *attachment_data = NULL; - email_meeting_request_t *meeting_req = NULL; - FILE *body_file; - - testapp_print("\n > Enter account id : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter mailbox id : "); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); - - email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data); - - test_mail_data = malloc(sizeof(email_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); - - testapp_print("\n From EAS? [0/1]> "); - if (0 >= scanf("%d", &from_eas)) - testapp_print("Invalid input. "); - - test_mail_data->account_id = account_id; - test_mail_data->save_status = 1; - test_mail_data->body_download_status = 1; - test_mail_data->flags_seen_field = 1; - test_mail_data->file_path_plain = strdup(body_file_path); - test_mail_data->mailbox_id = mailbox_id; - test_mail_data->mailbox_type = mailbox_data->mailbox_type; - test_mail_data->full_address_from = strdup("<test1@test.com>"); - test_mail_data->full_address_to = strdup("<test2@test.com>"); - test_mail_data->full_address_cc = strdup("<test3@test.com>"); - test_mail_data->full_address_bcc = strdup("<test4@test.com>"); - test_mail_data->subject = strdup("Meeting request mail"); - test_mail_data->remaining_resend_times = 3; - test_mail_data->eas_data = strdup("EAS DATA TEST"); - test_mail_data->eas_data_length = strlen(test_mail_data->eas_data) + 1; - - body_file = fopen(body_file_path, "w"); - - testapp_print("\n body_file [%p]\n", body_file); - - if (body_file == NULL) { - testapp_print("\n fopen [%s]failed\n", body_file_path); - return FALSE; - } -/* - for (i = 0; i < 500; i++) - fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); -*/ - fprintf(body_file, "Hello world"); - fflush(body_file); - fclose(body_file); - - testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrypt, 3: sing + encrypt] : "); - if (0 >= scanf("%d", &smime_type)) - testapp_print("Invalid input. "); - test_mail_data->smime_type = smime_type; - - testapp_print(" > How many file attachment? [>=0] : "); - if (0 >= scanf("%d", &attachment_count)) - testapp_print("Invalid input. "); - - test_mail_data->attachment_count = attachment_count; - if (attachment_count > 0) - attachment_data = calloc(attachment_count, sizeof(email_attachment_data_t)); - - - for (i = 0; i < attachment_count ; i++) { - memset(arg, 0x00, 50); - testapp_print("\n > Enter attachment name : "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); - - attachment_data[i].attachment_name = strdup(arg); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter attachment absolute path : "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); - - attachment_data[i].attachment_path = strdup(arg); - attachment_data[i].save_status = 1; - attachment_data[i].mailbox_id = test_mail_data->mailbox_id; - } - - testapp_print("\n > Meeting Request? [0: no, 1: yes(request from server), 2: yes(response from local)]"); - if (0 >= scanf("%d", (int *)&(test_mail_data->meeting_request_status))) - testapp_print("Invalid input. "); + int i = 0; + int account_id = 0; + int mailbox_id = 0; + int from_eas = 0; + int attachment_count = 0; + int err = EMAIL_ERROR_NONE; + int smime_type = 0; + char arg[50] = { 0 , }; + const char *body_file_path = MAIL_TEMP_BODY; + email_mailbox_t *mailbox_data = NULL; + email_mail_data_t *test_mail_data = NULL; + email_attachment_data_t *attachment_data = NULL; + email_meeting_request_t *meeting_req = NULL; + FILE *body_file; + + testapp_print("\n > Enter account id : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + memset(arg, 0x00, 50); + testapp_print("\n > Enter mailbox id : "); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); + + email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data); + + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); + + testapp_print("\n From EAS? [0/1]> "); + if (0 >= scanf("%d", &from_eas)) + testapp_print("Invalid input. "); + + test_mail_data->account_id = account_id; + test_mail_data->save_status = 1; + test_mail_data->body_download_status = 1; + test_mail_data->flags_seen_field = 1; + test_mail_data->file_path_plain = strdup(body_file_path); + test_mail_data->mailbox_id = mailbox_id; + test_mail_data->mailbox_type = mailbox_data->mailbox_type; + test_mail_data->full_address_from = strdup("<test1@test.com>"); + test_mail_data->full_address_to = strdup("<test2@test.com>"); + test_mail_data->full_address_cc = strdup("<test3@test.com>"); + test_mail_data->full_address_bcc = strdup("<test4@test.com>"); + test_mail_data->subject = strdup("Meeting request mail"); + test_mail_data->remaining_resend_times = 3; + test_mail_data->eas_data = strdup("EAS DATA TEST"); + test_mail_data->eas_data_length = strlen(test_mail_data->eas_data) + 1; + + body_file = fopen(body_file_path, "w"); + + testapp_print("\n body_file [%p]\n", body_file); + + if (body_file == NULL) { + testapp_print("\n fopen [%s]failed\n", body_file_path); + return FALSE; + } + /* + for (i = 0; i < 500; i++) + fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); + */ + fprintf(body_file, "Hello world"); + fflush(body_file); + fclose(body_file); + + testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrypt, 3: sing + encrypt] : "); + if (0 >= scanf("%d", &smime_type)) + testapp_print("Invalid input. "); + test_mail_data->smime_type = smime_type; + + testapp_print(" > How many file attachment? [>=0] : "); + if (0 >= scanf("%d", &attachment_count)) + testapp_print("Invalid input. "); + + test_mail_data->attachment_count = attachment_count; + if (attachment_count > 0) + attachment_data = calloc(attachment_count, sizeof(email_attachment_data_t)); + + + for (i = 0; i < attachment_count ; i++) { + memset(arg, 0x00, 50); + testapp_print("\n > Enter attachment name : "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); + + attachment_data[i].attachment_name = strdup(arg); + + memset(arg, 0x00, 50); + testapp_print("\n > Enter attachment absolute path : "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); + + attachment_data[i].attachment_path = strdup(arg); + attachment_data[i].save_status = 1; + attachment_data[i].mailbox_id = test_mail_data->mailbox_id; + } - if (test_mail_data->meeting_request_status == 1 - || test_mail_data->meeting_request_status == 2) { - time_t current_time; - /* dummy data for meeting request */ - meeting_req = malloc(sizeof(email_meeting_request_t)); - memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); - - meeting_req->meeting_response = 1; - current_time = time(NULL); - gmtime_r(¤t_time, &(meeting_req->start_time)); - gmtime_r(¤t_time, &(meeting_req->end_time)); - meeting_req->location = strdup("Seoul"); - meeting_req->global_object_id = strdup("abcdef12345"); - - meeting_req->time_zone.offset_from_GMT = 9; - strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); - gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date)); - meeting_req->time_zone.standard_bias = 3; - - strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME"); - gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date)); - meeting_req->time_zone.daylight_bias = 7; + testapp_print("\n > Meeting Request? [0: no, 1: yes(request from server), 2: yes(response from local)]"); + if (0 >= scanf("%d", (int *)&(test_mail_data->meeting_request_status))) + testapp_print("Invalid input. "); + + if (test_mail_data->meeting_request_status == 1 + || test_mail_data->meeting_request_status == 2) { + time_t current_time; + /* dummy data for meeting request */ + meeting_req = malloc(sizeof(email_meeting_request_t)); + memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); + + meeting_req->meeting_response = 1; + current_time = time(NULL); + gmtime_r(¤t_time, &(meeting_req->start_time)); + gmtime_r(¤t_time, &(meeting_req->end_time)); + meeting_req->location = strdup("Seoul"); + meeting_req->global_object_id = strdup("abcdef12345"); + + meeting_req->time_zone.offset_from_GMT = 9; + strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); + gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date)); + meeting_req->time_zone.standard_bias = 3; + + strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME"); + gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date)); + meeting_req->time_zone.daylight_bias = 7; - } + } - if ((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) - testapp_print("email_add_mail failed. [%d]\n", err); - else - testapp_print("email_add_mail success.\n"); + if ((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) + testapp_print("email_add_mail failed. [%d]\n", err); + else + testapp_print("email_add_mail success.\n"); - testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); - testapp_print("saved mailbox id = [%d]\n", test_mail_data->mailbox_id); + testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); + testapp_print("saved mailbox id = [%d]\n", test_mail_data->mailbox_id); - if (result_mail_id) - *result_mail_id = test_mail_data->mail_id; + if (result_mail_id) + *result_mail_id = test_mail_data->mail_id; - if (attachment_data) - email_free_attachment_data(&attachment_data, attachment_count); + if (attachment_data) + email_free_attachment_data(&attachment_data, attachment_count); - if (meeting_req) - email_free_meeting_request(&meeting_req, 1); + if (meeting_req) + email_free_meeting_request(&meeting_req, 1); - email_free_mail_data(&test_mail_data, 1); - email_free_mailbox(&mailbox_data, 1); + email_free_mail_data(&test_mail_data, 1); + email_free_mailbox(&mailbox_data, 1); - return FALSE; + return FALSE; } static gboolean testapp_test_update_mail() { - int mail_id = 0; - int err = EMAIL_ERROR_NONE; - int test_attachment_data_count = 0; - int ret = 0; - char arg[50]; - email_mail_data_t *test_mail_data = NULL; - email_attachment_data_t *test_attachment_data_list = NULL; - email_meeting_request_t *meeting_req = NULL; - - testapp_print("\n > Enter mail id : "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - - email_get_mail_data(mail_id, &test_mail_data); - - if (!test_mail_data) { - testapp_print("email_get_mail_data() failed\n"); - return FALSE; - } + int mail_id = 0; + int err = EMAIL_ERROR_NONE; + int test_attachment_data_count = 0; + int ret = 0; + char arg[50]; + email_mail_data_t *test_mail_data = NULL; + email_attachment_data_t *test_attachment_data_list = NULL; + email_meeting_request_t *meeting_req = NULL; + + testapp_print("\n > Enter mail id : "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + email_get_mail_data(mail_id, &test_mail_data); + + if (!test_mail_data) { + testapp_print("email_get_mail_data() failed\n"); + return FALSE; + } - testapp_print("\n > Enter Subject: "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter Subject: "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); - test_mail_data->subject = strdup(arg); + test_mail_data->subject = strdup(arg); - if (test_mail_data->attachment_count > 0) { - if ((err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE) { - testapp_print("email_get_attachment_data_list() failed [%d]\n", err); - goto FINISH_OFF; - } - } + if (test_mail_data->attachment_count > 0) { + if ((err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE) { + testapp_print("email_get_attachment_data_list() failed [%d]\n", err); + goto FINISH_OFF; + } + } - if (test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST - || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE - || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { + if (test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST + || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE + || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) { - if ((err = email_get_meeting_request(mail_id, &meeting_req)) != EMAIL_ERROR_NONE) { - testapp_print("email_get_meeting_request() failed [%d]\n", err); - goto FINISH_OFF; - } + if ((err = email_get_meeting_request(mail_id, &meeting_req)) != EMAIL_ERROR_NONE) { + testapp_print("email_get_meeting_request() failed [%d]\n", err); + goto FINISH_OFF; + } - testapp_print("\n > Enter meeting response: "); - if (0 >= scanf("%d", (int *)&(meeting_req->meeting_response))) - testapp_print("Invalid input. "); - } + testapp_print("\n > Enter meeting response: "); + if (0 >= scanf("%d", (int *)&(meeting_req->meeting_response))) + testapp_print("Invalid input. "); + } - if ((err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMAIL_ERROR_NONE) - testapp_print("email_update_mail failed.[%d]\n", err); - else - testapp_print("email_update_mail success\n"); + if ((err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMAIL_ERROR_NONE) + testapp_print("email_update_mail failed.[%d]\n", err); + else + testapp_print("email_update_mail success\n"); - ret = 1; + ret = 1; FINISH_OFF: - if (test_mail_data) - email_free_mail_data(&test_mail_data, 1); + if (test_mail_data) + email_free_mail_data(&test_mail_data, 1); - if (test_attachment_data_list) - email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count); + if (test_attachment_data_list) + email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count); - if (meeting_req) - email_free_meeting_request(&meeting_req, 1); + if (meeting_req) + email_free_meeting_request(&meeting_req, 1); - if (!ret) - return FALSE; + if (!ret) + return FALSE; - return TRUE; + return TRUE; } static gboolean testapp_test_get_mails() { - testapp_print("\n >>> testapp_test_get_mails : Entered \n"); - email_mail_data_t *mails = NULL, **mails_pointer = NULL; - int mailbox_id = 0; - int count = 0, i = 0; - int account_id = 0; - int start_index = 0; - int limit_count = 0; - int sorting = 0; - int err_code = EMAIL_ERROR_NONE; - int to_get_count = 0; - int is_for_thread_view = 0; - int list_type; - struct tm *temp_time_info; - - testapp_print("\n > Enter Account_id(0 = all accounts) : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - testapp_print("\n > Enter Mailbox id(0 = all mailboxes) :"); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Sorting : "); - if (0 >= scanf("%d", &sorting)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Start index(starting at 0): "); - if (0 >= scanf("%d", &start_index)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter max_count : "); - if (0 >= scanf("%d", &limit_count)) - testapp_print("Invalid input. "); - - testapp_print("\n > For thread view : "); - if (0 >= scanf("%d", &is_for_thread_view)) - testapp_print("Invalid input. "); - - testapp_print("\n > Mail count only(0:list 1:count): "); - if (0 >= scanf("%d", &to_get_count)) - testapp_print("Invalid input. "); - - if (to_get_count) - mails_pointer = NULL; - else - mails_pointer = &mails; - - if (is_for_thread_view == -2) - list_type = EMAIL_LIST_TYPE_LOCAL; - else if (is_for_thread_view == -1) - list_type = EMAIL_LIST_TYPE_THREAD; - else - list_type = EMAIL_LIST_TYPE_NORMAL; - - /* Get mail list */ - if (mailbox_id == 0) { - testapp_print("Calling email_get_mails for all mailbox.\n"); - err_code = email_get_mails(account_id, 0, list_type, start_index, limit_count, sorting, mails_pointer, &count); - if (err_code < 0) - testapp_print("email_get_mails failed - err[%d]\n", err_code); - } else { - testapp_print("Calling email_get_mails for %d mailbox_id.\n", mailbox_id); - err_code = email_get_mails(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mails_pointer, &count); - if (err_code < 0) - testapp_print("email_get_mails failed - err[%d]\n", err_code); - } - testapp_print("email_get_mails >>>>>>count - %d\n", count); - - if (mails) { - for (i = 0; i < count; i++) { - testapp_print("\n[%d]\n", i); - testapp_print(" >>> mailbox_id [ %d ] \n", mails[i].mailbox_id); - testapp_print(" >>> mail_id [ %d ] \n", mails[i].mail_id); - testapp_print(" >>> account_id [ %d ] \n", mails[i].account_id); - if (mails[i].full_address_from != NULL) - testapp_print(" >>> full_address_from [ %s ] \n", mails[i].full_address_from); - if (mails[i].full_address_to != NULL) - testapp_print(" >>> recipients [ %s ] \n", mails[i].full_address_to); - if (mails[i].subject != NULL) - testapp_print(" >>> subject [ %s ] \n", mails[i].subject); - testapp_print(" >>> body_download_status [ %d ] \n", mails[i].body_download_status); - temp_time_info = localtime(&mails[i].date_time); - testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", - temp_time_info->tm_year + 1900, - temp_time_info->tm_mon+1, - temp_time_info->tm_mday, - temp_time_info->tm_hour, - temp_time_info->tm_min, - temp_time_info->tm_sec); - testapp_print(" >>> flags_seen_field [ %d ] \n", mails[i].flags_seen_field); - testapp_print(" >>> priority [ %d ] \n", mails[i].priority); - testapp_print(" >>> save_status [ %d ] \n", mails[i].save_status); - testapp_print(" >>> lock_status [ %d ] \n", mails[i].lock_status); - testapp_print(" >>> attachment_count [ %d ] \n", mails[i].attachment_count); - if (mails[i].preview_text != NULL) - testapp_print(" >>> preview_text [ %s ] \n", mails[i].preview_text); - } - free(mails); - } + testapp_print("\n >>> testapp_test_get_mails : Entered \n"); + email_mail_data_t *mails = NULL, **mails_pointer = NULL; + int mailbox_id = 0; + int count = 0, i = 0; + int account_id = 0; + int start_index = 0; + int limit_count = 0; + int sorting = 0; + int err_code = EMAIL_ERROR_NONE; + int to_get_count = 0; + int is_for_thread_view = 0; + int list_type; + struct tm *temp_time_info; + + testapp_print("\n > Enter Account_id(0 = all accounts) : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + testapp_print("\n > Enter Mailbox id(0 = all mailboxes) :"); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Sorting : "); + if (0 >= scanf("%d", &sorting)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Start index(starting at 0): "); + if (0 >= scanf("%d", &start_index)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter max_count : "); + if (0 >= scanf("%d", &limit_count)) + testapp_print("Invalid input. "); + + testapp_print("\n > For thread view : "); + if (0 >= scanf("%d", &is_for_thread_view)) + testapp_print("Invalid input. "); + + testapp_print("\n > Mail count only(0:list 1:count): "); + if (0 >= scanf("%d", &to_get_count)) + testapp_print("Invalid input. "); + + if (to_get_count) + mails_pointer = NULL; + else + mails_pointer = &mails; + + if (is_for_thread_view == -2) + list_type = EMAIL_LIST_TYPE_LOCAL; + else if (is_for_thread_view == -1) + list_type = EMAIL_LIST_TYPE_THREAD; + else + list_type = EMAIL_LIST_TYPE_NORMAL; + + /* Get mail list */ + if (mailbox_id == 0) { + testapp_print("Calling email_get_mails for all mailbox.\n"); + err_code = email_get_mails(account_id, 0, list_type, start_index, limit_count, sorting, mails_pointer, &count); + if (err_code < 0) + testapp_print("email_get_mails failed - err[%d]\n", err_code); + } else { + testapp_print("Calling email_get_mails for %d mailbox_id.\n", mailbox_id); + err_code = email_get_mails(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mails_pointer, &count); + if (err_code < 0) + testapp_print("email_get_mails failed - err[%d]\n", err_code); + } + testapp_print("email_get_mails >>>>>>count - %d\n", count); + + if (mails) { + for (i = 0; i < count; i++) { + testapp_print("\n[%d]\n", i); + testapp_print(" >>> mailbox_id [ %d ] \n", mails[i].mailbox_id); + testapp_print(" >>> mail_id [ %d ] \n", mails[i].mail_id); + testapp_print(" >>> account_id [ %d ] \n", mails[i].account_id); + if (mails[i].full_address_from != NULL) + testapp_print(" >>> full_address_from [ %s ] \n", mails[i].full_address_from); + if (mails[i].full_address_to != NULL) + testapp_print(" >>> recipients [ %s ] \n", mails[i].full_address_to); + if (mails[i].subject != NULL) + testapp_print(" >>> subject [ %s ] \n", mails[i].subject); + testapp_print(" >>> body_download_status [ %d ] \n", mails[i].body_download_status); + temp_time_info = localtime(&mails[i].date_time); + testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", + temp_time_info->tm_year + 1900, + temp_time_info->tm_mon+1, + temp_time_info->tm_mday, + temp_time_info->tm_hour, + temp_time_info->tm_min, + temp_time_info->tm_sec); + testapp_print(" >>> flags_seen_field [ %d ] \n", mails[i].flags_seen_field); + testapp_print(" >>> priority [ %d ] \n", mails[i].priority); + testapp_print(" >>> save_status [ %d ] \n", mails[i].save_status); + testapp_print(" >>> lock_status [ %d ] \n", mails[i].lock_status); + testapp_print(" >>> attachment_count [ %d ] \n", mails[i].attachment_count); + if (mails[i].preview_text != NULL) + testapp_print(" >>> preview_text [ %s ] \n", mails[i].preview_text); + } + free(mails); + } - testapp_print(" >>> testapp_test_get_mails : End \n"); - return 0; + testapp_print(" >>> testapp_test_get_mails : End \n"); + return 0; } #define TEMP_ARGUMENT_SIZE 4096 static gboolean testapp_test_mail_send(int *result_mail_id) { - int added_mail_id = 0; - int err = EMAIL_ERROR_NONE; - int handle = 0; - email_mail_data_t *result_mail_data = NULL; + int added_mail_id = 0; + int err = EMAIL_ERROR_NONE; + int handle = 0; + email_mail_data_t *result_mail_data = NULL; - testapp_add_mail_for_sending(&added_mail_id); + testapp_add_mail_for_sending(&added_mail_id); - if (added_mail_id) { - email_get_mail_data(added_mail_id, &result_mail_data); + if (added_mail_id) { + email_get_mail_data(added_mail_id, &result_mail_data); - testapp_print("Calling email_send_mail...\n"); + testapp_print("Calling email_send_mail...\n"); - if (email_send_mail(added_mail_id, &handle) < 0) { - testapp_print("Sending failed[%d]\n", err); - } else { - testapp_print("Start sending. handle[%d]\n", handle); - } + if (email_send_mail(added_mail_id, &handle) < 0) { + testapp_print("Sending failed[%d]\n", err); + } else { + testapp_print("Start sending. handle[%d]\n", handle); + } - email_free_mail_data(&result_mail_data, 1); - } + email_free_mail_data(&result_mail_data, 1); + } - if (result_mail_id) - *result_mail_id = added_mail_id; + if (result_mail_id) + *result_mail_id = added_mail_id; - return FALSE; + return FALSE; } static gboolean testapp_test_get_mail_list_ex() { - email_list_filter_t *filter_list = NULL; - email_list_sorting_rule_t sorting_rule_list[2]; - email_mail_list_item_t *result_mail_list = NULL; - int filter_rule_count = 0; - int sorting_rule_count = 2; - int result_mail_count = 0; - int err = EMAIL_ERROR_NONE; - int i = 0; - int sort_order = 0; - - filter_rule_count = 3; - - filter_list = malloc(sizeof(email_list_filter_t) * filter_rule_count); - memset(filter_list, 0 , sizeof(email_list_filter_t) * filter_rule_count); - - filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; - filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; - filter_list[0].list_filter_item.rule.key_value.integer_type_value = 1; - filter_list[0].list_filter_item.rule.case_sensitivity = false; - - filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; - - filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE; - filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; - filter_list[2].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX; - filter_list[2].list_filter_item.rule.case_sensitivity = false; - - /*filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE_ATTACH; - filter_list[0].list_filter_item.rule_attach.target_attribute = EMAIL_MAIL_ATTACH_ATTRIBUTE_ATTACHMENT_NAME; - filter_list[0].list_filter_item.rule_attach.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[0].list_filter_item.rule_attach.key_value.string_type_value = strdup("test"); - filter_list[0].list_filter_item.rule_attach.case_sensitivity = false;*/ - - /* - filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[0].list_filter_item.rule_fts.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; - filter_list[0].list_filter_item.rule_fts.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; - filter_list[0].list_filter_item.rule_fts.key_value.integer_type_value = 1; - - filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - - - filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; - filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("2013"); - filter_list[2].list_filter_item.rule.case_sensitivity = false; - - - filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - - filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; - filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); - filter_list[2].list_filter_item.rule.case_sensitivity = false; - - filter_list[3].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[3].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - - filter_list[4].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[4].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_CC; - filter_list[4].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[4].list_filter_item.rule.key_value.string_type_value = strdup("RE"); - filter_list[4].list_filter_item.rule.case_sensitivity = false; - - filter_list[5].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[5].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - - filter_list[6].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[6].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_BCC; - filter_list[6].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[6].list_filter_item.rule.key_value.string_type_value = strdup("RE"); - filter_list[6].list_filter_item.rule.case_sensitivity = false; - - filter_list[7].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[7].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - - filter_list[8].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[8].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FROM; - filter_list[8].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[8].list_filter_item.rule.key_value.string_type_value = strdup("RE"); - filter_list[8].list_filter_item.rule.case_sensitivity = false; - */ - - /* - filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; - filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; - filter_list[0].list_filter_item.rule.key_value.integer_type_value = 1; - - filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; - - filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME; - filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; - filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("INBOX"); - filter_list[2].list_filter_item.rule.case_sensitivity = true; - */ - - memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * sorting_rule_count); -/* - sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_RECIPIENT_ADDRESS; - sorting_rule_list[0].key_value.string_type_value = strdup("minsoo.kimn@gmail.com"); - sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_TO_CCBCC; -*/ - testapp_print("\n Enter the sort_order :"); - if (0 >= scanf("%d", &sort_order)) - testapp_print("Invalid input."); - - sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; - sorting_rule_list[0].sort_order = sort_order; - - sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME; - sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_DESCEND; - - err = email_get_mail_list_ex(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &result_mail_list, &result_mail_count); - - if (err == EMAIL_ERROR_NONE) { - testapp_print("email_get_mail_list_ex succeed.\n"); - - for (i = 0; i < result_mail_count; i++) { - testapp_print("mail_id [%d], subject [%s], mailbox_type [%d] full_address_from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].mailbox_type, result_mail_list[i].full_address_from); - } - } else { - testapp_print("email_get_mail_list_ex failed.\n"); - } + email_list_filter_t *filter_list = NULL; + email_list_sorting_rule_t sorting_rule_list[2]; + email_mail_list_item_t *result_mail_list = NULL; + int filter_rule_count = 0; + int sorting_rule_count = 2; + int result_mail_count = 0; + int err = EMAIL_ERROR_NONE; + int i = 0; + int sort_order = 0; + + filter_rule_count = 3; + + filter_list = malloc(sizeof(email_list_filter_t) * filter_rule_count); + memset(filter_list, 0 , sizeof(email_list_filter_t) * filter_rule_count); + + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[0].list_filter_item.rule.key_value.integer_type_value = 1; + filter_list[0].list_filter_item.rule.case_sensitivity = false; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[2].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX; + filter_list[2].list_filter_item.rule.case_sensitivity = false; + + /*filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE_ATTACH; + filter_list[0].list_filter_item.rule_attach.target_attribute = EMAIL_MAIL_ATTACH_ATTRIBUTE_ATTACHMENT_NAME; + filter_list[0].list_filter_item.rule_attach.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[0].list_filter_item.rule_attach.key_value.string_type_value = strdup("test"); + filter_list[0].list_filter_item.rule_attach.case_sensitivity = false;*/ + + /* + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule_fts.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; + filter_list[0].list_filter_item.rule_fts.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[0].list_filter_item.rule_fts.key_value.integer_type_value = 1; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("2013"); + filter_list[2].list_filter_item.rule.case_sensitivity = false; + + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[2].list_filter_item.rule.case_sensitivity = false; + + filter_list[3].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[3].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[4].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[4].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_CC; + filter_list[4].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[4].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[4].list_filter_item.rule.case_sensitivity = false; + + filter_list[5].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[5].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[6].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[6].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_BCC; + filter_list[6].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[6].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[6].list_filter_item.rule.case_sensitivity = false; + + filter_list[7].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[7].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[8].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[8].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FROM; + filter_list[8].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[8].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[8].list_filter_item.rule.case_sensitivity = false; + */ + + /* + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[0].list_filter_item.rule.key_value.integer_type_value = 1; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("INBOX"); + filter_list[2].list_filter_item.rule.case_sensitivity = true; + */ + + memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * sorting_rule_count); + /* + sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_RECIPIENT_ADDRESS; + sorting_rule_list[0].key_value.string_type_value = strdup("minsoo.kimn@gmail.com"); + sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_TO_CCBCC; + */ + testapp_print("\n Enter the sort_order :"); + if (0 >= scanf("%d", &sort_order)) + testapp_print("Invalid input."); + + sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; + sorting_rule_list[0].sort_order = sort_order; + + sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME; + sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_DESCEND; + + err = email_get_mail_list_ex(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &result_mail_list, &result_mail_count); + + if (err == EMAIL_ERROR_NONE) { + testapp_print("email_get_mail_list_ex succeed.\n"); + + for (i = 0; i < result_mail_count; i++) { + testapp_print("mail_id [%d], subject [%s], mailbox_type [%d] full_address_from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].mailbox_type, result_mail_list[i].full_address_from); + } + } else { + testapp_print("email_get_mail_list_ex failed.\n"); + } - email_free_list_filter(&filter_list, 3); + email_free_list_filter(&filter_list, 3); - return FALSE; + return FALSE; } static gboolean testapp_test_send_cancel() { - int num = 0; - int Y = 0; - int i = 0; - int j = 0; - int *mailIdList = NULL; - int mail_id = 0; - - testapp_print("\n > Enter total Number of mail want to send: "); - if (0 >= scanf("%d", &num)) - testapp_print("Invalid input. "); - mailIdList = (int *)malloc(sizeof(int)*num); - if (!mailIdList) - return false ; - - for (i = 1; i <= num; i++) { - testapp_test_mail_send(&mail_id); - - testapp_print("mail_id[%d]", mail_id); - - mailIdList[i] = mail_id; - testapp_print("mailIdList[%d][%d]", i, mailIdList[i]); - - mail_id = 0; - testapp_print("\n > Do you want to cancel the send mail job '1' or '0': "); - if (0 >= scanf("%d", &Y)) - testapp_print("Invalid input. "); - if (Y == 1) { - testapp_print("\n >Enter mail-id[1-%d] ", i); - if (0 >= scanf("%d", &j)) - testapp_print("Invalid input. "); - testapp_print("\n mailIdList[%d] ", mailIdList[j]); - if (email_cancel_sending_mail(mailIdList[j]) < 0) - testapp_print("email_cancel_sending_mail failed..!"); - else - testapp_print("email_cancel_sending_mail success..!"); - } - } - return FALSE; + int num = 0; + int Y = 0; + int i = 0; + int j = 0; + int *mailIdList = NULL; + int mail_id = 0; + + testapp_print("\n > Enter total Number of mail want to send: "); + if (0 >= scanf("%d", &num)) + testapp_print("Invalid input. "); + mailIdList = (int *)malloc(sizeof(int)*num); + if (!mailIdList) + return false ; + + for (i = 1; i <= num; i++) { + testapp_test_mail_send(&mail_id); + + testapp_print("mail_id[%d]", mail_id); + + mailIdList[i] = mail_id; + testapp_print("mailIdList[%d][%d]", i, mailIdList[i]); + + mail_id = 0; + testapp_print("\n > Do you want to cancel the send mail job '1' or '0': "); + if (0 >= scanf("%d", &Y)) + testapp_print("Invalid input. "); + if (Y == 1) { + testapp_print("\n >Enter mail-id[1-%d] ", i); + if (0 >= scanf("%d", &j)) + testapp_print("Invalid input. "); + testapp_print("\n mailIdList[%d] ", mailIdList[j]); + if (email_cancel_sending_mail(mailIdList[j]) < 0) + testapp_print("email_cancel_sending_mail failed..!"); + else + testapp_print("email_cancel_sending_mail success..!"); + } + } + return FALSE; } static gboolean testapp_test_delete() { - int mail_id = 0, account_id = 0; - int mailbox_id = 0; - int err = EMAIL_ERROR_NONE; - int from_server = 0; - - testapp_print("\n > Enter Account_id: "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Mail_id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Mailbox id: "); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter from_server: "); - if (0 >= scanf("%d", &from_server)) - testapp_print("Invalid input. "); - - /* delete message */ - if ((err = email_delete_mail(mailbox_id, &mail_id, 1, from_server)) < 0) - testapp_print("\n email_delete_mail failed[%d]\n", err); - else - testapp_print("\n email_delete_mail success\n"); - - return FALSE; + int mail_id = 0, account_id = 0; + int mailbox_id = 0; + int err = EMAIL_ERROR_NONE; + int from_server = 0; + + testapp_print("\n > Enter Account_id: "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Mail_id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Mailbox id: "); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter from_server: "); + if (0 >= scanf("%d", &from_server)) + testapp_print("Invalid input. "); + + /* delete message */ + if ((err = email_delete_mail(mailbox_id, &mail_id, 1, from_server)) < 0) + testapp_print("\n email_delete_mail failed[%d]\n", err); + else + testapp_print("\n email_delete_mail success\n"); + + return FALSE; } static gboolean testapp_test_update_mail_attribute() { - int err = EMAIL_ERROR_NONE; - int i = 0; - int account_id = 0; - int *mail_id_array = NULL; - int mail_id_count = 0; - email_mail_attribute_type attribute_type; - email_mail_attribute_value_t attribute_value; - - testapp_print("\n > Enter account_id: "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter attribute_type: "); - if (0 >= scanf("%d", (int*)&attribute_type)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter integer type value: "); - if (0 >= scanf("%d", (int*)&(attribute_value.integer_type_value))) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter mail_id_count: "); - if (0 >= scanf("%d", &mail_id_count)) - testapp_print("Invalid input. "); - - mail_id_count = (mail_id_count < 5000) ? mail_id_count : 5000; - - if (mail_id_count > 0) { - mail_id_array = malloc(sizeof(int) * mail_id_count); - } + int err = EMAIL_ERROR_NONE; + int i = 0; + int account_id = 0; + int *mail_id_array = NULL; + int mail_id_count = 0; + email_mail_attribute_type attribute_type; + email_mail_attribute_value_t attribute_value; + + testapp_print("\n > Enter account_id: "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter attribute_type: "); + if (0 >= scanf("%d", (int*)&attribute_type)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter integer type value: "); + if (0 >= scanf("%d", (int*)&(attribute_value.integer_type_value))) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter mail_id_count: "); + if (0 >= scanf("%d", &mail_id_count)) + testapp_print("Invalid input. "); + + mail_id_count = (mail_id_count < 5000) ? mail_id_count : 5000; + + if (mail_id_count > 0) { + mail_id_array = malloc(sizeof(int) * mail_id_count); + } - for (i = 0; i < mail_id_count; i++) { - testapp_print("\n > Enter mail id: "); - if (0 >= scanf("%d", (mail_id_array + i))) - testapp_print("Invalid input. "); - } + for (i = 0; i < mail_id_count; i++) { + testapp_print("\n > Enter mail id: "); + if (0 >= scanf("%d", (mail_id_array + i))) + testapp_print("Invalid input. "); + } - /* delete message */ - if ((err = email_update_mail_attribute(account_id, mail_id_array, mail_id_count, attribute_type, attribute_value)) < EMAIL_ERROR_NONE) - testapp_print("\n email_update_mail_attribute failed[%d]\n", err); - else - testapp_print("\n email_update_mail_attribute success\n"); + /* delete message */ + if ((err = email_update_mail_attribute(account_id, mail_id_array, mail_id_count, attribute_type, attribute_value)) < EMAIL_ERROR_NONE) + testapp_print("\n email_update_mail_attribute failed[%d]\n", err); + else + testapp_print("\n email_update_mail_attribute success\n"); - if (mail_id_array) - free(mail_id_array); + if (mail_id_array) + free(mail_id_array); - return FALSE; + return FALSE; } static gboolean testapp_test_move() { - int mail_id[3]; - int i = 0; - int mailbox_id = 0; - - for (i = 0; i < 3; i++) { - testapp_print("\n > Enter mail_id: "); - if (0 >= scanf("%d", &mail_id[i])) - testapp_print("Invalid input. "); - } + int mail_id[3]; + int i = 0; + int mailbox_id = 0; + + for (i = 0; i < 3; i++) { + testapp_print("\n > Enter mail_id: "); + if (0 >= scanf("%d", &mail_id[i])) + testapp_print("Invalid input. "); + } - testapp_print("\n > Enter mailbox_id: "); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter mailbox_id: "); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); - /* move mail */ - email_move_mail_to_mailbox(mail_id, 3, mailbox_id); - return FALSE; + /* move mail */ + email_move_mail_to_mailbox(mail_id, 3, mailbox_id); + return FALSE; } static gboolean testapp_test_delete_all() { - int mailbox_id = 0; - int err = EMAIL_ERROR_NONE; + int mailbox_id = 0; + int err = EMAIL_ERROR_NONE; - testapp_print("\n > Enter mailbox_id: "); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter mailbox_id: "); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); - /* delete all message */ - if ((err = email_delete_all_mails_in_mailbox(mailbox_id, 0)) < 0) - testapp_print("email_delete_all_mails_in_mailbox failed [%d]\n", err); - else - testapp_print("email_delete_all_mails_in_mailbox Success\n"); + /* delete all message */ + if ((err = email_delete_all_mails_in_mailbox(mailbox_id, 0)) < 0) + testapp_print("email_delete_all_mails_in_mailbox failed [%d]\n", err); + else + testapp_print("email_delete_all_mails_in_mailbox Success\n"); - return FALSE; + return FALSE; } static gboolean testapp_test_add_attachment() { - int mail_id = 0; - char arg[100]; - email_attachment_data_t attachment; + int mail_id = 0; + char arg[100]; + email_attachment_data_t attachment; - testapp_print("\n > Enter Mail Id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter Mail Id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); - memset(&attachment, 0x00, sizeof(email_attachment_data_t)); - memset(arg, 0x00, 100); - testapp_print("\n > Enter attachment name: "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); + memset(&attachment, 0x00, sizeof(email_attachment_data_t)); + memset(arg, 0x00, 100); + testapp_print("\n > Enter attachment name: "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); - attachment.attachment_name = strdup(arg); + attachment.attachment_name = strdup(arg); - memset(arg, 0x00, 100); - testapp_print("\n > Enter attachment absolute path: "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); + memset(arg, 0x00, 100); + testapp_print("\n > Enter attachment absolute path: "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); - attachment.save_status = true; - attachment.attachment_path = strdup(arg); - if (email_add_attachment(mail_id, &attachment) < 0) - testapp_print("email_add_attachment failed\n"); - else - testapp_print("email_add_attachment success\n"); + attachment.save_status = true; + attachment.attachment_path = strdup(arg); + if (email_add_attachment(mail_id, &attachment) < 0) + testapp_print("email_add_attachment failed\n"); + else + testapp_print("email_add_attachment success\n"); - return FALSE; + return FALSE; } static gboolean testapp_test_set_deleted_flag() { - int index = 0; - int account_id = 0; - int mail_ids[100] = { 0, }; - int temp_mail_id = 0; - int err_code = EMAIL_ERROR_NONE; - - testapp_print("\n >>> Input target account id: "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - do { - testapp_print("\n >>> Input target mail id( Input 0 to terminate ) [MAX = 100]: "); - if (0 >= scanf("%d", &temp_mail_id)) - testapp_print("Invalid input. "); - mail_ids[index++] = temp_mail_id; - } while (temp_mail_id != 0); - - err_code = email_set_flags_field(account_id, mail_ids, index, EMAIL_FLAGS_DELETED_FIELD, 1, true); - testapp_print("email_set_flags_field returns - err[%d]\n", err_code); - - return 0; + int index = 0; + int account_id = 0; + int mail_ids[100] = { 0, }; + int temp_mail_id = 0; + int err_code = EMAIL_ERROR_NONE; + + testapp_print("\n >>> Input target account id: "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + do { + testapp_print("\n >>> Input target mail id( Input 0 to terminate ) [MAX = 100]: "); + if (0 >= scanf("%d", &temp_mail_id)) + testapp_print("Invalid input. "); + mail_ids[index++] = temp_mail_id; + } while (temp_mail_id != 0); + + err_code = email_set_flags_field(account_id, mail_ids, index, EMAIL_FLAGS_DELETED_FIELD, 1, true); + testapp_print("email_set_flags_field returns - err[%d]\n", err_code); + + return 0; } static gboolean testapp_test_expunge_mails_deleted_flagged() { - int mailbox_id = 0; - int on_server = 0; - int err_code = EMAIL_ERROR_NONE; - int handle = 0; + int mailbox_id = 0; + int on_server = 0; + int err_code = EMAIL_ERROR_NONE; + int handle = 0; - testapp_print("\n >>> Input target mailbox id: "); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); + testapp_print("\n >>> Input target mailbox id: "); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); - testapp_print("\n >>> Expunge on server?: "); - if (0 >= scanf("%d", &on_server)) - testapp_print("Invalid input. "); + testapp_print("\n >>> Expunge on server?: "); + if (0 >= scanf("%d", &on_server)) + testapp_print("Invalid input. "); - err_code = email_expunge_mails_deleted_flagged(mailbox_id, on_server, &handle); + err_code = email_expunge_mails_deleted_flagged(mailbox_id, on_server, &handle); - testapp_print("email_expunge_mails_deleted_flagged returns - err[%d]\n", err_code); + testapp_print("email_expunge_mails_deleted_flagged returns - err[%d]\n", err_code); - return 0; + return 0; } static gboolean testapp_test_send_read_receipt() { - int read_mail_id = 0; - int receipt_mail_id = 0; - int err_code = EMAIL_ERROR_NONE; - int handle = 0; + int read_mail_id = 0; + int receipt_mail_id = 0; + int err_code = EMAIL_ERROR_NONE; + int handle = 0; - testapp_print("\n >>> Input read mail id: "); - if (0 >= scanf("%d", &read_mail_id)) - testapp_print("Invalid input. "); + testapp_print("\n >>> Input read mail id: "); + if (0 >= scanf("%d", &read_mail_id)) + testapp_print("Invalid input. "); - err_code = email_add_read_receipt(read_mail_id, &receipt_mail_id); + err_code = email_add_read_receipt(read_mail_id, &receipt_mail_id); - testapp_print("eamil_add_read_receipt returns receipt_mail_id [%d] - err[%d]\n", receipt_mail_id, err_code); - testapp_print("Calling email_send_mail...\n"); + testapp_print("eamil_add_read_receipt returns receipt_mail_id [%d] - err[%d]\n", receipt_mail_id, err_code); + testapp_print("Calling email_send_mail...\n"); - if ((err_code = email_send_mail(receipt_mail_id, &handle)) != EMAIL_ERROR_NONE) { - testapp_print("Sending failed[%d]\n", err_code); - } else { - testapp_print("Start sending. handle[%d]\n", handle); - } + if ((err_code = email_send_mail(receipt_mail_id, &handle)) != EMAIL_ERROR_NONE) { + testapp_print("Sending failed[%d]\n", err_code); + } else { + testapp_print("Start sending. handle[%d]\n", handle); + } - return 0; + return 0; } static gboolean testapp_test_delete_attachment() { - int attachment_id = 0; - int err_code = EMAIL_ERROR_NONE; + int attachment_id = 0; + int err_code = EMAIL_ERROR_NONE; - testapp_print("\n >>> Input attachment id: "); - if (0 >= scanf("%d", &attachment_id)) - testapp_print("Invalid input. "); + testapp_print("\n >>> Input attachment id: "); + if (0 >= scanf("%d", &attachment_id)) + testapp_print("Invalid input. "); - if ((err_code = email_delete_attachment(attachment_id)) != EMAIL_ERROR_NONE) { - testapp_print("email_delete_attachment failed[%d]\n", err_code); - } + if ((err_code = email_delete_attachment(attachment_id)) != EMAIL_ERROR_NONE) { + testapp_print("email_delete_attachment failed[%d]\n", err_code); + } - return 0; + return 0; } static gboolean testapp_test_get_mail_list() { - testapp_print("\n >>> testapp_test_get_mail_list : Entered \n"); - email_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL; - int mailbox_id = 0; - int count = 0, i = 0; - int account_id = 0; - int start_index = 0; - int limit_count = 0; - int sorting = 0; - int err_code = EMAIL_ERROR_NONE; - int to_get_count = 0; - int is_for_thread_view = 0; - int list_type; - struct tm *temp_time_info; - - testapp_print("\n > Enter Account_id(0 = all accounts) : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Mailbox id(0 = all mailboxes) :"); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Sorting : "); - if (0 >= scanf("%d", &sorting)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter Start index(starting at 0): "); - if (0 >= scanf("%d", &start_index)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter max_count : "); - if (0 >= scanf("%d", &limit_count)) - testapp_print("Invalid input. "); - - testapp_print("\n > For thread view : "); - if (0 >= scanf("%d", &is_for_thread_view)) - testapp_print("Invalid input. "); - - testapp_print("\n > Count mails?(1: YES):"); - if (0 >= scanf("%d", &to_get_count)) - testapp_print("Invalid input. "); - - if (to_get_count) - mail_list_pointer = NULL; - else - mail_list_pointer = &mail_list; - - if (is_for_thread_view == -2) { - list_type = EMAIL_LIST_TYPE_LOCAL; - } else if (is_for_thread_view == -1) - list_type = EMAIL_LIST_TYPE_THREAD; - else - list_type = EMAIL_LIST_TYPE_NORMAL; - - /* Get mail list */ - if (mailbox_id == 0) { - testapp_print("Calling email_get_mail_list for all mailbox.\n"); - err_code = email_get_mail_list(account_id, 0, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); - if (err_code < 0) - testapp_print("email_get_mail_list failed - err[%d]\n", err_code); - } else { - testapp_print("Calling email_get_mail_list for %d mailbox_id.\n", mailbox_id); - err_code = email_get_mail_list(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); - if (err_code < 0) - testapp_print("email_get_mail_list failed - err[%d]\n", err_code); - } - testapp_print("email_get_mail_list >>>>>>count - %d\n", count); - - if (mail_list) { - for (i = 0; i < count; i++) { - testapp_print("\n[%d]\n", i); - testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id); - testapp_print(" >>> mailbox_type [ %d ] \n", mail_list[i].mailbox_type); - testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id); - testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id); - if (mail_list[i].full_address_from != NULL) - testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from); - if (mail_list[i].email_address_recipient != NULL) - testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient); - if (mail_list[i].subject != NULL) - testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); - testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status); - temp_time_info = localtime(&mail_list[i].date_time); - testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", - temp_time_info->tm_year + 1900, - temp_time_info->tm_mon+1, - temp_time_info->tm_mday, - temp_time_info->tm_hour, - temp_time_info->tm_min, - temp_time_info->tm_sec); - testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field); - testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority); - testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status); - testapp_print(" >>> lock_status [ %d ] \n", mail_list[i].lock_status); - testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count); - if (mail_list[i].preview_text != NULL) - testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text); - } - free(mail_list); - } + testapp_print("\n >>> testapp_test_get_mail_list : Entered \n"); + email_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL; + int mailbox_id = 0; + int count = 0, i = 0; + int account_id = 0; + int start_index = 0; + int limit_count = 0; + int sorting = 0; + int err_code = EMAIL_ERROR_NONE; + int to_get_count = 0; + int is_for_thread_view = 0; + int list_type; + struct tm *temp_time_info; + + testapp_print("\n > Enter Account_id(0 = all accounts) : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Mailbox id(0 = all mailboxes) :"); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Sorting : "); + if (0 >= scanf("%d", &sorting)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter Start index(starting at 0): "); + if (0 >= scanf("%d", &start_index)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter max_count : "); + if (0 >= scanf("%d", &limit_count)) + testapp_print("Invalid input. "); + + testapp_print("\n > For thread view : "); + if (0 >= scanf("%d", &is_for_thread_view)) + testapp_print("Invalid input. "); + + testapp_print("\n > Count mails?(1: YES):"); + if (0 >= scanf("%d", &to_get_count)) + testapp_print("Invalid input. "); + + if (to_get_count) + mail_list_pointer = NULL; + else + mail_list_pointer = &mail_list; + + if (is_for_thread_view == -2) { + list_type = EMAIL_LIST_TYPE_LOCAL; + } else if (is_for_thread_view == -1) + list_type = EMAIL_LIST_TYPE_THREAD; + else + list_type = EMAIL_LIST_TYPE_NORMAL; + + /* Get mail list */ + if (mailbox_id == 0) { + testapp_print("Calling email_get_mail_list for all mailbox.\n"); + err_code = email_get_mail_list(account_id, 0, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); + if (err_code < 0) + testapp_print("email_get_mail_list failed - err[%d]\n", err_code); + } else { + testapp_print("Calling email_get_mail_list for %d mailbox_id.\n", mailbox_id); + err_code = email_get_mail_list(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); + if (err_code < 0) + testapp_print("email_get_mail_list failed - err[%d]\n", err_code); + } + testapp_print("email_get_mail_list >>>>>>count - %d\n", count); + + if (mail_list) { + for (i = 0; i < count; i++) { + testapp_print("\n[%d]\n", i); + testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id); + testapp_print(" >>> mailbox_type [ %d ] \n", mail_list[i].mailbox_type); + testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id); + testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id); + if (mail_list[i].full_address_from != NULL) + testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from); + if (mail_list[i].email_address_recipient != NULL) + testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient); + if (mail_list[i].subject != NULL) + testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); + testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status); + temp_time_info = localtime(&mail_list[i].date_time); + testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n", + temp_time_info->tm_year + 1900, + temp_time_info->tm_mon+1, + temp_time_info->tm_mday, + temp_time_info->tm_hour, + temp_time_info->tm_min, + temp_time_info->tm_sec); + testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field); + testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority); + testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status); + testapp_print(" >>> lock_status [ %d ] \n", mail_list[i].lock_status); + testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count); + if (mail_list[i].preview_text != NULL) + testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text); + } + free(mail_list); + } - testapp_print("\n >>> email_get_mail_list : End \n"); - return 0; + testapp_print("\n >>> email_get_mail_list : End \n"); + return 0; } static gboolean testapp_test_get_mail_list_for_thread_view() { - testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : Entered \n"); - email_mail_list_item_t *mail_list = NULL; - int count = 0, i = 0; - int account_id = 0; - int mailbox_id = 0; - int err_code = EMAIL_ERROR_NONE; - struct tm *time_info; - char buf[26] = {0}; - - testapp_print("\nEnter account id\n"); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - testapp_print("\nEnter mailbox id\n"); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); - - /* Get mail list */ - if (email_get_mail_list(account_id, mailbox_id , EMAIL_LIST_TYPE_THREAD, 0, 500, EMAIL_SORT_DATETIME_HIGH, &mail_list, &count) < 0) { - testapp_print("email_get_mail_list failed : %d\n", err_code); - return FALSE; - } - testapp_print("email_get_mail_list >>>>>>count - %d\n", count); - if (mail_list) { - for (i = 0; i < count; i++) { - testapp_print(" i [%d]\n", i); - testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id); - testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id); - testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id); - testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from); - testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient); - testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); - testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status); - time_info = localtime(&mail_list[i].date_time); - testapp_print(" >>> date_time [ %s ] \n", asctime_r(time_info, buf)); - testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field); - testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority); - testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status); - testapp_print(" >>> lock [ %d ] \n", mail_list[i].lock_status); - testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count); - testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text); - testapp_print(" >>> thread_id [ %d ] \n", mail_list[i].thread_id); - testapp_print(" >>> thread__item_count [ %d ] \n", mail_list[i].thread_item_count); - } - free(mail_list); - } - testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : End \n"); - return 0; + testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : Entered \n"); + email_mail_list_item_t *mail_list = NULL; + int count = 0, i = 0; + int account_id = 0; + int mailbox_id = 0; + int err_code = EMAIL_ERROR_NONE; + struct tm *time_info; + char buf[26] = {0}; + + testapp_print("\nEnter account id\n"); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\nEnter mailbox id\n"); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); + + /* Get mail list */ + if (email_get_mail_list(account_id, mailbox_id , EMAIL_LIST_TYPE_THREAD, 0, 500, EMAIL_SORT_DATETIME_HIGH, &mail_list, &count) < 0) { + testapp_print("email_get_mail_list failed : %d\n", err_code); + return FALSE; + } + testapp_print("email_get_mail_list >>>>>>count - %d\n", count); + if (mail_list) { + for (i = 0; i < count; i++) { + testapp_print(" i [%d]\n", i); + testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id); + testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id); + testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id); + testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from); + testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient); + testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); + testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status); + time_info = localtime(&mail_list[i].date_time); + testapp_print(" >>> date_time [ %s ] \n", asctime_r(time_info, buf)); + testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field); + testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority); + testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status); + testapp_print(" >>> lock [ %d ] \n", mail_list[i].lock_status); + testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count); + testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text); + testapp_print(" >>> thread_id [ %d ] \n", mail_list[i].thread_id); + testapp_print(" >>> thread__item_count [ %d ] \n", mail_list[i].thread_item_count); + } + free(mail_list); + } + testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : End \n"); + return 0; } static gboolean testapp_test_count() { - int total = 0; - int unseen = 0; - email_list_filter_t *filter_list = NULL; - - filter_list = malloc(sizeof(email_list_filter_t) * 3); - memset(filter_list, 0 , sizeof(email_list_filter_t) * 3); - - filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; - filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE"); - filter_list[0].list_filter_item.rule.case_sensitivity = false; - - filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; - filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; - - filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; - filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; - filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; - filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); - filter_list[2].list_filter_item.rule.case_sensitivity = false; - - if (EMAIL_ERROR_NONE == email_count_mail(filter_list, 3, &total, &unseen)) - printf("\n Total: %d, Unseen: %d \n", total, unseen); - return 0; + int total = 0; + int unseen = 0; + email_list_filter_t *filter_list = NULL; + + filter_list = malloc(sizeof(email_list_filter_t) * 3); + memset(filter_list, 0 , sizeof(email_list_filter_t) * 3); + + filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT; + filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[0].list_filter_item.rule.case_sensitivity = false; + + filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR; + filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR; + + filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE; + filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO; + filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE; + filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE"); + filter_list[2].list_filter_item.rule.case_sensitivity = false; + + if (EMAIL_ERROR_NONE == email_count_mail(filter_list, 3, &total, &unseen)) + printf("\n Total: %d, Unseen: %d \n", total, unseen); + email_free_list_filter(&filter_list, 3); + return 0; } static gboolean testapp_test_move_mails_to_mailbox_of_another_account() { - int err = EMAIL_ERROR_NONE; - int mail_id_count = 0 ; - int *mail_id_array = NULL; - int source_mailbox_id = 0; - int target_mailbox_id = 0; - int task_id = 0; - int i = 0; - - testapp_print("\n > Enter source mailbox id: "); - if (0 >= scanf("%d", &source_mailbox_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter target mailbox id: "); - if (0 >= scanf("%d", &target_mailbox_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter mail count: "); - if (0 >= scanf("%d", &mail_id_count)) - testapp_print("Invalid input. "); - - mail_id_count = (mail_id_count < 5000) ? mail_id_count : 5000; - - if (mail_id_count > 0) { - mail_id_array = malloc(sizeof(int) * mail_id_count); - } + int err = EMAIL_ERROR_NONE; + int mail_id_count = 0 ; + int *mail_id_array = NULL; + int source_mailbox_id = 0; + int target_mailbox_id = 0; + int task_id = 0; + int i = 0; + + testapp_print("\n > Enter source mailbox id: "); + if (0 >= scanf("%d", &source_mailbox_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter target mailbox id: "); + if (0 >= scanf("%d", &target_mailbox_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter mail count: "); + if (0 >= scanf("%d", &mail_id_count)) + testapp_print("Invalid input. "); + + mail_id_count = (mail_id_count < 5000) ? mail_id_count : 5000; + + if (mail_id_count > 0) { + mail_id_array = malloc(sizeof(int) * mail_id_count); + } - for (i = 0; i < mail_id_count; i++) { - testapp_print("\n > Enter mail id: "); - if (0 >= scanf("%d", (mail_id_array + i))) - testapp_print("Invalid input. "); - } + for (i = 0; i < mail_id_count; i++) { + testapp_print("\n > Enter mail id: "); + if (0 >= scanf("%d", (mail_id_array + i))) + testapp_print("Invalid input. "); + } - err = email_move_mails_to_mailbox_of_another_account(source_mailbox_id, mail_id_array, mail_id_count, target_mailbox_id, &task_id); + err = email_move_mails_to_mailbox_of_another_account(source_mailbox_id, mail_id_array, mail_id_count, target_mailbox_id, &task_id); - testapp_print("\nemail_move_mails_to_mailbox_of_another_account returns [%d], tast_id [%d] \n", err, task_id); - return 0; + testapp_print("\nemail_move_mails_to_mailbox_of_another_account returns [%d], tast_id [%d] \n", err, task_id); + return 0; } static gboolean copy_file(char *input_source_path, char *input_dest_path) @@ -1225,28 +1212,26 @@ static gboolean copy_file(char *input_source_path, char *input_dest_path) return FALSE; } testapp_print("copy_file started\n"); - pid = fork(); - if (pid == 0) { - testapp_print("Copying file [%s] [%s]\n", input_source_path, input_dest_path); + testapp_print("Copying file [%s] [%s]\n", input_source_path, input_dest_path); execl("/bin/cp", "/bin/cp", input_source_path, input_dest_path, (char *)0); } else { - testapp_print("Wating child process\n"); + testapp_print("Wating child process\n"); pid_t ws = waitpid(pid, &childExitStatus, WNOHANG); - if (ws == -1) { /* error - handle as you wish */ - testapp_print("waitpid returns error\n"); + if (ws == -1) { + /* error - handle as you wish */ + testapp_print("waitpid returns error\n"); } - if (WIFEXITED(childExitStatus)) { - /* exit code in childExitStatus */ + /* exit code in childExitStatus */ WEXITSTATUS(childExitStatus); /* zero is normal exit */ testapp_print("WEXITSTATUS\n"); /* handle non-zero as you wish */ } else if (WIFSIGNALED(childExitStatus)) { /* killed */ - testapp_print("WIFSIGNALED\n"); + testapp_print("WIFSIGNALED\n"); } else if (WIFSTOPPED(childExitStatus)) { /* stopped */ - testapp_print("WIFSTOPPED\n"); + testapp_print("WIFSTOPPED\n"); } } testapp_print("copy_file finished\n"); @@ -1256,1541 +1241,1535 @@ static gboolean copy_file(char *input_source_path, char *input_dest_path) static gboolean testapp_test_send_mail_with_downloading_attachment_of_original_mail() { - int err = EMAIL_ERROR_NONE; - int original_mail_id = 0; - int original_attachment_count = 0; - int i = 0; - int handle = 0; - char *plain_text_path = MAIL_TEMP_BODY; - char *html_file_path = HTML_TEMP_BODY; - char new_subject[4086] = { 0, }; -/* FILE *body_file; */ - email_mail_data_t *original_mail_data = NULL; - email_mailbox_t *outbox = NULL; - email_attachment_data_t *original_attachment_array = NULL; - - testapp_print("\n > Enter original mail id: "); - if (0 >= scanf("%d", &original_mail_id)) - testapp_print("Invalid input. "); - - /* Get original mail */ - if ((err = email_get_mail_data(original_mail_id, &original_mail_data)) != EMAIL_ERROR_NONE || !original_mail_data) { - testapp_print("email_get_mail_data failed [%d]\n", err); - return FALSE; - } + int err = EMAIL_ERROR_NONE; + int original_mail_id = 0; + int original_attachment_count = 0; + int i = 0; + int handle = 0; + char *plain_text_path = MAIL_TEMP_BODY; + char *html_file_path = HTML_TEMP_BODY; + char new_subject[4086] = { 0, }; + /* FILE *body_file; */ + email_mail_data_t *original_mail_data = NULL; + email_mailbox_t *outbox = NULL; + email_attachment_data_t *original_attachment_array = NULL; + + testapp_print("\n > Enter original mail id: "); + if (0 >= scanf("%d", &original_mail_id)) + testapp_print("Invalid input. "); + + /* Get original mail */ + if ((err = email_get_mail_data(original_mail_id, &original_mail_data)) != EMAIL_ERROR_NONE || !original_mail_data) { + testapp_print("email_get_mail_data failed [%d]\n", err); + return FALSE; + } - /* Get attachment of original mail */ - if ((err = email_get_attachment_data_list(original_mail_id, &original_attachment_array, &original_attachment_count)) != EMAIL_ERROR_NONE || !original_attachment_array) { - testapp_print("email_get_attachment_data_list failed [%d]\n", err); - return FALSE; - } + /* Get attachment of original mail */ + if ((err = email_get_attachment_data_list(original_mail_id, &original_attachment_array, &original_attachment_count)) != EMAIL_ERROR_NONE || !original_attachment_array) { + testapp_print("email_get_attachment_data_list failed [%d]\n", err); + return FALSE; + } - /* Remove attachment file path */ - for (i = 0; i < original_attachment_count; i++) { - original_attachment_array[i].save_status = 0; - if (original_attachment_array[i].attachment_path) - free(original_attachment_array[i].attachment_path); - original_attachment_array[i].attachment_path = NULL; - } + /* Remove attachment file path */ + for (i = 0; i < original_attachment_count; i++) { + original_attachment_array[i].save_status = 0; + if (original_attachment_array[i].attachment_path) + free(original_attachment_array[i].attachment_path); + original_attachment_array[i].attachment_path = NULL; + } - /* Set reference mail id */ - original_mail_data->reference_mail_id = original_mail_data->mail_id; - original_mail_data->body_download_status = 1; + /* Set reference mail id */ + original_mail_data->reference_mail_id = original_mail_data->mail_id; + original_mail_data->body_download_status = 1; - /* Set from address */ - if (!original_mail_data->full_address_from) { - original_mail_data->full_address_from = strdup("<abc@abc.com>"); - } + /* Set from address */ + if (!original_mail_data->full_address_from) { + original_mail_data->full_address_from = strdup("<abc@abc.com>"); + } - /* Rewrite subject */ - if (original_mail_data->subject) { - snprintf(new_subject, 4086, "Fw:%s", original_mail_data->subject); - free(original_mail_data->subject); - original_mail_data->subject = NULL; - } else { - snprintf(new_subject, 4086, "Forward test"); - } + /* Rewrite subject */ + if (original_mail_data->subject) { + snprintf(new_subject, 4086, "Fw:%s", original_mail_data->subject); + free(original_mail_data->subject); + original_mail_data->subject = NULL; + } else { + snprintf(new_subject, 4086, "Forward test"); + } - original_mail_data->subject = strdup(new_subject); + original_mail_data->subject = strdup(new_subject); - /* Set mailbox information */ - if ((err = email_get_mailbox_by_mailbox_type(original_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &outbox)) != EMAIL_ERROR_NONE || !outbox) { - testapp_print("email_get_mailbox_by_mailbox_type failed [%d]\n", err); - return FALSE; - } - original_mail_data->mailbox_id = outbox->mailbox_id; - original_mail_data->mailbox_type = outbox->mailbox_type; - - /* Copy body text */ - if (original_mail_data->file_path_html) { - copy_file(original_mail_data->file_path_html, html_file_path); - /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_html, html_file_path,(char *)0); */ - free(original_mail_data->file_path_html); - original_mail_data->file_path_html = strdup(html_file_path); - } + /* Set mailbox information */ + if ((err = email_get_mailbox_by_mailbox_type(original_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &outbox)) != EMAIL_ERROR_NONE || !outbox) { + testapp_print("email_get_mailbox_by_mailbox_type failed [%d]\n", err); + return FALSE; + } + original_mail_data->mailbox_id = outbox->mailbox_id; + original_mail_data->mailbox_type = outbox->mailbox_type; + + /* Copy body text */ + if (original_mail_data->file_path_html) { + copy_file(original_mail_data->file_path_html, html_file_path); + /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_html, html_file_path,(char *)0); */ + free(original_mail_data->file_path_html); + original_mail_data->file_path_html = strdup(html_file_path); + } - if (original_mail_data->file_path_plain) { - copy_file(original_mail_data->file_path_plain, plain_text_path); - /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_plain, plain_text_path,(char *)0);*/ - free(original_mail_data->file_path_plain); - original_mail_data->file_path_plain = strdup(plain_text_path); - } + if (original_mail_data->file_path_plain) { + copy_file(original_mail_data->file_path_plain, plain_text_path); + /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_plain, plain_text_path,(char *)0);*/ + free(original_mail_data->file_path_plain); + original_mail_data->file_path_plain = strdup(plain_text_path); + } - /* - body_file = fopen(body_file_path, "w"); + /* + body_file = fopen(body_file_path, "w"); - testapp_print("\n body_file [%p]\n", body_file); + testapp_print("\n body_file [%p]\n", body_file); - if (body_file == NULL) { - testapp_print("\n fopen [%s]failed\n", body_file_path); - return FALSE; - } + if (body_file == NULL) { + testapp_print("\n fopen [%s]failed\n", body_file_path); + return FALSE; + } - for (i = 0; i < 100; i++) - fprintf(body_file, "Mail sending Test. [%d]\n", i); + for (i = 0; i < 100; i++) + fprintf(body_file, "Mail sending Test. [%d]\n", i); - fflush(body_file); - fclose(body_file); - */ + fflush(body_file); + fclose(body_file); + */ - /* Add mail */ - if ((err = email_add_mail(original_mail_data, original_attachment_array, original_attachment_count, NULL, false)) != EMAIL_ERROR_NONE) { - testapp_print("email_get_attachment_data_list failed [%d]\n", err); - return FALSE; - } + /* Add mail */ + if ((err = email_add_mail(original_mail_data, original_attachment_array, original_attachment_count, NULL, false)) != EMAIL_ERROR_NONE) { + testapp_print("email_get_attachment_data_list failed [%d]\n", err); + return FALSE; + } - /* Send mail */ - if ((err = email_send_mail_with_downloading_attachment_of_original_mail(original_mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) { - testapp_print("email_send_mail_with_downloading_attachment_of_original_mail failed [%d]\n", err); - return FALSE; - } + /* Send mail */ + if ((err = email_send_mail_with_downloading_attachment_of_original_mail(original_mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) { + testapp_print("email_send_mail_with_downloading_attachment_of_original_mail failed [%d]\n", err); + return FALSE; + } - if (original_mail_data) - email_free_mail_data(&original_mail_data, 1); + if (original_mail_data) + email_free_mail_data(&original_mail_data, 1); - if (outbox) - email_free_mailbox(&outbox, 1); + if (outbox) + email_free_mailbox(&outbox, 1); - if (original_attachment_array) - email_free_attachment_data(&original_attachment_array, original_attachment_count); + if (original_attachment_array) + email_free_attachment_data(&original_attachment_array, original_attachment_count); - return TRUE; + return TRUE; } static gboolean testapp_test_get_mail_data() { - int err = EMAIL_ERROR_NONE; - int mail_id = 0; - email_mail_data_t *mail_data = NULL; + int err = EMAIL_ERROR_NONE; + int mail_id = 0; + email_mail_data_t *mail_data = NULL; - testapp_print("\n > Enter mail id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter mail id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); - /* Get original mail */ - if ((err = email_get_mail_data(mail_id, &mail_data)) != EMAIL_ERROR_NONE || !mail_data) { - testapp_print("email_get_mail_data failed [%d]\n", err); - return FALSE; - } + /* Get original mail */ + if ((err = email_get_mail_data(mail_id, &mail_data)) != EMAIL_ERROR_NONE || !mail_data) { + testapp_print("email_get_mail_data failed [%d]\n", err); + return FALSE; + } - testapp_print("mail_id [%d]\n", mail_data->mail_id); - testapp_print("account_id [%d]\n", mail_data->account_id); - testapp_print("mailbox_id [%d]\n", mail_data->mailbox_id); - testapp_print("mailbox_type [%d]\n", mail_data->mailbox_type); - if (mail_data->subject) - testapp_print("subject [%s]\n", mail_data->subject); - testapp_print("date_time [%d]\n", mail_data->date_time); - testapp_print("server_mail_status [%d]\n", mail_data->server_mail_status); + testapp_print("mail_id [%d]\n", mail_data->mail_id); + testapp_print("account_id [%d]\n", mail_data->account_id); + testapp_print("mailbox_id [%d]\n", mail_data->mailbox_id); + testapp_print("mailbox_type [%d]\n", mail_data->mailbox_type); + if (mail_data->subject) + testapp_print("subject [%s]\n", mail_data->subject); + testapp_print("date_time [%d]\n", mail_data->date_time); + testapp_print("server_mail_status [%d]\n", mail_data->server_mail_status); - if (mail_data->server_mailbox_name) - testapp_print("server_mailbox_name [%s]\n", mail_data->server_mailbox_name); + if (mail_data->server_mailbox_name) + testapp_print("server_mailbox_name [%s]\n", mail_data->server_mailbox_name); - if (mail_data->server_mail_id) - testapp_print("server_mail_id [%s]\n", mail_data->server_mail_id); + if (mail_data->server_mail_id) + testapp_print("server_mail_id [%s]\n", mail_data->server_mail_id); - if (mail_data->message_id) - testapp_print("message_id [%s]\n", mail_data->message_id); + if (mail_data->message_id) + testapp_print("message_id [%s]\n", mail_data->message_id); - testapp_print("reference_mail_id [%d]\n", mail_data->reference_mail_id); + testapp_print("reference_mail_id [%d]\n", mail_data->reference_mail_id); - if (mail_data->full_address_from) - testapp_print("full_address_from [%s]\n", mail_data->full_address_from); + if (mail_data->full_address_from) + testapp_print("full_address_from [%s]\n", mail_data->full_address_from); - if (mail_data->full_address_reply) - testapp_print("full_address_reply [%s]\n", mail_data->full_address_reply); + if (mail_data->full_address_reply) + testapp_print("full_address_reply [%s]\n", mail_data->full_address_reply); - if (mail_data->full_address_to) - testapp_print("full_address_to [%s]\n", mail_data->full_address_to); + if (mail_data->full_address_to) + testapp_print("full_address_to [%s]\n", mail_data->full_address_to); - if (mail_data->full_address_cc) - testapp_print("full_address_cc [%s]\n", mail_data->full_address_cc); + if (mail_data->full_address_cc) + testapp_print("full_address_cc [%s]\n", mail_data->full_address_cc); - if (mail_data->full_address_bcc) - testapp_print("full_address_bcc [%s]\n", mail_data->full_address_bcc); + if (mail_data->full_address_bcc) + testapp_print("full_address_bcc [%s]\n", mail_data->full_address_bcc); - if (mail_data->full_address_return) - testapp_print("full_address_return [%s]\n", mail_data->full_address_return); + if (mail_data->full_address_return) + testapp_print("full_address_return [%s]\n", mail_data->full_address_return); - if (mail_data->email_address_sender) - testapp_print("email_address_sender [%s]\n", mail_data->email_address_sender); + if (mail_data->email_address_sender) + testapp_print("email_address_sender [%s]\n", mail_data->email_address_sender); - if (mail_data->email_address_recipient) - testapp_print("email_address_recipient [%s]\n", mail_data->email_address_recipient); + if (mail_data->email_address_recipient) + testapp_print("email_address_recipient [%s]\n", mail_data->email_address_recipient); - if (mail_data->alias_sender) - testapp_print("alias_sender [%s]\n", mail_data->alias_sender); + if (mail_data->alias_sender) + testapp_print("alias_sender [%s]\n", mail_data->alias_sender); - if (mail_data->alias_recipient) - testapp_print("alias_recipient [%s]\n", mail_data->alias_recipient); + if (mail_data->alias_recipient) + testapp_print("alias_recipient [%s]\n", mail_data->alias_recipient); - testapp_print("body_download_status [%d]\n", mail_data->body_download_status); + testapp_print("body_download_status [%d]\n", mail_data->body_download_status); - if (mail_data->file_path_plain) - testapp_print("file_path_plain [%s]\n", mail_data->file_path_plain); + if (mail_data->file_path_plain) + testapp_print("file_path_plain [%s]\n", mail_data->file_path_plain); - if (mail_data->file_path_html) - testapp_print("file_path_html [%s]\n", mail_data->file_path_html); + if (mail_data->file_path_html) + testapp_print("file_path_html [%s]\n", mail_data->file_path_html); - testapp_print("file_path_mime_entity [%s]\n", mail_data->file_path_mime_entity); - testapp_print("mail_size [%d]\n", mail_data->mail_size); - testapp_print("flags_seen_field [%d]\n", mail_data->flags_seen_field); - testapp_print("flags_deleted_field [%d]\n", mail_data->flags_deleted_field); - testapp_print("flags_flagged_field [%d]\n", mail_data->flags_flagged_field); - testapp_print("flags_answered_field [%d]\n", mail_data->flags_answered_field); - testapp_print("flags_recent_field [%d]\n", mail_data->flags_recent_field); - testapp_print("flags_draft_field [%d]\n", mail_data->flags_draft_field); - testapp_print("flags_forwarded_field [%d]\n", mail_data->flags_forwarded_field); - testapp_print("DRM_status [%d]\n", mail_data->DRM_status); - testapp_print("priority [%d]\n", mail_data->priority); - testapp_print("save_status [%d]\n", mail_data->save_status); - testapp_print("lock_status [%d]\n", mail_data->lock_status); - testapp_print("report_status [%d]\n", mail_data->report_status); - testapp_print("attachment_count [%d]\n", mail_data->attachment_count); - testapp_print("inline_content_count [%d]\n", mail_data->inline_content_count); - testapp_print("thread_id [%d]\n", mail_data->thread_id); - testapp_print("thread_item_count [%d]\n", mail_data->thread_item_count); + testapp_print("file_path_mime_entity [%s]\n", mail_data->file_path_mime_entity); + testapp_print("mail_size [%d]\n", mail_data->mail_size); + testapp_print("flags_seen_field [%d]\n", mail_data->flags_seen_field); + testapp_print("flags_deleted_field [%d]\n", mail_data->flags_deleted_field); + testapp_print("flags_flagged_field [%d]\n", mail_data->flags_flagged_field); + testapp_print("flags_answered_field [%d]\n", mail_data->flags_answered_field); + testapp_print("flags_recent_field [%d]\n", mail_data->flags_recent_field); + testapp_print("flags_draft_field [%d]\n", mail_data->flags_draft_field); + testapp_print("flags_forwarded_field [%d]\n", mail_data->flags_forwarded_field); + testapp_print("DRM_status [%d]\n", mail_data->DRM_status); + testapp_print("priority [%d]\n", mail_data->priority); + testapp_print("save_status [%d]\n", mail_data->save_status); + testapp_print("lock_status [%d]\n", mail_data->lock_status); + testapp_print("report_status [%d]\n", mail_data->report_status); + testapp_print("attachment_count [%d]\n", mail_data->attachment_count); + testapp_print("inline_content_count [%d]\n", mail_data->inline_content_count); + testapp_print("thread_id [%d]\n", mail_data->thread_id); + testapp_print("thread_item_count [%d]\n", mail_data->thread_item_count); - if (mail_data->preview_text) - testapp_print("preview_text [%s]\n", mail_data->preview_text); + if (mail_data->preview_text) + testapp_print("preview_text [%s]\n", mail_data->preview_text); - testapp_print("meeting_request_status [%d]\n", mail_data->meeting_request_status); - testapp_print("message_class [%d]\n", mail_data->message_class); - testapp_print("digest_type [%d]\n", mail_data->digest_type); - testapp_print("smime_type [%d]\n", mail_data->smime_type); - testapp_print("scheduled_sending_time [%d]\n", mail_data->scheduled_sending_time); - testapp_print("remaining_resend_times [%d]\n", mail_data->remaining_resend_times); - testapp_print("eas_data_length [%d]\n", mail_data->eas_data_length); + testapp_print("meeting_request_status [%d]\n", mail_data->meeting_request_status); + testapp_print("message_class [%d]\n", mail_data->message_class); + testapp_print("digest_type [%d]\n", mail_data->digest_type); + testapp_print("smime_type [%d]\n", mail_data->smime_type); + testapp_print("scheduled_sending_time [%d]\n", mail_data->scheduled_sending_time); + testapp_print("remaining_resend_times [%d]\n", mail_data->remaining_resend_times); + testapp_print("eas_data_length [%d]\n", mail_data->eas_data_length); - return TRUE; + return TRUE; } static gboolean testapp_test_schedule_sending_mail() { - int added_mail_id = 0; - int err = EMAIL_ERROR_NONE; - int handle = 0; - time_t time_to_send; + int added_mail_id = 0; + int err = EMAIL_ERROR_NONE; + int handle = 0; + time_t time_to_send; - testapp_add_mail_for_sending(&added_mail_id); + testapp_add_mail_for_sending(&added_mail_id); - if (added_mail_id) { - time(&time_to_send); - time_to_send += 60; + if (added_mail_id) { + time(&time_to_send); + time_to_send += 60; - testapp_print("Calling email_schedule_sending_mail...\n"); + testapp_print("Calling email_schedule_sending_mail...\n"); - if (email_schedule_sending_mail(added_mail_id, time_to_send) < 0) { - testapp_print("email_schedule_sending_mail failed[%d]\n", err); - } else { - testapp_print("Start sending. handle[%d]\n", handle); - } - } + if (email_schedule_sending_mail(added_mail_id, time_to_send) < 0) { + testapp_print("email_schedule_sending_mail failed[%d]\n", err); + } else { + testapp_print("Start sending. handle[%d]\n", handle); + } + } - return TRUE; + return TRUE; } static gboolean testapp_test_set_flags_field() { - int account_id = 0; - int mail_id = 0; + int account_id = 0; + int mail_id = 0; - testapp_print("\n > Enter Account ID: "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter Account ID: "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); - testapp_print("\n > Enter Mail ID: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter Mail ID: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); - if (email_set_flags_field(account_id, &mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, 1, 1) < 0) - testapp_print("email_set_flags_field failed"); - else - testapp_print("email_set_flags_field success"); + if (email_set_flags_field(account_id, &mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, 1, 1) < 0) + testapp_print("email_set_flags_field failed"); + else + testapp_print("email_set_flags_field success"); - return TRUE; + return TRUE; } static gboolean testapp_test_download_body() { - int mail_id = 0; - int handle = 0, err; - - testapp_print("\n > Enter Mail Id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - err = email_download_body(mail_id, 0, &handle); - if (err < 0) - testapp_print("email_download_body failed"); - else { - testapp_print("email_download_body success"); - testapp_print("handle[%d]\n", handle); - } - return TRUE; + int mail_id = 0; + int handle = 0, err; + + testapp_print("\n > Enter Mail Id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + err = email_download_body(mail_id, 0, &handle); + if (err < 0) + testapp_print("email_download_body failed"); + else { + testapp_print("email_download_body success"); + testapp_print("handle[%d]\n", handle); + } + return TRUE; } static gboolean testapp_test_cancel_download_body() { - int mail_id = 0; - int account_id = 0; - int yes = 0; - int handle = 0; - - email_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(email_mailbox_t)); - - testapp_print("\n > Enter account_id: "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter mail id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - - if (email_download_body(mail_id, 0, &handle) < 0) - testapp_print("email_download_body failed"); - else { - testapp_print("email_download_body success\n"); - testapp_print("Do u want to cancel download job>>>>>1/0\n"); - if (0 >= scanf("%d", &yes)) - testapp_print("Invalid input. "); - if (1 == yes) { - if (email_cancel_job(account_id, handle , EMAIL_CANCELED_BY_USER) < 0) - testapp_print("email_cancel_job failed..!"); - else { - testapp_print("email_cancel_job success..!"); - testapp_print("handle[%d]\n", handle); - } - } + int mail_id = 0; + int account_id = 0; + int yes = 0; + int handle = 0; + + email_mailbox_t mailbox; + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); + + testapp_print("\n > Enter account_id: "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter mail id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + if (email_download_body(mail_id, 0, &handle) < 0) + testapp_print("email_download_body failed"); + else { + testapp_print("email_download_body success\n"); + testapp_print("Do u want to cancel download job>>>>>1/0\n"); + if (0 >= scanf("%d", &yes)) + testapp_print("Invalid input. "); + if (1 == yes) { + if (email_cancel_job(account_id, handle , EMAIL_CANCELED_BY_USER) < 0) + testapp_print("email_cancel_job failed..!"); + else { + testapp_print("email_cancel_job success..!"); + testapp_print("handle[%d]\n", handle); + } + } - } - return TRUE; + } + return TRUE; } static gboolean testapp_test_download_attachment() { - int mail_id = 0; - int attachment_no = 0; - int handle = 0; - - testapp_print("\n > Enter Mail Id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter attachment number: "); - if (0 >= scanf("%d", &attachment_no)) - testapp_print("Invalid input. "); - - if (email_download_attachment(mail_id, attachment_no, &handle) < 0) - testapp_print("email_download_attachment failed"); - else { - testapp_print("email_download_attachment success"); - testapp_print("handle[%d]\n", handle); - } - return TRUE; + int mail_id = 0; + int attachment_no = 0; + int handle = 0; + + testapp_print("\n > Enter Mail Id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter attachment number: "); + if (0 >= scanf("%d", &attachment_no)) + testapp_print("Invalid input. "); + + if (email_download_attachment(mail_id, attachment_no, &handle) < 0) + testapp_print("email_download_attachment failed"); + else { + testapp_print("email_download_attachment success"); + testapp_print("handle[%d]\n", handle); + } + return TRUE; } static gboolean testapp_test_get_attachment_data_list() { - int err = EMAIL_ERROR_NONE; - int i = 0; - int mail_id = 0; - int test_attachment_data_count; - email_attachment_data_t *test_attachment_data_list = NULL; - - testapp_print("\n > Enter Mail id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - - if ((err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE) { - testapp_print("email_get_attachment_data_list() failed [%d]\n", err); - goto FINISH_OFF; - } - if (test_attachment_data_list) { - for (i = 0; i < test_attachment_data_count; i++) { - testapp_print("index [%d]\n", i); - testapp_print("attachment_name [%s]\n", test_attachment_data_list[i].attachment_name); - testapp_print("attachment_path [%s]\n", test_attachment_data_list[i].attachment_path); - testapp_print("attachment_size [%d]\n", test_attachment_data_list[i].attachment_size); - testapp_print("mail_id [%d]\n", test_attachment_data_list[i].mail_id); - testapp_print("attachment_mime_type [%s]\n", test_attachment_data_list[i].attachment_mime_type); - } - email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count); - } + int err = EMAIL_ERROR_NONE; + int i = 0; + int mail_id = 0; + int test_attachment_data_count; + email_attachment_data_t *test_attachment_data_list = NULL; + + testapp_print("\n > Enter Mail id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + if ((err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE) { + testapp_print("email_get_attachment_data_list() failed [%d]\n", err); + goto FINISH_OFF; + } + if (test_attachment_data_list) { + for (i = 0; i < test_attachment_data_count; i++) { + testapp_print("index [%d]\n", i); + testapp_print("attachment_name [%s]\n", test_attachment_data_list[i].attachment_name); + testapp_print("attachment_path [%s]\n", test_attachment_data_list[i].attachment_path); + testapp_print("attachment_size [%d]\n", test_attachment_data_list[i].attachment_size); + testapp_print("mail_id [%d]\n", test_attachment_data_list[i].mail_id); + testapp_print("attachment_mime_type [%s]\n", test_attachment_data_list[i].attachment_mime_type); + } + email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count); + } FINISH_OFF: - return TRUE; + return TRUE; } static gboolean testapp_test_get_meeting_request() { - int mail_id = 0; - int err = EMAIL_ERROR_NONE; - email_meeting_request_t *meeting_request; + int mail_id = 0; + int err = EMAIL_ERROR_NONE; + email_meeting_request_t *meeting_request; - testapp_print("\n > Enter Mail Id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter Mail Id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); - err = email_get_meeting_request(mail_id, &meeting_request); + err = email_get_meeting_request(mail_id, &meeting_request); - testapp_print("err[%d]\n", err); + testapp_print("err[%d]\n", err); - if (err == EMAIL_ERROR_NONE && meeting_request) { - testapp_print("mail_id [%d]\n", meeting_request->mail_id); - testapp_print("global_object_id [%s]\n", meeting_request->global_object_id); - testapp_print("meeting_response [%d]\n", meeting_request->meeting_response); - } + if (err == EMAIL_ERROR_NONE && meeting_request) { + testapp_print("mail_id [%d]\n", meeting_request->mail_id); + testapp_print("global_object_id [%s]\n", meeting_request->global_object_id); + testapp_print("meeting_response [%d]\n", meeting_request->meeting_response); + } - email_free_meeting_request(&meeting_request, 1); - return TRUE; + email_free_meeting_request(&meeting_request, 1); + return TRUE; } static gboolean testapp_test_retry_send() { - int mail_id = 0; - int timeout = 0; + int mail_id = 0; + int timeout = 0; - email_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(email_mailbox_t)); + email_mailbox_t mailbox; + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); - testapp_print("\n > Enter Mail Id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter Mail Id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); - testapp_print("\n > Enter timeout in seconds: "); - if (0 >= scanf("%d", &timeout)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter timeout in seconds: "); + if (0 >= scanf("%d", &timeout)) + testapp_print("Invalid input. "); - if (email_retry_sending_mail(mail_id, timeout) < 0) - testapp_print("email_retry_sending_mail failed"); - return TRUE; + if (email_retry_sending_mail(mail_id, timeout) < 0) + testapp_print("email_retry_sending_mail failed"); + return TRUE; } static gboolean testapp_test_get_attachment_data() { - int attachment_id = 0; - email_attachment_data_t *attachment = NULL; + int attachment_id = 0; + email_attachment_data_t *attachment = NULL; - testapp_print("\n > Enter attachment id: "); - if (0 >= scanf("%d", &attachment_id)) - testapp_print("Invalid input. "); + testapp_print("\n > Enter attachment id: "); + if (0 >= scanf("%d", &attachment_id)) + testapp_print("Invalid input. "); - email_get_attachment_data(attachment_id, &attachment); + email_get_attachment_data(attachment_id, &attachment); - if (attachment) { - testapp_print("attachment_name [%s]\n", attachment->attachment_name); - testapp_print("attachment_path [%s]\n", attachment->attachment_path); - testapp_print("attachment_size [%d]\n", attachment->attachment_size); - testapp_print("mail_id [%d]\n", attachment->mail_id); - testapp_print("attachment_mime_type [%s]\n", attachment->attachment_mime_type); - } + if (attachment) { + testapp_print("attachment_name [%s]\n", attachment->attachment_name); + testapp_print("attachment_path [%s]\n", attachment->attachment_path); + testapp_print("attachment_size [%d]\n", attachment->attachment_size); + testapp_print("mail_id [%d]\n", attachment->mail_id); + testapp_print("attachment_mime_type [%s]\n", attachment->attachment_mime_type); + } - return TRUE; + return TRUE; } static gboolean testapp_test_move_all_mails_to_mailbox() { - int err = EMAIL_ERROR_NONE; - int src_mailbox_id; - int dest_mailbox_id; + int err = EMAIL_ERROR_NONE; + int src_mailbox_id; + int dest_mailbox_id; - testapp_print("src mailbox id> "); - if (0 >= scanf("%d", &src_mailbox_id)) - testapp_print("Invalid input. "); + testapp_print("src mailbox id> "); + if (0 >= scanf("%d", &src_mailbox_id)) + testapp_print("Invalid input. "); - testapp_print("dest mailbox id> "); - if (0 >= scanf("%d", &dest_mailbox_id)) - testapp_print("Invalid input. "); + testapp_print("dest mailbox id> "); + if (0 >= scanf("%d", &dest_mailbox_id)) + testapp_print("Invalid input. "); - err = email_move_all_mails_to_mailbox(src_mailbox_id, dest_mailbox_id); - if (err < 0) { - testapp_print("email_move_all_mails_to_mailbox failed: err[%d]\n", err); - } else { - testapp_print("email_move_all_mails_to_mailbox suceeded\n"); - } + err = email_move_all_mails_to_mailbox(src_mailbox_id, dest_mailbox_id); + if (err < 0) { + testapp_print("email_move_all_mails_to_mailbox failed: err[%d]\n", err); + } else { + testapp_print("email_move_all_mails_to_mailbox suceeded\n"); + } - return false; + return false; } static gboolean testapp_test_get_totaldiskusage() { - unsigned long total_size = 0; - int err_code = EMAIL_ERROR_NONE ; + unsigned long total_size = 0; + int err_code = EMAIL_ERROR_NONE ; - err_code = email_get_disk_space_usage(&total_size); - if (err_code < 0) - testapp_print("email_get_disk_space_usage failed err : %d\n", err_code); - else - testapp_print("email_get_disk_space_usage SUCCESS, total disk usage in KB : %ld \n", total_size); + err_code = email_get_disk_space_usage(&total_size); + if (err_code < 0) + testapp_print("email_get_disk_space_usage failed err : %d\n", err_code); + else + testapp_print("email_get_disk_space_usage SUCCESS, total disk usage in KB : %ld \n", total_size); - return FALSE; + return FALSE; } static gboolean testapp_test_db_test() { - int err = EMAIL_ERROR_NONE; - int mail_id; - int account_id; - char *to = NULL; - char *cc = NULL; - char *bcc = NULL; - - to = (char *)malloc(500000); - cc = (char *)malloc(500000); - bcc = (char *)malloc(500000); - - memset(to, 0x00, sizeof(500000)); - memset(cc, 0x00, sizeof(500000)); - memset(bcc, 0x00, sizeof(500000)); - - testapp_print("Input Mail id:\n"); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - testapp_print("Input Account id:\n"); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - testapp_print("Input TO field:\n"); - if (0 >= scanf("%s", to)) - testapp_print("Invalid input. "); - testapp_print("Input CC field:\n"); - if (0 >= scanf("%s", cc)) - testapp_print("Invalid input. "); - testapp_print("Input BCC field:\n"); - if (0 >= scanf("%s", bcc)) - testapp_print("Invalid input. "); - - if (emstorage_test(NULL, mail_id, account_id, to, cc, bcc, &err) == true) { - testapp_print(">> Saving Succeeded\n"); - } else { - testapp_print(">> Saving Failed[%d]\n", err); - } + int err = EMAIL_ERROR_NONE; + int mail_id; + int account_id; + char *to = NULL; + char *cc = NULL; + char *bcc = NULL; + + to = (char *)malloc(500000); + cc = (char *)malloc(500000); + bcc = (char *)malloc(500000); + + memset(to, 0x00, sizeof(500000)); + memset(cc, 0x00, sizeof(500000)); + memset(bcc, 0x00, sizeof(500000)); + + testapp_print("Input Mail id:\n"); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + testapp_print("Input Account id:\n"); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + testapp_print("Input TO field:\n"); + if (0 >= scanf("%s", to)) + testapp_print("Invalid input. "); + testapp_print("Input CC field:\n"); + if (0 >= scanf("%s", cc)) + testapp_print("Invalid input. "); + testapp_print("Input BCC field:\n"); + if (0 >= scanf("%s", bcc)) + testapp_print("Invalid input. "); + + if (emstorage_test(NULL, mail_id, account_id, to, cc, bcc, &err) == true) { + testapp_print(">> Saving Succeeded\n"); + } else { + testapp_print(">> Saving Failed[%d]\n", err); + } - free(to); - free(cc); - free(bcc); + free(to); + free(cc); + free(bcc); - return false; + return false; } static gboolean testapp_test_address_format_check_test() { - /* - int i; - int type; - int index; - int check_yn; - int err = EMAIL_ERROR_NONE; - char *pAddress = NULL; - char input_address[8096]; - char *address_list[] = { - "tom@gmail.com", - "tom@gmail,com", - "tom@gmail.com@gmail.com", - "[tom@gmail.com]", - "\"Tom\"<tom@gmail.com>", - "\"Tom\"[tom@gmail.com]", - "\"Tom\"<tom,@gmail.com>", - "<tom@gmail.com>", - "<tom@gmail,com>", - "<tom@gmail.>", - "<tom@gmail.com>,tom@gmail.com", - "<tom@gmail.com>;tom@gmail.com", - "tom @gmail.com", - "tom@ gmail.com", - "tom@gmail..com", - "tom@", - "tom@gmail", - "tom@gmail.", - "tom@gmail.c", - "tom@.", - "\"\"Tom\"<tom,@gmail.com>", - "tom@gmail.com,tom@gmail.com", - "tom@gmail.com.", - "<tom@gmail.com>,tom@.gmail.com", - "&& tom@live.com ----", - "madhu <tom@gmail.com>", - "tom@gmail.com, && tom@live.com", - "tom@gmail.com , && tom@live.com", - "< tom@gmail.com > , < tom@.gmail.com >", - "tom@gmail.com , tom@gmail.com", - "<tom@gmail.com >", - "<to m@gmail.com >", - "<tom@gmail.com>;tom@gmail.com", - "Tom< tom@gmail.com > , Tom <tom@gmail.com>", - " \"Tom\" < tom@gmail.com> , \"Tom\" < tom@gmail.com> , Tom < tom@gmail.com> ; Tom < tom@gmail.com>,\"tomtom\" < tom@aol.com>,\"tomtom\" < tom@aol.com> ,\"tomtom\" <tom@aol.com>;<tom@live.com>, <tom@live.com>; \"tomtomtomtom\" <tom@live.com> ; \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com>", - "<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>", - " tom@gmail.com ; < tom@gmail.com > ", - "\"Tom\" < tom@gmail.com > ; mama < tom@gmail.com > , abcd@gmail.com , abc@gmail.com ,\"tomtom\" <tom@aol.com>,\"tomtom\" < tom@aol.com> ;\"tomtom\" < tom@aol.com > ,\"tomtom\" <tom@aol.com> , \"tomtomtomtom\" <tom@live.com> ", - " \"tomtom\" <tom@aol.com> ;\"tomtom\" <tom@aol.com> ; ", - " tom@gmail.com , tom@gmail.com , tom@gmail.com; Tom < tom@gmail.com > ,< tom@aol.com>, <tom@aol.com> ,<tom@aol.com>;<tom@live.com>, tom@live.com;tom@live.com; \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com> ; ", - "<tom@aol.com> , \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com> ; ", - " Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom < tom@gmail.com> ,<tom@gmail.com>,Tom <tom@gmail.com >,Tom< tom@gmail.com > , Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>", - NULL - }; - int address_count = 0; - - testapp_print("Select input method:\n"); - testapp_print("1. Test data\n"); - testapp_print("2. Keyboard\n"); - if (0 >= scanf("%d", &type); - - switch (type) { - case 1: - do { - for (i = 0; address_list[i] != NULL; i++) { - testapp_print("[%d] addr[%s]\n", i, address_list[i]); - address_count++; - } - testapp_print("Choose address to be tested:[99:quit]\n"); - if (0 >= scanf("%d", &index); - if (index == 99 ) - break; - - testapp_print(">> [%d] Checking?(1:Yes, Other:No) [%s]\n", index, address_list[index]); - if (0 >= scanf("%d", &check_yn); - if (check_yn == 1) { - pAddress = strdup(address_list[index]); - if (em_verify_email_address(pAddress, false, &err ) == true) { - testapp_print("<< [%d] Checking Succeeded : addr[%s]\n", index, address_list[index]); - } - else { - testapp_print("<< [%d] Checking Failed : addr[%s], err[%d]\n", index, address_list[index], err); - } - if (pAddress) { - free(pAddress); - pAddress = NULL; - } - } - else { - testapp_print("<< [%d] Skipped : addr[%s]\n", index, address_list[index]); - } - } - while (1); - break; - case 2: - testapp_print("Input address: \n"); - if (0 >= scanf("%s", input_address); - if (em_verify_email_address(input_address, false, &err ) == true) { - testapp_print(">> Saving Succeeded : addr[%s]\n", input_address); - } - else { - testapp_print(">> Saving Failed : addr[%s], err[%d]\n", input_address, err); - } - break; - default: - testapp_print("wrong nuber... [%d]\n", type); - break; - } - */ - return FALSE; -} - -static gboolean testapp_test_get_max_mail_count() -{ - int max_count = -1; - int err = EMAIL_ERROR_NONE; - - err = email_get_max_mail_count(&max_count); - testapp_print("\n\t>>>>> email_get_max_mail_count() return [%d][%d]\n\n", max_count, err); - - return TRUE; -} + /* + int i; + int type; + int index; + int check_yn; + int err = EMAIL_ERROR_NONE; + char *pAddress = NULL; + char input_address[8096]; + char *address_list[] = { + "tom@gmail.com", + "tom@gmail,com", + "tom@gmail.com@gmail.com", + "[tom@gmail.com]", + "\"Tom\"<tom@gmail.com>", + "\"Tom\"[tom@gmail.com]", + "\"Tom\"<tom,@gmail.com>", + "<tom@gmail.com>", + "<tom@gmail,com>", + "<tom@gmail.>", + "<tom@gmail.com>,tom@gmail.com", + "<tom@gmail.com>;tom@gmail.com", + "tom @gmail.com", + "tom@ gmail.com", + "tom@gmail..com", + "tom@", + "tom@gmail", + "tom@gmail.", + "tom@gmail.c", + "tom@.", + "\"\"Tom\"<tom,@gmail.com>", + "tom@gmail.com,tom@gmail.com", + "tom@gmail.com.", + "<tom@gmail.com>,tom@.gmail.com", + "&& tom@live.com ----", + "madhu <tom@gmail.com>", + "tom@gmail.com, && tom@live.com", + "tom@gmail.com , && tom@live.com", + "< tom@gmail.com > , < tom@.gmail.com >", + "tom@gmail.com , tom@gmail.com", + "<tom@gmail.com >", + "<to m@gmail.com >", + "<tom@gmail.com>;tom@gmail.com", + "Tom< tom@gmail.com > , Tom <tom@gmail.com>", + " \"Tom\" < tom@gmail.com> , \"Tom\" < tom@gmail.com> , Tom < tom@gmail.com> ; Tom < tom@gmail.com>,\"tomtom\" < tom@aol.com>,\"tomtom\" < tom@aol.com> ,\"tomtom\" <tom@aol.com>;<tom@live.com>, <tom@live.com>; \"tomtomtomtom\" <tom@live.com> ; \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com>", + "<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>", + " tom@gmail.com ; < tom@gmail.com > ", + "\"Tom\" < tom@gmail.com > ; mama < tom@gmail.com > , abcd@gmail.com , abc@gmail.com ,\"tomtom\" <tom@aol.com>,\"tomtom\" < tom@aol.com> ;\"tomtom\" < tom@aol.com > ,\"tomtom\" <tom@aol.com> , \"tomtomtomtom\" <tom@live.com> ", + " \"tomtom\" <tom@aol.com> ;\"tomtom\" <tom@aol.com> ; ", + " tom@gmail.com , tom@gmail.com , tom@gmail.com; Tom < tom@gmail.com > ,< tom@aol.com>, <tom@aol.com> ,<tom@aol.com>;<tom@live.com>, tom@live.com;tom@live.com; \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com> ; ", + "<tom@aol.com> , \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com> ; ", + " Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom < tom@gmail.com> ,<tom@gmail.com>,Tom <tom@gmail.com >,Tom< tom@gmail.com > , Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>", + NULL + }; + int address_count = 0; + + testapp_print("Select input method:\n"); + testapp_print("1. Test data\n"); + testapp_print("2. Keyboard\n"); + if (0 >= scanf("%d", &type); + + switch (type) { + case 1: + do { + for (i = 0; address_list[i] != NULL; i++) { + testapp_print("[%d] addr[%s]\n", i, address_list[i]); + address_count++; + } + testapp_print("Choose address to be tested:[99:quit]\n"); + if (0 >= scanf("%d", &index); + if (index == 99 ) + break; + + testapp_print(">> [%d] Checking?(1:Yes, Other:No) [%s]\n", index, address_list[index]); + if (0 >= scanf("%d", &check_yn); + if (check_yn == 1) { + pAddress = strdup(address_list[index]); + if (em_verify_email_address(pAddress, false, &err ) == true) { + testapp_print("<< [%d] Checking Succeeded : addr[%s]\n", index, address_list[index]); + } + else { + testapp_print("<< [%d] Checking Failed : addr[%s], err[%d]\n", index, address_list[index], err); + } + if (pAddress) { + free(pAddress); + pAddress = NULL; + } + } + else { + testapp_print("<< [%d] Skipped : addr[%s]\n", index, address_list[index]); + } + } + while (1); + break; + case 2: + testapp_print("Input address: \n"); + if (0 >= scanf("%s", input_address); + if (em_verify_email_address(input_address, false, &err ) == true) { + testapp_print(">> Saving Succeeded : addr[%s]\n", input_address); + } + else { + testapp_print(">> Saving Failed : addr[%s], err[%d]\n", input_address, err); + } + break; + default: + testapp_print("wrong nuber... [%d]\n", type); + break; + } + */ + return FALSE; + } + + static gboolean testapp_test_get_max_mail_count() + { + int max_count = -1; + int err = EMAIL_ERROR_NONE; + + err = email_get_max_mail_count(&max_count); + testapp_print("\n\t>>>>> email_get_max_mail_count() return [%d][%d]\n\n", max_count, err); + + return TRUE; + } #include "email-storage.h" static gboolean testapp_test_test_get_thread_information() { - int error_code, thread_id = 38; - email_mail_list_item_t *result_mail; - - if ((error_code = email_get_thread_information_ex(thread_id, &result_mail)) == EMAIL_ERROR_NONE) { - testapp_print("email_get_thread_information returns = %d\n", error_code); - testapp_print("subject = %s\n", result_mail->subject); - testapp_print("mail_id = %d\n", result_mail->mail_id); - testapp_print("full_address_from = %s\n", result_mail->full_address_from); - testapp_print("thrad_id = %d\n", result_mail->thread_id); - testapp_print("count = %d\n", result_mail->thread_item_count); - } + int error_code, thread_id = 38; + email_mail_list_item_t *result_mail; + + if ((error_code = email_get_thread_information_ex(thread_id, &result_mail)) == EMAIL_ERROR_NONE) { + testapp_print("email_get_thread_information returns = %d\n", error_code); + testapp_print("subject = %s\n", result_mail->subject); + testapp_print("mail_id = %d\n", result_mail->mail_id); + testapp_print("full_address_from = %s\n", result_mail->full_address_from); + testapp_print("thrad_id = %d\n", result_mail->thread_id); + testapp_print("count = %d\n", result_mail->thread_item_count); + } - return TRUE; + return TRUE; } static gboolean testapp_test_get_address_info_list() { - testapp_print(" >>> testapp_test_get_address_info_list : Entered \n"); - - char buf[1024]; - int i = 0; - int mail_id = 0; - email_address_info_list_t *address_info_list = NULL; - email_address_info_t *p_address_info = NULL; - GList *list = NULL; - GList *node = NULL; - - memset(buf, 0x00, sizeof(buf)); - testapp_print("\n > Enter mail_id: "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print(" >>> testapp_test_get_address_info_list : Entered \n"); + + char buf[1024]; + int i = 0; + int mail_id = 0; + email_address_info_list_t *address_info_list = NULL; + email_address_info_t *p_address_info = NULL; + GList *list = NULL; + GList *node = NULL; + + memset(buf, 0x00, sizeof(buf)); + testapp_print("\n > Enter mail_id: "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + email_get_address_info_list(mail_id, &address_info_list); + + testapp_print("===================================================\n"); + testapp_print("\t\t\t address info list\n"); + testapp_print("===================================================\n"); + testapp_print("address_type\t address \t\tdisplay_name\t contact id\n"); + testapp_print("===================================================\n"); + + for (i = EMAIL_ADDRESS_TYPE_FROM; i <= EMAIL_ADDRESS_TYPE_BCC; i++) { + switch (i) { + case EMAIL_ADDRESS_TYPE_FROM: + list = address_info_list->from; + break; + case EMAIL_ADDRESS_TYPE_TO: + list = address_info_list->to; + break; + case EMAIL_ADDRESS_TYPE_CC: + list = address_info_list->cc; + break; + case EMAIL_ADDRESS_TYPE_BCC: + list = address_info_list->bcc; + break; + } - email_get_address_info_list(mail_id, &address_info_list); - - testapp_print("===================================================\n"); - testapp_print("\t\t\t address info list\n"); - testapp_print("===================================================\n"); - testapp_print("address_type\t address \t\tdisplay_name\t contact id\n"); - testapp_print("===================================================\n"); - - for (i = EMAIL_ADDRESS_TYPE_FROM; i <= EMAIL_ADDRESS_TYPE_BCC; i++) { - switch (i) { - case EMAIL_ADDRESS_TYPE_FROM: - list = address_info_list->from; - break; - case EMAIL_ADDRESS_TYPE_TO: - list = address_info_list->to; - break; - case EMAIL_ADDRESS_TYPE_CC: - list = address_info_list->cc; - break; - case EMAIL_ADDRESS_TYPE_BCC: - list = address_info_list->bcc; - break; - } - - /* delete dynamic-allocated memory for each item */ - node = g_list_first(list); - while (node != NULL) { - p_address_info = (email_address_info_t *)node->data; - testapp_print("%d\t\t%s\t%s\t%d\n", p_address_info->address_type, p_address_info->address, p_address_info->display_name, p_address_info->contact_id); - - node = g_list_next(node); - } - testapp_print("\n"); - } - testapp_print("===================================================\n"); + /* delete dynamic-allocated memory for each item */ + node = g_list_first(list); + while (node != NULL) { + p_address_info = (email_address_info_t *)node->data; + testapp_print("%d\t\t%s\t%s\t%d\n", p_address_info->address_type, p_address_info->address, p_address_info->display_name, p_address_info->contact_id); + + node = g_list_next(node); + } + testapp_print("\n"); + } + testapp_print("===================================================\n"); - if (address_info_list) - email_free_address_info_list(&address_info_list); + if (address_info_list) + email_free_address_info_list(&address_info_list); - testapp_print(" >>> testapp_test_get_address_info_list : END \n"); - return TRUE; + testapp_print(" >>> testapp_test_get_address_info_list : END \n"); + return TRUE; } static gboolean testapp_test_search_mail_on_server() { - testapp_print(" >>> testapp_test_search_mail_on_server : Entered \n"); - - int err_code = EMAIL_ERROR_NONE; - int account_id = 0; - int mailbox_id = 0; - int search_key_value_integer = 0; - int search_filter_count = 0; - email_search_filter_type search_filter_type = 0; - email_search_filter_t search_filter[10]; - int handle = 0; - time_t current_time = 0; - char search_key_value_string[256]; - - testapp_print("input account id : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); + testapp_print(" >>> testapp_test_search_mail_on_server : Entered \n"); + + int err_code = EMAIL_ERROR_NONE; + int account_id = 0; + int mailbox_id = 0; + int search_key_value_integer = 0; + int search_filter_count = 0; + email_search_filter_type search_filter_type = 0; + email_search_filter_t search_filter[10]; + int handle = 0; + time_t current_time = 0; + char search_key_value_string[256]; + + testapp_print("input account id : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("input mailbox id : "); + if (0 >= scanf("%d", &mailbox_id)) + testapp_print("Invalid input. "); + + memset(&search_filter, 0x00, sizeof(email_search_filter_t) * 10); + + while (1) { + testapp_print( + " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_UID = 2, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_ALL = 3, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_BCC = 7, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_BODY = 8, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_CC = 9, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FROM = 10, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_TEXT = 12, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_TO = 15, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, (integet type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER = 17, (integet type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE = 20, (time type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, (time type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, (time type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW = 27, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD = 29, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, (integer type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, (string type ) \n" + " EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, (string type ) \n" + " END = 0 \n"); + + testapp_print("input search filter type : "); + if (0 >= scanf("%d", (int *)&search_filter_type)) + testapp_print("Invalid input. "); + + search_filter[search_filter_count].search_filter_type = search_filter_type; + + switch (search_filter_type) { + case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO: + case EMAIL_SEARCH_FILTER_TYPE_UID: + case EMAIL_SEARCH_FILTER_TYPE_ALL: + case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER: + case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT: + case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN: + case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY: + testapp_print("input search filter key value : "); + if (0 >= scanf("%d", &search_key_value_integer)) + testapp_print("Invalid input. "); + search_filter[search_filter_count].search_filter_key_value.integer_type_key_value = search_key_value_integer; + break; + + case EMAIL_SEARCH_FILTER_TYPE_BCC: + case EMAIL_SEARCH_FILTER_TYPE_BODY: + case EMAIL_SEARCH_FILTER_TYPE_CC: + case EMAIL_SEARCH_FILTER_TYPE_FROM: + case EMAIL_SEARCH_FILTER_TYPE_KEYWORD: + case EMAIL_SEARCH_FILTER_TYPE_TEXT: + case EMAIL_SEARCH_FILTER_TYPE_SUBJECT: + case EMAIL_SEARCH_FILTER_TYPE_TO: + case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID: + case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME: + case EMAIL_SEARCH_FILTER_TYPE_CHARSET: + case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED: + testapp_print("input search filter key value : "); + int readn = read(0, search_key_value_string, 256); + if (readn < 0) + testapp_print("Invalid input. "); + + search_filter[search_filter_count].search_filter_key_value.string_type_key_value = strndup(search_key_value_string, readn - 1); + break; + + case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE: + case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON: + case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE: + time(¤t_time); + /* TODO : write codes for converting string to time */ + /* search_filter.search_filter_key_value.time_type_key_value = search_key_value_string; */ + search_filter[search_filter_count].search_filter_key_value.time_type_key_value = current_time; + break; + default: + testapp_print("END filter type [%d]", search_filter_type); + break; + } - testapp_print("input mailbox id : "); - if (0 >= scanf("%d", &mailbox_id)) - testapp_print("Invalid input. "); + if (!search_filter_type) + break; - memset(&search_filter, 0x00, sizeof(email_search_filter_t) * 10); - - while (1) { - testapp_print( - " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_UID = 2, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_ALL = 3, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_BCC = 7, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_BODY = 8, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_CC = 9, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FROM = 10, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_TEXT = 12, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_TO = 15, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, (integet type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER = 17, (integet type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE = 20, (time type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, (time type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, (time type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW = 27, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD = 29, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, (integer type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, (string type ) \n" - " EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, (string type ) \n" - " END = 0 \n"); - - testapp_print("input search filter type : "); - if (0 >= scanf("%d", (int *)&search_filter_type)) - testapp_print("Invalid input. "); - - search_filter[search_filter_count].search_filter_type = search_filter_type; - - switch (search_filter_type) { - case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO: - case EMAIL_SEARCH_FILTER_TYPE_UID: - case EMAIL_SEARCH_FILTER_TYPE_ALL: - case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER: - case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT: - case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN: - case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY: - testapp_print("input search filter key value : "); - if (0 >= scanf("%d", &search_key_value_integer)) - testapp_print("Invalid input. "); - search_filter[search_filter_count].search_filter_key_value.integer_type_key_value = search_key_value_integer; - break; - - case EMAIL_SEARCH_FILTER_TYPE_BCC: - case EMAIL_SEARCH_FILTER_TYPE_BODY: - case EMAIL_SEARCH_FILTER_TYPE_CC: - case EMAIL_SEARCH_FILTER_TYPE_FROM: - case EMAIL_SEARCH_FILTER_TYPE_KEYWORD: - case EMAIL_SEARCH_FILTER_TYPE_TEXT: - case EMAIL_SEARCH_FILTER_TYPE_SUBJECT: - case EMAIL_SEARCH_FILTER_TYPE_TO: - case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID: - case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME: - case EMAIL_SEARCH_FILTER_TYPE_CHARSET: - case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED: - testapp_print("input search filter key value : "); - int readn = read(0, search_key_value_string, 256); - if (readn < 0) - testapp_print("Invalid input. "); - - search_filter[search_filter_count].search_filter_key_value.string_type_key_value = strndup(search_key_value_string, readn - 1); - break; - - case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE: - case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON: - case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE: - time(¤t_time); - /* TODO : write codes for converting string to time */ - /* search_filter.search_filter_key_value.time_type_key_value = search_key_value_string; */ - search_filter[search_filter_count].search_filter_key_value.time_type_key_value = current_time; - break; - default: - testapp_print("END filter type [%d]", search_filter_type); - break; - } - - if (!search_filter_type) - break; - - search_filter_count++; - } + search_filter_count++; + } - if ((err_code = email_search_mail_on_server(account_id, mailbox_id, search_filter, search_filter_count, &handle)) != EMAIL_ERROR_NONE) { - testapp_print("email_search_mail_on_server failed [%d]", err_code); - } + if ((err_code = email_search_mail_on_server(account_id, mailbox_id, search_filter, search_filter_count, &handle)) != EMAIL_ERROR_NONE) { + testapp_print("email_search_mail_on_server failed [%d]", err_code); + } - testapp_print(" >>> testapp_test_search_mail_on_server : END \n"); - return TRUE; + testapp_print(" >>> testapp_test_search_mail_on_server : END \n"); + return TRUE; } static gboolean testapp_test_add_mail_to_search_result_box() { - int i = 0; - int account_id = 0; - int from_eas = 0; - int attachment_count = 0; - int err = EMAIL_ERROR_NONE; - char arg[50] = { 0 , }; - char *body_file_path = MAIL_TEMP_BODY; - email_mailbox_t *mailbox_data = NULL; - email_mail_data_t *test_mail_data = NULL; - email_attachment_data_t *attachment_data = NULL; - email_meeting_request_t *meeting_req = NULL; - FILE *body_file = NULL; - - testapp_print("\n > Enter account id : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &mailbox_data); - - test_mail_data = malloc(sizeof(email_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); - - testapp_print("\n From EAS? [0/1]> "); - if (0 >= scanf("%d", &from_eas)) - testapp_print("Invalid input. "); - - test_mail_data->account_id = account_id; - test_mail_data->save_status = 1; - test_mail_data->body_download_status = 1; - test_mail_data->flags_seen_field = 1; - test_mail_data->file_path_plain = strdup(body_file_path); - test_mail_data->mailbox_id = mailbox_data->mailbox_id; - test_mail_data->mailbox_type = mailbox_data->mailbox_type; - test_mail_data->full_address_from = strdup("<test1@test.com>"); - test_mail_data->full_address_to = strdup("<test2@test.com>"); - test_mail_data->full_address_cc = strdup("<test3@test.com>"); - test_mail_data->full_address_bcc = strdup("<test4@test.com>"); - test_mail_data->subject = strdup("Into search result mailbox"); - test_mail_data->remaining_resend_times = 3; - - body_file = fopen(body_file_path, "w"); - - for (i = 0; i < 500; i++) - fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); - fflush(body_file); - fclose(body_file); - - testapp_print(" > Attach file? [0/1] : "); - if (0 >= scanf("%d", &attachment_count)) - testapp_print("Invalid input. "); - - if (attachment_count) { - memset(arg, 0x00, 50); - testapp_print("\n > Enter attachment name : "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); - - attachment_data = malloc(sizeof(email_attachment_data_t)); - - attachment_data->attachment_name = strdup(arg); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter attachment absolute path : "); - if (0 >= scanf("%s", arg)) - testapp_print("Invalid input. "); - - attachment_data->attachment_path = strdup(arg); - attachment_data->save_status = 1; - test_mail_data->attachment_count = attachment_count; - } + int i = 0; + int account_id = 0; + int from_eas = 0; + int attachment_count = 0; + int err = EMAIL_ERROR_NONE; + char arg[50] = { 0 , }; + char *body_file_path = MAIL_TEMP_BODY; + email_mailbox_t *mailbox_data = NULL; + email_mail_data_t *test_mail_data = NULL; + email_attachment_data_t *attachment_data = NULL; + email_meeting_request_t *meeting_req = NULL; + FILE *body_file = NULL; + + testapp_print("\n > Enter account id : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &mailbox_data); + + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); + + testapp_print("\n From EAS? [0/1]> "); + if (0 >= scanf("%d", &from_eas)) + testapp_print("Invalid input. "); + + test_mail_data->account_id = account_id; + test_mail_data->save_status = 1; + test_mail_data->body_download_status = 1; + test_mail_data->flags_seen_field = 1; + test_mail_data->file_path_plain = strdup(body_file_path); + test_mail_data->mailbox_id = mailbox_data->mailbox_id; + test_mail_data->mailbox_type = mailbox_data->mailbox_type; + test_mail_data->full_address_from = strdup("<test1@test.com>"); + test_mail_data->full_address_to = strdup("<test2@test.com>"); + test_mail_data->full_address_cc = strdup("<test3@test.com>"); + test_mail_data->full_address_bcc = strdup("<test4@test.com>"); + test_mail_data->subject = strdup("Into search result mailbox"); + test_mail_data->remaining_resend_times = 3; + + body_file = fopen(body_file_path, "w"); + + for (i = 0; i < 500; i++) + fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2"); + fflush(body_file); + fclose(body_file); + + testapp_print(" > Attach file? [0/1] : "); + if (0 >= scanf("%d", &attachment_count)) + testapp_print("Invalid input. "); + + if (attachment_count) { + memset(arg, 0x00, 50); + testapp_print("\n > Enter attachment name : "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); + + attachment_data = malloc(sizeof(email_attachment_data_t)); + if (attachment_data) { + attachment_data->attachment_name = strdup(arg); + } - testapp_print("\n > Meeting Request? [0: no, 1: yes(request from server), 2: yes(response from local)]"); - if (0 >= scanf("%d", (int *)&(test_mail_data->meeting_request_status))) - testapp_print("Invalid input. "); + memset(arg, 0x00, 50); + testapp_print("\n > Enter attachment absolute path : "); + if (0 >= scanf("%s", arg)) + testapp_print("Invalid input. "); + if (attachment_data) { + attachment_data->attachment_path = strdup(arg); + attachment_data->save_status = 1; + } + test_mail_data->attachment_count = attachment_count; + } - if (test_mail_data->meeting_request_status == 1 - || test_mail_data->meeting_request_status == 2) { - time_t current_time; - /* dummy data for meeting request */ - meeting_req = malloc(sizeof(email_meeting_request_t)); - memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); - - meeting_req->meeting_response = 1; - current_time = time(NULL); - gmtime_r(¤t_time, &(meeting_req->start_time)); - gmtime_r(¤t_time, &(meeting_req->end_time)); - meeting_req->location = malloc(strlen("Seoul") + 1); - memset(meeting_req->location, 0x00, strlen("Seoul") + 1); - strcpy(meeting_req->location, "Seoul"); - strcpy(meeting_req->global_object_id, "abcdef12345"); - - meeting_req->time_zone.offset_from_GMT = 9; - strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); - gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date)); - meeting_req->time_zone.standard_bias = 3; - - strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME"); - gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date)); - meeting_req->time_zone.daylight_bias = 7; + testapp_print("\n > Meeting Request? [0: no, 1: yes(request from server), 2: yes(response from local)]"); + if (0 >= scanf("%d", (int *)&(test_mail_data->meeting_request_status))) + testapp_print("Invalid input. "); + + if (test_mail_data->meeting_request_status == 1 + || test_mail_data->meeting_request_status == 2) { + time_t current_time; + /* dummy data for meeting request */ + meeting_req = malloc(sizeof(email_meeting_request_t)); + memset(meeting_req, 0x00, sizeof(email_meeting_request_t)); + + meeting_req->meeting_response = 1; + current_time = time(NULL); + gmtime_r(¤t_time, &(meeting_req->start_time)); + gmtime_r(¤t_time, &(meeting_req->end_time)); + meeting_req->location = malloc(strlen("Seoul") + 1); + memset(meeting_req->location, 0x00, strlen("Seoul") + 1); + strcpy(meeting_req->location, "Seoul"); + strcpy(meeting_req->global_object_id, "abcdef12345"); + + meeting_req->time_zone.offset_from_GMT = 9; + strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME"); + gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date)); + meeting_req->time_zone.standard_bias = 3; + + strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME"); + gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date)); + meeting_req->time_zone.daylight_bias = 7; - } + } - if ((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) - testapp_print("email_add_mail failed. [%d]\n", err); - else - testapp_print("email_add_mail success.\n"); + if ((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE) + testapp_print("email_add_mail failed. [%d]\n", err); + else + testapp_print("email_add_mail success.\n"); - testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); + testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); - if (attachment_data) - email_free_attachment_data(&attachment_data, attachment_count); + if (attachment_data) + email_free_attachment_data(&attachment_data, attachment_count); - if (meeting_req) - email_free_meeting_request(&meeting_req, 1); + if (meeting_req) + email_free_meeting_request(&meeting_req, 1); - email_free_mail_data(&test_mail_data, 1); - email_free_mailbox(&mailbox_data, 1); + email_free_mail_data(&test_mail_data, 1); + email_free_mailbox(&mailbox_data, 1); - return FALSE; + return FALSE; } static gboolean testapp_test_email_parse_mime_file() { - int i = 0; - int attachment_count = 0; - int output_attachment_count = 0; - int verify = 0; - int err = EMAIL_ERROR_NONE; - char eml_file_path[255] = {0, }; - struct tm *struct_time; - - email_mail_data_t *mail_data = NULL; - email_attachment_data_t *mail_attachment_data = NULL; - email_mail_data_t *output_mail_data = NULL; - email_attachment_data_t *output_mail_attachment_data = NULL; - - testapp_print("Input eml file path : "); - if (0 >= scanf("%s", eml_file_path)) - testapp_print("Invalid input. "); - - if ((err = email_parse_mime_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) { - testapp_print("email_parse_mime_file failed : [%d]\n", err); - return false; - } - - testapp_print("load success\n"); - - struct_time = localtime(&(mail_data->date_time)); - - testapp_print("%4d year", struct_time->tm_year +1900); - testapp_print("%2d month(0-11)\n", struct_time->tm_mon + 1); - testapp_print("%2d day(1-31)\n", struct_time->tm_mday); - testapp_print("%2d wday\n", struct_time->tm_wday); - testapp_print("%2d hour(0-23)\n", struct_time->tm_hour); - testapp_print("%2d minutes(0-59)\n", struct_time->tm_min); - testapp_print("%2d second(0-59)\n", struct_time->tm_sec); - testapp_print("year day %3d\n", struct_time->tm_yday); - - testapp_print("Return-Path: %s\n", mail_data->full_address_return); - testapp_print("To: %s\n", mail_data->full_address_to); - testapp_print("Subject: %s\n", mail_data->subject); - testapp_print("Priority: %d\n", mail_data->priority); - testapp_print("From: %s\n", mail_data->full_address_from); - testapp_print("Reply-To: %s\n", mail_data->full_address_reply); - testapp_print("Sender: %s\n", mail_data->email_address_sender); - testapp_print("Message-ID: %s\n", mail_data->message_id); - testapp_print("attachment_count: %d\n", mail_data->attachment_count); - testapp_print("SMIME type : %d\n", mail_data->smime_type); - testapp_print("inline content count : %d\n", mail_data->inline_content_count); - testapp_print("mail_size : %d\n", mail_data->mail_size); - testapp_print("download_body_status : %d\n", mail_data->body_download_status); - - - for (i = 0; i < attachment_count ; i++) { - testapp_print("%d attachment\n", i); - testapp_print("attachment_id: %d\n", mail_attachment_data[i].attachment_id); - testapp_print("attachment_size: %d\n", mail_attachment_data[i].attachment_size); - testapp_print("inline_attachment_status: %d\n", mail_attachment_data[i].inline_content_status); - testapp_print("attachment_name: %s\n", mail_attachment_data[i].attachment_name); - testapp_print("attachment_path: %s\n", mail_attachment_data[i].attachment_path); - testapp_print("attachment_save_status: %d\n", mail_attachment_data[i].save_status); - testapp_print("content_id: %s\n", mail_attachment_data[i].content_id); - testapp_print("mailbox_id: %d\n", mail_attachment_data[i].mailbox_id); - } - - testapp_print("Success : Open eml file\n"); - - if (mail_data->smime_type != EMAIL_SMIME_NONE) { - if (mail_data->smime_type == EMAIL_SMIME_SIGNED || mail_data->smime_type == EMAIL_PGP_SIGNED) { - if (!email_verify_signature_ex(mail_data, mail_attachment_data, attachment_count, &verify)) - testapp_print("email_verify_signature_ex failed\n"); - } else { - if ((err = email_get_decrypt_message_ex(mail_data, - mail_attachment_data, - attachment_count, - &output_mail_data, - &output_mail_attachment_data, - &output_attachment_count, - &verify)) != EMAIL_ERROR_NONE) - testapp_print("email_get_decrypt_message_ex failed\n"); - } - - testapp_print("verify : [%d]\n", verify); - } - - if ((err = email_delete_parsed_data(mail_data)) != EMAIL_ERROR_NONE) { - testapp_print("email_delete_eml_data failed : [%d]\n", err); - return false; - } + int i = 0; + int attachment_count = 0; + int output_attachment_count = 0; + int verify = 0; + int err = EMAIL_ERROR_NONE; + char eml_file_path[255] = {0, }; + struct tm *struct_time; + email_mail_data_t *mail_data = NULL; + email_attachment_data_t *mail_attachment_data = NULL; + email_mail_data_t *output_mail_data = NULL; + email_attachment_data_t *output_mail_attachment_data = NULL; + + testapp_print("Input eml file path : "); + if (0 >= scanf("%s", eml_file_path)) + testapp_print("Invalid input. "); + + if ((err = email_parse_mime_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) { + testapp_print("email_parse_mime_file failed : [%d]\n", err); + return false; + } - testapp_print("Success : email_delete_eml_data\n"); + testapp_print("load success\n"); + struct_time = localtime(&(mail_data->date_time)); + testapp_print("%4d year", struct_time->tm_year +1900); + testapp_print("%2d month(0-11)\n", struct_time->tm_mon + 1); + testapp_print("%2d day(1-31)\n", struct_time->tm_mday); + testapp_print("%2d wday\n", struct_time->tm_wday); + testapp_print("%2d hour(0-23)\n", struct_time->tm_hour); + testapp_print("%2d minutes(0-59)\n", struct_time->tm_min); + testapp_print("%2d second(0-59)\n", struct_time->tm_sec); + testapp_print("year day %3d\n", struct_time->tm_yday); + testapp_print("Return-Path: %s\n", mail_data->full_address_return); + testapp_print("To: %s\n", mail_data->full_address_to); + testapp_print("Subject: %s\n", mail_data->subject); + testapp_print("Priority: %d\n", mail_data->priority); + testapp_print("From: %s\n", mail_data->full_address_from); + testapp_print("Reply-To: %s\n", mail_data->full_address_reply); + testapp_print("Sender: %s\n", mail_data->email_address_sender); + testapp_print("Message-ID: %s\n", mail_data->message_id); + testapp_print("attachment_count: %d\n", mail_data->attachment_count); + testapp_print("SMIME type : %d\n", mail_data->smime_type); + testapp_print("inline content count : %d\n", mail_data->inline_content_count); + testapp_print("mail_size : %d\n", mail_data->mail_size); + testapp_print("download_body_status : %d\n", mail_data->body_download_status); + + + for (i = 0; i < attachment_count ; i++) { + testapp_print("%d attachment\n", i); + testapp_print("attachment_id: %d\n", mail_attachment_data[i].attachment_id); + testapp_print("attachment_size: %d\n", mail_attachment_data[i].attachment_size); + testapp_print("inline_attachment_status: %d\n", mail_attachment_data[i].inline_content_status); + testapp_print("attachment_name: %s\n", mail_attachment_data[i].attachment_name); + testapp_print("attachment_path: %s\n", mail_attachment_data[i].attachment_path); + testapp_print("attachment_save_status: %d\n", mail_attachment_data[i].save_status); + testapp_print("content_id: %s\n", mail_attachment_data[i].content_id); + testapp_print("mailbox_id: %d\n", mail_attachment_data[i].mailbox_id); + } - if (mail_data) - email_free_mail_data(&mail_data, 1); + testapp_print("Success : Open eml file\n"); + + if (mail_data->smime_type != EMAIL_SMIME_NONE) { + if (mail_data->smime_type == EMAIL_SMIME_SIGNED || mail_data->smime_type == EMAIL_PGP_SIGNED) { + if (!email_verify_signature_ex(mail_data, mail_attachment_data, attachment_count, &verify)) + testapp_print("email_verify_signature_ex failed\n"); + } else { + if ((err = email_get_decrypt_message_ex(mail_data, + mail_attachment_data, + attachment_count, + &output_mail_data, + &output_mail_attachment_data, + &output_attachment_count, + &verify)) != EMAIL_ERROR_NONE) + testapp_print("email_get_decrypt_message_ex failed\n"); + } - testapp_print("Success : email_free_mail_data\n"); + testapp_print("verify : [%d]\n", verify); + } - if (mail_attachment_data) - email_free_attachment_data(&mail_attachment_data, attachment_count); + if ((err = email_delete_parsed_data(mail_data)) != EMAIL_ERROR_NONE) { + testapp_print("email_delete_eml_data failed : [%d]\n", err); + return false; + } + testapp_print("Success : email_delete_eml_data\n"); - testapp_print("Success : email_free_attachment_data\n"); + if (mail_data) + email_free_mail_data(&mail_data, 1); - return true; + testapp_print("Success : email_free_mail_data\n"); + if (mail_attachment_data) + email_free_attachment_data(&mail_attachment_data, attachment_count); + testapp_print("Success : email_free_attachment_data\n"); + return true; } static gboolean testapp_test_email_write_mime_file() { - int err = EMAIL_ERROR_NONE; - int mail_id = 0; - int attachment_count = 0; - char *file_path = NULL; - email_mail_data_t *mail_data = NULL; - email_attachment_data_t *mail_attachment_data = NULL; + int err = EMAIL_ERROR_NONE; + int mail_id = 0; + int attachment_count = 0; + char *file_path = NULL; + email_mail_data_t *mail_data = NULL; + email_attachment_data_t *mail_attachment_data = NULL; - file_path = malloc(512); - memset(file_path, 0x00, 512); + file_path = malloc(512); + memset(file_path, 0x00, 512); - testapp_print("Input mail id : "); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); + testapp_print("Input mail id : "); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); - err = email_get_mail_data(mail_id, &mail_data); - if (err != EMAIL_ERROR_NONE || mail_data == NULL) { - testapp_print("email_get_mail_data failed : [%d]\n", err); - return false; - } + err = email_get_mail_data(mail_id, &mail_data); + if (err != EMAIL_ERROR_NONE || mail_data == NULL) { + testapp_print("email_get_mail_data failed : [%d]\n", err); + return false; + } - err = email_get_attachment_data_list(mail_id, &mail_attachment_data, &attachment_count); - if (err != EMAIL_ERROR_NONE) { - testapp_print("email_get_attachment_data_list failed : [%d]\n", err); - return false; - } + err = email_get_attachment_data_list(mail_id, &mail_attachment_data, &attachment_count); + if (err != EMAIL_ERROR_NONE) { + testapp_print("email_get_attachment_data_list failed : [%d]\n", err); + return false; + } - snprintf(file_path, 512, tzplatform_mkpath(TZ_SYS_DATA,"email/.email_data/tmp/%d_%8d.eml"), mail_id, (int)time(NULL)); + snprintf(file_path, 512, tzplatform_mkpath(TZ_SYS_DATA,"email/.email_data/tmp/%d_%8d.eml"), mail_id, (int)time(NULL)); - err = email_write_mime_file(mail_data, mail_attachment_data, attachment_count, &file_path); - if (err != EMAIL_ERROR_NONE) { - testapp_print("email_write_mime_file failed : [%d]\n", err); - return false; - } + err = email_write_mime_file(mail_data, mail_attachment_data, attachment_count, &file_path); + if (err != EMAIL_ERROR_NONE) { + testapp_print("email_write_mime_file failed : [%d]\n", err); + return false; + } - testapp_print("file path : [%s]\n", file_path); + testapp_print("file path : [%s]\n", file_path); - if (mail_data) - email_free_mail_data(&mail_data, 1); + if (mail_data) + email_free_mail_data(&mail_data, 1); - if (mail_attachment_data) - email_free_attachment_data(&mail_attachment_data, attachment_count); + if (mail_attachment_data) + email_free_attachment_data(&mail_attachment_data, attachment_count); - if (file_path) - free(file_path); + if (file_path) + free(file_path); - return true; + return true; } static gboolean testapp_test_smime_verify_signature() { - int mail_id = 0; - int verify = 0; - int err = EMAIL_ERROR_NONE; - - testapp_print("input mail_id :"); - if (0 >= scanf("%d", &mail_id)) - testapp_print("Invalid input. "); - - err = email_verify_signature(mail_id, &verify); - if (err != EMAIL_ERROR_NONE) { - testapp_print("Failed Verify\n"); - return false; - } + int mail_id = 0; + int verify = 0; + int err = EMAIL_ERROR_NONE; + + testapp_print("input mail_id :"); + if (0 >= scanf("%d", &mail_id)) + testapp_print("Invalid input. "); + + err = email_verify_signature(mail_id, &verify); + if (err != EMAIL_ERROR_NONE) { + testapp_print("Failed Verify\n"); + return false; + } - testapp_print("verify value : [%d]\n", verify); - return true; + testapp_print("verify value : [%d]\n", verify); + return true; } static gboolean testapp_test_email_add_mail_with_multiple_recipient() { - int i = 0; - int account_id = 0; - int err = EMAIL_ERROR_NONE; -// int smime_type = 0; - int recipient_addresses_count = 0; - char *recipient_addresses = NULL; - char recipient_address[234] = { 0, }; - char from_address[300] = { 0 , }; - const char *body_file_path = MAIL_TEMP_BODY; - email_account_t *account_data = NULL; - email_mailbox_t *mailbox_data = NULL; - email_mail_data_t *test_mail_data = NULL; - FILE *body_file; + int i = 0; + int account_id = 0; + int err = EMAIL_ERROR_NONE; + // int smime_type = 0; + int recipient_addresses_count = 0; + char *recipient_addresses = NULL; + char recipient_address[234] = { 0, }; + char from_address[300] = { 0 , }; + const char *body_file_path = MAIL_TEMP_BODY; + email_account_t *account_data = NULL; + email_mailbox_t *mailbox_data = NULL; + email_mail_data_t *test_mail_data = NULL; + FILE *body_file; + + testapp_print("\n > Enter account id : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter recipient address count : "); + if (0 >= scanf("%d", &recipient_addresses_count)) + testapp_print("Invalid input. "); + + if (recipient_addresses_count < 1) + return TRUE; + + recipient_addresses = malloc(sizeof(char) * 234 * recipient_addresses_count); + + for (i = 0; i < recipient_addresses_count; i++) { + snprintf(recipient_address, 234, "\"mailtest%05d\" <mailtest%05d@a1234567890b1234567890.com>; ", i, i); + strcat(recipient_addresses, recipient_address); + } - testapp_print("\n > Enter account id : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); + email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data); - testapp_print("\n > Enter recipient address count : "); - if (0 >= scanf("%d", &recipient_addresses_count)) - testapp_print("Invalid input. "); + email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data); - if (recipient_addresses_count < 1) - return TRUE; + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); - recipient_addresses = malloc(sizeof(char) * 234 * recipient_addresses_count); + SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address); - for (i = 0; i < recipient_addresses_count; i++) { - snprintf(recipient_address, 234, "\"mailtest%05d\" <mailtest%05d@a1234567890b1234567890.com>; ", i, i); - strcat(recipient_addresses, recipient_address); - } + test_mail_data->account_id = account_id; + test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED; + test_mail_data->body_download_status = 1; + test_mail_data->flags_seen_field = 1; + test_mail_data->file_path_plain = strdup(body_file_path); + test_mail_data->mailbox_id = mailbox_data->mailbox_id; + test_mail_data->mailbox_type = mailbox_data->mailbox_type; + test_mail_data->full_address_from = strdup(from_address); + test_mail_data->full_address_to = recipient_addresses; + test_mail_data->subject = strdup("Read receipt request from TIZEN"); + test_mail_data->remaining_resend_times = 3; + test_mail_data->report_status = EMAIL_MAIL_REQUEST_DSN | EMAIL_MAIL_REQUEST_MDN; + test_mail_data->smime_type = 0; - email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data); + body_file = fopen(body_file_path, "w"); - email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data); - - test_mail_data = malloc(sizeof(email_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); + testapp_print("\n body_file [%p]\n", body_file); - SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address); - - test_mail_data->account_id = account_id; - test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED; - test_mail_data->body_download_status = 1; - test_mail_data->flags_seen_field = 1; - test_mail_data->file_path_plain = strdup(body_file_path); - test_mail_data->mailbox_id = mailbox_data->mailbox_id; - test_mail_data->mailbox_type = mailbox_data->mailbox_type; - test_mail_data->full_address_from = strdup(from_address); - test_mail_data->full_address_to = recipient_addresses; - test_mail_data->subject = strdup("Read receipt request from TIZEN"); - test_mail_data->remaining_resend_times = 3; - test_mail_data->report_status = EMAIL_MAIL_REQUEST_DSN | EMAIL_MAIL_REQUEST_MDN; - test_mail_data->smime_type = 0; - - body_file = fopen(body_file_path, "w"); - - testapp_print("\n body_file [%p]\n", body_file); - - if (body_file == NULL) { - testapp_print("\n fopen [%s]failed\n", body_file_path); - return FALSE; - } + if (body_file == NULL) { + testapp_print("\n fopen [%s]failed\n", body_file_path); + return FALSE; + } - for (i = 0; i < 100; i++) - fprintf(body_file, "Mail sending Test. [%d]\n", i); + for (i = 0; i < 100; i++) + fprintf(body_file, "Mail sending Test. [%d]\n", i); - fflush(body_file); - fclose(body_file); + fflush(body_file); + fclose(body_file); - if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) - testapp_print("email_add_mail failed. [%d]\n", err); - else - testapp_print("email_add_mail success.\n"); + if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) + testapp_print("email_add_mail failed. [%d]\n", err); + else + testapp_print("email_add_mail success.\n"); - testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); + testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id); - email_free_mail_data(&test_mail_data, 1); - email_free_mailbox(&mailbox_data, 1); - email_free_account(&account_data, 1); + email_free_mail_data(&test_mail_data, 1); + email_free_mailbox(&mailbox_data, 1); + email_free_account(&account_data, 1); - return FALSE; + return FALSE; } static gboolean testapp_test_send_mails_every_x_minutes() { - int added_mail_id = 0; - int err = EMAIL_ERROR_NONE; - int handle = 0; - time_t time_to_send; - int i = 0; - int j = 0; - int account_id = 0; - int send_interval_in_minutes = 0; - int number_of_mails = 0; - char recipient_address[300] = { 0 , }; - char from_address[300] = { 0 , }; - char subject_form[1024] = { 0 , }; - const char *body_file_path = MAIL_TEMP_BODY; - struct tm *time_to_send_tm; - email_account_t *account_data = NULL; - email_mailbox_t *mailbox_data = NULL; - email_mail_data_t *test_mail_data = NULL; - FILE *body_file; - - testapp_print("\n > Enter account id : "); - if (0 >= scanf("%d", &account_id)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter recipient address : "); - if (0 >= scanf("%s", recipient_address)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter number of mails: "); - if (0 >= scanf("%d", &number_of_mails)) - testapp_print("Invalid input. "); - - testapp_print("\n > Enter send interval in minutes: "); - if (0 >= scanf("%d", &send_interval_in_minutes)) - testapp_print("Invalid input. "); - - email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data); - - email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data); - - test_mail_data = malloc(sizeof(email_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); - - SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address); - - test_mail_data->account_id = account_id; - test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED; - test_mail_data->body_download_status = 1; - test_mail_data->flags_seen_field = 1; - test_mail_data->file_path_plain = strdup(body_file_path); - test_mail_data->mailbox_id = mailbox_data->mailbox_id; - test_mail_data->mailbox_type = mailbox_data->mailbox_type; - test_mail_data->full_address_from = strdup(from_address); - test_mail_data->full_address_to = strdup(recipient_address); - test_mail_data->remaining_resend_times = 3; - test_mail_data->report_status = EMAIL_MAIL_REPORT_NONE; - - - for (i = 0; i < number_of_mails; i++) { - if (test_mail_data->subject) - free(test_mail_data->subject); - - time(&time_to_send); - time_to_send += (60 * send_interval_in_minutes) * (i + 1); - time_to_send_tm = localtime(&time_to_send); - - strftime(subject_form, 1024, "[%H:%M] TEST.", time_to_send_tm); - test_mail_data->subject = strdup(subject_form); - - body_file = fopen(body_file_path, "w"); - - testapp_print("\n body_file [%p]\n", body_file); - - if (body_file == NULL) { - testapp_print("\n fopen [%s]failed\n", body_file_path); - return FALSE; - } + int added_mail_id = 0; + int err = EMAIL_ERROR_NONE; + int handle = 0; + time_t time_to_send; + int i = 0; + int j = 0; + int account_id = 0; + int send_interval_in_minutes = 0; + int number_of_mails = 0; + char recipient_address[300] = { 0 , }; + char from_address[300] = { 0 , }; + char subject_form[1024] = { 0 , }; + const char *body_file_path = MAIL_TEMP_BODY; + struct tm *time_to_send_tm; + email_account_t *account_data = NULL; + email_mailbox_t *mailbox_data = NULL; + email_mail_data_t *test_mail_data = NULL; + FILE *body_file; + + testapp_print("\n > Enter account id : "); + if (0 >= scanf("%d", &account_id)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter recipient address : "); + if (0 >= scanf("%s", recipient_address)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter number of mails: "); + if (0 >= scanf("%d", &number_of_mails)) + testapp_print("Invalid input. "); + + testapp_print("\n > Enter send interval in minutes: "); + if (0 >= scanf("%d", &send_interval_in_minutes)) + testapp_print("Invalid input. "); + + email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data); + + email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data); + + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); + + SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address); + + test_mail_data->account_id = account_id; + test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED; + test_mail_data->body_download_status = 1; + test_mail_data->flags_seen_field = 1; + test_mail_data->file_path_plain = strdup(body_file_path); + test_mail_data->mailbox_id = mailbox_data->mailbox_id; + test_mail_data->mailbox_type = mailbox_data->mailbox_type; + test_mail_data->full_address_from = strdup(from_address); + test_mail_data->full_address_to = strdup(recipient_address); + test_mail_data->remaining_resend_times = 3; + test_mail_data->report_status = EMAIL_MAIL_REPORT_NONE; + + + for (i = 0; i < number_of_mails; i++) { + if (test_mail_data->subject) + free(test_mail_data->subject); + + time(&time_to_send); + time_to_send += (60 * send_interval_in_minutes) * (i + 1); + time_to_send_tm = localtime(&time_to_send); + + strftime(subject_form, 1024, "[%H:%M] TEST.", time_to_send_tm); + test_mail_data->subject = strdup(subject_form); + + body_file = fopen(body_file_path, "w"); + + testapp_print("\n body_file [%p]\n", body_file); + + if (body_file == NULL) { + testapp_print("\n fopen [%s]failed\n", body_file_path); + return FALSE; + } - for (j = 0; j < 100; j++) - fprintf(body_file, "Mail sending Test. [%d]\n", j); + for (j = 0; j < 100; j++) + fprintf(body_file, "Mail sending Test. [%d]\n", j); - fflush(body_file); - fclose(body_file); + fflush(body_file); + fclose(body_file); - if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) { - testapp_print("email_add_mail failed. [%d]\n", err); - added_mail_id = 0; - } else { - testapp_print("email_add_mail success.\n"); - added_mail_id = test_mail_data->mail_id; - } + if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) { + testapp_print("email_add_mail failed. [%d]\n", err); + added_mail_id = 0; + } else { + testapp_print("email_add_mail success.\n"); + added_mail_id = test_mail_data->mail_id; + } - testapp_print("saved mail id = [%d]\n", added_mail_id); + testapp_print("saved mail id = [%d]\n", added_mail_id); - if (added_mail_id) { - testapp_print("Calling email_schedule_sending_mail...\n"); + if (added_mail_id) { + testapp_print("Calling email_schedule_sending_mail...\n"); - if (email_schedule_sending_mail(added_mail_id, time_to_send) < 0) { - testapp_print("email_schedule_sending_mail failed[%d]\n", err); - } else { - testapp_print("Start sending. handle[%d]\n", handle); - } - } - } + if (email_schedule_sending_mail(added_mail_id, time_to_send) < 0) { + testapp_print("email_schedule_sending_mail failed[%d]\n", err); + } else { + testapp_print("Start sending. handle[%d]\n", handle); + } + } + } - email_free_mail_data(&test_mail_data, 1); - email_free_mailbox(&mailbox_data, 1); - email_free_account(&account_data, 1); + email_free_mail_data(&test_mail_data, 1); + email_free_mailbox(&mailbox_data, 1); + email_free_account(&account_data, 1); - return TRUE; + return TRUE; } /* internal functions */ static gboolean testapp_test_interpret_command(int menu_number) { - gboolean go_to_loop = TRUE; - - switch (menu_number) { - case 1: - testapp_test_get_mails(); - break; - case 2: - testapp_test_mail_send(NULL); - break; - case 3: - testapp_test_get_mail_list_ex(); - break; - case 4: - testapp_test_add_attachment(); - break; - case 5: - testapp_test_set_deleted_flag(); - break; - case 6: - testapp_test_expunge_mails_deleted_flagged(); - break; - case 7: - testapp_test_send_read_receipt(); - break; - case 8: - testapp_test_delete_attachment(); - break; - case 9: - testapp_test_count(); - break; - case 10: - testapp_test_move_mails_to_mailbox_of_another_account(); - break; - case 11: - testapp_test_send_mail_with_downloading_attachment_of_original_mail(); - break; - case 12: - testapp_test_get_mail_data(); - break; - case 13: - testapp_test_schedule_sending_mail(); - break; - case 14: - testapp_test_delete(); - break; - case 15: - testapp_test_update_mail_attribute(); - break; - case 16: - testapp_test_download_body(); - break; - case 17: - testapp_test_download_attachment(); - break; - case 18: - testapp_test_get_attachment_data_list(); - break; - case 19: - testapp_test_get_meeting_request(); - break; - case 20: - testapp_test_delete_all(); - break; - case 21: - testapp_test_move(); - break; - case 23: - testapp_test_retry_send(); - break; - case 24: - testapp_test_get_attachment_data(); - break; - case 27: - testapp_test_move_all_mails_to_mailbox(); - break; - case 38: - testapp_test_get_totaldiskusage(); - break; - case 40: - testapp_test_address_format_check_test(); - break; - case 41: - testapp_test_get_max_mail_count(); - break; - case 42: - testapp_test_db_test(); - break; - case 43: - testapp_test_send_cancel(); - break; - case 44: - testapp_test_cancel_download_body(); - break; - case 46: - testapp_test_get_mail_list_for_thread_view(); - break; - case 48: - testapp_test_test_get_thread_information(); - break; - case 51: - testapp_test_get_mail_list(); - break; - case 52: - testapp_test_get_address_info_list(); - break; - case 55: - testapp_test_set_flags_field(); - break; - case 56: - testapp_test_add_mail(NULL); - break; - case 57: - testapp_test_update_mail(); - break; - case 58: - testapp_test_search_mail_on_server(); - break; - case 59: - testapp_test_add_mail_to_search_result_box(); - break; - case 60: - testapp_test_email_parse_mime_file(); - break; - case 61: - testapp_test_email_write_mime_file(); - break; - case 62: - testapp_test_smime_verify_signature(); - break; - case 63: - testapp_test_email_add_mail_with_multiple_recipient(); - break; - case 64: - testapp_test_send_mails_every_x_minutes(); - break; - case 0: - go_to_loop = FALSE; - break; - default: - break; - } + gboolean go_to_loop = TRUE; + + switch (menu_number) { + case 1: + testapp_test_get_mails(); + break; + case 2: + testapp_test_mail_send(NULL); + break; + case 3: + testapp_test_get_mail_list_ex(); + break; + case 4: + testapp_test_add_attachment(); + break; + case 5: + testapp_test_set_deleted_flag(); + break; + case 6: + testapp_test_expunge_mails_deleted_flagged(); + break; + case 7: + testapp_test_send_read_receipt(); + break; + case 8: + testapp_test_delete_attachment(); + break; + case 9: + testapp_test_count(); + break; + case 10: + testapp_test_move_mails_to_mailbox_of_another_account(); + break; + case 11: + testapp_test_send_mail_with_downloading_attachment_of_original_mail(); + break; + case 12: + testapp_test_get_mail_data(); + break; + case 13: + testapp_test_schedule_sending_mail(); + break; + case 14: + testapp_test_delete(); + break; + case 15: + testapp_test_update_mail_attribute(); + break; + case 16: + testapp_test_download_body(); + break; + case 17: + testapp_test_download_attachment(); + break; + case 18: + testapp_test_get_attachment_data_list(); + break; + case 19: + testapp_test_get_meeting_request(); + break; + case 20: + testapp_test_delete_all(); + break; + case 21: + testapp_test_move(); + break; + case 23: + testapp_test_retry_send(); + break; + case 24: + testapp_test_get_attachment_data(); + break; + case 27: + testapp_test_move_all_mails_to_mailbox(); + break; + case 38: + testapp_test_get_totaldiskusage(); + break; + case 40: + testapp_test_address_format_check_test(); + break; + case 41: + testapp_test_get_max_mail_count(); + break; + case 42: + testapp_test_db_test(); + break; + case 43: + testapp_test_send_cancel(); + break; + case 44: + testapp_test_cancel_download_body(); + break; + case 46: + testapp_test_get_mail_list_for_thread_view(); + break; + case 48: + testapp_test_test_get_thread_information(); + break; + case 51: + testapp_test_get_mail_list(); + break; + case 52: + testapp_test_get_address_info_list(); + break; + case 55: + testapp_test_set_flags_field(); + break; + case 56: + testapp_test_add_mail(NULL); + break; + case 57: + testapp_test_update_mail(); + break; + case 58: + testapp_test_search_mail_on_server(); + break; + case 59: + testapp_test_add_mail_to_search_result_box(); + break; + case 60: + testapp_test_email_parse_mime_file(); + break; + case 61: + testapp_test_email_write_mime_file(); + break; + case 62: + testapp_test_smime_verify_signature(); + break; + case 63: + testapp_test_email_add_mail_with_multiple_recipient(); + break; + case 64: + testapp_test_send_mails_every_x_minutes(); + break; + case 0: + go_to_loop = FALSE; + break; + default: + break; + } - return go_to_loop; + return go_to_loop; } void testapp_mail_main() { - gboolean go_to_loop = TRUE; - int menu_number = 0; + gboolean go_to_loop = TRUE; + int menu_number = 0; - while (go_to_loop) { - testapp_show_menu(EMAIL_MAIL_MENU); - testapp_show_prompt(EMAIL_MAIL_MENU); + while (go_to_loop) { + testapp_show_menu(EMAIL_MAIL_MENU); + testapp_show_prompt(EMAIL_MAIL_MENU); - if (0 >= scanf("%d", &menu_number)) - testapp_print("Invalid input"); + if (0 >= scanf("%d", &menu_number)) + testapp_print("Invalid input"); - go_to_loop = testapp_test_interpret_command(menu_number); - } + go_to_loop = testapp_test_interpret_command(menu_number); + } } |