2 * setting_personal_mode
7 #include <setting-debug.h>
8 #include <setting-common-draw-widget.h>
9 #include <setting-common-general-func.h>
11 #include <Elementary.h>
12 #include <efl_assist.h>
17 #include <notification.h>
18 #include <ui-gadget.h>
20 #define EXPORT_PUBLIC __attribute__ ((visibility ("default")))
22 typedef struct _personal_mode_data {
32 static void personal_mode_terminate(void *data)
37 personal_mode_data *ad = (personal_mode_data *) data;
41 evas_object_del(ad->popup);
47 evas_object_del(ad->ly_main);
53 evas_object_del(ad->win);
60 static void __del_cb(void *data, Evas_Object *obj, void *event)
65 void personal_mode_unmount(void *data)
69 personal_mode_data *ad = (personal_mode_data *) data;
74 SETTING_TRACE("change #1. init failed");
75 setting_create_simple_popup(ad, ad->win, NULL, "Fail to change unlock method");
78 if(pse_unmount() != 0)
80 SETTING_TRACE("change #2. unmount failed");
81 setting_create_simple_popup(ad, ad->win, NULL, "Fail to change unlock method");
87 vconf_set_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, 0);
88 notification_delete_all_by_type("org.tizen.setting.personal", NOTIFICATION_VARIABLE_TYPE_NONE);
89 // 1 line notification on the notification bar.
90 notification_status_message_post(_("IDS_ST_TPOP_PERSONAL_MODE_DISABLED_ABB"));
93 static Evas_Object* personal_mode_create_window(const char *name, bool transparent)
100 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
103 elm_win_title_set(eo, name);
104 elm_win_conformant_set(eo, EINA_TRUE);
108 SETTING_TRACE_DEBUG("set transparent");
110 elm_win_alpha_set(eo, EINA_TRUE);
112 unsigned int opaqueVal = 1;
113 Ecore_X_Atom opaqueAtom = ecore_x_atom_get("_E_ILLUME_WINDOW_REGION_OPAQUE");
114 Ecore_X_Window xwin = elm_win_xwindow_get(eo);
115 ecore_x_window_prop_card32_set(xwin, opaqueAtom, &opaqueVal, 1);
118 evas_object_smart_callback_add(eo, "delete,request", __del_cb, NULL);
119 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
120 evas_object_resize(eo, w, h);
122 elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
123 elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE);
125 if(elm_win_wm_rotation_supported_get(eo))
127 const int rots[4] = {0, 90, 180, 270};
128 elm_win_wm_rotation_available_rotations_set(eo, (const int*)&rots, 4);
130 SETTING_TRACE_DEBUG("win layer : %d", elm_win_layer_get(eo));
135 static Evas_Object* personal_mode_create_layout(Evas_Object *win)
138 Evas_Object *eo = elm_layout_add(win);
141 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
142 elm_layout_theme_set(eo, "layout", "application", "default");
143 evas_object_show(eo);
145 Evas_Object *conform = elm_conformant_add(win);
146 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
147 evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
148 elm_win_resize_object_add(win, conform);
149 elm_object_content_set(conform, eo);
150 evas_object_show(conform);
155 void personal_mode_destroy_ug_cb(ui_gadget_h ug, void *priv)
157 personal_mode_data *ad = (personal_mode_data *) priv;
159 return; /* do nothing if ad is NULL */
161 //elm_win_lower(ad->win);
164 setting_ug_destroy(ug);
169 void personal_mode_end_ug_cb(ui_gadget_h ug, void *priv)
173 personal_mode_data *ad = (personal_mode_data *) priv;
175 return; /* do nothing if ad is NULL */
176 personal_mode_terminate(ad);
179 void personal_mode_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
184 base = (Evas_Object *) ug_get_layout(ug);
189 case UG_MODE_FULLVIEW:
190 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
192 ug_disable_effect(ug);
193 evas_object_show(base);
200 static void personal_mode_popup_cb(void *data, Evas_Object *obj, void *event)
203 personal_mode_data *ad = data;
205 char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
206 if(!strcmp(btn_str, _("IDS_COM_SK_OK")))
210 int status = elm_check_state_get(ad->check);
211 vconf_set_bool("db/setting/personal_off_popup_do_not_show_flag", status);
213 personal_mode_unmount(ad);
216 personal_mode_terminate(ad);
219 static bool personal_mode_create(void *data)
226 static void personal_mode_service(app_control_h service, void *data)
230 personal_mode_data *ad = (personal_mode_data *)data;
234 char *viewtype = NULL;
236 // get current personal mode
237 vconf_get_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, &curStatus);
239 // get <do not show again> option
240 vconf_get_bool("db/setting/personal_off_popup_do_not_show_flag", &popupOption);
242 // check viewtype as "unlock_method"
243 app_control_get_extra_data(service, "viewtype", &viewtype);
246 if(curStatus && !safeStrCmp(viewtype, "unlock_method"))
250 // just unmount and exist
251 personal_mode_unmount(ad);
252 personal_mode_terminate(ad);
256 // create transparent window and popup
257 ad->win = personal_mode_create_window("personal_mode", 1);
258 UG_INIT_EFL(ad->win, UG_OPT_INDICATOR_ENABLE);
259 ad->evas = evas_object_evas_get(ad->win);
261 ad->ly_main = personal_mode_create_layout(ad->win);
262 evas_object_show(ad->win);
263 elm_win_activate(ad->win);
265 ad->popup = setting_create_popup_with_label_check(ad, ad->win, NULL,
266 _("IDS_ST_POP_ANY_PERSONAL_CONTENT_WILL_NOT_BE_ACCESSIBLE_IN_NORMAL_MODE"),
267 _("IDS_ST_BODY_DO_NOT_SHOW_AGAIN"), &(ad->check), personal_mode_popup_cb,
268 0, 2, "IDS_COM_SK_CANCEL", "IDS_COM_SK_OK");
269 evas_object_show(ad->popup);
274 // create normal window and create ug with service
275 ad->win = personal_mode_create_window("personal_mode", 1);
277 UG_INIT_EFL(ad->win, UG_OPT_INDICATOR_ENABLE);
278 ad->evas = evas_object_evas_get(ad->win);
280 ad->ly_main = personal_mode_create_layout(ad->win);
281 evas_object_show(ad->win);
282 elm_win_activate(ad->win);
285 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
288 personal_mode_terminate(ad);
291 cbs->layout_cb = personal_mode_layout_ug_cb;
292 cbs->result_cb = NULL;
293 cbs->destroy_cb = personal_mode_destroy_ug_cb;
294 cbs->end_cb = personal_mode_end_ug_cb;
295 cbs->priv = (void *)ad;
297 ad->ug = setting_ug_create(NULL, "setting-personalpage-efl", UG_MODE_FULLVIEW, service, cbs);
304 static void personal_mode_pause(void *data)
310 * The function is called when Setting begins run in forground from background
312 static void personal_mode_resume(void *data)
318 int main(int argc, char* argv[])
321 personal_mode_data ad;
323 elm_init(argc, argv);
325 app_event_callback_s ops = {0,};
326 ops.create = personal_mode_create;
327 ops.terminate = personal_mode_terminate;
328 ops.pause = personal_mode_pause;
329 ops.resume = personal_mode_resume;
330 ops.app_control = personal_mode_service;
332 memset(&ad, 0x00, sizeof(personal_mode_data));
334 int ret = app_efl_main(&argc, &argv, &ops, &ad);
335 retvm_if(ret == -1, -1, "App returns -1");