diff --git a/daemon/common.h b/daemon/common.h index 56017a30..4df76b62 100644 --- a/daemon/common.h +++ b/daemon/common.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009 Nedko Arnaudov + * Copyright (C) 2009,2010 Nedko Arnaudov * ************************************************************************** * This file contains stuff that is needed almost everywhere in the ladishd @@ -55,17 +55,6 @@ struct connection struct port * playback_port_ptr; /* The playback input port */ }; -struct room -{ - struct list_head siblings; /* link for studio::rooms list */ - struct list_head clients; /* non-virtual room clients */ - struct list_head ports; /* ports of the room clients */ - uuid_t uuid; /* The UUID of the room */ - char * name; /* Name of the room */ - struct client * link_client_ptr; /* client that connects the room to studio */ - struct studio * studio_ptr; /* Studio connected to the room */ -}; - #include "studio.h" extern bool g_quit; diff --git a/daemon/room.c b/daemon/room.c new file mode 100644 index 00000000..09689b14 --- /dev/null +++ b/daemon/room.c @@ -0,0 +1,81 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2010 Nedko Arnaudov + * + ************************************************************************** + * This file contains implementation of the room object + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "room.h" + +struct ladish_room +{ + uuid_t uuid; + char * name; +}; + +bool +ladish_room_create( + const uuid_t uuid_ptr, + const char * name, + ladish_room_handle * room_handle_ptr) +{ + struct ladish_room * room_ptr; + + room_ptr = malloc(sizeof(struct ladish_room)); + if (room_ptr == NULL) + { + log_error("malloc() failed to allocate struct ladish_room"); + return false; + } + + if (uuid_ptr == NULL) + { + uuid_generate(room_ptr->uuid); + } + else + { + uuid_copy(room_ptr->uuid, uuid_ptr); + } + + room_ptr->name = strdup(name); + if (room_ptr->name == NULL) + { + log_error("strdup() failed for room name"); + free(room_ptr); + return false; + } + + *room_handle_ptr = (ladish_room_handle)room_ptr; + return true; +} + +#define room_ptr ((struct ladish_room *)room_handle) + +void +ladish_room_destroy( + ladish_room_handle room_handle) +{ + free(room_ptr->name); + free(room_ptr); +} + +#undef room_ptr diff --git a/daemon/room.h b/daemon/room.h new file mode 100644 index 00000000..9d20ef5a --- /dev/null +++ b/daemon/room.h @@ -0,0 +1,44 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/* + * LADI Session Handler (ladish) + * + * Copyright (C) 2010 Nedko Arnaudov + * + ************************************************************************** + * This file contains interface of the room object + ************************************************************************** + * + * LADI Session Handler is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * LADI Session Handler is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LADI Session Handler. If not, see + * or write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED +#define ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED + +#include "common.h" + +typedef struct ladish_room_tag { int unused; } * ladish_room_handle; + +bool +ladish_room_create( + const uuid_t uuid_ptr, + const char * name, + ladish_room_handle * room_handle_ptr); + +void +ladish_room_destroy( + ladish_room_handle room_handle); + +#endif /* #ifndef ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED */ diff --git a/wscript b/wscript index 52439b5a..f7e83bd3 100644 --- a/wscript +++ b/wscript @@ -231,6 +231,7 @@ def build(bld): 'cmd_exit.c', 'cqueue.c', 'app_supervisor.c', + 'room.c', ]: daemon.source.append(os.path.join("daemon", source))