41#include <glib/gi18n.h>
42#include <glib/gstdio.h>
48#include <gwenhywfar/syncio_file.h>
49#include <gwenhywfar/syncio_buffered.h>
50#include <gwenhywfar/gui.h>
51typedef GWEN_SYNCIO GWEN_IO_LAYER;
55#include "dialog-utils.h"
57#include "gnc-file-aqb-import.h"
66static QofLogModule log_module = GNC_MOD_IMPORT;
68static AB_IMEXPORTER_CONTEXT*
69named_import_get_context (GtkWindow *parent, AB_BANKING *api,
70 const gchar *aqbanking_importername,
71 const gchar *aqbanking_profilename)
73 AB_IMEXPORTER_CONTEXT *context;
76 char *default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_AQBANKING);
77 char *selected_filename =
78 gnc_file_dialog(parent,
_(
"Select a file to import"),
79 NULL, default_dir, GNC_FILE_DIALOG_IMPORT);
82 if (!selected_filename)
84 DEBUG(
"filename: %s", selected_filename);
87 default_dir = g_path_get_dirname(selected_filename);
88 gnc_set_default_directory(GNC_PREFS_GROUP_AQBANKING, default_dir);
92 context = AB_ImExporterContext_new();
94 AB_Banking_ImportFromFileLoadProfile(api, aqbanking_importername,
95 context, aqbanking_profilename,
96 NULL, selected_filename);
97 g_free (selected_filename);
100 AB_ImExporterContext_free(context);
101 g_warning(
"gnc_file_aqbanking_import: Error on import");
107static const char *GNC_STATE_SECTION =
"dialogs.aqb.file-import";
108static const char *STATE_KEY_LAST_FORMAT =
"format";
109static const char *STATE_KEY_LAST_PROFILE =
"profile";
112load_imexporter_and_profile(
char** imexporter,
char** profile)
116 if (g_key_file_has_key(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_FORMAT, NULL))
117 *imexporter = g_key_file_get_string (state_file, GNC_STATE_SECTION, STATE_KEY_LAST_FORMAT, NULL);
119 if (g_key_file_has_key(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_PROFILE, NULL))
120 *profile = g_key_file_get_string (state_file, GNC_STATE_SECTION, STATE_KEY_LAST_PROFILE, NULL);
124save_imexporter_and_profile(
const char* imexporter,
const char *profile)
128 g_key_file_set_string(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_FORMAT, imexporter);
129 g_key_file_set_string(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_PROFILE, profile);
136 GncABSelectImExDlg* imexd =
138 char *imexporter = NULL, *profile = NULL;
139 AB_IMEXPORTER_CONTEXT* ctx = NULL;
144 PERR (
"Failed to create select imex dialog.");
148 load_imexporter_and_profile(&imexporter, &profile);
161 if (imexporter && profile)
163 ctx = named_import_get_context (parent, api, imexporter, profile);
168 GncABImExContextImport* ieci = NULL;
171 AB_ImExporterContext_free(ctx);
174 save_imexporter_and_profile(imexporter, profile);
Dialog to select AQBanking importer/exporter and format profile.
Dialog for AqBanking transaction data.
AqBanking utility functions.
GUI callbacks for AqBanking.
Functions to load, save and get gui state.
utility functions for the GnuCash UI
void gnc_ab_select_imex_dlg_destroy(GncABSelectImExDlg *imexd)
Destroy an AQBanking importer/exporter selection dialog.
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
Import balances and transactions found in a AB_IMEXPORTER_CONTEXT into GnuCash.
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Finish the AB_BANKING api.
char * gnc_ab_select_imex_dlg_get_imexporter_name(GncABSelectImExDlg *imexd)
Get the selected importer/exporter name.
void gnc_ab_select_imex_dlg_set_profile_name(GncABSelectImExDlg *imexd, const char *name)
Get the selected file format profile name.
char * gnc_ab_select_imex_dlg_get_profile_name(GncABSelectImExDlg *imexd)
Get the selected file format profile name.
GncABSelectImExDlg * gnc_ab_select_imex_dlg_new(GtkWidget *parent, AB_BANKING *abi)
Create an AQBanking importer/exporter selection dialog.
AB_BANKING * gnc_AB_BANKING_new(void)
If there is a cached AB_BANKING object, return it initialized.
gboolean gnc_ab_select_imex_dlg_run(GncABSelectImExDlg *imexd)
Run an AQBanking importer/exporter selection dialog.
void gnc_file_aqbanking_import_dialog(GtkWindow *parent)
Import files via AQBanking's Import Dialog.
void gnc_ab_select_imex_dlg_set_imexporter_name(GncABSelectImExDlg *imexd, const char *name)
Get the selected importer/exporter name.
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
#define DEBUG(format, args...)
Print a debugging message.
#define PERR(format, args...)
Log a serious error.
Generic and very flexible account matcher/picker.
Transaction matcher main window.