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.
18 #include <ui-gadget-module.h>
20 #include "edit-view.h"
22 #define CAL_EDIT_UG "calendar-edit-efl"
26 cal_edit_view_destroy_callback callback;
30 static void __cal_edit_layout_callback(ui_gadget_h ug, enum ug_mode mode, void *priv)
34 c_retm_if(!ug, "ug is null");
36 Evas_Object *base = ug_get_layout(ug);
44 case UG_MODE_FULLVIEW:
45 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
46 evas_object_show(base);
49 DBG("Unsupported ug layout");
55 static void __cal_edit_destroy_callback(ui_gadget_h ug, void *priv)
65 cal_edit_view_data *view_data = priv;
67 if (view_data->callback)
68 view_data->callback(view_data->callback_data);
70 view_data->ad->ug = NULL;
75 static void inline __cal_edit_clone_record(const calendar_record_h source_record, calendar_record_h *target_record)
79 c_ret_if(!source_record);
80 c_ret_if(!target_record);
82 calendar_error_e error = CALENDAR_ERROR_NONE;
84 error = calendar_record_clone(source_record, target_record);
85 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_clone() is failed(%x)", error);
88 static void inline __cal_edit_destroy_record(calendar_record_h record)
94 calendar_error_e error = CALENDAR_ERROR_NONE;
96 error = calendar_record_destroy(record, true);
97 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_destroy() is failed(%x)", error);
99 void cal_edit_create_view(struct appdata *ad, calendar_record_h record, cal_edit_view_destroy_callback callback, void *callback_data)
110 struct ug_cbs ug_callback = {0};
112 cal_edit_view_data *view_data = NULL;
114 view_data = calloc(1, sizeof(cal_edit_view_data));
118 view_data->callback = callback;
119 view_data->callback_data = callback_data;
124 ug_callback.layout_cb = __cal_edit_layout_callback;
125 ug_callback.destroy_cb = __cal_edit_destroy_callback;
126 ug_callback.priv = view_data;
128 service_h service = NULL;
130 service_error_e error = SERVICE_ERROR_NONE;
132 error = service_create(&service);
133 if (error != SERVICE_ERROR_NONE) {
134 ERR("service_create() is failed(%x)", error);
141 calendar_record_h cloned_record = NULL;
143 __cal_edit_clone_record(record, &cloned_record);
145 char record_address[16] = {0};
146 snprintf(record_address, sizeof(record_address), "%p", (void *)cloned_record);
148 error = service_add_extra_data(service, "record", record_address);
149 if(error != SERVICE_ERROR_NONE) {
150 ERR("service_add_extra_data(%s,%s) is failed(%x)", "record", record_address, error);
152 service_destroy(service);
159 long long int lli_time = 0;
160 cal_util_convert_tm_to_lli(NULL, &ad->base_tm, &lli_time);
161 snprintf(time, sizeof(time), "%lli", lli_time);
163 error = service_add_extra_data(service, "base_time", time);
164 if(error != SERVICE_ERROR_NONE) {
165 ERR("service_add_extra_data(%s,%s) is failed(%x)", "base_time", time, error);
167 service_destroy(service);
172 ui_gadget_h ug = ug_create(NULL, CAL_EDIT_UG, UG_MODE_FULLVIEW, service, &ug_callback);
174 ERR("ug_create(%s) is failed.", CAL_EDIT_UG);
176 service_destroy(service);
183 service_destroy(service);