Restore JACK parameters during studio load. Closes #2
[ladish.git] / dbus / signal.c
blob449d53747af958298f145b4bc606e2686db4627e
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
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.
28 #include <stdarg.h>
30 #include "../common/debug.h"
31 #include "signal.h"
32 #include "service.h"
34 static void
35 signal_send(signal_msg_t *signal);
37 void
38 signal_new_single(
39 DBusConnection * connection_ptr,
40 const char * path,
41 const char * interface,
42 const char * name,
43 int type,
44 const void * arg)
46 signal_msg_t signal;
47 DBusMessageIter iter;
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;
55 signal_send(&signal);
56 } else {
57 lash_error("Ran out of memory trying to append signal argument");
60 dbus_message_unref(signal.message);
61 signal.message = NULL;
63 return;
66 lash_error("Ran out of memory trying to create new signal");
69 void
70 signal_new_valist(
71 DBusConnection * connection_ptr,
72 const char * path,
73 const char * interface,
74 const char * name,
75 int type,
76 ...)
78 signal_msg_t signal;
79 va_list argp;
81 lash_debug("Sending signal %s.%s from %s", interface, name, path);
83 if ((signal.message = dbus_message_new_signal (path, interface, name))) {
84 va_start(argp, type);
85 if (dbus_message_append_args_valist(signal.message, type, argp)) {
86 signal.connection = connection_ptr;
87 signal_send(&signal);
88 } else {
89 lash_error("Ran out of memory trying to append signal argument(s)");
91 va_end(argp);
93 dbus_message_unref(signal.message);
94 signal.message = NULL;
96 return;
99 lash_error("Ran out of memory trying to create new signal");
102 static void
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);
112 /* EOF */