Merge branch 'import-cpp' into stable #1706

This commit is contained in:
Christopher Lam
2023-07-15 10:03:36 +08:00
19 changed files with 143 additions and 109 deletions

View File

@@ -14,16 +14,16 @@ add_subdirectory(qif-imp)
set (generic_import_SOURCES
import-account-matcher.c
import-commodity-matcher.c
import-account-matcher.cpp
import-commodity-matcher.cpp
import-backend.cpp
import-format-dialog.c
import-match-picker.c
import-parse.c
import-utilities.c
import-settings.c
import-main-matcher.c
import-pending-matches.c
import-format-dialog.cpp
import-match-picker.cpp
import-parse.cpp
import-utilities.cpp
import-settings.cpp
import-main-matcher.cpp
import-pending-matches.cpp
)
# Add dependency on config.h

View File

@@ -368,10 +368,9 @@ Account * gnc_import_select_account(GtkWidget *parent,
if (account_online_id_value)
{
AccountOnlineMatch match = {NULL, 0, account_online_id_value};
retval =
gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
test_acct_online_id_match,
(void*)&match);
retval = static_cast<Account*>(gnc_account_foreach_descendant_until (gnc_get_current_root_account (),
test_acct_online_id_match,
(void*)&match));
if (!retval && match.count == 1 &&
new_account_default_type == ACCT_TYPE_NONE)
retval = match.partial_match;

View File

@@ -68,12 +68,12 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip,
for (GList *n = namespace_list; !retval && n; n = g_list_next (n))
{
const char *ns = n->data;
auto ns = static_cast<const char*>(n->data);
DEBUG("Looking at namespace %s", ns);
GList *comm_list = gnc_commodity_table_get_commodities (commodity_table, ns);
for (GList *m = comm_list; !retval && m; m = g_list_next (m))
{
gnc_commodity *com = m->data;
auto com = static_cast<gnc_commodity*>(m->data);
DEBUG("Looking at commodity %s", gnc_commodity_get_fullname (com));
if (!g_strcmp0 (gnc_commodity_get_cusip (com), cusip))
{

View File

@@ -25,6 +25,10 @@
#ifndef IMPORT_COMMODITY_MATCHER_H
#define IMPORT_COMMODITY_MATCHER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "gnc-commodity.h"
/**
@@ -63,5 +67,10 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip,
const char * default_fullname,
const char * default_mnemonic);
#ifdef __cplusplus
}
#endif
#endif
/**@}*/

View File

@@ -38,7 +38,7 @@
static void
option_changed_cb (GtkWidget *widget, gpointer index_p)
{
gint *my_index = index_p;
auto my_index = static_cast<gint*>(index_p);
*my_index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
}
@@ -139,7 +139,7 @@ gnc_import_choose_fmt(const char* msg, GncImportFormat fmts, gpointer data)
GtkWidget *dialog;
GtkWidget *widget;
g_return_val_if_fail(fmts, FALSE);
g_return_val_if_fail (fmts, GNCIF_NONE);
/* if there is only one format available, just return it */
if (!(fmts & (fmts - 1)))

View File

@@ -48,7 +48,6 @@
#include "gnc-engine.h"
#include "gnc-gtk-utils.h"
#include "import-settings.h"
#include "import-match-picker.h"
#include "import-backend.h"
#include "import-account-matcher.h"
#include "import-pending-matches.h"
@@ -131,11 +130,13 @@ static QofLogModule log_module = G_MOD_IMPORT_MATCHER;
static const gpointer one = GINT_TO_POINTER (1);
extern "C" {
void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info);
void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data);
bool on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data);
void on_matcher_help_clicked (GtkButton *button, gpointer user_data);
void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data);
}
static void gnc_gen_trans_list_create_matches (GNCImportMainMatcher *gui);
@@ -171,8 +172,9 @@ update_all_balances (GNCImportMainMatcher *info)
{
for (GSList* iter = info->edited_accounts; iter; iter=iter->next)
{
gnc_account_set_defer_bal_computation (iter->data,false);
xaccAccountRecomputeBalance (iter->data);
auto acct = static_cast<Account*>(iter->data);
gnc_account_set_defer_bal_computation (acct, false);
xaccAccountRecomputeBalance (acct);
}
g_slist_free (info->edited_accounts);
info->edited_accounts = NULL;
@@ -307,7 +309,7 @@ static const GncGUID*
get_top_trans_match_id (GList* match_list)
{
if (!match_list || !match_list->data) return NULL;
GNCImportMatchInfo *match_info = match_list->data;
auto match_info = static_cast<GNCImportMatchInfo *>(match_list->data);
Transaction *trans = match_info->trans;
return xaccTransGetGUID (trans);
}
@@ -317,7 +319,7 @@ static gint
get_top_trans_match_score (GList* match_list)
{
if (!match_list || !match_list->data) return 0;
GNCImportMatchInfo *match_info = match_list->data;
auto match_info = static_cast<GNCImportMatchInfo *>(match_list->data);
return match_info->probability;
}
@@ -388,7 +390,7 @@ static void
remove_top_matches (GList* conflicts)
{
for (GList* iter = conflicts; iter && iter->data; iter=iter->next)
gnc_import_TransInfo_remove_top_match (iter->data);
gnc_import_TransInfo_remove_top_match (static_cast<GNCImportTransInfo*>(iter->data));
}
static void
@@ -461,9 +463,9 @@ load_hash_tables (GNCImportMainMatcher *info)
}
for (GList *m = accounts_list; m; m = m->next)
{
for (GList *n = xaccAccountGetSplitList (m->data); n; n = n->next)
for (GList *n = xaccAccountGetSplitList (static_cast<Account*>(m->data)); n; n = n->next)
{
const Split *s = n->data;
auto s = static_cast<const Split*>(n->data);
const Transaction *t = xaccSplitGetParent (s);
const gchar *key = xaccTransGetDescription (t);
@@ -492,10 +494,10 @@ gnc_gen_trans_list_show_all (GNCImportMainMatcher *info)
GSList *temp_trans_list = info->temp_trans_list;
if (!temp_trans_list)
{
gnc_info_dialog (GTK_WINDOW (info->main_widget), _("No new transactions were found in this import."));
gnc_info_dialog (GTK_WINDOW (info->main_widget), "%s", _("No new transactions were found in this import."));
return;
}
GNCImportTransInfo *trans_info = temp_trans_list->data;
auto trans_info = static_cast<GNCImportTransInfo *>(temp_trans_list->data);
Split *first_split = gnc_import_TransInfo_get_fsplit (trans_info);
Account *account = xaccSplitGetAccount(first_split);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (info->append_text),
@@ -550,7 +552,7 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
Transaction *trans = xaccSplitGetParent (first_split);
for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
acc_begin_edit (&accounts_modified, xaccSplitGetAccount (n->data));
acc_begin_edit (&accounts_modified, xaccSplitGetAccount (static_cast<Split*>(n->data)));
// Allow the backend to know if the Append checkbox is ticked or unticked
// by propagating info->append_text to every trans_info->append_text
@@ -592,14 +594,14 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
void
on_matcher_cancel_clicked (GtkButton *button, gpointer user_data)
{
GNCImportMainMatcher *info = user_data;
auto info = static_cast<GNCImportMainMatcher *>(user_data);
gnc_gen_trans_list_delete (info);
}
bool
on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
{
GNCImportMainMatcher *info = data;
auto info = static_cast<GNCImportMainMatcher *>(data);
gnc_gen_trans_list_delete (info);
return false;
}
@@ -607,7 +609,7 @@ on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
void
on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
{
GtkWidget *help_dialog = user_data;
auto help_dialog = static_cast<GtkWidget *>(user_data);
gtk_widget_destroy (help_dialog);
}
@@ -615,7 +617,7 @@ on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
void
on_matcher_help_clicked (GtkButton *button, gpointer user_data)
{
GNCImportMainMatcher *info = user_data;
auto info = static_cast<GNCImportMainMatcher*>(user_data);
GtkBuilder *builder = gtk_builder_new ();
gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2");
@@ -837,15 +839,16 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
GList *refs = NULL;
for (GList *l = selected_rows; l; l = l->next)
{
gchar *path_str = gtk_tree_path_to_string (l->data);
GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, l->data);
auto path = static_cast<GtkTreePath*>(l->data);
gchar *path_str = gtk_tree_path_to_string (path);
GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, path);
DEBUG("passing first = %s", first ? "true" : "false");
DEBUG("passing is_selection = %s", is_selection ? "true" : "false");
DEBUG("passing path = %s", path_str);
g_free (path_str);
refs = g_list_prepend (refs, ref);
gnc_gen_trans_assign_transfer_account (treeview,
&first, is_selection, l->data,
&first, is_selection, path,
&assigned_account, info);
gchar *fullname = gnc_account_get_full_name (assigned_account);
DEBUG("returned value of account = %s", fullname);
@@ -859,10 +862,11 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
// now reselect the transaction rows. This is very slow if there are lots of transactions.
for (GList *l = refs; l; l = l->next)
{
GtkTreePath *path = gtk_tree_row_reference_get_path (l->data);
auto ref = static_cast<GtkTreeRowReference*>(l->data);
GtkTreePath *path = gtk_tree_row_reference_get_path (ref);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
gtk_tree_row_reference_free (l->data);
gtk_tree_row_reference_free (ref);
}
g_list_free (refs);
@@ -888,7 +892,7 @@ static RowInfo * row_get_info (gpointer row, GNCImportMainMatcher *info)
{
GtkTreeModel *model = gtk_tree_view_get_model (info->view);
RowInfo *retval = g_new (RowInfo, 1);
gtk_tree_model_get_iter (model, &retval->iter, row);
gtk_tree_model_get_iter (model, &retval->iter, static_cast<GtkTreePath*>(row));
gtk_tree_model_get (model, &retval->iter,
DOWNLOADED_COL_DATA, &retval->trans_info,
DOWNLOADED_COL_DESCRIPTION_ORIGINAL, &retval->orig_desc,
@@ -908,7 +912,7 @@ enum
static void populate_list (gpointer key, gpointer value, GtkListStore *list)
{
GtkTreeIter iter;
const char *original = key;
auto original = static_cast<const char*>(key);
char *normalized = g_utf8_normalize (original, -1, G_NORMALIZE_NFC);
char *normalized_folded = normalized ? g_utf8_casefold (normalized, -1) : NULL;
gtk_list_store_append (list, &iter);
@@ -924,7 +928,7 @@ static bool
match_func (GtkEntryCompletion *completion, const char *entry_str,
GtkTreeIter *iter, gpointer user_data)
{
GtkTreeModel *model = user_data;
auto model = static_cast<GtkTreeModel*>(user_data);
gchar *existing_str = NULL;
bool ret = false;
gtk_tree_model_get (model, iter,
@@ -1084,7 +1088,7 @@ gnc_gen_trans_set_price_to_selection_cb (GtkMenuItem *menuitem,
GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info);
for (GList *n = row_info_list; n; n = g_list_next (n))
{
RowInfo *row = n->data;
auto row = static_cast<RowInfo*>(n->data);
Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info);
time64 post_date = xaccTransGetDate(trans);
Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info);
@@ -1137,12 +1141,12 @@ gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info)
char *new_desc = NULL, *new_notes = NULL, *new_memo = NULL;
GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info);
if (input_new_fields (info, row_info_list->data,
if (input_new_fields (info, static_cast<RowInfo*>(row_info_list->data),
&new_desc, &new_notes, &new_memo))
{
for (GList *n = row_info_list; n; n = g_list_next (n))
{
RowInfo *row = n->data;
auto row = static_cast<RowInfo*>(n->data);
Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info);
Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info);
if (info->can_edit_desc)
@@ -1273,8 +1277,9 @@ gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
GList* list = gtk_tree_selection_get_selected_rows (selection, &model);
for (GList *n = list; n; n = n->next)
{
if (get_action_for_path (n->data, model) != GNCImport_ADD)
gtk_tree_selection_unselect_path (selection, n->data);
auto path = static_cast<GtkTreePath*>(n->data);
if (get_action_for_path (path, model) != GNCImport_ADD)
gtk_tree_selection_unselect_path (selection, path);
}
g_list_free_full (list, (GDestroyNotify)gtk_tree_path_free);
}
@@ -1317,7 +1322,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
const char *desc = NULL, *memo = NULL, *notes = NULL;
if (row_info_list) /* should never be NULL. collect from first row. */
{
RowInfo* first_rowinfo = row_info_list->data;
auto first_rowinfo = static_cast<RowInfo*>(row_info_list->data);
Transaction *trans = gnc_import_TransInfo_get_trans (first_rowinfo->trans_info);
Split *split = gnc_import_TransInfo_get_fsplit (first_rowinfo->trans_info);
desc = xaccTransGetDescription (trans);
@@ -1334,7 +1339,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
bool can_assign_acct = true;
for (GList *n = row_info_list; n; n = g_list_next(n))
{
RowInfo *rowinfo = n->data;
auto rowinfo = static_cast<RowInfo*>(n->data);
/* Only allow assigning a destination account for unbalanced transactions */
if (can_assign_acct)
@@ -1448,7 +1453,7 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
GList* selected;
GtkTreeModel *model;
selected = gtk_tree_selection_get_selected_rows (selection, &model);
if (get_action_for_path (selected->data, model) == GNCImport_ADD)
if (get_action_for_path (static_cast<GtkTreePath*>(selected->data), model) == GNCImport_ADD)
gnc_gen_trans_view_popup_menu (treeview, event, info);
g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);
}
@@ -1893,7 +1898,7 @@ get_peer_acct_names (Split *split)
GList *names = NULL, *accounts_seen = NULL;
for (GList *n = xaccTransGetSplitList (xaccSplitGetParent (split)); n; n = n->next)
{
Account *account = xaccSplitGetAccount (n->data);
Account *account = xaccSplitGetAccount (static_cast<Split*>(n->data));
if ((n->data == split) ||
(xaccAccountGetType (account) == ACCT_TYPE_TRADING) ||
(g_list_find (accounts_seen, account)))
@@ -2277,7 +2282,7 @@ filter_existing_splits_on_account_and_date (GNCImportMainMatcher *gui)
for (GSList* txn = gui->temp_trans_list; txn != NULL;
txn = g_slist_next (txn))
{
GNCImportTransInfo* txn_info = txn->data;
auto txn_info = static_cast<GNCImportTransInfo*>(txn->data);
Account *txn_account =
xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info));
time64 txn_time =
@@ -2314,19 +2319,20 @@ create_hash_of_potential_matches (GList *candidate_splits,
for (GList* candidate = candidate_splits; candidate != NULL;
candidate = g_list_next (candidate))
{
if (gnc_import_split_has_online_id (candidate->data))
auto split = static_cast<Split*>(candidate->data);
if (gnc_import_split_has_online_id (split))
continue;
/* In this context an open transaction represents a freshly
* downloaded one. That can't possibly be a match yet */
if (xaccTransIsOpen(xaccSplitGetParent(candidate->data)))
if (xaccTransIsOpen(xaccSplitGetParent(split)))
continue;
Account *split_account = xaccSplitGetAccount (candidate->data);
Account *split_account = xaccSplitGetAccount (split);
/* g_hash_table_steal_extended would do the two calls in one shot but is
* not available until GLib 2.58.
*/
GSList *split_list = g_hash_table_lookup (account_hash, split_account);
auto split_list = static_cast<GSList*>(g_hash_table_lookup (account_hash, split_account));
g_hash_table_steal (account_hash, split_account);
split_list = g_slist_prepend (split_list, candidate->data);
split_list = g_slist_prepend (split_list, split);
g_hash_table_insert (account_hash, split_account, split_list);
}
return account_hash;
@@ -2372,11 +2378,11 @@ perform_matching (GNCImportMainMatcher *gui, GHashTable *account_hash)
for (GSList *imported_txn = gui->temp_trans_list; imported_txn !=NULL;
imported_txn = g_slist_next (imported_txn))
{
GNCImportTransInfo* txn_info = imported_txn->data;
auto txn_info = static_cast<GNCImportTransInfo*>(imported_txn->data);
Account *importaccount = xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info));
match_struct s = {txn_info, display_threshold, date_threshold, date_not_threshold, fuzzy_amount};
g_slist_foreach (g_hash_table_lookup (account_hash, importaccount),
g_slist_foreach (static_cast<GSList*>(g_hash_table_lookup (account_hash, importaccount)),
(GFunc) match_helper, &s);
// Sort the matches, select the best match, and set the action.

View File

@@ -33,15 +33,16 @@
#ifndef GNC_IMPORT_MAIN_MATCHER_H
#define GNC_IMPORT_MAIN_MATCHER_H
#include "Transaction.h"
#include "import-backend.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "Transaction.h"
#include "import-backend.h"
#include "import-match-picker.h"
#include <stdbool.h>
typedef struct _main_matcher_info GNCImportMainMatcher;
typedef void (*GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info,

View File

@@ -31,10 +31,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "import-backend.h"
#include "import-match-picker.h"
#include "import-pending-matches.h"
#include "qof.h"
#include "gnc-ui-util.h"
#include "dialog-utils.h"
@@ -196,7 +193,7 @@ match_update_match_model (GNCImportMatchPicker *matcher)
(matcher->selected_trans_info));
while (list_element != NULL)
{
match_info = list_element->data;
match_info = static_cast<GNCImportMatchInfo*>(list_element->data);
/* Skip this match if reconciled and we're not showing those */
reconciled = xaccSplitGetReconcile

View File

@@ -26,6 +26,10 @@
#ifndef GNC_GEN_MATCH_PICKER_H
#define GNC_GEN_MATCH_PICKER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "import-backend.h"
#include "import-pending-matches.h"
@@ -59,5 +63,8 @@ gnc_import_match_picker_run_and_close (GtkWidget *parent,
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -53,6 +53,10 @@ static regex_t date_ymd_regex;
static gboolean regex_compiled = FALSE;
/* Set and clear flags in bit-flags */
#define import_set_flag(i,f) (i = static_cast<GncImportFormat>(static_cast<int>(i) | static_cast<int>(f)))
#define import_clear_flag(i,f) (i = static_cast<GncImportFormat>(static_cast<int>(i) & static_cast<int>(~f)))
static void
compile_regex(void)
{
@@ -104,7 +108,7 @@ my_strntol(const char *str, int len)
static GncImportFormat
check_date_format(const char * str, regmatch_t *match, GncImportFormat fmts)
{
GncImportFormat res = 0;
GncImportFormat res = GNCIF_NONE;
int len0 = 0, len1 = 0, len2 = 0;
int val0 = 0, val1 = 0, val2 = 0;
@@ -179,7 +183,7 @@ check_date_format(const char * str, regmatch_t *match, GncImportFormat fmts)
GncImportFormat
gnc_import_test_numeric(const char* str, GncImportFormat fmts)
{
GncImportFormat res = 0;
GncImportFormat res = GNCIF_NONE;
g_return_val_if_fail(str, fmts);
@@ -187,10 +191,10 @@ gnc_import_test_numeric(const char* str, GncImportFormat fmts)
compile_regex();
if ((fmts & GNCIF_NUM_PERIOD) && !regexec(&decimal_radix_regex, str, 0, NULL, 0))
res |= GNCIF_NUM_PERIOD;
import_set_flag (res, GNCIF_NUM_PERIOD);
if ((fmts & GNCIF_NUM_COMMA) && !regexec(&comma_radix_regex, str, 0, NULL, 0))
res |= GNCIF_NUM_COMMA;
import_set_flag (res, GNCIF_NUM_COMMA);
return res;
}
@@ -200,7 +204,7 @@ GncImportFormat
gnc_import_test_date(const char* str, GncImportFormat fmts)
{
regmatch_t match[5];
GncImportFormat res = 0;
GncImportFormat res = GNCIF_NONE;
g_return_val_if_fail(str, fmts);
g_return_val_if_fail(strlen(str) > 1, fmts);
@@ -218,23 +222,24 @@ gnc_import_test_date(const char* str, GncImportFormat fmts)
* let's try both ways and let the parser check that YYYY is
* valid.
*/
char temp[9];
#define DATE_LEN 8
char temp[DATE_LEN + 1];
g_return_val_if_fail(match[4].rm_so != -1, fmts);
g_return_val_if_fail(match[4].rm_eo - match[4].rm_so == 8, fmts);
g_return_val_if_fail(match[4].rm_eo - match[4].rm_so == DATE_LEN, fmts);
/* make a temp copy of the XXXXXXXX string */
strncpy(temp, str + match[4].rm_so, 8);
temp[8] = '\0';
strncpy(temp, str + match[4].rm_so, DATE_LEN);
temp[DATE_LEN] = '\0';
/* then check it against the ymd or mdy formats, as necessary */
if (((fmts & GNCIF_DATE_YDM) || (fmts & GNCIF_DATE_YMD)) &&
!regexec(&date_ymd_regex, temp, 4, match, 0))
res |= check_date_format(temp, match, fmts);
import_set_flag (res, check_date_format (temp, match, fmts));
if (((fmts & GNCIF_DATE_DMY) || (fmts & GNCIF_DATE_MDY)) &&
!regexec(&date_mdy_regex, temp, 4, match, 0))
res |= check_date_format(temp, match, fmts);
import_set_flag (res, check_date_format (temp, match, fmts));
}
}

View File

@@ -27,6 +27,10 @@
#ifndef IMPORT_PARSE_H
#define IMPORT_PARSE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "qof.h"
typedef enum
@@ -57,9 +61,9 @@ gboolean gnc_import_parse_numeric(const char* str, GncImportFormat fmt,
gboolean gnc_import_parse_date(const char *date, GncImportFormat fmt,
time64 *val);
/* Set and clear flags in bit-flags */
#define import_set_flag(i,f) (i |= f)
#define import_clear_flag(i,f) (i &= ~f)
#ifdef __cplusplus
}
#endif
#endif /* IMPORT_PARSE_H */

View File

@@ -75,7 +75,6 @@ static GNCPendingMatches *
gnc_import_PendingMatches_get_value (GNCImportPendingMatches *map,
GNCImportMatchInfo *match_info)
{
GNCPendingMatches *pending_matches;
const GncGUID *match_guid;
g_return_val_if_fail (map, NULL);
@@ -83,9 +82,7 @@ gnc_import_PendingMatches_get_value (GNCImportPendingMatches *map,
match_guid = gnc_import_PendingMatches_get_key (match_info);
pending_matches = g_hash_table_lookup (map, match_guid);
return pending_matches;
return static_cast<GNCPendingMatches*>(g_hash_table_lookup (map, match_guid));
}
void

View File

@@ -2,7 +2,7 @@ add_subdirectory(gschemas)
add_subdirectory(test)
set(ofx_SOURCES
gnc-ofx-import.c
gnc-ofx-import.cpp
gncmod-ofx-import.c
gnc-plugin-ofx.c
)

View File

@@ -1058,32 +1058,32 @@ int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data)
{
switch (data.account_type)
{
case OFX_CHECKING :
case OfxAccountData::OFX_CHECKING:
default_type = ACCT_TYPE_BANK;
account_type_name = _("Unknown OFX checking account");
break;
case OFX_SAVINGS :
case OfxAccountData::OFX_SAVINGS:
default_type = ACCT_TYPE_BANK;
account_type_name = _("Unknown OFX savings account");
break;
case OFX_MONEYMRKT :
case OfxAccountData::OFX_MONEYMRKT:
default_type = ACCT_TYPE_MONEYMRKT;
account_type_name = _("Unknown OFX money market account");
break;
case OFX_CREDITLINE :
case OfxAccountData::OFX_CREDITLINE:
default_type = ACCT_TYPE_CREDITLINE;
account_type_name = _("Unknown OFX credit line account");
break;
case OFX_CMA :
case OfxAccountData::OFX_CMA:
default_type = ACCT_TYPE_NONE;
/* Cash Management Account */
account_type_name = _("Unknown OFX CMA account");
break;
case OFX_CREDITCARD :
case OfxAccountData::OFX_CREDITCARD:
default_type = ACCT_TYPE_CREDIT;
account_type_name = _("Unknown OFX credit card account");
break;
case OFX_INVESTMENT :
case OfxAccountData::OFX_INVESTMENT:
default_type = ACCT_TYPE_BANK;
account_type_name = _("Unknown OFX investment account");
break;
@@ -1226,7 +1226,7 @@ gnc_ofx_match_done (GtkDialog *dialog, gpointer user_data)
if (info->run_reconcile && info->statement && info->statement->data)
{
struct OfxStatementData* statement = info->statement->data;
auto statement = static_cast<struct OfxStatementData*>(info->statement->data);
// Open a reconcile window.
Account* account = gnc_import_select_account (gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui),
statement->account_id,
@@ -1305,13 +1305,13 @@ runMatcher (ofx_info* info, char * selected_filename, gboolean go_to_next_file)
// a hash of amount and date, and whose value is the account in which they appear.
for(GList* node = info->trans_list; node; node=node->next)
{
Transaction* trans = node->data;
auto trans = static_cast<Transaction*>(node->data);
Split* split = xaccTransGetSplit (trans, 0);
Account* account = xaccSplitGetAccount (split);
gchar *date_amount_key = make_date_amount_key (xaccTransGetDate (trans),
gnc_numeric_abs (xaccSplitGetAmount (split)));
// Test if date_amount_key is already in trans_hash.
Account* _account = g_hash_table_lookup (trans_hash, date_amount_key);
auto _account = static_cast<Account*>(g_hash_table_lookup (trans_hash, date_amount_key));
if (_account && _account != account)
{
if (qof_log_check (G_LOG_DOMAIN, QOF_LOG_DEBUG))
@@ -1393,7 +1393,7 @@ gnc_file_ofx_import_process_file (ofx_info* info)
if (info->file_list == NULL)
return;
filename = info->file_list->data;
filename = static_cast<char*>(info->file_list->data);
libofx_context = libofx_get_new_context();
#ifdef G_OS_WIN32
@@ -1465,7 +1465,7 @@ void gnc_file_ofx_import (GtkWindow *parent)
if (selected_filenames)
{
/* Remember the directory as the default. */
default_dir = g_path_get_dirname(selected_filenames->data);
default_dir = g_path_get_dirname(static_cast<char*>(selected_filenames->data));
gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
g_free(default_dir);

View File

@@ -25,6 +25,10 @@
#ifndef OFX_IMPORT_H
#define OFX_IMPORT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gtk/gtk.h>
/** The gnc_file_ofx_import() routine will pop up a standard file
@@ -33,4 +37,9 @@
* are merged into the existing session (if any). The current
* session continues to remain open for editing. */
void gnc_file_ofx_import (GtkWindow *parent);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -57,8 +57,8 @@ set(gtest_import_backend_LIBS
set(gtest_import_backend_SOURCES
gtest-import-backend.cpp
${CMAKE_SOURCE_DIR}/gnucash/import-export/import-backend.cpp
${CMAKE_SOURCE_DIR}/gnucash/import-export/import-settings.c
${CMAKE_SOURCE_DIR}/gnucash/import-export/import-utilities.c
${CMAKE_SOURCE_DIR}/gnucash/import-export/import-settings.cpp
${CMAKE_SOURCE_DIR}/gnucash/import-export/import-utilities.cpp
${CMAKE_SOURCE_DIR}/libgnucash/engine/mocks/gmock-qofinstance.cpp
${CMAKE_SOURCE_DIR}/libgnucash/app-utils/mocks/gmock-gnc-prefs.cpp
${CMAKE_SOURCE_DIR}/libgnucash/engine/mocks/gmock-qofbook.cpp

View File

@@ -346,20 +346,20 @@ gnucash/import-export/csv-imp/gnc-tokenizer-fw.cpp
gnucash/import-export/customer-import/dialog-customer-import.c
gnucash/import-export/customer-import/dialog-customer-import-gui.c
gnucash/import-export/customer-import/gnc-plugin-customer-import.c
gnucash/import-export/import-account-matcher.c
gnucash/import-export/import-account-matcher.cpp
gnucash/import-export/import-backend.cpp
gnucash/import-export/import-commodity-matcher.c
gnucash/import-export/import-format-dialog.c
gnucash/import-export/import-main-matcher.c
gnucash/import-export/import-match-picker.c
gnucash/import-export/import-parse.c
gnucash/import-export/import-pending-matches.c
gnucash/import-export/import-settings.c
gnucash/import-export/import-utilities.c
gnucash/import-export/import-commodity-matcher.cpp
gnucash/import-export/import-format-dialog.cpp
gnucash/import-export/import-main-matcher.cpp
gnucash/import-export/import-match-picker.cpp
gnucash/import-export/import-parse.cpp
gnucash/import-export/import-pending-matches.cpp
gnucash/import-export/import-settings.cpp
gnucash/import-export/import-utilities.cpp
gnucash/import-export/log-replay/gnc-log-replay.c
gnucash/import-export/log-replay/gnc-plugin-log-replay.c
gnucash/import-export/ofx/gncmod-ofx-import.c
gnucash/import-export/ofx/gnc-ofx-import.c
gnucash/import-export/ofx/gnc-ofx-import.cpp
gnucash/import-export/ofx/gnc-plugin-ofx.c
gnucash/import-export/ofx/gnc-plugin-ofx.ui
gnucash/import-export/ofx/gschemas/org.gnucash.GnuCash.dialogs.import.ofx.gschema.xml.in