2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
18 #include "ivug-common.h"
19 #include "ivug-define.h"
20 #include "ivug-effect.h"
21 #include "ivug-config.h"
24 #include <vconf-keys.h>
26 // TODO: Request vconf key to setting part, Slide show setting vconf key
27 #define VCONFKEY_GALLERY_INTERVAL_TIME "db/setting/gallery/interval_time" //double
28 #define VCONFKEY_GALLERY_REPEAT_STATE "db/setting/gallery/repeat_state" //boolean
29 #define VCONFKEY_GALLERY_SHUFFLE_STATE "db/setting/gallery/shuffle_state" //boolean
30 #define VCONFKEY_GALLERY_TRANSITION_EFFECT "db/setting/gallery/ss_effect" //char
32 enum { STATE_FALSE = 0, STATE_TRUE = 1, };
35 Set lock screen with given image.
37 CAUTION : does not check filepath integrity
39 bool ivug_config_set_lockscreen_image(const char* filepath)
43 MSG_IMAGEVIEW_ERROR("Lock screen path is NULL");
47 if(vconf_set_str( VCONFKEY_IDLE_LOCK_BGSET, filepath ) < 0)
49 MSG_IMAGEVIEW_ERROR("Lockscreen set Error : %s", filepath);
53 MSG_IMAGEVIEW_HIGH("Set Lockscreen filepath = %s", filepath);
59 Set home screen with given image
61 CAUTION : does not check filepath integrity
63 bool ivug_config_set_homescreen_image( const char* filepath )
67 MSG_IMAGEVIEW_ERROR("Home screen path is NULL");
70 // TODO : Need to check file existence?????
71 if(vconf_set_str(VCONFKEY_BGSET, filepath) < 0)
73 MSG_IMAGEVIEW_ERROR("Homescreen set Error");
77 MSG_IMAGEVIEW_HIGH("Set Homescreen filepath = %s", filepath);
83 _ivug_config_get_slideshow_repeat_state(void)
85 int repeat_state = STATE_FALSE;
87 if(vconf_get_bool(VCONFKEY_GALLERY_REPEAT_STATE, &repeat_state) < 0)
89 MSG_IMAGEVIEW_ERROR("vconf_get_bool failed, set as repeat state as default: false");
93 MSG_IMAGEVIEW_HIGH("repeat state is: %d", repeat_state);
95 return (repeat_state == STATE_TRUE ? true : false);
99 _ivug_config_get_slideshow_shuffle_state(void)
101 int shuffle_state = STATE_FALSE;
103 if(vconf_get_bool(VCONFKEY_GALLERY_SHUFFLE_STATE, &shuffle_state) < 0)
105 MSG_IMAGEVIEW_ERROR("vconf_get_bool failed, set as shuffle state as default: false");
109 MSG_IMAGEVIEW_HIGH("shuffle state is: %d", shuffle_state);
111 return (shuffle_state == STATE_TRUE ? true : false);
115 _ivug_config_get_slideshow_interval_time(void)
117 double interval_time = 0.0;
119 if(vconf_get_dbl(VCONFKEY_GALLERY_INTERVAL_TIME, &interval_time) < 0)
121 MSG_IMAGEVIEW_ERROR("vconf_get_dbl failed, set as interval time as -1");
123 interval_time = -1.0;
126 MSG_IMAGEVIEW_HIGH("interval time is: %f", interval_time);
127 return interval_time;
131 _ivug_config_get_slideshow_effect_type(void)
133 // TODO : Free returned string??
134 char *effect_str = NULL;
135 effect_str = vconf_get_str(VCONFKEY_GALLERY_TRANSITION_EFFECT);
139 MSG_IMAGEVIEW_ERROR("vconf_get_str failed, set as effect type as default");
144 MSG_IMAGEVIEW_HIGH("effect is: %s", effect_str);
149 static ivug_effect_type
150 _ivug_config_get_effect_type_by_string(char *effect_str)
152 ivug_retv_if(!effect_str, EFFECT_NONE);
154 ivug_effect_type type = IVUG_EFFECT_TYPE_SLIDE;
156 if(!strncmp(effect_str, "Slide", strlen(effect_str)))
158 type = IVUG_EFFECT_TYPE_SLIDE;
160 else //Set all other cases as default NONE
162 MSG_SLIDER_WARN("Invalid type : %s", effect_str);
166 MSG_IMAGEVIEW_HIGH("effect_str = %s, type = %d", effect_str, type);
172 ivug_config_get_slideshow_setting(slide_show_mode *mode,
173 double *interval_time,
174 ivug_effect_type *effect_type)
176 *mode = SLIDE_SHOW_MODE_NORMAL;
180 state = _ivug_config_get_slideshow_repeat_state();
183 *mode |= SLIDE_SHOW_MODE_REPEAT;
186 state = _ivug_config_get_slideshow_shuffle_state();
189 *mode |= SLIDE_SHOW_MODE_SHUFFLE;
192 *interval_time = _ivug_config_get_slideshow_interval_time();
194 /* EFFECT_NONE, EFFECT_FADE, EFFECT_BLIND, EFFECT_IRIS */
195 char *effect = _ivug_config_get_slideshow_effect_type();
197 *effect_type = _ivug_config_get_effect_type_by_string(effect);