[glom] ConnectionPool: create_database(): Take a progress slot.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] ConnectionPool: create_database(): Take a progress slot.
- Date: Thu, 29 Mar 2012 12:35:27 +0000 (UTC)
commit c2dd178baeab0548ec5441a42b9518fccd474e94
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Mar 29 14:35:18 2012 +0200
ConnectionPool: create_database(): Take a progress slot.
* glom/libglom/connectionpool.[h|cc]::
* glom/libglom/connectionpool_backends/backend.h: create_database():
Add a progress_slot parameter, to be emitted.
* glom/libglom/connectionpool_backends/postgres.[h|cc]:
* glom/libglom/connectionpool_backends/postgres_central.[h|cc]:
* glom/libglom/connectionpool_backends/postgres_self.[h|cc]:
* glom/libglom/connectionpool_backends/sqlite.[h|cc]:
* glom/libglom/db_utils.cc:
* glom/appwindow.[h|cc]: Adapt.
ChangeLog | 14 ++++++++++++++
glom/appwindow.cc | 9 ++++++++-
glom/appwindow.h | 1 +
glom/libglom/connectionpool.cc | 4 ++--
glom/libglom/connectionpool.h | 3 +--
glom/libglom/connectionpool_backends/backend.h | 2 +-
glom/libglom/connectionpool_backends/postgres.cc | 13 ++++++++++---
glom/libglom/connectionpool_backends/postgres.h | 2 +-
.../connectionpool_backends/postgres_central.cc | 4 ++--
.../connectionpool_backends/postgres_central.h | 2 +-
.../connectionpool_backends/postgres_self.cc | 4 ++--
.../connectionpool_backends/postgres_self.h | 2 +-
glom/libglom/connectionpool_backends/sqlite.cc | 10 ++++++++--
glom/libglom/connectionpool_backends/sqlite.h | 2 +-
glom/libglom/db_utils.cc | 2 +-
15 files changed, 54 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7cb5fab..13d7609 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-03-29 Murray Cumming <murrayc murrayc com>
+
+ ConnectionPool: create_database(): Take a progress slot.
+
+ * glom/libglom/connectionpool.[h|cc]::
+ * glom/libglom/connectionpool_backends/backend.h: create_database():
+ Add a progress_slot parameter, to be emitted.
+ * glom/libglom/connectionpool_backends/postgres.[h|cc]:
+ * glom/libglom/connectionpool_backends/postgres_central.[h|cc]:
+ * glom/libglom/connectionpool_backends/postgres_self.[h|cc]:
+ * glom/libglom/connectionpool_backends/sqlite.[h|cc]:
+ * glom/libglom/db_utils.cc:
+ * glom/appwindow.[h|cc]: Adapt.
+
1.21.8:
2012-03-28 Murray Cumming <murrayc murrayc com>
diff --git a/glom/appwindow.cc b/glom/appwindow.cc
index 9c06357..2942562 100644
--- a/glom/appwindow.cc
+++ b/glom/appwindow.cc
@@ -1269,6 +1269,11 @@ bool AppWindow::on_document_load()
return true; //Loading of the document into the application succeeded.
}
+void AppWindow::on_connection_create_database_progress()
+{
+ pulse_progress_message();
+}
+
void AppWindow::on_connection_close_progress()
{
//TODO_murrayc
@@ -1865,7 +1870,9 @@ bool AppWindow::recreate_database_from_backup(const Glib::ustring& backup_uri, b
connection_pool->set_database( Glib::ustring() );
try
{
- ConnectionPool::get_instance()->create_database(db_name);
+ ConnectionPool::get_instance()->create_database(
+ sigc::mem_fun(*this, &AppWindow::on_connection_convert_backup_progress),
+ db_name);
}
catch(const Glib::Exception& ex) // libgda does not set error domain
{
diff --git a/glom/appwindow.h b/glom/appwindow.h
index d3de807..f1a5072 100644
--- a/glom/appwindow.h
+++ b/glom/appwindow.h
@@ -220,6 +220,7 @@ private:
virtual void new_instance(const Glib::ustring& uri = Glib::ustring()); //Override
+ void on_connection_create_database_progress();
void on_connection_close_progress();
void on_connection_save_backup_progress();
void on_connection_convert_backup_progress();
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 4c97445..5082f7f 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -390,10 +390,10 @@ sharedptr<SharedConnection> ConnectionPool::connect()
return sharedptr<SharedConnection>(0);
}
-void ConnectionPool::create_database(const Glib::ustring& database_name)
+void ConnectionPool::create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name)
{
if(m_backend.get())
- m_backend->create_database(database_name, get_user(), get_password());
+ m_backend->create_database(slot_progress, database_name, get_user(), get_password());
}
void ConnectionPool::set_user(const Glib::ustring& value)
diff --git a/glom/libglom/connectionpool.h b/glom/libglom/connectionpool.h
index b54a34d..8b1f095 100644
--- a/glom/libglom/connectionpool.h
+++ b/glom/libglom/connectionpool.h
@@ -162,10 +162,9 @@ public:
*/
typedef Backend::SlotProgress SlotProgress;
- //TODO: Add SlotProgress?
/** Creates a new database.
*/
- void create_database(const Glib::ustring& database_name);
+ void create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name);
/** Save a backup of the database in a tarball.
* This backup can later be used to recreate the database,
diff --git a/glom/libglom/connectionpool_backends/backend.h b/glom/libglom/connectionpool_backends/backend.h
index 083d9f0..f85c055 100644
--- a/glom/libglom/connectionpool_backends/backend.h
+++ b/glom/libglom/connectionpool_backends/backend.h
@@ -181,7 +181,7 @@ protected:
/** This method is called to create a new database on the
* database server. */
- virtual bool create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password) = 0;
+ virtual bool create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password) = 0;
/** Save a backup of the database in a tarball.
* This backup can later be used to recreate the database,
diff --git a/glom/libglom/connectionpool_backends/postgres.cc b/glom/libglom/connectionpool_backends/postgres.cc
index 7feaa98..e0b2cf4 100644
--- a/glom/libglom/connectionpool_backends/postgres.cc
+++ b/glom/libglom/connectionpool_backends/postgres.cc
@@ -388,10 +388,15 @@ bool Postgres::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connec
return false;
}
-bool Postgres::attempt_create_database(const Glib::ustring& database_name, const Glib::ustring& host, const Glib::ustring& port, const Glib::ustring& username, const Glib::ustring& password)
+bool Postgres::attempt_create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& host, const Glib::ustring& port, const Glib::ustring& username, const Glib::ustring& password)
{
- Glib::RefPtr<Gnome::Gda::ServerOperation> op = Gnome::Gda::ServerOperation::prepare_create_database("PostgreSQL",
- database_name);
+ slot_progress();
+
+ Glib::RefPtr<Gnome::Gda::ServerOperation> op =
+ Gnome::Gda::ServerOperation::prepare_create_database("PostgreSQL", database_name);
+
+ slot_progress();
+
g_assert(op);
try
{
@@ -407,6 +412,8 @@ bool Postgres::attempt_create_database(const Glib::ustring& database_name, const
return false;
}
+ slot_progress();
+
return true;
}
diff --git a/glom/libglom/connectionpool_backends/postgres.h b/glom/libglom/connectionpool_backends/postgres.h
index f785025..8355274 100644
--- a/glom/libglom/connectionpool_backends/postgres.h
+++ b/glom/libglom/connectionpool_backends/postgres.h
@@ -65,7 +65,7 @@ private:
virtual bool change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connection, const Glib::ustring& table_name, const type_vec_const_fields& old_fields, const type_vec_const_fields& new_fields) throw();
protected:
- bool attempt_create_database(const Glib::ustring& database_name, const Glib::ustring& host, const Glib::ustring& port, const Glib::ustring& username, const Glib::ustring& password);
+ bool attempt_create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& host, const Glib::ustring& port, const Glib::ustring& username, const Glib::ustring& password);
/** Attempt to connect to the database with the specified criteria.
* @throws An ExceptionConnection if the correction failed.
diff --git a/glom/libglom/connectionpool_backends/postgres_central.cc b/glom/libglom/connectionpool_backends/postgres_central.cc
index fd76f1b..170e6e7 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.cc
+++ b/glom/libglom/connectionpool_backends/postgres_central.cc
@@ -159,9 +159,9 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
return connection;
}
-bool PostgresCentralHosted::create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password)
+bool PostgresCentralHosted::create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password)
{
- return attempt_create_database(database_name, get_host(), port_as_string(m_port), username, password);
+ return attempt_create_database(slot_progress, database_name, get_host(), port_as_string(m_port), username, password);
}
}
diff --git a/glom/libglom/connectionpool_backends/postgres_central.h b/glom/libglom/connectionpool_backends/postgres_central.h
index ae61024..fd20c4a 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.h
+++ b/glom/libglom/connectionpool_backends/postgres_central.h
@@ -50,7 +50,7 @@ public:
private:
virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection = false);
- virtual bool create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
+ virtual bool create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
private:
typedef std::vector<Glib::ustring> type_list_ports;
diff --git a/glom/libglom/connectionpool_backends/postgres_self.cc b/glom/libglom/connectionpool_backends/postgres_self.cc
index 7ae964a..7e9243e 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.cc
+++ b/glom/libglom/connectionpool_backends/postgres_self.cc
@@ -669,9 +669,9 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresSelfHosted::connect(const Glib::ust
return result;
}
-bool PostgresSelfHosted::create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password)
+bool PostgresSelfHosted::create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password)
{
- return attempt_create_database(database_name, "localhost", port_as_string(m_port), username, password);
+ return attempt_create_database(slot_progress, database_name, "localhost", port_as_string(m_port), username, password);
}
unsigned int PostgresSelfHosted::discover_first_free_port(unsigned int start_port, unsigned int end_port)
diff --git a/glom/libglom/connectionpool_backends/postgres_self.h b/glom/libglom/connectionpool_backends/postgres_self.h
index d5666f8..f1c36fa 100644
--- a/glom/libglom/connectionpool_backends/postgres_self.h
+++ b/glom/libglom/connectionpool_backends/postgres_self.h
@@ -63,7 +63,7 @@ private:
virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, bool fake_connection = false);
- virtual bool create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
+ virtual bool create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
private:
/** Examine ports one by one, starting at @a starting_port, in increasing
diff --git a/glom/libglom/connectionpool_backends/sqlite.cc b/glom/libglom/connectionpool_backends/sqlite.cc
index dc0eb39..37ce5fa 100644
--- a/glom/libglom/connectionpool_backends/sqlite.cc
+++ b/glom/libglom/connectionpool_backends/sqlite.cc
@@ -105,24 +105,30 @@ Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& databa
return connection;
}
-bool Sqlite::create_database(const Glib::ustring& database_name, const Glib::ustring& /* username */, const Glib::ustring& /* password */)
+bool Sqlite::create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& /* username */, const Glib::ustring& /* password */)
{
if(m_database_directory_uri.empty())
{
std::cerr << G_STRFUNC << ": m_database_directory_uri was empty." << std::endl;
return false;
}
-
+
+ slot_progress();
+
Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(m_database_directory_uri);
const std::string database_directory = file->get_path();
const Glib::ustring cnc_string = Glib::ustring::compose("DB_DIR=%1;DB_NAME=%2",
DbUtils::gda_cnc_string_encode(database_directory), DbUtils::gda_cnc_string_encode(database_name));
+ slot_progress();
+
Glib::RefPtr<Gnome::Gda::Connection> cnc =
Gnome::Gda::Connection::open_from_string("SQLite",
cnc_string, "",
Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+ slot_progress();
+
return true;
}
diff --git a/glom/libglom/connectionpool_backends/sqlite.h b/glom/libglom/connectionpool_backends/sqlite.h
index 0665be0..c7259b6 100644
--- a/glom/libglom/connectionpool_backends/sqlite.h
+++ b/glom/libglom/connectionpool_backends/sqlite.h
@@ -59,7 +59,7 @@ private:
/** Creates a new database.
*/
- virtual bool create_database(const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
+ virtual bool create_database(const SlotProgress& slot_progress, const Glib::ustring& database_name, const Glib::ustring& username, const Glib::ustring& password);
virtual bool save_backup(const SlotProgress& slot_progress, const Glib::ustring& username, const Glib::ustring& password, const Glib::ustring& database_name);
virtual bool convert_backup(const SlotProgress& slot_progress, const std::string& base_directory, const Glib::ustring& username, const Glib::ustring& password, const Glib::ustring& database_name);
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 757ea31..6fba763 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -105,7 +105,7 @@ bool create_database(Document* document, const Glib::ustring& database_name, con
try
{
- ConnectionPool::get_instance()->create_database(database_name);
+ ConnectionPool::get_instance()->create_database(progress, database_name);
}
catch(const Glib::Exception& ex) // libgda does not set error domain
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]