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.
30 #include "email-api.h"
31 #include "email-api-smime.h"
32 #include "email-api-account.h"
33 #include "email-api-network.h"
34 #include "email-types.h"
37 #include "testapp-utility.h"
38 #include "testapp-account.h"
40 #include <sys/times.h>
41 #include <tzplatform_config.h>
43 /* internal defines */
45 #define GWB_RECV_SERVER_ADDR "pop.gawab.com"
46 #define GWB_SMTP_SERVER_ADDR "smtp.gawab.com"
48 #define VDF_RECV_SERVER_ADDR "imap.email.vodafone.de"
49 #define VDF_SMTP_SERVER_ADDR "smtp.email.vodafone.de"
52 #define S3G_RECV_SERVER_ADDR "165.213.73.235"
53 #define S3G_RECV_SERVER_PORT EMAIL_POP3_PORT
54 #define S3G_RECV_USE_SECURITY 0
55 #define S3G_RECV_IMAP_USE_SECURITY 1
56 #define S3G_SMTP_SERVER_ADDR "165.213.73.235"
57 #define S3G_SMTP_SERVER_PORT 465
58 #define S3G_SMTP_AUTH 1
59 #define S3G_SMTP_USE_SECURITY 1
60 #define S3G_KEEP_ON_SERVER 1
62 gboolean testapp_create_account_object(email_account_t **result_account)
64 email_account_t *account = NULL;
65 char id_string[100] = { 0, }, password_string[1000] = { 0, }, address_string[100] = { 0, };
66 char accesss_token[1000] = { 0, }, refresh_token[1000] = { 0, };
67 int samsung3g_account_index;
70 testapp_print("1. Gawab\n");
71 testapp_print("2. Vodafone\n");
72 testapp_print("4. SAMSUNG 3G TEST(POP)\n");
73 testapp_print("5. SAMSUNG 3G TEST(IMAP)\n");
74 testapp_print("6. Gmail(POP3)\n");
75 testapp_print("7. Gmail(IMAP4)\n");
76 testapp_print("8. Active Sync(dummy)\n");
77 testapp_print("9. AOL\n");
78 testapp_print("10. Hotmail\n");
79 testapp_print("11. Daum(IMAP4)\n");
80 testapp_print("12. Daum(POP3)\n");
81 testapp_print("13. Yahoo(IMAP ID)\n");
82 testapp_print("14. Gmail IMAP with XOAUTH\n");
83 testapp_print("15. Yandex\n");
84 testapp_print("16. mopera\n");
85 testapp_print("Choose server type: ");
88 if (0 >= scanf("%d", &account_type))
89 testapp_print("Invalid input. ");
91 switch (account_type) {
95 testapp_print("Enter your account index [1~10] : ");
96 if (0 >= scanf("%d", &samsung3g_account_index))
97 testapp_print("Invalid input. ");
98 } while (samsung3g_account_index > 10 || samsung3g_account_index < 1);
99 sprintf(id_string, "test%02d", samsung3g_account_index);
100 sprintf(address_string, "test%02d@streaming.s3glab.net", samsung3g_account_index);
101 sprintf(password_string, "test%02d", samsung3g_account_index);
104 testapp_print("Enter email address : ");
105 if (0 >= scanf("%s", address_string))
106 testapp_print("Invalid input. ");
107 strcpy(id_string, address_string);
109 testapp_print("Enter access token : ");
110 if (0 >= scanf("%s", accesss_token))
111 testapp_print("Invalid input. ");
113 testapp_print("Enter refresh token : ");
114 if (0 >= scanf("%s", refresh_token))
115 testapp_print("Invalid input. ");
117 snprintf(password_string, 100, "%s\001%s\001", accesss_token, refresh_token);
120 testapp_print("Enter email address : ");
121 if (0 >= scanf("%s", address_string))
122 testapp_print("Invalid input. ");
124 testapp_print("Enter id : ");
125 if (0 >= scanf("%s", id_string))
126 testapp_print("Invalid input. ");
128 testapp_print("Enter password_string : ");
129 if (0 >= scanf("%s", password_string))
130 testapp_print("Invalid input. ");
134 account = malloc(sizeof(email_account_t));
135 memset(account, 0x00, sizeof(email_account_t));
138 int is_preset_account;
141 user_data_t data = (user_data_t) {1, 0};
142 /* if user_data_t has any pointer member, please don't use sizeof(). */
143 /* You need to serialize user_data to buffer and then take its length */
144 int data_length = sizeof(data);
147 account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL;
148 account->incoming_server_secure_connection = 1;
149 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
150 account->auto_download_size = 2;
151 account->outgoing_server_use_same_authenticator = 1;
152 account->auto_resend_times = 3;
153 account->pop_before_smtp = 0;
154 account->incoming_server_requires_apop = 0;
155 account->incoming_server_authentication_method = 0;
156 account->logo_icon_path = NULL;
157 account->color_label = (128 << 16) | (128 << 8) | (128);
158 account->user_data = malloc(data_length);
159 memcpy(account->user_data, (void *)&data, data_length);
160 account->user_data_length = data_length;
161 account->options.priority = EMAIL_MAIL_PRIORITY_NORMAL;
162 account->options.keep_local_copy = 1;
163 account->options.req_delivery_receipt = 0;
164 account->options.req_read_receipt = 0;
165 account->options.download_limit = 0;
166 account->options.block_address = 0;
167 account->options.block_subject = 0;
168 account->options.display_name_from = strdup("test");
169 account->options.reply_with_body = 0;
170 account->options.forward_with_files = 0;
171 account->options.add_myname_card = 0;
172 account->options.add_signature = 1;
173 account->options.signature = strdup("abcdef");
174 account->options.add_my_address_to_bcc = 0;
175 account->check_interval = 0;
176 account->keep_mails_on_pop_server_after_download = 1;
177 account->default_mail_slot_size = 20;
178 account->roaming_option = EMAIL_ROAMING_OPTION_RESTRICTED_BACKGROUND_TASK;
179 account->peak_interval = 30;
180 account->peak_days = EMAIL_PEAK_DAYS_MONDAY | EMAIL_PEAK_DAYS_TUEDAY | EMAIL_PEAK_DAYS_THUDAY | EMAIL_PEAK_DAYS_FRIDAY;
181 account->peak_start_time = 830;
182 account->peak_end_time = 1920;
184 account->account_name = strdup(address_string);
185 account->user_display_name = strdup(id_string);
186 account->user_email_address = strdup(address_string);
187 account->reply_to_address = strdup(address_string);
188 account->return_address = strdup(address_string);
190 account->incoming_server_user_name = strdup(id_string);
191 account->incoming_server_password = strdup(password_string);
192 account->outgoing_server_user_name = strdup(id_string);
193 account->outgoing_server_password = strdup(password_string);
195 switch (account_type) {
197 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3 ;
198 account->incoming_server_address = strdup(GWB_RECV_SERVER_ADDR);
199 account->incoming_server_port_number = EMAIL_POP3S_PORT;
200 account->outgoing_server_address = strdup(GWB_SMTP_SERVER_ADDR);
201 account->incoming_server_secure_connection = 1;
202 account->outgoing_server_need_authentication = 1;
203 account->outgoing_server_port_number = EMAIL_SMTPS_PORT;
204 account->outgoing_server_secure_connection = 1;
208 case 2:/* vadofone */
209 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
210 account->incoming_server_address = strdup(VDF_RECV_SERVER_ADDR);
211 account->incoming_server_port_number = EMAIL_IMAP_PORT;
212 account->outgoing_server_address = strdup(VDF_SMTP_SERVER_ADDR);
213 account->incoming_server_secure_connection = 0;
214 account->outgoing_server_need_authentication = 0;
217 case 4:/* SAMSUNG 3G TEST */
218 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
219 account->incoming_server_address = strdup(S3G_RECV_SERVER_ADDR);
220 account->incoming_server_port_number = S3G_RECV_SERVER_PORT;
221 account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR);
222 account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT;
223 account->incoming_server_secure_connection = S3G_RECV_USE_SECURITY;
224 account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY;
225 account->outgoing_server_need_authentication = S3G_SMTP_AUTH;
228 case 5:/* SAMSUNG 3G TEST */
229 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
230 account->incoming_server_address = strdup(S3G_RECV_SERVER_ADDR);
231 account->incoming_server_port_number = EMAIL_IMAPS_PORT;
232 account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR);
233 account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT;
234 account->incoming_server_secure_connection = 1;
235 account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY;
236 account->outgoing_server_need_authentication = S3G_SMTP_AUTH;
239 case 6:/* Gmail POP3 */
240 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
241 account->incoming_server_address = strdup("pop.gmail.com");
242 account->incoming_server_port_number = 995;
243 account->incoming_server_secure_connection = 1;
244 account->outgoing_server_address = strdup("smtp.gmail.com");
245 account->outgoing_server_port_number = 465;
246 account->outgoing_server_secure_connection = 1;
247 account->outgoing_server_need_authentication = 1;
250 case 7: /* Gmail IMAP4 */
251 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
252 account->incoming_server_address = strdup("imap.gmail.com");
253 account->incoming_server_port_number = 993;
254 account->incoming_server_secure_connection = 1;
255 account->outgoing_server_address = strdup("smtp.gmail.com");
256 account->outgoing_server_port_number = 465;
257 account->outgoing_server_secure_connection = 1;
258 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
259 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_NO_AUTH;
262 case 8: /* Active Sync */
263 account->incoming_server_type = EMAIL_SERVER_TYPE_ACTIVE_SYNC;
264 account->incoming_server_address = strdup("");
265 account->incoming_server_port_number = 0;
266 account->incoming_server_secure_connection = 1;
267 account->outgoing_server_address = strdup("");
268 account->outgoing_server_port_number = 0;
269 account->outgoing_server_secure_connection = 1;
270 account->outgoing_server_need_authentication = 1;
274 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
275 account->incoming_server_address = strdup("imap.aol.com");
276 account->incoming_server_port_number = 143;
277 account->incoming_server_secure_connection = 0;
278 account->outgoing_server_address = strdup("smtp.aol.com");
279 account->outgoing_server_port_number = 587;
280 account->outgoing_server_secure_connection = 0;
281 account->outgoing_server_need_authentication = 1;
284 case 10: /* Hotmail */
285 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
286 account->incoming_server_address = strdup("pop3.live.com");
287 account->incoming_server_port_number = 995;
288 account->incoming_server_secure_connection = 1;
289 account->outgoing_server_address = strdup("smtp.live.com");
290 account->outgoing_server_port_number = 587;
291 account->outgoing_server_secure_connection = 0x02;
292 account->outgoing_server_need_authentication = 1;
295 case 11:/* Daum IMAP4*/
296 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
297 account->incoming_server_address = strdup("imap.daum.net");
298 account->incoming_server_port_number = 993;
299 account->incoming_server_secure_connection = 1;
300 account->outgoing_server_address = strdup("smtp.daum.net");
301 account->outgoing_server_port_number = 465;
302 account->outgoing_server_secure_connection = 1;
303 account->outgoing_server_need_authentication = 1;
306 case 12:/* Daum POP3*/
307 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
308 account->incoming_server_address = strdup("pop.daum.net");
309 account->incoming_server_port_number = 995;
310 account->incoming_server_secure_connection = 1;
311 account->outgoing_server_address = strdup("smtp.daum.net");
312 account->outgoing_server_port_number = 465;
313 account->outgoing_server_secure_connection = 1;
314 account->outgoing_server_need_authentication = 1;
317 case 13: /* Yahoo IMAP ID */
318 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
319 account->incoming_server_address = strdup("samsung.imap.mail.yahoo.com");
320 account->incoming_server_port_number = 993;
321 account->incoming_server_secure_connection = 1;
322 account->outgoing_server_address = strdup("samsung.smtp.mail.yahoo.com");
323 account->outgoing_server_port_number = 465;
324 account->outgoing_server_secure_connection = 1;
325 account->outgoing_server_need_authentication = 1;
328 case 14: /* XOAUTH */
329 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
330 account->incoming_server_address = strdup("imap.gmail.com");
331 account->incoming_server_port_number = 993;
332 account->incoming_server_secure_connection = 1;
333 account->outgoing_server_address = strdup("smtp.gmail.com");
334 account->outgoing_server_port_number = 465;
335 account->outgoing_server_secure_connection = 1;
336 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_XOAUTH2;
337 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_XOAUTH2;
340 case 15: /* yandex */
341 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
342 account->incoming_server_address = strdup("imap.yandex.ru");
343 account->incoming_server_port_number = 993;
344 account->incoming_server_secure_connection = 1;
345 account->outgoing_server_address = strdup("smtp.yandex.ru");
346 account->outgoing_server_port_number = 465;
347 account->outgoing_server_secure_connection = 1;
348 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
349 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
352 case 16: /* mopera */
353 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
354 account->incoming_server_address = strdup("mail.mopera.net");
355 account->incoming_server_port_number = 110;
356 account->incoming_server_secure_connection = 0;
357 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_NO_AUTH;
358 account->outgoing_server_address = strdup("mail.mopera.net");
359 account->outgoing_server_port_number = 465;
360 account->outgoing_server_secure_connection = 0;
361 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
365 testapp_print("Invalid Account Number\n");
369 account->account_svc_id = 77;
372 *result_account = account;
377 static gboolean testapp_test_add_account_with_validation()
379 int err = EMAIL_ERROR_NONE;
380 email_account_t *account = NULL;
383 if (!testapp_create_account_object(&account)) {
384 testapp_print("testapp_test_create_account_by_account_type error\n");
388 err = email_add_account_with_validation(account, &handle);
390 testapp_print("email_add_account_with_validation error : %d\n", err);
391 err = email_free_account(&account, 1);
395 testapp_print("email_add_account succeed. account_id\n", account->account_id);
397 err = email_free_account(&account, 1);
402 static gboolean testapp_test_update_account()
405 email_account_t *account = NULL;
406 //char account_name[256];
407 int err = EMAIL_ERROR_NONE;
408 //char signature[100] = {0};
409 //char user_email_address[256] = {0,};
410 //int add_my_address_to_bcc = 0;
411 int with_validation = 0; //account_svc_id = 0,
413 testapp_print("\n>> Enter Account ID: ");
414 if (0 >= scanf("%d", &account_id))
415 testapp_print("Invalid input. ");
417 if ((err = email_get_account(account_id, GET_FULL_DATA, &account)) != EMAIL_ERROR_NONE) {
418 testapp_print("email_get_account failed - %d\n", err);
422 testapp_print("email_get_account result account_name - %s \n", account->account_name);
423 testapp_print("email_get_account result address - %s \n", account->user_email_address);
424 testapp_print("email_get_account result signature - %s \n", account->options.signature);
425 testapp_print("email_get_account result check_interval - %d \n", account->check_interval);
427 testapp_print("\n Enter new check interval(in mins):");
428 if (0 >= scanf("%d", &(account->check_interval)))
429 testapp_print("Invalid input. ");
431 testapp_print("\n Enter new peak interval(in mins):");
432 if (0 >= scanf("%d", &(account->peak_interval));
434 testapp_print("\n Enter new peak days:");
435 if (0 >= scanf("%d", &(account->peak_days));
437 testapp_print("\n Enter new peak start time:");
438 if (0 >= scanf("%d", &(account->peak_start_time));
440 testapp_print("\n Enter new peak end time:");
441 if (0 >= scanf("%d", &(account->peak_end_time));
445 testapp_print("\n Enter new Account name:");
446 if (0 >= scanf("%s",account_name);
448 testapp_print("\n Enter new email addr:");
449 if (0 >= scanf("%s",user_email_address);
451 testapp_print("\n Enter new signature:");
452 if (0 >= scanf("%s",signature);
454 testapp_print("\n>> Enter add_my_address_to_bcc:(0:off, 1:on) ");
455 if (0 >= scanf("%d", &add_my_address_to_bcc);
457 testapp_print("\n>> Enter account_svc_id: ");
458 if (0 >= scanf("%d", &account_svc_id);
460 testapp_print("\n>> With validation ?(0: No, 1:Yes) ");
461 if (0 >= scanf("%d", &with_validation);
464 testapp_print("\n Assigning New Account name:(%s)", account->account_name);
465 testapp_print("\n Assigning New Signature:(%s)\n", account->options.signature);
467 account->account_name = strdup(account_name);
468 account->user_email_address = strdup(user_email_address);
469 account->options.signature = strdup(signature);
470 account->options.add_my_address_to_bcc = add_my_address_to_bcc;
471 account->account_svc_id = account_svc_id;
474 if (with_validation) {
475 if ((err = email_update_account_with_validation(account_id, account)) != EMAIL_ERROR_NONE) {
476 testapp_print("email_update_account_with_validation failed - %d\n", err);
479 testapp_print("email_update_account_with_validation successful \n");
481 if ((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
482 testapp_print("email_update_account failed - %d\n", err);
485 testapp_print("email_update_account successful \n");
491 static gboolean testapp_test_delete_account()
494 email_account_t *account = NULL;
495 int err = EMAIL_ERROR_NONE;
497 testapp_print("\n>> Enter Account No: ");
498 if (0 >= scanf("%d", &account_id))
499 testapp_print("Invalid input. ");
501 /* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
502 if ((err = email_get_account(account_id, WITHOUT_OPTION, &account)) < 0) {
503 testapp_print("email_get_account failed \n");
504 testapp_print("testapp_test_delete_account failed\n");
506 testapp_print("email_get_account result account_name - %s \n", account->account_name);
507 if ((err = email_delete_account(account_id)) < 0)
508 testapp_print("email_delete_account failed[%d]\n", err);
510 testapp_print("email_delete_account successful \n");
517 static gboolean testapp_test_validate_account()
519 email_account_t *account = NULL;
520 int err_code = EMAIL_ERROR_NONE;
523 if (!testapp_create_account_object(&account)) {
524 testapp_print("testapp_create_account_object error\n");
528 if ((err_code = email_validate_account_ex(account, &handle)) == EMAIL_ERROR_NONE)
529 testapp_print("email_validate_account_ex successful handle : %u\n", handle);
531 testapp_print("email_validate_account_ex failed err_code : %d \n", err_code);
534 email_free_account(&account, 1);
541 static gboolean testapp_test_cancel_validate_account()
544 int err_code = EMAIL_ERROR_NONE;
545 unsigned account_handle = 0;
547 testapp_print("\n > Enter account_id: ");
548 if (0 >= scanf("%d", &account_id))
549 testapp_print("Invalid input. ");
551 testapp_print("\n > Enter handle: ");
552 if (0 >= scanf("%d", &account_handle))
553 testapp_print("Invalid input. ");
555 err_code = email_cancel_job(account_id, account_handle, EMAIL_CANCELED_BY_USER);
557 testapp_print("email_cancel_job Success..!handle:[%d]", account_handle);
559 testapp_print("email_cancel_job failed err_code: %d \n", err_code);
564 static gboolean testapp_test_get_account()
567 email_account_t *account = NULL;
568 int err_code = EMAIL_ERROR_NONE;
569 testapp_print("\n>> Enter Account No: ");
570 if (0 >= scanf("%d", &account_id))
571 testapp_print("Invalid input. ");
574 int is_preset_account;
578 testapp_print("\n----------------------------------------------------------\n");
579 testapp_print("email_get_account GET_FULL_DATA \n");
580 if ((err_code = email_get_account(account_id, GET_FULL_DATA, &account)) < 0) {
581 testapp_print("email_get_account failed - %d\n", err_code);
585 user_data_t *val = (user_data_t *)account->user_data;
586 int is_preset_account = val ? val->is_preset_account : 0;
587 int index_color = val ? val->index_color : 0;
589 testapp_print("email_get_account result\n"
590 "account_name - %s \n"
591 "user_email_address - %s \n"
592 "incoming_server_secure_connection %d \n"
595 "add_my_address_to_bcc %d \n"
596 "account_svc_id %d\n"
597 "incoming_server_address %s\n"
598 "outgoing_server_address %s\n"
599 "default_mail_slot_size %d\n"
604 "certificate_path %s\n"
606 "auto_resend_times %d\n"
607 "roaming_option %d\n"
610 "peak_start_time %d\n"
613 "notification_status %d\n"
614 "vibrate_status %d\n"
615 "display_content_status %d\n"
616 "default_ringtone_status %d\n"
617 "alert_ringtone_path %s\n"
619 account->account_name,
620 account->user_email_address,
621 account->incoming_server_secure_connection,
622 account->options.add_signature,
623 account->options.signature,
624 account->options.add_my_address_to_bcc,
625 account->account_svc_id,
626 account->incoming_server_address,
627 account->outgoing_server_address,
628 account->default_mail_slot_size,
629 account->sync_status,
630 account->sync_disabled,
633 account->certificate_path,
634 account->digest_type,
635 account->auto_resend_times,
636 account->roaming_option,
637 account->peak_interval,
639 account->peak_start_time,
640 account->peak_end_time,
641 account->color_label,
642 account->options.notification_status,
643 account->options.vibrate_status,
644 account->options.display_content_status,
645 account->options.default_ringtone_status,
646 account->options.alert_ringtone_path
649 err_code = email_free_account(&account, 1);
651 testapp_print("\n----------------------------------------------------------\n");
652 testapp_print("email_get_account WITHOUT_OPTION \n");
654 if ((err_code = email_get_account(account_id, WITHOUT_OPTION, &account)) < 0) {
655 testapp_print("email_get_account failed \n");
659 testapp_print("email_get_account result\n"
660 "account_name - %s \n"
661 "user_email_address - %s \n"
662 "incoming_server_secure_connection %d \n"
663 "add_signature : %d \n",
664 account->account_name,
665 account->user_email_address,
666 account->incoming_server_secure_connection,
667 account->options.add_signature
670 if (account->options.signature)
671 testapp_print("signature : %s\n", account->options.signature);
673 testapp_print("signature not retrieved \n");
675 err_code = email_free_account(&account, 1);
677 testapp_print("\n----------------------------------------------------------\n");
678 testapp_print("email_get_account ONLY_OPTION \n");
680 if ((err_code = email_get_account(account_id, ONLY_OPTION, &account)) < 0) {
681 testapp_print("email_get_account failed \n");
685 testapp_print("email_get_account result\n"
688 "add_my_address_to_bcc %d\n"
689 "account_svc_id %d\n",
690 account->options.add_signature,
691 account->options.signature,
692 account->options.add_my_address_to_bcc,
693 account->account_svc_id
696 if (account->account_name)
697 testapp_print("account_name : %s \n", account->account_name);
699 testapp_print("account_name not retrieved \n");
701 if (account->user_email_address)
702 testapp_print("user_email_address : %s \n", account->user_email_address);
704 testapp_print("user_email_address not retrieved \n");
705 err_code = email_free_account(&account, 1);
710 static gboolean testapp_test_get_account_list()
714 email_account_t *account_list = NULL;
715 struct timeval tv_1, tv_2;
717 int err_code = EMAIL_ERROR_NONE;
719 gettimeofday(&tv_1, NULL);
721 if ((err_code = email_get_account_list(&account_list, &count)) < 0) {
722 testapp_print(" email_get_account_list error\n");
726 gettimeofday(&tv_2, NULL);
727 interval = tv_2.tv_usec - tv_1.tv_usec;
728 testapp_print("\t testapp_test_get_account_list Proceed time %d us\n", interval);
730 for (i = 0; i < count; i++) {
731 testapp_print(" %2d) %-15s %-30s\n", account_list[i].account_id,
732 account_list[i].account_name,
733 account_list[i].user_email_address);
736 err_code = email_free_account(&account_list, count);
740 static gboolean testapp_test_update_check_interval()
743 int err_code = EMAIL_ERROR_NONE;
744 email_account_t *account = NULL;
746 testapp_print("\n Enter account id :");
747 if (0 >= scanf("%d", &account_id))
748 testapp_print("Invalid input. ");
750 if ((err_code = email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account)) != EMAIL_ERROR_NONE) {
751 testapp_print("email_get_account failed [%d]\n", err_code);
755 testapp_print("\n Enter new check interval(in mins):");
756 if (0 >= scanf("%d", &(account->check_interval)))
757 testapp_print("Invalid input. ");
759 if ((err_code = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
760 testapp_print("email_update_account failed [%d]\n", err_code);
764 testapp_print("email_update_account successful \n");
768 email_free_account(&account, 1);
773 static gboolean testapp_test_backup_account()
775 char *file_name = (char *)tzplatform_mkpath(TZ_SYS_DATA, "email/accounts_file");
777 error_code = email_backup_accounts_into_secure_storage(file_name);
778 testapp_print("\n email_backup_accounts_into_secure_storage returned [%d]\n", error_code);
781 static gboolean testapp_test_restore_account()
783 char *file_name = (char *)tzplatform_mkpath(TZ_SYS_DATA,"email/accounts_file");
785 error_code = email_restore_accounts_from_secure_storage(file_name);
786 testapp_print("\n email_restore_accounts_from_secure_storage returned [%d]\n", error_code);
790 static gboolean testapp_test_get_password_length_of_account()
792 int password_length, account_id;
794 testapp_print("\n input account id\n");
795 if (0 >= scanf("%d", &account_id))
796 testapp_print("Invalid input. ");
797 email_get_password_length_of_account(account_id, EMAIL_GET_INCOMING_PASSWORD_LENGTH, &password_length);
798 testapp_print("testapp_test_get_password_length_of_account returned [%d]\n", password_length);
802 static gboolean testapp_test_update_notification()
806 int t_mail_count = 0;
807 int input_from_eas = 0;
808 int unread_mail_count = 0;
810 testapp_print("\n Input account ID:\n");
811 if (0 >= scanf("%d", &account_id))
812 testapp_print("Invalid input. ");
814 testapp_print("\n Input mail count:\n");
815 if (0 >= scanf("%d", &t_mail_count))
816 testapp_print("Invalid input. ");
818 testapp_print("\n Input unread mail count:\n");
819 if (0 >= scanf("%d", &unread_mail_count))
820 testapp_print("Invalid input. ");
822 testapp_print("\n Input From eas:\n");
823 if (0 >= scanf("%d", &input_from_eas))
824 testapp_print("Invalid input. ");
826 error_code = email_update_notification_bar(account_id, t_mail_count, unread_mail_count, input_from_eas);
827 testapp_print("email_update_notification_bar returned [%d]\n", error_code);
831 static gboolean testapp_test_clear_notification()
836 testapp_print("\n Input account ID:\n");
837 if (0 >= scanf("%d", &account_id))
838 testapp_print("Invalid input. ");
840 error_code = email_clear_notification_bar(account_id);
841 testapp_print("email_clear_notification_bar returned [%d]\n", error_code);
845 static gboolean testapp_test_clear_all_notification()
849 error_code = email_clear_notification_bar(ALL_ACCOUNT);
850 testapp_print("email_clear_notification_bar returned [%d]\n", error_code);
854 static gboolean testapp_test_save_default_account_id()
859 testapp_print("\nInput default account id : ");
861 if (0 >= scanf("%d", &account_id))
862 testapp_print("Invalid input. ");
864 error_code = email_save_default_account_id(account_id);
866 testapp_print("email_save_default_account_id returned [%d]\n", error_code);
870 static gboolean testapp_test_load_default_account_id()
875 error_code = email_load_default_account_id(&account_id);
877 testapp_print("\ndefault account id : %d\n", account_id);
878 testapp_print("email_load_default_account_id returned [%d]\n", error_code);
882 static gboolean testapp_test_add_account()
884 int err = EMAIL_ERROR_NONE;
885 email_account_t *account = NULL;
887 if (!testapp_create_account_object(&account)) {
888 testapp_print("testapp_test_create_account_by_account_type error\n");
892 err = email_add_account(account);
894 testapp_print("email_add_account error : %d\n", err);
895 err = email_free_account(&account, 1);
899 testapp_print("email_add_account succeed. account_id\n", account->account_id);
901 err = email_free_account(&account, 1);
906 static gboolean testapp_test_update_peak_schedule()
909 email_account_t *account = NULL;
910 int err = EMAIL_ERROR_NONE;
912 testapp_print("\n>> Enter Account No: ");
913 if (0 >= scanf("%d", &account_id))
914 testapp_print("Invalid input. ");
916 if ((err = email_get_account(account_id, GET_FULL_DATA, &account)) != EMAIL_ERROR_NONE) {
917 testapp_print("email_get_account failed [%d]\n", err);
921 testapp_print("old check_interval - %d \n", account->check_interval);
922 testapp_print("\n Enter new check interval(in mins):");
923 if (0 >= scanf("%d", &(account->check_interval)))
924 testapp_print("Invalid input. ");
926 testapp_print("old peak_interval - %d \n", account->peak_interval);
928 testapp_print("\n Enter new peak interval(in mins):");
929 if (0 >= scanf("%d", &(account->peak_interval)))
930 testapp_print("Invalid input. ");
932 testapp_print("old peak_days - %d \n", account->peak_days);
934 testapp_print("\n Enter new peak days:");
935 if (0 >= scanf("%d", &(account->peak_days)))
936 testapp_print("Invalid input. ");
938 testapp_print("old peak_start_time - %d \n", account->peak_start_time);
940 testapp_print("\n Enter new peak start time:");
941 if (0 >= scanf("%d", &(account->peak_start_time)))
942 testapp_print("Invalid input. ");
944 testapp_print("old peak_end_time - %d \n", account->peak_start_time);
946 testapp_print("\n Enter new peak end time:");
947 if (0 >= scanf("%d", &(account->peak_end_time)))
948 testapp_print("Invalid input. ");
951 if ((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
952 testapp_print("email_update_account failed [%d]\n", err);
955 testapp_print("email_update_account successful \n");
960 static gboolean testapp_test_interpret_command(int selected_number)
962 gboolean go_to_loop = TRUE;
964 switch (selected_number) {
966 testapp_test_add_account_with_validation();
970 testapp_test_update_account();
974 testapp_test_delete_account();
978 testapp_test_get_account();
982 testapp_test_get_account_list();
986 testapp_test_update_check_interval();
990 testapp_test_validate_account();
994 testapp_test_cancel_validate_account();
998 testapp_test_backup_account();
1002 testapp_test_restore_account();
1006 testapp_test_get_password_length_of_account();
1010 testapp_test_update_notification();
1014 testapp_test_clear_notification();
1018 testapp_test_clear_all_notification();
1022 testapp_test_save_default_account_id();
1026 testapp_test_load_default_account_id();
1030 testapp_test_add_account();
1034 testapp_test_update_peak_schedule();
1048 void testapp_account_main()
1050 gboolean go_to_loop = TRUE;
1051 int menu_number = 0;
1053 while (go_to_loop) {
1054 testapp_show_menu(EMAIL_ACCOUNT_MENU);
1055 testapp_show_prompt(EMAIL_ACCOUNT_MENU);
1057 if (0 >= scanf("%d", &menu_number))
1058 testapp_print("Invalid input");
1060 go_to_loop = testapp_test_interpret_command(menu_number);