499c7e4020cc1b5e1dcfd26ff650a00f4d261444
[apps/core/preloaded/message-app.git] / composer / include / msg-ui-composer-data.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
18 #ifndef __MSG_UI_COMPOSER_DATA_H_
19 #define __MSG_UI_COMPOSER_DATA_H_
20
21 /***********************
22  *  includes
23  ************************/
24 #include <msg.h>
25 #include <msg_storage.h>
26 #include <msg_transport.h>
27
28 #include <Elementary.h>
29 #include <X11/Xlib.h>
30 #include <glib-object.h>
31 #include <glib.h>
32
33 #include <ui-gadget-module.h>
34
35 #include <contacts.h>
36 #include <assert.h>
37 #include <time.h>
38 #include <Ecore_X.h>
39
40 #include "msg-ui-util.h"
41 #include "msg-ui-composer-string.h"
42 #include "msg-ui-composer-res.h"
43 #include "msg-ui-common-utility.h"
44 #include "msg-ui-composer-bubble.h"
45
46 /*********************
47  * defines
48  ************************/
49
50 #if !defined(__TYPEDEF_INT64__)
51 #define __TYPEDEF_INT64__
52 typedef long long int64;
53 #endif
54
55 #define TO_FIELD_LABEL_SIZE_MAX 512
56 #define COMPOSER_RECIPIENT_PORTRAIT_HEIGHT_MAX  188
57 #define COMPOSER_RECIPIENT_LANDSCAPE_HEIGHT_MAX 112
58 #define COMPARE_STRING_NUM 8
59
60 #ifndef MAX_TO_ADDRESS_CNT
61 #define MAX_TO_ADDRESS_CNT (10)
62 #endif
63
64 #define COMPOSER_RECIPIENT_COUNT_MAX    MAX_TO_ADDRESS_CNT
65
66 #ifndef MAX_PHONE_NUMBER_LEN
67 #define MAX_PHONE_NUMBER_LEN (20)
68 #endif
69
70 #define COMPOSER_RECIPIENT_PHONE_NUMBER_LEN_MAX MAX_PHONE_NUMBER_LEN
71 #define COMPOSER_RECIPIENT_PHONE_NUMBER_LEN_MIN (3)
72
73 #ifndef MAX_ADDRESS_VAL_LEN
74 #define MAX_ADDRESS_VAL_LEN (254)
75 #endif
76
77 #define COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX MAX_ADDRESS_VAL_LEN
78 #define COMPOSER_SUBJECT_MAX_CHAR       (40)
79 #define COMPOSER_SUBJECT_MAX_BYTE       (COMPOSER_SUBJECT_MAX_CHAR * 3)
80
81 #define COMPOSER_MMS_TEXT_MAX_CHAR      (3000)
82 #define COMPOSER_MMS_TEXT_MAX_BYTE      (COMPOSER_MMS_TEXT_MAX_CHAR * 3)
83
84 #define COMPOSER_MMS_MAX_PAGE                   (20)
85 #define COMPOSER_MMS_MAX_ATTACH_COUNT   (10)
86 #define COMPOSER_FILEPATH_LEN_MAX       (1024)
87 #define COMPOSER_FILENAME_LEN_MAX       (255)
88 #define COMPOSER_PAGE_DEFAULT_DURATION (5) //sec
89
90 #define COMPOSER_MMS_MAX_MEDIA_COUNT    (COMPOSER_MMS_MAX_PAGE)
91
92 #define COMPOSER_COMMON_EXT_MAX_LENGTH          (7)
93 #define COMPOSER_COMMON_MIME_MAX_LEN            (64)
94
95 #define COMPOSER_SMS_UNICODE_MAX_LEN    (70)
96 #define COMPOSER_SMS_GSM7_MAX_LEN               (160)
97
98 #define COMPOSER_CMS_UNICODE_MAX_LEN    (67)
99 #define COMPOSER_CMS_GSM7_MAX_LEN               (153)
100
101 /* default 15 pages, it can be changed by operator spec. */
102 #define COMPOSER_CMS_MAX_PAGE                   (15)
103
104 #define COMPOSER_TMP_PATH "/tmp"
105
106 #define MSGC_1KB        1024
107
108 #define MSGC_RESTRICT_MAX_IMG_W 640
109 #define MSGC_RESTRICT_MAX_IMG_H 480
110
111 #define MSGC_INDICATOR_H 60
112 #define MSGC_NAVIBAR_TITLE_H 111
113 #define MSGC_BODY_TOP_PADDING 4
114 #define MSGC_BODY_BOTTOM_PADDING 20
115 #define MSGC_BODY_PADDING (MSGC_BODY_TOP_PADDING + MSGC_BODY_BOTTOM_PADDING)
116
117 #define MSGC_IMAGE_THUMB_WIDTH  132
118 #define MSGC_IMAGE_THUMB_HEIGHT 132
119 #define MSGC_SOUND_THUMB_WIDTH  48
120 #define MSGC_SOUND_THUMB_HEIGHT 48
121
122 #define MSGC_POPUP_GENLIST_H 128
123 #define MSGC_POPUP_LIST_H 112
124
125 #define MSGC_BODY_FONT_SIZE 36
126 #define MSGC_SUBJECT_FONT_SIZE 32
127
128 /*********************
129  * enum types
130  ************************/
131 typedef enum {
132         MSG_UG_MODE_FULL_COMPOSER,
133         MSG_UG_MODE_BUBBLE_COMPOSER,
134         MSG_UG_MODE_ONLY_COMPOSER,      /*In this mode Composer should destroy after send message*/
135         MSG_UG_MODE_MAX,
136 } MSG_UG_MODE_E;
137
138 typedef enum {
139         MSG_COMPOSER_MODE_NORMAL,
140         MSG_COMPOSER_MODE_EDIT,
141         MSG_COMPOSER_MODE_FORWARD,
142 } MSG_COMPOSER_MODE_E;
143
144 typedef enum {
145         COMPOSER_RETURN_SUCCESS = 0,
146         COMPOSER_RETURN_FAIL                                            = -1,
147         COMPOSER_RETURN_NULL_POINTER                            = -2,
148         COMPOSER_RETURN_NO_SIM                                          = -3,
149         COMPOSER_RETURN_HANDLE_NOT_EXIST                        = -4,
150         COMPOSER_RETURN_MAX_PAGE                                        = -5,
151         COMPOSER_RETURN_INVALID_MSG_TYPE                        = -6,
152         COMPOSER_RETURN_INVALID_PAGE                            = -7,
153         COMPOSER_RETURN_INVALID_MEDIA_TYPE                      = -8,
154         COMPOSER_RETURN_ATTACHMENT_ALREADY_EXIST        = -9,
155         COMPOSER_RETURN_LOW_RESOLUTION                          = -10,
156         COMPOSER_RETURN_HIGH_RESOLUTION                         = -11,
157         COMPOSER_RETURN_NONSTANDARD_FILE                        = -12,
158         COMPOSER_RETURN_RECIPIENT_INVALID                       = -13,
159         COMPOSER_RETURN_RECIPIENT_COUNTMAX                      = -14,
160         COMPOSER_RETURN_RECIPIENT_DUPLICATE                     = -15,
161         COMPOSER_RETURN_MSG_SIZE_OVER                           = -16,
162         COMPOSER_RETURN_RESIZE_IMAGE                            = -17,
163         COMPOSER_RETURN_DRM_FORWARDLOCK                         = -18,
164         COMPOSER_RETURN_OVERSIZE_FILE                           = -19,
165         COMPOSER_RETURN_CREATION_RESTRICTED_MODE_FAIL   = -20,
166         COMPOSER_RETURN_CREATION_RESTRICTED_MODE_PASS   = -21,
167         COMPOSER_RETURN_CREATION_WARINING_MODE_FAIL     = -22,
168         COMPOSER_RETURN_CREATION_WARINING_MODE_PASS     = -23,
169 } COMPOSER_RETURN_TYPE_E;
170
171 typedef enum {
172         COMPOSER_MSG_TYPE_INVALID,
173         COMPOSER_MSG_TYPE_SMS,
174         COMPOSER_MSG_TYPE_MMS,
175 } COMPOSER_MSG_TYPE_E;
176
177 typedef enum {
178         COMPOSER_RECP_TYPE_UNKOWN,
179         COMPOSER_RECP_TYPE_TO,
180         COMPOSER_RECP_TYPE_CC,
181         COMPOSER_RECP_TYPE_BCC,
182         COMPOSER_RECP_TYPE_FROM,
183         COMPOSER_RECP_TYPE_MAX,
184 } COMPOSER_RECP_TYPE_E;
185
186 typedef enum {
187         COMPOSER_MEDIA_TYPE_UNKNOWN,
188         COMPOSER_MEDIA_TYPE_IMAGE,
189         COMPOSER_MEDIA_TYPE_VIDEO,
190         COMPOSER_MEDIA_TYPE_AUDIO,
191         COMPOSER_MEDIA_TYPE_TEXT,
192         COMPOSER_MEDIA_TYPE_ANIMATE,
193         COMPOSER_MEDIA_TYPE_DRM,
194         COMPOSER_MEDIA_TYPE_MAX = 0xff
195 } COMPOSER_MEDIA_TYPE_E;
196
197 typedef enum {
198         COMPOSER_MEDIA_TRACK_TYPE_NONE,
199         COMPOSER_MEDIA_TRACK_TYPE_VIDEO,
200         COMPOSER_MEDIA_TRACK_TYPE_AUDIO,
201 } COMPOSER_MEDIA_TRACK_TYPE_E;
202
203 typedef enum {
204         COMPOSER_REGION_ORDER_UNDETERMINDED = 0x00,
205         COMPOSER_REGION_ORDER_IMAGE_TOP,
206         COMPOSER_REGION_ORDER_TEXT_TOP,
207 } COMPOSER_MMS_REGION_ORDER_E;
208
209 typedef enum {
210         COMPOSER_STATE_TYPE_INVALID = 0,
211         COMPOSER_STATE_TYPE_CREATE,
212         COMPOSER_STATE_TYPE_RUNNING,
213         COMPOSER_STATE_TYPE_PAUSE,
214         COMPOSER_STATE_TYPE_DESTROY,
215         COMPOSER_STATE_TYPE_MAX,
216 } COMPOSER_STATE_TYPE_E;
217
218 typedef enum {
219         COMPOSER_STATUS_POPUP_BUTTON_NONE = 0,
220         COMPOSER_STATUS_POPUP_BUTTON_OK,
221         COMPOSER_STATUS_POPUP_BUTTON_CLOSE,
222         COMPOSER_STATUS_POPUP_BUTTON_OK_CANCEL,
223         COMPOSER_STATUS_POPUP_BUTTON_MAX,
224 } COMPOSER_POPUP_BUTTON_TYPE_E;
225
226 enum {
227         COMPOSER_CREATION_MODE_RESTRICTED = 0,
228         COMPOSER_CREATION_MODE_WARNING,
229         COMPOSER_CREATION_MODE_FREE,
230         COMPOSER_CREATION_MODE_MAX,
231 };
232
233 typedef enum {
234         COMPOSER_FOCUS_RECIPIENT = 0,
235         COMPOSER_FOCUS_BODY,
236         COMPOSER_FOCUS_SUBJECT,
237         COMPOSER_FOCUS_DEFAULT,
238 } COMPOSER_FOCUS_E;
239
240 typedef enum {
241         COMPOSER_RECP_ADDR_NONE,
242         COMPOSER_RECP_ADDR_INVALID,
243         COMPOSER_RECP_ADDR_VALID_NUMBER,
244         COMPOSER_RECP_ADDR_VALID_EMAIL,
245 } COMPOSER_RECP_ADDR_E;
246
247 typedef enum {
248         COMPOSER_CHAR_ENCODE_GSM7 = 0,
249         COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL,
250         COMPOSER_CHAR_ENCODE_UNICODE,
251         COMPOSER_CHAR_ENCODE_MAX,
252 } COMPOSER_CHAR_ENCODE_E;
253
254 typedef enum {
255         COMPOSER_PREDICTSEARCH_NONE = 0,
256         COMPOSER_PREDICTSEARCH_NAME_OR_NUMBER,
257         COMPOSER_PREDICTSEARCH_NAME_OR_EMAIL,
258         COMPOSER_PREDICTSEARCH_LOG,
259         COMPOSER_PREDICTSEARCH_END,
260 } COMPOSER_PREDICTSEARCH_STATE_E;
261
262 typedef enum {
263         COMPOSER_ROTATE_UNKNOWN = 0,
264         COMPOSER_ROTATE_PORTRAIT = APP_DEVICE_ORIENTATION_0,
265         COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN = APP_DEVICE_ORIENTATION_180,
266         COMPOSER_ROTATE_LANDSCAPE = APP_DEVICE_ORIENTATION_270,
267         COMPOSER_ROTATE_LANDSCAPE_UPSIDEDOWN = APP_DEVICE_ORIENTATION_90,
268 } COMPOSER_ROTATE_TYPE_E;
269
270 typedef enum {
271         COMPOSER_EDIT_NONE,
272         COMPOSER_EDIT_RECIPIENT,
273         COMPOSER_EDIT_BODY,
274         COMPOSER_EDIT_RECIPIENT_AND_BODY,
275 } COMPOSER_EDIT_STATE_E;
276
277 enum {
278         COMPOSER_ADDR_TYPE_NUMBER,
279         COMPOSER_ADDR_TYPE_EMAIL
280 };
281
282 enum {
283         COMPOSER_TYPE_SUBJECT = 0,
284         COMPOSER_TYPE_BODY
285 };
286
287 typedef enum {
288         COMPOSER_CONTENT_CREATION_NONE,
289         COMPOSER_CONTENT_CREATION_ALLOWED,
290         COMPOSER_CONTENT_CREATION_ALLOWED_WITH_RESIZE,
291         COMPOSER_CONTENT_CREATION_NOT_ALLOWED,
292 } COMPOSER_CONTENT_CREATION_MODE_E;
293
294 /******************************
295  * structures
296  *******************************/
297 typedef struct {
298         char m_szextend[COMPOSER_COMMON_EXT_MAX_LENGTH + 1];
299         char m_szmime_type[COMPOSER_COMMON_MIME_MAX_LEN + 1];
300         COMPOSER_MEDIA_TYPE_E m_ncontent_type;
301 } composer_mime_type_t;
302
303 /*
304 Used change number for contact info
305 */
306 typedef struct _CONTACT_ITEM_S {
307         int index;
308         int type;       /*COMPOSER_ADDR_TYPE_NUMBER:number, COMPOSER_ADDR_TYPE_EMAIL:email*/
309         int contact_type;       /*number or email type of contact like Mobile, Home*/
310         char recipient[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX+1];
311 } CONTACT_ITEM_S;
312
313 /*
314 Used MBE's data && PredictSearch
315 */
316 typedef struct _RECIPIENT_ITEM_S {
317         COMPOSER_RECP_ADDR_E type;
318         int index;
319         char recipient[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX+1];
320         char display_name[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX+1];
321         char image_path[COMPOSER_FILEPATH_LEN_MAX+1];
322 } RECIPIENT_ITEM_S;
323
324 typedef struct _RECIPIENT_S {
325         const char *name;
326         void *cd;
327         int mode;
328         int recipient_h;
329         bool is_required_address_popup;
330
331         Evas_Object *parent;
332         Evas_Object *bx_main;
333         Evas_Object *sc;
334         Evas_Object *ly_to;
335         Evas_Object *mbe;
336
337         Evas_Object *popup_selected;
338         Elm_Object_Item *sel_mbe_item;
339         RECIPIENT_ITEM_S *sel_r_item;
340
341         Evas_Object *popup_change_number;
342         Elm_Genlist_Item_Class change_number_itc;
343
344         Ecore_Idler *scroll_down_idler;
345
346         COMPOSER_RECP_ADDR_E type;
347         Ecore_Idler *notify_popup_idler;
348 } RECIPIENT_S;
349
350 typedef struct _PREDICTSEARCH_S {
351         const char *name;
352         void *cd;
353         Evas_Object *parent;
354         Evas_Object *glist_ps;
355         Elm_Genlist_Item_Class itc_1line;
356         Elm_Genlist_Item_Class itc_2line;
357
358         COMPOSER_PREDICTSEARCH_STATE_E state;
359
360         char txt_ps_keyword[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX+1];
361         char txt_ps_reqkeyword[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX+1];
362         Eina_Bool IsShow;
363         contacts_list_h ct_list;
364         int count;
365
366         Ecore_Idler *idler_ps;
367         Ecore_Timer *timer_ps;
368 } PREDICTSEARCH_S;
369
370 typedef struct _SUBJECT_S {
371         Evas_Object *layout;
372         Evas_Object *entry;
373         Evas_Object *del_icon;
374 } SUBJECT_S;
375
376 typedef struct _MSG_COMPOSER_ATTACHITEM_S {
377         Evas_Object *layout;
378         char file_path[COMPOSER_FILEPATH_LEN_MAX + 1];
379         char file_name[COMPOSER_FILEPATH_LEN_MAX + 1];
380         int type;
381 } MSG_COMPOSER_ATTACH_ITEM_S;
382
383 typedef struct _MSG_COMPOSER_ATTACH_S {
384         int attachment_Cnt;
385         long long attachfileSize;
386         Eina_List *attachitem_list;
387 } MSG_COMPOSER_ATTACH_S;
388
389 typedef struct _text_info {
390         COMPOSER_CHAR_ENCODE_E encode;
391         int char_count;
392         int page_size;
393 } text_info_s;
394
395 typedef struct _MSG_COMPOSER_BODY_PAGE_S {
396         Evas_Object *layout;
397         Evas_Object *page_main_box;
398
399         Evas_Object *upper_layout;
400         Evas_Object *page_box;
401         Evas_Object *del_icon;
402
403         bool is_image_item;
404         bool isVideo;
405         Evas_Object *image_item;
406         char image_file_path[COMPOSER_FILEPATH_LEN_MAX + 1];
407
408         Evas_Object *entry;
409         text_info_s text_info;
410
411         bool is_sound_item;
412         Evas_Object *sound_item;
413         char sound_file_path[COMPOSER_FILEPATH_LEN_MAX + 1];
414
415         int page_duration;
416 } MSG_COMPOSER_BODY_PAGE_S;
417
418 typedef struct _MSG_COMPOSER_BODY_S {
419         int page_count;
420         Eina_List *page_list;
421
422         int region_order;
423         COMPOSER_CONTENT_CREATION_MODE_E creation_allowed;
424 } MSG_COMPOSER_BODY_S;
425
426 typedef struct _MSG_COMPOSER_DATA_S {
427         /*ug data & callback*/
428         ui_gadget_h ug;
429         ui_gadget_h loaded_ug;
430         struct ug_cbs cbs;
431
432         /*composer mode & state*/
433         MSG_UG_MODE_E msg_ug_mode;
434         MSG_COMPOSER_MODE_E composer_mode;
435         COMPOSER_STATE_TYPE_E state;
436         COMPOSER_ROTATE_TYPE_E rotate;
437         COMPOSER_MSG_TYPE_E msg_type;
438
439         bool isLoad;
440         bool isFullview;
441         bool isMsgInternal;
442         bool isAppControl;
443         bool isEmulator;
444         bool sending_success;
445
446         bool send_button_clicked;
447         bool add_button_clicked;
448         bool add_menu_clicked;
449
450         bool loaded_aul;
451         bool isSubject;
452         bool send_button_is_show;
453         bool isclosed;  /* composer is closed */
454         bool loading_draft;     /* draft msg loading status */
455         bool make_default_body_size;
456         bool is_default_body_size;
457         bool is_keypad_show;
458         bool disable_auto_save_mode;
459         Elm_Win_Indicator_Mode indicator_mode;
460
461         int current_edit_entry;
462         int first_focus;
463
464         int window_w;
465         int window_h;
466
467         int ly_body_h;
468         int send_check_exception_type;
469         char *working_path;
470
471         /* setting data */
472         int font_size;
473         int mms_max_size;
474         int page_duration;
475         int cms_max_page;
476         int encode_mode;
477
478         /*message handler*/
479         msg_handle_t msg_handle;
480         void *tapi_handle;
481
482         /*module data*/
483         SUBJECT_S sub_data;
484         MSG_COMPOSER_BODY_S body_data;
485         MSG_COMPOSER_ATTACH_S attach_data;
486
487         Eina_List *recipient_list; /* recipient list for bubble composer */
488         RECIPIENT_S *recipient;
489         PREDICTSEARCH_S *predictsearch;
490         Eina_List *attachlist;
491         Eina_List *iter_list;
492         int attach_index;       /*current added attach index*/
493
494         /*Evas Object*/
495         Evas_Object *main_window;
496         Evas_Object *base;
497         Evas_Object *navi_bar;
498         Evas_Object *navi_title_layout;
499         Evas_Object *title_menu_layout;
500         Evas_Object *more_btn;
501         Evas_Object *compose_btn;
502         Evas_Object *back_btn;
503         Evas_Object *toolbar_top;
504         Elm_Object_Item *navi_it;
505
506         Evas_Object *content_layout;
507         Evas_Object *bg;
508         Evas_Object *ly_body;
509         Evas_Object *ly_recipient;
510
511         Evas_Object *add_button;
512         Evas_Object *send_button;
513
514         Evas_Object *body_scroll;
515         Evas_Object *body_box;
516
517         Evas_Object *ly_attach_main;
518
519         Evas_Object *add_popup;
520         Evas_Object *progress_popup;
521         Evas_Object *popup_end;
522         Evas_Object *ctx_popup;
523         Evas_Object *custom_popup;
524         Eina_List *popup_list;
525
526         Evas_Object *page_duration_entry;
527
528         Evas_Object *last_focus_entry;
529         Ecore_Idler *last_focus_idler;
530
531         Ecore_Thread *attach_thread;
532         Ecore_Job *job_thread_end;
533         Ecore_Timer *flight_mode_timer;
534
535         Elm_Theme *th;
536
537         /* for use volume key setting */
538         Ecore_Event_Handler *volkey_release_handler;
539         Ecore_Event_Handler *volkey_press_handler;
540         Ecore_Timer *vol_up_key_longpress;
541         Ecore_Timer *vol_down_key_longpress;
542         Ecore_X_Display *xdisplay;
543
544         MSG_BUBBLE_DATA *bubble_data; /* For bubble data structure */
545 } MSG_COMPOSER_VIEW_DATA_S;
546
547 #endif                          /* __MSG_UI_COMPOSER_DATA_H_ */