1 /* -*- Mode: C ; c-basic-offset: 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 * Licensed under the Academic Free License version 2.1
14 * LADI Session Handler is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * LADI Session Handler is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
26 * or write to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "../common.h"
36 * Execute a method's function if the method specified in the method call
37 * object exists in the method array. Return true if the method was found,
40 bool dbus_interface_default_handler(const struct dbus_interface_descriptor
* iface_ptr
, struct dbus_method_call
* call_ptr
)
42 const struct dbus_method_descriptor
* method_ptr
;
44 for (method_ptr
= iface_ptr
->methods
; method_ptr
->name
!= NULL
; method_ptr
++)
46 if (strcmp(call_ptr
->method_name
, method_ptr
->name
) == 0)
48 call_ptr
->iface
= iface_ptr
;
49 method_ptr
->handler(call_ptr
);
50 /* If the method handler didn't construct a return message create a void one here */
51 // TODO: Also handle cases where the sender doesn't need a reply
52 if (call_ptr
->reply
== NULL
)
54 call_ptr
->reply
= dbus_message_new_method_return(call_ptr
->message
);
55 if (call_ptr
->reply
== NULL
)
57 log_error("Failed to construct void method return");