mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Clean up the xml file some by dropping empty kvp strings/frames and
'false' placeholder values. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13788 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ff513a4fcc
commit
c29ce7478d
@ -1,3 +1,11 @@
|
|||||||
|
2006-04-15 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
|
* src/backend/file/io-gncxml-v2.c:
|
||||||
|
* src/import-export/hbci/gnc-hbci-kvp.[ch]:
|
||||||
|
* src/engine/Account.c:
|
||||||
|
* src/engine/Scrub.[ch]: Clean up the xml file some by dropping
|
||||||
|
empty kvp strings/frames and 'false' placeholder values.
|
||||||
|
|
||||||
2006-04-15 Andreas Köhler <andi5.py@gmx.net>
|
2006-04-15 Andreas Köhler <andi5.py@gmx.net>
|
||||||
|
|
||||||
* src/gnome-utils/druid-gnc-xml-import.c: Fix to compile on
|
* src/gnome-utils/druid-gnc-xml-import.c: Fix to compile on
|
||||||
|
@ -172,6 +172,7 @@ add_account_local(sixtp_gdv2 *data, Account *act)
|
|||||||
xaccAccountSetCommoditySCU);
|
xaccAccountSetCommoditySCU);
|
||||||
|
|
||||||
xaccAccountScrubCommodity (act);
|
xaccAccountScrubCommodity (act);
|
||||||
|
xaccAccountScrubKvp (act);
|
||||||
|
|
||||||
if(!xaccAccountGetParent(act))
|
if(!xaccAccountGetParent(act))
|
||||||
{
|
{
|
||||||
|
@ -1102,11 +1102,17 @@ qofAccountSetParent (Account *acc, QofEntity *parent)
|
|||||||
void
|
void
|
||||||
xaccAccountSetNotes (Account *acc, const char *str)
|
xaccAccountSetNotes (Account *acc, const char *str)
|
||||||
{
|
{
|
||||||
if (!acc || !str) return;
|
if (!acc) return;
|
||||||
|
|
||||||
xaccAccountBeginEdit(acc);
|
xaccAccountBeginEdit(acc);
|
||||||
|
if (str) {
|
||||||
|
gchar *tmp = g_strstrip(g_strdup(str));
|
||||||
kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes",
|
kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes",
|
||||||
kvp_value_new_string(str));
|
strlen(tmp) ? kvp_value_new_string(tmp) : NULL);
|
||||||
|
g_free(tmp);
|
||||||
|
} else {
|
||||||
|
kvp_frame_set_slot_nc(acc->inst.kvp_data, "notes", NULL);
|
||||||
|
}
|
||||||
mark_account(acc);
|
mark_account(acc);
|
||||||
xaccAccountCommitEdit(acc);
|
xaccAccountCommitEdit(acc);
|
||||||
}
|
}
|
||||||
@ -1932,7 +1938,7 @@ xaccAccountSetPlaceholder (Account *acc, gboolean val)
|
|||||||
|
|
||||||
xaccAccountBeginEdit (acc);
|
xaccAccountBeginEdit (acc);
|
||||||
kvp_frame_set_string (acc->inst.kvp_data,
|
kvp_frame_set_string (acc->inst.kvp_data,
|
||||||
"placeholder", val ? "true" : "false");
|
"placeholder", val ? "true" : NULL);
|
||||||
mark_account (acc);
|
mark_account (acc);
|
||||||
xaccAccountCommitEdit (acc);
|
xaccAccountCommitEdit (acc);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
* Created by Linas Vepstas December 1998
|
* Created by Linas Vepstas December 1998
|
||||||
* Copyright (c) 1998-2000, 2003 Linas Vepstas <linas@linas.org>
|
* Copyright (c) 1998-2000, 2003 Linas Vepstas <linas@linas.org>
|
||||||
* Copyright (c) 2002 Christian Stimming
|
* Copyright (c) 2002 Christian Stimming
|
||||||
|
* Copyright (c) 2006 David Hampton
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -845,6 +846,35 @@ xaccGroupScrubQuoteSources (AccountGroup *group, gnc_commodity_table *table)
|
|||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccAccountScrubKvp (Account *account)
|
||||||
|
{
|
||||||
|
const gchar *str;
|
||||||
|
gchar *str2;
|
||||||
|
kvp_frame *frame;
|
||||||
|
|
||||||
|
if (!account) return;
|
||||||
|
|
||||||
|
str = kvp_frame_get_string(account->inst.kvp_data, "notes");
|
||||||
|
if (str) {
|
||||||
|
str2 = g_strstrip(g_strdup(str));
|
||||||
|
if (strlen(str2) == 0)
|
||||||
|
kvp_frame_set_slot_nc (account->inst.kvp_data, "notes", NULL);
|
||||||
|
g_free(str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = kvp_frame_get_string(account->inst.kvp_data, "placeholder");
|
||||||
|
if (str && strcmp(str, "false") == 0)
|
||||||
|
kvp_frame_set_slot_nc (account->inst.kvp_data, "placeholder", NULL);
|
||||||
|
|
||||||
|
frame = kvp_frame_get_frame(account->inst.kvp_data, "hbci");
|
||||||
|
if (frame && kvp_frame_is_empty(frame)) {
|
||||||
|
kvp_frame_set_frame_nc(account->inst.kvp_data, "hbci", NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================================ */
|
||||||
|
|
||||||
Account *
|
Account *
|
||||||
xaccScrubUtilityGetOrMakeAccount (AccountGroup *root, gnc_commodity * currency,
|
xaccScrubUtilityGetOrMakeAccount (AccountGroup *root, gnc_commodity * currency,
|
||||||
const char *name_root)
|
const char *name_root)
|
||||||
|
@ -156,6 +156,8 @@ void xaccGroupScrubCommodities (AccountGroup *group);
|
|||||||
*/
|
*/
|
||||||
void xaccGroupScrubQuoteSources (AccountGroup *group, gnc_commodity_table *table);
|
void xaccGroupScrubQuoteSources (AccountGroup *group, gnc_commodity_table *table);
|
||||||
|
|
||||||
|
void xaccAccountScrubKvp (Account *account);
|
||||||
|
|
||||||
#endif /* XACC_SCRUB_H */
|
#endif /* XACC_SCRUB_H */
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -42,25 +42,25 @@ static void force_account_dirty(Account *acct)
|
|||||||
/* Account */
|
/* Account */
|
||||||
char *gnc_hbci_get_account_accountid (Account *a)
|
char *gnc_hbci_get_account_accountid (Account *a)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNT_ID);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNT_ID);
|
||||||
return kvp_value_get_string (value);
|
return kvp_value_get_string (value);
|
||||||
}
|
}
|
||||||
char *gnc_hbci_get_account_bankcode (Account *a)
|
char *gnc_hbci_get_account_bankcode (Account *a)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_BANK_CODE);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_BANK_CODE);
|
||||||
return kvp_value_get_string (value);
|
return kvp_value_get_string (value);
|
||||||
}
|
}
|
||||||
gint gnc_hbci_get_account_countrycode (Account *a)
|
gint gnc_hbci_get_account_countrycode (Account *a)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_COUNTRY_CODE);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_COUNTRY_CODE);
|
||||||
return kvp_value_get_gint64 (value);
|
return kvp_value_get_gint64 (value);
|
||||||
}
|
}
|
||||||
void gnc_hbci_set_account_accountid (Account *a, const char *id)
|
void gnc_hbci_set_account_accountid (Account *a, const char *id)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, TRUE);
|
||||||
kvp_value *value = kvp_value_new_string (id);
|
kvp_value *value = kvp_value_new_string (id);
|
||||||
xaccAccountBeginEdit(a);
|
xaccAccountBeginEdit(a);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_ID, value);
|
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_ID, value);
|
||||||
@ -69,7 +69,7 @@ void gnc_hbci_set_account_accountid (Account *a, const char *id)
|
|||||||
}
|
}
|
||||||
void gnc_hbci_set_account_bankcode (Account *a, const char *code)
|
void gnc_hbci_set_account_bankcode (Account *a, const char *code)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, TRUE);
|
||||||
kvp_value *value = kvp_value_new_string (code);
|
kvp_value *value = kvp_value_new_string (code);
|
||||||
xaccAccountBeginEdit (a);
|
xaccAccountBeginEdit (a);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_BANK_CODE, value);
|
kvp_frame_set_slot_nc (frame, HBCI_BANK_CODE, value);
|
||||||
@ -78,7 +78,7 @@ void gnc_hbci_set_account_bankcode (Account *a, const char *code)
|
|||||||
}
|
}
|
||||||
void gnc_hbci_set_account_countrycode (Account *a, gint code)
|
void gnc_hbci_set_account_countrycode (Account *a, gint code)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, TRUE);
|
||||||
kvp_value *value = kvp_value_new_gint64 (code);
|
kvp_value *value = kvp_value_new_gint64 (code);
|
||||||
xaccAccountBeginEdit (a);
|
xaccAccountBeginEdit (a);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_COUNTRY_CODE, value);
|
kvp_frame_set_slot_nc (frame, HBCI_COUNTRY_CODE, value);
|
||||||
@ -87,13 +87,13 @@ void gnc_hbci_set_account_countrycode (Account *a, gint code)
|
|||||||
}
|
}
|
||||||
gint gnc_hbci_get_account_uid (Account *a)
|
gint gnc_hbci_get_account_uid (Account *a)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNT_UID);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNT_UID);
|
||||||
return kvp_value_get_gint64 (value);
|
return kvp_value_get_gint64 (value);
|
||||||
}
|
}
|
||||||
void gnc_hbci_set_account_uid (Account *a, gint uid)
|
void gnc_hbci_set_account_uid (Account *a, gint uid)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, TRUE);
|
||||||
kvp_value *value = kvp_value_new_gint64 (uid);
|
kvp_value *value = kvp_value_new_gint64 (uid);
|
||||||
xaccAccountBeginEdit (a);
|
xaccAccountBeginEdit (a);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_UID, value);
|
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_UID, value);
|
||||||
@ -102,13 +102,13 @@ void gnc_hbci_set_account_uid (Account *a, gint uid)
|
|||||||
}
|
}
|
||||||
Timespec gnc_hbci_get_account_trans_retrieval (Account *a)
|
Timespec gnc_hbci_get_account_trans_retrieval (Account *a)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TRANS_RETRIEVAL);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TRANS_RETRIEVAL);
|
||||||
return kvp_value_get_timespec (value);
|
return kvp_value_get_timespec (value);
|
||||||
}
|
}
|
||||||
void gnc_hbci_set_account_trans_retrieval (Account *a, Timespec time)
|
void gnc_hbci_set_account_trans_retrieval (Account *a, Timespec time)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_account_kvp (a);
|
kvp_frame *frame = gnc_hbci_get_account_kvp (a, TRUE);
|
||||||
kvp_value *value = kvp_value_new_timespec (time);
|
kvp_value *value = kvp_value_new_timespec (time);
|
||||||
xaccAccountBeginEdit (a);
|
xaccAccountBeginEdit (a);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_TRANS_RETRIEVAL, value);
|
kvp_frame_set_slot_nc (frame, HBCI_TRANS_RETRIEVAL, value);
|
||||||
@ -124,26 +124,26 @@ void gnc_hbci_set_account_trans_retrieval (Account *a, Timespec time)
|
|||||||
|
|
||||||
char *gnc_hbci_get_book_configfile (GNCBook *b)
|
char *gnc_hbci_get_book_configfile (GNCBook *b)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
kvp_frame *frame = gnc_hbci_get_book_kvp (b, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_CONFIGFILE);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_CONFIGFILE);
|
||||||
return kvp_value_get_string (value);
|
return kvp_value_get_string (value);
|
||||||
}
|
}
|
||||||
void gnc_hbci_set_book_configfile (GNCBook *b, const char *filename)
|
void gnc_hbci_set_book_configfile (GNCBook *b, const char *filename)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
kvp_frame *frame = gnc_hbci_get_book_kvp (b, TRUE);
|
||||||
kvp_value *value = kvp_value_new_string (filename);
|
kvp_value *value = kvp_value_new_string (filename);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_CONFIGFILE, value);
|
kvp_frame_set_slot_nc (frame, HBCI_CONFIGFILE, value);
|
||||||
qof_book_kvp_changed (b);
|
qof_book_kvp_changed (b);
|
||||||
}
|
}
|
||||||
GList *gnc_hbci_get_book_template_list (GNCBook *b)
|
GList *gnc_hbci_get_book_template_list (GNCBook *b)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
kvp_frame *frame = gnc_hbci_get_book_kvp (b, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TEMPLATES);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_TEMPLATES);
|
||||||
return kvp_value_get_glist (value);
|
return kvp_value_get_glist (value);
|
||||||
}
|
}
|
||||||
void gnc_hbci_set_book_template_list (GNCBook *b, GList *template_list)
|
void gnc_hbci_set_book_template_list (GNCBook *b, GList *template_list)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
kvp_frame *frame = gnc_hbci_get_book_kvp (b, TRUE);
|
||||||
kvp_value *value = kvp_value_new_glist_nc (template_list);
|
kvp_value *value = kvp_value_new_glist_nc (template_list);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_TEMPLATES, value);
|
kvp_frame_set_slot_nc (frame, HBCI_TEMPLATES, value);
|
||||||
qof_book_kvp_changed (b);
|
qof_book_kvp_changed (b);
|
||||||
@ -152,13 +152,13 @@ void gnc_hbci_set_book_template_list (GNCBook *b, GList *template_list)
|
|||||||
#if 0
|
#if 0
|
||||||
GList *gnc_hbci_get_book_account_list (GNCBook *b)
|
GList *gnc_hbci_get_book_account_list (GNCBook *b)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
kvp_frame *frame = gnc_hbci_get_book_kvp (b, FALSE);
|
||||||
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNTS);
|
kvp_value *value = kvp_frame_get_slot (frame, HBCI_ACCOUNTS);
|
||||||
return kvp_value_get_glist (value);
|
return kvp_value_get_glist (value);
|
||||||
}
|
}
|
||||||
void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list)
|
void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list)
|
||||||
{
|
{
|
||||||
kvp_frame *frame = gnc_hbci_get_book_kvp (b);
|
kvp_frame *frame = gnc_hbci_get_book_kvp (b, TRUE);
|
||||||
kvp_value *value = kvp_value_new_glist_nc (account_list);
|
kvp_value *value = kvp_value_new_glist_nc (account_list);
|
||||||
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNTS, value);
|
kvp_frame_set_slot_nc (frame, HBCI_ACCOUNTS, value);
|
||||||
qof_book_kvp_changed (b);
|
qof_book_kvp_changed (b);
|
||||||
@ -168,11 +168,11 @@ void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list)
|
|||||||
|
|
||||||
/* lowlevel */
|
/* lowlevel */
|
||||||
/* getters for kvp frame in book */
|
/* getters for kvp frame in book */
|
||||||
kvp_frame *gnc_hbci_get_book_kvp (GNCBook *b)
|
kvp_frame *gnc_hbci_get_book_kvp (GNCBook *b, gboolean create)
|
||||||
{
|
{
|
||||||
kvp_frame *toplevel = qof_book_get_slots (b);
|
kvp_frame *toplevel = qof_book_get_slots (b);
|
||||||
kvp_frame *result = kvp_frame_get_frame (toplevel, HBCI_KEY);
|
kvp_frame *result = kvp_frame_get_frame (toplevel, HBCI_KEY);
|
||||||
if (!result) {
|
if (!result && create) {
|
||||||
result = kvp_frame_new();
|
result = kvp_frame_new();
|
||||||
kvp_frame_add_frame_nc (toplevel, HBCI_KEY, result);
|
kvp_frame_add_frame_nc (toplevel, HBCI_KEY, result);
|
||||||
}
|
}
|
||||||
@ -182,11 +182,11 @@ kvp_frame *gnc_hbci_get_book_kvp (GNCBook *b)
|
|||||||
|
|
||||||
|
|
||||||
/* kvp frame in Account */
|
/* kvp frame in Account */
|
||||||
kvp_frame *gnc_hbci_get_account_kvp (Account *a)
|
kvp_frame *gnc_hbci_get_account_kvp (Account *a, gboolean create)
|
||||||
{
|
{
|
||||||
kvp_frame *toplevel = xaccAccountGetSlots (a);
|
kvp_frame *toplevel = xaccAccountGetSlots (a);
|
||||||
kvp_frame *result = kvp_frame_get_frame (toplevel, HBCI_KEY);
|
kvp_frame *result = kvp_frame_get_frame (toplevel, HBCI_KEY);
|
||||||
if (!result) {
|
if (!result && create) {
|
||||||
result = kvp_frame_new();
|
result = kvp_frame_new();
|
||||||
kvp_frame_add_frame_nc (toplevel, HBCI_KEY, result);
|
kvp_frame_add_frame_nc (toplevel, HBCI_KEY, result);
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,13 @@ void gnc_hbci_set_book_account_list (GNCBook *b, GList *account_list);
|
|||||||
|
|
||||||
/* lowlevel */
|
/* lowlevel */
|
||||||
|
|
||||||
/* internal getter for kvp frame in book */
|
/* internal getter for kvp frame in book. The create argument says
|
||||||
kvp_frame *gnc_hbci_get_book_kvp (GNCBook *b);
|
* to create the frame if it doesn't already exist. */
|
||||||
|
kvp_frame *gnc_hbci_get_book_kvp (GNCBook *b, gboolean create);
|
||||||
|
|
||||||
/* internal getter for kvp frame in Account */
|
/* internal getter for kvp frame in Account. The create argument says
|
||||||
kvp_frame *gnc_hbci_get_account_kvp (Account *a);
|
* to create the frame if it doesn't already exist. */
|
||||||
|
kvp_frame *gnc_hbci_get_account_kvp (Account *a, gboolean create);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user