Skip to content

Commit

Permalink
Replace G_MODULE_EXPORT with static.
Browse files Browse the repository at this point in the history
No need to expose those functions outside their compilation units.
  • Loading branch information
jralls committed Oct 30, 2022
1 parent 5a04554 commit 79723b0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 330 deletions.
58 changes: 23 additions & 35 deletions gnucash/import-export/aqb/dialog-ab-select-imexporter.c
Expand Up @@ -48,41 +48,28 @@ struct _GncABSelectImExDlg
};

// Expose the selection handlers to GtkBuilder.
G_MODULE_EXPORT gboolean imexporter_changed(GtkTreeSelection* sel,
gpointer data);
G_MODULE_EXPORT gboolean profile_changed(GtkTreeSelection* sel, gpointer data);
static gboolean imexporter_changed(GtkTreeSelection* sel,
gpointer data);
static gboolean profile_changed(GtkTreeSelection* sel, gpointer data);

static gboolean
clear_model_row (GtkTreeModel* model, GtkTreePath* path,
GtkTreeIter* iter, gpointer data)
enum
{
char *name, *desc;
g_return_val_if_fail (model && iter, TRUE);
gtk_tree_model_get (model, iter, 0, &name, 1, &desc, -1);
g_free (name);
g_free (desc);
return FALSE;
}

static void
clear_tree_model (GtkTreeModel* model)
{
gtk_tree_model_foreach (model, clear_model_row, NULL);
gtk_list_store_clear (GTK_LIST_STORE (model));
}
NAME_COL,
PROF_COL
};

static void
populate_tree_model (GtkTreeModel* model, GList* entries)
populate_list_store (GtkListStore* model, GList* entries)
{
clear_tree_model (model);
gtk_list_store_clear (model);
for (GList* node = entries; node; node = g_list_next (node))
{
AB_Node_Pair *pair = (AB_Node_Pair*)(node->data);
GtkTreeIter iter;
gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
&iter, -1,
0, pair->name,
1, pair->descr,
NAME_COL, pair->name,
PROF_COL, pair->descr,
-1);
g_slice_free1 (sizeof(AB_Node_Pair), pair);
}
Expand Down Expand Up @@ -128,7 +115,7 @@ gnc_ab_select_imex_dlg_new (GtkWidget* parent, AB_BANKING* abi)

imex_select = GTK_TREE_SELECTION (gtk_builder_get_object (builder, "imex-selection"));
prof_select = GTK_TREE_SELECTION (gtk_builder_get_object (builder, "prof-selection"));
populate_tree_model (GTK_TREE_MODEL (imexd->imexporter_list),
populate_list_store (imexd->imexporter_list,
imexporters);

g_signal_connect (imex_select, "changed", G_CALLBACK(imexporter_changed),
Expand All @@ -149,10 +136,10 @@ gnc_ab_select_imex_dlg_destroy (GncABSelectImExDlg* imexd)
{

if (imexd->imexporter_list)
clear_tree_model (GTK_TREE_MODEL (imexd->imexporter_list));
gtk_list_store_clear (imexd->imexporter_list);

if (imexd->profile_list)
clear_tree_model (GTK_TREE_MODEL (imexd->profile_list));
gtk_list_store_clear (imexd->profile_list);

if (imexd->dialog)
gtk_widget_destroy (imexd->dialog);
Expand All @@ -174,16 +161,16 @@ imexporter_changed(GtkTreeSelection* sel, gpointer data)
char* name = NULL;
GList* profiles = NULL;

gtk_tree_model_get (model, &iter, 0, &name, -1);
gtk_tree_model_get (model, &iter, NAME_COL, &name, -1);
if (name && *name)
{
profiles = gnc_ab_imexporter_profile_list (imexd->abi, name);
g_free (name);
}
clear_tree_model (GTK_TREE_MODEL (imexd->profile_list));
profiles = gnc_ab_imexporter_profile_list (imexd->abi, name);

g_free (name);
gtk_list_store_clear (imexd->profile_list);

if (profiles)
{
populate_tree_model (GTK_TREE_MODEL (imexd->profile_list), profiles);
populate_list_store (imexd->profile_list, profiles);
}
else
{
Expand All @@ -197,6 +184,7 @@ imexporter_changed(GtkTreeSelection* sel, gpointer data)
GtkTreeSelection* profile_sel =
gtk_tree_view_get_selection (GTK_TREE_VIEW (imexd->select_profile));
gtk_tree_selection_select_path (profile_sel, path); //should call profile_changed
gtk_tree_path_free (path);
}
return FALSE;
}
Expand Down Expand Up @@ -238,7 +226,7 @@ tree_view_get_name (GtkTreeView *tv)
if (sel && gtk_tree_selection_get_selected (sel, &model, &iter))
{
char* name;
gtk_tree_model_get(model, &iter, 0, &name, -1);
gtk_tree_model_get(model, &iter, NAME_COL, &name, -1);
return name;
}

Expand Down
18 changes: 9 additions & 9 deletions gnucash/import-export/aqb/dialog-ab-trans.c
Expand Up @@ -64,26 +64,26 @@ static void gnc_ab_trans_dialog_check_iban(const GncABTransDialog *td,
const AB_TRANSACTION *trans);

/* Callbacks - connected with GtkBuilder */
G_MODULE_EXPORT void gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_moveup_templ_cb(GtkButton *button, gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_movedown_templ_cb(GtkButton *button, gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_sort_templ_cb(GtkButton *button, gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_ibanentry_filter_cb (GtkEditable *editable,
static void gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data);
static void gnc_ab_trans_dialog_moveup_templ_cb(GtkButton *button, gpointer user_data);
static void gnc_ab_trans_dialog_movedown_templ_cb(GtkButton *button, gpointer user_data);
static void gnc_ab_trans_dialog_sort_templ_cb(GtkButton *button, gpointer user_data);
static void gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data);
static void gnc_ab_trans_dialog_ibanentry_filter_cb (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_bicentry_filter_cb (GtkEditable *editable,
static void gnc_ab_trans_dialog_bicentry_filter_cb (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
static void gnc_ab_trans_dialog_templ_list_row_activated_cb(GtkTreeView *view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data);
G_MODULE_EXPORT void gnc_ab_trans_dialog_verify_values(GncABTransDialog *td);
static void gnc_ab_trans_dialog_verify_values(GncABTransDialog *td);


enum
Expand Down
179 changes: 1 addition & 178 deletions gnucash/import-export/aqb/gnc-file-aqb-import.c
Expand Up @@ -22,7 +22,7 @@
/**
* @internal
* @file gnc-file-aqb-import.c
* @brief DTAUS import module code
* @brief File import module code
* @author Copyright (C) 2002 Benoit Grégoire <bock@step.polymtl.ca>
* @author Copyright (C) 2003 Jan-Pascal van Best <janpascal@vanbest.org>
* @author Copyright (C) 2006 Florian Steinel
Expand Down Expand Up @@ -103,183 +103,6 @@ named_import_get_context (GtkWindow *parent, AB_BANKING *api,
return context;
}

static void
report_failure (GtkWindow* parent, int num_jobs,
int num_jobs_failed, GString* errstr)
{
g_warning("%s", errstr->str);
gnc_error_dialog(parent,
_("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);
}

static void
report_no_jobs (GtkWindow *parent)
{
gnc_info_dialog(parent,
_("No jobs to be sent.")
);
}

static void
report_success (GtkWindow *parent, int num_jobs)
{
gnc_info_dialog(parent, 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);
}

static gboolean
check_job_status (GNC_AB_JOB_LIST2 *job_list, AB_BANKING *api, int *num_jobs,
int *num_jobs_failed, GString **errstr)
{
static const int max_failures = 5;
gboolean successful = TRUE;
GNC_AB_JOB_LIST2_ITERATOR *jit;
jit = AB_Transaction_List2_First(job_list);
AB_Transaction_List2_freeAll(job_list);
if (jit)
{
for (GNC_AB_JOB *job = AB_Transaction_List2Iterator_Data(jit);
job != NULL;
job = AB_Transaction_List2Iterator_Next(jit))
{
GNC_AB_JOB_STATUS job_status;
*num_jobs += 1;
job_status = AB_Transaction_GetStatus(job);
if (job_status != AB_Transaction_StatusAccepted &&
job_status != AB_Transaction_StatusPending)
{
successful = FALSE;
*num_jobs_failed += 1;

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

} /* while */
AB_Transaction_List2Iterator_free(jit);
}
return successful;
}

static void
do_execute_transactions (GtkWindow *parent, AB_BANKING *api,
GncABImExContextImport *ieci)
{
GString *errstr = NULL;
if (!gnc_ab_ieci_run_matcher(ieci))
{
return;
}
else
{
int num_jobs = 0;
int num_jobs_failed = 0;
/* Extract the list of jobs */
GNC_AB_JOB_LIST2 *job_list = gnc_ab_ieci_get_job_list(ieci);
/* Create a context to store possible results */
AB_IMEXPORTER_CONTEXT *execution_context =
AB_ImExporterContext_new();
/* Execute the jobs */
AB_Banking_SendCommands(api, job_list, execution_context);
AB_ImExporterContext_free(execution_context);

/* 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
* https://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.
*/
if (check_job_status (job_list, api, &num_jobs,
&num_jobs_failed, &errstr))
{
if (num_jobs == 0)
report_no_jobs (parent);
else
report_success (parent, num_jobs);
}
else
{
report_failure (parent, num_jobs, num_jobs_failed, errstr);
}

if (errstr)
g_string_free(errstr, TRUE);

}
}

void
gnc_file_aqbanking_import(GtkWindow *parent,
const gchar *aqbanking_importername,
const gchar *aqbanking_profilename,
gboolean execute_transactions)
{
gint dtaus_fd = -1;
AB_BANKING *api = NULL;
AB_IMEXPORTER_CONTEXT *context = NULL;
GncABImExContextImport *ieci = NULL;

/* Get the API */
api = gnc_AB_BANKING_new();
if (!api)
{
g_warning("gnc_file_aqbanking_import: Couldn't get AqBanking API");
return;
}

context = named_import_get_context (parent, api, aqbanking_importername,
aqbanking_profilename);
if (!context)
{
gnc_AB_BANKING_fini(api);
return;
}

/* Before importing the results, if this is a new book, let user specify
* book options, since they affect how transactions are created */
if (gnc_is_new_book())
gnc_new_book_option_display (GTK_WIDGET (parent));

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

if (execute_transactions)
do_execute_transactions (parent, api, ieci);

g_free(ieci);
AB_ImExporterContext_free(context);
gnc_AB_BANKING_fini(api);
}

void
gnc_file_aqbanking_import_dialog (GtkWindow *parent)
{
Expand Down
29 changes: 1 addition & 28 deletions gnucash/import-export/aqb/gnc-file-aqb-import.h
Expand Up @@ -25,9 +25,7 @@
* @addtogroup AqBanking
* @{
* @file aqbanking/gnc-file-aqb-import.h
* @brief DTAUS import module interface
* @author Copyright (C) 2002 Benoit Grégoire <bock@step.polymtl.ca>
* @author Copyright (C) 2008 Andreas Koehler <andi5.py@gmx.net>
* @brief File import module interface
* @author Copyright (C) 2022 John Ralls <jralls@ceridwen.us>
*/

Expand All @@ -38,31 +36,6 @@

G_BEGIN_DECLS

/**
* 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.
*
* @param aqbanking_importername The aqbanking importer module that should be
* used. Possible values: "dtaus", "csv", "swift", or more.
*
* @param aqbanking_formatname In 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.
*
* @param exec_as_aqbanking_jobs If TRUE, additionally queue the imported
* transactions as online jobs over aqbanking/HBCI. If FALSE, just import the
* transactions and that's it.
*/
void gnc_file_aqbanking_import (GtkWindow *parent,
const gchar *aqbanking_importername,
const gchar *aqbanking_formatname,
gboolean exec_as_aqbanking_jobs);

/**
* Import files via AQBanking's Import Dialog. This permits importing
* any file format that Aqbanking supports.
Expand Down
4 changes: 0 additions & 4 deletions gnucash/import-export/aqb/gnc-plugin-aqbanking-ui.xml
Expand Up @@ -3,10 +3,6 @@
<menu name="File" action="FileAction">
<menu name="FileImport" action="FileImportAction">
<placeholder name="FileImportPlaceholder">
<menuitem name="FileMt940Import" action="Mt940ImportAction"/>
<menuitem name="FileMt942Import" action="Mt942ImportAction"/>
<menuitem name="FileDtausImport" action="DtausImportAction"/>
<menuitem name="FileDtausImportsend" action="DtausImportSendAction"/>
<menuitem name="FileAQBImport" action="AQBankingImportAction"/>
</placeholder>
</menu>
Expand Down

0 comments on commit 79723b0

Please sign in to comment.