4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@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.
26 #include <dbus/dbus.h>
28 #include <notification_db.h>
29 #include <notification_debug.h>
30 #include <notification_ongoing.h>
31 #include <notification_private.h>
33 int notification_ongoing_update_progress(const char *caller_pkgname,
37 DBusConnection *connection = NULL;
38 DBusMessage *signal = NULL;
42 dbus_error_init(&err);
43 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
45 NOTIFICATION_ERR("Fail to dbus_bus_get");
46 return NOTIFICATION_ERROR_FROM_DBUS;
50 dbus_message_new_signal("/dbus/signal", "notification.ongoing",
53 NOTIFICATION_ERR("Fail to dbus_message_new_signal");
54 return NOTIFICATION_ERROR_FROM_DBUS;
57 ret = dbus_message_append_args(signal,
58 DBUS_TYPE_STRING, &caller_pkgname,
59 DBUS_TYPE_INT32, &priv_id,
60 DBUS_TYPE_DOUBLE, &progress,
64 ret = dbus_connection_send(connection, signal, NULL);
66 dbus_connection_flush(connection);
70 dbus_message_unref(signal);
73 return NOTIFICATION_ERROR_NONE;
76 return NOTIFICATION_ERROR_FROM_DBUS;
79 int notification_ongoing_update_size(const char *caller_pkgname,
80 int priv_id, double size)
82 DBusConnection *connection = NULL;
83 DBusMessage *signal = NULL;
87 dbus_error_init(&err);
88 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
90 NOTIFICATION_ERR("Fail to dbus_bus_get");
91 return NOTIFICATION_ERROR_FROM_DBUS;
95 dbus_message_new_signal("/dbus/signal", "notification.ongoing",
98 NOTIFICATION_ERR("Fail to dbus_message_new_signal");
99 return NOTIFICATION_ERROR_FROM_DBUS;
102 ret = dbus_message_append_args(signal,
103 DBUS_TYPE_STRING, &caller_pkgname,
104 DBUS_TYPE_INT32, &priv_id,
105 DBUS_TYPE_DOUBLE, &size,
108 ret = dbus_connection_send(connection, signal, NULL);
111 dbus_connection_flush(connection);
115 dbus_message_unref(signal);
118 return NOTIFICATION_ERROR_NONE;
121 return NOTIFICATION_ERROR_FROM_DBUS;
124 int notification_ongoing_update_content(const char *caller_pkgname,
125 int priv_id, const char *content)
127 DBusConnection *connection = NULL;
128 DBusMessage *signal = NULL;
132 dbus_error_init(&err);
133 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
135 NOTIFICATION_ERR("Fail to dbus_bus_get");
136 return NOTIFICATION_ERROR_FROM_DBUS;
140 dbus_message_new_signal("/dbus/signal", "notification.ongoing",
143 NOTIFICATION_ERR("Fail to dbus_message_new_signal");
144 return NOTIFICATION_ERROR_FROM_DBUS;
147 if(content == NULL) {
148 ret = dbus_message_append_args(signal,
149 DBUS_TYPE_STRING, &caller_pkgname,
150 DBUS_TYPE_INT32, &priv_id,
153 ret = dbus_message_append_args(signal,
154 DBUS_TYPE_STRING, &caller_pkgname,
155 DBUS_TYPE_INT32, &priv_id,
156 DBUS_TYPE_STRING, &content,
160 ret = dbus_connection_send(connection, signal, NULL);
163 dbus_connection_flush(connection);
167 dbus_message_unref(signal);
170 return NOTIFICATION_ERROR_NONE;
173 return NOTIFICATION_ERROR_FROM_DBUS;