summaryrefslogtreecommitdiff
path: root/gvfs
diff options
context:
space:
mode:
Diffstat (limited to 'gvfs')
-rw-r--r--gvfs/gvfs.c80
1 files changed, 27 insertions, 53 deletions
diff --git a/gvfs/gvfs.c b/gvfs/gvfs.c
index 557f08c..a5734cf 100644
--- a/gvfs/gvfs.c
+++ b/gvfs/gvfs.c
@@ -31,8 +31,8 @@
-#define VERSION "0.1.3"
-#define BUILD_DATE "2008-10-12"
+#define VERSION "0.1.4"
+#define BUILD_DATE "2008-10-28"
#define DEFAULT_BLOCK_SIZE 0x10000 /* 64kB */
#define CONST_DEFAULT_QUERY_INFO_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_NAME "," \
@@ -46,6 +46,7 @@ struct TVFSGlobs {
TVFSLogFunc log_func;
GFile *file;
GFileEnumerator *enumerator;
+ GCancellable *cancellable;
GMainLoop *mount_main_loop;
TVFSResult mount_result;
@@ -57,7 +58,8 @@ struct TVFSGlobs {
TVFSAskQuestionCallback callback_ask_question;
TVFSAskPasswordCallback callback_ask_password;
- void *callbacks_data;
+ TVFSProgressCallback callback_progress;
+ void *callback_data;
};
@@ -167,9 +169,9 @@ ask_password_cb (GMountOperation *op,
if (globs->callback_ask_password) {
fprintf (stderr, " (II) Spawning callback_ask_password (0x%.16llX)...\n", (unsigned long long) globs->callback_ask_password);
- result = globs->callback_ask_password (message, default_user, default_domain, flags,
+ result = globs->callback_ask_password (message, default_user, default_domain, NULL, flags,
&username, &password, &anonymous, &domain, &password_save,
- globs->callbacks_data);
+ globs->callback_data);
fprintf (stderr, " (II) Received result = %d\n", result);
if (result) {
if (flags & G_ASK_PASSWORD_NEED_USERNAME)
@@ -217,7 +219,7 @@ ask_question_cb (GMountOperation *op,
if (globs->callback_ask_question) {
fprintf (stderr, " (II) Spawning callback_ask_question (0x%.16llX)...\n", (unsigned long long) globs->callback_ask_question);
/* At this moment, only SFTP uses ask_question and the second button is cancellation */
- globs->callback_ask_question (message, choices, &choice, 1, globs->callbacks_data);
+ globs->callback_ask_question (message, choices, &choice, 1, globs->callback_data);
fprintf (stderr, " (II) Received choice = %d\n", choice);
if (choice >= 0) {
@@ -298,13 +300,15 @@ VFSNew (TVFSLogFunc log_func)
globs->file = NULL;
globs->enumerator = NULL;
+ globs->cancellable = NULL;
globs->break_get_dir_size = FALSE;
globs->block_size = DEFAULT_BLOCK_SIZE;
- globs->callbacks_data = NULL;
+ globs->callback_data = NULL;
globs->callback_ask_question = NULL;
globs->callback_ask_password = NULL;
+ globs->callback_progress = NULL;
return globs;
}
@@ -313,11 +317,13 @@ void
VFSSetCallbacks (struct TVFSGlobs *globs,
TVFSAskQuestionCallback ask_question_callback,
TVFSAskPasswordCallback ask_password_callback,
+ TVFSProgressCallback progress_func,
void *data)
{
globs->callback_ask_question = ask_question_callback;
globs->callback_ask_password = ask_password_callback;
- globs->callbacks_data = data;
+ globs->callback_progress = progress_func;
+ globs->callback_data = data;
}
void
@@ -599,17 +605,6 @@ VFSChangeDir (struct TVFSGlobs *globs, char *NewPath)
return res;
}
-int
-VFSLogin (struct TVFSGlobs *globs, char *user, char *pass)
-{
- g_print ("(II) VFSLogin: logging in with '%s'/'%s'\n", user, pass);
-
- /* FIXME: add auth code */
-
- return cVFS_Not_Supported;
-}
-
-
/**************************************************************************************************************************************/
/**************************************************************************************************************************************/
@@ -1275,41 +1270,31 @@ VFSTwoSameFiles (struct TVFSGlobs *globs, const char *Path1, const char *Path2)
/**************************************************************************************************************************************/
/**************************************************************************************************************************************/
-
-struct CopyJobRef {
- struct TVFSGlobs *globs;
- TVFSCopyCallBackFunc callback_func;
- void *callback_data;
-
- GCancellable *cancellable;
-};
-
static void
vfs_copy_progress_callback (goffset current_num_bytes,
goffset total_num_bytes,
gpointer user_data)
{
- struct CopyJobRef *ref;
+ struct TVFSGlobs *globs;
// g_print ("(II) vfs_copy_progress_callback spawned: current_num_bytes = %lu, total_num_bytes = %lu\n", current_num_bytes, total_num_bytes);
if (! user_data)
return;
- ref = (struct CopyJobRef*) user_data;
+ globs = (struct TVFSGlobs *)user_data;
- if (ref->callback_func) {
- if (! ref->callback_func (current_num_bytes, total_num_bytes, ref->callback_data))
- g_cancellable_cancel (ref->cancellable);
+ if (globs->callback_progress) {
+ if (! globs->callback_progress (current_num_bytes, total_num_bytes, globs->callback_data))
+ g_cancellable_cancel (globs->cancellable);
}
}
TVFSResult
-VFSCopyOut (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, gboolean Append)
+VFSCopyOut (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append)
{
GFile *src, *dst;
GError *error;
- struct CopyJobRef *ref;
TVFSResult res;
@@ -1331,15 +1316,11 @@ VFSCopyOut (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
return cVFS_Failed;
}
- ref = g_slice_new0 (struct CopyJobRef);
- ref->globs = globs;
- ref->callback_func = pCallBackProgress;
- ref->callback_data = data;
- ref->cancellable = g_cancellable_new ();
+ globs->cancellable = g_cancellable_new ();
res = cVFS_OK;
error = NULL;
- g_file_copy (src, dst, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS, ref->cancellable, vfs_copy_progress_callback, ref, &error);
+ g_file_copy (src, dst, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS, globs->cancellable, vfs_copy_progress_callback, globs, &error);
if (error) {
g_print ("(EE) VFSCopyOut: g_file_copy() error: %s\n", error->message);
// res = g_error_to_TVFSResult (error);
@@ -1349,19 +1330,17 @@ VFSCopyOut (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
g_error_free (error);
}
- g_object_unref (ref->cancellable);
- g_slice_free (struct CopyJobRef, ref);
+ g_object_unref (globs->cancellable);
g_object_unref (src);
g_object_unref (dst);
return res;
}
TVFSResult
-VFSCopyIn (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, gboolean Append)
+VFSCopyIn (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append)
{
GFile *src, *dst;
GError *error;
- struct CopyJobRef *ref;
TVFSResult res;
@@ -1383,16 +1362,12 @@ VFSCopyIn (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
return cVFS_Failed;
}
- ref = g_slice_new0 (struct CopyJobRef);
- ref->globs = globs;
- ref->callback_func = pCallBackProgress;
- ref->callback_data = data;
- ref->cancellable = g_cancellable_new ();
+ globs->cancellable = g_cancellable_new ();
res = cVFS_OK;
error = NULL;
/* FIXME: Appending not supported */
- g_file_copy (src, dst, G_FILE_COPY_NOFOLLOW_SYMLINKS, ref->cancellable, vfs_copy_progress_callback, ref, &error);
+ g_file_copy (src, dst, G_FILE_COPY_NOFOLLOW_SYMLINKS, globs->cancellable, vfs_copy_progress_callback, globs, &error);
if (error) {
g_print ("(EE) VFSCopyIn: g_file_copy() error: %s\n", error->message);
// res = g_error_to_TVFSResult (error);
@@ -1402,8 +1377,7 @@ VFSCopyIn (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName,
g_error_free (error);
}
- g_object_unref (ref->cancellable);
- g_slice_free (struct CopyJobRef, ref);
+ g_object_unref (globs->cancellable);
g_object_unref (src);
g_object_unref (dst);
return res;