apply FSL(Flora Software License)
[apps/home/call.git] / ui / vcui-application.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __VCUI_MAIN_H_
19 #define __VCUI_MAIN_H_
20
21 #include <contacts-svc.h>
22  
23 #include <dlog.h>
24
25 #include <glib.h>
26
27 #ifndef Eina_Bool
28 #include <stdbool.h>
29 #endif
30
31 #include <Evas.h>
32 #include <Edje.h>
33 #include <Eina.h>
34 #include <stdio.h>
35 #include <string.h>
36 #include <Elementary.h>
37 #include <Ecore_X.h>
38 #include <Ecore_X_Atoms.h>
39 #include <utilX.h>
40
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <arpa/inet.h>
44 #include <sys/time.h>
45 #include <sys/un.h>
46 #include <unistd.h>
47 #include <pthread.h>
48 #include <stdlib.h>
49 #include <sys/ioctl.h>
50
51 #include <aul.h>
52 #include "appcore-efl.h"
53
54 #include "vcui-doc-launch.h"
55 #include "voice-call-engine-msg.h"
56
57 #include "vcui-app-data.h"
58 #include "vcui-document.h"
59 #include "vcui-view-choice.h"
60 #include "vcui-engine-interface.h"
61 #include "vcui-view-common.h"
62 #include "vcui-view-elements.h"
63 #include "vcui-view-popup.h"
64
65 #include <vconf.h>
66
67 #include "ui-gadget.h"          /*for UG_INIT_EFL() & ug usage*/
68
69 #include "libintl.h"
70
71 #define DIALER_PKG              "org.tizen.phone"
72 #define CONTACTS_PKG    "org.tizen.contacts"
73
74 #if !defined(PACKAGE)
75 #  define PACKAGE "voice-call-ui"
76 #endif
77
78 #if !defined(LOCALEDIR)
79 #  define LOCALEDIR "/opt/apps/org.tizen.call/res/locale"
80 #endif
81
82 #if !defined(EDJDIR)
83 #  define EDJDIR "/opt/apps/org.tizen.call/res/edje"
84 #endif
85
86 #if !defined(IMGDIR)
87 #  define IMGDIR "/opt/apps/org.tizen.call/res/images"
88 #endif
89
90 #if !defined(MEDIADIR)
91 #  define MEDIADIR "/opt/apps/org.tizen.call/res/media"
92 #endif
93
94 #if !defined(ICONDIR)
95 #  define ICONDIR "/opt/apps/org.tizen.call/res/icons/default/small"
96 #endif
97
98 #define EDJ_NAME EDJDIR"/voice-call-ui.edj"
99 #define CALL_THEME EDJDIR"/call_theme.edj"
100
101 #define GRP_MTVIEW "mt-view"
102 #define GRP_MOVIEW "mo-view"
103 #define GRP_INCALL "incall"
104 #define GRP_MTLOCK "mtlock"
105 #define GRP_KEYPAD "keypad"
106 #define GRP_MULTICALL_SPLIT "multicall-split"
107 #define GRP_MULTICALL_SPLIT2 "multicall-split2"
108 #define GRP_MULTICALL_CONF "multicall-conf"
109 #define GRP_MULTICALL "multicall-list"
110 #define GRP_UG_EFFECT "ug_effect"
111 #define GRP_END_SINGLECALL "end-singlecall"
112 #define GRP_END_CONFCALL "end-confcall"
113  
114 #define GRP_LOCK_ACCEPT "lock_accept"
115 #define GRP_LOCK_REJECT "lock_reject"
116
117 #define QP_NOIMG_ICON   IMGDIR"/vc_qp_caller_ID.png"
118 #define QP_CONF_ICON    IMGDIR"/vc_qp_caller_ID_group.png"
119 #define NOIMG_ICON IMGDIR"/vc_normal_caller_ID.png"
120 #define CONF_ICON IMGDIR"/vc_normal_caller_ID_group.png"
121 #define PRIVATE_ICON IMGDIR"/vc_conference_private.png"
122 #define HOLD_ICON IMGDIR"/vc_icon_hold.png"
123 #define UNHOLD_ICON IMGDIR"/vc_icon_unhold.png"
124 #define KEYPAD_ICON IMGDIR"/vc_keypad_icon.png"
125 #define CONTACT_ICON IMGDIR"/vc_contact_icon.png"
126 #define ADDCALL_ICON IMGDIR"/vc_add_icon.png"
127 #define JOIN_ICON IMGDIR"/vc_join_icon.png"
128 #define SPEAKER_ICON IMGDIR"/vc_speaker_icon.png"
129 #define MUTE_ICON IMGDIR"/vc_mute_icon.png"
130 #define PLAY_ICON IMGDIR"/vc_icon_play.png"
131 #define PAUSE_ICON IMGDIR"/vc_icon_pause.png"
132 #define MORE_ICON IMGDIR"/vc_btn_more.png"
133 #define CONF_CALL_END_ICON IMGDIR"/vc_icon_conf_call_end.png"
134 #define CALLING_NAME_BG_IMAGE IMGDIR"/vc_calling_name_BG_image.png"
135
136 #define HOLD_DISABLED_ICON IMGDIR"/vc_icon_hold_dim.png"
137 #define UNHOLD_DISABLED_ICON IMGDIR"/vc_icon_unhold_dim.png"
138 #define KEYPAD_DISABLED_ICON IMGDIR"/vc_keypad_icon_dim.png"
139 #define CONTACT_DISABLED_ICON IMGDIR"/vc_contact_icon_dim.png"
140 #define ADDCALL_DISABLED_ICON IMGDIR"/vc_add_icon_dim.png"
141 #define JOIN_DISABLED_ICON IMGDIR"/vc_join_icon_dim.png"
142 #define SPEAKER_DISABLED_ICON IMGDIR"/vc_speaker_icon_dim.png"
143 #define MUTE_DISABLED_ICON IMGDIR"/vc_mute_icon_dim.png"
144 #define CONF_LIST_HOLD_ICON IMGDIR"/vc_icon_conf_list_hold.png"
145 #define CONF_LIST_UNHOLD_ICON IMGDIR"/vc_icon_conf_list_unhold.png"
146
147 #define VOLUME_ICON IMGDIR"/vc_volume_icon.png"
148 #define VOLUME_MUTE_ICON IMGDIR"/vc_volume_mute_icon.png"
149
150 #define NVAI_CONTROL_OTHER_ICON IMGDIR"/vc_reject_with_msg_header_icon_others.png"
151
152 #define MINI_CONTROLLER_WIDTH (480)
153 #define MINI_CONTROLLER_HEIGHT (42)
154
155 #define DEF_BUF_LEN (128)
156 #define DEF_BUF_LEN_LONG (256)
157
158 #define VAL_VOL_UP (1)
159 #define VAL_VOL_DOWN (0)
160
161 #define RINGTONE_MIN (0)
162 #define RINGTONE_MAX (15)
163 #define VOICE_VOL_MIN (1)
164 #define VOICE_VOL_MAX (7)       /* It must change to 6 later.. */
165 #define BT_VOL_MIN (1)
166 #define BT_VOL_MAX (15)
167
168 #define RINGTONE_LONGPRESS_MUTE_TIMEOUT                 0.7
169 #define VOLUME_KEY_LONG_PRESS_TIMEOUT                   0.1
170
171 #define POPUP_TIMEOUT_SHORT             (2.0)
172 #define POPUP_TIMEOUT_NORMAL            (3.0)
173 #define POPUP_TIMEOUT_LONG              (5.0)
174 #define POPUP_TIMEOUT_VERY_LONG (10.0)
175
176 #define TIMER_TIMEOUT_0_1_SEC   (0.1)
177 #define TIMER_TIMEOUT_0_3_SEC   (0.3)
178 #define TIMER_TIMEOUT_0_5_SEC   (0.5)
179 #define TIMER_TIMEOUT_1_SEC     (1.0)
180 #define TIMER_TIMEOUT_2_SEC     (2.0)
181 #define TIMER_TIMEOUT_4_SEC     (4.0)
182
183 #define BLUR_VALUE                              30
184 #define IMG_TYPE_FULL                   1
185 #define IMG_TYPE_WALLPAPER              2
186 #define IMG_TYPE_BLUR                   3
187
188 #define BG_DEFAULT_PATH         "/opt/media/Images and videos/Wallpapers/Home_default.png"
189
190 #ifndef EINA_TRUE
191 #define EINA_TRUE       1
192 #endif
193
194 #ifndef EINA_FALSE
195 #define EINA_FALSE      0
196 #endif
197
198 #ifdef CALL_DEBUG_ON_DLOG
199 #define CALL_UI_DEBUG(frmt, args...)  do { LOG(LOG_DEBUG, TAG_CALL, "[vcui] [%s:%d] "frmt"\n",  __func__, __LINE__, ##args); } while (0)
200 #define CALL_UI_KPI(frmt, args...)  do { LOG(LOG_DEBUG, TAG_CALL_LAUNCH, "[VC_KPI] [%s:%d] "frmt"\n",  __func__, __LINE__, ##args); } while (0)
201 #else
202 #define CALL_UI_DEBUG(args...)
203 #endif
204
205 #ifndef retv_if
206 #define retv_if(expr, val) do { \
207                 if (expr) { \
208                         CALL_UI_DEBUG("(%s) -> %s() return", #expr, __FUNCTION__); \
209                         return (val); \
210                 } \
211         } while (0)
212 #endif
213
214 #ifndef retvm_if
215 #define retvm_if(expr, val, fmt, arg...) do { \
216                 if (expr) { \
217                         CALL_UI_DEBUG(fmt, ##arg); \
218                         CALL_UI_DEBUG("(%s) -> %s() return", #expr, __FUNCTION__); \
219                         return (val); \
220                 } \
221         } while (0)
222 #endif
223
224 #ifndef VCUI_RETURN_IF_FAIL
225 #define VCUI_RETURN_IF_FAIL(check_condition)    \
226                         if (!(check_condition)) return;
227 #endif
228
229 #ifndef VCUI_RETURN_FALSE_IF_FAIL
230 #define VCUI_RETURN_FALSE_IF_FAIL(check_condition)      \
231                         if (!(check_condition)) return EINA_FALSE;
232 #endif
233
234 #ifndef VCUI_RETURN_VALUE_IF_FAIL
235 #define VCUI_RETURN_VALUE_IF_FAIL(check_condition, value)       \
236                         if (!(check_condition)) return value;
237 #endif
238
239 #ifndef VCUI_RETURN_NULL_IF_FAIL
240 #define VCUI_RETURN_NULL_IF_FAIL(check_condition)       \
241                         if (!(check_condition)) return NULL;
242 #endif
243
244 #ifndef VCUI_RETURN_ZERO_IF_FAIL
245 #define VCUI_RETURN_ZERO_IF_FAIL(check_condition)       \
246                         if (!(check_condition)) return 0;
247 #endif
248
249 #ifndef VCUI_RETURN_INVALID_IF_FAIL
250 #define VCUI_RETURN_INVALID_IF_FAIL(check_condition)    \
251                         if (!(check_condition)) return -1;
252 #endif
253
254 #ifndef VCUI_RETURN_VALUE_IF_NOT_IN_RANGE
255 #define VCUI_RETURN_VALUE_IF_NOT_IN_RANGE(value, min_value, max_value, ret_val) \
256                         if ((value < min_value) || (value > max_value)) return ret_val;
257 #endif
258
259 #ifndef _EDJ
260 #define _EDJ(obj) elm_layout_edje_get(obj)
261 #endif
262
263 #define _EVAS_OBJ_DEL(obj)      if (obj) \
264         { \
265                 evas_object_del(obj); \
266                 obj = NULL; \
267         }
268
269 struct text_part {
270         char *part;
271         char *msgid;
272 };
273
274 typedef enum _voice_call_bg_type_t {
275         BG_HIDE,
276         BG_SHOW
277 } voice_call_bg_type_t;
278
279 typedef enum {
280         CALL_END_TYPE_NONE = -1,
281         CALL_END_TYPE_SINGLE_CALL,
282         CALL_END_TYPE_CONF_CALL,
283 } voice_call_end_type_t;
284
285 /************************************************************************************/
286 void _create_main_ui_set_flag();
287 void _create_main_ui_real();
288 void _vcui_show_main_ui_set_flag();
289 void __vcui_hide_main_ui_set_flag();
290
291 void _vcui_determine_background_show_hide();
292
293 void _vcui_cache_flush();
294 vcui_app_call_data_t *_vcui_get_app_data();
295 int _vcui_is_idle_lock();
296
297 gboolean _vcui_is_gcf_mode(void);
298 gboolean _vcui_is_headset_conected(void);
299 gboolean _vcui_is_headset_switch_on(void);
300 gboolean _vcui_is_answering_mode_on(void);
301 gboolean _vcui_is_powerkey_mode_on(void);
302 gboolean _vcui_is_phonelock_status(void);
303
304 void _vcui_add_calllog(int type, call_data_t *data, int boutgoing_end);
305
306 void _vcui_response_volume(int vol_alert_type, int vol_level);
307 void _vcui_set_volume(int key_status);
308
309 void _vcui_raise_main_win();
310 int _vcui_check_valid_eo(Evas_Object *eo, char *v_name);
311
312 unsigned long _vcui_get_diff_now(time_t start_time);
313
314 char *_vcui_get_endcause_string(int end_cause, char *data);
315
316 Evas_Object *_vcui_load_edj(Evas_Object *parent, const char *file, const char *group);
317
318 #endif                          /* __VCUI_MAIN_H_ */