]> git.0d.be Git - empathy.git/blob - libempathy/empathy-tp-file.h
04da254c12243b7d01df01d3005d5ce37750040a
[empathy.git] / libempathy / empathy-tp-file.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2007-2009 Collabora Ltd.
4  * Copyright (C) 2007 Marco Barisione <marco@barisione.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * Authors: Marco Barisione <marco@barisione.org>
21  *          Jonny Lamb <jonny.lamb@collabora.co.uk>
22  *          Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
23  */
24
25 #ifndef __EMPATHY_TP_FILE_H__
26 #define __EMPATHY_TP_FILE_H__
27
28 #include <gio/gio.h>
29 #include <glib.h>
30
31 #include <telepathy-glib/channel.h>
32
33 G_BEGIN_DECLS
34
35 #define EMPATHY_TP_FILE_UNKNOWN_SIZE G_MAXUINT64
36
37 #define EMPATHY_TYPE_TP_FILE         (empathy_tp_file_get_type ())
38 #define EMPATHY_TP_FILE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_TP_FILE, EmpathyTpFile))
39 #define EMPATHY_TP_FILE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
40 #define EMPATHY_IS_TP_FILE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_TP_FILE))
41 #define EMPATHY_IS_TP_FILE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_TP_FILE))
42 #define EMPATHY_TP_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_TP_FILE, EmpathyTpFileClass))
43
44 typedef struct _EmpathyTpFile EmpathyTpFile;
45 typedef struct _EmpathyTpFileClass EmpathyTpFileClass;
46
47 struct _EmpathyTpFile {
48   GObject  parent;
49   gpointer priv;
50 };
51
52 struct _EmpathyTpFileClass {
53   GObjectClass parent_class;
54 };
55
56 /* prototypes for operation callbacks */
57
58 typedef void (* EmpathyTpFileProgressCallback)
59     (EmpathyTpFile *tp_file,
60      guint64 current_bytes,
61      gpointer user_data);
62
63 typedef void (* EmpathyTpFileOperationCallback)
64     (EmpathyTpFile *tp_file,
65      const GError *error,
66      gpointer user_data);
67
68 GType empathy_tp_file_get_type (void) G_GNUC_CONST;
69
70 /* public methods */
71
72 EmpathyTpFile * empathy_tp_file_new (TpChannel *channel, gboolean incoming);
73
74 void empathy_tp_file_accept (EmpathyTpFile *tp_file,
75   guint64 offset,
76   GFile *gfile,
77   GCancellable *cancellable,
78   EmpathyTpFileProgressCallback progress_callback,
79   gpointer progress_user_data,
80   EmpathyTpFileOperationCallback op_callback,
81   gpointer op_user_data);
82
83 void empathy_tp_file_offer (EmpathyTpFile *tp_file,
84   GFile *gfile,
85   GCancellable *cancellable,
86   EmpathyTpFileProgressCallback progress_callback,
87   gpointer progress_user_data,
88   EmpathyTpFileOperationCallback op_callback,
89   gpointer op_user_data);
90
91 void empathy_tp_file_cancel (EmpathyTpFile *tp_file);
92 void empathy_tp_file_close (EmpathyTpFile *tp_file);
93
94 gboolean empathy_tp_file_is_incoming (EmpathyTpFile *tp_file);
95
96 TpFileTransferState empathy_tp_file_get_state (EmpathyTpFile *tp_file, guint *reason);
97
98 G_END_DECLS
99
100 #endif /* __EMPATHY_TP_FILE_H__ */