[Gnucash-changes] r12835 - gnucash/trunk - Add initial work on upgrading the old non-compilable mt940-importer

Christian Stimming cstim at cvs.gnucash.org
Tue Jan 17 16:26:45 EST 2006


Author: cstim
Date: 2006-01-17 16:26:44 -0500 (Tue, 17 Jan 2006)
New Revision: 12835
Trac: http://svn.gnucash.org/trac/changeset/12835

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c
Log:
Add initial work on upgrading the old non-compilable mt940-importer
code by F. Steinel. Code still non-compilable, see
http://bugzilla.gnome.org/show_bug.cgi?id=325170



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-01-17 19:31:08 UTC (rev 12834)
+++ gnucash/trunk/ChangeLog	2006-01-17 21:26:44 UTC (rev 12835)
@@ -1,3 +1,10 @@
+2006-01-17  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/mt940/gnc-mt940-import.c: Add initial work on
+	upgrading the old non-compilable mt940-importer code by
+	F. Steinel. Code still non-compilable, see
+	http://bugzilla.gnome.org/show_bug.cgi?id=325170
+
 2006-01-17  Neil Williams <linux at codehelp.co.uk>
 
 	* src/engine/gnc-engine.c : Removing .la from

Modified: gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c
===================================================================
--- gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c	2006-01-17 19:31:08 UTC (rev 12834)
+++ gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c	2006-01-17 21:26:44 UTC (rev 12835)
@@ -21,8 +21,9 @@
 /** @internal
      @file gnc-mt940-import.c
      @brief MT940 import module code
-     @author Copyright (c) 2002 Benoit Grégoire <bock at step.polymtl.ca>, Copyright (c) 2003 Jan-Pascal van Best <janpascal at vanbest.org>
+     @author Copyright (c) 2002 Benoit Grégoire <bock at step.polymtl.ca>, Copyright (c) 2003 Jan-Pascal van Best <janpascal at vanbest.org>, Copyright (c) 2006 Florian Steinel
  */
+ /* See aqbanking-1.6.0beta/src/tools/aqbanking-tool/import.c for hints */
 #define _GNU_SOURCE
 
 #include "config.h"
@@ -32,7 +33,7 @@
 #include <string.h>
 #include <sys/time.h>
 
-#include <openhbci/swiftparser.h>
+#include <aqbanking/imexporter.h>
 
 #include "gnc-hbci-gettrans.h"
 #include "import-account-matcher.h"
@@ -56,6 +57,13 @@
 static void *trans_importer_cb (const HBCI_Transaction *h_trans, 
 			    void *user_data);
 
+
+/* Note: This file is broken. See
+   http://bugzilla.gnome.org/show_bug.cgi?id=325170 .  The patch from
+   there is already included, but the file still won't compile. */
+
+
+
 /********************************************************************\
  * gnc_file_mt940_import
  * Entry point
@@ -110,19 +118,39 @@
       {
         int pos=0;
         int result;
-        HBCI_transactionReport *tr;
+	AB_BANKING *tr;
+	AB_IMEXPORTER *importer;
+	AB_IMEXPORTER_CONTEXT *ctx=0;
+	GWEN_DB_NODE *dbCtx;
         const list_HBCI_Transaction *transactions;
         /*list_HBCI_Transaction_iter *iter;*/
 
-        tr=HBCI_transactionReport_new();
-        
+        tr=AB_Banking_new();
+	/* get import module */
+	importer=AB_Banking_GetImExporter(tr, "swift"); /* possible values: csv, swift, dtaus, */
+  	if (!importer) {
+	  DEBUG("Import module swift not found");
+	}
+
+	/* load the import profile */
+	//dbProfiles=AB_Banking_GetImExporterProfiles(tr, "swift");
+	dbProfile="default";
+
+	/* import new context */
+	ctx=AB_ImExporterContext_new();
+	
         while(pos<filesize){
           DEBUG("Parsing mt940 string, pos=%d\n",pos);
 
-          result=HBCI_SWIFTparser_readMT940(mt940_records,tr,&pos);
+          result=AB_ImExporter_Import(importer,
+			  		ctx,
+					mt940_records,
+					dbProfile);
 
           DEBUG("Parsing result: %d\n", result);
 
+	  AB_ImExporterContext_toDb(ctx, dbCtx);
+
           transactions=HBCI_transactionReport_transactions(tr);
 
           DEBUG("Got %d transactions.\n",
@@ -134,6 +162,11 @@
         }
         HBCI_transactionReport_delete(tr);
       }
+      AB_ImExporterContext_free(ctx);
+      /* that's is */
+      result=AB_Banking_Fini(ab);
+      if (result) {
+	      DEBUG("ERROR: Error on deinit (%d)\n",result);
       g_free(mt940_records);
       g_free(selected_filename);
     }



More information about the gnucash-changes mailing list