seahorse r2253 - in seahorse-plugins/trunk: . libseahorse plugins/applet plugins/nautilus plugins/nautilus-ext
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2253 - in seahorse-plugins/trunk: . libseahorse plugins/applet plugins/nautilus plugins/nautilus-ext
- Date: Mon, 30 Jun 2008 21:48:50 +0000 (UTC)
Author: nnielsen
Date: Mon Jun 30 21:48:50 2008
New Revision: 2253
URL: http://svn.gnome.org/viewvc/seahorse?rev=2253&view=rev
Log:
* configure.in:
* libseahorse/Makefile.am:
* libseahorse/seahorse-gtkstock.h:
* libseahorse/seahorse-multi-encrypt.glade: (added back)
* libseahorse/seahorse-util.c:
* libseahorse/seahorse-util.h:
* libseahorse/seahorse-vfs-data.c:
* libseahorse/seahorse-vfs-data.h:
* plugins/applet/seahorse-applet.c:
* plugins/nautilus/seahorse-tool.c:
* plugins/nautilus/seahorse-tool-files.c:
* plugins/nautilus/seahorse-tool-progress.c:
* plugins/nautilus-ext/seahorse-nautilus.c: Port to GIO from gnome-vfs
Fixes bug #509940
Added:
seahorse-plugins/trunk/libseahorse/seahorse-multi-encrypt.glade
Modified:
seahorse-plugins/trunk/ChangeLog
seahorse-plugins/trunk/configure.in
seahorse-plugins/trunk/libseahorse/Makefile.am
seahorse-plugins/trunk/libseahorse/seahorse-gtkstock.h
seahorse-plugins/trunk/libseahorse/seahorse-util.c
seahorse-plugins/trunk/libseahorse/seahorse-util.h
seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.c
seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.h
seahorse-plugins/trunk/plugins/applet/seahorse-applet.c
seahorse-plugins/trunk/plugins/nautilus-ext/seahorse-nautilus.c
seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-files.c
seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-progress.c
seahorse-plugins/trunk/plugins/nautilus/seahorse-tool.c
Modified: seahorse-plugins/trunk/configure.in
==============================================================================
--- seahorse-plugins/trunk/configure.in (original)
+++ seahorse-plugins/trunk/configure.in Mon Jun 30 21:48:50 2008
@@ -30,7 +30,7 @@
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
-PKG_CHECK_MODULES(SEAHORSE, libglade-2.0 gconf-2.0 gtk+-2.0 >= 2.10.0 gio-2.0 gnome-vfs-2.0)
+PKG_CHECK_MODULES(SEAHORSE, libglade-2.0 gconf-2.0 gtk+-2.0 >= 2.10.0 gio-2.0)
AC_MSG_CHECKING([for some Win32 platform])
case "$host" in
Modified: seahorse-plugins/trunk/libseahorse/Makefile.am
==============================================================================
--- seahorse-plugins/trunk/libseahorse/Makefile.am (original)
+++ seahorse-plugins/trunk/libseahorse/Makefile.am Mon Jun 30 21:48:50 2008
@@ -59,7 +59,8 @@
glade_DATA = \
seahorse-notify.glade \
seahorse-prefs.glade \
- seahorse-progress.glade
+ seahorse-progress.glade \
+ seahorse-multi-encrypt.glade
EXTRA_DIST = $(glade_DATA) \
seahorse-marshal.list
Modified: seahorse-plugins/trunk/libseahorse/seahorse-gtkstock.h
==============================================================================
--- seahorse-plugins/trunk/libseahorse/seahorse-gtkstock.h (original)
+++ seahorse-plugins/trunk/libseahorse/seahorse-gtkstock.h Mon Jun 30 21:48:50 2008
@@ -26,6 +26,8 @@
#ifndef _SEAHORSE_GTKSTOCK_H_
#define _SEAHORSE_GTKSTOCK_H_
+#include <gtk/gtk.h>
+
/* The default stock icons */
#define SEAHORSE_STOCK_SEAHORSE "seahorse"
#define SEAHORSE_STOCK_KEY "seahorse-key"
Added: seahorse-plugins/trunk/libseahorse/seahorse-multi-encrypt.glade
==============================================================================
--- (empty file)
+++ seahorse-plugins/trunk/libseahorse/seahorse-multi-encrypt.glade Mon Jun 30 21:48:50 2008
@@ -0,0 +1,340 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="multi-encrypt">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Encrypt Multiple Files</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="helpbutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-11</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="cancelbutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="okbutton1">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="message">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>You have selected multiple files or folders</b></property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="local-options">
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">10</property>
+
+ <child>
+ <widget class="GtkEntry" id="package-name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes">encrypted-package</property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="package-extension">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Package Name:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Packaging:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="do-separate">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Encrypt each file separately</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="do-package">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Encrypt packed together in a package</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">do-separate</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="remote-options">
+ <property name="label" translatable="yes">Because the files are located remotely, each file will be encrypted separately.</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
Modified: seahorse-plugins/trunk/libseahorse/seahorse-util.c
==============================================================================
--- seahorse-plugins/trunk/libseahorse/seahorse-util.c (original)
+++ seahorse-plugins/trunk/libseahorse/seahorse-util.c Mon Jun 30 21:48:50 2008
@@ -32,8 +32,9 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
#ifdef WITH_SHARING
#include <avahi-glib/glib-watch.h>
@@ -435,6 +436,8 @@
{
gchar* t;
+ g_return_val_if_fail (uri, "");
+
t = (gchar*)seahorse_util_uri_get_last (uri);
if(t != uri)
*(t - 1) = 0;
@@ -453,15 +456,15 @@
gboolean
seahorse_util_uri_exists (const gchar* uri)
{
- GnomeVFSURI* vuri;
+ GFile *file;
gboolean exists;
- vuri = gnome_vfs_uri_new (uri);
- g_return_val_if_fail (vuri != NULL, FALSE);
-
- exists = gnome_vfs_uri_exists (vuri);
- gnome_vfs_uri_unref (vuri);
-
+ file = g_file_new_for_uri (uri);
+ g_return_val_if_fail (file, FALSE);
+
+ exists = g_file_query_exists (file, NULL);
+ g_object_unref (file);
+
return exists;
}
@@ -567,78 +570,6 @@
return ret;
}
-/* Context for callback below */
-typedef struct _VisitUriCtx
-{
- GArray* files;
- const gchar* base_uri;
-}
-VisitUriCtx;
-
-/* Called for each sub file or directory */
-static gboolean
-visit_uri (const gchar *rel_path, GnomeVFSFileInfo *info, gboolean recursing_will_loop,
- gpointer data, gboolean *recurse)
-{
- VisitUriCtx* ctx = (VisitUriCtx*)data;
- gchar* t = g_strconcat (ctx->base_uri, "/", rel_path, NULL);
- gchar* uri = gnome_vfs_make_uri_canonical (t);
- g_free (t);
-
- if(info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
- g_array_append_val (ctx->files, uri);
-
- *recurse = !recursing_will_loop;
- return TRUE;
-}
-
-/**
- * seahorse_util_uris_expand
- * @uris: The null-terminated vector of URIs to enumerate
- *
- * Find all files in the given set of uris.
- *
- * Returns: Newly allocated null-terminated string vector of URIs.
- */
-gchar**
-seahorse_util_uris_expand (const gchar** uris)
-{
- GnomeVFSFileInfo* info;
- GArray* files = NULL;
- const gchar** u;
- gchar* uri;
-
- files = g_array_new (TRUE, FALSE, sizeof(gchar*));
- info = gnome_vfs_file_info_new ();
-
- for(u = uris; *u; u++) {
-
- uri = gnome_vfs_make_uri_canonical (*u);
-
- if (gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT) == GNOME_VFS_OK &&
- info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
- {
- VisitUriCtx ctx;
- ctx.files = files;
- ctx.base_uri = uri;
-
- gnome_vfs_directory_visit (uri, GNOME_VFS_FILE_INFO_DEFAULT,
- GNOME_VFS_DIRECTORY_VISIT_DEFAULT | GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
- visit_uri, &ctx);
-
- /* Not a directory */
- } else {
-
- g_array_append_val (files, uri);
- uri = NULL; /* To prevent freeing below */
- }
-
- g_free (uri);
- }
-
- return (gchar**)g_array_free (files, FALSE);
-}
-
/**
* seahorse_util_uris_package
* @package: Package uri
@@ -659,12 +590,12 @@
gchar *cmd;
gchar *t;
gchar *x;
- GnomeVFSFileInfo *info;
- GnomeVFSResult result;
+ GFile *file, *fpackage;
- t = gnome_vfs_get_local_path_from_uri (package);
- x = g_shell_quote(t);
- g_free(t);
+ fpackage = g_file_new_for_uri (package);
+ t = g_file_get_path (fpackage);
+ x = g_shell_quote (t);
+ g_free (t);
/* create execution */
str = g_string_new ("");
@@ -672,12 +603,15 @@
g_free(x);
while(*uris) {
- /* We should never be passed any remote uris at this point */
- x = gnome_vfs_make_uri_canonical (*uris);
-
- t = gnome_vfs_get_local_path_from_uri (x);
- g_free(x);
+ x = g_uri_parse_scheme (*uris);
+ if (x)
+ file = g_file_new_for_uri (*uris);
+ else
+ file = g_file_new_for_path (*uris);
+ g_free (x);
+ t = g_file_get_path (file);
+ g_object_unref (file);
g_return_val_if_fail (t != NULL, FALSE);
x = g_shell_quote(t);
@@ -710,16 +644,12 @@
return FALSE;
}
- info = gnome_vfs_file_info_new ();
- info->permissions = GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE;
- result = gnome_vfs_set_file_info (package, info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
- gnome_vfs_file_info_unref (info);
-
- if (result != GNOME_VFS_OK) {
- seahorse_util_handle_error (err, _("Couldn't set permissions on backup file."));
- return FALSE;
+ t = g_file_get_path (fpackage);
+ if (t != NULL) {
+ g_chmod (t, S_IRUSR | S_IWUSR);
+ g_free (t);
}
-
+
return TRUE;
}
Modified: seahorse-plugins/trunk/libseahorse/seahorse-util.h
==============================================================================
--- seahorse-plugins/trunk/libseahorse/seahorse-util.h (original)
+++ seahorse-plugins/trunk/libseahorse/seahorse-util.h Mon Jun 30 21:48:50 2008
@@ -93,8 +93,6 @@
const gchar* seahorse_util_uri_split_last (gchar* uri);
-gchar** seahorse_util_uris_expand (const gchar **uris);
-
gboolean seahorse_util_uris_package (const gchar* package,
const gchar** uris);
Modified: seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.c
==============================================================================
--- seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.c (original)
+++ seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.c Mon Jun 30 21:48:50 2008
@@ -25,8 +25,8 @@
#include <errno.h>
#include <string.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "seahorse-gpgmex.h"
#include "seahorse-vfs-data.h"
@@ -41,6 +41,7 @@
VFS_OP_OPENING,
VFS_OP_READING,
VFS_OP_WRITING,
+ VFS_OP_FLUSHING,
VFS_OP_SEEKING
}
VfsAsyncOp;
@@ -59,19 +60,21 @@
gpgme_data_t gdata; /* A pointer to the outside gpgme_data_t handle */
- gchar *uri; /* The URI we're operating on */
- GnomeVFSAsyncHandle* handle; /* Handle for operations */
- GtkWidget* widget; /* Widget for progress and cancel */
+ GFile *file; /* The file we're operating on */
+ GCancellable *cancellable; /* For cancelling any concurrent operation */
+ gboolean writer; /* Whether a writer or a reader */
+ GInputStream *istream; /* Stream for reading from */
+ GOutputStream *ostream; /* Stream for writing to */
VfsAsyncOp operation; /* The last/current operation */
VfsAsyncState state; /* State of the last/current operation */
- GnomeVFSResult result; /* Result of the current operation */
+ GError *error; /* Result of the current operation */
gpointer buffer; /* Current operation's buffer */
- GnomeVFSFileSize processed; /* Number of bytes processed in current op */
+ goffset processed; /* Number of bytes processed in current op */
- GnomeVFSFileSize last; /* Last update sent about number of bytes */
- GnomeVFSFileSize total; /* Total number of bytes read or written */
+ goffset last; /* Last update sent about number of bytes */
+ goffset total; /* Total number of bytes read or written */
SeahorseVfsProgressCb progcb; /* Progress callback */
gpointer userdata; /* User data for progress callback */
@@ -84,6 +87,7 @@
vfs_data_wait_results(VfsAsyncHandle* ah, gboolean errors)
{
VfsAsyncOp op;
+ gint code;
seahorse_util_wait_until (ah->state != VFS_ASYNC_PROCESSING);
@@ -91,113 +95,96 @@
ah->operation = VFS_OP_NONE;
/* Cancelling looks like an error to our caller */
- if(ah->state == VFS_ASYNC_CANCELLED)
- {
+ if (ah->state == VFS_ASYNC_CANCELLED) {
errno = 0;
return FALSE;
}
- g_assert(ah->state == VFS_ASYNC_READY);
+ g_assert (ah->state == VFS_ASYNC_READY);
/* There was no operation going on, result codes are not relevant */
- if(op == VFS_OP_NONE)
+ if (op == VFS_OP_NONE)
return TRUE;
-
- if(ah->result == GNOME_VFS_ERROR_EOF)
- {
- ah->processed = 0;
- ah->result = GNOME_VFS_OK;
+
+ /* No error result */
+ if (!ah->error) {
+ return TRUE;
}
+
+ code = -1;
+ if (ah->error->domain == G_IO_ERROR)
+ code = ah->error->code;
- else if(ah->result == GNOME_VFS_ERROR_CANCELLED)
- {
- vfs_data_cancel(ah);
+ if (code == G_IO_ERROR_CANCELLED) {
+ vfs_data_cancel (ah);
errno = 0;
return FALSE;
}
/* Check for error codes */
- if(ah->result != GNOME_VFS_OK)
- {
- if(errors)
- {
- switch(ah->result)
- {
- #define VFS_TO_SYS_ERR(v, s) \
- case v: errno = s; break;
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NOT_FOUND, ENOENT);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_GENERIC, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_INTERNAL, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_BAD_PARAMETERS, EINVAL);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NOT_SUPPORTED, EOPNOTSUPP);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_IO, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_CORRUPTED_DATA, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_WRONG_FORMAT, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_BAD_FILE, EBADF);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_TOO_BIG, EFBIG);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NO_SPACE, ENOSPC);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_READ_ONLY, EPERM);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_INVALID_URI, EINVAL);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NOT_OPEN, EBADF);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_INVALID_OPEN_MODE, EPERM);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_ACCESS_DENIED, EACCES);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_TOO_MANY_OPEN_FILES, EMFILE);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NOT_A_DIRECTORY, ENOTDIR);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_IN_PROGRESS, EALREADY);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_INTERRUPTED, EINTR);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_FILE_EXISTS, EEXIST);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_LOOP, ELOOP);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NOT_PERMITTED, EPERM);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_IS_DIRECTORY, EISDIR);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NO_MEMORY, ENOMEM);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_HOST_NOT_FOUND, ENOENT);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_INVALID_HOST_NAME, EHOSTDOWN);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS, EHOSTUNREACH);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_LOGIN_FAILED, EACCES);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_DIRECTORY_BUSY, EBUSY);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_DIRECTORY_NOT_EMPTY, ENOTEMPTY);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_TOO_MANY_LINKS, EMLINK);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM, EROFS);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NOT_SAME_FILE_SYSTEM, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NAME_TOO_LONG, ENAMETOOLONG);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE, ENOPROTOOPT);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_SERVICE_OBSOLETE, ENOPROTOOPT);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_PROTOCOL_ERROR, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NO_MASTER_BROWSER, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NO_DEFAULT, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_NO_HANDLER, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_PARSE, EIO);
- VFS_TO_SYS_ERR(GNOME_VFS_ERROR_LAUNCH, EIO);
-
- default:
- errno = EIO;
- break;
- }
+ if(errors) {
+ switch(code) {
+ #define GIO_TO_SYS_ERR(v, s) \
+ case v: errno = s; break;
+ GIO_TO_SYS_ERR (G_IO_ERROR_FAILED, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_FOUND, ENOENT);
+ GIO_TO_SYS_ERR (G_IO_ERROR_EXISTS, EEXIST);
+ GIO_TO_SYS_ERR (G_IO_ERROR_IS_DIRECTORY, EISDIR);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_DIRECTORY, ENOTDIR);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_EMPTY, ENOTEMPTY);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_REGULAR_FILE, EINVAL);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_SYMBOLIC_LINK, EINVAL);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_MOUNTABLE_FILE, EINVAL);
+ GIO_TO_SYS_ERR (G_IO_ERROR_FILENAME_TOO_LONG, ENAMETOOLONG);
+ GIO_TO_SYS_ERR (G_IO_ERROR_INVALID_FILENAME, EINVAL);
+ GIO_TO_SYS_ERR (G_IO_ERROR_TOO_MANY_LINKS, EMLINK);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NO_SPACE, ENOSPC);
+ GIO_TO_SYS_ERR (G_IO_ERROR_INVALID_ARGUMENT, EINVAL);
+ GIO_TO_SYS_ERR (G_IO_ERROR_PERMISSION_DENIED, EACCES);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_SUPPORTED, EOPNOTSUPP);
+ GIO_TO_SYS_ERR (G_IO_ERROR_NOT_MOUNTED, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_ALREADY_MOUNTED, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_CLOSED, EINVAL);
+ GIO_TO_SYS_ERR (G_IO_ERROR_CANCELLED, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_PENDING, EAGAIN);
+ GIO_TO_SYS_ERR (G_IO_ERROR_READ_ONLY, EPERM);
+ GIO_TO_SYS_ERR (G_IO_ERROR_CANT_CREATE_BACKUP, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_WRONG_ETAG, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_TIMED_OUT, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_WOULD_RECURSE, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_BUSY, EBUSY);
+ GIO_TO_SYS_ERR (G_IO_ERROR_WOULD_BLOCK, EWOULDBLOCK);
+ GIO_TO_SYS_ERR (G_IO_ERROR_HOST_NOT_FOUND, ENOENT);
+ GIO_TO_SYS_ERR (G_IO_ERROR_WOULD_MERGE, EIO);
+ GIO_TO_SYS_ERR (G_IO_ERROR_FAILED_HANDLED, EIO);
+ default:
+ errno = EIO;
+ break;
+ };
+ }
- /* When errors on open we look cancelled */
- if(op == VFS_OP_OPENING)
- ah->state = VFS_ASYNC_CANCELLED;
- }
+ /* When errors on open we look cancelled */
+ if(op == VFS_OP_OPENING)
+ ah->state = VFS_ASYNC_CANCELLED;
- return FALSE;
- }
-
- return TRUE;
+ return FALSE;
}
/* Called when a file open completes */
static void
-vfs_data_open_done(GnomeVFSAsyncHandle *handle, GnomeVFSResult result,
- gpointer callback_data)
+vfs_data_open_done (GObject *source, GAsyncResult *res, gpointer callback_data)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)callback_data;
- if(ah->state == VFS_ASYNC_PROCESSING)
- {
- g_assert(handle == ah->handle);
- g_assert(ah->operation == VFS_OP_OPENING);
+ if(ah->state == VFS_ASYNC_PROCESSING) {
+ g_assert (ah->operation == VFS_OP_OPENING);
+ g_clear_error (&ah->error);
+
+ if (ah->writer)
+ ah->ostream = G_OUTPUT_STREAM (g_file_replace_finish (ah->file, res, &ah->error));
+ else
+ ah->istream = G_INPUT_STREAM (g_file_read_finish (ah->file, res, &ah->error));
- ah->result = result;
ah->state = VFS_ASYNC_READY;
ah->total = 0;
ah->last = 0;
@@ -206,63 +193,58 @@
/* Open the given handle */
static void
-vfs_data_open_helper (VfsAsyncHandle *ah, gboolean write)
+vfs_data_open_helper (VfsAsyncHandle *ah)
{
- g_assert (ah->handle == NULL);
- g_assert (ah->uri != NULL);
+ g_assert (ah->file != NULL);
g_assert (ah->state == VFS_ASYNC_READY);
-
- if (write) {
- /* Note that we always overwrite the file */
- gnome_vfs_async_create (&(ah->handle), ah->uri, GNOME_VFS_OPEN_WRITE | GNOME_VFS_OPEN_RANDOM,
- FALSE, 0600, GNOME_VFS_PRIORITY_DEFAULT, vfs_data_open_done, ah);
- } else {
- gnome_vfs_async_open (&(ah->handle), ah->uri, GNOME_VFS_OPEN_READ | GNOME_VFS_OPEN_RANDOM,
- GNOME_VFS_PRIORITY_DEFAULT, vfs_data_open_done, ah);
- }
ah->state = VFS_ASYNC_PROCESSING;
ah->operation = VFS_OP_OPENING;
+
+ /* Note that we always overwrite the file */
+ if (ah->writer)
+ g_file_replace_async (ah->file, NULL, FALSE, G_FILE_CREATE_NONE, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_open_done, ah);
+ else
+ g_file_read_async (ah->file, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_open_done, ah);
}
/* Open the given URI */
static VfsAsyncHandle*
-vfs_data_open(const gchar* uri, gboolean write, gboolean delayed)
+vfs_data_open (GFile *file, gboolean write, gboolean delayed)
{
VfsAsyncHandle* ah;
/* We only support delayed opening of write files */
g_assert (write || !delayed);
- ah = g_new0(VfsAsyncHandle, 1);
+ ah = g_new0 (VfsAsyncHandle, 1);
+ ah->cancellable = g_cancellable_new ();
ah->state = VFS_ASYNC_READY;
- ah->operation = VFS_OP_NONE;
- ah->uri = g_strdup (uri);
+ ah->operation = VFS_OP_NONE;
+ ah->file = file;
+ ah->writer = write;
+ g_object_ref (file);
/* Open the file right here and now if requested */
if (!delayed)
- vfs_data_open_helper (ah, write);
+ vfs_data_open_helper (ah);
return ah;
}
/* Called when a read completes */
static void
-vfs_data_read_done(GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gpointer buffer,
- GnomeVFSFileSize bytes_requested, GnomeVFSFileSize bytes_read, gpointer callback_data)
+vfs_data_read_done (GObject *source, GAsyncResult *res, gpointer callback_data)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)callback_data;
+
+ if (ah->state == VFS_ASYNC_PROCESSING) {
+ g_assert (ah->operation == VFS_OP_READING);
+ g_clear_error (&ah->error);
- if(ah->state == VFS_ASYNC_PROCESSING)
- {
- g_assert(handle == ah->handle);
- g_assert(buffer == ah->buffer);
- g_assert(ah->operation == VFS_OP_READING);
-
- ah->result = result;
- ah->processed = bytes_read;
+ ah->processed = g_input_stream_read_finish (ah->istream, res, &ah->error);
ah->state = VFS_ASYNC_READY;
- ah->total += bytes_read;
+ ah->total += ah->processed;
/* Call progress callback if setup */
if (ah->progcb && ah->total >= ah->last + PROGRESS_BLOCK)
@@ -272,27 +254,25 @@
/* Called by gpgme to read data */
static ssize_t
-vfs_data_read(void *handle, void *buffer, size_t size)
+vfs_data_read (void *handle, void *buffer, size_t size)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)handle;
ssize_t sz = 0;
- g_assert (ah->handle != NULL);
-
/* Just in case we have an operation, like open */
- if(!vfs_data_wait_results(ah, TRUE))
+ if (!vfs_data_wait_results(ah, TRUE))
return -1;
- g_assert(ah->state == VFS_ASYNC_READY);
+ g_assert (ah->state == VFS_ASYNC_READY);
/* Start async operation */
ah->buffer = buffer;
ah->state = VFS_ASYNC_PROCESSING;
ah->operation = VFS_OP_READING;
- gnome_vfs_async_read(ah->handle, buffer, size, vfs_data_read_done, ah);
+ g_input_stream_read_async (ah->istream, buffer, size, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_read_done, ah);
/* Wait for it */
- if(!vfs_data_wait_results(ah, TRUE))
+ if (!vfs_data_wait_results (ah, TRUE))
return -1;
/* Return results */
@@ -307,21 +287,17 @@
/* Called when a write completes */
static void
-vfs_data_write_done(GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gconstpointer buffer,
- GnomeVFSFileSize bytes_requested, GnomeVFSFileSize bytes_written, gpointer callback_data)
+vfs_data_write_done (GObject *source, GAsyncResult *res, gpointer callback_data)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)callback_data;
- if(ah->state == VFS_ASYNC_PROCESSING)
- {
- g_assert(handle == ah->handle);
- g_assert(buffer == ah->buffer);
- g_assert(ah->operation == VFS_OP_WRITING);
+ if(ah->state == VFS_ASYNC_PROCESSING) {
+ g_assert (ah->operation == VFS_OP_WRITING);
+ g_clear_error (&ah->error);
- ah->result = result;
- ah->processed = bytes_written;
+ ah->processed = g_output_stream_write_finish (ah->ostream, res, &ah->error);
ah->state = VFS_ASYNC_READY;
- ah->total += bytes_written;
+ ah->total += ah->processed;
/* Call progress callback if setup */
if (ah->progcb && ah->total >= ah->last + PROGRESS_BLOCK)
@@ -329,101 +305,117 @@
}
}
+/* Called when a flush completes */
+static void
+vfs_data_flush_done (GObject *source, GAsyncResult *res, gpointer callback_data)
+{
+ VfsAsyncHandle* ah = (VfsAsyncHandle*)callback_data;
+
+ if(ah->state == VFS_ASYNC_PROCESSING) {
+ g_assert (ah->operation == VFS_OP_FLUSHING);
+ g_clear_error (&ah->error);
+
+ g_output_stream_flush_finish (ah->ostream, res, &ah->error);
+ ah->state = VFS_ASYNC_READY;
+ }
+}
+
/* Called by gpgme to write data */
static ssize_t
-vfs_data_write(void *handle, const void *buffer, size_t size)
+vfs_data_write (void *handle, const void *buffer, size_t size)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)handle;
ssize_t sz = 0;
/* If the file isn't open yet, then do that now */
- if (!ah->handle && ah->state == VFS_ASYNC_READY)
- vfs_data_open_helper (ah, TRUE);
+ if (!ah->ostream && ah->state == VFS_ASYNC_READY)
+ vfs_data_open_helper (ah);
/* Just in case we have an operation, like open */
- if(!vfs_data_wait_results(ah, TRUE))
+ if (!vfs_data_wait_results(ah, TRUE))
return -1;
- g_assert(ah->state == VFS_ASYNC_READY);
+ g_assert (ah->state == VFS_ASYNC_READY);
/* Start async operation */
ah->buffer = (gpointer)buffer;
ah->state = VFS_ASYNC_PROCESSING;
ah->operation = VFS_OP_WRITING;
- gnome_vfs_async_write(ah->handle, buffer, size, vfs_data_write_done, ah);
+ g_output_stream_write_async (ah->ostream, buffer, size, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_write_done, ah);
/* Wait for it */
- if(!vfs_data_wait_results(ah, TRUE))
+ if (!vfs_data_wait_results(ah, TRUE))
return -1;
-
+
/* Return results */
sz = (ssize_t)ah->processed;
- ah->state = VFS_ASYNC_READY;
ah->buffer = NULL;
ah->processed = 0;
-
- return sz;
-}
-/* Called when a VFS seek completes */
-static void
-vfs_data_seek_done(GnomeVFSAsyncHandle *handle, GnomeVFSResult result,
- gpointer callback_data)
-{
- VfsAsyncHandle* ah = (VfsAsyncHandle*)callback_data;
+ /* Sadly GPGME doesn't support errors on close, so we have to flush after each write */
+ ah->state = VFS_ASYNC_PROCESSING;
+ ah->operation = VFS_OP_FLUSHING;
+ g_output_stream_flush_async (ah->ostream, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_flush_done, ah);
- if(ah->state == VFS_ASYNC_PROCESSING)
- {
- g_assert(handle == ah->handle);
- g_assert(ah->operation == VFS_OP_SEEKING);
-
- ah->result = result;
- ah->state = VFS_ASYNC_READY;
- }
+ /* Wait for it */
+ if (!vfs_data_wait_results(ah, TRUE))
+ return -1;
+
+ return sz;
}
/* Called from gpgme to seek a file */
static off_t
-vfs_data_seek(void *handle, off_t offset, int whence)
+vfs_data_seek (void *handle, off_t offset, int whence)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)handle;
- GnomeVFSSeekPosition wh;
-
+ GSeekable *seekable = NULL;
+ GSeekType wh;
+
/* If the file isn't open yet, then do that now */
- if (!ah->handle && ah->state == VFS_ASYNC_READY)
- vfs_data_open_helper (ah, TRUE);
+ if (!ah->ostream && !ah->istream && ah->state == VFS_ASYNC_READY)
+ vfs_data_open_helper (ah);
/* Just in case we have an operation, like open */
- if(!vfs_data_wait_results(ah, TRUE))
+ if (!vfs_data_wait_results(ah, TRUE))
return (off_t)-1;
- g_assert(ah->state == VFS_ASYNC_READY);
-
+ g_assert (ah->state == VFS_ASYNC_READY);
+
+ if (ah->writer && G_IS_SEEKABLE (ah->ostream))
+ seekable = G_SEEKABLE (ah->ostream);
+ else
+ seekable = G_SEEKABLE (ah->istream);
+
+ if (!seekable || !g_seekable_can_seek (seekable)) {
+ errno = ENOTSUP;
+ return -1;
+ }
+
switch(whence)
{
case SEEK_SET:
- wh = GNOME_VFS_SEEK_START;
+ wh = G_SEEK_SET;
break;
case SEEK_CUR:
- wh = GNOME_VFS_SEEK_CURRENT;
+ wh = G_SEEK_CUR;
break;
case SEEK_END:
- wh = GNOME_VFS_SEEK_END;
+ wh = G_SEEK_END;
break;
default:
g_assert_not_reached();
break;
}
- /* Start async operation */
- ah->state = VFS_ASYNC_PROCESSING;
- ah->operation = VFS_OP_SEEKING;
- gnome_vfs_async_seek(ah->handle, wh, (GnomeVFSFileOffset)offset,
- vfs_data_seek_done, ah);
+ /* All seek operations are not async */
+ g_clear_error (&ah->error);
+ g_seekable_seek (seekable, (goffset)offset, wh, ah->cancellable, &ah->error);
- /* Wait for it */
- if(!vfs_data_wait_results(ah, TRUE))
+ /* Start async operation */
+ ah->state = VFS_ASYNC_READY;
+ if (!vfs_data_wait_results (ah, TRUE))
return -1;
/* Return results */
@@ -433,57 +425,75 @@
/* Dummy callback for closing a file */
static void
-vfs_data_close_done(GnomeVFSAsyncHandle *handle, GnomeVFSResult result,
- gpointer callback_data)
+vfs_data_close_done (GObject *source, GAsyncResult *res, gpointer callback_data)
{
- /* A noop, we just let this go */
+ /*
+ * GPGME doesn't have a way to return errors from close. So we mitigate this
+ * by always flushing data above. This isn't foolproof, but seems like the
+ * best we can do.
+ */
}
/* Called to cancel the current operation.
* Puts the async handle into a cancelled state. */
static void
-vfs_data_cancel(VfsAsyncHandle *ah)
+vfs_data_cancel (VfsAsyncHandle *ah)
{
- gboolean close = FALSE;
-
- if (ah->handle) {
- switch (ah->state) {
- case VFS_ASYNC_CANCELLED:
- break;
+ switch (ah->state) {
+ case VFS_ASYNC_CANCELLED:
+ break;
- case VFS_ASYNC_PROCESSING:
- close = (ah->operation != VFS_OP_OPENING);
- gnome_vfs_async_cancel (ah->handle);
- break;
+ case VFS_ASYNC_PROCESSING:
+ g_cancellable_cancel (ah->cancellable);
+ break;
- case VFS_ASYNC_READY:
- close = TRUE;
- break;
- };
+ case VFS_ASYNC_READY:
+ break;
}
- if (close) {
- gnome_vfs_async_close (ah->handle, vfs_data_close_done, NULL);
- ah->handle = NULL;
- }
+ if (ah->ostream)
+ g_output_stream_close_async (ah->ostream, G_PRIORITY_DEFAULT, NULL, vfs_data_close_done, ah);
+ else if (ah->istream)
+ g_input_stream_close_async (ah->istream, G_PRIORITY_DEFAULT, NULL, vfs_data_close_done, ah);
+ else
+ return;
+
+ vfs_data_wait_results (ah, FALSE);
ah->state = VFS_ASYNC_CANCELLED;
}
/* Called by gpgme to close a file */
static void
-vfs_data_release(void *handle)
+vfs_data_release (void *handle)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)handle;
vfs_data_cancel (ah);
- g_free (ah->uri);
+
+ if (ah->file)
+ g_object_unref (ah->file);
+ ah->file = NULL;
+
+ if (ah->istream)
+ g_object_unref (ah->istream);
+ ah->istream = NULL;
+
+ if (ah->ostream)
+ g_object_unref (ah->ostream);
+ ah->ostream = NULL;
+
+ if (ah->cancellable)
+ g_object_unref (ah->cancellable);
+ ah->cancellable = NULL;
+
+ g_clear_error (&ah->error);
+
g_free (ah);
}
/* GPGME vfs file operations */
-static struct gpgme_data_cbs vfs_data_cbs =
-{
+static struct gpgme_data_cbs vfs_data_cbs = {
vfs_data_read,
vfs_data_write,
vfs_data_seek,
@@ -496,20 +506,17 @@
/* Create a data on the given uri, remote uris get gnome-vfs backends,
* local uris get normal file access. */
static gpgme_data_t
-create_vfs_data (const gchar *uri, guint mode, SeahorseVfsProgressCb progcb,
+create_vfs_data (GFile *file, guint mode, SeahorseVfsProgressCb progcb,
gpointer userdata, gpg_error_t* err)
{
gpgme_error_t gerr;
gpgme_data_t ret = NULL;
VfsAsyncHandle* handle = NULL;
- char* ruri;
if (!err)
err = &gerr;
- ruri = gnome_vfs_make_uri_canonical (uri);
-
- handle = vfs_data_open (ruri, mode & SEAHORSE_VFS_WRITE,
+ handle = vfs_data_open (file, mode & SEAHORSE_VFS_WRITE,
mode & SEAHORSE_VFS_DELAY);
if (handle) {
@@ -523,8 +530,6 @@
handle->userdata = userdata;
handle->gdata = ret;
}
-
- g_free (ruri);
return ret;
}
@@ -533,29 +538,29 @@
gpgme_data_t
seahorse_vfs_data_create (const gchar *uri, guint mode, GError **err)
{
- return seahorse_vfs_data_create_full (uri, mode, NULL, NULL, err);
+ GFile *file = g_file_new_for_uri (uri);
+ gpgme_data_t data;
+
+ data = seahorse_vfs_data_create_full (file, mode, NULL, NULL, err);
+ g_object_unref (file);
+
+ return data;
}
gpgme_data_t
-seahorse_vfs_data_create_full (const gchar *uri, guint mode, SeahorseVfsProgressCb progcb,
+seahorse_vfs_data_create_full (GFile *file, guint mode, SeahorseVfsProgressCb progcb,
gpointer userdata, GError **err)
{
gpgme_data_t data;
gpgme_error_t gerr;
g_return_val_if_fail (!err || !*err, NULL);
- data = create_vfs_data (uri, mode, progcb, userdata, &gerr);
+ data = create_vfs_data (file, mode, progcb, userdata, &gerr);
if (!data)
seahorse_util_gpgme_to_error (gerr, err);
return data;
}
-gpgme_data_t
-seahorse_vfs_data_create_gerr (const gchar *uri, guint mode, gpg_error_t* err)
-{
- return create_vfs_data (uri, mode, NULL, NULL, err);
-}
-
gboolean
seahorse_vfs_set_file_contents (const gchar *uri, const gchar *text, gint len,
GError **err)
Modified: seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.h
==============================================================================
--- seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.h (original)
+++ seahorse-plugins/trunk/libseahorse/seahorse-vfs-data.h Mon Jun 30 21:48:50 2008
@@ -19,7 +19,7 @@
* Boston, MA 02111-1307, USA.
*/
-#include <libgnomevfs/gnome-vfs-file-size.h>
+#include <gio/gio.h>
/**
* A gpgme_data_t implementation which maps to a gnome-vfs handle.
@@ -35,7 +35,7 @@
* writing of a file.
*/
-typedef void (*SeahorseVfsProgressCb) (gpgme_data_t data, GnomeVFSFileSize pos,
+typedef void (*SeahorseVfsProgressCb) (gpgme_data_t data, goffset pos,
gpointer userdata);
#define SEAHORSE_VFS_READ 0x00000000
@@ -45,16 +45,12 @@
gpgme_data_t seahorse_vfs_data_create (const gchar *uri, guint mode,
GError **err);
-gpgme_data_t seahorse_vfs_data_create_full (const gchar *uri, guint mode,
+gpgme_data_t seahorse_vfs_data_create_full (GFile *file, guint mode,
SeahorseVfsProgressCb progcb,
gpointer userdata, GError **err);
gpgme_data_t seahorse_vfs_data_read_multi (const gchar **uris, GError **err);
-/* Deprecated compat API, eventually to be removed */
-gpgme_data_t seahorse_vfs_data_create_gerr (const gchar *uri, guint mode,
- gpgme_error_t *err);
-
gboolean seahorse_vfs_data_write_all (gpgme_data_t data, const void* buffer,
gint len, GError **err);
Modified: seahorse-plugins/trunk/plugins/applet/seahorse-applet.c
==============================================================================
--- seahorse-plugins/trunk/plugins/applet/seahorse-applet.c (original)
+++ seahorse-plugins/trunk/plugins/applet/seahorse-applet.c Mon Jun 30 21:48:50 2008
@@ -25,7 +25,7 @@
#include <stdlib.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gnome.h>
#include <panel-applet.h>
@@ -267,21 +267,18 @@
const gchar *url,
gpointer data)
{
- GnomeVFSResult error;
-
- error = gnome_vfs_url_show (url);
-
- if (error != GNOME_VFS_OK) {
GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (about), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Could not display URL: %s"),
- gnome_vfs_result_to_string (error));
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- }
+ GError *error = NULL;
+
+ if (!gnome_url_show (url, &error)) {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (about), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Could not display URL: %s"),
+ error && error->message ? error->message : "");
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+ }
}
static void
@@ -687,22 +684,19 @@
static void
help_cb (BonoboUIComponent *uic, SeahorseApplet *sapplet, const char *verbname)
{
- gchar const *document = "ghelp:seahorse-applet";
- GnomeVFSResult error;
-
- error = gnome_vfs_url_show (document);
-
- if (error != GNOME_VFS_OK) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Could not display help: %s"),
- gnome_vfs_result_to_string (error));
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- }
+ gchar const *document = "ghelp:seahorse-applet";
+ GtkWidget *dialog;
+ GError *error = NULL;
+
+ if (!gnome_url_show (document, &error)) {
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Could not display URL: %s"),
+ error && error->message ? error->message : "");
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+ }
}
static void
Modified: seahorse-plugins/trunk/plugins/nautilus-ext/seahorse-nautilus.c
==============================================================================
--- seahorse-plugins/trunk/plugins/nautilus-ext/seahorse-nautilus.c (original)
+++ seahorse-plugins/trunk/plugins/nautilus-ext/seahorse-nautilus.c Mon Jun 30 21:48:50 2008
@@ -24,9 +24,6 @@
#include <config.h>
#include <string.h>
#include <glib/gi18n-lib.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
#include <libnautilus-extension/nautilus-extension-types.h>
#include <libnautilus-extension/nautilus-file-info.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
Modified: seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-files.c
==============================================================================
--- seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-files.c (original)
+++ seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-files.c Mon Jun 30 21:48:50 2008
@@ -29,8 +29,7 @@
#include <libintl.h>
#include <glib/gi18n.h>
-
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
#include "seahorse-tool.h"
#include "seahorse-util.h"
@@ -39,16 +38,17 @@
#include "seahorse-vfs-data.h"
#define ONE_GIGABYTE 1024 * 1024 * 1024
+#define FILE_ATTRIBUTES "standard::*"
typedef struct _FileInfo {
+ GFile *file;
+ GFileInfo *info;
gchar *uri;
- GnomeVFSFileSize size;
- gboolean directory;
} FileInfo;
typedef struct _FilesCtx {
GSList *uris;
- GList *files;
+ GList *finfos;
FileInfo *cur;
gboolean remote;
@@ -57,11 +57,14 @@
} FilesCtx;
static void
-free_file_info (FileInfo *file, gpointer unused)
+free_file_info (FileInfo *finfo, gpointer unused)
{
- if (file)
- g_free (file->uri);
- g_free (file);
+ if (finfo) {
+ g_object_unref (finfo->file);
+ g_object_unref (finfo->info);
+ g_free (finfo->uri);
+ }
+ g_free (finfo);
}
/* Included from file-roller/src/main.c for file types */
@@ -234,22 +237,19 @@
gboolean
step_check_uris (FilesCtx *ctx, const gchar **uris, GError **err)
{
- GnomeVFSFileInfo *info = NULL;
- GnomeVFSResult res;
- GnomeVFSURI *guri, *base;
- gchar *t, *uri = NULL;
+ GFile *file, *base;
+ GFileInfo *info;
+ gchar *t, *path;
gboolean ret = TRUE;
- FileInfo *file;
+ FileInfo *finfo;
const gchar **k;
+ GFileType type;
g_assert (err && !*err);
t = g_get_current_dir ();
- uri = g_strdup_printf ("file://%s/", t);
+ base = g_file_new_for_path (t);
g_free (t);
- base = gnome_vfs_uri_new (uri);
-
- info = gnome_vfs_file_info_new ();
for (k = uris; *k; k++) {
@@ -258,46 +258,52 @@
break;
}
- if (uri)
- g_free (uri);
- guri = gnome_vfs_uri_resolve_relative (base, *k);
- g_return_val_if_fail (guri != NULL, FALSE);
- uri = gnome_vfs_uri_to_string (guri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (guri);
-
- gnome_vfs_file_info_clear (info);
-
- res = gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT);
- if (res != GNOME_VFS_OK) {
- g_set_error (err, G_FILE_ERROR, -1, gnome_vfs_result_to_string (res));
- ret = FALSE;
- break;
+ t = g_uri_parse_scheme (*k);
+ if (t)
+ file = g_file_new_for_uri (*k);
+ else
+ file = g_file_resolve_relative_path (base, *k);
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ /* Find out if file can be accessed locally? */
+ path = g_file_get_path (file);
+ if (!path)
+ ctx->remote = TRUE;
+ g_free (path);
+
+ info = g_file_query_info (file, FILE_ATTRIBUTES,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, err);
+
+ if (!info) {
+ ret = FALSE;
+ g_object_unref (file);
+ break;
}
+ type = g_file_info_get_file_type (info);
+
/* Only handle simple types */
- if (info->type != GNOME_VFS_FILE_TYPE_REGULAR &&
- info->type != GNOME_VFS_FILE_TYPE_UNKNOWN &&
- info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
- continue;
+ if (type == G_FILE_TYPE_REGULAR || type == G_FILE_TYPE_UNKNOWN ||
+ type == G_FILE_TYPE_DIRECTORY) {
- if (!GNOME_VFS_FILE_INFO_LOCAL (info))
- ctx->remote = TRUE;
+ finfo = g_new0 (FileInfo, 1);
+ finfo->file = file;
+ g_object_ref (file);
+ finfo->info = info;
+ g_object_ref (info);
+ finfo->uri = g_file_get_uri (file);
- file = g_new0 (FileInfo, 1);
- file->size = info->size;
- file->directory = (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY);
- file->uri = uri;
- uri = NULL;
+ ctx->total += g_file_info_get_size (info);
+ ctx->finfos = g_list_prepend (ctx->finfos, finfo);
+ }
- ctx->total += file->size;
- ctx->files = g_list_prepend (ctx->files, file);
+ g_object_unref (file);
+ g_object_unref (info);
}
- gnome_vfs_uri_unref (base);
- g_free (uri);
- gnome_vfs_file_info_unref (info);
-
- ctx->files = g_list_reverse (ctx->files);
+ g_object_unref (base);
+
+ ctx->finfos = g_list_reverse (ctx->finfos);
return ret;
}
@@ -360,21 +366,21 @@
/* Build the multiple file dialog */
static SeahorseWidget*
-prepare_dialog (FilesCtx *ctx, guint nfolders, guint nfiles, gchar* pkguri, gchar* ext)
+prepare_dialog (FilesCtx *ctx, guint nfolders, guint nfiles, GFileInfo *info, gchar* ext)
{
SeahorseWidget *swidget;
const gchar* pkg;
GtkWidget *tog;
GtkWidget *w;
GtkWidget *combo;
- gchar *msg;
+ gchar *msg, *display;
gboolean sep;
gint i;
GtkCellRenderer *cell;
GtkTreeModel *store;
FRFileType *save_type_list;
- g_assert (pkguri);
+ g_assert (info);
swidget = seahorse_widget_new ("multi-encrypt", NULL);
g_return_val_if_fail (swidget != NULL, NULL);
@@ -403,8 +409,10 @@
/* Setup the package */
w = glade_xml_get_widget (swidget->xml, "package-name");
- pkg = seahorse_util_uri_split_last (pkguri);
+ display = g_strdup (g_file_info_get_display_name (info));
+ pkg = seahorse_util_uri_split_last (display);
gtk_entry_set_text (GTK_ENTRY (w), pkg);
+ g_free (display);
/* Setup the URI combo box */
combo = glade_xml_get_widget (swidget->xml, "package-extension");
@@ -493,22 +501,25 @@
{
SeahorseWidget *swidget;
gboolean done = FALSE;
- gchar *pkg_uri = NULL;
+ FileInfo *pkg_info = NULL;
gchar *package = NULL;
gchar *ext;
+ GFile *file, *parent;
gboolean ok = FALSE;
GtkWidget *dlg;
guint nfolders, nfiles;
gchar *uris[2];
- gchar *t;
+ gchar *uri;
GList *l;
g_assert (err && !*err);
- for (l = ctx->files, nfolders = nfiles = 0; l; l = g_list_next (l)) {
- if (((FileInfo*)(l->data))->directory)
+ for (l = ctx->finfos, nfolders = nfiles = 0; l; l = g_list_next (l)) {
+ FileInfo *finfo = (FileInfo*)l->data;
+ if (g_file_info_get_file_type (finfo->info) == G_FILE_TYPE_DIRECTORY)
++nfolders;
- ++nfiles;
+ else
+ ++nfiles;
}
/* In the case of one or less files, no dialog */
@@ -520,15 +531,15 @@
ext = g_strdup (".zip"); /* Yes this happens when the schema isn't installed */
/* Figure out a good URI for our package */
- for (l = ctx->files; l; l = g_list_next (l)) {
+ for (l = ctx->finfos; l; l = g_list_next (l)) {
if (l->data) {
- pkg_uri = gnome_vfs_make_uri_canonical (((FileInfo*)(l->data))->uri);
+ pkg_info = (FileInfo*)(l->data);
break;
}
}
/* This sets up but doesn't run the dialog */
- swidget = prepare_dialog (ctx, nfolders, nfiles, pkg_uri, ext);
+ swidget = prepare_dialog (ctx, nfolders, nfiles, pkg_info->info, ext);
g_free (ext);
@@ -571,24 +582,32 @@
/* A package was selected */
/* Make a new path based on the first uri */
- t = g_strconcat (pkg_uri, "/", package, NULL);
- g_free (package);
+ parent = g_file_get_parent (pkg_info->file);
+ if (!parent)
+ parent = pkg_info->file;
+ file = g_file_get_child_for_display_name (parent, package, err);
+ if (!file)
+ return FALSE;
+
+ uri = g_file_get_uri (file);
+ g_return_val_if_fail (uri, FALSE);
+ g_object_unref (file);
- if (!seahorse_util_uris_package (t, orig_uris)) {
- g_free (t);
+ if (!seahorse_util_uris_package (uri, orig_uris)) {
+ g_free (uri);
return FALSE;
}
/* Free all file info */
- g_list_foreach (ctx->files, (GFunc)free_file_info, NULL);
- g_list_free (ctx->files);
- ctx->files = NULL;
+ g_list_foreach (ctx->finfos, (GFunc)free_file_info, NULL);
+ g_list_free (ctx->finfos);
+ ctx->finfos = NULL;
/* Reload up the new file, as what to encrypt */
- uris[0] = t;
+ uris[0] = uri;
uris[1] = NULL;
ok = step_check_uris (ctx, (const gchar**)uris, err);
- g_free (t);
+ g_free (uri);
return ok;
}
@@ -597,86 +616,104 @@
* EXPAND STEP
*/
-typedef struct _VisitCtx {
- FilesCtx *ctx;
- GList *cur;
- const gchar *base;
-} VisitCtx;
-
-/* Called for each sub file or directory */
static gboolean
-visit_uri (const gchar *rel_path, GnomeVFSFileInfo *info, gboolean recursing_will_loop,
- VisitCtx *vctx, gboolean *recurse)
+visit_enumerator (FilesCtx *ctx, GFile *parent, GFileEnumerator *enumerator, GError **err)
{
- GList *l;
- FileInfo *file;
- gchar *t, *uri;
+ GFileEnumerator *children;
+ gboolean ret = TRUE;
+ GFileInfo *info;
+ FileInfo *finfo;
+ GFile *file;
+
+ for (;;) {
+ if (!seahorse_tool_progress_check ()) {
+ ret = FALSE;
+ break;
+ }
- /* Only files get added to our list */
- if(info->type == GNOME_VFS_FILE_TYPE_REGULAR ||
- info->type == GNOME_VFS_FILE_TYPE_UNKNOWN) {
-
- t = g_strconcat (vctx->base, "/", rel_path, NULL);
- uri = gnome_vfs_make_uri_canonical (t);
- g_free (t);
-
- file = g_new0(FileInfo, 1);
- file->uri = uri;
- file->size = info->size;
-
- /* A bit of list hanky panky */
- l = g_list_insert (vctx->cur, file, 1);
- g_assert (l == vctx->cur);
-
- vctx->ctx->total += file->size;
+ info = g_file_enumerator_next_file (enumerator, NULL, err);
+ if (!info) {
+ if (err && *err)
+ ret = FALSE;
+ break;
+ }
+
+ file = g_file_resolve_relative_path (parent, g_file_info_get_name (info));
+ g_return_val_if_fail (file, FALSE);
+
+ /* Enumerate child directories */
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ children = g_file_enumerate_children (file, FILE_ATTRIBUTES,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, err);
+ if (!enumerator) {
+ ret = FALSE;
+ break;
+ }
+
+ ret = visit_enumerator (ctx, file, children, err);
+ if (!ret)
+ break;
+
+ /* A file, add it */
+ } else {
+
+ finfo = g_new0 (FileInfo, 1);
+ finfo->info = info;
+ finfo->file = file;
+ finfo->uri = g_file_get_uri (file);
+ g_object_ref (info);
+ g_object_ref (file);
+
+ ctx->total += g_file_info_get_size (info);
+ ctx->finfos = g_list_append (ctx->finfos, finfo);
+ }
+
+ g_object_unref (file);
+ file = NULL;
}
- if (!seahorse_tool_progress_check ())
- return FALSE;
-
- *recurse = !recursing_will_loop;
- return TRUE;
+ if (file != NULL)
+ g_object_unref (file);
+
+ g_object_unref (enumerator);
+ return ret;
}
gboolean
step_expand_uris (FilesCtx *ctx, GError **err)
{
- GnomeVFSResult res;
+ GFileEnumerator *enumerator;
gboolean ret = TRUE;
- FileInfo *file;
- VisitCtx vctx;
+ FileInfo *finfo;
GList *l;
g_assert (err && !*err);
- for (l = ctx->files; l; l = g_list_next (l)) {
+ for (l = ctx->finfos; l; l = g_list_next (l)) {
if (!seahorse_tool_progress_check ()) {
ret = FALSE;
break;
}
- file = (FileInfo*)(l->data);
- if (!file || !file->uri)
+ finfo = (FileInfo*)(l->data);
+ if (!finfo || !finfo->uri)
continue;
- if (file->directory) {
+ if (g_file_info_get_file_type (finfo->info) == G_FILE_TYPE_DIRECTORY) {
- vctx.ctx = ctx;
- vctx.cur = l;
- vctx.base = file->uri;
-
- res = gnome_vfs_directory_visit (file->uri, GNOME_VFS_FILE_INFO_DEFAULT,
- GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
- (GnomeVFSDirectoryVisitFunc)visit_uri, &vctx);
- if (res != GNOME_VFS_OK) {
- g_set_error (err, G_FILE_ERROR, -1, gnome_vfs_result_to_string (res));
- ret = FALSE;
- break;
- }
+ enumerator = g_file_enumerate_children (finfo->file, FILE_ATTRIBUTES,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, err);
+ if (!enumerator)
+ return FALSE;
+ if (!visit_enumerator (ctx, finfo->file, enumerator, err))
+ return FALSE;
+
/* We don't actually do operations on the dirs */
- free_file_info (file, NULL);
+ free_file_info (finfo, NULL);
l->data = NULL;
}
}
@@ -689,15 +726,17 @@
*/
static void
-progress_cb (gpgme_data_t data, GnomeVFSFileSize pos, FilesCtx *ctx)
+progress_cb (gpgme_data_t data, goffset pos, FilesCtx *ctx)
{
gdouble total, done, size, portion;
+ goffset fsize;
g_assert (ctx && ctx->cur);
total = ctx->total > ONE_GIGABYTE ? ctx->total / 1000 : ctx->total;
done = ctx->total > ONE_GIGABYTE ? ctx->done / 1000 : ctx->done;
- size = ctx->total > ONE_GIGABYTE ? ctx->cur->size / 1000 : ctx->cur->size;
+ fsize = g_file_info_get_size (ctx->cur->info);
+ size = ctx->total > ONE_GIGABYTE ? fsize / 1000 : fsize;
portion = ctx->total > ONE_GIGABYTE ? pos / 1000 : pos;
total = total <= 0 ? 1 : total;
@@ -705,7 +744,7 @@
/* The cancel check is done elsewhere */
seahorse_tool_progress_update ((done / total) + ((size / total) * (portion / size)),
- seahorse_util_uri_get_last (ctx->cur->uri));
+ seahorse_util_uri_get_last (g_file_info_get_display_name (ctx->cur->info)));
}
gboolean
@@ -716,25 +755,25 @@
gboolean ret = FALSE;
SeahorseOperation *op;
- FileInfo *file;
+ FileInfo *finfo;
GList *l;
/* Reset our done counter */
ctx->done = 0;
- for (l = ctx->files; l; l = g_list_next (l)) {
+ for (l = ctx->finfos; l; l = g_list_next (l)) {
- file = (FileInfo*)l->data;
- if (!file || !file->uri)
+ finfo = (FileInfo*)l->data;
+ if (!finfo || !finfo->file)
continue;
- ctx->cur = file;
+ ctx->cur = finfo;
/* A new operation for each context */
pop = seahorse_pgp_operation_new (NULL);
op = SEAHORSE_OPERATION (pop);
- data = seahorse_vfs_data_create_full (file->uri, SEAHORSE_VFS_READ,
+ data = seahorse_vfs_data_create_full (finfo->file, SEAHORSE_VFS_READ,
(SeahorseVfsProgressCb)progress_cb,
ctx, err);
if (!data)
@@ -745,7 +784,7 @@
/* The start callback */
if (mode->startcb) {
- if (!(mode->startcb) (mode, file->uri, data, pop, err))
+ if (!(mode->startcb) (mode, finfo->uri, data, pop, err))
goto finally;
}
@@ -769,11 +808,11 @@
/* The done callback */
if (mode->donecb) {
- if (!(mode->donecb) (mode, file->uri, data, pop, err))
+ if (!(mode->donecb) (mode, finfo->uri, data, pop, err))
goto finally;
}
- ctx->done += file->size;
+ ctx->done += g_file_info_get_size (finfo->info);
ctx->cur = NULL;
g_object_unref (pop);
@@ -867,12 +906,12 @@
if (err) {
seahorse_util_handle_error (err, errdesc, ctx.cur ?
- seahorse_util_uri_get_last (ctx.cur->uri) : "");
+ g_file_info_get_display_name (ctx.cur->info) : "");
}
- if (ctx.files) {
- g_list_foreach (ctx.files, (GFunc)free_file_info, NULL);
- g_list_free (ctx.files);
+ if (ctx.finfos) {
+ g_list_foreach (ctx.finfos, (GFunc)free_file_info, NULL);
+ g_list_free (ctx.finfos);
}
return ret;
Modified: seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-progress.c
==============================================================================
--- seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-progress.c (original)
+++ seahorse-plugins/trunk/plugins/nautilus/seahorse-tool-progress.c Mon Jun 30 21:48:50 2008
@@ -25,8 +25,6 @@
#include <signal.h>
#include <stdlib.h>
-#include <libgnomevfs/gnome-vfs.h>
-
#include "seahorse-gtkstock.h"
#include "seahorse-util.h"
#include "seahorse-progress.h"
@@ -268,26 +266,15 @@
gboolean
seahorse_tool_progress_update (gdouble fract, const gchar *message)
{
- gchar *msg;
-
- if (message != NULL)
- msg = gnome_vfs_unescape_string (message, NULL);
- else
- msg = g_strdup ("");
-
if (progress_fd != -1) {
if (!seahorse_util_printf_fd (progress_fd, "%s %0.2f %s\n", CMD_PROGRESS,
- fract, msg)) {
+ fract, message ? message : "")) {
cancelled = TRUE;
- g_free (msg);
-
return FALSE;
}
}
- g_free (msg);
-
return seahorse_tool_progress_check ();
}
Modified: seahorse-plugins/trunk/plugins/nautilus/seahorse-tool.c
==============================================================================
--- seahorse-plugins/trunk/plugins/nautilus/seahorse-tool.c (original)
+++ seahorse-plugins/trunk/plugins/nautilus/seahorse-tool.c Mon Jun 30 21:48:50 2008
@@ -28,8 +28,6 @@
#include <glib/gi18n.h>
#include <glib/gprintf.h>
-#include <libgnomevfs/gnome-vfs.h>
-
#include <dbus/dbus-glib-bindings.h>
#include "cryptui.h"
@@ -736,9 +734,6 @@
g_strfreev (uris);
- if (gnome_vfs_initialized ())
- gnome_vfs_shutdown ();
-
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]