From e43e3e490f7b01b005d210acc7d4d0473f910ff0 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 1 Jan 2011 20:57:33 +0000 Subject: [PATCH] Bug #454109: Online banking: grey out online action menu items when there is no online account Patch by Manfred Usselmann: Show error message, if assigned online account is not valid or cannot be found or if the selected online action is not valid for this account. Improved checking if online job has been successfully executed. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20022 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../aqbanking/gnc-ab-getbalance.c | 20 +++++++++++++++--- src/import-export/aqbanking/gnc-ab-gettrans.c | 21 ++++++++++++++++--- src/import-export/aqbanking/gnc-ab-transfer.c | 1 + 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/import-export/aqbanking/gnc-ab-getbalance.c b/src/import-export/aqbanking/gnc-ab-getbalance.c index fd07f92b53..698a652334 100644 --- a/src/import-export/aqbanking/gnc-ab-getbalance.c +++ b/src/import-export/aqbanking/gnc-ab-getbalance.c @@ -53,6 +53,7 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) GncGWENGui *gui = NULL; AB_IMEXPORTER_CONTEXT *context = NULL; GncABImExContextImport *ieci = NULL; + AB_JOB_STATUS job_status; g_return_if_fail(parent && gnc_acc); @@ -79,6 +80,7 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) if (!ab_acc) { g_warning("gnc_ab_getbalance: No AqBanking account found"); + gnc_error_dialog(parent, _("No valid online banking account assigned.")); goto cleanup; } @@ -92,6 +94,7 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) { g_warning("gnc_ab_getbalance: JobGetBalance not available for this " "account"); + gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account.")); goto cleanup; } job_list = AB_Job_List2_new(); @@ -109,13 +112,24 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) context = AB_ImExporterContext_new(); /* Execute the job */ - if (AB_Banking_ExecuteJobs(api, job_list, context + AB_Banking_ExecuteJobs(api, job_list, context #ifndef AQBANKING_VERSION_5_PLUS - , 0 + , 0 #endif - )) + ); + /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's + * status always describes better whether the job was actually + * transferred to and accepted by the bank. See also + * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html + */ + job_status = AB_Job_GetStatus(job); + if (job_status != AB_Job_StatusFinished + && job_status != AB_Job_StatusPending) { g_warning("gnc_ab_getbalance: Error on executing job"); + gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s") + , AB_Job_Status2Char(job_status) + , AB_Job_GetResultText(job)); goto cleanup; } diff --git a/src/import-export/aqbanking/gnc-ab-gettrans.c b/src/import-export/aqbanking/gnc-ab-gettrans.c index 3b87fcebef..48106051e8 100644 --- a/src/import-export/aqbanking/gnc-ab-gettrans.c +++ b/src/import-export/aqbanking/gnc-ab-gettrans.c @@ -39,6 +39,7 @@ #include "gnc-ab-kvp.h" #include "gnc-ab-utils.h" #include "gnc-gwen-gui.h" +#include "gnc-ui.h" /* This static indicates the debugging module that this .o belongs to. */ static QofLogModule log_module = G_LOG_DOMAIN; @@ -106,6 +107,7 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) GncGWENGui *gui = NULL; AB_IMEXPORTER_CONTEXT *context = NULL; GncABImExContextImport *ieci = NULL; + AB_JOB_STATUS job_status; g_return_if_fail(parent && gnc_acc); @@ -132,6 +134,7 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) if (!ab_acc) { g_warning("gnc_ab_gettrans: No AqBanking account found"); + gnc_error_dialog(parent, _("No valid online banking account assigned.")); goto cleanup; } @@ -154,6 +157,7 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) { g_warning("gnc_ab_gettrans: JobGetTransactions not available for this " "account"); + gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account.")); goto cleanup; } AB_JobGetTransactions_SetFromTime(job, from_date); @@ -173,13 +177,24 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) context = AB_ImExporterContext_new(); /* Execute the job */ - if (AB_Banking_ExecuteJobs(api, job_list, context + AB_Banking_ExecuteJobs(api, job_list, context #ifndef AQBANKING_VERSION_5_PLUS - , 0 + , 0 #endif - )) + ); + /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's + * status always describes better whether the job was actually + * transferred to and accepted by the bank. See also + * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html + */ + job_status = AB_Job_GetStatus(job); + if (job_status != AB_Job_StatusFinished + && job_status != AB_Job_StatusPending) { g_warning("gnc_ab_gettrans: Error on executing job"); + gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s") + , AB_Job_Status2Char(job_status) + , AB_Job_GetResultText(job)); goto cleanup; } diff --git a/src/import-export/aqbanking/gnc-ab-transfer.c b/src/import-export/aqbanking/gnc-ab-transfer.c index 0dff738618..926a16b50a 100644 --- a/src/import-export/aqbanking/gnc-ab-transfer.c +++ b/src/import-export/aqbanking/gnc-ab-transfer.c @@ -115,6 +115,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc, if (!ab_acc) { g_warning("gnc_ab_gettrans: No AqBanking account found"); + gnc_error_dialog(parent, _("No valid online banking account assigned.")); goto cleanup; }