2 * Copyright 2012 Samsung Electronics Co., Ltd
\r
4 * Licensed under the Flora License, Version 1.0 (the License);
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.tizenopensource.org/license
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an AS IS BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include <notification.h>
\r
19 #include <vconf-keys.h>
\r
21 #include "lockscreen.h"
\r
24 #define PHONE_LAUNCH_PKG "org.tizen.phone"
\r
25 #define EMAIL_LAUNCH_PKG "org.tizen.email"
\r
26 #define MESSAGE_LAUNCH_PKG "org.tizen.message"
\r
27 #define MAX_NOTI_NUM 3
\r
29 static void __noti_info_set(void *data, const char *pkgname, const char *title, int count, int line_num)
\r
31 struct appdata *ad = (struct appdata *)data;
\r
32 if(ad == NULL || pkgname == NULL){
\r
36 LOCK_SCREEN_TRACE_DBG("pkgname : %s, title : %s, count = %d, line_num = %d", pkgname, title, count, line_num);
\r
38 char buf1[512] = {0};
\r
39 char buf2[512] = {0};
\r
41 snprintf(buf2, sizeof(buf2), "noti_title%d", line_num);
\r
43 if (!strcmp(pkgname, PHONE_LAUNCH_PKG)) {
\r
45 snprintf(buf1, sizeof(buf1), "%d %s", count, _NOT_LOCALIZED("Missed call"));
\r
46 }else if(count > 1){
\r
47 snprintf(buf1, sizeof(buf1), "%d %s", count, _NOT_LOCALIZED("Missed calls"));
\r
49 edje_object_part_text_set(_EDJ(ad->noti), buf2, buf1);
\r
50 } else if (!strcmp(pkgname, MESSAGE_LAUNCH_PKG)) {
\r
52 snprintf(buf1, sizeof(buf1), "%d %s", count, _NOT_LOCALIZED("New message"));
\r
53 }else if(count > 1){
\r
54 snprintf(buf1, sizeof(buf1), "%d %s", count, _NOT_LOCALIZED("New messages"));
\r
56 edje_object_part_text_set(_EDJ(ad->noti), buf2, buf1);
\r
57 } else if (!strcmp(pkgname, EMAIL_LAUNCH_PKG)) {
\r
59 snprintf(buf1, sizeof(buf1), "%d %s", count, _NOT_LOCALIZED("New email"));
\r
60 }else if(count > 1){
\r
61 snprintf(buf1, sizeof(buf1), "%d %s", count, _NOT_LOCALIZED("New emails"));
\r
63 edje_object_part_text_set(_EDJ(ad->noti), buf2, buf1);
\r
65 edje_object_part_text_set(_EDJ(ad->noti), buf2, title);
\r
69 static int __ticker_check_setting_event_value(notification_h noti)
\r
71 char *pkgname = NULL;
\r
72 char key[512] = {0, };
\r
76 notification_get_application(noti, &pkgname);
\r
78 if (pkgname == NULL) {
\r
79 notification_get_pkgname(noti, &pkgname);
\r
82 if (pkgname == NULL) {
\r
86 if (!strcmp(pkgname, MESSAGE_LAUNCH_PKG)) {
\r
87 ret = vconf_get_bool(VCONFKEY_SETAPPL_STATE_TICKER_NOTI_MESSAGES_BOOL, &boolval);
\r
88 if (ret == 0 && boolval == 0) {
\r
91 } else if (!strcmp(pkgname, EMAIL_LAUNCH_PKG)) {
\r
92 ret = vconf_get_bool(VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL, &boolval);
\r
93 if (ret == 0 && boolval == 0) {
\r
98 snprintf(key, sizeof(key), "db/app-settings/noti-enabled/%s", pkgname);
\r
99 ret = vconf_get_int(key, &boolval);
\r
100 if (ret == 0 && boolval == 0) {
\r
107 static void __noti_changed_cb(void *data, notification_type_e type)
\r
109 notification_h noti = NULL;
\r
110 notification_list_h notification_list = NULL;
\r
111 notification_list_h get_list = NULL;
\r
112 int count = 0, group_id = 0, priv_id = 0, show_noti = 0, num = 1;
\r
113 char *pkgname = NULL;
\r
114 char *title = NULL;
\r
115 char *str_count = NULL;
\r
117 char buf[512] = {0};
\r
118 struct appdata *ad = (struct appdata *)data;
\r
120 for(i = 1; i <= MAX_NOTI_NUM; i++){
\r
121 snprintf(buf, sizeof(buf), "noti_title%d", i);
\r
122 edje_object_part_text_set(_EDJ(ad->noti), buf, "");
\r
125 notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬ification_list);
\r
126 if (notification_list) {
\r
127 get_list = notification_list_get_head(notification_list);
\r
128 noti = notification_list_get_data(get_list);
\r
129 LOCK_SCREEN_TRACE_DBG("get_list : %p, noti : %p", get_list, noti);
\r
130 while(get_list != NULL) {
\r
131 notification_get_id(noti, &group_id, &priv_id);
\r
132 notification_get_pkgname(noti, &pkgname);
\r
133 if(pkgname == NULL){
\r
134 notification_get_application(noti, &pkgname);
\r
136 show_noti = __ticker_check_setting_event_value(noti);
\r
137 LOCK_SCREEN_TRACE_DBG("show noti : %d", show_noti);
\r
138 if (show_noti == 0) {
\r
139 get_list = notification_list_get_next(get_list);
\r
140 noti = notification_list_get_data(get_list);
\r
144 if(num > MAX_NOTI_NUM){
\r
145 if (notification_list != NULL) {
\r
146 notification_free_list(notification_list);
\r
147 notification_list = NULL;
\r
152 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &str_count);
\r
156 count = atoi(str_count);
\r
158 notification_get_title(noti, &title, NULL);
\r
159 __noti_info_set(data, pkgname, title, count, num);
\r
160 get_list = notification_list_get_next(get_list);
\r
161 noti = notification_list_get_data(get_list);
\r
165 if (notification_list != NULL) {
\r
166 notification_free_list(notification_list);
\r
167 notification_list = NULL;
\r
171 void noti_process(void *data)
\r
173 struct appdata *ad = (struct appdata *)data;
\r
178 ad->noti = elm_layout_add(ad->ly_main);
\r
179 elm_layout_file_set(ad->noti, EDJEFILE, "lock-noti");
\r
180 evas_object_show(ad->noti);
\r
181 elm_object_part_content_set(ad->ly_main, "sw.noti", ad->noti);
\r
183 notification_resister_changed_cb(__noti_changed_cb, ad);
\r
184 __noti_changed_cb(ad, NOTIFICATION_TYPE_NOTI);
\r