test
[apps/core/preloaded/calendar.git] / include / cld.h
1 /*
2   *
3   *  Copyright 2012  Samsung Electronics Co., Ltd
4   *
5   *  Licensed under the Flora License, Version 1.0 (the "License");
6   *  you may not use this file except in compliance with the License.
7   *  You may obtain a copy of the License at
8   *
9   *       http://www.tizenopensource.org/license
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17
18
19 #ifndef __CALENDAR_H__
20 #define __CALENDAR_H__
21
22 #include <Elementary.h>
23 #include <contacts-svc.h>
24 #include <ui-gadget.h>
25 #include "cal-svc.h"
26 #include "acct-svc.h"
27 #include "cld-log.h"
28 #include "cld-utils.h"
29
30 #define CAL_QUICKADD_LONG_PRESS_TIME 0.5
31
32 #if !defined(CALENDAR_RING)
33 #define CALENDAR_RING "calendar-ring"
34 #endif
35
36 #ifndef API
37 #define API __attribute__ ((visibility("default")))
38 #endif
39
40 #if !defined(CALENDAR_PACKAGE)
41 #  define CALENDAR_PACKAGE "calendar"
42 #endif
43
44 #if !defined(RESDIR)
45 #  define RESDIR "/opt/apps/org.tizen."CALENDAR_PACKAGE"/res/"
46 #endif
47
48 #if !defined(LOCALEDIR)
49 #  define LOCALEDIR "/opt/apps/org.tizen."CALENDAR_PACKAGE"/res/locale"
50 #endif
51
52 #if !defined(VCALENDAR_DATA_LEN)
53 #define VCALENDAR_DATA_LEN 3000
54 #endif
55
56 #if !defined(EMAIL_LINK_FLAG)
57 #define EMAIL_LINK_FLAG "#email_viewer_link#"
58 #endif
59
60 #define CAL_CBAR_ICON_DELETE RESDIR"/icons/T01_controlbar_icon_delete.png"
61 #define CAL_CBAR_ICON_CREAT RESDIR"/icons/01_controlbar_icon_create.png"
62 #define CAL_CBAR_ICON_SHARE RESDIR"/icons/T01_controlbar_icon_share02.png"
63 #define CAL_CBAR_ICON_EDIT RESDIR"/icons/T01_controlbar_icon_edit.png"
64 #define CAL_CBAR_ICON_TODAY RESDIR"/icons/01_controlbar_icon_today.png"
65 #define CAL_CBAR_ICON_VIEW RESDIR"/icons/01_controlbar_icon_View.png"
66 #define CAL_CBAR_ICON_CALENDARS RESDIR"/icons/01_controlbar_icon_calendars.png"
67 #define CAL_EVENT_LIST_ICON_ALARM RESDIR"/icons/P01_event_list_icon_alarm.png"
68 #define CAL_EVENT_LIST_ICON_PRIORITY RESDIR"/icons/P01_event_list_icon_priority.png"
69 #define CAL_EVENT_LIST_ICON_REPEAT RESDIR"/icons/P01_event_list_icon_reapeat.png"
70 #define CAL_EVENT_LIST_ICON_REMINDER RESDIR"/icons/P01_event_list_icon_reminder.png"
71 #define CAL_EVENT_LIST_ICON_FACEBOOK RESDIR"/icons/P01_event_list_icon_facebook.png"
72 #define CAL_TASK_EVENT_HIGH_ICON  RESDIR"/icons/P01_Task_event.png"
73 #define CAL_TASK_EVENT_UNCOMPLETED_ICON  RESDIR"/icons/P01_Task_event_completion.png"
74 #define CAL_TASK_EVENT_COMPLETED_ICON RESDIR"/icons/P01_Task_event_completion_press.png"
75
76 #define CAL_APPCONTROL_ITEM_TYPE "itemType"
77 #define CAL_APPCONTROL_ITEM_TYPE_EVENT "event"
78 #define CAL_APPCONTROL_ITEM_TYPE_TODO "todo"
79 #define CAL_APPCONTROL_ITEM_TYPE_VCS "vcs"
80 #define CAL_APPCONTROL_EVENT_ID "eventId"
81 #define CAL_APPCONTROL_TODO_ID "todoId"
82 #define CAL_APPCONTROL_VCS_PATH "path"
83
84 enum cld_view {
85         CV_UNKNOWN = 0,
86         CV_YEAR,
87         CV_MONTH,
88         CV_WEEK,
89         CV_DAY,
90         CV_LIST,
91         CV_TODO,
92         CV_EDIT,
93         CV_DETAIL,
94         CV_NOTI,
95 };
96
97 typedef enum ug_type {
98         UG_UNKNOWN = 0,
99         UG_DETAIL,
100         UG_EDIT,
101         UG_MAX,
102 }ug_type;
103
104 typedef enum {
105         ITEM_TYPE_UNKNOWN = 0,
106         ITEM_TYPE_EVENT,
107         ITEM_TYPE_TODO,
108         ITEM_TYPE_VCS,
109         ITEM_TYPE_MAX
110 }cal_appcontrol_item_type;
111
112 typedef struct {
113         struct tm stm;
114         struct tm etm;
115         char *stitle;
116         const Evas_Object *entry; //for title
117         bool is_hold_press;
118         Evas_Object *title;
119         Evas_Object *start_time;
120         Evas_Object *end_time;
121         Ecore_Timer *hold_timer;
122         Evas_Object *popup;
123 }cal_quick_add;
124
125 typedef struct
126 {
127         int contact_id;
128         char *contact_image;
129         char *name;
130
131         char *email;
132         int email_id;
133
134         char *number;
135
136         int status;
137         int role;
138         int response;
139
140         Eina_Bool is_deleted;
141 }cal_participant;
142
143 typedef struct appdata
144 {
145         Evas_Object *win;                       //window
146         Evas_Coord win_w;                               //width of window
147         Evas_Coord win_h;                                       //height of window
148         Evas_Object *base;                      //base layout
149         Evas_Object *nv;                                //naviframe
150         Evas_Object *title;                     //title
151         Evas_Object *main;                      //main view( has year, month, day, list tabs)
152         Evas_Object *bg;                                //background
153         Evas_Object *cbar;              //coontrol bar(calendar,today,delete,create)
154
155         Elm_Object_Item* main_navi_item;        //Naviframe item for main layout.
156
157         enum cld_view request_view;     //initial or requested view to show, when app is relaunched,
158         enum cld_view current_view;
159
160         Eina_Bool is_update_view;       //only update when it is needed
161         Eina_Bool is_pause;                     //prevent updating view during app pause state
162
163         struct tm base_tm;              //base time
164         int base_hour;                  // This can be replace to base_tm.tm_hour
165         struct tm today_tm;             //today time
166         Ecore_Timer *today_tmr;         //to update today when day is changed.
167         Evas_Object *today_edj;         //edj for content of month tab, Need to change name to calendar_edj.
168
169         int wday_start;                 //0~6, since sunday
170
171         int cid;                                        //calendar id. for detail, edit view
172         struct tm tm_start;             //for detail, edit view
173         struct tm tm_end;                       //for detail, edit view
174
175         int acct_id;                            //this variable always have ALL_VISIBLE_ACCOUT == -2
176
177         Elm_Object_Item *bt_new;        //button for "Create event" in controlbar
178         Elm_Object_Item *bt_delete; //button for "Delete" in controlbar
179         Elm_Object_Item *bt_view; //button for "View" in controlbar
180         Elm_Object_Item *bt_today; //button for "Today" in controlbar
181         Elm_Object_Item *today_item;    // scroll to top item of today in list view.
182         cals_todo_list_order_t todo_sort_type;
183
184         int notifd;                             //for heynoti
185
186         Eina_Bool is_aul;                       //to check wheather launching with AUL
187         Elm_Object_Item* content;               //pop all aul content & jump to calendar content.
188
189         Eina_Bool edit_special_one;     //to remove this, cal_edit_create_view should have 1 more parameter.
190         Eina_Bool is_weekly;                    //check whethere monthly tab is for weekly or not.
191
192         ui_gadget_h ug;         //can access to ui_gadget* from ug_data
193         ug_type u_type;                 //ug type
194         cal_appcontrol_item_type item_type;                     //request item type for appcontrol
195         cal_struct* ical;                               //for vcard raw data used in calendar viewer.
196
197         int tm_year;                            //It would be better, if these are changed to struct tm. to save event with specific time
198         int tm_mon;                             //It would be better, if these are changed to struct tm. to save event with specific time
199         int tm_mday;                            //It would be better, if these are changed to struct tm. to save event with specific time
200
201         char *strnote;                  //to save str  from memo
202         Eina_Bool show_save_popup;      //to show save popup when edit UG is destroyed
203         int is_hour24;                  //to show time as 12 or 24 format
204
205         Elm_Theme *theme;               //theme customization
206
207         int account_id;                 //for email sharing feature
208         int mail_id;                            //for email sharing feature
209         char *src_box;                  //for email sharing feature
210
211         Evas_Coord h_cur;
212
213         Eina_Bool is_display_complete_todo;
214
215         int is_display_weeknumber;
216
217         Eina_Bool is_landscape_mode;
218
219         int calendar_facebook_id;
220 }ug_data;
221
222 static inline void cal_main_set_cs(struct appdata *ad, cal_struct *cs)
223 {
224         c_ret_if(!ad);
225         c_ret_if(!cs);
226
227         ad->cid = CALENDAR_SVC_STRUCT_GET_INT(cs, CAL_VALUE_INT_INDEX);
228
229         if (CALENDAR_SVC_IS_ALLDAY_EVENT(cs)) {
230
231                 ad->tm_start.tm_year = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_YEAR) - 1900;
232                 ad->tm_start.tm_mon = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_MONTH) - 1;
233                 ad->tm_start.tm_mday = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_MDAY);
234
235                 ad->tm_end.tm_year = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTEND_YEAR) - 1900;
236                 ad->tm_end.tm_mon = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTEND_MONTH) - 1;
237                 ad->tm_end.tm_mday = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTEND_MDAY);
238
239         } else {
240
241                 cal_util_convert_lli_to_tm(NULL, CALENDAR_SVC_STRUCT_GET_LLI(cs, CALS_VALUE_LLI_DTSTART_UTIME), &ad->tm_start);
242                 cal_util_convert_lli_to_tm(NULL, CALENDAR_SVC_STRUCT_GET_LLI(cs, CALS_VALUE_LLI_DTEND_UTIME), &ad->tm_end);
243         }
244 }
245
246 static inline void cal_main_set_cs_tm(struct tm *tm, cal_struct *cs)
247 {
248         c_ret_if(!tm);
249         c_ret_if(!cs);
250
251         if (CALENDAR_SVC_IS_ALLDAY_EVENT(cs)) {
252                 tm->tm_year = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_YEAR) - 1900;
253                 tm->tm_mon = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_MONTH) - 1;
254                 tm->tm_mday = CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_MDAY);
255
256         } else {
257                 cal_util_convert_lli_to_tm(NULL, CALENDAR_SVC_STRUCT_GET_LLI(cs, CALS_VALUE_LLI_DTSTART_UTIME), tm);
258         }
259 }
260
261 #endif /* __CALENDAR_H__ */
262