8acecf83d6141763c3203d11de2c5f76c7e3924c
[framework/telephony/libslp-tapi.git] / wearable / test_src / menu.h
1 /*
2  * Telephony test application
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@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 #ifndef __MENU_H__
22 #define __MENU_H__
23
24 __BEGIN_DECLS
25
26 #define ANSI_COLOR_NORMAL               "\e[0m"
27
28 #define ANSI_COLOR_BLACK                "\e[0;30m"
29 #define ANSI_COLOR_RED                  "\e[0;31m"
30 #define ANSI_COLOR_GREEN                "\e[0;32m"
31 #define ANSI_COLOR_BROWN                "\e[0;33m"
32 #define ANSI_COLOR_BLUE                 "\e[0;34m"
33 #define ANSI_COLOR_MAGENTA              "\e[0;35m"
34 #define ANSI_COLOR_CYAN                 "\e[0;36m"
35 #define ANSI_COLOR_LIGHTGRAY    "\e[0;37m"
36
37 #define ANSI_COLOR_DARKGRAY             "\e[1;30m"
38 #define ANSI_COLOR_LIGHTRED             "\e[1;31m"
39 #define ANSI_COLOR_LIGHTGREEN   "\e[1;32m"
40 #define ANSI_COLOR_YELLOW               "\e[1;33m"
41 #define ANSI_COLOR_LIGHTBLUE    "\e[1;34m"
42 #define ANSI_COLOR_LIGHTMAGENTA "\e[1;35m"
43 #define ANSI_COLOR_LIGHTCYAN    "\e[1;36m"
44 #define ANSI_COLOR_WHITE                "\e[1;37m"
45
46
47 #define msg(fmt,args...)        { fprintf(stdout, fmt "\n", ##args); \
48                 fflush(stdout); }
49
50 #define msgn(fmt,args...)       { fprintf(stdout, fmt, ##args); \
51                 fflush(stdout); }
52
53 /* Bold (green) */
54 #define msgb(fmt,args...)  { fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
55                 ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); }
56
57 /* Property message */
58 #define msgp(fmt,args...)  { fprintf(stdout, ANSI_COLOR_LIGHTMAGENTA fmt \
59                 ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); }
60
61 #define msgt(n,fmt,args...)     { fprintf(stdout, "\e[%dC" fmt "\n", \
62                 3 + ((n) * 2), ##args); fflush(stdout); }
63
64 #define pmsg(fmt,args...)       { \
65         if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
66         fprintf(stdout, fmt "\n", ##args); fflush(stdout); }
67
68 #define pmsgb(fmt,args...)      { \
69         if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
70         fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
71                         ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); }
72
73 #define pmsgt(n,fmt,args...) { \
74         if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
75         fprintf(stdout, "\e[%dC" fmt "\n", \
76                         3 + ((n) * 2), ##args); fflush(stdout); }
77
78 #define MENU_DATA_SIZE 255
79
80 #if 0
81 /*
82  * Horizontal Line - width: 44
83  *                                      .12345678901234567890123456789012345678901234.
84  */
85 #define HR_SINGLE       "--------------------------------------------"
86 #define HR_DOUBLE       "============================================"
87 #define HR_SINGLE2      " ------------------------------------------ "
88 #endif
89
90 #if 0
91 /*
92  * Horizontal Line - width: 55
93  *                                      .12345678901234567890123456789012345678901234567890.
94  */
95 #define HR_SINGLE       "----------------------------------------" \
96                                         "---------------"
97 #define HR_DOUBLE       "========================================" \
98                                         "==============="
99 #define HR_SINGLE2      " ---------------------------------------" \
100                                         "-------------- "
101 #endif
102
103 /*
104  * Horizontal Line - width: 65
105  *                                      .12345678901234567890123456789012345678901234567890.
106  */
107 #define HR_SINGLE       "----------------------------------------" \
108                                         "-------------------------"
109 #define HR_DOUBLE       "========================================" \
110                                         "========================="
111 #define HR_SINGLE2      " ---------------------------------------" \
112                                         "------------------------ "
113
114 #define MAX_WIDTH       strlen (HR_SINGLE)
115 #define MAX_TITLE       ((MAX_WIDTH) - 10)
116 #define POS_MORE        ((MAX_WIDTH) - 3)
117
118 typedef struct menu_manager MManager;
119
120 struct menu_data {
121         char *key;
122         char *title;
123         struct menu_data *sub_menu;
124         int (*callback)(MManager *mm, struct menu_data *menu);
125         char *data;
126 };
127
128 MManager* menu_manager_new(struct menu_data items[], GMainLoop *mainloop);
129 int       menu_manager_run(MManager *mm);
130 int       menu_manager_set_user_data(MManager *mm, void *user_data);
131 void*     menu_manager_ref_user_data(MManager *mm);
132
133 gboolean  on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
134                 gpointer data);
135
136 pid_t     get_tid ();
137 void      hide_pid ();
138 void      show_pid ();
139 int       is_pid_show ();
140
141 __END_DECLS
142
143 #endif