summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gvfs/gvfs.c79
1 files changed, 69 insertions, 10 deletions
diff --git a/gvfs/gvfs.c b/gvfs/gvfs.c
index 1a753d6..54ff29f 100644
--- a/gvfs/gvfs.c
+++ b/gvfs/gvfs.c
@@ -31,8 +31,8 @@
-#define VERSION "0.0.4"
-#define BUILD_DATE "2008-09-02"
+#define VERSION "0.0.5"
+#define BUILD_DATE "2008-09-03"
#define DEFAULT_BLOCK_SIZE 0x10000 /* 64kB */
#define CONST_DEFAULT_QUERY_INFO_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_NAME "," \
@@ -49,6 +49,7 @@ struct TVFSGlobs {
GMainLoop *mount_main_loop;
TVFSResult mount_result;
+ gchar *mount_password;
gboolean break_get_dir_size;
guint32 block_size;
@@ -148,12 +149,8 @@ ask_password_cb (GMountOperation *op,
if (flags & G_ASK_PASSWORD_NEED_PASSWORD)
{
g_print (" need password...\n");
-
-/*
- s = prompt_for ("Password", NULL, FALSE);
- g_mount_operation_set_password (op, s);
- g_free (s);
-*/
+ if (globs->mount_password)
+ g_mount_operation_set_password (op, globs->mount_password);
}
g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
@@ -201,8 +198,10 @@ vfs_handle_mount (struct TVFSGlobs *globs, GFile *file)
globs->mount_main_loop = g_main_loop_new (NULL, FALSE);
g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE, op, NULL, mount_done_cb, globs);
g_main_loop_run (globs->mount_main_loop);
+
g_main_loop_unref (globs->mount_main_loop);
globs->mount_main_loop = NULL;
+ g_object_unref (op);
return globs->mount_result;
}
@@ -281,11 +280,70 @@ VFSOpen (struct TVFSGlobs *globs, char *sName)
GError *error;
TVFSResult res;
gboolean try_again;
+ gchar **uri_matched;
+ char *uri_schema, *uri_username, *uri_password, *uri_service;
+ gchar *uri;
+ int i, seg;
- g_print ("(II) VFSOpen: opening URI '%s'\n", sName);
globs->file = NULL;
+ globs->mount_password = NULL;
+ uri = NULL;
+
+ /* Rip out password as GVFS URIs should contain only username (and domain). */
+ /* Password will be used in GMountOperation later */
+ /* FIXME: this just temporary solution until we got new VFS API */
+ /* (this is really ugly code) */
+ if (strstr (sName, "@") != NULL) {
+ uri_schema = NULL;
+ uri_username = NULL;
+ uri_password = NULL;
+ uri_service = NULL;
+
+ uri_matched = g_regex_split_simple ("^(.*)://(.*):(.*)@(.*)", sName, G_REGEX_CASELESS | G_REGEX_UNGREEDY | G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED);
+ if (uri_matched) {
+ seg = 0;
+ for (i = 0; uri_matched[i] != NULL; i++)
+ if (strlen (uri_matched[i]) > 0) {
+ seg++;
+ switch (seg) {
+ case 1:
+ uri_schema = g_strdup (uri_matched[i]);
+ break;
+ case 2:
+ uri_username = g_strdup (uri_matched[i]);
+ break;
+ case 3:
+ uri_password = g_strdup (uri_matched[i]);
+ break;
+ case 4:
+ uri_service = g_strdup (uri_matched[i]);
+ break;
+ }
+ }
+ g_strfreev (uri_matched);
+
+ globs->mount_password = g_strdup (uri_password);
+ if (seg == 4 && uri_schema && uri_username && uri_password && uri_service)
+ uri = g_strdup_printf ("%s://%s@%s", uri_schema, uri_username, uri_service);
+ }
+
+// g_print ("uri_schema = '%s', uri_username = '%s', uri_password = '%s', uri_service = '%s'\n", uri_schema, uri_username, uri_password, uri_service);
+// g_print ("uri = '%s'\n", uri);
+ if (uri_schema)
+ free (uri_schema);
+ if (uri_username)
+ free (uri_username);
+ if (uri_password)
+ free (uri_password);
+ if (uri_service)
+ free (uri_service);
+ }
+
- f = g_file_new_for_commandline_arg (sName);
+ g_print ("(II) VFSOpen: opening URI '%s'\n", uri ? uri : sName);
+ f = g_file_new_for_commandline_arg (uri ? uri : sName);
+ if (uri)
+ g_free (uri);
try_again = FALSE;
while (1) {
@@ -1294,5 +1352,6 @@ VFSCopyIn (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
* - block size settings for GIO subsystem
* - variable block size for different protocols?
* - support for appending in VFSCopyIn
+ * - authentication improvements (needs new VFS API)
*
***/