[misc] Sync from master branch.
[apps/core/preloaded/calendar.git] / ug / list / ug.c
index 02ae2ba..b972524 100755 (executable)
@@ -21,6 +21,7 @@
 
 #include "cld.h"
 #include "ug.h"
+#include "appcontrol.h"
 
 // TODO: get full path from caller
 #define VFILE_PATH "/opt/usr/media/Others"
@@ -80,54 +81,41 @@ static char* __cal_ug_get_file_path(service_h b, const char *key)
        return path;
 }
 
-static enum cld_ug_mode __cal_ug_get_mode(service_h service, const char *key)
+static cal_appcontrol_result_type __cal_ug_get_result_type(service_h service, const char *key)
 {
-       c_retv_if(!service, _MODE_UNKNOWN);
-       c_retv_if(!key, _MODE_UNKNOWN);
+       cal_appcontrol_result_type result_type = RESULT_TYPE_VCS;
+
+       c_retv_if(!service, result_type);
+       c_retv_if(!key, result_type);
 
        char *value = NULL;
 
        int r = service_get_extra_data(service, key, &value);
-       c_retvm_if(r != SERVICE_ERROR_NONE, _MODE_GET_VCS, "%d", r);
+       if (r != SERVICE_ERROR_NONE) {
+               CAL_FREE(value);
 
-       enum cld_ug_mode ret;
+               return result_type;
+       }
 
        if (!CAL_STRCMP(value, "text"))
-               ret =  _MODE_GET_EVT;
-       else if (!CAL_STRCMP(value, "view"))
-               ret =  _MODE_VIEW_VCS;
+               result_type = RESULT_TYPE_ITEM_CONTENT;
 
-       else
-               ret =  _MODE_GET_VCS;
-       free(value);
+       CAL_FREE(value);
 
-       return ret;
+       return result_type;
 }
 
-static inline int __cal_ug_set_ug_data(struct ug_data *ugd, service_h service)
+static void __cal_ug_get_ug_input_data(service_h service, struct ug_data *ugd)
 {
-       c_retv_if(!service, -1);
-       int val;
+       c_ret_if(!service);
 
-       ugd->mode = __cal_ug_get_mode(service, "mode");
+       int val = 0;
+
+       ugd->result_type = __cal_ug_get_result_type(service, "mode");
 
        char *selection_mode = NULL;
        char *item_type = NULL;
 
-       service_get_extra_data(service, CAL_APPCONTROL_SELECTION_MODE, &selection_mode);
-
-       if (!CAL_STRCMP(selection_mode, CAL_APPCONTROL_SELECTION_MODE_SINGLE))
-               ugd->selection_mode = SELECTION_MODE_SINGLE;
-       else
-               ugd->selection_mode = SELECTION_MODE_MULTIPLE;
-
-       service_get_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, &item_type);
-
-       if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_TODO))
-               ugd->item_type = ITEM_TYPE_TODO;
-       else
-               ugd->item_type = ITEM_TYPE_EVENT;
-
        int r = vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &val);
        if (r < 0)
                is_hour24 = 0;
@@ -136,30 +124,8 @@ static inline int __cal_ug_set_ug_data(struct ug_data *ugd, service_h service)
        else
                ERR("vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &val); error");
 
-       switch (ugd->mode) {
-       case _MODE_GET_VCS:
-               ugd->caller = __cal_ug_get_caller(service, "caller");
-               break;
-       case _MODE_VIEW_VCS:
-               ugd->vcs_file = __cal_ug_get_file_name(service, "file");
-               if (!ugd->vcs_file)
-               {
-                       ERR("UG: Invalid filename");
-                       return -1;
-               }
-               break;
-       default:
-               // do nothing
-               break;
-       }
-
-       if (selection_mode)
-               free(selection_mode);
-
-       if (item_type)
-               free(item_type);
+               ugd->selection_mode = SELECTION_MODE_MULTIPLE;
 
-       return 0;
 }
 
 static void __cal_ug_back_button_callback(void *data, Evas_Object *obj, void *ei)
@@ -174,12 +140,12 @@ static void __cal_ug_back_button_callback(void *data, Evas_Object *obj, void *ei
 
        service_create(&service);
 
-       service_add_extra_data(service, CAL_APPCONTROL_RESULT, CAL_APPCONTROL_RESULT_CANCEL);
+       service_add_extra_data(service, "result", "cancel");
 
        if (ugd->item_type == ITEM_TYPE_EVENT)
-               service_add_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, CAL_APPCONTROL_ITEM_TYPE_EVENT);
+               service_add_extra_data(service, "itemType", "event");
        else
-               service_add_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, CAL_APPCONTROL_ITEM_TYPE_TODO);
+               service_add_extra_data(service, "itemType", "todo");
 
        ug_send_result(ugd->ug, service);
 
@@ -227,19 +193,7 @@ static Evas_Object *__cal_ug_create(Evas_Object *parent, struct ug_data *ugd)
        elm_object_part_content_set(ugd->base, "elm.swallow.content", ugd->naviframe);
        elm_object_part_content_set(ugd->base, "elm.swallow.bg", ugd->bg);
 
-       switch (ugd->mode) {
-       case _MODE_GET_EVT:
-       case _MODE_GET_VCS:
-
-               cal_list_ug_create(S_("IDS_COM_BODY_CALENDAR"), ugd);
-               break;
-       case _MODE_VIEW_VCS:
-               cal_vcs_viewer_ug_create(ugd);
-               break;
-       default:
-               // do nothing
-               break;
-       }
+       cal_list_ug_create(S_("IDS_COM_BODY_CALENDAR"), ugd);
 
        if (!ugd->cont) {
                evas_object_del(ugd->base);
@@ -257,6 +211,95 @@ static void __cal_ug_free_data(struct ug_data *ugd)
 
        free(ugd->vcs_file);
 }
+static void __cal_ug_get_appcontrol_input_data(service_h service, struct ug_data *ugd)
+{
+       char *selection_mode = NULL;
+
+       service_get_extra_data(service, CAL_APPCONTROL_SELECTION_MODE, &selection_mode);
+
+       if (!CAL_STRCMP(selection_mode, CAL_APPCONTROL_SELECTION_MODE_MULTIPLE))
+               ugd->selection_mode = SELECTION_MODE_MULTIPLE;
+       else
+               ugd->selection_mode = SELECTION_MODE_SINGLE;
+
+       CAL_FREE(selection_mode);
+
+       char *item_type = NULL;
+
+       int r = service_get_extra_data(service, CAL_APPCONTROL_ITEM_TYPE, &item_type);
+       if (r != SERVICE_ERROR_NONE) {
+               ERR("service_get_extra_data(%s) is failed(%x).", CAL_APPCONTROL_ITEM_TYPE, r);
+
+               CAL_FREE(item_type);
+
+               return;
+       }
+
+       if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_EVENT))
+               ugd->item_type = ITEM_TYPE_EVENT;
+       else if (!CAL_STRCMP(item_type, CAL_APPCONTROL_ITEM_TYPE_TODO))
+               ugd->item_type = ITEM_TYPE_TODO;
+       else
+               ugd->item_type = ITEM_TYPE_EVENT_TODO;
+
+       CAL_FREE(item_type);
+
+       char *result_type = NULL;
+
+       r = service_get_extra_data(service, CAL_APPCONTROL_RESULT_TYPE, &result_type);
+       if (r != SERVICE_ERROR_NONE) {
+               ERR("service_get_extra_data(%s) is failed(%x).", CAL_APPCONTROL_RESULT_TYPE, r);
+
+               CAL_FREE(result_type);
+
+               return;
+       }
+
+       if (!CAL_STRCMP(result_type, CAL_APPCONTROL_RESULT_TYPE_ITEM_ID))
+               ugd->result_type = RESULT_TYPE_ITEM_ID;
+       else
+               ugd->result_type = RESULT_TYPE_VCS;
+
+       CAL_FREE(result_type);
+}
+
+static void __cal_ug_get_appcontrol_input_data_old(service_h service, struct ug_data *ugd)
+{
+       int r = 0;
+
+       char *selection_mode = NULL;
+
+       r = service_get_extra_data(service, "selectionMode", &selection_mode);
+       if (r != SERVICE_ERROR_NONE) {
+               ERR("service_get_extra_data(%s) is failed(%x).", "selectionMode", r);
+
+               CAL_FREE(selection_mode);
+
+               return;
+       }
+
+       if (!CAL_STRCMP(selection_mode, "single"))
+               ugd->selection_mode = SELECTION_MODE_SINGLE;
+       else
+               ugd->selection_mode = SELECTION_MODE_MULTIPLE;
+
+       CAL_FREE(selection_mode);
+
+       char *item_type = NULL;
+
+       service_get_extra_data(service, "itemType", &item_type);
+
+       if (!CAL_STRCMP(item_type, "todo"))
+               ugd->item_type = ITEM_TYPE_TODO;
+       else if (!CAL_STRCMP(item_type, "event"))
+               ugd->item_type = ITEM_TYPE_EVENT;
+       else
+               ugd->item_type = ITEM_TYPE_EVENT_TODO;
+
+       CAL_FREE(item_type);
+
+       ugd->result_type = RESULT_TYPE_VCS;
+}
 
 static void *__cal_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
 {
@@ -273,6 +316,20 @@ static void *__cal_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service
        ugd = priv;
        ugd->ug = ug;
 
+       char *operation = NULL;
+
+       r = service_get_operation(service, &operation);
+       c_retvm_if(r != SERVICE_ERROR_NONE, NULL, "service_get_operation() is failed(%x)", r);
+
+       if (!CAL_STRCMP(operation, CAL_APPCONTROL_SOCAIL_PICK))
+               __cal_ug_get_appcontrol_input_data(service, ugd);
+       else if (!CAL_STRCMP(operation, SERVICE_OPERATION_PICK))
+               __cal_ug_get_appcontrol_input_data_old(service, ugd);
+       else
+               __cal_ug_get_ug_input_data(service, ugd);
+
+       CAL_FREE(operation);
+
        cal_util_connect_pattern_generator();
 
        if (mode != UG_MODE_FULLVIEW)
@@ -281,8 +338,6 @@ static void *__cal_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service
        Evas_Object *parent = ug_get_parent_layout(ug);
        c_retv_if(!parent, NULL);
 
-       r = __cal_ug_set_ug_data(ugd, service);
-       c_retv_if(r, NULL);
        calendar_error_e err = CALENDAR_ERROR_NONE;
        err = calendar_connect();
        c_warn_if(err != CALENDAR_ERROR_NONE, "calendar_connect is failed(%d)", err);
@@ -295,6 +350,8 @@ static void *__cal_ug_create_callback(ui_gadget_h ug, enum ug_mode mode, service
                return NULL;
        }
 
+       elm_theme_extension_add(NULL, "/usr/apps/"CALENDAR_PACKAGE"/res/edje/theme3.edj");
+
        base = __cal_ug_create(parent, ugd);
        if (!base) {
                calendar_error_e error = CALENDAR_ERROR_NONE;