Restore JACK parameters during studio load. Closes #2
[ladish.git] / dbus / interface.c
blob34094d64cb983f63aabda5b9e3430374abfa797b
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
8 **************************************************************************
9 * This file contains D-Bus interface dispatcher
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 <string.h>
30 #include "../common/debug.h"
32 #include "interface.h"
33 #include "error.h"
34 #include "object_path.h"
37 * Execute a method's function if the method specified in the method call
38 * object exists in the method array. Return true if the method was found,
39 * false otherwise.
40 * TODO: rewrite description ^
42 bool
43 interface_default_handler(const interface_t *interface,
44 method_call_t *call)
46 const method_t *ptr;
48 for (ptr = (const method_t *) interface->methods;
49 ptr && ptr->name;
50 ++ptr) {
51 if (strcmp(call->method_name, ptr->name) == 0) {
52 if (ptr->handler) {
53 call->interface = interface;
54 call->context = ((object_path_t *)call->context)->context;
55 ptr->handler(call);
57 /* If the method handler didn't construct a return
58 message create a void one here */
59 // TODO: Also handle cases where the sender doesn't need a reply
60 if (!call->reply
61 && !(call->reply = dbus_message_new_method_return(call->message))) {
62 lash_error("Failed to construct void method return");
64 } else {
65 lash_dbus_error(call, LASH_DBUS_ERROR_GENERIC,
66 "Handler for method \"%s\" is NULL", ptr->name);
69 /* Found method */
70 return true;
74 /* Didn't find method */
75 return false;
78 /* EOF */