]> git.0d.be Git - empathy.git/blob - libempathy/empathy-tp-file.h
Use tp_proxy_prepare_async instead of tp_account_manager_prepare_async
[empathy.git] / libempathy / empathy-tp-file.h
1 /*
2  * Copyright (C) 2007-2009 Collabora Ltd.
3  * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * Authors: Marco Barisione <marco@barisione.org>
20  *          Jonny Lamb <jonny.lamb@collabora.co.uk>
21  *          Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
22  */
23
24 #ifndef __EMPATHY_TP_FILE_H__
25 #define __EMPATHY_TP_FILE_H__
26
27 #include <gio/gio.h>
28 #include <glib.h>
29
30 #include <telepathy-glib/channel.h>
31
32 G_BEGIN_DECLS
33
34 #define EMPATHY_TYPE_TP_FILE (empathy_tp_file_get_type ())
35 #define EMPATHY_TP_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
36     EMPATHY_TYPE_TP_FILE, EmpathyTpFile))
37 #define EMPATHY_TP_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
38     EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
39 #define EMPATHY_IS_TP_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
40     EMPATHY_TYPE_TP_FILE))
41 #define EMPATHY_IS_TP_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
42     EMPATHY_TYPE_TP_FILE))
43 #define EMPATHY_TP_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
44     EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
45
46 #define EMPATHY_FT_ERROR_QUARK g_quark_from_static_string ("EmpathyFTError")
47
48 typedef enum {
49         EMPATHY_FT_ERROR_FAILED,
50         EMPATHY_FT_ERROR_HASH_MISMATCH,
51         EMPATHY_FT_ERROR_TP_ERROR,
52         EMPATHY_FT_ERROR_SOCKET,
53         EMPATHY_FT_ERROR_NOT_SUPPORTED,
54         EMPATHY_FT_ERROR_INVALID_SOURCE_FILE,
55         EMPATHY_FT_ERROR_EMPTY_SOURCE_FILE
56 } EmpathyFTErrorEnum;
57
58 typedef struct _EmpathyTpFile EmpathyTpFile;
59 typedef struct _EmpathyTpFilePrivate EmpathyTpFilePrivate;
60 typedef struct _EmpathyTpFileClass EmpathyTpFileClass;
61
62 struct _EmpathyTpFile {
63   GObject  parent;
64   EmpathyTpFilePrivate *priv;
65 };
66
67 struct _EmpathyTpFileClass {
68   GObjectClass parent_class;
69 };
70
71 /* prototypes for operation callbacks */
72
73 /**
74  * EmpathyTpFileProgressCallback:
75  * @tp_file: the #EmpathyTpFile being transferred
76  * @current_bytes: the bytes currently transferred by the operation
77  * @user_data: user data passed to the callback
78  **/
79 typedef void (* EmpathyTpFileProgressCallback)
80     (EmpathyTpFile *tp_file,
81      guint64 current_bytes,
82      gpointer user_data);
83
84 /**
85  * EmpathyTpFileOperationCallback:
86  * @tp_file: the #EmpathyTpFile that has been transferred
87  * @error: a #GError if the operation didn't succeed, %NULL otherwise
88  * @user_data: user data passed to the callback
89  **/
90 typedef void (* EmpathyTpFileOperationCallback)
91     (EmpathyTpFile *tp_file,
92      const GError *error,
93      gpointer user_data);
94
95 GType empathy_tp_file_get_type (void) G_GNUC_CONST;
96
97 /* public methods */
98
99 EmpathyTpFile * empathy_tp_file_new (TpChannel *channel);
100
101 void empathy_tp_file_accept (EmpathyTpFile *tp_file,
102     guint64 offset,
103     GFile *gfile,
104     GCancellable *cancellable,
105     EmpathyTpFileProgressCallback progress_callback,
106     gpointer progress_user_data,
107     EmpathyTpFileOperationCallback op_callback,
108     gpointer op_user_data);
109
110 void empathy_tp_file_offer (EmpathyTpFile *tp_file,
111     GFile *gfile,
112     GCancellable *cancellable,
113     EmpathyTpFileProgressCallback progress_callback,
114     gpointer progress_user_data,
115     EmpathyTpFileOperationCallback op_callback,
116     gpointer op_user_data);
117
118 void empathy_tp_file_cancel (EmpathyTpFile *tp_file);
119 void empathy_tp_file_close (EmpathyTpFile *tp_file);
120
121 gboolean empathy_tp_file_is_incoming (EmpathyTpFile *tp_file);
122
123 G_END_DECLS
124
125 #endif /* __EMPATHY_TP_FILE_H__ */