2
* gnc-ab-getbalance.c --
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, contact:
17
* Free Software Foundation Voice: +1-617-542-5942
18
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
19
* Boston, MA 02110-1301, USA gnu@gnu.org
24
* @file gnc-ab-getbalance.c
25
* @brief AqBanking getbalance functions
26
* @author Copyright (C) 2002 Christian Stimming <stimming@tuhh.de>
27
* @author Copyright (C) 2008 Andreas Koehler <andi5.py@gmx.net>
32
#include <glib/gi18n.h>
33
#include <aqbanking/banking.h>
34
#include <aqbanking/jobgetbalance.h>
36
#include "gnc-ab-getbalance.h"
37
#include "gnc-ab-kvp.h"
38
#include "gnc-ab-utils.h"
39
#include "gnc-gwen-gui.h"
42
/* This static indicates the debugging module that this .o belongs to. */
43
static QofLogModule log_module = G_LOG_DOMAIN;
46
gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
49
gboolean online = FALSE;
52
AB_JOB_LIST2 *job_list = NULL;
53
GncGWENGui *gui = NULL;
54
AB_IMEXPORTER_CONTEXT *context = NULL;
55
GncABImExContextImport *ieci = NULL;
57
g_return_if_fail(parent && gnc_acc);
60
api = gnc_AB_BANKING_new();
62
g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
65
if (AB_Banking_OnlineInit(api) != 0) {
66
g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
71
/* Get the AqBanking Account */
72
ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
74
g_warning("gnc_ab_getbalance: No AqBanking account found");
78
/* Get a GetBalance job and enqueue it */
79
job = AB_JobGetBalance_new(ab_acc);
80
if (!job || AB_Job_CheckAvailability(job, 0)) {
81
g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
85
job_list = AB_Job_List2_new();
86
AB_Job_List2_PushBack(job_list, job);
88
/* Get a GUI object */
89
gui = gnc_GWEN_Gui_get(parent);
91
g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
95
/* Create a context to store the results */
96
context = AB_ImExporterContext_new();
99
if (AB_Banking_ExecuteJobs(api, job_list, context, 0)) {
100
g_warning("gnc_ab_getbalance: Error on executing job");
104
/* Import the results */
105
ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);
111
AB_ImExporterContext_free(context);
113
gnc_GWEN_Gui_release(gui);
115
AB_Job_List2_free(job_list);
119
AB_Banking_OnlineFini(api);
120
gnc_AB_BANKING_fini(api);