25 #include <glib/gi18n.h> 30 #include <sys/types.h> 42 static GHashTable *features_table = NULL;
45 { GNC_FEATURE_CREDIT_NOTES,
"Customer and vendor credit notes (requires at least GnuCash 2.5.0)" },
46 { GNC_FEATURE_NUM_FIELD_SOURCE,
"User specifies source of 'num' field'; either transaction number or split action (requires at least GnuCash 2.5.0)" },
47 { GNC_FEATURE_KVP_EXTRA_DATA,
"Extra data for addresses, jobs or invoice entries (requires at least GnuCash 2.6.4)" },
48 { GNC_FEATURE_BOOK_CURRENCY,
"User specifies a 'book-currency'; costs of other currencies/commodities tracked in terms of book-currency (requires at least GnuCash 2.7.0)" },
49 { GNC_FEATURE_GUID_BAYESIAN,
"Use account GUID as key for Bayesian data (requires at least GnuCash 2.6.12)" },
50 { GNC_FEATURE_GUID_FLAT_BAYESIAN,
"Use account GUID as key for bayesian data and store KVP flat (requires at least Gnucash 2.6.19)" },
51 { GNC_FEATURE_SQLITE3_ISO_DATES,
"Use ISO formatted date-time strings in SQLite3 databases (requires at least GnuCash 2.6.20)"},
52 { GNC_FEATURE_REG_SORT_FILTER,
"Store the register sort and filter settings in .gcm metadata file (requires at least GnuCash 3.3)"},
53 { GNC_FEATURE_BUDGET_UNREVERSED,
"Store budget amounts unreversed (i.e. natural) signs (requires at least Gnucash 3.8)"},
54 { GNC_FEATURE_BUDGET_SHOW_EXTRA_ACCOUNT_COLS,
"Show extra account columns in the Budget View (requires at least Gnucash 3.8)"},
55 { GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE, GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE
" (requires at least Gnucash 4.3)" },
65 static void gnc_features_init ()
72 features_table = g_hash_table_new (g_str_hash, g_str_equal);
73 for (i = 0; known_features[i].key; i++)
74 g_hash_table_insert (features_table,
75 g_strdup (known_features[i].key),
76 g_strdup (known_features[i].desc));
79 static void gnc_features_test_one(gpointer pkey, gpointer value,
82 const gchar *key = (
const gchar*)pkey;
83 const gchar *feature_desc = (
const gchar*)value;
84 GList **unknown_features;
87 unknown_features = (GList**) data;
90 if (g_hash_table_lookup_extended (features_table, key, NULL, NULL))
94 g_assert(feature_desc);
96 *unknown_features = g_list_prepend(*unknown_features,
97 (gpointer)feature_desc);
108 GList* features_list = NULL;
115 g_hash_table_foreach (features_used, &gnc_features_test_one,
119 const char* sep =
"\n* ";
120 const char* header = _(
"This Dataset contains features not supported " 121 "by this version of GnuCash. You must use a " 122 "newer version of GnuCash in order to support " 123 "the following features:");
126 char *msg = g_strconcat (header, sep, features_str, NULL);
127 g_free (features_str);
128 g_list_free(features_list);
131 g_hash_table_unref (features_used);
137 const gchar *description;
139 g_return_if_fail (book);
140 g_return_if_fail (feature);
145 description = g_hash_table_lookup (features_table, feature);
148 PWARN(
"Tried to set unknown feature as used.");
152 qof_book_set_feature (book, feature, description);
157 gchar
const * checked_feature;
161 static void gnc_features_check_feature_cb (gpointer pkey, gpointer value,
164 const gchar *key = (
const gchar*)pkey;
167 if (!g_strcmp0 (key, check_data->checked_feature))
168 check_data->found = TRUE;
171 gboolean gnc_features_check_used (QofBook *book,
const gchar * feature)
177 g_hash_table_foreach (features_used, &gnc_features_check_feature_cb, &check_data);
178 g_hash_table_unref (features_used);
179 return check_data.found;
gchar * gnc_g_list_stringjoin(GList *list_of_strings, const gchar *sep)
Return a string joining a GList whose elements are gchar* strings.
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
GHashTable * qof_book_get_features(QofBook *book)
Access functions for reading and setting the used-features on this book.
#define PWARN(format, args...)
Log a warning.
gchar * gnc_features_test_unknown(QofBook *book)
Test if the current book relies on features only introduced in a more recent version of GnuCash...
Utility functions for file access.