diff options
| author | Tomas Bzatek <tbzatek@tbzatek.englab.brq.redhat.com> | 2008-09-02 17:59:54 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@tbzatek.englab.brq.redhat.com> | 2008-09-02 17:59:54 +0200 |
| commit | 343dba08da92dc2f1d24168944bc08ae93d33cf9 (patch) | |
| tree | a23b935ed1091dfebc0341db1dd8d3cc26bf9056 | |
| parent | dbc4ef453c272395b7846c29d23cf6c6a696c98b (diff) | |
| download | tuxcmd-modules-343dba08da92dc2f1d24168944bc08ae93d33cf9.tar.xz | |
GVFS plugin: finish mount loop
Only password URI ripper missing now (will become obsolete with new VFS API anyway)
| -rw-r--r-- | gvfs/gvfs.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/gvfs/gvfs.c b/gvfs/gvfs.c index 5744d0c..1a753d6 100644 --- a/gvfs/gvfs.c +++ b/gvfs/gvfs.c @@ -26,14 +26,13 @@ #include <gio/gio.h> #include <glib/gtypes.h> -// #include <gdk/gdk.h> #include "vfs_types.h" -#define VERSION "0.0.3" -#define BUILD_DATE "2008-08-28" +#define VERSION "0.0.4" +#define BUILD_DATE "2008-09-02" #define DEFAULT_BLOCK_SIZE 0x10000 /* 64kB */ #define CONST_DEFAULT_QUERY_INFO_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_NAME "," \ @@ -49,6 +48,7 @@ struct TVFSGlobs { GFileEnumerator *enumerator; GMainLoop *mount_main_loop; + TVFSResult mount_result; gboolean break_get_dir_size; guint32 block_size; @@ -125,37 +125,31 @@ ask_password_cb (GMountOperation *op, gpointer user_data) { struct TVFSGlobs *globs; - char *s; - globs = (struct TVFSGlobs*) user_data; + g_assert (globs != NULL); - g_print ("(II) ask_password_cb: message = '%s'\n", message); + g_print ("(WW) ask_password_cb: message = '%s'\n", message); if (flags & G_ASK_PASSWORD_NEED_USERNAME) { g_print (" need username...\n"); -/* - s = prompt_for ("User", default_user, TRUE); - g_mount_operation_set_username (op, s); - g_free (s); -*/ +/* FIXME: need proper API and spawn callback + g_mount_operation_set_username (op, s); */ } if (flags & G_ASK_PASSWORD_NEED_DOMAIN) { g_print (" need domain...\n"); -/* - s = prompt_for ("Domain", default_domain, TRUE); - g_mount_operation_set_domain (op, s); - g_free (s); -*/ +/* FIXME: need proper API and spawn callback + g_mount_operation_set_domain (op, s); */ } 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); @@ -175,17 +169,24 @@ mount_done_cb (GObject *object, GError *error = NULL; globs = (struct TVFSGlobs*) user_data; + g_assert (globs != NULL); + succeeded = g_file_mount_enclosing_volume_finish (G_FILE (object), res, &error); if (! succeeded) { g_print ("(EE) Error mounting location: %s\n", error->message); + globs->mount_result = g_error_to_TVFSResult (error); g_error_free (error); } + else { + globs->mount_result = cVFS_OK; + g_print ("(II) Mount successful.\n"); + } g_main_loop_quit (globs->mount_main_loop); } -static gboolean +static TVFSResult vfs_handle_mount (struct TVFSGlobs *globs, GFile *file) { GMountOperation *op; @@ -194,17 +195,16 @@ vfs_handle_mount (struct TVFSGlobs *globs, GFile *file) op = g_mount_operation_new (); g_signal_connect (op, "ask_password", (GCallback)ask_password_cb, globs); + globs->mount_result = cVFS_Failed; -// gdk_threads_enter (); + /* Inspiration taken from Bastien Nocera's http://svn.gnome.org/viewvc/totem-pl-parser/trunk/plparse/totem-disc.c?view=markup */ 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; */ -// gdk_threads_leave (); + g_main_loop_unref (globs->mount_main_loop); + globs->mount_main_loop = NULL; - - return FALSE; + return globs->mount_result; } void @@ -304,7 +304,13 @@ VFSOpen (struct TVFSGlobs *globs, char *sName) } } if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED)) { - vfs_handle_mount (globs, f); + g_error_free (error); + error = NULL; + res = vfs_handle_mount (globs, f); + if (res != cVFS_OK) + return res; + else + continue; } if (error) { g_print ("(EE) VFSOpen: g_file_query_info() error: %s\n", error->message); |
