More code refactoring of aqbanking module:

Make importer name a function argument so that more menu items can be added easily.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14702 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2006-08-21 20:30:41 +00:00
parent c08483170a
commit 4bbe9d0b46
6 changed files with 56 additions and 14 deletions

View File

@ -141,7 +141,8 @@ AB_ImExporterAccountInfo_TransactionsForEach(AB_IMEXPORTER_ACCOUNTINFO *iea,
* Entry point * 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 *selected_filename;
char *default_dir; char *default_dir;
@ -184,10 +185,8 @@ void gnc_file_dtaus_import (void)
GWEN_DB_NODE *dbProfiles; GWEN_DB_NODE *dbProfiles;
GWEN_DB_NODE *dbProfile; GWEN_DB_NODE *dbProfile;
GNCInteractor *interactor = NULL; GNCInteractor *interactor = NULL;
const char *importerName = "dtaus"; /* possible values: csv, swift, dtaus, */ const char *importerName = aqbanking_importername;
const char *profileName = "default"; const char *profileName = aqbanking_profilename;
/* Possible values for profile: "default" for most importers;
for swift this can be "swiftmt940" or "swiftmt942". */
/* Get API */ /* Get API */
ab = gnc_AB_BANKING_new_currentbook (NULL, &interactor); ab = gnc_AB_BANKING_new_currentbook (NULL, &interactor);
@ -225,6 +224,15 @@ void gnc_file_dtaus_import (void)
profileName, importerName); profileName, importerName);
printf("Profile \"%s\" for importer \"%s\" not found\n", printf("Profile \"%s\" for importer \"%s\" not found\n",
profileName, importerName); 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; return;
} }
g_assert(dbProfile); g_assert(dbProfile);

View File

@ -29,6 +29,18 @@
* selection dialogue asking the user to pick an DTAUS file. If one * selection dialogue asking the user to pick an DTAUS file. If one
* is selected then the DTAUS file is opened and read. Its contents * is selected then the DTAUS file is opened and read. Its contents
* are merged into the existing session (if any). The current * are merged into the existing session (if any). The current
* session continues to remain open for editing. */ * session continues to remain open for editing.
void gnc_file_dtaus_import (void); *
* @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 #endif

View File

@ -523,7 +523,7 @@ static void
gnc_plugin_hbci_cmd_dtaus_import (GtkAction *action, gnc_plugin_hbci_cmd_dtaus_import (GtkAction *action,
GncMainWindowActionData *data) GncMainWindowActionData *data)
{ {
gnc_file_dtaus_import (); gnc_file_dtaus_import ("dtaus", "default");
} }
/************************************************************ /************************************************************
* Plugin Bootstrapping * * Plugin Bootstrapping *

View File

@ -128,7 +128,8 @@ AB_ImExporterAccountInfo_TransactionsForEach(AB_IMEXPORTER_ACCOUNTINFO *iea,
* Entry point * 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 *selected_filename;
char *default_dir; char *default_dir;
@ -170,8 +171,8 @@ void gnc_file_mt940_import (void)
GWEN_BUFFEREDIO *buffio; GWEN_BUFFEREDIO *buffio;
GWEN_DB_NODE *dbProfiles; GWEN_DB_NODE *dbProfiles;
GWEN_DB_NODE *dbProfile; GWEN_DB_NODE *dbProfile;
const char *importerName = "swift"; /* possible values: csv, swift, dtaus, */ const char *importerName = aqbanking_importername;
const char *profileName = "swift-mt940"; const char *profileName = aqbanking_profilename; /* "swift-mt940"; */
/* Possible values for profile: "swiftmt942", but for other /* Possible values for profile: "swiftmt942", but for other
importers: "default" */ importers: "default" */
@ -206,6 +207,15 @@ void gnc_file_mt940_import (void)
profileName, importerName); profileName, importerName);
printf("Profile \"%s\" for importer \"%s\" not found\n", printf("Profile \"%s\" for importer \"%s\" not found\n",
profileName, importerName); 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; return;
} }
g_assert(dbProfile); g_assert(dbProfile);

View File

@ -29,6 +29,18 @@
* selection dialogue asking the user to pick an MT940 file. If one * selection dialogue asking the user to pick an MT940 file. If one
* is selected then the MT940 file is opened and read. Its contents * is selected then the MT940 file is opened and read. Its contents
* are merged into the existing session (if any). The current * are merged into the existing session (if any). The current
* session continues to remain open for editing. */ * session continues to remain open for editing.
void gnc_file_mt940_import (void); *
* @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 #endif

View File

@ -145,7 +145,7 @@ static void
gnc_plugin_mt940_cmd_import (GtkAction *action, gnc_plugin_mt940_cmd_import (GtkAction *action,
GncMainWindowActionData *data) GncMainWindowActionData *data)
{ {
gnc_file_mt940_import (); gnc_file_mt940_import ("swift", "swift-mt940");
} }