Restore JACK parameters during studio load. Closes #2
[ladish.git] / gui / control_proxy.c
blob97a18cd656730751ec0af2380e74f040f048142e
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
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"
30 #include "../dbus_constants.h"
32 static const char * g_signals[] =
34 "StudioAppeared",
35 "StudioDisappeared",
36 NULL
39 static DBusHandlerResult message_hook(DBusConnection * connection, DBusMessage * message, void * data)
41 const char * object_path;
43 object_path = dbus_message_get_path(message);
44 if (object_path == NULL || strcmp(object_path, CONTROL_OBJECT_PATH) != 0)
46 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
49 if (dbus_message_is_signal(message, IFACE_CONTROL, "StudioAppeared"))
51 lash_info("StudioAppeared");
52 control_proxy_on_studio_appeared();
53 return DBUS_HANDLER_RESULT_HANDLED;
56 if (dbus_message_is_signal(message, IFACE_CONTROL, "StudioDisappeared"))
58 lash_info("StudioDisappeared");
59 control_proxy_on_studio_disappeared();
60 return DBUS_HANDLER_RESULT_HANDLED;
63 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
66 static bool control_proxy_is_studio_loaded(bool * present_ptr)
68 dbus_bool_t present;
70 if (!dbus_call_simple(SERVICE_NAME, CONTROL_OBJECT_PATH, IFACE_CONTROL, "IsStudioLoaded", "", "b", &present))
72 return false;
75 *present_ptr = present;
77 return true;
80 bool control_proxy_init(void)
82 bool studio_present;
84 if (!control_proxy_is_studio_loaded(&studio_present))
86 return false;
89 if (studio_present)
91 lash_info("Initial studio appear");
92 control_proxy_on_studio_appeared();
95 if (!dbus_register_object_signal_handler(g_dbus_connection, SERVICE_NAME, CONTROL_OBJECT_PATH, IFACE_CONTROL, g_signals, message_hook, NULL))
97 if (studio_present)
99 control_proxy_on_studio_disappeared();
102 return false;
105 return true;
108 void control_proxy_uninit(void)
110 dbus_unregister_object_signal_handler(g_dbus_connection, SERVICE_NAME, CONTROL_OBJECT_PATH, IFACE_CONTROL, g_signals, message_hook, NULL);
113 bool control_proxy_get_studio_list(struct list_head * studio_list)
115 return false;
118 bool control_proxy_load_studio(const char * studio_name)
120 return false;
123 bool control_proxy_exit(void)
125 return false;