glom r1930 - in trunk: . glom glom/libglom/connectionpool_backends glom/libglom/document glom/utility_widgets glom/utility_widgets/db_adddel



Author: arminb
Date: Tue Feb 24 11:43:12 2009
New Revision: 1930
URL: http://svn.gnome.org/viewvc/glom?rev=1930&view=rev

Log:
2009-02-24  Armin Burgmeier  <armin openismus com>

	* configure.in: Added an --enable-sqlite configure option, which is
	enabled by default.

	* glom/libglom/connectionpool_backends/sqlite.h: #error if this file
	is included with SQLite support disabled. Mostly meant as a debugging
	aid.

	* glom/libglom/connectionpool_backends/Makefile.am: Don't build
	sqlite.cc in case SQLite support is disabled.

	* glom/libglom/document/document_glom.h:
	* glom/libglom/document/document_glom.cc: Don't declare SQLITE_HOSTED
	hosting mode if SQLite support is disabled, and refuse to open files
	with unknown hosting mode instead of falling back to postgres central.

	* glom/utility_widgets/filechooserdialog_saveextras.h:
	* glom/utility_widgets/filechooserdialog_saveextras.cc: Don't show the
	option to create a SQLite hosted file in the GUI if SQLite support is
	disabled.

	* glom/utility_widgets/db_adddel/glom_db_treemodel.cc: Removed a
	superfluous <libglom/connectionpool_backends/sqlite.h> include.

	* glom/frame_glom.cc:
	* glom/application.cc: #ifdef-out code to create a SQLite
	connectionpool backend if SQLite support is disabled, as well as a few
	related checks.


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/glom/application.cc
   trunk/glom/frame_glom.cc
   trunk/glom/libglom/connectionpool_backends/Makefile.am
   trunk/glom/libglom/connectionpool_backends/sqlite.h
   trunk/glom/libglom/document/document_glom.cc
   trunk/glom/libglom/document/document_glom.h
   trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc
   trunk/glom/utility_widgets/filechooserdialog_saveextras.cc
   trunk/glom/utility_widgets/filechooserdialog_saveextras.h

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Feb 24 11:43:12 2009
@@ -85,8 +85,19 @@
 	AC_DEFINE([GLOM_ENABLE_CLIENT_ONLY], 1, [Whether to disable support for self-hosting and developer mode])
 fi
 
+AC_ARG_ENABLE([sqlite],
+	AC_HELP_STRING([--enable-sqlite],
+	[allow creation of SQLite databases and opening of documents using an SQLite database [default=yes]]),
+	[enable_sqlite=$enableval],
+	[enable_sqlite=yes])
+
+AM_CONDITIONAL(GLOM_ENABLE_SQLITE, test "$enable_sqlite" = "yes")
+if test "$enable_sqlite" = "yes"; then
+	AC_DEFINE([GLOM_ENABLE_SQLITE], 1, [Whether to enable support for SQLite databases])
+fi
+
 # Do not require, goocanvas and gtksourceviewmm in client only mode
-REQUIRED_LIBS="bakery-2.6 >= 2.6.0 gtkmm-2.4 >= 2.10 gthread-2.0 libxslt >= 1.1.10 pygda-4.0 >= 2.25.3 pygtk-2.0 >= 2.6.0 libgdamm-4.0 >= 3.99.11 libgda-4.0 >= 3.99.11 libgda-postgres-4.0  libgda-sqlite-4.0 goocanvasmm-1.0 >= 0.13.0"
+REQUIRED_LIBS="bakery-2.6 >= 2.6.0 gtkmm-2.4 >= 2.10 gthread-2.0 libxslt >= 1.1.10 pygda-4.0 >= 2.25.3 pygtk-2.0 >= 2.6.0 libgdamm-4.0 >= 3.99.11 libgda-4.0 >= 3.99.11 libgda-postgres-4.0 goocanvasmm-1.0 >= 0.13.0"
 if test $enable_client_only != yes; then
 	REQUIRED_LIBS="$REQUIRED_LIBS gtksourceviewmm-2.0"
 fi
@@ -100,6 +111,10 @@
 	REQUIRED_LIBS="$REQUIRED_LIBS iso-codes libepc-1.0 >= 0.3.1 avahi-ui";
 fi
 
+if test "$enable_sqlite" = "yes"; then
+	REQIRED_LIBS="$REQUIRED_LIBS libgda-sqlite-4.0"
+fi
+
 # Checks for libraries
 PKG_CHECK_MODULES(GLOM, $REQUIRED_LIBS)
 

Modified: trunk/glom/application.cc
==============================================================================
--- trunk/glom/application.cc	(original)
+++ trunk/glom/application.cc	Tue Feb 24 11:43:12 2009
@@ -18,6 +18,8 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include "config.h" //For VERSION, GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
+
 #include "application.h"
 #include "dialog_existing_or_new.h"
 
@@ -35,8 +37,6 @@
 #include <glom/libglom/connectionpool_backends/postgres_central.h>
 #include <glom/libglom/connectionpool_backends/postgres_self.h>
 
-#include "config.h" //For VERSION.
-
 #include <cstdio>
 #include <memory> //For std::auto_ptr<>
 #include <giomm.h>
@@ -2219,12 +2219,18 @@
           continue;
         }
       }
- 
+
+      bool is_self_hosted = false;
+      if(m_ui_save_extra_newdb_hosting_mode == Document_Glom::POSTGRES_SELF_HOSTED)
+        is_self_hosted = true;
+#ifdef GLOM_ENABLE_SQLITE
+      if(m_ui_save_extra_newdb_hosting_mode == Document_Glom::SQLITE_HOSTED)
+        is_self_hosted = true;
+#endif // GLOM_ENABLE_SQLITE
+
       // Create a directory for self-hosted databases (sqlite or self-hosted
       // postgresql).
-      if(!try_again && fileChooser_SaveExtras &&
-         (m_ui_save_extra_newdb_hosting_mode == Document_Glom::POSTGRES_SELF_HOSTED ||
-          m_ui_save_extra_newdb_hosting_mode == Document_Glom::SQLITE_HOSTED))
+      if(!try_again && fileChooser_SaveExtras && is_self_hosted)
       {
         //Check that the directory does not exist already.
         //The GtkFileChooser could not check for that because it could not know that we would create a directory based on the filename:

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Tue Feb 24 11:43:12 2009
@@ -18,7 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "config.h" // For GLOM_ENABLE_SQLITE, GLOM_ENABLE_CLIENT_ONLY
 
 #include "frame_glom.h"
 #include "application.h"
@@ -29,7 +29,10 @@
 #include <glom/libglom/connectionpool.h>
 #include <glom/libglom/connectionpool_backends/postgres_central.h>
 #include <glom/libglom/connectionpool_backends/postgres_self.h>
-#include <glom/libglom/connectionpool_backends/sqlite.h>
+
+#ifdef GLOM_ENABLE_SQLITE
+# include <glom/libglom/connectionpool_backends/sqlite.h>
+#endif
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 #include "mode_design/users/dialog_groups_list.h"
@@ -1659,7 +1662,7 @@
       }
 
       break;
-#ifndef GLOM_ENABLE_CLIENT_ONLY
+#ifdef GLOM_ENABLE_SQLITE
     case Document_Glom::SQLITE_HOSTED:
       {
         ConnectionPoolBackends::Sqlite* backend = new ConnectionPoolBackends::Sqlite;
@@ -1667,7 +1670,7 @@
         connection_pool->set_backend(std::auto_ptr<ConnectionPoolBackend>(backend));
       }
       break;
-#endif //GLOM_ENABLE_CLIENT_ONLY
+#endif // GLOM_ENABLE_SQLITE
     default:
       g_assert_not_reached();
       break;
@@ -1926,11 +1929,15 @@
     // not support authentication. I'd prefer to get that information from
     // libgda, but gda_connection_supports_feature() requires a GdaConnection
     // which we don't have at this point.
-    if(document->get_hosting_mode() != Document_Glom::SQLITE_HOSTED &&
-       known_username.empty() && known_password.empty())
+#ifdef GLOM_ENABLE_SQLITE
+    if(document->get_hosting_mode() != Document_Glom::SQLITE_HOSTED)
+#endif
     {
-       response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
-       m_pDialogConnection->hide();
+      if(known_username.empty() && known_password.empty())
+      {
+        response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
+        m_pDialogConnection->hide();
+      }
     }
 
     if(response == Gtk::RESPONSE_OK)

Modified: trunk/glom/libglom/connectionpool_backends/Makefile.am
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/Makefile.am	(original)
+++ trunk/glom/libglom/connectionpool_backends/Makefile.am	Tue Feb 24 11:43:12 2009
@@ -5,10 +5,14 @@
 noinst_LTLIBRARIES = libconnectionpool_backends.la
 libconnectionpool_backends_la_SOURCES = \
 	postgres.h postgres.cc \
-	postgres_central.h postgres_central.cc \
-	sqlite.h sqlite.cc
+	postgres_central.h postgres_central.cc
 
 if !GLOM_ENABLE_CLIENT_ONLY
 libconnectionpool_backends_la_SOURCES += \
 	postgres_self.h postgres_self.cc
 endif
+
+if GLOM_ENABLE_SQLITE
+libconnectionpool_backends_la_SOURCES += \
+	sqlite.h sqlite.cc
+endif

Modified: trunk/glom/libglom/connectionpool_backends/sqlite.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/sqlite.h	(original)
+++ trunk/glom/libglom/connectionpool_backends/sqlite.h	Tue Feb 24 11:43:12 2009
@@ -24,7 +24,11 @@
 #include <libgdamm.h>
 #include <glom/libglom/connectionpool.h>
 
-#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
+#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
+
+#ifndef GLOM_ENABLE_SQLITE
+# error <sqlite.h> has been included even though sqlite support is disabled
+#endif
 
 namespace Glom
 {

Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc	(original)
+++ trunk/glom/libglom/document/document_glom.cc	Tue Feb 24 11:43:12 2009
@@ -288,9 +288,11 @@
       case POSTGRES_CENTRAL_HOSTED:
         datadir = parent;
         break;
+#ifdef GLOM_ENABLE_SQLITE
       case SQLITE_HOSTED:
         datadir = parent;
         break;
+#endif
       default:
         g_assert_not_reached();
         break;
@@ -2327,10 +2329,15 @@
             mode = POSTGRES_CENTRAL_HOSTED;
           else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF)
             mode = POSTGRES_SELF_HOSTED;
+#ifdef GLOM_ENABLE_SQLITE
           else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE)
             mode = SQLITE_HOSTED;
+#endif
           else
-            mode = POSTGRES_CENTRAL_HOSTED; // Default
+	  {
+            std::cerr << "Document_Glom::load_after(): Hosting mode " << attr_mode << " is not supported" << std::endl;
+            return false; //TODO: Provide more information so the application (or Bakery) can say exactly why loading failed.
+	  }
         }
 
 #ifdef GLOM_ENABLE_CLIENT_ONLY
@@ -2339,9 +2346,8 @@
           std::cerr << "Document_Glom::load_after(): Loading failed because the document needs to be self-hosted, but self-hosting is not supported in client only mode" << std::endl;
           return false; //TODO: Provide more information so the application (or Bakery) can say exactly why loading failed.
         }
-#else
-        m_hosting_mode = mode;
 #endif
+        m_hosting_mode = mode;
       }
 
       //Tables:
@@ -3182,9 +3188,11 @@
     case POSTGRES_SELF_HOSTED:
       set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF);
       break;
+#ifdef GLOM_ENABLE_SQLITE
     case SQLITE_HOSTED:
       set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE);
       break;
+#endif
     default:
       g_assert_not_reached();
       break;

Modified: trunk/glom/libglom/document/document_glom.h
==============================================================================
--- trunk/glom/libglom/document/document_glom.h	(original)
+++ trunk/glom/libglom/document/document_glom.h	Tue Feb 24 11:43:12 2009
@@ -21,7 +21,7 @@
 #ifndef DOCUMENT_GLOM_H
 #define DOCUMENT_GLOM_H
 
-#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
+#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
 
 #include <bakery/Document/Document_XML.h>
 #include <bakery/View/View_Composite.h>
@@ -114,7 +114,9 @@
   {
     POSTGRES_CENTRAL_HOSTED, /*!< The database is hosted on an external postgresql server. */
     POSTGRES_SELF_HOSTED, /*!< A new postgres database process is spawned that hosts the data. */
+#ifdef GLOM_ENABLE_SQLITE
     SQLITE_HOSTED /*!< A sqlite database file is used. */
+#endif // GLOM_ENABLE_SQLITE
   };
 
   /** Set the hosting mode of the database.

Modified: trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc	(original)
+++ trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc	Tue Feb 24 11:43:12 2009
@@ -22,7 +22,6 @@
 #include "glom_db_treemodel.h"
 
 #include <glom/libglom/connectionpool.h>
-#include <glom/libglom/connectionpool_backends/sqlite.h> //For checking whether we are using SQLite or not
 #include <glom/libglom/data_structure/glomconversions.h> //For util_build_sql
 #include <glom/libglom/utils.h>
 

Modified: trunk/glom/utility_widgets/filechooserdialog_saveextras.cc
==============================================================================
--- trunk/glom/utility_widgets/filechooserdialog_saveextras.cc	(original)
+++ trunk/glom/utility_widgets/filechooserdialog_saveextras.cc	Tue Feb 24 11:43:12 2009
@@ -110,11 +110,14 @@
   vbox->pack_start(m_radiobutton_server_postgres_central);
   m_radiobutton_server_postgres_central.show();
 
+#ifdef GLOM_ENABLE_SQLITE
   m_radiobutton_server_sqlite.set_label(_("Create SQLite database in its own folder, to be hosted by this computer."));
   m_radiobutton_server_sqlite.set_tooltip_text(_("SQLite is more light-weight than postgresql, but it does not support authentication or remote access."));
   m_radiobutton_server_sqlite.set_group(group);
   vbox->pack_start(m_radiobutton_server_sqlite);
   m_radiobutton_server_sqlite.show();
+#endif // GLOM_ENABLE_SQLITE
+
   m_radiobutton_server_postgres_selfhosted.set_active(true); // Default
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
@@ -140,9 +143,11 @@
   case Document_Glom::POSTGRES_SELF_HOSTED:
     m_radiobutton_server_postgres_selfhosted.set_active();
     break;
+#ifdef GLOM_ENABLE_SQLITE
   case Document_Glom::SQLITE_HOSTED:
     m_radiobutton_server_sqlite.set_active();
     break;
+#endif
   default:
     g_assert_not_reached();
     break;
@@ -160,8 +165,12 @@
     return Document_Glom::POSTGRES_CENTRAL_HOSTED;
   else if(m_radiobutton_server_postgres_selfhosted.get_active())
     return Document_Glom::POSTGRES_SELF_HOSTED;
-  else
+#ifdef GLOM_ENABLE_SQLITE
+  else if(m_radiobutton_server_sqlite.get_active())
     return Document_Glom::SQLITE_HOSTED;
+#endif
+  else
+    g_assert_not_reached();
 }
 
 } //namespace Glom

Modified: trunk/glom/utility_widgets/filechooserdialog_saveextras.h
==============================================================================
--- trunk/glom/utility_widgets/filechooserdialog_saveextras.h	(original)
+++ trunk/glom/utility_widgets/filechooserdialog_saveextras.h	Tue Feb 24 11:43:12 2009
@@ -21,6 +21,8 @@
 #ifndef GLOM_UTILITY_WIDGETS_FILECHOOSERDIALOG_SAVEEXTRAS_H
 #define GLOM_UTILITY_WIDGETS_FILECHOOSERDIALOG_SAVEEXTRAS_H
 
+#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY, GLOM_ENABLE_SQLITE
+
 #include <glom/libglom/document/document_glom.h>
 
 #include <gtkmm/filechooserdialog.h>
@@ -30,8 +32,6 @@
 #include <gtkmm/entry.h>
 #include <gtkmm/radiobutton.h>
 
-#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
-
 namespace Glom
 {
 
@@ -68,7 +68,11 @@
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   Gtk::RadioButton m_radiobutton_server_postgres_central;
   Gtk::RadioButton m_radiobutton_server_postgres_selfhosted;
+
+#ifdef GLOM_ENABLE_SQLITE
   Gtk::RadioButton m_radiobutton_server_sqlite;
+#endif // GLOM_ENABLE_SQLITE
+
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]