From f0e42a005f4086add2db3fc951f5ef516d64d579 Mon Sep 17 00:00:00 2001 From: Michalis Kamprianis Date: Thu, 24 Apr 2014 05:56:29 +0200 Subject: [PATCH] Bug 728841 - XML backend does not always store KVP slots add appropriate code for slot handling in the relevant subclasses modified: src/backend/xml/gnc-address-xml-v2.c modified: src/backend/xml/gnc-entry-xml-v2.c modified: src/backend/xml/gnc-job-xml-v2.c modified: src/backend/xml/gnc-order-xml-v2.c modified: src/backend/xml/gnc-tax-table-xml-v2.c --- src/backend/xml/gnc-address-xml-v2.c | 16 +++++++++++++++- src/backend/xml/gnc-entry-xml-v2.c | 16 +++++++++++++++- src/backend/xml/gnc-job-xml-v2.c | 16 +++++++++++++++- src/backend/xml/gnc-order-xml-v2.c | 16 +++++++++++++++- src/backend/xml/gnc-tax-table-xml-v2.c | 16 +++++++++++++++- 5 files changed, 75 insertions(+), 5 deletions(-) diff --git a/src/backend/xml/gnc-address-xml-v2.c b/src/backend/xml/gnc-address-xml-v2.c index bada2bfd97..2e84319840 100644 --- a/src/backend/xml/gnc-address-xml-v2.c +++ b/src/backend/xml/gnc-address-xml-v2.c @@ -69,6 +69,7 @@ xmlNodePtr gnc_address_to_dom_tree (const char *tag, GncAddress *addr) { xmlNodePtr ret; + kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST tag); xmlSetProp(ret, BAD_CAST "version", BAD_CAST address_version_string); @@ -84,6 +85,16 @@ gnc_address_to_dom_tree (const char *tag, GncAddress *addr) maybe_add_string (ret, addr_fax_string, gncAddressGetFax (addr)); maybe_add_string (ret, addr_email_string, gncAddressGetEmail (addr)); + kf = qof_instance_get_slots (QOF_INSTANCE(addr)); + if (kf) + { + xmlNodePtr kvpnode = kvp_frame_to_dom_tree(addr_slots_string, kf); + if (kvpnode) + { + xmlAddChild(ret, kvpnode); + } + } + return ret; } @@ -175,7 +186,10 @@ address_email_handler (xmlNodePtr node, gpointer addr_pdata) static gboolean address_slots_handler (xmlNodePtr node, gpointer addr_pdata) { - return TRUE; + struct address_pdata *pdata = addr_pdata; + + return dom_tree_to_kvp_frame_given + (node, xaccAccountGetSlots (pdata->address)); } static struct dom_tree_handler address_handlers_v2[] = diff --git a/src/backend/xml/gnc-entry-xml-v2.c b/src/backend/xml/gnc-entry-xml-v2.c index c7a414f640..713bef9b5a 100644 --- a/src/backend/xml/gnc-entry-xml-v2.c +++ b/src/backend/xml/gnc-entry-xml-v2.c @@ -115,6 +115,7 @@ entry_dom_tree_create (GncEntry *entry) GncTaxTable *taxtable; GncOrder *order; GncInvoice *invoice; + kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_entry_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST entry_version_string); @@ -211,6 +212,16 @@ entry_dom_tree_create (GncEntry *entry) xmlAddChild (ret, guid_to_dom_tree (entry_order_string, qof_instance_get_guid(QOF_INSTANCE (order)))); + kf = qof_instance_get_slots (QOF_INSTANCE(entry)); + if (kf) + { + xmlNodePtr kvpnode = kvp_frame_to_dom_tree(entry_slots_string, kf); + if (kvpnode) + { + xmlAddChild(ret, kvpnode); + } + } + return ret; } @@ -661,7 +672,10 @@ entry_price_handler (xmlNodePtr node, gpointer entry_pdata) static gboolean entry_slots_handler (xmlNodePtr node, gpointer entry_pdata) { - return TRUE; + struct entry_pdata *pdata = entry_pdata; + + return dom_tree_to_kvp_frame_given + (node, xaccAccountGetSlots (pdata->entry)); } static struct dom_tree_handler entry_handlers_v2[] = diff --git a/src/backend/xml/gnc-job-xml-v2.c b/src/backend/xml/gnc-job-xml-v2.c index d4a5e8fc0b..1ed84df01d 100644 --- a/src/backend/xml/gnc-job-xml-v2.c +++ b/src/backend/xml/gnc-job-xml-v2.c @@ -66,6 +66,7 @@ static xmlNodePtr job_dom_tree_create (GncJob *job) { xmlNodePtr ret; + kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_job_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST job_version_string); @@ -87,6 +88,16 @@ job_dom_tree_create (GncJob *job) xmlAddChild(ret, int_to_dom_tree(job_active_string, gncJobGetActive (job))); + kf = qof_instance_get_slots (QOF_INSTANCE(job)); + if (kf) + { + xmlNodePtr kvpnode = kvp_frame_to_dom_tree(job_slots_string, kf); + if (kvpnode) + { + xmlAddChild(ret, kvpnode); + } + } + return ret; } @@ -193,7 +204,10 @@ job_active_handler (xmlNodePtr node, gpointer job_pdata) static gboolean job_slots_handler (xmlNodePtr node, gpointer job_pdata) { - return TRUE; + struct job_pdata *pdata = job_pdata; + + return dom_tree_to_kvp_frame_given + (node, xaccAccountGetSlots (pdata->job)); } static struct dom_tree_handler job_handlers_v2[] = diff --git a/src/backend/xml/gnc-order-xml-v2.c b/src/backend/xml/gnc-order-xml-v2.c index 7b584152b1..c393182ac5 100644 --- a/src/backend/xml/gnc-order-xml-v2.c +++ b/src/backend/xml/gnc-order-xml-v2.c @@ -76,6 +76,7 @@ order_dom_tree_create (GncOrder *order) { xmlNodePtr ret; Timespec ts; + kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_order_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST order_version_string); @@ -102,6 +103,16 @@ order_dom_tree_create (GncOrder *order) xmlAddChild(ret, int_to_dom_tree(order_active_string, gncOrderGetActive (order))); + kf = qof_instance_get_slots (QOF_INSTANCE(order)); + if (kf) + { + xmlNodePtr kvpnode = kvp_frame_to_dom_tree(order_slots_string, kf); + if (kvpnode) + { + xmlAddChild(ret, kvpnode); + } + } + return ret; } @@ -234,7 +245,10 @@ order_active_handler (xmlNodePtr node, gpointer order_pdata) static gboolean order_slots_handler (xmlNodePtr node, gpointer order_pdata) { - return TRUE; + struct order_pdata *pdata = order_pdata; + + return dom_tree_to_kvp_frame_given + (node, xaccAccountGetSlots (pdata->order)); } static struct dom_tree_handler order_handlers_v2[] = diff --git a/src/backend/xml/gnc-tax-table-xml-v2.c b/src/backend/xml/gnc-tax-table-xml-v2.c index 31b4538cce..aeff7818b5 100644 --- a/src/backend/xml/gnc-tax-table-xml-v2.c +++ b/src/backend/xml/gnc-tax-table-xml-v2.c @@ -104,6 +104,7 @@ taxtable_dom_tree_create (GncTaxTable *table) { xmlNodePtr ret, entries; GList *list; + kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_taxtable_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST taxtable_version_string); @@ -130,6 +131,16 @@ taxtable_dom_tree_create (GncTaxTable *table) xmlAddChild(entries, ttentry_dom_tree_create (entry)); } + kf = qof_instance_get_slots (QOF_INSTANCE(table)); + if (kf) + { + xmlNodePtr kvpnode = kvp_frame_to_dom_tree(taxtable_slots_string, kf); + if (kvpnode) + { + xmlAddChild(ret, kvpnode); + } + } + return ret; } @@ -368,7 +379,10 @@ taxtable_entries_handler (xmlNodePtr node, gpointer taxtable_pdata) static gboolean taxtable_slots_handler (xmlNodePtr node, gpointer taxtable_pdata) { - return TRUE; + struct taxtable_pdata *pdata = taxtable_pdata; + + return dom_tree_to_kvp_frame_given + (node, xaccAccountGetSlots (pdata->table)); } static struct dom_tree_handler taxtable_handlers_v2[] =