From f1d0a2e20b97a88874e4bd06607e5f98f4e77124 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Thu, 30 Dec 2010 02:17:48 +0200 Subject: [PATCH] ladishd: when saving xml, don't write the URI_A2J_PORT dict keys URI_A2J_PORT is set on jack port appear --- daemon/dict.c | 26 +++++++++++++++++++++++++- daemon/dict.h | 3 ++- daemon/save.c | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/daemon/dict.c b/daemon/dict.c index 99114229..ce45a070 100644 --- a/daemon/dict.c +++ b/daemon/dict.c @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009 Nedko Arnaudov + * Copyright (C) 2009, 2010 Nedko Arnaudov * ************************************************************************** * 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; +} diff --git a/daemon/dict.h b/daemon/dict.h index 4a54d00e..55583e44 100644 --- a/daemon/dict.h +++ b/daemon/dict.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009 Nedko Arnaudov + * Copyright (C) 2009, 2010 Nedko Arnaudov * ************************************************************************** * 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); diff --git a/daemon/save.c b/daemon/save.c index 8bc7136a..9b53dc18 100644 --- a/daemon/save.c +++ b/daemon/save.c @@ -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, "\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, "\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)