4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
6 * This file is part of org.tizen.setting
7 * Written by Hyejin Kim <hyejin0906.kim@samsung.com>
9 * PROPRIETARY/CONFIDENTIAL
11 * This software is the confidential and proprietary information of
12 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
13 * disclose such Confidential Information and shall use it only in
14 * accordance with the terms of the license agreement you entered
15 * into with SAMSUNG ELECTRONICS.
17 * SAMSUNG make no representations or warranties about the suitability
18 * of the software, either express or implied, including but not limited
19 * to the implied warranties of merchantability, fitness for a particular
20 * purpose, or non-infringement. SAMSUNG shall not be liable for any
21 * damages suffered by licensee as a result of using, modifying or
22 * distributing this software or its derivatives.
25 #include <setting-phone-ticker-notification.h>
28 static void get_3rd_applist(void *data, Evas_Object *scroller);
30 static char *get_appname(char *keyname);
32 static int setting_phone_ticker_notfication_create(void *cb);
33 static int setting_phone_ticker_notfication_destroy(void *cb);
34 static int setting_phone_ticker_notfication_update(void *cb);
35 static int setting_phone_ticker_notfication_cleanup(void *cb);
37 setting_view setting_view_phone_ticker_notification = {
38 .create = setting_phone_ticker_notfication_create,
39 .destroy = setting_phone_ticker_notfication_destroy,
40 .update = setting_phone_ticker_notfication_update,
41 .cleanup = setting_phone_ticker_notfication_cleanup,
44 /* ***************************************************
48 ***************************************************/
50 static int setting_phone_ticker_notfication_create(void *cb)
53 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
55 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
57 Evas_Object *navi_bar = NULL;
58 Evas_Object *scroller;
59 /* Evas_Object *outer_box; */
61 /* scroller is a genlist */
63 setting_create_layout_navi_bar_genlist(ad->win_main_layout,
66 ("IDS_ST_BODY_EVENTS_NOTIFICATIONS"),
67 dgettext("sys_string", "IDS_COM_BODY_BACK"),
69 setting_phone_noti_click_softkey_back_cb,
74 Elm_Object_Item *item;
77 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
78 ELM_GENLIST_ITEM_NONE, NULL, NULL);
79 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
80 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_DISPLAY_CONTENT,
83 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
84 setting_phone_noti_mouse_up_Gendial_list_cb,
85 ad, SWALLOW_Type_1TOGGLE, NULL,
87 "IDS_ST_BODY_DISPLAY_CONTENTS",
89 setting_phone_noti_mouse_up_chk_btn_cb);
91 ad->data_n_dsp->userdata = ad;
93 SETTING_TRACE_ERROR("ad->data_n_dsp is NULL");
97 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
98 ELM_GENLIST_ITEM_NONE, NULL, NULL);
99 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
100 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_MESSAGES, &value,
103 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
104 setting_phone_noti_mouse_up_Gendial_list_cb,
105 ad, SWALLOW_Type_1TOGGLE, NULL,
107 "IDS_COM_BODY_MESSAGES", NULL,
108 setting_phone_noti_mouse_up_chk_btn_cb);
109 if (ad->data_n_msg) {
110 ad->data_n_msg->userdata = ad;
112 SETTING_TRACE_ERROR("ad->data_n_msg is NULL");
115 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_VMAIL, &value,
118 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
119 setting_phone_noti_mouse_up_Gendial_list_cb,
120 ad, SWALLOW_Type_1TOGGLE, NULL,
122 "IDS_ST_BODY_VOICE_MAIL", NULL,
123 setting_phone_noti_mouse_up_chk_btn_cb);
124 if (ad->data_n_vmail) {
125 ad->data_n_vmail->userdata = ad;
127 SETTING_TRACE_ERROR("ad->data_n_vmail is NULL");
130 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_EMAIL, &value,
133 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
134 setting_phone_noti_mouse_up_Gendial_list_cb,
135 ad, SWALLOW_Type_1TOGGLE, NULL,
136 NULL, value, "IDS_ST_BODY_EMAIL", NULL,
137 setting_phone_noti_mouse_up_chk_btn_cb);
138 if (ad->data_n_email) {
139 ad->data_n_email->userdata = ad;
141 SETTING_TRACE_ERROR("ad->data_n_email is NULL");
145 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
146 ELM_GENLIST_ITEM_NONE, NULL, NULL);
147 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
148 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_SNS, &value,
151 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
152 setting_phone_noti_mouse_up_Gendial_list_cb,
153 ad, SWALLOW_Type_1TOGGLE, NULL,
154 NULL, value, "IDS_ST_BODY_SNS", NULL,
155 setting_phone_noti_mouse_up_chk_btn_cb);
156 if (ad->data_n_sns) {
157 ad->data_n_sns->userdata = ad;
159 SETTING_TRACE_ERROR("ad->data_n_sns is NULL");
163 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
164 ELM_GENLIST_ITEM_NONE, NULL, NULL);
165 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
166 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_FILE_TRAN, &value,
169 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
170 setting_phone_noti_mouse_up_Gendial_list_cb,
171 ad, SWALLOW_Type_1TOGGLE, NULL,
173 "IDS_ST_BODY_FILE_TRANSFER", NULL,
174 setting_phone_noti_mouse_up_chk_btn_cb);
175 if (ad->data_n_file) {
176 ad->data_n_file->userdata = ad;
178 SETTING_TRACE_ERROR("ad->data_n_file is NULL");
181 get_3rd_applist(ad, scroller);
183 setting_view_phone_ticker_notification.is_create = 1;
184 return SETTING_RETURN_SUCCESS;
187 static int setting_phone_ticker_notfication_destroy(void *cb)
191 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
193 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
195 if (ad->ly_ticker != NULL) {
196 evas_object_del(ad->ly_ticker);
198 setting_view_phone_ticker_notification.is_create = 0;
201 return SETTING_RETURN_SUCCESS;
204 static int setting_phone_ticker_notfication_update(void *cb)
207 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
209 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
211 if (ad->ly_ticker != NULL) {
212 evas_object_show(ad->ly_ticker);
215 return SETTING_RETURN_SUCCESS;
218 static int setting_phone_ticker_notfication_cleanup(void *cb)
221 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
223 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
225 if (ad->ly_ticker != NULL) {
226 evas_object_hide(ad->ly_ticker);
229 return SETTING_RETURN_SUCCESS;
232 /* ***************************************************
236 ***************************************************/
238 /* ***************************************************
242 ***************************************************/
245 setting_phone_noti_mouse_up_chk_btn_cb(void *data, Evas_Object *obj,
250 retm_if(data == NULL, "Data parameter is NULL");
251 Setting_GenGroupItem_Data *list_item =
252 (Setting_GenGroupItem_Data *) data;
253 SettingPhoneUG *ad = list_item->userdata;
254 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
257 if (list_item->eo_check == ad->data_n_dsp->eo_check) {
258 setting_set_bool_slp_key
259 (BOOL_SLP_SETTING_TICKER_NOTI_DISPLAY_CONTENT,
260 list_item->chk_status, &err);
261 } else if (list_item->eo_check == ad->data_n_msg->eo_check) {
262 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_MESSAGES,
263 list_item->chk_status, &err);
264 } else if (list_item->eo_check == ad->data_n_vmail->eo_check) {
265 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_VMAIL,
266 list_item->chk_status, &err);
267 } else if (list_item->eo_check == ad->data_n_email->eo_check) {
268 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_EMAIL,
269 list_item->chk_status, &err);
270 } else if (list_item->eo_check == ad->data_n_sns->eo_check) {
271 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_SNS,
272 list_item->chk_status, &err);
273 } else if (list_item->eo_check == ad->data_n_file->eo_check) {
274 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_FILE_TRAN,
275 list_item->chk_status, &err);
281 setting_phone_noti_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
285 setting_retm_if(data == NULL, "Data parameter is NULL");
287 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
288 SettingPhoneUG *ad = (SettingPhoneUG *) data;
290 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
291 elm_genlist_item_selected_set(item, 0);
292 Setting_GenGroupItem_Data *list_item =
293 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
295 int old_status = elm_check_state_get(list_item->eo_check);
297 list_item->chk_status = !old_status;
298 elm_check_state_set(list_item->eo_check, list_item->chk_status);
301 if (list_item->eo_check == ad->data_n_dsp->eo_check) {
302 setting_set_bool_slp_key
303 (BOOL_SLP_SETTING_TICKER_NOTI_DISPLAY_CONTENT,
304 list_item->chk_status, &err);
305 } else if (list_item->eo_check == ad->data_n_msg->eo_check) {
306 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_MESSAGES,
307 list_item->chk_status, &err);
308 } else if (list_item->eo_check == ad->data_n_vmail->eo_check) {
309 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_VMAIL,
310 list_item->chk_status, &err);
311 } else if (list_item->eo_check == ad->data_n_email->eo_check) {
312 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_EMAIL,
313 list_item->chk_status, &err);
314 } else if (list_item->eo_check == ad->data_n_sns->eo_check) {
315 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_SNS,
316 list_item->chk_status, &err);
317 } else if (list_item->eo_check == ad->data_n_file->eo_check) {
318 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_FILE_TRAN,
319 list_item->chk_status, &err);
324 setting_phone_noti_click_softkey_back_cb(void *data, Evas_Object *obj,
328 retm_if(data == NULL, "Data parameter is NULL");
330 SettingPhoneUG *ad = (SettingPhoneUG *) data;
332 /* Send destroy request */
333 ug_destroy_me(ad->ug);
339 setting_phone_noti_3rd_apps_chk_btn_cb(void *data, Evas_Object *obj,
344 retm_if(data == NULL, "Data parameter is NULL");
345 Setting_GenGroupItem_Data *list_item =
346 (Setting_GenGroupItem_Data *) data;
348 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
350 if (0 != vconf_set_int(list_item->sub_desc, list_item->chk_status)) {
351 SETTING_TRACE("Set vconf[%s] failed", list_item->sub_desc);
352 /* restore if failed */
353 list_item->chk_status = !list_item->chk_status;
354 elm_check_state_set(list_item->eo_check, list_item->chk_status);
356 SETTING_TRACE("Set vconf[%s] success", list_item->sub_desc);
359 ret = vconf_set_int(list_item->sub_desc, list_item->chk_status);
361 SETTING_TRACE("Set vconf[%s] failed",
362 list_item->sub_desc);
366 ("setting_event_noti_3rdapp_changed");
367 SETTING_TRACE("heynoti publish ret = %d ", ret);
370 ("heynoti_publish error - [%d] failed",
376 SETTING_TRACE("heynoti publish ret = %d ", ret);
377 /* restore if failed */
378 list_item->chk_status = !list_item->chk_status;
379 elm_check_state_set(list_item->eo_check,
380 list_item->chk_status);
386 setting_phone_noti_3rd_apps_mouse_up_Gendial_list_cb(void *data,
391 setting_retm_if(data == NULL, "Data parameter is NULL");
393 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
394 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
396 elm_genlist_item_selected_set(item, 0);
397 Setting_GenGroupItem_Data *list_item =
398 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
400 int old_status = elm_check_state_get(list_item->eo_check);
402 list_item->chk_status = !old_status;
403 elm_check_state_set(list_item->eo_check, list_item->chk_status);
406 static void get_3rd_applist(void *data, Evas_Object *scroller)
408 SettingPhoneUG *ad = (SettingPhoneUG *) data;
410 keylist_t *kl = NULL;
411 keynode_t *temp_node = NULL;
413 kl = vconf_keylist_new();
416 while ((temp_node = vconf_keylist_nextnode(kl))) {
418 if (VCONF_TYPE_INT == vconf_keynode_get_type(temp_node)) {
419 SETTING_TRACE("key = %s, value = %d",
420 vconf_keynode_get_name(temp_node),
421 vconf_keynode_get_int(temp_node));
423 int val = vconf_keynode_get_int(temp_node);
426 char *vconf_key = vconf_keynode_get_name(temp_node); /* key */
428 /* get app name with app_pkg_name and AIL */
430 char *app_name = get_appname(vconf_key);
432 app_name = strdup("UNTITLED");
437 Elm_Object_Item *item = NULL;
438 item = elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
439 ELM_GENLIST_ITEM_NONE, NULL, NULL);
440 setting_retm_if(item == NULL, "elm_genlist_item_append failed");
441 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
445 Setting_GenGroupItem_Data *obj =
446 setting_create_Gendial_field_def(scroller,
449 setting_phone_noti_3rd_apps_mouse_up_Gendial_list_cb,
451 SWALLOW_Type_1TOGGLE,
455 setting_phone_noti_3rd_apps_chk_btn_cb);
457 obj->sub_desc = (char *)g_strdup(vconf_key);
458 ad->app_list = eina_list_append(ad->app_list, obj); /* resources are freed at itc structure. */
460 SETTING_TRACE_ERROR("obj is NULL");
469 SETTING_TRACE("Unknown Type\n");
472 vconf_keylist_free(kl);
476 static char *strrstr(const char *str, const char *strSearch)
478 char *ptr, *last = NULL;
480 while ((ptr = strstr(ptr, strSearch)))
486 static char* package_get_name(char* package, int* err_ref)
488 ail_appinfo_h handle;
492 char *ret_str = NULL;
496 ret = ail_package_get_appinfo(package, &handle);
497 if (ret != AIL_ERROR_OK) {
498 err = AIL_ERROR_FAIL;
501 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
502 if (ret != AIL_ERROR_OK) {
503 err = AIL_ERROR_FAIL;
507 ret_str = strdup(str);
509 SETTING_TRACE_ERROR("str is NULL");
511 SETTING_TRACE("1 Package[%s] : %s", package, ret_str);
513 ret = ail_package_destroy_appinfo(handle);
514 if (ret != AIL_ERROR_OK) {
515 err = AIL_ERROR_FAIL;
519 SETTING_TRACE("2 Package[%s] : %s", package, ret_str);
524 /* input : package name*/
526 /* outout : app name*/
527 static char *get_appname(char *keyname)
531 char* pkg_name = strrstr(keyname, "/");
533 char *ret2 = package_get_name(pkg_name, &err);
536 SETTING_TRACE("app name : %s", ret2);
539 return strdup("UNTITLED");