[glom/maemo5] Check for unsupported hosting modes.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom/maemo5] Check for unsupported hosting modes.
- Date: Sat, 5 Sep 2009 13:41:23 +0000 (UTC)
commit 3fd3dc77ccf0592628c55dd98df718c266501352
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Sep 5 14:32:17 2009 +0200
Check for unsupported hosting modes.
* glom/application.[h|cc]:
Added check_document_hosting_mode_is_supported() to warn the user
if the build cannot use the hosting mode in the file, and call it from
on_document_load().
* glom/libglom/document/bakery/document.cc: load(), load_from_data():
Call set_is_new(false) so we can check for this in
App/View::on_document_load(), to avoid complaining about an unused
default hosting mode.
ChangeLog | 13 +++++++
glom/application.cc | 57 ++++++++++++++++++++++++++++++
glom/application.h | 5 +++
glom/libglom/document/bakery/document.cc | 2 +
4 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8cbbdf7..c8b9a30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2009-09-05 Murray Cumming <murrayc murrayc com>
+ Check for unsupported hosting modes.
+
+ * glom/application.[h|cc]:
+ Added check_document_hosting_mode_is_supported() to warn the user
+ if the build cannot use the hosting mode in the file, and call it from
+ on_document_load().
+ * glom/libglom/document/bakery/document.cc: load(), load_from_data():
+ Call set_is_new(false) so we can check for this in
+ App/View::on_document_load(), to avoid complaining about an unused
+ default hosting mode.
+
+2009-09-05 Murray Cumming <murrayc murrayc com>
+
* glom/application.cc: offer_new_or_existing(): In the client-only build,
actually handle the enum for opening an existing file in client mode.
diff --git a/glom/application.cc b/glom/application.cc
index a703bed..692ce60 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -911,6 +911,59 @@ void App_Glom::init_create_document()
type_base::init_create_document(); //Sets window title. Doesn't recreate doc.
}
+bool App_Glom::check_document_hosting_mode_is_supported(Document* document)
+{
+ //Check that the file's hosting mode is supported by this build:
+ Glib::ustring error_message;
+ switch(document->get_hosting_mode())
+ {
+ case Document::HOSTING_MODE_POSTGRES_SELF:
+ {
+ #ifdef GLOM_ENABLE_CLIENT_ONLY
+ error_message = _("The file cannot be opened because this version of Glom does not support self-hosting of databases.");
+ break;
+ #endif //GLOM_ENABLE_CLIENT_ONLY
+
+ #ifndef GLOM_ENABLE_POSTGRESQL
+ error_message = _("The file cannot be opened because this version of Glom does not support PostgreSQL databases.");
+ break;
+ #endif //GLOM_ENABLE_POSTGRESQL
+
+ break;
+ }
+ case Document::HOSTING_MODE_POSTGRES_CENTRAL:
+ {
+ #ifndef GLOM_ENABLE_POSTGRESQL
+ error_message = _("The file cannot be opened because this version of Glom does not support PostgreSQL databases.");
+ #endif //GLOM_ENABLE_POSTGRESQL
+
+ break;
+ }
+ case Document::HOSTING_MODE_SQLITE:
+ {
+ #ifdef GLOM_ENABLE_SQLITE
+ error_message = _("The file cannot be opened because this version of Glom does not support SQLite databases.");
+ #endif //GLOM_ENABLE_SQLITE
+
+ break;
+ }
+ default:
+ {
+ //on_document_load() should have checked for this already, informing the user.
+ std::cerr << "Glom: setup_connection_pool_from_document(): Unhandled hosting mode: " << document->get_hosting_mode() << std::endl;
+ g_assert_not_reached();
+ break;
+ }
+ }
+
+ if(error_message.empty())
+ return true;
+
+ //Warn the user.
+ Frame_Glom::show_ok_dialog(_("File Uses Unsupported Database Backend"), error_message, *this, Gtk::MESSAGE_ERROR);
+ return false;
+}
+
bool App_Glom::on_document_load()
{
//Link to the database described in the document.
@@ -919,6 +972,10 @@ bool App_Glom::on_document_load()
Document* pDocument = static_cast<Document*>(get_document());
if(!pDocument)
return false;
+
+ std::cout << "debug: is_new(): " << pDocument->get_is_new() << std::endl;
+ if(!pDocument->get_is_new() && check_document_hosting_mode_is_supported(pDocument))
+ return false;
#ifndef GLOM_ENABLE_CLIENT_ONLY
//Connect signals:
diff --git a/glom/application.h b/glom/application.h
index e5b883c..635ea8d 100644
--- a/glom/application.h
+++ b/glom/application.h
@@ -106,6 +106,11 @@ private:
void on_menu_help_contents();
+ /** Check that the file's hosting mode is supported by this build and
+ * tell the user if necessary.
+ */
+ bool check_document_hosting_mode_is_supported(Document* document);
+
#ifndef GLOM_ENABLE_CLIENT_ONLY
void existing_or_new_new();
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 9b80865..748a908 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -134,6 +134,7 @@ bool Document::load(int& failure_code)
}
}
+ set_is_new(false);
return bTest;
}
@@ -155,6 +156,7 @@ bool Document::load_from_data(const guchar* data, std::size_t length, int& failu
m_pView->load_from_document();
}
+ set_is_new(false);
return bTest;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]