2 * Copyright (c) 2016 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.h"
22 #include <system_settings.h>
24 #include <Ecore_File.h>
26 #define DEFAULT_BG IMAGE_DIR"Default.jpg"
28 static char *background_file;
29 static int init_count;
30 int LOCKSCREEN_EVENT_BACKGROUND_CHANGED;
32 int lockscreen_background_init(void)
37 LOCKSCREEN_EVENT_BACKGROUND_CHANGED = ecore_event_type_new();
38 int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &bg);
39 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
40 ERR("system_settings_set_value_string failed: %s", get_error_message(ret));
44 if (lockscreen_background_file_set(bg))
45 lockscreen_background_file_set(NULL);
52 int lockscreen_background_file_set(const char *path)
55 return lockscreen_background_file_set(util_get_res_file_path(DEFAULT_BG));
58 if (background_file && !strcmp(background_file, path)) {
62 if (!ecore_file_can_read(path)) {
63 ERR("Cannot access/read background file: %s", path);
67 free(background_file);
68 background_file = strdup(path);
70 ecore_event_add(LOCKSCREEN_EVENT_BACKGROUND_CHANGED, NULL, NULL, NULL);
74 void lockscreen_background_shutdown(void)
78 free(background_file);
79 background_file = NULL;
83 const char *lockscreen_background_file_get(void)
85 return background_file;