GnuCash 2.3.0
Data Structures | Files | Defines | Typedefs | Enumerations | Functions
AqBanking
Import_Export

Data Structures

struct  GncPluginAqBanking
struct  GncPluginAqBankingClass

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-file-aqb-import.h
 

DTAUS import module interface.


file  gnc-gwen-gui.h
 

GUI callbacks for AqBanking.


file  gnc-plugin-aqbanking.h
 

Plugin registration of the AqBanking module.


Defines

#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 GCONF_SECTION_AQBANKING   "dialogs/import/hbci"
#define KEY_FORMAT_SWIFT940   "format_swift_mt940"
#define KEY_FORMAT_SWIFT942   "format_swift_mt942"
#define KEY_FORMAT_DTAUS   "format_dtaus"
#define KEY_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 }

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)
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 kvp_frame *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)
kvp_frame * gnc_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)

Define 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.

{
    if (!api)
        api = gnc_AB_BANKING;

    if (api)
    {
        if (api == gnc_AB_BANKING)
        {
            gnc_AB_BANKING = NULL;
            gnc_AB_BANKING_fini(api);
        }

        AB_Banking_free(api);
    }
}
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.

{
    if (api == gnc_AB_BANKING)
    {
        if (--gnc_AB_BANKING_refcount == 0)
        {
#ifdef AQBANKING_VERSION_5_PLUS
            if (gnc_gwengui_extended_by_ABBanking)
                AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
            gnc_gwengui_extended_by_ABBanking = NULL;
#endif /* AQBANKING_VERSION_5_PLUS */
            return AB_Banking_Fini(api);
        }
    }
    else
    {
#ifdef AQBANKING_VERSION_5_PLUS
        if (gnc_gwengui_extended_by_ABBanking)
            AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
        gnc_gwengui_extended_by_ABBanking = NULL;
#endif /* AQBANKING_VERSION_5_PLUS */
        return AB_Banking_Fini(api);
    }
    return 0;
}
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.

{
    AB_BANKING *api;

    if (gnc_AB_BANKING)
    {
        /* API cached. */
        api = gnc_AB_BANKING;

        /* Init the API again. */
        if (gnc_AB_BANKING_refcount == 0)
            g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);

    }
    else
    {
        api = AB_Banking_new("gnucash", NULL, 0);
        g_return_val_if_fail(api, NULL);

#ifdef AQBANKING_VERSION_4_PLUS
        /* Check for config migration */
        if (AB_Banking_HasConf4(api
# ifndef AQBANKING_VERSION_5_PLUS
                                , 0
# endif
                               ) != 0)
        {
            if (AB_Banking_HasConf3(api
# ifndef AQBANKING_VERSION_5_PLUS
                                    , 0
# endif
                                   ) == 0)
            {
                g_message("gnc_AB_BANKING_new: importing aqbanking3 configuration\n");
                if (AB_Banking_ImportConf3(api
# ifndef AQBANKING_VERSION_5_PLUS
                                           , 0
# endif
                                          ) < 0)
                {
                    g_message("gnc_AB_BANKING_new: unable to import aqbanking3 configuration\n");
                }
            }
            else if (AB_Banking_HasConf2(api
# ifndef AQBANKING_VERSION_5_PLUS
                                         , 0
# endif
                                        ) == 0)
            {
                g_message("gnc_AB_BANKING_new: importing aqbanking2 configuration\n");
                if (AB_Banking_ImportConf2(api
# ifndef AQBANKING_VERSION_5_PLUS
                                           , 0
# endif
                                          ) < 0)
                {
                    g_message("gnc_AB_BANKING_new: unable to import aqbanking2 configuration\n");
                }
            }
        }
#endif /* AQBANKING_VERSION_4_PLUS */

        /* Init the API */
        g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);

#ifdef AQBANKING_VERSION_5_PLUS
        gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui();
        AB_Gui_Extend(gnc_gwengui_extended_by_ABBanking, api);
#endif /* AQBANKING_VERSION_5_PLUS */

        /* Cache it */
        gnc_AB_BANKING = api;
        gnc_AB_BANKING_refcount = 0;
    }

    gnc_AB_BANKING_refcount++;

    return api;
}
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.

{
    /* Description */
    gchar *description = gnc_ab_get_purpose(ab_trans);
    gchar *other_name = gnc_ab_get_remote_name(ab_trans);
    gchar *retval;

    if (other_name)
    {
        if (description && *description)
        {
            retval = g_strdup_printf("%s; %s", description, other_name);
        }
        else
        {
            retval = g_strdup(other_name);
        }
    }
    else
    {
        if (description && *description)
        {
            retval = g_strdup(description);
        }
        else
        {
            retval = g_strdup(_("Unspecified"));
        }
    }
    g_free(description);
    g_free(other_name);

    return retval;
}
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.

{
    GtkBuilder *builder;
    GtkWidget *dialog;
    GtkWidget *heading_label;
    GtkWidget *first_button;
    GtkWidget *last_retrieval_button;
    GtkWidget *now_button;
    DaterangeInfo info;
    gint result;

    ENTER("");

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Date Range Dialog");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Date Range Dialog"));

    /* Connect the signals */
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info );

    if (parent)
        gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));

    heading_label  = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
    first_button  = GTK_WIDGET(gtk_builder_get_object (builder, "first_button"));
    last_retrieval_button  = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button"));
    info.enter_from_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button"));
    now_button  = GTK_WIDGET(gtk_builder_get_object (builder, "now_button"));
    info.enter_to_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button"));

    info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE);
    gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")),
                      info.from_dateedit);
    gtk_widget_show(info.from_dateedit);

    info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE);
    gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")),
                      info.to_dateedit);
    gtk_widget_show(info.to_dateedit);

    if (*last_retv_date)
    {
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button),
                                     TRUE);
    }
    else
    {
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE);
        gtk_widget_set_sensitive(last_retrieval_button, FALSE);
    }

    gtk_widget_set_sensitive(info.from_dateedit, FALSE);
    gtk_widget_set_sensitive(info.to_dateedit, FALSE);

    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

    if (heading)
        gtk_label_set_text(GTK_LABEL(heading_label), heading);

    gtk_widget_show(dialog);

    result = gtk_dialog_run(GTK_DIALOG(dialog));
    gtk_widget_hide(dialog);

    if (result == GTK_RESPONSE_OK)
    {
        *from_date = gnc_date_edit_get_date_ts(
                         GNC_DATE_EDIT(info.from_dateedit));
        *last_retv_date = gtk_toggle_button_get_active(
                              GTK_TOGGLE_BUTTON(last_retrieval_button));
        *first_possible_date = gtk_toggle_button_get_active(
                                   GTK_TOGGLE_BUTTON(first_button));
        *to_date = gnc_date_edit_get_date_ts(
                       GNC_DATE_EDIT(info.to_dateedit));
        *to_now = gtk_toggle_button_get_active(
                      GTK_TOGGLE_BUTTON(now_button));
    }

    g_object_unref(G_OBJECT(builder));

    gtk_widget_destroy(dialog);

    LEAVE("");
    return result == GTK_RESPONSE_OK;
}
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.

{
    AB_ACCOUNT *ab_account = NULL;
    const gchar *bankcode = NULL;
    const gchar *accountid = NULL;
    guint32 account_uid = 0;

    bankcode = gnc_ab_get_account_bankcode(gnc_acc);
    accountid = gnc_ab_get_account_accountid(gnc_acc);
    account_uid = gnc_ab_get_account_uid (gnc_acc);

    if (account_uid > 0)
    {
        ab_account = AB_Banking_GetAccount(api, account_uid);

        if (!ab_account && bankcode && *bankcode && accountid && *accountid)
        {
            g_message("gnc_ab_get_ab_account: No AB_ACCOUNT found for UID %d, "
                      "trying bank code\n", account_uid);
            ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
                         accountid);
        }
        return ab_account;

    }
    else if (bankcode && *bankcode && accountid && *accountid)
    {
        ab_account = AB_Banking_GetAccountByCodeAndNumber(api, bankcode,
                     accountid);
        return ab_account;
    }

    return NULL;
}
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 49 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
    kvp_value *value = kvp_frame_get_slot(frame, AB_ACCOUNT_ID);
    return kvp_value_get_string(value);
}
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 68 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
    kvp_value *value = kvp_frame_get_slot(frame, AB_BANK_CODE);
    return kvp_value_get_string(value);
}
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 106 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
    kvp_value *value = kvp_frame_get_slot(frame, AB_TRANS_RETRIEVAL);
    return kvp_value_get_timespec(value);
}
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 87 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, FALSE);
    kvp_value *value = kvp_frame_get_slot(frame, AB_ACCOUNT_UID);
    return (guint32) kvp_value_get_gint64(value);
}
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 125 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_book_kvp(b, FALSE);
    kvp_value *value = kvp_frame_get_slot(frame, AB_TEMPLATES);
    return kvp_value_get_glist(value);
}
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 1063 of file gnc-ab-utils.c.

{
    int rv;
    GWEN_DB_NODE *perm_certs = NULL;
    AB_BANKING *banking = gnc_AB_BANKING_new();

    g_return_val_if_fail(banking, NULL);
#ifdef AQBANKING_VERSION_4_PLUS
    rv = AB_Banking_LoadSharedConfig(banking, "certs", &perm_certs
# ifndef AQBANKING_VERSION_5_PLUS
                                     , 0
# endif
                                    );
#else
    /* FIXME: Add code for older AqBanking versions */
    /* See QBankmanager 0.9.50 in src/kbanking/libs/kbanking.cpp lines 323ff
       for a proper example of how to do this */
    rv = 0;
#endif
    gnc_AB_BANKING_fini(banking);
    g_return_val_if_fail(rv >= 0, NULL);
    return perm_certs;
}
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.

{
    const GWEN_STRINGLIST *ab_purpose;
    gchar *gnc_description = NULL;

    g_return_val_if_fail(ab_trans, g_strdup(""));

    ab_purpose = AB_Transaction_GetPurpose(ab_trans);
    if (ab_purpose)
        GWEN_StringList_ForEach(ab_purpose, join_ab_strings_cb,
                                &gnc_description);

    if (!gnc_description)
        gnc_description = g_strdup("");

    return gnc_description;
}
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.

{
    const GWEN_STRINGLIST *ab_remote_name;
    gchar *gnc_other_name = NULL;

    g_return_val_if_fail(ab_trans, NULL);

    ab_remote_name = AB_Transaction_GetRemoteName(ab_trans);
    if (ab_remote_name)
        GWEN_StringList_ForEach(ab_remote_name, join_ab_strings_cb,
                                &gnc_other_name);

    if (!gnc_other_name || !*gnc_other_name)
    {
        g_free(gnc_other_name);
        gnc_other_name = NULL;
    }

    return gnc_other_name;
}
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 755 of file dialog-ab-trans.c.

{
    AB_JOB *job;

    g_return_val_if_fail(ab_acc && ab_trans, NULL);

    job = gnc_ab_trans_dialog_get_available_empty_job(ab_acc, trans_type);
    if (job)
    {
        switch (trans_type)
        {
        case SINGLE_DEBITNOTE:
            AB_JobSingleDebitNote_SetTransaction(job, ab_trans);
            break;
        case SINGLE_INTERNAL_TRANSFER:
            AB_JobInternalTransfer_SetTransaction(job, ab_trans);
            break;
        case SINGLE_TRANSFER:
        default:
            AB_JobSingleTransfer_SetTransaction(job, ab_trans);
            break;
        };
    }
    return job;
}
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.

{
    AB_BANKING *api;
    gboolean online = FALSE;
    AB_ACCOUNT *ab_acc;
    AB_JOB *job = NULL;
    AB_JOB_LIST2 *job_list = NULL;
    GncGWENGui *gui = NULL;
    AB_IMEXPORTER_CONTEXT *context = NULL;
    GncABImExContextImport *ieci = NULL;
    AB_JOB_STATUS job_status;

    g_return_if_fail(parent && gnc_acc);

    /* Get the API */
    api = gnc_AB_BANKING_new();
    if (!api)
    {
        g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
        return;
    }
    if (AB_Banking_OnlineInit(api
#ifdef AQBANKING_VERSION_4_EXACTLY
                              , 0
#endif
                             ) != 0)
    {
        g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
        goto cleanup;
    }
    online = TRUE;

    /* Get the AqBanking Account */
    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
    if (!ab_acc)
    {
        g_warning("gnc_ab_getbalance: No AqBanking account found");
        gnc_error_dialog(parent, _("No valid online banking account assigned."));
        goto cleanup;
    }

    /* Get a GetBalance job and enqueue it */
    job = AB_JobGetBalance_new(ab_acc);
    if (!job || AB_Job_CheckAvailability(job
#ifndef AQBANKING_VERSION_5_PLUS
                                         , 0
#endif
                                        ))
    {
        g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
                  "account");
        gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account."));
        goto cleanup;
    }
    job_list = AB_Job_List2_new();
    AB_Job_List2_PushBack(job_list, job);

    /* Get a GUI object */
    gui = gnc_GWEN_Gui_get(parent);
    if (!gui)
    {
        g_warning("gnc_ab_getbalance: Couldn't initialize Gwenhywfar GUI");
        goto cleanup;
    }

    /* Create a context to store the results */
    context = AB_ImExporterContext_new();

    /* Execute the job */
    AB_Banking_ExecuteJobs(api, job_list, context
#ifndef AQBANKING_VERSION_5_PLUS
                           , 0
#endif
                          );
    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
     * status always describes better whether the job was actually
     * transferred to and accepted by the bank.  See also
     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
     */
    job_status = AB_Job_GetStatus(job);
    if (job_status != AB_Job_StatusFinished
            && job_status != AB_Job_StatusPending)
    {
        g_warning("gnc_ab_getbalance: Error on executing job");
        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
                         , AB_Job_Status2Char(job_status)
                         , AB_Job_GetResultText(job));
        goto cleanup;
    }

    /* Import the results */
    ieci = gnc_ab_import_context(context, AWAIT_BALANCES, FALSE, NULL, parent);

cleanup:
    if (ieci)
        g_free(ieci);
    if (context)
        AB_ImExporterContext_free(context);
    if (gui)
        gnc_GWEN_Gui_release(gui);
    if (job_list)
        AB_Job_List2_free(job_list);
    if (job)
        AB_Job_free(job);
    if (online)
#ifdef AQBANKING_VERSION_4_EXACTLY
        AB_Banking_OnlineFini(api, 0);
#else
        AB_Banking_OnlineFini(api);
#endif
    gnc_AB_BANKING_fini(api);
}
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.

{
    AB_BANKING *api;
    gboolean online = FALSE;
    AB_ACCOUNT *ab_acc;
    GWEN_TIME *from_date = NULL, *to_date = NULL;
    Timespec until_timespec;
    AB_JOB *job = NULL;
    AB_JOB_LIST2 *job_list = NULL;
    GncGWENGui *gui = NULL;
    AB_IMEXPORTER_CONTEXT *context = NULL;
    GncABImExContextImport *ieci = NULL;
    AB_JOB_STATUS job_status;

    g_return_if_fail(parent && gnc_acc);

    /* Get the API */
    api = gnc_AB_BANKING_new();
    if (!api)
    {
        g_warning("gnc_ab_gettrans: Couldn't get AqBanking API");
        return;
    }
    if (AB_Banking_OnlineInit(api
#ifdef AQBANKING_VERSION_4_EXACTLY
                              , 0
#endif
                             ) != 0)
    {
        g_warning("gnc_ab_gettrans: Couldn't initialize AqBanking API");
        goto cleanup;
    }
    online = TRUE;

    /* Get the AqBanking Account */
    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
    if (!ab_acc)
    {
        g_warning("gnc_ab_gettrans: No AqBanking account found");
        gnc_error_dialog(parent, _("No valid online banking account assigned."));
        goto cleanup;
    }

    /* Get the start and end dates for the GetTransactions job.  */
    if (!gettrans_dates(parent, gnc_acc, &from_date, &to_date))
    {
        g_debug("gnc_ab_gettrans: gettrans_dates aborted");
        goto cleanup;
    }
    /* Use this as a local storage for the until_time below. */
    timespecFromTime_t(&until_timespec, GWEN_Time_toTime_t(to_date));

    /* Get a GetTransactions job and enqueue it */
    job = AB_JobGetTransactions_new(ab_acc);
    if (!job || AB_Job_CheckAvailability(job
#ifndef AQBANKING_VERSION_5_PLUS
                                         , 0
#endif
                                        ))
    {
        g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
                  "account");
        gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account."));
        goto cleanup;
    }
    AB_JobGetTransactions_SetFromTime(job, from_date);
    AB_JobGetTransactions_SetToTime(job, to_date);
    job_list = AB_Job_List2_new();
    AB_Job_List2_PushBack(job_list, job);

    /* Get a GUI object */
    gui = gnc_GWEN_Gui_get(parent);
    if (!gui)
    {
        g_warning("gnc_ab_gettrans: Couldn't initialize Gwenhywfar GUI");
        goto cleanup;
    }

    /* Create a context to store the results */
    context = AB_ImExporterContext_new();

    /* Execute the job */
    AB_Banking_ExecuteJobs(api, job_list, context
#ifndef AQBANKING_VERSION_5_PLUS
                           , 0
#endif
                          );
    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
     * status always describes better whether the job was actually
     * transferred to and accepted by the bank.  See also
     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
     */
    job_status = AB_Job_GetStatus(job);
    if (job_status != AB_Job_StatusFinished
            && job_status != AB_Job_StatusPending)
    {
        g_warning("gnc_ab_gettrans: Error on executing job");
        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
                         , AB_Job_Status2Char(job_status)
                         , AB_Job_GetResultText(job));
        goto cleanup;
    }

    /* Import the results */
    ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, FALSE, NULL,
                                 parent);
    if (!(gnc_ab_ieci_get_found(ieci) & FOUND_TRANSACTIONS))
    {
        /* No transaction found */
        GtkWidget *dialog = gtk_message_dialog_new(
                                GTK_WINDOW(parent),
                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                GTK_MESSAGE_INFO,
                                GTK_BUTTONS_OK,
                                "%s",
                                _("The Online Banking import returned no transactions "
                                  "for the selected time period."));
        gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);
    }

    /* Store the date of this retrieval */
    gnc_ab_set_account_trans_retrieval(gnc_acc, until_timespec);

cleanup:
    if (ieci)
        g_free(ieci);
    if (context)
        AB_ImExporterContext_free(context);
    if (gui)
        gnc_GWEN_Gui_release(gui);
    if (job_list)
        AB_Job_List2_free(job_list);
    if (job)
        AB_Job_free(job);
    if (to_date)
        GWEN_Time_free(to_date);
    if (from_date)
        GWEN_Time_free(from_date);
    if (online)
#ifdef AQBANKING_VERSION_4_EXACTLY
        AB_Banking_OnlineFini(api, 0);
#else
        AB_Banking_OnlineFini(api);
#endif
    gnc_AB_BANKING_fini(api);
}
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 1039 of file gnc-ab-utils.c.

{
    g_return_val_if_fail(ieci, 0);

    return ieci->awaiting;
}
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 1047 of file gnc-ab-utils.c.

{
    g_return_val_if_fail(ieci, NULL);

    return ieci->job_list;
}
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 1055 of file gnc-ab-utils.c.

{
    g_return_val_if_fail(ieci, FALSE);

    return gnc_gen_trans_list_run(ieci->generic_importer);
}
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 995 of file gnc-ab-utils.c.

{
    GncABImExContextImport *data = g_new(GncABImExContextImport, 1);

    g_return_val_if_fail(context, NULL);
    /* Do not await and ignore at the same time */
    g_return_val_if_fail(!(awaiting & AWAIT_BALANCES)
                         || !(awaiting & IGNORE_BALANCES),
                         NULL);
    g_return_val_if_fail(!(awaiting & AWAIT_TRANSACTIONS)
                         || !(awaiting & IGNORE_TRANSACTIONS),
                         NULL);
    /* execute_txns must be FALSE if txns are not awaited */
    g_return_val_if_fail(awaiting & AWAIT_TRANSACTIONS || !execute_txns, NULL);
    /* An api is needed for the jobs */
    g_return_val_if_fail(!execute_txns || api, NULL);

    data->awaiting = awaiting;
    data->txn_found = FALSE;
    data->execute_txns = execute_txns;
    data->api = api;
    data->parent = parent;
    data->job_list = AB_Job_List2_new();
    data->tmp_job_list = NULL;
    data->generic_importer = NULL;

    g_datalist_init(&data->tmp_job_list);

    /* Import transactions */
    if (!(awaiting & IGNORE_TRANSACTIONS))
        AB_ImExporterContext_AccountInfoForEach(context, txn_accountinfo_cb,
                                                data);

    /* Check balances */
    if (!(awaiting & IGNORE_BALANCES))
        AB_ImExporterContext_AccountInfoForEach(context, bal_accountinfo_cb,
                                                data);

    return data;
}
G_BEGIN_DECLS void gnc_ab_initial_assistant ( void  )

Create and show an assistant for the aqbanking setup.

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

{
    ABInitialInfo *info;
    GtkBuilder *builder;
    GtkTreeViewColumn *column;
    GtkTreeSelection *selection;
    gint component_id;

    info = g_new0(ABInitialInfo, 1);
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "assistant-ab-initial.glade", "AqBanking Init Assistant");

    info->window = GTK_WIDGET(gtk_builder_get_object (builder, "AqBanking Init Assistant"));

    gnc_assistant_set_colors (GTK_ASSISTANT (info->assistant));

    info->api = gnc_AB_BANKING_new();
    info->deferred_info = NULL;
    info->gnc_hash = NULL;

    info->match_page_prepared = FALSE;
    info->account_view =
        GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_page_view"));

    info->account_store = gtk_list_store_new(NUM_ACCOUNT_LIST_COLS,
                          G_TYPE_INT, G_TYPE_STRING,
                          G_TYPE_POINTER, G_TYPE_STRING,
                          G_TYPE_BOOLEAN);
    gtk_tree_view_set_model(info->account_view,
                            GTK_TREE_MODEL(info->account_store));
    g_object_unref(info->account_store);

    column = gtk_tree_view_column_new_with_attributes(
                 _("Online Banking Account Name"), gtk_cell_renderer_text_new(),
                 "text", ACCOUNT_LIST_COL_AB_NAME, (gchar*) NULL);
    gtk_tree_view_append_column(info->account_view, column);

    column = gtk_tree_view_column_new_with_attributes(
                 _("GnuCash Account Name"), gtk_cell_renderer_text_new(),
                 "text", ACCOUNT_LIST_COL_GNC_NAME, (gchar*) NULL);
    gtk_tree_view_column_set_expand(column, TRUE);
    gtk_tree_view_append_column(info->account_view, column);

    column = gtk_tree_view_column_new_with_attributes(
                 _("New?"), gtk_cell_renderer_toggle_new(),
                 "active", ACCOUNT_LIST_COL_CHECKED, (gchar*) NULL);
    gtk_tree_view_append_column(info->account_view, column);

    selection = gtk_tree_view_get_selection(info->account_view);
    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

    g_signal_connect(info->account_view, "row-activated",
                     G_CALLBACK(account_list_clicked_cb), info);

    g_signal_connect (G_OBJECT(info->window), "destroy",
                      G_CALLBACK (aai_destroy_cb), info);

    gtk_builder_connect_signals(builder, info);
    g_object_unref(G_OBJECT(builder));

    component_id = gnc_register_gui_component(ASSISTANT_AB_INITIAL_CM_CLASS,
                   NULL, aai_close_handler, info);

    gnc_gui_component_set_session(component_id, gnc_get_current_session());

    gtk_widget_show(info->window);
}
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 712 of file gnc-ab-utils.c.

{
    return g_strdup_printf("job_%lu", job_id);
}
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 700 of file gnc-ab-utils.c.

{
    if (job)
    {
        return gnc_AB_JOB_ID_to_string(AB_Job_GetJobId(job));
    }
    else
    {
        return gnc_AB_JOB_ID_to_string(0);
    }
}
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.

{
    AB_BANKING *api;
    gboolean online = FALSE;
    AB_ACCOUNT *ab_acc;
    GncABTransDialog *dialog = NULL;
    GList *templates = NULL;
    GncABTransDialog *td = NULL;
    gboolean successful = FALSE;
    gboolean aborted = FALSE;

    g_return_if_fail(parent && gnc_acc);

    /* Get the API */
    api = gnc_AB_BANKING_new();
    if (!api)
    {
        g_warning("gnc_ab_maketrans: Couldn't get AqBanking API");
        return;
    }
    if (AB_Banking_OnlineInit(api
#ifdef AQBANKING_VERSION_4_EXACTLY
                              , 0
#endif
                             ) != 0)
    {
        g_warning("gnc_ab_maketrans: Couldn't initialize AqBanking API");
        goto cleanup;
    }
    online = TRUE;

    /* Get the AqBanking Account */
    ab_acc = gnc_ab_get_ab_account(api, gnc_acc);
    if (!ab_acc)
    {
        g_warning("gnc_ab_gettrans: No AqBanking account found");
        gnc_error_dialog(parent, _("No valid online banking account assigned."));
        goto cleanup;
    }

    /* Get list of template transactions */
    templates = gnc_ab_trans_templ_list_new_from_kvp_list(
                    gnc_ab_get_book_template_list(gnc_account_get_book(gnc_acc)));

    /* Create new ABTransDialog */
    td = gnc_ab_trans_dialog_new(parent, ab_acc,
                                 xaccAccountGetCommoditySCU(gnc_acc),
                                 trans_type, templates);
    templates = NULL;

    /* Repeat until AqBanking action was successful or user pressed cancel */
    do
    {
        GncGWENGui *gui = NULL;
        gint result;
        gboolean changed;
        const AB_TRANSACTION *ab_trans;
        AB_JOB *job = NULL;
        AB_JOB_LIST2 *job_list = NULL;
        XferDialog *xfer_dialog = NULL;
        gnc_numeric amount;
        gchar *description;
        gchar *memo;
        Transaction *gnc_trans = NULL;
        AB_IMEXPORTER_CONTEXT *context = NULL;
        AB_JOB_STATUS job_status;
        GncABImExContextImport *ieci = NULL;

        /* Get a GUI object */
        gui = gnc_GWEN_Gui_get(parent);
        if (!gui)
        {
            g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
            aborted = TRUE;
            goto repeat;
        }

        /* Let the user enter the values */
        result = gnc_ab_trans_dialog_run_until_ok(td);

        if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
        {
            aborted = TRUE;
            goto repeat;
        }

        /* Save the templates */
        templates = gnc_ab_trans_dialog_get_templ(td, &changed);
        if (changed)
            save_templates(parent, gnc_acc, templates,
                           (result == GNC_RESPONSE_NOW));
        g_list_free(templates);
        templates = NULL;

        /* Get a job and enqueue it */
        ab_trans = gnc_ab_trans_dialog_get_ab_trans(td);
        job = gnc_ab_trans_dialog_get_job(td);
        if (!job || AB_Job_CheckAvailability(job
#ifndef AQBANKING_VERSION_5_PLUS
                                             , 0
#endif
                                            ))
        {
            if (!gnc_verify_dialog(
                        parent, FALSE, "%s",
                        _("The backend found an error during the preparation "
                          "of the job. It is not possible to execute this job. \n"
                          "\n"
                          "Most probable the bank does not support your chosen "
                          "job or your Online Banking account does not have the permission "
                          "to execute this job. More error messages might be "
                          "visible on your console log.\n"
                          "\n"
                          "Do you want to enter the job again?")))
                aborted = TRUE;
            goto repeat;
        }
        job_list = AB_Job_List2_new();
        AB_Job_List2_PushBack(job_list, job);

        /* Setup a Transfer Dialog for the GnuCash transaction */
        xfer_dialog = gnc_xfer_dialog(gnc_ab_trans_dialog_get_parent(td),
                                      gnc_acc);
        switch (trans_type)
        {
        case SINGLE_DEBITNOTE:
            gnc_xfer_dialog_set_title(
                xfer_dialog, _("Online Banking Direct Debit Note"));
            gnc_xfer_dialog_lock_to_account_tree(xfer_dialog);
            break;
        case SINGLE_INTERNAL_TRANSFER:
            gnc_xfer_dialog_set_title(
                xfer_dialog, _("Online Banking Bank-Internal Transfer"));
            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
            break;
        case SINGLE_TRANSFER:
        default:
            gnc_xfer_dialog_set_title(
                xfer_dialog, _("Online Banking Transaction"));
            gnc_xfer_dialog_lock_from_account_tree(xfer_dialog);
        }

        amount = double_to_gnc_numeric(
                     AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
                     xaccAccountGetCommoditySCU(gnc_acc),
                     GNC_HOW_RND_ROUND_HALF_UP);
        gnc_xfer_dialog_set_amount(xfer_dialog, amount);
        gnc_xfer_dialog_set_amount_sensitive(xfer_dialog, FALSE);

        description = gnc_ab_description_to_gnc(ab_trans);
        gnc_xfer_dialog_set_description(xfer_dialog, description);
        g_free(description);

        memo = gnc_ab_memo_to_gnc(ab_trans);
        gnc_xfer_dialog_set_memo(xfer_dialog, memo);
        g_free(memo);

        gnc_xfer_dialog_set_txn_cb(xfer_dialog, txn_created_cb, &gnc_trans);

        /* And run it */
        successful = gnc_xfer_dialog_run_until_done(xfer_dialog);

        /* On cancel, go back to the AB transaction dialog */
        if (!successful || !gnc_trans)
        {
            successful = FALSE;
            goto repeat;
        }

        if (result == GNC_RESPONSE_NOW)
        {
            /* Create a context to store possible results */
            context = AB_ImExporterContext_new();

            gui = gnc_GWEN_Gui_get(parent);
            if (!gui)
            {
                g_warning("gnc_ab_maketrans: Couldn't initialize Gwenhywfar GUI");
                aborted = TRUE;
                goto repeat;
            }

            /* Finally, execute the job */
            AB_Banking_ExecuteJobs(api, job_list, context
#ifndef AQBANKING_VERSION_5_PLUS
                                   , 0
#endif
                                  );

            /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
             * status always describes better whether the job was actually
             * transferred to and accepted by the bank.  See also
             * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
             */
            job_status = AB_Job_GetStatus(job);
            if (job_status != AB_Job_StatusFinished
                    && job_status != AB_Job_StatusPending)
            {
                successful = FALSE;
                if (!gnc_verify_dialog(
                            parent, FALSE, "%s",
                            _("An error occurred while executing the job.  Please check "
                              "the log window for the exact error message.\n"
                              "\n"
                              "Do you want to enter the job again?")))
                {
                    aborted = TRUE;
                }
            }
            else
            {
                successful = TRUE;
            }

            if (successful)
            {
                /* Import the results, awaiting nothing */
                ieci = gnc_ab_import_context(context, 0, FALSE, NULL, parent);
            }
        }
        /* Simply ignore any other case */

repeat:
        /* Clean up */
        if (gnc_trans && !successful)
        {
            xaccTransBeginEdit(gnc_trans);
            xaccTransDestroy(gnc_trans);
            xaccTransCommitEdit(gnc_trans);
            gnc_trans = NULL;
        }
        if (ieci)
            g_free(ieci);
        if (context)
            AB_ImExporterContext_free(context);
        if (job_list)
        {
            AB_Job_List2_free(job_list);
            job_list = NULL;
        }
        if (job)
        {
            AB_Job_free(job);
            job = NULL;
        }
        if (gui)
        {
            gnc_GWEN_Gui_release(gui);
            gui = NULL;
        }

    }
    while (!successful && !aborted);

cleanup:
    if (td)
        gnc_ab_trans_dialog_free(td);
    if (online)
#ifdef AQBANKING_VERSION_4_EXACTLY
        AB_Banking_OnlineFini(api, 0);
#else
        AB_Banking_OnlineFini(api);
#endif
    gnc_AB_BANKING_fini(api);
}
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.

{
    const gchar *ab_remote_accountnumber =
        AB_Transaction_GetRemoteAccountNumber(ab_trans);
    const gchar *ab_remote_bankcode =
        AB_Transaction_GetRemoteBankCode(ab_trans);

    gchar *ab_other_accountid = g_strdup(ab_remote_accountnumber ? ab_remote_accountnumber : "");
    gchar *ab_other_bankcode = g_strdup(ab_remote_bankcode ? ab_remote_bankcode : "");

    gboolean have_accountid;
    gboolean have_bankcode;

    gchar *retval;

    /* Ensure string is in utf8 */
    gnc_utf8_strip_invalid(ab_other_accountid);
    gnc_utf8_strip_invalid(ab_other_bankcode);

    /* and -then- trim it */
    g_strstrip(ab_other_accountid);
    g_strstrip(ab_other_bankcode);


    have_accountid = ab_other_accountid && *ab_other_accountid;
    have_bankcode = ab_other_bankcode && *ab_other_bankcode;

    if ( have_accountid || have_bankcode )
    {
        retval = g_strdup_printf("%s %s %s %s",
                                 have_accountid ? _("Account") : "",
                                 have_accountid ? ab_other_accountid : "",
                                 have_bankcode  ? _("Bank") : "",
                                 have_bankcode  ? ab_other_bankcode : ""
                                );
        g_strstrip(retval);
    }
    else
    {
        retval = g_strdup("");
    }

    g_free(ab_other_accountid);
    g_free(ab_other_bankcode);

    return retval;
}
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 57 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
    kvp_value *value = kvp_value_new_string(id);
    xaccAccountBeginEdit(a);
    kvp_frame_set_slot_nc(frame, AB_ACCOUNT_ID, value);
    qof_instance_set_dirty(QOF_INSTANCE (a));
    xaccAccountCommitEdit(a);
}
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 76 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
    kvp_value *value = kvp_value_new_string(code);
    xaccAccountBeginEdit(a);
    kvp_frame_set_slot_nc(frame, AB_BANK_CODE, value);
    qof_instance_set_dirty(QOF_INSTANCE (a));
    xaccAccountCommitEdit(a);
}
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 114 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
    kvp_value *value = kvp_value_new_timespec(time);
    xaccAccountBeginEdit(a);
    kvp_frame_set_slot_nc(frame, AB_TRANS_RETRIEVAL, value);
    qof_instance_set_dirty(QOF_INSTANCE (a));
    xaccAccountCommitEdit(a);
}
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 95 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_account_kvp(a, TRUE);
    kvp_value *value = kvp_value_new_gint64(uid);
    xaccAccountBeginEdit(a);
    kvp_frame_set_slot_nc(frame, AB_ACCOUNT_UID, value);
    qof_instance_set_dirty(QOF_INSTANCE (a));
    xaccAccountCommitEdit(a);
}
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 133 of file gnc-ab-kvp.c.

{
    kvp_frame *frame = gnc_ab_get_book_kvp(b, TRUE);
    kvp_value *value = kvp_value_new_glist_nc(template_list);
    kvp_frame_set_slot_nc(frame, AB_TEMPLATES, value);
    qof_book_kvp_changed (b);
}
void gnc_ab_trans_dialog_free ( GncABTransDialog td)

Free a Aqbanking transfer dialog

Parameters:
tdTransaction dialog

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

{
    if (!td) return;
    if (td->ab_trans)
        AB_Transaction_free(td->ab_trans);
    if (td->dialog)
        gtk_widget_destroy(td->dialog);
    if (td->template_list_store)
    {
        gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
                               gnc_ab_trans_dialog_clear_templ_helper, NULL);
        g_object_unref(td->template_list_store);
    }
#if HAVE_KTOBLZCHECK_H
    AccountNumberCheck_delete(td->blzcheck);
#endif
    g_free(td);
}
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 710 of file dialog-ab-trans.c.

{
    g_return_val_if_fail(td, NULL);
    return td->ab_trans;
}
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 748 of file dialog-ab-trans.c.

{
    g_return_val_if_fail(td, NULL);
    return gnc_ab_get_trans_job(td->ab_acc, td->ab_trans, td->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 703 of file dialog-ab-trans.c.

{
    g_return_val_if_fail(td, NULL);
    return td->parent;
}
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 683 of file dialog-ab-trans.c.

{
    GList *list = NULL;

    g_return_val_if_fail(td, NULL);

    if (changed)
    {
        *changed = td->templ_changed;
        if (!*changed)
            return NULL;
    }

    gtk_tree_model_foreach(GTK_TREE_MODEL(td->template_list_store),
                           gnc_ab_trans_dialog_get_templ_helper, &list);
    list = g_list_reverse(list);
    return list;
}
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 223 of file dialog-ab-trans.c.

{
    GncABTransDialog *td;
    GtkBuilder  *builder;
    const gchar *ab_ownername;
    const gchar *ab_accountnumber;
    const gchar *ab_bankname;
    const gchar *ab_bankcode;
    GtkWidget *trans_vbox;
    GtkWidget *heading_label;
    GtkWidget *recp_name_heading;
    GtkWidget *recp_account_heading;
    GtkWidget *recp_bankcode_heading;
    GtkWidget *amount_hbox;
    GtkWidget *orig_name_heading;
    GtkWidget *orig_name_label;
    GtkWidget *orig_account_heading;
    GtkWidget *orig_account_label;
    GtkWidget *orig_bankname_heading;
    GtkWidget *orig_bankname_label;
    GtkWidget *orig_bankcode_heading;
    GtkWidget *orig_bankcode_label;
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    g_return_val_if_fail(ab_acc, NULL);

    ab_ownername = AB_Account_GetOwnerName(ab_acc);
    if (!ab_ownername)
        ab_ownername = "";
    ab_accountnumber = AB_Account_GetAccountNumber(ab_acc);
    ab_bankcode = AB_Account_GetBankCode(ab_acc);
    ab_bankname = AB_Account_GetBankName(ab_acc);
    if (!ab_bankname || !*ab_bankname)
        ab_bankname = _("(unknown)");

    td = g_new0(GncABTransDialog, 1);
    td->parent = parent;
    td->ab_acc = ab_acc;
    td->trans_type = trans_type;

#if HAVE_KTOBLZCHECK_H
    td->blzcheck = AccountNumberCheck_new();
#endif

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-ab.glade", "Transaction Dialog");
    td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Transaction Dialog"));

    if (parent)
        gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent));

    /* Extract widgets */
    trans_vbox = GTK_WIDGET(gtk_builder_get_object (builder, "trans_vbox"));
    heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
    recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading"));
    td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry"));
    recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading"));
    td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry"));
    recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading"));
    td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry"));
    td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label"));
    amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox"));
    td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry"));
    td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry"));
    td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry"));
    td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry"));
    td->exec_button = GTK_WIDGET(gtk_builder_get_object(builder, "exec_now_button"));
    orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading"));
    orig_name_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label"));
    orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading"));
    orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label"));
    orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading"));
    orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label"));
    orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading"));
    orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label"));
    td->template_gtktreeview =
        GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list"));

    /* Amount edit */
    td->amount_edit = gnc_amount_edit_new();
    gtk_box_pack_start_defaults(GTK_BOX(amount_hbox), td->amount_edit);
    gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit),
                                          TRUE);
    gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit),
                                 commodity_scu);
#if 0
    // This doesn't yet work
    g_signal_connect_swapped (gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(td->amount_edit)), "changed",
                              G_CALLBACK(gnc_ab_trans_dialog_verify_values), td);
#endif

    /* Check for what kind of transaction this should be, and change the
     * labels accordingly */
    switch (trans_type)
    {
    case SINGLE_TRANSFER:
    case SINGLE_INTERNAL_TRANSFER:
        /* all labels are already set */
        break;
    case SINGLE_DEBITNOTE:
        gtk_label_set_text(GTK_LABEL (heading_label),
                           /* Translators: Strings from this file are
                             * needed only in countries that have one of
                             * aqbanking's Online Banking techniques
                             * available. This is 'OFX DirectConnect'
                             * (U.S. and others), 'HBCI' (in Germany),
                             * or 'YellowNet' (Switzerland). If none of
                             * these techniques are available in your
                             * country, you may safely ignore strings
                             * from the import-export/hbci
                             * subdirectory. */
                           _("Enter an Online Direct Debit Note"));

        gtk_label_set_text(GTK_LABEL(recp_name_heading),
                           _("Debited Account Owner"));
        gtk_label_set_text(GTK_LABEL(recp_account_heading),
                           _("Debited Account Number"));
        gtk_label_set_text(GTK_LABEL(recp_bankcode_heading),
                           _("Debited Account Bank Code"));

        gtk_label_set_text(GTK_LABEL(orig_name_heading),
                           _("Credited Account Owner"));
        gtk_label_set_text(GTK_LABEL(orig_account_heading),
                           _("Credited Account Number"));
        gtk_label_set_text(GTK_LABEL(orig_bankcode_heading),
                           _("Credited Account Bank Code"));
        break;

    default:
        g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d",
                   trans_type);
        break;
    }

    gtk_label_set_text(GTK_LABEL(orig_name_label), ab_ownername);
    gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber);
    gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname);
    gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode);

    /* Fill list for choosing a transaction template */
    td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS,
                              G_TYPE_STRING, G_TYPE_POINTER);
    g_list_foreach(templates, gnc_ab_trans_dialog_fill_templ_helper, td->template_list_store);
    gtk_tree_view_set_model(td->template_gtktreeview,
                            GTK_TREE_MODEL(td->template_list_store));
    td->templ_changed = FALSE;
    /* Keep a reference to the store */

    /* Show this list */
    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(
                 "Template Name", renderer, "text", TEMPLATE_NAME, NULL);
    gtk_tree_view_append_column(td->template_gtktreeview, column);

    /* Connect the Signals */
    gtk_builder_connect_signals_full(builder, gnc_builder_connect_full_func, td);

    g_object_unref(G_OBJECT(builder));

    /* Disabled OK button until suitable values are filled */
    gnc_ab_trans_dialog_verify_values(td);

    return td;
}
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 571 of file dialog-ab-trans.c.

{
    gint result;
    AB_JOB *job;
    const AB_TRANSACTION_LIMITS *joblimits;
    guint8 max_purpose_lines;
    gboolean values_ok;
    gchar *purpose;
    gchar *othername;

    /* Check whether the account supports this job */
    job = gnc_ab_trans_dialog_get_available_empty_job(td->ab_acc, td->trans_type);
    if (!job)
    {
        g_warning("gnc_ab_trans_dialog_run_until_ok: Oops, job not available");
        return GTK_RESPONSE_CANCEL;
    }

    /* Activate as many purpose entries as available for the job */
    joblimits = AB_JobSingleTransfer_GetFieldLimits(job);
    max_purpose_lines = joblimits ?
                        AB_TransactionLimits_GetMaxLinesPurpose(joblimits) : 2;
    gtk_widget_set_sensitive(td->purpose_cont_entry, max_purpose_lines > 1);
    gtk_widget_set_sensitive(td->purpose_cont2_entry, max_purpose_lines > 2);
    gtk_widget_set_sensitive(td->purpose_cont3_entry, max_purpose_lines > 3);

    /* Show the dialog */
    gtk_widget_show(td->dialog);

    /* Now run the dialog until it gets closed by a button press */
    result = gtk_dialog_run (GTK_DIALOG (td->dialog));

    /* Was cancel pressed or dialog closed?
     *  GNC_RESPONSE_NOW == execute now
     *  GNC_RESPONSE_LATER == scheduled for later execution (unimplemented)
     *  GTK_RESPONSE_CANCEL == cancel
     *  GTK_RESPONSE_DELETE_EVENT == window destroyed */
    if (result != GNC_RESPONSE_NOW && result != GNC_RESPONSE_LATER)
    {
        gtk_widget_destroy(td->dialog);
        td->dialog = NULL;
        return result;
    }

    /* Get the transaction details - have been checked beforehand */
    td->ab_trans = gnc_ab_trans_dialog_fill_values(td);

    /* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
     * transactionCode according to some GUI selection here!! */
    /*if (td->trans_type == SINGLE_DEBITNOTE)
    AB_TRANSACTION_setTextKey (td->hbci_trans, 05); */


    /* Hide the dialog */
    if (td->dialog)
        gtk_widget_hide(td->dialog);

    return result;
}
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.

{
    if (!t) return;
    g_free(t->name);
    g_free(t->name_key);
    g_free(t->recp_name);
    g_free(t->recp_account);
    g_free(t->recp_bankcode);
    g_free(t->purpose);
    g_free(t->purpose_cont);
    g_free(t);
}
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.

{
    g_return_val_if_fail(t, gnc_numeric_zero());
    return t->amount;
}
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.

{
    g_return_val_if_fail(t, NULL);
    return t->name;
}
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.

{
    g_return_val_if_fail(t, NULL);
    return t->purpose;
}
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.

{
    g_return_val_if_fail(t, NULL);
    return t->purpose_cont;
}
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.

{
    g_return_val_if_fail(t, NULL);
    return t->recp_account;
}
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.

{
    g_return_val_if_fail(t, NULL);
    return t->recp_bankcode;
}
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.

{
    g_return_val_if_fail(t, NULL);
    return t->recp_name;
}
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.

{
    GList *iter;
    for (iter = l; iter; iter = iter->next)
        gnc_ab_trans_templ_free((GncABTransTempl*) iter->data);
    g_list_free(l);
}
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 kvp_frame.

Parameters:
vGList of kvp_values
Returns:
A GList of newly allocated GncABTransTempls

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

{
    GList *res = NULL;
    GList *iter;

    for (iter = v; iter; iter = iter->next)
    {
        kvp_frame *frame = kvp_value_get_frame((kvp_value*) iter->data);
        res = g_list_prepend(res, gnc_ab_trans_templ_new_from_kvp(frame));
    }
    res = g_list_reverse(res);

    return res;
}
GList* gnc_ab_trans_templ_list_to_kvp_list ( GList *  k)

Create a list of kvp_values, which in turn contain a kvp_frame, 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.

{
    GList *res = NULL;
    GList *iter;

    for (iter = k; iter; iter = iter->next)
    {
        GncABTransTempl *t = (GncABTransTempl*) iter->data;
        kvp_value *value = kvp_value_new_frame_nc(gnc_ab_trans_templ_to_kvp(t));
        res = g_list_prepend(res, value);
    }
    res = g_list_reverse(res);

    return res;
}
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.

{
    return gnc_ab_trans_templ_new_full(NULL, NULL, NULL, NULL,
                                       gnc_numeric_zero(), NULL, NULL);
}
GncABTransTempl* gnc_ab_trans_templ_new_from_kvp ( const kvp_frame *  k)

Create a template, taking the values from a kvp_frame.

Parameters:
kkvp_frame
Returns:
A newly allocated GncABTransTempl

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

{
    g_return_val_if_fail(k, NULL);

    return gnc_ab_trans_templ_new_full(
               kvp_value_get_string(kvp_frame_get_slot(k, TT_NAME)),
               kvp_value_get_string(kvp_frame_get_slot(k, TT_RNAME)),
               kvp_value_get_string(kvp_frame_get_slot(k, TT_RACC)),
               kvp_value_get_string(kvp_frame_get_slot(k, TT_RBCODE)),
               kvp_value_get_numeric(kvp_frame_get_slot(k, TT_AMOUNT)),
               kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOS)),
               kvp_value_get_string(kvp_frame_get_slot(k, TT_PURPOSCT)));
}
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.

{
    g_return_if_fail(t);
    t->amount = amount;
}
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.

{
    g_return_if_fail(t);
    g_free(t->name);
    t->name = g_strdup(name);
}
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.

{
    g_return_if_fail(t);
    g_free(t->purpose);
    t->purpose = g_strdup(purpose);
}
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.

{
    g_return_if_fail(t);
    g_free(t->purpose_cont);
    t->purpose_cont = g_strdup(purpose_cont);
}
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.

{
    g_return_if_fail(t);
    g_free(t->recp_account);
    t->recp_account = g_strdup(recp_account);
}
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.

{
    g_return_if_fail(t);
    g_free(t->recp_bankcode);
    t->recp_bankcode = g_strdup(recp_bankcode);
}
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.

{
    g_return_if_fail(t);
    g_free(t->recp_name);
    t->recp_name = g_strdup(recp_name);
}
kvp_frame* gnc_ab_trans_templ_to_kvp ( const GncABTransTempl t)

Create a kvp_frame a given template.

Parameters:
tTemplate
Returns:
A newly allocated kvp_frame

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

{
    kvp_frame *k;

    g_return_val_if_fail(t, NULL);

    k = kvp_frame_new();
    kvp_frame_set_slot(k, TT_NAME, kvp_value_new_string(t->name));
    kvp_frame_set_slot(k, TT_RNAME, kvp_value_new_string(t->recp_name));
    kvp_frame_set_slot(k, TT_RACC, kvp_value_new_string(t->recp_account));
    kvp_frame_set_slot(k, TT_RBCODE, kvp_value_new_string(t->recp_bankcode));
    kvp_frame_set_slot(k, TT_AMOUNT, kvp_value_new_gnc_numeric(t->amount));
    kvp_frame_set_slot(k, TT_PURPOS, kvp_value_new_string(t->purpose));
    kvp_frame_set_slot(k, TT_PURPOSCT, kvp_value_new_string(t->purpose_cont));

    return k;
}
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 468 of file gnc-ab-utils.c.

{
    QofBook *book;
    Transaction *gnc_trans;
    const gchar *fitid;
    const GWEN_TIME *valuta_date;
    time_t current_time;
    const char *custref;
    gchar *description;
    Split *split;
    gchar *memo;

    g_return_val_if_fail(ab_trans && gnc_acc, NULL);

    /* Create new GnuCash transaction for the given AqBanking one */
    book = gnc_account_get_book(gnc_acc);
    gnc_trans = xaccMallocTransaction(book);
    xaccTransBeginEdit(gnc_trans);

    /* Date / Time */
    valuta_date = AB_Transaction_GetValutaDate(ab_trans);
    if (!valuta_date)
    {
        const GWEN_TIME *normal_date = AB_Transaction_GetDate(ab_trans);
        if (normal_date)
            valuta_date = normal_date;
    }
    if (valuta_date)
        xaccTransSetDatePostedSecs(gnc_trans, GWEN_Time_toTime_t(valuta_date));
    else
        g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");

    current_time = time(NULL);
    xaccTransSetDateEnteredSecs(gnc_trans, mktime(localtime(&current_time)));

    /* Currency.  We take simply the default currency of the gnucash account */
    xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));

    /* Number.  We use the "customer reference", if there is one. */
    custref = AB_Transaction_GetCustomerReference(ab_trans);
    if (custref && *custref
            && g_ascii_strncasecmp(custref, "NONREF", 6) != 0)
        xaccTransSetNum(gnc_trans, custref);

    /* Description */
    description = gnc_ab_description_to_gnc(ab_trans);
    xaccTransSetDescription(gnc_trans, description);
    g_free(description);

    /* Notes. */
    /* xaccTransSetNotes(gnc_trans, g_notes); */
    /* But Nobody ever uses the Notes field? */

    /* Add one split */
    split = xaccMallocSplit(book);
    xaccSplitSetParent(split, gnc_trans);
    xaccSplitSetAccount(split, gnc_acc);

    /* Set OFX unique transaction ID */
    fitid = AB_Transaction_GetFiId(ab_trans);
    if (fitid && *fitid)
        gnc_import_set_split_online_id(split, fitid);

    {
        /* Amount into the split */
        const AB_VALUE *ab_value = AB_Transaction_GetValue(ab_trans);
        double d_value = ab_value ? AB_Value_GetValueAsDouble (ab_value) : 0.0;
        AB_TRANSACTION_TYPE ab_type = AB_Transaction_GetType (ab_trans);
        gnc_numeric gnc_amount;

        /*printf("Transaction with value %f has type %d\n", d_value, ab_type);*/
        /* If the value is positive, but the transaction type says the
           money is transferred away from our account (Transfer instead of
           DebitNote), we switch the value to negative. */
        if (d_value > 0.0 && ab_type == AB_Transaction_TypeTransfer)
            d_value = -d_value;

        gnc_amount = double_to_gnc_numeric(
                         d_value,
                         xaccAccountGetCommoditySCU(gnc_acc),
                         GNC_HOW_RND_ROUND_HALF_UP);
        if (!ab_value)
            g_warning("transaction_cb: Oops, value was NULL.  Using 0");
        xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
    }

    /* Memo in the Split. */
    memo = gnc_ab_memo_to_gnc(ab_trans);
    xaccSplitSetMemo(split, memo);
    g_free(memo);

    return gnc_trans;
}
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.

{
    if (value)
        return g_strdup_printf("%.2f %s",
                               AB_Value_GetValueAsDouble(value),
                               AB_Value_GetCurrency(value));
    else
        return g_strdup_printf("%.2f", 0.0);
}
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 65 of file gnc-file-aqb-import.c.

{
    gchar *default_dir;
    gchar *selected_filename = NULL;
    gint dtaus_fd = -1;
    AB_BANKING *api = NULL;
    gboolean online = FALSE;
    GncGWENGui *gui = NULL;
    AB_IMEXPORTER *importer;
    GWEN_DB_NODE *db_profiles = NULL;
    GWEN_DB_NODE *db_profile;
    AB_IMEXPORTER_CONTEXT *context = NULL;
    GWEN_IO_LAYER *io = NULL;
    GncABImExContextImport *ieci = NULL;
    AB_JOB_LIST2 *job_list = NULL;
    AB_JOB_LIST2_ITERATOR *jit;
    AB_JOB *job;
    AB_JOB_STATUS job_status;
    gboolean successful = TRUE;
    int num_jobs = 0;
    int num_jobs_failed = 0;
    int max_failures = 5;
    GString *errstr = NULL;

    /* Select a file */
    default_dir = gnc_get_default_directory(GCONF_SECTION_AQBANKING);
    selected_filename = gnc_file_dialog(_("Select a file to import"),
                                        NULL, default_dir,
                                        GNC_FILE_DIALOG_IMPORT);
    g_free(default_dir);

    if (!selected_filename)
        goto cleanup;
    DEBUG("filename: %s", selected_filename);

    /* Remember the directory as the default */
    default_dir = g_path_get_dirname(selected_filename);
    gnc_set_default_directory(GCONF_SECTION_AQBANKING, default_dir);
    g_free(default_dir);

    dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
    if (dtaus_fd == -1)
    {
        DEBUG("Could not open file %s", selected_filename);
        goto cleanup;
    }

    /* Get the API */
    api = gnc_AB_BANKING_new();
    if (!api)
    {
        g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
        goto cleanup;
    }
    if (AB_Banking_OnlineInit(api
#ifdef AQBANKING_VERSION_4_EXACTLY
                              , 0
#endif
                             ) != 0)
    {
        g_warning("gnc_file_aqbanking_import: "
                  "Couldn't initialize AqBanking API");
        goto cleanup;
    }
    online = TRUE;

    /* Get import module */
    importer = AB_Banking_GetImExporter(api, aqbanking_importername);
    if (!importer)
    {
        g_warning("Import module %s not found", aqbanking_importername);
        gnc_error_dialog(NULL, "%s",
                         _("Import module for DTAUS import not found."));
        goto cleanup;
    }

    /* Load the import profile */
    db_profiles = AB_Banking_GetImExporterProfiles(api, aqbanking_importername);

    /* Select profile */
    db_profile = GWEN_DB_GetFirstGroup(db_profiles);
    while (db_profile)
    {
        const gchar *name;

        name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
        g_return_if_fail(name);
        if (g_ascii_strcasecmp(name, aqbanking_profilename) == 0)
            break;
        db_profile = GWEN_DB_GetNextGroup(db_profile);
    }
    if (!db_profile)
    {
        g_warning("Profile \"%s\" for importer \"%s\" not found",
                  aqbanking_profilename, aqbanking_importername);
        /* For debugging: Print those available names that have been found */
        db_profile = GWEN_DB_GetFirstGroup(db_profiles);
        while (db_profile)
        {
            const char *name = GWEN_DB_GetCharValue(db_profile, "name", 0, 0);
            g_warning("Only found profile \"%s\"\n", name ? name : "(null)");
            db_profile = GWEN_DB_GetNextGroup(db_profile);
        }
        goto cleanup;
    }

    /* Create a context to store the results */
    context = AB_ImExporterContext_new();

    /* Wrap file in buffered gwen io */
#ifdef AQBANKING_VERSION_5_PLUS
    close(dtaus_fd);
    io = GWEN_SyncIo_File_new(selected_filename, GWEN_SyncIo_File_CreationMode_OpenExisting);
    g_assert(io);
    GWEN_SyncIo_AddFlags(io, GWEN_SYNCIO_FILE_FLAGS_READ);
    {
        /* We must explicitly call "Connect" on the GWEN_SYNCIO
         * object. */
        int rv = GWEN_SyncIo_Connect(io);
        if (rv < 0)
        {
            g_warning("gnc_file_aqbanking_import: Failed to open file %s: %d", selected_filename, rv);
            goto cleanup;
        }
        g_assert(GWEN_SyncIo_GetStatus(io) == GWEN_SyncIo_Status_Connected);
    }
#else
    io = GWEN_Io_LayerFile_new(dtaus_fd, -1);
    g_assert(io);
    if (GWEN_Io_Manager_RegisterLayer(io))
    {
        g_warning("gnc_file_aqbanking_import: Failed to wrap file");
        goto cleanup;
    }
#endif
    dtaus_fd = -1;

    /* Run the import */
    if (AB_ImExporter_Import(importer, context, io, db_profile
#ifndef AQBANKING_VERSION_5_PLUS
                             , 0
#endif
                            ))
    {
        g_warning("gnc_file_aqbanking_import: Error on import");
        goto cleanup;
    }

    /* Close the file */
#ifdef AQBANKING_VERSION_5_PLUS
    GWEN_SyncIo_free(io);
#else
    GWEN_Io_Layer_free(io);
#endif
    io = NULL;

    /* Import the results */
    ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS,
                                 execute_transactions,
                                 execute_transactions ? api : NULL,
                                 NULL);

    if (execute_transactions)
    {
        if (gnc_ab_ieci_run_matcher(ieci))
        {
            AB_IMEXPORTER_CONTEXT *execution_context;

            /* Extract the list of jobs */
            job_list = gnc_ab_ieci_get_job_list(ieci);

            /* Create a context to store possible results */
            execution_context = AB_ImExporterContext_new();

            /* Get a GUI object */
            gui = gnc_GWEN_Gui_get(NULL);
            if (!gui)
            {
                g_warning("gnc_file_aqbanking_import: Couldn't initialize Gwenhywfar GUI");
                goto cleanup;
            }

            /* And execute the jobs */
            AB_Banking_ExecuteJobs(api, job_list, execution_context
#ifndef AQBANKING_VERSION_5_PLUS
                                   , 0
#endif
                                  );

            /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
             * status always describes better whether the job was actually
             * transferred to and accepted by the bank.  See also
             * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
             */

            /* So we must go through all jobs and check AB_Job_GetStatus(job)
             * to give the appropriate feedback if any of the jobs didn't
             * work. */

            jit = AB_Job_List2_First(job_list);
            if (jit)
            {

                job = AB_Job_List2Iterator_Data(jit);
                while (job)
                {
                    num_jobs += 1;
                    job_status = AB_Job_GetStatus(job);
                    if (job_status != AB_Job_StatusFinished
                            && job_status != AB_Job_StatusPending)
                    {
                        successful = FALSE;
                        num_jobs_failed += 1;

                        if (num_jobs_failed <= max_failures)
                        {
                            if (num_jobs_failed == 1)
                            {
                                errstr = g_string_new("Failed jobs:\n");
                            }
                            g_string_append_printf(errstr, _("Job %d status %d - %s: %s \n")
                                                   , num_jobs
                                                   , job_status
                                                   , AB_Job_Status2Char(job_status)
                                                   , AB_Job_GetResultText(job));
                        }
                        else
                        {
                            if (num_jobs_failed == (max_failures + 1) )
                            {
                                /* indicate that additional failures exist */
                                g_string_append(errstr, _("...\n"));
                            }
                        }
                    }
                    job = AB_Job_List2Iterator_Next(jit);
                } /* while */

                AB_Job_List2Iterator_free(jit);
            }

            if (!successful)
            {
                g_warning("%s", errstr->str);
                gnc_error_dialog(NULL,
                                 _("An error occurred while executing jobs: %d of %d failed. "
                                   "Please check the log window or gnucash.trace for the exact "
                                   "error message.\n\n%s")
                                 , num_jobs_failed, num_jobs, errstr->str);
            }
            else
            {
                if (num_jobs == 0)
                {
                    gnc_info_dialog(NULL,
                                    _("No jobs to be send.")
                                   );
                }
                else
                {
                    gnc_info_dialog(NULL, ngettext
                                    ("The job was executed successfully, but as a precaution "
                                     "please check the log window for potential errors.",
                                     "All %d jobs were executed successfully, but as a precaution "
                                     "please check the log window for potential errors.",
                                     num_jobs), num_jobs);
                }
            }
            AB_ImExporterContext_free(execution_context);
        }
    }

cleanup:
    if (io)
    {
#ifdef AQBANKING_VERSION_5_PLUS
        GWEN_SyncIo_free(io);
#else
        GWEN_Io_Layer_free(io);
#endif
    }

    if (job_list)
        AB_Job_List2_FreeAll(job_list);
    if (ieci)
        g_free(ieci);
    if (context)
        AB_ImExporterContext_free(context);
    if (db_profiles)
        GWEN_DB_Group_free(db_profiles);
    if (gui)
        gnc_GWEN_Gui_release(gui);
    if (online)
#ifdef AQBANKING_VERSION_4_EXACTLY
        AB_Banking_OnlineFini(api, 0);
#else
        AB_Banking_OnlineFini(api);
#endif
    if (api)
        gnc_AB_BANKING_fini(api);
    if (dtaus_fd != -1)
        close(dtaus_fd);
    if (selected_filename)
        g_free(selected_filename);
    if (errstr)
        g_string_free(errstr, TRUE);

}
void gnc_GWEN_Fini ( void  )

Finalize the gwenhywfar library.

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

{
    /* Shutdown the GWEN_GUIs */
    gnc_GWEN_Gui_shutdown();
    GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
    GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Warning);
    GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);

    /* Finalize gwen library */
    GWEN_Fini();
}
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 313 of file gnc-gwen-gui.c.

{
    GncGWENGui *gui;

    ENTER("parent=%p", parent);

    if (full_gui)
    {
        if (full_gui->state == INIT || full_gui->state == RUNNING)
        {
            LEAVE("full_gui in use, state=%d", full_gui->state);
            return NULL;
        }

        gui = full_gui;
        gui->parent = parent;
        reset_dialog(gui);
        register_callbacks(gui);

        LEAVE("gui=%p", gui);
        return gui;
    }

    gui = g_new0(GncGWENGui, 1);
    gui->parent = parent;
    setup_dialog(gui);
    register_callbacks(gui);

    full_gui = gui;

    LEAVE("new gui=%p", gui);
    return gui;
}
gboolean gnc_GWEN_Gui_get_close_flag ( void  )

Get "Close when finished" flag

Returns:
gboolean close_when_finished

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

{
    return gnc_gconf_get_bool(GCONF_SECTION_AQBANKING, KEY_CLOSE_ON_FINISH, NULL);
}
void gnc_GWEN_Gui_hide_dialog ( void  )

Hides Online Banking Connection Window (Close log window)

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

{
    GncGWENGui *gui = full_gui;

    if (gui)
    {
        hide_dialog(gui);
    }
}
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 291 of file gnc-gwen-gui.c.

{
    if (!log_gwen_gui)
    {
        log_gwen_gui =
#ifdef USING_GWENHYWFAR_GTK2_GUI
            Gtk2_Gui_new()
#else
        GWEN_Gui_new()
#endif
            ;

        /* Always use our own logging */
        GWEN_Gui_SetLogHookFn(log_gwen_gui, loghook_cb);

        /* Keep a reference so that the GWEN_GUI survives a GUI switch */
        GWEN_Gui_Attach(log_gwen_gui);
    }
    GWEN_Gui_SetGui(log_gwen_gui);
}
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 348 of file gnc-gwen-gui.c.

{
    g_return_if_fail(gui && gui == full_gui);

    /* Currently a no-op */
    ENTER("gui=%p", gui);
    LEAVE(" ");
}
void gnc_GWEN_Gui_set_close_flag ( gboolean  close_when_finished)

Set "Close when finished" flag

Parameters:
gbooleanclose_when_finished

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

{
    gnc_gconf_set_bool(
        GCONF_SECTION_AQBANKING, KEY_CLOSE_ON_FINISH,
        close_when_finished,
        NULL);

    if (full_gui)
    {
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(full_gui->close_checkbutton))
                != close_when_finished)
        {
            gtk_toggle_button_set_active(
                GTK_TOGGLE_BUTTON(full_gui->close_checkbutton),
                close_when_finished);
        }
    }
}
gboolean gnc_GWEN_Gui_show_dialog ( void  )

Unhides Online Banking Connection Window (Make log visible)

Returns:
gboolean window is visible

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

{
    GncGWENGui *gui = full_gui;

    if (!gui)
    {
        gnc_GWEN_Gui_get(NULL);
    }

    if (gui)
    {
        if (gui->state == HIDDEN)
        {
            gui->state = FINISHED;
        }
        gtk_toggle_button_set_active(
            GTK_TOGGLE_BUTTON(gui->close_checkbutton),
            gnc_gconf_get_bool(GCONF_SECTION_AQBANKING, KEY_CLOSE_ON_FINISH, NULL));

        show_dialog(gui, FALSE);

        return TRUE;
    }

    return FALSE;
}
void gnc_GWEN_Gui_shutdown ( void  )

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

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

{
    GncGWENGui *gui = full_gui;

    ENTER(" ");

    if (log_gwen_gui)
    {
        GWEN_Gui_free(log_gwen_gui);
        log_gwen_gui = NULL;
    }
    GWEN_Gui_SetGui(NULL);

    if (!gui)
        return;

    gui->parent = NULL;
    reset_dialog(gui);
    if (gui->passwords)
        g_hash_table_destroy(gui->passwords);
    if (gui->showbox_hash)
        g_hash_table_destroy(gui->showbox_hash);
    if (gui->permanently_accepted_certs)
        GWEN_DB_Group_free(gui->permanently_accepted_certs);
    if (gui->accepted_certs)
        g_hash_table_destroy(gui->accepted_certs);
    gtk_widget_destroy(gui->dialog);
    g_free(gui);

    full_gui = NULL;

    LEAVE(" ");
}
void gnc_GWEN_Init ( void  )

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

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

{
    gint i;
    gchar* gwen_logging = g_strdup(g_getenv("GWEN_LOGLEVEL"));
    gchar* aqb_logging = g_strdup(g_getenv("AQBANKING_LOGLEVEL"));

    /* Initialize gwen library */
    GWEN_Init();

    /* Initialize gwen logging */
    if (gnc_gconf_get_bool(GCONF_SECTION_AQBANKING, KEY_VERBOSE_DEBUG, NULL))
    {
        if (!gwen_logging)
        {
            GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Info);
            GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Info);
        }
        if (!aqb_logging)
            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Debug);
    }
    else
    {
        if (!gwen_logging)
        {
            GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Error);
            GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Error);
        }
        if (!aqb_logging)
            GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Warning);
    }
    g_free(gwen_logging);
    g_free(aqb_logging);
    gnc_GWEN_Gui_log_init();
}
void gnc_plugin_aqbanking_create_plugin ( void  )

Create a new GncPluginAqBanking object and register it.

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

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 194 of file gnc-plugin-aqbanking.c.

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

Set MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW

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

{
    GtkAction *action;

    action = gnc_main_window_find_action(gnc_main_window,
                                         MENU_TOGGLE_ACTION_AB_VIEW_LOGWINDOW);
    if (action)
    {
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),
                                     logwindow_visible);
    }
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines