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-account.h"
32 #include "email-api-network.h"
35 #include "testapp-utility.h"
36 #include "testapp-account.h"
38 #include <sys/times.h>
40 /* internal defines */
42 #define GWB_RECV_SERVER_ADDR "pop.gawab.com"
43 #define GWB_SMTP_SERVER_ADDR "smtp.gawab.com"
45 #define VDF_RECV_SERVER_ADDR "imap.email.vodafone.de"
46 #define VDF_SMTP_SERVER_ADDR "smtp.email.vodafone.de"
49 #define S3G_RECV_SERVER_ADDR "165.213.73.235"
50 #define S3G_RECV_SERVER_PORT EMAIL_POP3_PORT
51 #define S3G_RECV_USE_SECURITY 0
52 #define S3G_RECV_IMAP_USE_SECURITY 1
53 #define S3G_SMTP_SERVER_ADDR "165.213.73.235"
54 #define S3G_SMTP_SERVER_PORT 465
55 #define S3G_SMTP_AUTH 1
56 #define S3G_SMTP_USE_SECURITY 1
57 #define S3G_KEEP_ON_SERVER 1
59 gboolean testapp_test_create_account_by_account_type(int account_type,int *account_id)
61 email_account_t *account = NULL;
62 char id_string[100] = { 0, }, password_string[100] = { 0, }, address_string[100] = { 0, };
63 int err_code = EMAIL_ERROR_NONE, samsung3g_account_index;
64 int result_from_scanf = 0;
67 switch(account_type) {
71 testapp_print("Enter your account index [1~10] : ");
72 result_from_scanf = scanf("%d",&samsung3g_account_index);
73 }while( samsung3g_account_index > 10 || samsung3g_account_index < 1);
74 sprintf(id_string, "test%02d", samsung3g_account_index);
75 sprintf(address_string, "<test%02d@streaming.s3glab.net>", samsung3g_account_index);
76 strcpy(password_string, id_string);
79 testapp_print("Enter email address : ");
80 result_from_scanf = scanf("%s", address_string);
82 testapp_print("Enter id : ");
83 result_from_scanf = scanf("%s", id_string);
85 testapp_print("Enter password_string : ");
86 result_from_scanf = scanf("%s", password_string);
90 account = malloc(sizeof(email_account_t));
91 memset(account, 0x00, sizeof(email_account_t));
94 int is_preset_account;
97 user_data_t data = (user_data_t) {1, 0};
98 /* if user_data_t has any pointer member, please don't use sizeof(). */
99 /* You need to serialize user_data to buffer and then take its length */
100 int data_length = sizeof(data);
103 account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL;
104 account->incoming_server_secure_connection = 1;
105 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
106 account->auto_download_size = 2;
107 account->outgoing_server_use_same_authenticator = 1;
108 account->pop_before_smtp = 0;
109 account->incoming_server_requires_apop = 0;
110 account->logo_icon_path = NULL;
111 account->user_data = malloc (data_length);
112 memcpy( account->user_data, (void*) &data, data_length );
113 account->user_data_length = data_length;
114 account->options.priority = 3;
115 account->options.keep_local_copy = 1;
116 account->options.req_delivery_receipt = 0;
117 account->options.req_read_receipt = 0;
118 account->options.download_limit = 0;
119 account->options.block_address = 0;
120 account->options.block_subject = 0;
121 account->options.display_name_from = NULL;
122 account->options.reply_with_body = 0;
123 account->options.forward_with_files = 0;
124 account->options.add_myname_card = 0;
125 account->options.add_signature = 0;
126 account->options.signature = NULL;
127 account->options.add_my_address_to_bcc = 0;
128 account->check_interval = 0;
129 account->keep_mails_on_pop_server_after_download = 1;
130 account->default_mail_slot_size = 200;
132 account->account_name = strdup(address_string);
133 account->user_display_name = strdup(id_string);
134 account->user_email_address = strdup(address_string);
135 account->reply_to_address = strdup(address_string);
136 account->return_address = strdup(address_string);
138 account->incoming_server_user_name = strdup(id_string);
139 account->incoming_server_password = strdup(password_string);
140 account->outgoing_server_user_name = strdup(id_string);
141 account->outgoing_server_password = strdup(password_string);
143 switch (account_type) {
145 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3 ;
146 account->incoming_server_address = strdup(GWB_RECV_SERVER_ADDR);
147 account->incoming_server_port_number = EMAIL_POP3S_PORT;
148 account->outgoing_server_address = strdup(GWB_SMTP_SERVER_ADDR);
149 account->incoming_server_secure_connection = 1;
150 account->outgoing_server_need_authentication = 1;
151 account->outgoing_server_port_number = EMAIL_SMTPS_PORT;
152 account->outgoing_server_secure_connection = 1;
156 case 2:/* vadofone */
157 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
158 account->incoming_server_address= strdup(VDF_RECV_SERVER_ADDR);
159 account->incoming_server_port_number = EMAIL_IMAP_PORT;
160 account->outgoing_server_address = strdup(VDF_SMTP_SERVER_ADDR);
161 account->incoming_server_secure_connection = 0;
162 account->outgoing_server_need_authentication = 0;
165 case 4:/* SAMSUNG 3G TEST */
166 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
167 account->incoming_server_address = strdup(S3G_RECV_SERVER_ADDR);
168 account->incoming_server_port_number = S3G_RECV_SERVER_PORT;
169 account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR);
170 account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT;
171 account->incoming_server_secure_connection = S3G_RECV_USE_SECURITY;
172 account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY;
173 account->outgoing_server_need_authentication = S3G_SMTP_AUTH;
176 case 5:/* SAMSUNG 3G TEST */
177 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
178 account->incoming_server_address= strdup(S3G_RECV_SERVER_ADDR);
179 account->incoming_server_port_number = EMAIL_IMAPS_PORT;
180 account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR);
181 account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT;
182 account->incoming_server_secure_connection = 1;
183 account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY;
184 account->outgoing_server_need_authentication = S3G_SMTP_AUTH;
187 case 6:/* Gmail POP3 */
188 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
189 account->incoming_server_address= strdup("pop.gmail.com");
190 account->incoming_server_port_number = 995;
191 account->incoming_server_secure_connection = 1;
192 account->outgoing_server_address = strdup("smtp.gmail.com");
193 account->outgoing_server_port_number = 465;
194 account->outgoing_server_secure_connection = 1;
195 account->outgoing_server_need_authentication = 1;
198 case 7 : /* Gmail IMAP4 */
199 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
200 account->incoming_server_address= strdup("imap.gmail.com");
201 account->incoming_server_port_number = 993;
202 account->incoming_server_secure_connection = 1;
203 account->outgoing_server_address = strdup("smtp.gmail.com");
204 account->outgoing_server_port_number = 465;
205 account->outgoing_server_secure_connection = 1;
206 account->outgoing_server_need_authentication = 1;
209 case 8: /* Active Sync */
210 account->incoming_server_type = EMAIL_SERVER_TYPE_ACTIVE_SYNC;
211 account->incoming_server_address= strdup("");
212 account->incoming_server_port_number = 0;
213 account->incoming_server_secure_connection = 1;
214 account->outgoing_server_address = strdup("");
215 account->outgoing_server_port_number = 0;
216 account->outgoing_server_secure_connection = 1;
217 account->outgoing_server_need_authentication = 1;
221 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
222 account->incoming_server_address= strdup("imap.aol.com");
223 account->incoming_server_port_number = 143;
224 account->incoming_server_secure_connection = 0;
225 account->outgoing_server_address = strdup("smtp.aol.com");
226 account->outgoing_server_port_number = 587;
227 account->outgoing_server_secure_connection = 0;
228 account->outgoing_server_need_authentication = 1;
231 case 10: /* Hotmail */
232 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
233 account->incoming_server_address= strdup("pop3.live.com");
234 account->incoming_server_port_number = 995;
235 account->incoming_server_secure_connection = 1;
236 account->outgoing_server_address = strdup("smtp.live.com");
237 account->outgoing_server_port_number = 587;
238 account->outgoing_server_secure_connection = 0x02;
239 account->outgoing_server_need_authentication = 1;
242 case 11:/* Daum IMAP4*/
243 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
244 account->incoming_server_address= strdup("imap.daum.net");
245 account->incoming_server_port_number = 993;
246 account->incoming_server_secure_connection = 1;
247 account->outgoing_server_address = strdup("smtp.daum.net");
248 account->outgoing_server_port_number = 465;
249 account->outgoing_server_secure_connection = 1;
250 account->outgoing_server_need_authentication = 1;
253 case 12:/* Daum POP3*/
254 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
255 account->incoming_server_address= strdup("pop.daum.net");
256 account->incoming_server_port_number = 995;
257 account->incoming_server_secure_connection = 1;
258 account->outgoing_server_address = strdup("smtp.daum.net");
259 account->outgoing_server_port_number = 465;
260 account->outgoing_server_secure_connection = 1;
261 account->outgoing_server_need_authentication = 1;
264 case 13: /* Yahoo IMAP ID */
265 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
266 account->incoming_server_address= strdup("samsung.imap.mail.yahoo.com");
267 account->incoming_server_port_number = 993;
268 account->incoming_server_secure_connection = 1;
269 account->outgoing_server_address = strdup("samsung.smtp.mail.yahoo.com");
270 account->outgoing_server_port_number = 465;
271 account->outgoing_server_secure_connection = 1;
272 account->outgoing_server_need_authentication = 1;
276 testapp_print("Invalid Account Number\n");
280 account->account_svc_id = 77;
281 err_code = email_add_account_with_validation(account, &handle);
283 testapp_print (" email_add_account_with_validation error : %d\n",err_code);
284 err_code = email_free_account(&account, 1);
288 testapp_print (" email_add_account succeed\n");
291 *account_id = account->account_id;
293 err_code = email_free_account(&account, 1);
298 static gboolean testapp_test_create_account()
300 int account_type = 0 ;
301 int err = EMAIL_ERROR_NONE;
302 int result_from_scanf = 0;
304 testapp_print("1. Gawab\n");
305 testapp_print("2. Vodafone\n");
306 testapp_print("4. SAMSUNG 3G TEST (POP)\n");
307 testapp_print("5. SAMSUNG 3G TEST (IMAP)\n");
308 testapp_print("6. Gmail (POP3)\n");
309 testapp_print("7. Gmail (IMAP4)\n");
310 testapp_print("8. Active Sync (dummy)\n");
311 testapp_print("9. AOL\n");
312 testapp_print("10. Hotmail\n");
313 testapp_print("11. Daum (IMAP4)\n");
314 testapp_print("12. Daum (POP3)\n");
315 testapp_print("13. Yahoo (IMAP ID)\n");
316 testapp_print("Choose server type: ");
318 result_from_scanf = scanf("%d",&account_type);
320 if(!testapp_test_create_account_by_account_type(account_type,&err)) {
321 testapp_print (" testapp_test_create_account_by_account_type error\n");
327 static gboolean testapp_test_update_account()
329 int result_from_scanf = 0;
331 email_account_t *account = NULL;
332 char account_name[256];
333 int err = EMAIL_ERROR_NONE;
334 char signature[100] = {0};
335 char user_email_address[256] = {0,};
336 int add_my_address_to_bcc = 0;
337 int account_svc_id = 0, with_validation = 0;
340 testapp_print("\n>> Enter Account No: ");
341 result_from_scanf = scanf("%d",&account_id);
343 /* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
344 if( (err = email_get_account(account_id, GET_FULL_DATA,&account)) != EMAIL_ERROR_NONE) {
345 testapp_print ("email_get_account failed - %d\n", err);
349 testapp_print ("email_get_account result account_name - %s \n", account->account_name);
351 testapp_print ("email_get_account result signature - %s \n", account->options.signature);
353 #ifdef __FEATURE_AUTO_POLLING__
354 testapp_print ("email_get_account result check_interval - %d \n", account->check_interval);
357 testapp_print("\n Enter new Account name:");
358 result_from_scanf = scanf("%s",account_name);
361 testapp_print("\n Enter new email addr:");
362 result_from_scanf = scanf("%s",user_email_address);
363 #ifdef __FEATURE_AUTO_POLLING__
364 testapp_print("\n Enter new check interval (in mins):");
365 result_from_scanf = scanf("%d",&(account->check_interval));
367 testapp_print("\n Enter new signature:");
368 result_from_scanf = scanf("%s",signature);
370 testapp_print("\n>> Enter add_my_address_to_bcc:(0:off, 1:on) ");
371 result_from_scanf = scanf("%d",&add_my_address_to_bcc);
373 testapp_print("\n>> Enter account_svc_id: ");
374 result_from_scanf = scanf("%d",&account_svc_id);
376 testapp_print("\n>> With validation ? (0: No, 1:Yes) ");
377 result_from_scanf = scanf("%d",&with_validation);
380 account->account_name = strdup(account_name);
381 testapp_print("\n Assigning New Account name: (%s)", account->account_name);
382 account->user_email_address = strdup(user_email_address);
383 account->options.signature = strdup(signature);
384 testapp_print("\n Assigning New Signature: (%s)\n", account->options.signature);
385 account->options.add_my_address_to_bcc = add_my_address_to_bcc;
386 account->account_svc_id = account_svc_id;
388 if(with_validation) {
389 if((err = email_update_account_with_validation(account_id, account)) != EMAIL_ERROR_NONE){
390 testapp_print ("email_update_account_with_validation failed - %d\n", err);
393 testapp_print ("email_update_account_with_validation successful \n");
396 if((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
397 testapp_print ("email_update_account failed - %d\n", err);
400 testapp_print ("email_update_account successful \n");
406 static gboolean testapp_test_delete_account ()
409 email_account_t *account=NULL;
410 int err = EMAIL_ERROR_NONE;
411 int result_from_scanf = 0;
413 testapp_print("\n>> Enter Account No: ");
414 result_from_scanf = scanf("%d",&account_id);
416 /* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
417 if( (err = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0) {
418 testapp_print ("email_get_account failed \n");
419 testapp_print("testapp_test_delete_account failed\n");
422 testapp_print ("email_get_account result account_name - %s \n", account->account_name);
424 if((err = email_delete_account(account_id)) < 0)
425 testapp_print ("email_delete_account failed[%d]\n", err);
427 testapp_print ("email_delete_account successful \n");
434 static gboolean testapp_test_validate_account ()
436 int result_from_scanf = 0;
438 email_account_t *account=NULL;
439 int err_code = EMAIL_ERROR_NONE;
442 testapp_print("\n>> Enter Account No: ");
443 result_from_scanf = scanf("%d",&account_id);
445 /* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
446 if( (err_code = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0 ) {
447 testapp_print ("email_get_account failed \n");
451 testapp_print ("email_get_account result account_name - %s \n", account->account_name);
453 if((err_code = email_validate_account(account_id, &handle)) == EMAIL_ERROR_NONE )
454 testapp_print ("email_validate_account successful handle : %u\n",handle);
456 testapp_print ("email_validate_account failed err_code: %d \n",err_code);
463 static gboolean testapp_test_cancel_validate_account ()
465 int result_from_scanf = 0;
467 int err_code = EMAIL_ERROR_NONE;
468 unsigned account_handle = 0;
470 testapp_print("\n > Enter account_id: ");
471 result_from_scanf = scanf("%d", &account_id);
473 testapp_print("\n > Enter handle: ");
474 result_from_scanf = scanf("%d", &account_handle);
476 err_code = email_cancel_job(account_id, account_handle, EMAIL_CANCELED_BY_USER);
478 testapp_print("email_cancel_job Success..!handle:[%d]", account_handle);
480 testapp_print ("email_cancel_job failed err_code: %d \n",err_code);
485 static gboolean testapp_test_get_account()
487 int result_from_scanf = 0;
489 email_account_t *account=NULL;
490 int err_code = EMAIL_ERROR_NONE;
491 testapp_print("\n>> Enter Account No: ");
492 result_from_scanf = scanf("%d",&account_id);
495 int is_preset_account;
499 testapp_print ("\n----------------------------------------------------------\n");
500 testapp_print ("email_get_account GET_FULL_DATA \n");
501 if( (err_code = email_get_account(account_id,GET_FULL_DATA,&account)) < 0) {
502 testapp_print ("email_get_account failed - %d\n", err_code);
506 user_data_t* val = (user_data_t*) account->user_data;
507 int is_preset_account = val? val->is_preset_account : 0;
508 int index_color = val? val->index_color : 0;
510 testapp_print ("email_get_account result\n"
511 "account_name - %s \n"
512 "user_email_address - %s \n"
513 "incoming_server_secure_connection %d \n"
516 "add_my_address_to_bcc %d \n"
517 "account_svc_id %d\n"
518 "incoming_server_address %s\n"
519 "outgoing_server_address %s\n"
520 "default_mail_slot_size %d\n"
525 "certificate_path %s\n"
528 account->account_name,
529 account->user_email_address,
530 account->incoming_server_secure_connection,
531 account->options.add_signature,
532 account->options.signature,
533 account->options.add_my_address_to_bcc,
534 account->account_svc_id,
535 account->incoming_server_address,
536 account->outgoing_server_address,
537 account->default_mail_slot_size,
538 account->sync_status,
539 account->sync_disabled,
542 account->certificate_path,
546 err_code = email_free_account(&account, 1);
548 testapp_print ("\n----------------------------------------------------------\n");
549 testapp_print ("email_get_account WITHOUT_OPTION \n");
551 if( (err_code = email_get_account(account_id, WITHOUT_OPTION, &account)) < 0) {
552 testapp_print ("email_get_account failed \n");
556 testapp_print ("email_get_account result\n"
557 "account_name - %s \n"
558 "user_email_address - %s \n"
559 "incoming_server_secure_connection %d \n"
560 "add_signature : %d \n",
561 account->account_name,
562 account->user_email_address,
563 account->incoming_server_secure_connection,
564 account->options.add_signature
567 if(account->options.signature)
568 testapp_print ("signature : %s\n", account->options.signature);
570 testapp_print ("signature not retrieved \n");
572 err_code = email_free_account(&account, 1);
574 testapp_print ("\n----------------------------------------------------------\n");
575 testapp_print ("email_get_account ONLY_OPTION \n");
577 if( (err_code = email_get_account(account_id, ONLY_OPTION, &account)) < 0) {
578 testapp_print ("email_get_account failed \n");
582 testapp_print ("email_get_account result\n"
585 "add_my_address_to_bcc %d\n"
586 "account_svc_id %d\n",
587 account->options.add_signature,
588 account->options.signature,
589 account->options.add_my_address_to_bcc,
590 account->account_svc_id
593 if(account->account_name)
594 testapp_print ("account_name : %s \n", account->account_name);
596 testapp_print ("account_name not retrieved \n");
598 if(account->user_email_address)
599 testapp_print ("user_email_address : %s \n", account->user_email_address);
601 testapp_print ("user_email_address not retrieved \n");
602 err_code = email_free_account(&account, 1);
607 static gboolean testapp_test_get_account_list ()
611 email_account_t *account_list=NULL;
612 struct timeval tv_1, tv_2;
614 int err_code = EMAIL_ERROR_NONE;
616 gettimeofday(&tv_1, NULL);
618 if((err_code = email_get_account_list(&account_list, &count)) < 0 ) {
619 testapp_print(" email_get_account_list error\n");
623 gettimeofday(&tv_2, NULL);
624 interval = tv_2.tv_usec - tv_1.tv_usec;
625 testapp_print("\t testapp_test_get_account_list Proceed time %d us\n",interval);
627 for(i=0;i<count;i++){
628 testapp_print(" %2d) %-15s %-30s\n",account_list[i].account_id,
629 account_list[i].account_name,
630 account_list[i].user_email_address);
633 err_code = email_free_account(&account_list, count);
637 static gboolean testapp_test_backup_account()
639 char *file_name = "accounts_file";
641 error_code = email_backup_accounts_into_secure_storage(file_name);
642 testapp_print("\n email_backup_accounts_into_secure_storage returned [%d]\n",error_code);
645 static gboolean testapp_test_restore_account()
647 char *file_name = "accounts_file";
649 error_code = email_restore_accounts_from_secure_storage(file_name);
650 testapp_print("\n email_restore_accounts_from_secure_storage returned [%d]\n",error_code);
654 static gboolean testapp_test_get_password_length_of_account()
656 int result_from_scanf = 0;
657 int error_code, password_length, account_id;
659 testapp_print("\n input account id\n");
660 result_from_scanf = scanf("%d", &account_id);
661 error_code = email_get_password_length_of_account(account_id, &password_length);
662 testapp_print("testapp_test_get_password_length_of_account returned [%d]\n",password_length);
666 static gboolean testapp_test_query_server_info()
668 int result_from_scanf = 0;
670 char domain_name[255];
671 email_server_info_t *result_server_info;
673 testapp_print("\n input domain name\n");
674 result_from_scanf = scanf("%s", domain_name);
676 error_code = email_query_server_info(domain_name, &result_server_info);
677 testapp_print("email_query_server_info returned [%d]\n",error_code);
678 if(error_code == EMAIL_ERROR_NONE)
679 testapp_print("service_name [%s]\n", result_server_info->service_name);
683 static gboolean testapp_test_clear_all_notification()
687 error_code = email_clear_all_notification_bar();
688 testapp_print("email_clear_all_notification_bar returned [%d]\n",error_code);
692 static gboolean testapp_test_save_default_account_id()
694 int result_from_scanf = 0;
698 testapp_print ("\nInput default account id : ");
700 result_from_scanf = scanf("%d", &account_id);
702 error_code = email_save_default_account_id(account_id);
704 testapp_print("email_save_default_account_id returned [%d]\n",error_code);
708 static gboolean testapp_test_load_default_account_id()
713 error_code = email_load_default_account_id(&account_id);
715 testapp_print ("\ndefault account id : %d\n", account_id);
716 testapp_print("email_load_default_account_id returned [%d]\n",error_code);
720 static gboolean testapp_test_add_certificate()
722 int result_from_scanf = 0;
724 char save_name[50] = {0, };
725 char certificate_path[255] = {0, };
727 testapp_print("Input cert path : ");
728 result_from_scanf = scanf("%s", certificate_path);
730 testapp_print("Input cert email-address : ");
731 result_from_scanf = scanf("%s", save_name);
733 testapp_print("cert path : [%s]", certificate_path);
734 testapp_print("email-address : [%s]", save_name);
736 ret = email_add_certificate(certificate_path, save_name);
737 if (ret != EMAIL_ERROR_NONE) {
738 testapp_print("Add certificate failed\n");
742 testapp_print("Add certificate success\n");
746 static gboolean testapp_test_get_certificate()
748 int result_from_scanf = 0;
750 char save_name[20] = {0, };
751 email_certificate_t *certificate = NULL;
753 testapp_print("Input cert email-address : ");
754 result_from_scanf = scanf("%s", save_name);
756 ret = email_get_certificate(save_name, &certificate);
757 if (ret != EMAIL_ERROR_NONE) {
758 testapp_print("Get certificate failed\n");
762 testapp_print("certificate_id : %d\n", certificate->certificate_id);
763 testapp_print("issue_year : %d\n", certificate->issue_year);
764 testapp_print("issue_month : %d\n", certificate->issue_month);
765 testapp_print("issue_day : %d\n", certificate->issue_day);
766 testapp_print("expiration_year : %d\n", certificate->expiration_year);
767 testapp_print("expiration_month : %d\n", certificate->expiration_month);
768 testapp_print("expiration_day : %d\n", certificate->expiration_day);
769 testapp_print("issue_organization_name : %s\n", certificate->issue_organization_name);
770 testapp_print("subject_string : %s\n", certificate->subject_str);
771 testapp_print("file path : %s\n", certificate->filepath);
774 email_free_certificate(&certificate, 1);
776 testapp_print("Get certificate success\n");
780 static gboolean testapp_test_delete_certificate()
782 int result_from_scanf = 0;
784 char save_name[20] = {0, };
786 testapp_print("Input cert email-address : ");
787 result_from_scanf = scanf("%s", save_name);
789 ret = email_delete_certificate(save_name);
790 if (ret != EMAIL_ERROR_NONE) {
791 testapp_print("Delete certificate failed\n");
795 testapp_print("Delete certificate success\n");
798 static gboolean testapp_test_interpret_command (int selected_number)
800 gboolean go_to_loop = TRUE;
802 switch (selected_number) {
804 testapp_test_create_account();
808 testapp_test_update_account();
812 testapp_test_delete_account();
816 testapp_test_get_account();
820 testapp_test_get_account_list();
824 testapp_test_validate_account();
828 testapp_test_cancel_validate_account();
832 testapp_test_backup_account();
836 testapp_test_restore_account();
840 testapp_test_get_password_length_of_account();
844 testapp_test_query_server_info();
848 testapp_test_clear_all_notification();
852 testapp_test_save_default_account_id();
856 testapp_test_load_default_account_id();
860 testapp_test_add_certificate();
864 testapp_test_get_certificate();
868 testapp_test_delete_certificate();
882 void testapp_account_main ()
884 gboolean go_to_loop = TRUE;
886 int result_from_scanf = 0;
889 testapp_show_menu (EMAIL_ACCOUNT_MENU);
890 testapp_show_prompt (EMAIL_ACCOUNT_MENU);
892 result_from_scanf = scanf ("%d", &menu_number);
894 go_to_loop = testapp_test_interpret_command (menu_number);