4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-phone-ticker-notification-details.h>
24 //#include <badge_error.h>
26 #define NOTIFICATION_STR "IDS_ST_BODY_NOTIFICATION"
27 #define DISPLAY_CONTENT_STR "IDS_ST_BODY_DISPLAY_CONTENTS"
28 #define BADGE_STR "IDS_COM_BODY_BADGE_ABB"
30 #define STR_NOTIFICATION_DETAILS_HELP3 "IDS_ST_BODY_IF_YOU_DONT_WANT_TO_SEE_A_NUMBER_APPEAR_ON_THE_APP_ICON_FOR_EACH_NEW_EVENT_DISABLE_BADGE"
32 #define STR_NOTIFICATION_DETAILS_NOTI_HELP "You can turn off notification of this application."
33 #define STR_NOTIFICATION_DETAILS_DISPLAY_HELP "If you don't want to see contents in notification popup, turn off the display contents."
34 #define STR_NOTIFICATION_DETAILS_BADGE_HELP "If you don't want to display badge on app icon with a new event number, turn off the Badge."
37 static char* pkg_list[] = {"org.tizen.email", "org.tizen.message", "xnq5eh9vop.ChatON"};
40 static int setting_phone_ticker_notification_details_create(void *cb);
41 static int setting_phone_ticker_notification_details_destroy(void *cb);
42 static int setting_phone_ticker_notification_details_update(void *cb);
43 static int setting_phone_ticker_notification_details_cleanup(void *cb);
45 static void setting_phone_noti_details_chk_btn_cb(void *data, Evas_Object *obj, void *event_info);
46 static void setting_phone_noti_details_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info);
48 static int __status_get_notification_str(char* title);
49 static int __status_get_sound_str(char* title);
50 static int __status_get_display_contents_str(char* title);
51 static int __status_get_badge_str(char* title);
52 static void __status_set_display_contents_str(void* data);
54 setting_view setting_view_phone_ticker_notification_details = {
55 .create = setting_phone_ticker_notification_details_create,
56 .destroy = setting_phone_ticker_notification_details_destroy,
57 .update = setting_phone_ticker_notification_details_update,
58 .cleanup = setting_phone_ticker_notification_details_cleanup,
61 /* ***************************************************
65 ***************************************************/
66 char* g_sel_string = NULL;
67 SettingPhoneUG *g_phone_ad = NULL;
69 static int setting_phone_ticker_notification_details_create(void *cb)
73 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
74 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
77 Evas_Object *scroller;
79 /* scroller is a genlist */
80 const char *title = NULL;
81 if ( 0== safeStrCmp (ad->sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
82 title = "IDS_COM_BODY_INSTANT_MESSENGER";
83 } else if ( 0== safeStrCmp (ad->sel_string, "IDS_ST_BODY_MESSAGE")) {
84 title = "IDS_ST_BODY_MESSAGE";
85 } else if ( 0== safeStrCmp (ad->sel_string, "IDS_ST_BODY_EMAIL")) {
86 title = "IDS_ST_BODY_EMAIL";
89 title = ad->sel_string;
91 SETTING_TRACE("title:%s", title);
92 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
94 dgettext("sys_string", "IDS_COM_BODY_BACK"),
96 setting_phone_noti_details_click_softkey_back_cb,
100 Elm_Object_Item *item;
102 g_sel_string = ad->sel_string;
106 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
107 ELM_GENLIST_ITEM_NONE, NULL, NULL);
108 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
111 int noti_val = __status_get_notification_str(ad->sel_string);
112 ad->data_details_notification =
113 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
114 setting_phone_noti_details_mouse_up_Gendial_list_cb,
115 ad, SWALLOW_Type_1TOGGLE, NULL,
117 NOTIFICATION_STR, NULL,
118 setting_phone_noti_details_chk_btn_cb);
119 if (ad->data_details_notification) {
120 ad->data_details_notification->userdata = ad;
121 ad->data_details_notification->group_style = SETTING_GROUP_STYLE_TOP;
123 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
127 int sound_val = __status_get_sound_str(ad->sel_string);
128 ad->data_details_sound =
129 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
130 setting_phone_noti_details_mouse_up_Gendial_list_cb,
131 ad, SWALLOW_Type_1TOGGLE, NULL,
134 setting_phone_noti_details_chk_btn_cb);
135 if (ad->data_details_sound) {
136 ad->data_details_sound->userdata = ad;
137 ad->data_details_sound->group_style = SETTING_GROUP_STYLE_CENTER;
139 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
142 // [UI] Display contents
143 int display_val = __status_get_display_contents_str(ad->sel_string);
144 ad->data_details_display_content =
145 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
146 setting_phone_noti_details_mouse_up_Gendial_list_cb,
147 ad, SWALLOW_Type_1TOGGLE, NULL,
149 DISPLAY_CONTENT_STR, NULL,
150 setting_phone_noti_details_chk_btn_cb);
151 if (ad->data_details_display_content) {
152 ad->data_details_display_content->userdata = ad;
153 ad->data_details_display_content->group_style = SETTING_GROUP_STYLE_CENTER;
155 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
158 int badge_val = __status_get_badge_str(ad->sel_string);
159 ad->data_details_badge =
160 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
161 setting_phone_noti_details_mouse_up_Gendial_list_cb,
162 ad, SWALLOW_Type_1TOGGLE, NULL,
165 setting_phone_noti_details_chk_btn_cb);
166 if (ad->data_details_badge) {
167 ad->data_details_badge->userdata = ad;
168 ad->data_details_badge->group_style = SETTING_GROUP_STYLE_BOTTOM;
170 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
172 setting_view_phone_ticker_notification_details.is_create = 1;
173 return SETTING_RETURN_SUCCESS;
177 static int setting_phone_ticker_notification_details_destroy(void *cb)
181 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
183 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
185 elm_naviframe_item_pop(ad->navi_bar);
186 setting_view_phone_ticker_notification_details.is_create = 0;
188 return SETTING_RETURN_SUCCESS;
191 static int setting_phone_ticker_notification_details_update(void *cb)
194 return SETTING_RETURN_SUCCESS;
197 static int setting_phone_ticker_notification_details_cleanup(void *cb)
200 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
201 setting_phone_ticker_notification_details_destroy(cb);
202 return SETTING_RETURN_SUCCESS;
205 /* ***************************************************
209 ***************************************************/
211 /* ***************************************************
215 ***************************************************/
218 setting_phone_noti_details_click_softkey_back_cb(void *data, Evas_Object *obj,
223 retm_if(data == NULL, "Data parameter is NULL");
224 SettingPhoneUG *ad = (SettingPhoneUG *) data;
226 setting_view_change(&setting_view_phone_ticker_notification_details, &setting_view_phone_ticker_notification, ad);
233 static int __status_get_notification_str(char* title)
237 const char *vconf_key = NULL;
239 if ( 0== safeStrCmp (title, "IDS_ST_BODY_MESSAGE")) {
240 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_MESSAGES_BOOL;
241 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
242 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL;
245 else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
246 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_IM_BOOL;
247 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
248 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_TWITTER_BOOL;
249 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
250 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_FACEBOOK_BOOL;
253 SETTING_TRACE("vconf_key:%s", vconf_key);
254 vconf_get_bool(vconf_key, &val);
255 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
259 static int __status_get_sound_str(char* title)
263 const char *vconf_key = NULL;
264 if ( 0== safeStrCmp (title, "IDS_ST_BODY_MESSAGE")) {
265 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_MESSAGES;
267 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
268 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_EMAIL;
270 } else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
271 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_IM;
273 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
274 //vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
276 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
277 //vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
280 SETTING_TRACE("vconf_key:%s", vconf_key);
281 vconf_get_bool(vconf_key, &val);
282 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
289 static int __status_get_display_contents_str(char* title)
293 const char *vconf_key = NULL;
295 if ( 0== safeStrCmp (title, "IDS_ST_BODY_MESSAGE")) {
296 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_MESSASGES;
297 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
298 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_EMAIL;
301 else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
302 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_IM;
303 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
304 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_TWITTER;
305 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
306 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_FACEBOOK;
309 SETTING_TRACE("vconf_key:%s", vconf_key);
310 vconf_get_bool(vconf_key, &val);
311 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
314 static int __status_get_badge_str(char* title)
318 const char *vconf_key = NULL;
319 if ( 0== safeStrCmp (title, "IDS_ST_BODY_MESSAGE")) {
320 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_MESSAGES;
321 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
322 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_EMAIL;
325 else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
326 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_IM;
327 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
328 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
329 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
330 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
332 SETTING_TRACE("vconf_key:%s", vconf_key);
333 vconf_get_bool(vconf_key, &val);
334 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
338 static void __status_set_notification_str(void* data)
341 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
343 // message update in previos page
344 Setting_GenGroupItem_Data* item_to_update = NULL;
348 if (list_item->chk_status == 1) {
349 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
351 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
354 SETTING_TRACE("g_sel_string:%s", g_sel_string);
355 const char *vconf_key = NULL;
357 if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_MESSAGE")) {
358 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_MESSAGES_BOOL;
359 item_to_update = g_phone_ad->data_n_msg;
360 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
361 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL;
362 item_to_update = g_phone_ad->data_n_email;
365 else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
366 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_IM_BOOL;
367 item_to_update = g_phone_ad->data_n_im;
368 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
369 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_TWITTER_BOOL;
370 item_to_update = g_phone_ad->data_n_twt;
371 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
372 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_FACEBOOK_BOOL;
373 item_to_update = g_phone_ad->data_n_fb;
376 SETTING_TRACE("vconf_key:%s", vconf_key);
377 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
378 setting_retm_if(ret != 0, "fail to set vconf");
381 if (item_to_update) {
382 item_to_update->sub_desc = strdup(status);
383 elm_object_item_data_set(item_to_update->item,item_to_update);
384 elm_genlist_item_update(item_to_update->item);
388 static void __status_set_sound_str(void* data)
391 setting_retm_if(data == NULL, "Data parameter is NULL");
392 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
394 /* since the status is never used, so comment it.
397 if (list_item->chk_status == 1) {
398 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
400 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
403 SETTING_TRACE("g_sel_string:%s", g_sel_string);
404 const char *vconf_key = NULL;
406 if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_MESSAGE")) {
407 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_MESSAGES;
409 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
410 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_EMAIL;
412 } else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
413 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_IM;
415 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
416 //vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
418 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
419 //vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
423 SETTING_TRACE("vconf_key:%s", vconf_key);
424 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
425 setting_retm_if(ret != 0, "fail to set vconf");
428 static void __status_set_display_contents_str(void* data)
432 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
434 SETTING_TRACE("g_sel_string:%s", g_sel_string);
435 const char *vconf_key = NULL;
437 if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_MESSAGE")) {
438 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_MESSASGES;
439 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
440 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_EMAIL;
443 else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
444 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_IM;
445 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
446 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_TWITTER;
447 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
448 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_FACEBOOK;
450 SETTING_TRACE("vconf_key:%s", vconf_key);
451 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
452 setting_retm_if(ret != 0, "fail to set vconf");
456 static void __status_set_badge_str(void* data)
459 setting_retm_if(data == NULL, "Data parameter is NULL");
460 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
462 SETTING_TRACE("g_sel_string:%s", g_sel_string);
463 const char *vconf_key = NULL;
464 char* pkgname = NULL;
465 if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_MESSAGE")) {
466 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_MESSAGES;
467 pkgname = pkg_list[1]; /* message */
468 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
469 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_EMAIL;
470 pkgname = pkg_list[0]; /* email */
473 else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
474 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_IM;
475 pkgname = pkg_list[2]; /* email */
479 else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
480 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
481 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
482 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
486 SETTING_TRACE("vconf_key:%s", vconf_key);
487 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
493 //BADGE_ERROR_NONE = 0, /**< Success */
494 badge_error_e badge_ret = badge_set_display(pkgname, list_item->chk_status);
495 if (badge_ret == BADGE_ERROR_NONE)
497 SETTING_TRACE("pkg name : %s -- badge : %d \n", pkgname, list_item->chk_status);
499 SETTING_TRACE_ERROR("badge_set_display ERROR : %d \n", badge_ret);
507 static void setting_phone_noti_details_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
511 setting_retm_if(data == NULL, "Data parameter is NULL");
513 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
514 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
515 elm_genlist_item_selected_set(item, 0);
516 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
519 setting_update_gl_item_chk_status(list_item, !(list_item->chk_status));
521 if ( 0== safeStrCmp (list_item->keyStr, NOTIFICATION_STR)) {
522 __status_set_notification_str(list_item);
523 } else if ( 0== safeStrCmp (list_item->keyStr, KeyStr_Sounds)) {
524 __status_set_sound_str(list_item);
525 } else if ( 0== safeStrCmp (list_item->keyStr, DISPLAY_CONTENT_STR)) {
526 // vconf setting by g_sel_string
527 __status_set_display_contents_str(list_item);
528 } else if ( 0== safeStrCmp (list_item->keyStr, BADGE_STR)) {
529 __status_set_badge_str(list_item);
537 static void setting_phone_noti_details_chk_btn_cb(void *data, Evas_Object *obj, void *event_info)
541 retm_if(data == NULL, "Data parameter is NULL");
542 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
543 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
545 if ( 0== safeStrCmp (list_item->keyStr, NOTIFICATION_STR)) {
546 __status_set_notification_str(list_item);
547 } else if ( 0== safeStrCmp (list_item->keyStr, KeyStr_Sounds)) {
548 __status_set_sound_str(list_item);
549 } else if ( 0== safeStrCmp (list_item->keyStr, DISPLAY_CONTENT_STR)) {
550 __status_set_display_contents_str(list_item);
551 } else if ( 0== safeStrCmp (list_item->keyStr, BADGE_STR)) {
552 __status_set_badge_str(list_item);