[Gnucash-changes] Improve HBCI code.

Christian Stimming cstim at cvs.gnucash.org
Sat Jan 29 07:31:25 EST 2005


Log Message:
-----------
Improve HBCI code.

2005-01-29  Christian Stimming  <stimming at 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.

Tags:
----
gnucash-1-8-branch

Modified Files:
--------------
    gnucash:
        ChangeLog
        configure.in
    gnucash/src/import-export/hbci:
        dialog-hbcitrans.c
        druid-hbci-initial.c
        gnc-hbci-getbalance.c
        gnc-hbci-gettrans.c
        gnc-hbci-transfer.c
        gnc-hbci-utils.c
        gnc-hbci-utils.h

Added Files:
-----------
    gnucash/src/import-export/hbci:
        HACKING-HBCITEST.txt

Revision Data
-------------
Index: configure.in
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/configure.in,v
retrieving revision 1.358.2.44
retrieving revision 1.358.2.45
diff -Lconfigure.in -Lconfigure.in -u -r1.358.2.44 -r1.358.2.45
--- configure.in
+++ configure.in
@@ -556,7 +556,7 @@
 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.])
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1461.2.386
retrieving revision 1.1461.2.387
diff -LChangeLog -LChangeLog -u -r1.1461.2.386 -r1.1461.2.387
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,13 @@
+2005-01-29  Christian Stimming  <stimming at 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-28  Derek Atkins  <derek at ihtfp.com>
 
 	* src/business/business-ledger/Makefile.am: add explicit
Index: druid-hbci-initial.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/druid-hbci-initial.c,v
retrieving revision 1.26.2.15
retrieving revision 1.26.2.16
diff -Lsrc/import-export/hbci/druid-hbci-initial.c -Lsrc/import-export/hbci/druid-hbci-initial.c -u -r1.26.2.15 -r1.26.2.16
--- src/import-export/hbci/druid-hbci-initial.c
+++ src/import-export/hbci/druid-hbci-initial.c
@@ -452,46 +452,33 @@
   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 @@
     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 @@
 	_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 @@
     gnc_error_dialog_parented
       (GTK_WINDOW(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);
Index: gnc-hbci-utils.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.h,v
retrieving revision 1.12.2.4
retrieving revision 1.12.2.5
diff -Lsrc/import-export/hbci/gnc-hbci-utils.h -Lsrc/import-export/hbci/gnc-hbci-utils.h -u -r1.12.2.4 -r1.12.2.5
--- src/import-export/hbci/gnc-hbci-utils.h
+++ src/import-export/hbci/gnc-hbci-utils.h
@@ -76,6 +76,11 @@
 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
Index: dialog-hbcitrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/dialog-hbcitrans.c,v
retrieving revision 1.9.2.18
retrieving revision 1.9.2.19
diff -Lsrc/import-export/hbci/dialog-hbcitrans.c -Lsrc/import-export/hbci/dialog-hbcitrans.c -u -r1.9.2.18 -r1.9.2.19
--- src/import-export/hbci/dialog-hbcitrans.c
+++ src/import-export/hbci/dialog-hbcitrans.c
@@ -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 @@
   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;
Index: gnc-hbci-utils.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.c,v
retrieving revision 1.23.2.14
retrieving revision 1.23.2.15
diff -Lsrc/import-export/hbci/gnc-hbci-utils.c -Lsrc/import-export/hbci/gnc-hbci-utils.c -u -r1.23.2.14 -r1.23.2.15
--- src/import-export/hbci/gnc-hbci-utils.c
+++ src/import-export/hbci/gnc-hbci-utils.c
@@ -134,7 +134,7 @@
 
     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 @@
   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, 
--- /dev/null
+++ src/import-export/hbci/HACKING-HBCITEST.txt
@@ -0,0 +1,56 @@
+By Christian Stimming, 2005-01-11
+
+Hi all developers,
+
+as you know, Gnucash includes support for the German online banking 
+protocol HBCI, and I usually emphasize that anyone outside Germany will 
+be unable to use all these cool features. But it recently came to my 
+mind that there is a test server, simulating a HBCI bank, which is run 
+by a friend of us (Stefan Palme), and he is able to give the Gnucash 
+developers something like a test account for, well, testing purposes.
+
+One authentification method of the HBCI protocol requires only a PIN for 
+login, and a TAN (transaction number) for each issued online order. We 
+can use this as a shared test account, because anyone who knows the PIN 
+(and some TANs) can use it. So I invite all you fellow developers to 
+install the HBCI features of gnucash, start the HBCI setup druid, setup 
+a Pin/Tan-based HBCI account, and just try out all the possible 
+features. Naturally, this test account won't move any real money around )
+
+(The Pin/Tan authentification method was added in 1.8.10 when changing 
+the HBCI library to Aqbanking. This method is rather insecure, but since 
+it is very simple to use there is quite some demand for it. So we 
+eventually implemented it in gnucash. I wouldn't recommend this for real 
+online banking if there is any of the other HBCI authentification 
+methods like chip cards or RSA keys available.)
+
+Here's what you need to enter in the HBCI setup druid:
+* "Use Pin/Tan mode"
+* Bank Code: 80007777
+   Server: www.hora-obscura.de/pintan/PinTanServlet 
+   (the URL changed on 2005-01-15)
+
+   User-Name: (something arbitrary; only for yourself)
+   User-Id: gnucash
+   Customer-Id: gnucash [or as a second customer: gnucash2]
+* Then press next all the time
+* For this user the PIN is: 12345
+* The setup druid should automatically recognize that this account 
+  offers access to the account numbers "2501111538" and "2501111539"
+* That finishes the setup.
+
+If you want to send money between these two account numbers back and 
+forth, you can do so by using any of the following TANs:
+                                  11111111
+                                  22222222
+                                  ...
+                                  99999999
+
+Enjoy! Don't hesitate to notify me if anything is broke.
+
+Christian stimming at tuhh.de
+
+
+There's an administrator web frontend reachable under
+https://www.hora-obscura.de/hbci wheren the used TANs can be
+resetted. The password for this can be asked from Christian Stimming.
Index: gnc-hbci-getbalance.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-getbalance.c,v
retrieving revision 1.13.2.7
retrieving revision 1.13.2.8
diff -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -u -r1.13.2.7 -r1.13.2.8
--- src/import-export/hbci/gnc-hbci-getbalance.c
+++ src/import-export/hbci/gnc-hbci-getbalance.c
@@ -102,9 +102,7 @@
     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 @@
 				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);
   }
Index: gnc-hbci-gettrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-gettrans.c,v
retrieving revision 1.20.2.5
retrieving revision 1.20.2.6
diff -Lsrc/import-export/hbci/gnc-hbci-gettrans.c -Lsrc/import-export/hbci/gnc-hbci-gettrans.c -u -r1.20.2.5 -r1.20.2.6
--- src/import-export/hbci/gnc-hbci-gettrans.c
+++ src/import-export/hbci/gnc-hbci-gettrans.c
@@ -109,9 +109,7 @@
     /* 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_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);
Index: gnc-hbci-transfer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-transfer.c,v
retrieving revision 1.7.2.9
retrieving revision 1.7.2.10
diff -Lsrc/import-export/hbci/gnc-hbci-transfer.c -Lsrc/import-export/hbci/gnc-hbci-transfer.c -u -r1.7.2.9 -r1.7.2.10
--- src/import-export/hbci/gnc-hbci-transfer.c
+++ src/import-export/hbci/gnc-hbci-transfer.c
@@ -135,15 +135,9 @@
 	    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


More information about the gnucash-changes mailing list