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"
36 #include "testapp-utility.h"
37 #include "testapp-account.h"
39 #include <sys/times.h>
41 /* internal defines */
43 #define GWB_RECV_SERVER_ADDR "pop.gawab.com"
44 #define GWB_SMTP_SERVER_ADDR "smtp.gawab.com"
46 #define VDF_RECV_SERVER_ADDR "imap.email.vodafone.de"
47 #define VDF_SMTP_SERVER_ADDR "smtp.email.vodafone.de"
50 #define S3G_RECV_SERVER_ADDR "165.213.73.235"
51 #define S3G_RECV_SERVER_PORT EMAIL_POP3_PORT
52 #define S3G_RECV_USE_SECURITY 0
53 #define S3G_RECV_IMAP_USE_SECURITY 1
54 #define S3G_SMTP_SERVER_ADDR "165.213.73.235"
55 #define S3G_SMTP_SERVER_PORT 465
56 #define S3G_SMTP_AUTH 1
57 #define S3G_SMTP_USE_SECURITY 1
58 #define S3G_KEEP_ON_SERVER 1
60 gboolean testapp_create_account_object(email_account_t **result_account)
62 email_account_t *account = NULL;
63 char id_string[100] = { 0, }, password_string[1000] = { 0, }, address_string[100] = { 0, };
64 char accesss_token[1000] = { 0, }, refresh_token[1000] = { 0, };
65 int samsung3g_account_index;
68 testapp_print("1. Gawab\n");
69 testapp_print("2. Vodafone\n");
70 testapp_print("4. SAMSUNG 3G TEST (POP)\n");
71 testapp_print("5. SAMSUNG 3G TEST (IMAP)\n");
72 testapp_print("6. Gmail (POP3)\n");
73 testapp_print("7. Gmail (IMAP4)\n");
74 testapp_print("8. Active Sync (dummy)\n");
75 testapp_print("9. AOL\n");
76 testapp_print("10. Hotmail\n");
77 testapp_print("11. Daum (IMAP4)\n");
78 testapp_print("12. Daum (POP3)\n");
79 testapp_print("13. Yahoo (IMAP ID)\n");
80 testapp_print("14. Gmail IMAP with XOAUTH\n");
81 testapp_print("15. Yandex\n");
82 testapp_print("16. mopera\n");
83 testapp_print("Choose server type: ");
86 if (0 >= scanf("%d",&account_type))
87 testapp_print("Invalid input. ");
89 switch(account_type) {
93 testapp_print("Enter your account index [1~10] : ");
94 if (0 >= scanf("%d",&samsung3g_account_index))
95 testapp_print("Invalid input. ");
96 }while( samsung3g_account_index > 10 || samsung3g_account_index < 1);
97 sprintf(id_string, "test%02d", samsung3g_account_index);
98 sprintf(address_string, "test%02d@streaming.s3glab.net", samsung3g_account_index);
99 sprintf(password_string, "test%02d", samsung3g_account_index);
102 testapp_print("Enter email address : ");
103 if (0 >= scanf("%s", address_string))
104 testapp_print("Invalid input. ");
105 strcpy(id_string, address_string);
107 testapp_print("Enter access token : ");
108 if (0 >= scanf("%s", accesss_token))
109 testapp_print("Invalid input. ");
111 testapp_print("Enter refresh token : ");
112 if (0 >= scanf("%s", refresh_token))
113 testapp_print("Invalid input. ");
115 snprintf(password_string, 100, "%s\001%s\001", accesss_token, refresh_token);
118 testapp_print("Enter email address : ");
119 if (0 >= scanf("%s", address_string))
120 testapp_print("Invalid input. ");
122 testapp_print("Enter id : ");
123 if (0 >= scanf("%s", id_string))
124 testapp_print("Invalid input. ");
126 testapp_print("Enter password_string : ");
127 if (0 >= scanf("%s", password_string))
128 testapp_print("Invalid input. ");
132 account = malloc(sizeof(email_account_t));
133 memset(account, 0x00, sizeof(email_account_t));
136 int is_preset_account;
139 user_data_t data = (user_data_t) {1, 0};
140 /* if user_data_t has any pointer member, please don't use sizeof(). */
141 /* You need to serialize user_data to buffer and then take its length */
142 int data_length = sizeof(data);
145 account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL;
146 account->incoming_server_secure_connection = 1;
147 account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
148 account->auto_download_size = 2;
149 account->outgoing_server_use_same_authenticator = 1;
150 account->auto_resend_times = 3;
151 account->pop_before_smtp = 0;
152 account->incoming_server_requires_apop = 0;
153 account->incoming_server_authentication_method = 0;
154 account->logo_icon_path = NULL;
155 account->color_label = (128 << 16) | (128 << 8) | (128);
156 account->user_data = malloc (data_length);
157 memcpy( account->user_data, (void*) &data, data_length );
158 account->user_data_length = data_length;
159 account->options.priority = 3;
160 account->options.keep_local_copy = 1;
161 account->options.req_delivery_receipt = 0;
162 account->options.req_read_receipt = 0;
163 account->options.download_limit = 0;
164 account->options.block_address = 0;
165 account->options.block_subject = 0;
166 account->options.display_name_from = NULL;
167 account->options.reply_with_body = 0;
168 account->options.forward_with_files = 0;
169 account->options.add_myname_card = 0;
170 account->options.add_signature = 0;
171 account->options.signature = NULL;
172 account->options.add_my_address_to_bcc = 0;
173 account->check_interval = 0;
174 account->keep_mails_on_pop_server_after_download = 1;
175 account->default_mail_slot_size = 20;
176 account->roaming_option = EMAIL_ROAMING_OPTION_RESTRICTED_BACKGROUND_TASK;
177 account->peak_interval = 30;
178 account->peak_days = EMAIL_PEAK_DAYS_MONDAY | EMAIL_PEAK_DAYS_TUEDAY | EMAIL_PEAK_DAYS_THUDAY | EMAIL_PEAK_DAYS_FRIDAY;
179 account->peak_start_time = 830;
180 account->peak_end_time = 1920;
182 account->account_name = strdup(address_string);
183 account->user_display_name = strdup(id_string);
184 account->user_email_address = strdup(address_string);
185 account->reply_to_address = strdup(address_string);
186 account->return_address = strdup(address_string);
188 account->incoming_server_user_name = strdup(id_string);
189 account->incoming_server_password = strdup(password_string);
190 account->outgoing_server_user_name = strdup(id_string);
191 account->outgoing_server_password = strdup(password_string);
193 switch (account_type) {
195 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3 ;
196 account->incoming_server_address = strdup(GWB_RECV_SERVER_ADDR);
197 account->incoming_server_port_number = EMAIL_POP3S_PORT;
198 account->outgoing_server_address = strdup(GWB_SMTP_SERVER_ADDR);
199 account->incoming_server_secure_connection = 1;
200 account->outgoing_server_need_authentication = 1;
201 account->outgoing_server_port_number = EMAIL_SMTPS_PORT;
202 account->outgoing_server_secure_connection = 1;
206 case 2:/* vadofone */
207 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
208 account->incoming_server_address= strdup(VDF_RECV_SERVER_ADDR);
209 account->incoming_server_port_number = EMAIL_IMAP_PORT;
210 account->outgoing_server_address = strdup(VDF_SMTP_SERVER_ADDR);
211 account->incoming_server_secure_connection = 0;
212 account->outgoing_server_need_authentication = 0;
215 case 4:/* SAMSUNG 3G TEST */
216 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
217 account->incoming_server_address = strdup(S3G_RECV_SERVER_ADDR);
218 account->incoming_server_port_number = S3G_RECV_SERVER_PORT;
219 account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR);
220 account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT;
221 account->incoming_server_secure_connection = S3G_RECV_USE_SECURITY;
222 account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY;
223 account->outgoing_server_need_authentication = S3G_SMTP_AUTH;
226 case 5:/* SAMSUNG 3G TEST */
227 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
228 account->incoming_server_address= strdup(S3G_RECV_SERVER_ADDR);
229 account->incoming_server_port_number = EMAIL_IMAPS_PORT;
230 account->outgoing_server_address = strdup(S3G_SMTP_SERVER_ADDR);
231 account->outgoing_server_port_number = S3G_SMTP_SERVER_PORT;
232 account->incoming_server_secure_connection = 1;
233 account->outgoing_server_secure_connection = S3G_SMTP_USE_SECURITY;
234 account->outgoing_server_need_authentication = S3G_SMTP_AUTH;
237 case 6:/* Gmail POP3 */
238 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
239 account->incoming_server_address= strdup("pop.gmail.com");
240 account->incoming_server_port_number = 995;
241 account->incoming_server_secure_connection = 1;
242 account->outgoing_server_address = strdup("smtp.gmail.com");
243 account->outgoing_server_port_number = 465;
244 account->outgoing_server_secure_connection = 1;
245 account->outgoing_server_need_authentication = 1;
248 case 7 : /* Gmail IMAP4 */
249 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
250 account->incoming_server_address = strdup("imap.gmail.com");
251 account->incoming_server_port_number = 993;
252 account->incoming_server_secure_connection = 1;
253 account->outgoing_server_address = strdup("smtp.gmail.com");
254 account->outgoing_server_port_number = 465;
255 account->outgoing_server_secure_connection = 1;
256 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
257 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_NO_AUTH;
260 case 8: /* Active Sync */
261 account->incoming_server_type = EMAIL_SERVER_TYPE_ACTIVE_SYNC;
262 account->incoming_server_address= strdup("");
263 account->incoming_server_port_number = 0;
264 account->incoming_server_secure_connection = 1;
265 account->outgoing_server_address = strdup("");
266 account->outgoing_server_port_number = 0;
267 account->outgoing_server_secure_connection = 1;
268 account->outgoing_server_need_authentication = 1;
272 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
273 account->incoming_server_address= strdup("imap.aol.com");
274 account->incoming_server_port_number = 143;
275 account->incoming_server_secure_connection = 0;
276 account->outgoing_server_address = strdup("smtp.aol.com");
277 account->outgoing_server_port_number = 587;
278 account->outgoing_server_secure_connection = 0;
279 account->outgoing_server_need_authentication = 1;
282 case 10: /* Hotmail */
283 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
284 account->incoming_server_address= strdup("pop3.live.com");
285 account->incoming_server_port_number = 995;
286 account->incoming_server_secure_connection = 1;
287 account->outgoing_server_address = strdup("smtp.live.com");
288 account->outgoing_server_port_number = 587;
289 account->outgoing_server_secure_connection = 0x02;
290 account->outgoing_server_need_authentication = 1;
293 case 11:/* Daum IMAP4*/
294 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
295 account->incoming_server_address= strdup("imap.daum.net");
296 account->incoming_server_port_number = 993;
297 account->incoming_server_secure_connection = 1;
298 account->outgoing_server_address = strdup("smtp.daum.net");
299 account->outgoing_server_port_number = 465;
300 account->outgoing_server_secure_connection = 1;
301 account->outgoing_server_need_authentication = 1;
304 case 12:/* Daum POP3*/
305 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
306 account->incoming_server_address= strdup("pop.daum.net");
307 account->incoming_server_port_number = 995;
308 account->incoming_server_secure_connection = 1;
309 account->outgoing_server_address = strdup("smtp.daum.net");
310 account->outgoing_server_port_number = 465;
311 account->outgoing_server_secure_connection = 1;
312 account->outgoing_server_need_authentication = 1;
315 case 13: /* Yahoo IMAP ID */
316 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
317 account->incoming_server_address= strdup("samsung.imap.mail.yahoo.com");
318 account->incoming_server_port_number = 993;
319 account->incoming_server_secure_connection = 1;
320 account->outgoing_server_address = strdup("samsung.smtp.mail.yahoo.com");
321 account->outgoing_server_port_number = 465;
322 account->outgoing_server_secure_connection = 1;
323 account->outgoing_server_need_authentication = 1;
326 case 14 : /* XOAUTH */
327 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
328 account->incoming_server_address = strdup("imap.gmail.com");
329 account->incoming_server_port_number = 993;
330 account->incoming_server_secure_connection = 1;
331 account->outgoing_server_address = strdup("smtp.gmail.com");
332 account->outgoing_server_port_number = 465;
333 account->outgoing_server_secure_connection = 1;
334 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_XOAUTH2;
335 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_XOAUTH2;
338 case 15 : /* yandex */
339 account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
340 account->incoming_server_address = strdup("imap.yandex.ru");
341 account->incoming_server_port_number = 993;
342 account->incoming_server_secure_connection = 1;
343 account->outgoing_server_address = strdup("smtp.yandex.ru");
344 account->outgoing_server_port_number = 465;
345 account->outgoing_server_secure_connection = 1;
346 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
347 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
350 case 16 : /* mopera */
351 account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
352 account->incoming_server_address = strdup("mail.mopera.net");
353 account->incoming_server_port_number = 110;
354 account->incoming_server_secure_connection = 0;
355 account->incoming_server_authentication_method = EMAIL_AUTHENTICATION_METHOD_NO_AUTH;
356 account->outgoing_server_address = strdup("mail.mopera.net");
357 account->outgoing_server_port_number = 465;
358 account->outgoing_server_secure_connection = 0;
359 account->outgoing_server_need_authentication = EMAIL_AUTHENTICATION_METHOD_DEFAULT;
363 testapp_print("Invalid Account Number\n");
367 account->account_svc_id = 77;
370 *result_account = account;
375 static gboolean testapp_test_add_account_with_validation()
377 int err = EMAIL_ERROR_NONE;
378 email_account_t *account = NULL;
381 if(!testapp_create_account_object(&account)) {
382 testapp_print ("testapp_test_create_account_by_account_type error\n");
386 err = email_add_account_with_validation(account, &handle);
388 testapp_print ("email_add_account_with_validation error : %d\n", err);
389 err = email_free_account(&account, 1);
393 testapp_print ("email_add_account succeed. account_id\n", account->account_id);
395 err = email_free_account(&account, 1);
400 static gboolean testapp_test_update_account()
403 email_account_t *account = NULL;
404 //char account_name[256];
405 int err = EMAIL_ERROR_NONE;
406 //char signature[100] = {0};
407 //char user_email_address[256] = {0,};
408 //int add_my_address_to_bcc = 0;
409 int with_validation = 0; //account_svc_id = 0,
411 testapp_print("\n>> Enter Account ID: ");
412 if (0 >= scanf("%d",&account_id))
413 testapp_print("Invalid input. ");
415 if( (err = email_get_account(account_id, GET_FULL_DATA,&account)) != EMAIL_ERROR_NONE) {
416 testapp_print ("email_get_account failed - %d\n", err);
420 testapp_print ("email_get_account result account_name - %s \n", account->account_name);
421 testapp_print ("email_get_account result address - %s \n", account->user_email_address);
422 testapp_print ("email_get_account result signature - %s \n", account->options.signature);
423 testapp_print ("email_get_account result check_interval - %d \n", account->check_interval);
425 testapp_print("\n Enter new check interval (in mins):");
426 if (0 >= scanf("%d",&(account->check_interval)))
427 testapp_print("Invalid input. ");
429 testapp_print("\n Enter new peak interval (in mins):");
430 if (0 >= scanf("%d",&(account->peak_interval));
432 testapp_print("\n Enter new peak days:");
433 if (0 >= scanf("%d",&(account->peak_days));
435 testapp_print("\n Enter new peak start time:");
436 if (0 >= scanf("%d",&(account->peak_start_time));
438 testapp_print("\n Enter new peak end time:");
439 if (0 >= scanf("%d",&(account->peak_end_time));
443 testapp_print("\n Enter new Account name:");
444 if (0 >= scanf("%s",account_name);
446 testapp_print("\n Enter new email addr:");
447 if (0 >= scanf("%s",user_email_address);
449 testapp_print("\n Enter new signature:");
450 if (0 >= scanf("%s",signature);
452 testapp_print("\n>> Enter add_my_address_to_bcc:(0:off, 1:on) ");
453 if (0 >= scanf("%d",&add_my_address_to_bcc);
455 testapp_print("\n>> Enter account_svc_id: ");
456 if (0 >= scanf("%d",&account_svc_id);
458 testapp_print("\n>> With validation ? (0: No, 1:Yes) ");
459 if (0 >= scanf("%d",&with_validation);
462 testapp_print("\n Assigning New Account name: (%s)", account->account_name);
463 testapp_print("\n Assigning New Signature: (%s)\n", account->options.signature);
465 account->account_name = strdup(account_name);
466 account->user_email_address = strdup(user_email_address);
467 account->options.signature = strdup(signature);
468 account->options.add_my_address_to_bcc = add_my_address_to_bcc;
469 account->account_svc_id = account_svc_id;
472 if(with_validation) {
473 if((err = email_update_account_with_validation(account_id, account)) != EMAIL_ERROR_NONE){
474 testapp_print ("email_update_account_with_validation failed - %d\n", err);
477 testapp_print ("email_update_account_with_validation successful \n");
480 if((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
481 testapp_print ("email_update_account failed - %d\n", err);
484 testapp_print ("email_update_account successful \n");
490 static gboolean testapp_test_delete_account ()
493 email_account_t *account=NULL;
494 int err = EMAIL_ERROR_NONE;
496 testapp_print("\n>> Enter Account No: ");
497 if (0 >= scanf("%d",&account_id))
498 testapp_print("Invalid input. ");
500 /* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
501 if( (err = email_get_account(account_id, WITHOUT_OPTION,&account)) < 0) {
502 testapp_print ("email_get_account failed \n");
503 testapp_print("testapp_test_delete_account failed\n");
506 testapp_print ("email_get_account result account_name - %s \n", account->account_name);
508 if((err = email_delete_account(account_id)) < 0)
509 testapp_print ("email_delete_account failed[%d]\n", err);
511 testapp_print ("email_delete_account successful \n");
518 static gboolean testapp_test_validate_account ()
520 email_account_t *account = NULL;
521 int err_code = EMAIL_ERROR_NONE;
524 if(!testapp_create_account_object(&account)) {
525 testapp_print ("testapp_create_account_object error\n");
529 if((err_code = email_validate_account_ex(account, &handle)) == EMAIL_ERROR_NONE )
530 testapp_print ("email_validate_account_ex successful handle : %u\n",handle);
532 testapp_print ("email_validate_account_ex failed err_code : %d \n",err_code);
535 email_free_account(&account, 1);
542 static gboolean testapp_test_cancel_validate_account ()
545 int err_code = EMAIL_ERROR_NONE;
546 unsigned account_handle = 0;
548 testapp_print("\n > Enter account_id: ");
549 if (0 >= scanf("%d", &account_id))
550 testapp_print("Invalid input. ");
552 testapp_print("\n > Enter handle: ");
553 if (0 >= scanf("%d", &account_handle))
554 testapp_print("Invalid input. ");
556 err_code = email_cancel_job(account_id, account_handle, EMAIL_CANCELED_BY_USER);
558 testapp_print("email_cancel_job Success..!handle:[%d]", account_handle);
560 testapp_print ("email_cancel_job failed err_code: %d \n",err_code);
565 static gboolean testapp_test_get_account()
568 email_account_t *account=NULL;
569 int err_code = EMAIL_ERROR_NONE;
570 testapp_print("\n>> Enter Account No: ");
571 if (0 >= scanf("%d",&account_id))
572 testapp_print("Invalid input. ");
575 int is_preset_account;
579 testapp_print ("\n----------------------------------------------------------\n");
580 testapp_print ("email_get_account GET_FULL_DATA \n");
581 if( (err_code = email_get_account(account_id,GET_FULL_DATA,&account)) < 0) {
582 testapp_print ("email_get_account failed - %d\n", err_code);
586 user_data_t* val = (user_data_t*) account->user_data;
587 int is_preset_account = val? val->is_preset_account : 0;
588 int index_color = val? val->index_color : 0;
590 testapp_print ("email_get_account result\n"
591 "account_name - %s \n"
592 "user_email_address - %s \n"
593 "incoming_server_secure_connection %d \n"
596 "add_my_address_to_bcc %d \n"
597 "account_svc_id %d\n"
598 "incoming_server_address %s\n"
599 "outgoing_server_address %s\n"
600 "default_mail_slot_size %d\n"
605 "certificate_path %s\n"
607 "auto_resend_times %d\n"
608 "roaming_option %d\n"
611 "peak_start_time %d\n"
614 "notification_status %d\n"
615 "vibrate_status %d\n"
616 "display_content_status %d\n"
617 "default_ringtone_status %d\n"
618 "alert_ringtone_path %s\n"
620 account->account_name,
621 account->user_email_address,
622 account->incoming_server_secure_connection,
623 account->options.add_signature,
624 account->options.signature,
625 account->options.add_my_address_to_bcc,
626 account->account_svc_id,
627 account->incoming_server_address,
628 account->outgoing_server_address,
629 account->default_mail_slot_size,
630 account->sync_status,
631 account->sync_disabled,
634 account->certificate_path,
635 account->digest_type,
636 account->auto_resend_times,
637 account->roaming_option,
638 account->peak_interval,
640 account->peak_start_time,
641 account->peak_end_time,
642 account->color_label,
643 account->options.notification_status,
644 account->options.vibrate_status,
645 account->options.display_content_status,
646 account->options.default_ringtone_status,
647 account->options.alert_ringtone_path
650 err_code = email_free_account(&account, 1);
652 testapp_print ("\n----------------------------------------------------------\n");
653 testapp_print ("email_get_account WITHOUT_OPTION \n");
655 if( (err_code = email_get_account(account_id, WITHOUT_OPTION, &account)) < 0) {
656 testapp_print ("email_get_account failed \n");
660 testapp_print ("email_get_account result\n"
661 "account_name - %s \n"
662 "user_email_address - %s \n"
663 "incoming_server_secure_connection %d \n"
664 "add_signature : %d \n",
665 account->account_name,
666 account->user_email_address,
667 account->incoming_server_secure_connection,
668 account->options.add_signature
671 if(account->options.signature)
672 testapp_print ("signature : %s\n", account->options.signature);
674 testapp_print ("signature not retrieved \n");
676 err_code = email_free_account(&account, 1);
678 testapp_print ("\n----------------------------------------------------------\n");
679 testapp_print ("email_get_account ONLY_OPTION \n");
681 if( (err_code = email_get_account(account_id, ONLY_OPTION, &account)) < 0) {
682 testapp_print ("email_get_account failed \n");
686 testapp_print ("email_get_account result\n"
689 "add_my_address_to_bcc %d\n"
690 "account_svc_id %d\n",
691 account->options.add_signature,
692 account->options.signature,
693 account->options.add_my_address_to_bcc,
694 account->account_svc_id
697 if(account->account_name)
698 testapp_print ("account_name : %s \n", account->account_name);
700 testapp_print ("account_name not retrieved \n");
702 if(account->user_email_address)
703 testapp_print ("user_email_address : %s \n", account->user_email_address);
705 testapp_print ("user_email_address not retrieved \n");
706 err_code = email_free_account(&account, 1);
711 static gboolean testapp_test_get_account_list ()
715 email_account_t *account_list=NULL;
716 struct timeval tv_1, tv_2;
718 int err_code = EMAIL_ERROR_NONE;
720 gettimeofday(&tv_1, NULL);
722 if((err_code = email_get_account_list(&account_list, &count)) < 0 ) {
723 testapp_print(" email_get_account_list error\n");
727 gettimeofday(&tv_2, NULL);
728 interval = tv_2.tv_usec - tv_1.tv_usec;
729 testapp_print("\t testapp_test_get_account_list Proceed time %d us\n",interval);
731 for(i=0;i<count;i++){
732 testapp_print(" %2d) %-15s %-30s\n",account_list[i].account_id,
733 account_list[i].account_name,
734 account_list[i].user_email_address);
737 err_code = email_free_account(&account_list, count);
741 static gboolean testapp_test_update_check_interval()
744 int err_code = EMAIL_ERROR_NONE;
745 email_account_t *account = NULL;
747 testapp_print("\n Enter account id :");
748 if (0 >= scanf("%d",&account_id))
749 testapp_print("Invalid input. ");
751 if( (err_code = email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account)) != EMAIL_ERROR_NONE) {
752 testapp_print ("email_get_account failed [%d]\n", err_code);
756 testapp_print("\n Enter new check interval (in mins):");
757 if (0 >= scanf("%d",&(account->check_interval)))
758 testapp_print("Invalid input. ");
760 if((err_code = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
761 testapp_print ("email_update_account failed [%d]\n", err_code);
765 testapp_print ("email_update_account successful \n");
769 email_free_account(&account, 1);
774 static gboolean testapp_test_backup_account()
776 char *file_name = "/opt/usr/data/email/accounts_file";
778 error_code = email_backup_accounts_into_secure_storage(file_name);
779 testapp_print("\n email_backup_accounts_into_secure_storage returned [%d]\n",error_code);
782 static gboolean testapp_test_restore_account()
784 char *file_name = "/opt/usr/data/email/accounts_file";
786 error_code = email_restore_accounts_from_secure_storage(file_name);
787 testapp_print("\n email_restore_accounts_from_secure_storage returned [%d]\n",error_code);
791 static gboolean testapp_test_get_password_length_of_account()
793 int password_length, account_id;
795 testapp_print("\n input account id\n");
796 if (0 >= scanf("%d", &account_id))
797 testapp_print("Invalid input. ");
798 email_get_password_length_of_account(account_id, EMAIL_GET_INCOMING_PASSWORD_LENGTH, &password_length);
799 testapp_print("testapp_test_get_password_length_of_account returned [%d]\n",password_length);
803 static gboolean testapp_test_update_notification()
807 int t_mail_count = 0;
808 int input_from_eas = 0;
809 int unread_mail_count = 0;
811 testapp_print("\n Input account ID:\n");
812 if (0 >= scanf("%d", &account_id))
813 testapp_print("Invalid input. ");
815 testapp_print("\n Input mail count:\n");
816 if (0 >= scanf("%d", &t_mail_count))
817 testapp_print("Invalid input. ");
819 testapp_print("\n Input unread mail count:\n");
820 if (0 >= scanf("%d", &unread_mail_count))
821 testapp_print("Invalid input. ");
823 testapp_print("\n Input From eas:\n");
824 if (0 >= scanf("%d", &input_from_eas))
825 testapp_print("Invalid input. ");
827 error_code = email_update_notification_bar(account_id, t_mail_count, unread_mail_count, input_from_eas);
828 testapp_print("email_update_notification_bar returned [%d]\n",error_code);
832 static gboolean testapp_test_clear_notification()
837 testapp_print("\n Input account ID:\n");
838 if (0 >= scanf("%d", &account_id))
839 testapp_print("Invalid input. ");
841 error_code = email_clear_notification_bar(account_id);
842 testapp_print("email_clear_notification_bar returned [%d]\n",error_code);
846 static gboolean testapp_test_clear_all_notification()
850 error_code = email_clear_notification_bar(ALL_ACCOUNT);
851 testapp_print("email_clear_notification_bar returned [%d]\n",error_code);
855 static gboolean testapp_test_save_default_account_id()
860 testapp_print ("\nInput default account id : ");
862 if (0 >= scanf("%d", &account_id))
863 testapp_print("Invalid input. ");
865 error_code = email_save_default_account_id(account_id);
867 testapp_print("email_save_default_account_id returned [%d]\n",error_code);
871 static gboolean testapp_test_load_default_account_id()
876 error_code = email_load_default_account_id(&account_id);
878 testapp_print ("\ndefault account id : %d\n", account_id);
879 testapp_print("email_load_default_account_id returned [%d]\n",error_code);
883 static gboolean testapp_test_add_certificate()
886 char save_name[50] = {0, };
887 char certificate_path[255] = {0, };
889 testapp_print("Input cert path : ");
890 if (0 >= scanf("%s", certificate_path))
891 testapp_print("Invalid input. ");
893 testapp_print("Input cert email-address : ");
894 if (0 >= scanf("%s", save_name))
895 testapp_print("Invalid input. ");
897 testapp_print("cert path : [%s]", certificate_path);
898 testapp_print("email-address : [%s]", save_name);
900 ret = email_add_certificate(certificate_path, save_name);
901 if (ret != EMAIL_ERROR_NONE) {
902 testapp_print("Add certificate failed\n");
906 testapp_print("Add certificate success\n");
910 static gboolean testapp_test_get_certificate()
913 char save_name[20] = {0, };
914 email_certificate_t *certificate = NULL;
916 testapp_print("Input cert email-address : ");
917 if (0 >= scanf("%s", save_name))
918 testapp_print("Invalid input. ");
920 ret = email_get_certificate(save_name, &certificate);
921 if (ret != EMAIL_ERROR_NONE) {
922 testapp_print("Get certificate failed\n");
926 testapp_print("certificate_id : %d\n", certificate->certificate_id);
927 testapp_print("issue_year : %d\n", certificate->issue_year);
928 testapp_print("issue_month : %d\n", certificate->issue_month);
929 testapp_print("issue_day : %d\n", certificate->issue_day);
930 testapp_print("expiration_year : %d\n", certificate->expiration_year);
931 testapp_print("expiration_month : %d\n", certificate->expiration_month);
932 testapp_print("expiration_day : %d\n", certificate->expiration_day);
933 testapp_print("issue_organization_name : %s\n", certificate->issue_organization_name);
934 testapp_print("subject_string : %s\n", certificate->subject_str);
935 testapp_print("file path : %s\n", certificate->filepath);
938 email_free_certificate(&certificate, 1);
940 testapp_print("Get certificate success\n");
944 static gboolean testapp_test_delete_certificate()
947 char save_name[20] = {0, };
949 testapp_print("Input cert email-address : ");
950 if (0 >= scanf("%s", save_name))
951 testapp_print("Invalid input. ");
953 ret = email_delete_certificate(save_name);
954 if (ret != EMAIL_ERROR_NONE) {
955 testapp_print("Delete certificate failed\n");
959 testapp_print("Delete certificate success\n");
963 static gboolean testapp_test_add_account()
965 int err = EMAIL_ERROR_NONE;
966 email_account_t *account = NULL;
968 if(!testapp_create_account_object(&account)) {
969 testapp_print ("testapp_test_create_account_by_account_type error\n");
973 err = email_add_account(account);
975 testapp_print ("email_add_account error : %d\n", err);
976 err = email_free_account(&account, 1);
980 testapp_print ("email_add_account succeed. account_id\n", account->account_id);
982 err = email_free_account(&account, 1);
987 static gboolean testapp_test_update_peak_schedule()
990 email_account_t *account = NULL;
991 int err = EMAIL_ERROR_NONE;
993 testapp_print("\n>> Enter Account No: ");
994 if (0 >= scanf("%d",&account_id))
995 testapp_print("Invalid input. ");
997 if( (err = email_get_account(account_id, GET_FULL_DATA, &account)) != EMAIL_ERROR_NONE) {
998 testapp_print ("email_get_account failed [%d]\n", err);
1002 testapp_print ("old check_interval - %d \n", account->check_interval);
1004 testapp_print("\n Enter new check interval (in mins):");
1005 if (0 >= scanf("%d",&(account->check_interval)))
1006 testapp_print("Invalid input. ");
1008 testapp_print ("old peak_interval - %d \n", account->peak_interval);
1010 testapp_print("\n Enter new peak interval (in mins):");
1011 if (0 >= scanf("%d",&(account->peak_interval)))
1012 testapp_print("Invalid input. ");
1014 testapp_print ("old peak_days - %d \n", account->peak_days);
1016 testapp_print("\n Enter new peak days:");
1017 if (0 >= scanf("%d",&(account->peak_days)))
1018 testapp_print("Invalid input. ");
1020 testapp_print ("old peak_start_time - %d \n", account->peak_start_time);
1022 testapp_print("\n Enter new peak start time:");
1023 if (0 >= scanf("%d",&(account->peak_start_time)))
1024 testapp_print("Invalid input. ");
1026 testapp_print ("old peak_end_time - %d \n", account->peak_start_time);
1028 testapp_print("\n Enter new peak end time:");
1029 if (0 >= scanf("%d",&(account->peak_end_time)))
1030 testapp_print("Invalid input. ");
1033 if((err = email_update_account(account_id, account)) != EMAIL_ERROR_NONE) {
1034 testapp_print ("email_update_account failed [%d]\n", err);
1037 testapp_print ("email_update_account successful \n");
1042 static gboolean testapp_test_interpret_command (int selected_number)
1044 gboolean go_to_loop = TRUE;
1046 switch (selected_number) {
1048 testapp_test_add_account_with_validation();
1052 testapp_test_update_account();
1056 testapp_test_delete_account();
1060 testapp_test_get_account();
1064 testapp_test_get_account_list();
1068 testapp_test_update_check_interval();
1072 testapp_test_validate_account();
1076 testapp_test_cancel_validate_account();
1080 testapp_test_backup_account();
1084 testapp_test_restore_account();
1088 testapp_test_get_password_length_of_account();
1092 testapp_test_update_notification();
1096 testapp_test_clear_notification();
1100 testapp_test_clear_all_notification();
1104 testapp_test_save_default_account_id();
1108 testapp_test_load_default_account_id();
1112 testapp_test_add_certificate();
1116 testapp_test_get_certificate();
1120 testapp_test_delete_certificate();
1124 testapp_test_add_account();
1128 testapp_test_update_peak_schedule();
1142 void testapp_account_main ()
1144 gboolean go_to_loop = TRUE;
1145 int menu_number = 0;
1147 while (go_to_loop) {
1148 testapp_show_menu (EMAIL_ACCOUNT_MENU);
1149 testapp_show_prompt (EMAIL_ACCOUNT_MENU);
1151 if (0 >= scanf("%d", &menu_number))
1152 testapp_print("Invalid input");
1154 go_to_loop = testapp_test_interpret_command (menu_number);