GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
AqBanking

Files

file  assistant-ab-initial.h
 AqBanking setup functionality.
 
file  dialog-ab-trans.h
 Dialog for AqBanking transaction data.
 
file  gnc-ab-getbalance.h
 AqBanking getbalance functions.
 
file  gnc-ab-getbalance.h
 AqBanking getbalance functions.
 
file  gnc-ab-kvp.h
 AqBanking KVP handling.
 
file  gnc-ab-trans-templ.h
 Templates for AqBanking transactions.
 
file  gnc-ab-transfer.h
 Dialog for AqBanking transaction data.
 
file  gnc-ab-utils.h
 AqBanking utility functions.
 
file  gnc-gwen-gui.h
 GUI callbacks for AqBanking.
 
file  gnc-plugin-aqbanking.h
 Plugin registration of the AqBanking module.
 

Data Structures

struct  GncPluginAqBanking
 
struct  GncPluginAqBankingClass
 

Macros

#define GNC_RESPONSE_NOW   GTK_RESPONSE_YES
 
#define GNC_RESPONSE_LATER   GTK_RESPONSE_NO
 
#define AQBANKING_VERSION_INT   (10000 * AQBANKING_VERSION_MAJOR + 100 * AQBANKING_VERSION_MINOR + AQBANKING_VERSION_PATCHLEVEL)
 
#define GWENHYWFAR_VERSION_INT   (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)
 
#define GNC_PREFS_GROUP_AQBANKING   "dialogs.import.hbci"
 
#define GNC_PREF_FORMAT_SWIFT940   "format-swift-mt940"
 
#define GNC_PREF_FORMAT_SWIFT942   "format-swift-mt942"
 
#define GNC_PREF_FORMAT_DTAUS   "format-dtaus"
 
#define GNC_PREF_VERBOSE_DEBUG   "verbose-debug"
 
#define AWAIT_BALANCES   1 << 1
 
#define FOUND_BALANCES   1 << 2
 
#define IGNORE_BALANCES   1 << 3
 
#define AWAIT_TRANSACTIONS   1 << 4
 
#define FOUND_TRANSACTIONS   1 << 5
 
#define IGNORE_TRANSACTIONS   1 << 6
 
#define GNC_TYPE_PLUGIN_AQBANKING   (gnc_plugin_aqbanking_get_type())
 
#define GNC_PLUGIN_AQBANKING(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBanking))
 
#define GNC_PLUGIN_AQBANKING_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
 
#define GNC_IS_PLUGIN_AQBANKING(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNC_TYPE_PLUGIN_AQBANKING))
 
#define GNC_IS_PLUGIN_AQBANKING_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNC_TYPE_PLUGIN_AQBANKING))
 
#define GNC_PLUGIN_AQBANKING_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GNC_TYPE_PLUGIN_AQBANKING, GncPluginAqBankingClass))
 
#define GNC_PLUGIN_AQBANKING_NAME   "gnc-plugin-aqbanking"
 

Typedefs

typedef struct _GncABTransDialog GncABTransDialog
 
typedef enum _GncABTransType GncABTransType
 
typedef typedefG_BEGIN_DECLS
struct _GncABTransTempl 
GncABTransTempl
 
typedef struct
_GncABImExContextImport 
GncABImExContextImport
 
typedef typedefG_BEGIN_DECLS
struct _GncGWENGui 
GncGWENGui
 

Enumerations

enum  _GncABTransType {
  SINGLE_TRANSFER = 0, SINGLE_DEBITNOTE, SINGLE_INTERNAL_TRANSFER, SEPA_TRANSFER,
  SEPA_DEBITNOTE
}
 

Functions

G_BEGIN_DECLS void gnc_ab_initial_assistant (void)
 
G_BEGIN_DECLS gboolean gnc_ab_enter_daterange (GtkWidget *parent, const char *heading, Timespec *from_date, gboolean *last_retv_date, gboolean *first_possible_date, Timespec *to_date, gboolean *to_now)
 
gboolean gnc_ab_trans_isSEPA (GncABTransType t)
 
GncABTransDialoggnc_ab_trans_dialog_new (GtkWidget *parent, AB_ACCOUNT *ab_acc, gint commodity_scu, GncABTransType trans_type, GList *templates)
 
gint gnc_ab_trans_dialog_run_until_ok (GncABTransDialog *td)
 
void gnc_ab_trans_dialog_free (GncABTransDialog *td)
 
GList * gnc_ab_trans_dialog_get_templ (const GncABTransDialog *td, gboolean *changed)
 
GtkWidget * gnc_ab_trans_dialog_get_parent (const GncABTransDialog *td)
 
const AB_TRANSACTION * gnc_ab_trans_dialog_get_ab_trans (const GncABTransDialog *td)
 
AB_JOB * gnc_ab_trans_dialog_get_job (const GncABTransDialog *td)
 
AB_JOB * gnc_ab_get_trans_job (AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans, GncABTransType trans_type)
 
G_BEGIN_DECLS void gnc_ab_getbalance (GtkWidget *parent, Account *gnc_acc)
 
G_BEGIN_DECLS void gnc_ab_gettrans (GtkWidget *parent, Account *gnc_acc)
 
GncABTransTemplgnc_ab_trans_templ_new (void)
 
GncABTransTemplgnc_ab_trans_templ_new_full (const gchar *name, const gchar *recp_name, const gchar *recp_account, const gchar *recp_bankcode, gnc_numeric amount, const gchar *purpose, const gchar *purpose_cont)
 
GncABTransTemplgnc_ab_trans_templ_new_from_kvp (const KvpFrame *k)
 
GList * gnc_ab_trans_templ_list_new_from_kvp_list (GList *v)
 
void gnc_ab_trans_templ_free (GncABTransTempl *t)
 
void gnc_ab_trans_templ_list_free (GList *l)
 
KvpFramegnc_ab_trans_templ_to_kvp (const GncABTransTempl *t)
 
GList * gnc_ab_trans_templ_list_to_kvp_list (GList *k)
 
const gchar * gnc_ab_trans_templ_get_name (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_recp_name (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_recp_account (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_recp_bankcode (const GncABTransTempl *t)
 
gnc_numeric gnc_ab_trans_templ_get_amount (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_purpose (const GncABTransTempl *t)
 
const gchar * gnc_ab_trans_templ_get_purpose_cont (const GncABTransTempl *t)
 
void gnc_ab_trans_templ_set_name (GncABTransTempl *t, const gchar *name)
 
void gnc_ab_trans_templ_set_recp_name (GncABTransTempl *t, const gchar *recp_name)
 
void gnc_ab_trans_templ_set_recp_account (GncABTransTempl *t, const gchar *recp_account)
 
void gnc_ab_trans_templ_set_recp_bankcode (GncABTransTempl *t, const gchar *recp_bankcode)
 
void gnc_ab_trans_templ_set_amount (GncABTransTempl *t, gnc_numeric amount)
 
void gnc_ab_trans_templ_set_purpose (GncABTransTempl *t, const gchar *purpose)
 
void gnc_ab_trans_templ_set_purpose_cont (GncABTransTempl *t, const gchar *purpose_cont)
 
G_BEGIN_DECLS void gnc_ab_maketrans (GtkWidget *parent, Account *gnc_acc, GncABTransType trans_type)
 
void gnc_GWEN_Init (void)
 
void gnc_GWEN_Fini (void)
 
AB_BANKING * gnc_AB_BANKING_new (void)
 
void gnc_AB_BANKING_delete (AB_BANKING *api)
 
gint gnc_AB_BANKING_fini (AB_BANKING *api)
 
AB_ACCOUNT * gnc_ab_get_ab_account (const AB_BANKING *api, Account *gnc_acc)
 
gchar * gnc_AB_VALUE_to_readable_string (const AB_VALUE *value)
 
gchar * gnc_AB_JOB_to_readable_string (const AB_JOB *job)
 
gchar * gnc_AB_JOB_ID_to_string (gulong job_id)
 
gchar * gnc_ab_get_remote_name (const AB_TRANSACTION *ab_trans)
 
gchar * gnc_ab_get_purpose (const AB_TRANSACTION *ab_trans)
 
gchar * gnc_ab_description_to_gnc (const AB_TRANSACTION *ab_trans)
 
gchar * gnc_ab_memo_to_gnc (const AB_TRANSACTION *ab_trans)
 
Transactiongnc_ab_trans_to_gnc (const AB_TRANSACTION *ab_trans, Account *gnc_acc)
 
GncABImExContextImportgnc_ab_import_context (AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
 
guint gnc_ab_ieci_get_found (GncABImExContextImport *ieci)
 
AB_JOB_LIST2 * gnc_ab_ieci_get_job_list (GncABImExContextImport *ieci)
 
gboolean gnc_ab_ieci_run_matcher (GncABImExContextImport *ieci)
 
GWEN_DB_NODE * gnc_ab_get_permanent_certs (void)
 
G_BEGIN_DECLS void gnc_file_aqbanking_import (const gchar *aqbanking_importername, const gchar *aqbanking_formatname, gboolean exec_as_aqbanking_jobs)
 
void gnc_GWEN_Gui_log_init (void)
 
GncGWENGui * gnc_GWEN_Gui_get (GtkWidget *parent)
 
void gnc_GWEN_Gui_release (GncGWENGui *gui)
 
void gnc_GWEN_Gui_shutdown (void)
 
void gnc_GWEN_Gui_set_close_flag (gboolean close_when_finished)
 
gboolean gnc_GWEN_Gui_get_close_flag (void)
 
gboolean gnc_GWEN_Gui_show_dialog (void)
 
void gnc_GWEN_Gui_hide_dialog (void)
 
GType gnc_plugin_aqbanking_get_type (void)
 
GncPlugingnc_plugin_aqbanking_new (void)
 
void gnc_plugin_aqbanking_create_plugin (void)
 
void gnc_plugin_aqbanking_set_logwindow_visible (gboolean logwindow_visible)
 

Account

const gchar * gnc_ab_get_account_accountid (const Account *a)
 
void gnc_ab_set_account_accountid (Account *a, const gchar *id)
 
const gchar * gnc_ab_get_account_bankcode (const Account *a)
 
void gnc_ab_set_account_bankcode (Account *a, const gchar *code)
 
guint32 gnc_ab_get_account_uid (const Account *a)
 
void gnc_ab_set_account_uid (Account *a, guint32 uid)
 
Timespec gnc_ab_get_account_trans_retrieval (const Account *a)
 
void gnc_ab_set_account_trans_retrieval (Account *a, Timespec time)
 

Book

GList * gnc_ab_get_book_template_list (QofBook *b)
 
void gnc_ab_set_book_template_list (QofBook *b, GList *template_list)
 

Detailed Description

Macro Definition Documentation

#define AQBANKING_VERSION_INT   (10000 * AQBANKING_VERSION_MAJOR + 100 * AQBANKING_VERSION_MINOR + AQBANKING_VERSION_PATCHLEVEL)

A define that combines the aqbanking version number into one single integer number. Assumption: Both MINOR and PATCHLEVEL numbers are in the interval [0..99].

Definition at line 48 of file gnc-ab-utils.h.

#define GWENHYWFAR_VERSION_INT   (10000 * GWENHYWFAR_VERSION_MAJOR + 100 * GWENHYWFAR_VERSION_MINOR + GWENHYWFAR_VERSION_PATCHLEVEL)

A define that combines the gwenhywfar version number into one single integer number. Assumption: Both MINOR and PATCHLEVEL numbers are in the interval [0..99].

Definition at line 53 of file gnc-ab-utils.h.

Typedef Documentation

typedef typedefG_BEGIN_DECLS struct _GncABTransTempl GncABTransTempl

A template for an AqBanking transaction

Definition at line 43 of file gnc-ab-trans-templ.h.

Function Documentation

void gnc_AB_BANKING_delete ( AB_BANKING *  api)

Delete the AB_BANKING api. If this is also the one that was cached by gnc_AB_BANKING_new(), then all references are deleted, too.

Parameters
apiAB_BANKING or NULL for the cached AB_BANKING object

Definition at line 218 of file gnc-ab-utils.c.

219 {
220  if (!api)
221  api = gnc_AB_BANKING;
222 
223  if (api)
224  {
225  if (api == gnc_AB_BANKING)
226  {
227  gnc_AB_BANKING = NULL;
228  gnc_AB_BANKING_fini(api);
229  }
230 
231  AB_Banking_free(api);
232  }
233 }
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Definition: gnc-ab-utils.c:237
gint gnc_AB_BANKING_fini ( AB_BANKING *  api)

Finish the AB_BANKING api. If this is also the one that was cached by gnc_AB_BANKING_new(), then finish only if the decremented reference count reaches zero. After this call, you may only call gnc_AB_BANKING_new() to get the api again in a properly initialized state.

Parameters
apiAB_BANKING object
Returns
Zero on success

Definition at line 237 of file gnc-ab-utils.c.

238 {
239  if (api == gnc_AB_BANKING)
240  {
241  if (--gnc_AB_BANKING_refcount == 0)
242  {
243 #ifdef AQBANKING_VERSION_5_PLUS
244  if (gnc_gwengui_extended_by_ABBanking)
245  AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
246  gnc_gwengui_extended_by_ABBanking = NULL;
247 #endif /* AQBANKING_VERSION_5_PLUS */
248  return AB_Banking_Fini(api);
249  }
250  }
251  else
252  {
253 #ifdef AQBANKING_VERSION_5_PLUS
254  if (gnc_gwengui_extended_by_ABBanking)
255  AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
256  gnc_gwengui_extended_by_ABBanking = NULL;
257 #endif /* AQBANKING_VERSION_5_PLUS */
258  return AB_Banking_Fini(api);
259  }
260  return 0;
261 }
AB_BANKING* gnc_AB_BANKING_new ( void  )

If there is a cached AB_BANKING object, return it initialized. Otherwise, create a new AB_BANKING, let it load its environment from its default configuration and cache it.

Returns
The AB_BANKING object

Definition at line 137 of file gnc-ab-utils.c.

138 {
139  AB_BANKING *api;
140 
141  if (gnc_AB_BANKING)
142  {
143  /* API cached. */
144  api = gnc_AB_BANKING;
145 
146  /* Init the API again. */
147  if (gnc_AB_BANKING_refcount == 0)
148  g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
149 
150  }
151  else
152  {
153  api = AB_Banking_new("gnucash", NULL, 0);
154  g_return_val_if_fail(api, NULL);
155 
156 #ifdef AQBANKING_VERSION_4_PLUS
157  /* Check for config migration */
158  if (AB_Banking_HasConf4(api
159 # ifndef AQBANKING_VERSION_5_PLUS
160  , 0
161 # endif
162  ) != 0)
163  {
164  if (AB_Banking_HasConf3(api
165 # ifndef AQBANKING_VERSION_5_PLUS
166  , 0
167 # endif
168  ) == 0)
169  {
170  g_message("gnc_AB_BANKING_new: importing aqbanking3 configuration\n");
171  if (AB_Banking_ImportConf3(api
172 # ifndef AQBANKING_VERSION_5_PLUS
173  , 0
174 # endif
175  ) < 0)
176  {
177  g_message("gnc_AB_BANKING_new: unable to import aqbanking3 configuration\n");
178  }
179  }
180  else if (AB_Banking_HasConf2(api
181 # ifndef AQBANKING_VERSION_5_PLUS
182  , 0
183 # endif
184  ) == 0)
185  {
186  g_message("gnc_AB_BANKING_new: importing aqbanking2 configuration\n");
187  if (AB_Banking_ImportConf2(api
188 # ifndef AQBANKING_VERSION_5_PLUS
189  , 0
190 # endif
191  ) < 0)
192  {
193  g_message("gnc_AB_BANKING_new: unable to import aqbanking2 configuration\n");
194  }
195  }
196  }
197 #endif /* AQBANKING_VERSION_4_PLUS */
198 
199  /* Init the API */
200  g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
201 
202 #ifdef AQBANKING_VERSION_5_PLUS
203  gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui();
204  AB_Gui_Extend(gnc_gwengui_extended_by_ABBanking, api);
205 #endif /* AQBANKING_VERSION_5_PLUS */
206 
207  /* Cache it */
208  gnc_AB_BANKING = api;
209  gnc_AB_BANKING_refcount = 0;
210  }
211 
212  gnc_AB_BANKING_refcount++;
213 
214  return api;
215 }
gchar* gnc_ab_description_to_gnc ( const AB_TRANSACTION *  ab_trans)

Create the appropriate description field for a GnuCash Transaction by the information given in the AB_TRANSACTION ab_trans. The returned string must be g_free'd by the caller.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string, may be ""

Definition at line 383 of file gnc-ab-utils.c.

384 {
385  /* Description */
386  gchar *description = gnc_ab_get_purpose(ab_trans);
387  gchar *other_name = gnc_ab_get_remote_name(ab_trans);
388  gchar *retval;
389 
390  if (other_name)
391  {
392  if (description && *description)
393  {
394  retval = g_strdup_printf("%s; %s", description, other_name);
395  }
396  else
397  {
398  retval = g_strdup(other_name);
399  }
400  }
401  else
402  {
403  if (description && *description)
404  {
405  retval = g_strdup(description);
406  }
407  else
408  {
409  retval = g_strdup(_("Unspecified"));
410  }
411  }
412  g_free(description);
413  g_free(other_name);
414 
415  return retval;
416 }
gchar * gnc_ab_get_remote_name(const AB_TRANSACTION *ab_trans)
Definition: gnc-ab-utils.c:342
gchar * gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans)
Definition: gnc-ab-utils.c:364
G_BEGIN_DECLS gboolean gnc_ab_enter_daterange ( GtkWidget *  parent,
const char *  heading,
Timespec from_date,
gboolean *  last_retv_date,
gboolean *  first_possible_date,
Timespec to_date,
gboolean *  to_now 
)

Show a dialog to pick a time frame using a sensible set of default options.

Parameters
parentWidget to use as parent, may be NULL
headingDescriptive text showed at the top, may be NULL
from_dateLocation to read from the initial and write to the final value of the from date entry
last_retv_dateLocation to read from whether the caller knows the last retrieval date and write to whether the corresponding button has been chosen
first_possible_dateLocation to write to whether the earliest possible date button has been chosen
to_dateLocation to read from the initial and write to the final value of the to date entry
to_nowLocation to write to whether the to now button has been chosen

Definition at line 52 of file dialog-ab-daterange.c.

59 {
60  GtkBuilder *builder;
61  GtkWidget *dialog;
62  GtkWidget *heading_label;
63  GtkWidget *first_button;
64  GtkWidget *last_retrieval_button;
65  GtkWidget *now_button;
66  DaterangeInfo info;
67  gint result;
68 
69  ENTER("");
70 
71  builder = gtk_builder_new();
72  gnc_builder_add_from_file (builder, "dialog-ab.glade", "Date Range Dialog");
73 
74  dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Range Dialog"));
75 
76  /* Connect the signals */
77  gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info );
78 
79  if (parent)
80  gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
81 
82  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
83  first_button = GTK_WIDGET(gtk_builder_get_object (builder, "first_button"));
84  last_retrieval_button = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button"));
85  info.enter_from_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button"));
86  now_button = GTK_WIDGET(gtk_builder_get_object (builder, "now_button"));
87  info.enter_to_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button"));
88 
89  info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE);
90  gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")),
91  info.from_dateedit);
92  gtk_widget_show(info.from_dateedit);
93 
94  info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE);
95  gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")),
96  info.to_dateedit);
97  gtk_widget_show(info.to_dateedit);
98 
99  if (*last_retv_date)
100  {
101  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button),
102  TRUE);
103  }
104  else
105  {
106  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE);
107  gtk_widget_set_sensitive(last_retrieval_button, FALSE);
108  }
109 
110  gtk_widget_set_sensitive(info.from_dateedit, FALSE);
111  gtk_widget_set_sensitive(info.to_dateedit, FALSE);
112 
113  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
114 
115  if (heading)
116  gtk_label_set_text(GTK_LABEL(heading_label), heading);
117 
118  gtk_widget_show(dialog);
119 
120  result = gtk_dialog_run(GTK_DIALOG(dialog));
121  gtk_widget_hide(dialog);
122 
123  if (result == GTK_RESPONSE_OK)
124  {
125  *from_date = gnc_date_edit_get_date_ts(
126  GNC_DATE_EDIT(info.from_dateedit));
127  *last_retv_date = gtk_toggle_button_get_active(
128  GTK_TOGGLE_BUTTON(last_retrieval_button));
129  *first_possible_date = gtk_toggle_button_get_active(
130  GTK_TOGGLE_BUTTON(first_button));
131  *to_date = gnc_date_edit_get_date_ts(
132  GNC_DATE_EDIT(info.to_dateedit));
133  *to_now = gtk_toggle_button_get_active(
134  GTK_TOGGLE_BUTTON(now_button));
135  }
136 
137  g_object_unref(G_OBJECT(builder));
138 
139  gtk_widget_destroy(dialog);
140 
141  LEAVE("");
142  return result == GTK_RESPONSE_OK;
143 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
AB_ACCOUNT* gnc_ab_get_ab_account ( const AB_BANKING *  api,
Account gnc_acc 
)

Get the corresponding AqBanking account to the GnuCash account gnc_acc. Of course this only works after the GnuCash account has been set up for AqBanking use, i.e. the kvp_frame "hbci/..." has been filled with information.

Parameters
apiThe AB_BANKING to get the AB_ACCOUNT from
gnc_accThe GnuCash account to query for AB_ACCOUNT reference data
Returns
The AB_ACCOUNT found or NULL otherwise

Definition at line 264 of file gnc-ab-utils.c.

265 {
266  AB_ACCOUNT *ab_account = NULL;
267  const gchar *bankcode = NULL;
268  const gchar *accountid = NULL;
269  guint32 account_uid = 0;
270 
271  bankcode = gnc_ab_get_account_bankcode(gnc_acc);
272  accountid = gnc_ab_get_account_accountid(gnc_acc);
273  account_uid = gnc_ab_get_account_uid (gnc_acc);
274 
275  if (account_uid > 0)
276  {
277  ab_account = AB_Banking_GetAccount(api, account_uid);
278 
279  if (!ab_account && bankcode && *bankcode && accountid && *accountid)
280  {
281  g_message("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
282  "trying bank code\n", account_uid);
283  ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
284  accountid);
285  }
286  return ab_account;
287 
288  }
289  else if (bankcode && *bankcode && accountid && *accountid)
290  {
291  ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
292  accountid);
293  return ab_account;
294  }
295 
296  return NULL;
297 }
guint32 gnc_ab_get_account_uid(const Account *a)
Definition: gnc-ab-kvp.c:79
const gchar * gnc_ab_get_account_bankcode(const Account *a)
Definition: gnc-ab-kvp.c:59
const gchar * gnc_ab_get_account_accountid(const Account *a)
Definition: gnc-ab-kvp.c:39
const gchar* gnc_ab_get_account_accountid ( const Account a)

Return a non-copied pointer to the accountid string in the Account a. The gchar* is still owned by the kvp_frame, so don't free it until you want to delete the whole kvp_frame.

Parameters
aAccount
Returns
Account ID

Definition at line 39 of file gnc-ab-kvp.c.

40 {
41  gchar *id = NULL;
42  qof_instance_get (QOF_INSTANCE (a),
43  "ab-account-id", &id,
44  NULL);
45  return id;
46 }
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
const gchar* gnc_ab_get_account_bankcode ( const Account a)

Return a non-copied pointer to the bankcode string in the Account a. The gchar* is still owned by the kvp_frame, so don't free it until you want to delete the whole kvp_frame.

Parameters
aAccount
Returns
Bank code

Definition at line 59 of file gnc-ab-kvp.c.

60 {
61  gchar *code = NULL;
62  qof_instance_get (QOF_INSTANCE (a),
63  "ab-bank-code", &code,
64  NULL);
65  return code;
66 }
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
Timespec gnc_ab_get_account_trans_retrieval ( const Account a)

Return the time of last online transaction retrieval for Account a.

Parameters
aAccount
Returns
Retrieval time

Definition at line 99 of file gnc-ab-kvp.c.

100 {
101  Timespec *t = NULL;
102  qof_instance_get (QOF_INSTANCE (a),
103  "ab-trans-retrieval", &t,
104  NULL);
105  return *t;
106 }
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
guint32 gnc_ab_get_account_uid ( const Account a)

Return the unique id for the AB_BANKING account in the Account a.

Parameters
aAccount
Returns
Unique ID

Definition at line 79 of file gnc-ab-kvp.c.

80 {
81  guint64 uid = 0LL;
82  qof_instance_get (QOF_INSTANCE (a),
83  "ab-account-uid", &uid,
84  NULL);
85  return (guint32)uid;
86 }
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
GList* gnc_ab_get_book_template_list ( QofBook b)

Return a non-copied pointer to the GList of kvp_frames which eventually are the template transactions, stored in the given book.

Parameters
bBook
Returns
Template list

Definition at line 130 of file gnc-ab-kvp.c.

131 {
132  KvpFrame *frame = gnc_ab_get_book_kvp(b, FALSE);
133  KvpValue *value = kvp_frame_get_slot(frame, AB_TEMPLATES);
134  return kvp_value_get_glist(value);
135 }
GList * kvp_value_get_glist(const KvpValue *value)
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
GWEN_DB_NODE* gnc_ab_get_permanent_certs ( void  )

get the GWEN_DB_NODE from AqBanking configuration files

Returns
a GWEN_DB containing all permanently accepted SSL certificates (hashed).

Definition at line 1077 of file gnc-ab-utils.c.

1078 {
1079  int rv;
1080  GWEN_DB_NODE *perm_certs = NULL;
1081  AB_BANKING *banking = gnc_AB_BANKING_new();
1082 
1083  g_return_val_if_fail(banking, NULL);
1084 #ifdef AQBANKING_VERSION_4_PLUS
1085  rv = AB_Banking_LoadSharedConfig(banking, "certs", &perm_certs
1086 # ifndef AQBANKING_VERSION_5_PLUS
1087  , 0
1088 # endif
1089  );
1090 #else
1091  /* FIXME: Add code for older AqBanking versions */
1092  /* See QBankmanager 0.9.50 in src/kbanking/libs/kbanking.cpp lines 323ff
1093  for a proper example of how to do this */
1094  rv = 0;
1095 #endif
1096  gnc_AB_BANKING_fini(banking);
1097  g_return_val_if_fail(rv >= 0, NULL);
1098  return perm_certs;
1099 }
AB_BANKING * gnc_AB_BANKING_new(void)
Definition: gnc-ab-utils.c:137
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Definition: gnc-ab-utils.c:237
gchar* gnc_ab_get_purpose ( const AB_TRANSACTION *  ab_trans)

Retrieve the merged purpose fields from a transaction. The returned string must be g_free'd by the caller. If there was no purpose, an empty (but allocated) string is returned.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string, may be ""

Definition at line 364 of file gnc-ab-utils.c.

365 {
366  const GWEN_STRINGLIST *ab_purpose;
367  gchar *gnc_description = NULL;
368 
369  g_return_val_if_fail(ab_trans, g_strdup(""));
370 
371  ab_purpose = AB_Transaction_GetPurpose(ab_trans);
372  if (ab_purpose)
373  GWEN_StringList_ForEach(ab_purpose, join_ab_strings_cb,
374  &gnc_description);
375 
376  if (!gnc_description)
377  gnc_description = g_strdup("");
378 
379  return gnc_description;
380 }
gchar* gnc_ab_get_remote_name ( const AB_TRANSACTION *  ab_trans)

Retrieve the merged "remote name" fields from a transaction. The returned string must be g_free'd by the caller. If there was no "remote name" field, NULL (!) is returned.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string or NULL otherwise

Definition at line 342 of file gnc-ab-utils.c.

343 {
344  const GWEN_STRINGLIST *ab_remote_name;
345  gchar *gnc_other_name = NULL;
346 
347  g_return_val_if_fail(ab_trans, NULL);
348 
349  ab_remote_name = AB_Transaction_GetRemoteName(ab_trans);
350  if (ab_remote_name)
351  GWEN_StringList_ForEach(ab_remote_name, join_ab_strings_cb,
352  &gnc_other_name);
353 
354  if (!gnc_other_name || !*gnc_other_name)
355  {
356  g_free(gnc_other_name);
357  gnc_other_name = NULL;
358  }
359 
360  return gnc_other_name;
361 }
AB_JOB* gnc_ab_get_trans_job ( AB_ACCOUNT *  ab_acc,
const AB_TRANSACTION *  ab_trans,
GncABTransType  trans_type 
)

FIXME

Parameters
tdTransaction dialog
Returns
FIXME

Definition at line 940 of file dialog-ab-trans.c.

942 {
943  AB_JOB *job;
944 
945  g_return_val_if_fail(ab_acc && ab_trans, NULL);
946 
947  job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
948  if (job)
949  {
950 #ifdef AQBANKING_VERSION_GREATER_5_2_0
951  AB_Job_SetTransaction(job, ab_trans);
952 #else
953  switch (trans_type)
954  {
955  case SINGLE_DEBITNOTE:
956  AB_JobSingleDebitNote_SetTransaction(job, ab_trans);
957  break;
958  case SINGLE_INTERNAL_TRANSFER:
959  AB_JobInternalTransfer_SetTransaction(job, ab_trans);
960  break;
961  case SEPA_TRANSFER:
962  AB_JobSepaTransfer_SetTransaction(job, ab_trans);
963  break;
964  case SEPA_DEBITNOTE:
965  AB_JobSepaDebitNote_SetTransaction(job, ab_trans);
966  break;
967  case SINGLE_TRANSFER:
968  default:
969  AB_JobSingleTransfer_SetTransaction(job, ab_trans);
970  break;
971  };
972 #endif
973  }
974  return job;
975 }
G_BEGIN_DECLS void gnc_ab_getbalance ( GtkWidget *  parent,
Account gnc_acc 
)

Execute a GetBalance job, show the resulting balance and offer to reconcile the GnuCash account.

Parameters
parentWidget to use as parent, may be NULL
gnc_accGnuCash account to fetch balance for

Definition at line 46 of file gnc-ab-getbalance.c.

47 {
48  AB_BANKING *api;
49  gboolean online = FALSE;
50  AB_ACCOUNT *ab_acc;
51  AB_JOB *job = NULL;
52  AB_JOB_LIST2 *job_list = NULL;
53  GncGWENGui *gui = NULL;
54  AB_IMEXPORTER_CONTEXT *context = NULL;
55  GncABImExContextImport *ieci = NULL;
56  AB_JOB_STATUS job_status;
57 
58  g_return_if_fail(parent && gnc_acc);
59 
60  /* Get the API */
61  api = gnc_AB_BANKING_new();
62  if (!api)
63  {
64  g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
65  return;
66  }
67  if (AB_Banking_OnlineInit(api
68 #ifdef AQBANKING_VERSION_4_EXACTLY
69  , 0
70 #endif
71  ) != 0)
72  {
73  g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
74  goto cleanup;
75  }
76  online = TRUE;
77 
78  /* Get the AqBanking Account */
79  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
80  if (!ab_acc)
81  {
82  g_warning("gnc_ab_getbalance: No AqBanking account found");
83  gnc_error_dialog(parent, _("No valid online banking account assigned."));
84  goto cleanup;
85  }
86 
87  /* Get a GetBalance job and enqueue it */
88  job = AB_JobGetBalance_new(ab_acc);
89  if (!job || AB_Job_CheckAvailability(job
90 #ifndef AQBANKING_VERSION_5_PLUS
91  , 0
92 #endif
93  ))
94  {
95  g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
96  "account");
97  gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account."));
98  goto cleanup;
99  }
100  job_list = AB_Job_List2_new();
101  AB_Job_List2_PushBack(job_list, job);
102 
103  /* Get a GUI object */
104  gui = gnc_GWEN_Gui_get(parent);
105  if (!gui)
106  {
107  g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
108  goto cleanup;
109  }
110 
111  /* Create a context to store the results */
112  context = AB_ImExporterContext_new();
113 
114  /* Execute the job */
115  AB_Banking_ExecuteJobs(api, job_list, context
116 #ifndef AQBANKING_VERSION_5_PLUS
117  , 0
118 #endif
119  );
120  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
121  * status always describes better whether the job was actually
122  * transferred to and accepted by the bank. See also
123  * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
124  */
125  job_status = AB_Job_GetStatus(job);
126  if (job_status != AB_Job_StatusFinished
127  && job_status != AB_Job_StatusPending)
128  {
129  g_warning("gnc_ab_getbalance: Error on executing job");
130  gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
131  , AB_Job_Status2Char(job_status)
132  , AB_Job_GetResultText(job));
133  goto cleanup;
134  }
135 
136  /* Import the results */
137  ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);
138 
139 cleanup:
140  if (ieci)
141  g_free(ieci);
142  if (context)
143  AB_ImExporterContext_free(context);
144  if (gui)
146  if (job_list)
147  AB_Job_List2_free(job_list);
148  if (job)
149  AB_Job_free(job);
150  if (online)
151 #ifdef AQBANKING_VERSION_4_EXACTLY
152  AB_Banking_OnlineFini(api, 0);
153 #else
154  AB_Banking_OnlineFini(api);
155 #endif
156  gnc_AB_BANKING_fini(api);
157 }
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
Definition: gnc-gwen-gui.c:311
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Definition: gnc-gwen-gui.c:346
AB_BANKING * gnc_AB_BANKING_new(void)
Definition: gnc-ab-utils.c:137
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Definition: gnc-ab-utils.c:237
AB_ACCOUNT * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
Definition: gnc-ab-utils.c:264
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
G_BEGIN_DECLS void gnc_ab_gettrans ( GtkWidget *  parent,
Account gnc_acc 
)

Execute a GetTransactions job.

Parameters
parentWidget to use as parent, may be NULL
gnc_accGnuCash account to fetch transactions for

Definition at line 98 of file gnc-ab-gettrans.c.

99 {
100  AB_BANKING *api;
101  gboolean online = FALSE;
102  AB_ACCOUNT *ab_acc;
103  GWEN_TIME *from_date = NULL, *to_date = NULL;
104  Timespec until_timespec;
105  AB_JOB *job = NULL;
106  AB_JOB_LIST2 *job_list = NULL;
107  GncGWENGui *gui = NULL;
108  AB_IMEXPORTER_CONTEXT *context = NULL;
109  GncABImExContextImport *ieci = NULL;
110  AB_JOB_STATUS job_status;
111 
112  g_return_if_fail(parent && gnc_acc);
113 
114  /* Get the API */
115  api = gnc_AB_BANKING_new();
116  if (!api)
117  {
118  g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
119  return;
120  }
121  if (AB_Banking_OnlineInit(api
122 #ifdef AQBANKING_VERSION_4_EXACTLY
123  , 0
124 #endif
125  ) != 0)
126  {
127  g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
128  goto cleanup;
129  }
130  online = TRUE;
131 
132  /* Get the AqBanking Account */
133  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
134  if (!ab_acc)
135  {
136  g_warning("gnc_ab_gettrans: No AqBanking account found");
137  gnc_error_dialog(parent, _("No valid online banking account assigned."));
138  goto cleanup;
139  }
140 
141  /* Get the start and end dates for the GetTransactions job. */
142  if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
143  {
144  g_debug("gnc_ab_gettrans: gettrans_dates aborted");
145  goto cleanup;
146  }
147  /* Use this as a local storage for the until_time below. */
148  timespecFromTime64(&until_timespec, GWEN_Time_toTime_t(to_date));
149 
150  /* Get a GetTransactions job and enqueue it */
151  job = AB_JobGetTransactions_new(ab_acc);
152  if (!job || AB_Job_CheckAvailability(job
153 #ifndef AQBANKING_VERSION_5_PLUS
154  , 0
155 #endif
156  ))
157  {
158  g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
159  "account");
160  gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account."));
161  goto cleanup;
162  }
163  AB_JobGetTransactions_SetFromTime(job, from_date);
164  AB_JobGetTransactions_SetToTime(job, to_date);
165  job_list = AB_Job_List2_new();
166  AB_Job_List2_PushBack(job_list, job);
167 
168  /* Get a GUI object */
169  gui = gnc_GWEN_Gui_get(parent);
170  if (!gui)
171  {
172  g_warning("gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
173  goto cleanup;
174  }
175 
176  /* Create a context to store the results */
177  context = AB_ImExporterContext_new();
178 
179  /* Execute the job */
180  AB_Banking_ExecuteJobs(api, job_list, context
181 #ifndef AQBANKING_VERSION_5_PLUS
182  , 0
183 #endif
184  );
185  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
186  * status always describes better whether the job was actually
187  * transferred to and accepted by the bank. See also
188  * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
189  */
190  job_status = AB_Job_GetStatus(job);
191  if (job_status != AB_Job_StatusFinished
192  && job_status != AB_Job_StatusPending)
193  {
194  g_warning("gnc_ab_gettrans: Error on executing job");
195  gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
196  , AB_Job_Status2Char(job_status)
197  , AB_Job_GetResultText(job));
198  goto cleanup;
199  }
200 
201  /* Import the results */
202  ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, FALSE, NULL,
203  parent);
204  if (!(gnc_ab_ieci_get_found(ieci) & FOUND_TRANSACTIONS))
205  {
206  /* No transaction found */
207  GtkWidget *dialog = gtk_message_dialog_new(
208  GTK_WINDOW(parent),
209  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
210  GTK_MESSAGE_INFO,
211  GTK_BUTTONS_OK,
212  "%s",
213  _("The Online Banking import returned no transactions "
214  "for the selected time period."));
215  gtk_dialog_run(GTK_DIALOG(dialog));
216  gtk_widget_destroy(dialog);
217  }
218 
219  /* Store the date of this retrieval */
220  gnc_ab_set_account_trans_retrieval(gnc_acc, until_timespec);
221 
222 cleanup:
223  if (ieci)
224  g_free(ieci);
225  if (context)
226  AB_ImExporterContext_free(context);
227  if (gui)
229  if (job_list)
230  AB_Job_List2_free(job_list);
231  if (job)
232  AB_Job_free(job);
233  if (to_date)
234  GWEN_Time_free(to_date);
235  if (from_date)
236  GWEN_Time_free(from_date);
237  if (online)
238 #ifdef AQBANKING_VERSION_4_EXACTLY
239  AB_Banking_OnlineFini(api, 0);
240 #else
241  AB_Banking_OnlineFini(api);
242 #endif
243  gnc_AB_BANKING_fini(api);
244 }
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
Definition: gnc-gwen-gui.c:311
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Definition: gnc-gwen-gui.c:346
void gnc_ab_set_account_trans_retrieval(Account *a, Timespec time)
Definition: gnc-ab-kvp.c:109
AB_BANKING * gnc_AB_BANKING_new(void)
Definition: gnc-ab-utils.c:137
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Definition: gnc-ab-utils.c:237
AB_ACCOUNT * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
Definition: gnc-ab-utils.c:264
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
guint gnc_ab_ieci_get_found(GncABImExContextImport *ieci)
void timespecFromTime64(Timespec *ts, time64 t)
guint gnc_ab_ieci_get_found ( GncABImExContextImport ieci)

Extract awaiting from data.

Parameters
ieciThe return value of gnc_ab_import_context()
Returns
The initial awaiting bitmask plus IGNORE_* for unexpected and then ignored items, and FOUND_* for non-empty items

Definition at line 1053 of file gnc-ab-utils.c.

1054 {
1055  g_return_val_if_fail(ieci, 0);
1056 
1057  return ieci->awaiting;
1058 }
AB_JOB_LIST2* gnc_ab_ieci_get_job_list ( GncABImExContextImport ieci)

Extract the job list from data.

Parameters
ieciThe return value of gnc_ab_import_context()
Returns
The list of jobs, freeable with AB_Job_List2_FreeAll()

Definition at line 1061 of file gnc-ab-utils.c.

1062 {
1063  g_return_val_if_fail(ieci, NULL);
1064 
1065  return ieci->job_list;
1066 }
gboolean gnc_ab_ieci_run_matcher ( GncABImExContextImport ieci)

Run the generic transaction matcher dialog.

Parameters
ieciThe return value of gnc_ab_import_context()
Returns
The return value of gnc_gen_trans_list_run().

Definition at line 1069 of file gnc-ab-utils.c.

1070 {
1071  g_return_val_if_fail(ieci, FALSE);
1072 
1073  return gnc_gen_trans_list_run(ieci->generic_importer);
1074 }
gboolean gnc_gen_trans_list_run(GNCImportMainMatcher *info)
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. By using awaiting the caller can specify what the user will expect to receive. By using execute_txns, transactions in context can be used to generate corresponding AqBanking jobs, e.g. after a file import.

Parameters
contextAB_IMEXPORTER_CONTEXT to import
awaitingInformation the caller expects to receive or wants to ignore, bitmask of AWAIT_* or IGNORE_* values
execute_txnsIf awaiting contains AWAIT_TRANSACTIONS, whether to create an aqbanking job for each of the transactions found
apiIf execute_txns is TRUE, the AB_BANKING to get AB_ACCOUNTs from
parentWidget to set new dialogs transient for, may be NULL
Returns
A new GncABImExContextImport object which must be freed with g_free(), or NULL otherwise. If execute_txns is TRUE, additionally gnc_ab_ieci_get_job_list() must be called and the result freed with AB_Job_List2_FreeAll()

Definition at line 1009 of file gnc-ab-utils.c.

1012 {
1014 
1015  g_return_val_if_fail(context, NULL);
1016  /* Do not await and ignore at the same time */
1017  g_return_val_if_fail(!(awaiting & AWAIT_BALANCES)
1018  || !(awaiting & IGNORE_BALANCES),
1019  NULL);
1020  g_return_val_if_fail(!(awaiting & AWAIT_TRANSACTIONS)
1021  || !(awaiting & IGNORE_TRANSACTIONS),
1022  NULL);
1023  /* execute_txns must be FALSE if txns are not awaited */
1024  g_return_val_if_fail(awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
1025  /* An api is needed for the jobs */
1026  g_return_val_if_fail(!execute_txns || api, NULL);
1027 
1028  data->awaiting = awaiting;
1029  data->txn_found = FALSE;
1030  data->execute_txns = execute_txns;
1031  data->api = api;
1032  data->parent = parent;
1033  data->job_list = AB_Job_List2_new();
1034  data->tmp_job_list = NULL;
1035  data->generic_importer = NULL;
1036 
1037  g_datalist_init(&data->tmp_job_list);
1038 
1039  /* Import transactions */
1040  if (!(awaiting & IGNORE_TRANSACTIONS))
1041  AB_ImExporterContext_AccountInfoForEach(context, txn_accountinfo_cb,
1042  data);
1043 
1044  /* Check balances */
1045  if (!(awaiting & IGNORE_BALANCES))
1046  AB_ImExporterContext_AccountInfoForEach(context, bal_accountinfo_cb,
1047  data);
1048 
1049  return data;
1050 }
G_BEGIN_DECLS void gnc_ab_initial_assistant ( void  )

Create and show an assistant for the aqbanking setup.

Definition at line 844 of file assistant-ab-initial.c.

845 {
846  ABInitialInfo *info;
847  GtkBuilder *builder;
848  GtkTreeViewColumn *column;
849  GtkTreeSelection *selection;
850  gint component_id;
851 
852  info = g_new0(ABInitialInfo, 1);
853  builder = gtk_builder_new();
854  gnc_builder_add_from_file (builder, "assistant-ab-initial.glade", "AqBanking Init Assistant");
855 
856  info->window = GTK_WIDGET(gtk_builder_get_object (builder, "AqBanking Init Assistant"));
857 
858  gnc_assistant_set_colors (GTK_ASSISTANT (info->assistant));
859 
860  info->api = gnc_AB_BANKING_new();
861  info->deferred_info = NULL;
862  info->gnc_hash = NULL;
863 
864  info->match_page_prepared = FALSE;
865  info->account_view =
866  GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_page_view"));
867 
868  info->account_store = gtk_list_store_new(NUM_ACCOUNT_LIST_COLS,
869  G_TYPE_INT, G_TYPE_STRING,
870  G_TYPE_POINTER, G_TYPE_STRING,
871  G_TYPE_BOOLEAN);
872  gtk_tree_view_set_model(info->account_view,
873  GTK_TREE_MODEL(info->account_store));
874  g_object_unref(info->account_store);
875 
876  column = gtk_tree_view_column_new_with_attributes(
877  _("Online Banking Account Name"), gtk_cell_renderer_text_new(),
878  "text", ACCOUNT_LIST_COL_AB_NAME, (gchar*) NULL);
879  gtk_tree_view_append_column(info->account_view, column);
880 
881  column = gtk_tree_view_column_new_with_attributes(
882  _("GnuCash Account Name"), gtk_cell_renderer_text_new(),
883  "text", ACCOUNT_LIST_COL_GNC_NAME, (gchar*) NULL);
884  gtk_tree_view_column_set_expand(column, TRUE);
885  gtk_tree_view_append_column(info->account_view, column);
886 
887  column = gtk_tree_view_column_new_with_attributes(
888  _("New?"), gtk_cell_renderer_toggle_new(),
889  "active", ACCOUNT_LIST_COL_CHECKED, (gchar*) NULL);
890  gtk_tree_view_append_column(info->account_view, column);
891 
892  selection = gtk_tree_view_get_selection(info->account_view);
893  gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
894 
895  gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
896 
897  g_signal_connect(info->account_view, "row-activated",
898  G_CALLBACK(account_list_clicked_cb), info);
899 
900  g_signal_connect (G_OBJECT(info->window), "destroy",
901  G_CALLBACK (aai_destroy_cb), info);
902 
903  gtk_builder_connect_signals(builder, info);
904  g_object_unref(G_OBJECT(builder));
905 
906  component_id = gnc_register_gui_component(ASSISTANT_AB_INITIAL_CM_CLASS,
907  NULL, aai_close_handler, info);
908 
909  gnc_gui_component_set_session(component_id, gnc_get_current_session());
910 
911  gtk_widget_show(info->window);
912 }
AB_BANKING * gnc_AB_BANKING_new(void)
Definition: gnc-ab-utils.c:137
gchar* gnc_AB_JOB_ID_to_string ( gulong  job_id)

Return the job_id as string.

Parameters
job_id
Returns
A newly allocated string

Definition at line 726 of file gnc-ab-utils.c.

727 {
728  return g_strdup_printf("job_%lu", job_id);
729 }
gchar* gnc_AB_JOB_to_readable_string ( const AB_JOB *  job)

Return the job as string.

Parameters
valueAB_JOB or NULL
Returns
A newly allocated string

Definition at line 714 of file gnc-ab-utils.c.

715 {
716  if (job)
717  {
718  return gnc_AB_JOB_ID_to_string(AB_Job_GetJobId(job));
719  }
720  else
721  {
722  return gnc_AB_JOB_ID_to_string(0);
723  }
724 }
gchar * gnc_AB_JOB_ID_to_string(gulong job_id)
Definition: gnc-ab-utils.c:726
G_BEGIN_DECLS void gnc_ab_maketrans ( GtkWidget *  parent,
Account gnc_acc,
GncABTransType  trans_type 
)

FIXME

Parameters
parentWidget to use as parent, may be NULL
gnc_accGnuCash account to fetch balance for
trans_typeType of transaction

Definition at line 81 of file gnc-ab-transfer.c.

83 {
84  AB_BANKING *api;
85  gboolean online = FALSE;
86  AB_ACCOUNT *ab_acc;
87  GList *templates = NULL;
88  GncABTransDialog *td = NULL;
89  gboolean successful = FALSE;
90  gboolean aborted = FALSE;
91 
92  g_return_if_fail(parent && gnc_acc);
93 
94  /* Get the API */
95  api = gnc_AB_BANKING_new();
96  if (!api)
97  {
98  g_warning("gnc_ab_maketrans: Couldn't get AqBanking API");
99  return;
100  }
101  if (AB_Banking_OnlineInit(api
102 #ifdef AQBANKING_VERSION_4_EXACTLY
103  , 0
104 #endif
105  ) != 0)
106  {
107  g_warning("gnc_ab_maketrans: Couldn't initialize AqBanking API");
108  goto cleanup;
109  }
110  online = TRUE;
111 
112  /* Get the AqBanking Account */
113  ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
114  if (!ab_acc)
115  {
116  g_warning("gnc_ab_gettrans: No AqBanking account found");
117  gnc_error_dialog(parent, _("No valid online banking account assigned."));
118  goto cleanup;
119  }
120 
121  /* Get list of template transactions */
123  gnc_ab_get_book_template_list(gnc_account_get_book(gnc_acc)));
124 
125  /* Create new ABTransDialog */
126  td = gnc_ab_trans_dialog_new(parent, ab_acc,
128  trans_type, templates);
129  templates = NULL;
130 
131  /* Repeat until AqBanking action was successful or user pressed cancel */
132  do
133  {
134  GncGWENGui *gui = NULL;
135  gint result;
136  gboolean changed;
137  const AB_TRANSACTION *ab_trans;
138  AB_JOB *job = NULL;
139  AB_JOB_LIST2 *job_list = NULL;
140  XferDialog *xfer_dialog = NULL;
141  gnc_numeric amount;
142  gchar *description;
143  gchar *memo;
144  Transaction *gnc_trans = NULL;
145  AB_IMEXPORTER_CONTEXT *context = NULL;
146  AB_JOB_STATUS job_status;
147  GncABImExContextImport *ieci = NULL;
148 
149  /* Get a GUI object */
150  gui = gnc_GWEN_Gui_get(parent);
151  if (!gui)
152  {
153  g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
154  aborted = TRUE;
155  goto repeat;
156  }
157 
158  /* Let the user enter the values */
160 
161  /* Save the templates */
162  templates = gnc_ab_trans_dialog_get_templ(td, &changed);
163  if (changed)
164  save_templates(parent, gnc_acc, templates,
165  (result == GNC_RESPONSE_NOW));
166  g_list_free(templates);
167  templates = NULL;
168 
169  if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
170  {
171  aborted = TRUE;
172  goto repeat;
173  }
174 
175  /* Get a job and enqueue it */
176  ab_trans = gnc_ab_trans_dialog_get_ab_trans(td);
177  job = gnc_ab_trans_dialog_get_job(td);
178  if (!job || AB_Job_CheckAvailability(job
179 #ifndef AQBANKING_VERSION_5_PLUS
180  , 0
181 #endif
182  ))
183  {
184  if (!gnc_verify_dialog(
185  parent, FALSE, "%s",
186  _("The backend found an error during the preparation "
187  "of the job. It is not possible to execute this job. \n"
188  "\n"
189  "Most probable the bank does not support your chosen "
190  "job or your Online Banking account does not have the permission "
191  "to execute this job. More error messages might be "
192  "visible on your console log.\n"
193  "\n"
194  "Do you want to enter the job again?")))
195  aborted = TRUE;
196  goto repeat;
197  }
198  job_list = AB_Job_List2_new();
199  AB_Job_List2_PushBack(job_list, job);
200 
201  /* Setup a Transfer Dialog for the GnuCash transaction */
202  xfer_dialog = gnc_xfer_dialog(gnc_ab_trans_dialog_get_parent(td),
203  gnc_acc);
204  switch (trans_type)
205  {
206  case SINGLE_DEBITNOTE:
207  gnc_xfer_dialog_set_title(
208  xfer_dialog, _("Online Banking Direct Debit Note"));
209  gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
210  break;
211  case SINGLE_INTERNAL_TRANSFER:
212  gnc_xfer_dialog_set_title(
213  xfer_dialog, _("Online Banking Bank-Internal Transfer"));
214  gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
215  break;
216  case SEPA_TRANSFER:
217  gnc_xfer_dialog_set_title(
218  xfer_dialog, _("Online Banking European (SEPA) Transfer"));
219  gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
220  break;
221  case SEPA_DEBITNOTE:
222  gnc_xfer_dialog_set_title(
223  xfer_dialog, _("Online Banking European (SEPA) Debit Note"));
224  gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
225  break;
226  case SINGLE_TRANSFER:
227  default:
228  gnc_xfer_dialog_set_title(
229  xfer_dialog, _("Online Banking Transaction"));
230  gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
231  }
232  gnc_xfer_dialog_set_to_show_button_active(xfer_dialog, TRUE);
233 
234  amount = double_to_gnc_numeric(
235  AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
238  gnc_xfer_dialog_set_amount(xfer_dialog, amount);
239  gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);
240  gnc_xfer_dialog_set_date_sensitive(xfer_dialog, FALSE);
241 
242  description = gnc_ab_description_to_gnc(ab_trans);
243  gnc_xfer_dialog_set_description(xfer_dialog, description);
244  g_free(description);
245 
246  memo = gnc_ab_memo_to_gnc(ab_trans);
247  gnc_xfer_dialog_set_memo(xfer_dialog, memo);
248  g_free(memo);
249 
250  gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);
251 
252  /* And run it */
253  successful = gnc_xfer_dialog_run_until_done(xfer_dialog);
254 
255  /* On cancel, go back to the AB transaction dialog */
256  if (!successful || !gnc_trans)
257  {
258  successful = FALSE;
259  goto repeat;
260  }
261 
262  if (result == GNC_RESPONSE_NOW)
263  {
264  /* Create a context to store possible results */
265  context = AB_ImExporterContext_new();
266 
267  gui = gnc_GWEN_Gui_get(parent);
268  if (!gui)
269  {
270  g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
271  aborted = TRUE;
272  goto repeat;
273  }
274 
275  /* Finally, execute the job */
276  AB_Banking_ExecuteJobs(api, job_list, context
277 #ifndef AQBANKING_VERSION_5_PLUS
278  , 0
279 #endif
280  );
281 
282  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
283  * status always describes better whether the job was actually
284  * transferred to and accepted by the bank. See also
285  * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
286  */
287  job_status = AB_Job_GetStatus(job);
288  if (job_status != AB_Job_StatusFinished
289  && job_status != AB_Job_StatusPending)
290  {
291  successful = FALSE;
292  if (!gnc_verify_dialog(
293  parent, FALSE, "%s",
294  _("An error occurred while executing the job. Please check "
295  "the log window for the exact error message.\n"
296  "\n"
297  "Do you want to enter the job again?")))
298  {
299  aborted = TRUE;
300  }
301  }
302  else
303  {
304  successful = TRUE;
305  }
306 
307  if (successful)
308  {
309  /* Import the results, awaiting nothing */
310  ieci = gnc_ab_import_context(context, 0, FALSE, NULL, parent);
311  }
312  }
313  /* Simply ignore any other case */
314 
315 repeat:
316  /* Clean up */
317  if (gnc_trans && !successful)
318  {
319  xaccTransBeginEdit(gnc_trans);
320  xaccTransDestroy(gnc_trans);
321  xaccTransCommitEdit(gnc_trans);
322  gnc_trans = NULL;
323  }
324  if (ieci)
325  g_free(ieci);
326  if (context)
327  AB_ImExporterContext_free(context);
328  if (job_list)
329  {
330  AB_Job_List2_free(job_list);
331  job_list = NULL;
332  }
333  if (job)
334  {
335  AB_Job_free(job);
336  job = NULL;
337  }
338  if (gui)
339  {
341  gui = NULL;
342  }
343 
344  }
345  while (!successful && !aborted);
346 
347 cleanup:
348  if (td)
350  if (online)
351 #ifdef AQBANKING_VERSION_4_EXACTLY
352  AB_Banking_OnlineFini(api, 0);
353 #else
354  AB_Banking_OnlineFini(api);
355 #endif
356  gnc_AB_BANKING_fini(api);
357 }
GncABTransDialog * gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc, gint commodity_scu, GncABTransType trans_type, GList *templates)
gnc_numeric double_to_gnc_numeric(double n, gint64 denom, gint how)
int xaccAccountGetCommoditySCU(const Account *acc)
Definition: Account.c:2458
gchar * gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans)
Definition: gnc-ab-utils.c:383
gchar * gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
Definition: gnc-ab-utils.c:419
AB_JOB * gnc_ab_trans_dialog_get_job(const GncABTransDialog *td)
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
Definition: gnc-gwen-gui.c:311
void xaccTransDestroy(Transaction *trans)
Definition: Transaction.c:1402
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Definition: gnc-gwen-gui.c:346
GList * gnc_ab_trans_dialog_get_templ(const GncABTransDialog *td, gboolean *changed)
AB_BANKING * gnc_AB_BANKING_new(void)
Definition: gnc-ab-utils.c:137
void xaccTransCommitEdit(Transaction *trans)
Definition: Transaction.c:1579
void xaccTransBeginEdit(Transaction *trans)
Definition: Transaction.c:1380
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Definition: gnc-ab-utils.c:237
AB_ACCOUNT * gnc_ab_get_ab_account(const AB_BANKING *api, Account *gnc_acc)
Definition: gnc-ab-utils.c:264
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
void gnc_ab_trans_dialog_free(GncABTransDialog *td)
const AB_TRANSACTION * gnc_ab_trans_dialog_get_ab_trans(const GncABTransDialog *td)
GList * gnc_ab_trans_templ_list_new_from_kvp_list(GList *v)
GtkWidget * gnc_ab_trans_dialog_get_parent(const GncABTransDialog *td)
GList * gnc_ab_get_book_template_list(QofBook *b)
Definition: gnc-ab-kvp.c:130
gint gnc_ab_trans_dialog_run_until_ok(GncABTransDialog *td)
gchar* gnc_ab_memo_to_gnc ( const AB_TRANSACTION *  ab_trans)

Create the appropriate memo field for a GnuCash Split by the information given in the AB_TRANSACTION ab_trans. The returned string must be g_free'd by the caller.

Parameters
ab_transAqBanking transaction
Returns
A newly allocated string, may be ""

Definition at line 419 of file gnc-ab-utils.c.

420 {
421  const gchar *ab_remote_accountnumber =
422  AB_Transaction_GetRemoteAccountNumber(ab_trans);
423  const gchar *ab_remote_bankcode =
424  AB_Transaction_GetRemoteBankCode(ab_trans);
425 
426  gchar *ab_other_accountid;
427  gchar *ab_other_bankcode;
428 
429  gboolean have_accountid;
430  gboolean have_bankcode;
431 
432  gchar *retval;
433 
434  // For SEPA transactions, we need to ask for something different here
435  if (!ab_remote_accountnumber)
436  ab_remote_accountnumber = AB_Transaction_GetRemoteIban(ab_trans);
437  if (!ab_remote_bankcode)
438  ab_remote_bankcode = AB_Transaction_GetRemoteBic(ab_trans);
439 
440  ab_other_accountid = g_strdup(ab_remote_accountnumber ? ab_remote_accountnumber : "");
441  ab_other_bankcode = g_strdup(ab_remote_bankcode ? ab_remote_bankcode : "");
442 
443  /* Ensure string is in utf8 */
444  gnc_utf8_strip_invalid(ab_other_accountid);
445  gnc_utf8_strip_invalid(ab_other_bankcode);
446 
447  /* and -then- trim it */
448  g_strstrip(ab_other_accountid);
449  g_strstrip(ab_other_bankcode);
450 
451 
452  have_accountid = ab_other_accountid && *ab_other_accountid;
453  have_bankcode = ab_other_bankcode && *ab_other_bankcode;
454 
455  if ( have_accountid || have_bankcode )
456  {
457  retval = g_strdup_printf("%s %s %s %s",
458  have_accountid ? _("Account") : "",
459  have_accountid ? ab_other_accountid : "",
460  have_bankcode ? _("Bank") : "",
461  have_bankcode ? ab_other_bankcode : ""
462  );
463  g_strstrip(retval);
464  }
465  else
466  {
467  retval = g_strdup("");
468  }
469 
470  g_free(ab_other_accountid);
471  g_free(ab_other_bankcode);
472 
473  return retval;
474 }
void gnc_utf8_strip_invalid(gchar *str)
void gnc_ab_set_account_accountid ( Account a,
const gchar *  id 
)

Set the accountid string in the Account a to id. A copy of the string will be stored. The Account will be marked as "dirty".

Parameters
aAccount
idAccount ID

Definition at line 49 of file gnc-ab-kvp.c.

50 {
52  qof_instance_set (QOF_INSTANCE (a),
53  "ab-account-id", id,
54  NULL);
56 }
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void gnc_ab_set_account_bankcode ( Account a,
const gchar *  code 
)

Set the bankcode string in the Account a to code. A copy of the string will be stored. The Account will be marked as "dirty".

Parameters
aAccount
codeBank code

Definition at line 69 of file gnc-ab-kvp.c.

70 {
72  qof_instance_set (QOF_INSTANCE (a),
73  "ab-bank-code", code,
74  NULL);
76 }
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void gnc_ab_set_account_trans_retrieval ( Account a,
Timespec  time 
)

Set the time of last online transaction retrieval for Account a. The account will be marked as "dirty".

Parameters
aAccount
timeRetrieval time

Definition at line 109 of file gnc-ab-kvp.c.

110 {
112  qof_instance_set (QOF_INSTANCE (a),
113  "ab-trans-retrieval", &time,
114  NULL);
116 }
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void gnc_ab_set_account_uid ( Account a,
guint32  uid 
)

Set the unique id for the AB_BANKING account in the Account a to uid. The Account will be marked as "dirty".

Parameters
aAccount
uidUnique ID

Definition at line 89 of file gnc-ab-kvp.c.

90 {
92  qof_instance_set (QOF_INSTANCE (a),
93  "ab-account-uid", (guint64)uid,
94  NULL);
96 }
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
void gnc_ab_set_book_template_list ( QofBook b,
GList *  template_list 
)

Set the GList of kvp_frames of template transactions in the Book b to template_list. No copy of the GList will be stored, the callee becomes the owner and the caller must not free it. The book will be marked "dirty".

Parameters
bBook
template_listTemplate list

Definition at line 138 of file gnc-ab-kvp.c.

139 {
140  KvpFrame *frame = gnc_ab_get_book_kvp(b, TRUE);
141  KvpValue *value = kvp_value_new_glist_nc(template_list);
142  kvp_frame_set_slot_nc(frame, AB_TEMPLATES, value);
143  qof_instance_set_dirty_flag(QOF_INSTANCE(b), TRUE);
144 }
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
KvpValue * kvp_value_new_glist_nc(GList *lst)
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
void gnc_ab_trans_dialog_free ( GncABTransDialog td)

Free a Aqbanking transfer dialog

Parameters
tdTransaction dialog

Definition at line 826 of file dialog-ab-trans.c.

827 {
828  if (!td) return;
829  if (td->ab_trans)
830  AB_Transaction_free(td->ab_trans);
831  if (td->dialog)
832  gtk_widget_destroy(td->dialog);
833  if (td->template_list_store)
834  {
835  gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
836  gnc_ab_trans_dialog_clear_templ_helper, NULL);
837  g_object_unref(td->template_list_store);
838  }
839 #if HAVE_KTOBLZCHECK_H
840  AccountNumberCheck_delete(td->blzcheck);
841 #endif
842  g_free(td);
843 }
const AB_TRANSACTION* gnc_ab_trans_dialog_get_ab_trans ( const GncABTransDialog td)

Receive the Aqbanking Transaction filled by the dialog

Parameters
tdTransaction dialog
Returns
An Aqbanking transaction

Definition at line 889 of file dialog-ab-trans.c.

890 {
891  g_return_val_if_fail(td, NULL);
892  return td->ab_trans;
893 }
AB_JOB* gnc_ab_trans_dialog_get_job ( const GncABTransDialog td)

Receive the Aqbanking job associated with the transaction

Parameters
tdTransaction dialog
Returns
An Aqbanking job

Definition at line 933 of file dialog-ab-trans.c.

934 {
935  g_return_val_if_fail(td, NULL);
936  return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->trans_type);
937 }
AB_JOB * gnc_ab_get_trans_job(AB_ACCOUNT *ab_acc, const AB_TRANSACTION *ab_trans, GncABTransType trans_type)
GtkWidget* gnc_ab_trans_dialog_get_parent ( const GncABTransDialog td)

Retrieve the widget used as parent.

Parameters
tdTransaction dialog
Returns
The parent

Definition at line 882 of file dialog-ab-trans.c.

883 {
884  g_return_val_if_fail(td, NULL);
885  return td->parent;
886 }
GList* gnc_ab_trans_dialog_get_templ ( const GncABTransDialog td,
gboolean *  changed 
)

Retrieve the current list of transaction templates from the dialog td, unless changed is a specified location and the templates have not been touched by the user.

Parameters
tdTransaction dialog
changedLocation to store whether the templates have been changed, may be NULL
Returns
The a newly allocated list of the internal transaction templates. Free this one via g_list_free().

Definition at line 862 of file dialog-ab-trans.c.

863 {
864  GList *list = NULL;
865 
866  g_return_val_if_fail(td, NULL);
867 
868  if (changed)
869  {
870  *changed = td->templ_changed;
871  if (!*changed)
872  return NULL;
873  }
874 
875  gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
876  gnc_ab_trans_dialog_get_templ_helper, &list);
877  list = g_list_reverse(list);
878  return list;
879 }
GncABTransDialog* gnc_ab_trans_dialog_new ( GtkWidget *  parent,
AB_ACCOUNT *  ab_acc,
gint  commodity_scu,
GncABTransType  trans_type,
GList *  templates 
)

Create a new AqBanking transfer dialog

Parameters
parentWidget to use as parent, may be NULL
ab_accAqbanking account
commodity_scucommodity used for the amount
trans_typeType of transaction
templatesA GList of template transactions which will become fully managed by the dialog, so do not free it and retrieve snapshots via gnc_ab_trans_dialog_get_templ()
Returns
A new GncABTransDialog, free with gnc_ab_trans_dialog_free()

Definition at line 259 of file dialog-ab-trans.c.

262 {
263  GncABTransDialog *td;
264  GtkBuilder *builder;
265  const gchar *ab_ownername;
266  const gchar *ab_accountnumber;
267  const gchar *ab_bankname;
268  const gchar *ab_bankcode;
269  G_GNUC_UNUSED GtkWidget *trans_vbox;
270  GtkWidget *heading_label;
271  GtkWidget *recp_name_heading;
272  GtkWidget *recp_account_heading;
273  GtkWidget *recp_bankcode_heading;
274  GtkWidget *amount_hbox;
275  GtkWidget *orig_name_heading;
276  GtkWidget *orig_account_heading;
277  GtkWidget *orig_account_label;
278  G_GNUC_UNUSED GtkWidget *orig_bankname_heading;
279  GtkWidget *orig_bankname_label;
280  GtkWidget *orig_bankcode_heading;
281  GtkWidget *orig_bankcode_label;
282  GtkCellRenderer *renderer;
283  GtkTreeViewColumn *column;
284 
285  g_return_val_if_fail(ab_acc, NULL);
286 
287  ab_ownername = AB_Account_GetOwnerName(ab_acc);
288  if (!ab_ownername)
289  ab_ownername = "";
290  ab_accountnumber = AB_Account_GetAccountNumber(ab_acc);
291  ab_bankcode = AB_Account_GetBankCode(ab_acc);
292  ab_bankname = AB_Account_GetBankName(ab_acc);
293  if (!ab_bankname || !*ab_bankname)
294  ab_bankname = _("(unknown)");
295 
296  td = g_new0(GncABTransDialog, 1);
297  td->parent = parent;
298  td->ab_acc = ab_acc;
299  td->trans_type = trans_type;
300 
301 #if HAVE_KTOBLZCHECK_H
302  td->blzcheck = AccountNumberCheck_new();
303 #endif
304 
305  builder = gtk_builder_new();
306  gnc_builder_add_from_file (builder, "dialog-ab.glade", "Transaction Dialog");
307  td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Transaction Dialog"));
308 
309  if (parent)
310  gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent));
311 
312  /* Extract widgets */
313  trans_vbox = GTK_WIDGET(gtk_builder_get_object (builder, "trans_vbox"));
314  heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
315  recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading"));
316  td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry"));
317  recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading"));
318  td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry"));
319  recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading"));
320  td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry"));
321  td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label"));
322  amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox"));
323  td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry"));
324  td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry"));
325  td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry"));
326  td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry"));
327  td->exec_button = GTK_WIDGET(gtk_builder_get_object(builder, "exec_now_button"));
328  orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading"));
329  td->orig_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label"));
330  orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading"));
331  orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label"));
332  orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading"));
333  orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label"));
334  orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading"));
335  orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label"));
336  td->template_gtktreeview =
337  GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list"));
338 
339  /* Amount edit */
340  td->amount_edit = gnc_amount_edit_new();
341  gtk_box_pack_start(GTK_BOX(amount_hbox), td->amount_edit, TRUE, TRUE, 0);
342  gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit),
343  TRUE);
344  gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit),
345  commodity_scu);
346 
347  /* Use "focus-out" signal because "amount-changed" is only sent when ENTER is pressed */
348  g_signal_connect_swapped (gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit)), "focus-out-event",
349  G_CALLBACK(gnc_ab_trans_dialog_verify_values), td);
350 
351  /* Check for what kind of transaction this should be, and change the
352  * labels accordingly */
353  switch (trans_type)
354  {
355  case SINGLE_TRANSFER:
356  case SINGLE_INTERNAL_TRANSFER:
357  /* all labels are already set */
358  break;
359  case SEPA_TRANSFER:
360  gtk_label_set_text(GTK_LABEL (heading_label),
361  /* Translators: Strings from this file are
362  * needed only in countries that have one of
363  * aqbanking's Online Banking techniques
364  * available. This is 'OFX DirectConnect'
365  * (U.S. and others), 'HBCI' (in Germany),
366  * or 'YellowNet' (Switzerland). If none of
367  * these techniques are available in your
368  * country, you may safely ignore strings
369  * from the import-export/hbci
370  * subdirectory. */
371  _("Enter a SEPA Online Transfer"));
372  gtk_label_set_text(GTK_LABEL(recp_account_heading),
373  _("Recipient IBAN (International Account Number)"));
374  gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
375  _("Recipient BIC (Bank Code)"));
376 
377  gtk_label_set_text(GTK_LABEL(orig_account_heading),
378  _("Originator IBAN (International Account Number)"));
379  gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
380  _("Originator BIC (Bank Code)"));
381  break;
382 
383  case SINGLE_DEBITNOTE:
384  gtk_label_set_text(GTK_LABEL (heading_label),
385  _("Enter an Online Direct Debit Note"));
386 
387  gtk_label_set_text(GTK_LABEL(recp_name_heading),
388  _("Debited Account Owner"));
389  gtk_label_set_text(GTK_LABEL(recp_account_heading),
390  _("Debited Account Number"));
391  gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
392  _("Debited Account Bank Code"));
393 
394  gtk_label_set_text(GTK_LABEL(orig_name_heading),
395  _("Credited Account Owner"));
396  gtk_label_set_text(GTK_LABEL(orig_account_heading),
397  _("Credited Account Number"));
398  gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
399  _("Credited Account Bank Code"));
400  break;
401 
402  case SEPA_DEBITNOTE:
403  gtk_label_set_text(GTK_LABEL (heading_label),
404  _("Enter a SEPA Online Direct Debit Note"));
405 
406  gtk_label_set_text(GTK_LABEL(recp_name_heading),
407  _("Debited Account Owner"));
408  gtk_label_set_text(GTK_LABEL(recp_account_heading),
409  _("Debited IBAN (International Account Number)"));
410  gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
411  _("Debited BIC (Bank Code)"));
412 
413  gtk_label_set_text(GTK_LABEL(orig_name_heading),
414  _("Credited Account Owner"));
415  gtk_label_set_text(GTK_LABEL(orig_account_heading),
416  _("Credited IBAN (International Account Number)"));
417  gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
418  _("Credited BIC (Bank Code)"));
419  break;
420 
421  default:
422  g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d",
423  trans_type);
424  break;
425  }
426 
427  /* Additionally change the labels for the European (SEPA) transactions */
428  if (gnc_ab_trans_isSEPA(trans_type))
429  {
430  // Also, SEPA might have much longer IBAN (up to 34 chars) and BIC (11)
431  gtk_entry_set_max_length(GTK_ENTRY(td->recp_bankcode_entry), 11);
432  gtk_entry_set_max_length(GTK_ENTRY(td->recp_account_entry), 34);
433  }
434 
435  gtk_entry_set_text(GTK_ENTRY(td->orig_name_entry), ab_ownername);
436  gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname);
437  if (gnc_ab_trans_isSEPA(trans_type))
438  {
439  gtk_widget_set_sensitive(GTK_WIDGET(td->orig_name_entry), TRUE);
440  ab_accountnumber = AB_Account_GetIBAN(ab_acc);
441  ab_bankcode = AB_Account_GetBIC(ab_acc);
442  gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
443  gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
444  }
445  else
446  {
447  gtk_widget_set_sensitive(GTK_WIDGET(td->orig_name_entry), FALSE);
448  gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
449  gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);
450  }
451 
452  /* Fill list for choosing a transaction template */
453  td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS,
454  G_TYPE_STRING, G_TYPE_POINTER);
455  g_list_foreach(templates, gnc_ab_trans_dialog_fill_templ_helper, td->template_list_store);
456  gtk_tree_view_set_model(td->template_gtktreeview,
457  GTK_TREE_MODEL(td->template_list_store));
458  td->templ_changed = FALSE;
459  /* Keep a reference to the store */
460 
461  /* Show this list */
462  renderer = gtk_cell_renderer_text_new();
463  column = gtk_tree_view_column_new_with_attributes(
464  "Template Name", renderer, "text", TEMPLATE_NAME, NULL);
465  gtk_tree_view_append_column(td->template_gtktreeview, column);
466 
467  /* Connect the Signals */
468  gtk_builder_connect_signals_full(builder, gnc_builder_connect_full_func, td);
469 
470  g_object_unref(G_OBJECT(builder));
471 
472  /* Disabled OK button until suitable values are filled */
473  gnc_ab_trans_dialog_verify_values(td);
474 
475  return td;
476 }
gboolean gnc_ab_trans_isSEPA(GncABTransType t)
gint gnc_ab_trans_dialog_run_until_ok ( GncABTransDialog td)

Run the Aqbanking transfer dialog until correct values where entered or the user cancelled the dialog.

Parameters
tdTransaction dialog
ab_accAqBanking account
Returns
GTK_RESPONSE_CANCEL or GTK_RESPONSE_DESTROY_EVENT if the user cancelled the dialog and GNC_RESPONSE_NOW otherwise.

Definition at line 734 of file dialog-ab-trans.c.

735 {
736  gint result;
737  AB_JOB *job;
738  const AB_TRANSACTION_LIMITS *joblimits;
739  guint8 max_purpose_lines;
740 
741  /* Check whether the account supports this job */
742  job = gnc_ab_trans_dialog_get_available_empty_job(td->ab_acc, td->trans_type);
743  if (!job)
744  {
745  g_warning("gnc_ab_trans_dialog_run_until_ok: Oops, job not available");
746  return GTK_RESPONSE_CANCEL;
747  }
748 
749  /* Activate as many purpose entries as available for the job */
750  joblimits =
751 #ifdef AQBANKING_VERSION_GREATER_5_2_0
752  AB_Job_GetFieldLimits
753 #else
754  AB_JobSingleTransfer_GetFieldLimits
755 #endif
756  (job);
757  max_purpose_lines = joblimits ?
758  AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2;
759  gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1);
760  gtk_widget_set_sensitive(td->purpose_cont2_entry, max_purpose_lines > 2);
761  gtk_widget_set_sensitive(td->purpose_cont3_entry, max_purpose_lines > 3);
762  if (joblimits)
763  {
764  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_entry),
765  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
766  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_cont_entry),
767  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
768  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_cont2_entry),
769  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
770  gtk_entry_set_max_length(GTK_ENTRY(td->purpose_cont3_entry),
771  AB_TransactionLimits_GetMaxLenPurpose(joblimits));
772  gtk_entry_set_max_length(GTK_ENTRY(td->recp_name_entry),
773  AB_TransactionLimits_GetMaxLenRemoteName(joblimits));
774  }
775 
776  /* Show the dialog */
777  gtk_widget_show(td->dialog);
778 
779  /* Now run the dialog until it gets closed by a button press */
780  result = gtk_dialog_run (GTK_DIALOG (td->dialog));
781 
782  /* Was cancel pressed or dialog closed?
783  * GNC_RESPONSE_NOW == execute now
784  * GNC_RESPONSE_LATER == scheduled for later execution (unimplemented)
785  * GTK_RESPONSE_CANCEL == cancel
786  * GTK_RESPONSE_DELETE_EVENT == window destroyed */
787  if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
788  {
789  gtk_widget_destroy(td->dialog);
790  td->dialog = NULL;
791  return result;
792  }
793 
794  /* Get the transaction details - have been checked beforehand */
795  td->ab_trans = gnc_ab_trans_dialog_fill_values(td);
796 
797  /* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
798  * transactionCode according to some GUI selection here!! */
799  /*if (td->trans_type == SINGLE_DEBITNOTE)
800  AB_TRANSACTION_setTextKey (td->hbci_trans, 05); */
801 
802 
803  /* Hide the dialog */
804  if (td->dialog)
805  gtk_widget_hide(td->dialog);
806 
807  return result;
808 }
gboolean gnc_ab_trans_isSEPA ( GncABTransType  t)

Returns true if the given GncABTransType is an European (SEPA) transaction (transfer or debit note), otherwise false.

Definition at line 161 of file dialog-ab-trans.c.

162 {
163  switch (t)
164  {
165  case SEPA_TRANSFER:
166  case SEPA_DEBITNOTE:
167  return TRUE;
168  default:
169  return FALSE;
170  }
171 }
void gnc_ab_trans_templ_free ( GncABTransTempl t)

Free the memory used by a template.

Parameters
tGncABTransTempl to be freed

Definition at line 124 of file gnc-ab-trans-templ.c.

125 {
126  if (!t) return;
127  g_free(t->name);
128  g_free(t->name_key);
129  g_free(t->recp_name);
130  g_free(t->recp_account);
131  g_free(t->recp_bankcode);
132  g_free(t->purpose);
133  g_free(t->purpose_cont);
134  g_free(t);
135 }
gnc_numeric gnc_ab_trans_templ_get_amount ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Amount

Definition at line 211 of file gnc-ab-trans-templ.c.

212 {
213  g_return_val_if_fail(t, gnc_numeric_zero());
214  return t->amount;
215 }
const gchar* gnc_ab_trans_templ_get_name ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Name of the template, an internal string

Definition at line 183 of file gnc-ab-trans-templ.c.

184 {
185  g_return_val_if_fail(t, NULL);
186  return t->name;
187 }
const gchar* gnc_ab_trans_templ_get_purpose ( const GncABTransTempl t)
Parameters
tTemplate
Returns
First purpose line, an internal string

Definition at line 218 of file gnc-ab-trans-templ.c.

219 {
220  g_return_val_if_fail(t, NULL);
221  return t->purpose;
222 }
const gchar* gnc_ab_trans_templ_get_purpose_cont ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Second purpose line, an internal string

Definition at line 225 of file gnc-ab-trans-templ.c.

226 {
227  g_return_val_if_fail(t, NULL);
228  return t->purpose_cont;
229 }
const gchar* gnc_ab_trans_templ_get_recp_account ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Account Number of the recipient, an internal string

Definition at line 197 of file gnc-ab-trans-templ.c.

198 {
199  g_return_val_if_fail(t, NULL);
200  return t->recp_account;
201 }
const gchar* gnc_ab_trans_templ_get_recp_bankcode ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Bank Code of the recipient, an internal string

Definition at line 204 of file gnc-ab-trans-templ.c.

205 {
206  g_return_val_if_fail(t, NULL);
207  return t->recp_bankcode;
208 }
const gchar* gnc_ab_trans_templ_get_recp_name ( const GncABTransTempl t)
Parameters
tTemplate
Returns
Name of the recipient, an internal string

Definition at line 190 of file gnc-ab-trans-templ.c.

191 {
192  g_return_val_if_fail(t, NULL);
193  return t->recp_name;
194 }
void gnc_ab_trans_templ_list_free ( GList *  l)

Free the memory used by a list of templates, including the list itself.

Parameters
lGList of GncABTransTempl

Definition at line 138 of file gnc-ab-trans-templ.c.

139 {
140  GList *iter;
141  for (iter = l; iter; iter = iter->next)
143  g_list_free(l);
144 }
typedefG_BEGIN_DECLS struct _GncABTransTempl GncABTransTempl
void gnc_ab_trans_templ_free(GncABTransTempl *t)
GList* gnc_ab_trans_templ_list_new_from_kvp_list ( GList *  v)

Create a list of templates from a list of kvp_values which in turn contain a KvpFrame.

Parameters
vGList of kvp_values
Returns
A GList of newly allocated GncABTransTempls

Definition at line 108 of file gnc-ab-trans-templ.c.

109 {
110  GList *res = NULL;
111  GList *iter;
112 
113  for (iter = v; iter; iter = iter->next)
114  {
115  KvpFrame *frame = kvp_value_get_frame((KvpValue*) iter->data);
116  res = g_list_prepend(res, gnc_ab_trans_templ_new_from_kvp(frame));
117  }
118  res = g_list_reverse(res);
119 
120  return res;
121 }
GncABTransTempl * gnc_ab_trans_templ_new_from_kvp(const KvpFrame *k)
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
KvpFrame * kvp_value_get_frame(const KvpValue *value)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
GList* gnc_ab_trans_templ_list_to_kvp_list ( GList *  k)

Create a list of kvp_values, which in turn contain a KvpFrame, from a list of templates.

Parameters
kGList of GncABTransTempls
Returns
GList of newly allocated kvp_values

Definition at line 166 of file gnc-ab-trans-templ.c.

167 {
168  GList *res = NULL;
169  GList *iter;
170 
171  for (iter = k; iter; iter = iter->next)
172  {
173  GncABTransTempl *t = (GncABTransTempl*) iter->data;
175  res = g_list_prepend(res, value);
176  }
177  res = g_list_reverse(res);
178 
179  return res;
180 }
typedefG_BEGIN_DECLS struct _GncABTransTempl GncABTransTempl
KvpValue * kvp_value_new_frame_nc(KvpFrame *value)
KvpFrame * gnc_ab_trans_templ_to_kvp(const GncABTransTempl *t)
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
GncABTransTempl* gnc_ab_trans_templ_new ( void  )

Create a template with unset contents.

Returns
A newly allocated GncABTransTempl

Definition at line 67 of file gnc-ab-trans-templ.c.

68 {
69  return gnc_ab_trans_templ_new_full(NULL, NULL, NULL, NULL,
70  gnc_numeric_zero(), NULL, NULL);
71 }
GncABTransTempl * gnc_ab_trans_templ_new_full(const gchar *name, const gchar *recp_name, const gchar *recp_account, const gchar *recp_bankcode, gnc_numeric amount, const gchar *purpose, const gchar *purpose_cont)
GncABTransTempl* gnc_ab_trans_templ_new_from_kvp ( const KvpFrame k)

Create a template, taking the values from a KvpFrame.

Parameters
kKvpFrame
Returns
A newly allocated GncABTransTempl

Definition at line 93 of file gnc-ab-trans-templ.c.

94 {
95  g_return_val_if_fail(k, NULL);
96 
98  kvp_value_get_string(kvp_frame_get_slot(k, TT_NAME)),
99  kvp_value_get_string(kvp_frame_get_slot(k, TT_RNAME)),
100  kvp_value_get_string(kvp_frame_get_slot(k, TT_RACC)),
101  kvp_value_get_string(kvp_frame_get_slot(k, TT_RBCODE)),
102  kvp_value_get_numeric(kvp_frame_get_slot(k, TT_AMOUNT)),
103  kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOS)),
104  kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOSCT)));
105 }
char * kvp_value_get_string(const KvpValue *value)
GncABTransTempl * gnc_ab_trans_templ_new_full(const gchar *name, const gchar *recp_name, const gchar *recp_account, const gchar *recp_bankcode, gnc_numeric amount, const gchar *purpose, const gchar *purpose_cont)
GncABTransTempl* gnc_ab_trans_templ_new_full ( const gchar *  name,
const gchar *  recp_name,
const gchar *  recp_account,
const gchar *  recp_bankcode,
gnc_numeric  amount,
const gchar *  purpose,
const gchar *  purpose_cont 
)

Create a template with given contents.

Parameters
nameName of the template
recp_nameName of the recipient
recp_accountAccount Number of the recipient
recp_bankcodeBank Code of the recipient
amountAmount
purposeFirst purpose line
purpose_contSecond purpose line
Returns
A newly allocated GncABTransTempl
void gnc_ab_trans_templ_set_amount ( GncABTransTempl t,
gnc_numeric  amount 
)

Replace the amount stored in a template.

Parameters
tTemplate
amountAmount

Definition at line 266 of file gnc-ab-trans-templ.c.

267 {
268  g_return_if_fail(t);
269  t->amount = amount;
270 }
void gnc_ab_trans_templ_set_name ( GncABTransTempl t,
const gchar *  name 
)

Set the name of a template.

Parameters
tTemplate
nameName

Definition at line 232 of file gnc-ab-trans-templ.c.

233 {
234  g_return_if_fail(t);
235  g_free(t->name);
236  t->name = g_strdup(name);
237 }
void gnc_ab_trans_templ_set_purpose ( GncABTransTempl t,
const gchar *  purpose 
)

Replace the first purpose line stored in a template.

Parameters
tTemplate
purposeFirst purpose line

Definition at line 273 of file gnc-ab-trans-templ.c.

274 {
275  g_return_if_fail(t);
276  g_free(t->purpose);
277  t->purpose = g_strdup(purpose);
278 }
void gnc_ab_trans_templ_set_purpose_cont ( GncABTransTempl t,
const gchar *  purpose_cont 
)

Replace the second purpose line stored in a template.

Parameters
tTemplate
purpose_contSecond purpose line

Definition at line 281 of file gnc-ab-trans-templ.c.

283 {
284  g_return_if_fail(t);
285  g_free(t->purpose_cont);
286  t->purpose_cont = g_strdup(purpose_cont);
287 }
void gnc_ab_trans_templ_set_recp_account ( GncABTransTempl t,
const gchar *  recp_account 
)

Replace the Account Number of the recipient stored in a template.

Parameters
tTemplate
recp_accountAccount Number of the recipient

Definition at line 248 of file gnc-ab-trans-templ.c.

250 {
251  g_return_if_fail(t);
252  g_free(t->recp_account);
253  t->recp_account = g_strdup(recp_account);
254 }
void gnc_ab_trans_templ_set_recp_bankcode ( GncABTransTempl t,
const gchar *  recp_bankcode 
)

Replace the Bank Code of the recipient stored in a template.

Parameters
tTemplate
recp_bankcodeBank Code of the recipient

Definition at line 257 of file gnc-ab-trans-templ.c.

259 {
260  g_return_if_fail(t);
261  g_free(t->recp_bankcode);
262  t->recp_bankcode = g_strdup(recp_bankcode);
263 }
void gnc_ab_trans_templ_set_recp_name ( GncABTransTempl t,
const gchar *  recp_name 
)

Replace the Account Number of the recipient stored in a template.

Parameters
tTemplate
recp_nameAccount Number of the recipient

Definition at line 240 of file gnc-ab-trans-templ.c.

241 {
242  g_return_if_fail(t);
243  g_free(t->recp_name);
244  t->recp_name = g_strdup(recp_name);
245 }
KvpFrame* gnc_ab_trans_templ_to_kvp ( const GncABTransTempl t)

Create a KvpFrame a given template.

Parameters
tTemplate
Returns
A newly allocated KvpFrame

Definition at line 147 of file gnc-ab-trans-templ.c.

148 {
149  KvpFrame *k;
150 
151  g_return_val_if_fail(t, NULL);
152 
153  k = kvp_frame_new();
154  kvp_frame_set_slot(k, TT_NAME, kvp_value_new_string(t->name));
155  kvp_frame_set_slot(k, TT_RNAME, kvp_value_new_string(t->recp_name));
156  kvp_frame_set_slot(k, TT_RACC, kvp_value_new_string(t->recp_account));
157  kvp_frame_set_slot(k, TT_RBCODE, kvp_value_new_string(t->recp_bankcode));
158  kvp_frame_set_slot(k, TT_AMOUNT, kvp_value_new_gnc_numeric(t->amount));
159  kvp_frame_set_slot(k, TT_PURPOS, kvp_value_new_string(t->purpose));
160  kvp_frame_set_slot(k, TT_PURPOSCT, kvp_value_new_string(t->purpose_cont));
161 
162  return k;
163 }
void kvp_frame_set_slot(KvpFrame *frame, const gchar *key, KvpValue *value)
#define kvp_value_new_gnc_numeric
Definition: kvp_frame.h:466
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
KvpFrame * kvp_frame_new(void)
Transaction* gnc_ab_trans_to_gnc ( const AB_TRANSACTION *  ab_trans,
Account gnc_acc 
)

Create an unbalanced and dirty GnuCash transaction with a split to gnc_acc from the information available in the AqBanking transaction ab_trans.

Parameters
ab_transAqBanking transaction
gnc_accAccount of to use for the split
Returns
A dirty GnuCash transaction or NULL otherwise

Definition at line 477 of file gnc-ab-utils.c.

478 {
479  QofBook *book;
480  Transaction *gnc_trans;
481  const gchar *fitid;
482  const GWEN_TIME *valuta_date;
483  time64 current_time;
484  const char *custref;
485  gchar *description;
486  Split *split;
487  gchar *memo;
488 
489  g_return_val_if_fail(ab_trans && gnc_acc, NULL);
490 
491  /* Create new GnuCash transaction for the given AqBanking one */
492  book = gnc_account_get_book(gnc_acc);
493  gnc_trans = xaccMallocTransaction(book);
494  xaccTransBeginEdit(gnc_trans);
495 
496  /* Date / Time */
497  valuta_date = AB_Transaction_GetValutaDate(ab_trans);
498  if (!valuta_date)
499  {
500  const GWEN_TIME *normal_date = AB_Transaction_GetDate(ab_trans);
501  if (normal_date)
502  valuta_date = normal_date;
503  }
504  if (valuta_date)
505  xaccTransSetDatePostedSecsNormalized(gnc_trans, GWEN_Time_toTime_t(valuta_date));
506  else
507  g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
508 
509  xaccTransSetDateEnteredSecs(gnc_trans, gnc_time_utc (NULL));
510 
511  /* Currency. We take simply the default currency of the gnucash account */
512  xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
513 
514  /* Trans-Num or Split-Action set with gnc_set_num_action below per book
515  * option */
516 
517  /* Description */
518  description = gnc_ab_description_to_gnc(ab_trans);
519  xaccTransSetDescription(gnc_trans, description);
520  g_free(description);
521 
522  /* Notes. */
523  /* xaccTransSetNotes(gnc_trans, g_notes); */
524  /* But Nobody ever uses the Notes field? */
525 
526  /* Add one split */
527  split = xaccMallocSplit(book);
528  xaccSplitSetParent(split, gnc_trans);
529  xaccSplitSetAccount(split, gnc_acc);
530 
531  /* Set the transaction number or split action field based on book option.
532  * We use the "customer reference", if there is one. */
533  custref = AB_Transaction_GetCustomerReference(ab_trans);
534  if (custref && *custref
535  && g_ascii_strncasecmp(custref, "NONREF", 6) != 0)
536  gnc_set_num_action (gnc_trans, split, custref, NULL);
537 
538  /* Set OFX unique transaction ID */
539  fitid = AB_Transaction_GetFiId(ab_trans);
540  if (fitid && *fitid)
541  gnc_import_set_split_online_id(split, fitid);
542 
543  {
544  /* Amount into the split */
545  const AB_VALUE *ab_value = AB_Transaction_GetValue(ab_trans);
546  double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
547  AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
548  gnc_numeric gnc_amount;
549 
550  /*printf("Transaction with value %f has type %d\n", d_value, ab_type);*/
551  /* If the value is positive, but the transaction type says the
552  money is transferred away from our account (Transfer instead of
553  DebitNote), we switch the value to negative. */
554  if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
555  d_value = -d_value;
556 
557  gnc_amount = double_to_gnc_numeric(
558  d_value,
561  if (!ab_value)
562  g_warning("transaction_cb: Oops, value was NULL. Using 0");
563  xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
564  }
565 
566  /* Memo in the Split. */
567  memo = gnc_ab_memo_to_gnc(ab_trans);
568  xaccSplitSetMemo(split, memo);
569  g_free(memo);
570 
571  return gnc_trans;
572 }
Transaction * xaccMallocTransaction(QofBook *book)
Definition: Transaction.c:513
void xaccSplitSetBaseValue(Split *s, gnc_numeric value, const gnc_commodity *base_currency)
Definition: Split.c:1341
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
Definition: Transaction.c:1920
gnc_numeric double_to_gnc_numeric(double n, gint64 denom, gint how)
int xaccAccountGetCommoditySCU(const Account *acc)
Definition: Account.c:2458
gchar * gnc_ab_description_to_gnc(const AB_TRANSACTION *ab_trans)
Definition: gnc-ab-utils.c:383
void xaccTransSetDescription(Transaction *trans, const char *desc)
Definition: Transaction.c:2085
gchar * gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
Definition: gnc-ab-utils.c:419
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Definition: Transaction.c:1354
void xaccSplitSetMemo(Split *split, const char *memo)
Definition: Split.c:1774
void xaccTransBeginEdit(Transaction *trans)
Definition: Transaction.c:1380
Split * xaccMallocSplit(QofBook *book)
Definition: Split.c:582
Definition: SplitP.h:71
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Definition: Account.c:3148
time64 gnc_time_utc(time64 *tbuf)
get the current utc time
gint64 time64
Definition: gnc-date.h:83
void xaccTransSetDateEnteredSecs(Transaction *trans, time64 secs)
Definition: Transaction.c:1951
gchar* gnc_AB_VALUE_to_readable_string ( const AB_VALUE *  value)

Print the value of value with two decimal places and value's currency appended, or 0.0 otherwise

Parameters
valueAB_VALUE or NULL
Returns
A newly allocated string

Definition at line 300 of file gnc-ab-utils.c.

301 {
302  if (value)
303  return g_strdup_printf("%.2f %s",
304  AB_Value_GetValueAsDouble(value),
305  AB_Value_GetCurrency(value));
306  else
307  return g_strdup_printf("%.2f", 0.0);
308 }
G_BEGIN_DECLS void gnc_file_aqbanking_import ( const gchar *  aqbanking_importername,
const gchar *  aqbanking_formatname,
gboolean  exec_as_aqbanking_jobs 
)

This routine will pop up a standard file selection dialog asking the user to pick a file to import. This file will be opened and read. Its contents will be imported into the current book, using the import matcher from import-main-matcher.h.

Parameters
aqbanking_importernameThe aqbanking importer module that should be used. Possible values: "dtaus", "csv", "swift", or more.
aqbanking_formatnameIn aqbanking, each importer has one or more data formats available which define the actual data fields that should be used. In aqbanking, such a different format is called a "profile". Possible values for swift: "swift-mt940" or "swift-mt942", but for all others: "default", or more precisely: Look into $datadir/aqbanking/imexporters and look into the "name" field of the foo.conf files.
exec_as_aqbanking_jobsIf TRUE, additionally queue the imported transactions as online jobs over aqbanking/HBCI. If FALSE, just import the transactions and that's it.

Definition at line 66 of file gnc-file-aqb-import.c.

69 {
70  gchar *default_dir;
71  gchar *selected_filename = NULL;
72  gint dtaus_fd = -1;
73  AB_BANKING *api = NULL;
74  gboolean online = FALSE;
75  GncGWENGui *gui = NULL;
76  AB_IMEXPORTER *importer;
77  GWEN_DB_NODE *db_profiles = NULL;
78  GWEN_DB_NODE *db_profile;
79  AB_IMEXPORTER_CONTEXT *context = NULL;
80  GWEN_IO_LAYER *io = NULL;
81  GncABImExContextImport *ieci = NULL;
82  AB_JOB_LIST2 *job_list = NULL;
83  AB_JOB_LIST2_ITERATOR *jit;
84  AB_JOB *job;
85  AB_JOB_STATUS job_status;
86  gboolean successful = TRUE;
87  int num_jobs = 0;
88  int num_jobs_failed = 0;
89  int max_failures = 5;
90  GString *errstr = NULL;
91 
92  /* Select a file */
93  default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_AQBANKING);
94  selected_filename = gnc_file_dialog(_("Select a file to import"),
95  NULL, default_dir,
96  GNC_FILE_DIALOG_IMPORT);
97  g_free(default_dir);
98 
99  if (!selected_filename)
100  goto cleanup;
101  DEBUG("filename: %s", selected_filename);
102 
103  /* Remember the directory as the default */
104  default_dir = g_path_get_dirname(selected_filename);
105  gnc_set_default_directory(GNC_PREFS_GROUP_AQBANKING, default_dir);
106  g_free(default_dir);
107 
108  dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
109  if (dtaus_fd == -1)
110  {
111  DEBUG("Could not open file %s", selected_filename);
112  goto cleanup;
113  }
114 
115  /* Get the API */
116  api = gnc_AB_BANKING_new();
117  if (!api)
118  {
119  g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
120  goto cleanup;
121  }
122  if (AB_Banking_OnlineInit(api
123 #ifdef AQBANKING_VERSION_4_EXACTLY
124  , 0
125 #endif
126  ) != 0)
127  {
128  g_warning("gnc_file_aqbanking_import: "
129  "Couldn't initialize AqBanking API");
130  goto cleanup;
131  }
132  online = TRUE;
133 
134  /* Get import module */
135  importer = AB_Banking_GetImExporter(api, aqbanking_importername);
136  if (!importer)
137  {
138  g_warning("Import module %s not found", aqbanking_importername);
139  gnc_error_dialog(NULL, "%s",
140  _("Import module for DTAUS import not found."));
141  goto cleanup;
142  }
143 
144  /* Load the import profile */
145  db_profiles = AB_Banking_GetImExporterProfiles(api, aqbanking_importername);
146 
147  /* Select profile */
148  db_profile = GWEN_DB_GetFirstGroup(db_profiles);
149  while (db_profile)
150  {
151  const gchar *name;
152 
153  name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
154  g_return_if_fail(name);
155  if (g_ascii_strcasecmp(name, aqbanking_profilename) == 0)
156  break;
157  db_profile = GWEN_DB_GetNextGroup(db_profile);
158  }
159  if (!db_profile)
160  {
161  g_warning("Profile \"%s\" for importer \"%s\" not found",
162  aqbanking_profilename, aqbanking_importername);
163  /* For debugging: Print those available names that have been found */
164  db_profile = GWEN_DB_GetFirstGroup(db_profiles);
165  while (db_profile)
166  {
167  const char *name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
168  g_warning("Only found profile \"%s\"\n", name ? name : "(null)");
169  db_profile = GWEN_DB_GetNextGroup(db_profile);
170  }
171  goto cleanup;
172  }
173 
174  /* Create a context to store the results */
175  context = AB_ImExporterContext_new();
176 
177  /* Wrap file in buffered gwen io */
178 #ifdef AQBANKING_VERSION_5_PLUS
179  close(dtaus_fd);
180  io = GWEN_SyncIo_File_new(selected_filename, GWEN_SyncIo_File_CreationMode_OpenExisting);
181  g_assert(io);
182  GWEN_SyncIo_AddFlags(io, GWEN_SYNCIO_FILE_FLAGS_READ);
183  {
184  /* We must explicitly call "Connect" on the GWEN_SYNCIO
185  * object. */
186  int rv = GWEN_SyncIo_Connect(io);
187  if (rv < 0)
188  {
189  g_warning("gnc_file_aqbanking_import: Failed to open file %s: %d", selected_filename, rv);
190  goto cleanup;
191  }
192  g_assert(GWEN_SyncIo_GetStatus(io) == GWEN_SyncIo_Status_Connected);
193  }
194 #else
195  io = GWEN_Io_LayerFile_new(dtaus_fd, -1);
196  g_assert(io);
197  if (GWEN_Io_Manager_RegisterLayer(io))
198  {
199  g_warning("gnc_file_aqbanking_import: Failed to wrap file");
200  goto cleanup;
201  }
202 #endif
203  dtaus_fd = -1;
204 
205  /* Run the import */
206  if (AB_ImExporter_Import(importer, context, io, db_profile
207 #ifndef AQBANKING_VERSION_5_PLUS
208  , 0
209 #endif
210  ))
211  {
212  g_warning("gnc_file_aqbanking_import: Error on import");
213  goto cleanup;
214  }
215 
216  /* Close the file */
217 #ifdef AQBANKING_VERSION_5_PLUS
218  GWEN_SyncIo_free(io);
219 #else
220  GWEN_Io_Layer_free(io);
221 #endif
222  io = NULL;
223 
224  /* Before importing the results, if this is a new book, let user specify
225  * book options, since they affect how transactions are created */
226  if (gnc_is_new_book())
227  gnc_new_book_option_display(gnc_ui_get_toplevel());
228 
229  /* Import the results */
230  ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS,
231  execute_transactions,
232  execute_transactions ? api : NULL,
233  NULL);
234 
235  if (execute_transactions)
236  {
237  if (gnc_ab_ieci_run_matcher(ieci))
238  {
239  AB_IMEXPORTER_CONTEXT *execution_context;
240 
241  /* Extract the list of jobs */
242  job_list = gnc_ab_ieci_get_job_list(ieci);
243 
244  /* Create a context to store possible results */
245  execution_context = AB_ImExporterContext_new();
246 
247  /* Get a GUI object */
248  gui = gnc_GWEN_Gui_get(NULL);
249  if (!gui)
250  {
251  g_warning("gnc_file_aqbanking_import: Couldn't initialize Gwenhywfar GUI");
252  goto cleanup;
253  }
254 
255  /* And execute the jobs */
256  AB_Banking_ExecuteJobs(api, job_list, execution_context
257 #ifndef AQBANKING_VERSION_5_PLUS
258  , 0
259 #endif
260  );
261 
262  /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
263  * status always describes better whether the job was actually
264  * transferred to and accepted by the bank. See also
265  * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
266  */
267 
268  /* So we must go through all jobs and check AB_Job_GetStatus(job)
269  * to give the appropriate feedback if any of the jobs didn't
270  * work. */
271 
272  jit = AB_Job_List2_First(job_list);
273  if (jit)
274  {
275 
276  job = AB_Job_List2Iterator_Data(jit);
277  while (job)
278  {
279  num_jobs += 1;
280  job_status = AB_Job_GetStatus(job);
281  if (job_status != AB_Job_StatusFinished
282  && job_status != AB_Job_StatusPending)
283  {
284  successful = FALSE;
285  num_jobs_failed += 1;
286 
287  if (num_jobs_failed <= max_failures)
288  {
289  if (num_jobs_failed == 1)
290  {
291  errstr = g_string_new("Failed jobs:\n");
292  }
293  g_string_append_printf(errstr, _("Job %d status %d - %s: %s \n")
294  , num_jobs
295  , job_status
296  , AB_Job_Status2Char(job_status)
297  , AB_Job_GetResultText(job));
298  }
299  else
300  {
301  if (num_jobs_failed == (max_failures + 1) )
302  {
303  /* indicate that additional failures exist */
304  g_string_append(errstr, _("...\n"));
305  }
306  }
307  }
308  job = AB_Job_List2Iterator_Next(jit);
309  } /* while */
310 
311  AB_Job_List2Iterator_free(jit);
312  }
313 
314  if (!successful)
315  {
316  g_warning("%s", errstr->str);
317  gnc_error_dialog(NULL,
318  _("An error occurred while executing jobs: %d of %d failed. "
319  "Please check the log window or gnucash.trace for the exact "
320  "error message.\n\n%s")
321  , num_jobs_failed, num_jobs, errstr->str);
322  }
323  else
324  {
325  if (num_jobs == 0)
326  {
327  gnc_info_dialog(NULL,
328  _("No jobs to be send.")
329  );
330  }
331  else
332  {
333  gnc_info_dialog(NULL, ngettext
334  ("The job was executed successfully, but as a precaution "
335  "please check the log window for potential errors.",
336  "All %d jobs were executed successfully, but as a precaution "
337  "please check the log window for potential errors.",
338  num_jobs), num_jobs);
339  }
340  }
341  AB_ImExporterContext_free(execution_context);
342  }
343  }
344 
345 cleanup:
346  if (io)
347  {
348 #ifdef AQBANKING_VERSION_5_PLUS
349  GWEN_SyncIo_free(io);
350 #else
351  GWEN_Io_Layer_free(io);
352 #endif
353  }
354 
355  if (job_list)
356  AB_Job_List2_FreeAll(job_list);
357  if (ieci)
358  g_free(ieci);
359  if (context)
360  AB_ImExporterContext_free(context);
361  if (db_profiles)
362  GWEN_DB_Group_free(db_profiles);
363  if (gui)
365  if (online)
366 #ifdef AQBANKING_VERSION_4_EXACTLY
367  AB_Banking_OnlineFini(api, 0);
368 #else
369  AB_Banking_OnlineFini(api);
370 #endif
371  if (api)
372  gnc_AB_BANKING_fini(api);
373  if (dtaus_fd != -1)
374  close(dtaus_fd);
375  if (selected_filename)
376  g_free(selected_filename);
377  if (errstr)
378  g_string_free(errstr, TRUE);
379 
380 }
AB_JOB_LIST2 * gnc_ab_ieci_get_job_list(GncABImExContextImport *ieci)
#define DEBUG(format, args...)
Definition: qoflog.h:255
gboolean gnc_ab_ieci_run_matcher(GncABImExContextImport *ieci)
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
Definition: gnc-gwen-gui.c:311
void gnc_GWEN_Gui_release(GncGWENGui *gui)
Definition: gnc-gwen-gui.c:346
AB_BANKING * gnc_AB_BANKING_new(void)
Definition: gnc-ab-utils.c:137
gint gnc_AB_BANKING_fini(AB_BANKING *api)
Definition: gnc-ab-utils.c:237
GncABImExContextImport * gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, guint awaiting, gboolean execute_txns, AB_BANKING *api, GtkWidget *parent)
GtkWidget * gnc_ui_get_toplevel(void)
void gnc_GWEN_Fini ( void  )

Finalize the gwenhywfar library.

Definition at line 122 of file gnc-ab-utils.c.

123 {
124  /* Shutdown the GWEN_GUIs */
126  GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
127  GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Warning);
128  GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
129 
130  /* Finalize gwen library */
131  GWEN_Fini();
132 }
void gnc_GWEN_Gui_shutdown(void)
Definition: gnc-gwen-gui.c:356
GncGWENGui* gnc_GWEN_Gui_get ( GtkWidget *  parent)

When called for the first time, create a unique GncGWENGui object featuring a GWEN_GUI with all necessary callbacks, which can serve as a user interface for AqBanking jobs. On later calls, return the object only when it is not active and save to use. Typically, you only need to call gnc_GWEN_Gui_release() once your job has finished.

Parameters
parentWidget to set new dialogs transient for, may be NULL
Returns
The unique GncGWENGui object or NULL otherwise

Definition at line 311 of file gnc-gwen-gui.c.

312 {
313  GncGWENGui *gui;
314 
315  ENTER("parent=%p", parent);
316 
317  if (full_gui)
318  {
319  if (full_gui->state == INIT || full_gui->state == RUNNING)
320  {
321  LEAVE("full_gui in use, state=%d", full_gui->state);
322  return NULL;
323  }
324 
325  gui = full_gui;
326  gui->parent = parent;
327  reset_dialog(gui);
328  register_callbacks(gui);
329 
330  LEAVE("gui=%p", gui);
331  return gui;
332  }
333 
334  gui = g_new0(GncGWENGui, 1);
335  gui->parent = parent;
336  setup_dialog(gui);
337  register_callbacks(gui);
338 
339  full_gui = gui;
340 
341  LEAVE("new gui=%p", gui);
342  return gui;
343 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
gboolean gnc_GWEN_Gui_get_close_flag ( void  )

Get "Close when finished" flag

Returns
gboolean close_when_finished

Definition at line 410 of file gnc-gwen-gui.c.

411 {
412  return gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH);
413 }
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
void gnc_GWEN_Gui_hide_dialog ( void  )

Hides Online Banking Connection Window (Close log window)

Definition at line 444 of file gnc-gwen-gui.c.

445 {
446  GncGWENGui *gui = full_gui;
447 
448  if (gui)
449  {
450  hide_dialog(gui);
451  }
452 }
void gnc_GWEN_Gui_log_init ( void  )

Hook our logging into the gwenhywfar logging framework by creating a minimalistic GWEN_GUI with only a callback for Gwen_Gui_LogHook(). This function can be called more than once, it will unref and replace the currently set GWEN_GUI though.

Definition at line 289 of file gnc-gwen-gui.c.

290 {
291  if (!log_gwen_gui)
292  {
293  log_gwen_gui =
294 #ifdef USING_GWENHYWFAR_GTK2_GUI
295  Gtk2_Gui_new()
296 #else
297  GWEN_Gui_new()
298 #endif
299  ;
300 
301  /* Always use our own logging */
302  GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb);
303 
304  /* Keep a reference so that the GWEN_GUI survives a GUI switch */
305  GWEN_Gui_Attach(log_gwen_gui);
306  }
307  GWEN_Gui_SetGui(log_gwen_gui);
308 }
void gnc_GWEN_Gui_release ( GncGWENGui *  gui)

Currently a no-op. The GncGWENGui will not be freed and it is considered finished once the first tracked progress has ended.

Parameters
guiThe GncGwenGUI returned by gnc_GWEN_Gui_get()

Definition at line 346 of file gnc-gwen-gui.c.

347 {
348  g_return_if_fail(gui && gui == full_gui);
349 
350  /* Currently a no-op */
351  ENTER("gui=%p", gui);
352  LEAVE(" ");
353 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_GWEN_Gui_set_close_flag ( gboolean  close_when_finished)

Set "Close when finished" flag

Parameters
gbooleanclose_when_finished

Definition at line 391 of file gnc-gwen-gui.c.

392 {
394  GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH,
395  close_when_finished);
396 
397  if (full_gui)
398  {
399  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(full_gui->close_checkbutton))
400  != close_when_finished)
401  {
402  gtk_toggle_button_set_active(
403  GTK_TOGGLE_BUTTON(full_gui->close_checkbutton),
404  close_when_finished);
405  }
406  }
407 }
gboolean gnc_prefs_set_bool(const gchar *group, const gchar *pref_name, gboolean value)
Definition: gnc-prefs.c:282
gboolean gnc_GWEN_Gui_show_dialog ( void  )

Unhides Online Banking Connection Window (Make log visible)

Returns
gboolean window is visible

Definition at line 416 of file gnc-gwen-gui.c.

417 {
418  GncGWENGui *gui = full_gui;
419 
420  if (!gui)
421  {
422  gnc_GWEN_Gui_get(NULL);
423  }
424 
425  if (gui)
426  {
427  if (gui->state == HIDDEN)
428  {
429  gui->state = FINISHED;
430  }
431  gtk_toggle_button_set_active(
432  GTK_TOGGLE_BUTTON(gui->close_checkbutton),
433  gnc_prefs_get_bool (GNC_PREFS_GROUP_AQBANKING, GNC_PREF_CLOSE_ON_FINISH));
434 
435  show_dialog(gui, FALSE);
436 
437  return TRUE;
438  }
439 
440  return FALSE;
441 }
GncGWENGui * gnc_GWEN_Gui_get(GtkWidget *parent)
Definition: gnc-gwen-gui.c:311
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
void gnc_GWEN_Gui_shutdown ( void  )

Free all memory related to both the full-blown and minimalistic GUI objects.

Definition at line 356 of file gnc-gwen-gui.c.

357 {
358  GncGWENGui *gui = full_gui;
359 
360  ENTER(" ");
361 
362  if (log_gwen_gui)
363  {
364  GWEN_Gui_free(log_gwen_gui);
365  log_gwen_gui = NULL;
366  }
367  GWEN_Gui_SetGui(NULL);
368 
369  if (!gui)
370  return;
371 
372  gui->parent = NULL;
373  reset_dialog(gui);
374  if (gui->passwords)
375  g_hash_table_destroy(gui->passwords);
376  if (gui->showbox_hash)
377  g_hash_table_destroy(gui->showbox_hash);
378  if (gui->permanently_accepted_certs)
379  GWEN_DB_Group_free(gui->permanently_accepted_certs);
380  if (gui->accepted_certs)
381  g_hash_table_destroy(gui->accepted_certs);
382  gtk_widget_destroy(gui->dialog);
383  g_free(gui);
384 
385  full_gui = NULL;
386 
387  LEAVE(" ");
388 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_GWEN_Init ( void  )

Initialize the gwenhywfar library by calling GWEN_Init() and setting up gwenhywfar logging.

Definition at line 87 of file gnc-ab-utils.c.

88 {
89  gchar* gwen_logging = g_strdup(g_getenv("GWEN_LOGLEVEL"));
90  gchar* aqb_logging = g_strdup(g_getenv("AQBANKING_LOGLEVEL"));
91 
92  /* Initialize gwen library */
93  GWEN_Init();
94 
95  /* Initialize gwen logging */
96  if (gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_VERBOSE_DEBUG))
97  {
98  if (!gwen_logging)
99  {
100  GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Info);
101  GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Info);
102  }
103  if (!aqb_logging)
104  GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Debug);
105  }
106  else
107  {
108  if (!gwen_logging)
109  {
110  GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
111  GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Error);
112  }
113  if (!aqb_logging)
114  GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
115  }
116  g_free(gwen_logging);
117  g_free(aqb_logging);
119 }
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
void gnc_GWEN_Gui_log_init(void)
Definition: gnc-gwen-gui.c:289
void gnc_plugin_aqbanking_create_plugin ( void  )

Create a new GncPluginAqBanking object and register it.

Definition at line 707 of file gnc-plugin-aqbanking.c.

708 {
710 
712 }
void gnc_plugin_manager_add_plugin(GncPluginManager *manager, GncPlugin *plugin)
GncPluginManager * gnc_plugin_manager_get(void)
GncPlugin * gnc_plugin_aqbanking_new(void)
GType gnc_plugin_aqbanking_get_type ( void  )
Returns
The glib runtime type of an aqbanking plugin page
GncPlugin* gnc_plugin_aqbanking_new ( void  )
Returns
A new GncPluginAqBanking object

Definition at line 209 of file gnc-plugin-aqbanking.c.

210 {
211  return GNC_PLUGIN(g_object_new(GNC_TYPE_PLUGIN_AQBANKING, (gchar*) NULL));
212 }
void gnc_plugin_aqbanking_set_logwindow_visible ( gboolean  logwindow_visible)

Set MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW

Definition at line 470 of file gnc-plugin-aqbanking.c.

471 {
472  GtkAction *action;
473 
474  action = gnc_main_window_find_action(gnc_main_window,
475  MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW);
476  if (action)
477  {
478  gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),
479  logwindow_visible);
480  }
481 }
GtkAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *name)