4 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "common/debug.h"
24 #include "dbus/signal.h"
25 #include "dbus/service.h"
28 signal_send(signal_msg_t
*signal
);
31 signal_new_single(service_t
*service
,
33 const char *interface
,
41 lash_debug("Sending signal %s.%s from %s", interface
, name
, path
);
43 if ((signal
.message
= dbus_message_new_signal(path
, interface
, name
))) {
44 dbus_message_iter_init_append(signal
.message
, &iter
);
45 if (dbus_message_iter_append_basic(&iter
, type
, arg
)) {
46 signal
.connection
= service
->connection
;
49 lash_error("Ran out of memory trying to append signal argument");
52 dbus_message_unref(signal
.message
);
53 signal
.message
= NULL
;
58 lash_error("Ran out of memory trying to create new signal");
62 signal_new_valist (service_t
*service
,
64 const char *interface
,
72 lash_debug("Sending signal %s.%s from %s", interface
, name
, path
);
74 if ((signal
.message
= dbus_message_new_signal (path
, interface
, name
))) {
76 if (dbus_message_append_args_valist(signal
.message
, type
, argp
)) {
77 signal
.connection
= service
->connection
;
80 lash_error("Ran out of memory trying to append signal argument(s)");
84 dbus_message_unref(signal
.message
);
85 signal
.message
= NULL
;
90 lash_error("Ran out of memory trying to create new signal");
94 signal_send(signal_msg_t
*signal
)
96 if (!dbus_connection_send(signal
->connection
, signal
->message
, NULL
)) {
97 lash_error("Ran out of memory trying to queue signal");
100 dbus_connection_flush(signal
->connection
);