summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2007-11-12 12:22:05 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-11-12 12:22:05 +0000
commit5390fb86582c79939b7a51ef512bd28664bbb1ca (patch)
tree5a4bb1e7f34929b7ca7e8c0675183f5e884eb702
parent31644982c385c859b9d4b3794b1d842d32aaebd8 (diff)
downloadgvfs-5390fb86582c79939b7a51ef512bd28664bbb1ca.tar.gz
Add new functions
2007-11-12 Alexander Larsson <alexl@redhat.com> * common/gmountspec.[ch]: (g_mount_spec_new_from_data): (g_mount_spec_set_with_len): Add new functions * client/Makefile.am: * common/Makefile.am: Update for moved files Build non-shared version of common libs. Ups non-shared common libs in client module. * common/gvfsuriutils.[ch]: Removed. * client/gvfsuriutils.[ch]: Added. Moved uriutils to gvfs (not used by daemon) Re-namespace to g_vfs_* * common/gvfsurimapper.[ch]: Removed. * client/gvfsurimapper.[ch]: Added. Move UriMapper to client lib Remove/Hide use of GMountSpec * client/gdaemonvfs.c: * client/smburi.c: Update to the new APIs * client/gvfsfusedaemon.c: * daemon/gvfsbackendtrash.c: * daemon/gvfsjobqueryfsinfo.c: Fix warnings svn path=/trunk/; revision=1020
-rw-r--r--ChangeLog32
-rw-r--r--client/Makefile.am15
-rw-r--r--client/gdaemonvfs.c54
-rw-r--r--client/gvfsfusedaemon.c1
-rw-r--r--client/gvfsurimapper.c195
-rw-r--r--client/gvfsurimapper.h (renamed from common/gvfsurimapper.h)59
-rw-r--r--client/gvfsuriutils.c (renamed from common/gvfsuriutils.c)14
-rw-r--r--client/gvfsuriutils.h (renamed from common/gvfsuriutils.h)10
-rw-r--r--client/smburi.c89
-rw-r--r--common/Makefile.am10
-rw-r--r--common/gmountspec.c29
-rw-r--r--common/gmountspec.h2
-rw-r--r--common/gvfsurimapper.c97
-rw-r--r--daemon/gvfsbackendtrash.c3
-rw-r--r--daemon/gvfsjobqueryfsinfo.c2
15 files changed, 405 insertions, 207 deletions
diff --git a/ChangeLog b/ChangeLog
index f591ddf3..9196d5a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2007-11-12 Alexander Larsson <alexl@redhat.com>
+
+ * common/gmountspec.[ch]:
+ (g_mount_spec_new_from_data):
+ (g_mount_spec_set_with_len):
+ Add new functions
+
+ * client/Makefile.am:
+ * common/Makefile.am:
+ Update for moved files
+ Build non-shared version of common libs.
+ Ups non-shared common libs in client module.
+
+ * common/gvfsuriutils.[ch]: Removed.
+ * client/gvfsuriutils.[ch]: Added.
+ Moved uriutils to gvfs (not used by daemon)
+ Re-namespace to g_vfs_*
+
+ * common/gvfsurimapper.[ch]: Removed.
+ * client/gvfsurimapper.[ch]: Added.
+ Move UriMapper to client lib
+ Remove/Hide use of GMountSpec
+
+ * client/gdaemonvfs.c:
+ * client/smburi.c:
+ Update to the new APIs
+
+ * client/gvfsfusedaemon.c:
+ * daemon/gvfsbackendtrash.c:
+ * daemon/gvfsjobqueryfsinfo.c:
+ Fix warnings
+
2007-11-08 Alexander Larsson <alexl@redhat.com>
* daemon/gvfsdaemon.c:
diff --git a/client/Makefile.am b/client/Makefile.am
index 9bfcdec9..67f9d4bf 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -8,11 +8,16 @@ INCLUDES = -I$(top_srcdir) \
-DGVFS_MODULE_DIR=\"$(libdir)/gvfs/modules\" \
-DDBUS_API_SUBJECT_TO_CHANGE
-module_flags = -export_dynamic -avoid-version -module -no-undefined
+module_flags = -export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_vfs_.*|g_io_module_load|g_io_module_unload'
giomodulesdir = $(libdir)/gio/modules
## Common to dynamic and static client libs
+gvfsclientincludedir=$(includedir)/gvfs-client/gvfs/
+gvfsclientinclude_HEADERS = \
+ gvfsuriutils.h gvfsurimapper.h \
+ $(NULL)
+
vfssources = \
gdaemonvfs.c gdaemonvfs.h \
gdaemonvolume.c gdaemonvolume.h \
@@ -23,11 +28,13 @@ vfssources = \
gdaemonfileenumerator.c gdaemonfileenumerator.h \
gdaemondirectorymonitor.c gdaemondirectorymonitor.h \
gdaemonfilemonitor.c gdaemonfilemonitor.h \
- gvfsdaemondbus.c gvfsdaemondbus.h\
+ gvfsdaemondbus.c gvfsdaemondbus.h \
+ gvfsuriutils.c gvfsuriutils.h \
+ gvfsurimapper.c gvfsurimapper.h \
$(NULL)
vfslibs = \
- $(top_builddir)/common/libgvfscommon.la \
+ $(top_builddir)/common/libgvfscommon-noin.la \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
$(NULL)
@@ -51,7 +58,7 @@ libsmb_la_SOURCES = \
$(NULL)
libsmb_la_LIBADD = \
- $(top_builddir)/common/libgvfscommon.la \
+ libgvfsdbus.la \
$(GLIB_LIBS) \
$(NULL)
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index 1aa08fe6..312134da 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -111,20 +111,34 @@ get_mountspec_from_uri (GDaemonVfs *vfs,
char *path;
GVfsUriMapper *mapper;
char *scheme;
-
+ GVfsUriMountInfo *info;
+
scheme = g_uri_get_scheme (uri);
if (scheme == NULL)
return FALSE;
spec = NULL;
+ path = NULL;
mapper = g_hash_table_lookup (vfs->from_uri_hash, scheme);
- if (mapper == NULL ||
- !g_vfs_uri_mapper_from_uri (mapper, uri, &spec, &path))
+
+ if (mapper)
+ {
+ info = g_vfs_uri_mapper_from_uri (mapper, uri);
+ if (info != NULL)
+ {
+ spec = g_mount_spec_new_from_data (info->keys, NULL);
+ path = info->path;
+ /* We took over ownership, custom free: */
+ g_free (info);
+ }
+ }
+
+ if (spec == NULL)
{
GDecodedUri *decoded;
- decoded = g_decode_uri (uri);
+ decoded = g_vfs_decode_uri (uri);
if (decoded)
{
spec = g_mount_spec_new (decoded->scheme);
@@ -144,7 +158,7 @@ get_mountspec_from_uri (GDaemonVfs *vfs,
path = g_strdup (decoded->path);
- g_decoded_uri_free (decoded);
+ g_vfs_decoded_uri_free (decoded);
}
}
@@ -280,7 +294,12 @@ _g_daemon_vfs_get_uri_for_mountspec (GMountSpec *spec,
uri = NULL;
mapper = g_hash_table_lookup (the_vfs->to_uri_hash, type);
if (mapper)
- uri = g_vfs_uri_mapper_to_uri (mapper, spec, path, allow_utf8);
+ {
+ GVfsUriMountInfo info;
+ info.keys = spec->items;
+ info.path = path;
+ uri = g_vfs_uri_mapper_to_uri (mapper, &info, allow_utf8);
+ }
if (uri == NULL)
{
@@ -302,7 +321,7 @@ _g_daemon_vfs_get_uri_for_mountspec (GMountSpec *spec,
else
decoded.path = path;
- uri = g_encode_uri (&decoded, FALSE);
+ uri = g_vfs_encode_uri (&decoded, FALSE);
}
return uri;
@@ -319,15 +338,21 @@ _g_daemon_vfs_mountspec_get_uri_scheme (GMountSpec *spec)
scheme = NULL;
if (mapper)
- scheme = g_vfs_uri_mapper_to_uri_scheme (mapper, spec);
+ {
+ GVfsUriMountInfo info;
+
+ info.keys = spec->items;
+ info.path = "/";
+
+ scheme = g_vfs_uri_mapper_to_uri_scheme (mapper, &info);
+ }
if (scheme == NULL)
scheme = type;
-
+
return scheme;
}
-
static void
fill_supported_uri_schemes (GDaemonVfs *vfs)
{
@@ -389,7 +414,14 @@ fill_supported_uri_schemes (GDaemonVfs *vfs)
mapper = g_hash_table_lookup (vfs->to_uri_hash, type);
if (mapper)
- scheme = g_vfs_uri_mapper_to_uri_scheme (mapper, spec);
+ {
+ GVfsUriMountInfo info;
+
+ info.keys = spec->items;
+ info.path = "/";
+
+ scheme = g_vfs_uri_mapper_to_uri_scheme (mapper, &info);
+ }
if (scheme == NULL)
scheme = type;
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index e05501a3..facb0ea2 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -2040,7 +2040,6 @@ vfs_init (struct fuse_conn_info *conn)
DBusConnection *dbus_conn;
DBusMessage *message;
DBusError error;
- GVfs *vfs;
daemon_creation_time = time (NULL);
daemon_uid = getuid ();
diff --git a/client/gvfsurimapper.c b/client/gvfsurimapper.c
new file mode 100644
index 00000000..2b320b7e
--- /dev/null
+++ b/client/gvfsurimapper.c
@@ -0,0 +1,195 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Alexander Larsson <alexl@redhat.com>
+ */
+
+#include <config.h>
+#include <string.h>
+#include <gmodule.h>
+#include "gvfsurimapper.h"
+
+G_DEFINE_TYPE (GVfsUriMapper, g_vfs_uri_mapper, G_TYPE_OBJECT);
+
+GVfsUriMountInfo *
+g_vfs_uri_mount_info_new (const char *type)
+{
+ GVfsUriMountInfo *info;
+
+ info = g_new0 (GVfsUriMountInfo, 1);
+ info->keys = g_array_new (TRUE, TRUE, sizeof (GVfsUriMountInfoKey));
+
+ if (type != NULL)
+ g_vfs_uri_mount_info_set (info, "type", type);
+
+ return info;
+}
+
+void
+g_vfs_uri_mount_info_free (GVfsUriMountInfo *info)
+{
+ int i;
+ GVfsUriMountInfoKey *key;
+
+ for (i = 0; i < info->keys->len; i++) {
+ key = &g_array_index (info->keys, GVfsUriMountInfoKey, i);
+
+ g_free (key->key);
+ g_free (key->value);
+ }
+ g_array_free (info->keys, TRUE);
+ g_free (info->path);
+ g_free (info);
+}
+
+static GVfsUriMountInfoKey *
+lookup_key (GVfsUriMountInfo *info,
+ const char *key)
+{
+ int i;
+ GVfsUriMountInfoKey *keyp;
+
+ for (i = 0; i < info->keys->len; i++) {
+ keyp = &g_array_index (info->keys, GVfsUriMountInfoKey, i);
+
+ if (strcmp (keyp->key, key) == 0)
+ return keyp;
+ }
+
+ return NULL;
+}
+
+const char *
+g_vfs_uri_mount_info_get (GVfsUriMountInfo *info,
+ const char *key)
+{
+ GVfsUriMountInfoKey *keyp;
+
+ keyp = lookup_key (info, key);
+
+ if (keyp)
+ return keyp->value;
+
+ return NULL;
+}
+
+void
+g_vfs_uri_mount_info_set_with_len (GVfsUriMountInfo *info,
+ const char *key,
+ const char *value,
+ int value_len)
+{
+ GVfsUriMountInfoKey *keyp;
+ GVfsUriMountInfoKey keyv;
+ char *value_copy;
+
+ if (value_len == -1)
+ value_copy = g_strdup (value);
+ else
+ value_copy = g_strndup (value, value_len);
+
+ keyp = lookup_key (info, key);
+ if (keyp)
+ {
+ g_free (keyp->value);
+ keyp->value = value_copy;
+ }
+ else
+ {
+ keyv.key = g_strdup (key);
+ keyv.value = value_copy;
+ g_array_append_val (info->keys, keyv);
+ }
+}
+
+void
+g_vfs_uri_mount_info_set (GVfsUriMountInfo *info,
+ const char *key,
+ const char *value)
+{
+ g_vfs_uri_mount_info_set_with_len (info, key, value, -1);
+}
+
+
+
+static void
+g_vfs_uri_mapper_class_init (GVfsUriMapperClass *klass)
+{
+}
+
+static void
+g_vfs_uri_mapper_init (GVfsUriMapper *vfs)
+{
+}
+
+const char * const *
+g_vfs_uri_mapper_get_handled_schemes (GVfsUriMapper *mapper)
+{
+ GVfsUriMapperClass *class;
+
+ class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
+
+ return (* class->get_handled_schemes) (mapper);
+}
+
+
+GVfsUriMountInfo *
+g_vfs_uri_mapper_from_uri (GVfsUriMapper *mapper,
+ const char *uri)
+{
+ GVfsUriMapperClass *class;
+
+ class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
+
+ return (* class->from_uri) (mapper, uri);
+}
+
+const char * const *
+g_vfs_uri_mapper_get_handled_mount_types (GVfsUriMapper *mapper)
+{
+ GVfsUriMapperClass *class;
+
+ class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
+
+ return (* class->get_handled_mount_types) (mapper);
+}
+
+char *
+g_vfs_uri_mapper_to_uri (GVfsUriMapper *mapper,
+ GVfsUriMountInfo *mount_info,
+ gboolean allow_utf8)
+{
+ GVfsUriMapperClass *class;
+
+ class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
+
+ return (* class->to_uri) (mapper, mount_info, allow_utf8);
+}
+
+const char *
+g_vfs_uri_mapper_to_uri_scheme (GVfsUriMapper *mapper,
+ GVfsUriMountInfo *mount_info)
+{
+ GVfsUriMapperClass *class;
+
+ class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
+
+ return (* class->to_uri_scheme) (mapper, mount_info);
+}
+
diff --git a/common/gvfsurimapper.h b/client/gvfsurimapper.h
index cf8e0d6c..139630e5 100644
--- a/common/gvfsurimapper.h
+++ b/client/gvfsurimapper.h
@@ -24,8 +24,6 @@
#define __G_VFS_URI_MAPPER_H__
#include <glib-object.h>
-#include <gvfsuriutils.h>
-#include <gmountspec.h>
G_BEGIN_DECLS
@@ -43,6 +41,16 @@ struct _GVfsUriMapper {
GObject parent;
};
+typedef struct {
+ char *key;
+ char *value;
+} GVfsUriMountInfoKey;
+
+typedef struct {
+ GArray *keys;
+ char *path;
+} GVfsUriMountInfo;
+
struct _GVfsUriMapperClass
{
GObjectClass parent_class;
@@ -50,35 +58,42 @@ struct _GVfsUriMapperClass
/* Virtual Table */
const char * const * (*get_handled_schemes) (GVfsUriMapper *mapper);
- gboolean (*from_uri) (GVfsUriMapper *mapper,
- const char *uri,
- GMountSpec **spec_out,
- char **path_out);
+ GVfsUriMountInfo * (*from_uri) (GVfsUriMapper *mapper,
+ const char *uri);
const char * const * (*get_handled_mount_types) (GVfsUriMapper *mapper);
char * (*to_uri) (GVfsUriMapper *mapper,
- GMountSpec *spec,
- char *path,
+ GVfsUriMountInfo *mount_info,
gboolean allow_utf8);
const char * (*to_uri_scheme) (GVfsUriMapper *mapper,
- GMountSpec *spec);
+ GVfsUriMountInfo *mount_info);
};
GType g_vfs_uri_mapper_get_type (void) G_GNUC_CONST;
-const char * const * g_vfs_uri_mapper_get_handled_schemes (GVfsUriMapper *mapper);
-gboolean g_vfs_uri_mapper_from_uri (GVfsUriMapper *mapper,
- const char *uri,
- GMountSpec **spec_out,
- char **path_out);
-
-const char * const * g_vfs_uri_mapper_get_handled_mount_types (GVfsUriMapper *mapper);
-char * g_vfs_uri_mapper_to_uri (GVfsUriMapper *mapper,
- GMountSpec *spec,
- char *path,
- gboolean allow_utf8);
-const char * g_vfs_uri_mapper_to_uri_scheme (GVfsUriMapper *mapper,
- GMountSpec *spec);
+GVfsUriMountInfo *g_vfs_uri_mount_info_new (const char *type);
+void g_vfs_uri_mount_info_free (GVfsUriMountInfo *info);
+const char * g_vfs_uri_mount_info_get (GVfsUriMountInfo *info,
+ const char *key);
+void g_vfs_uri_mount_info_set (GVfsUriMountInfo *info,
+ const char *key,
+ const char *value);
+void g_vfs_uri_mount_info_set_with_len (GVfsUriMountInfo *info,
+ const char *key,
+ const char *value,
+ int value_len);
+
+const char * const *g_vfs_uri_mapper_get_handled_schemes (GVfsUriMapper *mapper);
+GVfsUriMountInfo * g_vfs_uri_mapper_from_uri (GVfsUriMapper *mapper,
+ const char *uri);
+
+const char * const *g_vfs_uri_mapper_get_handled_mount_types (GVfsUriMapper *mapper);
+char * g_vfs_uri_mapper_to_uri (GVfsUriMapper *mapper,
+ GVfsUriMountInfo *mount_info,
+ gboolean allow_utf8);
+const char * g_vfs_uri_mapper_to_uri_scheme (GVfsUriMapper *mapper,
+ GVfsUriMountInfo *mount_infoxo);
+
G_END_DECLS
diff --git a/common/gvfsuriutils.c b/client/gvfsuriutils.c
index 0070392a..78aa850e 100644
--- a/common/gvfsuriutils.c
+++ b/client/gvfsuriutils.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
void
-g_decoded_uri_free (GDecodedUri *decoded)
+g_vfs_decoded_uri_free (GDecodedUri *decoded)
{
if (decoded == NULL)
return;
@@ -41,7 +41,7 @@ g_decoded_uri_free (GDecodedUri *decoded)
}
GDecodedUri *
-g_decoded_uri_new (void)
+g_vfs_decoded_uri_new (void)
{
GDecodedUri *uri;
@@ -52,7 +52,7 @@ g_decoded_uri_new (void)
}
GDecodedUri *
-g_decode_uri (const char *uri)
+g_vfs_decode_uri (const char *uri)
{
GDecodedUri *decoded;
const char *p, *in, *hier_part_start, *hier_part_end, *query_start, *fragment_start;
@@ -86,7 +86,7 @@ g_decode_uri (const char *uri)
return NULL;
}
- decoded = g_decoded_uri_new ();
+ decoded = g_vfs_decoded_uri_new ();
decoded->scheme = g_malloc (p - uri);
out = decoded->scheme;
@@ -162,7 +162,7 @@ g_decode_uri (const char *uri)
decoded->userinfo = g_uri_unescape_segment (userinfo_start, userinfo_end, NULL);
if (decoded->userinfo == NULL)
{
- g_decoded_uri_free (decoded);
+ g_vfs_decoded_uri_free (decoded);
return NULL;
}
host_start = userinfo_end + 1;
@@ -192,7 +192,7 @@ g_decode_uri (const char *uri)
if (decoded->path == NULL)
{
- g_decoded_uri_free (decoded);
+ g_vfs_decoded_uri_free (decoded);
return NULL;
}
@@ -200,7 +200,7 @@ g_decode_uri (const char *uri)
}
char *
-g_encode_uri (GDecodedUri *decoded, gboolean allow_utf8)
+g_vfs_encode_uri (GDecodedUri *decoded, gboolean allow_utf8)
{
GString *uri;
diff --git a/common/gvfsuriutils.h b/client/gvfsuriutils.h
index ab91d8f8..1f2c93b2 100644
--- a/common/gvfsuriutils.h
+++ b/client/gvfsuriutils.h
@@ -38,11 +38,11 @@ typedef struct {
char *fragment;
} GDecodedUri;
-char * g_encode_uri (GDecodedUri *decoded,
- gboolean allow_utf8);
-void g_decoded_uri_free (GDecodedUri *decoded);
-GDecodedUri *g_decode_uri (const char *uri);
-GDecodedUri *g_decoded_uri_new (void);
+char * g_vfs_encode_uri (GDecodedUri *decoded,
+ gboolean allow_utf8);
+void g_vfs_decoded_uri_free (GDecodedUri *decoded);
+GDecodedUri *g_vfs_decode_uri (const char *uri);
+GDecodedUri *g_vfs_decoded_uri_new (void);
G_END_DECLS
diff --git a/client/smburi.c b/client/smburi.c
index 82087726..7ba62297 100644
--- a/client/smburi.c
+++ b/client/smburi.c
@@ -25,6 +25,7 @@
#include <gio/giomodule.h>
#include <gvfsurimapper.h>
+#include <gvfsuriutils.h>
typedef struct _GVfsUriMapperSmb GVfsUriMapperSmb;
typedef struct _GVfsUriMapperSmbClass GVfsUriMapperSmbClass;
@@ -112,30 +113,28 @@ smb_get_handled_schemes (GVfsUriMapper *mapper)
return schemes;
}
-static gboolean
+static GVfsUriMountInfo *
smb_from_uri (GVfsUriMapper *mapper,
- const char *uri_str,
- GMountSpec **spec_out,
- char **path_out)
+ const char *uri_str)
{
- GMountSpec *spec;
- char *path, *tmp;
+ char *tmp;
const char *p;
const char *share, *share_end;
GDecodedUri *uri;
+ GVfsUriMountInfo *info;
- uri = g_decode_uri (uri_str);
+ uri = g_vfs_decode_uri (uri_str);
if (uri == NULL)
return FALSE;
-
+
if (uri->host == NULL || strlen (uri->host) == 0)
{
/* uri form: smb:/// or smb:///$path */
- spec = g_mount_spec_new ("smb-network");
+ info = g_vfs_uri_mount_info_new ("smb-network");
if (uri->path == NULL || *uri->path == 0)
- path = g_strdup ("/");
+ info->path = g_strdup ("/");
else
- path = g_strdup (uri->path);
+ info->path = g_strdup (uri->path);
}
else
{
@@ -147,11 +146,11 @@ smb_from_uri (GVfsUriMapper *mapper,
if (p == NULL || *p == 0)
{
/* uri form: smb://$host/ */
- spec = g_mount_spec_new ("smb-server");
+ info = g_vfs_uri_mount_info_new ("smb-server");
tmp = normalize_smb_name (uri->host, -1);
- g_mount_spec_set (spec, "server", tmp);
+ g_vfs_uri_mount_info_set (info, "server", tmp);
g_free (tmp);
- path = g_strdup ("/");
+ info->path = g_strdup ("/");
}
else
{
@@ -171,39 +170,39 @@ smb_from_uri (GVfsUriMapper *mapper,
* Here we special case smb-server files by adding "._" to the names in the uri */
if (share[0] == '.' && share[1] == '_')
{
- spec = g_mount_spec_new ("smb-server");
+ info = g_vfs_uri_mount_info_new ("smb-server");
tmp = normalize_smb_name (uri->host, -1);
- g_mount_spec_set (spec, "server", tmp);
+ g_vfs_uri_mount_info_set (info, "server", tmp);
g_free (tmp);
tmp = normalize_smb_name (share + 2, share_end - (share + 2));
- path = g_strconcat ("/", tmp, NULL);
+ info->path = g_strconcat ("/", tmp, NULL);
g_free (tmp);
}
else
{
- spec = g_mount_spec_new ("smb-share");
+ info = g_vfs_uri_mount_info_new ("smb-share");
tmp = normalize_smb_name (uri->host, -1);
- g_mount_spec_set (spec, "server", tmp);
+ g_vfs_uri_mount_info_set (info, "server", tmp);
g_free (tmp);
tmp = normalize_smb_name (share, share_end - share);
- g_mount_spec_set (spec, "share", tmp);
+ g_vfs_uri_mount_info_set (info, "share", tmp);
g_free (tmp);
- path = g_strdup ("/");
+ info->path = g_strdup ("/");
}
}
else
{
- spec = g_mount_spec_new ("smb-share");
+ info = g_vfs_uri_mount_info_new ("smb-share");
tmp = normalize_smb_name (uri->host, -1);
- g_mount_spec_set (spec, "server", tmp);
+ g_vfs_uri_mount_info_set (info, "server", tmp);
g_free (tmp);
tmp = normalize_smb_name (share, share_end - share);
- g_mount_spec_set (spec, "share", tmp);
+ g_vfs_uri_mount_info_set (info, "share", tmp);
g_free (tmp);
- path = g_strconcat ("/", p, NULL);
+ info->path = g_strconcat ("/", p, NULL);
}
}
}
@@ -215,17 +214,14 @@ smb_from_uri (GVfsUriMapper *mapper,
if (p)
{
if (p != user)
- g_mount_spec_set_with_len (spec, "domain", user, p - user);
+ g_vfs_uri_mount_info_set_with_len (info, "domain", user, p - user);
user = p + 1;
}
if (*user != 0)
- g_mount_spec_set (spec, "user", user);
+ g_vfs_uri_mount_info_set (info, "user", user);
}
- *spec_out = spec;
- *path_out = path;
-
- return spec != NULL;
+ return info;
}
static const char * const *
@@ -242,8 +238,7 @@ smb_get_handled_mount_types (GVfsUriMapper *mapper)
static char *
smb_to_uri (GVfsUriMapper *mapper,
- GMountSpec *spec,
- char *path,
+ GVfsUriMountInfo *info,
gboolean allow_utf8)
{
const char *type;
@@ -254,47 +249,47 @@ smb_to_uri (GVfsUriMapper *mapper,
uri = g_new0 (GDecodedUri, 1);
- type = g_mount_spec_get_type (spec);
+ type = g_vfs_uri_mount_info_get (info, "type");
uri->scheme = g_strdup ("smb");
uri->port = -1;
if (strcmp (type, "smb-network") == 0)
{
- uri->path = g_strdup (path);
+ uri->path = g_strdup (info->path);
}
else if (strcmp (type, "smb-server") == 0)
{
- server = g_mount_spec_get (spec, "server");
+ server = g_vfs_uri_mount_info_get (info, "server");
uri->host = g_strdup (server);
/* Map the mountables in server to ._share because the actual share mount maps to smb://server/share */
- if (path && path[0] == '/' && path[1] != 0)
- uri->path = g_strconcat ("/._", path + 1, NULL);
+ if (info->path && info->path[0] == '/' && info->path[1] != 0)
+ uri->path = g_strconcat ("/._", info->path + 1, NULL);
else
uri->path = g_strdup ("/");
}
else if (strcmp (type, "smb-share") == 0)
{
- server = g_mount_spec_get (spec, "server");
+ server = g_vfs_uri_mount_info_get (info, "server");
uri->host = g_strdup (server);
- share = g_mount_spec_get (spec, "share");
- if (path[0] == '/')
- uri->path = g_strconcat ("/", share, path, NULL);
+ share = g_vfs_uri_mount_info_get (info, "share");
+ if (info->path[0] == '/')
+ uri->path = g_strconcat ("/", share, info->path, NULL);
else
- uri->path = g_strconcat ("/", share, "/", path, NULL);
+ uri->path = g_strconcat ("/", share, "/", info->path, NULL);
}
- s = g_encode_uri (uri, allow_utf8);
- g_decoded_uri_free (uri);
+ s = g_vfs_encode_uri (uri, allow_utf8);
+ g_vfs_decoded_uri_free (uri);
return s;
}
static const char *
smb_to_uri_scheme (GVfsUriMapper *mapper,
- GMountSpec *spec)
+ GVfsUriMountInfo *info)
{
- const gchar *type = g_mount_spec_get_type (spec);
+ const gchar *type = g_vfs_uri_mount_info_get (info, "type");
if (strcmp ("smb-network", type) == 0 ||
strcmp ("smb-server", type) == 0 ||
diff --git a/common/Makefile.am b/common/Makefile.am
index c669c852..5c59496b 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -1,5 +1,6 @@
NULL =
+noinst_LTLIBRARIES = libgvfscommon-noin.la
lib_LTLIBRARIES=libgvfscommon.la
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gvfs \
@@ -8,7 +9,7 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gvfs \
-DG_LOG_DOMAIN=\"GVFS\" -DG_DISABLE_DEPRECATED \
-DDBUS_API_SUBJECT_TO_CHANGE
-libgvfscommon_la_SOURCES = \
+libgvfscommon_noin_la_SOURCES = \
gsysutils.c gsysutils.h \
gdbusutils.c gdbusutils.h \
gmountspec.c gmountspec.h \
@@ -16,10 +17,11 @@ libgvfscommon_la_SOURCES = \
gmountsource.c gmountsource.h \
gmounttracker.c gmounttracker.h \
gvfsdaemonprotocol.c gvfsdaemonprotocol.h \
- gvfsuriutils.c gvfsuriutils.h \
- gvfsurimapper.c gvfsurimapper.h \
$(NULL)
-libgvfscommon_la_LIBADD = \
+libgvfscommon_noin_la_LIBADD = \
$(DBUS_LIBS) \
$(GLIB_LIBS)
+
+libgvfscommon_la_SOURCES =
+libgvfscommon_la_LIBADD = libgvfscommon-noin.la
diff --git a/common/gmountspec.c b/common/gmountspec.c
index 51adc005..179e2a5a 100644
--- a/common/gmountspec.c
+++ b/common/gmountspec.c
@@ -59,6 +59,22 @@ g_mount_spec_new (const char *type)
}
GMountSpec *
+g_mount_spec_new_from_data (GArray *items,
+ char *mount_prefix)
+{
+ GMountSpec *spec;
+
+ spec = g_new0 (GMountSpec, 1);
+ spec->ref_count = 1;
+ spec->items = items;
+ spec->mount_prefix = mount_prefix;
+
+ g_array_sort (spec->items, item_compare);
+
+ return spec;
+}
+
+GMountSpec *
g_mount_spec_get_unique_for (GMountSpec *spec)
{
GMountSpec *unique_spec;
@@ -118,22 +134,23 @@ g_mount_spec_set_with_len (GMountSpec *spec,
{
int i;
char *value_copy;
-
+
+ if (value_len == -1)
+ value_copy = g_strdup (value);
+ else
+ value_copy = g_strndup (value, value_len);
+
for (i = 0; i < spec->items->len; i++)
{
GMountSpecItem *item = &g_array_index (spec->items, GMountSpecItem, i);
if (strcmp (item->key, key) == 0)
{
g_free (item->value);
- item->value = g_strdup (value);
+ item->value = value_copy;
return;
}
}
- if (value_len == -1)
- value_copy = g_strdup (value);
- else
- value_copy = g_strndup (value, value_len);
add_item (spec, key, value_copy);
g_array_sort (spec->items, item_compare);
}
diff --git a/common/gmountspec.h b/common/gmountspec.h
index 68c06d58..1b8fef0a 100644
--- a/common/gmountspec.h
+++ b/common/gmountspec.h
@@ -59,6 +59,8 @@ typedef struct {
} GMountSpec;
GMountSpec *g_mount_spec_new (const char *type);
+GMountSpec *g_mount_spec_new_from_data (GArray *items,
+ char *mount_prefix);
GMountSpec *g_mount_spec_ref (GMountSpec *spec);
void g_mount_spec_unref (GMountSpec *spec);
GMountSpec *g_mount_spec_get_unique_for (GMountSpec *spec);
diff --git a/common/gvfsurimapper.c b/common/gvfsurimapper.c
deleted file mode 100644
index e4df7f9e..00000000
--- a/common/gvfsurimapper.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* GIO - GLib Input, Output and Streaming Library
- *
- * Copyright (C) 2006-2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Alexander Larsson <alexl@redhat.com>
- */
-
-#include <config.h>
-#include <string.h>
-#include <gmodule.h>
-#include "gvfsurimapper.h"
-
-G_DEFINE_TYPE (GVfsUriMapper, g_vfs_uri_mapper, G_TYPE_OBJECT);
-
-static void
-g_vfs_uri_mapper_class_init (GVfsUriMapperClass *klass)
-{
-}
-
-static void
-g_vfs_uri_mapper_init (GVfsUriMapper *vfs)
-{
-}
-
-const char * const *
-g_vfs_uri_mapper_get_handled_schemes (GVfsUriMapper *mapper)
-{
- GVfsUriMapperClass *class;
-
- class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
-
- return (* class->get_handled_schemes) (mapper);
-}
-
-
-gboolean
-g_vfs_uri_mapper_from_uri (GVfsUriMapper *mapper,
- const char *uri,
- GMountSpec **spec_out,
- char **path_out)
-{
- GVfsUriMapperClass *class;
-
- class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
-
- return (* class->from_uri) (mapper, uri, spec_out, path_out);
-}
-
-const char * const *
-g_vfs_uri_mapper_get_handled_mount_types (GVfsUriMapper *mapper)
-{
- GVfsUriMapperClass *class;
-
- class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
-
- return (* class->get_handled_mount_types) (mapper);
-}
-
-char *
-g_vfs_uri_mapper_to_uri (GVfsUriMapper *mapper,
- GMountSpec *spec,
- char *path,
- gboolean allow_utf8)
-{
- GVfsUriMapperClass *class;
-
- class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
-
- return (* class->to_uri) (mapper, spec, path, allow_utf8);
-}
-
-const char *
-g_vfs_uri_mapper_to_uri_scheme (GVfsUriMapper *mapper,
- GMountSpec *spec)
-{
- GVfsUriMapperClass *class;
-
- class = G_VFS_URI_MAPPER_GET_CLASS (mapper);
-
- return (* class->to_uri_scheme) (mapper, spec);
-}
-
diff --git a/daemon/gvfsbackendtrash.c b/daemon/gvfsbackendtrash.c
index 05630e8b..914a136c 100644
--- a/daemon/gvfsbackendtrash.c
+++ b/daemon/gvfsbackendtrash.c
@@ -38,8 +38,7 @@
#include <gio/gfile.h>
#include <gio/gthemedicon.h>
#include <gio/gunixmounts.h>
-
-#include "gvfsuriutils.h"
+#include <gio/gurifuncs.h>
#include "gvfsbackendtrash.h"
#include "gvfsmonitor.h"
diff --git a/daemon/gvfsjobqueryfsinfo.c b/daemon/gvfsjobqueryfsinfo.c
index 8399e041..6090d070 100644
--- a/daemon/gvfsjobqueryfsinfo.c
+++ b/daemon/gvfsjobqueryfsinfo.c
@@ -164,7 +164,7 @@ create_reply (GVfsJob *job,
GVfsJobQueryFsInfo *op_job = G_VFS_JOB_QUERY_FS_INFO (job);
DBusMessage *reply;
DBusMessageIter iter;
- const char *type, *name;
+ const char *type;
reply = dbus_message_new_method_return (message);