[glom] Fixed creating a centrally-hosted database from example



commit 3db69751fa81ee7025e5a6cabafcf535e184b496
Author: Armin Burgmeier <armin arbur net>
Date:   Mon Jun 22 20:33:00 2009 +0200

    Fixed creating a centrally-hosted database from example
    
    	* glom/application.cc (on_document_load): If we load an example file,
    	set the connection port in the document to 0, and enable trying other
    	ports, instead of using the (arbitrary) values from the example file.
    	This allows trying out various standard ports for postgresql when
    	centrally-hosting the document and fixed creating a centrally-hosted
    	database from an example file.
    
    	* glom/dialog_connection.cc (connect_to_server_with_connection): On a
    	successful connection, set try other ports to false in the document,
    	as we found a working port and don't need to try all the other ports
    	next time.
    
    	* glom/frame_glom.cc
    	(connection_request_password_and_choose_new_database_name): When
    	creating a centrally-hosted database, remember the user name in the
    	document, to be able to connect to the database from the saved
    	document later. Actually, we would also need to save the password to
    	do this correctly, though I wonder whether it's a good idea to save
    	the user's database password in the .glom file.

 ChangeLog                 |   22 ++++++++++++++++++++++
 glom/application.cc       |    7 +++++++
 glom/dialog_connection.cc |    4 ++++
 glom/frame_glom.cc        |    7 +++++++
 4 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d503a70..1c81437 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2009-06-22  Armin Burgmeier  <armin openismus com>
 
+	* glom/application.cc (on_document_load): If we load an example file,
+	set the connection port in the document to 0, and enable trying other
+	ports, instead of using the (arbitrary) values from the example file.
+	This allows trying out various standard ports for postgresql when
+	centrally-hosting the document and fixed creating a centrally-hosted
+	database from an example file.
+
+	* glom/dialog_connection.cc (connect_to_server_with_connection): On a
+	successful connection, set try other ports to false in the document,
+	as we found a working port and don't need to try all the other ports
+	next time.
+
+	* glom/frame_glom.cc
+	(connection_request_password_and_choose_new_database_name): When
+	creating a centrally-hosted database, remember the user name in the
+	document, to be able to connect to the database from the saved
+	document later. Actually, we would also need to save the password to
+	do this correctly, though I wonder whether it's a good idea to save
+	the user's database password in the .glom file.
+
+2009-06-22  Armin Burgmeier  <armin openismus com>
+
 	* glom/frame_glom.cc:
 	(connection_request_password_and_choose_new_database_name): Fixed a
 	mistyped #ifdef, so that creating a centrally-hosted database does not
diff --git a/glom/application.cc b/glom/application.cc
index 096835a..1826b85 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -1008,6 +1008,13 @@ bool App_Glom::on_document_load()
           pDocument->set_hosting_mode(m_ui_save_extra_newdb_hosting_mode);
           m_ui_save_extra_newdb_hosting_mode = Document::DEFAULT_HOSTED;
           pDocument->set_is_example_file(false);
+
+          // For self-hosting, we will choose a port later. For central
+          // hosting, try several default ports. Don't use the values that
+          // are set in the example file.
+          pDocument->set_connection_port(0);
+          pDocument->set_connection_try_other_ports(true);
+
           // We have a valid uri, so we can set it to !new and modified here
         }        
         
diff --git a/glom/dialog_connection.cc b/glom/dialog_connection.cc
index 941ca9d..524a96d 100644
--- a/glom/dialog_connection.cc
+++ b/glom/dialog_connection.cc
@@ -134,6 +134,9 @@ sharedptr<SharedConnection> Dialog_Connection::connect_to_server_with_connection
         g_assert(central != NULL);
 
         unconst->set_connection_port(central->get_port() );
+	// As we know the port of the database already, we don't need to try
+	// other ports anymore:
+        unconst->set_connection_try_other_ports(false);
       }
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -144,6 +147,7 @@ sharedptr<SharedConnection> Dialog_Connection::connect_to_server_with_connection
         g_assert(self != NULL);
 
         unconst->set_connection_port(self->get_port() );
+        unconst->set_connection_try_other_ports(false);
       }
 #endif //GLOM_ENABLE_CLIENT_ONLY
     }
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index ec08c84..3194c4c 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -2122,6 +2122,13 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
         ConnectionPool::SlotProgress slot_ignored;
         if(!handle_connection_initialize_errors( connection_pool->initialize(slot_ignored)) )
           return false;
+
+        // Remember the user name in the document, to be able to open the
+        // document again later:
+        Glib::ustring username, password;
+        m_pDialogConnection->get_username_and_password(username, password);
+        document->set_connection_user(username);
+
       }
       else
       {



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