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";
88 title = ad->sel_string;
90 SETTING_TRACE("title:%s", title);
91 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
93 dgettext("sys_string", "IDS_COM_BODY_BACK"),
95 setting_phone_noti_details_click_softkey_back_cb,
99 Elm_Object_Item *item;
101 g_sel_string = ad->sel_string;
105 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
106 ELM_GENLIST_ITEM_NONE, NULL, NULL);
107 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
109 /* [UI] Notification */
110 int noti_val = __status_get_notification_str(ad->sel_string);
111 ad->data_details_notification =
112 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
113 setting_phone_noti_details_mouse_up_Gendial_list_cb,
114 ad, SWALLOW_Type_1TOGGLE, NULL,
116 NOTIFICATION_STR, NULL,
117 setting_phone_noti_details_chk_btn_cb);
118 if (ad->data_details_notification) {
119 ad->data_details_notification->userdata = ad;
120 ad->data_details_notification->group_style = SETTING_GROUP_STYLE_TOP;
122 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
126 int sound_val = __status_get_sound_str(ad->sel_string);
127 ad->data_details_sound =
128 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
129 setting_phone_noti_details_mouse_up_Gendial_list_cb,
130 ad, SWALLOW_Type_1TOGGLE, NULL,
133 setting_phone_noti_details_chk_btn_cb);
134 if (ad->data_details_sound) {
135 ad->data_details_sound->userdata = ad;
136 ad->data_details_sound->group_style = SETTING_GROUP_STYLE_CENTER;
138 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
141 /* [UI] Display contents */
142 int display_val = __status_get_display_contents_str(ad->sel_string);
143 ad->data_details_display_content =
144 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
145 setting_phone_noti_details_mouse_up_Gendial_list_cb,
146 ad, SWALLOW_Type_1TOGGLE, NULL,
148 DISPLAY_CONTENT_STR, NULL,
149 setting_phone_noti_details_chk_btn_cb);
150 if (ad->data_details_display_content) {
151 ad->data_details_display_content->userdata = ad;
152 ad->data_details_display_content->group_style = SETTING_GROUP_STYLE_CENTER;
154 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
157 int badge_val = __status_get_badge_str(ad->sel_string);
158 ad->data_details_badge =
159 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
160 setting_phone_noti_details_mouse_up_Gendial_list_cb,
161 ad, SWALLOW_Type_1TOGGLE, NULL,
164 setting_phone_noti_details_chk_btn_cb);
165 if (ad->data_details_badge) {
166 ad->data_details_badge->userdata = ad;
167 ad->data_details_badge->group_style = SETTING_GROUP_STYLE_BOTTOM;
169 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
171 setting_view_phone_ticker_notification_details.is_create = 1;
172 return SETTING_RETURN_SUCCESS;
176 static int setting_phone_ticker_notification_details_destroy(void *cb)
180 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
182 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
184 elm_naviframe_item_pop(ad->navi_bar);
185 setting_view_phone_ticker_notification_details.is_create = 0;
187 return SETTING_RETURN_SUCCESS;
190 static int setting_phone_ticker_notification_details_update(void *cb)
193 return SETTING_RETURN_SUCCESS;
196 static int setting_phone_ticker_notification_details_cleanup(void *cb)
199 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
200 setting_phone_ticker_notification_details_destroy(cb);
201 return SETTING_RETURN_SUCCESS;
204 /* ***************************************************
208 ***************************************************/
210 /* ***************************************************
214 ***************************************************/
217 setting_phone_noti_details_click_softkey_back_cb(void *data, Evas_Object *obj,
222 retm_if(data == NULL, "Data parameter is NULL");
223 SettingPhoneUG *ad = (SettingPhoneUG *) data;
225 setting_view_change(&setting_view_phone_ticker_notification_details, &setting_view_phone_ticker_notification, ad);
232 static int __status_get_notification_str(char *title)
236 const char *vconf_key = NULL;
238 if (0 == safeStrCmp(title, "IDS_ST_BODY_MESSAGE")) {
239 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_MESSAGES_BOOL;
240 } else if (0 == safeStrCmp(title, "IDS_ST_BODY_EMAIL")) {
241 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL;
244 else if (0 == safeStrCmp(title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
245 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_IM_BOOL;
246 } else if (0 == safeStrCmp(title, KeyStr_Twitter)) {
247 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_TWITTER_BOOL;
248 } else if (0 == safeStrCmp(title, KeyStr_Facebook)) {
249 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_FACEBOOK_BOOL;
252 SETTING_TRACE("vconf_key:%s", vconf_key);
253 vconf_get_bool(vconf_key, &val);
254 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
258 static int __status_get_sound_str(char *title)
262 const char *vconf_key = NULL;
263 if (0 == safeStrCmp(title, "IDS_ST_BODY_MESSAGE")) {
264 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_MESSAGES;
266 } else if (0 == safeStrCmp(title, "IDS_ST_BODY_EMAIL")) {
267 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_EMAIL;
269 } else if (0 == safeStrCmp(title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
270 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_IM;
272 } else if (0 == safeStrCmp(title, KeyStr_Twitter)) {
273 /*vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER; */
275 } else if (0 == safeStrCmp(title, KeyStr_Facebook)) {
276 /*vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK; */
279 SETTING_TRACE("vconf_key:%s", vconf_key);
280 vconf_get_bool(vconf_key, &val);
281 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
288 static int __status_get_display_contents_str(char *title)
292 const char *vconf_key = NULL;
294 if (0 == safeStrCmp(title, "IDS_ST_BODY_MESSAGE")) {
295 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_MESSASGES;
296 } else if (0 == safeStrCmp(title, "IDS_ST_BODY_EMAIL")) {
297 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_EMAIL;
300 else if (0 == safeStrCmp(title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
301 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_IM;
302 } else if (0 == safeStrCmp(title, KeyStr_Twitter)) {
303 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_TWITTER;
304 } else if (0 == safeStrCmp(title, KeyStr_Facebook)) {
305 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_FACEBOOK;
308 SETTING_TRACE("vconf_key:%s", vconf_key);
309 vconf_get_bool(vconf_key, &val);
310 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
313 static int __status_get_badge_str(char *title)
317 const char *vconf_key = NULL;
318 if (0 == safeStrCmp(title, "IDS_ST_BODY_MESSAGE")) {
319 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_MESSAGES;
320 } else if (0 == safeStrCmp(title, "IDS_ST_BODY_EMAIL")) {
321 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_EMAIL;
324 else if (0 == safeStrCmp(title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
325 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_IM;
326 } else if (0 == safeStrCmp(title, KeyStr_Twitter)) {
327 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
328 } else if (0 == safeStrCmp(title, KeyStr_Facebook)) {
329 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
331 SETTING_TRACE("vconf_key:%s", vconf_key);
332 vconf_get_bool(vconf_key, &val);
333 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
337 static void __status_set_notification_str(void *data)
340 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
342 /* message update in previos page */
343 Setting_GenGroupItem_Data *item_to_update = NULL;
347 if (list_item->chk_status == 1) {
348 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
350 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
353 SETTING_TRACE("g_sel_string:%s", g_sel_string);
354 const char *vconf_key = NULL;
356 if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_MESSAGE")) {
357 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_MESSAGES_BOOL;
358 item_to_update = g_phone_ad->data_n_msg;
359 } else if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_EMAIL")) {
360 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL;
361 item_to_update = g_phone_ad->data_n_email;
364 else if (0 == safeStrCmp(g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
365 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_IM_BOOL;
366 item_to_update = g_phone_ad->data_n_im;
367 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Twitter)) {
368 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_TWITTER_BOOL;
369 item_to_update = g_phone_ad->data_n_twt;
370 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Facebook)) {
371 vconf_key = VCONFKEY_SETAPPL_STATE_TICKER_NOTI_FACEBOOK_BOOL;
372 item_to_update = g_phone_ad->data_n_fb;
375 SETTING_TRACE("vconf_key:%s", vconf_key);
376 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
377 setting_retm_if(ret != 0, "fail to set vconf");
380 if (item_to_update) {
381 item_to_update->sub_desc = strdup(status);
382 elm_object_item_data_set(item_to_update->item, item_to_update);
383 elm_genlist_item_update(item_to_update->item);
387 static void __status_set_sound_str(void *data)
390 setting_retm_if(data == NULL, "Data parameter is NULL");
391 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
393 /* since the status is never used, so comment it.
396 if (list_item->chk_status == 1) {
397 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
399 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
402 SETTING_TRACE("g_sel_string:%s", g_sel_string);
403 const char *vconf_key = NULL;
405 if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_MESSAGE")) {
406 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_MESSAGES;
408 } else if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_EMAIL")) {
409 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_EMAIL;
411 } else if (0 == safeStrCmp(g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
412 vconf_key = VCONFKEY_TICKER_NOTI_SOUND_IM;
414 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Twitter)) {
415 /*vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER; */
417 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Facebook)) {
418 /*vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK; */
422 SETTING_TRACE("vconf_key:%s", vconf_key);
423 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
424 setting_retm_if(ret != 0, "fail to set vconf");
427 static void __status_set_display_contents_str(void *data)
431 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
433 SETTING_TRACE("g_sel_string:%s", g_sel_string);
434 const char *vconf_key = NULL;
436 if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_MESSAGE")) {
437 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_MESSASGES;
438 } else if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_EMAIL")) {
439 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_EMAIL;
442 else if (0 == safeStrCmp(g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
443 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_IM;
444 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Twitter)) {
445 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_TWITTER;
446 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Facebook)) {
447 vconf_key = VCONFKEY_TICKER_NOTI_DISPLAY_CONTENT_FACEBOOK;
449 SETTING_TRACE("vconf_key:%s", vconf_key);
450 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
451 setting_retm_if(ret != 0, "fail to set vconf");
455 static void __status_set_badge_str(void *data)
458 setting_retm_if(data == NULL, "Data parameter is NULL");
459 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
461 SETTING_TRACE("g_sel_string:%s", g_sel_string);
462 const char *vconf_key = NULL;
463 char *pkgname = NULL;
464 if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_MESSAGE")) {
465 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_MESSAGES;
466 pkgname = pkg_list[1]; /* message */
467 } else if (0 == safeStrCmp(g_sel_string, "IDS_ST_BODY_EMAIL")) {
468 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_EMAIL;
469 pkgname = pkg_list[0]; /* email */
472 else if (0 == safeStrCmp(g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
473 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_IM;
474 pkgname = pkg_list[2]; /* email */
478 else if (0 == safeStrCmp(g_sel_string, KeyStr_Twitter)) {
479 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
480 } else if (0 == safeStrCmp(g_sel_string, KeyStr_Facebook)) {
481 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
485 SETTING_TRACE("vconf_key:%s", vconf_key);
486 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
491 /*BADGE_ERROR_NONE = 0, /**< Success * / */
492 badge_error_e badge_ret = badge_set_display(pkgname, list_item->chk_status);
493 if (badge_ret == BADGE_ERROR_NONE) {
494 SETTING_TRACE("pkg name : %s -- badge : %d \n", pkgname, list_item->chk_status);
496 SETTING_TRACE_ERROR("badge_set_display ERROR : %d \n", badge_ret);
504 static void setting_phone_noti_details_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
508 setting_retm_if(data == NULL, "Data parameter is NULL");
510 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
511 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
512 elm_genlist_item_selected_set(item, 0);
513 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
516 setting_update_gl_item_chk_status(list_item, !(list_item->chk_status));
518 if (0 == safeStrCmp(list_item->keyStr, NOTIFICATION_STR)) {
519 __status_set_notification_str(list_item);
520 } else if (0 == safeStrCmp(list_item->keyStr, KeyStr_Sounds)) {
521 __status_set_sound_str(list_item);
522 } else if (0 == safeStrCmp(list_item->keyStr, DISPLAY_CONTENT_STR)) {
523 /* vconf setting by g_sel_string */
524 __status_set_display_contents_str(list_item);
525 } else if (0 == safeStrCmp(list_item->keyStr, BADGE_STR)) {
526 __status_set_badge_str(list_item);
534 static void setting_phone_noti_details_chk_btn_cb(void *data, Evas_Object *obj, void *event_info)
538 retm_if(data == NULL, "Data parameter is NULL");
539 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
540 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
542 if (0 == safeStrCmp(list_item->keyStr, NOTIFICATION_STR)) {
543 __status_set_notification_str(list_item);
544 } else if (0 == safeStrCmp(list_item->keyStr, KeyStr_Sounds)) {
545 __status_set_sound_str(list_item);
546 } else if (0 == safeStrCmp(list_item->keyStr, DISPLAY_CONTENT_STR)) {
547 __status_set_display_contents_str(list_item);
548 } else if (0 == safeStrCmp(list_item->keyStr, BADGE_STR)) {
549 __status_set_badge_str(list_item);