Make TIZEN 2.0
[apps/home/call.git] / ui / src / include / 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_APPLICATION_H_
19 #define _VCUI_APPLICATION_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-app-data.h"
55 #include "vcui-doc-launch.h"
56 #include "voice-call-engine-msg.h"
57
58 #include "vcui-document.h"
59 #include "vcui-view-choice.h"
60 #include "vcui-view-common.h"
61 #include "vcui-view-elements.h"
62 #include "vcui-view-popup.h"
63
64 #include <vconf.h>
65
66 #include "libintl.h"
67
68 #define DIALER_PKG              "org.tizen.phone"
69 #define CONTACTS_PKG    "org.tizen.contacts"
70
71 #if !defined(PACKAGE)
72 #  define PACKAGE "voice-call-ui"
73 #endif
74
75 #if !defined(LOCALEDIR)
76 #  define LOCALEDIR "/opt/apps/org.tizen.call/res/locale"
77 #endif
78
79 #if !defined(EDJDIR)
80 #  define EDJDIR "/opt/apps/org.tizen.call/res/edje"
81 #endif
82
83 #if !defined(IMGDIR)
84 #  define IMGDIR "/opt/apps/org.tizen.call/res/images"
85 #endif
86
87 #if !defined(MEDIADIR)
88 #  define MEDIADIR "/opt/apps/org.tizen.call/res/media"
89 #endif
90
91 #if !defined(ICONDIR)
92 #  define ICONDIR "/opt/apps/org.tizen.call/res/icons/default/small"
93 #endif
94
95 #define EDJ_NAME EDJDIR"/voice-call-ui.edj"
96 #define CALL_THEME EDJDIR"/call_theme.edj"
97
98 #define GRP_MTVIEW "mt-view"
99 #define GRP_MOVIEW "mo-view"
100 #define GRP_INCALL "incall"
101 #define GRP_MTLOCK "mtlock"
102 #define GRP_KEYPAD "keypad"
103 #define GRP_MULTICALL_SPLIT "multicall-split"
104 #define GRP_MULTICALL_SPLIT2 "multicall-split2"
105 #define GRP_MULTICALL_CONF "multicall-conf"
106 #define GRP_MULTICALL "multicall-list"
107 #define GRP_REJECT_MSG "reject_with_msg"
108 #define GRP_UG_EFFECT "ug_effect"
109 #define GRP_END_SINGLECALL "end-singlecall"
110 #define GRP_END_CONFCALL "end-confcall"
111 #define GRP_QUICKPANEL "quickpanel"
112 #define GRP_QUICKPANEL_LSCAPE "quickpanel-lscape"
113 #define GRP_SEPARATOR_LAYOUT "separator-layout"
114 #define GRP_SEPARATOR_LAYOUT_3BUTTON "separator-layout-3button"
115 #define GRP_BUTTON_LAYOUT "button-layout"
116 #define GRP_CALLER_INFO "caller-info"
117 #define GRP_KEYPAD_SEP_LAYOUT "keypad-separator"
118 #define GRP_ALERTS_LAYOUT "sns-alerts-layout"
119
120 #define GRP_LOCK_ACCEPT "lock_accept"
121 #define GRP_LOCK_REJECT "lock_reject"
122 #define GRP_LOCK_REJECT_WITH_MSG "lock_reject_with_msg"
123
124 #define QP_NOIMG_ICON   IMGDIR"/vc_qp_caller_ID.png"
125 #define QP_CONF_ICON    IMGDIR"/vc_qp_caller_ID_group.png"
126 #define QP_CALL_ICON    ICONDIR"/org.tizen.call.png"
127 #define NOIMG_ICON IMGDIR"/vc_normal_caller_ID.png"
128 #define CONF_ICON IMGDIR"/vc_normal_caller_ID_group.png"
129 #define PRIVATE_ICON IMGDIR"/vc_conference_private.png"
130 #define CALLER_ID_DEFAULT IMGDIR"/vc_caller_ID_default.png"
131
132 #define KEYPAD_ICON IMGDIR"/vc_keypad_icon.png"
133 #define CONTACT_ICON IMGDIR"/vc_contact_icon.png"
134 #define ADDCALL_ICON IMGDIR"/vc_add_icon.png"
135 #define JOIN_ICON IMGDIR"/vc_join_icon.png"
136 #define END_CALL_ICON IMGDIR"/vc_end_call_icon.png"
137 #define SPEAKER_ICON IMGDIR"/vc_speaker_icon.png"
138 #define MUTE_ICON IMGDIR"/vc_mute_icon.png"
139 #define CONF_CALL_END_ICON IMGDIR"/vc_icon_conf_call_end.png"
140 #define CALLING_NAME_BG_IMAGE IMGDIR"/vc_calling_name_BG_image.png"
141 #define BDAY_ICON IMGDIR"/vc_birthday_icon.png"
142 #define MO_NOCALLER_ID_ICON IMGDIR"/vc_outgoingcall_No_caller_ID.png"
143 #define CALLER_INFO_ICON IMGDIR"/vc_caller_info_icon.png"
144 #define NOIMG_SPLIT_ICON IMGDIR"/vc_caller_ID_split.png"
145 #define CONF_SPLIT_ICON IMGDIR"/vc_caller_ID_split_group.png"
146
147 #define SPEAKER_PRESS_ICON IMGDIR"/vc_speaker_on_icon.png"
148 #define MUTE_PRESS_ICON IMGDIR"/vc_mute_on_icon.png"
149
150 #define KEYPAD_DISABLED_ICON IMGDIR"/vc_keypad_icon_dim.png"
151 #define CONTACT_DISABLED_ICON IMGDIR"/vc_contact_icon_dim.png"
152 #define ADDCALL_DISABLED_ICON IMGDIR"/vc_add_icon_dim.png"
153 #define JOIN_DISABLED_ICON IMGDIR"/vc_join_icon_dim.png"
154 #define END_CALL_DISABLED_ICON IMGDIR"/vc_end_call_icon_dim.png"
155 #define SPEAKER_DISABLED_ICON IMGDIR"/vc_speaker_icon_dim.png"
156 #define MUTE_DISABLED_ICON IMGDIR"/vc_mute_icon_dim.png"
157 #define SHARE_DISABLED_ICON IMGDIR"/vc_rcs_share_icon_dim.png"
158
159 #define HOLD_ICON IMGDIR"/vc_icon_hold_call.png"
160 #define UNHOLD_ICON IMGDIR"/vc_icon_unhold_call.png"
161 #define SWAP_ICON IMGDIR"/vc_icon_swap_call.png"
162
163 #define VOLUME_ICON IMGDIR"/vc_volume_icon.png"
164 #define VOLUME_MUTE_ICON IMGDIR"/vc_volume_mute_icon.png"
165
166 #define VOICE_CALL_ICON IMGDIR"/vc_voice_call_icon.png"
167 #define VIDEO_CALL_ICON IMGDIR"/vc_video_call_icon.png"
168 #define MESSAGE_ICON IMGDIR"/vc_msg_icon.png"
169
170 #define REJ_MSG_BACK_ICON IMGDIR"/vc_reject_back_icon.png"
171 #define REJ_MSG_CREATE_ICON IMGDIR"/vc_reject_create_icon.png"
172
173 #define CALL_BG_IMG IMGDIR"/vc_call_bg_img.png"
174 #define CALL_NOT_SAVED_BG_IMG IMGDIR"/vc_call_not_saved_bg_img.png"
175
176 #define MORE_MANAGE_CONF_ICON IMGDIR"/vc_more_manage_conf.png"
177 #define MORE_ADD_CALL_ICON IMGDIR"/vc_more_add_call.png"
178 #define MORE_JOIN_ICON IMGDIR"/vc_more_join.png"
179 #define MORE_CONTACTS_ICON IMGDIR"/vc_more_contacts.png"
180
181 #define QP_MUTE_ICON IMGDIR"/vc_qp_mute_on.png"
182
183 #define NOTIFY_MISSED_CALL_ICON IMGDIR"/vc_notify_missed_call.png"
184 #define NOTIFY_SUB_MISSED_CALL_ICON IMGDIR"/vc_notify_sub_missed_call.png"
185
186 #define MINI_CONTROLLER_WIDTH (480)
187 #define MINI_CONTROLLER_HEIGHT (42)
188
189 #define MAIN_WIN_HD_W 720
190 #define MAIN_WIN_HD_H 1280
191 #define MAIN_WIN_WVGA_W 480
192 #define MAIN_WIN_WVGA_H 800
193
194 #define QUICKPANEL_WIDTH        (720)
195 #define LSCAPE_QUICKPANEL_WIDTH (1280)
196 #define QUICKPANEL_HEIGHT       (170)
197
198 #define MORE_MENU_CTXPOPUP_X 660
199 #define MORE_MENU_CTXPOPUP_Y 175
200
201 #define DEF_BUF_LEN (128)
202 #define DEF_BUF_LEN_LONG (256)
203
204 #define VAL_VOL_UP (1)
205 #define VAL_VOL_DOWN (0)
206
207 #define RINGTONE_MIN (0)
208 #define RINGTONE_MAX (15)
209 #define VOICE_VOL_MIN (1)
210 #define VOICE_VOL_MAX (7)       /* It must change to 6 later.. */
211 #define BT_VOL_MIN (1)
212 #define BT_VOL_MAX (15)
213
214 #define RINGTONE_LONGPRESS_MUTE_TIMEOUT                 0.7
215 #define VOLUME_KEY_LONG_PRESS_TIMEOUT                   0.1
216
217 #define POPUP_TIMEOUT_SHORT             (2.0)
218 #define POPUP_TIMEOUT_NORMAL            (3.0)
219 #define POPUP_TIMEOUT_LONG              (5.0)
220 #define POPUP_TIMEOUT_VERY_LONG (10.0)
221
222 #define TIMER_TIMEOUT_0_1_SEC   (0.1)
223 #define TIMER_TIMEOUT_0_3_SEC   (0.3)
224 #define TIMER_TIMEOUT_0_5_SEC   (0.5)
225 #define TIMER_TIMEOUT_1_SEC     (1.0)
226 #define TIMER_TIMEOUT_2_SEC     (2.0)
227 #define TIMER_TIMEOUT_4_SEC     (4.0)
228
229 #define BLUR_VALUE                              30
230 #define IMG_TYPE_FULL                   1
231 #define IMG_TYPE_WALLPAPER              2
232 #define IMG_TYPE_BLUR                   3
233
234 #define BG_DEFAULT_PATH         "/opt/media/Images and videos/Wallpapers/Home_default.png"
235
236 #ifndef EINA_TRUE
237 #define EINA_TRUE       1
238 #endif
239
240 #ifndef EINA_FALSE
241 #define EINA_FALSE      0
242 #endif
243
244 #ifdef CALL_DEBUG_ON_DLOG
245 #define CALL_UI_DEBUG(frmt, args...)  do { LOG(LOG_DEBUG, TAG_CALL, "[vcui] [%s:%d] "frmt"\n",  __func__, __LINE__, ##args); } while (0)
246 #define CALL_UI_KPI(frmt, args...)  do { LOG(LOG_DEBUG, TAG_CALL_LAUNCH, "[VC_KPI] [%s:%d] "frmt"\n",  __func__, __LINE__, ##args); } while (0)
247 #else
248 #define CALL_UI_DEBUG(args...)
249 #endif
250
251 #ifndef retv_if
252 #define retv_if(expr, val) do { \
253                 if (expr) { \
254                         CALL_UI_DEBUG("(%s) -> %s() return", #expr, __FUNCTION__); \
255                         return (val); \
256                 } \
257         } while (0)
258 #endif
259
260 #ifndef retvm_if
261 #define retvm_if(expr, val, fmt, arg...) do { \
262                 if (expr) { \
263                         CALL_UI_DEBUG(fmt, ##arg); \
264                         CALL_UI_DEBUG("(%s) -> %s() return", #expr, __FUNCTION__); \
265                         return (val); \
266                 } \
267         } while (0)
268 #endif
269
270 #ifndef VCUI_RETURN_IF_FAIL
271 #define VCUI_RETURN_IF_FAIL(check_condition)    \
272                         if (!(check_condition)) return;
273 #endif
274
275 #ifndef VCUI_RETURN_FALSE_IF_FAIL
276 #define VCUI_RETURN_FALSE_IF_FAIL(check_condition)      \
277                         if (!(check_condition)) return EINA_FALSE;
278 #endif
279
280 #ifndef VCUI_RETURN_VALUE_IF_FAIL
281 #define VCUI_RETURN_VALUE_IF_FAIL(check_condition, value)       \
282                         if (!(check_condition)) return value;
283 #endif
284
285 #ifndef VCUI_RETURN_NULL_IF_FAIL
286 #define VCUI_RETURN_NULL_IF_FAIL(check_condition)       \
287                         if (!(check_condition)) return NULL;
288 #endif
289
290 #ifndef VCUI_RETURN_ZERO_IF_FAIL
291 #define VCUI_RETURN_ZERO_IF_FAIL(check_condition)       \
292                         if (!(check_condition)) return 0;
293 #endif
294
295 #ifndef VCUI_RETURN_INVALID_IF_FAIL
296 #define VCUI_RETURN_INVALID_IF_FAIL(check_condition)    \
297                         if (!(check_condition)) return -1;
298 #endif
299
300 #ifndef VCUI_RETURN_VALUE_IF_NOT_IN_RANGE
301 #define VCUI_RETURN_VALUE_IF_NOT_IN_RANGE(value, min_value, max_value, ret_val) \
302                         if ((value < min_value) || (value > max_value)) return ret_val;
303 #endif
304
305 #ifndef _EDJ
306 #define _EDJ(obj) elm_layout_edje_get(obj)
307 #endif
308
309 #define _EVAS_OBJ_DEL(obj)      if (obj) \
310         { \
311                 evas_object_del(obj); \
312                 obj = NULL; \
313         }
314
315 struct text_part {
316         char *part;
317         char *msgid;
318 };
319
320 typedef enum _voice_call_bg_type_t {
321         BG_HIDE,
322         BG_SHOW
323 } voice_call_bg_type_t;
324
325 typedef enum {
326         CALL_END_TYPE_NONE = -1,
327         CALL_END_TYPE_SINGLE_CALL,
328         CALL_END_TYPE_CONF_CALL,
329 } voice_call_end_type_t;
330
331 void _create_main_ui_set_flag();
332 void _create_main_ui_real();
333 void _vcui_show_main_ui_set_flag();
334 void __vcui_hide_main_ui_set_flag();
335
336 void _vcui_determine_background_show_hide();
337
338 void _vcui_cache_flush();
339 vcui_app_call_data_t *_vcui_get_app_data();
340 int _vcui_is_idle_lock();
341
342 gboolean _vcui_is_gcf_mode(void);
343 gboolean _vcui_is_headset_conected(void);
344 gboolean _vcui_is_headset_switch_on(void);
345 gboolean _vcui_is_answering_mode_on(void);
346 gboolean _vcui_is_powerkey_mode_on(void);
347 gboolean _vcui_is_phonelock_status(void);
348
349 void _vcui_add_calllog(int type, call_data_t *data, int boutgoing_end);
350
351 void _vcui_response_volume(int vol_alert_type, int vol_level);
352 void _vcui_set_volume(int key_status);
353
354 void _vcui_raise_main_win();
355 int _vcui_check_valid_eo(Evas_Object *eo, char *v_name);
356
357 unsigned long _vcui_get_diff_now(time_t start_time);
358
359 char *_vcui_get_endcause_string(int end_cause, char *data);
360
361 Evas_Object *_vcui_load_edj(Evas_Object *parent, const char *file, const char *group);
362
363 #endif                          /* _VCUI_APPLICATION_H_ */