1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
8 **************************************************************************
9 * This file contains D-Bus signal helpers
10 **************************************************************************
12 * LADI Session Handler is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * LADI Session Handler is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
24 * or write to the Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "../common/debug.h"
35 signal_send(signal_msg_t
*signal
);
39 DBusConnection
* connection_ptr
,
41 const char * interface
,
49 lash_debug("Sending signal %s.%s from %s", interface
, name
, path
);
51 if ((signal
.message
= dbus_message_new_signal(path
, interface
, name
))) {
52 dbus_message_iter_init_append(signal
.message
, &iter
);
53 if (dbus_message_iter_append_basic(&iter
, type
, arg
)) {
54 signal
.connection
= connection_ptr
;
57 lash_error("Ran out of memory trying to append signal argument");
60 dbus_message_unref(signal
.message
);
61 signal
.message
= NULL
;
66 lash_error("Ran out of memory trying to create new signal");
71 DBusConnection
* connection_ptr
,
73 const char * interface
,
81 lash_debug("Sending signal %s.%s from %s", interface
, name
, path
);
83 if ((signal
.message
= dbus_message_new_signal (path
, interface
, name
))) {
85 if (dbus_message_append_args_valist(signal
.message
, type
, argp
)) {
86 signal
.connection
= connection_ptr
;
89 lash_error("Ran out of memory trying to append signal argument(s)");
93 dbus_message_unref(signal
.message
);
94 signal
.message
= NULL
;
99 lash_error("Ran out of memory trying to create new signal");
103 signal_send(signal_msg_t
*signal
)
105 if (!dbus_connection_send(signal
->connection
, signal
->message
, NULL
)) {
106 lash_error("Ran out of memory trying to queue signal");
109 dbus_connection_flush(signal
->connection
);