3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 #define COMPONENT_TAG APP
23 #define LOG_TAG "OMA_DM_CLIENT"
25 #include <sync_agent.h>
27 #define SMASUNG_SERVER "RSate"
28 #define SESSION_ID "11111"
30 GMainLoop *g_mainloop;
31 gchar g_policy_type[256];
32 static int selected_ui_num = -1;
34 static gboolean _process_cmd_input(GIOChannel * gio, GIOCondition condition, gpointer data);
35 static void _select_ui_input();
37 static void _print_admin_ui_test();
38 static void _print_alert_ui_test();
39 static void _print_cp_ui_test();
40 static void _print_fota_ui_test();
41 static void _print_noti_ui_test();
42 static void _print_reg_ui_test();
43 static void _printf_dmacc_control_ui_test();
45 /* Admin wrapping test api */
46 static gboolean __test_admin_get_fumo_config();
47 static gboolean __test_admin_set_fumo_config();
48 static gboolean __test_admin_get_profile();
49 static gboolean __test_admin_set_profile();
50 static gboolean __test_admin_reset_profile();
51 static gboolean __test_admin_user_initiate();
53 /* Alert wrapping test api */
54 /*static gboolean __test_alert_display();*/
55 static gboolean __test_alert_confirmation();
56 static gboolean __test_alert_inputtext();
57 static gboolean __test_alert_single_choice();
58 static gboolean __test_alert_multiple_choice();
60 /* CP wrapping test api */
61 static gboolean __test_cp_check_pin_code();
63 /* Fota wrapping test api */
64 static gboolean __test_fota_software_update();
65 static gboolean __test_fota_cancel();
66 static gboolean __test_fota_download();
67 static gboolean __test_fota_install();
68 static gboolean __test_fota_set_interval();
70 /* Noti wrapping test api */
71 static gboolean __test_noti_software_update();
72 static gboolean __test_noti_cancel();
73 static gboolean __test_noti_download();
74 static gboolean __test_noti_install();
75 static gboolean __test_noti_set_interval();
77 /* Registration wrapping test api */
78 static gboolean __test_reg_account_registration();
80 /* Add/Remove Dmacc */
81 static gboolean __test_add_dmacc();
82 static gboolean __test_remove_dmacc();
84 static gboolean _process_cmd_input(GIOChannel * gio, GIOCondition condition, gpointer data)
94 /* Reads data from a GIOChannel. */
95 GIOError status = g_io_channel_read(gio, buf, 256, &read);
96 retvm_if(status != G_IO_ERROR_NONE, FALSE, "Error reading:");
97 _DEBUG_TRACE("read data : %s (size : %d)", buf, read);
101 /* Removes leading and trailing whitespace from a string. */
104 _DEBUG_TRACE("user input cmd is %s", buf);
108 _DEBUG_TRACE("exiting...");
109 g_main_loop_quit(g_mainloop);
111 switch (selected_ui_num) {
112 _DEBUG_TRACE("buf[0] : %c", buf[0]);
113 case 1: /* Admin UI */
116 gboolean test_result = FALSE;
119 test_result = __test_admin_get_fumo_config();
120 printf("Admin UI - get fumo config : result = %s\n\n", test_result ? "success" : "fail");
125 test_result = __test_admin_set_fumo_config();
126 printf("Admin UI - set fumo config : result = %s\n\n", test_result ? "success" : "fail");
131 test_result = __test_admin_get_profile();
132 printf("Admin UI - get profile : result = %s\n\n", test_result ? "success" : "fail");
137 test_result = __test_admin_set_profile();
138 printf("Admin UI - set profile : result = %s\n\n", test_result ? "success" : "fail");
143 test_result = __test_admin_reset_profile();
144 printf("Admin UI - reset profile : result = %s\n\n", test_result ? "success" : "fail");
149 test_result = __test_admin_user_initiate();
150 printf("Admin UI - user initiate : result = %s\n\n", test_result ? "success" : "fail");
154 _DEBUG_TRACE("Admin UI - Wrong Choice: enter your choice again...");
159 _print_admin_ui_test();
162 case 2: /* Alert UI */
165 gboolean test_result = FALSE;
168 /*test_result = __test_alert_display(); */
169 /*do not push event */
170 printf("Alert UI - display : result = success");
183 test_result = __test_alert_confirmation();
184 printf("Alert UI - confirmation : result = %s\n\n", test_result ? "success" : "fail");
189 test_result = __test_alert_inputtext();
190 printf("Alert UI - input text : result = %s\n\n", test_result ? "success" : "fail");
195 test_result = __test_alert_single_choice();
196 printf("Alert UI - single choice : result = %s\n\n", test_result ? "success" : "fail");
201 test_result = __test_alert_multiple_choice();
202 printf("Alert UI - multiple choice : result = %s\n\n", test_result ? "success" : "fail");
206 _DEBUG_TRACE("Alert UI - Wrong Choice: enter your choice again...");
211 _print_alert_ui_test();
217 gboolean test_result = FALSE;
220 test_result = __test_cp_check_pin_code();
221 printf("CP UI - check pin code : result = %s\n\n", test_result ? "success" : "fail");
225 _DEBUG_TRACE("CP UI - Wrong Choice: enter your choice again...");
233 case 4: /* Fota UI */
236 gboolean test_result = FALSE;
239 test_result = __test_fota_software_update();
240 printf("Fota UI - software update : result = %s\n\n", test_result ? "success" : "fail");
245 test_result = __test_fota_cancel();
246 printf("Fota UI - cancel : result = %s\n\n", test_result ? "success" : "fail");
251 test_result = __test_fota_download();
252 printf("Fota UI - download : result = %s\n\n", test_result ? "success" : "fail");
257 test_result = __test_fota_install();
258 printf("Fota UI - install : result = %s\n\n", test_result ? "success" : "fail");
263 test_result = __test_fota_set_interval();
264 printf("Fota UI - set interval : result = %s\n\n", test_result ? "success" : "fail");
268 _DEBUG_TRACE("Fota UI - Wrong Choice: enter your choice again...");
273 _print_fota_ui_test();
276 case 5: /* Noti UI */
279 gboolean test_result = FALSE;
282 test_result = __test_noti_software_update();
283 printf("Noti UI - software update : result = %s\n\n", test_result ? "success" : "fail");
288 test_result = __test_noti_cancel();
289 printf("Noti UI - cancel : result = %s\n\n", test_result ? "success" : "fail");
294 test_result = __test_noti_download();
295 printf("Noti UI - download : result = %s\n\n", test_result ? "success" : "fail");
300 test_result = __test_noti_install();
301 printf("Noti UI - install : result = %s\n\n", test_result ? "success" : "fail");
306 test_result = __test_noti_set_interval();
307 printf("Noti UI - set interval : result = %s\n\n", test_result ? "success" : "fail");
311 _DEBUG_TRACE("Noti UI - Wrong Choice: enter your choice again...");
316 _print_noti_ui_test();
319 case 6: /* Registration UI */
322 gboolean test_result = FALSE;
325 test_result = __test_reg_account_registration();
326 printf("Registration UI - account registration : result = %s\n\n", test_result ? "success" : "fail");
330 _DEBUG_TRACE("Registration UI - Wrong Choice: enter your choice again...");
335 _print_reg_ui_test();
340 gboolean test_result = FALSE;
343 test_result = __test_add_dmacc();
344 printf("DMACC CONTROL UI - add dm acc : result = %s\n\n", test_result ? "success" : "fail");
349 test_result = __test_remove_dmacc();
353 printf("DMACC CONTROL UI - remove dm acc : result = %s\n\n", test_result ? "success" : "fail");
358 _printf_dmacc_control_ui_test();
371 static void _select_ui_input()
375 printf(" ####### oma dm client test ##########\n");
376 printf("select UI\n");
377 printf(" Press '0': to exit\n");
378 printf(" Press '1': Admin UI\n");
379 printf(" Press '2': Alert UI\n");
380 printf(" Press '3': CP UI\n");
381 printf(" Press '4': Fota UI\n");
382 printf(" Press '5': Noti UI\n");
383 printf(" Press '6': Registration UI\n");
384 printf(" Press '7': Dmacc control UI\n");
385 printf(" Enter your choice : ");
387 scanf("%d", &selected_ui_num);
388 _DEBUG_TRACE("selected ui : %d", selected_ui_num);
390 if (selected_ui_num == 0) {
391 _DEBUG_TRACE("Exit !!");
398 static void _print_admin_ui_test()
402 printf(" ####### Admin UI Test ##########\n");
403 printf(" Press '0': to exit\n");
404 printf(" Press '1': get fumo config\n");
405 printf(" Press '2': set fumo config\n");
406 printf(" Press '3': get profile\n");
407 printf(" Press '4': set profile\n");
408 printf(" Press '5': reset profile\n");
409 printf(" Press '6': user initiate\n");
410 printf(" Enter your choice : ");
417 static void _print_alert_ui_test()
421 printf(" ####### Alert UI Test ##########\n");
422 printf(" Press '0': to exit\n");
423 printf(" Press '1': display\n");
424 printf(" Press '2': confirmation\n");
425 printf(" Press '3': input text\n");
426 printf(" Press '4': single choice\n");
427 printf(" Press '5': multiple choice\n");
428 printf(" Enter your choice : ");
435 static void _print_cp_ui_test()
439 printf(" ####### CP UI Test ##########\n");
440 printf(" Press '0': to exit\n");
441 printf(" Press '1': check pin code\n");
442 printf(" Enter your choice : ");
449 static void _print_fota_ui_test()
453 printf(" ####### Fota UI Test ##########\n");
454 printf(" Press '0': to exit\n");
455 printf(" Press '1': software update\n");
456 printf(" Press '2': cancel\n");
457 printf(" Press '3': download\n");
458 printf(" Press '4': install\n");
459 printf(" Press '5': set interval\n");
460 printf(" Enter your choice : ");
467 static void _print_noti_ui_test()
471 printf(" ####### Noti UI Test ##########\n");
472 printf(" Press '0': to exit\n");
473 printf(" Press '1': software update\n");
474 printf(" Press '2': cancel\n");
475 printf(" Press '3': download\n");
476 printf(" Press '4': install\n");
477 printf(" Press '5': set interval\n");
478 printf(" Enter your choice : ");
485 static void _print_reg_ui_test()
489 printf(" ####### Registration UI Test ##########\n");
490 printf(" Press '0': to exit\n");
491 printf(" Press '1': account registration\n");
492 printf(" Enter your choice : ");
499 static void _printf_dmacc_control_ui_test()
503 printf(" ####### Dmacc Control UI Test ##########\n");
504 printf(" Press '0': to exit\n");
505 printf(" Press '1': add dm acc(fota)\n");
506 printf(" Press '2': remove dm acc(fota)\n");
507 printf(" Enter your choice : ");
514 /* Admin wrapping test api */
515 static gboolean __test_admin_get_fumo_config()
519 gboolean is_test_successful = TRUE;
520 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
523 result = sync_agent_dm_admin_get_fumo_config(&wifi_only);
524 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
525 _DEBUG_VERBOSE("sync_agent_admin_get_fumo_config() failed !!");
526 is_test_successful = FALSE;
528 _DEBUG_VERBOSE("sync_agent_admin_get_fumo_config() success !!");
529 is_test_successful = TRUE;
534 return is_test_successful;
537 static gboolean __test_admin_set_fumo_config()
541 gboolean is_test_successful = TRUE;
542 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
544 int wifi_only = 0; /* FIXME */
546 result = sync_agent_dm_admin_set_fumo_config(wifi_only);
547 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
548 _DEBUG_VERBOSE("sync_agent_admin_set_fumo_config() failed !!");
549 is_test_successful = FALSE;
551 _DEBUG_VERBOSE("sync_agent_admin_set_fumo_config() success !!");
552 is_test_successful = TRUE;
557 return is_test_successful;
560 static gboolean __test_admin_get_profile()
564 gboolean is_test_successful = TRUE;
565 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
567 int profile_type = UI_GCF_TYPE; /* FIXME */
568 sync_agent_dm_setting_data_s *setting_data = (sync_agent_dm_setting_data_s *) calloc(1, sizeof(sync_agent_dm_setting_data_s));
569 if (setting_data == NULL) {
570 _DEBUG_ERROR("calloc failed !!");
574 result = sync_agent_dm_admin_get_profile(profile_type, &setting_data);
575 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
576 _DEBUG_VERBOSE("sync_agent_admin_get_profile() failed !!");
577 is_test_successful = FALSE;
579 _DEBUG_VERBOSE("sync_agent_admin_get_profile() success !!");
580 is_test_successful = TRUE;
584 if (setting_data != NULL) {
585 if (setting_data->profile_name != NULL)
586 g_free(setting_data->profile_name);
587 if (setting_data->imei != NULL)
588 g_free(setting_data->imei);
589 if (setting_data->server_url != NULL)
590 g_free(setting_data->server_url);
591 if (setting_data->server_pwd != NULL)
592 g_free(setting_data->server_pwd);
593 if (setting_data->client_id != NULL)
594 g_free(setting_data->client_id);
595 if (setting_data->client_pwd != NULL)
596 g_free(setting_data->client_pwd);
597 if (setting_data->client_auth_type != NULL)
598 g_free(setting_data->client_auth_type);
599 if (setting_data->server_auth_type != NULL)
600 g_free(setting_data->server_auth_type);
602 g_free(setting_data);
607 return is_test_successful;
610 static gboolean __test_admin_set_profile()
614 gboolean is_test_successful = TRUE;
615 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
617 int profile_type = UI_GCF_TYPE; /* FIXME */
618 sync_agent_dm_setting_data_s *setting_data = (sync_agent_dm_setting_data_s *) calloc(1, sizeof(sync_agent_dm_setting_data_s));
619 if (setting_data == NULL) {
620 _DEBUG_ERROR("calloc failed !!");
626 setting_data->server_url = strdup("https://XXX");
627 setting_data->server_id = strdup("XXX");
628 setting_data->server_pwd = strdup("XXX==");
629 setting_data->client_id = strdup("IMEI:XXX");
630 setting_data->client_pwd = strdup("XXX");
631 setting_data->client_auth_type = strdup("DIGEST");
632 setting_data->server_auth_type = strdup("DIGEST");
635 // setting_data->server_url = strdup("https://XXX");
636 // setting_data->server_id = strdup("XXX");
637 // setting_data->server_pwd = strdup("XXX==");
638 // setting_data->client_id = strdup("IMEI:XXX");
639 // setting_data->client_pwd = strdup("XXX");
640 // setting_data->client_auth_type = strdup("DIGEST");
641 // setting_data->server_auth_type = strdup("DIGEST");
644 // setting_data->server_url = strdup("http://XXX");
645 // setting_data->server_id = strdup("XXX");
646 // setting_data->server_pwd = strdup("XXX");
647 // setting_data->client_id = strdup("XXX");
648 // setting_data->client_pwd = strdup("XXX");
649 // setting_data->client_auth_type = strdup("DIGEST");
650 // setting_data->server_auth_type = strdup("DIGEST");
652 result = sync_agent_dm_admin_set_profile(profile_type, setting_data);
653 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
654 _DEBUG_VERBOSE("sync_agent_admin_set_profile() failed !!");
655 is_test_successful = FALSE;
657 _DEBUG_VERBOSE("sync_agent_admin_set_profile() success !!");
658 is_test_successful = TRUE;
662 if (setting_data != NULL) {
663 if (setting_data->server_url != NULL)
664 g_free(setting_data->server_url);
665 if (setting_data->server_id != NULL)
666 g_free(setting_data->server_id);
667 if (setting_data->server_pwd != NULL)
668 g_free(setting_data->server_pwd);
669 if (setting_data->client_id != NULL)
670 g_free(setting_data->client_id);
671 if (setting_data->client_pwd != NULL)
672 g_free(setting_data->client_pwd);
673 if (setting_data->client_auth_type != NULL)
674 g_free(setting_data->client_auth_type);
675 if (setting_data->server_auth_type != NULL)
676 g_free(setting_data->server_auth_type);
678 g_free(setting_data);
683 return is_test_successful;
686 static gboolean __test_admin_reset_profile()
690 gboolean is_test_successful = TRUE;
691 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
693 int profile_type = UI_GCF_TYPE; /* FIXME */
695 result = sync_agent_dm_admin_reset_profile(profile_type);
696 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
697 _DEBUG_VERBOSE("sync_agent_admin_reset_profile() failed !!");
698 is_test_successful = FALSE;
700 _DEBUG_VERBOSE("sync_agent_admin_reset_profile() success !!");
701 is_test_successful = TRUE;
706 return is_test_successful;
709 static gboolean __test_admin_user_initiate()
713 gboolean is_test_successful = TRUE;
714 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
716 sync_agent_dm_service_server_type_e server_type = UI_GCF_TYPE;
718 result = sync_agent_dm_admin_user_initiate(server_type);
719 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
720 _DEBUG_VERBOSE("sync_agent_admin_reset_profile() failed !!");
721 is_test_successful = FALSE;
723 _DEBUG_VERBOSE("sync_agent_admin_reset_profile() success !!");
724 is_test_successful = TRUE;
729 return is_test_successful;
732 /* Alert wrapping test api *//*
733 static gboolean __test_alert_display()
737 gboolean is_test_successful = TRUE;
738 sync_agent_dm_error_e result = SYNC_AGENT_DM_FAIL;
740 int response_type = UI_RESPONSE_TYPE_OK; FIXME
742 result = sync_agent_alert_display(response_type);
743 if (result != SYNC_AGENT_DM_SUCCESS) {
744 _DEBUG_VERBOSE("sync_agent_alert_display() failed !!");
745 is_test_successful = FALSE;
747 _DEBUG_VERBOSE("sync_agent_alert_display() success !!");
748 is_test_successful = TRUE;
753 return is_test_successful;
756 static gboolean __test_alert_confirmation()
760 gboolean is_test_successful = TRUE;
761 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
763 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
765 result = sync_agent_dm_alert_confirmation(response_type);
766 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
767 _DEBUG_VERBOSE("sync_agent_alert_confirmation() failed !!");
768 is_test_successful = FALSE;
770 _DEBUG_VERBOSE("sync_agent_alert_confirmation() success !!");
771 is_test_successful = TRUE;
776 return is_test_successful;
779 static gboolean __test_alert_inputtext()
783 gboolean is_test_successful = TRUE;
784 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
786 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
787 char *input_text = strdup("alert input text"); /* FIXME */
789 result = sync_agent_dm_alert_inputtext(response_type, input_text);
790 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
791 _DEBUG_VERBOSE("sync_agent_alert_inputtext() failed !!");
792 is_test_successful = FALSE;
794 _DEBUG_VERBOSE("sync_agent_alert_inputtext() success !!");
795 is_test_successful = TRUE;
799 if (input_text != NULL)
804 return is_test_successful;
807 static gboolean __test_alert_single_choice()
811 gboolean is_test_successful = TRUE;
812 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
814 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
815 int selected_count = 1;
816 char *selected_number = strdup("1"); /* FIXME */
818 result = sync_agent_dm_alert_single_choice(response_type, selected_count, selected_number);
819 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
820 _DEBUG_VERBOSE("sync_agent_alert_single_choice() failed !!");
821 is_test_successful = FALSE;
823 _DEBUG_VERBOSE("sync_agent_alert_single_choice() success !!");
824 is_test_successful = TRUE;
828 if (selected_number != NULL)
829 g_free(selected_number);
833 return is_test_successful;
836 static gboolean __test_alert_multiple_choice()
840 gboolean is_test_successful = TRUE;
841 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
843 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
844 GList *selected_list = NULL;
846 /* FIXME - add selected number */
847 selected_list = g_list_append(selected_list, strdup("1"));
848 selected_list = g_list_append(selected_list, strdup("2"));
849 selected_list = g_list_append(selected_list, strdup("3"));
851 result = sync_agent_dm_alert_multiple_choice(response_type, selected_list);
852 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
853 _DEBUG_VERBOSE("sync_agent_alert_multiple_choice() failed !!");
854 is_test_successful = FALSE;
856 _DEBUG_VERBOSE("sync_agent_alert_multiple_choice() success !!");
857 is_test_successful = TRUE;
861 if (selected_list != NULL) {
864 for (iter = selected_list; iter != NULL;) {
865 data = (char *)(iter->data);
866 iter = g_list_next(iter);
867 selected_list = g_list_remove(selected_list, data);
869 g_free((char *)data);
872 g_list_free(selected_list);
877 return is_test_successful;
880 /* CP wrapping test api */
881 static gboolean __test_cp_check_pin_code()
885 gboolean is_test_successful = TRUE;
886 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
888 int ext_id = 1; /* FIXME */
889 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME - RESPONSE_TYPE_CANCEL => ext_id : -1 / pin_code : NULL */
890 char *pin_code = "1234"; /* FIXME */
892 int user_pin_val = 0; //fail
894 result = sync_agent_dm_cp_check_pin_code(ext_id, response_type, pin_code, &user_pin_val);
895 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
896 _DEBUG_VERBOSE("sync_agent_cp_check_pin_code() failed !!");
898 _DEBUG_VERBOSE("user pin valiation : %d", user_pin_val);
900 is_test_successful = FALSE;
902 _DEBUG_VERBOSE("sync_agent_cp_check_pin_code() success !!");
904 _DEBUG_VERBOSE("user pin valiation : %d", user_pin_val);
906 is_test_successful = TRUE;
911 return is_test_successful;
914 /* Fota wrapping test api */
915 static gboolean __test_fota_software_update()
919 gboolean is_test_successful = TRUE;
920 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
922 sync_agent_dm_service_server_type_e server_type = UI_SAMSUNG_FUMO_TYPE; /* FIXME */
924 result = sync_agent_dm_fota_software_update(server_type);
925 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
926 _DEBUG_VERBOSE("sync_agent_fota_software_update() failed !!");
927 is_test_successful = FALSE;
929 _DEBUG_VERBOSE("sync_agent_fota_software_update() success !!");
930 is_test_successful = TRUE;
935 return is_test_successful;
938 static gboolean __test_fota_cancel()
942 gboolean is_test_successful = TRUE;
943 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
945 result = sync_agent_dm_fota_cancel();
946 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
947 _DEBUG_VERBOSE("sync_agent_fota_cancel() failed !!");
948 is_test_successful = FALSE;
950 _DEBUG_VERBOSE("sync_agent_fota_cancel() success !!");
951 is_test_successful = TRUE;
956 return is_test_successful;
959 static gboolean __test_fota_download()
963 gboolean is_test_successful = TRUE;
964 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
966 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
968 result = sync_agent_dm_fota_download(response_type);
969 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
970 _DEBUG_VERBOSE("sync_agent_fota_download() failed !!");
971 is_test_successful = FALSE;
973 _DEBUG_VERBOSE("sync_agent_fota_download() success !!");
974 is_test_successful = TRUE;
979 return is_test_successful;
982 static gboolean __test_fota_install()
986 gboolean is_test_successful = TRUE;
987 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
989 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
991 result = sync_agent_dm_fota_install(response_type);
992 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
993 _DEBUG_VERBOSE("sync_agent_fota_install() failed !!");
994 is_test_successful = FALSE;
996 _DEBUG_VERBOSE("sync_agent_fota_install() success !!");
997 is_test_successful = TRUE;
1002 return is_test_successful;
1005 static gboolean __test_fota_set_interval()
1009 gboolean is_test_successful = TRUE;
1010 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1012 int interval_type = UI_RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR; /* FIXME */
1014 result = sync_agent_dm_fota_set_interval(interval_type);
1015 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1016 _DEBUG_VERBOSE("sync_agent_fota_set_interval() failed !!");
1017 is_test_successful = FALSE;
1019 _DEBUG_VERBOSE("sync_agent_fota_set_interval() success !!");
1020 is_test_successful = TRUE;
1025 return is_test_successful;
1028 /* Noti wrapping test api */
1029 static gboolean __test_noti_software_update()
1033 gboolean is_test_successful = TRUE;
1034 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1036 result = sync_agent_dm_fota_update_noti(SMASUNG_SERVER, SESSION_ID);
1037 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1038 _DEBUG_VERBOSE("sync_agent_push_software_update() failed !!");
1039 is_test_successful = FALSE;
1041 _DEBUG_VERBOSE("sync_agent_push_software_update() success !!");
1042 is_test_successful = TRUE;
1047 return is_test_successful;
1050 static gboolean __test_noti_cancel()
1054 gboolean is_test_successful = TRUE;
1055 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1057 result = sync_agent_dm_fota_cancel_noti();
1058 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1059 _DEBUG_VERBOSE("sync_agent_push_cancel() failed !!");
1060 is_test_successful = FALSE;
1062 _DEBUG_VERBOSE("sync_agent_push_cancel() success !!");
1063 is_test_successful = TRUE;
1068 return is_test_successful;
1071 static gboolean __test_noti_download()
1075 gboolean is_test_successful = TRUE;
1076 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1078 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
1080 result = sync_agent_dm_fota_download_noti(response_type);
1081 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1082 _DEBUG_VERBOSE("sync_agent_push_download() failed !!");
1083 is_test_successful = FALSE;
1085 _DEBUG_VERBOSE("sync_agent_push_download() success !!");
1086 is_test_successful = TRUE;
1091 return is_test_successful;
1094 static gboolean __test_noti_install()
1098 gboolean is_test_successful = TRUE;
1099 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1101 int response_type = UI_RESPONSE_TYPE_OK; /* FIXME */
1103 result = sync_agent_dm_fota_install_noti(response_type);
1104 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1105 _DEBUG_VERBOSE("sync_agent_push_install() failed !!");
1106 is_test_successful = FALSE;
1108 _DEBUG_VERBOSE("sync_agent_push_install() success !!");
1109 is_test_successful = TRUE;
1114 return is_test_successful;
1117 static gboolean __test_noti_set_interval()
1121 gboolean is_test_successful = TRUE;
1122 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1124 int interval_type = UI_RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR; /* FIXME */
1126 result = sync_agent_dm_fota_set_interval_noti(interval_type);
1127 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1128 _DEBUG_VERBOSE("sync_agent_push_set_interval() failed !!");
1129 is_test_successful = FALSE;
1131 _DEBUG_VERBOSE("sync_agent_push_set_interval() success !!");
1132 is_test_successful = TRUE;
1137 return is_test_successful;
1140 /* Registration wrapping test api */
1141 static gboolean __test_reg_account_registration()
1145 gboolean is_test_successful = TRUE;
1146 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1148 result = sync_agent_dm_reg_account_registration();
1149 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1150 _DEBUG_VERBOSE("sync_agent_reg_account_registration() failed !!");
1151 is_test_successful = FALSE;
1153 _DEBUG_VERBOSE("sync_agent_reg_account_registration() success !!");
1154 is_test_successful = TRUE;
1159 return is_test_successful;
1162 static gboolean __test_add_dmacc()
1166 gboolean is_test_successful = TRUE;
1167 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1168 sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
1170 result = sync_agent_dm_add_dmacc(dmacc_type);
1171 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1172 _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() failed !!");
1173 is_test_successful = FALSE;
1175 _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() success !!");
1176 is_test_successful = TRUE;
1181 return is_test_successful;
1184 static gboolean __test_remove_dmacc()
1188 gboolean is_test_successful = TRUE;
1189 sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
1190 sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
1192 result = sync_agent_dm_remove_dmacc(dmacc_type);
1193 if (result != UI_SYNC_AGENT_DM_SUCCESS) {
1194 _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() failed !!");
1195 is_test_successful = FALSE;
1197 _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() success !!");
1198 is_test_successful = TRUE;
1203 return is_test_successful;
1206 int main(int argc, char *argv[])
1210 GIOChannel *stdin_channel = NULL;
1213 // signal(SIGPIPE, _pipe_handler);
1215 sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
1219 switch (selected_ui_num) {
1221 dm_err = sync_agent_dm_admin_init();
1224 dm_err = sync_agent_dm_alert_init();
1227 dm_err = sync_agent_dm_cp_init();
1230 dm_err = sync_agent_dm_fota_init();
1233 dm_err = sync_agent_dm_push_init();
1236 dm_err = sync_agent_dm_reg_init();
1239 dm_err = sync_agent_dm_dmacc_init();
1245 if (dm_err != UI_SYNC_AGENT_DM_SUCCESS) {
1246 _DEBUG_ERROR("dm ui init failed !!");
1250 /* Creates a new GIOChannel from std input */
1251 stdin_channel = g_io_channel_unix_new(0);
1252 retvm_if(stdin_channel == NULL, -1, "Error creating new GIOChannel!");
1254 /* Adds the GIOChannel into the default main loop context with the default priority. */
1255 result = g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) _process_cmd_input, NULL);
1256 retvm_if(result == 0, -1, "Error creating watch!");
1259 switch (selected_ui_num) {
1261 _print_admin_ui_test();
1264 _print_alert_ui_test();
1267 _print_cp_ui_test();
1270 _print_fota_ui_test();
1273 _print_noti_ui_test();
1276 _print_reg_ui_test();
1279 _printf_dmacc_control_ui_test();
1285 // wait for policy receiver callback rest
1286 g_mainloop = g_main_loop_new(NULL, FALSE);
1287 g_main_loop_run(g_mainloop);
1289 // reaches here when g_main_loop_quit is called
1290 switch (selected_ui_num) {
1292 dm_err = sync_agent_dm_admin_deinit();
1295 dm_err = sync_agent_dm_alert_deinit();
1298 dm_err = sync_agent_dm_cp_deinit();
1301 dm_err = sync_agent_dm_fota_deinit();
1304 dm_err = sync_agent_dm_push_deinit();
1307 dm_err = sync_agent_dm_reg_deinit();
1310 dm_err = sync_agent_dm_dmacc_deinit();
1315 if (dm_err != UI_SYNC_AGENT_DM_SUCCESS) {
1316 _DEBUG_ERROR("dm ui deinit failed !!");