GnuCash  4.11-517-g41de4cefce
Files | Functions

Files

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

Functions

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_unused (QofBook *book, const gchar *feature)
 Indicate that the current book does not use the given feature. 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_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_unused()

void gnc_features_set_unused ( QofBook *  book,
const gchar *  feature 
)

Indicate that the current book does not use the given feature.

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

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

156 {
157  const gchar *description;
158 
159  g_return_if_fail (book);
160  g_return_if_fail (feature);
161 
162  gnc_features_init();
163 
164  /* Can't unset an unknown feature */
165  description = g_hash_table_lookup (features_table, feature);
166  if (!description)
167  {
168  PWARN("Tried to set unknown feature as unused.");
169  return;
170  }
171 
172  qof_book_unset_feature (book, feature, description);
173 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ 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 134 of file gnc-features.c.

135 {
136  const gchar *description;
137 
138  g_return_if_fail (book);
139  g_return_if_fail (feature);
140 
141  gnc_features_init();
142 
143  /* Can't set an unknown feature */
144  description = g_hash_table_lookup (features_table, feature);
145  if (!description)
146  {
147  PWARN("Tried to set unknown feature as used.");
148  return;
149  }
150 
151  qof_book_set_feature (book, feature, description);
152 }
#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 104 of file gnc-features.c.

105 {
106 
107  GList* features_list = NULL;
108  GHashTable *features_used = qof_book_get_features (book);
109 
110  /* Setup the known_features hash table */
111  gnc_features_init();
112 
113  /* Iterate over the members of this frame for unknown features */
114  g_hash_table_foreach (features_used, &gnc_features_test_one,
115  &features_list);
116  if (features_list)
117  {
118  const char* sep = "\n* ";
119  const char* header = _("This Dataset contains features not supported "
120  "by this version of GnuCash. You must use a "
121  "newer version of GnuCash in order to support "
122  "the following features:");
123 
124  char *features_str = gnc_g_list_stringjoin (features_list, sep);
125  char *msg = g_strconcat (header, sep, features_str, NULL);
126  g_free (features_str);
127  g_list_free(features_list);
128  return msg;
129  }
130  g_hash_table_unref (features_used);
131  return NULL;
132 }
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:1103