From 739ce8a40c6fd0734efe790c5d1bf21ba3c34a98 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 2 Jul 2003 21:09:13 +0000 Subject: [PATCH] 2003-07-02 Christian Stimming * src/import-export/hbci/gnc-hbci-transfer.c, src/import-export/hbci/dialog-hbcitrans.c: Change HBCI online transfer action so that first the gnucash Transaction is created and only after that the HBCI connection is started. Necessary for later implementation of offline queueing and multi-job execution. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8818 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 8 ++ src/import-export/hbci/dialog-hbcitrans.c | 124 +++++++------------- src/import-export/hbci/dialog-hbcitrans.h | 29 ++++- src/import-export/hbci/druid-hbci-initial.c | 48 ++++---- src/import-export/hbci/druid-hbci-utils.c | 10 +- src/import-export/hbci/gnc-hbci-transfer.c | 116 ++++++++++++++---- src/import-export/hbci/gnc-hbci-transfer.h | 11 +- src/import-export/hbci/gnc-hbci-utils.c | 14 +-- src/import-export/hbci/hbci-interaction.c | 10 +- src/import-export/hbci/hbci-progressmon.c | 12 +- 10 files changed, 219 insertions(+), 163 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4019ce1762..6e5d8b729b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-07-02 Christian Stimming + + * src/import-export/hbci/gnc-hbci-transfer.c, + src/import-export/hbci/dialog-hbcitrans.c: Change HBCI online + transfer action so that first the gnucash Transaction is created + and only after that the HBCI connection is started. Necessary for + later implementation of offline queueing and multi-job execution. + 2003-07-01 David Hampton * src/backend/file/gnc-backend-file.c: New data file should have diff --git a/src/import-export/hbci/dialog-hbcitrans.c b/src/import-export/hbci/dialog-hbcitrans.c index 4d2aaa6fdd..95cf04d5ee 100644 --- a/src/import-export/hbci/dialog-hbcitrans.c +++ b/src/import-export/hbci/dialog-hbcitrans.c @@ -93,30 +93,56 @@ void gnc_hbci_dialog_delete(HBCITransDialog *td) /* Unregister handler for transaction creation callback */ if (td->gnc_trans_dialog) gnc_xfer_dialog_set_txn_cb(td->gnc_trans_dialog, NULL, NULL); + if (td->hbci_trans) + HBCI_Transaction_delete (td->hbci_trans); + gtk_widget_destroy (GTK_WIDGET (td->dialog)); #if HAVE_KTOBLZCHECK_H AccountNumberCheck_delete(td->blzcheck); #endif } +GList *gnc_hbci_dialog_get_templ(const HBCITransDialog *td) +{ + g_assert(td); + return td->templ; +} +GtkWidget *gnc_hbci_dialog_get_parent(const HBCITransDialog *td) +{ + g_assert(td); + return td->parent; +} +const HBCI_Transaction *gnc_hbci_dialog_get_htrans(const HBCITransDialog *td) +{ + g_assert(td); + return td->hbci_trans; +} +Transaction *gnc_hbci_dialog_get_gtrans(const HBCITransDialog *td) +{ + g_assert(td); + return td->gnc_trans; +} +void gnc_hbci_dialog_hide(HBCITransDialog *td) +{ + g_assert(td); + gtk_widget_hide_all (td->dialog); +} +void gnc_hbci_dialog_show(HBCITransDialog *td) +{ + g_assert(td); + gtk_widget_show_all (td->dialog); +} /* -------------------------------------- */ /* Prototypes; callbacks for dialog function */ /* -------------------------------------- */ -int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td, - const HBCI_Account *h_acc); HBCI_Transaction * hbci_trans_fill_values(const HBCI_Account *h_acc, HBCITransDialog *td); gboolean check_ktoblzcheck(GtkWidget *parent, const HBCITransDialog *td, const HBCI_Transaction *trans); -HBCI_OutboxJob * -gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api, - const HBCI_Customer *customer, - HBCI_Account *h_acc, - GNC_HBCI_Transtype trans_type) ; void template_selection_cb(GtkButton *b, gpointer user_data); void add_template_cb(GtkButton *b, gpointer user_data); @@ -128,75 +154,7 @@ void blz_changed_cb(GtkEditable *e, gpointer user_data); /* Main dialog function */ /* -------------------------------------- */ - -HBCI_Transaction * -gnc_hbci_trans (GtkWidget *parent, - HBCI_API *api, - GNCInteractor *interactor, - const HBCI_Account *h_acc, - const HBCI_Customer *customer, - Account *gnc_acc, - GNC_HBCI_Transtype trans_type, - GList **templ) -{ - int result; - gboolean successful; - HBCITransDialog *td; - - /* Create new HBCIDialogTrans */ - td = gnc_hbci_dialog_new(parent, h_acc, customer, gnc_acc, trans_type, templ); - - /* Repeat until HBCI action was successful or user pressed cancel */ - do { - - /* Let the user enter the values. If cancel is pressed, -1 is returned. */ - result = gnc_hbci_dialog_run_until_ok(td, h_acc); - - /* Set the template list in case the dialog got cancelled. */ - *templ = td->templ; - - if (result < 0) { - gnc_hbci_dialog_delete(td); - return NULL; - } - - /* Make really sure the dialog is hidden now. */ - gtk_widget_hide_all (td->dialog); - - { - HBCI_OutboxJob *job = - gnc_hbci_trans_dialog_enqueue(td, api, customer, - (HBCI_Account *)h_acc, trans_type); - - if (result == 0) { - - /* If the user pressed "execute now", then execute this job - now. This function already delete()s the job. */ - successful = gnc_hbci_trans_dialog_execute(td, api, job, interactor); - - } /* result == 0 */ - else { - /* huh? Only result == 0 should be possible. Simply ignore - this case. */ - break; - } /* result == 0 */ - - } /* Create a do-transaction (transfer) job */ - - } while (!successful); - - - /* Just to be on the safe side, clear queue once again. */ - HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE); - { - HBCI_Transaction *trans = td->hbci_trans; - gnc_hbci_dialog_delete(td); - return trans; - } -} - - - +/* doesn't exist any longer */ /* ************************************************************ * constructor @@ -224,7 +182,7 @@ gnc_hbci_dialog_new (GtkWidget *parent, const HBCI_Customer *customer, Account *gnc_acc, GNC_HBCI_Transtype trans_type, - GList **templ) + GList *templates) { GladeXML *xml; const HBCI_Bank *bank; @@ -233,7 +191,7 @@ gnc_hbci_dialog_new (GtkWidget *parent, td = g_new0(HBCITransDialog, 1); td->parent = parent; - td->templ = *templ; + td->templ = templates; g_assert (h_acc); g_assert (customer); bank = HBCI_Account_bank (h_acc); @@ -582,8 +540,8 @@ gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api, break; default: { - /*printf("dialog-hbcitrans: Oops, unknown GNC_HBCI_Transtype %d.\n", - trans_type);*/ + /*printf("dialog-hbcitrans: Oops, unknown GNC_HBCI_Transtype %d.\n", + trans_type);*/ HBCI_OutboxJobTransfer *transfer_job = HBCI_OutboxJobTransfer_new (customer, h_acc, td->hbci_trans); job = HBCI_OutboxJobTransfer_OutboxJob (transfer_job); @@ -769,8 +727,10 @@ void gnc_hbci_dialog_xfer_cb(Transaction *trans, gpointer user_data) td->gnc_trans_dialog = NULL; } else { - gnc_xfer_dialog_set_txn_cb(td->gnc_trans_dialog, NULL, NULL); - td->gnc_trans_dialog = NULL; + if (td->gnc_trans_dialog) { + gnc_xfer_dialog_set_txn_cb(td->gnc_trans_dialog, NULL, NULL); + td->gnc_trans_dialog = NULL; + } } return; } diff --git a/src/import-export/hbci/dialog-hbcitrans.h b/src/import-export/hbci/dialog-hbcitrans.h index a3d478d8a7..2f94691d95 100644 --- a/src/import-export/hbci/dialog-hbcitrans.h +++ b/src/import-export/hbci/dialog-hbcitrans.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "Account.h" #include "hbci-interaction.h" @@ -42,7 +43,7 @@ typedef enum GNC_HBCI_Transtype { } GNC_HBCI_Transtype; -HBCI_Transaction * +/*HBCI_Transaction * gnc_hbci_trans (GtkWidget *parent, HBCI_API *api, GNCInteractor *interactor, @@ -50,7 +51,7 @@ gnc_hbci_trans (GtkWidget *parent, const HBCI_Customer *customer, Account *gnc_acc, GNC_HBCI_Transtype type, - GList **templ); + GList **templ);*/ /** Constructor: Create a new HBCITransDialog, fill in the values as * specified by the arguments, and return a pointer to it. */ @@ -60,10 +61,32 @@ gnc_hbci_dialog_new (GtkWidget *parent, const HBCI_Customer *customer, Account *gnc_acc, GNC_HBCI_Transtype trans_type, - GList **templ); + GList *templ); /** Destructor */ void gnc_hbci_dialog_delete(HBCITransDialog *td); +/** Return the parent widget */ +GtkWidget *gnc_hbci_dialog_get_parent(const HBCITransDialog *td); +/** Return the GList of transaction templates. */ +GList *gnc_hbci_dialog_get_templ(const HBCITransDialog *td); +/** Return the HBCI_Transaction. */ +const HBCI_Transaction *gnc_hbci_dialog_get_htrans(const HBCITransDialog *td); +/** Return the gnucash Transaction. */ +Transaction *gnc_hbci_dialog_get_gtrans(const HBCITransDialog *td); +/** Hide the dialog */ +void gnc_hbci_dialog_hide(HBCITransDialog *td); +/** Show the dialog */ +void gnc_hbci_dialog_show(HBCITransDialog *td); + + + +int gnc_hbci_dialog_run_until_ok(HBCITransDialog *td, + const HBCI_Account *h_acc); +HBCI_OutboxJob * +gnc_hbci_trans_dialog_enqueue(HBCITransDialog *td, HBCI_API *api, + const HBCI_Customer *customer, + HBCI_Account *h_acc, + GNC_HBCI_Transtype trans_type); /** Callback function for gnc_xfer_dialog_set_txn_cb(). The user_data * has to be a pointer to a HBCITransDialog structure. */ void gnc_hbci_dialog_xfer_cb(Transaction *trans, gpointer user_data); diff --git a/src/import-export/hbci/druid-hbci-initial.c b/src/import-export/hbci/druid-hbci-initial.c index 33d268c6dd..13158c9e47 100644 --- a/src/import-export/hbci/druid-hbci-initial.c +++ b/src/import-export/hbci/druid-hbci-initial.c @@ -72,7 +72,7 @@ struct _hbciinitialinfo GtkWidget *bankcode; GtkWidget *countrycode; GtkWidget *ipaddr; - //GtkWidget *port; + /*GtkWidget *port;*/ /* user info page */ GtkWidget *userpage; @@ -252,7 +252,7 @@ update_accountlist (HBCIInitialInfo *info) g_assert(info->gnc_hash); banklist = HBCI_API_bankList (info->api); - //printf("%d banks found.\n", list_HBCI_Bank_size (banklist)); + /*printf("%d banks found.\n", list_HBCI_Bank_size (banklist));*/ if (list_HBCI_Bank_size (banklist) == 0) return; @@ -273,8 +273,8 @@ update_accountlist (HBCIInitialInfo *info) &update_accountlist_bank_cb, info); - //printf("HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash)); - //printf("GNC hash has %d entries.\n", g_hash_table_size(info->gnc_hash)); + /*printf("HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash));*/ + /*printf("GNC hash has %d entries.\n", g_hash_table_size(info->gnc_hash));*/ g_hash_table_thaw (info->hbci_hash); gtk_clist_thaw (GTK_CLIST (info->accountlist)); @@ -323,7 +323,7 @@ to_hexstring (const char *str) res[3*i+2] = '\n'; } res [3*i+2] = '\0'; - //printf ("Converted -%s- to -%s-.\n", str, res); + /*printf ("Converted -%s- to -%s-.\n", str, res);*/ return res; } static char * @@ -338,7 +338,7 @@ to_hexstring_hash (const char *str) res[3*i+2] = '\n'; } res [3*i+2] = '\0'; - //printf ("Converted -%s- to -%s-.\n", str, res); + /*printf ("Converted -%s- to -%s-.\n", str, res);*/ return res; } /* @@ -357,7 +357,7 @@ choose_one_bank (HBCIInitialInfo *info, int *list_size) /* Get HBCI bank and account list */ banklist = HBCI_API_bankList (info->api); - //printf("%d banks found.\n", list_HBCI_Bank_size (banklist)); + /*printf("%d banks found.\n", list_HBCI_Bank_size (banklist));*/ *list_size = list_HBCI_Bank_size (banklist); if (*list_size == 0) return NULL; @@ -636,8 +636,8 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage, g_free (filename); return TRUE; } - // file doesn't need to be created here since OpenHBCI will create - // it automatically. + /* file doesn't need to be created here since OpenHBCI will create + it automatically.*/ if (!gnc_test_dir_exist_error (GTK_WINDOW (info->window), filename)) { g_free (filename); @@ -666,7 +666,7 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage, if (api == NULL) return TRUE; } - // no libchipcard? Make that button greyed out + /* no libchipcard? Make that button greyed out*/ if (HBCI_API_mediumType(info->api, "DDVCard") != MediumTypeCard) { gtk_widget_set_sensitive (GTK_WIDGET (info->mediumddv), @@ -682,9 +682,9 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage, const list_HBCI_Bank *banklist; banklist = HBCI_API_bankList (api); - //printf("%d banks found.\n", list_HBCI_Bank_size (banklist)); + /*printf("%d banks found.\n", list_HBCI_Bank_size (banklist));*/ if (list_HBCI_Bank_size (banklist) == 0) { - // Zero banks? go to next page (create_bank) + /* Zero banks? go to next page (create_bank)*/ info->state = INI_ADD_BANK; gnome_druid_set_page (GNOME_DRUID (info->druid), GNOME_DRUID_PAGE (info->bankpage)); @@ -693,7 +693,7 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage, if (HBCI_API_totalUsers(api) == 0) { int dummy; - // zero users? go to user-creation page + /* zero users? go to user-creation page*/ info->state = INI_ADD_USER; info->newbank = choose_one_bank (info, &dummy); gnome_druid_set_page (GNOME_DRUID (info->druid), @@ -702,7 +702,7 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage, } if (HBCI_API_totalAccounts(api) == 0) { - // still no accounts? go to account update page + /* still no accounts? go to account update page*/ info->state = INI_UPDATE_ACCOUNTS; info->newcustomer = choose_customer (info); gnome_druid_set_page (GNOME_DRUID (info->druid), @@ -712,7 +712,7 @@ on_configfile_next (GnomeDruidPage *gnomedruidpage, } info->state = INI_MATCH_ACCOUNTS; - // accounts already exist? Then go to account matching page + /* accounts already exist? Then go to account matching page*/ gnome_druid_set_page (GNOME_DRUID (info->druid), GNOME_DRUID_PAGE (info->accountpage)); return TRUE; @@ -752,7 +752,7 @@ on_bankpage_next (GnomeDruidPage *gnomedruidpage, HBCIInitialInfo *info = user_data; const char *bankcode = NULL; int countrycode = 0; - const char *ipaddr = NULL;//, *port; + const char *ipaddr = NULL;/*, *port;*/ HBCI_Bank *bank = NULL; g_assert (info); g_assert (info->api); @@ -763,7 +763,7 @@ on_bankpage_next (GnomeDruidPage *gnomedruidpage, bank = HBCI_API_findBank(info->api, countrycode, bankcode); if (bank == NULL) { - //printf("on_bankpage_next: Creating bank with code %s.\n", bankcode); + /*printf("on_bankpage_next: Creating bank with code %s.\n", bankcode);*/ bank = HBCI_API_bankFactory (info->api, countrycode, bankcode, ipaddr); { HBCI_Error *err; @@ -901,7 +901,7 @@ on_userid_next (GnomeDruidPage *gnomedruidpage, const char *mediumtype; int secmode; - //printf("on_userid_next: Didn't find user with userid %s.\n", userid); + /*printf("on_userid_next: Didn't find user with userid %s.\n", userid);*/ is_rdh = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (info->mediumrdh)); @@ -910,7 +910,7 @@ on_userid_next (GnomeDruidPage *gnomedruidpage, mediumname = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (info->mediumpath), FALSE); - // Some sanity checks on the filename + /* Some sanity checks on the filename*/ if (!gnc_verify_exist_or_new_file (GTK_WIDGET (info->window), mediumname)) { g_free (mediumname); @@ -949,7 +949,7 @@ on_userid_next (GnomeDruidPage *gnomedruidpage, newuser = HBCI_API_userFactory (bank, medium, TRUE, userid); HBCI_User_setUserName (newuser, username); - //printf("on_userid_next: Created user with userid %s.\n", userid); + /*printf("on_userid_next: Created user with userid %s.\n", userid);*/ g_assert(newuser); err = HBCI_Bank_addUser (bank, newuser, TRUE); if (err != NULL) { @@ -1070,7 +1070,7 @@ on_accountinfo_next (GnomeDruidPage *gnomedruidpage, HBCI_API_clearQueueByStatus (info->api, HBCI_JOB_STATUS_NONE); } - //update_accountlist(info->api); + /*update_accountlist(info->api);*/ return FALSE; } @@ -1418,7 +1418,7 @@ on_iniletter_user_next (GnomeDruidPage *gnomedruidpage, gpointer arg1, gpointer user_data) { - //HBCIInitialInfo *info = user_data; + /*HBCIInitialInfo *info = user_data;*/ return FALSE; } @@ -1682,8 +1682,8 @@ void gnc_hbci_initial_druid (void) - //gtk_signal_connect (GTK_OBJECT(dialog), "destroy", - // GTK_SIGNAL_FUNC(gnc_hierarchy_destroy_cb), NULL); + /*gtk_signal_connect (GTK_OBJECT(dialog), "destroy",*/ + /* GTK_SIGNAL_FUNC(gnc_hierarchy_destroy_cb), NULL);*/ gtk_widget_show_all (info->window); diff --git a/src/import-export/hbci/druid-hbci-utils.c b/src/import-export/hbci/druid-hbci-utils.c index 8dadd02072..d4531ac606 100644 --- a/src/import-export/hbci/druid-hbci-utils.c +++ b/src/import-export/hbci/druid-hbci-utils.c @@ -114,9 +114,9 @@ update_accounts (GtkWidget *parent, HBCI_API *api, GNCInteractor *inter) g_assert(api); banklist = HBCI_API_bankList (api); - //printf("%d banks found.\n", list_HBCI_Bank_size (banklist)); + /*printf("%d banks found.\n", list_HBCI_Bank_size (banklist)); */ if (list_HBCI_Bank_size (banklist) == 0) { - // Zero banks? nothing to do. + /* Zero banks? nothing to do. */ return; } else if (list_HBCI_Bank_size (banklist) == 1) { @@ -141,7 +141,7 @@ update_accounts_forbank (GtkWidget *parent, HBCI_API *api, userlist = HBCI_Bank_users (bank); if (list_HBCI_User_size (userlist) == 0) { printf("update_accounts_forbank: Oops, zero users found.\n"); - // Zero users? nothing to do. + /* Zero users? nothing to do. */ return; } else if (list_HBCI_User_size (userlist) == 1) { @@ -166,7 +166,7 @@ update_accounts_foruser (GtkWidget *parent, HBCI_API *api, customerlist = HBCI_User_customers (user); if (list_HBCI_Customer_size (customerlist) == 0) { printf("update_accounts_foruser: Oops, zero customers found.\n"); - // Zero customers? nothing to do. + /* Zero customers? nothing to do. */ return; } else if (list_HBCI_Customer_size (customerlist) == 1) { @@ -190,7 +190,7 @@ update_accounts_forcustomer (GtkWidget *parent, HBCI_API *api, HBCI_OutboxJob *job; g_assert(cust); - // this const-warning is okay and can be ignored. + /* this const-warning is okay and can be ignored. */ get_job = HBCI_OutboxJobGetAccounts_new((HBCI_Customer *)cust); job = HBCI_OutboxJobGetAccounts_OutboxJob(get_job); HBCI_API_addJob(api, job); diff --git a/src/import-export/hbci/gnc-hbci-transfer.c b/src/import-export/hbci/gnc-hbci-transfer.c index 11d28afaab..e779f0acef 100644 --- a/src/import-export/hbci/gnc-hbci-transfer.c +++ b/src/import-export/hbci/gnc-hbci-transfer.c @@ -81,31 +81,90 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc, gnc_trans_templ_glist_from_kvp_glist ( gnc_hbci_get_book_template_list ( xaccAccountGetBook(gnc_acc))); - unsigned nr_templates = g_list_length(template_list); + unsigned nr_templates; + int result; + gboolean successful; + HBCITransDialog *td; /* Now open the HBCI_trans_dialog, which also calls HBCI_API_executeQueue. */ - HBCI_Transaction *h_trans = gnc_hbci_trans (parent, api, interactor, - h_acc, customer, - gnc_acc, - trans_type, &template_list); + + /* Create new HBCIDialogTrans */ + td = gnc_hbci_dialog_new(parent, h_acc, customer, gnc_acc, + trans_type, template_list); + + /* Repeat until HBCI action was successful or user pressed cancel */ + do { - /* New templates? If yes, store them */ - if (nr_templates < g_list_length(template_list)) - maketrans_save_templates(parent, gnc_acc, template_list, (h_trans != NULL)); + nr_templates = g_list_length(template_list); + + /* Let the user enter the values. If cancel is pressed, -1 is returned. */ + result = gnc_hbci_dialog_run_until_ok(td, h_acc); + + /* Set the template list in case it got modified. */ + template_list = gnc_hbci_dialog_get_templ(td); + /* New templates? If yes, store them */ + if (nr_templates < g_list_length(template_list)) + maketrans_save_templates(parent, gnc_acc, template_list, (result >= 0)); + + if (result < 0) { + break; + } + + /* Make really sure the dialog is hidden now. */ + gnc_hbci_dialog_hide(td); + + { + HBCI_OutboxJob *job = + gnc_hbci_trans_dialog_enqueue(td, api, customer, + (HBCI_Account *)h_acc, trans_type); + + /* HBCI Transaction has been created and enqueued, so now open + * the gnucash transaction dialog and fill in all values. */ + successful = gnc_hbci_maketrans_final (td, gnc_acc, trans_type); + + /* User pressed cancel? Then go back to HBCI transaction */ + if (!successful) + continue; + + if (result == 0) { + + /* If the user pressed "execute now", then execute this job + now. This function already delete()s the job. */ + successful = gnc_hbci_trans_dialog_execute(td, api, job, interactor); + + if (!successful) { + /* HBCI job failed -- then remove gnc txn from the books. */ + Transaction *gtrans = gnc_hbci_dialog_get_gtrans(td); + xaccTransBeginEdit(gtrans); + xaccTransDestroy(gtrans); + xaccTransCommitEdit(gtrans); + } + + } /* result == 0 */ + else { + /* huh? Only result == 0 should be possible. Simply ignore + this case. */ + break; + } /* result == 0 */ + + } /* Create a do-transaction (transfer) job */ + + } while (!successful); + + if (result >= 0) { + /* If we wanted to do something here with the gnc txn, we could. */ + Transaction *gtrans = gnc_hbci_dialog_get_gtrans(td); + printf("gnc-hbci-transfer: Got gnc txn w/ description: %s\n", + xaccTransGetDescription(gtrans)); + } + + /* Just to be on the safe side, clear queue once again. */ + HBCI_API_clearQueueByStatus (api, HBCI_JOB_STATUS_NONE); + gnc_hbci_dialog_delete(td); gnc_trans_templ_delete_glist (template_list); - if (!h_trans) - return; - /* GNCInteractor_hide (interactor); */ - - /* HBCI Transaction has finished, so now open the gnucash - transaction dialog and fill in all values. */ - gnc_hbci_maketrans_final (parent, gnc_acc, trans_type, h_trans, FALSE); - - /* Everything finished. */ - HBCI_Transaction_delete (h_trans); } } @@ -132,17 +191,21 @@ void maketrans_save_templates(GtkWidget *parent, Account *gnc_acc, } gboolean -gnc_hbci_maketrans_final (GtkWidget *parent, Account *gnc_acc, - GNC_HBCI_Transtype trans_type, - const HBCI_Transaction *h_trans, - gboolean run_until_done) +gnc_hbci_maketrans_final(HBCITransDialog *td, Account *gnc_acc, + GNC_HBCI_Transtype trans_type) { - /* HBCI Transaction has finished, so now open the gnucash - transaction dialog and fill in all values. */ gnc_numeric amount; XferDialog *transdialog; + const HBCI_Transaction *h_trans; + gboolean run_until_done = TRUE; + g_assert(td); + + h_trans = gnc_hbci_dialog_get_htrans(td); - transdialog = gnc_xfer_dialog (parent, gnc_acc); + /* HBCI Transaction has finished, so now open the gnucash + transaction dialog and fill in all values. */ + + transdialog = gnc_xfer_dialog (gnc_hbci_dialog_get_parent(td), gnc_acc); switch (trans_type) { case SINGLE_DEBITNOTE: @@ -181,6 +244,9 @@ gnc_hbci_maketrans_final (GtkWidget *parent, Account *gnc_acc, } /*gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_time)*/ + /* Set the callback for the Gnucash Transaction */ + gnc_xfer_dialog_set_txn_cb(transdialog, gnc_hbci_dialog_xfer_cb, td); + /* Run the dialog until the user has either successfully completed the * transaction (just clicking OK doesn't always count) or clicked Cancel. * Return TRUE if the transaction was a success, FALSE otherwise. diff --git a/src/import-export/hbci/gnc-hbci-transfer.h b/src/import-export/hbci/gnc-hbci-transfer.h index ed374be3a5..9772db5f76 100644 --- a/src/import-export/hbci/gnc-hbci-transfer.h +++ b/src/import-export/hbci/gnc-hbci-transfer.h @@ -33,13 +33,12 @@ gnc_hbci_maketrans (GtkWidget *parent, Account *gnc_acc, GNC_HBCI_Transtype trans_type); /** Open a gnucash transfer dialog for gnucash Account gnc_acc and - * fill in all the values from the HBCI_Transaction h_trans. Returns - * TRUE if the gnucash transaction has been successfully created. */ + * fill in all the values from the HBCI_Transaction inside the + * HBCITransDialog. Returns TRUE if the gnucash transaction has been + * successfully created, FALSE if e.g. the user pressed cancel. */ gboolean -gnc_hbci_maketrans_final (GtkWidget *parent, Account *gnc_acc, - GNC_HBCI_Transtype trans_type, - const HBCI_Transaction *h_trans, - gboolean run_until_done); +gnc_hbci_maketrans_final(HBCITransDialog *td, Account *gnc_acc, + GNC_HBCI_Transtype trans_type); #endif /* GNC_HBCI_TRANSFER_H */ diff --git a/src/import-export/hbci/gnc-hbci-utils.c b/src/import-export/hbci/gnc-hbci-utils.c index 7d779d7ab2..219593023c 100644 --- a/src/import-export/hbci/gnc-hbci-utils.c +++ b/src/import-export/hbci/gnc-hbci-utils.c @@ -90,7 +90,7 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile, gnc_hbci_api_interactors (api, parent); return api; -}; +} static HBCI_API *gnc_hbci_api = NULL; static char *gnc_hbci_configfile = NULL; @@ -122,7 +122,7 @@ HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent, GNCInteractor_reparent (*inter, parent); return gnc_hbci_api; } -}; +} void gnc_hbci_api_delete (HBCI_API *api) { @@ -160,17 +160,17 @@ gnc_hbci_get_hbci_acc (const HBCI_API *api, Account *gnc_acc) bankcode = gnc_hbci_get_account_bankcode (gnc_acc); countrycode = gnc_hbci_get_account_countrycode (gnc_acc); if (bankcode && (strlen(bankcode)>0) && (countrycode > 0)) { - //printf("gnc_acc %s has blz %s and ccode %d\n", - // xaccAccountGetName (gnc_acc), bankcode, countrycode); + /*printf("gnc_acc %s has blz %s and ccode %d\n", + xaccAccountGetName (gnc_acc), bankcode, countrycode);*/ bank = HBCI_API_findBank (api, countrycode, bankcode); if (bank) { accountid = gnc_hbci_get_account_accountid (gnc_acc); if (accountid && (strlen(accountid)>0)) { hbci_acc = HBCI_Bank_findAccount (bank, accountid); if (hbci_acc) { - //printf("can connect gnc_acc %s to hbci_acc %s\n", - // xaccAccountGetName (gnc_acc), - // HBCI_Account_accountId (hbci_acc)); + /*printf("can connect gnc_acc %s to hbci_acc %s\n", + xaccAccountGetName (gnc_acc), + HBCI_Account_accountId (hbci_acc));*/ return hbci_acc; } /* hbci_acc */ } /* accountid */ diff --git a/src/import-export/hbci/hbci-interaction.c b/src/import-export/hbci/hbci-interaction.c index 06abc96f9a..c69e79f863 100644 --- a/src/import-export/hbci/hbci-interaction.c +++ b/src/import-export/hbci/hbci-interaction.c @@ -56,10 +56,10 @@ GNCInteractor *gnc_hbci_api_interactors (HBCI_API *api, GtkWidget *parent) "HBCI Remember PIN in memory", FALSE); - // set HBCI_Interactor + /* set HBCI_Interactor */ HBCI_Hbci_setInteractor(HBCI_API_Hbci(api), gnc_hbci_new_interactor(data), TRUE); - // Set HBCI_Progressmonitor + /* Set HBCI_Progressmonitor */ HBCI_API_setMonitor(api, gnc_hbci_new_pmonitor(data), TRUE); return data; } @@ -269,7 +269,7 @@ static int msgInputPin(const HBCI_User *user, else { *pinbuf = g_strdup (passwd); if (user && data->cache_pin) { - //printf("Cached the PIN for user %s.\n", HBCI_User_userId (user)); + /*printf("Cached the PIN for user %s.\n", HBCI_User_userId (user));*/ data->user = user; if (data->pw) g_free (memset (data->pw, 0, strlen (data->pw))); @@ -427,7 +427,7 @@ static void msgStateResponse(const char *msg, void *user_data) g_assert(data); add_log_text (data, msg); - //fprintf(stdout,"hbci-initial-druid-msgStateResponse: %s\n",msg); + /*fprintf(stdout,"hbci-initial-druid-msgStateResponse: %s\n",msg);*/ /* Let the widgets be redrawn */ while (g_main_iteration (FALSE)); } @@ -436,7 +436,7 @@ static int keepAlive(void *user_data) { GNCInteractor *data = user_data; g_assert(data); - //fprintf(stdout, "my-keepAlive: returning 1\n"); + /*fprintf(stdout, "my-keepAlive: returning 1\n");*/ /* Let the widgets be redrawn */ while (g_main_iteration (FALSE)); diff --git a/src/import-export/hbci/hbci-progressmon.c b/src/import-export/hbci/hbci-progressmon.c index 79e5a3c78f..ba0ca8ceaf 100644 --- a/src/import-export/hbci/hbci-progressmon.c +++ b/src/import-export/hbci/hbci-progressmon.c @@ -76,7 +76,7 @@ static void transStarted (TransProgressType type, GNCInteractor_setRunning (data); - //printf("Executing %d jobs.\n",jobs); + /*printf("Executing %d jobs.\n",jobs);*/ data->jobs = jobs; data->current_job = 0; @@ -194,7 +194,7 @@ static void jobStarted(JobProgressType type, int actions, void *user_data) } g_assert(msg); - //printf("Jobstart (w/ %d actions): %s\n",actions, msg); + /*printf("Jobstart (w/ %d actions): %s\n",actions, msg);*/ data->actions = actions; data->current_act = 0; gtk_entry_set_text (GTK_ENTRY (data->job_entry), msg); @@ -212,9 +212,9 @@ static void jobFinished (void *user_data) g_assert(data); data->current_job++; gtk_entry_set_text (GTK_ENTRY (data->job_entry), _("Done")); - //gtk_entry_set_text (GTK_ENTRY (data->action_entry), _("Done")); - //GNCInteractor_setFinished (data); - //gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress), 1.0); + /*gtk_entry_set_text (GTK_ENTRY (data->action_entry), _("Done")); + GNCInteractor_setFinished (data); + gtk_progress_set_percentage (GTK_PROGRESS (data->action_progress), 1.0);*/ /* Let the widgets be redrawn */ while (g_main_iteration (FALSE)); if (debug_pmonitor) @@ -379,7 +379,7 @@ gnc_hbci_new_pmonitor(GNCInteractor *data) if (data->parent) gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (data->parent)); - //gtk_widget_set_parent (GTK_WIDGET (dialog), data->parent); + /*gtk_widget_set_parent (GTK_WIDGET (dialog), data->parent);*/ gtk_object_ref (GTK_OBJECT (dialog)); gtk_widget_hide_all (dialog);