Mercurial > pidgin
annotate src/ft.h @ 6579:9714538226f0
[gaim-migrate @ 7101]
(20:25:50) Robot101: LSchiere: eek
(20:25:54) Robot101: LSchiere: that's garbled
(20:26:10) Robot101: I said move the c=, not the b=..
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 23 Aug 2003 00:27:10 +0000 |
parents | 0a902bd3e170 |
children | 41120df7ed94 |
rev | line source |
---|---|
4514 | 1 /** |
2 * @file ft.h The file transfer interface | |
5034
4691c5936c01
[gaim-migrate @ 5377]
Christian Hammond <chipx86@chipx86.com>
parents:
4675
diff
changeset
|
3 * @ingroup core |
4514 | 4 * |
5 * gaim | |
6 * | |
7 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
8 * | |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #ifndef _GAIM_FT_H_ | |
24 #define _GAIM_FT_H_ | |
25 | |
26 /**************************************************************************/ | |
27 /** Data Structures */ | |
28 /**************************************************************************/ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
29 typedef struct _GaimXfer GaimXfer; |
4514 | 30 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
31 #include "account.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
32 |
4514 | 33 /** |
34 * Types of file transfers. | |
35 */ | |
36 typedef enum | |
37 { | |
38 GAIM_XFER_UNKNOWN = 0, /**< Unknown file transfer type. */ | |
39 GAIM_XFER_SEND, /**< File sending. */ | |
40 GAIM_XFER_RECEIVE /**< File receiving. */ | |
41 | |
42 } GaimXferType; | |
43 | |
44 /** | |
45 * File transfer UI operations. | |
46 * | |
47 * 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
|
48 * GaimXferUiOps structure to the gaim_xfer. |
4514 | 49 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
50 typedef struct |
4514 | 51 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
52 void (*new_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
53 void (*destroy)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
54 void (*request_file)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
55 void (*ask_cancel)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
56 void (*add_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
57 void (*update_progress)(GaimXfer *xfer, double percent); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
58 void (*cancel_local)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
59 void (*cancel_remote)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
60 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
61 } GaimXferUiOps; |
4514 | 62 |
63 /** | |
64 * A core representation of a file transfer. | |
65 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
66 struct _GaimXfer |
4514 | 67 { |
68 GaimXferType type; /**< The type of transfer. */ | |
69 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
70 GaimAccount *account; /**< The account. */ |
4514 | 71 |
72 char *who; /**< The person on the other end of the | |
73 transfer. */ | |
74 | |
4605 | 75 char *filename; /**< The name sent over the network. */ |
76 char *local_filename; /**< The name on the local hard drive. */ | |
4514 | 77 size_t size; /**< The size of the file. */ |
78 | |
79 FILE *dest_fp; /**< The destination file pointer. */ | |
80 | |
81 char *local_ip; /**< The local IP address. */ | |
82 char *remote_ip; /**< The remote IP address. */ | |
83 int local_port; /**< The local port. */ | |
84 int remote_port; /**< The remote port. */ | |
85 | |
86 int fd; /**< The socket file descriptor. */ | |
87 int watcher; /**< Watcher. */ | |
88 | |
89 size_t bytes_sent; /**< The number of bytes sent. */ | |
90 size_t bytes_remaining; /**< The number of bytes remaining. */ | |
91 | |
4538 | 92 gboolean completed; /**< File Transfer is completed. */ |
93 | |
4514 | 94 /* I/O operations. */ |
95 struct | |
96 { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
97 void (*init)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
98 void (*start)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
99 void (*end)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
100 void (*cancel_send)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
101 void (*cancel_recv)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
102 size_t (*read)(char **buffer, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
103 size_t (*write)(const char *buffer, size_t size, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
104 void (*ack)(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 105 |
106 } ops; | |
107 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
108 GaimXferUiOps *ui_ops; /**< UI-specific operations. */ |
4514 | 109 void *ui_data; /**< UI-specific data. */ |
110 | |
111 void *data; /**< prpl-specific data. */ | |
112 }; | |
113 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
114 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
115 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
116 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
117 |
4514 | 118 /**************************************************************************/ |
119 /** @name File Transfer API */ | |
120 /**************************************************************************/ | |
121 /*@{*/ | |
122 | |
123 /** | |
124 * Creates a new file transfer handle. | |
125 * | |
126 * @param account The account sending or receiving the file. | |
127 * @param type The type of file transfer. | |
128 * @param who The name of the remote user. | |
129 * | |
130 * @return A file transfer handle. | |
131 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
132 GaimXfer *gaim_xfer_new(GaimAccount *account, |
4514 | 133 GaimXferType type, const char *who); |
134 | |
135 /** | |
136 * Destroys a file transfer handle. | |
137 * | |
138 * @param xfer The file transfer to destroy. | |
139 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
140 void gaim_xfer_destroy(GaimXfer *xfer); |
4514 | 141 |
142 /** | |
143 * Requests confirmation for a file transfer from the user. | |
144 * | |
145 * @param xfer The file transfer to request confirmation on. | |
146 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
147 void gaim_xfer_request(GaimXfer *xfer); |
4514 | 148 |
149 /** | |
150 * Called if the user accepts the file transfer request. | |
151 * | |
152 * @param xfer The file transfer. | |
153 * @param filename The filename. | |
154 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
155 void gaim_xfer_request_accepted(GaimXfer *xfer, char *filename); |
4514 | 156 |
157 /** | |
158 * Called if the user rejects the file transfer request. | |
159 * | |
160 * @param xfer The file transfer. | |
161 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
162 void gaim_xfer_request_denied(GaimXfer *xfer); |
4514 | 163 |
164 /** | |
165 * Returns the type of file transfer. | |
166 * | |
167 * @param xfer The file transfer. | |
168 * | |
169 * @return The type of the file transfer. | |
170 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
171 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
4514 | 172 |
173 /** | |
174 * Returns the account the file transfer is using. | |
175 * | |
176 * @param xfer The file transfer. | |
177 * | |
178 * @return The account. | |
179 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
180 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
4514 | 181 |
182 /** | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
183 * Returns the completed state for a file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
184 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
185 * @param xfer The file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
186 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
187 * @return The completed state. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
188 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
189 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
190 |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
191 /** |
4514 | 192 * Returns the name of the file being sent or received. |
193 * | |
194 * @param xfer The file transfer. | |
195 * | |
196 * @return The filename. | |
197 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
198 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
4514 | 199 |
200 /** | |
201 * Returns the file's destination filename, | |
202 * | |
203 * @param xfer The file transfer. | |
204 * | |
205 * @return The destination filename. | |
206 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
207 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
4514 | 208 |
209 /** | |
210 * Returns the number of bytes sent so far. | |
211 * | |
212 * @param xfer The file transfer. | |
213 * | |
214 * @return The number of bytes sent. | |
215 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
216 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
4514 | 217 |
218 /** | |
219 * Returns the number of bytes received so far. | |
220 * | |
221 * @param xfer The file transfer. | |
222 * | |
223 * @return The number of bytes received. | |
224 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
225 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
4514 | 226 |
227 /** | |
228 * Returns the size of the file being sent or received. | |
229 * | |
230 * @param xfer The file transfer. | |
231 * | |
232 * @return The total size of the file. | |
233 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
234 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
4514 | 235 |
236 /** | |
237 * Returns the current percentage of progress of the transfer. | |
238 * | |
239 * This is a number between 0 (0%) and 1 (100%). | |
240 * | |
241 * @param xfer The file transfer. | |
242 * | |
243 * @return The percentage complete. | |
244 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
245 double gaim_xfer_get_progress(const GaimXfer *xfer); |
4514 | 246 |
247 /** | |
248 * Returns the local IP address in the file transfer. | |
249 * | |
250 * @param xfer The file transfer. | |
251 * | |
252 * @return The IP address on this end. | |
253 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
254 const char *gaim_xfer_get_local_ip(const GaimXfer *xfer); |
4514 | 255 |
256 /** | |
257 * Returns the local port number in the file transfer. | |
258 * | |
259 * @param xfer The file transfer. | |
260 * | |
261 * @return The port number on this end. | |
262 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
263 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
4514 | 264 |
265 /** | |
266 * Returns the remote IP address in the file transfer. | |
267 * | |
268 * @param xfer The file transfer. | |
269 * | |
270 * @return The IP address on the other end. | |
271 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
272 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
4514 | 273 |
274 /** | |
275 * Returns the remote port number in the file transfer. | |
276 * | |
277 * @param xfer The file transfer. | |
278 * | |
279 * @return The port number on the other end. | |
280 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
281 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
4514 | 282 |
283 /** | |
4538 | 284 * Sets the completed state for the file transfer. |
285 * | |
286 * @param xfer The file transfer. | |
287 * @param completed The completed state. | |
288 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
289 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
4538 | 290 |
291 /** | |
4514 | 292 * Sets the filename for the file transfer. |
293 * | |
294 * @param xfer The file transfer. | |
295 * @param filename The filename. | |
296 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
297 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
4514 | 298 |
299 /** | |
4605 | 300 * Sets the local filename for the file transfer. |
4514 | 301 * |
302 * @param xfer The file transfer. | |
303 * @param filename The filename | |
304 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
305 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
4514 | 306 |
307 /** | |
308 * Sets the size of the file in a file transfer. | |
309 * | |
310 * @param xfer The file transfer. | |
311 * @param size The size of the file. | |
312 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
313 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
4514 | 314 |
315 /** | |
316 * Returns the UI operations structure for a file transfer. | |
317 * | |
318 * @param xfer The file transfer. | |
319 * | |
320 * @return The UI operations structure. | |
321 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
322 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
4514 | 323 |
324 /** | |
325 * Sets the read function for the file transfer. | |
326 * | |
327 * @param xfer The file transfer. | |
328 * @param fnc The read function. | |
329 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
330 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
331 size_t (*fnc)(char **, GaimXfer *)); |
4514 | 332 |
333 /** | |
334 * Sets the write function for the file transfer. | |
335 * | |
336 * @param xfer The file transfer. | |
337 * @param fnc The write function. | |
338 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
339 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
340 size_t (*fnc)(const char *, size_t, GaimXfer *)); |
4514 | 341 |
342 /** | |
343 * Sets the acknowledge function for the file transfer. | |
344 * | |
345 * @param xfer The file transfer. | |
346 * @param fnc The acknowledge function. | |
347 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
348 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
349 void (*fnc)(GaimXfer *, const char *, size_t)); |
4514 | 350 |
351 /** | |
352 * Sets the transfer initialization function for the file transfer. | |
353 * | |
354 * This function is required, and must call gaim_xfer_start() with | |
355 * the necessary parameters. This will be called if the file transfer | |
356 * is accepted by the user. | |
357 * | |
358 * @param xfer The file transfer. | |
359 * @param fnc The transfer initialization function. | |
360 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
361 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 362 |
363 /** | |
364 * Sets the start transfer function for the file transfer. | |
365 * | |
366 * @param xfer The file transfer. | |
367 * @param fnc The start transfer function. | |
368 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
369 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 370 |
371 /** | |
372 * Sets the end transfer function for the file transfer. | |
373 * | |
374 * @param xfer The file transfer. | |
375 * @param fnc The end transfer function. | |
376 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
377 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 378 |
379 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
380 * Sets the cancel send function for the file transfer. |
4514 | 381 * |
382 * @param xfer The file transfer. | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
383 * @param fnc The cancel send function. |
4514 | 384 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
385 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
|
386 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
387 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
388 * Sets the cancel receive function for the file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
389 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
390 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
391 * @param fnc The cancel receive function. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
392 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
393 void gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 394 |
395 /** | |
396 * Reads in data from a file transfer stream. | |
397 * | |
398 * @param xfer The file transfer. | |
399 * @param buffer The buffer that will be created to contain the data. | |
400 * | |
401 * @return The number of bytes read. | |
402 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
403 size_t gaim_xfer_read(GaimXfer *xfer, char **buffer); |
4514 | 404 |
405 /** | |
406 * Writes data to a file transfer stream. | |
407 * | |
408 * @param xfer The file transfer. | |
409 * @param buffer The buffer to read the data from. | |
410 * @param size The number of bytes to write. | |
411 * | |
412 * @return The number of bytes written. | |
413 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
414 size_t gaim_xfer_write(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 415 |
416 /** | |
417 * Starts a file transfer. | |
418 * | |
419 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
420 * file receive transfer. On send, @a fd must be specified, and | |
421 * @a ip and @a port are ignored. | |
422 * | |
423 * @param xfer The file transfer. | |
424 * @param fd The file descriptor for the socket. | |
425 * @param ip The IP address to connect to. | |
426 * @param port The port to connect to. | |
427 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
428 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514 | 429 unsigned int port); |
430 | |
431 /** | |
432 * Ends a file transfer. | |
433 * | |
434 * @param xfer The file transfer. | |
435 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
436 void gaim_xfer_end(GaimXfer *xfer); |
4514 | 437 |
438 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
439 * Cancels a file transfer on the local end. |
4514 | 440 * |
441 * @param xfer The file transfer. | |
442 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
443 void gaim_xfer_cancel_local(GaimXfer *xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
444 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
445 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
446 * Cancels a file transfer from the remote end. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
447 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
448 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
449 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
450 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
4514 | 451 |
452 /** | |
453 * Displays a file transfer-related error message. | |
454 * | |
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
455 * This is a wrapper around gaim_notify_error(), which automatically |
4514 | 456 * specifies a title ("File transfer to <i>user</i> aborted" or |
457 * "File Transfer from <i>user</i> aborted"). | |
458 * | |
459 * @param type The type of file transfer. | |
460 * @param who The user on the other end of the transfer. | |
461 * @param msg The message to display. | |
462 */ | |
463 void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); | |
464 | |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
465 /*@}*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
466 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
467 /**************************************************************************/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
468 /** @name File Transfer Subsystem API */ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
469 /**************************************************************************/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
470 /*@{*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
471 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
472 /** |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
473 * Sets the IP address of the local system in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
474 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
475 * @param ip The local IP address. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
476 */ |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
477 void gaim_xfers_set_local_ip(const char *ip); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
478 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
479 /** |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
480 * Returns the IP address of the local system set in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
481 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
482 * @return The local IP address set in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
483 */ |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
484 const char *gaim_xfers_get_local_ip(void); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
485 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
486 /** |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
487 * Returns the IP address of the local system. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
488 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
489 * @note The returned string is a pointer to a static buffer. If this |
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
490 * function is called twice, it may be important to make a copy |
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
491 * of the returned string. |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
492 * |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
493 * @return The local IP address. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
494 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
495 const char *gaim_xfers_get_local_system_ip(void); |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
496 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
497 /** |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
498 * Returns the IP address that should be used for the specified account. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
499 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
500 * First, the IP associated with @a account is tried, via a call to |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
501 * gaim_account_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
502 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
503 * If that IP is not set, the IP set in preferences is tried. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
504 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
505 * If that IP is not set, the system's local IP is tried, via a call to |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
506 * gaim_xfers_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
507 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
508 * @note The returned IP address must be g_free()'d when no longer |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
509 * in use. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
510 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
511 * @note The returned string is a pointer to a static buffer. If this |
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
512 * function is called twice, it may be important to make a copy |
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
513 * of the returned string. |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
514 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
515 * @return The local IP address to be used. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
516 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
517 const char *gaim_xfers_get_ip_for_account(const GaimAccount *account); |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
518 |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
519 /** |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
520 * Initializes the file transfer subsystem. |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
521 */ |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
522 void gaim_xfers_init(void); |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
523 |
4514 | 524 /*@}*/ |
525 | |
526 /**************************************************************************/ | |
527 /** @name UI Registration Functions */ | |
528 /**************************************************************************/ | |
529 /*@{*/ | |
530 | |
531 /** | |
532 * Sets the UI operations structure to be used in all gaim file transfers. | |
533 * | |
534 * @param fnc The function. | |
535 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
536 void gaim_set_xfer_ui_ops(GaimXferUiOps *ops); |
4514 | 537 |
538 /** | |
539 * Returns the UI operations structure to be used in all gaim file transfers. | |
540 * | |
541 * @return The UI operations structure. | |
542 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
543 GaimXferUiOps *gaim_get_xfer_ui_ops(void); |
4514 | 544 |
545 /*@}*/ | |
546 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
547 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
548 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
549 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
550 |
4514 | 551 #endif /* _GAIM_FT_H_ */ |