summaryrefslogtreecommitdiff
path: root/daemon/gvfsftptask.h
blob: 744169b31b6ca757c05179458692a954cf31cb83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* GIO - GLib Input, Output and Streaming Library
 *
 * Copyright (C) 2009 Benjamin Otte <otte@gnome.org>
 *
 * 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., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 * Author: Benjamin Otte <otte@gnome.org>
 */

#ifndef __G_VFS_FTP_TASK_H__
#define __G_VFS_FTP_TASK_H__

#include "gvfsbackendftp.h"
#include "gvfsftpconnection.h"

G_BEGIN_DECLS

typedef enum {
  G_VFS_FTP_PASS_100 = (1 << 0),
  G_VFS_FTP_PASS_300 = (1 << 1),
  G_VFS_FTP_PASS_500 = (1 << 2),
  G_VFS_FTP_PASS_550 = (1 << 3),
  G_VFS_FTP_FAIL_200 = (1 << 4)
} GVfsFtpResponseFlags;

#define G_VFS_FTP_RESPONSE_GROUP(response) ((response) / 100)

typedef struct _GVfsFtpTask GVfsFtpTask;
struct _GVfsFtpTask
{
  GVfsBackendFtp *      backend;        /* backend this task is running on */
  GVfsJob *             job;            /* job that is processed or NULL if not bound to a task */
  GCancellable *        cancellable;    /* cancellable in use */

  GError *              error;          /* NULL or current error - will be propagated to task */
  GVfsFtpConnection *   conn;           /* connection in use by this task or NULL if none */
  GVfsFtpMethod         method;         /* method currently in use (only valid after call to _setup_data_connection() */
};

typedef void (* GVfsFtpErrorFunc) (GVfsFtpTask *task, gpointer data);

#define G_VFS_FTP_TASK_INIT(backend,job) { (backend), (job), (job)->cancellable, }
void                    g_vfs_ftp_task_done                     (GVfsFtpTask *          task);

#define g_vfs_ftp_task_is_in_error(task) ((task)->error != NULL)
#define g_vfs_ftp_task_error_matches(task, domain, code) (g_error_matches ((task)->error, (domain), (code)))
#define g_vfs_ftp_task_clear_error(task) (g_clear_error (&(task)->error))
void                    g_vfs_ftp_task_set_error_from_response  (GVfsFtpTask *          task,
                                                                 guint                  response);

void                    g_vfs_ftp_task_give_connection          (GVfsFtpTask *          task,
                                                                 GVfsFtpConnection *    conn);
GVfsFtpConnection *     g_vfs_ftp_task_take_connection          (GVfsFtpTask *          task);

guint                   g_vfs_ftp_task_send                     (GVfsFtpTask *          task,
                                                                 GVfsFtpResponseFlags   flags,
                                                                 const char *           format,
                                                                 ...) G_GNUC_PRINTF (3, 4);
guint                   g_vfs_ftp_task_send_and_check           (GVfsFtpTask *          task,
                                                                 GVfsFtpResponseFlags   flags,
                                                                 const GVfsFtpErrorFunc *funcs,
                                                                 gpointer               data,
                                                                 char ***               reply,
                                                                 const char *           format,
                                                                 ...) G_GNUC_PRINTF (6, 7);
guint                   g_vfs_ftp_task_sendv                    (GVfsFtpTask *          task,
                                                                 GVfsFtpResponseFlags   flags,
                                                                 char ***               reply,
                                                                 const char *           format,
        	                                                 va_list                varargs);
guint                   g_vfs_ftp_task_receive                  (GVfsFtpTask *          task,
                                                                 GVfsFtpResponseFlags   flags,
                                                                 char ***               reply);
void                    g_vfs_ftp_task_setup_data_connection    (GVfsFtpTask *          task);
void                    g_vfs_ftp_task_open_data_connection     (GVfsFtpTask *          task);
void                    g_vfs_ftp_task_close_data_connection    (GVfsFtpTask *          task);

gboolean                g_vfs_ftp_task_login                    (GVfsFtpTask *          task,
                                                                 const char *           username,
                                                                 const char *           password);
void                    g_vfs_ftp_task_setup_connection         (GVfsFtpTask *          task);

gboolean                g_vfs_ftp_task_initial_handshake        (GVfsFtpTask *          task,
                                                                 CertificateCallback    cb,
                                                                 gpointer               user_data);


G_END_DECLS

#endif /* __G_VFS_FTP_TASK_H__ */