1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of code that interfaces
9 * the ladishd Control object through D-Bus
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 "control_proxy.h"
29 #include "../dbus/helpers.h"
31 #define SERVICE DBUS_NAME_BASE
32 #define OBJECT DBUS_BASE_PATH "/Control"
33 #define IFACE DBUS_NAME_BASE ".Control"
35 const char * g_signals
[] =
42 static DBusHandlerResult
message_hook(DBusConnection
* connection
, DBusMessage
* message
, void * data
)
44 const char * object_path
;
46 object_path
= dbus_message_get_path(message
);
47 if (object_path
== NULL
|| strcmp(object_path
, OBJECT
) != 0)
49 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
52 if (dbus_message_is_signal(message
, IFACE
, "StudioAppeared"))
54 lash_info("StudioAppeared");
55 control_proxy_on_studio_appeared();
56 return DBUS_HANDLER_RESULT_HANDLED
;
59 if (dbus_message_is_signal(message
, IFACE
, "StudioDisappeared"))
61 lash_info("StudioDisappeared");
62 control_proxy_on_studio_disappeared();
63 return DBUS_HANDLER_RESULT_HANDLED
;
66 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED
;
69 static bool control_proxy_is_studio_loaded(bool * present_ptr
)
73 if (!dbus_call_simple(SERVICE
, OBJECT
, IFACE
, "IsStudioLoaded", "", "b", &present
))
78 *present_ptr
= present
;
83 bool control_proxy_init(void)
87 if (!dbus_register_object_signal_handler(g_dbus_connection
, SERVICE
, OBJECT
, IFACE
, g_signals
, message_hook
, NULL
))
92 if (!control_proxy_is_studio_loaded(&studio_present
))
94 dbus_unregister_object_signal_handler(g_dbus_connection
, SERVICE
, OBJECT
, IFACE
, g_signals
, message_hook
, NULL
);
100 control_proxy_on_studio_appeared();
106 void control_proxy_uninit(void)
108 dbus_unregister_object_signal_handler(g_dbus_connection
, SERVICE
, OBJECT
, IFACE
, g_signals
, message_hook
, NULL
);
111 bool control_proxy_get_studio_list(struct list_head
* studio_list
)
116 bool control_proxy_load_studio(const char * studio_name
)
121 bool control_proxy_exit(void)