TizenRefApp-5292 [Wallpaper] refactor code 36/82236/2
authorDmytro Dragan <dm.dragan@samsung.com>
Fri, 29 Jul 2016 13:02:27 +0000 (16:02 +0300)
committerDmytro Dragan <dm.dragan@samsung.com>
Tue, 2 Aug 2016 08:02:43 +0000 (11:02 +0300)
Change-Id: I98ca954497da9aa62eb339e8250eaeab9a0e512c
Signed-off-by: Dmytro Dragan <dm.dragan@samsung.com>
inc/wallpaper-ui-service.h
src/wallpaper-ui-service-main.c
src/wallpaper-ui-service.c

index c953dcb..ec403d0 100644 (file)
 #define GENGRID_ITEM_SIZE (126)
 #define MAX_LENGTH_LINE 2001
 #define MAX_LENGTH_STRING 4096
-#define MAX_MULTIPLE_SELECTION 6
 
 
 #if !defined(PACKAGEID)
 #define PACKAGEID "org.tizen.wallpaper-ui-service"
 #endif
 
-#define EXTRA_KEY_FILE "file_path"
-#define EXTRA_KEY_POPUP_TYPE "popup_type"
-
-typedef enum {
-       WALLPAPER_POPUP_TYPE_NONE = 0,
-       WALLPAPER_POPUP_TYPE_SELECTION,
-       WALLPAPER_POPUP_TYPE_THEME,
-} wallpaper_popup_type;
-
-#define EXTRA_KEY_WALLPAPER_TYPE "wallpaper_type"
-
-#define EXTRA_DATA_WP_DEFAULT "default"
-#define EXTRA_DATA_WP_MULTI    "multi"
-
 typedef enum {
        WALLPAPER_TYPE_DEFAULT = 0,
        WALLPAPER_TYPE_GALLERY,
-       WALLPAPER_TYPE_MULTIPLE,
        WALLPAPER_TYPE_MAX
 } wallpaper_img_type;
 
-
-#define EXTRA_FROM_KEY "from"
-
-typedef enum {
-       WALLPAPER_POPUP_FROM_NONE = 0,
-       WALLPAPER_POPUP_FROM_HOME_SCREEN,
-       WALLPAPER_POPUP_FROM_LOCK_SCREEN,
-       WALLPAPER_POPUP_FROM_SETTING,
-       WALLPAPER_POPUP_FROM_GALLERY,
-} wallpaper_popup_from;
-
-
-#define EXTRA_KEY_SETAS "setas-type"
-
-#define EXTRA_DATA_HOMESCREEN "Homescreen"
-#define EXTRA_DATA_LOCKSCREEN  "Lockscreen"
-#define EXTRA_DATA_HOME_N_LOCKSCREEN   "Home&Lockscreen"
-
-typedef enum {
-       WALLPAPER_POPUP_SETAS_NONE = 0,
-       WALLPAPER_POPUP_SETAS_HOMESCREEN,
-       WALLPAPER_POPUP_SETAS_LOCKSCREEN,
-       WALLPAPER_POPUP_SETAS_HOME_N_LOCKSCREEN
-} wallpaper_popup_menu;
-
-
-#define DiSABLE_CROP_VIEW 0
-#define DISABLE_MULTISELECTION 1
-
-typedef struct _popup_colortheme_data {
-       Evas_Object *popup;
-
-       int theme_index;
-       char *file_path;
-} popup_colortheme_data;
-
-typedef struct _popup_wallpaper_data {
-       Evas_Object *win_main;
-       Evas_Object *base;
-
-       Evas_Object *act_pop;
-       int launch_from;
-       int setas_type;
-} popup_wallpaper_data;
-
-typedef struct page_data {
-       Evas_Object *scroller;
-       Evas_Object *index;
-       Evas_Object *page[2];
-       Elm_Object_Item *last_it;
-       Elm_Object_Item *new_it;
-       int current_page;
-       Evas_Object *home_icon;
-       Evas_Object *lockscreen_icon;
-       Evas_Object *main_layout;
-} page_data_s;
-
-typedef struct preview_page_data {
-       Evas_Object *scroller;
-       Evas_Object *page[6];
-       int current_page;
-} preview_page_data_s;
-
-
 typedef struct _wallpaper_ui_service_appdata {
 
        Evas_Object *navi_bar;
        Evas *evas;
        Evas_Object *win;
        Evas_Object *layout;
-       int request_type;
-
-       app_control_h service;  // clone service to reply when terminate
-       popup_wallpaper_data sel_popup_data;
-       popup_colortheme_data color_popup_data;
-       int popup_type;
-       int lock_wallpaper_type;
-
-       unsigned int caller_win_id;
-       unsigned int wallpaper_win_id;
-       page_data_s *pd;
        Evas_Object *main_layout;
-       Evas_Object *thumnail_layout;
-       Evas_Object *box;
-       Evas_Object *popup;
        Evas_Object *preview_image;
        int preview_image_type;
-       Elm_Object_Item *main_nf_it;
     Evas_Object *gengrid;
 
+    // DBus doesn't work any more in this case. Replace this in scope of TizenRefApp-6828
        E_DBus_Connection *dbus_conn;
        E_DBus_Signal_Handler *dbus_home_button_handler;
 
     char* last_preview_img_path;
     char current_preview_img_path[MAX_LENGTH_LINE];
-       char saved_img_path[6][MAX_LENGTH_LINE];
+       char saved_img_path[MAX_LENGTH_LINE];
 } wallpaper_ui_service_appdata;
 
 HAPI int wallpaper_ui_service_copy_wallpaper_file(const char *source, char *destination);
index fa067fc..8e64c63 100644 (file)
@@ -42,14 +42,14 @@ static struct _wallpaper_ui_service_state_data {
     Eina_Bool flag_changed;
     Eina_Bool flag_edit_click;
     Eina_Bool flag_image_from_gallery;
-       char *from[MAX_LENGTH_LINE];
-       char *to[MAX_LENGTH_LINE];
+       char *from;
+       char *to;
 } state_data = {
     .flag_changed = EINA_FALSE,
     .flag_edit_click = EINA_FALSE,
     .flag_image_from_gallery = EINA_FALSE,
-       .from = { NULL, },
-       .to = { NULL, },
+       .from = NULL,
+       .to = NULL,
 };
 
 
@@ -69,7 +69,6 @@ enum {
 };
 
 struct scaledata {
-       int img_idx;
        int to_w;
        int to_h;
 
@@ -91,7 +90,7 @@ struct scaledata {
 
 static void _wallpaper_destroy(void *data);
 static Evas_Object *main_gengrid_add(Evas_Object *parent, void *data);
-static int _lockscreen_gallery_scale_job_maker(int to_w, int to_h, int idx);
+static int _lockscreen_gallery_scale_job_maker(int to_w, int to_h);
 static void _lockscreen_gallery_destroy_func();
 static void _wallpaper_show_focus_highlight(int selected_index) ;
 static void _done_to_set_wallpaper();
@@ -99,40 +98,6 @@ static void _wallpaper_back_key_cb(void *data, Evas_Object *obj, void *event_inf
 static void _preview_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _wallpaper_preview_main();
 
-static int _lockscreen_gallery_file_cb(const char *src, const char *dst)
-{
-       WALLPAPERUI_TRACE_BEGIN;
-
-       FILE *f1, *f2;
-       char buf[16384];
-       size_t num;
-       int ret = 1;
-
-       f1 = fopen(src, "rb");
-       if (!f1) {
-               return 0;
-       }
-
-       f2 = fopen(dst, "wb");
-       if (!f2) {
-               fclose(f1);
-               return 0;
-       }
-
-       while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) {
-               if (fwrite(buf, 1, num, f2) != num) {
-                       ret = 0;
-
-               }
-       }
-
-       fclose(f1);
-       fclose(f2);
-
-       WALLPAPERUI_TRACE_END;
-       return ret;
-}
-
 static void _rotate_right(Evas_Object *image)
 {
        WALLPAPERUI_TRACE_BEGIN;
@@ -204,7 +169,7 @@ static void _rotate_right(Evas_Object *image)
        evas_object_image_data_set(image, data1);
        evas_object_image_data_update_add(image, 0, 0, iw, ih);
 
-       WALLPAPERUI_TRACE_BEGIN;
+       WALLPAPERUI_TRACE_END;
 }
 
 static void _rotate_left(Evas_Object *image)
@@ -422,23 +387,22 @@ static Eina_Bool _lockscreen_gallery_scale_job_0(void *data)
                return ECORE_CALLBACK_CANCEL;
        }
 
-       if (state_data.from[sd->img_idx]) {
-               WALLPAPERUI_DBG("from[%s]", state_data.from[sd->img_idx]);
-               WALLPAPERUI_DBG("to[%s]", state_data.to[sd->img_idx]);
+       if (state_data.from) {
+               WALLPAPERUI_DBG("from[%s]", state_data.from);
+               WALLPAPERUI_DBG("to[%s]", state_data.to);
 
-               evas_object_image_file_set(sd->img, state_data.from[sd->img_idx], NULL);
+               evas_object_image_file_set(sd->img, state_data.from, NULL);
                err = evas_object_image_load_error_get(sd->img);
                if (err != EVAS_LOAD_ERROR_NONE) {
                        WALLPAPERUI_ERR("evas_object_image_file_set() failed");
-                       WALLPAPERUI_ERR("file(%s) err(%s)", state_data.from[sd->img_idx], evas_load_error_str(err));
+                       WALLPAPERUI_ERR("file(%s) err(%s)", state_data.from, evas_load_error_str(err));
                        sd->next_job = SCALE_JOB_ERR;
                        return ECORE_CALLBACK_CANCEL;
                }
 
-               WALLPAPERUI_DBG("from[i]:%s", state_data.from[sd->img_idx]);
-               if (!strstr(state_data.from[sd->img_idx], "wallpaper_list")) {
-                       WALLPAPERUI_DBG("need rotateRight:%s", state_data.from[sd->img_idx]);
-                       _rotate_image(sd->img, state_data.from[sd->img_idx]);
+               if (!strstr(state_data.from, "wallpaper_list")) {
+                       WALLPAPERUI_DBG("need rotateRight:%s", state_data.from);
+                       _rotate_image(sd->img, state_data.from);
                }
 
                evas_object_image_alpha_set(sd->img, EINA_FALSE);
@@ -446,8 +410,8 @@ static Eina_Bool _lockscreen_gallery_scale_job_0(void *data)
 
                if ((sd->img_w == sd->to_w && sd->img_h >= sd->to_h) ||
                        (sd->img_h == sd->to_h && sd->img_w >= sd->to_w)) {
-                       WALLPAPERUI_DBG("No need to be scaled. cp(%s, %s)", state_data.from[sd->img_idx], state_data.to[sd->img_idx]);
-                       _lockscreen_gallery_file_cb(state_data.from[sd->img_idx], state_data.to[sd->img_idx]);
+                       WALLPAPERUI_DBG("No need to be scaled. cp(%s, %s)", state_data.from, state_data.to);
+                       wallpaper_ui_service_copy_wallpaper_file(state_data.from, state_data.to);
                        WALLPAPERUI_DBG("cp end");
                        sd->next_job = SCALE_JOB_END;
                        return ECORE_CALLBACK_CANCEL;
@@ -473,7 +437,7 @@ static Eina_Bool _lockscreen_gallery_scale_job_1(void *data)
 
        sd->to_w = (float)sd->img_w / sd->img_h * sd->to_h;
 
-       WALLPAPERUI_DBG("idx(%d) img_w(%d) img_h(%d)", sd->img_idx, sd->img_w, sd->img_h);
+       WALLPAPERUI_DBG("img_w(%d) img_h(%d)", sd->img_w, sd->img_h);
        WALLPAPERUI_DBG(" -> to_w(%d) to_h(%d)", sd->to_w, sd->to_h);
        ecore_evas_resize(sd->ee, sd->to_w, sd->to_h);
        evas_object_resize(sd->img, sd->to_w, sd->to_h);
@@ -547,12 +511,12 @@ static Eina_Bool _lockscreen_gallery_scale_job_5(void *data)
        struct scaledata *sd = data;
        WALLPAPERUI_DBG("DBG 5 : save image");
 
-       Eina_Bool b = evas_object_image_save(sd->o, state_data.to[sd->img_idx], NULL, "quality=100 compress=4");
+       Eina_Bool b = evas_object_image_save(sd->o, state_data.to, NULL, "quality=100 compress=4");
        if (b == EINA_FALSE) {
-               WALLPAPERUI_DBG("evas_object_image_save to %s fail!", state_data.to[sd->img_idx]);
+               WALLPAPERUI_DBG("evas_object_image_save to %s fail!", state_data.to);
        }
 
-       _set_wallpaper(state_data.to[sd->img_idx]);
+       _set_wallpaper(state_data.to);
        sd->next_job = job_idx+1;
 
        WALLPAPERUI_TRACE_END;
@@ -564,30 +528,15 @@ static Eina_Bool _lockscreen_gallery_scale_job_end(void *data)
        WALLPAPERUI_TRACE_BEGIN;
 
        struct scaledata *sd = data;
-       int idx = 0;
 
        if (sd->ee) {
                ecore_evas_free(sd->ee);
        }
 
-       if (state_data.from[sd->img_idx+1] == NULL) {
-               WALLPAPERUI_ERR("There is no image to process : ALL job end");
-               free(sd);
-               _lockscreen_gallery_destroy_func();
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       idx = sd->img_idx;
-
-       free(sd);
-
-       if (_lockscreen_gallery_scale_job_maker(480, 800, idx+1) != 0) {
-               WALLPAPERUI_DBG("All job end");
-               _lockscreen_gallery_destroy_func();
-       }
-
-       WALLPAPERUI_TRACE_END;
-       return ECORE_CALLBACK_CANCEL;
+    free(sd);
+    _lockscreen_gallery_destroy_func();
+    WALLPAPERUI_TRACE_END;
+    return ECORE_CALLBACK_CANCEL;
 }
 
 static Eina_Bool _lockscreen_gallery_scale_job_handler(void *data)
@@ -596,7 +545,7 @@ static Eina_Bool _lockscreen_gallery_scale_job_handler(void *data)
 
        struct scaledata *sd = data;
 
-       WALLPAPERUI_DBG("idx(%d) curr(%d) next(%d)", sd->img_idx, sd->curr_job, sd->next_job);
+       WALLPAPERUI_DBG("curr(%d) next(%d)", sd->curr_job, sd->next_job);
        sd->curr_job = sd->next_job;
 
        switch (sd->curr_job) {
@@ -640,7 +589,7 @@ static Eina_Bool _lockscreen_gallery_scale_job_handler(void *data)
        return ECORE_CALLBACK_RENEW;
 }
 
-static int _lockscreen_gallery_scale_job_maker(int to_w, int to_h, int idx)
+static int _lockscreen_gallery_scale_job_maker(int to_w, int to_h)
 {
        WALLPAPERUI_TRACE_BEGIN;
 
@@ -648,9 +597,8 @@ static int _lockscreen_gallery_scale_job_maker(int to_w, int to_h, int idx)
        struct scaledata *sd = calloc(1, sizeof(struct scaledata));
        scale_resize_state = 1;
 
-       WALLPAPERUI_DBG("make scale log(%d)", idx);
+       WALLPAPERUI_DBG("make scale log");
        if (sd != NULL) {
-               sd->img_idx = idx;
                sd->to_w = to_w;
                sd->to_h = to_h;
                sd->curr_job = job_idx;
@@ -674,7 +622,7 @@ static void _main_done_button_cb(void *data, Evas_Object *obj, void *event_info)
                        s_item = (Thumbnail *)elm_object_item_data_get(object_item);
                        if (s_item && s_item->path && s_item->bSelected) {
                                WALLPAPERUI_DBG("Done button Selected path=%s %d", s_item->path, s_item->index);
-                               strncpy(ad->saved_img_path[0], s_item->path, MAX_LENGTH_LINE - 1);
+                               strncpy(ad->saved_img_path, s_item->path, MAX_LENGTH_LINE - 1);
                                _done_to_set_wallpaper();
                        }
                        object_item = elm_gengrid_item_next_get(object_item);
@@ -730,25 +678,25 @@ static void _service_gallery_ug_result_cb(app_control_h request, app_control_h r
                                        WALLPAPERUI_DBG("invalid image path: path_array[%d] = %d", i, path_array[i]);
                                        return;
                                }
-                               if (!strcmp(file_ext, ".PNG")
-                                       && !strcmp(file_ext, ".BMP")
-                                       && !strcmp(file_ext, ".WBMP")
-                                       && !strcmp(file_ext, ".PCX")
-                                       && !strcmp(file_ext, ".TIFF")
-                                       && !strcmp(file_ext, ".JPEG")
-                                       && !strcmp(file_ext, ".TGA")
-                                       && !strcmp(file_ext, ".EXIF")
-                                       && !strcmp(file_ext, ".FPX")
-                                       && !strcmp(file_ext, ".SVG")
-                                       && !strcmp(file_ext, ".PSD")
-                                       && !strcmp(file_ext, ".CDR")
-                                       && !strcmp(file_ext, ".PCD")
-                                       && !strcmp(file_ext, ".DXF")
-                                       && !strcmp(file_ext, ".UFO")
-                                       && !strcmp(file_ext, ".EPS")
-                                       && !strcmp(file_ext, ".JPG")
-                                       && !strcmp(file_ext, ".GIF")) {
-                                       WALLPAPERUI_DBG("invalid image path: path_array[%d] = %d", i, path_array[i]);
+                               if (!(!strcmp(file_ext, ".PNG")
+                                       || !strcmp(file_ext, ".BMP")
+                                       || !strcmp(file_ext, ".WBMP")
+                                       || !strcmp(file_ext, ".PCX")
+                                       || !strcmp(file_ext, ".TIFF")
+                                       || !strcmp(file_ext, ".JPEG")
+                                       || !strcmp(file_ext, ".TGA")
+                                       || !strcmp(file_ext, ".EXIF")
+                                       || !strcmp(file_ext, ".FPX")
+                                       || !strcmp(file_ext, ".SVG")
+                                       || !strcmp(file_ext, ".PSD")
+                                       || !strcmp(file_ext, ".CDR")
+                                       || !strcmp(file_ext, ".PCD")
+                                       || !strcmp(file_ext, ".DXF")
+                                       || !strcmp(file_ext, ".UFO")
+                                       || !strcmp(file_ext, ".EPS")
+                                       || !strcmp(file_ext, ".JPG")
+                                       || !strcmp(file_ext, ".GIF"))) {
+                                       WALLPAPERUI_DBG("invalid image path: path_array[%d] = %s", i, path_array[i]);
                                        return;
                                } else {
                                        WALLPAPERUI_DBG("path_array[%d] = %s", i, path_array[i]);
@@ -756,17 +704,21 @@ static void _service_gallery_ug_result_cb(app_control_h request, app_control_h r
                        }
                }
                memset(ad->saved_img_path, 0, sizeof(ad->saved_img_path));
-               strncpy(ad->saved_img_path[0], path_array[0], MAX_LENGTH_LINE - 1);
-               WALLPAPERUI_DBG("saved_img_path is %s", ad->saved_img_path[0]);
+               strncpy(ad->saved_img_path, path_array[0], MAX_LENGTH_LINE - 1);
+               WALLPAPERUI_DBG("saved_img_path is %s", ad->saved_img_path);
+               for(i = 0; i < array_length; i++) {
+                   free(path_array[i]);
+               }
+               free(path_array);
 
-               elm_image_file_set(ad->preview_image, ad->saved_img_path[0], NULL);
+               elm_image_file_set(ad->preview_image, ad->saved_img_path, NULL);
                evas_object_show(ad->preview_image);
 
                object_item = elm_gengrid_first_item_get(ad->gengrid);
 
                item = (Thumbnail *)elm_object_item_data_get(object_item);
                item->bSelected = EINA_TRUE;
-               item->path = strdup(ad->saved_img_path[0]);
+               item->path = strdup(ad->saved_img_path);
                item->type = WALLPAPER_TYPE_GALLERY;
                ad->preview_image_type = WALLPAPER_TYPE_GALLERY;
 
@@ -804,18 +756,13 @@ static void _gallery_clicked_cb(void *data, Evas_Object *obj, void *event_info)
                app_control_set_app_id(svc_handle,  "org.tizen.ug-gallery-efl");
                app_control_set_mime(svc_handle, "image/*");
 
-               if (!DISABLE_MULTISELECTION) {
-                       app_control_add_extra_data(svc_handle, "max-count", "6");
-                       app_control_add_extra_data(svc_handle, "launch-type", "select-multiple");
-               } else {
-                  app_control_add_extra_data(svc_handle, "launch-type", "select-setas");
-                  app_control_add_extra_data(svc_handle, "setas-type", "crop");
-                  app_control_add_extra_data(svc_handle, "View Mode", "SETAS");
-                  app_control_add_extra_data(svc_handle, "Setas type", "Crop");
-                  app_control_add_extra_data(svc_handle, "Fixed ratio", "TRUE");
-                  /*app_control_add_extra_data(svc_handle, "Area Size", "100"); */
-                  app_control_add_extra_data(svc_handle, "Resolution", "480x800");
-               }
+        app_control_add_extra_data(svc_handle, "launch-type", "select-setas");
+        app_control_add_extra_data(svc_handle, "setas-type", "crop");
+        app_control_add_extra_data(svc_handle, "View Mode", "SETAS");
+        app_control_add_extra_data(svc_handle, "Setas type", "Crop");
+        app_control_add_extra_data(svc_handle, "Fixed ratio", "TRUE");
+        /*app_control_add_extra_data(svc_handle, "Area Size", "100"); */
+               app_control_add_extra_data(svc_handle, "Resolution", "480x800");
                app_control_add_extra_data(svc_handle, "file-type", "image");
                app_control_add_extra_data(svc_handle, "hide-personal", "true");
                app_control_send_launch_request(svc_handle, _service_gallery_ug_result_cb, data);
@@ -992,81 +939,68 @@ static void _done_to_set_wallpaper()
        char filepath[MAX_LENGTH_LINE] = {0};
        char filename[MAX_LENGTH_LINE] = {0};
        char *q = NULL;
-       int i = 0;
-       int index = 0;
-       char *temp_path[6] = {NULL};
+       char *temp_path = NULL;
 
        /*copy lock wallpaper */
-       while (i < MAX_MULTIPLE_SELECTION) {
-               if (strlen(ad->saved_img_path[i]) > 1) {
-                       WALLPAPERUI_DBG("saved_img_path[%d] = %s", i, ad->saved_img_path[i]);
-                       p = strrchr(ad->saved_img_path[i], '/');
-                       if (p) {
-                               if (ad->preview_image_type != WALLPAPER_TYPE_GALLERY) {
-                                       q = strrchr(p, '.');
-                                       const char *wallpapers_path = wallpaper_ui_service_get_settings_wallpapers_path();
-                                       if (q && ((strcmp(q, ".gif") == 0) || (strcmp(q, ".wbmp") == 0) || (strcmp(q, ".bmp") == 0))) {
-                                               WALLPAPERUI_DBG(".gif||.wbmp||.bmp image");
-                                               strncpy(filename, p, MAX_LENGTH_LINE-1);
-                                               q = strrchr(filename, '.');
-                                               if (q) {
-                                                       *q = '\0';
-                                               }
-                                               WALLPAPERUI_DBG("filename = %s", filename);
-                                               snprintf(filepath, sizeof(filepath), "%s%s.jpg", wallpapers_path, &filename[1]);  /*skip slash */
-
-                                       } else {
-                                               WALLPAPERUI_DBG("other image");
-                                               WALLPAPERUI_DBG("filename = %s", p);
-                                               if(*p)
-                                                       ++p;  /*skip slash */
-
-                                               if (ad->preview_image_type != WALLPAPER_TYPE_GALLERY)
-                                               snprintf(filepath, sizeof(filepath), "%s%s", wallpapers_path, p);
-                                       }
-                               } else {
-                                       const char *res_path = get_working_dir();
-                                       snprintf(filepath, sizeof(filepath), "%s/%s", res_path, CUSTOM_WALLPAPER_FILE_NAME);
-                                       wallpaper_ui_service_copy_wallpaper_file(ad->saved_img_path[i], filepath);
-                               }
-
-                               WALLPAPERUI_DBG("filepath = %s", filepath);
-                               if (state_data.from[index] != NULL) {
-                                       free(state_data.from[index]);
-                                       state_data.from[index] = NULL;
-                               }
-                               state_data.from[index] = strdup(ad->saved_img_path[i]);
-
-                               if (state_data.to[index] != NULL) {
-                                       free(state_data.to[index]);
-                                       state_data.to[index] = NULL;
-                               }
-                               state_data.to[index] = strdup(filepath);
-                               index++;
-
-                               if (ad->preview_image_type == WALLPAPER_TYPE_GALLERY) {
-                                       WALLPAPERUI_DBG("Gallery image");
-                                       temp_path[i] = strdup(filepath);
-                               } else {
-                                       WALLPAPERUI_DBG("Default image");
-                                       temp_path[i] = strdup(ad->saved_img_path[i]);
-                               }
-                               _set_wallpaper(temp_path[i]);
-
-                               strncpy(ad->current_preview_img_path, temp_path[0], MAX_LENGTH_LINE-1);
-                               WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path);
-                       }
-               }
-               i++;
-       }
-
-       i--;
-       while (i >= 0 && temp_path[i]) {
-               free(temp_path[i]);
-               i--;
-       }
+    if (strlen(ad->saved_img_path) > 1) {
+        WALLPAPERUI_DBG("saved_img_path = %s", ad->saved_img_path);
+        p = strrchr(ad->saved_img_path, '/');
+        if (p) {
+            if (ad->preview_image_type != WALLPAPER_TYPE_GALLERY) {
+                q = strrchr(p, '.');
+                const char *wallpapers_path = wallpaper_ui_service_get_settings_wallpapers_path();
+                if (q && ((strcmp(q, ".gif") == 0) || (strcmp(q, ".wbmp") == 0) || (strcmp(q, ".bmp") == 0))) {
+                    WALLPAPERUI_DBG(".gif||.wbmp||.bmp image");
+                    strncpy(filename, p, MAX_LENGTH_LINE-1);
+                    q = strrchr(filename, '.');
+                    if (q) {
+                        *q = '\0';
+                    }
+                    WALLPAPERUI_DBG("filename = %s", filename);
+                    snprintf(filepath, sizeof(filepath), "%s%s.jpg", wallpapers_path, &filename[1]);  /*skip slash */
+
+                } else {
+                    WALLPAPERUI_DBG("other image");
+                    WALLPAPERUI_DBG("filename = %s", p);
+                    if(*p)
+                        ++p;  /*skip slash */
+
+                    snprintf(filepath, sizeof(filepath), "%s%s", wallpapers_path, p);
+                }
+            } else {
+                const char *res_path = get_working_dir();
+                snprintf(filepath, sizeof(filepath), "%s/%s", res_path, CUSTOM_WALLPAPER_FILE_NAME);
+                wallpaper_ui_service_copy_wallpaper_file(ad->saved_img_path, filepath);
+            }
+
+            WALLPAPERUI_DBG("filepath = %s", filepath);
+            if (state_data.from != NULL) {
+                free(state_data.from);
+                state_data.from = NULL;
+            }
+            state_data.from = strdup(ad->saved_img_path);
+
+            if (state_data.to != NULL) {
+                free(state_data.to);
+                state_data.to = NULL;
+            }
+            state_data.to = strdup(filepath);
+
+            if (ad->preview_image_type == WALLPAPER_TYPE_GALLERY) {
+                WALLPAPERUI_DBG("Gallery image");
+                temp_path = strdup(filepath);
+            } else {
+                WALLPAPERUI_DBG("Default image");
+                temp_path = strdup(ad->saved_img_path);
+            }
+            _set_wallpaper(temp_path);
+
+            strncpy(ad->current_preview_img_path, temp_path, MAX_LENGTH_LINE-1);
+            WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path);
+        }
+    }
 
-       vconf_set_int(VCONFKEY_LOCKSCREEN_WALLPAPER_COUNT, index);
+    free(temp_path);
 
        if (state_data.flag_image_from_gallery) {
                vconf_set_int(VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE, WALLPAPER_TYPE_GALLERY);
@@ -1076,11 +1010,11 @@ static void _done_to_set_wallpaper()
                WALLPAPERUI_DBG("Set VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE = WALLPAPER_TYPE_DEFAULT");
        }
 
-       WALLPAPERUI_DBG("from[%d] : %s", 0, state_data.from[0]);
+       WALLPAPERUI_DBG("from[%d] : %s", 0, state_data.from);
 
        if (ad->preview_image_type == WALLPAPER_TYPE_GALLERY) {
                WALLPAPERUI_DBG("SCALE start!");
-               _lockscreen_gallery_scale_job_maker(480, 800, 0);
+               _lockscreen_gallery_scale_job_maker(480, 800);
        } else {
                _lockscreen_gallery_destroy_func();
        }
index 5fc4dbb..5eb0fa7 100644 (file)
@@ -43,7 +43,6 @@ static bool flag_view_exist = false;
 #define DBUS_HOME_RAISE_PATH "/Org/Tizen/Coreapps/home/raise"
 #define DBUS_HOME_RAISE_INTERFACE DBUS_HOME_BUS_NAME".raise"
 #define DBUS_HOME_RAISE_MEMBER "homeraise"
-#define SETTINGS_APP_ID "org.tizen.setting"
 #define DEF_WALLPAPERS_PATH "/opt/share/settings/Wallpapers/"
 
 static bool _g_is_system_init = false;
@@ -303,15 +302,12 @@ static void _home_button_clicked_cb(void *data, DBusMessage *msg)
        wallpaper_ui_service_appdata *ad = (wallpaper_ui_service_appdata *)data;
        ret_if(ad == NULL);
 
-       if (ad->sel_popup_data.launch_from == WALLPAPER_POPUP_FROM_HOME_SCREEN
-               && ad->popup_type == WALLPAPER_POPUP_TYPE_SELECTION) {
-               if (scale_resize_state == 1) {
-                       WALLPAPERUI_ERR("Destroy wallpaper cancel");
-                       return;
-               }
-               WALLPAPERUI_ERR("Destroy wallpaper");
-               ui_app_exit();
+       if (scale_resize_state == 1) {
+               WALLPAPERUI_ERR("Destroy wallpaper cancel");
+               return;
        }
+       WALLPAPERUI_ERR("Destroy wallpaper");
+       ui_app_exit();
 
        WALLPAPERUI_TRACE_END;
 }
@@ -346,110 +342,7 @@ void *_register_view(app_control_h service, void *data)
        wallpaper_ui_service_appdata *ad = (wallpaper_ui_service_appdata *)data;
        retv_if(!ad, NULL);
 
-       char *from = NULL;
-       char *popup_type = NULL;
-       char *setas = NULL;
-       app_control_get_extra_data(service, EXTRA_KEY_POPUP_TYPE, &popup_type);
-
-       if (popup_type != NULL) {
-               WALLPAPERUI_ERR("popup_type %s", popup_type);
-       }
-
-       if (popup_type != NULL) {
-               ad->popup_type = WALLPAPER_POPUP_TYPE_SELECTION;
-
-               free(popup_type);
-       } else {
-               ad->popup_type = WALLPAPER_POPUP_TYPE_SELECTION;
-       }
-       app_control_get_extra_data(service, EXTRA_FROM_KEY, &from);
-       WALLPAPERUI_ERR("from %s", from);
-
-       if (from != NULL) {
-               if (strcmp(from, "Homescreen-efl") == 0) {
-                       ad->sel_popup_data.launch_from = WALLPAPER_POPUP_FROM_HOME_SCREEN;
-               } else if (strcmp(from, "Setting") == 0) {
-                       ad->sel_popup_data.launch_from = WALLPAPER_POPUP_FROM_SETTING;
-               } else {
-                       ad->sel_popup_data.launch_from = WALLPAPER_POPUP_FROM_LOCK_SCREEN;
-               }
-               free(from);
-       } else {
-               ad->sel_popup_data.launch_from = WALLPAPER_POPUP_FROM_GALLERY;
-       }
-
-       app_control_get_extra_data(service, EXTRA_KEY_SETAS, &setas);
-
-       if (setas == NULL) {
-               WALLPAPERUI_ERR("setas (%s) failed", setas);
-       }
-
-       if (setas != NULL) {
-               WALLPAPERUI_DBG("setas is (%s)", setas);
-               if (strcmp(setas, EXTRA_DATA_HOMESCREEN) == 0) {
-                       ad->sel_popup_data.setas_type = WALLPAPER_POPUP_SETAS_HOMESCREEN;
-               } else if (strcmp(setas, EXTRA_DATA_LOCKSCREEN) == 0) {
-                       char *wallpaper_type = NULL;
-                       ad->sel_popup_data.setas_type = WALLPAPER_POPUP_SETAS_LOCKSCREEN;
-
-                       app_control_get_extra_data(service, EXTRA_KEY_WALLPAPER_TYPE, &wallpaper_type);
-
-                       if (wallpaper_type != NULL) {
-                               WALLPAPERUI_ERR("wallpaper_type (%s) failed", wallpaper_type);
-                               if (strcmp(wallpaper_type, EXTRA_DATA_WP_DEFAULT) == 0) {
-                                       ad->lock_wallpaper_type = WALLPAPER_TYPE_DEFAULT;
-                               } else if (strcmp(wallpaper_type, EXTRA_DATA_WP_MULTI) == 0) {
-                                       ad->lock_wallpaper_type = WALLPAPER_TYPE_MULTIPLE;
-                               } else {
-                                       ad->lock_wallpaper_type = WALLPAPER_TYPE_GALLERY;
-                               }
-                               free(wallpaper_type);
-                       } else {
-                               ad->lock_wallpaper_type = WALLPAPER_TYPE_GALLERY;
-                       }
-               } else {
-                       ad->sel_popup_data.setas_type = WALLPAPER_POPUP_SETAS_HOME_N_LOCKSCREEN;
-               }
-               free(setas);
-       } else {
-               WALLPAPERUI_ERR("app_control_get_extra_data(%s) failed", EXTRA_KEY_SETAS);
-               ad->sel_popup_data.setas_type = WALLPAPER_POPUP_SETAS_LOCKSCREEN;
-       }
-
-
-       if (ad->popup_type == WALLPAPER_POPUP_TYPE_SELECTION) {
-               ad->sel_popup_data.win_main = ad->win;
-               wallpaper_main_create_view(data);
-       } else if (ad->popup_type == WALLPAPER_POPUP_TYPE_THEME) {
-/*             WALLPAPERUI_ERR("EXTRA_FROM_KEY(%s) failed", from); */
-
-               char *file_name = NULL;
-               app_control_get_extra_data(service, EXTRA_KEY_FILE, &file_name);
-               if (file_name == NULL) {
-                       WALLPAPERUI_ERR("app_control_get_extra_data(%s) failed", EXTRA_KEY_FILE);
-                       if (ad->sel_popup_data.setas_type == WALLPAPER_POPUP_SETAS_LOCKSCREEN) {
-                               if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &file_name) != SYSTEM_SETTINGS_ERROR_NONE) {
-                                       WALLPAPERUI_ERR("system_settings_get_value_string() failed");
-                               }
-                       } else {
-                               if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &file_name) != SYSTEM_SETTINGS_ERROR_NONE) {
-                                       WALLPAPERUI_ERR("system_settings_get_value_string() failed");
-                               }
-                       }
-
-                       if (file_name == NULL) {
-                               WALLPAPERUI_ERR("CIRITICAL ERROR : wallpaper file is NULL");
-                               ui_app_exit();
-                               return NULL;
-                       }
-               }
-               ad->color_popup_data.file_path = strdup(file_name);
-               free(file_name);
-               if (ad->color_popup_data.file_path == NULL) {
-                       WALLPAPERUI_ERR("CIRITICAL ERROR : strdup() failed");
-               }
-
-       }
+       wallpaper_main_create_view(data);
 
        WALLPAPERUI_TRACE_END;
        return NULL;
@@ -473,11 +366,6 @@ static void _app_terminate(void *data)
 
        flag_view_exist = false;
 
-       if (ad->pd) {
-               free(ad->pd);
-               ad->pd = NULL;
-       }
-
        if (ad->win) {
                evas_object_del(ad->win);
                ad->win = NULL;
@@ -544,10 +432,6 @@ static void _app_resume(void *data)
        }
        WALLPAPERUI_DBG("value = %s", value);
 
-       evas_object_geometry_get(ad->main_layout, NULL, NULL, &w, &h);
-
-       WALLPAPERUI_DBG("main_layout W = %d, H = %d", w, h);
-
        WALLPAPERUI_TRACE_END;
 }
 
@@ -557,26 +441,16 @@ static void _app_control(app_control_h service, void *data)
        ret_if(!data);
        int bTransparent = 0;
        wallpaper_ui_service_appdata *ad = data;
-       char *popup_type = NULL;
-       app_control_get_extra_data(service, EXTRA_KEY_POPUP_TYPE, &popup_type);
 
        feedback_initialize();
 
-       /* clone service */
-       app_control_clone(&(ad->service), service);
-
-       ad->popup_type = WALLPAPER_POPUP_TYPE_SELECTION;
-
-       if (ad->win != NULL && ad->popup_type == WALLPAPER_POPUP_TYPE_SELECTION) {
+       if (ad->win != NULL) {
                WALLPAPERUI_DBG("ALREADY EXIST");
                return;
 /*             evas_object_del(ad->win); */
 /*             ad->win = NULL; */
        }
 
-       if (ad->popup_type == WALLPAPER_POPUP_TYPE_THEME) {
-               bTransparent = 1;
-       }
 
     /* create window */
     ad->win = _create_win(PKGNAME, bTransparent);
@@ -594,7 +468,7 @@ static void _app_control(app_control_h service, void *data)
        elm_theme_extension_add(NULL, edjPath);
        free(edjPath);
 
-       if (ad->win && flag_view_exist && popup_type && ad->popup_type == WALLPAPER_POPUP_TYPE_SELECTION) {
+       if (ad->win && flag_view_exist) {
                elm_win_activate(ad->win);
        } else {
                _register_view(service, ad);
@@ -605,32 +479,6 @@ static void _app_control(app_control_h service, void *data)
        _wallpaper_set_dbus_handler(ad);
        _wallpaper_register_home_button_cb(ad);
 
-       if (popup_type) {
-               free(popup_type);
-       }
-
-       WALLPAPERUI_TRACE_END;
-}
-
-static void update_text(void *data)
-{
-       WALLPAPERUI_TRACE_BEGIN;
-
-       wallpaper_ui_service_appdata *ad = (wallpaper_ui_service_appdata *) data;
-       ret_if(ad == NULL);
-
-       if (ad->main_nf_it) {
-               elm_object_item_text_set(ad->main_nf_it, APP_STRING("IDS_LCKSCN_MBODY_WALLPAPERS"));
-               Evas_Object *cancel_button = elm_object_item_part_content_get(ad->main_nf_it, "title_left_text_btn");
-               if (cancel_button) {
-                       elm_object_text_set(cancel_button, APP_STRING("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB"));
-               }
-               Evas_Object *done_button = elm_object_item_part_content_get(ad->main_nf_it, "title_right_text_btn");
-               if (done_button) {
-                       elm_object_text_set(done_button, APP_STRING("IDS_TPLATFORM_ACBUTTON_DONE_ABB"));
-               }
-       }
-
        WALLPAPERUI_TRACE_END;
 }
 
@@ -649,8 +497,6 @@ static void _app_lang_changed(app_event_info_h event_info, void *data)
                FREE(lang);
        }
 
-       update_text(data);
-
        WALLPAPERUI_TRACE_END;
 }