mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2004-01-31 Christian Stimming <stimming@tuhh.de>
* src/import-export/import-backend.c: Commented out setting the memo always to "Auto-created split" due to popular request. * src/import-export/hbci/druid-hbci-initial.c, hbci-interaction.c, all files: Preliminary completion of openhbci2 support -- getting the transactions seems to work, as well as the HBCI setup. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9817 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7e4b6dba4a
commit
a925e484ff
@ -1,5 +1,12 @@
|
||||
2004-01-31 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/import-backend.c: Commented out setting the
|
||||
memo always to "Auto-created split" due to popular request.
|
||||
|
||||
* src/import-export/hbci/druid-hbci-initial.c, hbci-interaction.c,
|
||||
all files: Preliminary completion of openhbci2 support -- getting
|
||||
the transactions seems to work, as well as the HBCI setup.
|
||||
|
||||
* src/engine/kvp_frame.h, src/engine/Account.c: Add clear notice
|
||||
of the semantic change of kvp_frame_get_frame
|
||||
function. Fortunately it seems the only place that still had to be
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
#include <openhbci2.h>
|
||||
|
||||
#define DEFAULT_HBCI_VERSION 201
|
||||
|
||||
typedef enum _infostate {
|
||||
INI_ADD_BANK,
|
||||
INI_ADD_USER,
|
||||
@ -189,15 +191,10 @@ delete_initial_druid (HBCIInitialInfo *info)
|
||||
if (info->interactor)
|
||||
GNCInteractor_delete(info->interactor);
|
||||
|
||||
printf("delete_initial_druid: FIXME: gnucash will crash here in a call to gnome_entry_destroy(), probably related to the configfileentry object.\n");
|
||||
|
||||
if (info->window != NULL)
|
||||
gtk_widget_destroy (info->window);
|
||||
|
||||
printf("delete_initial_druid: FIXME: this is not reached \n");
|
||||
|
||||
g_free (info);
|
||||
printf("delete_initial_druid: 4\n");
|
||||
}
|
||||
|
||||
|
||||
@ -217,12 +214,7 @@ update_accountlist_acc_cb (gnc_HBCI_Account *hacc, gpointer user_data)
|
||||
g_assert(info);
|
||||
row_text[2] = "";
|
||||
|
||||
row_text[0] =
|
||||
/* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
|
||||
g_strdup_printf(_("%s at %s (code %s)"),
|
||||
gnc_HBCI_Account_accountId (hacc),
|
||||
HBCI_Bank_name (gnc_HBCI_Account_bank (hacc)),
|
||||
HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hacc)));
|
||||
row_text[0] = gnc_HBCI_Account_longname(hacc);
|
||||
|
||||
/* Get corresponding gnucash account */
|
||||
gacc = g_hash_table_lookup (info->gnc_hash, hacc);
|
||||
@ -282,8 +274,8 @@ update_accountlist (HBCIInitialInfo *info)
|
||||
update_accountlist_acc_cb,
|
||||
info);
|
||||
|
||||
/*printf("HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash));*/
|
||||
/*printf("GNC hash has %d entries.\n", g_hash_table_size(info->gnc_hash));*/
|
||||
//printf("update_accountlist: HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash));
|
||||
//printf("update_accountlist: GNC hash has %d entries.\n", g_hash_table_size(info->gnc_hash));
|
||||
|
||||
g_hash_table_thaw (info->hbci_hash);
|
||||
gtk_clist_thaw (GTK_CLIST (info->accountlist));
|
||||
@ -560,21 +552,22 @@ static void gnc_hbci_addaccount(HBCIInitialInfo *info,
|
||||
|
||||
if ((retval == 0) && accnr && (strlen(accnr) > 0)) {
|
||||
|
||||
/* Create the wrapper object */
|
||||
acc = gnc_HBCI_Account_new(bank, HBCI_Bank_bankCode (bank), accnr);
|
||||
/* Search for existing duplicate */
|
||||
acc = list_HBCI_Account_find(info->hbci_accountlist,
|
||||
bank, HBCI_Bank_bankCode (bank), accnr);
|
||||
|
||||
/* Check if such an account already exists */
|
||||
if (list_HBCI_Account_foreach(info->hbci_accountlist, hbci_find_acc_cb, acc))
|
||||
if (acc)
|
||||
{
|
||||
/* Yes, then don't create it again */
|
||||
gnc_HBCI_Account_delete(acc);
|
||||
gnc_error_dialog
|
||||
(info->window,
|
||||
_("An account with this account id at this bank already exists."));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No, then add it to our internal list. */
|
||||
/* No, then create it and add it to our internal list. */
|
||||
acc = gnc_HBCI_Account_new (bank, HBCI_Bank_bankCode (bank), accnr);
|
||||
info->hbci_accountlist = g_list_append(info->hbci_accountlist, acc);
|
||||
|
||||
/* Don't forget to update the account list, otherwise the new
|
||||
@ -589,17 +582,6 @@ static void gnc_hbci_addaccount(HBCIInitialInfo *info,
|
||||
}
|
||||
/* -------------------------------------- */
|
||||
|
||||
void *hbci_find_acc_cb(gnc_HBCI_Account *acc, void *user_data)
|
||||
{
|
||||
gnc_HBCI_Account *new_acc = user_data;
|
||||
if (gnc_HBCI_Account_bank(acc) == gnc_HBCI_Account_bank(new_acc))
|
||||
if (strcmp(gnc_HBCI_Account_accountId(acc),
|
||||
gnc_HBCI_Account_accountId(new_acc))==0)
|
||||
return acc;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************
|
||||
@ -822,6 +804,22 @@ on_bankpage_next (GnomeDruidPage *gnomedruidpage,
|
||||
"");
|
||||
{
|
||||
HBCI_Error *err;
|
||||
HBCI_Transporter *tr;
|
||||
HBCI_MessageEngine *me;
|
||||
|
||||
me = HBCI_API_engineFactory(info->api,
|
||||
countrycode,
|
||||
bankcode,
|
||||
DEFAULT_HBCI_VERSION,
|
||||
"msgxml");
|
||||
tr = HBCI_API_transporterFactory(info->api,
|
||||
ipaddr,
|
||||
"3000" /* DEFAULT_PORT */,
|
||||
500 /*AQMONEY_DEFAULT_CONN_TIMEOUT*/,
|
||||
"xptcp");
|
||||
HBCI_Bank_setMessageEngine(bank, me, TRUE);
|
||||
HBCI_Bank_setTransporter(bank, tr, TRUE);
|
||||
|
||||
err = HBCI_API_addBank (info->api, bank, TRUE);
|
||||
if (err != NULL) {
|
||||
printf("on_bankpage_next-CRITICAL: Error at addBank: %s.\n",
|
||||
@ -829,6 +827,7 @@ on_bankpage_next (GnomeDruidPage *gnomedruidpage,
|
||||
HBCI_Error_delete (err);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*else {
|
||||
@ -1133,7 +1132,7 @@ on_accountinfo_next (GnomeDruidPage *gnomedruidpage,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Now evaluate the GetAccounts job. FIXME: needs more work */
|
||||
/* Now evaluate the GetAccounts job. */
|
||||
info->hbci_accountlist =
|
||||
gnc_processOutboxResponse(info->api, info->outbox, info->hbci_accountlist);
|
||||
|
||||
@ -1190,13 +1189,28 @@ on_accountlist_select_row (GtkCList *clist, gint row,
|
||||
HBCIInitialInfo *info = user_data;
|
||||
gnc_HBCI_Account *hbci_acc;
|
||||
Account *gnc_acc, *old_value;
|
||||
gchar *longname;
|
||||
gnc_commodity *currency = NULL;
|
||||
|
||||
hbci_acc = g_hash_table_lookup (info->hbci_hash, &row);
|
||||
if (hbci_acc) {
|
||||
old_value = g_hash_table_lookup (info->gnc_hash, hbci_acc);
|
||||
|
||||
gnc_acc = gnc_import_select_account(NULL, FALSE, NULL, NULL, NO_TYPE,
|
||||
/*printf("on_accountlist_select_row: Selected hbci_acc id %s; old_value %p \n",
|
||||
gnc_HBCI_Account_accountId(hbci_acc),
|
||||
old_value);*/
|
||||
|
||||
longname = gnc_HBCI_Account_longname(hbci_acc);
|
||||
if (gnc_HBCI_Account_currency(hbci_acc) &&
|
||||
(strlen(gnc_HBCI_Account_currency(hbci_acc)) > 0)) {
|
||||
currency = gnc_commodity_table_lookup
|
||||
(gnc_book_get_commodity_table (gnc_get_current_book ()),
|
||||
GNC_COMMODITY_NS_ISO, gnc_HBCI_Account_currency(hbci_acc));
|
||||
}
|
||||
|
||||
gnc_acc = gnc_import_select_account(NULL, TRUE, longname, currency, BANK,
|
||||
old_value, NULL);
|
||||
g_free(longname);
|
||||
|
||||
if (gnc_acc) {
|
||||
if (old_value)
|
||||
|
@ -79,12 +79,30 @@ accounts_save_kvp_cb (gpointer key, gpointer value, gpointer user_data)
|
||||
(gnc_acc, HBCI_Bank_country (gnc_HBCI_Account_bank (hbci_acc)));
|
||||
}
|
||||
|
||||
static gpointer accounts_clear_kvp (Account *gnc_acc, gpointer user_data)
|
||||
{
|
||||
if (gnc_hbci_get_account_accountid(gnc_acc))
|
||||
gnc_hbci_set_account_accountid (gnc_acc, NULL);
|
||||
if (gnc_hbci_get_account_bankcode(gnc_acc))
|
||||
gnc_hbci_set_account_bankcode (gnc_acc, NULL);
|
||||
if (gnc_hbci_get_account_countrycode(gnc_acc))
|
||||
gnc_hbci_set_account_countrycode (gnc_acc, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* hash is a DIRECT hash from each HBCI account to each gnucash
|
||||
account. */
|
||||
void
|
||||
accounts_save_kvp (GHashTable *hash)
|
||||
{
|
||||
AccountGroup *grp;
|
||||
g_assert(hash);
|
||||
|
||||
grp = gnc_book_get_group (gnc_get_current_book ());
|
||||
xaccGroupForEachAccount (grp,
|
||||
&accounts_clear_kvp,
|
||||
NULL, TRUE);
|
||||
|
||||
g_hash_table_foreach (hash, &accounts_save_kvp_cb, NULL);
|
||||
}
|
||||
/*
|
||||
@ -290,8 +308,10 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
|
||||
const char *accountSubId;
|
||||
const char *bankCode;
|
||||
int country;
|
||||
gnc_HBCI_Account *acc;
|
||||
const char *custid;
|
||||
const char *currency;
|
||||
const char *acc_name;
|
||||
const char *acc_name1;
|
||||
/*list_HBCI_Customer *customers;*/
|
||||
/*HBCI_User *user;*/
|
||||
HBCI_Bank *bank;
|
||||
@ -306,6 +326,10 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
|
||||
continue;
|
||||
}
|
||||
|
||||
currency = GWEN_DB_GetCharValue(n, "currency", 0, NULL);
|
||||
acc_name = GWEN_DB_GetCharValue(n, "name", 0, NULL);
|
||||
acc_name1 = GWEN_DB_GetCharValue(n, "name1", 0, NULL);
|
||||
|
||||
bank = HBCI_API_findBank(api, country, bankCode);
|
||||
if (bank) {
|
||||
/* bank uses a different bank code for the accounts, so find
|
||||
@ -335,46 +359,31 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
|
||||
bank=user.ref().bank();*/
|
||||
}
|
||||
|
||||
/* Create new account object */
|
||||
/* FIXME: Store more information here. For now, we stop with
|
||||
this essential information. */
|
||||
acc = gnc_HBCI_Account_new(bank, bankCode, accountId);
|
||||
|
||||
{
|
||||
/* Check if such an account already exists */
|
||||
gnc_HBCI_Account *found_account =
|
||||
list_HBCI_Account_foreach(accountlist, hbci_find_acc_cb, acc);
|
||||
|
||||
if (found_account) {
|
||||
const char *p;
|
||||
gnc_HBCI_Account *acc =
|
||||
list_HBCI_Account_find(accountlist, bank, bankCode, accountId);
|
||||
|
||||
if (acc) {
|
||||
/* Update account information */
|
||||
printf("Account %d/%s/%s already exists, updating.\n",
|
||||
printf("gnc_processOutboxResponse: Account %d/%s/%s already exists, updating.\n",
|
||||
country, bankCode, accountId);
|
||||
|
||||
p=GWEN_DB_GetCharValue(n, "name", 0, 0);
|
||||
/*if (p)
|
||||
gnc_HBCI_Account_setAccountName(found_account,p);
|
||||
p=GWEN_DB_GetCharValue(n, "customer", 0, 0);
|
||||
if (p)
|
||||
gnc_HBCI_Account_setCustomer(found_account,p);
|
||||
p=GWEN_DB_GetCharValue(n, "currency", 0, 0);
|
||||
if (p)
|
||||
gnc_HBCI_Account_setCurrency(found_account,p);
|
||||
p=GWEN_DB_GetCharValue(n, "name1", 0, 0);
|
||||
if (p)
|
||||
gnc_HBCI_Account_setUserName(found_account,p);*/
|
||||
gnc_HBCI_Account_delete(acc);
|
||||
}
|
||||
else {
|
||||
/* new account already created */
|
||||
/* Create new account object */
|
||||
acc = gnc_HBCI_Account_new(bank, bankCode, accountId);
|
||||
|
||||
/* Add it to our internal list. */
|
||||
accountlist = g_list_append(accountlist, acc);
|
||||
|
||||
printf("Added account %d/%s/%s\n",
|
||||
printf("gnc_processOutboxResponse: Added account %d/%s/%s\n",
|
||||
country, bankCode, accountId);
|
||||
}
|
||||
gnc_HBCI_Account_set_currency(acc, currency);
|
||||
gnc_HBCI_Account_set_name(acc, acc_name);
|
||||
gnc_HBCI_Account_set_name1(acc, acc_name1);
|
||||
gnc_HBCI_Account_set_customer(acc, custid);
|
||||
}
|
||||
|
||||
|
||||
@ -395,5 +404,7 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
|
||||
} /* while n */
|
||||
|
||||
GWEN_DB_Group_free(response);
|
||||
//printf("gnc_processOutboxResponse: accountlist.size: %d\n", g_list_length(accountlist));
|
||||
|
||||
return accountlist;
|
||||
}
|
||||
|
@ -58,6 +58,5 @@ GList *
|
||||
gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
|
||||
GList *accountlist);
|
||||
|
||||
void *hbci_find_acc_cb(gnc_HBCI_Account *acc, void *user_data);
|
||||
|
||||
#endif
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <errno.h>
|
||||
#include <openhbci2.h>
|
||||
#include <openhbci2/error.h>
|
||||
#include "Account.h"
|
||||
|
||||
#include "hbci-interaction.h"
|
||||
|
||||
@ -37,6 +38,10 @@ struct _gnc_HBCI_Account
|
||||
const HBCI_Bank *bank;
|
||||
char *bankCode;
|
||||
char *accountid;
|
||||
char *name;
|
||||
char *customer;
|
||||
char *currency;
|
||||
char *name1;
|
||||
};
|
||||
|
||||
gnc_HBCI_Account *gnc_HBCI_Account_new(const HBCI_Bank *bank,
|
||||
@ -54,6 +59,10 @@ void gnc_HBCI_Account_delete (gnc_HBCI_Account *h)
|
||||
if (!h) return;
|
||||
g_free(h->bankCode);
|
||||
g_free(h->accountid);
|
||||
if (h->name) g_free(h->name);
|
||||
if (h->customer) g_free(h->customer);
|
||||
if (h->currency) g_free(h->currency);
|
||||
if (h->name1) g_free(h->name1);
|
||||
g_free(h);
|
||||
}
|
||||
|
||||
@ -74,6 +83,62 @@ gnc_HBCI_Account_bank (const gnc_HBCI_Account *hbci_acc)
|
||||
return hbci_acc->bank;
|
||||
}
|
||||
|
||||
|
||||
void gnc_HBCI_Account_set_name (gnc_HBCI_Account *hbci_acc, const char *n)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
if (hbci_acc->name) g_free(hbci_acc->name);
|
||||
hbci_acc->name = g_strdup(n);
|
||||
}
|
||||
void gnc_HBCI_Account_set_customer (gnc_HBCI_Account *hbci_acc, const char *n)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
if (hbci_acc->customer) g_free(hbci_acc->customer);
|
||||
hbci_acc->customer = g_strdup(n);
|
||||
}
|
||||
void gnc_HBCI_Account_set_currency (gnc_HBCI_Account *hbci_acc, const char *n)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
if (hbci_acc->currency) g_free(hbci_acc->currency);
|
||||
hbci_acc->currency = g_strdup(n);
|
||||
}
|
||||
void gnc_HBCI_Account_set_name1 (gnc_HBCI_Account *hbci_acc, const char *n)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
if (hbci_acc->name1) g_free(hbci_acc->name1);
|
||||
hbci_acc->name1 = g_strdup(n);
|
||||
}
|
||||
const char *gnc_HBCI_Account_name (const gnc_HBCI_Account *hbci_acc)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
return hbci_acc->name;
|
||||
}
|
||||
const char *gnc_HBCI_Account_customer (const gnc_HBCI_Account *hbci_acc)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
return hbci_acc->customer;
|
||||
}
|
||||
const char *gnc_HBCI_Account_currency (const gnc_HBCI_Account *hbci_acc)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
return hbci_acc->currency;
|
||||
}
|
||||
const char *gnc_HBCI_Account_name1 (const gnc_HBCI_Account *hbci_acc)
|
||||
{
|
||||
g_assert(hbci_acc);
|
||||
return hbci_acc->name1;
|
||||
}
|
||||
|
||||
gchar *gnc_HBCI_Account_longname(const gnc_HBCI_Account *hacc)
|
||||
{
|
||||
g_assert(hacc);
|
||||
/* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
|
||||
return g_strdup_printf(_("%s at %s (code %s)"),
|
||||
gnc_HBCI_Account_accountId (hacc),
|
||||
HBCI_Bank_name (gnc_HBCI_Account_bank (hacc)),
|
||||
HBCI_Bank_bankCode (gnc_HBCI_Account_bank (hacc)));
|
||||
}
|
||||
|
||||
void *list_HBCI_Account_foreach(GList *h_list,
|
||||
void*(*func_cb)(gnc_HBCI_Account *acc,
|
||||
void *user_data),
|
||||
@ -85,16 +150,10 @@ void *list_HBCI_Account_foreach(GList *h_list,
|
||||
|
||||
if (!h_list) return NULL;
|
||||
|
||||
iter = h_list;
|
||||
if (iter->data)
|
||||
res = func_cb(iter->data, user_data);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
for (iter = h_list; iter; iter = iter->next)
|
||||
{
|
||||
if (iter->data)
|
||||
func_cb(iter->data, user_data);
|
||||
res = func_cb(iter->data, user_data);
|
||||
if (res)
|
||||
break;
|
||||
}
|
||||
@ -116,11 +175,54 @@ void list_HBCI_Account_delete(GList *list_HBCI_Account)
|
||||
}
|
||||
|
||||
|
||||
static void *hbci_find_acc_cb(gnc_HBCI_Account *acc, void *user_data)
|
||||
{
|
||||
gnc_HBCI_Account *new_acc = user_data;
|
||||
if (gnc_HBCI_Account_bank(acc) == gnc_HBCI_Account_bank(new_acc)) {
|
||||
if (strcmp(gnc_HBCI_Account_accountId(acc),
|
||||
gnc_HBCI_Account_accountId(new_acc))==0) {
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
gnc_HBCI_Account *list_HBCI_Account_find(GList *list,
|
||||
const HBCI_Bank *bank,
|
||||
const char *bankCode,
|
||||
const char *accountid)
|
||||
{
|
||||
gnc_HBCI_Account *acc;
|
||||
gnc_HBCI_Account *res;
|
||||
|
||||
if (list == NULL) return NULL;
|
||||
g_assert(bank);
|
||||
g_assert(bankCode);
|
||||
g_assert(accountid);
|
||||
|
||||
/* Create the wrapper object */
|
||||
acc = gnc_HBCI_Account_new(bank, bankCode, accountid);
|
||||
|
||||
/* Check if such an account already exists */
|
||||
res = list_HBCI_Account_foreach(list, hbci_find_acc_cb, acc);
|
||||
|
||||
gnc_HBCI_Account_delete(acc);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#define HBCI_ACCOUNT_ID "account-id"
|
||||
#define HBCI_BANK_CODE "bank-code"
|
||||
#define HBCI_COUNTRY_CODE "country-code"
|
||||
#define HBCI_ACCOUNT_CURRENCY "acc-currency"
|
||||
#define HBCI_ACCOUNT_NAME "acc-name"
|
||||
#define HBCI_ACCOUNT_NAME1 "acc-name1"
|
||||
#define HBCI_ACCOUNT_CUSTOMER "acc-customer"
|
||||
|
||||
/** Constructor from a kvp_frame */
|
||||
gnc_HBCI_Account *gnc_HBCI_Account_from_kvp(kvp_frame *k, HBCI_API *api)
|
||||
@ -135,16 +237,24 @@ gnc_HBCI_Account *gnc_HBCI_Account_from_kvp(kvp_frame *k, HBCI_API *api)
|
||||
countrycode = kvp_value_get_gint64 (kvp_frame_get_slot(k, HBCI_COUNTRY_CODE));
|
||||
|
||||
if (bankcode && (strlen(bankcode)>0) && (countrycode > 0)) {
|
||||
/*printf("gnc_acc %s has blz %s and ccode %d\n",
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
|
||||
bank = HBCI_API_findBank (api, countrycode, bankcode);
|
||||
res= gnc_HBCI_Account_new(bank,
|
||||
kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_ID)),
|
||||
kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_BANK_CODE)));
|
||||
/*printf("gnc_HBCI_Account_from_kvp: kvpframe has blz %s and ccode %d and accountid %s, bank %p\n",
|
||||
bankcode, countrycode, kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_ID)), bank);*/
|
||||
res = gnc_HBCI_Account_new(bank,
|
||||
bankcode,
|
||||
kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_ID)));
|
||||
if (!bank)
|
||||
printf("gnc_HBCI_Account_from_kvp: oops, no bank found.");
|
||||
gnc_HBCI_Account_set_currency(res, kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_CURRENCY)));
|
||||
gnc_HBCI_Account_set_name(res, kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_NAME)));
|
||||
gnc_HBCI_Account_set_name1(res, kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_NAME1)));
|
||||
gnc_HBCI_Account_set_customer(res, kvp_value_get_string
|
||||
(kvp_frame_get_slot(k, HBCI_ACCOUNT_CUSTOMER)));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -159,6 +269,14 @@ kvp_frame *gnc_HBCI_Account_to_kvp(const gnc_HBCI_Account *t)
|
||||
kvp_value_new_string(gnc_HBCI_Account_accountId(t)));
|
||||
kvp_frame_set_slot(k, HBCI_BANK_CODE,
|
||||
kvp_value_new_string(gnc_HBCI_Account_bankCode (t)));
|
||||
kvp_frame_set_slot(k, HBCI_ACCOUNT_CURRENCY,
|
||||
kvp_value_new_string(gnc_HBCI_Account_currency (t)));
|
||||
kvp_frame_set_slot(k, HBCI_ACCOUNT_NAME,
|
||||
kvp_value_new_string(gnc_HBCI_Account_name (t)));
|
||||
kvp_frame_set_slot(k, HBCI_ACCOUNT_NAME1,
|
||||
kvp_value_new_string(gnc_HBCI_Account_name1 (t)));
|
||||
kvp_frame_set_slot(k, HBCI_ACCOUNT_CUSTOMER,
|
||||
kvp_value_new_string(gnc_HBCI_Account_customer (t)));
|
||||
if (gnc_HBCI_Account_bank(t))
|
||||
kvp_frame_set_slot(k, HBCI_COUNTRY_CODE,
|
||||
kvp_value_new_gint64(HBCI_Bank_country
|
||||
|
@ -20,6 +20,10 @@
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
/** @file
|
||||
Hbci account definition
|
||||
*/
|
||||
|
||||
#ifndef GNC_HBCI_ACCOUNT_H
|
||||
#define GNC_HBCI_ACCOUNT_H
|
||||
|
||||
@ -41,11 +45,30 @@ const char *gnc_HBCI_Account_accountId (const gnc_HBCI_Account *hbci_acc);
|
||||
/** Returns the bank code -- this might be different than the actual
|
||||
* bank's bank code */
|
||||
const char *gnc_HBCI_Account_bankCode (const gnc_HBCI_Account *hbci_acc);
|
||||
|
||||
void gnc_HBCI_Account_set_name (gnc_HBCI_Account *hbci_acc, const char *n);
|
||||
void gnc_HBCI_Account_set_customer (gnc_HBCI_Account *hbci_acc, const char *n);
|
||||
void gnc_HBCI_Account_set_currency (gnc_HBCI_Account *hbci_acc, const char *n);
|
||||
void gnc_HBCI_Account_set_name1 (gnc_HBCI_Account *hbci_acc, const char *n);
|
||||
const char *gnc_HBCI_Account_name (const gnc_HBCI_Account *hbci_acc);
|
||||
const char *gnc_HBCI_Account_customer (const gnc_HBCI_Account *hbci_acc);
|
||||
const char *gnc_HBCI_Account_currency (const gnc_HBCI_Account *hbci_acc);
|
||||
const char *gnc_HBCI_Account_name1 (const gnc_HBCI_Account *hbci_acc);
|
||||
|
||||
/** Returns the bank this account belongs to */
|
||||
const HBCI_Bank *
|
||||
gnc_HBCI_Account_bank (const gnc_HBCI_Account *hbci_acc);
|
||||
/** Destructor for this account object */
|
||||
void gnc_HBCI_Account_delete (gnc_HBCI_Account *hbci_acc);
|
||||
|
||||
/** Returns a newly allocated string that is a human-readable
|
||||
* description of this account. The returned string will be owned by
|
||||
* the caller. */
|
||||
gchar *gnc_HBCI_Account_longname(const gnc_HBCI_Account *hbci_acc);
|
||||
/*@}*/
|
||||
|
||||
/** @name List of hbci accounts */
|
||||
/*@{*/
|
||||
/** Foreach function */
|
||||
void *list_HBCI_Account_foreach(GList *list_HBCI_Account,
|
||||
void*(*func_cb)(gnc_HBCI_Account *acc,
|
||||
@ -54,6 +77,13 @@ void *list_HBCI_Account_foreach(GList *list_HBCI_Account,
|
||||
/** Delete each element of a GList of HBCI_Accounts and finally the
|
||||
* list itself. */
|
||||
void list_HBCI_Account_delete(GList *list_HBCI_Account);
|
||||
|
||||
/** Searches for an account with the given data fields. Returns this
|
||||
* account, or NULL if none was found. */
|
||||
gnc_HBCI_Account *list_HBCI_Account_find(GList *list_HBCI_Account,
|
||||
const HBCI_Bank *bank,
|
||||
const char *bankCode,
|
||||
const char *accountid);
|
||||
/*@}*/
|
||||
|
||||
/** @name Serialization -- List of gnc_HBCI_Accounts to kvp_frame and
|
||||
|
@ -206,12 +206,17 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
|
||||
gboolean dialogres;
|
||||
|
||||
response = HBCI_Job_responseData((HBCI_Job*)HBCI_OutboxJob_Job_const(job));
|
||||
if (!response)
|
||||
if (!response) {
|
||||
printf("gnc_hbci_getbalance_finish: Oops, response == NULL.\n");
|
||||
return TRUE;
|
||||
acc_bal =GWEN_DB_GetGroup(response,
|
||||
}
|
||||
acc_bal = GWEN_DB_GetGroup(response,
|
||||
GWEN_PATH_FLAGS_NAMEMUSTEXIST, "balance");
|
||||
if (!acc_bal)
|
||||
if (!acc_bal) {
|
||||
printf("gnc_hbci_getbalance_finish: Oops, acc_bal == NULL. Response was:\n");
|
||||
GWEN_DB_Dump(response, stdout, 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
noted_grp = GWEN_DB_GetGroup(response, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "noted");
|
||||
booked_grp = GWEN_DB_GetGroup(response, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "booked");
|
||||
|
@ -39,6 +39,12 @@
|
||||
|
||||
/* static short module = MOD_IMPORT; */
|
||||
|
||||
/* Globale variables for HBCI_API caching. */
|
||||
static HBCI_API *gnc_hbci_api = NULL;
|
||||
static char *gnc_hbci_configfile = NULL;
|
||||
static GNCInteractor *gnc_hbci_inter = NULL;
|
||||
static GList *gnc_hbci_accountlist = NULL;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
HBCI_API *
|
||||
@ -51,7 +57,6 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
char *errstring;
|
||||
|
||||
g_assert(inter);
|
||||
g_assert(list_accounts);
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
@ -119,10 +124,12 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
|
||||
*inter = gnc_hbci_api_interactors (api, parent);
|
||||
|
||||
*list_accounts =
|
||||
gnc_hbci_accountlist =
|
||||
gnc_HBCI_Account_glist_from_kvp_glist
|
||||
(gnc_hbci_get_book_account_list(gnc_get_current_book ()),
|
||||
api);
|
||||
if (list_accounts)
|
||||
*list_accounts = gnc_hbci_accountlist;
|
||||
|
||||
{
|
||||
/* FIXME FIXME FIXME : Use a sane directory here. FIXME FIXME
|
||||
@ -144,11 +151,6 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile,
|
||||
return api;
|
||||
}
|
||||
|
||||
static HBCI_API *gnc_hbci_api = NULL;
|
||||
static char *gnc_hbci_configfile = NULL;
|
||||
static GNCInteractor *gnc_hbci_inter = NULL;
|
||||
static GList *gnc_hbci_accountlist = NULL;
|
||||
|
||||
HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
|
||||
GNCInteractor **inter,
|
||||
GList **list_accounts)
|
||||
@ -159,14 +161,10 @@ HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent,
|
||||
g_strdup (gnc_hbci_get_book_configfile (gnc_get_current_book ()));
|
||||
gnc_hbci_api = gnc_hbci_api_new (gnc_hbci_configfile,
|
||||
FALSE, parent, &gnc_hbci_inter,
|
||||
&gnc_hbci_accountlist);
|
||||
list_accounts);
|
||||
if (inter)
|
||||
*inter = gnc_hbci_inter;
|
||||
|
||||
/* Retrieve the stored list of HBCI accounts */
|
||||
if (list_accounts)
|
||||
*list_accounts = gnc_hbci_accountlist;
|
||||
|
||||
return gnc_hbci_api;
|
||||
|
||||
} else if ((gnc_hbci_configfile != NULL) &&
|
||||
@ -229,15 +227,17 @@ gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc)
|
||||
bankcode = gnc_hbci_get_account_bankcode (gnc_acc);
|
||||
countrycode = gnc_hbci_get_account_countrycode (gnc_acc);
|
||||
if (bankcode && (strlen(bankcode)>0) && (countrycode > 0)) {
|
||||
/*printf("gnc_acc %s has blz %s and ccode %d\n",
|
||||
/*printf("gnc_hbci_get_hbci_acc: gnc_acc %s has blz %s and ccode %d\n",
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
|
||||
bank = HBCI_API_findBank (api, countrycode, bankcode);
|
||||
if (bank) {
|
||||
/*printf("gnc_acc %s has blz %s and ccode %d\n",
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode);*/
|
||||
accountid = gnc_hbci_get_account_accountid (gnc_acc);
|
||||
/*printf("gnc_hbci_get_hbci_acc: gnc_acc %s found blz %s and ccode %d and accountid %s, bank %p\n",
|
||||
xaccAccountGetName (gnc_acc), bankcode, countrycode, accountid, bank);*/
|
||||
if (accountid && (strlen(accountid)>0)) {
|
||||
hbci_acc = gnc_HBCI_Account_new(bank, bankcode, accountid);
|
||||
hbci_acc = list_HBCI_Account_find(gnc_hbci_accountlist,
|
||||
bank, bankcode, accountid);
|
||||
/*printf("gnc_hbci_get_hbci_acc: return HBCI_Account %p\n", hbci_acc);*/
|
||||
return hbci_acc;
|
||||
}
|
||||
}
|
||||
|
@ -577,10 +577,6 @@ static void actStarted (ActionProgressType type, void *user_data)
|
||||
const char *msg = NULL;
|
||||
g_assert(data);
|
||||
switch (type) {
|
||||
/** Sending message. */
|
||||
case ACT_SENDINGMESSAGE:
|
||||
msg = _("Sending message");
|
||||
break;
|
||||
/** Creating HBCI job. Number of Job will follow in string argument. */
|
||||
case ACT_FILLINGQUEUE:
|
||||
msg = _("Creating HBCI Job");
|
||||
@ -601,9 +597,57 @@ static void actStarted (ActionProgressType type, void *user_data)
|
||||
case ACT_CLOSECONNECTION:
|
||||
msg = _("Closing connection");
|
||||
break;
|
||||
default:
|
||||
msg = _("Unknown");
|
||||
case ACT_OPENSESSION:
|
||||
msg = _("Open session");
|
||||
break;
|
||||
case ACT_CLOSESESSION:
|
||||
msg = _("Close session");
|
||||
break;
|
||||
case ACT_OPENDIALOG:
|
||||
msg = _("Open dialog");
|
||||
break;
|
||||
case ACT_CLOSEDIALOG:
|
||||
msg = _("Close dialog");
|
||||
break;
|
||||
case ACT_PROCESSMSG:
|
||||
msg = _("Process message");
|
||||
break;
|
||||
case ACT_CREATEJOB:
|
||||
msg = _("Create job");
|
||||
break;
|
||||
case ACT_HANDLEJOBS:
|
||||
msg = _("Handle jobs");
|
||||
break;
|
||||
case ACT_SIGNMSG:
|
||||
msg = _("Sign message");
|
||||
break;
|
||||
case ACT_ENCRYPTMSG:
|
||||
msg = _("Encrypt message");
|
||||
break;
|
||||
case ACT_VERIFYMSG:
|
||||
msg = _("Verify message");
|
||||
break;
|
||||
case ACT_DECRYPTMSG:
|
||||
msg = _("Decrypt message");
|
||||
break;
|
||||
case ACT_ENCODEMSG:
|
||||
msg = _("Encode message");
|
||||
break;
|
||||
case ACT_DECODEMSG:
|
||||
msg = _("Decode message");
|
||||
break;
|
||||
/** Sending message. */
|
||||
case ACT_SENDINGMESSAGE:
|
||||
/* Note: the ACT_SENDINGMESSAGE doesn't seem to be used. */
|
||||
case ACT_LOW_SENDMSG:
|
||||
msg = _("Sending message");
|
||||
break;
|
||||
case ACT_LOW_RECEIVEMSG:
|
||||
msg = _("Receiving message");
|
||||
break;
|
||||
/*default:
|
||||
msg = _("Unknown");
|
||||
break;*/
|
||||
}
|
||||
|
||||
g_assert(msg);
|
||||
|
@ -837,7 +837,8 @@ gnc_import_process_trans_clist (GtkCList *clist,
|
||||
xaccSplitSetValue (split, v);
|
||||
xaccSplitSetAmount (split, v);
|
||||
}
|
||||
xaccSplitSetMemo (split, _("Auto-Balance split"));
|
||||
/*xaccSplitSetMemo (split, _("Auto-Balance split"));
|
||||
-- disabled due to popular request */
|
||||
}
|
||||
|
||||
xaccSplitSetReconcile(gnc_import_TransInfo_get_fsplit (trans_info), CREC);
|
||||
|
Loading…
Reference in New Issue
Block a user