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 #define NOTIFICATION_STR "IDS_ST_BODY_NOTIFICATION"
25 #define DISPLAY_CONTENT_STR "IDS_ST_BODY_DISPLAY_CONTENTS"
26 #define BADGE_STR "IDS_COM_BODY_BADGE_ABB"
28 #define STR_NOTIFICATION_DETAILS_HELP1 "You can turn off notification of this application. <br> <br>" \
29 "If you don't want to see contents in notification popup, turn off the display contents. <br> <br>"\
30 "If you don't want to display badge on app icon with a new event number, turn off the Badge."
32 static int setting_phone_ticker_notification_details_create(void *cb);
33 static int setting_phone_ticker_notification_details_destroy(void *cb);
34 static int setting_phone_ticker_notification_details_update(void *cb);
35 static int setting_phone_ticker_notification_details_cleanup(void *cb);
37 static void setting_phone_noti_details_chk_btn_cb(void *data, Evas_Object *obj, void *event_info);
38 static void setting_phone_noti_details_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info);
40 static int __status_get_notification_str(char* title);
41 static int __status_get_display_contents_str(char* title);
42 static int __status_get_badge_str(char* title);
43 static void __status_set_display_contents_str(void* data);
45 setting_view setting_view_phone_ticker_notification_details = {
46 .create = setting_phone_ticker_notification_details_create,
47 .destroy = setting_phone_ticker_notification_details_destroy,
48 .update = setting_phone_ticker_notification_details_update,
49 .cleanup = setting_phone_ticker_notification_details_cleanup,
52 /* ***************************************************
56 ***************************************************/
57 char* g_sel_string = NULL;
58 SettingPhoneUG *g_phone_ad = NULL;
60 static int setting_phone_ticker_notification_details_create(void *cb)
63 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
64 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
67 Evas_Object *scroller;
69 /* scroller is a genlist */
70 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
72 dgettext("sys_string", "IDS_COM_BODY_BACK"),
74 setting_phone_noti_details_click_softkey_back_cb,
78 Elm_Object_Item *item;
80 g_sel_string = ad->sel_string;
84 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
85 ELM_GENLIST_ITEM_NONE, NULL, NULL);
86 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
88 int noti_val = __status_get_notification_str(ad->sel_string);
91 ad->data_details_notification =
92 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
93 setting_phone_noti_details_mouse_up_Gendial_list_cb,
94 ad, SWALLOW_Type_1TOGGLE, NULL,
96 NOTIFICATION_STR, NULL,
97 setting_phone_noti_details_chk_btn_cb);
98 if (ad->data_details_notification) {
99 ad->data_details_notification->userdata = ad;
101 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
104 int display_val = __status_get_display_contents_str(ad->sel_string);
106 // [UI] Display contents
107 ad->data_details_display_content =
108 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
109 setting_phone_noti_details_mouse_up_Gendial_list_cb,
110 ad, SWALLOW_Type_1TOGGLE, NULL,
112 DISPLAY_CONTENT_STR, NULL,
113 setting_phone_noti_details_chk_btn_cb);
114 if (ad->data_details_display_content) {
115 ad->data_details_display_content->userdata = ad;
117 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
121 int badge_val = __status_get_badge_str(ad->sel_string);
122 ad->data_details_badge =
123 setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
124 setting_phone_noti_details_mouse_up_Gendial_list_cb,
125 ad, SWALLOW_Type_1TOGGLE, NULL,
128 setting_phone_noti_details_chk_btn_cb);
129 if (ad->data_details_badge) {
130 ad->data_details_badge->userdata = ad;
132 SETTING_TRACE_ERROR("ad->data_launch_effect is NULL");
135 setting_create_Gendial_field_def(scroller, &(ad->itc_bg_1icon), NULL,
136 ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
137 NULL, NULL, 0, STR_NOTIFICATION_DETAILS_HELP1, NULL,
140 setting_view_phone_ticker_notification_details.is_create = 1;
141 return SETTING_RETURN_SUCCESS;
144 static int setting_phone_ticker_notification_details_destroy(void *cb)
148 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
150 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
152 elm_naviframe_item_pop(ad->navi_bar);
153 setting_view_phone_ticker_notification_details.is_create = 0;
155 return SETTING_RETURN_SUCCESS;
158 static int setting_phone_ticker_notification_details_update(void *cb)
161 return SETTING_RETURN_SUCCESS;
164 static int setting_phone_ticker_notification_details_cleanup(void *cb)
167 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
168 setting_phone_ticker_notification_details_destroy(cb);
169 return SETTING_RETURN_SUCCESS;
172 /* ***************************************************
176 ***************************************************/
178 /* ***************************************************
182 ***************************************************/
185 setting_phone_noti_details_click_softkey_back_cb(void *data, Evas_Object *obj,
190 retm_if(data == NULL, "Data parameter is NULL");
191 SettingPhoneUG *ad = (SettingPhoneUG *) data;
193 setting_view_change(&setting_view_phone_ticker_notification_details, &setting_view_phone_ticker_notification, ad);
200 static int __status_get_notification_str(char* title)
206 if ( 0== safeStrCmp (title, "IDS_COM_BODY_MESSAGES")) {
207 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_MESSAGES, &val, &err);
209 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
210 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_EMAIL, &val, &err);
213 else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
214 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_IM, &val, &err);
215 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
216 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_TWITTER, &val, &err);
217 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
218 setting_get_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_FACEBOOK, &val, &err);
221 SETTING_TRACE_DEBUG("title : %s, value : %d, err : %d", title, val, err);
229 static int __status_get_display_contents_str(char* title)
235 if ( 0== safeStrCmp (title, "IDS_COM_BODY_MESSAGES")) {
236 setting_get_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_MESSASGES, &val, &err);
237 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
238 setting_get_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_EMAIL, &val, &err);
241 else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
242 setting_get_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_IM, &val, &err);
243 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
244 setting_get_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_TWITTER, &val, &err);
245 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
246 setting_get_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_FACEBOOK, &val, &err);
249 SETTING_TRACE_DEBUG("title : %s, value : %d, err : %d", title, val, err);
253 static int __status_get_badge_str(char* title)
257 const char *vconf_key = NULL;
258 if ( 0== safeStrCmp (title, "IDS_COM_BODY_MESSAGES")) {
259 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_MESSAGES;
260 } else if ( 0== safeStrCmp (title, "IDS_ST_BODY_EMAIL")) {
261 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_EMAIL;
264 else if ( 0== safeStrCmp (title, "IDS_COM_BODY_INSTANT_MESSENGER")) {
265 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_IM;
266 } else if ( 0== safeStrCmp (title, KeyStr_Twitter)) {
267 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
268 } else if ( 0== safeStrCmp (title, KeyStr_Facebook)) {
269 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
271 SETTING_TRACE("vconf_key:%s", vconf_key);
272 vconf_get_bool(vconf_key, &val);
273 SETTING_TRACE_DEBUG("title : %s, value : %d", title, val);
277 static void __status_set_notification_str(void* data)
281 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
283 // message update in previos page
284 Setting_GenGroupItem_Data* item_to_update = NULL;
288 if (list_item->chk_status == 1) {
289 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
291 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
294 if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_MESSAGES")) {
295 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_MESSAGES, list_item->chk_status, &err);
296 item_to_update = g_phone_ad->data_n_msg;
297 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
298 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_EMAIL, list_item->chk_status, &err);
299 item_to_update = g_phone_ad->data_n_email;
302 else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
303 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_IM, list_item->chk_status, &err);
304 item_to_update = g_phone_ad->data_n_im;
305 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
306 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_TWITTER, list_item->chk_status, &err);
307 item_to_update = g_phone_ad->data_n_twt;
308 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
309 setting_set_bool_slp_key(BOOL_SLP_SETTING_TICKER_NOTI_FACEBOOK, list_item->chk_status, &err);
310 item_to_update = g_phone_ad->data_n_fb;
314 if (item_to_update) {
315 item_to_update->sub_desc = strdup(status);
316 elm_object_item_data_set(item_to_update->item,item_to_update);
317 elm_genlist_item_update(item_to_update->item);
321 static void __status_set_display_contents_str(void* data)
325 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
327 // message update in previos page
331 if (list_item->chk_status == 1) {
332 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
334 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
337 if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_MESSAGES")) {
338 setting_set_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_MESSASGES, list_item->chk_status, &err);
339 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
340 setting_set_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_EMAIL, list_item->chk_status, &err);
343 else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
344 setting_set_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_IM, list_item->chk_status, &err);
345 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
346 setting_set_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_TWITTER, list_item->chk_status, &err);
347 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
348 setting_set_bool_slp_key(BOOL_SLP_SETTING_NOTI_DISPLAY_CONTENT_FACEBOOK, list_item->chk_status, &err);
352 static void __status_set_badge_str(void* data)
355 setting_retm_if(data == NULL, "Data parameter is NULL");
356 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
360 if (list_item->chk_status == 1) {
361 status = setting_gettext("IDS_COM_BODY_ON_M_STATUS");
363 status = setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
366 SETTING_TRACE("g_sel_string:%s", g_sel_string);
367 const char *vconf_key = NULL;
368 if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_MESSAGES")) {
369 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_MESSAGES;
370 } else if ( 0== safeStrCmp (g_sel_string, "IDS_ST_BODY_EMAIL")) {
371 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_EMAIL;
374 else if ( 0== safeStrCmp (g_sel_string, "IDS_COM_BODY_INSTANT_MESSENGER")) {
375 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_IM;
376 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Twitter)) {
377 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_TWITTER;
378 } else if ( 0== safeStrCmp (g_sel_string, KeyStr_Facebook)) {
379 vconf_key = VCONFKEY_TICKER_NOTI_BADGE_FACEBOOK;
381 SETTING_TRACE("vconf_key:%s", vconf_key);
382 int ret = vconf_set_bool(vconf_key, list_item->chk_status);
383 setting_retm_if(ret != 0, "fail to set vconf");
389 static void setting_phone_noti_details_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
393 setting_retm_if(data == NULL, "Data parameter is NULL");
395 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
396 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
397 elm_genlist_item_selected_set(item, 0);
398 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
401 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); /* new status */
405 if ( 0== safeStrCmp (list_item->keyStr, NOTIFICATION_STR)) {
406 __status_set_notification_str(list_item);
407 } else if ( 0== safeStrCmp (list_item->keyStr, DISPLAY_CONTENT_STR)) {
408 // vconf setting by g_sel_string
409 __status_set_display_contents_str(list_item);
410 } else if ( 0== safeStrCmp (list_item->keyStr, BADGE_STR)) {
411 __status_set_badge_str(list_item);
419 static void setting_phone_noti_details_chk_btn_cb(void *data, Evas_Object *obj, void *event_info)
423 retm_if(data == NULL, "Data parameter is NULL");
424 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
425 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
427 if ( 0== safeStrCmp (list_item->keyStr, NOTIFICATION_STR)) {
428 __status_set_notification_str(list_item);
429 } else if ( 0== safeStrCmp (list_item->keyStr, DISPLAY_CONTENT_STR)) {
430 __status_set_display_contents_str(list_item);
431 } else if ( 0== safeStrCmp (list_item->keyStr, BADGE_STR)) {
432 __status_set_badge_str(list_item);