Mercurial > pidgin.yaz
annotate src/ft.h @ 7965:b02b30247e7a
[gaim-migrate @ 8642]
oops
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 31 Dec 2003 08:22:55 +0000 |
parents | 4b43a3f9de73 |
children | fa6395637e2c |
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 * | |
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 | |
7805 | 44 /** |
45 * The different states of the xfer. | |
46 */ | |
7738 | 47 typedef enum |
48 { | |
7805 | 49 GAIM_XFER_STATUS_UNKNOWN = 0, /**< Unknown, the xfer may be null. */ |
50 GAIM_XFER_STATUS_NOT_STARTED, /**< It hasn't started yet. */ | |
51 GAIM_XFER_STATUS_STARTED, /**< gaim_xfer_start has been called. */ | |
52 GAIM_XFER_STATUS_DONE, /**< The xfer completed successfully. */ | |
53 GAIM_XFER_STATUS_CANCEL_LOCAL, /**< The xfer was canceled by us. */ | |
7887 | 54 GAIM_XFER_STATUS_CANCEL_REMOTE /**< The xfer was canceled by the other end, or we couldn't connect. */ |
7805 | 55 } GaimXferStatusType; |
7738 | 56 |
4514 | 57 /** |
58 * File transfer UI operations. | |
59 * | |
60 * 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
|
61 * GaimXferUiOps structure to the gaim_xfer. |
4514 | 62 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
63 typedef struct |
4514 | 64 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
65 void (*new_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
66 void (*destroy)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
67 void (*request_file)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
68 void (*ask_cancel)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
69 void (*add_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
70 void (*update_progress)(GaimXfer *xfer, double percent); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
71 void (*cancel_local)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
72 void (*cancel_remote)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
73 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
74 } GaimXferUiOps; |
4514 | 75 |
76 /** | |
77 * A core representation of a file transfer. | |
78 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
79 struct _GaimXfer |
4514 | 80 { |
7887 | 81 guint ref; /**< The reference count. */ |
4514 | 82 GaimXferType type; /**< The type of transfer. */ |
83 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
84 GaimAccount *account; /**< The account. */ |
4514 | 85 |
86 char *who; /**< The person on the other end of the | |
87 transfer. */ | |
88 | |
4605 | 89 char *filename; /**< The name sent over the network. */ |
90 char *local_filename; /**< The name on the local hard drive. */ | |
4514 | 91 size_t size; /**< The size of the file. */ |
92 | |
93 FILE *dest_fp; /**< The destination file pointer. */ | |
94 | |
95 char *local_ip; /**< The local IP address. */ | |
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); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
117 size_t (*read)(char **buffer, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
118 size_t (*write)(const char *buffer, size_t size, GaimXfer *xfer); |
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. | |
166 * Since the core keeps a ref on the xfer, only an erronous call to | |
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 /** | |
174 * Requests confirmation for a file transfer from the user. | |
175 * | |
176 * @param xfer The file transfer to request confirmation on. | |
177 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
178 void gaim_xfer_request(GaimXfer *xfer); |
4514 | 179 |
180 /** | |
181 * Called if the user accepts the file transfer request. | |
182 * | |
183 * @param xfer The file transfer. | |
184 * @param filename The filename. | |
185 */ | |
7805 | 186 void gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename); |
4514 | 187 |
188 /** | |
189 * Called if the user rejects the file transfer request. | |
190 * | |
191 * @param xfer The file transfer. | |
192 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
193 void gaim_xfer_request_denied(GaimXfer *xfer); |
4514 | 194 |
195 /** | |
196 * Returns the type of file transfer. | |
197 * | |
198 * @param xfer The file transfer. | |
199 * | |
200 * @return The type of the file transfer. | |
201 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
202 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
4514 | 203 |
204 /** | |
205 * Returns the account the file transfer is using. | |
206 * | |
207 * @param xfer The file transfer. | |
208 * | |
209 * @return The account. | |
210 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
211 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
4514 | 212 |
213 /** | |
7805 | 214 * Returns the status of the xfer. |
215 * | |
216 * @param xfer The file transfer. | |
217 * | |
218 * @return The status. | |
219 */ | |
220 GaimXferStatusType gaim_xfer_get_status(const GaimXfer *xfer); | |
221 | |
222 /** | |
7738 | 223 * Returns true if the file transfer was canceled. |
224 * | |
225 * @param xfer The file transfer. | |
226 * | |
227 * @return Whether or not the transfer was canceled. | |
228 */ | |
7805 | 229 gboolean gaim_xfer_is_canceled(const GaimXfer *xfer); |
7738 | 230 |
231 /** | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
232 * Returns the completed state for a file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
233 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
234 * @param xfer The file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
235 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
236 * @return The completed state. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
237 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
238 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
4539
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 /** |
4514 | 241 * Returns the name of the file being sent or received. |
242 * | |
243 * @param xfer The file transfer. | |
244 * | |
245 * @return The filename. | |
246 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
247 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
4514 | 248 |
249 /** | |
250 * Returns the file's destination filename, | |
251 * | |
252 * @param xfer The file transfer. | |
253 * | |
254 * @return The destination filename. | |
255 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
256 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
4514 | 257 |
258 /** | |
259 * Returns the number of bytes sent so far. | |
260 * | |
261 * @param xfer The file transfer. | |
262 * | |
263 * @return The number of bytes sent. | |
264 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
265 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
4514 | 266 |
267 /** | |
268 * Returns the number of bytes received so far. | |
269 * | |
270 * @param xfer The file transfer. | |
271 * | |
272 * @return The number of bytes received. | |
273 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
274 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
4514 | 275 |
276 /** | |
277 * Returns the size of the file being sent or received. | |
278 * | |
279 * @param xfer The file transfer. | |
7805 | 280 * |
4514 | 281 * @return The total size of the file. |
282 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
283 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
4514 | 284 |
285 /** | |
286 * Returns the current percentage of progress of the transfer. | |
287 * | |
288 * This is a number between 0 (0%) and 1 (100%). | |
289 * | |
290 * @param xfer The file transfer. | |
291 * | |
292 * @return The percentage complete. | |
293 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
294 double gaim_xfer_get_progress(const GaimXfer *xfer); |
4514 | 295 |
296 /** | |
297 * Returns the local IP address in the file transfer. | |
298 * | |
299 * @param xfer The file transfer. | |
300 * | |
301 * @return The IP address on this end. | |
302 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
303 const char *gaim_xfer_get_local_ip(const GaimXfer *xfer); |
4514 | 304 |
305 /** | |
306 * Returns the local port number in the file transfer. | |
307 * | |
308 * @param xfer The file transfer. | |
309 * | |
310 * @return The port number on this end. | |
311 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
312 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
4514 | 313 |
314 /** | |
315 * Returns the remote IP address in the file transfer. | |
316 * | |
317 * @param xfer The file transfer. | |
318 * | |
319 * @return The IP address on the other end. | |
320 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
321 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
4514 | 322 |
323 /** | |
324 * Returns the remote port number in the file transfer. | |
325 * | |
326 * @param xfer The file transfer. | |
327 * | |
328 * @return The port number on the other end. | |
329 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
330 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
4514 | 331 |
332 /** | |
4538 | 333 * Sets the completed state for the file transfer. |
334 * | |
335 * @param xfer The file transfer. | |
336 * @param completed The completed state. | |
337 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
338 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
4538 | 339 |
340 /** | |
4514 | 341 * Sets the filename for the file transfer. |
342 * | |
343 * @param xfer The file transfer. | |
344 * @param filename The filename. | |
345 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
346 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
4514 | 347 |
348 /** | |
4605 | 349 * Sets the local filename for the file transfer. |
4514 | 350 * |
351 * @param xfer The file transfer. | |
352 * @param filename The filename | |
353 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
354 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
4514 | 355 |
356 /** | |
357 * Sets the size of the file in a file transfer. | |
358 * | |
359 * @param xfer The file transfer. | |
360 * @param size The size of the file. | |
361 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
362 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
4514 | 363 |
364 /** | |
365 * Returns the UI operations structure for a file transfer. | |
366 * | |
367 * @param xfer The file transfer. | |
368 * | |
369 * @return The UI operations structure. | |
370 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
371 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
4514 | 372 |
373 /** | |
374 * Sets the read function for the file transfer. | |
375 * | |
376 * @param xfer The file transfer. | |
377 * @param fnc The read function. | |
378 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
379 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
380 size_t (*fnc)(char **, GaimXfer *)); |
4514 | 381 |
382 /** | |
383 * Sets the write function for the file transfer. | |
384 * | |
385 * @param xfer The file transfer. | |
386 * @param fnc The write function. | |
387 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
388 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
389 size_t (*fnc)(const char *, size_t, GaimXfer *)); |
4514 | 390 |
391 /** | |
392 * Sets the acknowledge function for the file transfer. | |
393 * | |
394 * @param xfer The file transfer. | |
395 * @param fnc The acknowledge function. | |
396 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
397 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
398 void (*fnc)(GaimXfer *, const char *, size_t)); |
4514 | 399 |
400 /** | |
7805 | 401 * Sets the function to be called if the request is denied. |
402 * | |
403 * @param xfer The file transfer. | |
404 * @param fnc The request denied prpl callback. | |
405 */ | |
406 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); | |
407 | |
408 /** | |
4514 | 409 * Sets the transfer initialization function for the file transfer. |
410 * | |
411 * This function is required, and must call gaim_xfer_start() with | |
412 * the necessary parameters. This will be called if the file transfer | |
413 * is accepted by the user. | |
414 * | |
415 * @param xfer The file transfer. | |
416 * @param fnc The transfer initialization function. | |
417 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
418 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 419 |
420 /** | |
421 * Sets the start transfer function for the file transfer. | |
422 * | |
423 * @param xfer The file transfer. | |
424 * @param fnc The start transfer function. | |
425 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
426 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 427 |
428 /** | |
429 * Sets the end transfer function for the file transfer. | |
430 * | |
431 * @param xfer The file transfer. | |
432 * @param fnc The end transfer function. | |
433 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
434 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 435 |
436 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
437 * Sets the cancel send function for the file transfer. |
4514 | 438 * |
439 * @param xfer The file transfer. | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
440 * @param fnc The cancel send function. |
4514 | 441 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
442 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
|
443 |
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 * Sets the cancel receive function for the file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
446 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
447 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
448 * @param fnc The cancel receive function. |
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_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 451 |
452 /** | |
453 * Reads in data from a file transfer stream. | |
454 * | |
455 * @param xfer The file transfer. | |
456 * @param buffer The buffer that will be created to contain the data. | |
457 * | |
458 * @return The number of bytes read. | |
459 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
460 size_t gaim_xfer_read(GaimXfer *xfer, char **buffer); |
4514 | 461 |
462 /** | |
463 * Writes data to a file transfer stream. | |
464 * | |
465 * @param xfer The file transfer. | |
466 * @param buffer The buffer to read the data from. | |
467 * @param size The number of bytes to write. | |
468 * | |
469 * @return The number of bytes written. | |
470 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
471 size_t gaim_xfer_write(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 472 |
473 /** | |
474 * Starts a file transfer. | |
475 * | |
476 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
477 * file receive transfer. On send, @a fd must be specified, and | |
478 * @a ip and @a port are ignored. | |
479 * | |
480 * @param xfer The file transfer. | |
481 * @param fd The file descriptor for the socket. | |
482 * @param ip The IP address to connect to. | |
483 * @param port The port to connect to. | |
484 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
485 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514 | 486 unsigned int port); |
487 | |
488 /** | |
489 * Ends a file transfer. | |
490 * | |
491 * @param xfer The file transfer. | |
492 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
493 void gaim_xfer_end(GaimXfer *xfer); |
4514 | 494 |
495 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
496 * Cancels a file transfer on the local end. |
4514 | 497 * |
498 * @param xfer The file transfer. | |
499 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
500 void gaim_xfer_cancel_local(GaimXfer *xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
501 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
502 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
503 * Cancels a file transfer from the remote end. |
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 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
506 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
507 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
4514 | 508 |
509 /** | |
510 * Displays a file transfer-related error message. | |
511 * | |
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
512 * This is a wrapper around gaim_notify_error(), which automatically |
4514 | 513 * specifies a title ("File transfer to <i>user</i> aborted" or |
514 * "File Transfer from <i>user</i> aborted"). | |
515 * | |
516 * @param type The type of file transfer. | |
517 * @param who The user on the other end of the transfer. | |
518 * @param msg The message to display. | |
519 */ | |
520 void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); | |
521 | |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
522 /*@}*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
523 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
524 /**************************************************************************/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
525 /** @name File Transfer Subsystem API */ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
526 /**************************************************************************/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
527 /*@{*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
528 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
529 /** |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
530 * Sets the IP address of the local system in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
531 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
532 * @param ip The local IP address. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
533 */ |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
534 void gaim_xfers_set_local_ip(const char *ip); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
535 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
536 /** |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
537 * Returns the IP address of the local system set in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
538 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
539 * @return The local IP address set in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
540 */ |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
541 const char *gaim_xfers_get_local_ip(void); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
542 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
543 /** |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
544 * Returns the IP address of the local system. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
545 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
546 * @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
|
547 * 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
|
548 * of the returned string. |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
549 * |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
550 * @return The local IP address. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
551 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
552 const char *gaim_xfers_get_local_system_ip(void); |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
553 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
554 /** |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
555 * 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
|
556 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
557 * 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
|
558 * gaim_account_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
559 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
560 * 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
|
561 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
562 * 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
|
563 * gaim_xfers_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
564 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
565 * @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
|
566 * in use. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
567 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
568 * @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
|
569 * 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
|
570 * of the returned string. |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
571 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
572 * @return The local IP address to be used. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
573 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
574 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
|
575 |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
576 /** |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
577 * Initializes the file transfer subsystem. |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
578 */ |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
579 void gaim_xfers_init(void); |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
580 |
4514 | 581 /*@}*/ |
582 | |
583 /**************************************************************************/ | |
584 /** @name UI Registration Functions */ | |
585 /**************************************************************************/ | |
586 /*@{*/ | |
587 | |
588 /** | |
589 * Sets the UI operations structure to be used in all gaim file transfers. | |
590 * | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6269
diff
changeset
|
591 * @param ops The UI operations structure. |
4514 | 592 */ |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
593 void gaim_xfers_set_ui_ops(GaimXferUiOps *ops); |
4514 | 594 |
595 /** | |
596 * Returns the UI operations structure to be used in all gaim file transfers. | |
597 * | |
598 * @return The UI operations structure. | |
599 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
600 GaimXferUiOps *gaim_xfers_get_ui_ops(void); |
4514 | 601 |
602 /*@}*/ | |
603 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
604 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
605 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
606 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
607 |
4514 | 608 #endif /* _GAIM_FT_H_ */ |