Tizen 2.0 Release
[platform/core/messaging/email-service.git] / utilities / test-application / testapp-thread.c
1 /*
2 *  email-service
3 *
4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5 *
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
7
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
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
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.
19 *
20 */
21
22
23
24 /* common header */
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28
29
30 /* open header */
31 #include <glib.h>
32
33 #include "email-api-account.h"
34 #include "email-api-mail.h"
35
36 /* internal header */
37 #include "testapp-utility.h"
38 #include "testapp-thread.h"
39
40 static gboolean testapp_test_move_thread()
41 {
42         int thread_id, move_always_flag;
43         int target_mailbox_id;
44         int result;
45         int result_from_scanf = 0;
46
47         testapp_print("\n > Enter thread_id: ");
48         result_from_scanf = scanf("%d", &thread_id);
49
50         testapp_print("\n > Enter target_mailbox_id: ");
51         result_from_scanf = scanf("%d", &target_mailbox_id);
52
53         testapp_print("\n > Enter move_always_flag: ");
54         result_from_scanf = scanf("%d", &move_always_flag);
55         
56         result = email_move_thread_to_mailbox(thread_id, target_mailbox_id, move_always_flag);
57
58         return FALSE;
59 }
60
61 static gboolean testapp_test_delete_thread()
62 {
63         int thread_id, delete_always_flag;
64         int result;
65         int result_from_scanf = 0;
66
67         testapp_print("\n > Enter thread_id: ");
68         result_from_scanf = scanf("%d", &thread_id);
69
70         testapp_print("\n > Enter delete_always_flag: ");
71         result_from_scanf = scanf("%d", &delete_always_flag);
72
73         result = email_delete_thread(thread_id, delete_always_flag);
74
75         return FALSE;
76 }
77
78 static gboolean testapp_test_set_seen_flag_of_thread()
79 {
80         int thread_id, seen_flag, on_server;
81         int result;
82         int result_from_scanf = 0;
83
84         testapp_print("\n > Enter thread_id: ");
85         result_from_scanf = scanf("%d", &thread_id);
86
87         testapp_print("\n > Enter seen_flag: ");
88         result_from_scanf = scanf("%d", &seen_flag);
89
90         testapp_print("\n > Enter on_server: ");
91         result_from_scanf = scanf("%d", &on_server);
92
93         result = email_modify_seen_flag_of_thread(thread_id, seen_flag, on_server);
94
95         return FALSE;
96 }
97
98 static gboolean testapp_test_interpret_command (int menu_number)
99 {
100         gboolean go_to_loop = TRUE;
101
102         switch (menu_number) {
103                 case 1:
104                         testapp_test_move_thread();
105                         break;
106
107                 case 2:
108                         testapp_test_delete_thread();
109                         break;
110
111                 case 3:
112                         testapp_test_set_seen_flag_of_thread();
113                         break;
114
115                 case 0:
116                         go_to_loop = FALSE;
117                         break;
118                 default:
119                         break;
120         }
121
122         return go_to_loop;
123 }
124
125 void testapp_thread_main()
126 {
127         gboolean go_to_loop = TRUE;
128         int menu_number = 0;
129         int result_from_scanf = 0;
130
131         while (go_to_loop) {
132                 testapp_show_menu (EMAIL_THREAD_MENU);
133                 testapp_show_prompt (EMAIL_THREAD_MENU);
134
135                 result_from_scanf = scanf("%d", &menu_number);
136
137                 go_to_loop = testapp_test_interpret_command (menu_number);
138         }
139 }