r14702 - gnucash/trunk/src/import-export - More code refactoring of aqbanking module:
Christian Stimming
cstim at cvs.gnucash.org
Mon Aug 21 16:30:42 EDT 2006
Author: cstim
Date: 2006-08-21 16:30:41 -0400 (Mon, 21 Aug 2006)
New Revision: 14702
Trac: http://svn.gnucash.org/trac/changeset/14702
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
gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c
gnucash/trunk/src/import-export/mt940/gnc-mt940-import.h
gnucash/trunk/src/import-export/mt940/gnc-plugin-mt940.c
Log:
More code refactoring of aqbanking module:
Make importer name a function argument so that more menu items can be added easily.
Modified: gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c 2006-08-20 21:57:33 UTC (rev 14701)
+++ gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.c 2006-08-21 20:30:41 UTC (rev 14702)
@@ -141,7 +141,8 @@
* Entry point
\********************************************************************/
-void gnc_file_dtaus_import (void)
+void gnc_file_dtaus_import (const gchar *aqbanking_importername,
+ const gchar *aqbanking_profilename)
{
char *selected_filename;
char *default_dir;
@@ -184,10 +185,8 @@
GWEN_DB_NODE *dbProfiles;
GWEN_DB_NODE *dbProfile;
GNCInteractor *interactor = NULL;
- const char *importerName = "dtaus"; /* possible values: csv, swift, dtaus, */
- const char *profileName = "default";
- /* Possible values for profile: "default" for most importers;
- for swift this can be "swiftmt940" or "swiftmt942". */
+ const char *importerName = aqbanking_importername;
+ const char *profileName = aqbanking_profilename;
/* Get API */
ab = gnc_AB_BANKING_new_currentbook (NULL, &interactor);
@@ -225,6 +224,15 @@
profileName, importerName);
printf("Profile \"%s\" for importer \"%s\" not found\n",
profileName, importerName);
+ /* For debugging: Print those available names that have been found. */
+ dbProfile=GWEN_DB_GetFirstGroup(dbProfiles);
+ while(dbProfile) {
+ const char *name;
+ name=GWEN_DB_GetCharValue(dbProfile, "name", 0, 0);
+ g_assert(name);
+ printf("Only found profile \"%s\"\n", name);
+ dbProfile=GWEN_DB_GetNextGroup(dbProfile);
+ }
return;
}
g_assert(dbProfile);
Modified: gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h 2006-08-20 21:57:33 UTC (rev 14701)
+++ gnucash/trunk/src/import-export/hbci/gnc-dtaus-import.h 2006-08-21 20:30:41 UTC (rev 14702)
@@ -29,6 +29,18 @@
* selection dialogue asking the user to pick an DTAUS file. If one
* is selected then the DTAUS file is opened and read. Its contents
* are merged into the existing session (if any). The current
- * session continues to remain open for editing. */
-void gnc_file_dtaus_import (void);
+ * session continues to remain open for editing.
+ *
+ * @param aqbanking_importername The aqbanking importer module that
+ * should be used. Possible values: "dtaus", "csv", "swift".
+ *
+ * @param aqbanking_profilename In aqbanking, each importer has one or
+ * more "profiles" that define the actual data fields that should be
+ * used. Possible values for swift: "swift-mt940" or "swift-mt942",
+ * but for all others: "default", or more precisely: Look into
+ * $datadir/aqbanking/imexporters and look into the "name" field of
+ * the foo.conf files.
+ */
+void gnc_file_dtaus_import (const gchar *aqbanking_importername,
+ const gchar *aqbanking_profilename);
#endif
Modified: gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c 2006-08-20 21:57:33 UTC (rev 14701)
+++ gnucash/trunk/src/import-export/hbci/gnc-plugin-hbci.c 2006-08-21 20:30:41 UTC (rev 14702)
@@ -523,7 +523,7 @@
gnc_plugin_hbci_cmd_dtaus_import (GtkAction *action,
GncMainWindowActionData *data)
{
- gnc_file_dtaus_import ();
+ gnc_file_dtaus_import ("dtaus", "default");
}
/************************************************************
* Plugin Bootstrapping *
Modified: gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c
===================================================================
--- gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c 2006-08-20 21:57:33 UTC (rev 14701)
+++ gnucash/trunk/src/import-export/mt940/gnc-mt940-import.c 2006-08-21 20:30:41 UTC (rev 14702)
@@ -128,7 +128,8 @@
* Entry point
\********************************************************************/
-void gnc_file_mt940_import (void)
+void gnc_file_mt940_import (const gchar *aqbanking_importername,
+ const gchar *aqbanking_profilename)
{
char *selected_filename;
char *default_dir;
@@ -170,8 +171,8 @@
GWEN_BUFFEREDIO *buffio;
GWEN_DB_NODE *dbProfiles;
GWEN_DB_NODE *dbProfile;
- const char *importerName = "swift"; /* possible values: csv, swift, dtaus, */
- const char *profileName = "swift-mt940";
+ const char *importerName = aqbanking_importername;
+ const char *profileName = aqbanking_profilename; /* "swift-mt940"; */
/* Possible values for profile: "swiftmt942", but for other
importers: "default" */
@@ -206,6 +207,15 @@
profileName, importerName);
printf("Profile \"%s\" for importer \"%s\" not found\n",
profileName, importerName);
+ /* For debugging: Print those available names that have been found. */
+ dbProfile=GWEN_DB_GetFirstGroup(dbProfiles);
+ while(dbProfile) {
+ const char *name;
+ name=GWEN_DB_GetCharValue(dbProfile, "name", 0, 0);
+ g_assert(name);
+ printf("Only found profile \"%s\"\n", name);
+ dbProfile=GWEN_DB_GetNextGroup(dbProfile);
+ }
return;
}
g_assert(dbProfile);
Modified: gnucash/trunk/src/import-export/mt940/gnc-mt940-import.h
===================================================================
--- gnucash/trunk/src/import-export/mt940/gnc-mt940-import.h 2006-08-20 21:57:33 UTC (rev 14701)
+++ gnucash/trunk/src/import-export/mt940/gnc-mt940-import.h 2006-08-21 20:30:41 UTC (rev 14702)
@@ -29,6 +29,18 @@
* selection dialogue asking the user to pick an MT940 file. If one
* is selected then the MT940 file is opened and read. Its contents
* are merged into the existing session (if any). The current
- * session continues to remain open for editing. */
-void gnc_file_mt940_import (void);
+ * session continues to remain open for editing.
+ *
+ * @param aqbanking_importername The aqbanking importer module that
+ * should be used. Possible values: "dtaus", "csv", "swift".
+ *
+ * @param aqbanking_profilename In aqbanking, each importer has one or
+ * more "profiles" that define the actual data fields that should be
+ * used. Possible values for swift: "swift-mt940" or "swift-mt942",
+ * but for all others: "default", or more precisely: Look into
+ * $datadir/aqbanking/imexporters and look into the "name" field of
+ * the foo.conf files.
+ */
+void gnc_file_mt940_import (const gchar *aqbanking_importername,
+ const gchar *aqbanking_profilename);
#endif
Modified: gnucash/trunk/src/import-export/mt940/gnc-plugin-mt940.c
===================================================================
--- gnucash/trunk/src/import-export/mt940/gnc-plugin-mt940.c 2006-08-20 21:57:33 UTC (rev 14701)
+++ gnucash/trunk/src/import-export/mt940/gnc-plugin-mt940.c 2006-08-21 20:30:41 UTC (rev 14702)
@@ -145,7 +145,7 @@
gnc_plugin_mt940_cmd_import (GtkAction *action,
GncMainWindowActionData *data)
{
- gnc_file_mt940_import ();
+ gnc_file_mt940_import ("swift", "swift-mt940");
}
More information about the gnucash-changes
mailing list