4104614ceb4ecb3b3036dd367aed53ea5991327a
[apps/core/preloaded/message-app.git] / viewer / include / msg-ui-viewer-play-view.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://floralicense.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 #ifndef __MSG_UI_VIEWER_PLAY_VIEW_H__
18 #define __MSG_UI_VIEWER_PLAY_VIEW_H__
19 /*==================================================================================================
20  *                                                                      INCLUDE HEADERS
21  *==================================================================================================*/
22 #include <msg.h>
23
24 #include "msg-smil-player-interface.h"
25 #include "msg-ui-viewer-types.h"
26
27 #include <Ecore_X.h>
28 #include <Ecore.h>
29 #include <Elementary.h>
30 #include <ui-gadget-module.h>
31
32 /*==================================================================================================
33  *                                                                      DEFINITIONS
34  *==================================================================================================*/
35 #define VIEWER_BUFFER_SIZE_64 64
36 #define VIEWER_TITLE_MENU_GENLIST_MAX_ITEM 3
37 #define VIEWER_TITLE_MENU_LINE_HEIGHT 129
38 #define VIEWER_ATTACH_GL_ITEM_HEIGHT 112
39 #define VIEWER_TITLE_FONT_LEN 100
40 #define VIEWER_NAVI_FRAME_HEIGHT 98
41 #define VIEWER_NAVIFRAME_BOTTOM_H 114
42
43
44 #define VIEWER_PLAY_CONTROLLER_LIFETIME (3.0)
45 #define VIEWER_PLAY_CONTROLLER_PROGRESSBAR_TIME (1.0)
46 #define VIEWER_PLAY_CONTROLLER_HEIGHT 218
47
48 #define VIEWER_VOLUMEBAR_LIFETIME (3.0)
49 #define VIEWER_VOLUME_KEY_FONT_LONG_PRESS_TIME (0.3)
50 #define VIEWER_VOLUME_KEY_VOLUME_LONG_PRESS_TIME (0.1)
51
52 #define VIEWER_DETAILS_TEXT_SPACE " "
53 #define VIEWER_DETAILS_TEXT_LEFT_BRACE "("
54 #define VIEWER_DETAILS_TEXT_RIGHT_BRACE ")"
55 #define VIEWER_DETAILS_TEXT_MSG_SIZE_KB 1024
56
57 #define MSG_VIEWER_EDJ EDJDIR"/msg_viewer.edj"
58 /*==================================================================================================
59  *                                                                              ENUMERATIONS
60  *==================================================================================================*/
61 typedef enum {
62         MSG_VIEWER_PLAY = 0,
63         MSG_VIEWER_PAUSE,
64         MSG_VIEWER_STOP,
65         MSG_VIEWER_CLOSE,
66         MSG_VIEWER_UNKOWN,
67 } MSG_VIEWER_PLAY_STATUS_E;
68
69 typedef enum {
70         MSG_VIEWER_ACTION_NONE = 0,
71         MSG_VIEWER_ACTION_TOOLBAR_PLAY,         /* action tapping play button in play toolbar */
72         MSG_VIEWER_ACTION_TOOLBAR_PAUSE,        /* action tapping pause button in play toolbar */
73         MSG_VIEWER_ACTION_AUTO_PLAY,            /* action auto play by related UX flow */
74         MSG_VIEWER_ACTION_AUTO_PAUSE,           /* action auto pause by related UX flow */
75 } MSG_VIEWER_ACTION_TYPE_E;
76
77 typedef enum {
78         MSG_VIEWER_DEFAULT_MODE = 0,
79         MSG_VIEWER_LOAD_CONTACT_UG,                     /* launching CONTACT UG */
80         MSG_VIEWER_LOAD_COMPOSER_UG,            /* launching COMPOSER UG */
81         MSG_VIEWER_HIDED_BY_OTHER_WINDOW,       /* launch other application like email/call/vcall/browser */
82 } MSG_VIEWER_MODE_E;
83
84 typedef enum {
85         MSG_VIEWER_FILE_SAVE_SUCCESS = 0,
86         MSG_VIEWER_FILE_SAVE_FAILED,
87         MSG_VIEWER_FILE_SAVE_INVALID_ERROR,
88 } MSG_VIEWER_FILE_SAVE_STATUS_E;
89
90 typedef enum {
91         MSG_VIEWER_POPUP_NONE = 0,
92         MSG_VIEWER_NORMAL_POPUP,
93         MSG_VIEWER_DELETE_POPUP,
94         MSG_VIEWER_ATTACHMENTS_POPUP,
95         MSG_VIEWER_DETAILS_POPUP,
96         MSG_VIEWER_MENU_CTX_POPUP,
97         MSG_VIEWER_CUTLINK_POPUP,
98         MSG_VIEWER_TITLE_MENU_POPUP,
99         MSG_VIEWER_BLOCK_POPOP,
100 } MSG_VIEWER_POPUP_TYPE_E;
101
102 typedef enum {
103         MSG_VIEWER_MEDIA_INVALID = 0,
104         MSG_VIEWER_MEDIA_IMG,
105         MSG_VIEWER_MEDIA_AUDIO,
106         MSG_VIEWER_MEDIA_VIDEO,
107         MSG_VIEWER_MEDIA_TEXT,
108         MSG_VIEWER_MEDIA_ANIMATE,
109         MSG_VIEWER_MEDIA_IMG_OR_VIDEO,
110         MSG_VIEWER_MEDIA_ATTACH,
111         MSG_VIEWER_MEDIA_DRM,
112 } MSG_VIEWER_MEDIA_TYPE_E;
113
114 typedef enum {
115         MSG_VIEWER_OPTION_CONTACT = 0,
116         MSG_VIEWER_OPTION_BLOCK,
117 } MSG_VIEWER_OPTION_CHANGE_TYPE_E;
118
119 typedef enum {
120         MSG_VIEWER_FONT_SIZE_NONE,
121         MSG_VIEWER_ACCESSIBILITY_FONT_SIZE,
122         MSG_VIEWER_MSG_FONT_SIZE
123 } MSG_VIEWER_FONT_SIZE_TYPE_E;
124
125 typedef enum {
126         MSG_VIEWER_FONT_CHANGE_LOAD_SETTING,
127         MSG_VIEWER_FONT_CHANGE_LATEST_UPDATE,
128 } MSG_VIEWER_FONT_CHANGE_TYPE_E;
129
130 typedef enum {
131         MSG_VIEWER_ENTRY_NORMAL_TEXT,
132         MSG_VIEWER_ENTRY_HELP_TEXT,
133 } MSG_VIEWER_ENTRY_TYPE_E;
134
135 typedef enum {
136         MSG_VIEWER_VOLUME_EVENT_DRAG_START,
137         MSG_VIEWER_VOLUME_EVENT_DRAG_STOP,
138 } MSG_VIEWER_VOLUME_BAR_EVENT_E;
139
140 typedef void (*MSG_VIEWER_VOLUMEBAR_CB)(void *user_data, Evas_Object *obj, MSG_VIEWER_VOLUME_BAR_EVENT_E event);
141 /*==================================================================================================
142  *                                                                              STRUCTURES
143  *==================================================================================================*/
144 typedef struct _MSG_VIEWER_ADDR_INFO_S{
145         int contact_id;
146         char address[MAX_ADDRESS_VAL_LEN+1];
147         char name[MAX_DISPLAY_NAME_LEN+1];
148 } MSG_VIEWER_ADDR_INFO;
149
150 typedef struct _MSG_VIEWER_ADDR_LIST_S{
151         int addr_cnt;
152         MSG_VIEWER_ADDR_INFO addr_info[MAX_TO_ADDRESS_CNT];
153 } MSG_VIEWER_ADDR_LIST;
154
155 typedef struct _MSG_PLAY_DATA_S {
156         struct ug_cbs cbs;
157         void *viewer_main;
158         Evas_Object *main_window;
159         Evas_Object *navi_frame;
160         Evas_Object *navi_title_layout;         /* navi title area layout */
161         Evas_Object *title_button;                              /* navi title button */
162         Evas_Object *attach_button;                             /* attachment button */
163         Evas_Object *more_btn;                          /* control toolbar */
164         Evas_Object *title_box_layout;                  /* title box layout for genlist */
165         Evas_Object *play_layout;                               /* play viewer main layout */
166         Evas_Object *subject_index_layout;      /* subject / page index */
167         Evas_Object *play_controller;                   /* play controller */
168         Evas_Object *progressbar;                               /* progressbar of play controller */
169         Evas_Object *volumebar;                         /* volumebar */
170         Evas_Object *volume_slider;             /* volumebar_slider */
171
172         Evas_Object *help_page_gl;                      /* help page genlist */
173         Evas_Object *save_attachment_gl;                /* save attachments genlist(controlbar menu) */
174         Evas_Object *render_entry;                      /* entry handle of SMIL render */
175
176         Evas_Object *save_button;                       /* save attachment's popup button */
177         Evas_Object *sa_check;                          /* select all check object in save attachment popup */
178         Eina_Bool isSelectAll;                                  /* check if save attachments select all mode is enable */
179
180         Elm_Object_Item *navi_item;                     /* naviframe item */
181
182         Evas_Object *popup;                                     /*simple popup*/
183         MSG_VIEWER_POPUP_TYPE_E popup_type;
184         SMIL_SLIDE_CLIENT_CB_PARAM_S *smil_eventStatus;
185
186         int m_x;
187         int m_y;
188         int window_width;
189         int window_height;
190
191         Ecore_Event_Handler *mouse_down_event_handler;
192         Ecore_Event_Handler *mouse_up_event_handler;
193
194         msg_handle_t msgHandle; /*ipc handler between viewer and MF*/
195         msg_struct_t msg_t;
196         msg_struct_t mms_t;
197         int     msgID;
198         void *SmilHandle;
199         MSG_VIEWER_PLAY_STATUS_E status;
200         MSG_VIEWER_PLAY_STATUS_E previous_status;
201         MSG_VIEWER_MODE_E mode;
202         int font_size;
203
204         Ecore_Idler *del_idler;
205         Ecore_Timer *play_controller_timer;
206         Ecore_Timer *play_controller_progressbar_timer;
207         Ecore_Timer *volumebar_timer;
208
209         MSG_VIEWER_VOLUMEBAR_CB volumebar_event_cb;
210
211         int ctrl_start_x;               /* play controller mouse pointer */
212         int ctrl_start_y;               /* play controller mouse pointer */
213         int ctrl_end_x;                 /* play controller mouse pointer */
214         int ctrl_end_y;                 /* play controller mouse pointer */
215
216         int insert_count;       /*inserted contents count, except text file*/
217         int attach_count;       /*attached contents count*/
218
219         Eina_List *insert_list; /*inserted content list */
220         Eina_List *attach_list; /*attached contents list */
221
222         bool title_menu_opened; /* check if title button option is opened*/
223         bool playcontroller_opened;             /*check play controller is shown or not */
224         bool auto_resume_state;         /* check state of auto resume availablity */
225         bool msg_box_viewer;    /* TRUE is viewer is launched from message box */
226         bool drag_volume_slider; /* check do not navigate multiple page when volume bar is displayed */
227
228         int totalProgressTime;          /* total progress time for all slide*/
229         int elapsedProgressTime;                /*progress time from 1st slide to current slide*/
230
231         Elm_Genlist_Item_Class itc_title_single;        /* title button single recipient item */
232         Elm_Genlist_Item_Class itc_title;       /* title button multi recipient item */
233         Elm_Genlist_Item_Class hp_sa_class;     /* help page attach list save all item */
234         Elm_Genlist_Item_Class hp_class;        /* help page attach list item */
235         Elm_Genlist_Item_Class attach_sa_class; /*attachments select all item */
236         Elm_Genlist_Item_Class attach_item_class;       /*attachments each item */
237
238         Elm_Theme *title_th;    /* title theme */
239         Elm_Theme *progress_th;         /* progressbar theme*/
240
241         /* for use volume key setting */
242         Ecore_Event_Handler *volkey_release_handler;
243         Ecore_Event_Handler *volkey_press_handler;
244         Ecore_Event_Handler *focus_in;
245         Ecore_Event_Handler *focus_out;
246
247         Ecore_Timer *vol_up_key_longpress;
248         Ecore_Timer *vol_down_key_longpress;
249
250         Ecore_X_Display *xdisplay;
251 } MSG_PLAY_DATA_S;
252
253 typedef struct {
254         char pfile_name[MSG_VIEWER_FILENAME_MAX_LEN + 1];
255         char pfile_path[MSG_VIEWER_FILEPATH_MAX_LEN + 1];
256         int pfile_size;
257         bool isSaveAll;                 /* for select all item */
258         Eina_Bool isChecked;            /* check object status of save attachment genlist */
259         Evas_Object *check_item;        /* check object for save attachments genlist */
260         MSG_VIEWER_MEDIA_TYPE_E media_type;
261         MSG_PLAY_DATA_S *viewer_play_data;
262 } MSG_VIEWER_ATTACH_MEDIA_INFO_S;
263 /*==================================================================================================
264  *                                                                      FUNCTION DECLARATIONS
265  *==================================================================================================*/
266 MSG_BOOL msg_ui_viewer_create_player_view(MSG_PLAY_DATA_S *data);
267
268 /*
269  *@fn           msg_ui_viewer_show_player_view(MSG_PLAY_DATA_S *data);
270  *@brief                This function is used to show player view again when player view is already ready.
271  * @param[in] data MSG_PLAY_DATA_S structure
272  * @return      return TRUE if player view is playing, else FALSE
273  */
274 MSG_BOOL msg_ui_viewer_show_player_view(MSG_PLAY_DATA_S *data);
275
276 void msg_ui_viewer_play_view_init(void *data);
277 void msg_ui_viewer_destroy_play_view(void *data);
278 void msg_ui_viewer_connect_handler(void *data);
279 void msg_ui_viewer_disconnect_handler(void *data);
280
281 /*
282  *@fn           msg_ui_viewer_update_play_controller(void *data, MSG_VIEWER_PLAY_STATUS_E status);
283  *@brief                This function is used to enable/disable prev & next button
284  * @param[in] data MSG_PLAY_DATA_S structure
285  * @param[in] status viewer play status.
286  */
287 void msg_ui_viewer_update_play_controller(void *data, MSG_VIEWER_PLAY_STATUS_E status);
288 Evas_Object *msg_ui_viewer_create_navigation_layout(Evas_Object *parent);
289 Evas_Object     *msg_ui_viewer_create_navi_title_layout(MSG_PLAY_DATA_S *data);
290 void msg_ui_viewer_set_navi_title_layout(MSG_PLAY_DATA_S *data);
291 void msg_ui_viewer_open_title_menu_genlist(void *data);
292 void msg_ui_viewer_close_title_menu_genlist(void *data);
293 void msg_ui_viewer_show_popup(void *data, Evas_Object *parent, char *pcontent);
294 void msg_ui_viewer_create_msg_detail_popup(MSG_PLAY_DATA_S *data);
295 void msg_ui_viewer_create_play_controller_timer(MSG_PLAY_DATA_S *data);
296 void msg_ui_viewer_create_progressbar(MSG_PLAY_DATA_S *data, int slideIdx);
297 void msg_ui_viewer_destroy_play_controller_progressbar_timer(MSG_PLAY_DATA_S *data);
298 void msg_ui_viewer_destroy_play_controller_timer(MSG_PLAY_DATA_S *data);
299 void msg_ui_viewer_copy_message_text_to_clipboard(MSG_PLAY_DATA_S *data);
300 void msg_ui_viewer_create_volume_bar(void *data);
301 void msg_ui_viewer_destroy_volume_bar(void *data);
302
303 /* ========================VIEWER  CALLBACK========================*/
304 /*
305  *@fn           msg_ui_viewer_smil_cb(SMIL_SLIDE_EVENT_PARAM_S *eventStatus, void *appUserData);
306  *@brief                This function is SMIL callback function
307  * @param[in] eventStatus  this is the slide info to be used by the application.
308  * @param[in] appUserData appdata structure
309  * @return MSG_SMIL_ERROR_E
310  */
311 MSG_SMIL_ERROR_E msg_ui_viewer_smil_cb(SMIL_SLIDE_CLIENT_CB_PARAM_S *eventStatus, void *appUserData);
312 MSG_SMIL_ERROR_E msg_ui_viewer_set_entry_handle_cb(MSG_PLAY_DATA_S *data, void *entry);
313 Eina_Bool msg_ui_viewer_focused_in_cb(void *data, int type, void *event);
314 Eina_Bool msg_ui_viewer_focused_out_cb(void *data, int type, void *event);
315 Eina_Bool msg_ui_viewer_mouse_down_cb(void *data, int type, void *event);
316 Eina_Bool msg_ui_viewer_mouse_up_cb(void *data, int type, void *event);
317 void msg_ui_viewer_play_layout_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
318 void msg_ui_viewer_play_layout_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
319 void msg_ui_viewer_play_layout_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
320 void msg_ui_viewer_title_button_clicked_cb(void *data, Evas_Object *obj, void *event_info);
321 void msg_ui_viewer_save_button_cb(void *data, Evas_Object *obj, void *event_info);
322 void msg_ui_viewer_delete_button_cb(void *data, Evas_Object *obj, void *event_info);
323 void msg_ui_viewer_forward_button_cb(void *data, Evas_Object *obj, void *event_info);
324 void msg_ui_viewer_resend_button_cb(void *data, Evas_Object *obj, void *event_info);
325 void msg_ui_viewer_reply_button_cb(void *data, Evas_Object *obj, void *event_info);
326 void msg_ui_viewer_more_button_cb(void *data, Evas_Object *obj, void *event_info);
327 void msg_ui_viewer_back_button_cb(void *data, Evas_Object *obj, void *event_info);
328 void msg_ui_viewer_toolbar_email_cb(void *data, Evas_Object *obj, void *event_info);
329 void msg_ui_viewer_toolbar_call_cb(void *data, Evas_Object *obj, void *event_info);
330 void msg_ui_viewer_toolbar_vcall_cb(void *data, Evas_Object *obj, void *event_info);
331 void msg_ui_viewer_toolbar_add_to_contact_cb(void *data, Evas_Object *obj, void *event_info);
332 void msg_ui_viewer_toolbar_view_contact_cb(void *data, Evas_Object *obj, void *event_info);
333 void msg_ui_viewer_toolbar_block_address_cb(void *data, Evas_Object *obj, void *event_info);
334 void msg_ui_viewer_toolbar_unblock_address_cb(void *data, Evas_Object *obj, void *event_info);
335
336 /* Play controller */
337 void msg_ui_viewer_volume_button_cb(void *data, Evas_Object *o, const char *emission, const char *source);
338 void msg_ui_viewer_prev_button_cb(void *data, Evas_Object *o, const char *emission, const char *source);
339 void msg_ui_viewer_play_pause_button_cb(void *data, Evas_Object *o, const char *emission, const char *source);
340 void msg_ui_viewer_next_button_cb(void *data, Evas_Object *o, const char *emission, const char *source);
341 Eina_Bool  msg_ui_viewer_play_controller_progressbar_timer_cb(void *data);
342 Eina_Bool msg_ui_viewer_play_controller_timer_cb(void *data);
343 MSG_BOOL msg_ui_viewer_command_play_pause(void *data, MSG_VIEWER_ACTION_TYPE_E action_type);
344
345 /* help page create cb - called from SMIL renderer */
346 MSG_SMIL_ERROR_E msg_ui_viewer_help_page_smilrenderer_cb(MSG_PLAY_DATA_S *data, void **attach_list, void *box);
347 void msg_ui_viewer_help_page_save_button_clicked_cb(void *data, Evas_Object *obj, void *event_info);
348
349 /* popup */
350 void msg_ui_viewer_create_save_attachments_popup(MSG_PLAY_DATA_S *data);
351 void msg_ui_viewer_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info);
352 void msg_ui_viewer_popup_timeout_cb(void *data, Evas_Object *obj, void *event_info);
353
354 /* message info */
355 int msg_ui_viewer_get_thread_address_count(MSG_PLAY_DATA_S *data);
356 void msg_ui_viewer_get_thread_address_nth_address(MSG_PLAY_DATA_S *data, int number, char **address, int *contact_id);
357 void msg_ui_viewer_title_update(MSG_PLAY_DATA_S *data, MSG_VIEWER_OPTION_CHANGE_TYPE_E option_type);
358 MSG_BOOL msg_ui_viewer_check_address_is_blocked(void *data, char *address, int *filter_id);
359 void msg_ui_viewer_set_font_size(MSG_PLAY_DATA_S *data, MSG_VIEWER_ENTRY_TYPE_E entry_type, MSG_VIEWER_FONT_CHANGE_TYPE_E change_type);
360 #endif  /* __MSG_UI_VIEWER_PLAY_VIEW_H__*/