4 * Copyright(c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
8 * Licensed under the Apache License, Version 2.0(the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
35 #include "email-api-account.h"
36 #include "email-api-network.h"
37 #include "email-api-mail.h"
38 #include "email-api-mailbox.h"
39 #include "email-api-etc.h"
40 #include "email-api-smime.h"
43 #include "testapp-utility.h"
44 #include "testapp-mail.h"
45 #include "email-core-utils.h"
46 #include "email-core-mime.h"
48 #define MAIL_TEMP_BODY "/tmp/utf8"
49 #define HTML_TEMP_BODY "/tmp/utf8.htm"
52 static void testapp_test_print_sorting_menu()
54 testapp_print(" EMAIL_SORT_DATETIME_HIGH = 0\n");
55 testapp_print(" EMAIL_SORT_DATETIME_LOW = 1\n");
56 testapp_print(" EMAIL_SORT_SENDER_HIGH = 2\n");
57 testapp_print(" EMAIL_SORT_SENDER_LOW = 3\n");
58 testapp_print(" EMAIL_SORT_RCPT_HIGH = 4\n");
59 testapp_print(" EMAIL_SORT_RCPT_LOW = 5\n");
60 testapp_print(" EMAIL_SORT_SUBJECT_HIGH = 6\n");
61 testapp_print(" EMAIL_SORT_SUBJECT_LOW = 7\n");
62 testapp_print(" EMAIL_SORT_PRIORITY_HIGH = 8\n");
63 testapp_print(" EMAIL_SORT_PRIORITY_LOW = 9\n");
64 testapp_print(" EMAIL_SORT_ATTACHMENT_HIGH = 10\n");
65 testapp_print(" EMAIL_SORT_ATTACHMENT_LOW = 11\n");
66 testapp_print(" EMAIL_SORT_FAVORITE_HIGH = 12\n");
67 testapp_print(" EMAIL_SORT_FAVORITE_LOW = 13\n");
70 static void testapp_test_print_mail_list_item(email_mail_list_item_t *mail_list_item, int count)
74 testapp_print("\n>>>>> Print mail list items: count[%d]\n", count);
75 for (i=0; i< count; i++) {
76 testapp_print("\n[%d]\n", i);
77 testapp_print(" >>> Mailbox Name [ %s ] \n", mail_list_item[i].mailbox_name);
78 testapp_print(" >>> Mail ID [ %d ] \n", mail_list_item[i].mail_id);
79 testapp_print(" >>> Account ID [ %d ] \n", mail_list_item[i].account_id);
80 if (mail_list_item[i].from!= NULL) {
81 testapp_print(" >>> From [ %s ] \n", mail_list_item[i].from);
83 if (mail_list_item[i].from_email_address != NULL) {
84 testapp_print(" >>> from_email_address [ %s ] \n", mail_list_item[i].from_email_address);
86 if (mail_list_item[i].recipients!= NULL) {
87 testapp_print(" >>> recipients [ %s ] \n", mail_list_item[i].recipients);
89 if (mail_list_item[i].subject != NULL) {
90 testapp_print(" >>> subject [ %s ] \n", mail_list_item[i].subject);
92 testapp_print(" >>> text_download_yn [ %d ] \n", mail_list_item[i].body_download_status);
93 testapp_print(" >>> date_time [ %d ] \n", mail_list_item[i].date_time);
94 testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list_item[i].flags_seen_field);
95 testapp_print(" >>> priority [ %d ] \n", mail_list_item[i].priority);
96 testapp_print(" >>> save_status [ %d ] \n", mail_list_item[i].save_status);
97 testapp_print(" >>> lock [ %d ] \n", mail_list_item[i].lock_status);
98 testapp_print(" >>> report_status [ %d ] \n", mail_list_item[i].report_status);
99 testapp_print(" >>> recipients_count [ %d ] \n", mail_list_item[i].recipients_count);
100 testapp_print(" >>> attachment_count [ %d ] \n", mail_list_item[i].attachment_count);
101 testapp_print(" >>> DRM_status [ %d ] \n", mail_list_item[i].DRM_status);
103 if (mail_list_item[i].preview_text != NULL) {
104 testapp_print(" >>> preview_text [ %s ] \n", mail_list_item[i].preview_text);
107 testapp_print(" >>> thread_id [ %d ] \n", mail_list_item[i].thread_id);
108 testapp_print(" >>> thread_item_count [ %d ] \n", mail_list_item[i].thread_item_count);
113 static gboolean testapp_add_mail_for_sending(int *result_mail_id)
117 int err = EMAIL_ERROR_NONE;
119 char recipient_address[300] = { 0 , };
120 char from_address[300] = { 0 , };
121 char passpharse[300] = {0, };
122 const char *body_file_path = MAIL_TEMP_BODY;
124 email_account_t *account_data = NULL;
125 email_mailbox_t *mailbox_data = NULL;
126 email_mail_data_t *test_mail_data = NULL;
129 testapp_print("\n > Enter account id : ");
130 if (0 >= scanf("%d", &account_id))
131 testapp_print("Invalid input. ");
133 testapp_print("\n > Enter recipient address : ");
134 if (0 >= scanf("%s", recipient_address))
135 testapp_print("Invalid input. ");
137 email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data);
139 email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data);
141 test_mail_data = malloc(sizeof(email_mail_data_t));
142 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
144 SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address);
146 test_mail_data->account_id = account_id;
147 test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED;
148 test_mail_data->body_download_status = 1;
149 test_mail_data->flags_seen_field = 1;
150 test_mail_data->file_path_plain = strdup(body_file_path);
151 test_mail_data->mailbox_id = mailbox_data->mailbox_id;
152 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
153 test_mail_data->full_address_from = strdup(from_address);
154 test_mail_data->full_address_to = strdup(recipient_address);
155 test_mail_data->subject = strdup("Read receipt request from TIZEN");
156 test_mail_data->remaining_resend_times = 3;
157 test_mail_data->report_status = EMAIL_MAIL_REQUEST_DSN | EMAIL_MAIL_REQUEST_MDN;
159 body_file = fopen(body_file_path, "w");
161 testapp_print("\n body_file [%p]\n", body_file);
163 if (body_file == NULL) {
164 testapp_print("\n fopen [%s]failed\n", body_file_path);
168 for (i = 0; i < 100; i++)
169 fprintf(body_file, "Mail sending Test. [%d]\n", i);
174 testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrpyt, 3: sing + encrypt, 4: pgp sign, 5: pgp encrypted, 6: pgp sign + encrypt] : ");
175 if (0 >= scanf("%d", &smime_type))
176 testapp_print("Invalid input. ");
177 test_mail_data->smime_type = smime_type;
179 if (smime_type >= EMAIL_PGP_SIGNED) {
180 testapp_print(" > passpharse : ");
181 if (0 >= scanf("%s", passpharse))
182 testapp_print("Invalid input. ");
183 test_mail_data->pgp_password = strdup(passpharse);
186 if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE)
187 testapp_print("email_add_mail failed. [%d]\n", err);
189 testapp_print("email_add_mail success.\n");
191 testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id);
194 *result_mail_id = test_mail_data->mail_id;
196 email_free_mail_data(&test_mail_data, 1);
197 email_free_mailbox(&mailbox_data, 1);
198 email_free_account(&account_data, 1);
203 static gboolean testapp_test_add_mail(int *result_mail_id)
209 int attachment_count = 0;
210 int err = EMAIL_ERROR_NONE;
212 char arg[50] = { 0 , };
213 const char *body_file_path = MAIL_TEMP_BODY;
214 email_mailbox_t *mailbox_data = NULL;
215 email_mail_data_t *test_mail_data = NULL;
216 email_attachment_data_t *attachment_data = NULL;
217 email_meeting_request_t *meeting_req = NULL;
220 testapp_print("\n > Enter account id : ");
221 if (0 >= scanf("%d", &account_id))
222 testapp_print("Invalid input. ");
224 memset(arg, 0x00, 50);
225 testapp_print("\n > Enter mailbox id : ");
226 if (0 >= scanf("%d", &mailbox_id))
227 testapp_print("Invalid input. ");
229 if (email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data) != EMAIL_ERROR_NONE)
230 testapp_print("email_get_mailbox_by_mailbox_id failed ");
232 test_mail_data = malloc(sizeof(email_mail_data_t));
233 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
235 testapp_print("\n From EAS? [0/1]> ");
236 if (0 >= scanf("%d", &from_eas))
237 testapp_print("Invalid input. ");
239 test_mail_data->account_id = account_id;
240 test_mail_data->save_status = 1;
241 test_mail_data->body_download_status = 1;
242 test_mail_data->flags_seen_field = 1;
243 test_mail_data->file_path_plain = strdup(body_file_path);
244 test_mail_data->mailbox_id = mailbox_id;
245 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
246 test_mail_data->full_address_from = strdup("<test1@test.com>");
247 test_mail_data->full_address_to = strdup("<test2@test.com>");
248 test_mail_data->full_address_cc = strdup("<test3@test.com>");
249 test_mail_data->full_address_bcc = strdup("<test4@test.com>");
250 test_mail_data->subject = strdup("Meeting request mail");
251 test_mail_data->remaining_resend_times = 3;
252 test_mail_data->eas_data = strdup("EAS DATA TEST");
253 test_mail_data->eas_data_length = strlen(test_mail_data->eas_data) + 1;
255 body_file = fopen(body_file_path, "w");
257 testapp_print("\n body_file [%p]\n", body_file);
259 if (body_file == NULL) {
260 testapp_print("\n fopen [%s]failed\n", body_file_path);
261 email_free_mail_data(&test_mail_data, 1);
262 email_free_mailbox(&mailbox_data, 1);
266 for (i = 0; i < 500; i++)
267 fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2");
269 fprintf(body_file, "Hello world");
273 testapp_print(" > Select smime? [0: Normal, 1: sign, 2: Encrypt, 3: sing + encrypt] : ");
274 if (0 >= scanf("%d", &smime_type))
275 testapp_print("Invalid input. ");
276 test_mail_data->smime_type = smime_type;
278 testapp_print(" > How many file attachment? [>=0] : ");
279 if (0 >= scanf("%d", &attachment_count))
280 testapp_print("Invalid input. ");
282 test_mail_data->attachment_count = attachment_count;
283 if (attachment_count > 0)
284 attachment_data = calloc(attachment_count, sizeof(email_attachment_data_t));
287 for (i = 0; i < attachment_count ; i++) {
288 memset(arg, 0x00, 50);
289 testapp_print("\n > Enter attachment name : ");
290 if (0 >= scanf("%s", arg))
291 testapp_print("Invalid input. ");
293 attachment_data[i].attachment_name = strdup(arg);
295 memset(arg, 0x00, 50);
296 testapp_print("\n > Enter attachment absolute path : ");
297 if (0 >= scanf("%s", arg))
298 testapp_print("Invalid input. ");
300 attachment_data[i].attachment_path = strdup(arg);
301 attachment_data[i].save_status = 1;
302 attachment_data[i].mailbox_id = test_mail_data->mailbox_id;
305 testapp_print("\n > Meeting Request? [0: no, 1: yes(request from server), 2: yes(response from local)]");
306 if (0 >= scanf("%d", (int *)&(test_mail_data->meeting_request_status)))
307 testapp_print("Invalid input. ");
309 if (test_mail_data->meeting_request_status == 1
310 || test_mail_data->meeting_request_status == 2) {
312 /* dummy data for meeting request */
313 meeting_req = malloc(sizeof(email_meeting_request_t));
314 memset(meeting_req, 0x00, sizeof(email_meeting_request_t));
316 meeting_req->meeting_response = 1;
317 current_time = time(NULL);
318 gmtime_r(¤t_time, &(meeting_req->start_time));
319 gmtime_r(¤t_time, &(meeting_req->end_time));
320 meeting_req->location = strdup("Seoul");
321 meeting_req->global_object_id = strdup("abcdef12345");
323 meeting_req->time_zone.offset_from_GMT = 9;
324 strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME");
325 gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date));
326 meeting_req->time_zone.standard_bias = 3;
328 strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME");
329 gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date));
330 meeting_req->time_zone.daylight_bias = 7;
334 if ((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE)
335 testapp_print("email_add_mail failed. [%d]\n", err);
337 testapp_print("email_add_mail success.\n");
339 testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id);
340 testapp_print("saved mailbox id = [%d]\n", test_mail_data->mailbox_id);
343 *result_mail_id = test_mail_data->mail_id;
346 email_free_attachment_data(&attachment_data, attachment_count);
349 email_free_meeting_request(&meeting_req, 1);
351 email_free_mail_data(&test_mail_data, 1);
352 email_free_mailbox(&mailbox_data, 1);
357 static gboolean testapp_test_update_mail()
360 int err = EMAIL_ERROR_NONE;
361 int test_attachment_data_count = 0;
364 email_mail_data_t *test_mail_data = NULL;
365 email_attachment_data_t *test_attachment_data_list = NULL;
366 email_meeting_request_t *meeting_req = NULL;
368 testapp_print("\n > Enter mail id : ");
369 if (0 >= scanf("%d", &mail_id))
370 testapp_print("Invalid input. ");
372 if (email_get_mail_data(mail_id, &test_mail_data) != EMAIL_ERROR_NONE)
373 testapp_print("email_get_mail_data Failed \n ");
375 if (!test_mail_data) {
376 testapp_print("email_get_mail_data() failed\n");
380 testapp_print("\n > Enter Subject: ");
381 if (0 >= scanf("%s", arg))
382 testapp_print("Invalid input. ");
384 test_mail_data->subject = strdup(arg);
386 if (test_mail_data->attachment_count > 0) {
387 if ((err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE) {
388 testapp_print("email_get_attachment_data_list() failed [%d]\n", err);
393 if (test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
394 || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
395 || test_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
397 if ((err = email_get_meeting_request(mail_id, &meeting_req)) != EMAIL_ERROR_NONE) {
398 testapp_print("email_get_meeting_request() failed [%d]\n", err);
402 testapp_print("\n > Enter meeting response: ");
403 if (0 >= scanf("%d", (int *)&(meeting_req->meeting_response)))
404 testapp_print("Invalid input. ");
407 if ((err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMAIL_ERROR_NONE)
408 testapp_print("email_update_mail failed.[%d]\n", err);
410 testapp_print("email_update_mail success\n");
417 email_free_mail_data(&test_mail_data, 1);
419 if (test_attachment_data_list)
420 email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count);
423 email_free_meeting_request(&meeting_req, 1);
431 static gboolean testapp_test_get_mails()
433 testapp_print("\n >>> testapp_test_get_mails : Entered \n");
434 email_mail_data_t *mails = NULL, **mails_pointer = NULL;
436 int count = 0, i = 0;
441 int err_code = EMAIL_ERROR_NONE;
442 int to_get_count = 0;
443 int is_for_thread_view = 0;
445 struct tm *temp_time_info;
447 testapp_print("\n > Enter Account_id(0 = all accounts) : ");
448 if (0 >= scanf("%d", &account_id))
449 testapp_print("Invalid input. ");
450 testapp_print("\n > Enter Mailbox id(0 = all mailboxes) :");
451 if (0 >= scanf("%d", &mailbox_id))
452 testapp_print("Invalid input. ");
454 testapp_print("\n > Enter Sorting : ");
455 if (0 >= scanf("%d", &sorting))
456 testapp_print("Invalid input. ");
458 testapp_print("\n > Enter Start index(starting at 0): ");
459 if (0 >= scanf("%d", &start_index))
460 testapp_print("Invalid input. ");
462 testapp_print("\n > Enter max_count : ");
463 if (0 >= scanf("%d", &limit_count))
464 testapp_print("Invalid input. ");
466 testapp_print("\n > For thread view : ");
467 if (0 >= scanf("%d", &is_for_thread_view))
468 testapp_print("Invalid input. ");
470 testapp_print("\n > Mail count only(0:list 1:count): ");
471 if (0 >= scanf("%d", &to_get_count))
472 testapp_print("Invalid input. ");
475 mails_pointer = NULL;
477 mails_pointer = &mails;
479 if (is_for_thread_view == -2)
480 list_type = EMAIL_LIST_TYPE_LOCAL;
481 else if (is_for_thread_view == -1)
482 list_type = EMAIL_LIST_TYPE_THREAD;
484 list_type = EMAIL_LIST_TYPE_NORMAL;
487 if (mailbox_id == 0) {
488 testapp_print("Calling email_get_mails for all mailbox.\n");
489 err_code = email_get_mails(account_id, 0, list_type, start_index, limit_count, sorting, mails_pointer, &count);
491 testapp_print("email_get_mails failed - err[%d]\n", err_code);
493 testapp_print("Calling email_get_mails for %d mailbox_id.\n", mailbox_id);
494 err_code = email_get_mails(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mails_pointer, &count);
496 testapp_print("email_get_mails failed - err[%d]\n", err_code);
498 testapp_print("email_get_mails >>>>>>count - %d\n", count);
501 for (i = 0; i < count; i++) {
502 testapp_print("\n[%d]\n", i);
503 testapp_print(" >>> mailbox_id [ %d ] \n", mails[i].mailbox_id);
504 testapp_print(" >>> mail_id [ %d ] \n", mails[i].mail_id);
505 testapp_print(" >>> account_id [ %d ] \n", mails[i].account_id);
506 if (mails[i].full_address_from != NULL)
507 testapp_print(" >>> full_address_from [ %s ] \n", mails[i].full_address_from);
508 if (mails[i].full_address_to != NULL)
509 testapp_print(" >>> recipients [ %s ] \n", mails[i].full_address_to);
510 if (mails[i].subject != NULL)
511 testapp_print(" >>> subject [ %s ] \n", mails[i].subject);
512 testapp_print(" >>> body_download_status [ %d ] \n", mails[i].body_download_status);
513 temp_time_info = localtime(&mails[i].date_time);
514 testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n",
515 temp_time_info->tm_year + 1900,
516 temp_time_info->tm_mon+1,
517 temp_time_info->tm_mday,
518 temp_time_info->tm_hour,
519 temp_time_info->tm_min,
520 temp_time_info->tm_sec);
521 testapp_print(" >>> flags_seen_field [ %d ] \n", mails[i].flags_seen_field);
522 testapp_print(" >>> priority [ %d ] \n", mails[i].priority);
523 testapp_print(" >>> save_status [ %d ] \n", mails[i].save_status);
524 testapp_print(" >>> lock_status [ %d ] \n", mails[i].lock_status);
525 testapp_print(" >>> attachment_count [ %d ] \n", mails[i].attachment_count);
526 if (mails[i].preview_text != NULL)
527 testapp_print(" >>> preview_text [ %s ] \n", mails[i].preview_text);
532 testapp_print(" >>> testapp_test_get_mails : End \n");
536 #define TEMP_ARGUMENT_SIZE 4096
538 static gboolean testapp_test_mail_send(int *result_mail_id)
540 int added_mail_id = 0;
541 int err = EMAIL_ERROR_NONE;
543 email_mail_data_t *result_mail_data = NULL;
545 testapp_add_mail_for_sending(&added_mail_id);
548 if (email_get_mail_data(added_mail_id, &result_mail_data) != EMAIL_ERROR_NONE)
549 testapp_print("email_get_mail_data Failed \n ");
551 testapp_print("Calling email_send_mail...\n");
553 if (email_send_mail(added_mail_id, &handle) < 0)
554 testapp_print("Sending failed[%d]\n", err);
556 testapp_print("Start sending. handle[%d]\n", handle);
558 email_free_mail_data(&result_mail_data, 1);
562 *result_mail_id = added_mail_id;
567 static gboolean testapp_test_get_mail_list_ex()
569 email_list_filter_t *filter_list = NULL;
570 email_list_sorting_rule_t sorting_rule_list[2];
571 email_mail_list_item_t *result_mail_list = NULL;
572 int filter_rule_count = 0;
573 int sorting_rule_count = 2;
574 int result_mail_count = 0;
575 int err = EMAIL_ERROR_NONE;
579 filter_rule_count = 3;
581 filter_list = malloc(sizeof(email_list_filter_t) * filter_rule_count);
582 memset(filter_list, 0 , sizeof(email_list_filter_t) * filter_rule_count);
584 filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
585 filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID;
586 filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
587 filter_list[0].list_filter_item.rule.key_value.integer_type_value = 1;
588 filter_list[0].list_filter_item.rule.case_sensitivity = false;
590 filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
591 filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND;
593 filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
594 filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
595 filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
596 filter_list[2].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX;
597 filter_list[2].list_filter_item.rule.case_sensitivity = false;
599 /*filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE_ATTACH;
600 filter_list[0].list_filter_item.rule_attach.target_attribute = EMAIL_MAIL_ATTACH_ATTRIBUTE_ATTACHMENT_NAME;
601 filter_list[0].list_filter_item.rule_attach.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
602 filter_list[0].list_filter_item.rule_attach.key_value.string_type_value = strdup("test");
603 filter_list[0].list_filter_item.rule_attach.case_sensitivity = false;*/
606 filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
607 filter_list[0].list_filter_item.rule_fts.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID;
608 filter_list[0].list_filter_item.rule_fts.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
609 filter_list[0].list_filter_item.rule_fts.key_value.integer_type_value = 1;
611 filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
612 filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
615 filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
616 filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT;
617 filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
618 filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("2013");
619 filter_list[2].list_filter_item.rule.case_sensitivity = false;
622 filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
623 filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
625 filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
626 filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO;
627 filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
628 filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE");
629 filter_list[2].list_filter_item.rule.case_sensitivity = false;
631 filter_list[3].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
632 filter_list[3].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
634 filter_list[4].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
635 filter_list[4].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_CC;
636 filter_list[4].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
637 filter_list[4].list_filter_item.rule.key_value.string_type_value = strdup("RE");
638 filter_list[4].list_filter_item.rule.case_sensitivity = false;
640 filter_list[5].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
641 filter_list[5].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
643 filter_list[6].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
644 filter_list[6].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_BCC;
645 filter_list[6].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
646 filter_list[6].list_filter_item.rule.key_value.string_type_value = strdup("RE");
647 filter_list[6].list_filter_item.rule.case_sensitivity = false;
649 filter_list[7].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
650 filter_list[7].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
652 filter_list[8].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
653 filter_list[8].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FROM;
654 filter_list[8].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
655 filter_list[8].list_filter_item.rule.key_value.string_type_value = strdup("RE");
656 filter_list[8].list_filter_item.rule.case_sensitivity = false;
660 filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
661 filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID;
662 filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
663 filter_list[0].list_filter_item.rule.key_value.integer_type_value = 1;
665 filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
666 filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND;
668 filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
669 filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME;
670 filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
671 filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("INBOX");
672 filter_list[2].list_filter_item.rule.case_sensitivity = true;
675 memset(sorting_rule_list, 0 , sizeof(email_list_sorting_rule_t) * sorting_rule_count);
677 sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_RECIPIENT_ADDRESS;
678 sorting_rule_list[0].key_value.string_type_value = strdup("minsoo.kimn@gmail.com");
679 sorting_rule_list[0].sort_order = EMAIL_SORT_ORDER_TO_CCBCC;
681 testapp_print("\n Enter the sort_order :");
682 if (0 >= scanf("%d", &sort_order))
683 testapp_print("Invalid input.");
685 sorting_rule_list[0].target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT;
686 sorting_rule_list[0].sort_order = sort_order;
688 sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_DATE_TIME;
689 sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_DESCEND;
691 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);
693 if (err == EMAIL_ERROR_NONE) {
694 testapp_print("email_get_mail_list_ex succeed.\n");
696 for (i = 0; i < result_mail_count; i++) {
697 testapp_print("mail_id [%d], subject [%s], mailbox_type [%d] full_address_from [%s]\n",
698 result_mail_list[i].mail_id,
699 result_mail_list[i].subject,
700 result_mail_list[i].mailbox_type,
701 result_mail_list[i].full_address_from);
704 testapp_print("email_get_mail_list_ex failed.\n");
707 email_free_list_filter(&filter_list, 3);
712 static gboolean testapp_test_send_cancel()
718 int *mailIdList = NULL;
721 testapp_print("\n > Enter total Number of mail want to send: ");
722 if (0 >= scanf("%d", &num))
723 testapp_print("Invalid input. ");
724 mailIdList = (int *)malloc(sizeof(int)*num);
728 for (i = 1; i <= num; i++) {
729 testapp_test_mail_send(&mail_id);
731 testapp_print("mail_id[%d]", mail_id);
733 mailIdList[i] = mail_id;
734 testapp_print("mailIdList[%d][%d]", i, mailIdList[i]);
737 testapp_print("\n > Do you want to cancel the send mail job '1' or '0': ");
738 if (0 >= scanf("%d", &Y))
739 testapp_print("Invalid input. ");
741 testapp_print("\n >Enter mail-id[1-%d] ", i);
742 if (0 >= scanf("%d", &j))
743 testapp_print("Invalid input. ");
744 testapp_print("\n mailIdList[%d] ", mailIdList[j]);
745 if (email_cancel_sending_mail(mailIdList[j]) < 0)
746 testapp_print("email_cancel_sending_mail failed..!");
748 testapp_print("email_cancel_sending_mail success..!");
755 static gboolean testapp_test_delete()
757 int mail_id = 0, account_id = 0;
759 int err = EMAIL_ERROR_NONE;
762 testapp_print("\n > Enter Account_id: ");
763 if (0 >= scanf("%d", &account_id))
764 testapp_print("Invalid input. ");
766 testapp_print("\n > Enter Mail_id: ");
767 if (0 >= scanf("%d", &mail_id))
768 testapp_print("Invalid input. ");
770 testapp_print("\n > Enter Mailbox id: ");
771 if (0 >= scanf("%d", &mailbox_id))
772 testapp_print("Invalid input. ");
774 testapp_print("\n > Enter from_server: ");
775 if (0 >= scanf("%d", &from_server))
776 testapp_print("Invalid input. ");
779 if ((err = email_delete_mail(mailbox_id, &mail_id, 1, from_server)) < 0)
780 testapp_print("\n email_delete_mail failed[%d]\n", err);
782 testapp_print("\n email_delete_mail success\n");
787 static gboolean testapp_test_update_mail_attribute()
789 int err = EMAIL_ERROR_NONE;
792 int *mail_id_array = NULL;
793 int mail_id_count = 0;
794 email_mail_attribute_type attribute_type;
795 email_mail_attribute_value_t attribute_value;
797 testapp_print("\n > Enter account_id: ");
798 if (0 >= scanf("%d", &account_id))
799 testapp_print("Invalid input. ");
801 testapp_print("\n > Enter attribute_type: ");
802 if (0 >= scanf("%d", (int*)&attribute_type))
803 testapp_print("Invalid input. ");
805 testapp_print("\n > Enter integer type value: ");
806 if (0 >= scanf("%d", (int*)&(attribute_value.integer_type_value)))
807 testapp_print("Invalid input. ");
809 testapp_print("\n > Enter mail_id_count: ");
810 if (0 >= scanf("%d", &mail_id_count))
811 testapp_print("Invalid input. ");
813 mail_id_count = (mail_id_count < 5000) ? mail_id_count : 5000;
815 if (mail_id_count > 0)
816 mail_id_array = malloc(sizeof(int) * mail_id_count);
818 for (i = 0; i < mail_id_count; i++) {
819 testapp_print("\n > Enter mail id: ");
820 if (0 >= scanf("%d", (mail_id_array + i)))
821 testapp_print("Invalid input. ");
825 if ((err = email_update_mail_attribute(account_id, mail_id_array, mail_id_count, attribute_type, attribute_value)) < EMAIL_ERROR_NONE)
826 testapp_print("\n email_update_mail_attribute failed[%d]\n", err);
828 testapp_print("\n email_update_mail_attribute success\n");
836 static gboolean testapp_test_move()
842 for (i = 0; i < 3; i++) {
843 testapp_print("\n > Enter mail_id: ");
844 if (0 >= scanf("%d", &mail_id[i]))
845 testapp_print("Invalid input. ");
848 testapp_print("\n > Enter mailbox_id: ");
849 if (0 >= scanf("%d", &mailbox_id))
850 testapp_print("Invalid input. ");
853 email_move_mail_to_mailbox(mail_id, 3, mailbox_id);
857 static gboolean testapp_test_delete_all()
860 int err = EMAIL_ERROR_NONE;
862 testapp_print("\n > Enter mailbox_id: ");
863 if (0 >= scanf("%d", &mailbox_id))
864 testapp_print("Invalid input. ");
866 /* delete all message */
867 if ((err = email_delete_all_mails_in_mailbox(mailbox_id, 0)) < 0)
868 testapp_print("email_delete_all_mails_in_mailbox failed [%d]\n", err);
870 testapp_print("email_delete_all_mails_in_mailbox Success\n");
876 static gboolean testapp_test_add_attachment()
880 email_attachment_data_t attachment;
882 testapp_print("\n > Enter Mail Id: ");
883 if (0 >= scanf("%d", &mail_id))
884 testapp_print("Invalid input. ");
886 memset(&attachment, 0x00, sizeof(email_attachment_data_t));
887 memset(arg, 0x00, 100);
888 testapp_print("\n > Enter attachment name: ");
889 if (0 >= scanf("%s", arg))
890 testapp_print("Invalid input. ");
892 attachment.attachment_name = strdup(arg);
894 memset(arg, 0x00, 100);
895 testapp_print("\n > Enter attachment absolute path: ");
896 if (0 >= scanf("%s", arg))
897 testapp_print("Invalid input. ");
899 attachment.save_status = true;
900 attachment.attachment_path = strdup(arg);
901 if (email_add_attachment(mail_id, &attachment) < 0)
902 testapp_print("email_add_attachment failed\n");
904 testapp_print("email_add_attachment success\n");
911 static gboolean testapp_test_set_deleted_flag()
915 int mail_ids[100] = { 0, };
916 int temp_mail_id = 0;
917 int err_code = EMAIL_ERROR_NONE;
919 testapp_print("\n >>> Input target account id: ");
920 if (0 >= scanf("%d", &account_id))
921 testapp_print("Invalid input. ");
924 testapp_print("\n >>> Input target mail id( Input 0 to terminate ) [MAX = 100]: ");
925 if (0 >= scanf("%d", &temp_mail_id))
926 testapp_print("Invalid input. ");
927 mail_ids[index++] = temp_mail_id;
928 } while (temp_mail_id != 0);
930 err_code = email_set_flags_field(account_id, mail_ids, index, EMAIL_FLAGS_DELETED_FIELD, 1, true);
931 testapp_print("email_set_flags_field returns - err[%d]\n", err_code);
936 static gboolean testapp_test_expunge_mails_deleted_flagged()
940 int err_code = EMAIL_ERROR_NONE;
943 testapp_print("\n >>> Input target mailbox id: ");
944 if (0 >= scanf("%d", &mailbox_id))
945 testapp_print("Invalid input. ");
947 testapp_print("\n >>> Expunge on server?: ");
948 if (0 >= scanf("%d", &on_server))
949 testapp_print("Invalid input. ");
951 err_code = email_expunge_mails_deleted_flagged(mailbox_id, on_server, &handle);
953 testapp_print("email_expunge_mails_deleted_flagged returns - err[%d]\n", err_code);
958 static gboolean testapp_test_send_read_receipt()
960 int read_mail_id = 0;
961 int receipt_mail_id = 0;
962 int err_code = EMAIL_ERROR_NONE;
965 testapp_print("\n >>> Input read mail id: ");
966 if (0 >= scanf("%d", &read_mail_id))
967 testapp_print("Invalid input. ");
969 err_code = email_add_read_receipt(read_mail_id, &receipt_mail_id);
971 testapp_print("eamil_add_read_receipt returns receipt_mail_id [%d] - err[%d]\n", receipt_mail_id, err_code);
972 testapp_print("Calling email_send_mail...\n");
974 if ((err_code = email_send_mail(receipt_mail_id, &handle)) != EMAIL_ERROR_NONE)
975 testapp_print("Sending failed[%d]\n", err_code);
977 testapp_print("Start sending. handle[%d]\n", handle);
982 static gboolean testapp_test_delete_attachment()
984 int attachment_id = 0;
985 int err_code = EMAIL_ERROR_NONE;
987 testapp_print("\n >>> Input attachment id: ");
988 if (0 >= scanf("%d", &attachment_id))
989 testapp_print("Invalid input. ");
991 if ((err_code = email_delete_attachment(attachment_id)) != EMAIL_ERROR_NONE)
992 testapp_print("email_delete_attachment failed[%d]\n", err_code);
997 static gboolean testapp_test_get_mail_list()
999 testapp_print("\n >>> testapp_test_get_mail_list : Entered \n");
1000 email_mail_list_item_t *mail_list = NULL, **mail_list_pointer = NULL;
1002 int count = 0, i = 0;
1004 int start_index = 0;
1005 int limit_count = 0;
1007 int err_code = EMAIL_ERROR_NONE;
1008 int to_get_count = 0;
1009 int is_for_thread_view = 0;
1011 struct tm *temp_time_info;
1013 testapp_print("\n > Enter Account_id(0 = all accounts) : ");
1014 if (0 >= scanf("%d", &account_id))
1015 testapp_print("Invalid input. ");
1017 testapp_print("\n > Enter Mailbox id(0 = all mailboxes) :");
1018 if (0 >= scanf("%d", &mailbox_id))
1019 testapp_print("Invalid input. ");
1021 testapp_print("\n > Enter Sorting : ");
1022 if (0 >= scanf("%d", &sorting))
1023 testapp_print("Invalid input. ");
1025 testapp_print("\n > Enter Start index(starting at 0): ");
1026 if (0 >= scanf("%d", &start_index))
1027 testapp_print("Invalid input. ");
1029 testapp_print("\n > Enter max_count : ");
1030 if (0 >= scanf("%d", &limit_count))
1031 testapp_print("Invalid input. ");
1033 testapp_print("\n > For thread view : ");
1034 if (0 >= scanf("%d", &is_for_thread_view))
1035 testapp_print("Invalid input. ");
1037 testapp_print("\n > Count mails?(1: YES):");
1038 if (0 >= scanf("%d", &to_get_count))
1039 testapp_print("Invalid input. ");
1042 mail_list_pointer = NULL;
1044 mail_list_pointer = &mail_list;
1046 if (is_for_thread_view == -2)
1047 list_type = EMAIL_LIST_TYPE_LOCAL;
1048 else if (is_for_thread_view == -1)
1049 list_type = EMAIL_LIST_TYPE_THREAD;
1051 list_type = EMAIL_LIST_TYPE_NORMAL;
1054 if (mailbox_id == 0) {
1055 testapp_print("Calling email_get_mail_list for all mailbox.\n");
1056 err_code = email_get_mail_list(account_id, 0, list_type, start_index, limit_count, sorting, mail_list_pointer, &count);
1058 testapp_print("email_get_mail_list failed - err[%d]\n", err_code);
1060 testapp_print("Calling email_get_mail_list for %d mailbox_id.\n", mailbox_id);
1061 err_code = email_get_mail_list(account_id, mailbox_id, list_type, start_index, limit_count, sorting, mail_list_pointer, &count);
1063 testapp_print("email_get_mail_list failed - err[%d]\n", err_code);
1065 testapp_print("email_get_mail_list >>>>>>count - %d\n", count);
1068 for (i = 0; i < count; i++) {
1069 testapp_print("\n[%d]\n", i);
1070 testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id);
1071 testapp_print(" >>> mailbox_type [ %d ] \n", mail_list[i].mailbox_type);
1072 testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id);
1073 testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id);
1074 testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from);
1075 testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient);
1076 testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject);
1077 testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status);
1078 temp_time_info = localtime(&mail_list[i].date_time);
1079 testapp_print(" >>> date_time [ %d/%d/%d %d:%d:%d] \n",
1080 temp_time_info->tm_year + 1900,
1081 temp_time_info->tm_mon+1,
1082 temp_time_info->tm_mday,
1083 temp_time_info->tm_hour,
1084 temp_time_info->tm_min,
1085 temp_time_info->tm_sec);
1086 testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field);
1087 testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority);
1088 testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status);
1089 testapp_print(" >>> lock_status [ %d ] \n", mail_list[i].lock_status);
1090 testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count);
1091 if (!*mail_list[i].preview_text)
1092 testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text);
1097 testapp_print("\n >>> email_get_mail_list : End \n");
1102 static gboolean testapp_test_get_mail_list_for_thread_view()
1104 testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : Entered \n");
1105 email_mail_list_item_t *mail_list = NULL;
1106 int count = 0, i = 0;
1109 int err_code = EMAIL_ERROR_NONE;
1110 struct tm *time_info;
1113 testapp_print("\nEnter account id\n");
1114 if (0 >= scanf("%d", &account_id))
1115 testapp_print("Invalid input. ");
1117 testapp_print("\nEnter mailbox id\n");
1118 if (0 >= scanf("%d", &mailbox_id))
1119 testapp_print("Invalid input. ");
1122 if (email_get_mail_list(account_id, mailbox_id , EMAIL_LIST_TYPE_THREAD, 0, 500, EMAIL_SORT_DATETIME_HIGH, &mail_list, &count) < 0) {
1123 testapp_print("email_get_mail_list failed : %d\n", err_code);
1126 testapp_print("email_get_mail_list >>>>>>count - %d\n", count);
1128 for (i = 0; i < count; i++) {
1129 testapp_print(" i [%d]\n", i);
1130 testapp_print(" >>> mail_id [ %d ] \n", mail_list[i].mail_id);
1131 testapp_print(" >>> account_id [ %d ] \n", mail_list[i].account_id);
1132 testapp_print(" >>> mailbox_id [ %d ] \n", mail_list[i].mailbox_id);
1133 testapp_print(" >>> full_address_from [ %s ] \n", mail_list[i].full_address_from);
1134 testapp_print(" >>> email_address_recipient [ %s ] \n", mail_list[i].email_address_recipient);
1135 testapp_print(" >>> subject [ %s ] \n", mail_list[i].subject);
1136 testapp_print(" >>> body_download_status [ %d ] \n", mail_list[i].body_download_status);
1137 time_info = localtime(&mail_list[i].date_time);
1138 testapp_print(" >>> date_time [ %s ] \n", asctime_r(time_info, buf));
1139 testapp_print(" >>> flags_seen_field [ %d ] \n", mail_list[i].flags_seen_field);
1140 testapp_print(" >>> priority [ %d ] \n", mail_list[i].priority);
1141 testapp_print(" >>> save_status [ %d ] \n", mail_list[i].save_status);
1142 testapp_print(" >>> lock [ %d ] \n", mail_list[i].lock_status);
1143 testapp_print(" >>> attachment_count [ %d ] \n", mail_list[i].attachment_count);
1144 testapp_print(" >>> preview_text [ %s ] \n", mail_list[i].preview_text);
1145 testapp_print(" >>> thread_id [ %d ] \n", mail_list[i].thread_id);
1146 testapp_print(" >>> thread__item_count [ %d ] \n", mail_list[i].thread_item_count);
1150 testapp_print(" >>> testapp_test_get_mail_list_for_thread_view : End \n");
1154 static gboolean testapp_test_count()
1158 email_list_filter_t *filter_list = NULL;
1160 filter_list = malloc(sizeof(email_list_filter_t) * 3);
1161 memset(filter_list, 0 , sizeof(email_list_filter_t) * 3);
1163 filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
1164 filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_SUBJECT;
1165 filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
1166 filter_list[0].list_filter_item.rule.key_value.string_type_value = strdup("RE");
1167 filter_list[0].list_filter_item.rule.case_sensitivity = false;
1169 filter_list[1].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
1170 filter_list[1].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_OR;
1172 filter_list[2].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
1173 filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_TO;
1174 filter_list[2].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_INCLUDE;
1175 filter_list[2].list_filter_item.rule.key_value.string_type_value = strdup("RE");
1176 filter_list[2].list_filter_item.rule.case_sensitivity = false;
1178 if (EMAIL_ERROR_NONE == email_count_mail(filter_list, 3, &total, &unseen))
1179 printf("\n Total: %d, Unseen: %d \n", total, unseen);
1184 static gboolean testapp_test_move_mails_to_mailbox_of_another_account()
1186 int err = EMAIL_ERROR_NONE;
1187 int mail_id_count = 0 ;
1188 int *mail_id_array = NULL;
1189 int source_mailbox_id = 0;
1190 int target_mailbox_id = 0;
1194 testapp_print("\n > Enter source mailbox id: ");
1195 if (0 >= scanf("%d", &source_mailbox_id))
1196 testapp_print("Invalid input. ");
1198 testapp_print("\n > Enter target mailbox id: ");
1199 if (0 >= scanf("%d", &target_mailbox_id))
1200 testapp_print("Invalid input. ");
1202 testapp_print("\n > Enter mail count: ");
1203 if (0 >= scanf("%d", &mail_id_count))
1204 testapp_print("Invalid input. ");
1206 mail_id_count = (mail_id_count < 5000) ? mail_id_count : 5000;
1208 if (mail_id_count > 0)
1209 mail_id_array = malloc(sizeof(int) * mail_id_count);
1211 for (i = 0; i < mail_id_count; i++) {
1212 testapp_print("\n > Enter mail id: ");
1213 if (0 >= scanf("%d", (mail_id_array + i)))
1214 testapp_print("Invalid input. ");
1217 err = email_move_mails_to_mailbox_of_another_account(source_mailbox_id, mail_id_array, mail_id_count, target_mailbox_id, &task_id);
1219 testapp_print("\nemail_move_mails_to_mailbox_of_another_account returns [%d], tast_id [%d] \n", err, task_id);
1223 static gboolean copy_file(char *input_source_path, char *input_dest_path)
1225 int childExitStatus;
1228 if (!input_source_path || !input_dest_path)
1231 testapp_print("copy_file started\n");
1236 testapp_print("Copying file [%s] [%s]\n", input_source_path, input_dest_path);
1237 execl("/bin/cp", "/bin/cp", input_source_path, input_dest_path, (char *)0);
1239 testapp_print("Wating child process\n");
1240 pid_t ws = waitpid(pid, &childExitStatus, WNOHANG);
1241 if (ws == -1) { /* error - handle as you wish */
1242 testapp_print("waitpid returns error\n");
1245 if (WIFEXITED(childExitStatus)) {
1246 /* exit code in childExitStatus */
1247 WEXITSTATUS(childExitStatus); /* zero is normal exit */
1248 testapp_print("WEXITSTATUS\n");
1249 /* handle non-zero as you wish */
1250 } else if (WIFSIGNALED(childExitStatus)) { /* killed */
1251 testapp_print("WIFSIGNALED\n");
1252 } else if (WIFSTOPPED(childExitStatus)) { /* stopped */
1253 testapp_print("WIFSTOPPED\n");
1256 testapp_print("copy_file finished\n");
1261 static gboolean testapp_test_send_mail_with_downloading_attachment_of_original_mail()
1263 int err = EMAIL_ERROR_NONE;
1264 int original_mail_id = 0;
1265 int original_attachment_count = 0;
1268 char *plain_text_path = MAIL_TEMP_BODY;
1269 char *html_file_path = HTML_TEMP_BODY;
1270 char new_subject[4086] = { 0, };
1271 /* FILE *body_file; */
1272 email_mail_data_t *original_mail_data = NULL;
1273 email_mailbox_t *outbox = NULL;
1274 email_attachment_data_t *original_attachment_array = NULL;
1276 testapp_print("\n > Enter original mail id: ");
1277 if (0 >= scanf("%d", &original_mail_id))
1278 testapp_print("Invalid input. ");
1280 /* Get original mail */
1281 if ((err = email_get_mail_data(original_mail_id, &original_mail_data)) != EMAIL_ERROR_NONE || !original_mail_data) {
1282 testapp_print("email_get_mail_data failed [%d]\n", err);
1286 /* Get attachment of original mail */
1287 if ((err = email_get_attachment_data_list(original_mail_id, &original_attachment_array, &original_attachment_count)) != EMAIL_ERROR_NONE || !original_attachment_array) {
1288 testapp_print("email_get_attachment_data_list failed [%d]\n", err);
1292 /* Remove attachment file path */
1293 for (i = 0; i < original_attachment_count; i++) {
1294 original_attachment_array[i].save_status = 0;
1295 if (original_attachment_array[i].attachment_path)
1296 free(original_attachment_array[i].attachment_path);
1297 original_attachment_array[i].attachment_path = NULL;
1300 /* Set reference mail id */
1301 original_mail_data->reference_mail_id = original_mail_data->mail_id;
1302 original_mail_data->body_download_status = 1;
1304 /* Set from address */
1305 if (!original_mail_data->full_address_from)
1306 original_mail_data->full_address_from = strdup("<abc@abc.com>");
1308 /* Rewrite subject */
1309 if (original_mail_data->subject) {
1310 snprintf(new_subject, 4086, "Fw:%s", original_mail_data->subject);
1311 free(original_mail_data->subject);
1312 original_mail_data->subject = NULL;
1314 snprintf(new_subject, 4086, "Forward test");
1317 original_mail_data->subject = strdup(new_subject);
1319 /* Set mailbox information */
1320 if ((err = email_get_mailbox_by_mailbox_type(original_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &outbox)) != EMAIL_ERROR_NONE || !outbox) {
1321 testapp_print("email_get_mailbox_by_mailbox_type failed [%d]\n", err);
1324 original_mail_data->mailbox_id = outbox->mailbox_id;
1325 original_mail_data->mailbox_type = outbox->mailbox_type;
1327 /* Copy body text */
1328 if (original_mail_data->file_path_html) {
1329 copy_file(original_mail_data->file_path_html, html_file_path);
1330 /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_html, html_file_path,(char *)0); */
1331 free(original_mail_data->file_path_html);
1332 original_mail_data->file_path_html = strdup(html_file_path);
1335 if (original_mail_data->file_path_plain) {
1336 copy_file(original_mail_data->file_path_plain, plain_text_path);
1337 /*execl("/bin/cp", "/bin/cp", original_mail_data->file_path_plain, plain_text_path,(char *)0);*/
1338 free(original_mail_data->file_path_plain);
1339 original_mail_data->file_path_plain = strdup(plain_text_path);
1344 body_file = fopen(body_file_path, "w");
1346 testapp_print("\n body_file [%p]\n", body_file);
1348 if (body_file == NULL) {
1349 testapp_print("\n fopen [%s]failed\n", body_file_path);
1353 for (i = 0; i < 100; i++)
1354 fprintf(body_file, "Mail sending Test. [%d]\n", i);
1361 if ((err = email_add_mail(original_mail_data, original_attachment_array, original_attachment_count, NULL, false)) != EMAIL_ERROR_NONE) {
1362 testapp_print("email_get_attachment_data_list failed [%d]\n", err);
1363 email_free_mailbox(&outbox, 1);
1368 if ((err = email_send_mail_with_downloading_attachment_of_original_mail(original_mail_data->mail_id, &handle)) != EMAIL_ERROR_NONE) {
1369 testapp_print("email_send_mail_with_downloading_attachment_of_original_mail failed [%d]\n", err);
1370 email_free_mailbox(&outbox, 1);
1374 if (original_mail_data)
1375 email_free_mail_data(&original_mail_data, 1);
1378 email_free_mailbox(&outbox, 1);
1380 if (original_attachment_array)
1381 email_free_attachment_data(&original_attachment_array, original_attachment_count);
1386 static gboolean testapp_test_get_mail_data()
1388 int err = EMAIL_ERROR_NONE;
1390 email_mail_data_t *mail_data = NULL;
1392 testapp_print("\n > Enter mail id: ");
1393 if (0 >= scanf("%d", &mail_id))
1394 testapp_print("Invalid input. ");
1396 /* Get original mail */
1397 if ((err = email_get_mail_data(mail_id, &mail_data)) != EMAIL_ERROR_NONE || !mail_data) {
1398 testapp_print("email_get_mail_data failed [%d]\n", err);
1402 testapp_print("mail_id [%d]\n", mail_data->mail_id);
1403 testapp_print("account_id [%d]\n", mail_data->account_id);
1404 testapp_print("mailbox_id [%d]\n", mail_data->mailbox_id);
1405 testapp_print("mailbox_type [%d]\n", mail_data->mailbox_type);
1406 if (mail_data->subject)
1407 testapp_print("subject [%s]\n", mail_data->subject);
1408 testapp_print("date_time [%d]\n", mail_data->date_time);
1409 testapp_print("server_mail_status [%d]\n", mail_data->server_mail_status);
1411 if (mail_data->server_mailbox_name)
1412 testapp_print("server_mailbox_name [%s]\n", mail_data->server_mailbox_name);
1414 if (mail_data->server_mail_id)
1415 testapp_print("server_mail_id [%s]\n", mail_data->server_mail_id);
1417 if (mail_data->message_id)
1418 testapp_print("message_id [%s]\n", mail_data->message_id);
1420 testapp_print("reference_mail_id [%d]\n", mail_data->reference_mail_id);
1422 if (mail_data->full_address_from)
1423 testapp_print("full_address_from [%s]\n", mail_data->full_address_from);
1425 if (mail_data->full_address_reply)
1426 testapp_print("full_address_reply [%s]\n", mail_data->full_address_reply);
1428 if (mail_data->full_address_to)
1429 testapp_print("full_address_to [%s]\n", mail_data->full_address_to);
1431 if (mail_data->full_address_cc)
1432 testapp_print("full_address_cc [%s]\n", mail_data->full_address_cc);
1434 if (mail_data->full_address_bcc)
1435 testapp_print("full_address_bcc [%s]\n", mail_data->full_address_bcc);
1437 if (mail_data->full_address_return)
1438 testapp_print("full_address_return [%s]\n", mail_data->full_address_return);
1440 if (mail_data->email_address_sender)
1441 testapp_print("email_address_sender [%s]\n", mail_data->email_address_sender);
1443 if (mail_data->email_address_recipient)
1444 testapp_print("email_address_recipient [%s]\n", mail_data->email_address_recipient);
1446 if (mail_data->alias_sender)
1447 testapp_print("alias_sender [%s]\n", mail_data->alias_sender);
1449 if (mail_data->alias_recipient)
1450 testapp_print("alias_recipient [%s]\n", mail_data->alias_recipient);
1452 testapp_print("body_download_status [%d]\n", mail_data->body_download_status);
1454 if (mail_data->file_path_plain)
1455 testapp_print("file_path_plain [%s]\n", mail_data->file_path_plain);
1457 if (mail_data->file_path_html)
1458 testapp_print("file_path_html [%s]\n", mail_data->file_path_html);
1460 testapp_print("file_path_mime_entity [%s]\n", mail_data->file_path_mime_entity);
1461 testapp_print("mail_size [%d]\n", mail_data->mail_size);
1462 testapp_print("flags_seen_field [%d]\n", mail_data->flags_seen_field);
1463 testapp_print("flags_deleted_field [%d]\n", mail_data->flags_deleted_field);
1464 testapp_print("flags_flagged_field [%d]\n", mail_data->flags_flagged_field);
1465 testapp_print("flags_answered_field [%d]\n", mail_data->flags_answered_field);
1466 testapp_print("flags_recent_field [%d]\n", mail_data->flags_recent_field);
1467 testapp_print("flags_draft_field [%d]\n", mail_data->flags_draft_field);
1468 testapp_print("flags_forwarded_field [%d]\n", mail_data->flags_forwarded_field);
1469 testapp_print("DRM_status [%d]\n", mail_data->DRM_status);
1470 testapp_print("priority [%d]\n", mail_data->priority);
1471 testapp_print("save_status [%d]\n", mail_data->save_status);
1472 testapp_print("lock_status [%d]\n", mail_data->lock_status);
1473 testapp_print("report_status [%d]\n", mail_data->report_status);
1474 testapp_print("attachment_count [%d]\n", mail_data->attachment_count);
1475 testapp_print("inline_content_count [%d]\n", mail_data->inline_content_count);
1476 testapp_print("thread_id [%d]\n", mail_data->thread_id);
1477 testapp_print("thread_item_count [%d]\n", mail_data->thread_item_count);
1479 if (mail_data->preview_text)
1480 testapp_print("preview_text [%s]\n", mail_data->preview_text);
1482 testapp_print("meeting_request_status [%d]\n", mail_data->meeting_request_status);
1483 testapp_print("message_class [%d]\n", mail_data->message_class);
1484 testapp_print("digest_type [%d]\n", mail_data->digest_type);
1485 testapp_print("smime_type [%d]\n", mail_data->smime_type);
1486 testapp_print("scheduled_sending_time [%d]\n", mail_data->scheduled_sending_time);
1487 testapp_print("remaining_resend_times [%d]\n", mail_data->remaining_resend_times);
1488 testapp_print("eas_data_length [%d]\n", mail_data->eas_data_length);
1493 static gboolean testapp_test_schedule_sending_mail()
1495 int added_mail_id = 0;
1496 int err = EMAIL_ERROR_NONE;
1498 time_t time_to_send;
1500 testapp_add_mail_for_sending(&added_mail_id);
1502 if (added_mail_id) {
1503 time(&time_to_send);
1506 testapp_print("Calling email_schedule_sending_mail...\n");
1508 if (email_schedule_sending_mail(added_mail_id, time_to_send) < 0)
1509 testapp_print("email_schedule_sending_mail failed[%d]\n", err);
1511 testapp_print("Start sending. handle[%d]\n", handle);
1517 static gboolean testapp_test_set_flags_field()
1522 testapp_print("\n > Enter Account ID: ");
1523 if (0 >= scanf("%d", &account_id))
1524 testapp_print("Invalid input. ");
1526 testapp_print("\n > Enter Mail ID: ");
1527 if (0 >= scanf("%d", &mail_id))
1528 testapp_print("Invalid input. ");
1530 if (email_set_flags_field(account_id, &mail_id, 1, EMAIL_FLAGS_FLAGGED_FIELD, 1, 1) < 0)
1531 testapp_print("email_set_flags_field failed");
1533 testapp_print("email_set_flags_field success");
1538 static gboolean testapp_test_download_body()
1541 int handle = 0, err;
1543 testapp_print("\n > Enter Mail Id: ");
1544 if (0 >= scanf("%d", &mail_id))
1545 testapp_print("Invalid input. ");
1546 err = email_download_body(mail_id, 0, &handle);
1548 testapp_print("email_download_body failed");
1550 testapp_print("email_download_body success");
1551 testapp_print("handle[%d]\n", handle);
1557 static gboolean testapp_test_cancel_download_body()
1564 email_mailbox_t mailbox;
1565 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
1567 testapp_print("\n > Enter account_id: ");
1568 if (0 >= scanf("%d", &account_id))
1569 testapp_print("Invalid input. ");
1571 testapp_print("\n > Enter mail id: ");
1572 if (0 >= scanf("%d", &mail_id))
1573 testapp_print("Invalid input. ");
1575 if (email_download_body(mail_id, 0, &handle) < 0)
1576 testapp_print("email_download_body failed");
1578 testapp_print("email_download_body success\n");
1579 testapp_print("Do u want to cancel download job>>>>>1/0\n");
1580 if (0 >= scanf("%d", &yes))
1581 testapp_print("Invalid input. ");
1583 if (email_cancel_job(account_id, handle , EMAIL_CANCELED_BY_USER) < 0)
1584 testapp_print("email_cancel_job failed..!");
1586 testapp_print("email_cancel_job success..!");
1587 testapp_print("handle[%d]\n", handle);
1594 static gboolean testapp_test_download_attachment()
1597 int attachment_no = 0;
1600 testapp_print("\n > Enter Mail Id: ");
1601 if (0 >= scanf("%d", &mail_id))
1602 testapp_print("Invalid input. ");
1604 testapp_print("\n > Enter attachment number: ");
1605 if (0 >= scanf("%d", &attachment_no))
1606 testapp_print("Invalid input. ");
1608 if (email_download_attachment(mail_id, attachment_no, &handle) < 0)
1609 testapp_print("email_download_attachment failed");
1611 testapp_print("email_download_attachment success");
1612 testapp_print("handle[%d]\n", handle);
1618 static gboolean testapp_test_get_attachment_data_list()
1620 int err = EMAIL_ERROR_NONE;
1623 int test_attachment_data_count;
1624 email_attachment_data_t *test_attachment_data_list = NULL;
1626 testapp_print("\n > Enter Mail id: ");
1627 if (0 >= scanf("%d", &mail_id))
1628 testapp_print("Invalid input. ");
1630 if ((err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMAIL_ERROR_NONE) {
1631 testapp_print("email_get_attachment_data_list() failed [%d]\n", err);
1634 if (test_attachment_data_list) {
1635 for (i = 0; i < test_attachment_data_count; i++) {
1636 testapp_print("index [%d]\n", i);
1637 testapp_print("attachment_name [%s]\n", test_attachment_data_list[i].attachment_name);
1638 testapp_print("attachment_path [%s]\n", test_attachment_data_list[i].attachment_path);
1639 testapp_print("attachment_size [%d]\n", test_attachment_data_list[i].attachment_size);
1640 testapp_print("mail_id [%d]\n", test_attachment_data_list[i].mail_id);
1641 testapp_print("attachment_mime_type [%s]\n", test_attachment_data_list[i].attachment_mime_type);
1643 email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count);
1651 static gboolean testapp_test_get_meeting_request()
1654 int err = EMAIL_ERROR_NONE;
1655 email_meeting_request_t *meeting_request;
1657 testapp_print("\n > Enter Mail Id: ");
1658 if (0 >= scanf("%d", &mail_id))
1659 testapp_print("Invalid input. ");
1661 err = email_get_meeting_request(mail_id, &meeting_request);
1663 testapp_print("err[%d]\n", err);
1665 if (err == EMAIL_ERROR_NONE && meeting_request) {
1666 testapp_print("mail_id [%d]\n", meeting_request->mail_id);
1667 testapp_print("global_object_id [%s]\n", meeting_request->global_object_id);
1668 testapp_print("meeting_response [%d]\n", meeting_request->meeting_response);
1671 email_free_meeting_request(&meeting_request, 1);
1675 static gboolean testapp_test_retry_send()
1680 email_mailbox_t mailbox;
1681 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
1683 testapp_print("\n > Enter Mail Id: ");
1684 if (0 >= scanf("%d", &mail_id))
1685 testapp_print("Invalid input. ");
1687 testapp_print("\n > Enter timeout in seconds: ");
1688 if (0 >= scanf("%d", &timeout))
1689 testapp_print("Invalid input. ");
1691 if (email_retry_sending_mail(mail_id, timeout) < 0)
1692 testapp_print("email_retry_sending_mail failed");
1696 static gboolean testapp_test_get_attachment_data()
1698 int attachment_id = 0;
1699 email_attachment_data_t *attachment = NULL;
1701 testapp_print("\n > Enter attachment id: ");
1702 if (0 >= scanf("%d", &attachment_id))
1703 testapp_print("Invalid input. ");
1705 email_get_attachment_data(attachment_id, &attachment);
1708 testapp_print("attachment_name [%s]\n", attachment->attachment_name);
1709 testapp_print("attachment_path [%s]\n", attachment->attachment_path);
1710 testapp_print("attachment_size [%d]\n", attachment->attachment_size);
1711 testapp_print("mail_id [%d]\n", attachment->mail_id);
1712 testapp_print("attachment_mime_type [%s]\n", attachment->attachment_mime_type);
1718 static gboolean testapp_test_move_all_mails_to_mailbox()
1720 int err = EMAIL_ERROR_NONE;
1722 int dest_mailbox_id;
1724 testapp_print("src mailbox id> ");
1725 if (0 >= scanf("%d", &src_mailbox_id))
1726 testapp_print("Invalid input. ");
1728 testapp_print("dest mailbox id> ");
1729 if (0 >= scanf("%d", &dest_mailbox_id))
1730 testapp_print("Invalid input. ");
1732 err = email_move_all_mails_to_mailbox(src_mailbox_id, dest_mailbox_id);
1734 testapp_print("email_move_all_mails_to_mailbox failed: err[%d]\n", err);
1736 testapp_print("email_move_all_mails_to_mailbox suceeded\n");
1741 static gboolean testapp_test_get_totaldiskusage()
1743 unsigned long total_size = 0;
1744 int err_code = EMAIL_ERROR_NONE ;
1746 err_code = email_get_disk_space_usage(&total_size);
1748 testapp_print("email_get_disk_space_usage failed err : %d\n", err_code);
1750 testapp_print("email_get_disk_space_usage SUCCESS, total disk usage in KB : %ld \n", total_size);
1757 static gboolean testapp_test_db_test()
1759 int err = EMAIL_ERROR_NONE;
1766 to = (char *)malloc(500000);
1767 cc = (char *)malloc(500000);
1768 bcc = (char *)malloc(500000);
1770 memset(to, 0x00, sizeof(500000));
1771 memset(cc, 0x00, sizeof(500000));
1772 memset(bcc, 0x00, sizeof(500000));
1774 testapp_print("Input Mail id:\n");
1775 if (0 >= scanf("%d", &mail_id))
1776 testapp_print("Invalid input. ");
1777 testapp_print("Input Account id:\n");
1778 if (0 >= scanf("%d", &account_id))
1779 testapp_print("Invalid input. ");
1780 testapp_print("Input TO field:\n");
1781 if (0 >= scanf("%s", to))
1782 testapp_print("Invalid input. ");
1783 testapp_print("Input CC field:\n");
1784 if (0 >= scanf("%s", cc))
1785 testapp_print("Invalid input. ");
1786 testapp_print("Input BCC field:\n");
1787 if (0 >= scanf("%s", bcc))
1788 testapp_print("Invalid input. ");
1790 if (emstorage_test(NULL, mail_id, account_id, to, cc, bcc, &err) == true)
1791 testapp_print(">> Saving Succeeded\n");
1793 testapp_print(">> Saving Failed[%d]\n", err);
1802 static gboolean testapp_test_address_format_check_test()
1809 int err = EMAIL_ERROR_NONE;
1810 char *pAddress = NULL;
1811 char input_address[8096];
1812 char *address_list[] = {
1815 "tom@gmail.com@gmail.com",
1817 "\"Tom\"<tom@gmail.com>",
1818 "\"Tom\"[tom@gmail.com]",
1819 "\"Tom\"<tom,@gmail.com>",
1823 "<tom@gmail.com>,tom@gmail.com",
1824 "<tom@gmail.com>;tom@gmail.com",
1833 "\"\"Tom\"<tom,@gmail.com>",
1834 "tom@gmail.com,tom@gmail.com",
1836 "<tom@gmail.com>,tom@.gmail.com",
1837 "&& tom@live.com ----",
1838 "madhu <tom@gmail.com>",
1839 "tom@gmail.com, && tom@live.com",
1840 "tom@gmail.com , && tom@live.com",
1841 "< tom@gmail.com > , < tom@.gmail.com >",
1842 "tom@gmail.com , tom@gmail.com",
1844 "<to m@gmail.com >",
1845 "<tom@gmail.com>;tom@gmail.com",
1846 "Tom< tom@gmail.com > , Tom <tom@gmail.com>",
1847 " \"Tom\" < tom@gmail.com> , \"Tom\" < tom@gmail.com> , Tom < tom@gmail.com> ; Tom < tom@gmail.com>,\"tomtom\" < tom@aol.com>,\"tomtom\" < tom@aol.com> ,\"tomtom\" <tom@aol.com>;<tom@live.com>, <tom@live.com>; \"tomtomtomtom\" <tom@live.com> ; \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com>",
1848 "<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>,<tom@gmail.com>",
1849 " tom@gmail.com ; < tom@gmail.com > ",
1850 "\"Tom\" < tom@gmail.com > ; mama < tom@gmail.com > , abcd@gmail.com , abc@gmail.com ,\"tomtom\" <tom@aol.com>,\"tomtom\" < tom@aol.com> ;\"tomtom\" < tom@aol.com > ,\"tomtom\" <tom@aol.com> , \"tomtomtomtom\" <tom@live.com> ",
1851 " \"tomtom\" <tom@aol.com> ;\"tomtom\" <tom@aol.com> ; ",
1852 " tom@gmail.com , tom@gmail.com , tom@gmail.com; Tom < tom@gmail.com > ,< tom@aol.com>, <tom@aol.com> ,<tom@aol.com>;<tom@live.com>, tom@live.com;tom@live.com; \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com> ; ",
1853 "<tom@aol.com> , \"tomtomtomtom\" <tom@live.com>,\"Tom\" < tom@gmail.com> ; ",
1854 " Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom < tom@gmail.com> ,<tom@gmail.com>,Tom <tom@gmail.com >,Tom< tom@gmail.com > , Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>,Tom <tom@gmail.com>",
1857 int address_count = 0;
1859 testapp_print("Select input method:\n");
1860 testapp_print("1. Test data\n");
1861 testapp_print("2. Keyboard\n");
1862 if (0 >= scanf("%d", &type);
1867 for (i = 0; address_list[i] != NULL; i++) {
1868 testapp_print("[%d] addr[%s]\n", i, address_list[i]);
1871 testapp_print("Choose address to be tested:[99:quit]\n");
1872 if (0 >= scanf("%d", &index);
1876 testapp_print(">> [%d] Checking?(1:Yes, Other:No) [%s]\n", index, address_list[index]);
1877 if (0 >= scanf("%d", &check_yn);
1878 if (check_yn == 1) {
1879 pAddress = strdup(address_list[index]);
1880 if (em_verify_email_address(pAddress, false, &err ) == true) {
1881 testapp_print("<< [%d] Checking Succeeded : addr[%s]\n", index, address_list[index]);
1884 testapp_print("<< [%d] Checking Failed : addr[%s], err[%d]\n", index, address_list[index], err);
1892 testapp_print("<< [%d] Skipped : addr[%s]\n", index, address_list[index]);
1898 testapp_print("Input address: \n");
1899 if (0 >= scanf("%s", input_address);
1900 if (em_verify_email_address(input_address, false, &err ) == true) {
1901 testapp_print(">> Saving Succeeded : addr[%s]\n", input_address);
1904 testapp_print(">> Saving Failed : addr[%s], err[%d]\n", input_address, err);
1908 testapp_print("wrong nuber... [%d]\n", type);
1915 static gboolean testapp_test_get_max_mail_count()
1918 int err = EMAIL_ERROR_NONE;
1920 err = email_get_max_mail_count(&max_count);
1921 testapp_print("\n\t>>>>> email_get_max_mail_count() return [%d][%d]\n\n", max_count, err);
1926 #include "email-storage.h"
1927 static gboolean testapp_test_test_get_thread_information()
1929 int error_code, thread_id = 38;
1930 email_mail_list_item_t *result_mail;
1932 if ((error_code = email_get_thread_information_ex(thread_id, &result_mail)) == EMAIL_ERROR_NONE) {
1933 testapp_print("email_get_thread_information returns = %d\n", error_code);
1934 testapp_print("subject = %s\n", result_mail->subject);
1935 testapp_print("mail_id = %d\n", result_mail->mail_id);
1936 testapp_print("full_address_from = %s\n", result_mail->full_address_from);
1937 testapp_print("thrad_id = %d\n", result_mail->thread_id);
1938 testapp_print("count = %d\n", result_mail->thread_item_count);
1944 static gboolean testapp_test_get_address_info_list()
1946 testapp_print(" >>> testapp_test_get_address_info_list : Entered \n");
1951 email_address_info_list_t *address_info_list = NULL;
1952 email_address_info_t *p_address_info = NULL;
1956 memset(buf, 0x00, sizeof(buf));
1957 testapp_print("\n > Enter mail_id: ");
1958 if (0 >= scanf("%d", &mail_id))
1959 testapp_print("Invalid input. ");
1961 email_get_address_info_list(mail_id, &address_info_list);
1963 testapp_print("===================================================\n");
1964 testapp_print("\t\t\t address info list\n");
1965 testapp_print("===================================================\n");
1966 testapp_print("address_type\t address \t\tdisplay_name\t contact id\n");
1967 testapp_print("===================================================\n");
1969 for (i = EMAIL_ADDRESS_TYPE_FROM; i <= EMAIL_ADDRESS_TYPE_BCC; i++) {
1971 case EMAIL_ADDRESS_TYPE_FROM:
1972 list = address_info_list->from;
1974 case EMAIL_ADDRESS_TYPE_TO:
1975 list = address_info_list->to;
1977 case EMAIL_ADDRESS_TYPE_CC:
1978 list = address_info_list->cc;
1980 case EMAIL_ADDRESS_TYPE_BCC:
1981 list = address_info_list->bcc;
1985 /* delete dynamic-allocated memory for each item */
1986 node = g_list_first(list);
1987 while (node != NULL) {
1988 p_address_info = (email_address_info_t *)node->data;
1989 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);
1991 node = g_list_next(node);
1993 testapp_print("\n");
1995 testapp_print("===================================================\n");
1997 if (address_info_list)
1998 email_free_address_info_list(&address_info_list);
2000 testapp_print(" >>> testapp_test_get_address_info_list : END \n");
2004 static gboolean testapp_test_search_mail_on_server()
2006 testapp_print(" >>> testapp_test_search_mail_on_server : Entered \n");
2008 int err_code = EMAIL_ERROR_NONE;
2011 int search_key_value_integer = 0;
2012 int search_filter_count = 0;
2013 email_search_filter_type search_filter_type = 0;
2014 email_search_filter_t search_filter[10];
2016 time_t current_time = 0;
2017 char search_key_value_string[256];
2019 testapp_print("input account id : ");
2020 if (0 >= scanf("%d", &account_id))
2021 testapp_print("Invalid input. ");
2023 testapp_print("input mailbox id : ");
2024 if (0 >= scanf("%d", &mailbox_id))
2025 testapp_print("Invalid input. ");
2027 memset(&search_filter, 0x00, sizeof(email_search_filter_t) * 10);
2031 " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, (integer type ) \n"
2032 " EMAIL_SEARCH_FILTER_TYPE_UID = 2, (integer type ) \n"
2033 " EMAIL_SEARCH_FILTER_TYPE_ALL = 3, (integer type ) \n"
2034 " EMAIL_SEARCH_FILTER_TYPE_BCC = 7, (string type ) \n"
2035 " EMAIL_SEARCH_FILTER_TYPE_BODY = 8, (string type ) \n"
2036 " EMAIL_SEARCH_FILTER_TYPE_CC = 9, (string type ) \n"
2037 " EMAIL_SEARCH_FILTER_TYPE_FROM = 10, (string type ) \n"
2038 " EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, (string type ) \n"
2039 " EMAIL_SEARCH_FILTER_TYPE_TEXT = 12, (string type ) \n"
2040 " EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, (string type ) \n"
2041 " EMAIL_SEARCH_FILTER_TYPE_TO = 15, (string type ) \n"
2042 " EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, (integet type ) \n"
2043 " EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER = 17, (integet type ) \n"
2044 " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE = 20, (time type ) \n"
2045 " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, (time type ) \n"
2046 " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, (time type ) \n"
2047 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, (integer type ) \n"
2048 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW = 27, (integer type ) \n"
2049 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, (integer type ) \n"
2050 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD = 29, (integer type ) \n"
2051 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, (integer type ) \n"
2052 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, (integer type ) \n"
2053 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, (integer type ) \n"
2054 " EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, (integer type ) \n"
2055 " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, (string type ) \n"
2056 " EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, (integer type ) \n"
2057 " EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, (string type ) \n"
2058 " EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, (string type ) \n"
2059 " EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, (string type ) \n"
2062 testapp_print("input search filter type : ");
2063 if (0 >= scanf("%d", (int *)&search_filter_type))
2064 testapp_print("Invalid input. ");
2066 search_filter[search_filter_count].search_filter_type = search_filter_type;
2068 switch (search_filter_type) {
2069 case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:
2070 case EMAIL_SEARCH_FILTER_TYPE_UID:
2071 case EMAIL_SEARCH_FILTER_TYPE_ALL:
2072 case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:
2073 case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:
2074 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:
2075 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
2076 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:
2077 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
2078 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:
2079 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:
2080 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:
2081 case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:
2082 case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:
2083 testapp_print("input search filter key value : ");
2084 if (0 >= scanf("%d", &search_key_value_integer))
2085 testapp_print("Invalid input. ");
2086 search_filter[search_filter_count].search_filter_key_value.integer_type_key_value = search_key_value_integer;
2089 case EMAIL_SEARCH_FILTER_TYPE_BCC:
2090 case EMAIL_SEARCH_FILTER_TYPE_BODY:
2091 case EMAIL_SEARCH_FILTER_TYPE_CC:
2092 case EMAIL_SEARCH_FILTER_TYPE_FROM:
2093 case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
2094 case EMAIL_SEARCH_FILTER_TYPE_TEXT:
2095 case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
2096 case EMAIL_SEARCH_FILTER_TYPE_TO:
2097 case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
2098 case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
2099 case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
2100 case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
2101 testapp_print("input search filter key value : ");
2102 int readn = read(0, search_key_value_string, 256);
2104 testapp_print("Invalid input. ");
2106 search_filter[search_filter_count].search_filter_key_value.string_type_key_value = strndup(search_key_value_string, readn - 1);
2109 case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:
2110 case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:
2111 case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:
2112 time(¤t_time);
2113 /* TODO : write codes for converting string to time */
2114 /* search_filter.search_filter_key_value.time_type_key_value = search_key_value_string; */
2115 search_filter[search_filter_count].search_filter_key_value.time_type_key_value = current_time;
2118 testapp_print("END filter type [%d]", search_filter_type);
2122 if (!search_filter_type)
2125 search_filter_count++;
2128 err_code = email_search_mail_on_server(account_id, mailbox_id, search_filter, search_filter_count, &handle);
2129 if (err_code != EMAIL_ERROR_NONE)
2130 testapp_print("email_search_mail_on_server failed [%d]", err_code);
2132 testapp_print(" >>> testapp_test_search_mail_on_server : END \n");
2136 static gboolean testapp_test_add_mail_to_search_result_box()
2141 int attachment_count = 0;
2142 int err = EMAIL_ERROR_NONE;
2143 char arg[50] = { 0 , };
2144 char *body_file_path = MAIL_TEMP_BODY;
2145 email_mailbox_t *mailbox_data = NULL;
2146 email_mail_data_t *test_mail_data = NULL;
2147 email_attachment_data_t *attachment_data = NULL;
2148 email_meeting_request_t *meeting_req = NULL;
2149 FILE *body_file = NULL;
2151 testapp_print("\n > Enter account id : ");
2152 if (0 >= scanf("%d", &account_id))
2153 testapp_print("Invalid input. ");
2155 email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SEARCH_RESULT, &mailbox_data);
2157 test_mail_data = malloc(sizeof(email_mail_data_t));
2158 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
2160 testapp_print("\n From EAS? [0/1]> ");
2161 if (0 >= scanf("%d", &from_eas))
2162 testapp_print("Invalid input. ");
2164 test_mail_data->account_id = account_id;
2165 test_mail_data->save_status = 1;
2166 test_mail_data->body_download_status = 1;
2167 test_mail_data->flags_seen_field = 1;
2168 test_mail_data->file_path_plain = strdup(body_file_path);
2169 test_mail_data->mailbox_id = mailbox_data->mailbox_id;
2170 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
2171 test_mail_data->full_address_from = strdup("<test1@test.com>");
2172 test_mail_data->full_address_to = strdup("<test2@test.com>");
2173 test_mail_data->full_address_cc = strdup("<test3@test.com>");
2174 test_mail_data->full_address_bcc = strdup("<test4@test.com>");
2175 test_mail_data->subject = strdup("Into search result mailbox");
2176 test_mail_data->remaining_resend_times = 3;
2178 body_file = fopen(body_file_path, "w");
2180 for (i = 0; i < 500; i++)
2181 fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2");
2185 testapp_print(" > Attach file? [0/1] : ");
2186 if (0 >= scanf("%d", &attachment_count))
2187 testapp_print("Invalid input. ");
2189 if (attachment_count) {
2190 memset(arg, 0x00, 50);
2191 testapp_print("\n > Enter attachment name : ");
2192 if (0 >= scanf("%s", arg))
2193 testapp_print("Invalid input. ");
2195 attachment_data = malloc(sizeof(email_attachment_data_t));
2196 if (attachment_data == NULL) {
2197 testapp_print("malloc failed");
2200 attachment_data->attachment_name = strdup(arg);
2202 memset(arg, 0x00, 50);
2203 testapp_print("\n > Enter attachment absolute path : ");
2204 if (0 >= scanf("%s", arg))
2205 testapp_print("Invalid input. ");
2207 attachment_data->attachment_path = strdup(arg);
2208 attachment_data->save_status = 1;
2209 test_mail_data->attachment_count = attachment_count;
2212 testapp_print("\n > Meeting Request? [0: no, 1: yes(request from server), 2: yes(response from local)]");
2213 if (0 >= scanf("%d", (int *)&(test_mail_data->meeting_request_status)))
2214 testapp_print("Invalid input. ");
2216 if (test_mail_data->meeting_request_status == 1
2217 || test_mail_data->meeting_request_status == 2) {
2218 time_t current_time;
2219 /* dummy data for meeting request */
2220 meeting_req = malloc(sizeof(email_meeting_request_t));
2221 memset(meeting_req, 0x00, sizeof(email_meeting_request_t));
2223 meeting_req->meeting_response = 1;
2224 current_time = time(NULL);
2225 gmtime_r(¤t_time, &(meeting_req->start_time));
2226 gmtime_r(¤t_time, &(meeting_req->end_time));
2227 meeting_req->location = malloc(strlen("Seoul") + 1);
2228 memset(meeting_req->location, 0x00, strlen("Seoul") + 1);
2229 strcpy(meeting_req->location, "Seoul");
2230 strcpy(meeting_req->global_object_id, "abcdef12345");
2232 meeting_req->time_zone.offset_from_GMT = 9;
2233 strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME");
2234 gmtime_r(¤t_time, &(meeting_req->time_zone.standard_time_start_date));
2235 meeting_req->time_zone.standard_bias = 3;
2237 strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME");
2238 gmtime_r(¤t_time, &(meeting_req->time_zone.daylight_time_start_date));
2239 meeting_req->time_zone.daylight_bias = 7;
2243 if ((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMAIL_ERROR_NONE)
2244 testapp_print("email_add_mail failed. [%d]\n", err);
2246 testapp_print("email_add_mail success.\n");
2248 testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id);
2250 if (attachment_data)
2251 email_free_attachment_data(&attachment_data, attachment_count);
2254 email_free_meeting_request(&meeting_req, 1);
2256 email_free_mail_data(&test_mail_data, 1);
2257 email_free_mailbox(&mailbox_data, 1);
2262 static gboolean testapp_test_email_parse_mime_file()
2265 int attachment_count = 0;
2266 int output_attachment_count = 0;
2268 int err = EMAIL_ERROR_NONE;
2269 char eml_file_path[255] = {0, };
2270 struct tm *struct_time;
2272 email_mail_data_t *mail_data = NULL;
2273 email_attachment_data_t *mail_attachment_data = NULL;
2274 email_mail_data_t *output_mail_data = NULL;
2275 email_attachment_data_t *output_mail_attachment_data = NULL;
2277 testapp_print("Input eml file path : ");
2278 if (0 >= scanf("%s", eml_file_path))
2279 testapp_print("Invalid input. ");
2281 if ((err = email_parse_mime_file(eml_file_path, &mail_data, &mail_attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) {
2282 testapp_print("email_parse_mime_file failed : [%d]\n", err);
2286 testapp_print("load success\n");
2288 struct_time = localtime(&(mail_data->date_time));
2290 testapp_print("%4d year", struct_time->tm_year +1900);
2291 testapp_print("%2d month(0-11)\n", struct_time->tm_mon + 1);
2292 testapp_print("%2d day(1-31)\n", struct_time->tm_mday);
2293 testapp_print("%2d wday\n", struct_time->tm_wday);
2294 testapp_print("%2d hour(0-23)\n", struct_time->tm_hour);
2295 testapp_print("%2d minutes(0-59)\n", struct_time->tm_min);
2296 testapp_print("%2d second(0-59)\n", struct_time->tm_sec);
2297 testapp_print("year day %3d\n", struct_time->tm_yday);
2299 testapp_print("Return-Path: %s\n", mail_data->full_address_return);
2300 testapp_print("To: %s\n", mail_data->full_address_to);
2301 testapp_print("Subject: %s\n", mail_data->subject);
2302 testapp_print("Priority: %d\n", mail_data->priority);
2303 testapp_print("From: %s\n", mail_data->full_address_from);
2304 testapp_print("Reply-To: %s\n", mail_data->full_address_reply);
2305 testapp_print("Sender: %s\n", mail_data->email_address_sender);
2306 testapp_print("Message-ID: %s\n", mail_data->message_id);
2307 testapp_print("attachment_count: %d\n", mail_data->attachment_count);
2308 testapp_print("SMIME type : %d\n", mail_data->smime_type);
2309 testapp_print("inline content count : %d\n", mail_data->inline_content_count);
2310 testapp_print("mail_size : %d\n", mail_data->mail_size);
2311 testapp_print("download_body_status : %d\n", mail_data->body_download_status);
2314 for (i = 0; i < attachment_count ; i++) {
2315 testapp_print("%d attachment\n", i);
2316 testapp_print("attachment_id: %d\n", mail_attachment_data[i].attachment_id);
2317 testapp_print("attachment_size: %d\n", mail_attachment_data[i].attachment_size);
2318 testapp_print("inline_attachment_status: %d\n", mail_attachment_data[i].inline_content_status);
2319 testapp_print("attachment_name: %s\n", mail_attachment_data[i].attachment_name);
2320 testapp_print("attachment_path: %s\n", mail_attachment_data[i].attachment_path);
2321 testapp_print("attachment_save_status: %d\n", mail_attachment_data[i].save_status);
2322 testapp_print("content_id: %s\n", mail_attachment_data[i].content_id);
2323 testapp_print("mailbox_id: %d\n", mail_attachment_data[i].mailbox_id);
2326 testapp_print("Success : Open eml file\n");
2328 if (mail_data->smime_type != EMAIL_SMIME_NONE) {
2329 if (mail_data->smime_type == EMAIL_SMIME_SIGNED || mail_data->smime_type == EMAIL_PGP_SIGNED) {
2330 if (!email_verify_signature_ex(mail_data, mail_attachment_data, attachment_count, &verify))
2331 testapp_print("email_verify_signature_ex failed\n");
2333 if ((err = email_get_decrypt_message_ex(mail_data,
2334 mail_attachment_data,
2337 &output_mail_attachment_data,
2338 &output_attachment_count,
2339 &verify)) != EMAIL_ERROR_NONE)
2340 testapp_print("email_get_decrypt_message_ex failed\n");
2343 testapp_print("verify : [%d]\n", verify);
2346 if ((err = email_delete_parsed_data(mail_data)) != EMAIL_ERROR_NONE) {
2347 testapp_print("email_delete_eml_data failed : [%d]\n", err);
2351 testapp_print("Success : email_delete_eml_data\n");
2354 email_free_mail_data(&mail_data, 1);
2356 testapp_print("Success : email_free_mail_data\n");
2358 if (mail_attachment_data)
2359 email_free_attachment_data(&mail_attachment_data, attachment_count);
2361 testapp_print("Success : email_free_attachment_data\n");
2367 static gboolean testapp_test_email_write_mime_file()
2369 int err = EMAIL_ERROR_NONE;
2371 int attachment_count = 0;
2372 char *file_path = NULL;
2373 email_mail_data_t *mail_data = NULL;
2374 email_attachment_data_t *mail_attachment_data = NULL;
2377 file_path = malloc(512);
2378 memset(file_path, 0x00, 512);
2380 testapp_print("Input mail id : ");
2381 if (0 >= scanf("%d", &mail_id))
2382 testapp_print("Invalid input. ");
2384 err = email_get_mail_data(mail_id, &mail_data);
2385 if (err != EMAIL_ERROR_NONE || mail_data == NULL) {
2386 testapp_print("email_get_mail_data failed : [%d]\n", err);
2391 err = email_get_attachment_data_list(mail_id, &mail_attachment_data, &attachment_count);
2392 if (err != EMAIL_ERROR_NONE) {
2393 testapp_print("email_get_attachment_data_list failed : [%d]\n", err);
2397 snprintf(file_path, 512, tzplatform_mkpath(TZ_SYS_DATA, "email/.email_data/tmp/%d_%8d.eml"), mail_id, (int)time(NULL));
2399 err = email_write_mime_file(mail_data, mail_attachment_data, attachment_count, &file_path);
2400 if (err != EMAIL_ERROR_NONE) {
2401 testapp_print("email_write_mime_file failed : [%d]\n", err);
2405 testapp_print("file path : [%s]\n", file_path);
2408 email_free_mail_data(&mail_data, 1);
2410 if (mail_attachment_data)
2411 email_free_attachment_data(&mail_attachment_data, attachment_count);
2419 static gboolean testapp_test_smime_verify_signature()
2423 int err = EMAIL_ERROR_NONE;
2425 testapp_print("input mail_id :");
2426 if (0 >= scanf("%d", &mail_id))
2427 testapp_print("Invalid input. ");
2429 err = email_verify_signature(mail_id, &verify);
2430 if (err != EMAIL_ERROR_NONE) {
2431 testapp_print("Failed Verify\n");
2435 testapp_print("verify value : [%d]\n", verify);
2439 static gboolean testapp_test_email_add_mail_with_multiple_recipient()
2443 int err = EMAIL_ERROR_NONE;
2444 // int smime_type = 0;
2445 int recipient_addresses_count = 0;
2446 char *recipient_addresses = NULL;
2447 char recipient_address[234] = { 0, };
2448 char from_address[300] = { 0 , };
2449 const char *body_file_path = MAIL_TEMP_BODY;
2450 email_account_t *account_data = NULL;
2451 email_mailbox_t *mailbox_data = NULL;
2452 email_mail_data_t *test_mail_data = NULL;
2455 testapp_print("\n > Enter account id : ");
2456 if (0 >= scanf("%d", &account_id))
2457 testapp_print("Invalid input. ");
2459 testapp_print("\n > Enter recipient address count : ");
2460 if (0 >= scanf("%d", &recipient_addresses_count))
2461 testapp_print("Invalid input. ");
2463 if (recipient_addresses_count < 1)
2466 recipient_addresses = malloc(sizeof(char) * 234 * recipient_addresses_count);
2468 for (i = 0; i < recipient_addresses_count; i++) {
2469 snprintf(recipient_address, 234, "\"mailtest%05d\" <mailtest%05d@a1234567890b1234567890.com>; ", i, i);
2470 strcat(recipient_addresses, recipient_address);
2473 email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data);
2475 email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data);
2477 test_mail_data = malloc(sizeof(email_mail_data_t));
2478 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
2480 SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address);
2482 test_mail_data->account_id = account_id;
2483 test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED;
2484 test_mail_data->body_download_status = 1;
2485 test_mail_data->flags_seen_field = 1;
2486 test_mail_data->file_path_plain = strdup(body_file_path);
2487 test_mail_data->mailbox_id = mailbox_data->mailbox_id;
2488 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
2489 test_mail_data->full_address_from = strdup(from_address);
2490 test_mail_data->full_address_to = recipient_addresses;
2491 test_mail_data->subject = strdup("Read receipt request from TIZEN");
2492 test_mail_data->remaining_resend_times = 3;
2493 test_mail_data->report_status = EMAIL_MAIL_REQUEST_DSN | EMAIL_MAIL_REQUEST_MDN;
2494 test_mail_data->smime_type = 0;
2496 body_file = fopen(body_file_path, "w");
2498 testapp_print("\n body_file [%p]\n", body_file);
2500 if (body_file == NULL) {
2501 testapp_print("\n fopen [%s]failed\n", body_file_path);
2505 for (i = 0; i < 100; i++)
2506 fprintf(body_file, "Mail sending Test. [%d]\n", i);
2512 if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE)
2513 testapp_print("email_add_mail failed. [%d]\n", err);
2515 testapp_print("email_add_mail success.\n");
2517 testapp_print("saved mail id = [%d]\n", test_mail_data->mail_id);
2519 email_free_mail_data(&test_mail_data, 1);
2520 email_free_mailbox(&mailbox_data, 1);
2521 email_free_account(&account_data, 1);
2526 static gboolean testapp_test_send_mails_every_x_minutes()
2528 int added_mail_id = 0;
2529 int err = EMAIL_ERROR_NONE;
2531 time_t time_to_send;
2535 int send_interval_in_minutes = 0;
2536 int number_of_mails = 0;
2537 char recipient_address[300] = { 0 , };
2538 char from_address[300] = { 0 , };
2539 char subject_form[1024] = { 0 , };
2540 const char *body_file_path = MAIL_TEMP_BODY;
2541 struct tm *time_to_send_tm;
2542 email_account_t *account_data = NULL;
2543 email_mailbox_t *mailbox_data = NULL;
2544 email_mail_data_t *test_mail_data = NULL;
2547 testapp_print("\n > Enter account id : ");
2548 if (0 >= scanf("%d", &account_id))
2549 testapp_print("Invalid input. ");
2551 testapp_print("\n > Enter recipient address : ");
2552 if (0 >= scanf("%s", recipient_address))
2553 testapp_print("Invalid input. ");
2555 testapp_print("\n > Enter number of mails: ");
2556 if (0 >= scanf("%d", &number_of_mails))
2557 testapp_print("Invalid input. ");
2559 testapp_print("\n > Enter send interval in minutes: ");
2560 if (0 >= scanf("%d", &send_interval_in_minutes))
2561 testapp_print("Invalid input. ");
2563 email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_data);
2565 email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_data);
2567 test_mail_data = malloc(sizeof(email_mail_data_t));
2568 memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
2570 SNPRINTF(from_address, 300, "<%s>", account_data->user_email_address);
2572 test_mail_data->account_id = account_id;
2573 test_mail_data->save_status = EMAIL_MAIL_STATUS_SEND_DELAYED;
2574 test_mail_data->body_download_status = 1;
2575 test_mail_data->flags_seen_field = 1;
2576 test_mail_data->file_path_plain = strdup(body_file_path);
2577 test_mail_data->mailbox_id = mailbox_data->mailbox_id;
2578 test_mail_data->mailbox_type = mailbox_data->mailbox_type;
2579 test_mail_data->full_address_from = strdup(from_address);
2580 test_mail_data->full_address_to = strdup(recipient_address);
2581 test_mail_data->remaining_resend_times = 3;
2582 test_mail_data->report_status = EMAIL_MAIL_REPORT_NONE;
2585 for (i = 0; i < number_of_mails; i++) {
2586 if (test_mail_data->subject)
2587 free(test_mail_data->subject);
2589 time(&time_to_send);
2590 time_to_send += (60 * send_interval_in_minutes) * (i + 1);
2591 time_to_send_tm = localtime(&time_to_send);
2593 strftime(subject_form, 1024, "[%H:%M] TEST.", time_to_send_tm);
2594 test_mail_data->subject = strdup(subject_form);
2596 body_file = fopen(body_file_path, "w");
2598 testapp_print("\n body_file [%p]\n", body_file);
2600 if (body_file == NULL) {
2601 testapp_print("\n fopen [%s]failed\n", body_file_path);
2605 for (j = 0; j < 100; j++)
2606 fprintf(body_file, "Mail sending Test. [%d]\n", j);
2611 if ((err = email_add_mail(test_mail_data, NULL, 0, NULL, 0)) != EMAIL_ERROR_NONE) {
2612 testapp_print("email_add_mail failed. [%d]\n", err);
2615 testapp_print("email_add_mail success.\n");
2616 added_mail_id = test_mail_data->mail_id;
2619 testapp_print("saved mail id = [%d]\n", added_mail_id);
2621 if (added_mail_id) {
2622 testapp_print("Calling email_schedule_sending_mail...\n");
2624 if (email_schedule_sending_mail(added_mail_id, time_to_send) < 0)
2625 testapp_print("email_schedule_sending_mail failed[%d]\n", err);
2627 testapp_print("Start sending. handle[%d]\n", handle);
2631 email_free_mail_data(&test_mail_data, 1);
2632 email_free_mailbox(&mailbox_data, 1);
2633 email_free_account(&account_data, 1);
2638 /* internal functions */
2639 static gboolean testapp_test_interpret_command(int menu_number)
2641 gboolean go_to_loop = TRUE;
2643 switch (menu_number) {
2645 testapp_test_get_mails();
2648 testapp_test_mail_send(NULL);
2651 testapp_test_get_mail_list_ex();
2654 testapp_test_add_attachment();
2657 testapp_test_set_deleted_flag();
2660 testapp_test_expunge_mails_deleted_flagged();
2663 testapp_test_send_read_receipt();
2666 testapp_test_delete_attachment();
2669 testapp_test_count();
2672 testapp_test_move_mails_to_mailbox_of_another_account();
2675 testapp_test_send_mail_with_downloading_attachment_of_original_mail();
2678 testapp_test_get_mail_data();
2681 testapp_test_schedule_sending_mail();
2684 testapp_test_delete();
2687 testapp_test_update_mail_attribute();
2690 testapp_test_download_body();
2693 testapp_test_download_attachment();
2696 testapp_test_get_attachment_data_list();
2699 testapp_test_get_meeting_request();
2702 testapp_test_delete_all();
2705 testapp_test_move();
2708 testapp_test_retry_send();
2711 testapp_test_get_attachment_data();
2714 testapp_test_move_all_mails_to_mailbox();
2717 testapp_test_get_totaldiskusage();
2720 testapp_test_address_format_check_test();
2723 testapp_test_get_max_mail_count();
2726 testapp_test_db_test();
2729 testapp_test_send_cancel();
2732 testapp_test_cancel_download_body();
2735 testapp_test_get_mail_list_for_thread_view();
2738 testapp_test_test_get_thread_information();
2741 testapp_test_get_mail_list();
2744 testapp_test_get_address_info_list();
2747 testapp_test_set_flags_field();
2750 testapp_test_add_mail(NULL);
2753 testapp_test_update_mail();
2756 testapp_test_search_mail_on_server();
2759 testapp_test_add_mail_to_search_result_box();
2762 testapp_test_email_parse_mime_file();
2765 testapp_test_email_write_mime_file();
2768 testapp_test_smime_verify_signature();
2771 testapp_test_email_add_mail_with_multiple_recipient();
2774 testapp_test_send_mails_every_x_minutes();
2786 void testapp_mail_main()
2788 gboolean go_to_loop = TRUE;
2789 int menu_number = 0;
2791 while (go_to_loop) {
2792 testapp_show_menu(EMAIL_MAIL_MENU);
2793 testapp_show_prompt(EMAIL_MAIL_MENU);
2795 if (0 >= scanf("%d", &menu_number))
2796 testapp_print("Invalid input");
2798 go_to_loop = testapp_test_interpret_command(menu_number);