daemon: refuse to create room with duplicate name. Fix for #106
This commit is contained in:
parent
7217c4f3d3
commit
a9a55b0ddc
|
@ -28,6 +28,7 @@
|
|||
#include "studio_internal.h"
|
||||
#include "../dbus/error.h"
|
||||
#include "control.h"
|
||||
#include "../proxies/notify_proxy.h"
|
||||
|
||||
struct ladish_command_create_room
|
||||
{
|
||||
|
@ -53,6 +54,12 @@ static bool run(void * cmd_context)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (ladish_studio_check_room_name(cmd_ptr->room_name))
|
||||
{
|
||||
ladish_notify_simple(LADISH_NOTIFY_URGENCY_HIGH, "Room with requested name already exists", cmd_ptr->room_name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!ladish_room_create(NULL, cmd_ptr->room_name, room, g_studio.studio_graph, &room))
|
||||
{
|
||||
log_error("ladish_room_create() failed.");
|
||||
|
|
|
@ -1009,6 +1009,23 @@ ladish_room_handle ladish_studio_find_room_by_uuid(const uuid_t room_uuid_ptr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool ladish_studio_check_room_name(const char * room_name)
|
||||
{
|
||||
struct list_head * node_ptr;
|
||||
ladish_room_handle room;
|
||||
|
||||
list_for_each(node_ptr, &g_studio.rooms)
|
||||
{
|
||||
room = ladish_room_from_list_node(node_ptr);
|
||||
if (strcmp(ladish_room_get_name(room), room_name) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
/* D-Bus methods */
|
||||
/**********************************************************************************/
|
||||
|
|
|
@ -74,5 +74,6 @@ void ladish_studio_room_appeared(ladish_room_handle room);
|
|||
void ladish_studio_room_disappeared(ladish_room_handle room);
|
||||
|
||||
ladish_room_handle ladish_studio_find_room_by_uuid(const uuid_t room_uuid_ptr);
|
||||
bool ladish_studio_check_room_name(const char * room_name);
|
||||
|
||||
#endif /* #ifndef STUDIO_H__0BEDE85E_4FB3_4D74_BC08_C373A22409C0__INCLUDED */
|
||||
|
|
Loading…
Reference in New Issue