[libgda: 1/2] libgda-ui: Improvements in login dialog



commit 9eca431d134e3d80558abf6ca54c89654a01e5f1
Author: Pavlo Solntsev <p sun fun gmail com>
Date:   Sun Jul 14 21:57:16 2019 -0500

    libgda-ui: Improvements in login dialog
    
    Login dialog now returns NULL if "OK" button is
    clicked in the dialog but DSN name wasn't selected
    or connection parameters have not been specified.

 libgda-ui/gdaui-login.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/libgda-ui/gdaui-login.c b/libgda-ui/gdaui-login.c
index 8db99cdfd..49f27ecf4 100644
--- a/libgda-ui/gdaui-login.c
+++ b/libgda-ui/gdaui-login.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2010 David King <davidk openismus com>
  * Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
  * Copyright (C) 2013 Daniel Espinosa <esodan gmail com>
+ * Copyright (C) 2019 Pavlo Solntsev <p sun fun gmail com> 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -570,9 +571,10 @@ gdaui_login_set_mode (GdauiLogin *login, GdauiLoginMode mode)
  *
  * Get the information specified in @login as a pointer to a (read-only) #GdaDsnInfo.
  * If the connection is not specified by a DSN, then the 'name' attribute of the returned
- * #GdaDsnInfo will be %NULL, and otherwise it will contain the name of the selected DSN.
+ * #GdaDsnInfo will be %NULL, and otherwise it will contain the name of the selected DSN or %NULL
+ * if no DSN selected or connection specified but "OK" button pressed.
  *
- * Returns: (transfer none): a pointer to a (read-only) #GdaDsnInfo.
+ * Returns: (transfer none) (nullable): a pointer to a (read-only) #GdaDsnInfo or %NULL.
  *
  * Since: 4.2
  */
@@ -587,19 +589,18 @@ gdaui_login_get_connection_information (GdauiLogin *login)
                GdaDsnInfo *info = NULL;
                gchar *dsn;
                dsn = _gdaui_dsn_selector_get_dsn (GDAUI_DSN_SELECTOR (priv->dsn_selector));
-               if (dsn && *dsn)
-                       info = gda_config_get_dsn_info (dsn);
+    if (!dsn || !*dsn)
+                       return NULL;
+               info = gda_config_get_dsn_info (dsn);
                g_free (dsn);
-               if (info) {
-                       priv->dsn_info.name = g_strdup (info->name);
-                       if (info->provider)
-                               priv->dsn_info.provider = g_strdup (info->provider);
-                       if (info->description)
-                               priv->dsn_info.description = g_strdup (info->description);
-                       if (info->cnc_string)
-                               priv->dsn_info.cnc_string = g_strdup (info->cnc_string);
-                       priv->dsn_info.is_system = info->is_system;
-               }
+               priv->dsn_info.name = g_strdup (info->name);
+               if (info->provider)
+                       priv->dsn_info.provider = g_strdup (info->provider);
+               if (info->description)
+                       priv->dsn_info.description = g_strdup (info->description);
+               if (info->cnc_string)
+                       priv->dsn_info.cnc_string = g_strdup (info->cnc_string);
+               priv->dsn_info.is_system = info->is_system;
                priv->dsn_info.auth_string = _gdaui_provider_auth_editor_get_auth (GDAUI_PROVIDER_AUTH_EDITOR 
(priv->auth_widget));
        }
        else {


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