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