25 #include <glib/gi18n.h>
30 #include <sys/types.h>
32 #include "libqof/qof/qof.h"
41 static GHashTable *features_table = NULL;
44 { GNC_FEATURE_CREDIT_NOTES,
"Customer and vendor credit notes (requires at least GnuCash 2.5.0)" },
45 { GNC_FEATURE_NUM_FIELD_SOURCE,
"User specifies source of 'num' field'; either transaction number or split action (requires at least GnuCash 2.5.0)" },
46 { GNC_FEATURE_KVP_EXTRA_DATA,
"Extra data for addresses, jobs or invoice entries (requires at least GnuCash 2.6.4)" },
56 static void gnc_features_init ()
63 features_table = g_hash_table_new (g_str_hash, g_str_equal);
64 for (i = 0; known_features[i].key; i++)
65 g_hash_table_insert (features_table,
66 g_strdup (known_features[i].key),
67 g_strdup (known_features[i].desc));
70 static void gnc_features_test_one(gpointer pkey, gpointer value,
73 const gchar *key = (
const gchar*)pkey;
74 const gchar *feature_desc = (
const gchar*)value;
75 GList **unknown_features;
78 unknown_features = (GList**) data;
81 if (g_hash_table_lookup_extended (features_table, key, NULL, NULL))
85 g_assert(feature_desc);
87 *unknown_features = g_list_prepend(*unknown_features,
88 (gpointer)feature_desc);
99 GList* features_list = NULL;
106 g_hash_table_foreach (features_used, &gnc_features_test_one,
111 char* msg = g_strdup(_(
"This Dataset contains features not supported "
112 "by this version of GnuCash. You must use a "
113 "newer version of GnuCash in order to support "
114 "the following features:"
117 for (i = features_list; i; i = i->next)
119 char *tmp = g_strconcat(msg,
"\n* ", i->data, NULL);
124 g_list_free(features_list);
133 const gchar *description;
135 g_return_if_fail (book);
136 g_return_if_fail (feature);
141 description = g_hash_table_lookup (features_table, feature);
144 PWARN(
"Tried to set unknown feature as used.");
148 qof_book_set_feature (book, feature, description);
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
void gnc_features_set_used(QofBook *book, const gchar *feature)
GHashTable * qof_book_get_features(QofBook *book)
#define PWARN(format, args...)
gchar * gnc_features_test_unknown(QofBook *book)
const gchar * QofLogModule
Utility functions for file access.