3 * Copyright 2012 Samsung Electronics Co., Ltd
\r
5 * Licensed under the Flora License, Version 1.1 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://floralicense.org/license/
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
19 #include "external-ug.h"
\r
20 #include "detail-common.h"
\r
23 const char *organizer_email;
\r
25 calendar_record_h record;
\r
27 Evas_Object *parent;
\r
28 Evas_Object *genlist;
\r
29 Evas_Object *ctx_popup;
\r
32 Eina_List *attendee_list;
\r
33 Eina_List *required_plist;
\r
34 Eina_List *non_required_plist;
\r
36 Ecore_Event_Handler *event_handler;
\r
38 cal_participant *host;
\r
42 }cal_detail_attendee_data;
\r
44 static char* __cal_detail_attendee_get_genlist_req_header_item_label(void *data, Evas_Object *obj, const char *part);
\r
45 static char* __cal_detail_attendee_get_genlist_non_req_header_item_label(void *data, Evas_Object *obj, const char *part);
\r
47 Elm_Genlist_Item_Class itc_2text = {0};
\r
49 static Elm_Genlist_Item_Class itc_req_h = {
\r
50 .item_style = "grouptitle",
\r
51 .func.text_get = __cal_detail_attendee_get_genlist_req_header_item_label,
\r
55 static Elm_Genlist_Item_Class itc_non_req_h = {
\r
56 .item_style = "grouptitle",
\r
57 .func.text_get = __cal_detail_attendee_get_genlist_non_req_header_item_label,
\r
61 static char *__cal_detail_attendee_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
\r
63 c_retvm_if(!data, NULL, "data is null");
\r
64 c_retvm_if(!obj, NULL, "obj is null");
\r
66 cal_participant *participant = data;
\r
68 if (!CAL_STRCMP(part, "elm.text.1"))
\r
69 return CAL_STRDUP(participant->name);
\r
71 if (!CAL_STRCMP(part, "elm.text.2")) {
\r
73 if (participant->role == CALENDAR_ATTENDEE_ROLE_CHAIR)
\r
74 return strdup(C_("IDS_CLD_BODY_HOST_M_PERSON"));
\r
77 switch (participant->status) {
\r
79 case CALENDAR_ATTENDEE_STATUS_ACCEPTED:
\r
80 return strdup("Attend");
\r
83 case CALENDAR_ATTENDEE_STATUS_DECLINED:
\r
84 return strdup(C_("IDS_CLD_BODY_DECLINED"));
\r
87 case CALENDAR_ATTENDEE_STATUS_TENTATIVE:
\r
88 return strdup(C_("IDS_CLD_BODY_TENTATIVE"));
\r
91 return strdup("Not responded");
\r
99 static void __cal_detail_attendee_popup_hide_callback(void *data, Evas_Object *obj, void *ei)
\r
101 c_retm_if(!data, "data is null");
\r
102 c_retm_if(!obj, "obj is null");
\r
104 cal_detail_attendee_data* p = data;
\r
106 p->ctx_popup = NULL;
\r
108 evas_object_del(obj);
\r
111 static void __cal_detail_parcitipants_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
\r
113 c_retm_if(!data, "data is null");
\r
114 c_retm_if(!obj, "obj is null");
\r
116 cal_participant *part = data;
\r
117 cal_detail_attendee_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
\r
118 c_retm_if(!p, "p is null");
\r
121 evas_object_del(p->ctx_popup);
\r
123 Evas_Object *ctx_popup = p->ctx_popup = elm_ctxpopup_add(obj);
\r
124 c_retm_if(!ctx_popup, "ctx_popup is null");
\r
126 evas_object_smart_callback_add(ctx_popup, "dismissed", __cal_detail_attendee_popup_hide_callback, p);
\r
128 char *email = part->email;
\r
130 if (0 < part->person_id) {
\r
131 cal_detail_common_get_person_default_number(part->person_id, &part->number);
\r
133 char *number = part->number;
\r
135 if (CAL_STRLEN(number)) {
\r
136 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_VOICE_CALL"), NULL, cal_detail_common_ctx_callback_for_voice_call, number);
\r
138 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_MESSAGE"), NULL, cal_detail_common_ctx_callback_for_message, number);
\r
141 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_EMAIL"), NULL, cal_detail_common_ctx_callback_for_email, email);
\r
145 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_BODY_EMAIL"), NULL, cal_detail_common_ctx_callback_for_email, email);
\r
146 elm_ctxpopup_item_append(ctx_popup, S_("IDS_COM_OPT_ADD_TO_CONTACTS"), NULL, cal_detail_common_ctx_callback_for_contact, email);
\r
149 c_retm_if(!p->genlist, "p->genilst is null");
\r
150 elm_genlist_item_selected_set(elm_genlist_selected_item_get(p->genlist), EINA_FALSE);
\r
152 evas_object_data_set(ctx_popup, "record", p->record);
\r
153 evas_object_move(ctx_popup, p->x, p->y);
\r
154 evas_object_show(ctx_popup);
\r
157 static void __cal_detail_attendee_append_genlist_item(cal_detail_attendee_data *p)
\r
159 c_retm_if(!p, "p is null");
\r
161 c_retm_if(!p->genlist, "p->genlist is null");
\r
162 c_retm_if(!p->attendee_list, "p->attendee_list is null");
\r
164 Eina_List *l = NULL;
\r
165 cal_participant *part = NULL;
\r
166 Evas_Object *genlist = p->genlist;
\r
168 Elm_Object_Item *item = NULL;
\r
170 itc_2text.item_style = "dialogue/2text.5";
\r
171 itc_2text.func.text_get = __cal_detail_attendee_get_genlist_item_label;
\r
174 elm_genlist_item_append(genlist, &itc_2text, (void*)p->host, NULL, ELM_GENLIST_ITEM_NONE, __cal_detail_parcitipants_genlist_item_select_callback, part);
\r
176 if (eina_list_count(p->required_plist)) {
\r
177 item = elm_genlist_item_append(genlist, &itc_req_h, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
\r
178 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
\r
179 EINA_LIST_FOREACH(p->required_plist, l, part) {
\r
180 elm_genlist_item_append(genlist, &itc_2text, (void*)part, NULL, ELM_GENLIST_ITEM_NONE, __cal_detail_parcitipants_genlist_item_select_callback, part);
\r
184 if (eina_list_count(p->non_required_plist)) {
\r
185 item = elm_genlist_item_append(genlist, &itc_non_req_h, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
\r
186 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
\r
187 EINA_LIST_FOREACH(p->non_required_plist, l, part) {
\r
188 elm_genlist_item_append(genlist, &itc_2text, (void*)part, NULL, ELM_GENLIST_ITEM_NONE, __cal_detail_parcitipants_genlist_item_select_callback, part);
\r
195 static Eina_Bool __cal_detail_attendee_mouse_down_callback(void *data, int type, void *event)
\r
197 c_retvm_if(!event, EINA_FALSE, "event is null");
\r
198 c_retvm_if(!data, EINA_FALSE, "data is null");
\r
200 Ecore_Event_Mouse_Button *ev = event;
\r
201 cal_detail_attendee_data *p = data;
\r
206 return ECORE_CALLBACK_RENEW;
\r
209 static void __cal_detail_attendee_delete_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
\r
213 c_retm_if(!data, "data is null");
\r
215 cal_detail_attendee_data *p = data;
\r
218 evas_object_del(p->ctx_popup);
\r
220 if (p->event_handler)
\r
221 ecore_event_handler_del(p->event_handler);
\r
223 if (p->attendee_list)
\r
224 eina_list_free(p->attendee_list);
\r
229 static void __cal_detail_attendee_ordering_genlist_item(void *data)
\r
231 c_retm_if(!data, "data is null");
\r
233 cal_participant *part = NULL;
\r
234 cal_detail_attendee_data *p = data;
\r
235 Eina_List *l = NULL;
\r
237 EINA_LIST_FOREACH(p->attendee_list, l, part) {
\r
240 if (p->organizer_email && !strcmp(p->organizer_email, part->email)) {
\r
241 part->role = CALENDAR_ATTENDEE_ROLE_CHAIR;
\r
245 else if (part->role == CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT)
\r
246 p->required_plist = eina_list_append(p->required_plist, part);
\r
248 p->non_required_plist = eina_list_append(p->non_required_plist, part);
\r
253 static const char * __cal_detail_attendee_get_organizer_email(calendar_record_h record)
\r
255 c_retv_if(!record, NULL);
\r
257 char *organizer_email = NULL;
\r
259 calendar_error_e error = CALENDAR_ERROR_NONE;
\r
261 error = calendar_record_get_str_p(record, _calendar_event.organizer_email, &organizer_email);
\r
262 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
\r
264 return organizer_email;
\r
267 static cal_participant * __cal_detail_attendee_append_list(calendar_record_h calendar_attendee)
\r
269 cal_participant *part = calloc(1, sizeof(cal_participant));
\r
270 c_retv_if(!part, NULL);
\r
274 calendar_error_e error = CALENDAR_ERROR_NONE;
276 error = calendar_record_get_str(calendar_attendee, _calendar_attendee.name, &name);
\r
277 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
279 if (!CAL_STRLEN(name)) {
\r
280 ERR("Attendee name is NULL!!");
281 name = S_("IDS_COM_BODY_UNKNOWN");
288 error = calendar_record_get_str(calendar_attendee, _calendar_attendee.email, &email);
\r
289 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_str() is failed(%x)", error);
291 if (CAL_STRLEN(email))
292 part->email = email;
\r
294 ERR("Attendee email is mandatory data!! There is no email for %s.", part->name);
296 error = calendar_record_get_int(calendar_attendee, _calendar_attendee.person_id, &part->person_id);
\r
297 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
299 error = calendar_record_get_int(calendar_attendee, _calendar_attendee.status, &part->status);
\r
300 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
302 error = calendar_record_get_int(calendar_attendee, _calendar_attendee.role, &part->role);
\r
303 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
305 error = calendar_record_get_int(calendar_attendee, _calendar_attendee.rsvp, &part->response);
\r
306 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_int() is failed(%x)", error);
\r
311 static Eina_List * __cal_detail_attendee_get_attendee_list(calendar_record_h record)
\r
313 c_retv_if(!record, NULL);
\r
315 Eina_List *attendee_list = NULL;
\r
317 int attendee_count = 0;
\r
319 calendar_error_e error = CALENDAR_ERROR_NONE;
\r
321 error = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, (unsigned int *)&attendee_count);
\r
322 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_get_child_record_count() is failed(%x)", error);
\r
326 for (i = 0; i < attendee_count; i++) {
\r
327 calendar_record_h calendar_attendee = NULL;
\r
329 error = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_attendee, i, &calendar_attendee);
\r
330 if (error != CALENDAR_ERROR_NONE) {
\r
331 ERR("calendar_record_get_child_record_at_p() is failed(%x)", error);
\r
335 cal_participant *part = __cal_detail_attendee_append_list(calendar_attendee);
\r
338 attendee_list = eina_list_append(attendee_list, part);
\r
341 return attendee_list;
\r
344 static void inline __cal_detail_attendee_clone_record(const calendar_record_h source_record, calendar_record_h *target_record)
\r
348 c_ret_if(!source_record);
\r
349 c_ret_if(!target_record);
\r
351 calendar_error_e error = CALENDAR_ERROR_NONE;
\r
353 error = calendar_record_clone(source_record, target_record);
\r
354 c_warn_if(error != CALENDAR_ERROR_NONE, "calendar_record_clone() is failed(%x)", error);
\r
357 void cal_detail_attendee_create_view(Evas_Object *naviframe, calendar_record_h record)
\r
359 c_retm_if(!naviframe, "naviframe is null.");
\r
360 c_retm_if(!record, "participants_list is null.");
\r
362 cal_detail_attendee_data *p = calloc(1, sizeof(cal_detail_attendee_data));
\r
363 c_retm_if(!p, "p is null");
\r
365 __cal_detail_attendee_clone_record(record, &p->record);
\r
367 p->attendee_list = __cal_detail_attendee_get_attendee_list(p->record);
\r
368 p->organizer_email = __cal_detail_attendee_get_organizer_email(p->record);
\r
369 __cal_detail_attendee_ordering_genlist_item(p);
\r
371 Evas_Object *ly = cal_util_add_layout(naviframe, "list/base");
\r
379 evas_object_data_set(ly, "priv", p);
\r
380 edje_object_signal_emit(CAL_UTIL_GET_EDJ_DATA(ly), "searchbar,hide", "prog");
\r
382 p->bg = cal_util_add_bg(ly,EINA_FALSE);
\r
384 ERR("cal_util_add_bg returned null");
\r
385 evas_object_del(ly);
\r
389 elm_object_part_content_set(ly, "base", p->bg);
\r
391 p->genlist = elm_genlist_add(naviframe);
\r
392 c_retm_if(!p->genlist, "p->genlist is null");
\r
393 evas_object_show(p->genlist);
\r
395 evas_object_event_callback_add(p->genlist, EVAS_CALLBACK_DEL, __cal_detail_attendee_delete_callback, p);
\r
397 evas_object_data_set(p->genlist, "priv", p);
\r
399 __cal_detail_attendee_append_genlist_item(p);
\r
401 elm_object_part_content_set(ly, "sw", p->genlist);
\r
403 p->event_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __cal_detail_attendee_mouse_down_callback, p);
\r
404 c_warn_if(!p->event_handler, "p->event_handler is null");
\r
407 Elm_Object_Item *navi_item = elm_naviframe_item_push(naviframe, C_("IDS_CLD_BODY_ATTENDANCE_STATUS"), NULL, NULL, ly, NULL);
\r
408 c_retm_if(!navi_item, "navi_item is null");
\r
410 Evas_Object *back_button = elm_object_item_part_content_get(navi_item, "prev_btn");
\r
413 ERR("elm_object_item_part_content_get returned null");
\r
414 elm_naviframe_item_pop(naviframe);
\r
415 evas_object_del(p->genlist);
\r
419 elm_object_style_set(back_button, "naviframe/back_btn/default");
\r
423 static char* __cal_detail_attendee_get_genlist_req_header_item_label(void *data, Evas_Object *obj, const char *part)
\r
425 if (!CAL_STRCMP(part, "elm.text")) {
\r
427 const char* text = "Required participant";
\r
428 return strdup(text);
\r
434 static char* __cal_detail_attendee_get_genlist_non_req_header_item_label(void *data, Evas_Object *obj, const char *part)
\r
436 if (!CAL_STRCMP(part, "elm.text")) {
\r
438 const char* text = "Non-required participant";
\r
439 return strdup(text);
\r