summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackendftp.h
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-06-02 13:19:51 +0200
committerBenjamin Otte <otte@gnome.org>2009-06-11 10:05:40 +0200
commite62142b001e218d268a85f2f90993cdf42148fae (patch)
tree4948320f6778cb04118a1c6541291eac338fed73 /daemon/gvfsbackendftp.h
parent2f5c4dcfd579f9b9cceb8eb08b71d4318e9c03b6 (diff)
downloadgvfs-e62142b001e218d268a85f2f90993cdf42148fae.tar.gz
[FTP] introduce GVfsFtpTask
split out the old FtpConnection struct into a separate GVfsFtpTask structure that acts as a one-stop solution to vfuncs. It keeps track of all important structures: - the backend - the current job - the potential connection to the server - the error state during the lifetime of a backend vfunc and supplies convenience functions to ease implementing these vfuncs. The API of gvfsftptask.h is documented.
Diffstat (limited to 'daemon/gvfsbackendftp.h')
-rw-r--r--daemon/gvfsbackendftp.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/daemon/gvfsbackendftp.h b/daemon/gvfsbackendftp.h
index 23538342..e1df8b0b 100644
--- a/daemon/gvfsbackendftp.h
+++ b/daemon/gvfsbackendftp.h
@@ -28,6 +28,38 @@
G_BEGIN_DECLS
+#define G_VFS_FTP_TIMEOUT_IN_SECONDS 30
+
+typedef enum {
+ G_VFS_FTP_FEATURE_MDTM,
+ G_VFS_FTP_FEATURE_SIZE,
+ G_VFS_FTP_FEATURE_TVFS,
+ G_VFS_FTP_FEATURE_EPSV,
+ G_VFS_FTP_FEATURE_UTF8
+} GVfsFtpFeature;
+#define G_VFS_FTP_FEATURES_DEFAULT (1 << G_VFS_FTP_FEATURE_EPSV)
+
+typedef enum {
+ G_VFS_FTP_SYSTEM_UNKNOWN = 0,
+ G_VFS_FTP_SYSTEM_UNIX,
+ G_VFS_FTP_SYSTEM_WINDOWS
+} GVfsFtpSystem;
+
+typedef enum {
+ /* Server advertises support for EPSV (or we assume that it supports it),
+ * but it does fail to do so, we set this flag so we can fall back to
+ * PASV. */
+ G_VFS_FTP_WORKAROUND_BROKEN_EPSV,
+ /* Server replies with a wrong address in PASV, we use connection IP
+ * instead */
+ G_VFS_FTP_WORKAROUND_PASV_ADDR,
+ /* server does not allow querying features before login, so we try after
+ * logging in instead. */
+ G_VFS_FTP_WORKAROUND_FEAT_AFTER_LOGIN,
+} GVfsFtpWorkaround;
+
+typedef struct FtpDirReader FtpDirReader;
+
#define G_VFS_TYPE_BACKEND_FTP (g_vfs_backend_ftp_get_type ())
#define G_VFS_BACKEND_FTP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_VFS_TYPE_BACKEND_FTP, GVfsBackendFtp))
#define G_VFS_BACKEND_FTP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_VFS_TYPE_BACKEND_FTP, GVfsBackendFtpClass))
@@ -38,6 +70,36 @@ G_BEGIN_DECLS
typedef struct _GVfsBackendFtp GVfsBackendFtp;
typedef struct _GVfsBackendFtpClass GVfsBackendFtpClass;
+struct _GVfsBackendFtp
+{
+ GVfsBackend backend;
+
+ GSocketConnectable * addr;
+ GSocketClient * connection_factory;
+ char * user;
+ gboolean has_initial_user;
+ char * password; /* password or NULL for anonymous */
+ char * host_display_name;
+
+ GVfsFtpSystem system; /* the system from the SYST response */
+ int features; /* GVfsFtpFeatures that are supported */
+ int workarounds; /* GVfsFtpWorkarounds in use - int because it's atomic */
+
+ /* vfuncs */
+ const FtpDirReader * dir_ops;
+
+ /* connection collection - accessed from gvfsftptask.c */
+ GMutex * mutex; /* mutex protecting the following variables */
+ GCond * cond; /* cond used to signal tasks waiting on the mutex */
+ GQueue * queue; /* queue containing the connections */
+ guint connections; /* current number of connections */
+ guint max_connections; /* upper server limit for number of connections - dynamically generated */
+
+ /* caching results from dir queries */
+ GStaticRWLock directory_cache_lock;
+ GHashTable * directory_cache;
+};
+
struct _GVfsBackendFtpClass
{
GVfsBackendClass parent_class;
@@ -45,6 +107,14 @@ struct _GVfsBackendFtpClass
GType g_vfs_backend_ftp_get_type (void) G_GNUC_CONST;
+gboolean g_vfs_backend_ftp_has_feature (GVfsBackendFtp * ftp,
+ GVfsFtpFeature feature);
+gboolean g_vfs_backend_ftp_uses_workaround (GVfsBackendFtp * ftp,
+ GVfsFtpWorkaround workaround);
+void g_vfs_backend_ftp_use_workaround (GVfsBackendFtp * ftp,
+ GVfsFtpWorkaround workaround);
+
+
G_END_DECLS
#endif /* __G_VFS_BACKEND_FTP_H__ */