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>, Youngsub Ko <ys4610.ko@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_internal.h>
33 notification_error_e 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 notification_error_e 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 NOTIFICATION_INFO("Send size info : %s(%d) %.2f",
119 caller_pkgname, priv_id, size);
120 return NOTIFICATION_ERROR_NONE;
123 return NOTIFICATION_ERROR_FROM_DBUS;
126 notification_error_e notification_ongoing_update_content(const char *caller_pkgname,
127 int priv_id, const char *content)
129 DBusConnection *connection = NULL;
130 DBusMessage *signal = NULL;
134 dbus_error_init(&err);
135 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
137 NOTIFICATION_ERR("Fail to dbus_bus_get");
138 return NOTIFICATION_ERROR_FROM_DBUS;
142 dbus_message_new_signal("/dbus/signal", "notification.ongoing",
145 NOTIFICATION_ERR("Fail to dbus_message_new_signal");
146 return NOTIFICATION_ERROR_FROM_DBUS;
149 if(content == NULL) {
150 ret = dbus_message_append_args(signal,
151 DBUS_TYPE_STRING, &caller_pkgname,
152 DBUS_TYPE_INT32, &priv_id,
155 ret = dbus_message_append_args(signal,
156 DBUS_TYPE_STRING, &caller_pkgname,
157 DBUS_TYPE_INT32, &priv_id,
158 DBUS_TYPE_STRING, &content,
162 ret = dbus_connection_send(connection, signal, NULL);
165 dbus_connection_flush(connection);
169 dbus_message_unref(signal);
172 return NOTIFICATION_ERROR_NONE;
175 return NOTIFICATION_ERROR_FROM_DBUS;