diff --git a/src/import-export/hbci/druid-hbci-initial.c b/src/import-export/hbci/druid-hbci-initial.c index a131652479..e720ded529 100644 --- a/src/import-export/hbci/druid-hbci-initial.c +++ b/src/import-export/hbci/druid-hbci-initial.c @@ -48,12 +48,14 @@ #include "gnc-html.h" //#include "import-account-matcher.h" #include "gnc-component-manager.h" +#include "gnc-session.h" #include #include #include #include +#define DRUID_HBCI_IMPORT_CM_CLASS "druid-hbci-import" /* #define DEFAULT_HBCI_VERSION 201 */ enum account_list_cols { @@ -112,6 +114,8 @@ delete_initial_druid (HBCIInitialInfo *info) { if (info == NULL) return; + gnc_unregister_gui_component_by_data(DRUID_HBCI_IMPORT_CM_CLASS, info); + reset_initial_info (info); /* if (info->interactor) @@ -279,8 +283,7 @@ static gboolean banking_has_accounts(AB_BANKING *banking) static void -on_cancel (GnomeDruid *gnomedruid, - gpointer user_data) +cm_close_handler(gpointer user_data) { HBCIInitialInfo *info = user_data; @@ -290,6 +293,13 @@ on_cancel (GnomeDruid *gnomedruid, delete_initial_druid(info); } +static void +on_cancel (GnomeDruid *gnomedruid, + gpointer user_data) +{ + cm_close_handler(user_data); +} + static void on_finish (GnomeDruidPage *gnomedruidpage, gpointer arg1, @@ -650,6 +660,7 @@ void gnc_hbci_initial_druid (void) GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *selection; + gint component_id; info = g_new0 (HBCIInitialInfo, 1); @@ -719,6 +730,10 @@ void gnc_hbci_initial_druid (void) G_CALLBACK (on_accountlist_prepare), info); } + component_id = gnc_register_gui_component(DRUID_HBCI_IMPORT_CM_CLASS, + NULL, cm_close_handler, + info); + gnc_gui_component_set_session(component_id, gnc_get_current_session()); /*g_signal_connect (dialog, "destroy",*/ /* G_CALLBACK(gnc_hierarchy_destroy_cb), NULL);*/ diff --git a/src/import-export/hbci/hbci-interaction.c b/src/import-export/hbci/hbci-interaction.c index 5ae604da63..20e0787023 100644 --- a/src/import-export/hbci/hbci-interaction.c +++ b/src/import-export/hbci/hbci-interaction.c @@ -40,6 +40,8 @@ #include "gnc-ui-util.h" #include "gnc-ui.h" #include "gnc-gconf-utils.h" +#include "gnc-component-manager.h" +#include "gnc-session.h" #include "dialog-pass.h" #include "gnc-hbci-utils.h" @@ -70,13 +72,16 @@ GWEN_INHERIT(AB_BANKING, GNCInteractor) #define GCONF_SECTION_CONNECTION GCONF_SECTION "/connection_dialog" +#define DIALOG_HBCILOG_CM_CLASS "dialog-hbcilog" gchar *gnc__extractText(const char *text); +static void cm_close_handler(gpointer user_data); /** Adds the interactor and progressmonitor classes to the api. */ GNCInteractor *gnc_AB_BANKING_interactors (AB_BANKING *api, GtkWidget *parent) { GNCInteractor *data; + gint component_id; data = g_new0 (GNCInteractor, 1); data->parent = parent; @@ -94,6 +99,11 @@ GNCInteractor *gnc_AB_BANKING_interactors (AB_BANKING *api, GtkWidget *parent) data->showbox_hash = g_hash_table_new(NULL, NULL); data->min_loglevel = AB_Banking_LogLevelVerbous; + component_id = gnc_register_gui_component(DIALOG_HBCILOG_CM_CLASS, + NULL, cm_close_handler, + data); + gnc_gui_component_set_session(component_id, gnc_get_current_session()); + /* set HBCI_Interactor */ gnc_hbci_add_callbacks(api, data); return data; @@ -113,6 +123,8 @@ void GNCInteractor_delete(GNCInteractor *data) gtk_widget_destroy (data->dialog); } + gnc_unregister_gui_component_by_data(DIALOG_HBCILOG_CM_CLASS, data); + data->dialog = NULL; g_hash_table_destroy(data->showbox_hash); @@ -824,6 +836,37 @@ on_button_clicked (GtkButton *button, while (g_main_context_iteration(context, FALSE)); } +static void +cm_close_handler(gpointer user_data) +{ + GNCInteractor *data = user_data; + + GNCInteractor_setAborted(data); + /* Notes about correctly handling this ComponentManager close event: + We can't actually close the dialog here because AqBanking might + still be running and expecting the GNCInteractor object to exist + (and it doesn't offer any handlers for aborting from here). This + is not per se a problem with gnucash objects because as soon as + AqBanking received the SetAborted signal, it will abort and not + deliver any actual results, which means the gnc-hbci module will + not continue any operation. + + However, the dialog and the AB_BANKING object will still be + around. It is unclear whether this is 1. correct or 2. wrong: + 1. It might be correct because a user might still want to see the + log messages in the window until he manually closes the + GNCInteractor. 2. It might be wrong because once we've received + the close event, nobody wants to see the GNCInteractor log + messages anyway. To implement the behaviour #2, we should add a + new flag in GNCInteractor that is being queried in + gnc_AB_BANKING_execute() right after AB_Banking_ExecuteQueue() + has finished, and if it is activated from the cm_close_handler, + gnc_AB_BANKING_execute should immediately delete the AB_BANKING + object (which will also delete the GNCInteractor object) and + abort. + */ +} + /******************************************************** * Constructor