glom r1793 - in trunk: . glom glom/libglom glom/libglom/connectionpool_backends glom/libglom/data_structure glom/utility_widgets



Author: arminb
Date: Tue Dec  9 19:49:34 2008
New Revision: 1793
URL: http://svn.gnome.org/viewvc/glom?rev=1793&view=rev

Log:
2008-12-09  Armin Burgmeier  <armin openismus com>

	* glom/application.h:
	* glom/application.cc: Set "Users" mene item in "Developer" menu
	insensitive when the database does not support users.

	* glom/frame_glom.cc: Don't ask for user/password for SQLite
	connections.

	* glom/libglom/data_structure/glomconversions.cc
	(get_text_for_gda_value): Really allow TIME values to be strings.

	* glom/libglom/connectionpool.h:
	* glom/libglom/connectionpool_backends/postgres_central.h:
	* glom/libglom/connectionpool_backends/postgres_self.h:
	* glom/libglom/connectionpool_backends/sqlite.h: Added a
	supports_remote_connection() virtual function to the ConnectionPool
	backends.

	* glom/libglom/connectionpool.cc: Don't advertize the Glom document
	via avahi when the database does not support remote connections, such
	as SQLite.


Modified:
   trunk/ChangeLog
   trunk/glom/application.cc
   trunk/glom/application.h
   trunk/glom/frame_glom.cc
   trunk/glom/libglom/connectionpool.cc
   trunk/glom/libglom/connectionpool.h
   trunk/glom/libglom/connectionpool_backends/postgres_central.h
   trunk/glom/libglom/connectionpool_backends/postgres_self.h
   trunk/glom/libglom/connectionpool_backends/sqlite.h
   trunk/glom/libglom/data_structure/glomconversions.cc
   trunk/glom/utility_widgets/filechooserdialog_saveextras.cc

Modified: trunk/glom/application.cc
==============================================================================
--- trunk/glom/application.cc	(original)
+++ trunk/glom/application.cc	Tue Dec  9 19:49:34 2008
@@ -459,9 +459,9 @@
   m_listDeveloperActions.push_back(action);
   m_refActionGroup_Others->add(action, sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_developer_relationships) );
 
-  action = Gtk::Action::create("GlomAction_Menu_Developer_Users", _("_Users"));
-  m_listDeveloperActions.push_back(action);
-  m_refActionGroup_Others->add(action, sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_developer_users));
+  m_action_developer_users = Gtk::Action::create("GlomAction_Menu_Developer_Users", _("_Users"));
+  m_listDeveloperActions.push_back(m_action_developer_users);
+  m_refActionGroup_Others->add(m_action_developer_users, sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_developer_users));
 
   action = Gtk::Action::create("GlomAction_Menu_Developer_PrintLayouts", _("_Print Layouts")); //TODO: Rename? This looks like an action rather than a noun. It won't actually start printing.
   m_listDeveloperActions.push_back(action);
@@ -1131,6 +1131,15 @@
      action->set_sensitive ( userlevel == AppState::USERLEVEL_DEVELOPER );
   }
 
+  // Hide users entry from developer menu for connections that don't
+  // support users
+  if(userlevel == AppState::USERLEVEL_DEVELOPER)
+  {
+    sharedptr<SharedConnection> connection = ConnectionPool::get_and_connect();
+    if(connection && !connection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
+      m_action_developer_users->set_sensitive(false);
+  } 
+
   //Make sure that the correct radio menu item is activated (the userlevel might have been set programmatically):
   //We only need to set/unset one, because the others are in the same radio group.
   if(userlevel ==  AppState::USERLEVEL_DEVELOPER)

Modified: trunk/glom/application.h
==============================================================================
--- trunk/glom/application.h	(original)
+++ trunk/glom/application.h	Tue Dec  9 19:49:34 2008
@@ -150,6 +150,7 @@
   type_listActions m_listDeveloperActions; //Only enabled when in developer mode.
   Glib::RefPtr<Gtk::Action> m_action_mode_data, m_action_mode_find;
 #ifndef GLOM_ENABLE_CLIENT_ONLY
+  Glib::RefPtr<Gtk::Action> m_action_developer_users;
   Glib::RefPtr<Gtk::RadioAction> m_action_menu_userlevel_developer, m_action_menu_userlevel_operator;
   Glib::RefPtr<Gtk::ToggleAction> m_action_show_layout_toolbar;
 #endif // !GLOM_ENABLE_CLIENT_ONLY

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Tue Dec  9 19:49:34 2008
@@ -1839,7 +1839,12 @@
 
     //Only show the dialog if we don't know the correct username/password yet:
     int response = Gtk::RESPONSE_OK;
-    if(known_username.empty() && known_password.empty())
+    // 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
+    // which we don't have at this point.
+    if(document->get_hosting_mode() != Document_Glom::SQLITE_HOSTED &&
+       known_username.empty() && known_password.empty())
     {
        response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
        m_pDialogConnection->hide();

Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc	(original)
+++ trunk/glom/libglom/connectionpool.cc	Tue Dec  9 19:49:34 2008
@@ -770,6 +770,10 @@
  */
 void ConnectionPool::avahi_start_publishing()
 {
+  // Don't advertize if the database cannot be accessed remotely anyway
+  if(!m_backend->supports_remote_access())
+    return;
+
   if(m_epc_publisher)
     return;
 #ifdef GLOM_CONNECTION_DEBUG
@@ -822,6 +826,9 @@
 
 void ConnectionPool::avahi_stop_publishing()
 {
+  if(!m_backend->supports_remote_access())
+    return;
+
   if(!m_epc_publisher)
     return;
 #ifdef GLOM_CONNECTION_DEBUG

Modified: trunk/glom/libglom/connectionpool.h
==============================================================================
--- trunk/glom/libglom/connectionpool.h	(original)
+++ trunk/glom/libglom/connectionpool.h	Tue Dec  9 19:49:34 2008
@@ -116,6 +116,10 @@
    */
   virtual Field::sql_format get_sql_format() const = 0;
 
+  /* Whether the database can be accessed from remote machines, once startup()
+   * was called. */
+  virtual bool supports_remote_access() const = 0;
+
   /* This method is called for one-time initialization of the database
    * storage. No need to implement this function if the data is centrally
    * hosted, not managed by Glom. */

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	Tue Dec  9 19:49:34 2008
@@ -67,6 +67,7 @@
 
 protected:
   virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_POSTGRES; }
+  virtual bool supports_remote_access() const { return true; }
 
   virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, std::auto_ptr<ExceptionConnection>& error);
 

Modified: trunk/glom/libglom/connectionpool_backends/postgres_self.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres_self.h	(original)
+++ trunk/glom/libglom/connectionpool_backends/postgres_self.h	Tue Dec  9 19:49:34 2008
@@ -75,6 +75,7 @@
 
 protected:
   virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_POSTGRES; }
+  virtual bool supports_remote_access() const { return true; }
 
   virtual bool initialize(Gtk::Window* parent_window, const Glib::ustring& initial_username, const Glib::ustring& password);
 

Modified: trunk/glom/libglom/connectionpool_backends/sqlite.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/sqlite.h	(original)
+++ trunk/glom/libglom/connectionpool_backends/sqlite.h	Tue Dec  9 19:49:34 2008
@@ -42,6 +42,7 @@
 
 protected:
   virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_SQLITE; }
+  virtual bool supports_remote_access() const { return false; }
 
   virtual Glib::RefPtr<Gnome::Gda::Connection> connect(const Glib::ustring& database, const Glib::ustring& username, const Glib::ustring& password, std::auto_ptr<ExceptionConnection>& error);
 

Modified: trunk/glom/libglom/data_structure/glomconversions.cc
==============================================================================
--- trunk/glom/libglom/data_structure/glomconversions.cc	(original)
+++ trunk/glom/libglom/data_structure/glomconversions.cc	Tue Dec  9 19:49:34 2008
@@ -360,7 +360,7 @@
     return date.format_string("%x"); //%x means "is replaced by the locale's appropriate date representation".
     */
   }
-  else if((glom_type == Field::TYPE_TIME) && (value.get_value_type() == GDA_TYPE_TIME))
+  else if(glom_type == Field::TYPE_TIME)
   {
     tm the_c_time;
     memset(&the_c_time, 0, sizeof(the_c_time));

Modified: trunk/glom/utility_widgets/filechooserdialog_saveextras.cc
==============================================================================
--- trunk/glom/utility_widgets/filechooserdialog_saveextras.cc	(original)
+++ trunk/glom/utility_widgets/filechooserdialog_saveextras.cc	Tue Dec  9 19:49:34 2008
@@ -110,7 +110,8 @@
   vbox->pack_start(m_radiobutton_server_postgres_central);
   m_radiobutton_server_postgres_central.show();
 
-  m_radiobutton_server_sqlite.set_label(_("Create sqlite database in its own folder, to be hosted by this computer."));
+  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();



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