Mercurial > pidgin.yaz
annotate src/ft.h @ 12651:a74cb5952db4
[gaim-migrate @ 14992]
Activate a GtkSpell on the status box. If your message contains a word
that GtkSpell doesn't recognize then it will have red squiggles underneath
it FOREVER. Is that going to annoy people?
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 25 Dec 2005 01:36:31 +0000 |
parents | de798f2f4bf1 |
children | 661bce46758b |
rev | line source |
---|---|
4514 | 1 /** |
7820 | 2 * @file ft.h File Transfer API |
5034
4691c5936c01
[gaim-migrate @ 5377]
Christian Hammond <chipx86@chipx86.com>
parents:
4675
diff
changeset
|
3 * @ingroup core |
4514 | 4 * |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
10 * |
4514 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #ifndef _GAIM_FT_H_ | |
26 #define _GAIM_FT_H_ | |
27 | |
28 /**************************************************************************/ | |
29 /** Data Structures */ | |
30 /**************************************************************************/ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
31 typedef struct _GaimXfer GaimXfer; |
4514 | 32 |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
33 #include <glib.h> |
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
34 #include <stdio.h> |
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
35 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
36 #include "account.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
37 |
4514 | 38 /** |
39 * Types of file transfers. | |
40 */ | |
41 typedef enum | |
42 { | |
43 GAIM_XFER_UNKNOWN = 0, /**< Unknown file transfer type. */ | |
44 GAIM_XFER_SEND, /**< File sending. */ | |
45 GAIM_XFER_RECEIVE /**< File receiving. */ | |
46 | |
47 } GaimXferType; | |
48 | |
7805 | 49 /** |
50 * The different states of the xfer. | |
51 */ | |
7738 | 52 typedef enum |
53 { | |
7805 | 54 GAIM_XFER_STATUS_UNKNOWN = 0, /**< Unknown, the xfer may be null. */ |
55 GAIM_XFER_STATUS_NOT_STARTED, /**< It hasn't started yet. */ | |
8585 | 56 GAIM_XFER_STATUS_ACCEPTED, /**< Receive accepted, but destination file not selected yet */ |
7805 | 57 GAIM_XFER_STATUS_STARTED, /**< gaim_xfer_start has been called. */ |
58 GAIM_XFER_STATUS_DONE, /**< The xfer completed successfully. */ | |
59 GAIM_XFER_STATUS_CANCEL_LOCAL, /**< The xfer was canceled by us. */ | |
7887 | 60 GAIM_XFER_STATUS_CANCEL_REMOTE /**< The xfer was canceled by the other end, or we couldn't connect. */ |
7805 | 61 } GaimXferStatusType; |
7738 | 62 |
4514 | 63 /** |
64 * File transfer UI operations. | |
65 * | |
66 * Any UI representing a file transfer must assign a filled-out | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
67 * GaimXferUiOps structure to the gaim_xfer. |
4514 | 68 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
69 typedef struct |
4514 | 70 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
71 void (*new_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
72 void (*destroy)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
73 void (*add_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
74 void (*update_progress)(GaimXfer *xfer, double percent); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
75 void (*cancel_local)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
76 void (*cancel_remote)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
77 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
78 } GaimXferUiOps; |
4514 | 79 |
80 /** | |
81 * A core representation of a file transfer. | |
82 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
83 struct _GaimXfer |
4514 | 84 { |
7887 | 85 guint ref; /**< The reference count. */ |
4514 | 86 GaimXferType type; /**< The type of transfer. */ |
87 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
88 GaimAccount *account; /**< The account. */ |
4514 | 89 |
90 char *who; /**< The person on the other end of the | |
91 transfer. */ | |
92 | |
9933 | 93 char *message; /**< A message sent with the request */ |
4605 | 94 char *filename; /**< The name sent over the network. */ |
95 char *local_filename; /**< The name on the local hard drive. */ | |
4514 | 96 size_t size; /**< The size of the file. */ |
97 | |
98 FILE *dest_fp; /**< The destination file pointer. */ | |
99 | |
100 char *remote_ip; /**< The remote IP address. */ | |
101 int local_port; /**< The local port. */ | |
102 int remote_port; /**< The remote port. */ | |
103 | |
104 int fd; /**< The socket file descriptor. */ | |
105 int watcher; /**< Watcher. */ | |
106 | |
107 size_t bytes_sent; /**< The number of bytes sent. */ | |
108 size_t bytes_remaining; /**< The number of bytes remaining. */ | |
109 | |
7805 | 110 GaimXferStatusType status; /**< File Transfer's status. */ |
4538 | 111 |
4514 | 112 /* I/O operations. */ |
113 struct | |
114 { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
115 void (*init)(GaimXfer *xfer); |
7805 | 116 void (*request_denied)(GaimXfer *xfer); |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
117 void (*start)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
118 void (*end)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
119 void (*cancel_send)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
120 void (*cancel_recv)(GaimXfer *xfer); |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
121 gssize (*read)(guchar **buffer, GaimXfer *xfer); |
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
122 gssize (*write)(const guchar *buffer, size_t size, GaimXfer *xfer); |
11159 | 123 void (*ack)(GaimXfer *xfer, const guchar *buffer, size_t size); |
4514 | 124 |
125 } ops; | |
126 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
127 GaimXferUiOps *ui_ops; /**< UI-specific operations. */ |
4514 | 128 void *ui_data; /**< UI-specific data. */ |
129 | |
130 void *data; /**< prpl-specific data. */ | |
131 }; | |
132 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
133 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
134 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
135 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
136 |
4514 | 137 /**************************************************************************/ |
138 /** @name File Transfer API */ | |
139 /**************************************************************************/ | |
140 /*@{*/ | |
141 | |
142 /** | |
143 * Creates a new file transfer handle. | |
7805 | 144 * This is called by prpls. |
145 * The handle starts with a ref count of 1, and this reference | |
146 * is owned by the core. The prpl normally does not need to | |
147 * gaim_xfer_ref or unref. | |
4514 | 148 * |
149 * @param account The account sending or receiving the file. | |
150 * @param type The type of file transfer. | |
151 * @param who The name of the remote user. | |
152 * | |
153 * @return A file transfer handle. | |
154 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
155 GaimXfer *gaim_xfer_new(GaimAccount *account, |
4514 | 156 GaimXferType type, const char *who); |
157 | |
158 /** | |
7805 | 159 * Increases the reference count on a GaimXfer. |
160 * Please call gaim_xfer_unref later. | |
4514 | 161 * |
7805 | 162 * @param xfer A file transfer handle. |
4514 | 163 */ |
7805 | 164 void gaim_xfer_ref(GaimXfer *xfer); |
165 | |
166 /** | |
167 * Decreases the reference count on a GaimXfer. | |
168 * If the reference reaches 0, gaim_xfer_destroy (an internal function) | |
169 * will destroy the xfer. It calls the ui destroy cb first. | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8585
diff
changeset
|
170 * Since the core keeps a ref on the xfer, only an erroneous call to |
7805 | 171 * this function will destroy the xfer while still in use. |
172 * | |
173 * @param xfer A file transfer handle. | |
174 */ | |
175 void gaim_xfer_unref(GaimXfer *xfer); | |
4514 | 176 |
177 /** | |
8585 | 178 * Requests confirmation for a file transfer from the user. If receiving |
179 * a file which is known at this point, this requests user to accept and | |
180 * save the file. If the filename is unknown (not set) this only requests user | |
181 * to accept the file transfer. In this case protocol must call this function | |
182 * again once the filename is available. | |
4514 | 183 * |
184 * @param xfer The file transfer to request confirmation on. | |
185 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
186 void gaim_xfer_request(GaimXfer *xfer); |
4514 | 187 |
188 /** | |
189 * Called if the user accepts the file transfer request. | |
190 * | |
191 * @param xfer The file transfer. | |
192 * @param filename The filename. | |
193 */ | |
7805 | 194 void gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename); |
4514 | 195 |
196 /** | |
197 * Called if the user rejects the file transfer request. | |
198 * | |
199 * @param xfer The file transfer. | |
200 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
201 void gaim_xfer_request_denied(GaimXfer *xfer); |
4514 | 202 |
203 /** | |
204 * Returns the type of file transfer. | |
205 * | |
206 * @param xfer The file transfer. | |
207 * | |
208 * @return The type of the file transfer. | |
209 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
210 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
4514 | 211 |
212 /** | |
213 * Returns the account the file transfer is using. | |
214 * | |
215 * @param xfer The file transfer. | |
216 * | |
217 * @return The account. | |
218 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
219 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
4514 | 220 |
221 /** | |
7805 | 222 * Returns the status of the xfer. |
223 * | |
224 * @param xfer The file transfer. | |
225 * | |
226 * @return The status. | |
227 */ | |
228 GaimXferStatusType gaim_xfer_get_status(const GaimXfer *xfer); | |
229 | |
230 /** | |
7738 | 231 * Returns true if the file transfer was canceled. |
232 * | |
233 * @param xfer The file transfer. | |
234 * | |
235 * @return Whether or not the transfer was canceled. | |
236 */ | |
7805 | 237 gboolean gaim_xfer_is_canceled(const GaimXfer *xfer); |
7738 | 238 |
239 /** | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
240 * Returns the completed state for a file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
241 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
242 * @param xfer The file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
243 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
244 * @return The completed state. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
245 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
246 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
247 |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
248 /** |
4514 | 249 * Returns the name of the file being sent or received. |
250 * | |
251 * @param xfer The file transfer. | |
252 * | |
253 * @return The filename. | |
254 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
255 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
4514 | 256 |
257 /** | |
258 * Returns the file's destination filename, | |
259 * | |
260 * @param xfer The file transfer. | |
261 * | |
262 * @return The destination filename. | |
263 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
264 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
4514 | 265 |
266 /** | |
267 * Returns the number of bytes sent so far. | |
268 * | |
269 * @param xfer The file transfer. | |
270 * | |
271 * @return The number of bytes sent. | |
272 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
273 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
4514 | 274 |
275 /** | |
276 * Returns the number of bytes received so far. | |
277 * | |
278 * @param xfer The file transfer. | |
279 * | |
280 * @return The number of bytes received. | |
281 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
282 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
4514 | 283 |
284 /** | |
285 * Returns the size of the file being sent or received. | |
286 * | |
287 * @param xfer The file transfer. | |
7805 | 288 * |
4514 | 289 * @return The total size of the file. |
290 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
291 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
4514 | 292 |
293 /** | |
294 * Returns the current percentage of progress of the transfer. | |
295 * | |
296 * This is a number between 0 (0%) and 1 (100%). | |
297 * | |
298 * @param xfer The file transfer. | |
299 * | |
300 * @return The percentage complete. | |
301 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
302 double gaim_xfer_get_progress(const GaimXfer *xfer); |
4514 | 303 |
304 /** | |
305 * Returns the local port number in the file transfer. | |
306 * | |
307 * @param xfer The file transfer. | |
308 * | |
309 * @return The port number on this end. | |
310 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
311 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
4514 | 312 |
313 /** | |
314 * Returns the remote IP address in the file transfer. | |
315 * | |
316 * @param xfer The file transfer. | |
317 * | |
318 * @return The IP address on the other end. | |
319 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
320 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
4514 | 321 |
322 /** | |
323 * Returns the remote port number in the file transfer. | |
324 * | |
325 * @param xfer The file transfer. | |
326 * | |
327 * @return The port number on the other end. | |
328 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
329 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
4514 | 330 |
331 /** | |
4538 | 332 * Sets the completed state for the file transfer. |
333 * | |
334 * @param xfer The file transfer. | |
335 * @param completed The completed state. | |
336 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
337 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
4538 | 338 |
339 /** | |
4514 | 340 * Sets the filename for the file transfer. |
341 * | |
342 * @param xfer The file transfer. | |
9933 | 343 * @param message The message. |
344 */ | |
345 void gaim_xfer_set_message(GaimXfer *xfer, const char *message); | |
346 | |
347 /** | |
348 * Sets the filename for the file transfer. | |
349 * | |
350 * @param xfer The file transfer. | |
4514 | 351 * @param filename The filename. |
352 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
353 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
4514 | 354 |
355 /** | |
4605 | 356 * Sets the local filename for the file transfer. |
4514 | 357 * |
358 * @param xfer The file transfer. | |
359 * @param filename The filename | |
360 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
361 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
4514 | 362 |
363 /** | |
364 * Sets the size of the file in a file transfer. | |
365 * | |
366 * @param xfer The file transfer. | |
367 * @param size The size of the file. | |
368 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
369 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
4514 | 370 |
371 /** | |
372 * Returns the UI operations structure for a file transfer. | |
373 * | |
374 * @param xfer The file transfer. | |
375 * | |
376 * @return The UI operations structure. | |
377 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
378 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
4514 | 379 |
380 /** | |
381 * Sets the read function for the file transfer. | |
382 * | |
383 * @param xfer The file transfer. | |
384 * @param fnc The read function. | |
385 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
386 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
387 gssize (*fnc)(guchar **, GaimXfer *)); |
4514 | 388 |
389 /** | |
390 * Sets the write function for the file transfer. | |
391 * | |
392 * @param xfer The file transfer. | |
393 * @param fnc The write function. | |
394 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
395 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
396 gssize (*fnc)(const guchar *, size_t, GaimXfer *)); |
4514 | 397 |
398 /** | |
399 * Sets the acknowledge function for the file transfer. | |
400 * | |
401 * @param xfer The file transfer. | |
402 * @param fnc The acknowledge function. | |
403 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
404 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
11159 | 405 void (*fnc)(GaimXfer *, const guchar *, size_t)); |
4514 | 406 |
407 /** | |
7805 | 408 * Sets the function to be called if the request is denied. |
409 * | |
410 * @param xfer The file transfer. | |
411 * @param fnc The request denied prpl callback. | |
412 */ | |
413 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); | |
414 | |
415 /** | |
4514 | 416 * Sets the transfer initialization function for the file transfer. |
417 * | |
418 * This function is required, and must call gaim_xfer_start() with | |
419 * the necessary parameters. This will be called if the file transfer | |
420 * is accepted by the user. | |
421 * | |
422 * @param xfer The file transfer. | |
423 * @param fnc The transfer initialization function. | |
424 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
425 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 426 |
427 /** | |
428 * Sets the start transfer function for the file transfer. | |
429 * | |
430 * @param xfer The file transfer. | |
431 * @param fnc The start transfer function. | |
432 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
433 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 434 |
435 /** | |
436 * Sets the end transfer function for the file transfer. | |
437 * | |
438 * @param xfer The file transfer. | |
439 * @param fnc The end transfer function. | |
440 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
441 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 442 |
443 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
444 * Sets the cancel send function for the file transfer. |
4514 | 445 * |
446 * @param xfer The file transfer. | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
447 * @param fnc The cancel send function. |
4514 | 448 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
449 void gaim_xfer_set_cancel_send_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
450 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
451 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
452 * Sets the cancel receive function for the file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
453 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
454 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
455 * @param fnc The cancel receive function. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
456 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
457 void gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 458 |
459 /** | |
460 * Reads in data from a file transfer stream. | |
461 * | |
462 * @param xfer The file transfer. | |
463 * @param buffer The buffer that will be created to contain the data. | |
464 * | |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
465 * @return The number of bytes read, or -1. |
4514 | 466 */ |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
467 gssize gaim_xfer_read(GaimXfer *xfer, guchar **buffer); |
4514 | 468 |
469 /** | |
470 * Writes data to a file transfer stream. | |
471 * | |
472 * @param xfer The file transfer. | |
473 * @param buffer The buffer to read the data from. | |
474 * @param size The number of bytes to write. | |
475 * | |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
476 * @return The number of bytes written, or -1. |
4514 | 477 */ |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
12150
diff
changeset
|
478 gssize gaim_xfer_write(GaimXfer *xfer, const guchar *buffer, gsize size); |
4514 | 479 |
480 /** | |
481 * Starts a file transfer. | |
482 * | |
483 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
484 * file receive transfer. On send, @a fd must be specified, and | |
485 * @a ip and @a port are ignored. | |
486 * | |
487 * @param xfer The file transfer. | |
488 * @param fd The file descriptor for the socket. | |
489 * @param ip The IP address to connect to. | |
490 * @param port The port to connect to. | |
491 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
492 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514 | 493 unsigned int port); |
494 | |
495 /** | |
496 * Ends a file transfer. | |
497 * | |
498 * @param xfer The file transfer. | |
499 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
500 void gaim_xfer_end(GaimXfer *xfer); |
4514 | 501 |
502 /** | |
8585 | 503 * Adds a new file transfer to the list of file transfers. Call this only |
504 * if you are not using gaim_xfer_start. | |
505 * | |
506 * @param xfer The file transfer. | |
507 */ | |
508 void gaim_xfer_add(GaimXfer *xfer); | |
509 | |
510 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
511 * Cancels a file transfer on the local end. |
4514 | 512 * |
513 * @param xfer The file transfer. | |
514 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
515 void gaim_xfer_cancel_local(GaimXfer *xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
516 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
517 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
518 * Cancels a file transfer from the remote end. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
519 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
520 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
521 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
522 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
4514 | 523 |
524 /** | |
525 * Displays a file transfer-related error message. | |
526 * | |
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
527 * This is a wrapper around gaim_notify_error(), which automatically |
10654 | 528 * specifies a title ("File transfer to <i>user</i> failed" or |
529 * "File Transfer from <i>user</i> failed"). | |
4514 | 530 * |
10654 | 531 * @param type The type of file transfer. |
532 * @param account The account sending or receiving the file. | |
533 * @param who The user on the other end of the transfer. | |
534 * @param msg The message to display. | |
4514 | 535 */ |
10654 | 536 void gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg); |
4514 | 537 |
8585 | 538 /** |
539 * Updates file transfer progress. | |
540 * | |
541 * @param xfer The file transfer. | |
542 */ | |
543 void gaim_xfer_update_progress(GaimXfer *xfer); | |
544 | |
11084 | 545 /** |
546 * Displays a file transfer-related message in the conversation window | |
547 * | |
548 * This is a wrapper around gaim_conversation_write | |
549 * | |
550 * @param xfer The file transfer to which this message relates. | |
551 * @param message The message to display. | |
11129 | 552 * @param is_error Is this an error message?. |
11084 | 553 */ |
554 void gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error); | |
555 | |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
556 /*@}*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
557 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
558 /**************************************************************************/ |
4514 | 559 /** @name UI Registration Functions */ |
560 /**************************************************************************/ | |
561 /*@{*/ | |
562 | |
563 /** | |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
564 * Returns the handle to the file transfer subsystem |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
565 * |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
566 * @return The handle |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
567 */ |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
568 void *gaim_xfers_get_handle(void); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
569 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
570 /** |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
571 * Initializes the file transfer subsystem |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
572 */ |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
573 void gaim_xfers_init(void); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
574 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
575 /** |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
576 * Uninitializes the file transfer subsystem |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
577 */ |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
578 void gaim_xfers_uninit(void); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
579 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
580 /** |
4514 | 581 * Sets the UI operations structure to be used in all gaim file transfers. |
582 * | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6269
diff
changeset
|
583 * @param ops The UI operations structure. |
4514 | 584 */ |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
585 void gaim_xfers_set_ui_ops(GaimXferUiOps *ops); |
4514 | 586 |
587 /** | |
588 * Returns the UI operations structure to be used in all gaim file transfers. | |
589 * | |
590 * @return The UI operations structure. | |
591 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
592 GaimXferUiOps *gaim_xfers_get_ui_ops(void); |
4514 | 593 |
594 /*@}*/ | |
595 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
596 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
597 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
598 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
599 |
4514 | 600 #endif /* _GAIM_FT_H_ */ |