4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * @file notification.c
23 * @desc Notification specific functions
25 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
29 #include <resourced.h>
31 #include "edbus-handler.h"
32 #include "notification.h"
36 #include "datausage-vconf-common.h"
38 #define RESTRICTION_ACTIVE "RestrictionActive"
39 #define RESTRICTION_WARNING "RestrictionWarning"
41 #define NOTI_KEY "_SYSPOPUP_CONTENT_"
42 #define NOTI_KEY_LIMIT "_DATAUSAGE_LIMIT_"
43 #define NOTI_VALUE_DISABLED "datausage_disabled"
44 #define NOTI_VALUE_WARNING "datausage_warning"
46 #define METHOD_CALL_POPUP "DatausagePopupLaunch"
48 static int show_restriction_popup(const char *value)
50 char buf[MAX_DEC_SIZE(int)];
53 int ret, retval, quota_limit = -1;
55 if (restriction_check_limit_status(&retval) < 0)
56 _E("Failed to check limit status");
59 _E("data usage limit is not set");
60 return RESOURCED_ERROR_FAIL;
63 if (restriction_read_quota("a_limit) < 0)
64 _E("Failed to read a quota value");
66 if (quota_limit <= 0) {
67 _D("quota_limit is invalid\n");
68 return RESOURCED_ERROR_FAIL;
71 snprintf(str_val, sizeof(str_val), "%s", value);
72 snprintf(buf, sizeof(buf), "%d", quota_limit);
76 pa[2] = NOTI_KEY_LIMIT;
79 ret = dbus_method_async(SYSTEM_POPUP_BUS_NAME, SYSTEM_POPUP_PATH_WATCHDOG, SYSTEM_POPUP_IFACE_WATCHDOG, METHOD_CALL_POPUP, "ssss", pa);
81 _E("no message : failed to setting %d", ret);
85 void send_restriction_notification(const char *appid)
87 if (broadcast_edbus_signal(RESOURCED_PATH_NETWORK,
88 RESOURCED_INTERFACE_NETWORK,
91 (void *)(&appid)) != RESOURCED_ERROR_NONE) {
92 _E("Failed to send DBUS message.");
95 restriction_set_status(RESTRICTION_STATE_SET);
97 _I("Show a network disabled popup");
98 show_restriction_popup(NOTI_VALUE_DISABLED);
101 void send_restriction_warn_notification(const char *appid)
103 if (broadcast_edbus_signal(RESOURCED_PATH_NETWORK,
104 RESOURCED_INTERFACE_NETWORK,
107 (void *)(&appid)) != RESOURCED_ERROR_NONE) {
108 _E("Failed to send DBUS message.");
111 _I("Show a network warning popup");
112 show_restriction_popup(NOTI_VALUE_WARNING);