mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Improve HBCI code.
2005-01-29 Christian Stimming <stimming@tuhh.de> * src/import-export/hbci/dialog-hbcitrans.c: Enable debit notes again. Various other improvements. * src/import-export/hbci/druid-hbci-initial.c (on_aqhbci_button), configure.in: Adapt to latest changes in aqbanking; external wizard name is no longer hard-coded here but is asked from aqbanking. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10427 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2005-01-29 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/import-export/hbci/dialog-hbcitrans.c: Enable debit notes
|
||||
again. Various other improvements.
|
||||
|
||||
* src/import-export/hbci/druid-hbci-initial.c (on_aqhbci_button),
|
||||
configure.in: Adapt to latest changes in aqbanking; external
|
||||
wizard name is no longer hard-coded here but is asked from
|
||||
aqbanking.
|
||||
|
||||
2005-01-23 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/business/business-core/gncInvoice.c: Properly accumulate
|
||||
|
||||
@@ -601,7 +601,7 @@ AC_ARG_ENABLE( mt940,
|
||||
if test x${MT940_DIR} = xmt940 ;
|
||||
then
|
||||
AC_MSG_ERROR([Sorry, MT940 support is currently broken since it depended on the hbci module with the old openhbci 0.9.x library. But the hbci module has now been ported to a new hbci library called aqbanking. That library contains a MT940 parser, too, so porting shouldnt be too difficult. Nevertheless someone needs to do the porting work before this can be enabled again.])
|
||||
AC_AQBANKING(0,9,8)
|
||||
AC_AQBANKING(1,0,0)
|
||||
# Note: HBCI_LIBS is changed again below in the --enable-hbci
|
||||
# section. So check for mt940 first and *not* the other way round!
|
||||
HBCI_LIBS="${OPENHBCI_LIBS}"
|
||||
@@ -623,7 +623,7 @@ AC_ARG_ENABLE( hbci,
|
||||
if test x${HBCI_DIR} = xhbci ;
|
||||
then
|
||||
# Check for Aqbanking library
|
||||
AC_AQBANKING(0,9,8)
|
||||
AC_AQBANKING(1,0,0)
|
||||
if test x${have_aqbanking} != xyes;
|
||||
then
|
||||
AC_MSG_ERROR([Could not find aqbanking. If you use --enable-hbci, you *have* to enable aqbanking.])
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <gnome.h>
|
||||
#include <aqbanking/account.h>
|
||||
#include <aqbanking/jobsingletransfer.h>
|
||||
#include <aqbanking/jobsingledebitnote.h>
|
||||
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-ui.h"
|
||||
@@ -624,7 +625,14 @@ gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, AB_BANKING *api,
|
||||
AB_JOB *job;
|
||||
|
||||
/* Create a Do-Transaction (Transfer) job. */
|
||||
job = AB_JobSingleTransfer_new(h_acc);
|
||||
switch (trans_type) {
|
||||
case SINGLE_DEBITNOTE:
|
||||
job = AB_JobSingleDebitNote_new(h_acc);
|
||||
break;
|
||||
default:
|
||||
case SINGLE_TRANSFER:
|
||||
job = AB_JobSingleTransfer_new(h_acc);
|
||||
};
|
||||
if (AB_Job_CheckAvailability(job)) {
|
||||
printf("gnc_hbci_trans_dialog_enqueue: Oops, job not available. Aborting.\n");
|
||||
return NULL;
|
||||
|
||||
@@ -452,46 +452,33 @@ on_aqhbci_button (GtkButton *button,
|
||||
int res;
|
||||
const char *backend_name = "aqhbci";
|
||||
|
||||
/* NOTE NOTE NOTE: This is the name for the external application
|
||||
shipped with aqhbci that contains the setup druid for HBCI
|
||||
related stuff. The name is misleading -- it requires qt but not
|
||||
kde). This application contains the very verbose step-by-step
|
||||
setup wizard for the HBCI account, and the application is shared
|
||||
with other AqBanking-based financial managers that offer the HBCI
|
||||
features (e.g. KMyMoney). See gnucash-devel discussion here
|
||||
https://lists.gnucash.org/pipermail/gnucash-devel/2004-December/012351.html
|
||||
/* This is the point where we look for and start an external
|
||||
application shipped with aqhbci that contains the setup druid for
|
||||
HBCI related stuff. It requires qt (but not kde). This
|
||||
application contains the very verbose step-by-step setup wizard
|
||||
for the HBCI account, and the application is shared with other
|
||||
AqBanking-based financial managers that offer the HBCI features
|
||||
(e.g. KMyMoney). See gnucash-devel discussion here
|
||||
https://lists.gnucash.org/pipermail/gnucash-devel/2004-December/012351.html
|
||||
*/
|
||||
const char *wizard_name = "kde_wizard";
|
||||
gboolean wizard_exists;
|
||||
const char *wizard_path;
|
||||
int fd;
|
||||
AB_BANKING *banking = info->api;
|
||||
g_assert(info->druid);
|
||||
|
||||
buf = GWEN_Buffer_new(NULL, 200, 0, 0);
|
||||
AB_Banking_GetWizardPath(banking, backend_name, buf);
|
||||
buf = GWEN_Buffer_new(NULL, 300, 0, 0);
|
||||
AB_Banking_FindWizard(banking, backend_name, NULL, buf);
|
||||
wizard_exists = (strlen(GWEN_Buffer_GetStart(buf)) > 0);
|
||||
|
||||
GWEN_Buffer_AppendString(buf, "/");
|
||||
/* {
|
||||
GWEN_PLUGIN_DESCRIPTION_LIST2 *l =
|
||||
AB_Banking_GetWizardDescrs(banking, backend_name);
|
||||
const GWEN_PLUGIN_DESCRIPTION *x = GWEN_PluginDescription_List2_GetFront(l);
|
||||
// There needs to be a way to find the file name here. Currently
|
||||
// this doesnt work yet.
|
||||
wizard_name = GWEN_PluginDescription_GetName(x);
|
||||
GWEN_Buffer_AppendString(buf, wizard_name);
|
||||
GWEN_PluginDescription_List2_freeAll(l);
|
||||
} */
|
||||
GWEN_Buffer_AppendString(buf, wizard_name);
|
||||
wizard_path = GWEN_Buffer_GetStart(buf);
|
||||
|
||||
/* Really check whether the file exists */
|
||||
fd = open( wizard_path, O_RDONLY );
|
||||
if ( fd == -1)
|
||||
wizard_exists = FALSE;
|
||||
else
|
||||
close( fd );
|
||||
if (wizard_exists) {
|
||||
/* Really check whether the file exists */
|
||||
int fd = open( wizard_path, O_RDONLY );
|
||||
if ( fd == -1)
|
||||
wizard_exists = FALSE;
|
||||
else
|
||||
close( fd );
|
||||
}
|
||||
|
||||
druid_disable_next_button(info);
|
||||
AB_Banking_DeactivateProvider(banking, backend_name);
|
||||
@@ -499,8 +486,8 @@ on_aqhbci_button (GtkButton *button,
|
||||
int wait_status;
|
||||
int wait_result = 0;
|
||||
|
||||
/* Call the qt wizard (called kde wizard). See the note above
|
||||
about why this approach is chosen. */
|
||||
/* Call the qt wizard. See the note above about why this approach
|
||||
is chosen. */
|
||||
|
||||
/* In gtk2, this would be g_spawn_async or similar. */
|
||||
AB_Banking_Fini (info->api);
|
||||
@@ -519,6 +506,7 @@ on_aqhbci_button (GtkButton *button,
|
||||
_exit(0);
|
||||
default: /* parent */
|
||||
res = 0;
|
||||
/* wait until child is finished */
|
||||
while (wait_result == 0) {
|
||||
gtk_main_iteration();
|
||||
wait_result = waitpid(pid, &wait_status, WNOHANG);
|
||||
@@ -556,10 +544,8 @@ on_aqhbci_button (GtkButton *button,
|
||||
gnc_error_dialog
|
||||
(info->window, "%s",
|
||||
_("The external program \"AqHBCI Setup Wizard\" has not been found. \n\n"
|
||||
"Did you install the package \"kde_wizard\" of AqHBCI? \n"
|
||||
"If not, please install it now. (The name of that package \n"
|
||||
"is misleading, as it does not require the KDE desktop \n"
|
||||
"environment but only the Qt toolkit libraries.)"));
|
||||
"Did you install the package \"aqhbci-qt-wizard\" of AqHBCI? \n"
|
||||
"If not, please install it now."));
|
||||
druid_disable_next_button(info);
|
||||
}
|
||||
GWEN_Buffer_free(buf);
|
||||
|
||||
@@ -102,9 +102,7 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
|
||||
|
||||
/* AB_BANKING_executeOutbox failed. */
|
||||
AB_Banking_DequeueJob(api, job);
|
||||
AB_Banking_DelFinishedJob(api, job);
|
||||
AB_Banking_DelPendingJob(api, job);
|
||||
gnc_hbci_cleanup_job(api, job);
|
||||
/* FIXME: free unneeded data */
|
||||
return;
|
||||
}
|
||||
@@ -117,9 +115,7 @@ gnc_hbci_getbalance (GtkWidget *parent, Account *gnc_acc)
|
||||
job);
|
||||
|
||||
/* Clean up after ourselves. */
|
||||
AB_Banking_DequeueJob(api, job);
|
||||
AB_Banking_DelFinishedJob(api, job);
|
||||
AB_Banking_DelPendingJob(api, job);
|
||||
gnc_hbci_cleanup_job(api, job);
|
||||
gnc_AB_BANKING_fini (api);
|
||||
GNCInteractor_hide (interactor);
|
||||
}
|
||||
|
||||
@@ -109,9 +109,7 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
/* Execute Outbox. */
|
||||
if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
|
||||
/* AB_BANKING_executeOutbox failed. */
|
||||
AB_Banking_DequeueJob(api, job);
|
||||
AB_Banking_DelFinishedJob(api, job);
|
||||
AB_Banking_DelPendingJob(api, job);
|
||||
gnc_hbci_cleanup_job(api, job);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,9 +120,7 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc)
|
||||
gnc_hbci_gettrans_final(parent, gnc_acc, job, FALSE);
|
||||
|
||||
/* Clean up behind ourself. */
|
||||
AB_Banking_DequeueJob(api, job);
|
||||
AB_Banking_DelFinishedJob(api, job);
|
||||
AB_Banking_DelPendingJob(api, job);
|
||||
gnc_hbci_cleanup_job(api, job);
|
||||
gnc_AB_BANKING_fini (api);
|
||||
GNCInteractor_hide (interactor);
|
||||
GWEN_Time_free (from_date);
|
||||
|
||||
@@ -135,15 +135,9 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc,
|
||||
xaccTransBeginEdit(gtrans);
|
||||
xaccTransDestroy(gtrans);
|
||||
xaccTransCommitEdit(gtrans);
|
||||
|
||||
/* AB_Banking_DequeueJob(api, job); */
|
||||
/* AB_Banking_DelFinishedJob(api, job); */
|
||||
/* AB_Banking_DelPendingJob(api, job); */
|
||||
}
|
||||
|
||||
AB_Banking_DequeueJob(api, job);
|
||||
AB_Banking_DelFinishedJob(api, job);
|
||||
AB_Banking_DelPendingJob(api, job);
|
||||
gnc_hbci_cleanup_job(api, job);
|
||||
} /* result == 0 */
|
||||
else {
|
||||
/* huh? Only result == 0 should be possible. Simply ignore
|
||||
|
||||
@@ -134,7 +134,7 @@ gnc_hbci_get_hbci_acc (const AB_BANKING *api, Account *gnc_acc)
|
||||
|
||||
if (!hbci_acc && bankcode && (strlen(bankcode)>0) &&
|
||||
accountid && (strlen(accountid) > 0)) {
|
||||
printf("gnc_hbci_get_hbci_acc: No AB_ACCOUNT found for UID %d, trying bank code\n", account_uid);
|
||||
/* printf("gnc_hbci_get_hbci_acc: No AB_ACCOUNT found for UID %d, trying bank code\n", account_uid); */
|
||||
hbci_acc = AB_Banking_GetAccountByCodeAndNumber(api, bankcode, accountid);
|
||||
}
|
||||
/*printf("gnc_hbci_get_hbci_acc: return HBCI_Account %p\n", hbci_acc);*/
|
||||
@@ -239,6 +239,18 @@ gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose)
|
||||
return cause;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_hbci_cleanup_job(AB_BANKING *api, AB_JOB *job)
|
||||
{
|
||||
if (AB_Job_GetStatus(job) == AB_Job_StatusFinished) {
|
||||
AB_Banking_DelFinishedJob(api, job);
|
||||
} else if (AB_Job_GetStatus(job) == AB_Job_StatusPending) {
|
||||
AB_Banking_DelPendingJob(api, job);
|
||||
}
|
||||
/* Martin assured me that there will be no job in the queue after
|
||||
ExecuteQueue, so we don't need to remove it from the queue. */
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gnc_hbci_Error_retry (GtkWidget *parent, int error,
|
||||
|
||||
@@ -76,6 +76,11 @@ gnc_hbci_get_hbci_acc (const AB_BANKING *api, Account *gnc_acc);
|
||||
int
|
||||
gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose);
|
||||
|
||||
/** Clean up the queue after executing, i.e. delete the job as good as
|
||||
possible. */
|
||||
void
|
||||
gnc_hbci_cleanup_job(AB_BANKING *api, AB_JOB *job);
|
||||
|
||||
/* Check int on whether some feedback should be given to the
|
||||
* user. Returns true if the HBCI action should be tried again; on the
|
||||
* other hand, returns false if the user can't do anything about this
|
||||
|
||||
Reference in New Issue
Block a user