GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Functions

Files

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

Functions

gchar * gnc_features_test_unknown (QofBook *book)
 
void gnc_features_set_used (QofBook *book, const gchar *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"
 

Detailed Description

Function Documentation

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

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

97 {
98 
99  GList* features_list = NULL;
100  GHashTable *features_used = qof_book_get_features (book);
101 
102  /* Setup the known_features hash table */
103  gnc_features_init();
104 
105  /* Iterate over the members of this frame for unknown features */
106  g_hash_table_foreach (features_used, &gnc_features_test_one,
107  &features_list);
108  if (features_list)
109  {
110  GList *i;
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:"
115  ));
116 
117  for (i = features_list; i; i = i->next)
118  {
119  char *tmp = g_strconcat(msg, "\n* ", i->data, NULL);
120  g_free (msg);
121  msg = tmp;
122  }
123 
124  g_list_free(features_list);
125  return msg;
126  }
127 
128  return NULL;
129 }
GHashTable * qof_book_get_features(QofBook *book)