GnuCash  4.8a-176-g88ecf8dd1
Files | Functions


file  gnc-features.h
 Utility functions for file access.


gchar * gnc_features_test_unknown (QofBook *book)
 Test if the current book relies on features only introduced in a more recent version of GnuCash. More...
void gnc_features_set_used (QofBook *book, const gchar *feature)
 Indicate that the current book uses the given feature. More...
gboolean gnc_features_check_used (QofBook *, char const *feature)

Defined features

#define GNC_FEATURE_CREDIT_NOTES   "Credit Notes"
#define GNC_FEATURE_NUM_FIELD_SOURCE   "Number Field Source"
#define GNC_FEATURE_KVP_EXTRA_DATA   "Extra data in addresses, jobs or invoice entries"
#define GNC_FEATURE_BOOK_CURRENCY   "Use a Book-Currency"
#define GNC_FEATURE_GUID_BAYESIAN   "Account GUID based Bayesian data"
#define GNC_FEATURE_GUID_FLAT_BAYESIAN   "Account GUID based bayesian with flat KVP"
#define GNC_FEATURE_SQLITE3_ISO_DATES   "ISO-8601 formatted date strings in SQLite3 databases."
#define GNC_FEATURE_REG_SORT_FILTER   "Register sort and filter settings stored in .gcm file"
#define GNC_FEATURE_BUDGET_UNREVERSED   "Use natural signs in budget amounts"
#define GNC_FEATURE_BUDGET_SHOW_EXTRA_ACCOUNT_COLS   "Show extra account columns in the Budget View"
#define GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE   "Use a dedicated opening balance account identified by an 'equity-type' slot"

Detailed Description

Function Documentation

◆ gnc_features_set_used()

void gnc_features_set_used ( QofBook *  book,
const gchar *  feature 

Indicate that the current book uses the given feature.

This will prevent older versions of GnuCash that don't support this feature to refuse to load this book.

Definition at line 135 of file gnc-features.c.

136 {
137  const gchar *description;
139  g_return_if_fail (book);
140  g_return_if_fail (feature);
142  gnc_features_init();
144  /* Can't set an unknown feature */
145  description = g_hash_table_lookup (features_table, feature);
146  if (!description)
147  {
148  PWARN("Tried to set unknown feature as used.");
149  return;
150  }
152  qof_book_set_feature (book, feature, description);
153 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_features_test_unknown()

gchar* gnc_features_test_unknown ( QofBook *  book)

Test if the current book relies on features only introduced in a more recent version of GnuCash.

Returns a message to display if we found unknown features, NULL if we're okay.

Definition at line 105 of file gnc-features.c.

106 {
108  GList* features_list = NULL;
109  GHashTable *features_used = qof_book_get_features (book);
111  /* Setup the known_features hash table */
112  gnc_features_init();
114  /* Iterate over the members of this frame for unknown features */
115  g_hash_table_foreach (features_used, &gnc_features_test_one,
116  &features_list);
117  if (features_list)
118  {
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:");
125  char *features_str = gnc_g_list_stringjoin (features_list, sep);
126  char *msg = g_strconcat (header, sep, features_str, NULL);
127  g_free (features_str);
128  g_list_free(features_list);
129  return msg;
130  }
131  g_hash_table_unref (features_used);
132  return NULL;
133 }
gchar * gnc_g_list_stringjoin(GList *list_of_strings, const gchar *sep)
Return a string joining a GList whose elements are gchar* strings.
GHashTable * qof_book_get_features(QofBook *book)
Access functions for reading and setting the used-features on this book.
Definition: qofbook.cpp:1223