More work on openhbci2 support.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9810 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2004-01-27 21:30:49 +00:00
parent bbe599b144
commit 480c61d88a
5 changed files with 55 additions and 31 deletions

View File

@ -172,6 +172,9 @@ reset_initial_info (HBCIInitialInfo *info)
if (info->gnc_hash != NULL) if (info->gnc_hash != NULL)
g_hash_table_destroy (info->gnc_hash); g_hash_table_destroy (info->gnc_hash);
info->gnc_hash = NULL; info->gnc_hash = NULL;
list_HBCI_Account_delete(info->hbci_accountlist);
info->hbci_accountlist = NULL;
} }
static void static void
@ -613,21 +616,30 @@ on_finish (GnomeDruidPage *gnomedruidpage,
if (info->configfile) { if (info->configfile) {
printf("on_finish: Got configfile %s, but the book has %s.\n", info->configfile, gnc_hbci_get_book_configfile (gnc_get_current_book ()));
if (!gnc_hbci_get_book_configfile (gnc_get_current_book ()) || if (!gnc_hbci_get_book_configfile (gnc_get_current_book ()) ||
(strcmp(info->configfile, (strcmp(info->configfile,
gnc_hbci_get_book_configfile (gnc_get_current_book ())) != 0)) gnc_hbci_get_book_configfile (gnc_get_current_book ())) != 0)) {
/* Name of configfile has changed */ /* Name of configfile has changed */
gnc_hbci_set_book_configfile (gnc_get_current_book (), info->configfile); gnc_hbci_set_book_configfile (gnc_get_current_book (), info->configfile);
if (strcmp(info->configfile,
gnc_hbci_get_book_configfile (gnc_get_current_book ())) != 0)
printf("on_finish: OOOPS: I just setted the book_configfile to %s, but the book now still has %s.\n", info->configfile, gnc_hbci_get_book_configfile (gnc_get_current_book ()));
}
} }
{ {
HBCI_Error *err; HBCI_Error *err;
printf("on_finish: trying to save openhbci data to file %s.\n", info->configfile);
err = gnc_hbci_api_save (info->api); err = gnc_hbci_api_save (info->api);
if (err != NULL) { if (err != NULL) {
if (!HBCI_Error_isOk (err)) if (!HBCI_Error_isOk (err))
printf("on_finish: Error at saving OpenHBCI data: %s.\n", printf("on_finish: Error at saving OpenHBCI data: %s.\n",
HBCI_Error_message (err)); HBCI_Error_message (err));
HBCI_Error_delete (err); HBCI_Error_delete (err);
delete_initial_druid(info);
return;
} }
} }
@ -1065,39 +1077,47 @@ on_accountinfo_next (GnomeDruidPage *gnomedruidpage,
return FALSE; return FALSE;
{ {
/* Execute a Synchronize job, then a GetAccounts job. */
HBCI_OutboxJob *job; HBCI_OutboxJob *job;
job = HBCI_OutboxJob_new("JobSync", /* Execute a Synchronize job, then a GetAccounts job. */
(HBCI_Customer *)info->newcustomer, ""); /*job = HBCI_OutboxJob_new("JobSync",
HBCI_Outbox_addJob (info->outbox, job); (HBCI_Customer *)info->newcustomer, "");
HBCI_Outbox_addJob (info->outbox, job);*/
/* Execute Outbox. */ /* Execute Outbox. */
if (!gnc_hbci_api_execute (info->window, info->api, info->outbox, /*if (!gnc_hbci_api_execute (info->window, info->api, info->outbox,
job, info->interactor)) { job, info->interactor)) {*/
/* HBCI_API_executeOutbox failed. */ /* HBCI_API_executeOutbox failed. */
/*return FALSE;*/ /*return FALSE;*/
/* -- it seems to be no problem if this fails ?! */ /* -- it seems to be no problem if this fails ?! */
} /*}*/
/* Now the GetAccounts job. */ /* Now the GetAccounts job. */
job = HBCI_OutboxJob_new("JobGetAccounts", job = HBCI_OutboxJob_new("JobGetAccounts",
(HBCI_Customer *)info->newcustomer, ""); (HBCI_Customer *)info->newcustomer, "");
HBCI_Outbox_addJob (info->outbox, job); HBCI_Outbox_addJob (info->outbox, job);
/*{ {
HBCI_Job *jjob = HBCI_OutboxJob_Job(job); HBCI_Job *jjob = HBCI_OutboxJob_Job(job);
HBCI_Job_setIntProperty("open/ident/country", bank.ref().country()); HBCI_Job_setIntProperty
HBCI_Job_setProperty("open/ident/bankcode", bank.ref().bankCode()); (jjob, "open/ident/country",
HBCI_Job_setProperty("open/ident/customerid", c.ref().custId()); HBCI_Bank_country(HBCI_User_bank
HBCI_Job_setIntProperty("open/prepare/updversion",0); (HBCI_Customer_user(info->newcustomer))));
}*/ HBCI_Job_setProperty
(jjob, "open/ident/bankcode",
HBCI_Bank_bankCode(HBCI_User_bank
(HBCI_Customer_user(info->newcustomer))));
HBCI_Job_setProperty
(jjob, "open/ident/customerid", HBCI_Customer_custId(info->newcustomer));
HBCI_Job_setIntProperty(jjob, "open/prepare/updversion",0);
}
/* Execute Outbox. */ /* Execute Outbox. */
if (!gnc_hbci_api_execute (info->window, info->api, info->outbox, if (!gnc_hbci_api_execute (info->window, info->api, info->outbox,
job, info->interactor)) { job, info->interactor)) {
/* HBCI_API_executeOutbox failed. */ /* HBCI_API_executeOutbox failed. */
printf("on_accountinfo_next: oops, executeOutbox failed.\n");
return FALSE; return FALSE;
} }

View File

@ -278,9 +278,13 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
/*g_assert(accountlist);*/ /*g_assert(accountlist);*/
response = HBCI_Outbox_response(outbox); response = HBCI_Outbox_response(outbox);
/*printf("gnc_processOutboxResponse: Complete response:\n");
GWEN_DB_Dump(response, stdout, 1);*/
n=GWEN_DB_GetFirstGroup(response); n=GWEN_DB_GetFirstGroup(response);
while (n){ while (n){
if (strcasecmp(GWEN_DB_GroupName(n), "accountdata")==0) { if (strcasecmp(GWEN_DB_GroupName(n), "AccountData")==0) {
/* found account data, create account */ /* found account data, create account */
const char *accountId; const char *accountId;
const char *accountSubId; const char *accountSubId;
@ -298,7 +302,7 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
accountId=GWEN_DB_GetCharValue(n, "accountid", 0, ""); accountId=GWEN_DB_GetCharValue(n, "accountid", 0, "");
accountSubId=GWEN_DB_GetCharValue(n, "accountsubid", 0, ""); accountSubId=GWEN_DB_GetCharValue(n, "accountsubid", 0, "");
if (strlen(bankCode)==0 || strlen(accountId)==0 || strlen(custid)==0) { if (strlen(bankCode)==0 || strlen(accountId)==0 || strlen(custid)==0) {
fprintf(stderr, "gnc_processOutboxResponse: AccountData without bank code/account id/customer id"); printf("gnc_processOutboxResponse: AccountData without bank code/account id/customer id\n");
continue; continue;
} }
@ -345,7 +349,7 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
const char *p; const char *p;
/* Update account information */ /* Update account information */
printf("Account %d/%s/%s already exists, updating", printf("Account %d/%s/%s already exists, updating.\n",
country, bankCode, accountId); country, bankCode, accountId);
p=GWEN_DB_GetCharValue(n, "name", 0, 0); p=GWEN_DB_GetCharValue(n, "name", 0, 0);
@ -368,7 +372,7 @@ gnc_processOutboxResponse(HBCI_API *api, HBCI_Outbox *outbox,
/* Add it to our internal list. */ /* Add it to our internal list. */
accountlist = g_list_append(accountlist, acc); accountlist = g_list_append(accountlist, acc);
printf("Added account %d/%s/%s", printf("Added account %d/%s/%s\n",
country, bankCode, accountId); country, bankCode, accountId);
} }
} }

View File

@ -83,7 +83,7 @@ void *list_HBCI_Account_foreach(GList *h_list,
g_assert(func_cb); g_assert(func_cb);
void *res = NULL; void *res = NULL;
if (h_list == NULL) return NULL; if (!h_list) return NULL;
iter = h_list; iter = h_list;
if (iter->data) if (iter->data)
@ -91,7 +91,7 @@ void *list_HBCI_Account_foreach(GList *h_list,
if (res) if (res)
return res; return res;
for (iter = h_list->next; iter != h_list; iter = iter->next) for (iter = h_list; iter; iter = iter->next)
{ {
if (iter->data) if (iter->data)
func_cb(iter->data, user_data); func_cb(iter->data, user_data);
@ -112,7 +112,7 @@ static void* del_func(gnc_HBCI_Account *acc, void *user_data)
void list_HBCI_Account_delete(GList *list_HBCI_Account) void list_HBCI_Account_delete(GList *list_HBCI_Account)
{ {
list_HBCI_Account_foreach(list_HBCI_Account, del_func, NULL); list_HBCI_Account_foreach(list_HBCI_Account, del_func, NULL);
g_free (list_HBCI_Account); g_list_free (list_HBCI_Account);
} }

View File

@ -211,7 +211,7 @@ HBCI_Error * gnc_hbci_api_save (const HBCI_API *api)
if ((file == NULL) || (strlen (file) == 0)) if ((file == NULL) || (strlen (file) == 0))
return HBCI_Error_new ("gnc_hbci_api_save", ERROR_LEVEL_NORMAL, 0, return HBCI_Error_new ("gnc_hbci_api_save", ERROR_LEVEL_NORMAL, 0,
ERROR_ADVISE_ABORT, ERROR_ADVISE_ABORT,
"No filename for config file.", ""); "No filename for config file in gnc_book.", "");
return HBCI_API_saveEnvironment (api, file); return HBCI_API_saveEnvironment (api, file);
} }

View File

@ -632,10 +632,10 @@ static void closeConnection(TransportType t, void *user_data)
if (debug_pmonitor) if (debug_pmonitor)
printf("actFinished-cb: current_job %d, jobs %d, current_act %d, actions %d.\n", printf("actFinished-cb: current_job %d, jobs %d, current_act %d, actions %d.\n",
data->current_job, data->jobs, data->current_act, data->actions); data->current_job, data->jobs, data->current_act, data->actions);
if (data->current_act > data->actions) { /*if (data->current_act > data->actions) {
printf("actFinished-cb: oops, current_act==%d is > than actions==%d.\n", printf("actFinished-cb: oops, current_act==%d is > than actions==%d.\n",
data->current_act, data->actions); data->current_act, data->actions);
} }*/
GNCInteractor_setFinished (data); GNCInteractor_setFinished (data);