diff options
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/test-application/include/testapp-account.h | 4 | ||||
-rwxr-xr-x | utilities/test-application/include/testapp-mail.h | 6 | ||||
-rwxr-xr-x | utilities/test-application/include/testapp-mailbox.h | 6 | ||||
-rwxr-xr-x | utilities/test-application/include/testapp-others.h | 4 | ||||
-rwxr-xr-x | utilities/test-application/include/testapp-rule.h | 6 | ||||
-rwxr-xr-x | utilities/test-application/include/testapp-thread.h | 6 | ||||
-rwxr-xr-x | utilities/test-application/include/testapp-utility.h | 24 | ||||
-rwxr-xr-x | utilities/test-application/main.c | 19 | ||||
-rwxr-xr-x | utilities/test-application/testapp-account.c | 625 | ||||
-rwxr-xr-x | utilities/test-application/testapp-mail.c | 1207 | ||||
-rwxr-xr-x | utilities/test-application/testapp-mailbox.c | 371 | ||||
-rwxr-xr-x | utilities/test-application/testapp-others.c | 70 | ||||
-rwxr-xr-x | utilities/test-application/testapp-rule.c | 81 | ||||
-rwxr-xr-x | utilities/test-application/testapp-thread.c | 32 | ||||
-rwxr-xr-x | utilities/test-application/testapp-utility.c | 75 |
15 files changed, 1312 insertions, 1224 deletions
diff --git a/utilities/test-application/include/testapp-account.h b/utilities/test-application/include/testapp-account.h index 267e01e..2f22aa0 100755 --- a/utilities/test-application/include/testapp-account.h +++ b/utilities/test-application/include/testapp-account.h @@ -20,8 +20,8 @@ */ -#ifndef EMF_TEST_ACCOUNT_H -#define EMF_TEST_ACCOUNT_H +#ifndef EMAIL_TEST_ACCOUNT_H +#define EMAIL_TEST_ACCOUNT_H /* export API */ void testapp_account_main(); diff --git a/utilities/test-application/include/testapp-mail.h b/utilities/test-application/include/testapp-mail.h index 0c50437..e7f3b40 100755 --- a/utilities/test-application/include/testapp-mail.h +++ b/utilities/test-application/include/testapp-mail.h @@ -21,8 +21,8 @@ -#ifndef EMF_TEST_MESSAGE_H -#define EMF_TEST_MESSAGE_H +#ifndef EMAIL_TEST_MESSAGE_H +#define EMAIL_TEST_MESSAGE_H #include <glib.h> @@ -31,5 +31,5 @@ void testapp_mail_main (void); -#endif /* EMF_TEST_MESSAGE_H */ +#endif /* EMAIL_TEST_MESSAGE_H */ diff --git a/utilities/test-application/include/testapp-mailbox.h b/utilities/test-application/include/testapp-mailbox.h index 3f92a9a..836a299 100755 --- a/utilities/test-application/include/testapp-mailbox.h +++ b/utilities/test-application/include/testapp-mailbox.h @@ -20,9 +20,9 @@ */ -#ifndef EMF_TEST_MAILBOX_H -#define EMF_TEST_MAILBOX_H +#ifndef EMAIL_TEST_MAILBOX_H +#define EMAIL_TEST_MAILBOX_H /* export API */ -void emf_test_mailbox_main (void); +void email_test_mailbox_main (void); #endif diff --git a/utilities/test-application/include/testapp-others.h b/utilities/test-application/include/testapp-others.h index 6864300..8c10989 100755 --- a/utilities/test-application/include/testapp-others.h +++ b/utilities/test-application/include/testapp-others.h @@ -21,8 +21,8 @@ -#ifndef EMF_TEST_OTHERS_H -#define EMF_TEST_OTHERS_H +#ifndef EMAIL_TEST_OTHERS_H +#define EMAIL_TEST_OTHERS_H /* export API */ void testapp_others_main(void); diff --git a/utilities/test-application/include/testapp-rule.h b/utilities/test-application/include/testapp-rule.h index 1a59a28..61f6e4c 100755 --- a/utilities/test-application/include/testapp-rule.h +++ b/utilities/test-application/include/testapp-rule.h @@ -21,11 +21,11 @@ -#ifndef EMF_TEST_RULE_H -#define EMF_TEST_RULE_H +#ifndef EMAIL_TEST_RULE_H +#define EMAIL_TEST_RULE_H /* export API */ -void emf_test_rule_main (void); +void email_test_rule_main (void); #endif diff --git a/utilities/test-application/include/testapp-thread.h b/utilities/test-application/include/testapp-thread.h index e5e0e99..c3e81c5 100755 --- a/utilities/test-application/include/testapp-thread.h +++ b/utilities/test-application/include/testapp-thread.h @@ -21,8 +21,8 @@ -#ifndef EMF_TEST_THREAD_H -#define EMF_TEST_THREAD_H +#ifndef EMAIL_TEST_THREAD_H +#define EMAIL_TEST_THREAD_H #include <glib.h> @@ -31,4 +31,4 @@ void testapp_thread_main(); -#endif /* EMF_TEST_THREAD_H */
\ No newline at end of file +#endif /* EMAIL_TEST_THREAD_H */
\ No newline at end of file diff --git a/utilities/test-application/include/testapp-utility.h b/utilities/test-application/include/testapp-utility.h index b6e0fa3..b88d69a 100755 --- a/utilities/test-application/include/testapp-utility.h +++ b/utilities/test-application/include/testapp-utility.h @@ -21,26 +21,26 @@ -#ifndef EMF_TEST_UTILITY_H -#define EMF_TEST_UTILITY_H +#ifndef EMAIL_TEST_UTILITY_H +#define EMAIL_TEST_UTILITY_H #include <glib.h> typedef enum { - EMF_MAIN_MENU = 0x0, - EMF_ACCOUNT_MENU, - EMF_MAIL_MENU, - EMF_MAILBOX_MENU, - EMF_RULE_MENU, - EMF_THREAD_MENU, - EMF_OTHERS_MENU, -} eEMF_MENU; + EMAIL_MAIN_MENU = 0x0, + EMAIL_ACCOUNT_MENU, + EMAIL_MAIL_MENU, + EMAIL_MAILBOX_MENU, + EMAIL_RULE_MENU, + EMAIL_THREAD_MENU, + EMAIL_OTHERS_MENU, +} eEMAIL_MENU; void testapp_print(char *fmt, ...); -void testapp_show_menu(eEMF_MENU menu); -void testapp_show_prompt(eEMF_MENU menu); +void testapp_show_menu(eEMAIL_MENU menu); +void testapp_show_prompt(eEMAIL_MENU menu); #endif diff --git a/utilities/test-application/main.c b/utilities/test-application/main.c index 1d58f62..449d72c 100755 --- a/utilities/test-application/main.c +++ b/utilities/test-application/main.c @@ -78,7 +78,7 @@ static gboolean testapp_initialize_testing () gettimeofday(&tv_1, NULL); - if ( email_service_begin() != EMF_ERROR_NONE ) { + if ( email_service_begin() != EMAIL_ERROR_NONE ) { testapp_print ("unexpected error: opening email service fail\n"); return FALSE; } @@ -87,7 +87,7 @@ static gboolean testapp_initialize_testing () testapp_print("\t email_service_begin Proceed time %d us\n",interval); gettimeofday(&tv_1, NULL); - if ( (error = email_open_db()) != EMF_ERROR_NONE) { + if ( (error = email_open_db()) != EMAIL_ERROR_NONE) { testapp_print("email_open_db failed [%d]\n", error); } gettimeofday(&tv_2, NULL); @@ -101,11 +101,11 @@ static gboolean testapp_finalize_testing () { int error; - if ( (error = email_close_db()) != EMF_ERROR_NONE) { + if ( (error = email_close_db()) != EMAIL_ERROR_NONE) { testapp_print("email_close_db failed [%d]\n", error); } - if ( email_service_end() != EMF_ERROR_NONE) { + if ( email_service_end() != EMAIL_ERROR_NONE) { testapp_print ("unexpected error: closing email service fail \n"); } @@ -145,14 +145,14 @@ static gboolean testapp_interpret_command (int menu_number) break; case 3: - emf_test_mailbox_main(); + email_test_mailbox_main(); break; case 4: break; case 5: - emf_test_rule_main(); + email_test_rule_main(); break; case 6: @@ -176,6 +176,7 @@ int main (int argc, char *argv[]) { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; if ( testapp_initialize_testing() == FALSE ) { testapp_print ("email-serivce is not ready\n"); @@ -183,10 +184,10 @@ int main (int argc, char *argv[]) } while (go_to_loop) { - testapp_show_menu (EMF_MAIN_MENU); - testapp_show_prompt (EMF_MAIN_MENU); + testapp_show_menu (EMAIL_MAIN_MENU); + testapp_show_prompt (EMAIL_MAIN_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf ("%d", &menu_number); go_to_loop = testapp_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-account.c b/utilities/test-application/testapp-account.c index 9c38a1b..c3d99c1 100755 --- a/utilities/test-application/testapp-account.c +++ b/utilities/test-application/testapp-account.c @@ -27,6 +27,7 @@ /* open header */ #include <glib.h> +#include "email-api.h" #include "email-api-account.h" #include "email-api-network.h" @@ -46,7 +47,7 @@ /* SAMSUNG 3G TEST */ #define S3G_RECV_SERVER_ADDR "165.213.73.235" -#define S3G_RECV_SERVER_PORT EMF_POP3_PORT +#define S3G_RECV_SERVER_PORT EMAIL_POP3_PORT #define S3G_RECV_USE_SECURITY 0 #define S3G_RECV_IMAP_USE_SECURITY 1 #define S3G_SMTP_SERVER_ADDR "165.213.73.235" @@ -57,9 +58,10 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *account_id) { - emf_account_t *account = NULL; + email_account_t *account = NULL; char id_string[100] = { 0, }, password_string[100] = { 0, }, address_string[100] = { 0, }; - int err_code = EMF_ERROR_NONE, samsung3g_account_index; + int err_code = EMAIL_ERROR_NONE, samsung3g_account_index; + int result_from_scanf = 0; unsigned handle; switch(account_type) { @@ -67,7 +69,7 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou case 5 : do { testapp_print("Enter your account index [1~10] : "); - scanf("%d",&samsung3g_account_index); + result_from_scanf = scanf("%d",&samsung3g_account_index); }while( samsung3g_account_index > 10 || samsung3g_account_index < 1); sprintf(id_string, "test%02d", samsung3g_account_index); sprintf(address_string, "<test%02d@streaming.s3glab.net>", samsung3g_account_index); @@ -75,178 +77,188 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou break; default: testapp_print("Enter email address : "); - scanf("%s", address_string); + result_from_scanf = scanf("%s", address_string); testapp_print("Enter id : "); - scanf("%s", id_string); + result_from_scanf = scanf("%s", id_string); testapp_print("Enter password_string : "); - scanf("%s", password_string); + result_from_scanf = scanf("%s", password_string); break; } - account = malloc(sizeof(emf_account_t)); - memset(account, 0x00, sizeof(emf_account_t)); + account = malloc(sizeof(email_account_t)); + memset(account, 0x00, sizeof(email_account_t)); + + typedef struct { + int is_preset_account; + int index_color; + } user_data_t; + user_data_t data = (user_data_t) {1, 0}; + /* if user_data_t has any pointer member, please don't use sizeof(). */ + /* You need to serialize user_data to buffer and then take its length */ + int data_length = sizeof(data); /* Common Options */ - account->account_bind_type = EMF_BIND_TYPE_EM_CORE; - account->retrieval_mode = EMF_IMAP4_RETRIEVAL_MODE_ALL; - account->use_security = 1; - account->sending_server_type = EMF_SERVER_TYPE_SMTP; - account->flag1 = 2; - account->flag2 = 1; + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; + account->incoming_server_secure_connection = 1; + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->auto_download_size = 2; + account->outgoing_server_use_same_authenticator = 1; account->pop_before_smtp = 0; - account->apop = 0; - account->logo_icon_path = NULL; - account->preset_account = 0; - account->options.priority = 3; - account->options.keep_local_copy = 0; - account->options.req_delivery_receipt = 0; - account->options.req_read_receipt = 0; - account->options.download_limit = 0; - account->options.block_address = 0; - account->options.block_subject = 0; - account->options.display_name_from = NULL; - account->options.reply_with_body = 0; - account->options.forward_with_files = 0; - account->options.add_myname_card = 0; - account->options.add_signature = 0; + account->incoming_server_requires_apop = 0; + account->logo_icon_path = NULL; + account->user_data = malloc (data_length); + memcpy( account->user_data, (void*) &data, data_length ); + account->user_data_length = data_length; + account->options.priority = 3; + account->options.keep_local_copy = 0; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 0; + account->options.block_subject = 0; + account->options.display_name_from = NULL; + account->options.reply_with_body = 0; + account->options.forward_with_files = 0; + account->options.add_myname_card = 0; + account->options.add_signature = 0; account->options.signature = NULL; - account->options.add_my_address_to_bcc = 0; - account->target_storage = 0; - account->check_interval = 0; - account->keep_on_server = 1; - - account->account_name = strdup(address_string); - account->display_name = strdup(id_string); - account->email_addr = strdup(address_string); - account->reply_to_addr = strdup(address_string); - account->return_addr = strdup(address_string); - - account->user_name = strdup(id_string); - account->password = strdup(password_string); - account->sending_user = strdup(id_string); - account->sending_password = strdup(password_string); + account->options.add_my_address_to_bcc = 0; + account->check_interval = 0; + account->keep_mails_on_pop_server_after_download = 1; + account->default_mail_slot_size = 200; + + account->account_name = strdup(address_string); + account->user_display_name = strdup(id_string); + account->user_email_address = strdup(address_string); + account->reply_to_address = strdup(address_string); + account->return_address = strdup(address_string); + + account->incoming_server_user_name = strdup(id_string); + account->incoming_server_password = strdup(password_string); + account->outgoing_server_user_name = strdup(id_string); + account->outgoing_server_password = strdup(password_string); switch (account_type) { case 1:/* gawab */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3 ; - account->receiving_server_addr = strdup(GWB_RECV_SERVER_ADDR); - account->port_num = EMF_POP3S_PORT; - account->sending_server_addr = strdup(GWB_SMTP_SERVER_ADDR); - account->use_security = 1; - account->sending_auth = 1; - account->sending_port_num = EMF_SMTPS_PORT; - account->sending_security = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3 ; + account->incoming_server_address = strdup(GWB_RECV_SERVER_ADDR); + account->incoming_server_port_number = EMAIL_POP3S_PORT; + account->outgoing_server_address = strdup(GWB_SMTP_SERVER_ADDR); + account->incoming_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; + account->outgoing_server_port_number = EMAIL_SMTPS_PORT; + account->outgoing_server_secure_connection = 1; break; case 2:/* vadofone */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup(VDF_RECV_SERVER_ADDR); - account->port_num = EMF_IMAP_PORT; - account->sending_server_addr = strdup(VDF_SMTP_SERVER_ADDR); - account->use_security = 0; - account->sending_auth = 0; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup(VDF_RECV_SERVER_ADDR); + account->incoming_server_port_number = EMAIL_IMAP_PORT; + account->outgoing_server_address = strdup(VDF_SMTP_SERVER_ADDR); + account->incoming_server_secure_connection = 0; + account->outgoing_server_need_authentication = 0; break; case 4:/* SAMSUNG 3G TEST */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup(S3G_RECV_SERVER_ADDR); - account->port_num = S3G_RECV_SERVER_PORT; - account->sending_server_addr = strdup(S3G_SMTP_SERVER_ADDR); - account->sending_port_num = S3G_SMTP_SERVER_PORT; - account->use_security = S3G_RECV_USE_SECURITY; - account->sending_security = S3G_SMTP_USE_SECURITY; - account->sending_auth = S3G_SMTP_AUTH; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address = strdup(S3G_RECV_SERVER_ADDR); + account->incoming_server_port_number = S3G_RECV_SERVER_PORT; + account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR); + account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT; + account->incoming_server_secure_connection = S3G_RECV_USE_SECURITY; + account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY; + account->outgoing_server_need_authentication = S3G_SMTP_AUTH; break; - + case 5:/* SAMSUNG 3G TEST */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup(S3G_RECV_SERVER_ADDR); - account->port_num = EMF_IMAPS_PORT; - account->sending_server_addr = strdup(S3G_SMTP_SERVER_ADDR); - account->sending_port_num = S3G_SMTP_SERVER_PORT; - account->use_security = 1; - account->sending_security = S3G_SMTP_USE_SECURITY; - account->sending_auth = S3G_SMTP_AUTH; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup(S3G_RECV_SERVER_ADDR); + account->incoming_server_port_number = EMAIL_IMAPS_PORT; + account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR); + account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT; + account->incoming_server_secure_connection = 1; + account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY; + account->outgoing_server_need_authentication = S3G_SMTP_AUTH; break; case 6:/* Gmail POP3 */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup("pop.gmail.com"); - account->port_num = 995; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.gmail.com"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address= strdup("pop.gmail.com"); + account->incoming_server_port_number = 995; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.gmail.com"); + account->outgoing_server_port_number = 465; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; case 7 : /* Gmail IMAP4 */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup("imap.gmail.com"); - account->port_num = 993; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.gmail.com"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup("imap.gmail.com"); + account->incoming_server_port_number = 993; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.gmail.com"); + account->outgoing_server_port_number = 465; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; case 8: /* Active Sync */ - account->receiving_server_type = EMF_SERVER_TYPE_ACTIVE_SYNC; - account->receiving_server_addr = strdup(""); - account->port_num = 0; - account->use_security = 1; - account->sending_server_addr = strdup(""); - account->sending_port_num = 0; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_ACTIVE_SYNC; + account->incoming_server_address= strdup(""); + account->incoming_server_port_number = 0; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup(""); + account->outgoing_server_port_number = 0; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; case 9: /* AOL */ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup("imap.aol.com"); - account->port_num = 143; - account->use_security = 0; - account->sending_server_addr = strdup("smtp.aol.com"); - account->sending_port_num = 587; - account->sending_security = 0; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup("imap.aol.com"); + account->incoming_server_port_number = 143; + account->incoming_server_secure_connection = 0; + account->outgoing_server_address = strdup("smtp.aol.com"); + account->outgoing_server_port_number = 587; + account->outgoing_server_secure_connection = 0; + account->outgoing_server_need_authentication = 1; break; case 10: /* Hotmail */ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup("pop3.live.com"); - account->port_num = 995; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.live.com"); - account->sending_port_num = 587; - account->sending_security = 0x02; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address= strdup("pop3.live.com"); + account->incoming_server_port_number = 995; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.live.com"); + account->outgoing_server_port_number = 587; + account->outgoing_server_secure_connection = 0x02; + account->outgoing_server_need_authentication = 1; break; case 11:/* Daum IMAP4*/ - account->receiving_server_type = EMF_SERVER_TYPE_IMAP4; - account->receiving_server_addr = strdup("imap.daum.net"); - account->port_num = 993; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.daum.net"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + account->incoming_server_address= strdup("imap.daum.net"); + account->incoming_server_port_number = 993; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.daum.net"); + account->outgoing_server_port_number = 465; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; case 12:/* Daum POP3*/ - account->receiving_server_type = EMF_SERVER_TYPE_POP3; - account->receiving_server_addr = strdup("pop.daum.net"); - account->port_num = 995; - account->use_security = 1; - account->sending_server_addr = strdup("smtp.daum.net"); - account->sending_port_num = 465; - account->sending_security = 1; - account->sending_auth = 1; + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + account->incoming_server_address= strdup("pop.daum.net"); + account->incoming_server_port_number = 995; + account->incoming_server_secure_connection = 1; + account->outgoing_server_address = strdup("smtp.daum.net"); + account->outgoing_server_port_number = 465; + account->outgoing_server_secure_connection = 1; + account->outgoing_server_need_authentication = 1; break; default: @@ -254,12 +266,12 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou return FALSE; break; } - account->my_account_id = 77; + account->account_svc_id = 77; err_code = email_add_account_with_validation(account, &handle); if( err_code < 0) { testapp_print (" email_add_account_with_validation error : %d\n",err_code); return FALSE; - } + } testapp_print (" email_add_account succeed\n"); @@ -274,7 +286,8 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou static gboolean testapp_test_create_account() { int account_type = 0 ; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; testapp_print("1. Gawab\n"); testapp_print("2. Vodafone\n"); @@ -289,7 +302,7 @@ static gboolean testapp_test_create_account() testapp_print("12. Daum (POP3)\n"); testapp_print("Choose server type: "); - scanf("%d",&account_type); + result_from_scanf = scanf("%d",&account_type); if(!testapp_test_create_account_by_account_type(account_type,&err)) { testapp_print (" testapp_test_create_account_by_account_type error\n"); @@ -300,25 +313,27 @@ static gboolean testapp_test_create_account() static gboolean testapp_test_update_account() { + int result_from_scanf = 0; int account_id; - emf_account_t *account = NULL; - char account_name[20]; - int err = EMF_ERROR_NONE; + email_account_t *account = NULL; + char account_name[256]; + int err = EMAIL_ERROR_NONE; char signature[100] = {0}; - char email_addr[50] = {0,}; + char user_email_address[256] = {0,}; int add_my_address_to_bcc = 0; - int my_account_id = 0, with_validation = 0; + int account_svc_id = 0, with_validation = 0; testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ - if( (err = email_get_account(account_id, GET_FULL_DATA,&account)) < 0) { - testapp_print ("email_get_account failed \n"); +/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */ + if( (err = email_get_account(account_id, GET_FULL_DATA,&account)) != EMAIL_ERROR_NONE) { + testapp_print ("email_get_account failed - %d\n", err); + return false; } - else - testapp_print ("email_get_account result account_name - %s \n", account->account_name); + + testapp_print ("email_get_account result account_name - %s \n", account->account_name); testapp_print ("email_get_account result signature - %s \n", account->options.signature); @@ -327,57 +342,65 @@ static gboolean testapp_test_update_account() #endif testapp_print("\n Enter new Account name:"); - scanf("%s",account_name); + result_from_scanf = scanf("%s",account_name); testapp_print("\n Enter new email addr:"); - scanf("%s",email_addr); + result_from_scanf = scanf("%s",user_email_address); #ifdef __FEATURE_AUTO_POLLING__ testapp_print("\n Enter new check interval (in mins):"); - scanf("%d",&(account->check_interval)); + result_from_scanf = scanf("%d",&(account->check_interval)); #endif testapp_print("\n Enter new signature:"); - scanf("%s",signature); + result_from_scanf = scanf("%s",signature); testapp_print("\n>> Enter add_my_address_to_bcc:(0:off, 1:on) "); - scanf("%d",&add_my_address_to_bcc); + result_from_scanf = scanf("%d",&add_my_address_to_bcc); - testapp_print("\n>> Enter my_account_id: "); - scanf("%d",&my_account_id); + testapp_print("\n>> Enter account_svc_id: "); + result_from_scanf = scanf("%d",&account_svc_id); testapp_print("\n>> With validation ? (0: No, 1:Yes) "); - scanf("%d",&with_validation); + result_from_scanf = scanf("%d",&with_validation); if( account ) { account->account_name = strdup(account_name); - testapp_print("\n Assigning New Account name: %p", account->account_name); - account->email_addr = strdup(email_addr); + testapp_print("\n Assigning New Account name: (%s)", account->account_name); + account->user_email_address = strdup(user_email_address); account->options.signature = strdup(signature); - testapp_print("\n Assigning New Account name: %p", account->options.signature); + testapp_print("\n Assigning New Signature: (%s)\n", account->options.signature); account->options.add_my_address_to_bcc = add_my_address_to_bcc; - account->my_account_id= my_account_id; + account->account_svc_id = account_svc_id; if(with_validation) { - if((err = email_update_account_with_validation(account_id, account)) < 0) + if((err = email_update_account_with_validation(account_id, account)) != EMAIL_ERROR_NONE){ + testapp_print ("email_update_account_with_validation failed - %d\n", err); + return false; + } testapp_print ("email_update_account_with_validation successful \n"); } else { - if((err = email_update_account(account_id, account)) < 0) - testapp_print ("email_update_account_with_validation successful \n"); + if((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) { + testapp_print ("email_update_account failed - %d\n", err); + return false; + } + testapp_print ("email_update_account successful \n"); } } - return FALSE; + return true; } static gboolean testapp_test_delete_account () { int account_id; - emf_account_t *account=NULL; - int err = EMF_ERROR_NONE; + email_account_t *account=NULL; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ +/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */ if( (err = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0) { testapp_print ("email_get_account failed \n"); testapp_print("testapp_test_delete_account failed\n"); @@ -397,15 +420,16 @@ static gboolean testapp_test_delete_account () static gboolean testapp_test_validate_account () { + int result_from_scanf = 0; int account_id; - emf_account_t *account=NULL; - int err_code = EMF_ERROR_NONE; + email_account_t *account=NULL; + int err_code = EMAIL_ERROR_NONE; unsigned account_handle = 0; testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ +/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */ if( (err_code = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0 ) { testapp_print ("email_get_account failed \n"); return FALSE; @@ -413,7 +437,7 @@ static gboolean testapp_test_validate_account () else testapp_print ("email_get_account result account_name - %s \n", account->account_name); - if((err_code = email_validate_account(account_id, &account_handle)) == EMF_ERROR_NONE ) + if((err_code = email_validate_account(account_id, &account_handle)) == EMAIL_ERROR_NONE ) testapp_print ("email_validate_account successful account_handle : %u\n",account_handle); else testapp_print ("email_validate_account failed err_code: %d \n",err_code); @@ -425,17 +449,18 @@ static gboolean testapp_test_validate_account () static gboolean testapp_test_cancel_validate_account () { + int result_from_scanf = 0; int account_id = 0; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; unsigned account_handle = 0; testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter handle: "); - scanf("%d", &account_handle); + result_from_scanf = scanf("%d", &account_handle); - err_code = email_cancel_job(account_id, account_handle); + err_code = email_cancel_job(account_id, account_handle, EMAIL_CANCELED_BY_USER); if(err_code == 0) testapp_print("email_cancel_job Success..!handle:[%d]", account_handle); else @@ -446,63 +471,110 @@ static gboolean testapp_test_cancel_validate_account () static gboolean testapp_test_get_account() { + int result_from_scanf = 0; int account_id; - emf_account_t *account=NULL; - int err_code = EMF_ERROR_NONE; + email_account_t *account=NULL; + int err_code = EMAIL_ERROR_NONE; testapp_print("\n>> Enter Account No: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); -/* sowmya.kr, 281209 Adding signature to options in emf_account_t changes */ + typedef struct { + int is_preset_account; + int index_color; + } user_data_t; + + testapp_print ("\n----------------------------------------------------------\n"); testapp_print ("email_get_account GET_FULL_DATA \n"); if( (err_code = email_get_account(account_id,GET_FULL_DATA,&account)) < 0) { - testapp_print ("email_get_account failed \n"); + testapp_print ("email_get_account failed - %d\n", err_code); return FALSE; } - else - testapp_print ("email_get_account result account_name - %s \n email_addr - %s \n use_security %d \n add_sig : %d \n signature %s \n add_my_address_to_bcc %d \nmy_account_id %d\n", + + user_data_t* val = (user_data_t*) account->user_data; + int is_preset_account = val? val->is_preset_account : 0; + int index_color = val? val->index_color : 0; + + testapp_print ("email_get_account result\n" + "account_name - %s \n" + "user_email_address - %s \n" + "incoming_server_secure_connection %d \n" + "add_sig : %d \n" + "signature %s \n" + "add_my_address_to_bcc %d \n" + "account_svc_id %d\n" + "incoming_server_address %s\n" + "outgoing_server_address %s\n" + "default_mail_slot_size %d\n" + "sync_status %d\n" + "sync_disabled %d\n" + "is_preset %d\n" + "index_color %d\n" + "certificate_path %s\n" + "digest_type %d\n" + , account->account_name, - account->email_addr, - account->use_security, + account->user_email_address, + account->incoming_server_secure_connection, account->options.add_signature, account->options.signature, account->options.add_my_address_to_bcc, - account->my_account_id + account->account_svc_id, + account->incoming_server_address, + account->outgoing_server_address, + account->default_mail_slot_size, + account->sync_status, + account->sync_disabled, + is_preset_account, + index_color, + account->certificate_path, + account->digest_type ); err_code = email_free_account(&account, 1); + testapp_print ("\n----------------------------------------------------------\n"); testapp_print ("email_get_account WITHOUT_OPTION \n"); - if( (err_code = email_get_account(account_id,WITHOUT_OPTION,&account)) < 0) { + if( (err_code = email_get_account(account_id, WITHOUT_OPTION, &account)) < 0) { testapp_print ("email_get_account failed \n"); return FALSE; } - else - testapp_print ("email_get_account result account_name - %s \n email_addr - %s \n use_security %d \n add_sig : %d \n ", + + testapp_print ("email_get_account result\n" + "account_name - %s \n" + "user_email_address - %s \n" + "incoming_server_secure_connection %d \n" + "add_signature : %d \n", account->account_name, - account->email_addr, - account->use_security, - account->options.add_signature); + account->user_email_address, + account->incoming_server_secure_connection, + account->options.add_signature + ); if(account->options.signature) - testapp_print ("signature : %s \n", account->options.signature); + testapp_print ("signature : %s\n", account->options.signature); else testapp_print ("signature not retrieved \n"); err_code = email_free_account(&account, 1); + testapp_print ("\n----------------------------------------------------------\n"); testapp_print ("email_get_account ONLY_OPTION \n"); - if( (err_code = email_get_account(account_id,ONLY_OPTION,&account)) < 0) { + if( (err_code = email_get_account(account_id, ONLY_OPTION, &account)) < 0) { testapp_print ("email_get_account failed \n"); return FALSE; } - else - testapp_print ("email_get_account result add_sig : %d \n signature %s \n add_my_address_to_bcc %d\n my_account_id %d\n", + + testapp_print ("email_get_account result\n" + "add_sig : %d \n" + "signature %s \n" + "add_my_address_to_bcc %d\n" + "account_svc_id %d\n", account->options.add_signature, account->options.signature, account->options.add_my_address_to_bcc, - account->my_account_id + account->account_svc_id ); if(account->account_name) @@ -510,10 +582,10 @@ static gboolean testapp_test_get_account() else testapp_print ("account_name not retrieved \n"); - if(account->email_addr) - testapp_print ("email_addr : %s \n", account->email_addr); + if(account->user_email_address) + testapp_print ("user_email_address : %s \n", account->user_email_address); else - testapp_print ("email_addr not retrieved \n"); + testapp_print ("user_email_address not retrieved \n"); err_code = email_free_account(&account, 1); return FALSE; @@ -523,10 +595,10 @@ static gboolean testapp_test_get_account_list () { int count, i; - emf_account_t *account_list=NULL; + email_account_t *account_list=NULL; struct timeval tv_1, tv_2; int interval; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; gettimeofday(&tv_1, NULL); @@ -542,7 +614,7 @@ static gboolean testapp_test_get_account_list () for(i=0;i<count;i++){ testapp_print(" %2d) %-15s %-30s\n",account_list[i].account_id, account_list[i].account_name, - account_list[i].email_addr); + account_list[i].user_email_address); } err_code = email_free_account(&account_list, count); @@ -568,10 +640,11 @@ static gboolean testapp_test_restore_account() static gboolean testapp_test_get_password_length_of_account() { + int result_from_scanf = 0; int error_code, password_length, account_id; testapp_print("\n input account id\n"); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); error_code = email_get_password_length_of_account(account_id, &password_length); testapp_print("testapp_test_get_password_length_of_account returned [%d]\n",password_length); return FALSE; @@ -579,16 +652,17 @@ static gboolean testapp_test_get_password_length_of_account() static gboolean testapp_test_query_server_info() { + int result_from_scanf = 0; int error_code; char domain_name[255]; - emf_server_info_t *result_server_info; + email_server_info_t *result_server_info; testapp_print("\n input domain name\n"); - scanf("%s", domain_name); + result_from_scanf = scanf("%s", domain_name); error_code = email_query_server_info(domain_name, &result_server_info); testapp_print("email_query_server_info returned [%d]\n",error_code); - if(error_code == EMF_ERROR_NONE) + if(error_code == EMAIL_ERROR_NONE) testapp_print("service_name [%s]\n", result_server_info->service_name); return FALSE; } @@ -601,6 +675,113 @@ static gboolean testapp_test_clear_all_notification() testapp_print("email_clear_all_notification_bar returned [%d]\n",error_code); return FALSE; } + +static gboolean testapp_test_save_default_account_id() +{ + int result_from_scanf = 0; + int error_code; + int account_id = 0; + + testapp_print ("\nInput default account id : "); + + result_from_scanf = scanf("%d", &account_id); + + error_code = email_save_default_account_id(account_id); + + testapp_print("email_save_default_account_id returned [%d]\n",error_code); + return FALSE; +} + +static gboolean testapp_test_load_default_account_id() +{ + int error_code; + int account_id = 0; + + error_code = email_load_default_account_id(&account_id); + + testapp_print ("\ndefault account id : %d\n", account_id); + testapp_print("email_load_default_account_id returned [%d]\n",error_code); + return FALSE; +} + +static gboolean testapp_test_add_certificate() +{ + int result_from_scanf = 0; + int ret = 0; + char save_name[50] = {0, }; + char certificate_path[255] = {0, }; + + testapp_print("Input cert path : "); + result_from_scanf = scanf("%s", certificate_path); + + testapp_print("Input cert email-address : "); + result_from_scanf = scanf("%s", save_name); + + testapp_print("cert path : [%s]", certificate_path); + testapp_print("email-address : [%s]", save_name); + + ret = email_add_certificate(certificate_path, save_name); + if (ret != EMAIL_ERROR_NONE) { + testapp_print("Add certificate failed\n"); + return false; + } + + testapp_print("Add certificate success\n"); + return true; +} + +static gboolean testapp_test_get_certificate() +{ + int result_from_scanf = 0; + int ret = 0; + char save_name[20] = {0, }; + email_certificate_t *certificate = NULL; + + testapp_print("Input cert email-address : "); + result_from_scanf = scanf("%s", save_name); + + ret = email_get_certificate(save_name, &certificate); + if (ret != EMAIL_ERROR_NONE) { + testapp_print("Get certificate failed\n"); + return false; + } + + testapp_print("certificate_id : %d\n", certificate->certificate_id); + testapp_print("issue_year : %d\n", certificate->issue_year); + testapp_print("issue_month : %d\n", certificate->issue_month); + testapp_print("issue_day : %d\n", certificate->issue_day); + testapp_print("expiration_year : %d\n", certificate->expiration_year); + testapp_print("expiration_month : %d\n", certificate->expiration_month); + testapp_print("expiration_day : %d\n", certificate->expiration_day); + testapp_print("issue_organization_name : %s\n", certificate->issue_organization_name); + testapp_print("subject_string : %s\n", certificate->subject_str); + testapp_print("file path : %s\n", certificate->filepath); + + if (certificate) + email_free_certificate(&certificate, 1); + + testapp_print("Get certificate success\n"); + return true; +} + +static gboolean testapp_test_delete_certificate() +{ + int result_from_scanf = 0; + int ret = 0; + char save_name[20] = {0, }; + + testapp_print("Input cert email-address : "); + result_from_scanf = scanf("%s", save_name); + + ret = email_delete_certificate(save_name); + if (ret != EMAIL_ERROR_NONE) { + testapp_print("Delete certificate failed\n"); + return false; + } + + testapp_print("Delete certificate success\n"); + return true; +} static gboolean testapp_test_interpret_command (int selected_number) { gboolean go_to_loop = TRUE; @@ -609,12 +790,15 @@ static gboolean testapp_test_interpret_command (int selected_number) case 1: testapp_test_create_account(); break; + case 2: testapp_test_update_account(); break; + case 3: testapp_test_delete_account(); break; + case 4: testapp_test_get_account(); break; @@ -651,6 +835,26 @@ static gboolean testapp_test_interpret_command (int selected_number) testapp_test_clear_all_notification(); break; + case 14: + testapp_test_save_default_account_id(); + break; + + case 15: + testapp_test_load_default_account_id(); + break; + + case 16: + testapp_test_add_certificate(); + break; + + case 17: + testapp_test_get_certificate(); + break; + + case 18: + testapp_test_delete_certificate(); + break; + case 0: go_to_loop = FALSE; break; @@ -666,12 +870,13 @@ void testapp_account_main () { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_ACCOUNT_MENU); - testapp_show_prompt (EMF_ACCOUNT_MENU); + testapp_show_menu (EMAIL_ACCOUNT_MENU); + testapp_show_prompt (EMAIL_ACCOUNT_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf ("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-mail.c b/utilities/test-application/testapp-mail.c index 219480e..b7870af 100755 --- a/utilities/test-application/testapp-mail.c +++ b/utilities/test-application/testapp-mail.c @@ -35,34 +35,36 @@ #include "email-api-network.h" #include "email-api-mail.h" #include "email-api-mailbox.h" +#include "email-api-etc.h" /* internal header */ #include "testapp-utility.h" #include "testapp-mail.h" #include "email-core-utils.h" +#include "email-core-mime.h" #define MAIL_TEMP_BODY "/tmp/mail.txt" /* static void testapp_test_print_sorting_menu() { - testapp_print(" EMF_SORT_DATETIME_HIGH = 0\n"); - testapp_print(" EMF_SORT_DATETIME_LOW = 1\n"); - testapp_print(" EMF_SORT_SENDER_HIGH = 2\n"); - testapp_print(" EMF_SORT_SENDER_LOW = 3\n"); - testapp_print(" EMF_SORT_RCPT_HIGH = 4\n"); - testapp_print(" EMF_SORT_RCPT_LOW = 5\n"); - testapp_print(" EMF_SORT_SUBJECT_HIGH = 6\n"); - testapp_print(" EMF_SORT_SUBJECT_LOW = 7\n"); - testapp_print(" EMF_SORT_PRIORITY_HIGH = 8\n"); - testapp_print(" EMF_SORT_PRIORITY_LOW = 9\n"); - testapp_print(" EMF_SORT_ATTACHMENT_HIGH = 10\n"); - testapp_print(" EMF_SORT_ATTACHMENT_LOW = 11\n"); - testapp_print(" EMF_SORT_FAVORITE_HIGH = 12\n"); - testapp_print(" EMF_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(emf_mail_list_item_t *mail_list_item, int count) +static void testapp_test_print_mail_list_item(email_mail_list_item_t *mail_list_item, int count) { int i; @@ -107,41 +109,44 @@ static void testapp_test_print_mail_list_item(emf_mail_list_item_t *mail_list_it static gboolean testapp_test_add_mail (int *result_mail_id) { + int result_from_scanf = 0; int i = 0; int account_id = 0; + int mailbox_id = 0; int from_eas = 0; int attachment_count = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int smime_type = 0; char arg[50] = { 0 , }; const char *body_file_path = MAIL_TEMP_BODY; - emf_mailbox_t *mailbox_data = NULL; - emf_mail_data_t *test_mail_data = NULL; - emf_attachment_data_t *attachment_data = NULL; - emf_meeting_request_t *meeting_req = NULL; + 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 : "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); memset(arg, 0x00, 50); - testapp_print("\n > Enter mailbox name : "); - scanf("%s", arg); + testapp_print("\n > Enter mailbox id : "); + result_from_scanf = scanf("%d", &mailbox_id); - email_get_mailbox_by_name(account_id, arg, &mailbox_data); + email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data); - test_mail_data = malloc(sizeof(emf_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(emf_mail_data_t)); + test_mail_data = malloc(sizeof(email_mail_data_t)); + memset(test_mail_data, 0x00, sizeof(email_mail_data_t)); testapp_print("\n Sync server? [0/1]> "); - scanf("%d", &from_eas); + result_from_scanf = scanf("%d", &from_eas); 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_name = strdup(mailbox_data->name); + 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>"); @@ -157,51 +162,58 @@ static gboolean testapp_test_add_mail (int *result_mail_id) 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: Encrpyt, 3: sing + encrypt] : "); + result_from_scanf = scanf("%d", &smime_type); + test_mail_data->smime_type = smime_type; - testapp_print(" > Attach file? [0/1] : "); - scanf("%d",&attachment_count); + testapp_print(" > How many file attachment? [>=0] : "); + result_from_scanf = scanf("%d",&attachment_count); - if ( attachment_count ) { + 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 : "); - scanf("%s", arg); + result_from_scanf = scanf("%s", arg); - attachment_data = malloc(sizeof(emf_attachment_data_t)); - - attachment_data->attachment_name = strdup(arg); + attachment_data[i].attachment_name = strdup(arg); memset(arg, 0x00, 50); testapp_print("\n > Enter attachment absolute path : "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); - attachment_data->attachment_path = strdup(arg); - attachment_data->save_status = 1; - test_mail_data->attachment_count = attachment_count; + 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)]"); - scanf("%d", &(test_mail_data->meeting_request_status)); + result_from_scanf = scanf("%d", &(test_mail_data->meeting_request_status)); 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(emf_meeting_request_t)); - memset(meeting_req, 0x00, sizeof(emf_meeting_request_t)); + 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->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"); @@ -214,7 +226,7 @@ static gboolean testapp_test_add_mail (int *result_mail_id) } - if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE) + 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"); @@ -238,45 +250,46 @@ static gboolean testapp_test_add_mail (int *result_mail_id) static gboolean testapp_test_update_mail() { + int result_from_scanf = 0; int mail_id = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; int test_attachment_data_count = 0; char arg[50]; - emf_mail_data_t *test_mail_data = NULL; - emf_attachment_data_t *test_attachment_data_list = NULL; - emf_meeting_request_t *meeting_req = NULL; + 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 : "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); email_get_mail_data(mail_id, &test_mail_data); testapp_print("\n > Enter Subject: "); - scanf("%s", arg); + result_from_scanf = scanf("%s", 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)) != EMF_ERROR_NONE ) { + if ( (err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE ) { testapp_print("email_get_meeting_request() failed [%d]\n", err); return FALSE; } } - if ( test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST - || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE - || test_mail_data->meeting_request_status == EMF_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)) != EMF_ERROR_NONE ) { + if ( (err = email_get_meeting_request(mail_id, &meeting_req)) != EMAIL_ERROR_NONE ) { testapp_print("email_get_meeting_request() failed [%d]\n", err); return FALSE; } testapp_print("\n > Enter meeting response: "); - scanf("%d", (int*)&(meeting_req->meeting_response)); + result_from_scanf = scanf("%d", (int*)&(meeting_req->meeting_response)); } - if ( (err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMF_ERROR_NONE) + 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"); @@ -296,39 +309,40 @@ static gboolean testapp_test_update_mail() static gboolean testapp_test_get_mails() { testapp_print("\n >>> testapp_test_get_mails : Entered \n"); - emf_mail_data_t *mails = NULL, **mails_pointer = NULL; - char mailbox_name[50] = { 0, }; + 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 = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; int to_get_count = 0; int is_for_thread_view = 0; int list_type; + int result_from_scanf = 0; struct tm *temp_time_info; testapp_print("\n > Enter Account_id (0 = all accounts) : "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); - testapp_print("\n > Enter Mailbox name (0 = all mailboxes) :"); - scanf("%s", mailbox_name); + testapp_print("\n > Enter Mailbox id (0 = all mailboxes) :"); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter Sorting : "); - scanf("%d",&sorting); + result_from_scanf = scanf("%d",&sorting); - testapp_print("\n > Enter Start index : "); - scanf("%d",&start_index); + testapp_print("\n > Enter Start index (starting at 0): "); + result_from_scanf = scanf("%d",&start_index); testapp_print("\n > Enter max_count : "); - scanf("%d",&limit_count); + result_from_scanf = scanf("%d",&limit_count); testapp_print("\n > For thread view : "); - scanf("%d",&is_for_thread_view); + result_from_scanf = scanf("%d",&is_for_thread_view); - testapp_print("\n > To get count : "); - scanf("%d",&to_get_count); + testapp_print("\n > Mail count only (0:list 1:count): "); + result_from_scanf = scanf("%d",&to_get_count); if(to_get_count) mails_pointer = NULL; @@ -336,23 +350,23 @@ static gboolean testapp_test_get_mails() mails_pointer = &mails; if(is_for_thread_view == -2) { - list_type = EMF_LIST_TYPE_LOCAL; + list_type = EMAIL_LIST_TYPE_LOCAL; } else if(is_for_thread_view == -1) - list_type = EMF_LIST_TYPE_THREAD; + list_type = EMAIL_LIST_TYPE_THREAD; else - list_type = EMF_LIST_TYPE_NORMAL; + list_type = EMAIL_LIST_TYPE_NORMAL; /* Get mail list */ - if(strcmp(mailbox_name, "0") == 0) { - testapp_print("Calling email_get_mail_list_ex for all mailbox.\n"); - err_code = email_get_mails(account_id, NULL, list_type, start_index, limit_count, sorting, mails_pointer, &count); + if(mailbox_id == 0) { + testapp_print("Calling email_get_mail_list 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_mail_list_ex for %s mailbox.\n", mailbox_name); - err_code = email_get_mails(account_id, mailbox_name, list_type, start_index, limit_count, sorting, mails_pointer, &count); + testapp_print("Calling email_get_mail_list 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); } @@ -361,7 +375,7 @@ static gboolean testapp_test_get_mails() if (mails) { for (i=0; i< count; i++) { testapp_print("\n[%d]\n", i); - testapp_print(" >>> mailbox_name [ %s ] \n", mails[i].mailbox_name); + 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 ) @@ -372,7 +386,13 @@ static gboolean testapp_test_get_mails() 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 + 1970, temp_time_info->tm_mon, temp_time_info->tm_mday, temp_time_info->tm_hour, temp_time_info->tm_min, temp_time_info->tm_sec); + 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); @@ -393,25 +413,25 @@ static gboolean testapp_test_get_mails() static gboolean testapp_test_mail_send (int *result_mail_id) { int added_mail_id = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; unsigned handle = 0; - emf_option_t option = { 0 }; - emf_mailbox_t mailbox_data = { 0 }; - emf_mail_data_t *result_mail_data = NULL; + email_option_t option = { 0 }; + email_mailbox_t mailbox_data = { 0 }; + email_mail_data_t *result_mail_data = NULL; testapp_test_add_mail(&added_mail_id); if(result_mail_id) { email_get_mail_data(added_mail_id, &result_mail_data); - memset(&mailbox_data, 0x00, sizeof(emf_mailbox_t)); - mailbox_data.account_id = result_mail_data->account_id; - mailbox_data.name = result_mail_data->mailbox_name; - option.keep_local_copy = 1; + memset(&mailbox_data, 0x00, sizeof(email_mailbox_t)); + mailbox_data.account_id = result_mail_data->account_id; + mailbox_data.mailbox_id = result_mail_data->mailbox_id; + option.keep_local_copy = 1; testapp_print("Calling email_send_mail...\n"); - if( email_send_mail(&mailbox_data, added_mail_id, &option, &handle) < 0) { + if( email_send_mail(added_mail_id, &option, &handle) < 0) { testapp_print("Sending failed[%d]\n", err); } else { @@ -427,6 +447,104 @@ static gboolean testapp_test_mail_send (int *result_mail_id) return FALSE; } +static gboolean testapp_test_get_mail_list() +{ + email_list_filter_t *filter_list = NULL; + email_list_sorting_rule_t *sorting_rule_list = NULL; + email_mail_list_item_t *result_mail_list = NULL; + int result_mail_count = 0; + int err = EMAIL_ERROR_NONE; + int i = 0; + + filter_list = malloc(sizeof(email_list_filter_t) * 9); + memset(filter_list, 0 , sizeof(email_list_filter_t) * 9); + + 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; + + 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; + */ + + sorting_rule_list = malloc(sizeof(email_list_sorting_rule_t) * 2); + memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * 2); + + sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT; + sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_ASCEND; + sorting_rule_list[0].force_boolean_check = true; + + sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME; + sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_ASCEND; + + err = email_get_mail_list_ex(filter_list, 9, sorting_rule_list, 2, -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], from [%s]\n", result_mail_list[i].mail_id, result_mail_list[i].subject, result_mail_list[i].from); + } + } + else { + testapp_print("email_get_mail_list_ex failed.\n"); + } + + email_free_list_filter(&filter_list, 9); + + return FALSE; +} + static gboolean testapp_test_send_cancel () { int num = 0; @@ -435,9 +553,10 @@ static gboolean testapp_test_send_cancel () int j = 0; int *mailIdList = NULL; int mail_id = 0; + int result_from_scanf = 0; testapp_print("\n > Enter total Number of mail want to send: "); - scanf("%d", &num); + result_from_scanf = scanf("%d", &num); mailIdList = (int *)malloc(sizeof(int)*num); if(!mailIdList) return false ; @@ -452,15 +571,15 @@ static gboolean testapp_test_send_cancel () mail_id = 0; testapp_print("\n > Do you want to cancel the send mail job '1' or '0': "); - scanf("%d", &Y); + result_from_scanf = scanf("%d", &Y); if(Y == 1) { testapp_print("\n >Enter mail-id[1-%d] ",i); - scanf("%d", &j); + result_from_scanf = scanf("%d", &j); testapp_print("\n mailIdList[%d] ",mailIdList[j]); - if(email_cancel_send_mail( mailIdList[j]) < 0) - testapp_print("EmfMailSendCancel failed..!"); + if(email_cancel_sending_mail( mailIdList[j]) < 0) + testapp_print("email_cancel_sending_mail failed..!"); else - testapp_print("EmfMailSendCancel success..!"); + testapp_print("email_cancel_sending_mail success..!"); } } return FALSE; @@ -469,36 +588,29 @@ static gboolean testapp_test_send_cancel () static gboolean testapp_test_delete() { int mail_id=0, account_id =0; - emf_mailbox_t mbox = {0}; - char arg[10]; - int err = EMF_ERROR_NONE; + int mailbox_id = 0; + int err = EMAIL_ERROR_NONE; int from_server = 0; + int result_from_scanf = 0; testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter Mail_id: "); - scanf("%d",&mail_id); + result_from_scanf = scanf("%d", &mail_id); - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); + testapp_print("\n > Enter Mailbox id: "); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter from_server: "); - scanf("%d",&from_server); - - mbox.account_id = account_id; - mbox.name = strdup(arg); - + result_from_scanf = scanf("%d", &from_server); /* delete message */ - if( (err = email_delete_message(&mbox, &mail_id, 1, from_server)) < 0) - testapp_print("\n email_delete_message failed[%d]\n", err); + 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_message success\n"); + testapp_print("\n email_delete_mail success\n"); - if ( mbox.name ) - free(mbox.name); - return FALSE; } @@ -507,50 +619,37 @@ static gboolean testapp_test_delete() static gboolean testapp_test_move() { int mail_id[3]; - int account_id =0; - emf_mailbox_t mbox; - char arg[10]; int i = 0; - - testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); + int mailbox_id = 0; + int result_from_scanf = 0; for(i = 0; i< 3; i++) { - testapp_print("\n > Enter Mail_id: "); - scanf("%d",&mail_id[i]); + testapp_print("\n > Enter mail_id: "); + result_from_scanf = scanf("%d",&mail_id[i]); } - memset(&mbox, 0x00, sizeof(emf_mailbox_t)); - - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); - mbox.account_id = account_id; - mbox.name = strdup(arg); - /* move message */ - email_move_mail_to_mailbox(mail_id, 3, &mbox); + testapp_print("\n > Enter mailbox_id: "); + result_from_scanf = scanf("%d", &mailbox_id); + + /* move mail */ + email_move_mail_to_mailbox(mail_id, 3, mailbox_id); return FALSE; } static gboolean testapp_test_delete_all() { - int account_id =0; - emf_mailbox_t mbox = {0}; - char arg[100] = {0}; - int err = EMF_ERROR_NONE; - testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); - - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); - - mbox.account_id = account_id; - mbox.name = strdup(arg); + int mailbox_id =0; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + testapp_print("\n > Enter mailbox_id: "); + result_from_scanf = scanf("%d",&mailbox_id); + /* delete all message */ - if ( (err = email_delete_all_message_in_mailbox(&mbox, 0)) < 0) - testapp_print("email_delete_all_message_in_mailbox failed[%d]\n", err); + 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_message_in_mailbox Success\n"); + testapp_print("email_delete_all_mails_in_mailbox Success\n"); return FALSE; } @@ -558,41 +657,28 @@ static gboolean testapp_test_delete_all() static gboolean testapp_test_add_attachment() { - int account_id = 0; int mail_id = 0; + int result_from_scanf = 0; char arg[100]; - emf_mailbox_t mbox; - emf_attachment_info_t attachment; + email_attachment_data_t attachment; testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); - - testapp_print("\n > Enter Account_id: "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d", &mail_id); - memset(arg, 0x00, 100); - testapp_print("\n > Enter Mailbox name: "); - scanf("%s",arg); - - memset(&mbox, 0x00, sizeof(emf_attachment_info_t)); - mbox.account_id = account_id; - mbox.name = strdup(arg); - - memset(&attachment, 0x00, sizeof(emf_attachment_info_t)); + memset(&attachment, 0x00, sizeof(email_attachment_data_t)); memset(arg, 0x00, 100); testapp_print("\n > Enter attachment name: "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); - attachment.name = strdup(arg); + attachment.attachment_name = strdup(arg); memset(arg, 0x00, 100); testapp_print("\n > Enter attachment absolute path: "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); - attachment.downloaded = true; - attachment.savename = strdup(arg); - attachment.next = NULL; - if(email_add_attachment( &mbox, mail_id, &attachment) < 0) + 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"); @@ -602,42 +688,88 @@ static gboolean testapp_test_add_attachment() } +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; + int result_from_scanf = 0; + + testapp_print("\n >>> Input target account id: "); + result_from_scanf = scanf("%d", &account_id); + + do { + testapp_print("\n >>> Input target mail id ( Input 0 to terminate ) [MAX = 100]: "); + result_from_scanf = scanf("%d", &temp_mail_id); + 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; + unsigned handle = 0; + int result_from_scanf = 0; + + testapp_print("\n >>> Input target mailbox id: "); + result_from_scanf = scanf("%d", &mailbox_id); + + testapp_print("\n >>> Expunge on server?: "); + result_from_scanf = scanf("%d", &on_server); + + 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); + + return 0; +} + static gboolean testapp_test_get_mail_list_ex() { testapp_print("\n >>> testapp_test_get_mail_list_ex : Entered \n"); - emf_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL; - char mailbox_name[50] = { 0, }; + 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 = EMF_ERROR_NONE; + 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; + int result_from_scanf = 0; testapp_print("\n > Enter Account_id (0 = all accounts) : "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); - testapp_print("\n > Enter Mailbox name (0 = all mailboxes) :"); - scanf("%s", mailbox_name); + testapp_print("\n > Enter Mailbox id (0 = all mailboxes) :"); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter Sorting : "); - scanf("%d",&sorting); + result_from_scanf = scanf("%d",&sorting); - testapp_print("\n > Enter Start index : "); - scanf("%d",&start_index); + testapp_print("\n > Enter Start index (starting at 0): "); + result_from_scanf = scanf("%d",&start_index); testapp_print("\n > Enter max_count : "); - scanf("%d",&limit_count); + result_from_scanf = scanf("%d",&limit_count); testapp_print("\n > For thread view : "); - scanf("%d",&is_for_thread_view); + result_from_scanf = scanf("%d",&is_for_thread_view); - testapp_print("\n > To get count : "); - scanf("%d",&to_get_count); + testapp_print("\n > Count mails?(1: YES):"); + result_from_scanf = scanf("%d",&to_get_count); if(to_get_count) mail_list_pointer = NULL; @@ -645,32 +777,32 @@ static gboolean testapp_test_get_mail_list_ex() mail_list_pointer = &mail_list; if(is_for_thread_view == -2) { - list_type = EMF_LIST_TYPE_LOCAL; + list_type = EMAIL_LIST_TYPE_LOCAL; } else if(is_for_thread_view == -1) - list_type = EMF_LIST_TYPE_THREAD; + list_type = EMAIL_LIST_TYPE_THREAD; else - list_type = EMF_LIST_TYPE_NORMAL; + list_type = EMAIL_LIST_TYPE_NORMAL; /* Get mail list */ - if(strcmp(mailbox_name, "0") == 0) { - testapp_print("Calling email_get_mail_list_ex for all mailbox.\n"); - err_code = email_get_mail_list_ex(account_id, NULL, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); + 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_ex failed - err[%d]\n", err_code); + testapp_print("email_get_mail_list failed - err[%d]\n", err_code); } else { - testapp_print("Calling email_get_mail_list_ex for %s mailbox.\n", mailbox_name); - err_code = email_get_mail_list_ex(account_id, mailbox_name, list_type, start_index, limit_count, sorting, mail_list_pointer, &count); + 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_ex failed - err[%d]\n", err_code); + testapp_print("email_get_mail_list failed - err[%d]\n", err_code); } - testapp_print("email_get_mail_list_ex >>>>>>count - %d\n",count); + 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_name [ %s ] \n", mail_list[i].mailbox_name); + testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id); 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].from != NULL ) @@ -681,7 +813,13 @@ static gboolean testapp_test_get_mail_list_ex() testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); testapp_print(" >>> is_text_downloaded [ %d ] \n", mail_list[i].is_text_downloaded); 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 + 1970, temp_time_info->tm_mon, temp_time_info->tm_mday, temp_time_info->tm_hour, temp_time_info->tm_min, temp_time_info->tm_sec); + 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); @@ -693,7 +831,7 @@ static gboolean testapp_test_get_mail_list_ex() free(mail_list); } - testapp_print("\n >>> email_get_mail_list_ex : End \n"); + testapp_print("\n >>> email_get_mail_list : End \n"); return 0; } @@ -701,24 +839,24 @@ static gboolean testapp_test_get_mail_list_ex() static gboolean testapp_test_get_mail_list_for_thread_view() { testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : Entered \n"); - emf_mail_list_item_t *mail_list = NULL; + email_mail_list_item_t *mail_list = NULL; int count = 0, i = 0; int account_id = 0; - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; struct tm *time_info; /* Get mail list */ - if ( email_get_mail_list_ex(account_id, NULL , EMF_LIST_TYPE_THREAD, 0, 500, EMF_SORT_DATETIME_HIGH, &mail_list, &count) < 0) { - testapp_print("email_get_mail_list_ex failed : %d\n",err_code); + if ( email_get_mail_list(account_id, 0 , 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_ex >>>>>>count - %d\n",count); + 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 Name [ %s ] \n", mail_list[i].mailbox_name); + testapp_print(" >>> Mailbox id [ %d ] \n", mail_list[i].mailbox_id); testapp_print(" >>> From [ %s ] \n", mail_list[i].from); testapp_print(" >>> recipients [ %s ] \n", mail_list[i].recipients); testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject); @@ -742,83 +880,46 @@ static gboolean testapp_test_get_mail_list_for_thread_view() static gboolean testapp_test_count () { - emf_mailbox_t mailbox; - int account_id = 0; int total = 0; int unseen = 0; - char arg[50]; - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - - testapp_print("\n > Enter account_id (0 means all accounts) : "); - scanf("%d", &account_id); - - if(account_id == 0) { - mailbox.name = NULL; - } - else { - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - mailbox.name = strdup(arg); - } - - mailbox.account_id = account_id; - if(email_count_message(&mailbox, &total, &unseen) >= 0) - testapp_print("\n Total: %d, Unseen: %d \n", total, unseen); - - return TRUE; -} - -static gboolean testapp_test_modify_flag() -{ - emf_mail_flag_t newflag; - int mail_id = 0; - - memset(&newflag, 0x00, sizeof(emf_mail_flag_t)); - newflag.seen = 1; - newflag.answered = 0; - newflag.sticky = 1; - - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + email_list_filter_t *filter_list = NULL; - if(email_modify_mail_flag(mail_id, newflag, 1) < 0) - testapp_print("email_modify_mail_flag failed"); - else - testapp_print("email_modify_mail_flag success"); - - return TRUE; -} + filter_list = malloc(sizeof(email_list_filter_t) * 3); + memset(filter_list, 0 , sizeof(email_list_filter_t) * 3); -static gboolean testapp_test_modify_extra_flag () -{ - emf_extra_flag_t newflag; - int mail_id = 0; + 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; - memset(&newflag, 0x00, sizeof(emf_extra_flag_t)); + 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; - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + 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_modify_extra_mail_flag(mail_id, newflag) < 0) - testapp_print("email_modify_extra_mail_flag failed"); - else - testapp_print("email_modify_extra_mail_flag success"); - return TRUE; + if(EMAIL_ERROR_NONE == email_count_mail(filter_list, 3, &total, &unseen)) + printf("\n Total: %d, Unseen: %d \n", total, unseen); + return 0; } static gboolean testapp_test_set_flags_field () { int account_id = 0; int mail_id = 0; + int result_from_scanf = 0; testapp_print("\n > Enter Account ID: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter Mail ID: "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); - if(email_set_flags_field(account_id, &mail_id, 1, EMF_FLAGS_FLAGGED_FIELD, 1, 1) < 0) + 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"); @@ -829,25 +930,12 @@ static gboolean testapp_test_set_flags_field () static gboolean testapp_test_download_body () { int mail_id = 0; - int account_id = 0; - char arg[50]; unsigned handle = 0, err; - - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + int result_from_scanf = 0; - testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); - - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - - mailbox.name = strdup(arg); - mailbox.account_id = account_id; - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); - err = email_download_body(&mailbox, mail_id, 0, &handle); + result_from_scanf = scanf("%d", &mail_id); + err = email_download_body(mail_id, 0, &handle); if(err < 0) testapp_print("email_download_body failed"); else { @@ -863,35 +951,29 @@ static gboolean testapp_test_cancel_download_body () int mail_id = 0; int account_id = 0; int yes = 0; - char arg[50]; unsigned handle = 0; + int result_from_scanf = 0; - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + email_mailbox_t mailbox; + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); - - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - - mailbox.name = strdup(arg); - mailbox.account_id = account_id; + result_from_scanf = scanf("%d", &account_id); - testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + testapp_print("\n > Enter mail id: "); + result_from_scanf = scanf("%d", &mail_id); - if( email_download_body(&mailbox, mail_id, 0, &handle) < 0) + 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"); - scanf("%d",&yes); + result_from_scanf = scanf("%d",&yes); if(1 == yes) { - if(email_cancel_job(account_id, handle) < 0) - testapp_print("EmfCancelJob failed..!"); + if(email_cancel_job(account_id, handle , EMAIL_CANCELED_BY_USER) < 0) + testapp_print("email_cancel_job failed..!"); else { - testapp_print("EmfCancelJob success..!"); + testapp_print("email_cancel_job success..!"); testapp_print("handle[%d]\n", handle); } } @@ -902,271 +984,74 @@ static gboolean testapp_test_cancel_download_body () static gboolean testapp_test_download_attachment () { int mail_id = 0; - int account_id = 0; - char arg[50]; + int attachment_no = 0; unsigned handle = 0; - - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - - testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter maibox name: "); - scanf("%s", arg); - - mailbox.name = strdup(arg); - mailbox.account_id = account_id; + int result_from_scanf = 0; testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); - - memset(arg, 0x00, 50); + result_from_scanf = scanf("%d", &mail_id); + testapp_print("\n > Enter attachment number: "); - scanf("%s",arg); + result_from_scanf = scanf("%d", &attachment_no); - if( email_download_attachment(&mailbox, mail_id, arg ,&handle) < 0) + 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_retry_send() { int mail_id = 0; int timeout = 0; + int result_from_scanf = 0; - emf_mailbox_t mailbox; - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); + email_mailbox_t mailbox; + memset(&mailbox, 0x00, sizeof(email_mailbox_t)); testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); testapp_print("\n > Enter timeout in seconds: "); - scanf("%d", &timeout); + result_from_scanf = scanf("%d", &timeout); - if( email_retry_send_mail(mail_id, timeout) < 0) - testapp_print("email_retry_send_mail failed"); + if( email_retry_sending_mail(mail_id, timeout) < 0) + testapp_print("email_retry_sending_mail failed"); return TRUE; } -static gboolean testapp_test_find() -{ - int i, account_id = 0, result_count; - char mailbox_name[255] = { 0, }, *mailbox_name_pointer = NULL, search_keyword[255] = { 0, }; - emf_mail_list_item_t *mail_list = NULL; - - testapp_print("\n > Enter account_id : "); - scanf("%d", &account_id); - - testapp_print("\n > Enter maibox name [0 means all mailboxes] : "); - scanf("%s", mailbox_name); - - if(strcmp(mailbox_name, "0") == 0) - mailbox_name_pointer = NULL; - else - mailbox_name_pointer = mailbox_name; - - testapp_print("\n > Enter Keyword : "); - scanf("%s", search_keyword); - - if(email_find_mail(account_id, mailbox_name_pointer, EMF_LIST_TYPE_NORMAL, EMF_SEARCH_FILTER_ALL , search_keyword, -1, -1, EMF_SORT_DATETIME_HIGH, &mail_list, &result_count) == EMF_ERROR_NONE) { - testapp_print("\n Result count [%d]", result_count); - for(i = 0; i < result_count; i++) { - testapp_print("\nmail_id[%d], from[%s], subject[%s]", mail_list[i].mail_id, mail_list[i].from, mail_list[i].subject); - } - } - - if(mail_list) - free(mail_list); - - return TRUE; -} - -static gboolean testapp_test_count_message_on_sending() -{ - emf_mailbox_t mailbox; - int total_count; - int err = EMF_ERROR_NONE; - char temp[128]; - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - /* input mailbox information : need account_id and name */ - testapp_print("mail account id(0: All account)> "); - scanf("%d", &mailbox.account_id); - - testapp_print("mailbox_name(0 : NULL)> "); - scanf("%s", temp ); - if ( strcmp(temp, "0") == 0 ) { - mailbox.name = NULL; - } - else { - mailbox.name = malloc(strlen(temp) + 1); - if ( mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - return false; - } - strcpy(mailbox.name, temp); - } - - err = email_count_message_on_sending(&mailbox, &total_count); - if ( err < 0 ) { - testapp_print(" fail email_count_message_on_sending: err[%d]\n", err); - } - else { - testapp_print(" success email_count_message_on_sending: # of messages on senging status : %d\n", total_count); - } - - if ( mailbox.name ) { - free(mailbox.name); - mailbox.name = NULL; - } - return false; -} - - static gboolean testapp_test_move_all_mails_to_mailbox() { - emf_mailbox_t src_mailbox; - emf_mailbox_t dest_mailbox; - int err = EMF_ERROR_NONE; - char temp[128]; - - memset(&src_mailbox, 0x00, sizeof(emf_mailbox_t)); - memset(&dest_mailbox, 0x00, sizeof(emf_mailbox_t)); - - /* input mailbox information : need account_id and name (src & dest) */ - testapp_print("src mail account id(0: All account)> "); - scanf("%d", &src_mailbox.account_id); - - testapp_print("src mailbox_name(0 : NULL)> "); - scanf("%s", temp ); - if ( strcmp(temp, "0") == 0 ) { - src_mailbox.name = NULL; - } - else { - src_mailbox.name = malloc(strlen(temp) + 1); - if ( src_mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - return false; - } - strcpy(src_mailbox.name, temp); - } + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + int src_mailbox_id; + int dest_mailbox_id; - /* Destination mailbox */ - testapp_print("dest mail account id> "); - scanf("%d", &dest_mailbox.account_id); - if ( dest_mailbox.account_id <= 0 ) { - testapp_print("Invalid dest account_id[%d]\n", dest_mailbox.account_id); - goto FINISH_OFF; - } + testapp_print("src mailbox id> "); + result_from_scanf = scanf("%d", &src_mailbox_id); - testapp_print("dest mailbox_name> "); - scanf("%s", temp); - if ( strcmp(temp, "") == 0 ) { - testapp_print("Invalid dest mailbox_name[%s]\n", temp); - goto FINISH_OFF; - } - else { - dest_mailbox.name = malloc(strlen(temp) + 1); - if ( dest_mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - goto FINISH_OFF; - } - strcpy(dest_mailbox.name, temp); - } + testapp_print("dest mailbox id> "); + result_from_scanf = scanf("%d", &dest_mailbox_id); - err = email_move_all_mails_to_mailbox(&src_mailbox, &dest_mailbox); + err = email_move_all_mails_to_mailbox(src_mailbox_id, dest_mailbox_id); if ( err < 0 ) { - testapp_print(" fail email_move_all_mails_to_mailbox: err[%d]\n", err); + testapp_print("email_move_all_mails_to_mailbox failed: err[%d]\n", err); } else { - testapp_print(" success email_move_all_mails_to_mailbox: from [%d:%s] to [%d:%s]\n", src_mailbox.account_id, src_mailbox.name, dest_mailbox.account_id, dest_mailbox.name); + testapp_print("email_move_all_mails_to_mailbox suceeded\n"); } -FINISH_OFF: - if ( src_mailbox.name ) { - free(src_mailbox.name); - src_mailbox.name = NULL; - } - if ( dest_mailbox.name ) { - free(dest_mailbox.name); - dest_mailbox.name = NULL; - } return false; } -static gboolean testapp_test_count_message_with_draft_flag() -{ - emf_mailbox_t mailbox; - int total_count; - int err = EMF_ERROR_NONE; - char temp[128]; - - memset(&mailbox, 0x00, sizeof(emf_mailbox_t)); - /* input mailbox information : need account_id and name */ - testapp_print("mail account id(0: All account)> "); - scanf("%d", &mailbox.account_id); - - testapp_print("mailbox_name(0 : NULL)> "); - scanf("%s", temp ); - if ( strcmp(temp, "0") == 0 ) { - mailbox.name = NULL; - } - else { - mailbox.name = malloc(strlen(temp) + 1); - if ( mailbox.name == NULL ) { - testapp_print("fail malloc\n"); - return false; - } - strcpy(mailbox.name, temp); - } - - err = email_count_message_with_draft_flag(&mailbox, &total_count); - - if ( err < 0) { - testapp_print(" fail email_count_message_with_draft_flag: err[%d]\n", err); - } - else { - testapp_print(" success email_count_message_with_draft_flag: # of messages with draft flag : %d\n", total_count); - } - - if ( mailbox.name ) { - free(mailbox.name); - mailbox.name = NULL; - } - return false; -} - -/* sowmya.kr@samsung.com, 01282010 - Changes to get latest unread mail id for given account */ -static gboolean testapp_test_get_latest_unread_mail_id() -{ - - int mail_id = 0,account_id = 0; - int err = EMF_ERROR_NONE; - - - testapp_print("Enter account Id to get latest unread mail Id,<-1 to get latest irrespective of account id> "); - scanf("%d", &account_id); - - err = email_get_latest_unread_mail_id(account_id, &mail_id); - if ( err < 0) { - testapp_print(" fail email_get_latest_unread_mail_id: err[%d]\n", err); - } - else { - testapp_print(" success email_get_latest_unread_mail_id: Latest unread mail id : %d\n", mail_id); - } - return FALSE; -} - static gboolean testapp_test_get_totaldiskusage() { unsigned long total_size = 0; - int err_code = EMF_ERROR_NONE ; + int err_code = EMAIL_ERROR_NONE ; err_code = email_get_disk_space_usage(&total_size); if ( err_code < 0) @@ -1181,7 +1066,8 @@ static gboolean testapp_test_get_totaldiskusage() static gboolean testapp_test_db_test() { - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; int mail_id; int account_id; char *to = NULL; @@ -1197,15 +1083,15 @@ static gboolean testapp_test_db_test() memset(bcc, 0x00, sizeof(to)); testapp_print("Input Mail id:\n"); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); testapp_print("Input Account id:\n"); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("Input TO field:\n"); - scanf("%s", to); + result_from_scanf = scanf("%s", to); testapp_print("Input CC field:\n"); - scanf("%s", cc); + result_from_scanf = scanf("%s", cc); testapp_print("Input BCC field:\n"); - scanf("%s", bcc); + result_from_scanf = scanf("%s", bcc); if ( emstorage_test(mail_id, account_id, to, cc, bcc, &err) == true ) { testapp_print(">> Saving Succeeded\n"); @@ -1228,7 +1114,7 @@ static gboolean testapp_test_address_format_check_test() int type; int index; int check_yn; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; char *pAddress = NULL; char input_address[8096]; char *address_list[] = { @@ -1281,7 +1167,7 @@ static gboolean testapp_test_address_format_check_test() testapp_print("Select input method:\n"); testapp_print("1. Test data\n"); testapp_print("2. Keyboard\n"); - scanf("%d", &type); + result_from_scanf = scanf("%d", &type); switch ( type ) { case 1: @@ -1291,12 +1177,12 @@ static gboolean testapp_test_address_format_check_test() address_count++; } testapp_print("Choose address to be tested:[99:quit]\n"); - scanf("%d", &index); + result_from_scanf = scanf("%d", &index); if ( index == 99 ) break; testapp_print(">> [%d] Checking? (1:Yes, Other:No) [%s]\n", index, address_list[index]); - scanf("%d", &check_yn); + result_from_scanf = scanf("%d", &check_yn); if ( check_yn == 1 ) { pAddress = strdup(address_list[index]); if ( em_verify_email_address(pAddress, false, &err ) == true ) { @@ -1318,7 +1204,7 @@ static gboolean testapp_test_address_format_check_test() break; case 2: testapp_print("Input address: \n"); - scanf("%s", input_address); + result_from_scanf = scanf("%s", input_address); if ( em_verify_email_address(input_address, false, &err ) == true ) { testapp_print(">> Saving Succeeded : addr[%s]\n", input_address); } @@ -1337,7 +1223,7 @@ static gboolean testapp_test_address_format_check_test() static gboolean testapp_test_get_max_mail_count() { int max_count = -1; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; err = email_get_max_mail_count(&max_count); testapp_print("\n\t>>>>> email_get_max_mail_count() return [%d]\n\n", max_count); @@ -1349,9 +1235,9 @@ static gboolean testapp_test_get_max_mail_count() static gboolean testapp_test_test_get_thread_information() { int error_code, thread_id= 38; - emf_mail_list_item_t *result_mail; + email_mail_list_item_t *result_mail; - if( (error_code = email_get_thread_information_ex(thread_id, &result_mail)) == EMF_ERROR_NONE) { + 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); @@ -1363,51 +1249,6 @@ static gboolean testapp_test_test_get_thread_information() return TRUE; } - -static gboolean testapp_test_get_sender_list() -{ - testapp_print(" >>> testapp_test_get_sender_list : Entered \n"); - - char *mailbox_name = NULL; - int i = 0; - int account_id = 0; - int sorting = 0; - int err_code = EMF_ERROR_NONE; - emf_sender_list_t *sender_list = NULL; - int sender_count = 0; - - mailbox_name = NULL; - account_id = 0; - sorting = 0; - - if ( (err_code = email_get_sender_list(account_id, mailbox_name, EMF_SEARCH_FILTER_NONE, NULL, sorting, &sender_list, &sender_count)) != EMF_ERROR_NONE) { - testapp_print("email_get_sender_list failed : %d\n",err_code); - return FALSE; - } - - testapp_print("===================================================\n"); - testapp_print("\t\t\tSender list\n"); - testapp_print("===================================================\n"); - testapp_print("sender address \tdisplay_name\t [unread/total]\n"); - testapp_print("===================================================\n"); - for ( i =0; i < sender_count; i++ ) { - testapp_print("[%s]\t[%s]\t[%d/%d]\n", sender_list[i].address, sender_list[i].display_name, sender_list[i].unread_count, sender_list[i].total_count); - } - testapp_print("===================================================\n"); - - if ( sender_list ) { - email_free_sender_list(&sender_list, sender_count); - } - if ( mailbox_name ) { - free(mailbox_name); - mailbox_name = NULL; - } - - testapp_print(" >>> testapp_test_get_sender_list : END \n"); - return TRUE; -} - - static gboolean testapp_test_get_address_info_list() { testapp_print(" >>> testapp_test_get_address_info_list : Entered \n"); @@ -1415,22 +1256,17 @@ static gboolean testapp_test_get_address_info_list() char buf[1024]; int i = 0; int mail_id = 0; - int err_code = EMF_ERROR_NONE; - emf_address_info_list_t *address_info_list= NULL; - emf_address_info_t *p_address_info = NULL; + int result_from_scanf = 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: "); - scanf("%d",&mail_id); - + result_from_scanf = scanf("%d",&mail_id); - if ((err_code = email_get_address_info_list(mail_id, &address_info_list)) != EMF_ERROR_NONE) { - testapp_print("email_get_address_info_list failed : %d\n",err_code); - email_free_address_info_list(&address_info_list); - return FALSE; - } + email_get_address_info_list(mail_id, &address_info_list); testapp_print("===================================================\n"); testapp_print("\t\t\t address info list\n"); @@ -1438,18 +1274,18 @@ static gboolean testapp_test_get_address_info_list() testapp_print("address_type\t address \t\tdisplay_name\t contact id\n"); testapp_print("===================================================\n"); - for ( i = EMF_ADDRESS_TYPE_FROM; i <= EMF_ADDRESS_TYPE_BCC; i++ ) { + for ( i = EMAIL_ADDRESS_TYPE_FROM; i <= EMAIL_ADDRESS_TYPE_BCC; i++ ) { switch ( i ) { - case EMF_ADDRESS_TYPE_FROM: + case EMAIL_ADDRESS_TYPE_FROM: list = address_info_list->from; break; - case EMF_ADDRESS_TYPE_TO: + case EMAIL_ADDRESS_TYPE_TO: list = address_info_list->to; break; - case EMF_ADDRESS_TYPE_CC: + case EMAIL_ADDRESS_TYPE_CC: list = address_info_list->cc; break; - case EMF_ADDRESS_TYPE_BCC: + case EMAIL_ADDRESS_TYPE_BCC: list = address_info_list->bcc; break; } @@ -1457,7 +1293,7 @@ static gboolean testapp_test_get_address_info_list() /* delete dynamic-allocated memory for each item */ node = g_list_first(list); while ( node != NULL ) { - p_address_info = (emf_address_info_t*)node->data; + 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); @@ -1466,30 +1302,32 @@ static gboolean testapp_test_get_address_info_list() } testapp_print("===================================================\n"); - 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; } -static gboolean testapp_test_find_mail_on_server() +static gboolean testapp_test_search_mail_on_server() { - testapp_print(" >>> testapp_test_find_mail_on_server : Entered \n"); + testapp_print(" >>> testapp_test_search_mail_on_server : Entered \n"); - int err_code = EMF_ERROR_NONE; + int err_code = EMAIL_ERROR_NONE; int account_id = 0; + int mailbox_id = 0; int search_key_value_integer = 0; + int result_from_scanf = 0; email_search_filter_type search_filter_type = 0; email_search_filter_t search_filter; unsigned int handle = 0; - char mailbox_name[MAILBOX_NAME_LENGTH]; char search_key_value_string[MAX_EMAIL_ADDRESS_LENGTH]; testapp_print("input account id : "); - scanf("%d",&account_id); + result_from_scanf = scanf("%d",&account_id); - testapp_print("input mailbox name : "); - scanf("%s", mailbox_name); + testapp_print("input mailbox id : "); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print( " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, ( integet type ) \n" @@ -1513,7 +1351,7 @@ static gboolean testapp_test_find_mail_on_server() " EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, ( integet type ) \n" " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, ( string type ) \n"); testapp_print("input search filter type : "); - scanf("%d", (int*)&search_filter_type); + result_from_scanf = scanf("%d", (int*)&search_filter_type); search_filter.search_filter_type = search_filter_type; @@ -1529,7 +1367,7 @@ static gboolean testapp_test_find_mail_on_server() case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT : case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN : testapp_print("input search filter key value : "); - scanf("%d", &search_key_value_integer); + result_from_scanf = scanf("%d", &search_key_value_integer); search_filter.search_filter_key_value.integer_type_key_value = search_key_value_integer; break; @@ -1541,7 +1379,7 @@ static gboolean testapp_test_find_mail_on_server() case EMAIL_SEARCH_FILTER_TYPE_TO : case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID : testapp_print("input search filter key value : "); - scanf("%s", search_key_value_string); + result_from_scanf = scanf("%s", search_key_value_string); search_filter.search_filter_key_value.string_type_key_value = search_key_value_string; break; @@ -1549,7 +1387,7 @@ static gboolean testapp_test_find_mail_on_server() case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON : case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE : testapp_print("input search filter key value (format = YYYYMMDDHHMMSS) : "); - scanf("%s", search_key_value_string); + result_from_scanf = scanf("%s", search_key_value_string); /* TODO : write codes for converting string to time */ /* search_filter.search_filter_key_value.time_type_key_value = search_key_value_string; */ break; @@ -1558,11 +1396,11 @@ static gboolean testapp_test_find_mail_on_server() return FALSE; } - if( (err_code = email_search_mail_on_server(account_id, mailbox_name, &search_filter,1, &handle)) != EMF_ERROR_NONE) { + if( (err_code = email_search_mail_on_server(account_id, mailbox_id, &search_filter,1, &handle)) != EMAIL_ERROR_NONE) { testapp_print("email_search_mail_on_server failed [%d]", err_code); } - testapp_print(" >>> testapp_test_find_mail_on_server : END \n"); + testapp_print(" >>> testapp_test_search_mail_on_server : END \n"); return TRUE; } @@ -1572,32 +1410,33 @@ static gboolean testapp_test_add_mail_to_search_result_box() int account_id = 0; int from_eas = 0; int attachment_count = 0; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; char arg[50] = { 0 , }; char *body_file_path = MAIL_TEMP_BODY; - emf_mailbox_t *mailbox_data = NULL; - emf_mail_data_t *test_mail_data = NULL; - emf_attachment_data_t *attachment_data = NULL; - emf_meeting_request_t *meeting_req = NULL; + 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 : "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); - email_get_mailbox_by_name(account_id, EMF_SEARCH_RESULT_MAILBOX_NAME, &mailbox_data); + email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &mailbox_data); - test_mail_data = malloc(sizeof(emf_mail_data_t)); - memset(test_mail_data, 0x00, sizeof(emf_mail_data_t)); + 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]> "); - scanf("%d", &from_eas); + result_from_scanf = scanf("%d", &from_eas); 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_name = strdup(mailbox_data->name); + 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>"); @@ -1613,20 +1452,20 @@ static gboolean testapp_test_add_mail_to_search_result_box() fclose(body_file); testapp_print(" > Attach file? [0/1] : "); - scanf("%d",&attachment_count); + result_from_scanf = scanf("%d",&attachment_count); if ( attachment_count ) { memset(arg, 0x00, 50); testapp_print("\n > Enter attachment name : "); - scanf("%s", arg); + result_from_scanf = scanf("%s", arg); - attachment_data = malloc(sizeof(emf_attachment_data_t)); + 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 : "); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); attachment_data->attachment_path = strdup(arg); attachment_data->save_status = 1; @@ -1634,14 +1473,14 @@ static gboolean testapp_test_add_mail_to_search_result_box() } testapp_print("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]"); - scanf("%d", &(test_mail_data->meeting_request_status)); + result_from_scanf = scanf("%d", &(test_mail_data->meeting_request_status)); 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(emf_meeting_request_t)); - memset(meeting_req, 0x00, sizeof(emf_meeting_request_t)); + 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); @@ -1663,7 +1502,7 @@ static gboolean testapp_test_add_mail_to_search_result_box() } - if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE) + 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"); @@ -1682,6 +1521,67 @@ static gboolean testapp_test_add_mail_to_search_result_box() return FALSE; } +static gboolean testapp_test_email_load_eml_file() +{ + email_mail_data_t *mail_data = NULL; + email_attachment_data_t *mail_attachment_data = NULL; + int i = 0; + int attachment_count = 0; + int err = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + char eml_file_path[255] = {0, }; + + testapp_print("Input eml file path : "); + result_from_scanf = scanf("%s", eml_file_path); + + if ((err = email_open_eml_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) + { + testapp_print("email_open_eml_file failed : [%d]\n", err); + return false; + } + + testapp_print("load success\n"); + 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("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("inline content count : %d\n", mail_data->inline_content_count); + + for (i = 0;i < mail_data->attachment_count ; i++) { + testapp_print("attachment_id: %d\n", mail_attachment_data[i].attachment_id); + 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("mailbox_id: %d\n", mail_attachment_data[i].mailbox_id); + } + + testapp_print("Success : Open eml file\n"); + + if ((err = email_delete_eml_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"); + + if (mail_data) + email_free_mail_data(&mail_data, 1); + + 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; + +} + /* internal functions */ static gboolean testapp_test_interpret_command (int menu_number) { @@ -1692,25 +1592,28 @@ static gboolean testapp_test_interpret_command (int menu_number) testapp_test_get_mails(); break; case 2: - testapp_test_mail_send (NULL); + testapp_test_mail_send(NULL); + break; + case 3: + testapp_test_get_mail_list(); break; case 4: testapp_test_add_attachment(); break; - case 9: - testapp_test_count (); + case 5: + testapp_test_set_deleted_flag(); break; - case 10: - testapp_test_modify_flag(); + case 6: + testapp_test_expunge_mails_deleted_flagged(); + break; + case 9: + testapp_test_count(); break; - case 11: - testapp_test_modify_extra_flag (); - break; case 14: - testapp_test_delete (); + testapp_test_delete(); break; case 16: - testapp_test_download_body (); + testapp_test_download_body(); break; case 17: testapp_test_download_attachment(); @@ -1724,21 +1627,9 @@ static gboolean testapp_test_interpret_command (int menu_number) case 23: testapp_test_retry_send(); break; - case 24: - testapp_test_find(); - break; - case 26: - testapp_test_count_message_on_sending(); - break; case 27: testapp_test_move_all_mails_to_mailbox(); break; - case 28: - testapp_test_count_message_with_draft_flag(); - break; - case 29: - testapp_test_get_latest_unread_mail_id(); - break; case 38: testapp_test_get_totaldiskusage(); break; @@ -1763,18 +1654,12 @@ static gboolean testapp_test_interpret_command (int menu_number) case 48: testapp_test_test_get_thread_information(); break; - case 49: - testapp_test_get_sender_list(); - break; case 51: testapp_test_get_mail_list_ex(); break; case 52: testapp_test_get_address_info_list(); break; - case 54: - email_get_recipients_list(1, NULL, NULL); - break; case 55: testapp_test_set_flags_field(); break; @@ -1785,11 +1670,14 @@ static gboolean testapp_test_interpret_command (int menu_number) testapp_test_update_mail(); break; case 58: - testapp_test_find_mail_on_server(); + testapp_test_search_mail_on_server(); break; case 59: testapp_test_add_mail_to_search_result_box(); break; + case 60: + testapp_test_email_load_eml_file(); + break; case 0: go_to_loop = FALSE; break; @@ -1804,12 +1692,13 @@ void testapp_mail_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_MAIL_MENU); - testapp_show_prompt (EMF_MAIL_MENU); + testapp_show_menu(EMAIL_MAIL_MENU); + testapp_show_prompt(EMAIL_MAIL_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-mailbox.c b/utilities/test-application/testapp-mailbox.c index c267f29..ad7b961 100755 --- a/utilities/test-application/testapp-mailbox.c +++ b/utilities/test-application/testapp-mailbox.c @@ -37,45 +37,79 @@ #include "testapp-utility.h" #include "testapp-mailbox.h" +static gboolean testapp_print_mailbox_list(email_mailbox_t *input_mailbox_list, int input_count) +{ + int i; + char time_string[40] = { 0, }; + + + + testapp_print("There are %d mailboxes\n", input_count); + + testapp_print("============================================================================\n"); + testapp_print("id a_id name\t\t\t alias\t\t unread\t total\t total_on_ server\tmailbox_type\t last_sync_time\n"); + testapp_print("============================================================================\n"); + if ( input_count == 0 ) { + testapp_print("No mailbox is matched\n"); + } + else { + for(i=0;i<input_count;i++) { + strftime(time_string, 40, "%Y-%m-%d %H:%M:%S", localtime(&(input_mailbox_list[i].last_sync_time))); + testapp_print("[%2d]", input_mailbox_list[i].mailbox_id); + testapp_print(" %2d [%2d]\t[%-12s] ", input_mailbox_list[i].account_id, input_mailbox_list[i].mailbox_id, input_mailbox_list[i].alias); + testapp_print(" %3d\t %3d\t %3d\t %3d\t %s\n" + , input_mailbox_list[i].unread_count + , input_mailbox_list[i].total_mail_count_on_local + , input_mailbox_list[i].total_mail_count_on_server + , input_mailbox_list[i].mailbox_type + , time_string); + } + } + testapp_print("============================================================================\n"); + + return FALSE; +} + static gboolean testapp_test_add_mailbox() { - emf_mailbox_t mbox; + email_mailbox_t mailbox; int account_id,mailbox_type = 0; int local_yn = 0; char arg[500]; int ret; unsigned handle; + int result_from_scanf = 0; memset(arg, 0x00, 500); testapp_print("\n> Enter mailbox name: "); - scanf("%s",arg); - mbox.name = strdup(arg); + result_from_scanf = scanf("%s",arg); + mailbox.mailbox_name = strdup(arg); memset(arg, 0x00, 500); testapp_print("> Enter mailbox alias name: "); - scanf("%s",arg); - mbox.alias = strdup(arg); + result_from_scanf = scanf("%s",arg); + mailbox.alias = strdup(arg); testapp_print("> Enter account id: "); - scanf("%d", &account_id); - mbox.account_id = account_id; + result_from_scanf = scanf("%d", &account_id); + mailbox.account_id = account_id; testapp_print("> Enter local_yn (1/0): "); - scanf("%d", &local_yn); - mbox.local= local_yn; + result_from_scanf = scanf("%d", &local_yn); + mailbox.local= local_yn; testapp_print("> Enter mailbox type: "); - scanf("%d", &mailbox_type); - mbox.mailbox_type= mailbox_type; + result_from_scanf = scanf("%d", &mailbox_type); + mailbox.mailbox_type= mailbox_type; - ret = email_add_mailbox(&mbox, local_yn?0:1, &handle); + ret = email_add_mailbox(&mailbox, local_yn?0:1, &handle); if (ret < 0) { testapp_print("\n email_add_mailbox failed"); } else { - testapp_print("\n email_add_mailbox succeed : handle[%d]\n", handle); + testapp_print("\n email_add_mailbox succeed : handle[%d], mailbox_id [%d]\n", handle, mailbox.mailbox_id); } return FALSE; @@ -83,27 +117,19 @@ static gboolean testapp_test_add_mailbox() static gboolean testapp_test_delete_mailbox() { - - emf_mailbox_t mbox; - int account_id; - int local_yn = 0; - char arg[500]; + int mailbox_id = 0; + int on_server = 0; int ret; unsigned handle; + int result_from_scanf = 0; - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name:"); - scanf("%s",arg); - mbox.name = strdup(arg); + testapp_print("\n> Enter mailbox id:"); + result_from_scanf = scanf("%d", &mailbox_id); - testapp_print("> Enter account id: "); - scanf("%d", &account_id); - mbox.account_id = account_id; - - testapp_print("> Enter local_yn (1/0): "); - scanf("%d", &local_yn); + testapp_print("> Enter on_server (1/0): "); + result_from_scanf = scanf("%d", &on_server); - ret = email_delete_mailbox(&mbox, local_yn?0:1, &handle); + ret = email_delete_mailbox(mailbox_id, on_server, &handle); if ( ret < 0) { testapp_print("\n email_delete_mailbox failed"); @@ -116,55 +142,33 @@ static gboolean testapp_test_delete_mailbox() } -static gboolean testapp_test_update_mailbox() +static gboolean testapp_test_rename_mailbox() { - testapp_print ("testapp_test_update_mailbox - support ONLY updating mailbox type\n"); - emf_mailbox_t *old_mailbox_name = NULL; - emf_mailbox_t *new_mbox = NULL; - int account_id,mailbox_type = 0; - char arg[500]; + testapp_print ("testapp_test_rename_mailbox\n"); + int mailbox_id; + char mailbox_name[500] = { 0, }; + char mailbox_alias[500] = { 0, }; int err; - - memset(arg, 0x00, 500); + int result_from_scanf = 0; + unsigned handle = 0; - testapp_print("> Enter account id: "); - scanf("%d", &account_id); + testapp_print("> Enter mailbox id: "); + result_from_scanf = scanf("%d", &mailbox_id); - testapp_print("\n> Enter mailbox name: "); - scanf("%s", arg); - - testapp_print("> Enter mailbox type: "); - scanf("%d", &mailbox_type); + testapp_print("> Enter new mailbox name: "); + result_from_scanf = scanf("%s", mailbox_name); + + testapp_print("> Enter new mailbox name: "); + result_from_scanf = scanf("%s", mailbox_alias); - /* Get old mailbox information from db */ - if ( (err = email_get_mailbox_by_name(account_id, arg, &old_mailbox_name)) < 0 ) { - testapp_print("\n email_get_mailbox_by_name failed[%d]\n", err); - } - else { - testapp_print("\n email_get_mailbox_by_name succeed\n"); - } - - /* copy old maibox to new mailbox */ - if ( (err = email_get_mailbox_by_name(account_id, arg, &new_mbox)) < 0 ) { - testapp_print("\n email_get_mailbox_by_name failed[%d]\n", err); - } - else { - testapp_print("\n email_get_mailbox_by_name succeed\n"); - } - - /* set new value of new mailbox */ - new_mbox->mailbox_type= mailbox_type; - if ( (err = email_update_mailbox(old_mailbox_name, new_mbox)) < 0) { - testapp_print("\n email_update_mailbox failed[%d]\n", err); + if ( (err = email_rename_mailbox(mailbox_id, mailbox_name, mailbox_alias, true, &handle)) < 0) { + testapp_print("\n email_rename_mailbox failed[%d]\n", err); } else { - testapp_print("\n email_update_mailbox succeed\n"); + testapp_print("\n email_rename_mailbox succeed\n"); } - email_free_mailbox(&old_mailbox_name, 1); - email_free_mailbox(&new_mbox, 1); - return FALSE; } @@ -172,124 +176,82 @@ static gboolean testapp_test_get_imap_mailbox_list() { int account_id = 0; unsigned handle = 0; + int result_from_scanf = 0; testapp_print("> Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); - if( email_get_imap_mailbox_list(account_id, "", &handle) < 0) - testapp_print("email_get_imap_mailbox_list failed"); + if( email_sync_imap_mailbox_list(account_id, &handle) < 0) + testapp_print("email_sync_imap_mailbox_list failed"); return FALSE; } -static gboolean testapp_test_get_child_mailbox_list () +static gboolean testapp_test_get_mailbox_by_type () { - int account_id =0; - int count = 0; - int i = 0, err_code = EMF_ERROR_NONE; - emf_mailbox_t *mailbox_list=NULL; - char parent_mailbox[100], *parent_mailbox_pointer = NULL; - - - memset(parent_mailbox,0x00,sizeof(parent_mailbox)); + int account_id =0; + int err_code = EMAIL_ERROR_NONE; + int result_from_scanf = 0; + email_mailbox_t *mailbox =NULL; + email_mailbox_type_e mailbox_type =0; testapp_print("\n > Enter account id: "); - scanf("%d", &account_id); - - testapp_print("\n > Enter parent mailbox name to fetch child list: "); - scanf("%s", parent_mailbox); - - + result_from_scanf = scanf("%d", &account_id); - if(strcmp(parent_mailbox, "0") != 0) { - testapp_print("\ninput : %s\n", parent_mailbox); - parent_mailbox_pointer = parent_mailbox; - } + testapp_print("\n > Enter mailbox_type: "); + result_from_scanf = scanf("%d", (int*)&mailbox_type); - if( (err_code = email_get_child_mailbox_list(account_id,parent_mailbox_pointer, &mailbox_list, &count)) < 0) { - testapp_print(" email_get_child_mailbox_list error : %d\n",err_code); + if( (err_code = email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox)) < 0) { + testapp_print(" email_get_mailbox_by_mailbox_type error : %d\n",err_code); return false ; } - testapp_print("There are %d mailboxes\n", count); - - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t alias\t local_yn\t unread\t mailbox_type\thas_archived_mails\n"); - testapp_print("============================================================================\n"); - if(count == 0) { - testapp_print("No mailbox is matched\n"); - } - else { - for(i=0;i<count;i++) - { - testapp_print("[%d] - ", i); - testapp_print(" %2d\t [%-15s]\t[%-15s]\t", mailbox_list[i].account_id, mailbox_list[i].name, mailbox_list[i].alias); - testapp_print(" %d\t %d\t %d\n", mailbox_list[i].local, mailbox_list[i].unread_count,mailbox_list[i].mailbox_type, mailbox_list[i].has_archived_mails); - } - } - testapp_print("============================================================================\n"); + testapp_print_mailbox_list(mailbox, 1); - email_free_mailbox(&mailbox_list, count); + email_free_mailbox(&mailbox, 1); return FALSE; } -static gboolean testapp_test_get_mailbox_by_type () +static gboolean testapp_test_set_mailbox_type() { + int mailbox_id = 0; + int mailbox_type = 0; + int err_code = EMAIL_ERROR_NONE; + int result_from_scanf = 0; - int account_id =0; - int i = 0, err_code = EMF_ERROR_NONE; - emf_mailbox_t *mailbox =NULL; - emf_mailbox_type_e mailbox_type =0; - - testapp_print("\n > Enter account id: "); - scanf("%d", &account_id); + testapp_print("\n > Enter mailbox id : "); + result_from_scanf = scanf("%d", &mailbox_id); - testapp_print("\n > Enter mailbox_type: "); - scanf("%d", (int*)&mailbox_type); + testapp_print("\n > Enter mailbox type : "); + result_from_scanf = scanf("%d", &mailbox_type); - if( (err_code = email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox)) < 0) { - testapp_print(" email_get_mailbox_by_mailbox_type error : %d\n",err_code); - return false ; + if( (err_code = email_set_mailbox_type(mailbox_id, mailbox_type) ) != EMAIL_ERROR_NONE) { + testapp_print("\nemail_set_mailbox_type error : %d\n", err_code); } - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t alias\t local_yn\t unread\t mailbox_type\thas_archived_mails\n"); - testapp_print("============================================================================\n"); - - testapp_print("[%d] - ", i); - testapp_print(" %2d\t [%-15s]\t[%-15s]\t", mailbox->account_id, mailbox->name, mailbox->alias); - testapp_print(" %d\t %d\t %d\n", mailbox->local, mailbox->unread_count,mailbox->mailbox_type, mailbox->has_archived_mails); - - testapp_print("============================================================================\n"); - - email_free_mailbox(&mailbox, 1); return FALSE; } static gboolean testapp_test_set_mail_slot_size () { - - int account_id = 0, mail_slot_size = 0; - int err_code = EMF_ERROR_NONE; - char arg[500]; - char *mailbox_name = NULL; + int account_id = 0; + int mailbox_id = 0; + int mail_slot_size = 0; + int err_code = EMAIL_ERROR_NONE; + int result_from_scanf = 0; testapp_print("\n > Enter account id (0: All account): "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name (0 : All mailboxes):"); - scanf("%s",arg); - if (strcmp(arg, "0") != 0 ) { - mailbox_name = arg; - } + testapp_print("\n> Enter mailbox id (0 : All mailboxes):"); + result_from_scanf = scanf("%d", &mailbox_id); testapp_print("\n > Enter mailbox slot size: "); - scanf("%d", &mail_slot_size); + result_from_scanf = scanf("%d", &mail_slot_size); - if( (err_code = email_set_mail_slot_size(account_id, mailbox_name, mail_slot_size) ) < 0) { + if( (err_code = email_set_mail_slot_size(account_id, mailbox_id, mail_slot_size) ) < 0) { testapp_print(" testapp_test_set_mail_slot_size error : %d\n", err_code); return false ; } @@ -299,62 +261,32 @@ static gboolean testapp_test_set_mail_slot_size () static gboolean testapp_test_get_mailbox_list () { - + int result_from_scanf = 0; int account_id =0; int mailbox_sync_type; int count = 0; - int i = 0, error_code = EMF_ERROR_NONE; - emf_mailbox_t *mailbox_list=NULL; + int error_code = EMAIL_ERROR_NONE; + email_mailbox_t *mailbox_list=NULL; testapp_print("\n > Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter mailbox_sync_type\n[-1 :for all mailboxes, 0 : for mailboxes from server, 1 : local mailboxes\n : "); - scanf("%d", &mailbox_sync_type); + result_from_scanf = scanf("%d", &mailbox_sync_type); if((error_code = email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count)) < 0) { testapp_print(" email_get_mailbox_list error %d\n", error_code); return false ; } - testapp_print("There are %d mailboxes\n", count); + testapp_print_mailbox_list(mailbox_list, count); - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t\t alias\t local_yn\t unread\tmailbox_type\t has_archived_mails\n"); - testapp_print("============================================================================\n"); - if ( count == 0 ) { - testapp_print("No mailbox is matched\n"); - } - else { - for(i=0;i<count;i++) { - testapp_print("[%d] - ", i); - testapp_print(" %2d\t [%-15s]\t[%-15s]\t", mailbox_list[i].account_id, mailbox_list[i].name, mailbox_list[i].alias); - testapp_print(" %d\t %d\t %d\n", mailbox_list[i].local, mailbox_list[i].unread_count,mailbox_list[i].mailbox_type, mailbox_list[i].has_archived_mails); - } - } - testapp_print("============================================================================\n"); - /* EmfMailboxFree(emf_mailbox_t** mailbox_list, int count, int* err_code) */ + email_free_mailbox(&mailbox_list, count); if((error_code = email_get_mailbox_list_ex(account_id, mailbox_sync_type, 1, &mailbox_list, &count)) < 0) { testapp_print(" email_get_mailbox_list_ex error %d\n", error_code); return false ; } - testapp_print("There are %d mailboxes\n", count); - - testapp_print("============================================================================\n"); - testapp_print("number\taccount_id\t name\t\t alias\t local_yn\t unread\t total\t total_on_ server\tmailbox_type\t has_archived_mails\n"); - testapp_print("============================================================================\n"); - if ( count == 0 ) { - testapp_print("No mailbox is matched\n"); - } - else { - for(i=0;i<count;i++) { - testapp_print("[%d] - ", i); - testapp_print(" %2d\t [%-15s]\t[%-15s]\t", mailbox_list[i].account_id, mailbox_list[i].name, mailbox_list[i].alias); - testapp_print(" %d\t %d\t %d\t %d\t %d\t %d\n", mailbox_list[i].local, mailbox_list[i].unread_count, mailbox_list[i].total_mail_count_on_local, mailbox_list[i].total_mail_count_on_server, mailbox_list[i].mailbox_type, mailbox_list[i].has_archived_mails); - } - } - testapp_print("============================================================================\n"); - testapp_print("Start to free\n"); + testapp_print_mailbox_list(mailbox_list, count); email_free_mailbox(&mailbox_list, count); return FALSE; @@ -362,25 +294,16 @@ static gboolean testapp_test_get_mailbox_list () static gboolean testapp_test_sync_mailbox() { - emf_mailbox_t mbox; + int result_from_scanf = 0; int account_id = 0; - char arg[50]; unsigned handle = 0; - testapp_print("\n > Enter Account id (0: for all account) : "); - scanf("%d",&account_id); - - memset(arg, 0x00, 50); - testapp_print("\n > Enter Mailbox name (ALL: for all mailboxes) : "); - scanf("%s",arg); - - memset(&mbox, 0x00, sizeof(emf_mailbox_t)); + int mailbox_id = 0; - mbox.account_id = account_id; + testapp_print("\n > Enter Account id (0: for all account) : "); + result_from_scanf = scanf("%d",&account_id); - if(strcmp("ALL", arg) == 0) - mbox.name = NULL; - else - mbox.name = strdup(arg); + testapp_print("\n > Enter Mailbox id (0: for all mailboxes) : "); + result_from_scanf = scanf("%d",&mailbox_id); if(account_id == ALL_ACCOUNT) { if(email_sync_header_for_all_account(&handle) < 0) @@ -389,7 +312,7 @@ static gboolean testapp_test_sync_mailbox() testapp_print("\n email_sync_header_for_all_account success. Handle[%d]\n", handle); } else { - if(email_sync_header(&mbox,&handle) < 0) + if(email_sync_header(account_id, mailbox_id, &handle) < 0) testapp_print("\n email_sync_header failed\n"); else testapp_print("\n email_sync_header success. Handle[%d]\n", handle); @@ -398,6 +321,19 @@ static gboolean testapp_test_sync_mailbox() return FALSE; } +static gboolean testapp_test_stamp_sync_time() +{ + int result_from_scanf; + int input_mailbox_id = 0; + + testapp_print("\n > Enter Mailbox id : "); + result_from_scanf = scanf("%d",&input_mailbox_id); + + email_stamp_sync_time_of_mailbox(input_mailbox_id); + + return FALSE; +} + static gboolean testapp_test_interpret_command (int menu_number) { gboolean go_to_loop = TRUE; @@ -408,37 +344,41 @@ static gboolean testapp_test_interpret_command (int menu_number) break; case 2: - testapp_test_delete_mailbox (); + testapp_test_delete_mailbox(); break; case 3: - testapp_test_update_mailbox (); + testapp_test_rename_mailbox(); break; case 4: testapp_test_get_imap_mailbox_list(); break; - case 6: - testapp_test_get_child_mailbox_list(); - break; - case 7: testapp_test_get_mailbox_by_type(); - break; + break; case 8: - testapp_test_set_mail_slot_size(); + testapp_test_set_mailbox_type(); break; case 9: + testapp_test_set_mail_slot_size(); + break; + + case 10: testapp_test_get_mailbox_list (); break; - case 10: + case 11: testapp_test_sync_mailbox(); break; + case 12: + testapp_test_stamp_sync_time(); + break; + case 0: go_to_loop = FALSE; break; @@ -449,16 +389,17 @@ static gboolean testapp_test_interpret_command (int menu_number) return go_to_loop; } -void emf_test_mailbox_main() +void email_test_mailbox_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_MAILBOX_MENU); - testapp_show_prompt (EMF_MAILBOX_MENU); + testapp_show_menu (EMAIL_MAILBOX_MENU); + testapp_show_prompt (EMAIL_MAILBOX_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-others.c b/utilities/test-application/testapp-others.c index 6aee94e..1181d90 100755 --- a/utilities/test-application/testapp-others.c +++ b/utilities/test-application/testapp-others.c @@ -55,18 +55,19 @@ static gboolean testapp_test_get_pending_job() int action = -1; int account_id = 0; int mail_id = 0; - emf_event_status_type_t status = -1; + int result_from_scanf = 0; + email_event_status_type_t status = -1; testapp_print( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \ " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \ " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \ " NUM = 7 \n"); - scanf("%d",&action); + result_from_scanf = scanf("%d",&action); testapp_print("\n > Enter account_id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter Mail Id: "); - scanf("%d", &mail_id); + result_from_scanf = scanf("%d", &mail_id); if( email_get_pending_job( action, account_id, mail_id, &status) >= 0) testapp_print("\t status - %d \n",status); @@ -78,14 +79,15 @@ static gboolean testapp_test_cancel_job () { int account_id = 0; int handle = 0; + int result_from_scanf = 0; testapp_print("\n > Enter account_id (0: all account): "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); testapp_print("\n > Enter handle: "); - scanf("%d", &handle); + result_from_scanf = scanf("%d", &handle); - if(email_cancel_job(account_id, handle) < 0) + if(email_cancel_job(account_id, handle, EMAIL_CANCELED_BY_USER) < 0) testapp_print("email_cancel_job failed..!"); return FALSE; } @@ -110,12 +112,12 @@ static gboolean testapp_test_print_receving_queue_via_debug_msg() void* hAPI = (void*)emipc_create_email_api(_EMAIL_API_PRINT_RECEIVING_EVENT_QUEUE); if(hAPI == NULL) - return EMF_ERROR_NULL_VALUE; + return EMAIL_ERROR_NULL_VALUE; - if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) { + if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) { testapp_print("testapp_test_print_receving_queue_via_debug_msg - emipc_execute_proxy_api failed \n "); if(hAPI == NULL) - return EMF_ERROR_NULL_VALUE; + return EMAIL_ERROR_NULL_VALUE; } emipc_get_parameter(hAPI, 1, 0, sizeof(int), &err); @@ -144,10 +146,10 @@ static int encode_base64(char *src, unsigned long src_len, char **enc, unsigned { unsigned char *content = NULL; int ret = true; - int err = EMF_ERROR_NONE; + int err = EMAIL_ERROR_NONE; if (err_code != NULL) { - *err_code = EMF_ERROR_NONE; + *err_code = EMAIL_ERROR_NONE; } content = rfc822_binary(src, src_len, enc_len); @@ -155,7 +157,7 @@ static int encode_base64(char *src, unsigned long src_len, char **enc, unsigned if (content) *enc = (char *)content; else { - err = EMF_ERROR_UNKNOWN; + err = EMAIL_ERROR_UNKNOWN; ret = false; } @@ -168,7 +170,7 @@ static int encode_base64(char *src, unsigned long src_len, char **enc, unsigned static gboolean testapp_test_encoding_test() { - int error = EMF_ERROR_NONE; + int error = EMAIL_ERROR_NONE; int has_special_character = 0, base64_file_name_length = 0, i; gsize bytes_read, bytes_written; char *encoded_file_name = NULL, *base64_file_name = NULL; @@ -364,6 +366,33 @@ static gboolean email_test_dtt_Datastore_C() return true; } +static gboolean testapp_test_show_user_message() +{ + int mail_id; + int result_from_scanf = 0; + + testapp_print("\n > Enter mail id : "); + result_from_scanf = scanf("%d", &mail_id); + + email_show_user_message(mail_id, EMAIL_ACTION_SEND_MAIL, EMAIL_ERROR_NETWORK_NOT_AVAILABLE); + return FALSE; +} + +static gboolean testapp_test_get_mime_entity() +{ + char mime_path[512] = {0, }; + int result_from_scanf = 0; + char *mime_entity = NULL; + + testapp_print("\n > Enter mime path for parsing : "); + result_from_scanf = scanf("%s", mime_path); + + email_get_mime_entity(mime_path, &mime_entity); + + testapp_print("\nmime_entity = %s\n", mime_entity); + return true; +} + static gboolean testapp_test_interpret_command (int menu_number) { gboolean go_to_loop = TRUE; @@ -398,6 +427,12 @@ static gboolean testapp_test_interpret_command (int menu_number) email_test_dtt_Datastore_C(); email_test_dtt_Datastore_R(); break; + case 15: + testapp_test_show_user_message(); + break; + case 16: + testapp_test_get_mime_entity(); + break; case 0: go_to_loop = FALSE; break; @@ -412,12 +447,13 @@ void testapp_others_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_OTHERS_MENU); - testapp_show_prompt (EMF_OTHERS_MENU); + testapp_show_menu (EMAIL_OTHERS_MENU); + testapp_show_prompt (EMAIL_OTHERS_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf ("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-rule.c b/utilities/test-application/testapp-rule.c index 3d8c104..45a4ea9 100755 --- a/utilities/test-application/testapp-rule.c +++ b/utilities/test-application/testapp-rule.c @@ -38,46 +38,49 @@ static gboolean testapp_test_add_rule() { - emf_rule_t* rule = NULL; + email_rule_t* rule = NULL; int account_id = 0; + int target_mailbox_id = 0; int action = 0; int type = 0; int flag = 0; char arg[500]; + int result_from_scanf = 0; - rule = malloc(sizeof(emf_rule_t)); + rule = malloc(sizeof(email_rule_t)); testapp_print("> Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); rule->account_id = account_id; testapp_print("> Enter Type(FROM - 1 / SUBJECT - 2): "); - scanf("%d", &type); + result_from_scanf = scanf("%d", &type); rule->type= type; memset(arg, 0x00, 500); testapp_print("\n> Enter Filtering Value:"); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); rule->value= strdup(arg); testapp_print("> Enter Action(MOVE - 1, BLOCK - 2, DELETE - 3): "); - scanf("%d", &action); + result_from_scanf = scanf("%d", &action); rule->faction= action; - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name:"); - scanf("%s",arg); - rule->mailbox= strdup(arg); + if (action == 1) { + testapp_print("\n> Enter target mailbox id:"); + result_from_scanf = scanf("%d", &target_mailbox_id); + rule->target_mailbox_id = target_mailbox_id; + } testapp_print("> Enter Flag1 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag1= flag; testapp_print("> Enter Flag2 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag2= flag; if ( email_add_rule(rule) < 0) - testapp_print("\n EmfRuleAdd failed"); + testapp_print("\n email_add_rule failed"); email_free_rule(&rule, 1); @@ -87,11 +90,11 @@ static gboolean testapp_test_add_rule() static gboolean testapp_test_delete_rule() { - + int result_from_scanf = 0; int filter_id = 0; testapp_print("> Enter filter id: "); - scanf("%d", &filter_id); + result_from_scanf = scanf("%d", &filter_id); if(email_delete_rule(filter_id) < 0) testapp_print("email_delete_rule failed..! "); @@ -102,48 +105,50 @@ static gboolean testapp_test_delete_rule() static gboolean testapp_test_update_rule() { - - emf_rule_t* rule = NULL; + int result_from_scanf = 0; + email_rule_t* rule = NULL; int account_id = 0; + int target_mailbox_id = 0; int action = 0; int type = 0; int flag = 0; char arg[500]; int filter_id = 0; - rule = malloc(sizeof(emf_rule_t)); - memset(rule,0X00,sizeof(emf_rule_t)); + rule = malloc(sizeof(email_rule_t)); + memset(rule,0X00,sizeof(email_rule_t)); testapp_print("> Enter filter id: "); - scanf("%d", &filter_id); + result_from_scanf = scanf("%d", &filter_id); testapp_print("> Enter account id: "); - scanf("%d", &account_id); + result_from_scanf = scanf("%d", &account_id); rule->account_id = account_id; testapp_print("> Enter Type(FROM - 1 / SUBJECT - 2): "); - scanf("%d", &type); + result_from_scanf = scanf("%d", &type); rule->type= type; memset(arg, 0x00, 500); testapp_print("\n> Enter Filtering Value:"); - scanf("%s",arg); + result_from_scanf = scanf("%s",arg); rule->value= strdup(arg); testapp_print("> Enter Action(MOVE - 1, BLOCK - 2, DELETE - 3): "); - scanf("%d", &action); + result_from_scanf = scanf("%d", &action); rule->faction= action; - memset(arg, 0x00, 500); - testapp_print("\n> Enter mailbox name:"); - scanf("%s",arg); - rule->mailbox= strdup(arg); + if (action == 1) { + testapp_print("\n> Enter target mailbox id:"); + result_from_scanf = scanf("%d", &target_mailbox_id); + rule->target_mailbox_id = target_mailbox_id; + } testapp_print("> Enter Flag1 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag1= flag; testapp_print("> Enter Flag2 value: "); - scanf("%d", &flag); + result_from_scanf = scanf("%d", &flag); rule->flag2= flag; if( !email_update_rule(filter_id, rule) < 0) @@ -157,11 +162,12 @@ static gboolean testapp_test_update_rule() static gboolean testapp_test_get_rule(void) { - emf_rule_t* rule = NULL; + email_rule_t* rule = NULL; int filter_id = 0; + int result_from_scanf = 0; testapp_print("> Enter filter id: "); - scanf("%d", &filter_id); + result_from_scanf = scanf("%d", &filter_id); if(email_get_rule(filter_id, &rule) >= 0) testapp_print("\n Got rule of account_id = %d and type = %d\n", rule->account_id, rule->type); @@ -175,7 +181,7 @@ static gboolean testapp_test_get_rule(void) static gboolean testapp_test_get_rule_list (void) { int count, i; - emf_rule_t* rule_list=NULL; + email_rule_t* rule_list=NULL; if(email_get_rule_list(&rule_list, &count) < 0) { testapp_print(" email_get_rule_list error\n"); @@ -228,16 +234,17 @@ static gboolean testapp_test_interpret_command (int menu_number) return go_to_loop; } -void emf_test_rule_main() +void email_test_rule_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_RULE_MENU); - testapp_show_prompt (EMF_RULE_MENU); + testapp_show_menu (EMAIL_RULE_MENU); + testapp_show_prompt (EMAIL_RULE_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-thread.c b/utilities/test-application/testapp-thread.c index e146506..c035fce 100755 --- a/utilities/test-application/testapp-thread.c +++ b/utilities/test-application/testapp-thread.c @@ -40,19 +40,20 @@ static gboolean testapp_test_move_thread() { int thread_id, move_always_flag; - char target_mailbox_name[512]; + int target_mailbox_id; int result; + int result_from_scanf = 0; testapp_print("\n > Enter thread_id: "); - scanf("%d", &thread_id); + result_from_scanf = scanf("%d", &thread_id); - testapp_print("\n > Enter target_mailbox_name: "); - scanf("%s", target_mailbox_name); + testapp_print("\n > Enter target_mailbox_id: "); + result_from_scanf = scanf("%d", &target_mailbox_id); testapp_print("\n > Enter move_always_flag: "); - scanf("%d", &move_always_flag); + result_from_scanf = scanf("%d", &move_always_flag); - result = email_move_thread_to_mailbox(thread_id, target_mailbox_name, move_always_flag); + result = email_move_thread_to_mailbox(thread_id, target_mailbox_id, move_always_flag); return FALSE; } @@ -61,12 +62,13 @@ static gboolean testapp_test_delete_thread() { int thread_id, delete_always_flag; int result; + int result_from_scanf = 0; testapp_print("\n > Enter thread_id: "); - scanf("%d", &thread_id); + result_from_scanf = scanf("%d", &thread_id); testapp_print("\n > Enter delete_always_flag: "); - scanf("%d", &delete_always_flag); + result_from_scanf = scanf("%d", &delete_always_flag); result = email_delete_thread(thread_id, delete_always_flag); @@ -77,15 +79,16 @@ static gboolean testapp_test_set_seen_flag_of_thread() { int thread_id, seen_flag, on_server; int result; + int result_from_scanf = 0; testapp_print("\n > Enter thread_id: "); - scanf("%d", &thread_id); + result_from_scanf = scanf("%d", &thread_id); testapp_print("\n > Enter seen_flag: "); - scanf("%d", &seen_flag); + result_from_scanf = scanf("%d", &seen_flag); testapp_print("\n > Enter on_server: "); - scanf("%d", &on_server); + result_from_scanf = scanf("%d", &on_server); result = email_modify_seen_flag_of_thread(thread_id, seen_flag, on_server); @@ -123,12 +126,13 @@ void testapp_thread_main() { gboolean go_to_loop = TRUE; int menu_number = 0; + int result_from_scanf = 0; while (go_to_loop) { - testapp_show_menu (EMF_THREAD_MENU); - testapp_show_prompt (EMF_THREAD_MENU); + testapp_show_menu (EMAIL_THREAD_MENU); + testapp_show_prompt (EMAIL_THREAD_MENU); - scanf ("%d", &menu_number); + result_from_scanf = scanf("%d", &menu_number); go_to_loop = testapp_test_interpret_command (menu_number); } diff --git a/utilities/test-application/testapp-utility.c b/utilities/test-application/testapp-utility.c index 527df2c..5ee0dfd 100755 --- a/utilities/test-application/testapp-utility.c +++ b/utilities/test-application/testapp-utility.c @@ -43,10 +43,10 @@ void testapp_print (char *fmt, ...) fflush (stdout); } -void testapp_show_menu (eEMF_MENU menu) +void testapp_show_menu (eEMAIL_MENU menu) { switch (menu) { - case EMF_MAIN_MENU: + case EMAIL_MAIN_MENU: testapp_print ("==========================================\n"); testapp_print (" Email test application \n"); testapp_print ("==========================================\n"); @@ -60,47 +60,49 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("------------------------------------------\n"); break; - case EMF_ACCOUNT_MENU: + case EMAIL_ACCOUNT_MENU: testapp_print ("==========================================\n"); testapp_print (" ACCOUNT MENU \n"); testapp_print ("==========================================\n"); - testapp_print (" 1. Create Account\n"); - testapp_print (" 2. Update Account\n"); - testapp_print (" 3. Delete Account\n"); - testapp_print (" 4. Get Account\n"); - testapp_print (" 5. Get Account List\n"); - testapp_print (" 7. Validate Account\n"); + testapp_print (" 1. Create account\n"); + testapp_print (" 2. Update account\n"); + testapp_print (" 3. Delete account\n"); + testapp_print (" 4. Get account\n"); + testapp_print (" 5. Get account list\n"); + testapp_print (" 7. Validate account\n"); testapp_print (" 8. Cancel validate Account\n"); - testapp_print (" 9. Backup All Accounts\n"); + testapp_print (" 9. Backup All accounts\n"); testapp_print (" 10. Restore accounts\n"); testapp_print (" 11. Get password length of account\n"); testapp_print (" 12. Query server info\n"); testapp_print (" 13. Clear all notifications\n"); + testapp_print (" 14. Save default account ID\n"); + testapp_print (" 15. Load default account ID\n"); + testapp_print (" 16. Add certificate\n"); + testapp_print (" 17. Get certificate\n"); + testapp_print (" 18. Delete certificate\n"); testapp_print (" 0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; - case EMF_MAIL_MENU: + case EMAIL_MAIL_MENU: testapp_print ("==========================================\n"); testapp_print (" MAIL MENU\n"); testapp_print ("==========================================\n"); testapp_print ("1. Get mails\n"); testapp_print ("2. Send a mail \n"); + testapp_print ("3. Get mail list\n"); testapp_print ("4. Add Attachment\n"); + testapp_print ("5. Set deleted flag\n"); + testapp_print ("6. Expunge deleted flagged mails\n"); testapp_print ("9. Mail Count \n"); - testapp_print ("10. Modify mail flag \n"); - testapp_print ("11. Modify mail extra flag modify\n"); testapp_print ("14. Delete a mail \n"); testapp_print ("16. Download mail body\n"); testapp_print ("17. Download an attachment\n"); testapp_print ("20. Delete all mail\n"); testapp_print ("21. Move Mail \n"); testapp_print ("23. Resend Mail \n"); - testapp_print ("24. Find mails\n"); - testapp_print ("26. Count mails On Sending\n"); testapp_print ("27. Move all mails to mailbox\n"); - testapp_print ("28. Count mails with Draft Flag\n"); - testapp_print ("29. Get latest unread mail Id\n"); testapp_print ("38. Get total email disk usage \n"); testapp_print ("40. Verify Email Address Format\n"); testapp_print ("41. Get Max Mail Count\n"); @@ -108,7 +110,6 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("43. Send mail Cancel\n"); testapp_print ("44. Cancel Download Body\n"); testapp_print ("48. Get thread information\n"); - testapp_print ("49. Get sender list\n"); testapp_print ("51. Get mail list ex\n"); testapp_print ("52. Get address info list\n"); testapp_print ("55. Set a field of flags\n"); @@ -116,28 +117,30 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("57. Update mail\n"); testapp_print ("58. Search on server\n"); testapp_print ("59. Add mail to search result table\n"); + testapp_print ("60. Open eml file\n"); testapp_print ("0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; - case EMF_MAILBOX_MENU: + case EMAIL_MAILBOX_MENU: testapp_print ("==========================================\n"); testapp_print (" MAILBOX MENU\n"); testapp_print ("==========================================\n"); testapp_print (" 1. Add mailbox\n"); testapp_print (" 2. Delete mailbox\n"); - testapp_print (" 3. Update mailbox\n"); + testapp_print (" 3. Raname mailbox\n"); testapp_print (" 4. Get IMAP mailbox List\n"); - testapp_print (" 6. Get Child List for given mailbox \n"); testapp_print (" 7. Get mailbox by mailbox type\n"); - testapp_print (" 8. Set mail slot size\n"); - testapp_print (" 9. Get mailbox list\n"); - testapp_print ("10. Sync mailbox\n"); + testapp_print (" 8. Set mailbox type\n"); + testapp_print (" 9. Set mail slot size\n"); + testapp_print ("10. Get mailbox list\n"); + testapp_print ("11. Sync mailbox\n"); + testapp_print ("12. Stamp sync time\n"); testapp_print ("0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; - case EMF_RULE_MENU: + case EMAIL_RULE_MENU: testapp_print ("==========================================\n"); testapp_print (" RULE MENU\n"); testapp_print ("==========================================\n"); @@ -150,7 +153,7 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("------------------------------------------\n"); break; - case EMF_THREAD_MENU: + case EMAIL_THREAD_MENU: testapp_print ("==========================================\n"); testapp_print (" TRHEAD MENU\n"); testapp_print ("==========================================\n"); @@ -161,7 +164,7 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("------------------------------------------\n"); break; - case EMF_OTHERS_MENU: + case EMAIL_OTHERS_MENU: testapp_print ("==========================================\n"); testapp_print (" OTHERS\n"); testapp_print ("==========================================\n"); @@ -175,6 +178,8 @@ void testapp_show_menu (eEMF_MENU menu) testapp_print ("12. Create DB full\n"); testapp_print ("13. Encoding Test\n"); testapp_print ("14. DTT Test\n"); + testapp_print ("15. Show User Message\n"); + testapp_print ("16. Get mime entity in signed file\n"); testapp_print ("0. Go to Main Menu\n"); testapp_print ("------------------------------------------\n"); break; @@ -183,34 +188,34 @@ void testapp_show_menu (eEMF_MENU menu) break; } } -void testapp_show_prompt (eEMF_MENU menu) +void testapp_show_prompt (eEMAIL_MENU menu) { switch (menu) { - case EMF_MAIN_MENU: + case EMAIL_MAIN_MENU: testapp_print ("[MAIN]# "); break; - case EMF_ACCOUNT_MENU: + case EMAIL_ACCOUNT_MENU: testapp_print ("[ACCOUNT]# "); break; - case EMF_MAIL_MENU: + case EMAIL_MAIL_MENU: testapp_print ("[MAIL]# "); break; - case EMF_MAILBOX_MENU: + case EMAIL_MAILBOX_MENU: testapp_print ("[MAILBOX]# "); break; - case EMF_RULE_MENU: + case EMAIL_RULE_MENU: testapp_print ("[RULE]# "); break; - case EMF_THREAD_MENU: + case EMAIL_THREAD_MENU: testapp_print ("[THREAD]# "); break; - case EMF_OTHERS_MENU: + case EMAIL_OTHERS_MENU: testapp_print ("[OTHERS]# "); break; |