summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorKyuho Jo <kyuho.jo@samsung.com>2013-01-18 15:47:44 +0900
committerKyuho Jo <kyuho.jo@samsung.com>2013-01-18 15:47:44 +0900
commitbdcb6e160907caff4ce2207d0073a151df741f1e (patch)
treea1dd11351fc648bf3de6b229f8fead8ca9f87c5c /utilities
parent19a453e0939247ac2ccd7423cdc2521c5025e541 (diff)
downloademail-service-bdcb6e160907caff4ce2207d0073a151df741f1e.tar.gz
email-service-bdcb6e160907caff4ce2207d0073a151df741f1e.tar.bz2
email-service-bdcb6e160907caff4ce2207d0073a151df741f1e.zip
Boiler plate changed.
Diffstat (limited to 'utilities')
-rwxr-xr-xutilities/test-application/include/testapp-account.h2
-rwxr-xr-xutilities/test-application/include/testapp-mail.h2
-rwxr-xr-xutilities/test-application/include/testapp-mailbox.h2
-rwxr-xr-xutilities/test-application/include/testapp-others.h2
-rwxr-xr-xutilities/test-application/include/testapp-rule.h2
-rwxr-xr-xutilities/test-application/include/testapp-thread.h2
-rwxr-xr-xutilities/test-application/include/testapp-utility.h2
-rwxr-xr-xutilities/test-application/main.c2
-rwxr-xr-xutilities/test-application/testapp-account.c4
-rwxr-xr-xutilities/test-application/testapp-mail.c182
-rwxr-xr-xutilities/test-application/testapp-mailbox.c2
-rwxr-xr-xutilities/test-application/testapp-others.c2
-rwxr-xr-xutilities/test-application/testapp-rule.c2
-rwxr-xr-xutilities/test-application/testapp-thread.c2
-rwxr-xr-xutilities/test-application/testapp-utility.c3
15 files changed, 195 insertions, 18 deletions
diff --git a/utilities/test-application/include/testapp-account.h b/utilities/test-application/include/testapp-account.h
index 2f22aa0..1c19e78 100755
--- a/utilities/test-application/include/testapp-account.h
+++ b/utilities/test-application/include/testapp-account.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/include/testapp-mail.h b/utilities/test-application/include/testapp-mail.h
index e7f3b40..3bd21fd 100755
--- a/utilities/test-application/include/testapp-mail.h
+++ b/utilities/test-application/include/testapp-mail.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/include/testapp-mailbox.h b/utilities/test-application/include/testapp-mailbox.h
index 836a299..e3aae25 100755
--- a/utilities/test-application/include/testapp-mailbox.h
+++ b/utilities/test-application/include/testapp-mailbox.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/include/testapp-others.h b/utilities/test-application/include/testapp-others.h
index 8c10989..9e4ce9e 100755
--- a/utilities/test-application/include/testapp-others.h
+++ b/utilities/test-application/include/testapp-others.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/include/testapp-rule.h b/utilities/test-application/include/testapp-rule.h
index 61f6e4c..9fb79b7 100755
--- a/utilities/test-application/include/testapp-rule.h
+++ b/utilities/test-application/include/testapp-rule.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/include/testapp-thread.h b/utilities/test-application/include/testapp-thread.h
index c3e81c5..4e8a8ec 100755
--- a/utilities/test-application/include/testapp-thread.h
+++ b/utilities/test-application/include/testapp-thread.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/include/testapp-utility.h b/utilities/test-application/include/testapp-utility.h
index b88d69a..45f14e2 100755
--- a/utilities/test-application/include/testapp-utility.h
+++ b/utilities/test-application/include/testapp-utility.h
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/main.c b/utilities/test-application/main.c
index 449d72c..7cdec48 100755
--- a/utilities/test-application/main.c
+++ b/utilities/test-application/main.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/testapp-account.c b/utilities/test-application/testapp-account.c
index 2621578..b6e2fee 100755
--- a/utilities/test-application/testapp-account.c
+++ b/utilities/test-application/testapp-account.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
@@ -112,7 +112,7 @@ gboolean testapp_test_create_account_by_account_type(int account_type,int *accou
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.keep_local_copy = 1;
account->options.req_delivery_receipt = 0;
account->options.req_read_receipt = 0;
account->options.download_limit = 0;
diff --git a/utilities/test-application/testapp-mail.c b/utilities/test-application/testapp-mail.c
index d68ec59..1ee47ac 100755
--- a/utilities/test-application/testapp-mail.c
+++ b/utilities/test-application/testapp-mail.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
@@ -26,6 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <wait.h>
/* open header */
#include <glib.h>
@@ -44,7 +45,8 @@
#include "email-core-utils.h"
#include "email-core-mime.h"
-#define MAIL_TEMP_BODY "/tmp/mail.txt"
+#define MAIL_TEMP_BODY "/tmp/utf8"
+#define HTML_TEMP_BODY "/tmp/utf8.htm"
/*
static void testapp_test_print_sorting_menu()
@@ -614,7 +616,7 @@ static gboolean testapp_test_get_mail_list_ex()
sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME;
sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_DESCEND;
- err = email_get_mail_list_ex(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &result_mail_list, &result_mail_count);
+ err = email_get_mail_list_ex(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, 0, 10, &result_mail_list, &result_mail_count);
if(err == EMAIL_ERROR_NONE) {
testapp_print("email_get_mail_list_ex succeed.\n");
@@ -1082,6 +1084,177 @@ static gboolean testapp_test_move_mails_to_mailbox_of_another_account()
return 0;
}
+static gboolean copy_file(char *input_source_path, char *input_dest_path)
+{
+ int childExitStatus;
+ pid_t pid;
+ int status;
+ if (!input_source_path || !input_dest_path) {
+ return FALSE;
+ }
+ testapp_print("copy_file started\n");
+
+ pid = fork();
+
+ if (pid == 0) {
+ testapp_print("Copying file [%s] [%s]\n", input_source_path, input_dest_path);
+ execl("/bin/cp", "/bin/cp", input_source_path, input_dest_path, (char *)0);
+ }
+ else {
+ testapp_print("Wating child process\n");
+ pid_t ws = waitpid( pid, &childExitStatus, WNOHANG);
+ if (ws == -1)
+ { /* error - handle as you wish */
+ testapp_print("waitpid returns error\n");
+ }
+
+ if( WIFEXITED(childExitStatus)) /* exit code in childExitStatus */
+ {
+ status = WEXITSTATUS(childExitStatus); /* zero is normal exit */
+ testapp_print("WEXITSTATUS\n");
+ /* handle non-zero as you wish */
+ }
+ else if (WIFSIGNALED(childExitStatus)) /* killed */
+ {
+ testapp_print("WIFSIGNALED\n");
+ }
+ else if (WIFSTOPPED(childExitStatus)) /* stopped */
+ {
+ testapp_print("WIFSTOPPED\n");
+ }
+ }
+ testapp_print("copy_file finished\n");
+ return TRUE;
+}
+
+
+static gboolean testapp_test_send_mail_with_downloading_attachment_of_original_mail()
+{
+ int err = EMAIL_ERROR_NONE;
+ int original_mail_id = 0;
+ int result_from_scanf = 0;
+ int original_attachment_count = 0;
+ int i = 0;
+ int handle = 0;
+ char *plain_text_path = MAIL_TEMP_BODY;
+ char *html_file_path = HTML_TEMP_BODY;
+ char new_subject[4086] = { 0, };
+/* FILE *body_file; */
+ email_mail_data_t *original_mail_data = NULL;
+ email_mailbox_t *outbox = NULL;
+ email_attachment_data_t *original_attachment_array = NULL;
+
+ testapp_print("\n > Enter original mail id: ");
+ result_from_scanf = scanf("%d", &original_mail_id);
+
+ /* Get original mail */
+ if((err = email_get_mail_data(original_mail_id, &original_mail_data)) != EMAIL_ERROR_NONE || !original_mail_data) {
+ testapp_print("email_get_mail_data failed [%d]\n", err);
+ return FALSE;
+ }
+
+ /* Get attachment of original mail */
+ if((err = email_get_attachment_data_list(original_mail_id, &original_attachment_array, &original_attachment_count)) != EMAIL_ERROR_NONE || !original_attachment_array) {
+ testapp_print("email_get_attachment_data_list failed [%d]\n", err);
+ return FALSE;
+ }
+
+ /* Remove attachment file path */
+ for(i = 0; i < original_attachment_count; i++) {
+ original_attachment_array[i].save_status = 0;
+ if(original_attachment_array[i].attachment_path)
+ free(original_attachment_array[i].attachment_path);
+ original_attachment_array[i].attachment_path = NULL;
+ }
+
+ /* Set reference mail id */
+ original_mail_data->reference_mail_id = original_mail_data->mail_id;
+ original_mail_data->body_download_status = 1;
+
+ /* Set from address */
+ if(!original_mail_data->full_address_from) {
+ original_mail_data->full_address_from = strdup("<abc@abc.com>");
+ }
+
+ /* Rewrite subject */
+ if(original_mail_data->subject) {
+ snprintf(new_subject, 4086, "Fw:%s", original_mail_data->subject);
+ free(original_mail_data->subject);
+ original_mail_data->subject = NULL;
+ }
+ else {
+ snprintf(new_subject, 4086, "Forward test");
+ }
+
+ original_mail_data->subject = strdup(new_subject);
+
+ /* Set mailbox information */
+ if((err = email_get_mailbox_by_mailbox_type(original_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &outbox)) != EMAIL_ERROR_NONE || !outbox) {
+ testapp_print("email_get_mailbox_by_mailbox_type failed [%d]\n", err);
+ return FALSE;
+ }
+ original_mail_data->mailbox_id = outbox->mailbox_id;
+ original_mail_data->mailbox_type = outbox->mailbox_type;
+
+ /* Copy body text */
+ if(original_mail_data->file_path_html) {
+ copy_file(original_mail_data->file_path_html, html_file_path);
+ /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_html, html_file_path, (char *)0); */
+ free(original_mail_data->file_path_html);
+ original_mail_data->file_path_html = strdup(html_file_path);
+ }
+
+ if(original_mail_data->file_path_plain) {
+ copy_file(original_mail_data->file_path_plain, plain_text_path);
+ /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_plain, plain_text_path, (char *)0);*/
+ free(original_mail_data->file_path_plain);
+ original_mail_data->file_path_plain = strdup(plain_text_path);
+ }
+
+
+ /*
+ body_file = fopen(body_file_path, "w");
+
+ testapp_print("\n body_file [%p]\n", body_file);
+
+ if(body_file == NULL) {
+ testapp_print("\n fopen [%s]failed\n", body_file_path);
+ return FALSE;
+ }
+
+ for(i = 0; i < 100; i++)
+ fprintf(body_file, "Mail sending Test. [%d]\n", i);
+
+ fflush(body_file);
+ fclose(body_file);
+ */
+
+ /* Add mail */
+ if((err = email_add_mail(original_mail_data, original_attachment_array, original_attachment_count, NULL, false)) != EMAIL_ERROR_NONE) {
+ testapp_print("email_get_attachment_data_list failed [%d]\n", err);
+ return FALSE;
+ }
+
+ /* Send mail */
+ if((err = email_send_mail_with_downloading_attachment_of_original_mail(original_mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) {
+ testapp_print("email_send_mail_with_downloading_attachment_of_original_mail failed [%d]\n", err);
+ return FALSE;
+ }
+
+ if(original_mail_data)
+ email_free_mail_data(&original_mail_data, 1);
+
+ if(outbox)
+ email_free_mailbox(&outbox, 1);
+
+ if(original_attachment_array)
+ email_free_attachment_data(&original_attachment_array, original_attachment_count);
+
+ return TRUE;
+}
+
+
+
static gboolean testapp_test_set_flags_field ()
{
int account_id = 0;
@@ -1877,6 +2050,9 @@ static gboolean testapp_test_interpret_command (int menu_number)
case 10:
testapp_test_move_mails_to_mailbox_of_another_account();
break;
+ case 11:
+ testapp_test_send_mail_with_downloading_attachment_of_original_mail();
+ break;
case 14:
testapp_test_delete();
break;
diff --git a/utilities/test-application/testapp-mailbox.c b/utilities/test-application/testapp-mailbox.c
index 768a940..915a11f 100755
--- a/utilities/test-application/testapp-mailbox.c
+++ b/utilities/test-application/testapp-mailbox.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/testapp-others.c b/utilities/test-application/testapp-others.c
index f37229a..92f8e5a 100755
--- a/utilities/test-application/testapp-others.c
+++ b/utilities/test-application/testapp-others.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/testapp-rule.c b/utilities/test-application/testapp-rule.c
index 45a4ea9..ca8dfed 100755
--- a/utilities/test-application/testapp-rule.c
+++ b/utilities/test-application/testapp-rule.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/testapp-thread.c b/utilities/test-application/testapp-thread.c
index c035fce..34b913e 100755
--- a/utilities/test-application/testapp-thread.c
+++ b/utilities/test-application/testapp-thread.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
diff --git a/utilities/test-application/testapp-utility.c b/utilities/test-application/testapp-utility.c
index 4a0f9f3..acf39ae 100755
--- a/utilities/test-application/testapp-utility.c
+++ b/utilities/test-application/testapp-utility.c
@@ -1,7 +1,7 @@
/*
* email-service
*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
@@ -99,6 +99,7 @@ void testapp_show_menu (eEMAIL_MENU menu)
testapp_print ("8. Delete attachment\n");
testapp_print ("9. Mail Count \n");
testapp_print ("10. Move mails to another account\n");
+ testapp_print ("11. Send mail with downloading attachment of original mail\n");
testapp_print ("14. Delete a mail \n");
testapp_print ("16. Download mail body\n");
testapp_print ("17. Download an attachment\n");