diff --git a/po/POTFILES.in b/po/POTFILES.in index c160f09483..5ed76aa246 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,6 +10,7 @@ src/app-utils/gnc-component-manager.c src/app-utils/gnc-entry-quickfill.c src/app-utils/gnc-euro.c src/app-utils/gnc-exp-parser.c +src/app-utils/gnc-features.c src/app-utils/gnc-gettext-util.c src/app-utils/gnc-helpers.c src/app-utils/gnc-help-utils.c @@ -424,11 +425,12 @@ src/libqof/qof/qofsession.c src/libqof/qof/qofutil.c src/libqof/qof/qof-win32.c src/plugins/bi_import/dialog-bi-import.c -src/plugins/bi_import/gtkbuilder/dialog-bi-import-gui.glade -src/plugins/bi_import/gncmod-bi-import.c -src/plugins/bi_import/gnc-plugin-bi-import.c src/plugins/bi_import/dialog-bi-import-gui.c src/plugins/bi_import/dialog-bi-import-helper.c +src/plugins/bi_import/glade/bi_import.glade +src/plugins/bi_import/gncmod-bi-import.c +src/plugins/bi_import/gnc-plugin-bi-import.c +src/plugins/bi_import/gtkbuilder/dialog-bi-import-gui.glade src/python/gncmod-python.c src/register/ledger-core/gnc-ledger-display.c src/register/ledger-core/gncmod-ledger-core.c diff --git a/src/app-utils/Makefile.am b/src/app-utils/Makefile.am index f948035d2e..e9b77fded9 100644 --- a/src/app-utils/Makefile.am +++ b/src/app-utils/Makefile.am @@ -47,6 +47,7 @@ libgncmod_app_utils_la_SOURCES = \ gnc-entry-quickfill.c \ gnc-euro.c \ gnc-exp-parser.c \ + gnc-features.c \ gnc-gettext-util.c \ gnc-helpers.c \ gnc-sx-instance-model.c \ @@ -70,6 +71,7 @@ gncinclude_HEADERS = \ gnc-entry-quickfill.h \ gnc-euro.h \ gnc-exp-parser.h \ + gnc-features.h \ gnc-gettext-util.h \ gnc-help-utils.h \ gnc-helpers.h \ diff --git a/src/app-utils/gnc-features.c b/src/app-utils/gnc-features.c new file mode 100644 index 0000000000..14ad515210 --- /dev/null +++ b/src/app-utils/gnc-features.c @@ -0,0 +1,103 @@ +/********************************************************************\ + * gnc-features.c -- manage GnuCash features table * + * Copyright (C) 2011 Derek Atkins * + * Copyright (C) 2012 Geert Janssens * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + * * +\********************************************************************/ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "gnc-engine.h" +#include "gnc-features.h" + +/* This static indicates the debugging module that this .o belongs to. */ +static QofLogModule log_module = GNC_MOD_GUI; + +/********************************************************************\ +\********************************************************************/ +static void features_test(const gchar *key, KvpValue *value, gpointer data) +{ + GList** unknown_features = (GList**) data; + char* feature_desc; + + g_assert(data); + + /* XXX: test if 'key' is an unknown feature. */ + + /* Yes, it is unknown, so add the description to the list: */ + feature_desc = kvp_value_get_string(value); + g_assert(feature_desc); + + *unknown_features = g_list_prepend(*unknown_features, feature_desc); +} + +/* + * Right now this is done by a KVP check for a features table. + * Currently we don't know about any features, so the mere + * existence of this KVP frame means we have a problem and + * need to tell the user. + * + * returns a message to display if we found unknown features, NULL if we're okay. + */ +gchar *test_unknown_features(QofSession* new_session) +{ + KvpFrame *frame = qof_book_get_slots (qof_session_get_book (new_session)); + KvpValue *value; + + g_assert(frame); + value = kvp_frame_get_value(frame, "features"); + + if (value) + { + GList* features_list = NULL; + frame = kvp_value_get_frame(value); + g_assert(frame); + + /* Iterate over the members of this frame for unknown features */ + kvp_frame_for_each_slot(frame, &features_test, &features_list); + if (features_list) + { + GList *i; + char* msg = g_strdup( + _("This Dataset contains features not supported by this " + "version of GnuCash. You must use a newer version of " + "GnuCash in order to support the following features:" + )); + + for (i = features_list; i; i = i->next) + { + char *tmp = g_strconcat(msg, "\n* ", _(i->data), NULL); + g_free (msg); + msg = tmp; + } + + g_free(msg); + g_list_free(features_list); + return msg; + } + } + + return NULL; +} diff --git a/src/app-utils/gnc-features.h b/src/app-utils/gnc-features.h new file mode 100644 index 0000000000..589144f88a --- /dev/null +++ b/src/app-utils/gnc-features.h @@ -0,0 +1,50 @@ +/********************************************************************\ + * gnc-features.h -- manage GnuCash features table * + * Copyright (C) 2011 Derek Atkins * + * Copyright (C) 2012 Geert Janssens * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + * * +\********************************************************************/ + +/** @addtogroup Utils Utility functions + @{ */ +/** @addtogroup UtilFeature Features + * @{ */ +/** @file gnc-features.h + * @brief Utility functions for file access + * @author Copyright (C) 2011 Derek Atkins + * @author Copyright (C) 2012 Geert Janssens + * + * These functions help you to manage features that GnuCash supports. + * This is mainly used to prevent older GnuCash versions from opening + * datasets with data they aren't capable of processing properly. + */ + +#ifndef GNC_FEATURES_H +#define GNC_FEATURES_H + + +/** + * Test if the current session relies on features we don't know. + * + * Returns a message to display if we found unknown features, NULL if we're okay. + */ +gchar *test_unknown_features(QofSession* new_session); + +#endif /* GNC_FEATURES_H */ +/** @} */ +/** @} */ + diff --git a/src/gnome-utils/gnc-file.c b/src/gnome-utils/gnc-file.c index a23283ab39..e75cacfe14 100644 --- a/src/gnome-utils/gnc-file.c +++ b/src/gnome-utils/gnc-file.c @@ -34,6 +34,7 @@ #include "gnc-engine.h" #include "Account.h" #include "gnc-file.h" +#include "gnc-features.h" #include "gnc-filepath-utils.h" #include "gnc-gui-query.h" #include "gnc-hooks.h" @@ -619,76 +620,6 @@ gnc_file_query_save (gboolean can_cancel) } - -static void features_test(const gchar *key, KvpValue *value, gpointer data) -{ - GList** unknown_features = (GList**) data; - char* feature_desc; - - g_assert(data); - - /* XXX: test if 'key' is an unknown feature. */ - - /* Yes, it is unknown, so add the description to the list: */ - feature_desc = kvp_value_get_string(value); - g_assert(feature_desc); - - *unknown_features = g_list_prepend(*unknown_features, feature_desc); -} - -/* - * Right now this is done by a KVP check for a features table. - * Currently we don't know about any features, so the mere - * existence of this KVP frame means we have a problem and - * need to tell the user. - * - * returns true if we found unknown features, false if we're okay. - */ -static gboolean test_unknown_features(QofSession* new_session) -{ - KvpFrame *frame = qof_book_get_slots (qof_session_get_book (new_session)); - KvpValue *value; - - g_assert(frame); - value = kvp_frame_get_value(frame, "features"); - - if (value) - { - GList* features_list = NULL; - frame = kvp_value_get_frame(value); - g_assert(frame); - - /* Iterate over the members of this frame for unknown features */ - kvp_frame_for_each_slot(frame, &features_test, &features_list); - if (features_list) - { - GList *i; - char* msg = g_strdup( - _("This Dataset contains features not supported by this " - "version of GnuCash. You must use a newer version of " - "GnuCash in order to support the following features:" - )); - - for (i = features_list; i; i = i->next) - { - char *tmp = g_strconcat(msg, "\n* ", _(i->data), NULL); - g_free (msg); - msg = tmp; - } - - // XXX: should pull out the file name here */ - gnc_error_dialog(gnc_ui_get_toplevel(), msg, ""); - - g_free(msg); - g_list_free(features_list); - return TRUE; - } - } - - return FALSE; -} - - /* private utilities for file open; done in two stages */ #define RESPONSE_NEW 1 @@ -988,7 +919,16 @@ RESTART: /* test for unknown features. */ if (!uh_oh) { - uh_oh = test_unknown_features(new_session); + gchar *msg = test_unknown_features(new_session); + + if (msg) + { + uh_oh = TRUE; + + // XXX: should pull out the file name here */ + gnc_error_dialog(gnc_ui_get_toplevel(), msg, ""); + g_free (msg); + } } }