2 * Copyright (c) 2010 Samsung Electronics, Inc.
5 * This software is a confidential and proprietary information
6 * of Samsung Electronics, Inc. ("Confidential Information"). You
7 * shall not disclose such Confidential Information and shall use
8 * it only in accordance with the terms of the license agreement
9 * you entered into with Samsung Electronics.
14 * Created on: Jan 7, 2014
15 * Author: Sunyeop Hwang
19 #include "setting-privacy.h"
20 #include "setting_data_vconf.h"
23 static void _privacy_lock_cb(void *data, Evas_Object *obj, void *event_info);
24 static void _privacy_see_pattern_cb(void *data, Evas_Object *obj, void *event_info);
25 static void _privacy_help_cb(void *data, Evas_Object *obj, void *event_info);
26 static void _privacy_pattern_enable_cb(void *data, Evas_Object *obj, void *event_info);
27 static void _privacy_pattern_disable_cb(void *data, Evas_Object *obj, void *event_info);
28 static void _create_privacy_pattern_list(void *data);
30 static struct _privacy_menu_item privacy_menu_list[] = {
31 { "IDS_LCKSCN_BODY_PRIVACY_LOCK_ABB", _privacy_lock_cb },
32 { "IDS_ST_MBODY_HELP", _privacy_help_cb }
36 static struct _privacy_menu_item privacy_pattern_menu_list[] = {
37 { "IDS_LCKSCN_HEADER_PIN", _privacy_pattern_enable_cb },
38 { "IDS_LCKSCN_BODY_NONE", _privacy_pattern_disable_cb }
41 static char *lock_type_str[] = {
42 "IDS_LCKSCN_BODY_NONE",
43 "IDS_LCKSCN_HEADER_PIN"
46 static Evas_Object *g_privacy_genlist = NULL;
48 int _get_lock_type_value()
51 if (vconf_get_int("db/setting/lock_type", &value) != 0) {
52 ERR("error get vconf value!!");
57 int _set_lock_type_value(int value)
59 if (vconf_set_int("db/setting/lock_type", value) != 0) {
60 ERR("error set vconf value!!");
66 int _get_see_pattern_value()
69 if (vconf_get_bool("db/setting/see_pattern", &value) != 0) {
70 ERR("error get vconf value!!");
75 int _set_see_pattern_value(int value)
77 if (vconf_set_bool("db/setting/see_pattern", value) != 0) {
78 ERR("error set vconf value!!");
84 static void _privacy_lock_setting_cb(app_control_h service, app_control_h reply, app_control_result_e result, void *data)
88 ERR("appdata is null");
92 if (result == APP_CONTROL_RESULT_SUCCEEDED) {
93 _set_lock_type_value(1);
94 elm_naviframe_item_pop(ad->nf);
96 if (g_privacy_genlist) {
97 elm_genlist_realized_items_update(g_privacy_genlist);
102 static void _privacy_lock_verify_cb(app_control_h service, app_control_h reply, app_control_result_e result, void *data)
106 ERR("appdata is null");
110 if (result == APP_CONTROL_RESULT_SUCCEEDED) {
111 _create_privacy_pattern_list(ad);
115 static void _gl_privacy_del(void *data, Evas_Object *obj)
117 Privacy_Item_Data *id = data;
122 char *_gl_privacy_pattern_title_get(void *data, Evas_Object *obj, const char *part)
125 Item_Data *id = data;
126 int index = id->index;
127 char * device_info = NULL;
129 if (!strcmp(part, "elm.text")) {
130 snprintf(buf, sizeof(buf)-1, "%s", _(privacy_pattern_menu_list[index].name));
136 static void _privacy_pattern_enable_cb(void *data, Evas_Object *obj, void *event_info)
138 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
142 ERR("appdata is null");
146 app_control_h service;
147 app_control_create(&service);
148 app_control_set_app_id(service, "org.tizen.w-lockscreen-setting");
150 app_control_add_extra_data(service, "type", "setting");
151 app_control_send_launch_request(service, _privacy_lock_setting_cb, ad);
152 app_control_destroy(service);
155 static void _privacy_pattern_disable_cb(void *data, Evas_Object *obj, void *event_info)
157 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
161 ERR("appdata is null");
165 _set_lock_type_value(0);
166 elm_naviframe_item_pop(ad->nf);
168 if (g_privacy_genlist) {
169 elm_genlist_realized_items_update(g_privacy_genlist);
173 static void _create_privacy_pattern_list(void *data)
178 ERR("appdata is null!!");
182 Evas_Object *genlist = NULL;
183 Evas_Object *layout = NULL;
184 Elm_Object_Item *nf_it = NULL;
185 struct _privacy_menu_item *menu_list = NULL;
188 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
189 itc->item_style = "1text";
190 itc->func.text_get = _gl_privacy_pattern_title_get;
191 itc->func.del = _gl_privacy_del;
193 layout = elm_layout_add(ad->nf);
194 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
195 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
197 genlist = elm_genlist_add(layout);
198 elm_genlist_block_count_set(genlist, 14);
200 menu_list = privacy_pattern_menu_list;
202 for (idx = 0; idx < sizeof(privacy_pattern_menu_list) / sizeof(struct _privacy_menu_item); idx++) {
203 Privacy_Item_Data *id = calloc(sizeof(Privacy_Item_Data), 1);
205 id->item = elm_genlist_item_append(
206 genlist, // genlist object
210 ELM_GENLIST_ITEM_NONE,
211 menu_list[idx].func, // call back
215 elm_genlist_item_class_free(itc);
217 elm_object_part_content_set(layout, "elm.genlist", genlist);
219 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
220 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
223 char *_gl_privacy_title_get(void *data, Evas_Object *obj, const char *part)
226 Item_Data *id = data;
227 int index = id->index;
228 char * device_info = NULL;
230 if (!strcmp(part, "elm.text.1") || !strcmp(part, "elm.text")) {
231 snprintf(buf, sizeof(buf)-1, "%s", _(privacy_menu_list[index].name));
232 } else if (!strcmp(part, "elm.text.2")) {
233 snprintf(buf, sizeof(buf)-1, "%s", _(lock_type_str[_get_lock_type_value()]));
239 Evas_Object *_gl_privacy_content_get(void *data, Evas_Object *obj, const char *part)
241 Evas_Object *check = NULL;
243 Privacy_Item_Data *id = data;
245 if (!strcmp(part, "elm.icon")) {
246 check = elm_check_add(obj);
247 elm_check_state_set(check, (_get_see_pattern_value()) ? EINA_TRUE : EINA_FALSE);
248 //evas_object_smart_callback_add(check, "changed", _see_pattern_chk_changed_cb, (void *)1);
249 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
250 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
257 static void _privacy_lock_cb(void *data, Evas_Object *obj, void *event_info)
259 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
263 ERR("appdata is null");
267 if (!_get_lock_type_value()) {
268 _create_privacy_pattern_list(ad);
270 app_control_h service;
271 app_control_create(&service);
272 app_control_set_app_id(service, "org.tizen.w-lockscreen-setting");
274 app_control_add_extra_data(service, "type", "verify");
275 app_control_send_launch_request(service, _privacy_lock_verify_cb, ad);
276 app_control_destroy(service);
280 void _create_help_popup(void *data)
282 Evas_Object *popup = NULL;
283 Evas_Object *btn = NULL;
284 Evas_Object *scroller = NULL;
285 Evas_Object *label = NULL;
287 appdata *ad = (appdata *) data;
291 popup = elm_popup_add(ad->nf);
292 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
293 elm_object_translatable_part_text_set(popup, "title,text", "IDS_ST_MBODY_HELP");
297 scroller = elm_scroller_add(popup);
298 evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
299 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
300 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
301 elm_object_style_set(scroller, "effect");
302 elm_object_content_set(popup, scroller);
303 evas_object_show(scroller);
305 label = elm_label_add(scroller);
306 elm_object_style_set(label, "popup/default");
307 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
308 elm_object_translatable_text_set(label, "IDS_LCKSCN_BODY_THE_PRIVACY_LOCK_OPTION_WILL_BE_SHOWN_WHEN_BLUETOOTH_IS_DISCONNECTED");
310 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
311 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
312 elm_object_content_set(scroller, label);
313 evas_object_show(label);
315 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, setting_popup_back_cb, ad);
317 evas_object_show(popup);
320 static void _privacy_help_cb(void *data, Evas_Object *obj, void *event_info)
322 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
327 DBG("%s", "_privcay_help_cb - ad is null");
331 _create_help_popup(ad);
334 Evas_Object *create_privacy_list(void *data)
339 ERR("appdata is null!!");
343 Evas_Object *genlist = NULL;
344 Evas_Object *layout = NULL;
345 struct _privacy_menu_item *menu_list = NULL;
348 Elm_Genlist_Item_Class *itc = NULL;
350 Elm_Genlist_Item_Class *itc_2text = elm_genlist_item_class_new();
351 itc_2text->item_style = "2text";
352 itc_2text->func.text_get = _gl_privacy_title_get;
353 itc_2text->func.del = _gl_privacy_del;
355 Elm_Genlist_Item_Class *itc_1text = elm_genlist_item_class_new();
356 itc_1text->item_style = "1text";
357 itc_1text->func.text_get = _gl_privacy_title_get;
358 itc_1text->func.del = _gl_privacy_del;
360 layout = elm_layout_add(ad->nf);
361 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
362 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
364 genlist = elm_genlist_add(layout);
365 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
366 //elm_genlist_block_count_set(genlist, 14);
368 menu_list = privacy_menu_list;
370 for (idx = 0; idx < sizeof(privacy_menu_list) / sizeof(struct _privacy_menu_item); idx++) {
377 Privacy_Item_Data *id = calloc(sizeof(Privacy_Item_Data), 1);
379 id->item = elm_genlist_item_append(
380 genlist, // genlist object
384 ELM_GENLIST_ITEM_NONE,
385 menu_list[idx].func, // call back
389 elm_genlist_item_class_free(itc_2text);
390 elm_genlist_item_class_free(itc_1text);
393 g_privacy_genlist = genlist;
395 elm_object_part_content_set(layout, "elm.genlist", genlist);
400 Eina_Bool clear_privacy_cb(void *data, Elm_Object_Item *it)
402 g_privacy_genlist = NULL;