aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@src.gnome.org>2008-01-14 04:42:01 +0800
committerCosimo Cecchi <cosimoc@src.gnome.org>2008-01-14 04:42:01 +0800
commitaf1c2ceaef7d949e36a7680f463c5e25f79c43d6 (patch)
tree19c94f1df613831ed8ab92b4ac904be0c20c673f /src
parent12d96e8a6fc9eddaffdbad58754e712af5fc5fef (diff)
downloadgsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.tar
gsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.tar.gz
gsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.tar.bz2
gsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.tar.lz
gsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.tar.xz
gsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.tar.zst
gsoc2013-epiphany-af1c2ceaef7d949e36a7680f463c5e25f79c43d6.zip
Drop gnome-vfs dependency. Now Epiphany depends on glib >= 2.15.1.
Also, optional Zeroconf support depends on Avahi >= 0.6.22. Bug #507152. svn path=/trunk/; revision=7858
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/Makefile.am9
-rw-r--r--src/bookmarks/ephy-bookmark-action.c59
-rw-r--r--src/bookmarks/ephy-bookmarks-export.c98
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c20
-rw-r--r--src/bookmarks/ephy-bookmarks.c364
-rw-r--r--src/bookmarks/ephy-topic-action.c1
-rw-r--r--src/ephy-extensions-manager.c47
-rw-r--r--src/ephy-main.c31
-rw-r--r--src/ephy-session.c79
-rw-r--r--src/ephy-window.c12
-rw-r--r--src/popup-commands.c41
-rw-r--r--src/prefs-dialog.c17
-rw-r--r--src/window-commands.c72
13 files changed, 541 insertions, 309 deletions
diff --git a/src/bookmarks/Makefile.am b/src/bookmarks/Makefile.am
index 1863fc55b..aceaeef13 100644
--- a/src/bookmarks/Makefile.am
+++ b/src/bookmarks/Makefile.am
@@ -113,6 +113,15 @@ libephybookmarks_la_CFLAGS = \
$(DEPENDENCIES_CFLAGS) \
$(AM_CFLAGS)
+libephybookmarks_la_LIBADD =
+
+if ENABLE_ZEROCONF
+libephybookmarks_la_CFLAGS += \
+ $(AVAHI_CFLAGS)
+libephybookmarks_la_LIBADD += \
+ $(AVAHI_LIBS)
+endif
+
CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index 2958f0f09..242cd00aa 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -32,6 +32,7 @@
#include "ephy-gui.h"
#include "ephy-debug.h"
#include "ephy-dnd.h"
+#include "ephy-string.h"
#include <glib/gi18n.h>
#include <gtk/gtkwidget.h>
@@ -46,7 +47,6 @@
#include <gtk/gtkentry.h>
#include <gtk/gtktoolitem.h>
#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
#include <string.h>
@@ -367,16 +367,17 @@ ephy_bookmark_action_activate (EphyBookmarkAction *action,
/* The entered search term is empty, and we have a smart bookmark */
if ((text == NULL || text[0] == '\0') && strstr (location, "%s") != NULL)
{
- GnomeVFSURI *uri = gnome_vfs_uri_new (location);
- if (uri != NULL)
- {
- address = g_strconcat (
- gnome_vfs_uri_get_scheme (uri),
- "://",
- gnome_vfs_uri_get_host_name (uri),
- NULL);
- gnome_vfs_uri_unref (uri);
- }
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_get_scheme (location);
+ host_name = ephy_string_get_host_name (location);
+ address = g_strconcat (scheme,
+ "://",
+ host_name,
+ NULL);
+ g_free (scheme);
+ g_free (host_name);
}
if (address == NULL)
@@ -511,24 +512,28 @@ query_tooltip_cb (GtkWidget *proxy,
{
if (strstr (location, "%s") != NULL)
{
- GnomeVFSURI *uri = gnome_vfs_uri_new (location);
- if (uri != NULL)
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_get_scheme (location);
+ host_name = ephy_string_get_host_name (location);
+
+ if (title[0] == '\0')
{
- if (title[0] == '\0')
- {
- text = g_markup_printf_escaped ("%s://%s",
- gnome_vfs_uri_get_scheme (uri),
- gnome_vfs_uri_get_host_name (uri));
- }
- else
- {
- text = g_markup_printf_escaped ("%s\n%s://%s",
- title,
- gnome_vfs_uri_get_scheme (uri),
- gnome_vfs_uri_get_host_name (uri));
- }
- gnome_vfs_uri_unref (uri);
+ text = g_markup_printf_escaped ("%s://%s",
+ scheme,
+ host_name);
}
+ else
+ {
+ text = g_markup_printf_escaped ("%s\n%s://%s",
+ title,
+ scheme,
+ host_name);
+ }
+
+ g_free (scheme);
+ g_free (host_name);
}
if (text == NULL)
{
diff --git a/src/bookmarks/ephy-bookmarks-export.c b/src/bookmarks/ephy-bookmarks-export.c
index a2af331a6..c220777fd 100644
--- a/src/bookmarks/ephy-bookmarks-export.c
+++ b/src/bookmarks/ephy-bookmarks-export.c
@@ -24,6 +24,7 @@
#include "ephy-bookmarks-export.h"
#include "ephy-node-common.h"
#include "ephy-file-helpers.h"
+#include "ephy-string.h"
#include "ephy-debug.h"
#include <libxml/globals.h>
@@ -32,8 +33,6 @@
#include <libxslt/xslt.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
static inline xmlChar *
sanitise_string (const xmlChar *string)
@@ -118,7 +117,7 @@ write_topics_list (EphyNode *topics,
static int
write_rdf (EphyBookmarks *bookmarks,
- const char *filename,
+ GFile *file,
xmlTextWriterPtr writer)
{
EphyNode *bmks, *topics, *smart_bmks;
@@ -168,7 +167,7 @@ write_rdf (EphyBookmarks *bookmarks,
if (ret < 0) goto out;
/* FIXME: sanitise file_uri? */
- file_uri = gnome_vfs_get_uri_from_local_path (filename);
+ file_uri = g_file_get_uri (file);
safeString = sanitise_string ((const xmlChar *) file_uri);
g_free (file_uri);
@@ -229,21 +228,20 @@ write_rdf (EphyBookmarks *bookmarks,
smart_url = ephy_node_has_child (smart_bmks, kid);
url = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_LOCATION);
- if (smart_url)
+ if (smart_url && url)
{
- GnomeVFSURI *uri;
-
- uri = gnome_vfs_uri_new (url);
-
- if (uri)
- {
- link = g_strconcat (gnome_vfs_uri_get_scheme (uri),
- "://",
- gnome_vfs_uri_get_host_name (uri),
- NULL);
-
- gnome_vfs_uri_unref (uri);
- }
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_get_scheme (url);
+ host_name = ephy_string_get_host_name (url);
+ link = g_strconcat (scheme,
+ "://",
+ host_name,
+ NULL);
+
+ g_free (scheme);
+ g_free (host_name);
}
safeLink = sanitise_string (link ? (const xmlChar *) link : (const xmlChar *) url);
@@ -301,21 +299,20 @@ write_rdf (EphyBookmarks *bookmarks,
title = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_TITLE);
- if (smart_url)
+ if (smart_url && url)
{
- GnomeVFSURI *uri;
-
- uri = gnome_vfs_uri_new (url);
-
- if (uri)
- {
- link = g_strconcat (gnome_vfs_uri_get_scheme (uri),
- "://",
- gnome_vfs_uri_get_host_name (uri),
- NULL);
-
- gnome_vfs_uri_unref (uri);
- }
+ char *scheme;
+ char *host_name;
+
+ scheme = g_uri_get_scheme (url);
+ host_name = ephy_string_get_host_name (url);
+
+ link = g_strconcat (scheme,
+ "://",
+ host_name,
+ NULL);
+ g_free (scheme);
+ g_free (host_name);
}
if (link == NULL)
@@ -391,20 +388,23 @@ out:
void
ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *file_path)
{
xmlTextWriterPtr writer;
- char *tmp_file;
+ GFile *file, *tmp_file;
+ char *tmp_file_path;
int ret;
LOG ("Exporting as RDF to %s", filename);
START_PROFILER ("Exporting as RDF")
- tmp_file = g_strconcat (filename, ".tmp", NULL);
+ tmp_file_path = g_strconcat (file_path, ".tmp", NULL);
+ file = g_file_new_for_path (file_path);
+ tmp_file = g_file_new_for_path (tmp_file_path);
/* FIXME: do we want to turn on compression here? */
- writer = xmlNewTextWriterFilename (tmp_file, 0);
+ writer = xmlNewTextWriterFilename (tmp_file_path, 0);
if (writer == NULL)
{
g_free (tmp_file);
@@ -417,20 +417,22 @@ ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
ret = xmlTextWriterSetIndentString (writer, (xmlChar *) " ");
if (ret < 0) goto out;
- ret = write_rdf (bookmarks, filename, writer);
+ ret = write_rdf (bookmarks, file, writer);
if (ret < 0) goto out;
xmlFreeTextWriter (writer);
out:
if (ret >= 0)
{
- if (ephy_file_switch_temp_file (filename, tmp_file) == FALSE)
+ if (ephy_file_switch_temp_file (file, tmp_file) == FALSE)
{
ret = -1;
}
}
- g_free (tmp_file);
+ g_object_unref (file);
+ g_object_unref (tmp_file);
+ g_free (tmp_file_path);
STOP_PROFILER ("Exporting as RDF")
@@ -439,31 +441,33 @@ out:
void
ephy_bookmarks_export_mozilla (EphyBookmarks *bookmarks,
- const char *filename)
+ const char *filename)
{
xsltStylesheetPtr cur = NULL;
xmlTextWriterPtr writer;
xmlDocPtr doc = NULL, res;
- char *tmp_file, *template;
+ char *tmp_file_path, *template;
+ GFile *tmp_file;
int ret = -1;
LOG ("Exporting as Mozilla to %s", filename);
template = g_build_filename (g_get_tmp_dir (),
"export-bookmarks-XXXXXX", NULL);
- tmp_file = ephy_file_tmp_filename (template, "rdf");
+ tmp_file_path = ephy_file_tmp_filename (template, "rdf");
g_free (template);
- if (tmp_file == NULL) return;
+ if (tmp_file_path == NULL) return;
writer = xmlNewTextWriterDoc (&doc, 0);
if (writer == NULL || doc == NULL)
{
- g_free (tmp_file);
+ g_free (tmp_file_path);
return;
}
- START_PROFILER ("Exporting as Mozilla")
-
+ START_PROFILER ("Exporting as Mozilla");
+
+ tmp_file = g_file_new_for_path (tmp_file_path);
ret = write_rdf (bookmarks, tmp_file, writer);
if (ret < 0) goto out;
@@ -492,7 +496,7 @@ ephy_bookmarks_export_mozilla (EphyBookmarks *bookmarks,
out:
xmlFreeTextWriter (writer);
xmlFreeDoc (doc);
- g_free (tmp_file);
+ g_free (tmp_file_path);
STOP_PROFILER ("Exporting as Mozilla")
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 56d9d628f..44f5fd63a 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -23,10 +23,10 @@
#include "config.h"
#include <glib.h>
+#include <gio/gio.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlreader.h>
#include <string.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
#include <glib/gi18n.h>
@@ -71,14 +71,21 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
const char *type;
char *basename;
gboolean success = FALSE;
+ GFile *file;
+ GFileInfo *file_info;
if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
g_return_val_if_fail (filename != NULL, FALSE);
+
+ file = g_file_new_for_path (filename);
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ 0, NULL, NULL);
+ type = g_file_info_get_content_type (file_info);
+ g_object_unref (file_info);
- type = gnome_vfs_get_file_mime_type (filename, NULL, FALSE);
-
- LOG ("Importing bookmarks of type %s", type ? type : "(null)");
+ g_debug ("Importing bookmarks of type %s", type ? type : "(null)");
if (type != NULL && (strcmp (type, "application/rdf+xml") == 0 ||
strcmp (type, "text/rdf") == 0))
@@ -92,6 +99,7 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
success = ephy_bookmarks_import_xbel (bookmarks, filename);
}
else if ((type != NULL && strcmp (type, "application/x-mozilla-bookmarks") == 0) ||
+ strcmp (type, "text/html") == 0 ||
strstr (filename, MOZILLA_BOOKMARKS_DIR) != NULL ||
strstr (filename, FIREFOX_BOOKMARKS_DIR_0) != NULL ||
strstr (filename, FIREFOX_BOOKMARKS_DIR_1) != NULL ||
@@ -101,7 +109,7 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
}
else if (type == NULL)
{
- basename = g_path_get_basename (filename);
+ basename = g_file_get_basename (file);
if (g_str_has_suffix (basename, ".rdf"))
{
@@ -124,6 +132,8 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
g_free (basename);
}
+ g_object_unref (file);
+
return success;
}
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 121326874..535ac17f0 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -44,17 +44,19 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-dns-sd.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkdialog.h>
+#include <avahi-common/error.h>
+#include <avahi-gobject/ga-service-browser.h>
+#include <avahi-gobject/ga-service-resolver.h>
+#include <avahi-gobject/ga-client.h>
+#include <avahi-gobject/ga-enums.h>
#define EPHY_BOOKMARKS_XML_ROOT "ephy_bookmarks"
#define EPHY_BOOKMARKS_XML_VERSION "1.03"
#define BOOKMARKS_SAVE_DELAY 3 /* seconds */
#define MAX_FAVORITES_NUM 10
#define UPDATE_URI_DATA_KEY "updated-uri"
-#define SD_RESOLVE_TIMEOUT 0 /* ms; 0 means no timeout */
#define EPHY_BOOKMARKS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BOOKMARKS, EphyBookmarksPrivate))
@@ -85,7 +87,8 @@ struct _EphyBookmarksPrivate
#ifdef ENABLE_ZEROCONF
/* Local sites */
EphyNode *local;
- GnomeVFSDNSSDBrowseHandle *browse_handles[G_N_ELEMENTS (zeroconf_protos)];
+ GaClient *ga_client;
+ GaServiceBrowser *browse_handles[G_N_ELEMENTS (zeroconf_protos)];
GHashTable *resolve_handles;
#endif
};
@@ -782,29 +785,96 @@ backup_file (const char *original_filename, const char *extension)
#ifdef ENABLE_ZEROCONF
+/* C&P adapted from gnome-vfs-dns-sd.c */
+static GHashTable *
+decode_txt_record (AvahiStringList *input_text)
+{
+ GHashTable *hash;
+ int i;
+ int len;
+ char *key, *value, *end;
+ char *key_dup, *value_dup;
+ char *raw_txt;
+ size_t raw_txt_len;
+
+ raw_txt_len = avahi_string_list_serialize (input_text, NULL, 0);
+ raw_txt = g_malloc (raw_txt_len);
+ raw_txt_len = avahi_string_list_serialize (input_text, raw_txt, raw_txt_len);
+
+ if (raw_txt == NULL)
+ return NULL;
+
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ i = 0;
+ while (i < raw_txt_len) {
+ len = raw_txt[i++];
+
+ if (i + len > raw_txt_len) {
+ break;
+ }
+
+ if (len == 0) {
+ continue;
+ }
+
+ key = &raw_txt[i];
+ end = &raw_txt[i + len];
+ i += len;
+
+ if (*key == '=') {
+ /* 6.4 - silently ignore keys starting with = */
+ continue;
+ }
+
+ value = memchr (key, '=', len);
+ if (value) {
+ key_dup = g_strndup (key, value - key);
+ value++; /* Skip '=' */
+ value_dup = g_strndup (value, end - value);
+ } else {
+ key_dup = g_strndup (key, len);
+ value_dup = NULL;
+ }
+ if (!g_hash_table_lookup_extended (hash,
+ key_dup,
+ NULL, NULL)) {
+ g_hash_table_insert (hash,
+ key_dup,
+ value_dup);
+ } else {
+ g_free (key_dup);
+ g_free (value_dup);
+ }
+ }
+
+ return hash;
+}
+
+/* End of copied code */
+
static char *
-get_id_for_service (const GnomeVFSDNSSDService *service)
+get_id_for_response (const char *type,
+ const char *domain,
+ const char *name)
{
/* FIXME: limit length! */
return g_strdup_printf ("%s\1%s\1%s",
- service->type,
- service->domain,
- service->name);
+ type,
+ domain,
+ name);
}
static EphyNode *
-get_node_for_service (EphyBookmarks *bookmarks,
- const GnomeVFSDNSSDService *service)
+get_node_for_id (EphyBookmarks *bookmarks,
+ char *node_id)
{
EphyBookmarksPrivate *priv = bookmarks->priv;
EphyNode *kid, *node = NULL;
GPtrArray *children;
- char *search_id;
const char *id;
guint i;
- search_id = get_id_for_service (service);
-
children = ephy_node_get_children (priv->local);
for (i = 0; i < children->len; i++)
{
@@ -813,14 +883,14 @@ get_node_for_service (EphyBookmarks *bookmarks,
id = ephy_node_get_property_string (kid,
EPHY_NODE_BMK_PROP_SERVICE_ID);
- if (g_str_equal (id, search_id))
+ if (g_str_equal (id, node_id))
{
node = kid;
break;
}
}
- g_free (search_id);
+ g_free (node_id);
return node;
}
@@ -833,21 +903,26 @@ typedef struct
} ResolveData;
static void
-resolve_cb (GnomeVFSDNSSDResolveHandle *handle,
- GnomeVFSResult result,
- const GnomeVFSDNSSDService *service,
- const char *host,
- int port,
- /* const */ GHashTable *text,
- int text_raw_len,
- const char *text_raw,
- ResolveData *data)
+resolver_found_cb (GaServiceResolver *resolver,
+ int interface,
+ GaProtocol protocol,
+ const char *name,
+ const char *type,
+ const char *domain,
+ const char *host_name,
+ const AvahiAddress *address,
+ guint16 port,
+ AvahiStringList *txt,
+ glong flags,
+ ResolveData *data)
{
EphyBookmarks *bookmarks = data->bookmarks;
EphyBookmarksPrivate *priv = bookmarks->priv;
EphyNode *node = data->node;
GValue value = { 0, };
const char *path = NULL;
+ char host[128];
+ GHashTable *text_table;
char *url;
gboolean was_immutable;
guint i;
@@ -856,39 +931,38 @@ resolve_cb (GnomeVFSDNSSDResolveHandle *handle,
ephy_node_db_set_immutable (priv->db, FALSE);
g_hash_table_steal (priv->resolve_handles, node);
-
- /* Error, don't add the service */
- if (result != GNOME_VFS_OK)
- {
- ephy_node_unref (node);
-
- ephy_node_db_set_immutable (priv->db, was_immutable);
-
- return;
- }
-
+
/* Find the protocol */
for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i)
{
char proto[20];
g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
- if (strcmp (service->type, proto) == 0) break;
+ if (strcmp (type, proto) == 0) break;
}
if (i == G_N_ELEMENTS (zeroconf_protos)) return;
+
+ text_table = decode_txt_record (txt);
- if (text != NULL)
+ if (text_table != NULL)
{
- path = g_hash_table_lookup (text, "path");
+ path = g_hash_table_lookup (text_table, "path");
}
if (path == NULL || path[0] == '\0')
{
path = "/";
}
+
+ if (address == NULL)
+ {
+ g_warning ("Zeroconf failed to resolve host %s", name);
+ return;
+ }
+ avahi_address_snprint (host, sizeof (host), address);
LOG ("0conf RESOLVED type=%s domain=%s name=%s => proto=%s host=%s port=%d path=%s\n",
- service->type, service->domain, service->name,
- zeroconf_protos[i], host, port, path);
+ type, domain, name,
+ zeroconf_protos[i], host, port, path);
/* FIXME: limit length! */
url = g_strdup_printf ("%s://%s:%d%s", zeroconf_protos[i], host, port, path);
@@ -908,39 +982,84 @@ resolve_cb (GnomeVFSDNSSDResolveHandle *handle,
}
static void
-browse_cb (GnomeVFSDNSSDBrowseHandle *handle,
- GnomeVFSDNSSDServiceStatus status,
- const GnomeVFSDNSSDService *service,
- EphyBookmarks *bookmarks)
+resolver_failure_cb (GaServiceResolver *resolver,
+ GError *error,
+ ResolveData *data)
{
+ EphyBookmarks *bookmarks = data->bookmarks;
EphyBookmarksPrivate *priv = bookmarks->priv;
- GnomeVFSDNSSDResolveHandle *reshandle = NULL;
- ResolveData *data;
- EphyNode *node;
- GValue value = { 0, };
- gboolean new_node = FALSE;
+ EphyNode *node = data->node;
+ gboolean was_immutable;
- if (service == NULL) return;
+ was_immutable = ephy_node_db_is_immutable (priv->db);
+ ephy_node_db_set_immutable (priv->db, FALSE);
- node = get_node_for_service (bookmarks, service);
+ g_hash_table_steal (priv->resolve_handles, node);
- if (status == GNOME_VFS_DNS_SD_SERVICE_REMOVED)
- {
- if (node != NULL)
- {
- g_hash_table_remove (priv->resolve_handles, node);
- ephy_node_unref (node);
- }
+ /* Error, don't add the service */
+ ephy_node_unref (node);
+ ephy_node_db_set_immutable (priv->db, was_immutable);
- return;
- }
+ return;
+}
- /* status == GNOME_VFS_DNS_SD_SERVICE_ADDED */
+static void
+free_resolve_cb_data (gpointer data)
+{
+ g_slice_free (ResolveData, data);
+}
- LOG ("0conf ADD: type=%s domain=%s name=%s\n",
- service->type, service->domain, service->name);
+static void
+browser_removed_service_cb (GaServiceBrowser *browser,
+ int interface,
+ GaProtocol protocol,
+ const char *name,
+ const char *type,
+ const char *domain,
+ glong flags,
+ EphyBookmarks *bookmarks)
+{
+ EphyBookmarksPrivate *priv = bookmarks->priv;
+ EphyNode *node;
+ char *node_id;
+
+ node_id = get_id_for_response (type, domain, name);
+ node = get_node_for_id (bookmarks, node_id);
+
+ if (node != NULL)
+ {
+ g_hash_table_remove (priv->resolve_handles, node);
+ ephy_node_unref (node);
+ }
+
+ return;
+}
- if (node != NULL &&
+static void
+browser_new_service_cb (GaServiceBrowser *browser,
+ int interface,
+ GaProtocol protocol,
+ const char *name,
+ const char *type,
+ const char *domain,
+ glong flags,
+ EphyBookmarks *bookmarks)
+{
+ EphyBookmarksPrivate *priv = bookmarks->priv;
+ EphyNode *node;
+ GValue value = { 0, };
+ gboolean new_node = FALSE;
+ GaServiceResolver *resolver = NULL;
+ ResolveData *data;
+ char *node_id;
+
+ node_id = get_id_for_response (type, domain, name);
+ node = get_node_for_id (bookmarks, node_id);
+
+ LOG ("0conf ADD: type=%s domain=%s name=%s\n",
+ type, domain, name);
+
+ if (node != NULL &&
g_hash_table_lookup (priv->resolve_handles, node) != NULL) return;
if (node == NULL)
@@ -959,14 +1078,14 @@ browse_cb (GnomeVFSDNSSDBrowseHandle *handle,
ephy_node_set_is_drag_source (node, FALSE);
g_value_init (&value, G_TYPE_STRING);
- g_value_take_string (&value, get_id_for_service (service));
+ g_value_take_string (&value, get_id_for_response (type, domain, name));
ephy_node_set_property (node, EPHY_NODE_BMK_PROP_SERVICE_ID, &value);
g_value_unset (&value);
/* FIXME: limit length! */
ephy_node_set_property_string (node,
EPHY_NODE_BMK_PROP_TITLE,
- service->name);
+ name);
ephy_node_set_property_boolean (node,
EPHY_NODE_BMK_PROP_IMMUTABLE,
@@ -975,58 +1094,110 @@ browse_cb (GnomeVFSDNSSDBrowseHandle *handle,
ephy_node_db_set_immutable (priv->db, was_immutable);
}
- data = g_new (ResolveData, 1);
+ data = g_slice_new0 (ResolveData);
data->bookmarks = bookmarks;
data->node = node;
data->new_node = new_node;
-
- if (gnome_vfs_dns_sd_resolve (&reshandle,
- service->name, service->type, service->domain,
- SD_RESOLVE_TIMEOUT,
- (GnomeVFSDNSSDResolveCallback) resolve_cb,
- data,
- (GDestroyNotify) g_free) != GNOME_VFS_OK)
+
+ resolver = ga_service_resolver_new (AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ name, type, domain,
+ AVAHI_PROTO_UNSPEC,
+ GA_LOOKUP_USE_MULTICAST);
+ g_signal_connect_data (resolver, "found",
+ G_CALLBACK (resolver_found_cb), data,
+ (GClosureNotify) free_resolve_cb_data, 0);
+ g_signal_connect_data (resolver, "failure",
+ G_CALLBACK (resolver_failure_cb), data,
+ (GClosureNotify) free_resolve_cb_data, 0);
+ if (!ga_service_resolver_attach (resolver,
+ priv->ga_client,
+ NULL))
{
+ g_warning ("Unable to resolve Zeroconf service %s", name);
ephy_node_unref (node);
- g_free (data);
-
+ free_resolve_cb_data (data);
return;
}
-
g_hash_table_insert (priv->resolve_handles,
- node, reshandle);
+ node, resolver);
}
static void
-ephy_local_bookmarks_init (EphyBookmarks *bookmarks)
+start_browsing (GaClient *ga_client,
+ EphyBookmarks *bookmarks)
{
EphyBookmarksPrivate *priv = bookmarks->priv;
guint i;
- priv->resolve_handles =
- g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL,
- (GDestroyNotify) gnome_vfs_dns_sd_cancel_resolve);
-
for (i = 0; i < G_N_ELEMENTS (zeroconf_protos); ++i)
{
- GnomeVFSDNSSDBrowseHandle *handle = NULL;
+ GaServiceBrowser *browser = NULL;
char proto[20];
g_snprintf (proto, sizeof (proto), "_%s._tcp", zeroconf_protos[i]);
- if (gnome_vfs_dns_sd_browse (&handle,
- "local", proto,
- (GnomeVFSDNSSDBrowseCallback) browse_cb,
- bookmarks,
- NULL) == GNOME_VFS_OK)
+ browser = ga_service_browser_new (proto);
+ g_signal_connect (browser, "new-service",
+ G_CALLBACK (browser_new_service_cb), bookmarks);
+ g_signal_connect (browser, "removed-service",
+ G_CALLBACK (browser_removed_service_cb), bookmarks);
+ if (!ga_service_browser_attach (browser,
+ ga_client,
+ NULL))
{
- priv->browse_handles[i] = handle;
+ g_warning ("Unable to start Zeroconf subsystem");
+ return;
}
+
+ priv->browse_handles[i] = browser;
}
}
static void
+ga_client_state_changed_cb (GaClient *ga_client,
+ GaClientState state,
+ EphyBookmarks *bookmarks)
+{
+ if (state == GA_CLIENT_STATE_FAILURE)
+ {
+ if (avahi_client_errno (ga_client->avahi_client) == AVAHI_ERR_DISCONNECTED)
+ {
+ /* Destroy and reconnect */
+ avahi_client_free (ga_client->avahi_client);
+ ga_client->avahi_client = NULL;
+ if (!ga_client_start (ga_client, NULL))
+ {
+ g_warning ("Unable to start Zeroconf subsystem");
+ }
+ }
+ }
+ if (state == GA_CLIENT_STATE_S_RUNNING)
+ {
+ start_browsing (ga_client, bookmarks);
+ }
+}
+
+static void
+ephy_local_bookmarks_init (EphyBookmarks *bookmarks)
+{
+ EphyBookmarksPrivate *priv = bookmarks->priv;
+ GaClient *ga_client;
+
+ ga_client = ga_client_new (GA_CLIENT_FLAG_NO_FAIL);
+ g_signal_connect (ga_client, "state-changed",
+ G_CALLBACK (ga_client_state_changed_cb),
+ bookmarks);
+ if (!ga_client_start (ga_client, NULL))
+ {
+ g_warning ("Unable to start Zeroconf subsystem");
+ return;
+ }
+ priv->ga_client = ga_client;
+ priv->resolve_handles = g_hash_table_new (g_direct_hash, g_direct_equal);
+}
+
+static void
ephy_local_bookmarks_stop (EphyBookmarks *bookmarks)
{
EphyBookmarksPrivate *priv = bookmarks->priv;
@@ -1036,7 +1207,6 @@ ephy_local_bookmarks_stop (EphyBookmarks *bookmarks)
{
if (priv->browse_handles[i] != NULL)
{
- gnome_vfs_dns_sd_stop_browse (priv->browse_handles[i]);
priv->browse_handles[i] = NULL;
}
}
@@ -1051,6 +1221,12 @@ ephy_local_bookmarks_stop (EphyBookmarks *bookmarks)
{
ephy_node_remove_child (priv->keywords, priv->local);
}
+
+ if (priv->ga_client != NULL)
+ {
+ g_object_unref (priv->ga_client);
+ priv->ga_client = NULL;
+ }
}
#endif /* ENABLE_ZEROCONF */
@@ -1569,7 +1745,7 @@ impl_resolve_address (EphyBookmarks *eb,
}
else
{
- escaped_arg = gnome_vfs_escape_string (arg);
+ escaped_arg = g_uri_escape_string (arg, NULL, TRUE);
g_string_append (result, escaped_arg);
g_free (escaped_arg);
g_free (arg);
@@ -1579,7 +1755,7 @@ impl_resolve_address (EphyBookmarks *eb,
}
else
{
- arg = gnome_vfs_escape_string (content);
+ arg = g_uri_escape_string (content, NULL, TRUE);
g_string_append (result, arg);
g_free (arg);
}
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index ad5eb9eef..34c9fc843 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -46,7 +46,6 @@
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkarrow.h>
#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
#include <string.h>
static const GtkTargetEntry dest_drag_types[] = {
diff --git a/src/ephy-extensions-manager.c b/src/ephy-extensions-manager.c
index 9d489d1cb..10aa75f9c 100644
--- a/src/ephy-extensions-manager.c
+++ b/src/ephy-extensions-manager.c
@@ -49,11 +49,9 @@
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include <gmodule.h>
#include <dirent.h>
#include <string.h>
@@ -998,35 +996,35 @@ schedule_load_from_monitor (EphyExtensionsManager *manager,
}
static void
-dir_changed_cb (GnomeVFSMonitorHandle *handle,
- const char *monitor_uri,
- const char *info_uri,
- GnomeVFSMonitorEventType event_type,
+dir_changed_cb (GFileMonitor *monitor,
+ GFile *child,
+ GFile *other_child,
+ GFileMonitorEvent event_type,
EphyExtensionsManager *manager)
{
char *path;
+
+ path = g_file_get_path (child);
/*
* We only deal with XML and INI files:
* Add them to the manager when created, remove them when deleted.
*/
- if (format_from_path (info_uri) == FORMAT_UNKNOWN) return;
-
- path = gnome_vfs_get_local_path_from_uri (info_uri);
+ if (format_from_path (path) == FORMAT_UNKNOWN) return;
switch (event_type)
{
- case GNOME_VFS_MONITOR_EVENT_CREATED:
- case GNOME_VFS_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ case G_FILE_MONITOR_EVENT_CHANGED:
schedule_load_from_monitor (manager, path);
break;
- case GNOME_VFS_MONITOR_EVENT_DELETED:
+ case G_FILE_MONITOR_EVENT_DELETED:
ephy_extensions_manager_unload_file (manager, path);
break;
default:
break;
}
-
+
g_free (path);
}
@@ -1037,9 +1035,8 @@ ephy_extensions_manager_load_dir (EphyExtensionsManager *manager,
DIR *d;
struct dirent *e;
char *file_path;
- char *file_uri;
- GnomeVFSMonitorHandle *monitor;
- GnomeVFSResult res;
+ GFile *directory;
+ GFileMonitor *monitor;
LOG ("Scanning directory '%s'", path);
@@ -1061,16 +1058,14 @@ ephy_extensions_manager_load_dir (EphyExtensionsManager *manager,
}
closedir (d);
- file_uri = gnome_vfs_get_uri_from_local_path (path);
- res = gnome_vfs_monitor_add (&monitor,
- path,
- GNOME_VFS_MONITOR_DIRECTORY,
- (GnomeVFSMonitorCallback) dir_changed_cb,
- manager);
- g_free (file_uri);
+ directory = g_file_new_for_path (path);
+ monitor = g_file_monitor_directory (directory, 0, NULL);
- if (res == GNOME_VFS_OK)
+ if (monitor != NULL)
{
+ g_signal_connect (monitor, "changed",
+ G_CALLBACK (dir_changed_cb),
+ manager);
manager->priv->dir_monitors = g_list_prepend
(manager->priv->dir_monitors, monitor);
}
@@ -1165,7 +1160,7 @@ ephy_extensions_manager_dispose (GObject *object)
if (priv->dir_monitors != NULL)
{
- g_list_foreach (priv->dir_monitors, (GFunc) gnome_vfs_monitor_cancel, NULL);
+ g_list_foreach (priv->dir_monitors, (GFunc) g_file_monitor_cancel, NULL);
g_list_free (priv->dir_monitors);
priv->dir_monitors = NULL;
}
diff --git a/src/ephy-main.c b/src/ephy-main.c
index ae473719b..f4bfec47e 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -47,8 +47,6 @@
#include <libgnome/gnome-program.h>
#include <libgnomeui/gnome-ui-init.h>
-#include <libgnomevfs/gnome-vfs-init.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomeui/gnome-app-helper.h>
#include <errno.h>
@@ -203,11 +201,24 @@ handle_email (GtkAboutDialog *about,
const char *link,
gpointer data)
{
- char *address;
+ char *command, *handler;
+ GAppInfo *appinfo;
- address = g_strdup_printf ("mailto:%s", link);
- gnome_vfs_url_show (address);
- g_free (address);
+ if (eel_gconf_get_boolean ("/desktop/gnome/url-handlers/mailto/enabled") == FALSE)
+ {
+ return;
+ }
+ /* FIXME: better use g_app_info_get_default_for_uri_scheme () when it is
+ * implemented.
+ */
+ handler = eel_gconf_get_string ("/desktop/gnome/url-handlers/mailto/command");
+ command = g_strconcat (handler, "mailto:", link, NULL);
+ appinfo = g_app_info_create_from_commandline (command, NULL, 0, NULL);
+ ephy_file_launch_application (appinfo, NULL,
+ gtk_get_current_event_time (),
+ GTK_WIDGET (about));
+ g_free (handler);
+ g_free (command);
}
static void
@@ -585,12 +596,15 @@ main (int argc,
{
g_free (arguments[i]);
- /* If it's a file, use gnome_vfs_make_uri_from_shell_arg,
+ /* If it's a file, use g_file_new_for_commandline_arg,
* so we get the right escaping.
*/
if (path != NULL)
{
- arguments[i] = gnome_vfs_make_uri_from_shell_arg (uri);
+ GFile *file;
+ file = g_file_new_for_commandline_arg (uri);
+ arguments[i] = g_file_get_uri (file);
+ g_object_unref (file);
g_free (uri);
}
else
@@ -727,7 +741,6 @@ main (int argc,
gnome_accelerators_sync ();
ephy_state_save ();
ephy_file_helpers_shutdown ();
- gnome_vfs_shutdown ();
xmlCleanupParser ();
_ephy_dbus_release ();
diff --git a/src/ephy-session.c b/src/ephy-session.c
index c1b79d25d..2342d2998 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -40,6 +40,7 @@
#include "ephy-notebook.h"
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkimage.h>
#include <gtk/gtklabel.h>
@@ -52,9 +53,6 @@
#include <libgnomeui/gnome-client.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
@@ -391,10 +389,11 @@ die_cb (GnomeClient* client,
/* Helper functions */
-static char *
-get_session_filename (const char *filename)
+static GFile *
+get_session_file (const char *filename)
{
- char *save_to;
+ GFile *file;
+ char *path;
if (filename == NULL)
{
@@ -403,29 +402,30 @@ get_session_filename (const char *filename)
if (strcmp (filename, SESSION_CRASHED) == 0)
{
- save_to = g_build_filename (ephy_dot_dir (),
- "session_crashed.xml",
- NULL);
+ path = g_build_filename (ephy_dot_dir (),
+ "session_crashed.xml",
+ NULL);
}
else
{
- save_to = g_strdup (filename);
+ path = g_strdup (filename);
}
- return save_to;
+ file = g_file_new_for_path (path);
+ g_free (path);
+
+ return file;
}
static void
session_delete (EphySession *session,
const char *filename)
{
- char *save_to;
+ GFile *file;
- save_to = get_session_filename (filename);
+ file = get_session_file (filename);
- gnome_vfs_unlink (save_to);
-
- g_free (save_to);
+ g_file_delete (file, NULL, NULL);
}
static void
@@ -566,14 +566,17 @@ session_command_autoresume (EphySession *session,
{
EphySessionPrivate *priv = session->priv;
GtkWidget *dialog;
- char *saved_session;
+ GFile *saved_session_file;
+ char *saved_session_file_path;
gboolean crashed_session;
LOG ("ephy_session_autoresume");
- saved_session = get_session_filename (SESSION_CRASHED);
- crashed_session = g_file_test (saved_session, G_FILE_TEST_EXISTS);
- g_free (saved_session);
+ saved_session_file = get_session_file (SESSION_CRASHED);
+ saved_session_file_path = g_file_get_path (saved_session_file);
+ crashed_session = g_file_test (saved_session_file_path, G_FILE_TEST_EXISTS);
+
+ g_free (saved_session_file_path);
if (crashed_session == FALSE ||
priv->windows != NULL ||
@@ -1225,7 +1228,8 @@ ephy_session_save (EphySession *session,
EphySessionPrivate *priv;
xmlTextWriterPtr writer;
GList *w;
- char *save_to, *tmp_file;
+ GFile *save_to_file, *tmp_file;
+ char *tmp_file_path;
int ret;
g_return_val_if_fail (EPHY_IS_SESSION (session), FALSE);
@@ -1245,15 +1249,15 @@ ephy_session_save (EphySession *session,
return TRUE;
}
- save_to = get_session_filename (filename);
- tmp_file = g_strconcat (save_to, ".tmp", NULL);
+ save_to_file = get_session_file (filename);
+ tmp_file_path = g_strconcat (g_file_get_path (save_to_file), ".tmp", NULL);
+ tmp_file = g_file_new_for_path (tmp_file_path);
/* FIXME: do we want to turn on compression? */
- writer = xmlNewTextWriterFilename (tmp_file, 0);
+ writer = xmlNewTextWriterFilename (tmp_file_path, 0);
if (writer == NULL)
{
- g_free (save_to);
- g_free (tmp_file);
+ g_free (tmp_file_path);
return FALSE;
}
@@ -1296,14 +1300,15 @@ out:
if (ret >= 0)
{
- if (ephy_file_switch_temp_file (save_to, tmp_file) == FALSE)
+ if (ephy_file_switch_temp_file (save_to_file, tmp_file) == FALSE)
{
ret = -1;
}
}
- g_free (save_to);
- g_free (tmp_file);
+ g_free (tmp_file_path);
+ g_object_unref (save_to_file);
+ g_object_unref (tmp_file);
STOP_PROFILER ("Saving session")
@@ -1345,9 +1350,11 @@ parse_embed (xmlNodePtr child,
char *escaped_url, *escaped_title;
title = xmlGetProp (child, (const xmlChar *) "title");
- escaped_title = gnome_vfs_escape_string (title ? (const char*) title : _("Untitled"));
+ escaped_title = g_uri_escape_string (title ? (const char*) title : _("Untitled"),
+ NULL, TRUE);
- escaped_url = gnome_vfs_escape_string ((const char *) url);
+ escaped_url = g_uri_escape_string ((const char *) url,
+ NULL, TRUE);
freeme = recover_url =
g_strconcat ("about:recover?u=",
escaped_url,
@@ -1452,14 +1459,16 @@ ephy_session_load (EphySession *session,
xmlNodePtr child;
EphyWindow *window;
GtkWidget *widget = NULL;
- char *save_to;
+ GFile *save_to_file;
+ char *save_to_path;
LOG ("ephy_sesion_load %s", filename);
- save_to = get_session_filename (filename);
+ save_to_file = get_session_file (filename);
+ save_to_path = g_file_get_path (save_to_file);
- doc = xmlParseFile (save_to);
- g_free (save_to);
+ doc = xmlParseFile (save_to_path);
+ g_free (save_to_path);
if (doc == NULL)
{
diff --git a/src/ephy-window.c b/src/ephy-window.c
index ef8935bea..7213d1315 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -60,7 +60,7 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
+#include <gio/gio.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
@@ -1977,15 +1977,9 @@ embed_popup_deactivate_cb (GtkWidget *popup,
static char *
get_name_from_address_value (const GValue *value)
{
- GnomeVFSURI *uri;
- char *name = NULL;
+ char *name;
- uri = gnome_vfs_uri_new (g_value_get_string (value));
- if (uri)
- {
- name = gnome_vfs_uri_extract_short_name (uri);
- gnome_vfs_uri_unref (uri);
- }
+ name = g_path_get_basename (g_value_get_string (value));
return name != NULL ? name : g_strdup ("");
}
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 6e4d677a4..51b2fbfd5 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -35,10 +35,6 @@
#include <glib/gi18n.h>
#include <gtk/gtkclipboard.h>
#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
void
popup_cmd_link_in_new_window (GtkAction *action,
@@ -279,7 +275,8 @@ popup_cmd_save_image_as (GtkAction *action,
#define GNOME_APPEARANCE_PROPERTIES "gnome-appearance-properties.desktop"
static void
-background_download_completed (EphyEmbedPersist *persist)
+background_download_completed (EphyEmbedPersist *persist,
+ GtkWidget *window)
{
const char *bg;
guint32 user_time;
@@ -289,15 +286,15 @@ background_download_completed (EphyEmbedPersist *persist)
bg = ephy_embed_persist_get_dest (persist);
/* open the Appearance Properties capplet on the Background tab */
- if (!ephy_file_launch_desktop_file (GNOME_APPEARANCE_PROPERTIES, bg, user_time))
+ if (!ephy_file_launch_desktop_file (GNOME_APPEARANCE_PROPERTIES, bg, user_time, window))
{
/* Fallback for <= 2.18 desktop: try to open the "Background Properties" capplet */
- if (!ephy_file_launch_desktop_file ("background.desktop", bg, user_time))
+ if (!ephy_file_launch_desktop_file ("background.desktop", bg, user_time, window))
{
/* If the above try didn't work, then we try the Fedora name.
* This is a fix for #387206, but is actually a workaround for
* bugzilla.redhat.com #201867 */
- ephy_file_launch_desktop_file ("gnome-background.desktop", bg, user_time);
+ ephy_file_launch_desktop_file ("gnome-background.desktop", bg, user_time, window);
}
}
@@ -338,7 +335,7 @@ popup_cmd_set_image_as_background (GtkAction *action,
g_signal_connect (persist, "completed",
G_CALLBACK (background_download_completed),
- NULL);
+ window);
ephy_embed_persist_save (persist);
@@ -383,13 +380,13 @@ popup_cmd_open_frame (GtkAction *action,
* doesn't work, fallback to open the URI in a new browser window.
*/
static void
-image_open_uri (const char *remote_address,
- const char *local_address,
+image_open_uri (GFile *file,
+ const char *remote_address,
guint32 user_time)
{
gboolean success;
- success = ephy_file_launch_handler (NULL, local_address, user_time);
+ success = ephy_file_launch_handler (NULL, file, user_time);
if (!success)
{
@@ -398,12 +395,12 @@ image_open_uri (const char *remote_address,
EPHY_NEW_TAB_IN_NEW_WINDOW);
}
- if (strcmp (remote_address, local_address) != 0)
+ if (strcmp (remote_address, g_file_get_uri (file)) != 0)
{
if (success)
- ephy_file_delete_on_exit (local_address);
+ ephy_file_delete_on_exit (file);
else
- gnome_vfs_unlink (local_address);
+ g_file_delete (file, NULL, NULL);
}
}
@@ -413,13 +410,17 @@ save_source_completed_cb (EphyEmbedPersist *persist)
const char *dest;
const char *source;
guint32 user_time;
+ GFile *file;
user_time = ephy_embed_persist_get_user_time (persist);
dest = ephy_embed_persist_get_dest (persist);
source = ephy_embed_persist_get_source (persist);
g_return_if_fail (dest != NULL);
+
+ file = g_file_new_for_path (dest);
- image_open_uri (source, dest, user_time);
+ image_open_uri (file, source, user_time);
+ g_object_unref (file);
}
static void
@@ -480,13 +481,17 @@ popup_cmd_open_image (GtkAction *action,
value = ephy_embed_event_get_property (event, "image");
address = g_value_get_string (value);
- scheme = gnome_vfs_get_uri_scheme (address);
+ scheme = g_uri_get_scheme (address);
if (scheme == NULL) return;
if (strcmp (scheme, "file") == 0)
{
- image_open_uri (address, address,
+ GFile *file;
+
+ file = g_file_new_for_uri (address);
+ image_open_uri (file, address,
gtk_get_current_event_time ());
+ g_object_unref (file);
}
else
{
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 5c203ec92..8cc84507e 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -64,8 +64,6 @@
#include <gtk/gtkmain.h>
#include <string.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
#define CONF_FONTS_FOR_LANGUAGE "/apps/epiphany/dialogs/preferences_font_language"
#define DOWNLOAD_BUTTON_WIDTH 8
@@ -649,18 +647,15 @@ static void
css_edit_button_clicked_cb (GtkWidget *button,
PrefsDialog *pd)
{
- char *css_file, *uri;
+ GFile *css_file;
- css_file = g_build_filename (ephy_dot_dir (),
- USER_STYLESHEET_FILENAME,
- NULL);
- uri = gnome_vfs_get_uri_from_local_path (css_file);
+ css_file = g_file_new_for_path (g_build_filename (ephy_dot_dir (),
+ USER_STYLESHEET_FILENAME,
+ NULL));
- ephy_file_launch_handler ("text/plain", uri,
+ ephy_file_launch_handler ("text/plain", css_file,
gtk_get_current_event_time ());
-
- g_free (css_file);
- g_free (uri);
+ g_object_unref (css_file);
}
static void
diff --git a/src/window-commands.c b/src/window-commands.c
index fb7438e58..9bc698a67 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -49,14 +49,13 @@
#include "ephy-bookmarks-ui.h"
#include "ephy-link.h"
#include "ephy-stock-icons.h"
+#include "ephy-string.h"
+#include "eel-app-launch-context.h"
#include "pdm-dialog.h"
#include <string.h>
#include <glib.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomeui/gnome-stock-icons.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <gio/gio.h>
#include <gtk/gtkaboutdialog.h>
#include <gtk/gtkeditable.h>
#include <gtk/gtkmain.h>
@@ -122,24 +121,38 @@ window_cmd_file_send_to (GtkAction *action,
EphyWindow *window)
{
EphyEmbed *embed;
- char *url, *location, *title;
+ char *handler, *command;
+ const char *location, *title;
+ GAppInfo *appinfo;
+
+ if (eel_gconf_get_boolean ("/desktop/gnome/url-handlers/mailto/enabled") == FALSE)
+ {
+ /* FIXME: add some UI to inform the user? */
+ return;
+ }
embed = ephy_embed_container_get_active_child
(EPHY_EMBED_CONTAINER (window));
g_return_if_fail (embed != NULL);
- location = gnome_vfs_escape_string (ephy_embed_get_address (embed));
- title = gnome_vfs_escape_string (ephy_embed_get_title (embed));
-
- url = g_strconcat ("mailto:",
- "?Subject=", title,
- "&Body=", location, NULL);
+ location = ephy_embed_get_address (embed);
+ title = ephy_embed_get_title (embed);
- gnome_vfs_url_show (url);
+ /* FIXME: better use g_app_info_get_default_for_uri_scheme () when it is
+ * implemented.
+ */
+ handler = eel_gconf_get_string ("/desktop/gnome/url-handlers/mailto/command");
+ command = g_strconcat (handler, "mailto:",
+ "?Subject=\"", title,
+ "\"&Body=\"", location, "\"", NULL);
+
+ appinfo = g_app_info_create_from_commandline (command, NULL, 0, NULL);
+ ephy_file_launch_application (appinfo, NULL,
+ gtk_get_current_event_time (),
+ GTK_WIDGET (window));
- g_free (title);
- g_free (location);
- g_free (url);
+ g_free (handler);
+ g_free (command);
}
static gboolean
@@ -564,14 +577,17 @@ save_source_completed_cb (EphyEmbedPersist *persist)
{
const char *dest;
guint32 user_time;
+ GFile *file;
user_time = ephy_embed_persist_get_user_time (persist);
dest = ephy_embed_persist_get_dest (persist);
g_return_if_fail (dest != NULL);
- ephy_file_delete_on_exit (dest);
+ file = g_file_new_for_path (dest);
+ ephy_file_delete_on_exit (file);
- ephy_file_launch_handler ("text/plain", dest, user_time);
+ ephy_file_launch_handler ("text/plain", file, user_time);
+ g_object_unref (file);
}
static void
@@ -631,7 +647,12 @@ window_cmd_view_page_source (GtkAction *action,
if (g_str_has_prefix (address, "file://"))
{
- ephy_file_launch_handler ("text/plain", address, user_time);
+ GFile *file;
+
+ file = g_file_new_for_uri (address);
+ ephy_file_launch_handler ("text/plain", file, user_time);
+
+ g_object_unref (file);
}
else
{
@@ -670,24 +691,21 @@ window_cmd_edit_personal_data (GtkAction *action,
{
PdmDialog *dialog;
EphyEmbed *embed;
- GnomeVFSURI *uri;
- const char *host;
+ const char *address;
+ char *host;
embed = ephy_embed_container_get_active_child
(EPHY_EMBED_CONTAINER (window));
if (embed == NULL) return;
- uri = gnome_vfs_uri_new (ephy_embed_get_address (embed));
-
- host = uri != NULL ? gnome_vfs_uri_get_host_name (uri) : NULL;
+ address = ephy_embed_get_address (embed);
+
+ host = address != NULL ? ephy_string_get_host_name (address) : NULL;
dialog = EPHY_PDM_DIALOG (ephy_shell_get_pdm_dialog (ephy_shell));
pdm_dialog_open (dialog, host);
- if (uri != NULL)
- {
- gnome_vfs_uri_unref (uri);
- }
+ g_free (host);
}
#ifdef ENABLE_CERTIFICATE_MANAGER