Example #1
0
File: gmount.c Project: Andais/glib
/**
 * g_mount_guess_content_type:
 * @mount: a #GMount
 * @force_rescan: Whether to force a rescan of the content. 
 *     Otherwise a cached result will be used if available
 * @cancellable: optional #GCancellable object, %NULL to ignore
 * @callback: a #GAsyncReadyCallback
 * @user_data: user data passed to @callback
 * 
 * Tries to guess the type of content stored on @mount. Returns one or
 * more textual identifiers of well-known content types (typically
 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera 
 * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
 * specification for more on x-content types.
 *
 * This is an asynchronous operation (see
 * g_mount_guess_content_type_sync() for the synchronous version), and
 * is finished by calling g_mount_guess_content_type_finish() with the
 * @mount and #GAsyncResult data returned in the @callback.
 *
 * Since: 2.18
 */
void
g_mount_guess_content_type (GMount              *mount,
                            gboolean             force_rescan,
                            GCancellable        *cancellable,
                            GAsyncReadyCallback  callback,
                            gpointer             user_data)
{
  GMountIface *iface;

  g_return_if_fail (G_IS_MOUNT (mount));

  iface = G_MOUNT_GET_IFACE (mount);

  if (iface->guess_content_type == NULL)
    {
      g_simple_async_report_error_in_idle (G_OBJECT (mount),
                                           callback, user_data,
                                           G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                                           /* Translators: This is an error
                                            * message for mount objects that
                                            * don't implement content type guessing. */
                                           _("mount doesn't implement content type guessing"));

      return;
    }
  
  (* iface->guess_content_type) (mount, force_rescan, cancellable, callback, user_data);
}
Example #2
0
static void
rb_removable_media_manager_eject_cb (GObject *object,
				     GAsyncResult *result,
				     RBRemovableMediaManager *mgr)
{
	GError *error = NULL;

	if (G_IS_VOLUME (object)) {
		GVolume *volume = G_VOLUME (object);

		rb_debug ("finishing ejection of volume");
		g_volume_eject_finish (volume, result, &error);
		if (error == NULL) {
			rb_removable_media_manager_remove_volume (mgr, volume);
		}
	} else if (G_IS_MOUNT (object)) {
		GMount *mount = G_MOUNT (object);

		rb_debug ("finishing ejection of mount");
		g_mount_eject_finish (mount, result, &error);
		if (error == NULL) {
			rb_removable_media_manager_remove_mount (mgr, mount);
		}
	}

	if (error != NULL) {
		if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) {
			rb_error_dialog (NULL, _("Unable to eject"), "%s", error->message);
		} else {
			rb_debug ("eject failure has already been handled");
		}
		g_error_free (error);
	}
	g_object_unref (mgr);
}
Example #3
0
static void
eject_cb (GObject *object, GAsyncResult *result, gpointer nothing)
{
	GError *error = NULL;

	if (G_IS_VOLUME (object)) {
		GVolume *volume = G_VOLUME (object);

		rb_debug ("finishing ejection of volume");
		g_volume_eject_with_operation_finish (volume, result, &error);
	} else if (G_IS_MOUNT (object)) {
		GMount *mount = G_MOUNT (object);

		rb_debug ("finishing ejection of mount");
		g_mount_eject_with_operation_finish (mount, result, &error);
	}

	if (error != NULL) {
		if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) {
			rb_error_dialog (NULL, _("Unable to eject"), "%s", error->message);
		} else {
			rb_debug ("eject failure has already been handled");
		}
		g_error_free (error);
	}
}
Example #4
0
File: gmount.c Project: Andais/glib
/**
 * g_mount_remount:
 * @mount: a #GMount.
 * @flags: flags affecting the operation
 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
 * @cancellable: optional #GCancellable object, %NULL to ignore.
 * @callback: a #GAsyncReadyCallback, or %NULL.
 * @user_data: user data passed to @callback.
 * 
 * Remounts a mount. This is an asynchronous operation, and is 
 * finished by calling g_mount_remount_finish() with the @mount 
 * and #GAsyncResults data returned in the @callback.
 *
 * Remounting is useful when some setting affecting the operation
 * of the volume has been changed, as these may need a remount to
 * take affect. While this is semantically equivalent with unmounting
 * and then remounting not all backends might need to actually be
 * unmounted.
 **/
void
g_mount_remount (GMount              *mount,
                 GMountMountFlags     flags,
                 GMountOperation     *mount_operation,
                 GCancellable        *cancellable,
                 GAsyncReadyCallback  callback,
                 gpointer             user_data)
{
  GMountIface *iface;

  g_return_if_fail (G_IS_MOUNT (mount));
  
  iface = G_MOUNT_GET_IFACE (mount);

  if (iface->remount == NULL)
    { 
      g_simple_async_report_error_in_idle (G_OBJECT (mount),
					   callback, user_data,
					   G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
					   /* Translators: This is an error
					    * message for mount objects that
					    * don't implement remount. */
					   _("mount doesn't implement \"remount\""));
      
      return;
    }
  
  (* iface->remount) (mount, flags, mount_operation, cancellable, callback, user_data);
}
Example #5
0
File: gmount.c Project: Andais/glib
/**
 * g_mount_can_eject: 
 * @mount: a #GMount.
 * 
 * Checks if @mount can be eject.
 * 
 * Returns: %TRUE if the @mount can be ejected.
 **/
gboolean
g_mount_can_eject (GMount *mount)
{
  GMountIface *iface;

  g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);

  iface = G_MOUNT_GET_IFACE (mount);

  return (* iface->can_eject) (mount);
}
Example #6
0
File: gmount.c Project: Andais/glib
/**
 * g_mount_get_drive:
 * @mount: a #GMount.
 * 
 * Gets the drive for the @mount.
 *
 * This is a convenience method for getting the #GVolume and then
 * using that object to get the #GDrive.
 * 
 * Returns: a #GDrive or %NULL if @mount is not associated with a volume or a drive.
 *      The returned object should be unreffed with 
 *      g_object_unref() when no longer needed.
 **/
GDrive *
g_mount_get_drive (GMount *mount)
{
  GMountIface *iface;

  g_return_val_if_fail (G_IS_MOUNT (mount), NULL);

  iface = G_MOUNT_GET_IFACE (mount);

  return (* iface->get_drive) (mount);
}
Example #7
0
static gboolean
tvm_block_device_autophoto (TvmContext *context,
                            GMount     *mount,
                            GError    **error)
{
  gboolean autophoto;
  gboolean result = FALSE;
  gchar   *autophoto_command;
  gint     response;

  g_return_val_if_fail (context != NULL, FALSE);
  g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  /* check if autophoto support is enabled */
  autophoto = xfconf_channel_get_bool (context->channel, "/autophoto/enabled", FALSE);
  if (autophoto)
    {
      autophoto_command = xfconf_channel_get_string (context->channel, 
                                                     "/autophoto/command", NULL);
      if (autophoto_command != NULL && *autophoto_command != '\0')
        {
          /* check if we have any photos on the volume */
          if (tvm_file_test (mount, "dcim", G_FILE_TEST_IS_DIR))
            {
              /* ask the user to import photos */
              response = tvm_prompt (context, "camera-photo", _("Photo Import"),
                                     _("A photo card has been detected"),
                                     _("There are photos on the card. Would you like to "
                                       "add these photos to your album?"),
                                     _("Ig_nore"), GTK_RESPONSE_CANCEL,
                                     _("Import _Photos"), TVM_RESPONSE_PHOTOS,
                                     NULL);

              if (response == TVM_RESPONSE_PHOTOS)
                {
                  /* run the preferred photo application */
                  result = tvm_run_command (context, mount, autophoto_command, error);
                }
              else
                {
                  /* pretend that we handled the device */
                  result = TRUE;
                }
            }
        }
          
      g_free (autophoto_command);
    }

  return result;
}
Example #8
0
void
thunar_notify_unmount_finish (GMount *mount)
{
  NotifyNotification *notification;

  g_return_if_fail (G_IS_MOUNT (mount));

  notification = g_object_get_data (G_OBJECT (mount), "thunar-notification");
  if (notification != NULL)
    {
      notify_notification_close (notification, NULL);
      g_object_set_data (G_OBJECT (mount), "thunar-notification", NULL);
    }
}
Example #9
0
static gboolean
tvm_file_test (GMount      *mount,
               const gchar *filename,
               GFileTest    test)
{
  const gchar *name;
  gboolean     result = FALSE;
  GFile       *mount_point;
  gchar       *directory;
  gchar       *path;
  GDir        *dp;

  g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
  g_return_val_if_fail (filename != NULL && *filename != '\0', FALSE);

  mount_point = g_mount_get_root (mount);
  directory = g_file_get_path (mount_point);
  g_object_unref (mount_point);

  /* try to open the specified directory */
  dp = g_dir_open (directory, 0, NULL);
  if (G_LIKELY (dp != NULL))
    {
      while (!result)
        {
          /* read the next entry */
          name = g_dir_read_name (dp);
          if (G_UNLIKELY (name == NULL))
            break;

          /* check if we have a potential match */
          if (g_ascii_strcasecmp (name, filename) == 0)
            {
              /* check if test condition met */
              path = g_build_filename (directory, name, NULL);
              result = g_file_test (path, test);
              g_free (path);
            }
        }

      /* cleanup */
      g_dir_close (dp);
    }

  g_free (directory);

  return result;
}
Example #10
0
File: gmount.c Project: Andais/glib
/**
 * g_mount_get_default_location:
 * @mount: a #GMount.
 *
 * Gets the default location of @mount. The default location of the given
 * @mount is a path that reflects the main entry point for the user (e.g.
 * the home directory, or the root of the volume).
 *
 * Returns: a #GFile.
 *      The returned object should be unreffed with
 *      g_object_unref() when no longer needed.
 **/
GFile *
g_mount_get_default_location (GMount *mount)
{
  GMountIface *iface;
  GFile       *file;

  g_return_val_if_fail (G_IS_MOUNT (mount), NULL);

  iface = G_MOUNT_GET_IFACE (mount);
  
  /* Fallback to get_root when default_location () is not available */
  if (iface->get_default_location)
    file = (* iface->get_default_location) (mount);
  else
    file = (* iface->get_root) (mount);

  return file;
}
static void
xfdesktop_volume_icon_unmount_finish(GObject *object,
                                     GAsyncResult *result,
                                     gpointer user_data)
{
    XfdesktopVolumeIcon *icon = XFDESKTOP_VOLUME_ICON(user_data);
    GtkWidget *icon_view = xfdesktop_icon_peek_icon_view(XFDESKTOP_ICON(icon));
    GtkWidget *toplevel = gtk_widget_get_toplevel(icon_view);
    GMount *mount = G_MOUNT(object);
    GError *error = NULL;
    gboolean unmount_successful;
      
    g_return_if_fail(G_IS_MOUNT(object));
    g_return_if_fail(G_IS_ASYNC_RESULT(result));
    g_return_if_fail(XFDESKTOP_IS_VOLUME_ICON(icon));

    unmount_successful = g_mount_unmount_with_operation_finish(mount, result, &error);

    if(!unmount_successful) {
        /* ignore GIO errors handled internally */
        if(error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) {
            gchar *mount_name = g_mount_get_name(mount);
            gchar *primary = g_markup_printf_escaped(_("Failed to eject \"%s\""), 
                                                     mount_name);

            /* display an error dialog to inform the user */
            xfce_message_dialog(toplevel ? GTK_WINDOW(toplevel) : NULL,
                                _("Eject Failed"), GTK_STOCK_DIALOG_ERROR, 
                                primary, error->message,
                                GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);

            g_free(primary);
            g_free(mount_name);
        }

        g_error_free(error);
    }

#ifdef HAVE_LIBNOTIFY
    xfdesktop_notify_unmount_finish(mount, unmount_successful);
#endif

    g_object_unref(icon);
}
Example #12
0
File: gmount.c Project: Andais/glib
/**
 * g_mount_remount_finish:
 * @mount: a #GMount.
 * @result: a #GAsyncResult.
 * @error: a #GError location to store the error occuring, or %NULL to 
 *     ignore.
 * 
 * Finishes remounting a mount. If any errors occurred during the operation, 
 * @error will be set to contain the errors and %FALSE will be returned.
 * 
 * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise.
 **/
gboolean
g_mount_remount_finish (GMount        *mount,
                        GAsyncResult  *result,
                        GError       **error)
{
  GMountIface *iface;

  g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);

  if (G_IS_SIMPLE_ASYNC_RESULT (result))
    {
      GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
      if (g_simple_async_result_propagate_error (simple, error))
        return FALSE;
    }
  
  iface = G_MOUNT_GET_IFACE (mount);
  return (* iface->remount_finish) (mount, result, error);
}
void vfs_backend_unmount (const gchar *cURI, int iVolumeID, CairoDockFMMountCallback pCallback, Icon *icon, CairoContainer *pContainer)
{
	g_return_if_fail (cURI != NULL);
	cd_message ("%s (%s)", __func__, cURI);
	
	gchar *cTargetURI = NULL;
	GMount *pMount = _cd_find_mount_from_uri (cURI, &cTargetURI);
	if (pMount == NULL || ! G_IS_MOUNT (pMount))
	{
		return ;
	}
	
	if ( ! g_mount_can_unmount (pMount))
		return ;
	
	gboolean bCanEject = g_mount_can_eject (pMount);
	gboolean bCanUnmount = g_mount_can_unmount (pMount);
	cd_message ("eject:%d / unmount:%d\n", bCanEject, bCanUnmount);
	if (! bCanEject && ! bCanUnmount)
		return ;
	
	gpointer *data2 = g_new (gpointer, 5);
	data2[0] = pCallback;
	data2[1] = GINT_TO_POINTER (bCanEject ? 2 : 0);
	data2[2] = g_mount_get_name (pMount);
	data2[3] = icon;
	data2[4] = pContainer;
	if (bCanEject)
		g_mount_eject (pMount,
			G_MOUNT_UNMOUNT_NONE,
			NULL,
			(GAsyncReadyCallback) _vfs_backend_mount_callback,
			data2);
	else
		g_mount_unmount (pMount,
			G_MOUNT_UNMOUNT_NONE ,
			NULL,
			(GAsyncReadyCallback) _vfs_backend_mount_callback,
			data2);
}
Example #14
0
// -------------------------------------------------------------------------------- //
void Unmounted_Device( GObject * object, GAsyncResult * result, guGIO_Mount * mnt )
{
    GError * error = NULL;

    if( G_IS_MOUNT( object ) )
    {
        GMount * mount = ( GMount * ) object;
        g_mount_eject_with_operation_finish( mount, result, &error);
    }

    if( error )
    {
		if( !g_error_matches( error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED ) )
		{
			guLogError( wxT( "Unable to eject %s" ), error->message );
		}
		else
		{
			guLogMessage( wxT( "Eject was already done" ) );
		}
		g_error_free (error);
	}

}
Example #15
0
void
thunar_notify_unmount (GMount *mount)
{
  const gchar * const *icon_names;
  NotifyNotification  *notification = NULL;
  const gchar         *summary;
  GFileInfo           *info;
  gboolean             read_only = FALSE;
  GFile               *icon_file;
  GFile               *mount_point;
  GIcon               *icon;
  gchar               *icon_name = NULL;
  gchar               *message;
  gchar               *name;

  g_return_if_fail (G_IS_MOUNT (mount));

  if (!thunar_notify_init ())
    return;

  mount_point = g_mount_get_root (mount);
  
  info = g_file_query_info (mount_point, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, 
                            G_FILE_QUERY_INFO_NONE, NULL, NULL);

  if (info != NULL)
    {
      read_only = !g_file_info_get_attribute_boolean (info, 
                                                      G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);

      g_object_unref (info);
    }

  g_object_unref (mount_point);

  name = g_mount_get_name (mount);

  icon = g_mount_get_icon (mount);
  if (G_IS_THEMED_ICON (icon))
    {
      icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
      if (icon_names != NULL)
        icon_name = g_strdup (icon_names[0]);
    }
  else if (G_IS_FILE_ICON (icon))
    {
      icon_file = g_file_icon_get_file (G_FILE_ICON (icon));
      if (icon_file != NULL)
        {
          icon_name = g_file_get_path (icon_file);
          g_object_unref (icon_file);
        }
    }
  g_object_unref (icon);

  if (icon_name == NULL)
    icon_name = g_strdup ("drive-removable-media");

  if (read_only)
    {
      summary = _("Unmounting device");
      message = g_strdup_printf (_("The device \"%s\" is being unmounted by the system. "
                                   "Please do not remove the media or disconnect the "
                                   "drive"), name);
    }
  else
    {
      summary = _("Writing data to device");
      message = g_strdup_printf (_("There is data that needs to be written to the "
                                   "device \"%s\" before it can be removed. Please "
                                   "do not remove the media or disconnect the drive"),
                                   name);
    }

#ifdef NOTIFY_CHECK_VERSION
#if NOTIFY_CHECK_VERSION (0, 7, 0)
  notification = notify_notification_new (summary, message, icon_name);
#else
  notification = notify_notification_new (summary, message, icon_name, NULL);
#endif
#else
  notification = notify_notification_new (summary, message, icon_name, NULL);
#endif
  notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
  notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
  notify_notification_show (notification, NULL);

  g_object_set_data_full (G_OBJECT (mount), "thunar-notification", notification, 
                          g_object_unref);

  g_free (message);
  g_free (icon_name);
  g_free (name);
}
Example #16
0
static gboolean
tvm_block_device_autoipod (TvmContext *context,
                           GMount     *mount,
                           GError    **error)
{
  gboolean autoipod;
  gboolean is_audio_player = FALSE;
  gboolean is_ipod = FALSE;
  gboolean result = FALSE;
  GFile   *mount_point;
  gchar   *autoipod_command;
  gchar   *autophoto_command;
  gchar   *mount_path;
  gchar   *path_dcim = NULL;
  gint     response = TVM_RESPONSE_NONE;

  g_return_val_if_fail (context != NULL, FALSE);
  g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  autoipod = xfconf_channel_get_bool (context->channel, "/autoipod/enabled", FALSE);
  if (autoipod)
    {
      /* check if we have a portable audio player here */
      is_audio_player = g_udev_device_has_property (context->device, 
                                                    "ID_MEDIA_PLAYER");

      /* check if we have an iPod */
      is_ipod = g_str_has_prefix (g_udev_device_get_property (context->device, 
                                                              "ID_MODEL"), "iPod");
      if (is_ipod)
        {
          /* determine the mount point path */
          mount_point = g_mount_get_root (mount);
          mount_path = g_file_get_path (mount_point);
          g_object_unref (mount_point);

          /* build dcim path */
          path_dcim = g_build_filename (mount_path, "dcim", NULL);
          g_free (mount_path);

          /* check if the iPod has photos */
          if (!g_file_test (path_dcim, G_FILE_TEST_IS_DIR))
            {
              /* no photos */
              g_free (path_dcim);
              path_dcim = NULL;
            }
        }

      autoipod_command = xfconf_channel_get_string (context->channel,
                                                    "/autoipod/command", NULL);
      autophoto_command = xfconf_channel_get_string (context->channel,
                                                     "/autophoto/command", NULL);

      /* check if autophoto command is specified, otherwise we cannot handle the photos 
       * on the iPod anyway */
      if (autophoto_command == NULL || *autophoto_command == '\0')
        {
          g_free (path_dcim);
          path_dcim = NULL;
        }

      /* iPods can carry music and photos... */
      if (path_dcim != NULL)
        {
          /* ...so we need to prompt what to do */
          response = tvm_prompt (context, "multimedia-player", _("Photos and Music"),
                                 _("Photos were found on your portable music player"),
                                 _("Would you like to import the photos or manage the "
                                   "music?"),
                                 _("Ig_nore"), GTK_RESPONSE_CANCEL,
                                 _("Import _Photos"), TVM_RESPONSE_PHOTOS,
                                 _("Manage _Music"), TVM_RESPONSE_MUSIC,
                                 NULL);
        }
      else if (is_audio_player || is_ipod)
        {
          response = TVM_RESPONSE_MUSIC;
        }

      /* check what to do */
      if (response == TVM_RESPONSE_MUSIC)
        {
          /* run the preferred application to manage music players */
          result = tvm_run_command (context, mount, autoipod_command, error);
        }
      else if (response == TVM_RESPONSE_PHOTOS)
        {
          /* run the preferred application to manage photos */
          result = tvm_run_command (context, mount, autophoto_command, error);
        }
      else if (path_dcim != NULL)
        {
          /* when the user has decided to ignore photos/music, we don't want
           * to ask him again in autophoto and we don't want to mount the 
           * device either... I guess? */
          result = TRUE;
        }

      g_free (autophoto_command);
      g_free (autoipod_command);
      g_free (path_dcim);
    }

  return result;
}
Example #17
0
static gboolean
tvm_block_device_autorun (TvmContext *context,
                          GMount     *mount,
                          GError    **error)
{
  struct stat statb_mount_point;
  struct stat statb_autoopen;
  gboolean    autoopen;
  gboolean    autoplay;
  gboolean    autorun;
  gboolean    result = FALSE;
  GError     *err = NULL;
  GFile      *mount_point;
  gchar     **argv;
  gchar      *autoplay_command;
  gchar      *message;
  gchar      *mount_path;
  gchar      *path_autoopen;
  gchar      *wine;
  gchar       line[1024];
  guint       n;
  FILE       *fp;
  gint        response;

  g_return_val_if_fail (context != NULL, FALSE);
  g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  /* check if autoplaying video CDs and DVDs is enabled */
  autoplay = xfconf_channel_get_bool (context->channel, 
                                      "/autoplay-video-cds/enabled", FALSE);
  if (autoplay)
    {
      /* check if we have a video CD or video DVD here */
      if (tvm_file_test (mount, "vcd", G_FILE_TEST_IS_DIR) 
          || tvm_file_test (mount, "video_ts", G_FILE_TEST_IS_DIR))
        {
          /* determine the autoplay command for video CDs/DVDs */
          autoplay_command = xfconf_channel_get_string (context->channel,
                                                        "/autoplay-video-cds/command", 
                                                        "parole");

          /* try to spawn the preferred video CD/DVD player */
          result = tvm_run_command (context, mount, autoplay_command, &err);

          /* free the command string */
          g_free (autoplay_command);

          /* forward errors to the caller */
          if (err != NULL)
            g_propagate_error (error, err);

          /* return success/failure to the caller */
          return result;
        }
    }

  /* check if autorun is enabled */
  autorun = xfconf_channel_get_bool (context->channel, "/autorun/enabled", FALSE);
  if (autorun)
    {
      /* Autostart files according to the Desktop Application Autostart
       * Specification */
      static const gchar *autorun_files[] = { ".autorun", "autorun", "autorun.sh" };
      for (n = 0; n < G_N_ELEMENTS (autorun_files); ++n) 
        {
          /* check if one of the autorun files is present and executable */
          if (tvm_file_test (mount, autorun_files[n], G_FILE_TEST_IS_EXECUTABLE)
              && tvm_file_test (mount, autorun_files[n], G_FILE_TEST_IS_REGULAR))
            {
              /* prompt the user to execute the file */
              message = g_strdup_printf (_("Would you like to allow \"%s\" to run?"),
                                         autorun_files[n]);
              response = tvm_prompt (context, "gnome-fs-executable", 
                                     _("Auto-Run Confirmation"),
                                     _("Auto-Run capability detected"), message,
                                     _("Ig_nore"), GTK_RESPONSE_CANCEL,
                                     _("_Allow Auto-Run"), TVM_RESPONSE_AUTORUN,
                                     NULL);
              g_free (message);

              /* check if we should autorun */
              if (response == TVM_RESPONSE_AUTORUN)
                {
                  /* determine the mount point as a string */
                  mount_point = g_mount_get_root (mount);
                  mount_path = g_file_get_path (mount_point);
                  g_object_unref (mount_point);

                  /* prepare argv to launch the autorun file */
                  argv = g_new0 (gchar *, 2);
                  argv[0] = g_build_filename (mount_path, autorun_files[n], NULL);
                  argv[1] = NULL;

                  /* try to launch the autorun file */
                  result = g_spawn_async (mount_path, argv, NULL, 0, NULL, NULL, NULL,
                                          &err);
                  
                  /* free strings */
                  g_strfreev (argv);
                  g_free (mount_path);

                  if (err != NULL)
                    g_propagate_error (error, err);

                  return result;
                }
            }
        }