glom r1943 - in trunk: . glom glom/libglom glom/libglom/connectionpool_backends glom/libglom/data_structure glom/libglom/document glom/utility_widgets
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1943 - in trunk: . glom glom/libglom glom/libglom/connectionpool_backends glom/libglom/data_structure glom/libglom/document glom/utility_widgets
- Date: Mon, 2 Mar 2009 13:49:02 +0000 (UTC)
Author: murrayc
Date: Mon Mar 2 13:49:02 2009
New Revision: 1943
URL: http://svn.gnome.org/viewvc/glom?rev=1943&view=rev
Log:
2009-03-02 Murray Cumming <murrayc murrayc com>
* configure.in: Added an --enable-postgresql option, so we can have
embedded builds that only use SQLite. Disable SQLite by default.
* glom/utility_widgets/filechooserdialog_saveextras.[h|cc]:
Don't mention the backend names if only SQLite is disabled, to avoid
confronting people with unnecessary technicalese.
* glom/application.cc:
* glom/dialog_connection.cc:
* glom/frame_glom.cc:
* glom/libglom/connectionpool_backends/Makefile.am:
* glom/libglom/connectionpool_backends/postgres.h:
* glom/libglom/connectionpool_backends/postgres_central.[h|cc]:
* glom/libglom/connectionpool_backends/sqlite.h:
* glom/libglom/data_structure/glomconversions.h:
* glom/libglom/document/document_glom.[h|cc]:
* glom/libglom/gst-package.c:
* glom/libglom/test_connectionpool.cc:
* glom/main.cc:
Added ifdefs to allow builds with -enable-postgresql=no.
* glom/dialog_import_csv.cc: Replace gettext() with _().
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/glom/application.cc
trunk/glom/dialog_connection.cc
trunk/glom/dialog_import_csv.cc
trunk/glom/frame_glom.cc
trunk/glom/libglom/connectionpool_backends/Makefile.am
trunk/glom/libglom/connectionpool_backends/postgres.h
trunk/glom/libglom/connectionpool_backends/postgres_central.cc
trunk/glom/libglom/connectionpool_backends/postgres_central.h
trunk/glom/libglom/connectionpool_backends/sqlite.h
trunk/glom/libglom/data_structure/glomconversions.h
trunk/glom/libglom/document/document_glom.cc
trunk/glom/libglom/document/document_glom.h
trunk/glom/libglom/gst-package.c
trunk/glom/libglom/test_connectionpool.cc
trunk/glom/main.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 Mon Mar 2 13:49:02 2009
@@ -79,23 +79,38 @@
enable_client_only="yes"
fi
+
AM_CONDITIONAL(GLOM_ENABLE_CLIENT_ONLY, test "$enable_client_only" = "yes")
if test "$enable_client_only" = "yes"; then
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]]),
+ [Allow creation of SQLite databases and opening of documents using SQLite databases. This disables some functionality and is intended only for embedded use. [default=no]]),
[enable_sqlite=$enableval],
- [enable_sqlite=yes])
+ [enable_sqlite=no])
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])
+ AC_DEFINE([GLOM_ENABLE_SQLITE], 1, [Whether to enable support for SQLite databases.])
fi
+
+AC_ARG_ENABLE([postgresql],
+ AC_HELP_STRING([--enable-postgresql],
+ [Allow creation of PostgreSQL databases and opening of documents using PostgreSQL databases. [default=yes]]),
+ [enable_postgresql=$enableval],
+ [enable_postgresql=yes])
+
+AM_CONDITIONAL(GLOM_ENABLE_POSTGRESQL, test "$enable_postgresql" = "yes")
+if test "$enable_postgresql" = "yes"; then
+ AC_DEFINE([GLOM_ENABLE_POSTGRESQL], 1, [Whether to enable support for PostgreSQL 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.12 libgda-4.0 >= 3.99.12 libgda-postgres-4.0 goocanvasmm-1.0 >= 0.13.0"
if test $enable_client_only != yes; then
Modified: trunk/glom/application.cc
==============================================================================
--- trunk/glom/application.cc (original)
+++ trunk/glom/application.cc Mon Mar 2 13:49:02 2009
@@ -34,8 +34,8 @@
#include <glom/libglom/utils.h>
#include <glom/libglom/glade_utils.h>
-#include <glom/libglom/connectionpool_backends/postgres_central.h>
-#include <glom/libglom/connectionpool_backends/postgres_self.h>
+//#include <glom/libglom/connectionpool_backends/postgres_central.h>
+//#include <glom/libglom/connectionpool_backends/postgres_self.h>
#include <cstdio>
#include <memory> //For std::auto_ptr<>
@@ -113,7 +113,13 @@
m_menu_print_layouts_ui_merge_id(0),
#ifndef GLOM_ENABLE_CLIENT_ONLY
m_ui_save_extra_showextras(false),
+
+#ifdef GLOM_ENABLE_POSTGRESQL
m_ui_save_extra_newdb_hosting_mode(Document_Glom::POSTGRES_CENTRAL_HOSTED),
+#else
+ m_ui_save_extra_newdb_hosting_mode(Document_Glom::SQLITE_HOSTED),
+#endif //GLOM_ENABLE_POSTGRESQL
+
#endif // !GLOM_ENABLE_CLIENT_ONLY
m_show_sql_debug(false)
{
@@ -707,9 +713,11 @@
{
// Connection is always remote-hosted in client only mode:
#ifndef GLOM_ENABLE_CLIENT_ONLY
+#ifdef GLOM_ENABLE_POSTGRESQL
//Stop the document from being self-hosted (it's already hosted by the other networked Glom instance):
if(document_temp.get_hosting_mode() == Document_Glom::POSTGRES_SELF_HOSTED)
document_temp.set_hosting_mode(Document_Glom::POSTGRES_CENTRAL_HOSTED);
+#endif //GLOM_ENABLE_POSTGRESQL
#endif // !GLOM_ENABLE_CLIENT_ONLY
// TODO: Error out in case this is a sqlite database, since we probably
// can't access it from this host?
@@ -935,7 +943,8 @@
m_ui_save_extra_title = _("Creating From Example File");
m_ui_save_extra_message = _("To use this example file you must save an editable copy of the file. A new database will also be created on the server.");
m_ui_save_extra_newdb_title = "TODO";
- m_ui_save_extra_newdb_hosting_mode = Document_Glom::POSTGRES_SELF_HOSTED;
+ m_ui_save_extra_newdb_hosting_mode = Document_Glom::DEFAULT_HOSTED;
+
// Reinit cancelled state
set_operation_cancelled(false);
@@ -951,7 +960,7 @@
//Get the results from the extended save dialog:
pDocument->set_database_title(m_ui_save_extra_newdb_title);
pDocument->set_hosting_mode(m_ui_save_extra_newdb_hosting_mode);
- m_ui_save_extra_newdb_hosting_mode = Document_Glom::POSTGRES_CENTRAL_HOSTED;
+ m_ui_save_extra_newdb_hosting_mode = Document_Glom::DEFAULT_HOSTED;
pDocument->set_is_example_file(false);
// We have a valid uri, so we can set it to !new and modified here
}
@@ -1256,7 +1265,7 @@
Glib::ustring db_title;
m_ui_save_extra_showextras = true; //Offer self-hosting or central hosting, and offer the database title.
- m_ui_save_extra_newdb_hosting_mode = Document_Glom::POSTGRES_SELF_HOSTED; /* Default to self-hosting */
+ m_ui_save_extra_newdb_hosting_mode = Document_Glom::DEFAULT_HOSTED; /* Default to self-hosting */
m_ui_save_extra_newdb_title.clear();
offer_saveas();
@@ -1268,13 +1277,13 @@
const Glib::ustring db_title = m_ui_save_extra_newdb_title;
Document_Glom::HostingMode hosting_mode = m_ui_save_extra_newdb_hosting_mode;
m_ui_save_extra_newdb_title.clear();
- m_ui_save_extra_newdb_hosting_mode = Document_Glom::POSTGRES_CENTRAL_HOSTED;
+ m_ui_save_extra_newdb_hosting_mode = Document_Glom::DEFAULT_HOSTED;
//Make sure that the user can do something with his new document:
document->set_userlevel(AppState::USERLEVEL_DEVELOPER);
// Try various ports if connecting to an existing database server instead
// of self-hosting one:
- document->set_connection_try_other_ports(m_ui_save_extra_newdb_hosting_mode == Document_Glom::POSTGRES_CENTRAL_HOSTED);
+ document->set_connection_try_other_ports(m_ui_save_extra_newdb_hosting_mode == Document_Glom::DEFAULT_HOSTED);
//Each new document must have an associated new database,
//so choose a name
@@ -1901,7 +1910,7 @@
m_ui_save_extra_title.clear();
m_ui_save_extra_message.clear();
m_ui_save_extra_newdb_title.clear();
- m_ui_save_extra_newdb_hosting_mode = Document_Glom::POSTGRES_CENTRAL_HOSTED;
+ m_ui_save_extra_newdb_hosting_mode = Document_Glom::DEFAULT_HOSTED;
Glib::ustring file_uri = ui_file_select_save(file_uriOld); //Also asks for overwrite confirmation.
if(!file_uri.empty())
@@ -2075,7 +2084,7 @@
//Create the appropriate dialog, depending on how the caller set m_ui_save_extra_showextras:
if(m_ui_save_extra_showextras)
{
- fileChooser_SaveExtras = new Glom::FileChooserDialog_SaveExtras(gettext("Save Document"), Gtk::FILE_CHOOSER_ACTION_SAVE);
+ fileChooser_SaveExtras = new Glom::FileChooserDialog_SaveExtras(_("Save Document"), Gtk::FILE_CHOOSER_ACTION_SAVE);
fileChooser_Save.reset(fileChooser_SaveExtras);
}
else
@@ -2182,7 +2191,7 @@
if(!uri_is_writable(file))
{
//Warn the user:
- ui_warning(gettext("Read-only File."), gettext("You may not overwrite the existing file, because you do not have sufficient access rights."));
+ ui_warning(gettext("Read-only File."), _("You may not overwrite the existing file, because you do not have sufficient access rights."));
try_again = true; //Try again.
continue;
}
@@ -2196,7 +2205,7 @@
if(!uri_is_writable(parent))
{
//Warn the user:
- ui_warning(gettext("Read-only Directory."), gettext("You may not create a file in this directory, because you do not have sufficient access rights."));
+ ui_warning(gettext("Read-only Directory."), _("You may not create a file in this directory, because you do not have sufficient access rights."));
try_again = true; //Try again.
continue;
}
@@ -2221,8 +2230,12 @@
}
bool is_self_hosted = false;
+
+#ifdef GLOM_ENABLE_POSTGRESQL
if(m_ui_save_extra_newdb_hosting_mode == Document_Glom::POSTGRES_SELF_HOSTED)
is_self_hosted = true;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
if(m_ui_save_extra_newdb_hosting_mode == Document_Glom::SQLITE_HOSTED)
is_self_hosted = true;
Modified: trunk/glom/dialog_connection.cc
==============================================================================
--- trunk/glom/dialog_connection.cc (original)
+++ trunk/glom/dialog_connection.cc Mon Mar 2 13:49:02 2009
@@ -23,8 +23,11 @@
#include <glibmm/i18n.h>
#include <glom/libglom/connectionpool.h>
+
+#ifdef GLOM_ENABLE_POSTGRESQL
#include <glom/libglom/connectionpool_backends/postgres_central.h>
#include <glom/libglom/connectionpool_backends/postgres_self.h>
+#endif //#ifdef GLOM_ENABLE_POSTGRESQL
namespace Glom
{
@@ -90,6 +93,7 @@
//std::cout << "debug: Dialog_Connection::connect_to_server_with_connection_settings(): m_database_name=" << m_database_name << std::endl;
connection_pool->set_database(m_database_name);
+#ifdef GLOM_ENABLE_POSTGRESQL
if(document->get_hosting_mode() == Document_Glom::POSTGRES_CENTRAL_HOSTED)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
@@ -98,7 +102,8 @@
central->set_host(m_entry_host->get_text());
}
-
+#endif //GLOM_ENABLE_POSTGRESQL
+
connection_pool->set_user(m_entry_user->get_text());
connection_pool->set_password(m_entry_password->get_text());
@@ -115,12 +120,14 @@
result = Base_DB::connect_to_server(const_cast<Dialog_Connection*>(this), error);
#endif
+#ifdef GLOM_ENABLE_POSTGRESQL
if(document)
{
//Remember the port,
//to make opening faster next time,
//and so we can tell connecting clients (using browse network) what port to use:
Document_Glom* unconst = const_cast<Document_Glom*>(document);
+
if(document->get_hosting_mode() == Document_Glom::POSTGRES_CENTRAL_HOSTED)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
@@ -129,6 +136,7 @@
unconst->set_connection_port(central->get_port() );
}
+
#ifndef GLOM_ENABLE_CLIENT_ONLY
else if(document->get_hosting_mode() == Document_Glom::POSTGRES_SELF_HOSTED)
{
@@ -138,8 +146,9 @@
unconst->set_connection_port(self->get_port() );
}
-#endif
+#endif //GLOM_ENABLE_CLIENT_ONLY
}
+#endif //GLOM_ENABLE_POSTGRESQL
/*
if(document)
@@ -161,6 +170,7 @@
if(document)
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
+#ifdef GLOM_ENABLE_POSTGRESQL
//Load server and user:
if(document->get_hosting_mode() != Document_Glom::POSTGRES_CENTRAL_HOSTED)
{
@@ -168,6 +178,7 @@
m_entry_host->set_sensitive(false);
}
else
+#endif // LOM_ENABLE_POSTGRESQL
#endif // !GLOM_ENABLE_CLIENT_ONLY
{
Glib::ustring host = document->get_connection_server();
Modified: trunk/glom/dialog_import_csv.cc
==============================================================================
--- trunk/glom/dialog_import_csv.cc (original)
+++ trunk/glom/dialog_import_csv.cc Mon Mar 2 13:49:02 2009
@@ -258,7 +258,7 @@
iter = m_encoding_model->append();
if(ENCODINGS[i].name != NULL)
{
- (*iter)[m_encoding_columns.m_col_name] = gettext(ENCODINGS[i].name);
+ (*iter)[m_encoding_columns.m_col_name] = _(ENCODINGS[i].name);
(*iter)[m_encoding_columns.m_col_charset] = ENCODINGS[i].charset;
}
}
Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc (original)
+++ trunk/glom/frame_glom.cc Mon Mar 2 13:49:02 2009
@@ -27,8 +27,11 @@
#include <glom/libglom/appstate.h>
#include <glom/libglom/connectionpool.h>
+
+#ifdef GLOM_ENABLE_POSTGRESQL
#include <glom/libglom/connectionpool_backends/postgres_central.h>
#include <glom/libglom/connectionpool_backends/postgres_self.h>
+#endif
#ifdef GLOM_ENABLE_SQLITE
# include <glom/libglom/connectionpool_backends/sqlite.h>
@@ -1643,6 +1646,8 @@
ConnectionPool* connection_pool = ConnectionPool::get_instance();
switch(document->get_hosting_mode())
{
+#ifdef GLOM_ENABLE_POSTGRESQL
+
#ifndef GLOM_ENABLE_CLIENT_ONLY
case Document_Glom::POSTGRES_SELF_HOSTED:
{
@@ -1652,6 +1657,7 @@
}
break;
#endif //GLOM_ENABLE_CLIENT_ONLY
+
case Document_Glom::POSTGRES_CENTRAL_HOSTED:
{
ConnectionPoolBackends::PostgresCentralHosted* backend = new ConnectionPoolBackends::PostgresCentralHosted;
@@ -1660,8 +1666,9 @@
backend->set_try_other_ports(document->get_connection_try_other_ports());
connection_pool->set_backend(std::auto_ptr<ConnectionPool::Backend>(backend));
}
-
break;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
case Document_Glom::SQLITE_HOSTED:
{
@@ -1671,6 +1678,7 @@
}
break;
#endif // GLOM_ENABLE_SQLITE
+
default:
g_assert_not_reached();
break;
@@ -1701,7 +1709,7 @@
//Ask either for the existing username and password to use an existing database server,
//or ask for a new username and password to specify when creating a new self-hosted database.
- int response = 0;
+#ifdef GLOM_ENABLE_POSTGRESQL
if(document->get_hosting_mode() == Document_Glom::POSTGRES_SELF_HOSTED)
{
#ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -1726,7 +1734,7 @@
std::cerr << error->what() << std::endl;
return false;
}
-#endif
+#endif //GLIBMM_EXCEPTIONS_ENABLED
refXml->get_widget_derived("dialog_new_self_hosted_connection", dialog);
if(!dialog) return false;
@@ -1734,7 +1742,7 @@
add_view(dialog);
- response = Gtk::RESPONSE_OK;
+ int response = Gtk::RESPONSE_OK;
bool keep_trying = true;
while(keep_trying)
{
@@ -1785,7 +1793,7 @@
//Ask for connection details:
m_pDialogConnection->load_from_document(); //Get good defaults.
m_pDialogConnection->set_transient_for(*get_app_window());
- response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
+ int response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
m_pDialogConnection->hide();
if(response == Gtk::RESPONSE_OK)
@@ -1802,6 +1810,9 @@
}
}
else
+#endif //GLOM_ENABLE_POSTGRESQL
+#ifdef GLOM_ENABLE_SQLITE
+ if(document->get_hosting_mode() == Document_Glom::SQLITE_HOSTED)
{
// sqlite
if(!connection_pool->initialize(get_app_window()))
@@ -1810,6 +1821,7 @@
m_pDialogConnection->load_from_document(); //Get good defaults.
// No authentication required
}
+#endif //GLOM_ENABLE_SQLITE
// Do startup, such as starting the self-hosting database server
if(!connection_pool->startup(get_app_window()))
@@ -1872,6 +1884,7 @@
document->set_connection_database(database_name_possible);
// Remember host if the document is not self hosted
+ #ifdef GLOM_ENABLE_POSTGRESQL
if(document->get_hosting_mode() == Document_Glom::POSTGRES_CENTRAL_HOSTED)
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
@@ -1894,6 +1907,7 @@
document->set_connection_port(self->get_port());
}
+ #endif //sGLOM_ENABLE_POSTGRESQL
return true;
}
@@ -1939,6 +1953,7 @@
//Only show the dialog if we don't know the correct username/password yet:
int response = Gtk::RESPONSE_OK;
+
// Don't ask for user/password for sqlite databases, since sqlite does
// not support authentication. I'd prefer to get that information from
// libgda, but gda_connection_supports_feature() requires a GdaConnection
Modified: trunk/glom/libglom/connectionpool_backends/Makefile.am
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/Makefile.am (original)
+++ trunk/glom/libglom/connectionpool_backends/Makefile.am Mon Mar 2 13:49:02 2009
@@ -4,7 +4,11 @@
noinst_LTLIBRARIES = libconnectionpool_backends.la
libconnectionpool_backends_la_SOURCES = \
- backend.h backend.cc \
+ backend.h backend.cc
+
+
+if GLOM_ENABLE_POSTGRESQL
+libconnectionpool_backends_la_SOURCES += \
postgres.h postgres.cc \
postgres_central.h postgres_central.cc
@@ -13,6 +17,9 @@
postgres_self.h postgres_self.cc
endif
+endif
+
+
if GLOM_ENABLE_SQLITE
libconnectionpool_backends_la_SOURCES += \
sqlite.h sqlite.cc
Modified: trunk/glom/libglom/connectionpool_backends/postgres.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres.h (original)
+++ trunk/glom/libglom/connectionpool_backends/postgres.h Mon Mar 2 13:49:02 2009
@@ -26,6 +26,10 @@
#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
+#ifndef GLOM_ENABLE_POSTGRESQL
+# error The Glom <postgres.h> backend has been included even though PostgreSQL support is disabled
+#endif
+
namespace Glom
{
Modified: trunk/glom/libglom/connectionpool_backends/postgres_central.cc
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres_central.cc (original)
+++ trunk/glom/libglom/connectionpool_backends/postgres_central.cc Mon Mar 2 13:49:02 2009
@@ -58,7 +58,7 @@
m_list_ports.push_back("5433"); //Ubuntu Dapper seems to default to this for Postgres 8.1, probably to avoid a clash with Postgres 7.4
- m_list_ports.push_back("5434"); //Earlier versions of Ubuntu Feistry defaulted to this for Postgres 8.2.
+ m_list_ports.push_back("5434"); //Earlier versions of Ubuntu Feisty defaulted to this for Postgres 8.2.
m_list_ports.push_back("5435"); //In case Ubuntu increases the port number again in future.
m_list_ports.push_back("5436"); //In case Ubuntu increases the port number again in future.
}
Modified: trunk/glom/libglom/connectionpool_backends/postgres_central.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres_central.h (original)
+++ trunk/glom/libglom/connectionpool_backends/postgres_central.h Mon Mar 2 13:49:02 2009
@@ -25,6 +25,10 @@
#include "config.h" // For GLOM_ENABLE_CLIENT_ONLY
+#ifndef GLOM_ENABLE_POSTGRESQL
+# error The Glom <postgres_central.h> backend has been included even though PostgreSQL support is disabled
+#endif
+
namespace Glom
{
Modified: trunk/glom/libglom/connectionpool_backends/sqlite.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/sqlite.h (original)
+++ trunk/glom/libglom/connectionpool_backends/sqlite.h Mon Mar 2 13:49:02 2009
@@ -27,7 +27,7 @@
#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
+# error The Glom <sqlite.h> backend has been included even though sqlite support is disabled
#endif
namespace Glom
Modified: trunk/glom/libglom/data_structure/glomconversions.h
==============================================================================
--- trunk/glom/libglom/data_structure/glomconversions.h (original)
+++ trunk/glom/libglom/data_structure/glomconversions.h Mon Mar 2 13:49:02 2009
@@ -86,11 +86,6 @@
Glib::RefPtr<Gdk::Pixbuf> get_pixbuf_for_gda_value(const Gnome::Gda::Value& value);
}
-//Copied from Postgres's PQunescapeBytea() so I don't have the trouble of finding and linking to the
-//postgres libraries directly, without the benefit of a pkg-config .pc file. murrayc.
-unsigned char *
-Glom_PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen);
-
} //namespace Glom
#endif //GLOM_DATASTRUCTURE_GLOMCONVERSIONS_H
Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc (original)
+++ trunk/glom/libglom/document/document_glom.cc Mon Mar 2 13:49:02 2009
@@ -208,7 +208,7 @@
Document_Glom::Document_Glom()
:
- m_hosting_mode(POSTGRES_CENTRAL_HOSTED),
+ m_hosting_mode(DEFAULT_HOSTED),
m_connection_port(0),
m_connection_try_other_ports(false),
m_block_cache_update(false),
@@ -282,17 +282,20 @@
{
switch(m_hosting_mode)
{
+#ifdef GLOM_ENABLE_POSTGRESQL
case POSTGRES_SELF_HOSTED:
datadir = parent->get_child("glom_postgres_data");
break;
case POSTGRES_CENTRAL_HOSTED:
datadir = parent;
break;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
case SQLITE_HOSTED:
datadir = parent;
break;
-#endif
+#endif //GLOM_ENABLE_SQLITE
default:
g_assert_not_reached();
break;
@@ -2313,26 +2316,32 @@
m_connection_user = get_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_USER);
m_connection_database = get_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_DATABASE);
- Glib::ustring attr_mode = get_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE);
- HostingMode mode;
+ const Glib::ustring attr_mode = get_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE);
+
+ HostingMode mode = DEFAULT_HOSTED;
if(attr_mode.empty())
{
+#ifdef GLOM_ENABLE_POSTGRESQL
// If no hosting mode is set, then try the self_hosted flag which
// was used before sqlite support was implemented.
const bool self_hosted = get_node_attribute_value_as_bool(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_SELF_HOSTED);
mode = self_hosted ? POSTGRES_SELF_HOSTED : POSTGRES_CENTRAL_HOSTED;
+#endif //GLOM_ENABLE_POSTGRESQL
}
else
{
+#ifdef GLOM_ENABLE_POSTGRESQL
if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_CENTRAL)
mode = POSTGRES_CENTRAL_HOSTED;
else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF)
mode = POSTGRES_SELF_HOSTED;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
- else if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE)
+ if(attr_mode == GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE)
mode = SQLITE_HOSTED;
-#endif
+#endif //GLOM_ENABLE_SQLITE
else
{
std::cerr << "Document_Glom::load_after(): Hosting mode " << attr_mode << " is not supported" << std::endl;
@@ -3182,12 +3191,15 @@
switch(m_hosting_mode)
{
+#ifdef GLOM_ENABLE_POSTGRESQL
case POSTGRES_CENTRAL_HOSTED:
set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_CENTRAL);
break;
case POSTGRES_SELF_HOSTED:
set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_POSTGRES_SELF);
break;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
case SQLITE_HOSTED:
set_node_attribute_value(nodeConnection, GLOM_ATTRIBUTE_CONNECTION_HOSTING_MODE, GLOM_ATTRIBUTE_CONNECTION_HOSTING_SQLITE);
Modified: trunk/glom/libglom/document/document_glom.h
==============================================================================
--- trunk/glom/libglom/document/document_glom.h (original)
+++ trunk/glom/libglom/document/document_glom.h Mon Mar 2 13:49:02 2009
@@ -110,13 +110,23 @@
static guint get_latest_known_document_format_version();
+ //TODO: Use a prefix instead of a suffix for these enum names:
enum HostingMode
{
+#ifdef GLOM_ENABLE_POSTGRESQL
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. */
+#endif //GLOM_ENABLE_POSTGRESQL
#ifdef GLOM_ENABLE_SQLITE
- SQLITE_HOSTED /*!< A sqlite database file is used. */
+ SQLITE_HOSTED, /*!< A sqlite database file is used. */
#endif // GLOM_ENABLE_SQLITE
+
+ //This reduces the ifdefs elsewhere:
+#ifdef GLOM_ENABLE_POSTGRESQL
+ DEFAULT_HOSTED = POSTGRES_CENTRAL_HOSTED
+#else
+ DEFAULT_HOSTED = SQLITE_HOSTED
+#endif
};
/** Set the hosting mode of the database.
Modified: trunk/glom/libglom/gst-package.c
==============================================================================
--- trunk/glom/libglom/gst-package.c (original)
+++ trunk/glom/libglom/gst-package.c Mon Mar 2 13:49:02 2009
@@ -21,6 +21,7 @@
* Carlos Garnacho <carlosg gnome org>
*/
+//TODO: Use PackageKit? Is that recommended on all major distros now?
/* Commented-out because this is only useful when
* using the example code while patching
* ConnectionPoolBackends::PostgresSelf::install_postgres().
Modified: trunk/glom/libglom/test_connectionpool.cc
==============================================================================
--- trunk/glom/libglom/test_connectionpool.cc (original)
+++ trunk/glom/libglom/test_connectionpool.cc Mon Mar 2 13:49:02 2009
@@ -20,7 +20,12 @@
#include <libgdamm/init.h>
#include <glom/libglom/connectionpool.h>
+
+#ifdef GLOM_ENABLE_POSTGRESQL
#include <glom/libglom/connectionpool_backends/postgres_central.h>
+#else
+#include <glom/libglom/connectionpool_backends/sqlite.h>
+#endif //#GLOM_ENABLE_POSTGRESQL
int
@@ -42,10 +47,14 @@
connection_pool->set_user("murrayc");
connection_pool->set_password("murraycpw");
+#ifdef GLOM_ENABLE_POSTGRESQL
Glom::ConnectionPoolBackends::PostgresCentralHosted* backend = new Glom::ConnectionPoolBackends::PostgresCentralHosted;
backend->set_host("localhost");
backend->set_port(5433);
backend->set_try_other_ports(false);
+#else
+ Glom::ConnectionPoolBackends::Sqlite* backend = new Glom::ConnectionPoolBackends::Sqlite;
+#endif //GLOM_ENABLE_POSTGRESQL
connection_pool->set_backend(std::auto_ptr<Glom::ConnectionPool::Backend>(backend));
connection_pool->set_ready_to_connect(); //Box_WithButtons::connect_to_server() will now attempt the connection-> Shared instances of m_Connection will also be usable.
Modified: trunk/glom/main.cc
==============================================================================
--- trunk/glom/main.cc (original)
+++ trunk/glom/main.cc Mon Mar 2 13:49:02 2009
@@ -28,8 +28,12 @@
#include <giomm.h>
// For postgres availability checks:
+#ifdef GLOM_ENABLE_POSTGRESQL
#include <glom/libglom/connectionpool_backends/postgres.h>
+#ifndef GLOM_ENABLE_CLIENT_ONLY
#include <glom/libglom/connectionpool_backends/postgres_self.h>
+#endif //GLOM_ENABLE_CLIENT_ONLY
+#endif //GLOM_ENABLE_POSTGRESQL
// For sanity checks:
#include <glom/libglom/data_structure/glomconversions.h> // For GLOM_IMAGE_FORMAT
@@ -254,6 +258,7 @@
//debugging:
//input_uri = "file:///home/murrayc/cvs/gnome212/glom/examples/example_smallbusiness.glom";
+#ifdef GLOM_ENABLE_POSTGRESQL
bool install_complete = false;
#ifndef GLOM_ENABLE_CLIENT_ONLY
//Check that PostgreSQL is really available:
@@ -271,6 +276,7 @@
// So just prevent this in general. It is safer anyway.
if(!Glom::ConnectionPool::check_user_is_not_root())
return -1;
+#endif //GLOM_ENABLE_POSTGRESQL
// Some more sanity checking:
Modified: trunk/glom/utility_widgets/filechooserdialog_saveextras.cc
==============================================================================
--- trunk/glom/utility_widgets/filechooserdialog_saveextras.cc (original)
+++ trunk/glom/utility_widgets/filechooserdialog_saveextras.cc Mon Mar 2 13:49:02 2009
@@ -99,26 +99,59 @@
box_label->show();
vbox->pack_start(*box_label);
+
#ifndef GLOM_ENABLE_CLIENT_ONLY
- m_radiobutton_server_postgres_selfhosted.set_label(_("Create postgresql database in its own folder, to be hosted by this computer."));
+
+#ifdef GLOM_ENABLE_SQLITE
+
+#ifdef GLOM_ENABLE_POSTGRESQL
+ //Use titles that show the distinction between PostgreSQL and SQLite:
+ m_radiobutton_server_postgres_selfhosted.set_label(_("Create PostgreSQL database in its own folder, to be hosted by this computer."));
vbox->pack_start(m_radiobutton_server_postgres_selfhosted);
m_radiobutton_server_postgres_selfhosted.show();
- m_radiobutton_server_postgres_central.set_label(_("Create database on an external postgresql database server, to be specified in the next step."));
+ m_radiobutton_server_postgres_central.set_label(_("Create database on an external PostgreSQL database server, to be specified in the next step."));
Gtk::RadioButton::Group group = m_radiobutton_server_postgres_selfhosted.get_group();
m_radiobutton_server_postgres_central.set_group(group);
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_tooltip_text(_("SQLite does not support authentication or remote access but is suitable for embedded devices."));
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
+#else
+ //Only SQLite:
+ std::cerr << "WARNING: Glom was built with developer mode (not client-only) but with only support for SQLite. This is very unusual. Postgres is the default backend so it should not be hidden from developers." << std::endl;
+ //TODO: Hide this because it's the only radio button, so it's not a choice:
+ m_radiobutton_server_sqlite.set_label(_("Create database in its own folder, to be hosted by this computer, using SQLite"));
+ //m_radiobutton_server_sqlite.set_group(group);
+ vbox->pack_start(m_radiobutton_server_sqlite);
+ m_radiobutton_server_sqlite.show();
+#endif // GLOM_ENABLE_POSTGRESQL
+
+#else //GLOM_ENABLE_SQLITE
+ //Only PostgreSQL:
+ //Use titles that don't mention the boring name of the backend:
+ m_radiobutton_server_postgres_selfhosted.set_label(_("Create database in its own folder, to be hosted by this computer."));
+ vbox->pack_start(m_radiobutton_server_postgres_selfhosted);
+ m_radiobutton_server_postgres_selfhosted.show();
+
+ m_radiobutton_server_postgres_central.set_label(_("Create database on an external database server, to be specified in the next step."));
+ Gtk::RadioButton::Group group = m_radiobutton_server_postgres_selfhosted.get_group();
+ m_radiobutton_server_postgres_central.set_group(group);
+ vbox->pack_start(m_radiobutton_server_postgres_central);
+ m_radiobutton_server_postgres_central.show();
+
+ m_radiobutton_server_postgres_selfhosted.set_active(true); // Default
+
+#endif //GLOM_ENABLE_SQLITE
+
+
+
#endif // !GLOM_ENABLE_CLIENT_ONLY
@@ -137,17 +170,20 @@
{
switch(mode)
{
+#ifdef GLOM_ENABLE_POSTGRESQL
case Document_Glom::POSTGRES_CENTRAL_HOSTED:
m_radiobutton_server_postgres_central.set_active();
break;
case Document_Glom::POSTGRES_SELF_HOSTED:
m_radiobutton_server_postgres_selfhosted.set_active();
break;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
case Document_Glom::SQLITE_HOSTED:
m_radiobutton_server_sqlite.set_active();
break;
-#endif
+#endif //GLOM_ENABLE_SQLITE
default:
g_assert_not_reached();
break;
@@ -161,16 +197,25 @@
Document_Glom::HostingMode FileChooserDialog_SaveExtras::get_extra_newdb_hosting_mode() const
{
+#ifdef GLOM_ENABLE_POSTGRESQL
if(m_radiobutton_server_postgres_central.get_active())
return Document_Glom::POSTGRES_CENTRAL_HOSTED;
else if(m_radiobutton_server_postgres_selfhosted.get_active())
return Document_Glom::POSTGRES_SELF_HOSTED;
+#endif //GLOM_ENABLE_POSTGRESQL
+
#ifdef GLOM_ENABLE_SQLITE
- else if(m_radiobutton_server_sqlite.get_active())
+ if(m_radiobutton_server_sqlite.get_active())
return Document_Glom::SQLITE_HOSTED;
-#endif
- else
- g_assert_not_reached();
+#endif //GLOM_ENABLE_SQLITE
+
+ g_assert_not_reached();
+
+#ifdef GLOM_ENABLE_SQLITE
+ return Document_Glom::SQLITE_HOSTED; //Arbitrary
+#else
+ return Document_Glom::POSTGRES_SELF_HOSTED; //Arbitrary.
+#endif //GLOM_ENABLE_SQLITE
}
} //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 Mon Mar 2 13:49:02 2009
@@ -66,8 +66,11 @@
/* New database details: */
Gtk::Entry m_entry_title;
#ifndef GLOM_ENABLE_CLIENT_ONLY
+
+#ifdef GLOM_ENABLE_POSTGRESQL
Gtk::RadioButton m_radiobutton_server_postgres_central;
Gtk::RadioButton m_radiobutton_server_postgres_selfhosted;
+#endif // GLOM_ENABLE_POSTGRESQL
#ifdef GLOM_ENABLE_SQLITE
Gtk::RadioButton m_radiobutton_server_sqlite;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]