upload tizen1.0 source
[framework/messaging/email-service.git] / utilities / test-application / testapp-thread.c
1 /*
2 *  email-service
3 *
4 * Copyright (c) 2000 - 2011 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         char target_mailbox_name[512];
44         int result;
45
46         testapp_print("\n > Enter thread_id: ");
47         scanf("%d", &thread_id);
48
49         testapp_print("\n > Enter target_mailbox_name: ");
50         scanf("%s", target_mailbox_name);
51
52         testapp_print("\n > Enter move_always_flag: ");
53         scanf("%d", &move_always_flag);
54         
55         result = email_move_thread_to_mailbox(thread_id, target_mailbox_name, move_always_flag);
56
57         return FALSE;
58 }
59
60 static gboolean testapp_test_delete_thread()
61 {
62         int thread_id, delete_always_flag;
63         int result;
64
65         testapp_print("\n > Enter thread_id: ");
66         scanf("%d", &thread_id);
67
68         testapp_print("\n > Enter delete_always_flag: ");
69         scanf("%d", &delete_always_flag);
70
71         result = email_delete_thread(thread_id, delete_always_flag);
72
73         return FALSE;
74 }
75
76 static gboolean testapp_test_set_seen_flag_of_thread()
77 {
78         int thread_id, seen_flag, on_server;
79         int result;
80
81         testapp_print("\n > Enter thread_id: ");
82         scanf("%d", &thread_id);
83
84         testapp_print("\n > Enter seen_flag: ");
85         scanf("%d", &seen_flag);
86
87         testapp_print("\n > Enter on_server: ");
88         scanf("%d", &on_server);
89
90         result = email_modify_seen_flag_of_thread(thread_id, seen_flag, on_server);
91
92         return FALSE;
93 }
94
95 static gboolean testapp_test_interpret_command (int menu_number)
96 {
97         gboolean go_to_loop = TRUE;
98
99         switch (menu_number) {
100                 case 1:
101                         testapp_test_move_thread();
102                         break;
103
104                 case 2:
105                         testapp_test_delete_thread();
106                         break;
107
108                 case 3:
109                         testapp_test_set_seen_flag_of_thread();
110                         break;
111
112                 case 0:
113                         go_to_loop = FALSE;
114                         break;
115                 default:
116                         break;
117         }
118
119         return go_to_loop;
120 }
121
122 void testapp_thread_main()
123 {
124         gboolean go_to_loop = TRUE;
125         int menu_number = 0;
126
127         while (go_to_loop) {
128                 testapp_show_menu (EMF_THREAD_MENU);
129                 testapp_show_prompt (EMF_THREAD_MENU);
130
131                 scanf ("%d", &menu_number);
132
133                 go_to_loop = testapp_test_interpret_command (menu_number);
134         }
135 }