3 * Copyright 2012 Samsung Electronics Co., Ltd
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
9 * http://www.tizenopensource.org/license
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.
22 #define CAL_MONTH_CALENDAR_LAST_LINE_POS_INDEX 41
24 #define WEEKS_OF_MONTH 6
25 #define DAYS_OF_WEEK 7
26 #define DAYS_OF_WEEKLY_MONTHS_VIEW 42
27 #define LINES_OF_WEEKLY_MONTHS_EVENT 3
28 #define LINES_OF_WEEKLY_MONTHS_EVENT_LANDSCAPE 1
39 CAL_MONTH_CALENDAR_DAY_TYPE_SUNDAY = 0,
40 CAL_MONTH_CALENDAR_DAY_TYPE_SATDAY,
41 CAL_MONTH_CALENDAR_DAY_TYPE_WEEKDAY,
42 } cal_month_calendar_day_type_t;
47 cal_month_calendar_day_type_t d_type;
58 }cal_month_calendar_weekly_event;
64 Evas_Object *weekly_events_ly[WEEKS_OF_MONTH];
66 Eina_List *event_list;
70 int base_pos_for_weekly;
72 struct _day day[DAYS_OF_WEEKLY_MONTHS_VIEW];
78 GList* week_event_list[WEEKS_OF_MONTH][DAYS_OF_WEEK];
82 } cal_month_calendar_data;
84 static const char *_name = NULL;
85 static Calendar_color calendar_color;
87 static Evas_Object *__cal_month_calendar_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part);
88 static char* __cal_month_calendar_get_genlist_item_label(void *data, Evas_Object *obj, const char *part);
89 static void __cal_month_calendar_signal_week(cal_month_calendar_data *p, Evas_Object *obj, int index);
90 static int __cal_month_calendar_get_weekly_events(cal_month_calendar_data *p);
92 static void __cal_month_calendar_events_of_one_weekday(void *data);
93 static void __cal_month_calendar_get_events(cal_month_calendar_data *p);
94 static int __cal_month_calendar_get_day_time_by_pos(cal_month_calendar_data *p, int *first_day, int *last_day, struct tm *start_time, struct tm *end_time, int day_pos);
95 static void __cal_month_calendar_create_event_lists(Evas_Object *ly, cal_month_calendar_data *p);
96 static void __cal_month_calendar_signal_all_week(cal_month_calendar_data *p);
97 static void __cal_month_calendar_signal_all_clean(cal_month_calendar_data *p);
98 static void __cal_month_calendar_set_more_text(Evas_Object *ly, int count, int index);
99 static int __cal_month_calendar_clean_list(cal_month_calendar_data *p);
100 static void __cal_month_calendar_set_check_text(Evas_Object *ly, cal_month_calendar_data *p, int count, int index);
101 static void __cal_month_calendar_set_event_rect_color(Evas_Object *obj, cal_month_calendar_data *p, int line, int pos, int calendar_id);
102 static void __cal_month_calendar_set_day_default_color(cal_month_calendar_data* p, Evas_Object *eo, int pos);
103 static void __cal_month_calendar_fill_week_number(Evas_Object *ly);
105 static Elm_Genlist_Item_Class itc = {
106 .item_style = "3text.5icon",
107 .func.content_get = __cal_month_calendar_get_genlist_item_icon,
108 .func.text_get = __cal_month_calendar_get_genlist_item_label,
111 static Evas_Object *__cal_month_calendar_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
113 c_retvm_if(!data, NULL, "data is null");
114 c_retvm_if(!obj, NULL, "obj is null");
116 cal_struct *cs = data;
118 cal_month_calendar_data* p = CAL_UTIL_GET_PRIV_DATA(obj);
119 c_retvm_if(!p, NULL, "p is null");
122 Evas_Object *icon = NULL;
123 cal_struct *calendar = NULL;
125 if (!CAL_STRCMP(part, "elm.swallow.colorbar"))
127 r = CALENDAR_SVC_GET(CAL_STRUCT_CALENDAR, CALENDAR_SVC_STRUCT_GET_INT(cs,CAL_VALUE_INT_CALENDAR_ID), NULL, &calendar);
128 if (r != CAL_SUCCESS)
130 ERR("CALENDAR_SVC_GET fail. %d", r);
134 icon = evas_object_rectangle_add(evas_object_evas_get(obj));
135 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
137 CALENDAR_SVC_GET_CALENDAR_COLOR(calendar, &calendar_color);
139 evas_object_color_set(icon, calendar_color.red, calendar_color.green, calendar_color.blue, calendar_color.alpha);
141 CALENDAR_SVC_STRUCT_FREE(&calendar);
149 static void __cal_month_calendar_make_time_text(struct tm *tm_start, struct tm *tm, char *buf, int sz)
154 time = CAL_UTIL_TIME_FORMAT_6;
156 if (tm_start->tm_year != tm->tm_year)
157 date = CAL_UTIL_DATE_FORMAT_11;
158 else if (tm_start->tm_mon != tm->tm_mon)
159 date = CAL_UTIL_DATE_FORMAT_10;
160 else if (tm_start->tm_mday != tm->tm_mday)
161 date = CAL_UTIL_DATE_FORMAT_9;
165 cal_util_get_time_text(buf, sz, NULL, time, tm_start);
169 static char* __cal_month_calendar_get_time_text(cal_struct *cs, cal_month_calendar_data *p)
175 cal_util_convert_lli_to_tm(NULL, CALENDAR_SVC_STRUCT_GET_LLI(cs, CALS_VALUE_LLI_DTSTART_UTIME), &tm_start);
176 __cal_month_calendar_make_time_text(&tm_start, &p->ad->base_tm, stime, sizeof(stime));
178 snprintf(buf, sizeof(buf), "%s", stime);
183 static char* __cal_month_calendar_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
185 c_retvm_if(!data, NULL, "data is null");
189 cal_struct *cs = data;
191 if (!CAL_STRCMP(part, "elm.text.1")) {
193 str = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_SUMMARY);
197 return strdup(C_("IDS_CLD_BODY_NO_TITLE"));
199 else if (!CAL_STRCMP(part, "elm.text.2")) {
201 str = CALENDAR_SVC_STRUCT_GET_STR(cs, CAL_VALUE_TXT_LOCATION);
205 return strdup(C_("IDS_CLD_BODY_NO_LOCATION_SELECTED"));
207 else if (!CAL_STRCMP(part, "elm.text.3")) {
209 if (CALENDAR_SVC_STRUCT_GET_INT(cs, CALS_VALUE_INT_DTSTART_TYPE) == CALS_TIME_LOCALTIME)
210 return strdup(C_("IDS_COM_BODY_ALL_DAY"));
212 cal_month_calendar_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
213 c_retvm_if(!p, NULL, "p is null");
215 return __cal_month_calendar_get_time_text(cs, p);
221 static int __cal_month_calendar_get_first_wday(int mday, int wday)
223 return CAL_UTIL_GET_WDAY(wday - mday + 1);
226 static void __cal_month_calendar_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
230 c_retm_if(!data, "data is null");
231 cal_month_calendar_data *p = data;
233 struct appdata *ad = p->ad;
234 c_retm_if(!ad, "ad is null");
236 if (ad->today_edj && ad->today_edj == CAL_UTIL_GET_EDJ_DATA(obj))
237 ad->today_edj = NULL;
240 evas_object_del(p->popup);
243 __cal_month_calendar_clean_list(p);
250 static inline void __cal_month_calendar_set_color(Evas_Object *ly, cal_month_calendar_data *p, int pos, int wday)
252 c_retm_if(!p, "p is null");
254 struct _day *d = &p->day[pos];
256 const char *day_color;
260 day_color = "sunday";
261 d->d_type = CAL_MONTH_CALENDAR_DAY_TYPE_SUNDAY;
264 day_color = "satday";
265 d->d_type = CAL_MONTH_CALENDAR_DAY_TYPE_SATDAY;
268 d->d_type = CAL_MONTH_CALENDAR_DAY_TYPE_WEEKDAY;
269 day_color = "weekday";
273 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "%s,%d", day_color, pos);
276 static inline void __cal_month_calendar_set_disabled(Evas_Object *ly, cal_month_calendar_data *p, int pos)
278 struct _day *d = &p->day[pos];
280 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "disable,%d", pos);
285 static inline void __cal_month_calendar_set_enabled(Evas_Object *ly, cal_month_calendar_data *p, int pos, int wday)
287 struct _day *d = &p->day[pos];
290 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "enable,%d", pos);
292 __cal_month_calendar_set_color(ly, p, pos, wday);
297 static inline void __cal_month_calendar_set_today(Evas_Object *eo, int pos)
302 cal_util_emit_signal(eo, "today,%d", pos);
305 static inline void __cal_month_calendar_unset_today(Evas_Object *eo, int *pos)
310 cal_util_emit_signal(eo, "notoday,%d", *pos);
314 static inline void __cal_month_calendar_set_selected(Evas_Object *eo, int pos)
316 if (pos < 0 || DAYS_OF_WEEKLY_MONTHS_VIEW <= pos)
319 cal_util_emit_signal(eo, "select,%d", pos);
322 static inline void __cal_month_calendar_set_unselected(cal_month_calendar_data* p, Evas_Object *eo, int *pos)
324 c_retm_if(!p, "p is NULL");
325 c_retm_if(-1 == *pos, "pos is invalid");
326 c_retm_if(!eo, "eo is invalid");
328 cal_util_emit_signal(eo, "unselect,%d", *pos);
330 __cal_month_calendar_set_day_default_color(p, eo, *pos);
335 static inline int __cal_month_calendar_get_start_day(int *st, struct tm *tm, int start, int max)
340 prev_day = CAL_UTIL_GET_WDAY(__cal_month_calendar_get_first_wday(tm->tm_mday, tm->tm_wday) - start);
342 day = max - prev_day + 1;
352 static int __cal_month_calendar_update_today(Evas_Object *eo, cal_month_calendar_data *p)
357 struct appdata *ad = p->ad;
360 struct tm *base_tm = &ad->base_tm;
361 c_retv_if(!base_tm, -1);
363 __cal_month_calendar_unset_today(eo, &p->pos_today);
365 ad->today_edj = NULL;
367 if (base_tm->tm_year == ad->today_tm.tm_year && base_tm->tm_mon == ad->today_tm.tm_mon) {
368 p->pos_today = p->pos_start + ad->today_tm.tm_mday - 1;
369 __cal_month_calendar_set_today(eo, p->pos_today);
376 void cal_month_calendar_update_select(Evas_Object *ly)
379 Evas_Object* eo = CAL_UTIL_GET_EDJ_DATA(ly);
381 cal_month_calendar_data* p = CAL_UTIL_GET_PRIV_DATA(ly);
385 cal_main_update_title_text(p->ad->title, CV_MONTH, &p->ad->base_tm, p->ad->wday_start);
387 __cal_month_calendar_set_unselected(p, eo, &p->pos_selected);
388 p->pos_selected = p->pos_start + p->ad->base_tm.tm_mday - 1;
389 __cal_month_calendar_set_selected(eo, p->pos_selected);
393 static void __cal_month_calendar_get_simple_check(cal_month_calendar_data *p, struct tm *tm_start, struct tm *tm_end, char *map, int map_sz)
397 struct appdata *ad = p->ad;
401 int *month = CALENDAR_SVC_GET_SIMPLE_CS(ad->acct_id, tm_start, tm_end);
404 struct tm base_tm = ad->base_tm;
406 for (i = 0; i < cal_util_get_max_days(base_tm.tm_year, base_tm.tm_mon); i++) {
414 static void __cal_month_calendar_update_check(Evas_Object *ly, cal_month_calendar_data *p)
419 struct appdata *ad = p->ad;
422 char m[DAYS_OF_WEEKLY_MONTHS_VIEW] = { 0 };
424 struct tm base_tm = ad->base_tm;
426 struct tm tm_start = base_tm;
427 tm_start.tm_hour = 0;
430 cal_util_update_tm_day(&tm_start, 1 - tm_start.tm_mday);
432 struct tm tm_end = tm_start;
436 cal_util_update_tm_month(&tm_end, 1);
437 cal_util_update_tm_day(&tm_end, -1);
439 int max = cal_util_get_max_days(base_tm.tm_year, base_tm.tm_mon);
441 __cal_month_calendar_get_simple_check(p, &tm_start, &tm_end, &m[p->pos_start], max);
444 for (i = 0; i < DAYS_OF_WEEKLY_MONTHS_VIEW; i++) {
445 if (p->ad->is_weekly || p->ad ->is_landscape_mode) {
446 __cal_month_calendar_set_more_text(ly, m[i], i);
448 __cal_month_calendar_set_check_text(ly, p, m[i], i);
453 static int __cal_month_calendar_fill_calendar(Evas_Object *ly, int wday)
457 cal_month_calendar_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
460 struct appdata *ad = p->ad;
463 struct tm base_tm = ad->base_tm;
465 int prev_max = cal_util_get_max_days(base_tm.tm_year, base_tm.tm_mon - 1);
466 int cur_max = cal_util_get_max_days(base_tm.tm_year, base_tm.tm_mon);
469 int day = __cal_month_calendar_get_start_day(&st, &base_tm, wday, prev_max);
475 int line = WEEKS_OF_MONTH;
477 for (i = 0; i < DAYS_OF_WEEKLY_MONTHS_VIEW; i++) {
478 cal_util_set_text(CAL_UTIL_GET_EDJ_DATA(ly), cal_util_get_part_text("db/%d/text", i), "%d", day);
483 __cal_month_calendar_set_disabled(ly, p, i);
484 if (day == prev_max) {
487 p->pos_start = i + 1;
492 __cal_month_calendar_set_enabled(ly, p, i, wday);
493 if (day == cur_max) {
496 line = (int)(i / DAYS_OF_WEEK) + 1;
502 __cal_month_calendar_set_disabled(ly, p, i);
507 wday = CAL_UTIL_GET_WDAY(wday + 1);
510 __cal_month_calendar_update_today(CAL_UTIL_GET_EDJ_DATA(ly), p);
512 __cal_month_calendar_fill_week_number(ly);
517 static void __cal_month_calendar_click_event_callback(cal_month_calendar_data *p, Evas_Object *obj, int pos)
521 struct appdata *ad = p->ad;
524 if (p->pos_selected == pos) {
525 DBG("cal_cb: double clicked %d", pos);
527 if (p->ad->is_weekly || p->ad ->is_landscape_mode)
530 if (p->day[pos].checked) {
531 __cal_month_calendar_events_of_one_weekday(p);
536 cal_edit_create_view(ad, p->parent);
542 ad->base_tm.tm_mday = pos - p->pos_start + 1;
544 cal_month_calendar_update_select(p->month);
546 edje_object_signal_emit(obj, "changed", "prog");
549 static void __cal_month_calendar_cal_event_callback(void *data, Evas_Object *obj, const char *e, const char *src)
551 cal_month_calendar_data *p = data;
552 c_retm_if(!p, "p is null");
554 struct appdata *ad = p->ad;
555 c_retm_if(!ad, "ad is null");
557 int pos = atoi(&e[3]);
558 c_retm_if((p->pos_end < pos) || (pos < p->pos_start), "pos is diabled");
560 if (!strncmp(e, "up,", 3)) {
562 if (p->pos_down == pos) {
563 __cal_month_calendar_click_event_callback(p, obj, pos);
566 edje_object_signal_emit(obj, e, "prog");
568 }else if (!strncmp(e, "dn,", 3)) {
572 edje_object_signal_emit(obj, e, "prog");
576 static void __cal_month_calendar_prog_event_callback(void *data, Evas_Object *obj, const char *e, const char *src)
578 cal_month_calendar_data *p = data;
580 if (!CAL_STRCMP(e, "update_today")) {
581 __cal_month_calendar_update_today(obj, p);
585 if (CAL_STRCMP(e, "moved")) {
589 if (p->pos_down == -1) {
593 cal_util_emit_signal(obj, "up,%d", p->pos_down);
594 if (p->pos_selected!= p->pos_down) {
595 __cal_month_calendar_set_day_default_color(p, obj, p->pos_down);
596 cal_util_emit_signal(obj, "unselect,%d", p->pos_down);
601 static void __cal_month_calendar_set_wday_text(Evas_Object *ly, int start)
605 cal_month_calendar_data* p = CAL_UTIL_GET_PRIV_DATA(ly);
608 struct appdata *ad = p->ad;
611 struct tm base_tm = ad->base_tm;
613 cal_util_update_tm_day(&base_tm, base_tm.tm_wday*(-1)+start);
616 for (i = 0; i < DAYS_OF_WEEK; i++) {
617 cal_util_set_time_text(CAL_UTIL_GET_EDJ_DATA(ly), cal_util_get_part_text("wday/%d/text", i), CAL_UTIL_DATE_FORMAT_2, NULL, &base_tm);
619 if (base_tm.tm_wday == 6)
620 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "satday,%d", i);
622 if (base_tm.tm_wday == 0)
623 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "sunday,%d", i);
625 cal_util_update_tm_day(&base_tm, 1);
628 edje_object_part_text_set(CAL_UTIL_GET_EDJ_DATA(ly), "wday/weeknumber/text", "W");
631 static gint __cal_month_calendar_events_compare(gconstpointer a,gconstpointer b)
633 cal_month_calendar_weekly_event *p1 = (cal_month_calendar_weekly_event *)a;
634 cal_month_calendar_weekly_event *p2 = (cal_month_calendar_weekly_event *)b;
636 if (p2->start_time < p1->start_time)
638 else if(p1->start_time < p2->start_time)
644 static void __cal_month_calendar_signal_clean(cal_month_calendar_data *p,Evas_Object *eo)
646 c_retm_if(!p, "p is null");
647 c_retm_if(!eo, "eo is null");
652 for (i = 0; i < DAYS_OF_WEEK; i++) {
653 for (line = 1; line <= WEEKS_OF_MONTH; line++) {
654 cal_util_emit_signal(eo, "%d,%d,%d", line, 0, i);
655 cal_util_emit_signal(eo, "%d,%s,%d", line, "nocolor", i);
661 static int __cal_month_calendar_clean_list(cal_month_calendar_data *p)
663 c_retvm_if(!p, -1, "p is null");
668 for (k = 0; k < WEEKS_OF_MONTH; k++) {
669 for (i = 0; i < DAYS_OF_WEEK; i++) {
670 g_list_free(p->week_event_list[k][i]);
671 p->week_event_list[k][i] = NULL;
677 static int __cal_month_calendar_get_week_time(cal_month_calendar_data *p, int *first_day, int *last_day)
683 if(-1 == p->pos_selected)
686 day = p->pos_selected;
688 today = day - p->pos_start + 1;
689 start_day = day - ((day + 1) % DAYS_OF_WEEK) + 1;
691 if (day < DAYS_OF_WEEK) {
693 *last_day = DAYS_OF_WEEK - p->pos_start;
694 } else if (0 == ((day + 1) % DAYS_OF_WEEK)) {
695 *first_day = today - DAYS_OF_WEEK + 1;
698 *first_day = today - (day % DAYS_OF_WEEK);
699 if ((start_day + DAYS_OF_WEEK - 1) > p->pos_end) {
700 *last_day = p->pos_end - p->pos_start + 1;
702 *last_day = *first_day + DAYS_OF_WEEK - 1;
709 static bool __cal_month_calendar_is_last(GList* event_list[][DAYS_OF_WEEK], int list_index)
711 c_retvm_if(!event_list, FALSE, "event_list is null");
712 c_retvm_if(WEEKS_OF_MONTH <= list_index, FALSE, "list_index is invalid");
716 for (i = 0; i < DAYS_OF_WEEK; i++) {
717 if (event_list[list_index][i])
724 static void __cal_month_calendar_line_arrange(GList* event_list[][DAYS_OF_WEEK],int index,const int line, int list_index)
726 c_retm_if(!event_list, "event_list is null");
727 c_retm_if(DAYS_OF_WEEK <= index, "index is invalid");
728 c_retm_if(WEEKS_OF_MONTH <= list_index, "list_index is invalid");
730 cal_month_calendar_weekly_event *temp = NULL;
731 GList *list_temp = event_list[list_index][index];
733 if (list_temp && list_temp->data) {
734 temp = list_temp->data;
738 if (0 == temp->width)
741 if (DAYS_OF_WEEK <= index + temp->width)
744 __cal_month_calendar_line_arrange(event_list, index + temp->width, line, list_index);
746 if (DAYS_OF_WEEK <= index + 1)
749 __cal_month_calendar_line_arrange(event_list, index + 1, line, list_index);
753 static void __cal_month_calendar_get_next(GList* event_list[][DAYS_OF_WEEK], int list_index)
755 c_retm_if(!event_list, "event_list is null");
758 cal_month_calendar_weekly_event *temp = NULL;
760 for (i = 0; i < DAYS_OF_WEEK; i++) {
762 if (event_list[list_index][i] && event_list[list_index][i]->data) {
764 temp = (cal_month_calendar_weekly_event*)event_list[list_index][i]->data;
767 event_list[list_index][i] = event_list[list_index][i]->next;
772 static int __cal_month_calendar_get_weekly_events(cal_month_calendar_data *p)
776 struct appdata *ad = p->ad;
781 __cal_month_calendar_signal_all_clean(p);
783 __cal_month_calendar_clean_list(p);
785 for (week = 0; week < WEEKS_OF_MONTH; week++) {
791 cal_iter *iter = NULL;
792 cal_struct *record = NULL;
793 cal_month_calendar_weekly_event *event = NULL;
794 struct tm end_time = {0};
795 struct tm start_time = {0};
800 int wday_start = ad->wday_start;
801 long long int lli_start, lli_end;
803 __cal_month_calendar_get_day_time_by_pos(p, &start_day, &end_day, &start_time, &end_time, (week + 1) * DAYS_OF_WEEK - 1);
805 int day_num = end_time.tm_wday - start_time.tm_wday + 1;
807 cal_util_convert_tm_to_lli(NULL, &start_time, &lli_start);
808 cal_util_convert_tm_to_lli(NULL, &end_time, &lli_end);
810 // TODO: Change calendar_id to defined constants
812 int r = calendar_svc_event_get_normal_list_by_period(-1, CALS_LIST_PERIOD_NORMAL_OSP, lli_start, lli_end, &iter);
813 c_retvm_if(r != CAL_SUCCESS, -1, "calendar_svc_event_get_normal_list_by_period is failed(%d)", r);
815 while (CAL_SUCCESS == CALENDAR_SVC_ITER_NEXT(iter)) {
817 CALENDAR_SVC_ITER_GET_INFO(iter,&record);
819 event = calloc(1, sizeof(cal_month_calendar_weekly_event));
820 c_retvm_if(!event, -1, "event is null");
822 event->calendar_id = CALENDAR_SVC_STRUCT_GET_INT(record, CAL_VALUE_INT_CALENDAR_ID);
824 g_snprintf(event->title, sizeof(event->title), "%s", CALENDAR_SVC_STRUCT_GET_STR(record,CAL_VALUE_TXT_SUMMARY));
826 cal_util_convert_lli_to_time_t(NULL, CALENDAR_SVC_STRUCT_GET_LLI(record, CALS_VALUE_LLI_DTSTART_UTIME), &event->start_time);
827 cal_util_convert_lli_to_time_t(NULL, CALENDAR_SVC_STRUCT_GET_LLI(record, CALS_VALUE_LLI_DTEND_UTIME), &event->end_time);
828 cal_util_convert_lli_to_tm(NULL, CALENDAR_SVC_STRUCT_GET_LLI(record, CALS_VALUE_LLI_DTSTART_UTIME), &st);
829 cal_util_convert_lli_to_tm(NULL, CALENDAR_SVC_STRUCT_GET_LLI(record, CALS_VALUE_LLI_DTSTART_UTIME), &et);
831 event->width = et.tm_wday - st.tm_wday + 1;
832 if (event->width < 1)
835 wday = st.tm_wday - wday_start;
839 p->week_event_list[week][wday] = g_list_append(p->week_event_list[week][wday], event);
843 r = CALENDAR_SVC_STRUCT_FREE(&record);
846 CALENDAR_SVC_ITER_REMOVE(&iter);
858 r = calendar_svc_event_get_allday_list_by_period(-1, CALS_LIST_PERIOD_ALLDAY_OSP,
859 start_time.tm_year + 1900, start_time.tm_mon + 1, start_time.tm_mday,
860 end_time.tm_year + 1900, end_time.tm_mon + 1, end_time.tm_mday, &iter);
861 c_retvm_if(r != CAL_SUCCESS, -1, "calendar_svc_event_get_allday_list_by_period is failed(%d)", r);
863 while (CAL_SUCCESS == CALENDAR_SVC_ITER_NEXT(iter)) {
865 r = CALENDAR_SVC_ITER_GET_INFO(iter, &record);
866 c_retvm_if(r != CAL_SUCCESS, -1, "CALENDAR_SVC_ITER_GET_INFO is failed(%d)", r);
868 event = calloc(1, sizeof(cal_month_calendar_weekly_event));
869 c_retvm_if(!event, -1, "event is null");
871 event->calendar_id = CALENDAR_SVC_STRUCT_GET_INT(record, CAL_VALUE_INT_CALENDAR_ID);
873 g_snprintf(event->title, sizeof(event->title), "%s", CALENDAR_SVC_STRUCT_GET_STR(record,CAL_VALUE_TXT_SUMMARY));
875 st.tm_year = et.tm_year = CALENDAR_SVC_STRUCT_GET_INT(record, CALS_VALUE_INT_DTSTART_YEAR) - 1900;
876 st.tm_mon = et.tm_mon = CALENDAR_SVC_STRUCT_GET_INT(record, CALS_VALUE_INT_DTSTART_MONTH) - 1;
877 st.tm_mday = et.tm_mday = CALENDAR_SVC_STRUCT_GET_INT(record, CALS_VALUE_INT_DTSTART_MDAY);
879 event->start_time = mktime(&st);
880 event->end_time = mktime(&et);
882 st = *localtime(&event->start_time);
886 wday = st.tm_wday - wday_start;
890 p->week_event_list[week][wday] = g_list_append(p->week_event_list[week][wday], event);
894 CALENDAR_SVC_STRUCT_FREE(&record);
897 CALENDAR_SVC_ITER_REMOVE(&iter);
899 for (wday = 0; wday < day_num; wday++) {
900 if (p->week_event_list[week][wday])
901 p->week_event_list[week][wday] = g_list_sort(p->week_event_list[week][wday], __cal_month_calendar_events_compare);
904 GList* list_t[WEEKS_OF_MONTH][DAYS_OF_WEEK];
906 for (wday = 0 ; wday < DAYS_OF_WEEK; wday++)
907 list_t[week][wday] = p->week_event_list[week][wday];
909 while (__cal_month_calendar_is_last(p->week_event_list, week)) {
911 __cal_month_calendar_line_arrange(p->week_event_list, 0, line, week);
915 if ( (p->ad->is_landscape_mode ? LINES_OF_WEEKLY_MONTHS_EVENT_LANDSCAPE : LINES_OF_WEEKLY_MONTHS_EVENT) < line)
918 __cal_month_calendar_get_next(p->week_event_list, week);
921 for (wday = 0; wday < DAYS_OF_WEEK; wday++)
922 p->week_event_list[week][wday] = list_t[week][wday];
928 static void __cal_month_calendar_signal_week(cal_month_calendar_data *p, Evas_Object *obj, int week)
934 cal_month_calendar_weekly_event *event = NULL;
936 GList* event_list = NULL;
938 Evas_Object *eo = CAL_UTIL_GET_EDJ_DATA(obj);
941 for (wday = 0; wday < DAYS_OF_WEEK; wday++) {
943 if (!p->week_event_list[week][wday])
946 event_list = g_list_first( p->week_event_list[week][wday]);
948 while (event_list && event_list->data) {
949 event = event_list->data;
951 cal_util_emit_signal(eo, "%d,%d,%d", event->line, event->width, wday);
952 cal_util_emit_signal(eo, "%d,show,%d", event->line, wday);
954 __cal_month_calendar_set_event_rect_color(obj, p, event->line, wday, event->calendar_id);
956 memset(text,0x00,sizeof(text));
957 g_snprintf(text, sizeof(text), "%d/text/%d", event->line, wday);
958 edje_object_part_text_set(eo, text, event->title);
960 event_list = event_list->next;
965 static void __cal_month_calendar_mouse_down(void *data, Evas *e, Evas_Object *ly, void *ei)
967 c_retm_if(!data, "p is null");
968 c_retm_if(!ly, "ly is null");
969 c_retm_if(!ei, "ei is null");
971 cal_month_calendar_data *p = data;
972 Evas_Event_Mouse_Down *ev = ei;
976 int list_index = (int)evas_object_data_get(ly, "list_index");
977 p->base_pos_for_weekly = list_index * DAYS_OF_WEEK;
979 Evas_Coord_Rectangle r;
980 cal_util_get_geometry(&r, ly);
981 offset = ev->canvas.x / (r.w / DAYS_OF_WEEK);
982 if (DAYS_OF_WEEK <= offset)
983 offset = DAYS_OF_WEEK - 1;
985 p->down_x = ev->canvas.x;
986 p->down_y = ev->canvas.y;
988 if (p->day[p->base_pos_for_weekly + offset].enabled) {
989 p->index_for_press = p->base_pos_for_weekly + offset;
990 snprintf(eve, sizeof(eve) , "dn,%d", p->index_for_press);
991 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->month), eve, "cal");
995 static void __cal_month_calendar_mouse_move(void *data, Evas *e, Evas_Object *ly, void *ei)
997 c_retm_if(!data, "data is null");
998 c_retm_if(!ly, "ly is null");
999 c_retm_if(!ei, "ei is null");
1001 cal_month_calendar_data *p = data;
1002 Evas_Event_Mouse_Move *ev = ei;
1004 Evas_Coord th = elm_finger_size_get();
1008 dx = ev->cur.canvas.x - p->down_x ;
1009 dy = p->down_y - ev->cur.canvas.y;
1010 if (dy > th || dy < (th * -1) || dx > th || dx < (th * -1)) {
1012 if( -1 != p->index_for_press) {
1013 snprintf(eve, sizeof(eve) , "up,%d", p->index_for_press);
1014 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->month), eve, "prog");
1015 if (p->pos_selected != p->index_for_press) {
1016 __cal_month_calendar_set_day_default_color(p, CAL_UTIL_GET_EDJ_DATA(p->month), p->index_for_press);
1017 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(p->month), "unselect,%d", p->index_for_press);
1019 p->index_for_press = -1;
1024 static bool __cal_month_calendar_check_event_exists(GList* event_list[][DAYS_OF_WEEK], int index, int list_index)
1026 c_retvm_if(!event_list, FALSE, "data is null");
1027 c_retvm_if(DAYS_OF_WEEK <= index, FALSE, "index is invalid");
1028 c_retvm_if(WEEKS_OF_MONTH <= list_index, FALSE, "list_index is invalid");
1031 GList *list_temp = NULL;
1032 cal_month_calendar_weekly_event *event = NULL;
1034 for (i=0; i<=index; i++) {
1035 if (NULL == event_list[list_index][i])
1038 list_temp = g_list_first(event_list[list_index][i]);
1039 while (NULL != list_temp) {
1040 event = list_temp->data;
1041 if (NULL == event) {
1042 list_temp = g_list_next(list_temp);
1046 if (index - i + 1 <= event->width)
1049 list_temp = g_list_next(list_temp);
1056 static void __cal_month_calendar_genlist_item_select_callback(void *data, Evas_Object *obj, void *ei)
1061 cal_struct *cs = data;
1063 Elm_Object_Item *it = elm_genlist_selected_item_get(obj);
1065 elm_genlist_item_selected_set(it, EINA_FALSE);
1067 cal_month_calendar_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
1070 cal_main_set_cs(p->ad, cs);
1072 cal_detail_create_view(p->ad, p->parent);
1075 evas_object_hide(p->popup);
1078 static void __cal_month_calendar_get_events(cal_month_calendar_data *p)
1080 struct tm tm_start = p->ad->base_tm;
1081 tm_start.tm_hour = 0;
1082 tm_start.tm_min = 0;
1083 tm_start.tm_sec = 0;
1085 struct tm tm_end = tm_start;
1086 tm_end.tm_hour = 23;
1090 p->event_list = CALENDAR_SVC_GET_EVENT_LIST(&tm_start, &tm_end);
1093 static void __cal_month_calendar_update_genlist(cal_month_calendar_data *p)
1097 c_retm_if(!p, "p is null");
1098 c_retm_if(!p->gl, "p->gl is null");
1101 cal_struct *cs = NULL;
1102 Elm_Object_Item *it = NULL;
1103 elm_genlist_clear(p->gl);
1105 CALENDAR_SVC_FREE_CS_LIST(&p->event_list);
1107 __cal_month_calendar_get_events(p);
1108 c_retm_if(!p->event_list, "p->event_list is null");
1110 EINA_LIST_FOREACH(p->event_list, l, cs) {
1112 it = elm_genlist_item_append(p->gl, &itc, cs, NULL, ELM_GENLIST_ITEM_NONE, __cal_month_calendar_genlist_item_select_callback, cs);
1113 c_retm_if(!it, "elm_genlist_item_append() returned null");
1120 static void __cal_month_calendar_popup_response_callback(void *data, Evas_Object *obj, void *ei)
1122 c_retm_if(!data, "data is null");
1124 Evas_Object *popup = data;
1126 evas_object_hide(popup);
1129 static void __cal_month_calendar_events_of_one_weekday(void *data)
1131 c_retm_if(!data, "data is null");
1133 cal_month_calendar_data *p = data;
1134 c_retm_if(!p->parent, "p->parent is null");
1136 struct appdata *ad = p->ad;
1139 char title[128] = {0};
1140 cal_struct *cs = NULL;
1142 if (!p->event_list) {
1143 CALENDAR_SVC_FREE_CS_LIST(&p->event_list);
1146 __cal_month_calendar_get_events(p);
1147 c_retm_if(!p->event_list, "p->event_list is null");
1149 int count = eina_list_count(p->event_list);
1151 cal_util_get_time_text(title, sizeof(title), CAL_UTIL_DATE_FORMAT_13, NULL, &p->ad->base_tm);
1154 p->popup = cal_util_add_popup(ad->win, "menustyle", title, NULL,
1155 __cal_month_calendar_popup_response_callback, p,
1156 S_("IDS_COM_BODY_CLOSE"), NULL);
1158 c_retm_if(!p->popup, "cal_util_add_popup returned null");
1160 elm_object_part_text_set(p->popup, "title,text", title);
1161 evas_object_show(p->popup);
1165 p->gl = elm_genlist_add(p->popup);
1166 evas_object_data_set(p->gl, "priv", p);
1167 evas_object_show(p->gl);
1168 elm_object_content_set(p->popup, p->gl);
1170 } else if (1 == count) {
1171 cs = eina_list_data_get(p->event_list);
1172 c_retm_if(!cs, "cs is null");
1174 cal_main_set_cs(p->ad, cs);
1176 cal_detail_create_view(p->ad, p->parent);
1178 __cal_month_calendar_update_genlist(p);
1181 static void __cal_month_calendar_mouse_up(void *data, Evas *e, Evas_Object *ly, void *ei)
1183 c_retm_if(!data, "data is null");
1184 c_retm_if(!ly, "ly is null");
1186 cal_month_calendar_data *p = data;
1187 Evas_Event_Mouse_Down *ev = ei;
1190 int num_of_enable = 0;
1195 list_index = (int)evas_object_data_get(ly, "list_index");
1197 c_retm_if(-1 == p->index_for_press, "p->index_for_press is -1");
1199 Evas_Coord_Rectangle r;
1200 cal_util_get_geometry (&r, ly);
1201 int day_width = r.w / DAYS_OF_WEEK;
1203 snprintf(eve, sizeof(eve) , "up,%d", p->index_for_press);
1204 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(p->month), eve, "cal");
1206 if (p->pos_selected != p->index_for_press) {
1207 p->index_for_press = -1;
1211 p->index_for_press = -1;
1213 __cal_month_calendar_get_week_time(p,&start_day,&end_day);
1215 if (DAYS_OF_WEEK != (num_of_enable = end_day - start_day + 1)) {
1217 if (end_day < DAYS_OF_WEEK) {
1219 if (ev->canvas.x < (DAYS_OF_WEEK- num_of_enable) * day_width)
1222 start_day -= (DAYS_OF_WEEK - num_of_enable);
1223 } else if (DAYS_OF_WEEK < start_day) {
1225 if (ev->canvas.x > num_of_enable * day_width)
1230 for (i = 0; i < DAYS_OF_WEEK; i++) {
1231 if (ev->canvas.x > i*day_width && ev->canvas.x < (i+1)*day_width) {
1232 p->ad->base_tm.tm_mday = start_day + i;
1233 if (!__cal_month_calendar_check_event_exists(p->week_event_list, i, list_index)) {
1234 p->ad->base_hour = -1;
1236 cal_edit_create_view(p->ad, p->parent);
1238 __cal_month_calendar_events_of_one_weekday(p);
1244 Evas_Object* cal_month_calendar_create_view(struct appdata *ad,
1245 Evas_Object *main, Eina_Bool tmp)
1247 c_retv_if(!ad, NULL);
1248 c_retv_if(!main, NULL);
1250 cal_month_calendar_data *p = calloc(1, sizeof(cal_month_calendar_data));
1251 c_retv_if(!p, NULL);
1255 p->pos_down = p->pos_today = p->pos_selected = -1;
1256 p->pos_start = p->pos_end = -1;
1257 p->index_for_press = -1;
1259 if (ad->is_weekly || ad ->is_landscape_mode) {
1260 p->name = _name = "main/month/cal/weekly";
1262 p->name = _name = "main/month/cal";
1265 Evas_Object *ly = cal_util_add_layout(ad->nv, p->name);
1273 evas_object_data_set(ly, "priv", p);
1274 edje_object_signal_callback_add(CAL_UTIL_GET_EDJ_DATA(ly), "*", "cal", __cal_month_calendar_cal_event_callback, p);
1275 edje_object_signal_callback_add(CAL_UTIL_GET_EDJ_DATA(ly), "*", "prog", __cal_month_calendar_prog_event_callback, p);
1277 __cal_month_calendar_set_wday_text(ly, ad->wday_start);
1279 if (tmp == EINA_TRUE) {
1280 p->weekline = __cal_month_calendar_fill_calendar(ly, ad->wday_start);
1281 __cal_month_calendar_update_check(ly, p);
1284 if (p->ad->is_weekly || p->ad ->is_landscape_mode) {
1285 __cal_month_calendar_create_event_lists(ly, p);
1287 __cal_month_calendar_get_weekly_events(p);
1290 if (ad->is_display_weeknumber)
1291 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "display_week_number");
1293 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_month_calendar_delete_layout, p);
1298 void cal_month_calendar_update_view(Evas_Object *ly)
1304 cal_month_calendar_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
1305 if (!p || CAL_STRCMP(p->name, _name)) {
1306 ERR("update month calendar: Invalid object");
1310 struct appdata *ad = p->ad;
1313 p->weekline = __cal_month_calendar_fill_calendar(ly, ad->wday_start);
1315 __cal_month_calendar_update_check(ly, p);
1317 if (p->ad->is_weekly || p->ad ->is_landscape_mode) {
1318 __cal_month_calendar_get_weekly_events(p);
1320 __cal_month_calendar_signal_all_week(p);
1323 cal_month_calendar_update_select(ly);
1328 int cal_month_calendar_get_weekline(Evas_Object *ly)
1330 cal_month_calendar_data *p;
1334 p = CAL_UTIL_GET_PRIV_DATA(ly);
1335 if (!p || CAL_STRCMP(p->name, _name)) {
1336 ERR("get weekline: Invalid object");
1343 static int __cal_month_calendar_get_day_time_by_pos(cal_month_calendar_data *p, int *first_day, int *last_day, struct tm *start_time, struct tm *end_time, int day_pos)
1353 if (-1 != day_pos) {
1354 day = CAL_MONTH_CALENDAR_LAST_LINE_POS_INDEX <= day_pos ? p->pos_end : day_pos;
1355 } else if (-1 == p->pos_selected) {
1358 day = p->pos_selected;
1362 today = day - p->pos_start + 1;
1363 start_day = day - (day_tmp % DAYS_OF_WEEK) + 1;
1365 if (day < DAYS_OF_WEEK) {
1367 *last_day = DAYS_OF_WEEK - p->pos_start;
1368 } else if (0 == (day_tmp % DAYS_OF_WEEK)) {
1369 *first_day = today - DAYS_OF_WEEK + 1;
1372 *first_day = today - (day % DAYS_OF_WEEK);
1373 if (p->pos_end < (start_day + DAYS_OF_WEEK - 1))
1374 *last_day = p->pos_end - p->pos_start + 1;
1376 *last_day = *first_day + DAYS_OF_WEEK - 1;
1379 struct appdata *ad = p->ad;
1382 *start_time = ad->base_tm;
1383 start_time->tm_mday = *first_day;
1384 start_time->tm_hour = 0;
1385 start_time->tm_min = 0;
1386 start_time->tm_sec = 0;
1388 *end_time = ad->base_tm;
1389 end_time->tm_mday = *last_day;
1390 end_time->tm_hour = 23;
1391 end_time->tm_min = 59;
1392 end_time->tm_sec = 59;
1394 if (0 < p->pos_start && day < DAYS_OF_WEEK)
1395 cal_util_update_tm_day(start_time, -p->pos_start);
1396 else if ((0 != (day_tmp % DAYS_OF_WEEK)) && (p->pos_end < (start_day + DAYS_OF_WEEK - 1)))
1397 cal_util_update_tm_day(end_time, start_day + DAYS_OF_WEEK - 1 - p->pos_end);
1399 if (p->pos_end < day_pos && p->pos_end <= CAL_MONTH_CALENDAR_LAST_LINE_POS_INDEX && CAL_MONTH_CALENDAR_LAST_LINE_POS_INDEX < day_pos) {
1400 r = cal_util_update_tm_day(start_time, DAYS_OF_WEEK);
1401 c_retvm_if(-1 == r, -1, "start_time is out of range.");
1403 r = cal_util_update_tm_day(end_time, DAYS_OF_WEEK);
1404 c_retvm_if(-1 == r, -1, "end_time is out of range.");
1410 static void __cal_month_calendar_set_more_text(Evas_Object *ly, int count, int index)
1412 c_retm_if(!ly, "ly is null");
1413 c_retm_if(index < 0 , "index is wrong");
1415 cal_month_calendar_data* p = CAL_UTIL_GET_PRIV_DATA(ly);
1416 c_retm_if(!p, "p is null");
1417 c_retm_if(!p->ad, "p->ad is null");
1419 char part[32] = {0};
1420 char text[32] = {0};
1422 if (count <= (p->ad->is_landscape_mode ? LINES_OF_WEEKLY_MONTHS_EVENT_LANDSCAPE : LINES_OF_WEEKLY_MONTHS_EVENT)) {
1423 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "hide_count,%d", index);
1425 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "show_count,%d", index);
1426 snprintf(text, sizeof text, "+%d", count - (p->ad->is_landscape_mode ? LINES_OF_WEEKLY_MONTHS_EVENT_LANDSCAPE : LINES_OF_WEEKLY_MONTHS_EVENT));
1427 snprintf(part, sizeof part, "db/%d/count", index);
1428 edje_object_part_text_set(CAL_UTIL_GET_EDJ_DATA(ly), part, text);
1432 static void __cal_month_calendar_create_event_lists(Evas_Object *ly, cal_month_calendar_data *p)
1437 char part[32] = {0};
1440 for (week = 0; week < WEEKS_OF_MONTH; week++) {
1441 snprintf(part, sizeof part, "list/sw/%d", week * DAYS_OF_WEEK);
1442 Evas_Object *events = NULL;
1444 if (p->ad->is_landscape_mode) {
1445 events = cal_util_add_layout(p->ad->nv, "main/month/week/events/l");
1447 events = cal_util_add_layout(p->ad->nv, "main/month/week/events");
1450 c_retm_if(!events, "events is null");
1452 evas_object_data_set(events, "list_index", (void*)week);
1454 elm_object_part_content_set(ly, part, events);
1455 evas_object_event_callback_add(events, EVAS_CALLBACK_MOUSE_DOWN, __cal_month_calendar_mouse_down, p);
1456 evas_object_event_callback_add(events, EVAS_CALLBACK_MOUSE_UP, __cal_month_calendar_mouse_up, p);
1457 evas_object_event_callback_add(events, EVAS_CALLBACK_MOUSE_MOVE, __cal_month_calendar_mouse_move, p);
1459 p->weekly_events_ly[week] = events;
1463 static void __cal_month_calendar_signal_all_week(cal_month_calendar_data *p)
1465 c_retm_if(!p, "p is null");
1468 for (week = 0; week < WEEKS_OF_MONTH; week++)
1469 __cal_month_calendar_signal_week(p, p->weekly_events_ly[week], week);
1472 static void __cal_month_calendar_signal_all_clean(cal_month_calendar_data *p)
1474 c_retm_if(!p, "p is null");
1477 for (i = 0; i < WEEKS_OF_MONTH; i++)
1478 __cal_month_calendar_signal_clean(p,CAL_UTIL_GET_EDJ_DATA(p->weekly_events_ly[i]));
1481 static void __cal_month_calendar_set_check_text(Evas_Object *ly, cal_month_calendar_data *p, int count, int index)
1483 c_retm_if(!ly, "ly is null");
1484 c_retm_if(index < 0 , "index is wrong");
1486 char part[32] = {0};
1487 char text[32] = {0};
1490 p->day[index].checked = 0;
1491 snprintf(part, sizeof part, "db/%d/count", index);
1492 edje_object_part_text_set(CAL_UTIL_GET_EDJ_DATA(ly), part, "");
1494 cal_util_emit_signal(CAL_UTIL_GET_EDJ_DATA(ly), "show_count,%d", index);
1495 p->day[index].checked = 1;
1496 snprintf(text, sizeof text, "+%d", count);
1497 snprintf(part, sizeof part, "db/%d/count", index);
1498 edje_object_part_text_set(CAL_UTIL_GET_EDJ_DATA(ly), part, text);
1502 static void __cal_month_calendar_set_event_rect_color(Evas_Object *obj, cal_month_calendar_data *p, int line, int pos, int calendar_id)
1504 c_retm_if(!obj, "obj is null");
1505 c_retm_if(!p, "p is null");
1508 cal_struct *calendar = NULL;
1509 Calendar_color calendar_color;
1510 Evas_Object *event_content = NULL;
1511 char part[20] = {0};
1513 snprintf(part, sizeof part, "%d/bgcolor/%d", line, pos);
1515 r = CALENDAR_SVC_GET(CAL_STRUCT_CALENDAR, calendar_id, NULL, &calendar);
1516 c_retm_if(CAL_SUCCESS != r , "CALENDAR_SVC_GET is failed");
1518 CALENDAR_SVC_GET_CALENDAR_COLOR(calendar, &calendar_color);
1520 event_content = cal_util_add_rectangle(obj);
1521 c_retm_if(!event_content, "event_content is null");
1523 evas_object_size_hint_align_set(event_content, EVAS_HINT_FILL, 0);
1524 evas_object_size_hint_weight_set(event_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1525 evas_object_color_set(event_content, calendar_color.red, calendar_color.green, calendar_color.blue, calendar_color.alpha);
1527 elm_object_part_content_set(obj, part, event_content);
1529 CALENDAR_SVC_STRUCT_FREE(&calendar);
1533 static void __cal_month_calendar_set_day_default_color(cal_month_calendar_data* p, Evas_Object *eo, int pos)
1535 c_retm_if(!p, "p is null");
1536 c_retm_if(!eo, "eo is null");
1538 struct _day *d = &p->day[pos];
1539 c_retm_if(!d, "d is null");
1541 switch (d->d_type) {
1542 case CAL_MONTH_CALENDAR_DAY_TYPE_SUNDAY:
1543 cal_util_emit_signal(eo, "sunday,%d", pos);
1545 case CAL_MONTH_CALENDAR_DAY_TYPE_SATDAY:
1546 cal_util_emit_signal(eo, "satday,%d", pos);
1548 case CAL_MONTH_CALENDAR_DAY_TYPE_WEEKDAY:
1549 cal_util_emit_signal(eo, "weekday,%d", pos);
1552 cal_util_emit_signal(eo, "weekday,%d", pos);
1557 static void __cal_month_calendar_fill_week_number(Evas_Object *ly)
1559 c_retm_if(!ly, "ly is null");
1562 cal_month_calendar_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
1563 c_retm_if(!p, "p is null");
1565 for (k = 0; k < WEEKS_OF_MONTH; k++) {
1569 struct tm end_time = {0};
1570 struct tm start_time = {0};
1571 __cal_month_calendar_get_day_time_by_pos(p, &start_day, &end_day, &start_time, &end_time, (k + 1) * DAYS_OF_WEEK - 1);
1572 cal_util_get_week_number_text(&start_time, week, sizeof(week) - 1);
1573 cal_util_set_text(CAL_UTIL_GET_EDJ_DATA(ly), cal_util_get_part_text("wn/%d/text", k), "%s", week);