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
This commit is contained in:
Michalis Kamprianis 2014-04-24 05:56:29 +02:00 committed by Geert Janssens
parent 25256c1ba7
commit f0e42a005f
5 changed files with 75 additions and 5 deletions

View File

@ -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[] =

View File

@ -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[] =

View File

@ -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[] =

View File

@ -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[] =

View File

@ -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[] =