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://floralicense.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.
19 #include "view-day-list.h"
20 #include "detail-view.h"
21 #include "noti-handler.h"
23 #include "list-base.h"
38 static void __cal_day_list_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
42 cal_day_list_data *p = data;
43 c_retm_if(!p, "priv is null.");
44 cal_list_base_delete(p->list);
50 Evas_Object* cal_day_list_create(struct appdata *ad, Evas_Object *parent)
55 c_retv_if(!parent, NULL);
57 cal_day_list_data *p = calloc(1, sizeof(cal_day_list_data));
62 Evas_Object *layout = cal_util_add_layout(parent, "list/base/without_searchbar");
63 ad->tapbar_focus_view = CV_LIST;
68 ERR("layout is null.");
73 evas_object_data_set(layout, "priv", p);
77 elm_object_disabled_set(p->ad->new_event_button, EINA_FALSE);
79 Evas_Object *bg = cal_util_add_bg(layout, EINA_FALSE);
90 elm_object_part_content_set(layout, "base", bg);
92 evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, __cal_day_list_delete_layout, p);
94 char buffer[128] = {0};
95 cal_util_get_time_text(buffer, sizeof(buffer), CAL_UTIL_DATE_FORMAT_1, NULL, &ad->base_tm);
97 elm_naviframe_item_push(ad->naviframe, strdup(buffer), NULL, NULL, layout, NULL);
104 static void __cal_day_list_add_each_event_to_genlist(calendar_record_h record, void* data)
106 cal_day_list_data* p = (cal_day_list_data*)data;
107 cal_list_base_add_item(p->list, record, false);
110 void cal_day_list_update_list(Evas_Object *ly)
116 cal_day_list_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
119 struct appdata *ad = p->ad;
122 p->tm_start = ad->base_tm;
123 p->tm_start.tm_hour = 0;
124 p->tm_start.tm_min = 0;
125 p->tm_start.tm_sec = 0;
127 p->tm_end = p->tm_start;
128 p->tm_end.tm_hour = 23;
129 p->tm_end.tm_min = 59;
130 p->tm_end.tm_sec = 59;
132 cal_util_update_tm_month(&p->tm_start, -3);
133 cal_util_update_tm_month(&p->tm_end, 3);
135 cal_list_base_clear(p->list);
137 ad->today_item = NULL;
139 calendar_query_h query = cal_query_create_list_range_query(
140 _calendar_instance_normal_calendar_book._uri,
141 _calendar_instance_normal_calendar_book.start_time,
142 _calendar_instance_normal_calendar_book.end_time,
143 &p->tm_start, &p->tm_end, false);
145 calendar_list_h list = NULL;
146 calendar_error_e error =
147 calendar_db_get_records_with_query(query, 0, 0, &list);
148 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_db_get_records_with_query() has failed(%x)", error);
150 error = calendar_list_first(list);
151 if (error != CALENDAR_ERROR_NONE) {
152 ERR("calendar_list_first() is failed(%x)", error);
153 calendar_query_destroy(query);
157 p->list = cal_list_base_create(ad, p->layout, "sw", true, NULL, NULL);
159 cal_do_for_each_record_in_list(list, __cal_day_list_add_each_event_to_genlist, p);
161 calendar_list_destroy(list, false);
162 calendar_query_destroy(query);