Mercurial > pidgin.yaz
annotate src/ft.h @ 9776:1e5ef71c9583
[gaim-migrate @ 10644]
A patch from Daniel Atallah that should fix sf bug 1008489:
"Windows Messenger BOT Crashes Gaim"
Someone MSN-savvy should check this to make sure it's a valid fix.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 19 Aug 2004 01:13:58 +0000 |
parents | 3ed6001d5de8 |
children | cee849d17167 |
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 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
33 #include "account.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
34 |
4514 | 35 /** |
36 * Types of file transfers. | |
37 */ | |
38 typedef enum | |
39 { | |
40 GAIM_XFER_UNKNOWN = 0, /**< Unknown file transfer type. */ | |
41 GAIM_XFER_SEND, /**< File sending. */ | |
42 GAIM_XFER_RECEIVE /**< File receiving. */ | |
43 | |
44 } GaimXferType; | |
45 | |
7805 | 46 /** |
47 * The different states of the xfer. | |
48 */ | |
7738 | 49 typedef enum |
50 { | |
7805 | 51 GAIM_XFER_STATUS_UNKNOWN = 0, /**< Unknown, the xfer may be null. */ |
52 GAIM_XFER_STATUS_NOT_STARTED, /**< It hasn't started yet. */ | |
8585 | 53 GAIM_XFER_STATUS_ACCEPTED, /**< Receive accepted, but destination file not selected yet */ |
7805 | 54 GAIM_XFER_STATUS_STARTED, /**< gaim_xfer_start has been called. */ |
55 GAIM_XFER_STATUS_DONE, /**< The xfer completed successfully. */ | |
56 GAIM_XFER_STATUS_CANCEL_LOCAL, /**< The xfer was canceled by us. */ | |
7887 | 57 GAIM_XFER_STATUS_CANCEL_REMOTE /**< The xfer was canceled by the other end, or we couldn't connect. */ |
7805 | 58 } GaimXferStatusType; |
7738 | 59 |
4514 | 60 /** |
61 * File transfer UI operations. | |
62 * | |
63 * 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
|
64 * GaimXferUiOps structure to the gaim_xfer. |
4514 | 65 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
66 typedef struct |
4514 | 67 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
68 void (*new_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
69 void (*destroy)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
70 void (*add_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
71 void (*update_progress)(GaimXfer *xfer, double percent); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
72 void (*cancel_local)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
73 void (*cancel_remote)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
74 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
75 } GaimXferUiOps; |
4514 | 76 |
77 /** | |
78 * A core representation of a file transfer. | |
79 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
80 struct _GaimXfer |
4514 | 81 { |
7887 | 82 guint ref; /**< The reference count. */ |
4514 | 83 GaimXferType type; /**< The type of transfer. */ |
84 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
85 GaimAccount *account; /**< The account. */ |
4514 | 86 |
87 char *who; /**< The person on the other end of the | |
88 transfer. */ | |
89 | |
4605 | 90 char *filename; /**< The name sent over the network. */ |
91 char *local_filename; /**< The name on the local hard drive. */ | |
4514 | 92 size_t size; /**< The size of the file. */ |
93 | |
94 FILE *dest_fp; /**< The destination file pointer. */ | |
95 | |
96 char *remote_ip; /**< The remote IP address. */ | |
97 int local_port; /**< The local port. */ | |
98 int remote_port; /**< The remote port. */ | |
99 | |
100 int fd; /**< The socket file descriptor. */ | |
101 int watcher; /**< Watcher. */ | |
102 | |
103 size_t bytes_sent; /**< The number of bytes sent. */ | |
104 size_t bytes_remaining; /**< The number of bytes remaining. */ | |
105 | |
7805 | 106 GaimXferStatusType status; /**< File Transfer's status. */ |
4538 | 107 |
4514 | 108 /* I/O operations. */ |
109 struct | |
110 { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
111 void (*init)(GaimXfer *xfer); |
7805 | 112 void (*request_denied)(GaimXfer *xfer); |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
113 void (*start)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
114 void (*end)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
115 void (*cancel_send)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
116 void (*cancel_recv)(GaimXfer *xfer); |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
117 ssize_t (*read)(char **buffer, GaimXfer *xfer); |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
118 ssize_t (*write)(const char *buffer, size_t size, GaimXfer *xfer); |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
119 void (*ack)(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 120 |
121 } ops; | |
122 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
123 GaimXferUiOps *ui_ops; /**< UI-specific operations. */ |
4514 | 124 void *ui_data; /**< UI-specific data. */ |
125 | |
126 void *data; /**< prpl-specific data. */ | |
127 }; | |
128 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
129 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
130 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
131 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
132 |
4514 | 133 /**************************************************************************/ |
134 /** @name File Transfer API */ | |
135 /**************************************************************************/ | |
136 /*@{*/ | |
137 | |
138 /** | |
139 * Creates a new file transfer handle. | |
7805 | 140 * This is called by prpls. |
141 * The handle starts with a ref count of 1, and this reference | |
142 * is owned by the core. The prpl normally does not need to | |
143 * gaim_xfer_ref or unref. | |
4514 | 144 * |
145 * @param account The account sending or receiving the file. | |
146 * @param type The type of file transfer. | |
147 * @param who The name of the remote user. | |
148 * | |
149 * @return A file transfer handle. | |
150 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
151 GaimXfer *gaim_xfer_new(GaimAccount *account, |
4514 | 152 GaimXferType type, const char *who); |
153 | |
154 /** | |
7805 | 155 * Increases the reference count on a GaimXfer. |
156 * Please call gaim_xfer_unref later. | |
4514 | 157 * |
7805 | 158 * @param xfer A file transfer handle. |
4514 | 159 */ |
7805 | 160 void gaim_xfer_ref(GaimXfer *xfer); |
161 | |
162 /** | |
163 * Decreases the reference count on a GaimXfer. | |
164 * If the reference reaches 0, gaim_xfer_destroy (an internal function) | |
165 * 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
|
166 * Since the core keeps a ref on the xfer, only an erroneous call to |
7805 | 167 * this function will destroy the xfer while still in use. |
168 * | |
169 * @param xfer A file transfer handle. | |
170 */ | |
171 void gaim_xfer_unref(GaimXfer *xfer); | |
4514 | 172 |
173 /** | |
8585 | 174 * Requests confirmation for a file transfer from the user. If receiving |
175 * a file which is known at this point, this requests user to accept and | |
176 * save the file. If the filename is unknown (not set) this only requests user | |
177 * to accept the file transfer. In this case protocol must call this function | |
178 * again once the filename is available. | |
4514 | 179 * |
180 * @param xfer The file transfer to request confirmation on. | |
181 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
182 void gaim_xfer_request(GaimXfer *xfer); |
4514 | 183 |
184 /** | |
185 * Called if the user accepts the file transfer request. | |
186 * | |
187 * @param xfer The file transfer. | |
188 * @param filename The filename. | |
189 */ | |
7805 | 190 void gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename); |
4514 | 191 |
192 /** | |
193 * Called if the user rejects the file transfer request. | |
194 * | |
195 * @param xfer The file transfer. | |
196 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
197 void gaim_xfer_request_denied(GaimXfer *xfer); |
4514 | 198 |
199 /** | |
200 * Returns the type of file transfer. | |
201 * | |
202 * @param xfer The file transfer. | |
203 * | |
204 * @return The type of the file transfer. | |
205 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
206 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
4514 | 207 |
208 /** | |
209 * Returns the account the file transfer is using. | |
210 * | |
211 * @param xfer The file transfer. | |
212 * | |
213 * @return The account. | |
214 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
215 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
4514 | 216 |
217 /** | |
7805 | 218 * Returns the status of the xfer. |
219 * | |
220 * @param xfer The file transfer. | |
221 * | |
222 * @return The status. | |
223 */ | |
224 GaimXferStatusType gaim_xfer_get_status(const GaimXfer *xfer); | |
225 | |
226 /** | |
7738 | 227 * Returns true if the file transfer was canceled. |
228 * | |
229 * @param xfer The file transfer. | |
230 * | |
231 * @return Whether or not the transfer was canceled. | |
232 */ | |
7805 | 233 gboolean gaim_xfer_is_canceled(const GaimXfer *xfer); |
7738 | 234 |
235 /** | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
236 * Returns the completed state for a file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
237 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
238 * @param xfer The file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
239 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
240 * @return The completed state. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
241 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
242 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
4539
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 /** |
4514 | 245 * Returns the name of the file being sent or received. |
246 * | |
247 * @param xfer The file transfer. | |
248 * | |
249 * @return The filename. | |
250 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
251 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
4514 | 252 |
253 /** | |
254 * Returns the file's destination filename, | |
255 * | |
256 * @param xfer The file transfer. | |
257 * | |
258 * @return The destination filename. | |
259 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
260 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
4514 | 261 |
262 /** | |
263 * Returns the number of bytes sent so far. | |
264 * | |
265 * @param xfer The file transfer. | |
266 * | |
267 * @return The number of bytes sent. | |
268 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
269 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
4514 | 270 |
271 /** | |
272 * Returns the number of bytes received so far. | |
273 * | |
274 * @param xfer The file transfer. | |
275 * | |
276 * @return The number of bytes received. | |
277 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
278 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
4514 | 279 |
280 /** | |
281 * Returns the size of the file being sent or received. | |
282 * | |
283 * @param xfer The file transfer. | |
7805 | 284 * |
4514 | 285 * @return The total size of the file. |
286 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
287 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
4514 | 288 |
289 /** | |
290 * Returns the current percentage of progress of the transfer. | |
291 * | |
292 * This is a number between 0 (0%) and 1 (100%). | |
293 * | |
294 * @param xfer The file transfer. | |
295 * | |
296 * @return The percentage complete. | |
297 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
298 double gaim_xfer_get_progress(const GaimXfer *xfer); |
4514 | 299 |
300 /** | |
301 * Returns the local port number in the file transfer. | |
302 * | |
303 * @param xfer The file transfer. | |
304 * | |
305 * @return The port number on this end. | |
306 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
307 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
4514 | 308 |
309 /** | |
310 * Returns the remote IP address in the file transfer. | |
311 * | |
312 * @param xfer The file transfer. | |
313 * | |
314 * @return The IP address on the other end. | |
315 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
316 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
4514 | 317 |
318 /** | |
319 * Returns the remote port number in the file transfer. | |
320 * | |
321 * @param xfer The file transfer. | |
322 * | |
323 * @return The port number on the other end. | |
324 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
325 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
4514 | 326 |
327 /** | |
4538 | 328 * Sets the completed state for the file transfer. |
329 * | |
330 * @param xfer The file transfer. | |
331 * @param completed The completed state. | |
332 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
333 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
4538 | 334 |
335 /** | |
4514 | 336 * Sets the filename for the file transfer. |
337 * | |
338 * @param xfer The file transfer. | |
339 * @param filename The filename. | |
340 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
341 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
4514 | 342 |
343 /** | |
4605 | 344 * Sets the local filename for the file transfer. |
4514 | 345 * |
346 * @param xfer The file transfer. | |
347 * @param filename The filename | |
348 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
349 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
4514 | 350 |
351 /** | |
352 * Sets the size of the file in a file transfer. | |
353 * | |
354 * @param xfer The file transfer. | |
355 * @param size The size of the file. | |
356 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
357 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
4514 | 358 |
359 /** | |
360 * Returns the UI operations structure for a file transfer. | |
361 * | |
362 * @param xfer The file transfer. | |
363 * | |
364 * @return The UI operations structure. | |
365 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
366 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
4514 | 367 |
368 /** | |
369 * Sets the read function for the file transfer. | |
370 * | |
371 * @param xfer The file transfer. | |
372 * @param fnc The read function. | |
373 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
374 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
375 ssize_t (*fnc)(char **, GaimXfer *)); |
4514 | 376 |
377 /** | |
378 * Sets the write function for the file transfer. | |
379 * | |
380 * @param xfer The file transfer. | |
381 * @param fnc The write function. | |
382 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
383 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
384 ssize_t (*fnc)(const char *, size_t, GaimXfer *)); |
4514 | 385 |
386 /** | |
387 * Sets the acknowledge function for the file transfer. | |
388 * | |
389 * @param xfer The file transfer. | |
390 * @param fnc The acknowledge function. | |
391 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
392 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
393 void (*fnc)(GaimXfer *, const char *, size_t)); |
4514 | 394 |
395 /** | |
7805 | 396 * Sets the function to be called if the request is denied. |
397 * | |
398 * @param xfer The file transfer. | |
399 * @param fnc The request denied prpl callback. | |
400 */ | |
401 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); | |
402 | |
403 /** | |
4514 | 404 * Sets the transfer initialization function for the file transfer. |
405 * | |
406 * This function is required, and must call gaim_xfer_start() with | |
407 * the necessary parameters. This will be called if the file transfer | |
408 * is accepted by the user. | |
409 * | |
410 * @param xfer The file transfer. | |
411 * @param fnc The transfer initialization function. | |
412 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
413 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 414 |
415 /** | |
416 * Sets the start transfer function for the file transfer. | |
417 * | |
418 * @param xfer The file transfer. | |
419 * @param fnc The start transfer function. | |
420 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
421 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 422 |
423 /** | |
424 * Sets the end transfer function for the file transfer. | |
425 * | |
426 * @param xfer The file transfer. | |
427 * @param fnc The end transfer function. | |
428 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
429 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 430 |
431 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
432 * Sets the cancel send function for the file transfer. |
4514 | 433 * |
434 * @param xfer The file transfer. | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
435 * @param fnc The cancel send function. |
4514 | 436 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
437 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
|
438 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
439 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
440 * Sets the cancel receive function for the file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
441 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
442 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
443 * @param fnc The cancel receive function. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
444 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
445 void gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 446 |
447 /** | |
448 * Reads in data from a file transfer stream. | |
449 * | |
450 * @param xfer The file transfer. | |
451 * @param buffer The buffer that will be created to contain the data. | |
452 * | |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
453 * @return The number of bytes read, or -1. |
4514 | 454 */ |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
455 ssize_t gaim_xfer_read(GaimXfer *xfer, char **buffer); |
4514 | 456 |
457 /** | |
458 * Writes data to a file transfer stream. | |
459 * | |
460 * @param xfer The file transfer. | |
461 * @param buffer The buffer to read the data from. | |
462 * @param size The number of bytes to write. | |
463 * | |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
464 * @return The number of bytes written, or -1. |
4514 | 465 */ |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
466 ssize_t gaim_xfer_write(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 467 |
468 /** | |
469 * Starts a file transfer. | |
470 * | |
471 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
472 * file receive transfer. On send, @a fd must be specified, and | |
473 * @a ip and @a port are ignored. | |
474 * | |
475 * @param xfer The file transfer. | |
476 * @param fd The file descriptor for the socket. | |
477 * @param ip The IP address to connect to. | |
478 * @param port The port to connect to. | |
479 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
480 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514 | 481 unsigned int port); |
482 | |
483 /** | |
484 * Ends a file transfer. | |
485 * | |
486 * @param xfer The file transfer. | |
487 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
488 void gaim_xfer_end(GaimXfer *xfer); |
4514 | 489 |
490 /** | |
8585 | 491 * Adds a new file transfer to the list of file transfers. Call this only |
492 * if you are not using gaim_xfer_start. | |
493 * | |
494 * @param xfer The file transfer. | |
495 */ | |
496 void gaim_xfer_add(GaimXfer *xfer); | |
497 | |
498 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
499 * Cancels a file transfer on the local end. |
4514 | 500 * |
501 * @param xfer The file transfer. | |
502 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
503 void gaim_xfer_cancel_local(GaimXfer *xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
504 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
505 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
506 * Cancels a file transfer from the remote end. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
507 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
508 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
509 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
510 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
4514 | 511 |
512 /** | |
513 * Displays a file transfer-related error message. | |
514 * | |
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
515 * This is a wrapper around gaim_notify_error(), which automatically |
4514 | 516 * specifies a title ("File transfer to <i>user</i> aborted" or |
517 * "File Transfer from <i>user</i> aborted"). | |
518 * | |
519 * @param type The type of file transfer. | |
520 * @param who The user on the other end of the transfer. | |
521 * @param msg The message to display. | |
522 */ | |
523 void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); | |
524 | |
8585 | 525 /** |
526 * Updates file transfer progress. | |
527 * | |
528 * @param xfer The file transfer. | |
529 */ | |
530 void gaim_xfer_update_progress(GaimXfer *xfer); | |
531 | |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
532 /*@}*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
533 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
534 /**************************************************************************/ |
4514 | 535 /** @name UI Registration Functions */ |
536 /**************************************************************************/ | |
537 /*@{*/ | |
538 | |
539 /** | |
540 * Sets the UI operations structure to be used in all gaim file transfers. | |
541 * | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6269
diff
changeset
|
542 * @param ops The UI operations structure. |
4514 | 543 */ |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
544 void gaim_xfers_set_ui_ops(GaimXferUiOps *ops); |
4514 | 545 |
546 /** | |
547 * Returns the UI operations structure to be used in all gaim file transfers. | |
548 * | |
549 * @return The UI operations structure. | |
550 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
551 GaimXferUiOps *gaim_xfers_get_ui_ops(void); |
4514 | 552 |
553 /*@}*/ | |
554 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
555 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
556 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
557 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
558 |
4514 | 559 #endif /* _GAIM_FT_H_ */ |