r14719 - gnucash/trunk/src/import-export/hbci - Generalize importing function so that this function can fully replace gnc_file_mt940_import and the whole mt940 module.

Christian Stimming cstim at cvs.gnucash.org
Wed Aug 23 15:29:01 EDT 2006


Author: cstim
Date: 2006-08-23 15:29:00 -0400 (Wed, 23 Aug 2006)
New Revision: 14719
Trac: http://svn.gnucash.org/trac/changeset/14719

Modified:
   gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c
   gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h
   gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c
Log:
Generalize importing function so that this function can fully replace gnc_file_mt940_import and the whole mt940 module.

Modified: gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c	2006-08-23 12:09:43 UTC (rev 14718)
+++ gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c	2006-08-23 19:29:00 UTC (rev 14719)
@@ -78,6 +78,7 @@
   AB_BANKING *ab;
   AB_ACCOUNT *hbci_account;
   GList *job_list;
+  gboolean execute_transactions;
 };
 
 
@@ -141,8 +142,9 @@
  * Entry point
 \********************************************************************/
 
-void gnc_file_dtaus_import (const gchar *aqbanking_importername,
-			    const gchar *aqbanking_profilename)
+void gnc_file_aqbanking_import (const gchar *aqbanking_importername,
+				const gchar *aqbanking_profilename,
+				gboolean execute_transactions)
 {
   char *selected_filename;
   char *default_dir;
@@ -269,6 +271,7 @@
 	data.importer_generic = importer_generic_gui;
 	data.ab = ab;
 	data.job_list = NULL;
+	data.execute_transactions = execute_transactions;
 
 	/* Iterate through all accounts */
 	AB_ImExporterContext_AccountInfoForEach(ctx, accountinfolist_cb, &data);
@@ -277,20 +280,24 @@
 	/* that's it */
 	g_free(selected_filename);
 
-	/* and run the gnucash importer. */
-	result = gnc_gen_trans_list_run (importer_generic_gui);
+	if (execute_transactions) {
+	  /* and run the gnucash importer. */
+	  result = gnc_gen_trans_list_run (importer_generic_gui);
 
-	if (result)
-	  /* NEW: Copied from gnc-hbci-transfer.c: */
-	  /* Execute these jobs now. This function already delete()s the
-	     job. */
-	  /* no parent so far: GNCInteractor_reparent (interactor, parent); */
-	  successful = gnc_hbci_multijob_execute (parent, ab, data.job_list, interactor);
-	/* else */
+	  if (result)
+	    /* Execute these jobs now. This function already delete()s the
+	       job. */
+	    /* no parent so far; otherwise add this: GNCInteractor_reparent (interactor, parent); */
+	    successful = gnc_hbci_multijob_execute (parent, ab, data.job_list, interactor);
+	  /* else */
+	  
+	  /* Delete all jobs from queue in any case. */
+	  g_list_foreach (data.job_list, delpending_cb, ab);
+	}
+	else {
+	  successful = TRUE;
+	}
 
-	/* Delete all jobs from queue in any case. */
-	g_list_foreach (data.job_list, delpending_cb, ab);
-
 	/* We clean up here. */
 	AB_ImExporterContext_free(ctx);
 	if (successful) {
@@ -323,12 +330,18 @@
   if (gnc_acc) {
     /* Store chosen gnucash account in callback data */
     data->gnc_acc = gnc_acc;
-    /* Retrieve the aqbanking account that belongs to this gnucash
-       account */
-    data->hbci_account = gnc_hbci_get_hbci_acc (data->ab, gnc_acc);
-    if (data->hbci_account == NULL) {
-      gnc_error_dialog (NULL, _("No HBCI account found for this gnucash account. These transactions will not be executed by HBCI."));
+
+    if (data->execute_transactions) {
+      /* Retrieve the aqbanking account that belongs to this gnucash
+	 account */
+      data->hbci_account = gnc_hbci_get_hbci_acc (data->ab, gnc_acc);
+      if (data->hbci_account == NULL) {
+	gnc_error_dialog (NULL, _("No HBCI account found for this gnucash account. These transactions will not be executed by HBCI."));
+      }
     }
+    else {
+      data->hbci_account = NULL;
+    }
   
     /* Iterate through all transactions.  */
     AB_ImExporterAccountInfo_TransactionsForEach (accinfo, translist_cb, data);

Modified: gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h	2006-08-23 12:09:43 UTC (rev 14718)
+++ gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h	2006-08-23 19:29:00 UTC (rev 14719)
@@ -40,7 +40,12 @@
  * but for all others: "default", or more precisely: Look into
  * $datadir/aqbanking/imexporters and look into the "name" field of
  * the foo.conf files.
+ *
+ * @param execute_transactions If TRUE, import the transactions and
+ * additionally send them as online jobs over aqbanking/HBCI. If
+ * FALSE, simply import the transactions and that's it.
  */
-void              gnc_file_dtaus_import (const gchar *aqbanking_importername,
-					 const gchar *aqbanking_profilename);
+void gnc_file_aqbanking_import (const gchar *aqbanking_importername,
+				const gchar *aqbanking_profilename,
+				gboolean execute_transactions);
 #endif

Modified: gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c	2006-08-23 12:09:43 UTC (rev 14718)
+++ gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c	2006-08-23 19:29:00 UTC (rev 14719)
@@ -523,7 +523,7 @@
 gnc_plugin_hbci_cmd_dtaus_import (GtkAction *action,
 				  GncMainWindowActionData *data)
 {
-  gnc_file_dtaus_import ("dtaus", "default");
+  gnc_file_aqbanking_import ("dtaus", "default", TRUE);
 }
 /************************************************************
  *                    Plugin Bootstrapping                   *



More information about the gnucash-changes mailing list