2 * Copyright (c) 2000 - 2013 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.
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(service_h service, service_h reply, service_result_e result, void *data)
94 ERR("appdata is null");
98 if (result == SERVICE_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(service_h service, service_h reply, service_result_e result, void *data)
112 ERR("appdata is null");
116 if (result == SERVICE_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)
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");
153 service_create(&service);
154 service_set_app_id(service, "org.tizen.w-lockscreen-setting");
156 service_add_extra_data(service, "type", "setting");
157 service_send_launch_request(service, _privacy_lock_setting_cb, ad);
158 service_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);
211 id->item = elm_genlist_item_append(
212 genlist, // genlist object
216 ELM_GENLIST_ITEM_NONE,
217 menu_list[idx].func, // call back
221 elm_genlist_item_class_free(itc);
223 elm_object_part_content_set(layout, "elm.genlist", genlist);
225 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
226 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
229 char *_gl_privacy_title_get(void *data, Evas_Object *obj, const char *part)
232 Item_Data *id = data;
233 int index = id->index;
234 char * device_info = NULL;
236 if (!strcmp(part, "elm.text.1") || !strcmp(part, "elm.text")) {
237 snprintf(buf, sizeof(buf)-1, "%s", _(privacy_menu_list[index].name));
238 } else if (!strcmp(part, "elm.text.2")) {
239 snprintf(buf, sizeof(buf)-1, "%s", _(lock_type_str[_get_lock_type_value()]));
245 Evas_Object *_gl_privacy_content_get(void *data, Evas_Object *obj, const char *part)
247 Evas_Object *check = NULL;
249 Privacy_Item_Data *id = data;
251 if (!strcmp(part, "elm.icon")) {
252 check = elm_check_add(obj);
253 elm_check_state_set(check, (_get_see_pattern_value()) ? EINA_TRUE : EINA_FALSE);
254 //evas_object_smart_callback_add(check, "changed", _see_pattern_chk_changed_cb, (void *)1);
255 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
256 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
263 static void _privacy_lock_cb(void *data, Evas_Object *obj, void *event_info)
265 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
269 ERR("appdata is null");
273 if (!_get_lock_type_value()) {
274 _create_privacy_pattern_list(ad);
277 service_create(&service);
278 service_set_app_id(service, "org.tizen.w-lockscreen-setting");
280 service_add_extra_data(service, "type", "verify");
281 service_send_launch_request(service, _privacy_lock_verify_cb, ad);
282 service_destroy(service);
286 void _create_help_popup(void *data)
288 Evas_Object *popup = NULL;
289 Evas_Object *btn = NULL;
290 Evas_Object *scroller = NULL;
291 Evas_Object *label = NULL;
293 appdata *ad = (appdata *) data;
297 popup = elm_popup_add(ad->nf);
298 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
299 elm_object_translatable_part_text_set(popup, "title,text", "IDS_ST_MBODY_HELP");
303 scroller = elm_scroller_add(popup);
304 evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
305 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
306 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
307 elm_object_style_set(scroller, "effect");
308 elm_object_content_set(popup, scroller);
309 evas_object_show(scroller);
311 label = elm_label_add(scroller);
312 elm_object_style_set(label, "popup/default");
313 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
314 elm_object_translatable_text_set(label, "IDS_LCKSCN_BODY_THE_PRIVACY_LOCK_OPTION_WILL_BE_SHOWN_WHEN_BLUETOOTH_IS_DISCONNECTED");
316 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
317 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
318 elm_object_content_set(scroller, label);
319 evas_object_show(label);
321 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, setting_popup_back_cb, ad);
323 evas_object_show(popup);
326 static void _privacy_help_cb(void *data, Evas_Object *obj, void *event_info)
328 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
333 DBG("%s", "_privcay_help_cb - ad is null");
337 _create_help_popup(ad);
340 Evas_Object *create_privacy_list(void *data)
345 ERR("appdata is null!!");
349 Evas_Object *genlist = NULL;
350 Evas_Object *layout = NULL;
351 struct _privacy_menu_item *menu_list = NULL;
354 Elm_Genlist_Item_Class *itc = NULL;
356 Elm_Genlist_Item_Class *itc_2text = elm_genlist_item_class_new();
357 itc_2text->item_style = "2text";
358 itc_2text->func.text_get = _gl_privacy_title_get;
359 itc_2text->func.del = _gl_privacy_del;
361 Elm_Genlist_Item_Class *itc_1text = elm_genlist_item_class_new();
362 itc_1text->item_style = "1text";
363 itc_1text->func.text_get = _gl_privacy_title_get;
364 itc_1text->func.del = _gl_privacy_del;
366 layout = elm_layout_add(ad->nf);
367 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
368 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
370 genlist = elm_genlist_add(layout);
371 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
372 //elm_genlist_block_count_set(genlist, 14);
374 menu_list = privacy_menu_list;
376 for (idx = 0; idx < sizeof(privacy_menu_list) / sizeof(struct _privacy_menu_item); idx++) {
383 Privacy_Item_Data *id = calloc(sizeof(Privacy_Item_Data), 1);
385 id->item = elm_genlist_item_append(
386 genlist, // genlist object
390 ELM_GENLIST_ITEM_NONE,
391 menu_list[idx].func, // call back
395 elm_genlist_item_class_free(itc_2text);
396 elm_genlist_item_class_free(itc_1text);
399 g_privacy_genlist = genlist;
401 elm_object_part_content_set(layout, "elm.genlist", genlist);
406 Eina_Bool clear_privacy_cb(void *data, Elm_Object_Item *it)
408 g_privacy_genlist = NULL;