brasero r1400 - in trunk: . src



Author: philippr
Date: Sun Oct 19 16:42:15 2008
New Revision: 1400
URL: http://svn.gnome.org/viewvc/brasero?rev=1400&view=rev

Log:
	Fix for #547395 â Support for remote filesystems

	* src/brasero-io.c (brasero_io_return_result_idle),
	(brasero_io_mount_enclosing_volume_cb),
	(brasero_io_mount_ask_password),
	(brasero_io_mount_enclosing_volume),
	(brasero_io_get_file_info_thread_real), (brasero_io_finalize):


Modified:
   trunk/ChangeLog
   trunk/src/brasero-io.c
   trunk/src/burn.c

Modified: trunk/src/brasero-io.c
==============================================================================
--- trunk/src/brasero-io.c	(original)
+++ trunk/src/brasero-io.c	Sun Oct 19 16:42:15 2008
@@ -52,6 +52,8 @@
 {
 	GMutex *lock;
 
+	GSList *mounted;
+
 	/* used for returning results */
 	GSList *results;
 	gint results_id;
@@ -127,6 +129,7 @@
 
 G_DEFINE_TYPE (BraseroIO, brasero_io, BRASERO_TYPE_ASYNC_TASK_MANAGER);
 
+
 /**
  * That's the structure to pass the progress on
  */
@@ -324,6 +327,7 @@
 						       FALSE);
 		brasero_io_job_result_free (result);
 	}
+
 	return TRUE;
 }
 
@@ -479,6 +483,101 @@
 }
 
 /**
+ * That's when we need to mount a remote volume
+ */
+
+struct _BraseroIOMount {
+	GError *error;
+	gboolean result;
+	gboolean finished;
+};
+typedef struct _BraseroIOMount BraseroIOMount;
+
+static void
+brasero_io_mount_enclosing_volume_cb (GObject *source,
+				      GAsyncResult *result,
+				      gpointer callback_data)
+{
+	BraseroIOMount *mount = callback_data;
+
+	BRASERO_BURN_LOG ("Volume mounting operation result");
+	mount->result = g_file_mount_enclosing_volume_finish (G_FILE (source),
+							      result,
+							      &mount->error);
+	mount->finished = TRUE;
+}
+
+static void
+brasero_io_mount_ask_password (GMountOperation *operation,
+			       gchar *message,
+			       gchar *default_user,
+			       gchar *default_domain,
+			       GAskPasswordFlags flags,
+			       gpointer user_data)
+{
+	BRASERO_BURN_LOG ("Password asked");
+	g_mount_operation_reply (operation, G_MOUNT_OPERATION_HANDLED);
+}
+
+static gboolean
+brasero_io_mount_enclosing_volume (BraseroIO *self,
+				   GFile *file,
+				   GCancellable *cancel,
+				   GError **error)
+{
+	GMount *mounted;
+	GMountOperation *operation;
+	BraseroIOMount mount = { NULL, };
+
+	operation = g_mount_operation_new ();
+	g_mount_operation_set_anonymous (operation, TRUE);
+	g_signal_connect (operation,
+			  "ask-password",
+			  G_CALLBACK (brasero_io_mount_ask_password),
+			  NULL);
+
+	g_file_mount_enclosing_volume (file,
+				       G_MOUNT_MOUNT_NONE,
+				       operation,
+				       cancel,
+				       brasero_io_mount_enclosing_volume_cb,
+				       &mount);
+
+	/* sleep and wait operation end */
+	while (!mount.finished && !g_cancellable_is_cancelled (cancel))
+		sleep (1);
+
+	mounted = g_file_find_enclosing_mount (file, cancel, NULL);
+	if (mounted) {
+		BraseroIOPrivate *priv;
+
+		priv = BRASERO_IO_PRIVATE (self);
+
+		/* Keep these for later to unmount them */
+		if (mount.result) {
+			g_mutex_lock (priv->lock);
+			priv->mounted = g_slist_prepend (priv->mounted, mounted);
+			g_mutex_unlock (priv->lock);
+		}
+		else
+			g_object_unref (mounted);
+	}
+
+	if (!mounted
+	&&   mount.error
+	&&  !g_cancellable_is_cancelled (cancel))
+		g_propagate_error (error, mount.error);
+	else if (mount.error)
+		g_error_free (mount.error);
+
+	BRASERO_BURN_LOG ("Parent volume is %s",
+			  (mounted != NULL && !g_cancellable_is_cancelled (cancel))?
+			  "mounted":"not mounted");
+
+	return (mounted != NULL && !g_cancellable_is_cancelled (cancel));
+}
+
+/**
  * This part deals with symlinks, that allows to get unique filenames by
  * replacing any parent symlink by its target and check for recursive
  * symlinks
@@ -862,12 +961,13 @@
 				  G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK ","
 				  G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET ","
 				  G_FILE_ATTRIBUTE_STANDARD_TYPE};
+	GError *local_error = NULL;
 	GFileInfo *info;
 	GFile *file;
 
 	if (g_cancellable_is_cancelled (cancel))
-		return BRASERO_ASYNC_TASK_FINISHED;
-	
+		return NULL;
+
 	if (options & BRASERO_IO_INFO_PERM)
 		strcat (attributes, "," G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
 	if (options & BRASERO_IO_INFO_MIME)
@@ -885,8 +985,35 @@
 				  attributes,
 				  G_FILE_QUERY_INFO_NONE,	/* follow symlinks */
 				  cancel,
-				  error);
+				  &local_error);
 	if (!info) {
+		if (local_error && local_error->code == G_IO_ERROR_NOT_MOUNTED) {
+			gboolean res;
+
+			BRASERO_BURN_LOG ("Starting to mount parent volume");
+			g_error_free (local_error);
+			local_error = NULL;
+
+			/* try to mount whatever has to be mounted */
+			/* NOTE: of course, we block a thread but one advantage
+			 * is that we won't have many queries to mount the same
+			 * remote volume at the same time. */
+			res = brasero_io_mount_enclosing_volume (BRASERO_IO (manager),
+								 file,
+								 cancel,
+								 error);
+			g_object_unref (file);
+			if (!res)
+				return NULL;
+
+			return brasero_io_get_file_info_thread_real (manager,
+								     cancel,
+								     uri,
+								     options,
+								     error);
+		}
+
+		g_propagate_error (error, local_error);
 		g_object_unref (file);
 		return NULL;
 	}
@@ -2600,6 +2727,25 @@
 		priv->lock = NULL;
 	}
 
+	if (priv->mounted) {
+		GSList *iter;
+
+		/* unmount all volumes we mounted ourselves */
+		for (iter = priv->mounted; iter; iter = iter->next) {
+			GMount *mount;
+
+			mount = iter->data;
+
+			BRASERO_BURN_LOG ("Unmountin volume");
+			g_mount_unmount (mount,
+					 G_MOUNT_UNMOUNT_NONE,
+					 NULL,
+					 NULL,
+					 NULL);
+			g_object_unref (mount);
+		}
+	}
+
 	G_OBJECT_CLASS (brasero_io_parent_class)->finalize (object);
 }
 

Modified: trunk/src/burn.c
==============================================================================
--- trunk/src/burn.c	(original)
+++ trunk/src/burn.c	Sun Oct 19 16:42:15 2008
@@ -355,6 +355,7 @@
 	priv = BRASERO_BURN_PRIVATE (self);
 
 	BRASERO_BURN_LOG ("Ejecting destination disc");
+
 	if (!priv->dest)
 		return BRASERO_BURN_OK;
 
@@ -394,6 +395,8 @@
 
 	priv = BRASERO_BURN_PRIVATE (self);
 
+	BRASERO_BURN_LOG ("Ejecting source disc");
+
 	if (!priv->src)
 		return BRASERO_BURN_OK;
 
@@ -503,20 +506,9 @@
 				 BraseroMedia required_media,
 				 GError **error)
 {
-	BraseroMedia media;
 	BraseroMedium *medium;
 	BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
 
-	medium = brasero_drive_get_medium (priv->dest);
-	media = brasero_medium_get_status (medium);
-	if (media != BRASERO_MEDIUM_NONE) {
-		BraseroBurnResult result;
-
-		result = brasero_burn_eject_dest_media (burn, error);
-		if (result != BRASERO_BURN_OK)
-			return result;
-	}
-
 	if (!priv->dest) {
 		priv->dest = brasero_burn_session_get_burner (priv->session);
 		if (!priv->dest) {
@@ -528,6 +520,15 @@
 		}
 	}
 
+	medium = brasero_drive_get_medium (priv->dest);
+	if (medium || brasero_medium_get_status (medium) != BRASERO_MEDIUM_NONE) {
+		BraseroBurnResult result;
+
+		result = brasero_burn_eject_dest_media (burn, error);
+		if (result != BRASERO_BURN_OK)
+			return result;
+	}
+
 	return brasero_burn_ask_for_media (burn,
 					   priv->dest,
 					   error_type,
@@ -2354,6 +2355,9 @@
 	BraseroBurnFlag session_flags;
 
 	priv = BRASERO_BURN_PRIVATE (burn);
+
+	BRASERO_BURN_LOG ("Reloading medium after copy");
+
 	/* Now there is the problem of flags... This really is a special
 	 * case. we need to try to adjust the flags to the media type
 	 * just after a new one is detected. For example there could be
@@ -2365,7 +2369,8 @@
 								    priv->session);
 	required_media &= (BRASERO_MEDIUM_WRITABLE|
 			   BRASERO_MEDIUM_CD|
-			   BRASERO_MEDIUM_DVD);
+			   BRASERO_MEDIUM_DVD|
+			   BRASERO_MEDIUM_BD);
 
 	/* There is sometimes no way to determine which type of media is
 	 * required since some flags (that will be adjusted afterwards)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]