TizenRefApp-7691 [wallpaper-ui-service]codestyle 88/98988/2 submit/tizen_3.0/20161121.160543
authorOleksander Kostenko <o.kostenko@samsung.com>
Mon, 21 Nov 2016 10:18:48 +0000 (12:18 +0200)
committerOleksander Kostenko <o.kostenko@samsung.com>
Mon, 21 Nov 2016 13:43:50 +0000 (15:43 +0200)
Change-Id: I5f10b33940f8d39d77ad7a121567f49f26f72383
Signed-off-by: Oleksander Kostenko <o.kostenko@samsung.com>
src/wallpaper-ui-service-main.c
src/wallpaper-ui-service.c

index 66a3806..5692607 100644 (file)
@@ -30,8 +30,8 @@
 #include "wallpaper-ui-service.h"
 #include "wallpaper-ui-service-main.h"
 
-//#define DEFAULT_IMAGE_DIR tzplatform_mkpath(TZ_SYS_RO_APP, "org.tizen.setting/shared/res/settings/Wallpapers")
-//#define DEFAULT_IMAGE_DIR_TEMPLATE tzplatform_mkpath(TZ_SYS_RO_APP, "org.tizen.setting/shared/res/settings/Wallpapers/%s")
+/*#define DEFAULT_IMAGE_DIR tzplatform_mkpath(TZ_SYS_RO_APP, "org.tizen.setting/shared/res/settings/Wallpapers")
+  #define DEFAULT_IMAGE_DIR_TEMPLATE tzplatform_mkpath(TZ_SYS_RO_APP, "org.tizen.setting/shared/res/settings/Wallpapers/%s")*/
 #define CUSTOM_WALLPAPER_FILE_NAME "custom_wallpaper.jpg"
 
 /**
@@ -53,14 +53,14 @@ static Elm_Object_Item *nf_it = NULL;
  * @brief Struct to control image selection state
  */
 static struct _wallpaper_ui_service_state_data {
-    Eina_Bool flag_changed;             /**< True when selection changes */
-    Eina_Bool flag_image_from_gallery;  /**< True when selected image from gallery */
+       Eina_Bool flag_changed;             /**< True when selection changes */
+       Eina_Bool flag_image_from_gallery;  /**< True when selected image from gallery */
        char *from;                         /**< Stores original selected image's path from gallery */
        char *to;                           /**< Stores path where copied image should be placed */
        Evas_Object *done_btn;                          /**< Stores done button object to enable or disable it */
 } state_data = {
-    .flag_changed = EINA_FALSE,
-    .flag_image_from_gallery = EINA_FALSE,
+       .flag_changed = EINA_FALSE,
+       .flag_image_from_gallery = EINA_FALSE,
        .from = NULL,
        .to = NULL,
        .done_btn = NULL,
@@ -121,7 +121,7 @@ static void _main_done_button_cb(void *data, Evas_Object *obj, void *event_info)
 {
        WALLPAPERUI_TRACE_BEGIN;
 
-    if (state_data.flag_changed) {
+       if (state_data.flag_changed) {
                Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid);
                Thumbnail *s_item = NULL;
 
@@ -139,22 +139,22 @@ static void _main_done_button_cb(void *data, Evas_Object *obj, void *event_info)
        WALLPAPERUI_TRACE_END;
 }
 
-static void _get_filename_extension_in_uppercase(const char * inputString, char *buf, int bufLength)
+static void _get_filename_extension_in_uppercase(const char *inputString, char *buf, int bufLength)
 {
        WALLPAPERUI_TRACE_BEGIN;
 
-       if (!buf||!inputString||bufLength<1){
+       if (!buf || !inputString || bufLength < 1)
                return;
-       }
+
        char *pointChar = strrchr(inputString, '.');
-       if(pointChar) {
+       if (pointChar) {
                int i;
-               for (i=0; i < bufLength;++i, ++pointChar, ++buf){
-                       if (*pointChar == '\0'){
+               for (i = 0; i < bufLength; ++i, ++pointChar, ++buf) {
+                       if (*pointChar == '\0')
                                break;
-                       }
+
                        *buf = toupper(*pointChar);
-                       }
+               }
        }
        *buf = '\0';
 
@@ -201,28 +201,27 @@ 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, 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]);
-               }
+               for (i = 0; i < array_length; i++)
+                       free(path_array[i]);
+
                free(path_array);
-        int prescale_size = get_max_prescale_img_size(ad);
-        elm_image_prescale_set(ad->preview_image, prescale_size);
+               int prescale_size = get_max_prescale_img_size(ad);
+               elm_image_prescale_set(ad->preview_image, prescale_size);
                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);
-               if(item)
-               {
-                   item->bSelected = EINA_TRUE;
-                   item->path = strdup(ad->saved_img_path);
-                   item->type = WALLPAPER_TYPE_GALLERY;
+               if (item) {
+                       item->bSelected = EINA_TRUE;
+                       item->path = strdup(ad->saved_img_path);
+                       item->type = WALLPAPER_TYPE_GALLERY;
 
-                   elm_object_item_data_set(object_item, item);
-                   elm_gengrid_item_update(object_item);
+                       elm_object_item_data_set(object_item, item);
+                       elm_gengrid_item_update(object_item);
 
-                   _wallpaper_show_focus_highlight(item->index);
+                       _wallpaper_show_focus_highlight(item->index);
                }
                ad->preview_image_type = WALLPAPER_TYPE_GALLERY;
                elm_object_signal_emit(ad->preview_layout, "show_preview", "preview_image");
@@ -242,22 +241,21 @@ static void _gallery_clicked_cb(void *data, Evas_Object *obj, void *event_info)
        elm_gengrid_item_selected_set(item->item,  EINA_FALSE);
        app_control_h svc_handle = NULL;
 
-       if (obj) {
+       if (obj)
                elm_object_signal_emit(obj, "unpressed", "elm");
-       }
 
        if (!app_control_create(&svc_handle)) {
                app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_PICK);
-        app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP);
-               app_control_set_app_id(svc_handle,  "org.tizen.ug-gallery-efl");
+               app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP);
+               app_control_set_app_id(svc_handle, "org.tizen.ug-gallery-efl");
                app_control_set_mime(svc_handle, "image/*");
 
-        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, "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");
@@ -340,16 +338,15 @@ static char *_get_last_image_from_db()
 
        int ret = MEDIA_CONTENT_ERROR_NONE;
        filter_h media_filter = NULL;
-       char buf[1024] = {0,};
+       char buf[1024] = { 0, };
        media_info_h m_handle = NULL;
        int media_count = 0;
        char *thumbnailPath = NULL;
 
        snprintf(buf, sizeof(buf), "MEDIA_TYPE=0");
 
-       if (_wallpaper_db_create_filter(&media_filter) == false) {
+       if (_wallpaper_db_create_filter(&media_filter) == false)
                return NULL;
-       }
 
        if (_wallpaper_db_set_filter_condition(media_filter, buf) == false) {
                _wallpaper_db_destroy_filter(media_filter);
@@ -363,14 +360,13 @@ static char *_get_last_image_from_db()
        }
 
        ret = media_info_foreach_media_from_db(media_filter, _media_item_cb, &m_handle);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
                WALLPAPERUI_ERR("media_info_foreach_media_from_db is failed, err");
-       }
 
        if (m_handle) {
-               if (media_info_get_thumbnail_path(m_handle, &thumbnailPath) != MEDIA_CONTENT_ERROR_NONE) {
+               if (media_info_get_thumbnail_path(m_handle, &thumbnailPath) != MEDIA_CONTENT_ERROR_NONE)
                        WALLPAPERUI_ERR("Get media type failed!");
-               }
+
                WALLPAPERUI_DBG("thumbnailPath is %s", thumbnailPath);
                free(m_handle);
        }
@@ -429,71 +425,71 @@ static void _done_to_set_wallpaper()
        WALLPAPERUI_TRACE_BEGIN;
 
        char *p = NULL;
-       char filepath[MAX_LENGTH_LINE] = {0};
-       char filename[MAX_LENGTH_LINE] = {0};
+       char filepath[MAX_LENGTH_LINE] = { 0 };
+       char filename[MAX_LENGTH_LINE] = { 0 };
        char *q = NULL;
        char *temp_path = NULL;
 
        /*copy lock wallpaper */
-    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);
-        }
-    }
-
-    free(temp_path);
+       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);
+               }
+       }
+
+       free(temp_path);
 
        if (state_data.flag_image_from_gallery) {
                vconf_set_int(VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE, WALLPAPER_TYPE_GALLERY);
@@ -507,13 +503,12 @@ static void _done_to_set_wallpaper()
 
        if (ad->preview_image_type == WALLPAPER_TYPE_GALLERY) {
                WALLPAPERUI_DBG("SCALE start!");
-               //Image should be cropped by Image Viewer. Remove this temporary code when TSAM-6782 will be fixed.
-           Eina_Bool b = evas_object_image_save(elm_image_object_get(ad->preview_image), state_data.to, NULL, "quality=100 compress=4");
-           if (b == EINA_FALSE) {
-               WALLPAPERUI_DBG("evas_object_image_save to %s fail!", state_data.to);
-           } else {
-               _set_wallpaper(state_data.to);
-           }
+               /* Image should be cropped by Image Viewer. Remove this temporary code when TSAM-6782 will be fixed. */
+               Eina_Bool b = evas_object_image_save(elm_image_object_get(ad->preview_image), state_data.to, NULL, "quality=100 compress=4");
+               if (b == EINA_FALSE)
+                       WALLPAPERUI_DBG("evas_object_image_save to %s fail!", state_data.to);
+               else
+                       _set_wallpaper(state_data.to);
        }
        _wallpaper_destroy(ad);
 
@@ -528,8 +523,7 @@ static void _done_to_set_wallpaper()
 
 static void _wallpaper_destroy(wallpaper_ui_service_appdata *ad)
 {
-       WALLPAPERUI_TRACE_BEGIN
-
+       WALLPAPERUI_TRACE_BEGIN;
        ret_if(!ad);
 
        if (ad->last_preview_img_path != NULL) {
@@ -541,17 +535,17 @@ static void _wallpaper_destroy(wallpaper_ui_service_appdata *ad)
                evas_object_del(ad->win);
                ad->win = NULL;
        }
-    if (gic_for_main) {
-        elm_gengrid_item_class_free(gic_for_main);
-        gic_for_main = NULL;
-    }
+       if (gic_for_main) {
+               elm_gengrid_item_class_free(gic_for_main);
+               gic_for_main = NULL;
+       }
 
        char *edj = wallpaper_ui_service_get_edj_path("button_customized_theme.edj");
        elm_theme_extension_del(NULL, edj);
        free(edj);
        ui_app_exit();
 
-       WALLPAPERUI_TRACE_END
+       WALLPAPERUI_TRACE_END;
 }
 
 static void _wallpaper_back_key_cb(void *data, Evas_Object *obj, void *event_info)
@@ -600,32 +594,31 @@ static void _wallpaper_db_update_cb(media_content_error_e error, int pid,
        last_image = _get_last_image_from_db();
        WALLPAPERUI_DBG("last_image == %s", last_image);
        if ((last_image == NULL && strstr(ad->last_preview_img_path, "no_gallery_bg.png") == NULL)
-               || (last_image != NULL && strcmp(last_image, ad->last_preview_img_path) != 0)) {
-           //if last image was changed
-           Thumbnail *item = NULL;
-
-           Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid);
-
-           while (object_item) {
-               item = (Thumbnail *)elm_object_item_data_get(object_item);
-
-               if (item && item->type == WALLPAPER_TYPE_GALLERY) {
-                   free(item->path);
-                   if (last_image != NULL) {
-                       item->path = strdup(last_image);
-                   } else {
-                       item->path = wallpaper_ui_service_get_icon_path("no_gallery_bg.png");
-                   }
-                   elm_gengrid_item_update(item->item);
-                   break;
-               }
-               object_item = elm_gengrid_item_next_get(object_item);
-           }
+                               || (last_image != NULL && strcmp(last_image, ad->last_preview_img_path) != 0)) {
+               /* if last image was changed */
+               Thumbnail *item = NULL;
 
-       }
+               Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid);
+
+               while (object_item) {
+                       item = (Thumbnail *)elm_object_item_data_get(object_item);
 
-    free(last_image);
+                       if (item && item->type == WALLPAPER_TYPE_GALLERY) {
+                               free(item->path);
+                               if (last_image != NULL)
+                                       item->path = strdup(last_image);
+                               else
+                                       item->path = wallpaper_ui_service_get_icon_path("no_gallery_bg.png");
+
+                               elm_gengrid_item_update(item->item);
+                               break;
+                       }
+                       object_item = elm_gengrid_item_next_get(object_item);
+               }
+
+       }
 
+       free(last_image);
        WALLPAPERUI_TRACE_END;
 }
 
@@ -650,31 +643,31 @@ static void _wallpaper_preview_main()
        WALLPAPERUI_TRACE_BEGIN;
 
        Evas_Object *preveiw_main_layout = NULL;
-    Evas_Object *preview_image = NULL;
+       Evas_Object *preview_image = NULL;
 
-    preveiw_main_layout = elm_layout_add(ad->naviframe);
-    char *edj = wallpaper_ui_service_get_edj_path("popup-wallpaper.edj");
-    elm_layout_file_set(preveiw_main_layout, edj, "wallpaper.preview");
-    free(edj);
-    evas_object_size_hint_weight_set(preveiw_main_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       preveiw_main_layout = elm_layout_add(ad->naviframe);
+       char *edj = wallpaper_ui_service_get_edj_path("popup-wallpaper.edj");
+       elm_layout_file_set(preveiw_main_layout, edj, "wallpaper.preview");
+       free(edj);
+       evas_object_size_hint_weight_set(preveiw_main_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
-    preview_image = elm_image_add(preveiw_main_layout);
+       preview_image = elm_image_add(preveiw_main_layout);
 
        WALLPAPERUI_DBG("current_preview_img_path = %s", ad->current_preview_img_path);
 
        int prescale_size = get_max_prescale_img_size(ad);
        elm_image_prescale_set(preview_image, prescale_size);
-    elm_image_file_set(preview_image, ad->current_preview_img_path, NULL);
-    elm_image_aspect_fixed_set(preview_image, EINA_TRUE);
-    elm_image_fill_outside_set(preview_image, EINA_TRUE);
-    elm_image_preload_disabled_set(preview_image, EINA_TRUE);
-    elm_object_part_content_set(preveiw_main_layout, "preview", preview_image);
-    edje_object_signal_callback_add(_EDJ(preveiw_main_layout), "preview_clicked", "edj", _preview_clicked_cb, ad->naviframe);
-    elm_object_part_content_unset(preveiw_main_layout, "thumblist");
-    evas_object_show(preveiw_main_layout);
+       elm_image_file_set(preview_image, ad->current_preview_img_path, NULL);
+       elm_image_aspect_fixed_set(preview_image, EINA_TRUE);
+       elm_image_fill_outside_set(preview_image, EINA_TRUE);
+       elm_image_preload_disabled_set(preview_image, EINA_TRUE);
+       elm_object_part_content_set(preveiw_main_layout, "preview", preview_image);
+       edje_object_signal_callback_add(_EDJ(preveiw_main_layout), "preview_clicked", "edj", _preview_clicked_cb, ad->naviframe);
+       elm_object_part_content_unset(preveiw_main_layout, "thumblist");
+       evas_object_show(preveiw_main_layout);
 
        Elm_Object_Item *navi_item = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, preveiw_main_layout, NULL);
-       elm_naviframe_item_title_enabled_set (navi_item, EINA_FALSE, EINA_FALSE);
+       elm_naviframe_item_title_enabled_set(navi_item, EINA_FALSE, EINA_FALSE);
        WALLPAPERUI_TRACE_END;
 }
 
@@ -695,13 +688,12 @@ HAPI void wallpaper_main_create_view(wallpaper_ui_service_appdata *data)
                return;
        }
 
-       if (media_content_set_db_updated_cb(_wallpaper_db_update_cb, ad) != MEDIA_CONTENT_ERROR_NONE) {
+       if (media_content_set_db_updated_cb(_wallpaper_db_update_cb, ad) != MEDIA_CONTENT_ERROR_NONE)
                WALLPAPERUI_DBG("Set db updated cb failed!");
-       }
 
-       int w=0, h=0;
+       int w = 0, h = 0;
        evas_object_geometry_get(ad->layout, NULL, NULL, &w, &h);
-    WALLPAPERUI_DBG("ad->layout w = %d, ad->layout h = %d", w, h);
+       WALLPAPERUI_DBG("ad->layout w = %d, ad->layout h = %d", w, h);
 
        /* Naviframe */
        Evas_Object *naviframe = elm_naviframe_add(ad->layout);
@@ -718,9 +710,9 @@ HAPI void wallpaper_main_create_view(wallpaper_ui_service_appdata *data)
        evas_object_show(preveiw_main_layout);
        ad->preview_layout = preveiw_main_layout;
 
-       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) != SYSTEM_SETTINGS_ERROR_NONE) {
+       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) != SYSTEM_SETTINGS_ERROR_NONE)
                WALLPAPERUI_ERR("system_settings_get_value_string() failed");
-       }
+
        WALLPAPERUI_DBG("value = %s", value);
 
        /* preview image */
@@ -728,23 +720,22 @@ HAPI void wallpaper_main_create_view(wallpaper_ui_service_appdata *data)
        int prescale_size = get_max_prescale_img_size(ad);
        elm_image_prescale_set(image, prescale_size);
        elm_image_file_set(image, value, NULL);
-       elm_image_aspect_fixed_set(image,       EINA_TRUE);
+       elm_image_aspect_fixed_set(image, EINA_TRUE);
        elm_image_fill_outside_set(image, EINA_TRUE);
        elm_image_preload_disabled_set(image, EINA_FALSE);
        elm_object_part_content_set(preveiw_main_layout, "preview_image", image);
-    evas_object_smart_callback_add(image, "clicked", _main_preview_image_clicked_cb, ad->naviframe);
+       evas_object_smart_callback_add(image, "clicked", _main_preview_image_clicked_cb, ad->naviframe);
 
        ad->preview_image = image;
 
        /* preview text */
        elm_object_domain_translatable_part_text_set(preveiw_main_layout, "text_tap", PKGNAME, "IDS_LCKSCN_NPBODY_TAP_TO_PREVIEW");
-/*     elm_object_signal_emit(preveiw_main_layout, "hide_preview", "preview_image"); */
+       /* elm_object_signal_emit(preveiw_main_layout, "hide_preview", "preview_image"); */
 
        /* gallery last image */
        ad->last_preview_img_path = _get_last_image_from_db();
-       if (ad->last_preview_img_path != NULL) {
+       if (ad->last_preview_img_path != NULL)
                WALLPAPERUI_DBG("last_preview_img_path == %s", ad->last_preview_img_path);
-       }
 
        /* thumnail icon */
        ad->gengrid = main_gengrid_add(preveiw_main_layout);
@@ -756,19 +747,18 @@ HAPI void wallpaper_main_create_view(wallpaper_ui_service_appdata *data)
        elm_object_domain_translatable_part_text_set(preveiw_main_layout, "elm.text.title", PKGNAME, "IDS_LCKSCN_BODY_WALLPAPERS");
        elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
 
-    Evas_Object *title = (Evas_Object *) edje_object_part_object_get(elm_layout_edje_get(preveiw_main_layout), "elm.text.title");
-    if(title)
-    {
-        title = elm_access_object_register(title, preveiw_main_layout);
-        elm_atspi_accessible_name_set(title, "IDS_LCKSCN_BODY_WALLPAPERS");
-        elm_atspi_accessible_description_set(title, "IDS_TPLATFORM_BODY_TITLE");
-        elm_atspi_accessible_translation_domain_set(title, PKGNAME);
-        elm_atspi_accessible_reading_info_type_set(title, ELM_ACCESSIBLE_READING_INFO_TYPE_NAME |
-                                                          ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
-    }
+       Evas_Object *title = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(preveiw_main_layout), "elm.text.title");
+       if (title) {
+               title = elm_access_object_register(title, preveiw_main_layout);
+               elm_atspi_accessible_name_set(title, "IDS_LCKSCN_BODY_WALLPAPERS");
+               elm_atspi_accessible_description_set(title, "IDS_TPLATFORM_BODY_TITLE");
+               elm_atspi_accessible_translation_domain_set(title, PKGNAME);
+               elm_atspi_accessible_reading_info_type_set(title, ELM_ACCESSIBLE_READING_INFO_TYPE_NAME
+                                                                                                               | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
+       }
 
        /* Title Cancel Button */
-       Evas_Object *cancel_btn = elm_button_add(preveiw_main_layout);
+       Evas_Object *cancel_btn = elm_button_add(preveiw_main_layout);
        elm_object_style_set(cancel_btn, "naviframe/title_left");
        evas_object_smart_callback_add(cancel_btn, "clicked", _main_cancel_button_cb, NULL);
        elm_object_domain_translatable_part_text_set(cancel_btn, "elm.text", PKGNAME, "IDS_TPLATFORM_ACBUTTON_CANCEL_ABB");
@@ -823,9 +813,8 @@ static Evas_Object *_preview_create_edje_content(Evas_Object *parent, const char
        elm_image_preload_disabled_set(image, EINA_FALSE);
        evas_object_show(image);
 
-       if (thm->title) {
+       if (thm->title)
            elm_object_domain_translatable_part_text_set(layout, "text", PKGNAME, thm->title);
-       }
 
        WALLPAPERUI_TRACE_END;
        return layout;
@@ -848,15 +837,14 @@ static Evas_Object *_preview_grid_content_get(void *data, Evas_Object *obj, cons
                        WALLPAPERUI_DBG("Selected");
 
                        edje_object_signal_emit(elm_layout_edje_get(thm->content), "elm,focus_highlight,show", "app");
-            memset(ad->current_preview_img_path, 0, sizeof(ad->current_preview_img_path));
-            strncpy(ad->current_preview_img_path, thm->path, MAX_LENGTH_LINE-1);
-            WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path);
+                       memset(ad->current_preview_img_path, 0, sizeof(ad->current_preview_img_path));
+                       strncpy(ad->current_preview_img_path, thm->path, MAX_LENGTH_LINE - 1);
+                       WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path);
                } else {
                        WALLPAPERUI_DBG("UnSelected");
                        elm_gengrid_item_selected_set(thm->item, EINA_FALSE);
                        edje_object_signal_emit(elm_layout_edje_get(thm->content), "elm,state,unselected", "app");
                }
-
                return contents;
        }
 
@@ -915,11 +903,11 @@ static void _wallpaper_on_item_selected(void *data, Evas_Object *obj, void *even
        }
 
        if (item->type != WALLPAPER_TYPE_GALLERY) {
-/*             elm_object_signal_emit(ad->preview_layout, "hide_preview", "preview_image"); */
+               /* elm_object_signal_emit(ad->preview_layout, "hide_preview", "preview_image"); */
                elm_image_file_set(ad->preview_image, item->path, NULL);
-        memset(ad->current_preview_img_path, 0, sizeof(ad->current_preview_img_path));
-        strncpy(ad->current_preview_img_path, item->path, MAX_LENGTH_LINE-1);
-        WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path);
+               memset(ad->current_preview_img_path, 0, sizeof(ad->current_preview_img_path));
+               strncpy(ad->current_preview_img_path, item->path, MAX_LENGTH_LINE - 1);
+               WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path);
        }
 
        elm_gengrid_item_selected_set(item->item, EINA_FALSE);
@@ -929,8 +917,8 @@ static void _wallpaper_on_item_selected(void *data, Evas_Object *obj, void *even
 
        _wallpaper_show_focus_highlight(item->index);
 
-    state_data.flag_changed = EINA_TRUE;
-    elm_object_disabled_set(state_data.done_btn, EINA_FALSE);
+       state_data.flag_changed = EINA_TRUE;
+       elm_object_disabled_set(state_data.done_btn, EINA_FALSE);
 
        WALLPAPERUI_TRACE_END;
 }
@@ -949,9 +937,8 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent)
        int count = 0;
        Thumbnail *temp_item = NULL;
 
-       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &setting_value) != SYSTEM_SETTINGS_ERROR_NONE) {
+       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &setting_value) != SYSTEM_SETTINGS_ERROR_NONE)
                WALLPAPERUI_ERR("system_settings_get_value_string() failed");
-       }
 
        vconf_get_int(VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE, &setting_type);
        WALLPAPERUI_DBG("VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE %d", setting_type);
@@ -988,9 +975,9 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent)
                        if (ad->last_preview_img_path != NULL) {
                                s_item->path = strdup(ad->last_preview_img_path);
                        } else {
-                char *iconPath = wallpaper_ui_service_get_icon_path("no_gallery_bg.png");
-                s_item->path = strdup(iconPath);
-                free(iconPath);
+                               char *iconPath = wallpaper_ui_service_get_icon_path("no_gallery_bg.png");
+                               s_item->path = strdup(iconPath);
+                               free(iconPath);
                        }
                } else {
                        s_item->path = setting_value;
@@ -1009,12 +996,12 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent)
                elm_atspi_accessible_translation_domain_set(s_item->item, PKGNAME);
        }
 
-       const chardefaultImageDir = wallpaper_ui_service_get_settings_wallpapers_path();
-       file_list = ecore_file_ls(defaultImageDir);//ecore_file_ls(DEFAULT_IMAGE_DIR);
+       const char *defaultImageDir = wallpaper_ui_service_get_settings_wallpapers_path();
+       file_list = ecore_file_ls(defaultImageDir); /* ecore_file_ls(DEFAULT_IMAGE_DIR); */
        count = eina_list_count(file_list);
        WALLPAPERUI_DBG("count = %d", count);
 
-    char picturePath[MAX_LENGTH_LINE] = {0};
+       char picturePath[MAX_LENGTH_LINE] = { 0 };
        /* default directory */
        if (count > 0) {
                for (i = 0; i < count; i++) {
@@ -1036,16 +1023,15 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent)
                                } else {
                                        s_item->bSelected = EINA_FALSE;
                                }
-                               /*                              s_item->item = elm_gengrid_item_append(gengrid, gic, s_item, _gallery_clicked_cb, s_item); */
+                               /* s_item->item = elm_gengrid_item_append(gengrid, gic, s_item, _gallery_clicked_cb, s_item); */
                                s_item->item = elm_gengrid_item_append(ad->gengrid, gic_for_main, s_item, _wallpaper_on_item_selected, s_item);
                                elm_atspi_accessible_name_set(s_item->item, s_item->title);
                        }
                }
        }
 
-       if (file_list != NULL) {
+       if (file_list != NULL)
                eina_list_free(file_list);
-       }
 
        /* Shows the portion of a gengrid internal grid containing a given item immediately */
 
index 1b48b66..4e9843c 100644 (file)
@@ -65,29 +65,25 @@ static const char *_str_error_db(int error)
 
        static char buf[40];
        snprintf(buf, sizeof(buf), "Error Code=%d", error);
-    WALLPAPERUI_TRACE_END;
-    return buf;
+       WALLPAPERUI_TRACE_END;
+       return buf;
 }
 
 static void _update_character_orientation()
 {
-    char *lang = NULL;
-    system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
-    if(lang)
-    {
-        elm_language_set(lang);
-        i18n_ulocale_layout_type_e layout = I18N_ULOCALE_LAYOUT_UNKNOWN;
-        if(i18n_ulocale_get_character_orientation(lang, &layout) == I18N_ERROR_NONE)
-        {
-            if (layout == I18N_ULOCALE_LAYOUT_LTR) {
-                elm_config_mirrored_set(false);
-            }
-            else if (layout == I18N_ULOCALE_LAYOUT_RTL) {
-                elm_config_mirrored_set(true);
-            }
-        }
-        free(lang);
-    }
+       char *lang = NULL;
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
+       if (lang) {
+               elm_language_set(lang);
+               i18n_ulocale_layout_type_e layout = I18N_ULOCALE_LAYOUT_UNKNOWN;
+               if (i18n_ulocale_get_character_orientation(lang, &layout) == I18N_ERROR_NONE) {
+                       if (layout == I18N_ULOCALE_LAYOUT_LTR)
+                               elm_config_mirrored_set(false);
+                       else if (layout == I18N_ULOCALE_LAYOUT_RTL)
+                               elm_config_mirrored_set(true);
+               }
+               free(lang);
+       }
 }
 
 static void _essential_system_db_init(void)
@@ -101,10 +97,10 @@ static void _essential_system_db_init(void)
        _g_is_system_init = true;
 
        WALLPAPERUI_DBG("media_content_connect");
-       if (media_content_connect() != MEDIA_CONTENT_ERROR_NONE) {
+       if (media_content_connect() != MEDIA_CONTENT_ERROR_NONE)
                WALLPAPERUI_ERR("media_content_connect is FAILED .....");
-       }
-    WALLPAPERUI_TRACE_END;
+
+       WALLPAPERUI_TRACE_END;
 }
 
 static void _essential_system_db_destroy(void)
@@ -119,7 +115,7 @@ static void _essential_system_db_destroy(void)
 
        WALLPAPERUI_DBG("media_content_disconnect");
        media_content_disconnect();
-    WALLPAPERUI_TRACE_END;
+       WALLPAPERUI_TRACE_END;
 }
 
 static bool _wallpaper_db_create(void)
@@ -133,7 +129,7 @@ static bool _wallpaper_db_create(void)
                WALLPAPERUI_ERR("media_content_connect is failed, err:%s", _str_error_db(ret));
                return false;
        }
-    WALLPAPERUI_TRACE_END;
+       WALLPAPERUI_TRACE_END;
        return true;
 }
 
@@ -148,7 +144,7 @@ static bool _wallpaper_db_destroy(void)
                WALLPAPERUI_ERR("media_content_disconnect is failed, err:%s", _str_error_db(ret));
                return false;
        }
-    WALLPAPERUI_TRACE_END;
+       WALLPAPERUI_TRACE_END;
        return true;
 }
 
@@ -170,9 +166,8 @@ static Evas_Object *_create_win(const char *name, bool transparent)
                elm_win_title_set(eo, name);
                elm_win_conformant_set(eo, EINA_TRUE);
 
-               if (transparent) {
+               if (transparent)
                        elm_win_alpha_set(eo, EINA_TRUE);
-               }
 
                evas_object_smart_callback_add(eo, "delete,request", _del_win, NULL);
                elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
@@ -198,37 +193,36 @@ static Evas_Object *_create_main_layout(Evas_Object *win, const char *edj_path,
        WALLPAPERUI_TRACE_BEGIN;
        retv_if(!win, NULL);
 
-    Evas_Object *conform = elm_conformant_add(win);
-    evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    elm_win_resize_object_add(win, conform);
-    elm_win_conformant_set(win, EINA_TRUE);
+       Evas_Object *conform = elm_conformant_add(win);
+       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_win_resize_object_add(win, conform);
+       elm_win_conformant_set(win, EINA_TRUE);
 
-    /*indicator bg */
-//    Evas_Object *indicator_bg = elm_bg_add(conform);
-//    elm_object_style_set(indicator_bg, "indicator/headerbg");
-//    elm_object_part_content_set(conform, "elm.swallow.indicator_bg", indicator_bg);
-//    evas_object_show(indicator_bg);
+       /*indicator bg
+        Evas_Object *indicator_bg = elm_bg_add(conform);
+        elm_object_style_set(indicator_bg, "indicator/headerbg");
+        elm_object_part_content_set(conform, "elm.swallow.indicator_bg", indicator_bg);
+        evas_object_show(indicator_bg); */
 
-    Evas_Object *layout = elm_layout_add(conform);
-    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       Evas_Object *layout = elm_layout_add(conform);
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
-    if (edj_path) {
-        elm_layout_file_set(layout, edj_path, group);
-    } else {
-        elm_layout_theme_set(layout, "layout", "application", "default");
-    }
+       if (edj_path)
+               elm_layout_file_set(layout, edj_path, group);
+       else
+               elm_layout_theme_set(layout, "layout", "application", "default");
 
-    elm_object_content_set(conform, layout);
-    evas_object_show(conform);
-    evas_object_show(layout);
+       elm_object_content_set(conform, layout);
+       evas_object_show(conform);
+       evas_object_show(layout);
 
-    int h=0, w=0;
-    elm_win_screen_size_get(layout, NULL, NULL, &w, &h);
-    WALLPAPERUI_DBG("layout w = %d, layout h = %d", w, h);
+       int h = 0, w = 0;
+       elm_win_screen_size_get(layout, NULL, NULL, &w, &h);
+       WALLPAPERUI_DBG("layout w = %d, layout h = %d", w, h);
 
-    elm_win_screen_size_get(conform, NULL, NULL, &w, &h);
-    WALLPAPERUI_DBG("conform w = %d, conform h = %d", w, h);
+       elm_win_screen_size_get(conform, NULL, NULL, &w, &h);
+       WALLPAPERUI_DBG("conform w = %d, conform h = %d", w, h);
 
        WALLPAPERUI_TRACE_END;
        return layout;
@@ -337,9 +331,9 @@ static void _app_pause(void *data)
        WALLPAPERUI_TRACE_BEGIN;
        char *value = NULL;
 
-       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) != SYSTEM_SETTINGS_ERROR_NONE) {
+       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) != SYSTEM_SETTINGS_ERROR_NONE)
                WALLPAPERUI_ERR("system_settings_get_value_string() failed");
-       }
+
        WALLPAPERUI_DBG("value = %s", value);
        /* terminate */
 }
@@ -352,9 +346,9 @@ static void _app_resume(void *data)
        WALLPAPERUI_TRACE_BEGIN;
        char *value = NULL;
 
-       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) != SYSTEM_SETTINGS_ERROR_NONE) {
+       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value) != SYSTEM_SETTINGS_ERROR_NONE)
                WALLPAPERUI_ERR("system_settings_get_value_string() failed");
-       }
+
        WALLPAPERUI_DBG("value = %s", value);
 
        WALLPAPERUI_TRACE_END;
@@ -377,18 +371,18 @@ static void _app_control(app_control_h service, void *data)
        }
 
 
-    /* create window */
-    ad->win = _create_win(PKGNAME, bTransparent);
-    if (ad->win == NULL) {
-        WALLPAPERUI_DBG("Can't create window");
-        return;
-    }
+       /* create window */
+       ad->win = _create_win(PKGNAME, bTransparent);
+       if (ad->win == NULL) {
+               WALLPAPERUI_DBG("Can't create window");
+               return;
+       }
 
-    flag_view_exist = false;
+       flag_view_exist = false;
 
-    ad->layout = _create_main_layout(ad->win, NULL, NULL);
+       ad->layout = _create_main_layout(ad->win, NULL, NULL);
 
-    char* edjPath = wallpaper_ui_service_get_edj_path("button_customized_theme.edj");
+       char *edjPath = wallpaper_ui_service_get_edj_path("button_customized_theme.edj");
        elm_theme_extension_add(NULL, edjPath);
        free(edjPath);
 
@@ -441,30 +435,30 @@ HAPI int main(int argc, char *argv[])
        return 0;
 }
 
-char * wallpaper_ui_service_get_icon_path(const char *fileName)
+char *wallpaper_ui_service_get_icon_path(const char *fileName)
 {
-    char *path = (char *)calloc(1, MAX_LENGTH_STRING);
-    if(!path)
-        return NULL;
-
-    char *resPath = app_get_resource_path();
-    snprintf(path, MAX_LENGTH_STRING, "%sicons/%s", resPath, fileName);
-    WALLPAPERUI_DBG("iconPath = %s", path);
-    free(resPath);
-    return path;
+       char *path = (char *)calloc(1, MAX_LENGTH_STRING);
+       if (!path)
+               return NULL;
+
+       char *resPath = app_get_resource_path();
+       snprintf(path, MAX_LENGTH_STRING, "%sicons/%s", resPath, fileName);
+       WALLPAPERUI_DBG("iconPath = %s", path);
+       free(resPath);
+       return path;
 }
 
-char * wallpaper_ui_service_get_edj_path(const char *fileName)
+char *wallpaper_ui_service_get_edj_path(const char *fileName)
 {
-    char *path = (char *)calloc(1, MAX_LENGTH_STRING);
-    if(!path)
-        return NULL;
-
-    char *resPath = app_get_resource_path();
-    snprintf(path, MAX_LENGTH_STRING, "%sedje/%s", resPath, fileName);
-    free(resPath);
-    WALLPAPERUI_DBG("edjePath = %s", path);
-    return path;
+       char *path = (char *)calloc(1, MAX_LENGTH_STRING);
+       if (!path)
+               return NULL;
+
+       char *resPath = app_get_resource_path();
+       snprintf(path, MAX_LENGTH_STRING, "%sedje/%s", resPath, fileName);
+       free(resPath);
+       WALLPAPERUI_DBG("edjePath = %s", path);
+       return path;
 }
 
 const char *wallpaper_ui_service_get_settings_wallpapers_path()
@@ -472,11 +466,9 @@ const char *wallpaper_ui_service_get_settings_wallpapers_path()
        return DEF_WALLPAPERS_PATH;
 }
 
-static bool _storage_device_supported_cb(int storage_id, storage_type_e type,
-               storage_state_e state, const char *path, void *user_data)
+static bool _storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
 {
-       if (type == STORAGE_TYPE_INTERNAL)
-       {
+       if (type == STORAGE_TYPE_INTERNAL) {
                int *id = (int *)user_data;
                *id = storage_id;
                return false;
@@ -486,8 +478,7 @@ static bool _storage_device_supported_cb(int storage_id, storage_type_e type,
 
 const char *get_working_dir()
 {
-       if (!_g_workingDirPath)
-       {
+       if (!_g_workingDirPath) {
                int storage_id = -1;
                storage_foreach_device_supported(_storage_device_supported_cb, &storage_id);
                storage_get_directory(storage_id, STORAGE_DIRECTORY_IMAGES, &_g_workingDirPath);
@@ -503,8 +494,4 @@ int get_max_prescale_img_size(wallpaper_ui_service_appdata *app)
        return MAX(w, h);
 }
 
-/**
-* @}
-*/
 /* End of file */
-