ladishd: when saving xml, don't write the URI_A2J_PORT dict keys

URI_A2J_PORT is set on jack port appear
This commit is contained in:
Nedko Arnaudov 2010-12-30 02:17:48 +02:00
parent 6cb1de6104
commit f1d0a2e20b
3 changed files with 64 additions and 7 deletions

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 the implementation of the dictionary objects
@ -197,3 +197,27 @@ bool ladish_dict_is_empty(ladish_dict_handle dict_handle)
}
#undef dict_ptr
static bool dup_key(void * context, const char * key, const char * value)
{
return ladish_dict_set(context, key, value);
}
bool ladish_dict_dup(ladish_dict_handle src, ladish_dict_handle * dst_ptr)
{
ladish_dict_handle dst;
if (!ladish_dict_create(&dst))
{
return false;
}
if (!ladish_dict_iterate(src, dst, dup_key))
{
ladish_dict_destroy(dst);
return false;
}
*dst_ptr = dst;
return true;
}

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 the interface of the dictionary objects
@ -32,6 +32,7 @@
typedef struct ladish_dict_tag { int unused; } * ladish_dict_handle;
bool ladish_dict_create(ladish_dict_handle * dict_handle_ptr);
bool ladish_dict_dup(ladish_dict_handle src_dict_handle, ladish_dict_handle * dst_dict_handle_ptr);
void ladish_dict_destroy(ladish_dict_handle dict_handle);
bool ladish_dict_set(ladish_dict_handle dict_handle, const char * key, const char * value);
const char * ladish_dict_get(ladish_dict_handle dict_handle, const char * key);

View File

@ -287,10 +287,31 @@ ladish_write_room_port(
bool ladish_write_dict(int fd, int indent, ladish_dict_handle dict)
{
struct ladish_write_context context;
ladish_dict_handle dict_dup;
bool ret;
if (ladish_dict_get(dict, URI_A2J_PORT) != NULL)
{
if (!ladish_dict_dup(dict, &dict_dup))
{
log_error("ladish_dict_dup() failed");
dict_dup = NULL;
}
else
{
ladish_dict_drop(dict_dup, URI_A2J_PORT);
dict = dict_dup;
}
}
else
{
dict_dup = NULL;
}
if (ladish_dict_is_empty(dict))
{
return true;
ret = true;
goto dup_destroy;
}
context.fd = fd;
@ -298,20 +319,31 @@ bool ladish_write_dict(int fd, int indent, ladish_dict_handle dict)
if (!ladish_write_indented_string(fd, indent, "<dict>\n"))
{
return false;
ret = false;
goto dup_destroy;
}
if (!ladish_dict_iterate(dict, &context, write_dict_entry))
{
return false;
ret = false;
goto dup_destroy;
}
if (!ladish_write_indented_string(fd, indent, "</dict>\n"))
{
return false;
ret = false;
goto dup_destroy;
}
return true;
ret = true;
dup_destroy:
if (dict_dup != NULL)
{
ladish_dict_destroy(dict_dup);
}
return ret;
}
bool ladish_write_room_link_ports(int fd, int indent, ladish_room_handle room)