Mercurial > pidgin
annotate src/ft.h @ 8089:35db601609e3
[gaim-migrate @ 8788]
Gaim-Evolution Buddy List-Addressbook syncronocity by our very own
Chip X. Eightysix.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Tue, 13 Jan 2004 01:45:32 +0000 |
parents | fa6395637e2c |
children | 99a87d90b570 |
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. | |
4514 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #ifndef _GAIM_FT_H_ | |
26 #define _GAIM_FT_H_ | |
27 | |
28 /**************************************************************************/ | |
29 /** Data Structures */ | |
30 /**************************************************************************/ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
31 typedef struct _GaimXfer GaimXfer; |
4514 | 32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
33 #include "account.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
34 |
4514 | 35 /** |
36 * Types of file transfers. | |
37 */ | |
38 typedef enum | |
39 { | |
40 GAIM_XFER_UNKNOWN = 0, /**< Unknown file transfer type. */ | |
41 GAIM_XFER_SEND, /**< File sending. */ | |
42 GAIM_XFER_RECEIVE /**< File receiving. */ | |
43 | |
44 } GaimXferType; | |
45 | |
7805 | 46 /** |
47 * The different states of the xfer. | |
48 */ | |
7738 | 49 typedef enum |
50 { | |
7805 | 51 GAIM_XFER_STATUS_UNKNOWN = 0, /**< Unknown, the xfer may be null. */ |
52 GAIM_XFER_STATUS_NOT_STARTED, /**< It hasn't started yet. */ | |
53 GAIM_XFER_STATUS_STARTED, /**< gaim_xfer_start has been called. */ | |
54 GAIM_XFER_STATUS_DONE, /**< The xfer completed successfully. */ | |
55 GAIM_XFER_STATUS_CANCEL_LOCAL, /**< The xfer was canceled by us. */ | |
7887 | 56 GAIM_XFER_STATUS_CANCEL_REMOTE /**< The xfer was canceled by the other end, or we couldn't connect. */ |
7805 | 57 } GaimXferStatusType; |
7738 | 58 |
4514 | 59 /** |
60 * File transfer UI operations. | |
61 * | |
62 * 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
|
63 * GaimXferUiOps structure to the gaim_xfer. |
4514 | 64 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
65 typedef struct |
4514 | 66 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
67 void (*new_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
68 void (*destroy)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
69 void (*request_file)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
70 void (*ask_cancel)(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 | |
4605 | 91 char *filename; /**< The name sent over the network. */ |
92 char *local_filename; /**< The name on the local hard drive. */ | |
4514 | 93 size_t size; /**< The size of the file. */ |
94 | |
95 FILE *dest_fp; /**< The destination file pointer. */ | |
96 | |
97 char *local_ip; /**< The local IP address. */ | |
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); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
119 size_t (*read)(char **buffer, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
120 size_t (*write)(const char *buffer, size_t size, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
121 void (*ack)(GaimXfer *xfer, const char *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. | |
168 * Since the core keeps a ref on the xfer, only an erronous call to | |
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 /** | |
176 * Requests confirmation for a file transfer from the user. | |
177 * | |
178 * @param xfer The file transfer to request confirmation on. | |
179 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
180 void gaim_xfer_request(GaimXfer *xfer); |
4514 | 181 |
182 /** | |
183 * Called if the user accepts the file transfer request. | |
184 * | |
185 * @param xfer The file transfer. | |
186 * @param filename The filename. | |
187 */ | |
7805 | 188 void gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename); |
4514 | 189 |
190 /** | |
191 * Called if the user rejects the file transfer request. | |
192 * | |
193 * @param xfer The file transfer. | |
194 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
195 void gaim_xfer_request_denied(GaimXfer *xfer); |
4514 | 196 |
197 /** | |
198 * Returns the type of file transfer. | |
199 * | |
200 * @param xfer The file transfer. | |
201 * | |
202 * @return The type of the file transfer. | |
203 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
204 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
4514 | 205 |
206 /** | |
207 * Returns the account the file transfer is using. | |
208 * | |
209 * @param xfer The file transfer. | |
210 * | |
211 * @return The account. | |
212 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
213 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
4514 | 214 |
215 /** | |
7805 | 216 * Returns the status of the xfer. |
217 * | |
218 * @param xfer The file transfer. | |
219 * | |
220 * @return The status. | |
221 */ | |
222 GaimXferStatusType gaim_xfer_get_status(const GaimXfer *xfer); | |
223 | |
224 /** | |
7738 | 225 * Returns true if the file transfer was canceled. |
226 * | |
227 * @param xfer The file transfer. | |
228 * | |
229 * @return Whether or not the transfer was canceled. | |
230 */ | |
7805 | 231 gboolean gaim_xfer_is_canceled(const GaimXfer *xfer); |
7738 | 232 |
233 /** | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
234 * Returns the completed state for a 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 * @param xfer The file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
237 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
238 * @return The completed state. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
239 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
240 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
4539
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 /** |
4514 | 243 * Returns the name of the file being sent or received. |
244 * | |
245 * @param xfer The file transfer. | |
246 * | |
247 * @return The filename. | |
248 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
249 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
4514 | 250 |
251 /** | |
252 * Returns the file's destination filename, | |
253 * | |
254 * @param xfer The file transfer. | |
255 * | |
256 * @return The destination filename. | |
257 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
258 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
4514 | 259 |
260 /** | |
261 * Returns the number of bytes sent so far. | |
262 * | |
263 * @param xfer The file transfer. | |
264 * | |
265 * @return The number of bytes sent. | |
266 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
267 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
4514 | 268 |
269 /** | |
270 * Returns the number of bytes received so far. | |
271 * | |
272 * @param xfer The file transfer. | |
273 * | |
274 * @return The number of bytes received. | |
275 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
276 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
4514 | 277 |
278 /** | |
279 * Returns the size of the file being sent or received. | |
280 * | |
281 * @param xfer The file transfer. | |
7805 | 282 * |
4514 | 283 * @return The total size of the file. |
284 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
285 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
4514 | 286 |
287 /** | |
288 * Returns the current percentage of progress of the transfer. | |
289 * | |
290 * This is a number between 0 (0%) and 1 (100%). | |
291 * | |
292 * @param xfer The file transfer. | |
293 * | |
294 * @return The percentage complete. | |
295 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
296 double gaim_xfer_get_progress(const GaimXfer *xfer); |
4514 | 297 |
298 /** | |
299 * Returns the local IP address in the file transfer. | |
300 * | |
301 * @param xfer The file transfer. | |
302 * | |
303 * @return The IP address on this end. | |
304 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
305 const char *gaim_xfer_get_local_ip(const GaimXfer *xfer); |
4514 | 306 |
307 /** | |
308 * Returns the local port number in the file transfer. | |
309 * | |
310 * @param xfer The file transfer. | |
311 * | |
312 * @return The port number on this end. | |
313 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
314 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
4514 | 315 |
316 /** | |
317 * Returns the remote IP address in the file transfer. | |
318 * | |
319 * @param xfer The file transfer. | |
320 * | |
321 * @return The IP address on the other end. | |
322 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
323 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
4514 | 324 |
325 /** | |
326 * Returns the remote port number in the file transfer. | |
327 * | |
328 * @param xfer The file transfer. | |
329 * | |
330 * @return The port number on the other end. | |
331 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
332 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
4514 | 333 |
334 /** | |
4538 | 335 * Sets the completed state for the file transfer. |
336 * | |
337 * @param xfer The file transfer. | |
338 * @param completed The completed state. | |
339 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
340 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
4538 | 341 |
342 /** | |
4514 | 343 * Sets the filename for the file transfer. |
344 * | |
345 * @param xfer The file transfer. | |
346 * @param filename The filename. | |
347 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
348 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
4514 | 349 |
350 /** | |
4605 | 351 * Sets the local filename for the file transfer. |
4514 | 352 * |
353 * @param xfer The file transfer. | |
354 * @param filename The filename | |
355 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
356 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
4514 | 357 |
358 /** | |
359 * Sets the size of the file in a file transfer. | |
360 * | |
361 * @param xfer The file transfer. | |
362 * @param size The size of the file. | |
363 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
364 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
4514 | 365 |
366 /** | |
367 * Returns the UI operations structure for a file transfer. | |
368 * | |
369 * @param xfer The file transfer. | |
370 * | |
371 * @return The UI operations structure. | |
372 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
373 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
4514 | 374 |
375 /** | |
376 * Sets the read function for the file transfer. | |
377 * | |
378 * @param xfer The file transfer. | |
379 * @param fnc The read function. | |
380 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
381 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
382 size_t (*fnc)(char **, GaimXfer *)); |
4514 | 383 |
384 /** | |
385 * Sets the write function for the file transfer. | |
386 * | |
387 * @param xfer The file transfer. | |
388 * @param fnc The write function. | |
389 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
390 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
391 size_t (*fnc)(const char *, size_t, GaimXfer *)); |
4514 | 392 |
393 /** | |
394 * Sets the acknowledge function for the file transfer. | |
395 * | |
396 * @param xfer The file transfer. | |
397 * @param fnc The acknowledge function. | |
398 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
399 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
400 void (*fnc)(GaimXfer *, const char *, size_t)); |
4514 | 401 |
402 /** | |
7805 | 403 * Sets the function to be called if the request is denied. |
404 * | |
405 * @param xfer The file transfer. | |
406 * @param fnc The request denied prpl callback. | |
407 */ | |
408 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); | |
409 | |
410 /** | |
4514 | 411 * Sets the transfer initialization function for the file transfer. |
412 * | |
413 * This function is required, and must call gaim_xfer_start() with | |
414 * the necessary parameters. This will be called if the file transfer | |
415 * is accepted by the user. | |
416 * | |
417 * @param xfer The file transfer. | |
418 * @param fnc The transfer initialization function. | |
419 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
420 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 421 |
422 /** | |
423 * Sets the start transfer function for the file transfer. | |
424 * | |
425 * @param xfer The file transfer. | |
426 * @param fnc The start transfer function. | |
427 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
428 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 429 |
430 /** | |
431 * Sets the end transfer function for the file transfer. | |
432 * | |
433 * @param xfer The file transfer. | |
434 * @param fnc The end transfer function. | |
435 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
436 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 437 |
438 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
439 * Sets the cancel send function for the file transfer. |
4514 | 440 * |
441 * @param xfer The file transfer. | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
442 * @param fnc The cancel send function. |
4514 | 443 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
444 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
|
445 |
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 * Sets the cancel receive function for the file transfer. |
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 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
450 * @param fnc The cancel receive function. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
451 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
452 void gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 453 |
454 /** | |
455 * Reads in data from a file transfer stream. | |
456 * | |
457 * @param xfer The file transfer. | |
458 * @param buffer The buffer that will be created to contain the data. | |
459 * | |
460 * @return The number of bytes read. | |
461 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
462 size_t gaim_xfer_read(GaimXfer *xfer, char **buffer); |
4514 | 463 |
464 /** | |
465 * Writes data to a file transfer stream. | |
466 * | |
467 * @param xfer The file transfer. | |
468 * @param buffer The buffer to read the data from. | |
469 * @param size The number of bytes to write. | |
470 * | |
471 * @return The number of bytes written. | |
472 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
473 size_t gaim_xfer_write(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 474 |
475 /** | |
476 * Starts a file transfer. | |
477 * | |
478 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
479 * file receive transfer. On send, @a fd must be specified, and | |
480 * @a ip and @a port are ignored. | |
481 * | |
482 * @param xfer The file transfer. | |
483 * @param fd The file descriptor for the socket. | |
484 * @param ip The IP address to connect to. | |
485 * @param port The port to connect to. | |
486 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
487 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514 | 488 unsigned int port); |
489 | |
490 /** | |
491 * Ends a file transfer. | |
492 * | |
493 * @param xfer The file transfer. | |
494 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
495 void gaim_xfer_end(GaimXfer *xfer); |
4514 | 496 |
497 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
498 * Cancels a file transfer on the local end. |
4514 | 499 * |
500 * @param xfer The file transfer. | |
501 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
502 void gaim_xfer_cancel_local(GaimXfer *xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
503 |
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 * Cancels a file transfer from the remote end. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
506 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
507 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
508 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
509 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
4514 | 510 |
511 /** | |
512 * Displays a file transfer-related error message. | |
513 * | |
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
514 * This is a wrapper around gaim_notify_error(), which automatically |
4514 | 515 * specifies a title ("File transfer to <i>user</i> aborted" or |
516 * "File Transfer from <i>user</i> aborted"). | |
517 * | |
518 * @param type The type of file transfer. | |
519 * @param who The user on the other end of the transfer. | |
520 * @param msg The message to display. | |
521 */ | |
522 void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); | |
523 | |
6263
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 |
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 /** @name File Transfer Subsystem API */ |
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 /*@{*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
530 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
531 /** |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
532 * Sets the IP address of the local system in preferences. |
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 * @param ip The local IP address. |
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 void gaim_xfers_set_local_ip(const char *ip); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
537 |
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 * Returns the IP address of the local system 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 * @return The local IP address set in preferences. |
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 const char *gaim_xfers_get_local_ip(void); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
544 |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
545 /** |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
546 * Returns the IP address of the local system. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
547 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
548 * @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
|
549 * 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
|
550 * of the returned string. |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
551 * |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
552 * @return The local IP address. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
553 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
554 const char *gaim_xfers_get_local_system_ip(void); |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
555 |
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 * 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
|
558 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
559 * 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
|
560 * gaim_account_get_local_ip(). |
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 IP set in preferences is tried. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
563 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
564 * 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
|
565 * gaim_xfers_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
566 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
567 * @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
|
568 * in use. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
569 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
570 * @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
|
571 * 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
|
572 * of the returned string. |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
573 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
574 * @return The local IP address to be used. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
575 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
576 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
|
577 |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
578 /** |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
579 * Initializes the file transfer subsystem. |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
580 */ |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
581 void gaim_xfers_init(void); |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
582 |
4514 | 583 /*@}*/ |
584 | |
585 /**************************************************************************/ | |
586 /** @name UI Registration Functions */ | |
587 /**************************************************************************/ | |
588 /*@{*/ | |
589 | |
590 /** | |
591 * Sets the UI operations structure to be used in all gaim file transfers. | |
592 * | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6269
diff
changeset
|
593 * @param ops The UI operations structure. |
4514 | 594 */ |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
595 void gaim_xfers_set_ui_ops(GaimXferUiOps *ops); |
4514 | 596 |
597 /** | |
598 * Returns the UI operations structure to be used in all gaim file transfers. | |
599 * | |
600 * @return The UI operations structure. | |
601 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
602 GaimXferUiOps *gaim_xfers_get_ui_ops(void); |
4514 | 603 |
604 /*@}*/ | |
605 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
606 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
607 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
608 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
609 |
4514 | 610 #endif /* _GAIM_FT_H_ */ |