[gnome-control-center] printers: Handle cancelling of authentication dialog
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Handle cancelling of authentication dialog
- Date: Tue, 3 Sep 2013 20:11:53 +0000 (UTC)
commit da28022da6590d4370a742ee17d340969180b208
Author: Marek Kasik <mkasik redhat com>
Date: Mon Sep 2 16:50:56 2013 +0200
printers: Handle cancelling of authentication dialog
Add given Samba server to the list of found devices
if authentication dialog was cancelled.
https://bugzilla.gnome.org/show_bug.cgi?id=698532
panels/printers/pp-samba.c | 85 ++++++++++++++++++++++++++++----------------
1 files changed, 54 insertions(+), 31 deletions(-)
---
diff --git a/panels/printers/pp-samba.c b/panels/printers/pp-samba.c
index e876a53..3079990 100644
--- a/panels/printers/pp-samba.c
+++ b/panels/printers/pp-samba.c
@@ -192,6 +192,7 @@ typedef struct
GtkWindow *parent;
SMBAuthInfo *auth_info;
gboolean hostname_set;
+ gboolean cancelled;
} SMBData;
static void
@@ -235,6 +236,10 @@ auth_cb (PpAuthenticationDialog *auth_dialog,
g_object_unref (auth_dialog);
+ if (response_id == GTK_RESPONSE_CANCEL ||
+ response_id == GTK_RESPONSE_DELETE_EVENT)
+ data->cancelled = TRUE;
+
data->waiting = FALSE;
}
@@ -274,41 +279,44 @@ auth_fn (SMBCCTX *smb_context,
data = (SMBData *) smbc_getOptionUserData (smb_context);
- data->auth_info = g_new (SMBAuthInfo, 1);
- data->auth_info->server = g_strdup (server);
- data->auth_info->share = g_strdup (share);
- data->auth_info->workgroup = g_strdup (workgroup);
- data->auth_info->username = g_strdup (username);
- data->auth_info->password = g_strdup (password);
-
- data->waiting = TRUE;
-
- source = g_idle_source_new ();
- g_source_set_callback (source,
- get_auth_info,
- data,
- NULL);
- g_source_attach (source, data->context);
- g_source_unref (source);
-
- /*
- * smbclient needs to get authentication data
- * from this synchronous callback so we are blocking
- * until we get them
- */
- while (data->waiting)
+ if (!data->cancelled)
{
- g_usleep (POLL_DELAY);
- }
+ data->auth_info = g_new (SMBAuthInfo, 1);
+ data->auth_info->server = g_strdup (server);
+ data->auth_info->share = g_strdup (share);
+ data->auth_info->workgroup = g_strdup (workgroup);
+ data->auth_info->username = g_strdup (username);
+ data->auth_info->password = g_strdup (password);
- if (g_strcmp0 (username, data->auth_info->username) != 0)
- g_strlcpy (username, data->auth_info->username, unmaxlen);
+ data->waiting = TRUE;
+
+ source = g_idle_source_new ();
+ g_source_set_callback (source,
+ get_auth_info,
+ data,
+ NULL);
+ g_source_attach (source, data->context);
+ g_source_unref (source);
+
+ /*
+ * smbclient needs to get authentication data
+ * from this synchronous callback so we are blocking
+ * until we get them
+ */
+ while (data->waiting)
+ {
+ g_usleep (POLL_DELAY);
+ }
+
+ if (g_strcmp0 (username, data->auth_info->username) != 0)
+ g_strlcpy (username, data->auth_info->username, unmaxlen);
- if (g_strcmp0 (password, data->auth_info->password) != 0)
- g_strlcpy (password, data->auth_info->password, pwmaxlen);
+ if (g_strcmp0 (password, data->auth_info->password) != 0)
+ g_strlcpy (password, data->auth_info->password, pwmaxlen);
- smb_auth_info_free (data->auth_info);
- data->auth_info = NULL;
+ smb_auth_info_free (data->auth_info);
+ data->auth_info = NULL;
+ }
}
static void
@@ -351,13 +359,28 @@ list_dir (SMBCCTX *smb_context,
{
if (data->auth_if_needed)
{
+ data->cancelled = FALSE;
smbc_setFunctionAuthDataWithContext (smb_context, auth_fn);
dir = smbclient_opendir (smb_context, dirname);
smbc_setFunctionAuthDataWithContext (smb_context, anonymous_auth_fn);
+
+ if (data->cancelled)
+ {
+ device = g_new0 (PpPrintDevice, 1);
+ device->host_name = g_str_has_prefix (dirname, "smb://") ? g_strdup (dirname + 6) :
g_strdup (dirname);
+ device->is_authenticated_server = TRUE;
+
+ data->devices->devices = g_list_append (data->devices->devices, device);
+
+ if (dir)
+ smbclient_closedir (smb_context, dir);
+ return;
+ }
}
else
{
device = g_new0 (PpPrintDevice, 1);
+
device->host_name = g_str_has_prefix (dirname, "smb://") ? g_strdup (dirname + 6) : g_strdup
(dirname);
device->is_authenticated_server = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]