2 * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "lockscreen.h"
19 #include "background_view.h"
22 #include "default_lock.h"
24 #define EDJE_SIGNAL_SOURCE "bg"
25 #define EDJE_SIGNAL_EMIT_MUSIC_ON "music_on"
26 #define EDJE_SIGNAL_EMIT_MUSIC_OFF "music_off"
28 static struct _s_info {
34 Evas_Object *lock_background_view_bg_get(void)
39 lock_error_e lock_background_view_image_set(lock_bg_type_e type, char *file)
41 Evas_Object *lock_layout = NULL;
42 const char *old_filename = NULL;
47 retv_if(!s_info.bg, LOCK_ERROR_INVALID_PARAMETER);
49 elm_bg_file_get(s_info.bg, &old_filename, NULL);
51 old_filename = LOCK_DEFAULT_BG_PATH;
53 _D("old file name : %s", old_filename);
57 if (LOCK_ERROR_OK != lock_property_get_string(PROPERTY_TYPE_SYSTEM_SETTINGS, (void *)SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &lock_bg)) {
58 _E("Failed to get lockscreen BG");
61 goto_if(!lock_bg, ERROR);
63 _D("lock_bg : %s", lock_bg);
65 if (!elm_bg_file_set(s_info.bg, lock_bg, NULL)) {
66 _E("Failed to set a BG image : %s", lock_bg);
71 emission = EDJE_SIGNAL_EMIT_MUSIC_OFF;
75 case LOCK_BG_ALBUM_ART:
77 _E("Failed to set a BG image");
78 return LOCK_ERROR_INVALID_PARAMETER;
81 if (!elm_bg_file_set(s_info.bg, file, NULL)) {
82 _E("Failed to set album art BG : %s", file);
86 emission = EDJE_SIGNAL_EMIT_MUSIC_ON;
89 _E("Failed to set background image : type error(%d)", type);
93 lock_layout = lock_default_lock_layout_get();
95 elm_layout_signal_emit(lock_layout, emission, EDJE_SIGNAL_SOURCE);
101 if (!elm_bg_file_set(s_info.bg, old_filename, NULL)) {
102 _E("Failed to set old BG file : %s. Retry to set default BG.", old_filename);
103 if (!elm_bg_file_set(s_info.bg, LOCK_DEFAULT_BG_PATH, NULL)) {
104 _E("Failed to set default BG : %s.", LOCK_DEFAULT_BG_PATH);
105 return LOCK_ERROR_FAIL;
109 return LOCK_ERROR_OK;
112 Evas_Object *lock_background_view_bg_create(Evas_Object *win)
114 int win_w = lock_window_width_get();
115 int win_h = lock_window_height_get();
116 _D("win size : %dx%d", win_w, win_h);
120 Evas_Object *bg = elm_bg_add(win);
123 elm_bg_option_set(bg, ELM_BG_OPTION_SCALE);
125 evas_object_size_hint_min_set(bg, win_w, win_h);
126 elm_win_resize_object_add(win, bg);
127 evas_object_show(bg);
131 if (LOCK_ERROR_OK != lock_background_view_image_set(LOCK_BG_DEFAULT, NULL)) {
132 _E("Failed to set a BG image");
138 void lock_background_view_bg_del(void)
141 evas_object_del(s_info.bg);