summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-03-04 10:56:43 +0000
committerBenjamin Otte <otte@src.gnome.org>2008-03-04 10:56:43 +0000
commit13a1cd21fe5bbeb50c16b0a3cc68a0acb1af90b2 (patch)
tree0ea0e4ba78709e476499c5f7387edf3a963df544 /common
parent3cd81d08a157eb3723ed105f770b8da042d9bb54 (diff)
downloadgvfs-13a1cd21fe5bbeb50c16b0a3cc68a0acb1af90b2.tar.gz
add an anonymous_out parameter for anonymous logins.
2008-03-04 Benjamin Otte <otte@gnome.org> * common/gmountsource.c: (ask_password_reply), (g_mount_source_ask_password_finish), (g_mount_source_ask_password), (op_ask_password_reply): * common/gmountsource.h: add an anonymous_out parameter for anonymous logins. * daemon/gvfsbackenddav.c: (soup_authenticate_interactive): * daemon/gvfsbackendsftp.c: (handle_login): * daemon/gvfsbackendsmb.c: (auth_callback): make the backends compile with the new parameter. They don't use anonymous logins. * daemon/gvfsbackendftp.c: (do_mount): make login work as users would expect it with anonymous logins. Fixes bug #520131 svn path=/trunk/; revision=1520
Diffstat (limited to 'common')
-rw-r--r--common/gmountsource.c81
-rw-r--r--common/gmountsource.h2
2 files changed, 44 insertions, 39 deletions
diff --git a/common/gmountsource.c b/common/gmountsource.c
index d7bfbb18..8e9ed961 100644
--- a/common/gmountsource.c
+++ b/common/gmountsource.c
@@ -129,6 +129,7 @@ struct AskPasswordData {
char *username;
char *domain;
GPasswordSave password_save;
+ gboolean anonymous;
};
typedef struct AskSyncData AskSyncData;
@@ -193,10 +194,14 @@ ask_password_reply (DBusMessage *reply,
{
data->aborted = aborted;
- data->password = *password == 0 ? NULL : g_strdup (password);
- data->username = *username == 0 ? NULL : g_strdup (username);
- data->domain = *domain == 0 ? NULL : g_strdup (domain);
+ if (!anonymous)
+ {
+ data->password = *password == 0 ? NULL : g_strdup (password);
+ data->username = *username == 0 ? NULL : g_strdup (username);
+ data->domain = *domain == 0 ? NULL : g_strdup (domain);
+ }
data->password_save = (GPasswordSave)password_save;
+ data->anonymous = anonymous;
/* TODO: handle more args */
}
@@ -265,6 +270,27 @@ g_mount_source_ask_password_async (GMountSource *source,
}
+/**
+ * g_mount_source_ask_password_finish:
+ * @source: the source to query
+ * @result: the async result
+ * @aborted: set to %TRUE if the password dialog was aborted by the user
+ * @password_out: the to the password set by the user or to %NULL if none
+ * @user_out: set to the username set by the user or to %NULL if none
+ * @domain_out: set to the domain set by the user or to %NULL if none
+ * @anonymous_out: set to %TRUE if the user selected anonymous login. This
+ * should only happen if G_ASK_PASSWORD_ANONYMOUS_SUPPORTED
+ * was supplied whe querying the password.
+ * @password_save_out: set to the save flags to use when saving the password
+ * in the keyring.
+ *
+ * Requests the reply parameters from a g_mount_source_ask_password_async()
+ * request. All out parameters can be set to %NULL to ignore them.
+ * <note><para>Please be aware that all string parameters can be set to %NULL,
+ * so make sure to check them.</para></note>
+ *
+ * Returns: %FALSE if the async reply contained an error.
+ **/
gboolean
g_mount_source_ask_password_finish (GMountSource *source,
GAsyncResult *result,
@@ -272,6 +298,7 @@ g_mount_source_ask_password_finish (GMountSource *source,
char **password_out,
char **user_out,
char **domain_out,
+ gboolean *anonymous_out,
GPasswordSave *password_save_out)
{
AskPasswordData *data, def = { TRUE, };
@@ -305,6 +332,9 @@ g_mount_source_ask_password_finish (GMountSource *source,
data->domain = NULL;
}
+ if (anonymous_out)
+ *anonymous_out = data->anonymous;
+
if (password_save_out)
*password_save_out = data->password_save;
@@ -339,20 +369,12 @@ g_mount_source_ask_password (GMountSource *source,
char **password_out,
char **user_out,
char **domain_out,
+ gboolean *anonymous_out,
GPasswordSave *password_save_out)
{
- char *password, *username, *domain;
- GPasswordSave password_save;
- gboolean handled, aborted;
+ gboolean handled;
AskSyncData data = {NULL};
- if (password_out)
- *password_out = NULL;
- if (user_out)
- *user_out = NULL;
- if (domain_out)
- *domain_out = NULL;
-
data.mutex = g_mutex_new ();
data.cond = g_cond_new ();
@@ -376,34 +398,14 @@ g_mount_source_ask_password (GMountSource *source,
handled = g_mount_source_ask_password_finish (source,
data.result,
- &aborted,
- &password,
- &username,
- &domain,
- &password_save);
+ aborted_out,
+ password_out,
+ user_out,
+ domain_out,
+ anonymous_out,
+ password_save_out);
g_object_unref (data.result);
- if (aborted_out)
- *aborted_out = aborted;
-
- if (password_out)
- *password_out = password;
- else
- g_free (password);
-
- if (user_out)
- *user_out = username;
- else
- g_free (username);
-
- if (domain_out)
- *domain_out = domain;
- else
- g_free (domain);
-
- if (password_save_out)
- *password_save_out = password_save;
-
return handled;
}
@@ -433,6 +435,7 @@ op_ask_password_reply (GObject *source_object,
&username,
&password,
&domain,
+ NULL,
&password_save);
if (!handled)
diff --git a/common/gmountsource.h b/common/gmountsource.h
index 676595ff..e4298357 100644
--- a/common/gmountsource.h
+++ b/common/gmountsource.h
@@ -65,6 +65,7 @@ gboolean g_mount_source_ask_password (GMountSource
char **password_out,
char **user_out,
char **domain_out,
+ gboolean *anonymous_out,
GPasswordSave *password_save_out);
void g_mount_source_ask_password_async (GMountSource *mount_source,
@@ -81,6 +82,7 @@ gboolean g_mount_source_ask_password_finish (GMountSource
char **password_out,
char **user_out,
char **domain_out,
+ gboolean *anonymous_out,
GPasswordSave *password_save_out);
gboolean g_mount_source_ask_question (GMountSource *mount_source,