printers: Merge authentication dialog into "Add Printer"

This is a redesign based on the newest mockups available at
https://wiki.gnome.org/Design/SystemSettings/Printers#Guidelines

https://bugzilla.gnome.org/show_bug.cgi?id=760783
This commit is contained in:
Felipe Borges 2016-11-10 13:55:07 +01:00
parent e5106e9a54
commit afac6d5340
4 changed files with 420 additions and 294 deletions

View file

@ -61,7 +61,7 @@
</style>
</object>
<packing>
<property name="name">add-button</property>
<property name="name">addprinter-page</property>
</packing>
</child>
<child>
@ -79,6 +79,23 @@
<property name="name">unlock-button</property>
</packing>
</child>
<child>
<object class="GtkButton" id="authenticate-button">
<property name="label" translatable="yes" comments="Translators: This buttons submits the credentials for the selected server.">_Unlock</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="name">authentication-page</property>
</packing>
</child>
</object>
<packing>
<property name="pack-type">GTK_PACK_END</property>
@ -94,167 +111,270 @@
<property name="spacing">10</property>
<property name="border_width">0</property>
<child>
<object class="GtkBox" id="box2">
<object class="GtkStack" id="dialog-stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">0</property>
<child>
<object class="GtkStack" id="stack">
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="transition-type">none</property>
<style>
<class name="view"/>
</style>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkTreeView" id="devices-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">devices-model-filter</property>
<property name="headers_visible">False</property>
<property name="enable-grid-lines">GTK_TREE_VIEW_GRID_LINES_HORIZONTAL</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
</object>
</child>
</object>
<packing>
<property name="name">standard-page</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<property name="valign">GTK_ALIGN_CENTER</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">GTK_ALIGN_START</property>
<property name="pixel_size">72</property>
<property name="icon_name">printer-symbolic</property>
<property name="opacity">0.6</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="no-devices-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="sensitive">False</property>
<property name="label" translatable="yes" comments="Translators: No printers were detected">No Printers Found</property>
<property name="opacity">0.6</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="name">no-printers-page</property>
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="transition-type">none</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkSpinner" id="spinner">
<property name="visible">True</property>
<property name="active">True</property>
<property name="expand">True</property>
<property name="sensitive">False</property>
<property name="opacity">0.6</property>
</object>
</child>
</object>
<packing>
<property name="name">loading-page</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="toolbar_style">icons</property>
<property name="icon_size">1</property>
<style>
<class name="toolbar"/>
</style>
<child>
<object class="GtkToolItem" id="toolbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box1">
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">4</property>
<child>
<object class="GtkSearchEntry" id="search-entry">
<object class="GtkTreeView" id="devices-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="invisible_char">●</property>
<property name="truncate_multiline">True</property>
<property name="invisible_char_set">True</property>
<property name="placeholder_text" translatable="yes" comments="Translators: The entered text should contain network address of a printer or a text which will filter found devices (their names and locations)">Enter a network address or search for a printer</property>
<property name="margin_start">40</property>
<property name="margin_end">40</property>
<property name="model">devices-model-filter</property>
<property name="headers_visible">False</property>
<property name="enable-grid-lines">GTK_TREE_VIEW_GRID_LINES_HORIZONTAL</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">standard-page</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<property name="valign">GTK_ALIGN_CENTER</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">GTK_ALIGN_START</property>
<property name="pixel_size">72</property>
<property name="icon_name">printer-symbolic</property>
<property name="opacity">0.6</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="no-devices-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="sensitive">False</property>
<property name="label" translatable="yes" comments="Translators: No printers were detected">No Printers Found</property>
<property name="opacity">0.6</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="name">no-printers-page</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkSpinner" id="spinner">
<property name="visible">True</property>
<property name="active">True</property>
<property name="expand">True</property>
<property name="sensitive">False</property>
<property name="opacity">0.6</property>
</object>
</child>
</object>
<packing>
<property name="name">loading-page</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="toolbar_style">icons</property>
<property name="icon_size">1</property>
<style>
<class name="toolbar"/>
</style>
<child>
<object class="GtkToolItem" id="toolbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">4</property>
<child>
<object class="GtkSearchEntry" id="search-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="invisible_char">●</property>
<property name="truncate_multiline">True</property>
<property name="invisible_char_set">True</property>
<property name="placeholder_text" translatable="yes" comments="Translators: The entered text should contain network address of a printer or a text which will filter found devices (their names and locations)">Enter a network address or search for a printer</property>
<property name="margin_start">40</property>
<property name="margin_end">40</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="name">addprinter-page</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="margin">20</property>
<property name="row_spacing">10</property>
<property name="column_spacing">15</property>
<property name="expand">True</property>
<style>
<class name="background"/>
</style>
<child>
<object class="GtkImage">
<property name="pixel_size">48</property>
<property name="icon_name">dialog-password-symbolic</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Authentication Required</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="authentication-text">
<property name="wrap">True</property>
<property name="max_width_chars">36</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Enter username and password to view printers on Print Server.</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Username</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="username-entry">
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Password</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="password-entry">
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">●</property>
<property name="activates_default">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="name">authentication-page</property>
</packing>
</child>
</object>

View file

@ -55,6 +55,9 @@
#define WID(s) GTK_WIDGET (gtk_builder_get_object (priv->builder, s))
#define AUTHENTICATION_PAGE "authentication-page"
#define ADDPRINTER_PAGE "addprinter-page"
static void set_device (PpNewPrinterDialog *dialog,
PpPrintDevice *device,
GtkTreeIter *iter);
@ -329,6 +332,93 @@ get_authenticated_samba_devices_cb (GObject *source_object,
g_free (data);
}
static void
go_to_page (PpNewPrinterDialog *dialog,
const gchar *page)
{
PpNewPrinterDialogPrivate *priv = dialog->priv;
GtkStack *stack;
stack = GTK_STACK (WID ("dialog-stack"));
gtk_stack_set_visible_child_name (stack, page);
stack = GTK_STACK (WID ("headerbar-topright-buttons"));
gtk_stack_set_visible_child_name (stack, page);
}
static gchar *
get_entry_text (const gchar *object_name,
PpNewPrinterDialog *dialog)
{
PpNewPrinterDialogPrivate *priv = dialog->priv;
return g_strdup (gtk_entry_get_text (GTK_ENTRY (WID (object_name))));
}
static void
on_authenticate (GtkWidget *button,
gpointer user_data)
{
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
PpNewPrinterDialogPrivate *priv = dialog->priv;
gchar *username = NULL;
gchar *password = NULL;
username = get_entry_text ("username-entry", dialog);
password = get_entry_text ("password-entry", dialog);
if ((username == NULL) || (username[0] == '\0') ||
(password == NULL) || (password[0] == '\0'))
{
g_clear_pointer (&username, g_free);
g_clear_pointer (&password, g_free);
return;
}
pp_samba_set_auth_info (PP_SAMBA (priv->samba_host), username, password);
go_to_page (dialog, ADDPRINTER_PAGE);
}
static void
on_authentication_required (PpHost *host,
gpointer user_data)
{
PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
priv = dialog->priv;
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (WID ("headerbar")), NULL);
go_to_page (dialog, AUTHENTICATION_PAGE);
g_signal_connect (WID ("authenticate-button"), "clicked", G_CALLBACK (on_authenticate), dialog);
}
static void
auth_entries_changed (GtkEditable *editable,
gpointer user_data)
{
PpNewPrinterDialogPrivate *priv;
PpNewPrinterDialog *dialog = PP_NEW_PRINTER_DIALOG (user_data);
gboolean can_authenticate = FALSE;
gchar *username = NULL;
gchar *password = NULL;
priv = dialog->priv;
username = get_entry_text ("username-entry", dialog);
password = get_entry_text ("password-entry", dialog);
can_authenticate = (username != NULL && username[0] != '\0' &&
password != NULL && password[0] != '\0');
gtk_widget_set_sensitive (WID ("authenticate-button"), can_authenticate);
g_clear_pointer (&username, g_free);
g_clear_pointer (&password, g_free);
}
static void
authenticate_samba_server (GtkButton *button,
gpointer user_data)
@ -338,9 +428,12 @@ authenticate_samba_server (GtkButton *button,
GtkTreeModel *model;
GtkTreeIter iter;
AuthSMBData *data;
PpSamba *samba_host;
gchar *server_name = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
gtk_widget_set_sensitive (WID ("authenticate-button"), FALSE);
gtk_widget_grab_focus (WID ("username-entry"));
if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (priv->treeview), &model, &iter))
{
gtk_tree_model_get (model, &iter,
@ -349,8 +442,13 @@ authenticate_samba_server (GtkButton *button,
if (server_name != NULL)
{
samba_host = pp_samba_new (GTK_WINDOW (priv->dialog),
server_name);
g_clear_object (&priv->samba_host);
priv->samba_host = pp_samba_new (GTK_WINDOW (priv->dialog), server_name);
g_signal_connect_object (priv->samba_host,
"authentication-required",
G_CALLBACK (on_authentication_required),
dialog, 0);
priv->samba_authenticated_searching = TRUE;
update_dialog_state (dialog);
@ -359,7 +457,7 @@ authenticate_samba_server (GtkButton *button,
data->server_name = server_name;
data->dialog = dialog;
pp_samba_get_devices_async (samba_host,
pp_samba_get_devices_async (priv->samba_host,
TRUE,
priv->cancellable,
get_authenticated_samba_devices_cb,
@ -418,6 +516,10 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
widget = WID ("unlock-button");
g_signal_connect (widget, "clicked", G_CALLBACK (authenticate_samba_server), dialog);
/* Authentication form widgets */
g_signal_connect (WID ("username-entry"), "changed", G_CALLBACK (auth_entries_changed), dialog);
g_signal_connect (WID ("password-entry"), "changed", G_CALLBACK (auth_entries_changed), dialog);
/* Set junctions */
widget = WID ("scrolledwindow1");
context = gtk_widget_get_style_context (widget);
@ -514,7 +616,7 @@ device_selection_changed_cb (GtkTreeSelection *selection,
if (authentication_needed)
gtk_stack_set_visible_child_name (GTK_STACK (stack), "unlock-button");
else
gtk_stack_set_visible_child_name (GTK_STACK (stack), "add-button");
gtk_stack_set_visible_child_name (GTK_STACK (stack), ADDPRINTER_PAGE);
}
}

View file

@ -26,23 +26,21 @@
#include <libsmbclient.h>
#include <errno.h>
#include "pp-authentication-dialog.h"
#define POLL_DELAY 100000
struct _PpSambaPrivate
{
GtkWindow *parent;
/* Auth info */
gchar *server;
gchar *share;
gchar *workgroup;
gchar *username;
gchar *password;
gboolean waiting;
};
G_DEFINE_TYPE (PpSamba, pp_samba, PP_TYPE_HOST);
enum
{
PROP_0 = 0,
PROP_PARENT,
};
static void
pp_samba_finalize (GObject *object)
{
@ -50,55 +48,15 @@ pp_samba_finalize (GObject *object)
priv = PP_SAMBA (object)->priv;
g_object_unref (priv->parent);
g_free (priv->server);
g_free (priv->share);
g_free (priv->workgroup);
g_free (priv->username);
g_free (priv->password);
G_OBJECT_CLASS (pp_samba_parent_class)->finalize (object);
}
static void
pp_samba_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *param_spec)
{
PpSamba *self = PP_SAMBA (object);
switch (prop_id)
{
case PROP_PARENT:
g_value_set_pointer (value, self->priv->parent);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
prop_id,
param_spec);
break;
}
}
static void
pp_samba_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *param_spec)
{
PpSamba *self = PP_SAMBA (object);
switch (prop_id)
{
case PROP_PARENT:
if (self->priv->parent)
g_object_unref (self->priv->parent);
self->priv->parent = g_object_ref (G_OBJECT (g_value_get_pointer (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
prop_id,
param_spec);
break;
}
}
static void
pp_samba_class_init (PpSambaClass *klass)
{
@ -106,18 +64,7 @@ pp_samba_class_init (PpSambaClass *klass)
g_type_class_add_private (klass, sizeof (PpSambaPrivate));
gobject_class->set_property = pp_samba_set_property;
gobject_class->get_property = pp_samba_get_property;
gobject_class->finalize = pp_samba_finalize;
/*
* Used for authentication dialog.
*/
g_object_class_install_property (gobject_class, PROP_PARENT,
g_param_spec_pointer ("parent",
"Parent",
"Parent window",
G_PARAM_READWRITE));
}
static void
@ -133,42 +80,17 @@ pp_samba_new (GtkWindow *parent,
const gchar *hostname)
{
return g_object_new (PP_TYPE_SAMBA,
"parent", parent,
"hostname", hostname,
NULL);
}
typedef struct
{
gchar *server;
gchar *share;
gchar *workgroup;
gchar *username;
gchar *password;
} SMBAuthInfo;
static void
smb_auth_info_free (SMBAuthInfo *auth_info)
{
if (auth_info)
{
g_free (auth_info->server);
g_free (auth_info->share);
g_free (auth_info->workgroup);
g_free (auth_info->username);
g_free (auth_info->password);
g_free (auth_info);
}
}
typedef struct
{
PpSamba *samba;
PpDevicesList *devices;
GMainContext *context;
gboolean waiting;
gboolean auth_if_needed;
GtkWindow *parent;
SMBAuthInfo *auth_info;
gboolean hostname_set;
gboolean cancelled;
} SMBData;
@ -179,63 +101,46 @@ smb_data_free (SMBData *data)
if (data)
{
pp_devices_list_free (data->devices);
smb_auth_info_free (data->auth_info);
g_object_unref (data->parent);
g_free (data);
}
}
static void
auth_cb (PpAuthenticationDialog *auth_dialog,
gint response_id,
const gchar *username,
const gchar *password,
gpointer user_data)
{
SMBData *data = (SMBData *) user_data;
if (username && username[0] != '\0')
{
g_free (data->auth_info->username);
data->auth_info->username = g_strdup (username);
}
if (password && password[0] != '\0')
{
g_free (data->auth_info->password);
data->auth_info->password = g_strdup (password);
}
g_object_unref (auth_dialog);
if (response_id == GTK_RESPONSE_CANCEL ||
response_id == GTK_RESPONSE_DELETE_EVENT)
data->cancelled = TRUE;
data->waiting = FALSE;
}
static gboolean
get_auth_info (gpointer user_data)
{
PpAuthenticationDialog *auth_dialog;
SMBData *data = (SMBData *) user_data;
gchar *text;
SMBData *data = (SMBData *) user_data;
PpSamba *samba = PP_SAMBA (data->samba);
/* Translators: Samba server needs authentication of the user to show list of its printers. */
text = g_strdup_printf (_("Enter your username and password to view printers available on %s."),
data->auth_info->server);
auth_dialog = pp_authentication_dialog_new (data->parent,
text,
data->auth_info->username);
g_signal_connect (auth_dialog, "response", G_CALLBACK (auth_cb), user_data);
samba->priv->waiting = TRUE;
g_free (text);
g_signal_emit_by_name (samba, "authentication-required");
return FALSE;
}
void
pp_samba_set_auth_info (PpSamba *samba,
const gchar *username,
const gchar *password)
{
PpSambaPrivate *priv = samba->priv;
if ((username != NULL) && (username[0] != '\0'))
{
g_free (priv->username);
priv->username = g_strdup (username);
}
if ((password != NULL) && (password[0] != '\0'))
{
g_free (priv->password);
priv->password = g_strdup (password);
}
priv->waiting = FALSE;
}
static void
auth_fn (SMBCCTX *smb_context,
const char *server,
@ -247,21 +152,20 @@ auth_fn (SMBCCTX *smb_context,
char *password,
int pwmaxlen)
{
PpSamba *samba;
GSource *source;
SMBData *data;
data = (SMBData *) smbc_getOptionUserData (smb_context);
samba = data->samba;
if (!data->cancelled)
{
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;
samba->priv->server = g_strdup (server);
samba->priv->share = g_strdup (share);
samba->priv->workgroup = g_strdup (workgroup);
samba->priv->username = g_strdup (username);
samba->priv->password = g_strdup (password);
source = g_idle_source_new ();
g_source_set_callback (source,
@ -276,19 +180,16 @@ auth_fn (SMBCCTX *smb_context,
* from this synchronous callback so we are blocking
* until we get them
*/
while (data->waiting)
while (samba->priv->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 (username, samba->priv->username) != 0)
g_strlcpy (username, samba->priv->username, unmaxlen);
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;
if (g_strcmp0 (password, samba->priv->password) != 0)
g_strlcpy (password, samba->priv->password, pwmaxlen);
}
}
@ -448,6 +349,7 @@ _pp_samba_get_devices_thread (GSimpleAsyncResult *res,
data = g_simple_async_result_get_op_res_gpointer (res);
data->devices = g_new0 (PpDevicesList, 1);
data->devices->devices = NULL;
data->samba = PP_SAMBA (object);
g_mutex_lock (&mutex);
@ -493,7 +395,6 @@ pp_samba_get_devices_async (PpSamba *samba,
gpointer user_data)
{
GSimpleAsyncResult *res;
PpSambaPrivate *priv = samba->priv;
SMBData *data;
gchar *hostname = NULL;
@ -504,7 +405,6 @@ pp_samba_get_devices_async (PpSamba *samba,
data->devices = NULL;
data->context = g_main_context_default ();
data->hostname_set = hostname != NULL;
data->parent = g_object_ref (priv->parent);
data->auth_if_needed = auth_if_needed;
g_simple_async_result_set_check_cancellable (res, cancellable);

View file

@ -63,6 +63,10 @@ PpDevicesList *pp_samba_get_devices_finish (PpSamba *samba,
GAsyncResult *result,
GError **error);
void pp_samba_set_auth_info (PpSamba *samba,
const gchar *username,
const gchar *password);
G_END_DECLS
#endif /* __PP_SAMBA_H__ */