X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fhb-account.c;h=2ecbb6f93c5aa42ba6a1f14b5d8eff39c458328e;hb=0e1e5f856e9ab5faa63fd822354781baccccbcd9;hp=b6888c9144f2838ca7f9eb1886d3f6643511fa53;hpb=236cb5e47660876f46488ea8f76ecd5bebfa1fac;p=chaz%2Fhomebank diff --git a/src/hb-account.c b/src/hb-account.c index b6888c9..2ecbb6f 100644 --- a/src/hb-account.c +++ b/src/hb-account.c @@ -20,6 +20,9 @@ #include "homebank.h" #include "hb-account.h" +#include "ext.h" +#include "refcount.h" + /****************************************************************************/ /* Debug macros */ /****************************************************************************/ @@ -39,7 +42,7 @@ void da_acc_free(Account *item) { DB( g_print("da_acc_free\n") ); - if(item != NULL) + if(rc_unref(item)) { DB( g_print(" => %d, %s\n", item->key, item->name) ); @@ -47,10 +50,10 @@ da_acc_free(Account *item) g_free(item->number); g_free(item->bankname); g_free(item->notes); - + g_queue_free (item->txn_queue); - - g_free(item); + + rc_free(item); } } @@ -61,7 +64,7 @@ da_acc_malloc(void) Account *item; DB( g_print("da_acc_malloc\n") ); - item = g_malloc0(sizeof(Account)); + item = rc_alloc(sizeof(Account)); item->kcur = GLOBALS->kcur; item->txn_queue = g_queue_new (); return item; @@ -158,6 +161,9 @@ guint32 *new_key; *new_key = item->key; g_hash_table_insert(GLOBALS->h_acc, new_key, item); + GValue item_val = G_VALUE_INIT; + ext_hook("account_inserted", EXT_ACCOUNT(&item_val, item), NULL); + return TRUE; } @@ -183,6 +189,10 @@ Account *existitem; item->key = da_acc_get_max_key() + 1; item->pos = da_acc_length() + 1; da_acc_insert(item); + + GValue item_val = G_VALUE_INIT; + ext_hook("account_inserted", EXT_ACCOUNT(&item_val, item), NULL); + return TRUE; } @@ -228,7 +238,7 @@ gchar *stripname; g_free(stripname); } - return retval; + return retval; } @@ -345,14 +355,14 @@ gboolean retval; while (lnk_acc != NULL) { Account *acc = lnk_acc->data; - + if(acc->key != key) { lnk_txn = g_queue_peek_head_link(acc->txn_queue); while (lnk_txn != NULL) { Transaction *entry = lnk_txn->data; - + if( key == entry->kxferacc) { retval = TRUE; @@ -427,12 +437,12 @@ gchar *stripname = account_get_stripname(newname); g_free(stripname); } - + return FALSE; } -/* +/* * change the account currency * change every txn to currency * ensure dst xfer transaction account will be set to same currency @@ -473,7 +483,7 @@ guint32 maxkey, i; acc->kcur = kcur; DB( g_print(" - '%s'\n", acc->name) ); - + for(i=1;idata; - + /* set initial amount */ acc->bal_bank = acc->initial; acc->bal_today = acc->initial; acc->bal_future = acc->initial; - + /* add every txn */ lnk_txn = g_queue_peek_head_link(acc->txn_queue); while (lnk_txn != NULL) { Transaction *txn = lnk_txn->data; - + if(!(txn->status == TXN_STATUS_REMIND)) { account_balances_add_internal(acc, txn); } lnk_txn = g_list_next(lnk_txn); } - + lnk_acc = g_list_next(lnk_acc); } g_list_free(lst_acc);