gvfs r1426 - in trunk: . daemon
- From: otte svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1426 - in trunk: . daemon
- Date: Thu, 28 Feb 2008 17:45:28 +0000 (GMT)
Author: otte
Date: Thu Feb 28 17:45:28 2008
New Revision: 1426
URL: http://svn.gnome.org/viewvc/gvfs?rev=1426&view=rev
Log:
2008-02-28 Benjamin Otte <otte gnome org>
* daemon/gvfsbackendftp.c: (ftp_connection_create),
(ftp_connection_login), (ftp_connection_use), (ftp_connection_new):
split out login code, so we can try multiple auths when some fail.
Modified:
trunk/ChangeLog
trunk/daemon/gvfsbackendftp.c
Modified: trunk/daemon/gvfsbackendftp.c
==============================================================================
--- trunk/daemon/gvfsbackendftp.c (original)
+++ trunk/daemon/gvfsbackendftp.c Thu Feb 28 17:45:28 2008
@@ -466,11 +466,9 @@
}
static FtpConnection *
-ftp_connection_new (SoupAddress * addr,
- GCancellable *cancellable,
- const char * username,
- const char * password,
- GError ** error)
+ftp_connection_create (SoupAddress * addr,
+ GCancellable *cancellable,
+ GError ** error)
{
FtpConnection *conn;
guint status;
@@ -494,35 +492,72 @@
status = ftp_connection_receive (conn, 0, error);
if (status == 0)
goto fail;
+
+ return conn;
+
+fail:
+ ftp_connection_free (conn);
+ return NULL;
+}
+
+static guint
+ftp_connection_login (FtpConnection *conn,
+ const char * username,
+ const char * password,
+ GError ** error)
+{
+ guint status;
status = ftp_connection_send (conn, RESPONSE_PASS_300, error,
"USER %s", username);
- if (status == 0)
- goto fail;
- else if (STATUS_GROUP (status) == 3)
- {
- status = ftp_connection_send (conn, 0, error,
- "PASS %s", password);
- if (status == 0)
- goto fail;
- }
+
+ if (STATUS_GROUP (status) == 3)
+ status = ftp_connection_send (conn, 0, error,
+ "PASS %s", password);
+
+ return status;
+}
+
+static gboolean
+ftp_connection_use (FtpConnection *conn,
+ GError ** error)
+{
+ guint status;
/* only binary transfers please */
status = ftp_connection_send (conn, 0, error, "TYPE I");
if (status == 0)
- goto fail;
+ return FALSE;
/* check supported features */
status = ftp_connection_send (conn, 0, NULL, "FEAT");
if (status != 0)
ftp_connection_parse_features (conn);
+ return TRUE;
+}
- return conn;
+static FtpConnection *
+ftp_connection_new (SoupAddress * addr,
+ GCancellable *cancellable,
+ const char * username,
+ const char * password,
+ GError ** error)
+{
+ FtpConnection *conn;
-fail:
- ftp_connection_free (conn);
- return NULL;
+ conn = ftp_connection_create (addr, cancellable, error);
+ if (conn == NULL)
+ return NULL;
+
+ if (ftp_connection_login (conn, username, password, error) == 0 ||
+ !ftp_connection_use (conn, error))
+ {
+ ftp_connection_free (conn);
+ return NULL;
+ }
+
+ return conn;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]