2 * Copyright (c) 2014 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://floralicense.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.
20 * Created on: Jan 7, 2014
21 * Author: Sunyeop Hwang
25 #include "setting-privacy.h"
26 #include "setting_data_vconf.h"
29 static void _privacy_lock_cb(void *data, Evas_Object *obj, void *event_info);
30 static void _privacy_see_pattern_cb(void *data, Evas_Object *obj, void *event_info);
31 static void _privacy_help_cb(void *data, Evas_Object *obj, void *event_info);
32 static void _privacy_pattern_enable_cb(void *data, Evas_Object *obj, void *event_info);
33 static void _privacy_pattern_disable_cb(void *data, Evas_Object *obj, void *event_info);
34 static void _create_privacy_pattern_list(void *data);
36 static struct _privacy_menu_item privacy_menu_list[] = {
37 { "IDS_LCKSCN_BODY_PRIVACY_LOCK_ABB", _privacy_lock_cb },
38 { "IDS_ST_MBODY_HELP", _privacy_help_cb }
42 static struct _privacy_menu_item privacy_pattern_menu_list[] = {
43 { "IDS_LCKSCN_HEADER_PIN", _privacy_pattern_enable_cb },
44 { "IDS_LCKSCN_BODY_NONE", _privacy_pattern_disable_cb }
47 static char *lock_type_str[] = {
48 "IDS_LCKSCN_BODY_NONE",
49 "IDS_LCKSCN_HEADER_PIN"
52 static Evas_Object *g_privacy_genlist = NULL;
54 int _get_lock_type_value()
57 if (vconf_get_int("db/setting/lock_type", &value) != 0) {
58 ERR("error get vconf value!!");
63 int _set_lock_type_value(int value)
65 if (vconf_set_int("db/setting/lock_type", value) != 0) {
66 ERR("error set vconf value!!");
72 int _get_see_pattern_value()
75 if (vconf_get_bool("db/setting/see_pattern", &value) != 0) {
76 ERR("error get vconf value!!");
81 int _set_see_pattern_value(int value)
83 if (vconf_set_bool("db/setting/see_pattern", value) != 0) {
84 ERR("error set vconf value!!");
90 static void _privacy_lock_setting_cb(app_control_h service, app_control_h reply, app_control_result_e result, void *data)
94 ERR("appdata is null");
98 if (result == APP_CONTROL_RESULT_SUCCEEDED) {
99 _set_lock_type_value(1);
100 elm_naviframe_item_pop(ad->nf);
102 if (g_privacy_genlist) {
103 elm_genlist_realized_items_update(g_privacy_genlist);
108 static void _privacy_lock_verify_cb(app_control_h service, app_control_h reply, app_control_result_e result, void *data)
112 ERR("appdata is null");
116 if (result == APP_CONTROL_RESULT_SUCCEEDED) {
117 _create_privacy_pattern_list(ad);
121 static void _gl_privacy_del(void *data, Evas_Object *obj)
123 Privacy_Item_Data *id = data;
128 char *_gl_privacy_pattern_title_get(void *data, Evas_Object *obj, const char *part)
130 char buf[1024] = {0,};
131 Item_Data *id = data;
132 int index = id->index;
133 char *device_info = NULL;
135 if (!strcmp(part, "elm.text")) {
136 snprintf(buf, sizeof(buf) - 1, "%s", _(privacy_pattern_menu_list[index].name));
142 static void _privacy_pattern_enable_cb(void *data, Evas_Object *obj, void *event_info)
144 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
148 ERR("appdata is null");
152 app_control_h service;
153 app_control_create(&service);
154 app_control_set_app_id(service, "org.tizen.w-lockscreen-setting");
156 app_control_add_extra_data(service, "type", "setting");
157 app_control_send_launch_request(service, _privacy_lock_setting_cb, ad);
158 app_control_destroy(service);
161 static void _privacy_pattern_disable_cb(void *data, Evas_Object *obj, void *event_info)
163 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
167 ERR("appdata is null");
171 _set_lock_type_value(0);
172 elm_naviframe_item_pop(ad->nf);
174 if (g_privacy_genlist) {
175 elm_genlist_realized_items_update(g_privacy_genlist);
179 static void _create_privacy_pattern_list(void *data)
184 ERR("appdata is null!!");
188 Evas_Object *genlist = NULL;
189 Evas_Object *layout = NULL;
190 Elm_Object_Item *nf_it = NULL;
191 struct _privacy_menu_item *menu_list = NULL;
194 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
195 itc->item_style = "1text";
196 itc->func.text_get = _gl_privacy_pattern_title_get;
197 itc->func.del = _gl_privacy_del;
199 layout = elm_layout_add(ad->nf);
200 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
201 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
203 genlist = elm_genlist_add(layout);
204 elm_genlist_block_count_set(genlist, 14);
206 menu_list = privacy_pattern_menu_list;
208 for (idx = 0; idx < sizeof(privacy_pattern_menu_list) / sizeof(struct _privacy_menu_item); idx++) {
209 Privacy_Item_Data *id = calloc(sizeof(Privacy_Item_Data), 1);
212 id->item = elm_genlist_item_append(
213 genlist, /* genlist object */
214 itc, /* item class */
217 ELM_GENLIST_ITEM_NONE,
218 menu_list[idx].func, /* call back */
223 elm_genlist_item_class_free(itc);
225 elm_object_part_content_set(layout, "elm.genlist", genlist);
227 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
228 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
231 char *_gl_privacy_title_get(void *data, Evas_Object *obj, const char *part)
233 char buf[1024] = {0,};
234 Item_Data *id = data;
235 int index = id->index;
236 char *device_info = NULL;
238 if (!strcmp(part, "elm.text.1") || !strcmp(part, "elm.text")) {
239 snprintf(buf, sizeof(buf) - 1, "%s", _(privacy_menu_list[index].name));
240 } else if (!strcmp(part, "elm.text.2")) {
241 snprintf(buf, sizeof(buf) - 1, "%s", _(lock_type_str[_get_lock_type_value()]));
247 Evas_Object *_gl_privacy_content_get(void *data, Evas_Object *obj, const char *part)
249 Evas_Object *check = NULL;
251 Privacy_Item_Data *id = data;
253 if (!strcmp(part, "elm.icon")) {
254 check = elm_check_add(obj);
255 elm_check_state_set(check, (_get_see_pattern_value()) ? EINA_TRUE : EINA_FALSE);
256 /*evas_object_smart_callback_add(check, "changed", _see_pattern_chk_changed_cb, (void *)1); */
257 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
258 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
265 static void _privacy_lock_cb(void *data, Evas_Object *obj, void *event_info)
267 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
271 ERR("appdata is null");
275 if (!_get_lock_type_value()) {
276 _create_privacy_pattern_list(ad);
278 app_control_h service;
279 app_control_create(&service);
280 app_control_set_app_id(service, "org.tizen.w-lockscreen-setting");
282 app_control_add_extra_data(service, "type", "verify");
283 app_control_send_launch_request(service, _privacy_lock_verify_cb, ad);
284 app_control_destroy(service);
288 void _create_help_popup(void *data)
290 Evas_Object *popup = NULL;
291 Evas_Object *btn = NULL;
292 Evas_Object *scroller = NULL;
293 Evas_Object *label = NULL;
295 appdata *ad = (appdata *) data;
299 popup = elm_popup_add(ad->nf);
300 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
301 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
302 elm_object_translatable_part_text_set(popup, "title,text", "IDS_ST_MBODY_HELP");
306 scroller = elm_scroller_add(popup);
307 evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
308 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
309 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
310 elm_object_style_set(scroller, "effect");
311 elm_object_content_set(popup, scroller);
312 evas_object_show(scroller);
314 label = elm_label_add(scroller);
315 elm_object_style_set(label, "popup/default");
316 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
317 elm_object_translatable_text_set(label, "IDS_LCKSCN_BODY_THE_PRIVACY_LOCK_OPTION_WILL_BE_SHOWN_WHEN_BLUETOOTH_IS_DISCONNECTED");
319 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
320 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
321 elm_object_content_set(scroller, label);
322 evas_object_show(label);
324 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, setting_popup_back_cb, ad);
326 evas_object_show(popup);
329 static void _privacy_help_cb(void *data, Evas_Object *obj, void *event_info)
331 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
335 DBG("%s", "_privcay_help_cb - ad is null");
339 _create_help_popup(ad);
342 Evas_Object *create_privacy_list(void *data)
347 ERR("appdata is null!!");
351 Evas_Object *genlist = NULL;
352 Evas_Object *layout = NULL;
353 struct _privacy_menu_item *menu_list = NULL;
356 Elm_Genlist_Item_Class *itc = NULL;
358 Elm_Genlist_Item_Class *itc_2text = elm_genlist_item_class_new();
359 itc_2text->item_style = "2text";
360 itc_2text->func.text_get = _gl_privacy_title_get;
361 itc_2text->func.del = _gl_privacy_del;
363 Elm_Genlist_Item_Class *itc_1text = elm_genlist_item_class_new();
364 itc_1text->item_style = "1text";
365 itc_1text->func.text_get = _gl_privacy_title_get;
366 itc_1text->func.del = _gl_privacy_del;
368 layout = elm_layout_add(ad->nf);
369 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
370 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
372 genlist = elm_genlist_add(layout);
373 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
374 /*elm_genlist_block_count_set(genlist, 14); */
376 menu_list = privacy_menu_list;
378 for (idx = 0; idx < sizeof(privacy_menu_list) / sizeof(struct _privacy_menu_item); idx++) {
385 Privacy_Item_Data *id = calloc(sizeof(Privacy_Item_Data), 1);
388 id->item = elm_genlist_item_append(
389 genlist, /* genlist object */
390 itc, /* item class */
393 ELM_GENLIST_ITEM_NONE,
394 menu_list[idx].func, /* call back */
399 elm_genlist_item_class_free(itc_2text);
400 elm_genlist_item_class_free(itc_1text);
403 g_privacy_genlist = genlist;
405 elm_object_part_content_set(layout, "elm.genlist", genlist);
410 Eina_Bool clear_privacy_cb(void *data, Elm_Object_Item *it)
412 g_privacy_genlist = NULL;