daemon: expose new studio room objects on D-Bus

This commit is contained in:
Nedko Arnaudov 2010-03-06 17:03:14 +02:00
parent a76c415981
commit 2fd730ea55
7 changed files with 123 additions and 7 deletions

View File

@ -48,7 +48,7 @@ bool create_builtin_rooms(void)
{
ladish_room_handle room;
if (!ladish_room_create(empty_room, "Empty", NULL, &room))
if (!ladish_room_create(empty_room, "Empty", NULL, NULL, &room))
{
log_error("ladish_room_create() failed.");
return false;
@ -56,7 +56,7 @@ bool create_builtin_rooms(void)
list_add_tail(ladish_room_get_list_node(room), &g_rooms);
if (!ladish_room_create(basic_room, "Basic", NULL, &room))
if (!ladish_room_create(basic_room, "Basic", NULL, NULL, &room))
{
log_error("ladish_room_create() failed.");
return false;

View File

@ -2,7 +2,7 @@
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2008, 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2008 Juuso Alasuutari
*
**************************************************************************
@ -959,6 +959,11 @@ void ladish_graph_destroy(ladish_graph_handle graph_handle, bool destroy_ports)
free(graph_ptr);
}
const char * ladish_graph_get_opath(ladish_graph_handle graph_handle)
{
return graph_ptr->opath;
}
void
ladish_graph_set_connection_handlers(
ladish_graph_handle graph_handle,

View File

@ -2,7 +2,7 @@
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains interface to the D-Bus patchbay interface helpers
@ -50,6 +50,8 @@ bool
bool ladish_graph_create(ladish_graph_handle * graph_handle_ptr, const char * opath);
void ladish_graph_destroy(ladish_graph_handle graph_handle, bool destroy_ports);
const char * ladish_graph_get_opath(ladish_graph_handle graph_handle);
void
ladish_graph_set_connection_handlers(
ladish_graph_handle graph_handle,

View File

@ -25,6 +25,9 @@
*/
#include "room.h"
#include "../dbus_constants.h"
#include "graph.h"
#include "graph_dict.h"
struct ladish_room
{
@ -32,13 +35,18 @@ struct ladish_room
uuid_t uuid;
char * name;
uuid_t template_uuid;
dbus_object_path dbus_object;
ladish_graph_handle graph;
};
extern const struct dbus_interface_descriptor g_interface_room;
bool
ladish_room_create(
const uuid_t uuid_ptr,
const char * name,
ladish_room_handle template,
const char * object_path,
ladish_room_handle * room_handle_ptr)
{
struct ladish_room * room_ptr;
@ -83,6 +91,46 @@ ladish_room_create(
return false;
}
if (object_path)
{
if (!ladish_graph_create(&room_ptr->graph, object_path))
{
free(room_ptr);
return false;
}
room_ptr->dbus_object = dbus_object_path_new(
object_path,
&g_interface_room, room_ptr,
&g_interface_patchbay, ladish_graph_get_dbus_context(room_ptr->graph),
&g_iface_graph_dict, room_ptr->graph,
//&g_iface_app_supervisor, room_ptr->app_supervisor,
NULL);
if (room_ptr->dbus_object == NULL)
{
log_error("dbus_object_path_new() failed");
ladish_graph_destroy(room_ptr->graph, true);
free(room_ptr);
return false;
}
if (!dbus_object_path_register(g_dbus_connection, room_ptr->dbus_object))
{
log_error("object_path_register() failed");
dbus_object_path_destroy(g_dbus_connection, room_ptr->dbus_object);
ladish_graph_destroy(room_ptr->graph, true);
free(room_ptr);
return false;
}
log_info("D-Bus object \"%s\" created for room \"%s\".", object_path, room_ptr->name);
}
else
{
room_ptr->dbus_object = NULL;
room_ptr->graph = NULL;
}
*room_handle_ptr = (ladish_room_handle)room_ptr;
return true;
}
@ -93,6 +141,12 @@ void
ladish_room_destroy(
ladish_room_handle room_handle)
{
if (room_ptr->dbus_object != NULL)
{
dbus_object_path_destroy(g_dbus_connection, room_ptr->dbus_object);
ladish_graph_destroy(room_ptr->graph, true);
}
free(room_ptr->name);
free(room_ptr);
}
@ -107,6 +161,16 @@ const char * ladish_room_get_name(ladish_room_handle room_handle)
return room_ptr->name;
}
const char * ladish_room_get_opath(ladish_room_handle room_handle)
{
if (room_ptr->graph == NULL)
{
return NULL;
}
return ladish_graph_get_opath(room_ptr->graph);
}
bool ladish_room_get_template_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr)
{
if (uuid_is_null(room_ptr->template_uuid))
@ -129,3 +193,29 @@ ladish_room_handle ladish_room_from_list_node(struct list_head * node_ptr)
{
return (ladish_room_handle)list_entry(node_ptr, struct ladish_room, siblings);
}
#define room_ptr ((struct ladish_room *)call_ptr->iface_context)
static void ladish_get_room_name(struct dbus_method_call * call_ptr)
{
method_return_new_single(call_ptr, DBUS_TYPE_STRING, &room_ptr->name);
}
#undef room_ptr
METHOD_ARGS_BEGIN(GetName, "Get room name")
METHOD_ARG_DESCRIBE_OUT("room_name", "s", "Name of room")
METHOD_ARGS_END
METHODS_BEGIN
METHOD_DESCRIBE(GetName, ladish_get_room_name)
METHODS_END
SIGNALS_BEGIN
SIGNALS_END
INTERFACE_BEGIN(g_interface_room, IFACE_ROOM)
INTERFACE_DEFAULT_HANDLER
INTERFACE_EXPOSE_METHODS
INTERFACE_EXPOSE_SIGNALS
INTERFACE_END

View File

@ -36,6 +36,7 @@ ladish_room_create(
const uuid_t uuid_ptr,
const char * name,
ladish_room_handle template,
const char * object_path,
ladish_room_handle * room_handle_ptr);
void
@ -46,6 +47,7 @@ struct list_head * ladish_room_get_list_node(ladish_room_handle room_handle);
ladish_room_handle ladish_room_from_list_node(struct list_head * node_ptr);
const char * ladish_room_get_name(ladish_room_handle room_handle);
const char * ladish_room_get_opath(ladish_room_handle room_handle);
bool ladish_room_get_template_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr);
void ladish_room_get_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr);

View File

@ -328,6 +328,8 @@ bool studio_init(void)
g_studio.name = NULL;
g_studio.filename = NULL;
g_studio.room_count = 0;
if (!ladish_graph_create(&g_studio.jack_graph, NULL))
{
log_error("ladish_graph_create() failed to create jack graph object.");
@ -700,6 +702,8 @@ static void ladish_studio_new_room(struct dbus_method_call * call_ptr)
const char * room_name;
const char * template_name;
ladish_room_handle room;
char room_dbus_name[1024];
const char * arg;
dbus_error_init(&g_dbus_error);
@ -719,15 +723,21 @@ static void ladish_studio_new_room(struct dbus_method_call * call_ptr)
return;
}
if (!ladish_room_create(NULL, room_name, room, &room))
g_studio.room_count++;
sprintf(room_dbus_name, DBUS_BASE_PATH "/Room%u", g_studio.room_count);
if (!ladish_room_create(NULL, room_name, room, room_dbus_name, &room))
{
lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "ladish_room_create() failed.");
g_studio.room_count--;
return;
}
list_add_tail(ladish_room_get_list_node(room), &g_studio.rooms);
//dbus_signal_emit(g_dbus_connection, STUDIO_OBJECT_PATH, IFACE_STUDIO, "RoomAppeared", "");
arg = room_dbus_name;
dbus_signal_emit(g_dbus_connection, STUDIO_OBJECT_PATH, IFACE_STUDIO, "RoomAppeared", "s", &arg);
method_return_new_void(call_ptr);
}
@ -743,6 +753,7 @@ static void ladish_studio_get_room_list(struct dbus_method_call * call_ptr)
uuid_t template_uuid;
ladish_room_handle template;
const char * template_name;
const char * opath;
call_ptr->reply = dbus_message_new_method_return(call_ptr->message);
if (call_ptr->reply == NULL)
@ -761,6 +772,7 @@ static void ladish_studio_get_room_list(struct dbus_method_call * call_ptr)
{
room = ladish_room_from_list_node(node_ptr);
name = ladish_room_get_name(room);
opath = ladish_room_get_opath(room);
if (!ladish_room_get_template_uuid(room, template_uuid))
{
@ -792,6 +804,9 @@ static void ladish_studio_get_room_list(struct dbus_method_call * call_ptr)
if (!dbus_maybe_add_dict_entry_string(&dict_iter, "template", template_name))
goto fail_unref;
if (!dbus_maybe_add_dict_entry_string(&dict_iter, "opath", opath))
goto fail_unref;
if (!dbus_message_iter_close_container(&struct_iter, &dict_iter))
goto fail_unref;

View File

@ -2,7 +2,7 @@
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains declaration of internal stuff used by
@ -151,6 +151,8 @@ struct studio
ladish_graph_handle studio_graph;
ladish_virtualizer_handle virtualizer;
ladish_app_supervisor_handle app_supervisor;
unsigned int room_count;
};
struct jack_conf_parameter