apply FSL(Flora Software License)
[apps/home/message-app.git] / thread / include / msg-ui-thread-main.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 #ifndef __DEF_MSG_UI_THREAD_MAIN_H__
18 #define __DEF_MSG_UI_THREAD_MAIN_H__
19
20 #include <stdio.h>
21
22 #include <MsgStorageTypes.h>
23 #include <MapiTransport.h>
24 #include <MapiControl.h>
25 #include <MapiStorage.h>
26 #include <MapiMessage.h>
27
28 #include <libintl.h>
29 #include <bundle.h>
30 #include <appcore-efl.h>
31 #include <Ecore.h>
32 #include <Ecore_IMF.h>
33 #include <Elementary.h>
34 #include <ui-gadget-module.h>
35 #include <utilX.h>
36 #include <time.h>
37 #include <contacts-svc.h>
38
39 #include "message.h"
40 #include "msg-ui-util.h"
41 #include "msg-ui-common-utility.h"
42
43 #define MSG_THREAD_THEME        EDJDIR"/thread_genlist.edj"
44 #define MSG_THREAD_CONTROLBAR_ITEM_NUM  (4)
45
46 typedef enum {
47         THREAD_NORMAL_VIEW = 0,
48         THREAD_EDIT_VIEW,
49         THREAD_UNLOAD_VIEW, /* when it calls other gadgets or views. */
50 } ThreadViewMode;
51
52 typedef enum {
53         THREAD_SEARCH_OFF = 0,
54         THREAD_SEARCH_ON,
55 } ThreadSearchMode;
56
57 typedef struct {
58         MSG_THREAD_ID_T threadId;
59         char threadAddr[DEF_THREAD_ADDR_LEN+1];
60         char threadName[DEF_THREAD_NAME_LEN+1];
61         char threadData[DEF_BUF_LEN_S+1];
62         time_t *threadTime;
63         MSG_DIRECTION_TYPE_T direction;
64         MSG_CONTACT_ID_T contactId;
65         int unreadCnt;
66         int smsCnt;
67         int msgType;
68
69         Evas_Object *chk;
70         Eina_Bool isCheck;
71 } MSG_APP_THREAD_DATA_S, *PMSG_APP_THREAD_DATA_S;
72
73 typedef struct _MSG_THREAD_DATA {
74         Elm_Theme *th;
75
76         Evas_Object *win_main;
77         Evas_Object *navi_frame;
78         Evas_Object *conform;
79         Elm_Object_Item *nf_it;
80         Evas_Object *toolbar;
81         Evas_Object *content_ly;
82         Evas_Object *noc_ly;
83         Evas_Object *sel_all_ly;
84         Evas_Object *back_btn;
85
86         Evas_Object *sel_all_box;
87         Eina_Bool sel_all_checked;
88
89         Ecore_IMF_Context *imf_ctx;
90
91         Elm_Object_Item *toolbar_item[MSG_THREAD_CONTROLBAR_ITEM_NUM];
92
93         Evas_Object *genlist;
94         Evas_Object *noc;
95
96         Evas_Object *searchbar;
97
98         Evas_Object *tickernoti;
99         Ecore_Timer *e_timer;
100
101         Evas_Object *popup;
102         Evas_Object *progressbar;
103         Evas_Object *progresslabel;
104
105         Evas_Object *select_info;
106         Evas_Object *selectioninfo_layout;
107
108         Elm_Genlist_Item_Class *itc;
109
110         Elm_Genlist_Item_Class itc_thread;
111         Elm_Genlist_Item_Class itc_empty;
112
113         MSG_HANDLE_T msgHandle;
114         ThreadViewMode viewmode;
115         ThreadSearchMode search_mode;
116         int app_state;
117
118         Elm_Object_Item *sel_gen_item;
119         int sel_thread_id;
120
121         Ecore_Thread *del_thread;
122
123         bundle *msg_b;
124
125         char *time_12h_ptn;
126         char *time_24h_ptn;
127         char *date_ptn;
128         msg_time_format time_fmt;
129         char locale[DEF_BUF_LEN];
130         int noti_fd;
131
132         Eina_List *chk_list;
133         int del_index;
134         int thread_cnt;
135         int check_cnt;
136
137         bool isIncomingMsg;     /* Check there is new incoming message when it back from edit mode to normal. */
138 } MSG_THREAD_DATA, *PMSG_THREAD_DATA;
139
140 /* MAIN */
141 #define MSG_THREAD_UNREAD_BADGE \
142         IMGDIR"/M01_btn_Unread_message.png"
143 #define MSG_THREAD_OTA_BADGE \
144         IMGDIR"/M01_icon_OTA.png"
145 #define MSG_THREAD_PUSH_BADGE \
146         IMGDIR"/M01_icon_Push.png"
147 #define MSG_THREAD_BROADCAST_BADGE \
148         IMGDIR"/M01_icon_broadcasting.png"
149
150 #define MSG_THREAD_POPUP_DATA   "popup_data"
151 #define MSG_THREAD_DEL_CONFIRM  "del_confirm"
152
153 void *msg_ui_thread_init_thread_data(struct appdata *ad);
154 void msg_ui_thread_deinit_thread_data(void *data);
155
156 void msg_ui_thread_load_thread_view(void *data, bundle *b);
157 void msg_ui_thread_reset_thread_view(void *data, bundle *b);
158
159 void msg_ui_thread_fullview_launch(PMSG_THREAD_DATA pData);
160 Evas_Object *msg_ui_thread_create_content_layout(PMSG_THREAD_DATA pData);
161 Evas_Object *msg_ui_thread_create_nocontent_layout(PMSG_THREAD_DATA pData);
162 Evas_Object *msg_ui_thread_create_layout_main(Evas_Object *parent);
163 Evas_Object *msg_ui_thread_create_genlist(PMSG_THREAD_DATA pData);
164 Evas_Object *msg_ui_thread_create_searchbar_layout(PMSG_THREAD_DATA pDatat);
165
166 void msg_ui_thread_reg_msg_cb_func(PMSG_THREAD_DATA pData);
167
168 PMSG_THREAD_DATA msg_ui_thread_get_data(void);
169 void msg_ui_thread_add_navi_controlbar_item(PMSG_THREAD_DATA pData);
170
171
172 /* THREAD LIST */
173 void msg_ui_thread_set_msg_data(PMSG_APP_THREAD_DATA_S thread_data, msg_thread_view_t msgThreadInfo);
174 void msg_ui_thread_gl_sel(void *data, Evas_Object *obj, void *event_info);
175 void msg_ui_thread_gl_empty_sel(void *data, Evas_Object *obj, void *event_info);
176 void  msg_ui_thread_list_load(PMSG_THREAD_DATA ThreadData);
177 void msg_ui_thread_list_update(PMSG_THREAD_DATA ThreadData);
178 void msg_ui_thread_list_item_update(PMSG_THREAD_DATA ThreadData, MSG_THREAD_ID_T threadId);
179 void msg_ui_thread_genlist_style_set(PMSG_THREAD_DATA ThreadData);
180 void msg_ui_thread_genlist_frame_style_set(PMSG_THREAD_DATA ThreadData);
181 void msg_ui_thread_gl_mode_right(void *data, Evas_Object *obj, void *event_info);
182 void msg_ui_thread_gl_mode_left(void *data, Evas_Object *obj, void *event_info);
183
184 /* THREAD CALLBACK */
185 void msg_ui_thread_storage_change_cb(MSG_HANDLE_T handle, MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MSGID_LIST_S *pMsgIdList, void *user_param);
186 void msg_ui_thread_ctlbar_del_cb(void *data, Evas_Object *obj, void *event_info);
187 void msg_ui_thread_ctlbar_edit_cb(void *data, Evas_Object *obj, void *event_info);
188 void msg_ui_thread_ctlbar_compose_cb(void *data, Evas_Object *obj, void *event_info);
189 void msg_ui_thread_ctlbar_cancel_cb(void *data, Evas_Object *obj, void *event_info);
190
191 void msg_ui_thread_sel_all_clicked_cb(void *data, Evas_Object *obj, void *event_info);
192 void msg_ui_thread_list_checked_cb(void *data, Evas_Object *obj, void *event_info);
193 void msg_ui_thread_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info);
194 void msg_ui_thread_searchbar_entry_focus_cb(void *data, Evas_Object *obj, void *event_info);
195 void msg_ui_thread_searchbar_entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info);
196 void msg_ui_thread_searchbar_entry_change_cb(void *data, Evas_Object *obj, void *event_info);
197 void msg_ui_thread_searchbar_entry_click_cb(void *data, Evas_Object *obj, void *event_info);
198 void msg_ui_thread_searchbar_cancel_click_cb(void *data, Evas_Object *obj, void *event_info);
199 void msg_ui_thread_searchbar_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
200 void msg_ui_thread_timezone_change_cb(void *data);
201
202 /* THREAD UTILS */
203 void msg_ui_thread_get_time_format(PMSG_THREAD_DATA pData);
204 void msg_ui_thread_get_locale(PMSG_THREAD_DATA pData);
205
206 bundle *msg_ui_thread_get_bubble_data(PMSG_APP_THREAD_DATA_S item_data);
207
208 void msg_ui_thread_cancel_edit_mode(PMSG_THREAD_DATA pData);
209 void msg_ui_thread_show_normal_mode(PMSG_THREAD_DATA pData);
210 void msg_ui_thread_show_split_view(PMSG_THREAD_DATA pData);
211 void msg_ui_thread_select_item_by_thread_id(PMSG_THREAD_DATA pData, int thread_id);
212 void msg_ui_thread_show_notify(PMSG_THREAD_DATA threadData, const char *msg);
213 void msg_ui_thread_show_del_popup(PMSG_THREAD_DATA threadData, const char *msg);
214 Evas_Object* msg_ui_thread_show_notify_with_progressbar(PMSG_THREAD_DATA threadData, int count);
215 void msg_ui_thread_show_select_info(PMSG_THREAD_DATA pData);
216
217 void msg_ui_thread_set_app_state(int app_state);
218 int msg_ui_thread_get_app_state(PMSG_THREAD_DATA pData);
219
220 #endif  /* __DEF_MSG_UI_THREAD_MAIN_H__ */