Mercurial > pidgin.yaz
annotate src/ft.h @ 7738:b14442b31a9b
[gaim-migrate @ 8383]
This patch from Tim R. (I'll remember your last name next time), snazzes
up the file transfer dialog a bit. I also went in and hacked on
gtkcellrenderer a bit, so that if you expand the column, the renderer will
grow.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 04 Dec 2003 05:58:26 +0000 |
parents | feb3d21a7794 |
children | 5f0bb52c0609 |
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 | |
7738 | 44 typedef enum |
45 { | |
46 GAIM_XFER_CANCEL_NOT = 0, | |
47 GAIM_XFER_CANCEL_LOCAL, | |
48 GAIM_XFER_CANCEL_REMOTE | |
49 } GaimXferCancelType; | |
50 | |
4514 | 51 /** |
52 * File transfer UI operations. | |
53 * | |
54 * 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
|
55 * GaimXferUiOps structure to the gaim_xfer. |
4514 | 56 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
57 typedef struct |
4514 | 58 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
59 void (*new_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
60 void (*destroy)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
61 void (*request_file)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
62 void (*ask_cancel)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
63 void (*add_xfer)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
64 void (*update_progress)(GaimXfer *xfer, double percent); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
65 void (*cancel_local)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
66 void (*cancel_remote)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
67 |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
68 } GaimXferUiOps; |
4514 | 69 |
70 /** | |
71 * A core representation of a file transfer. | |
72 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
73 struct _GaimXfer |
4514 | 74 { |
75 GaimXferType type; /**< The type of transfer. */ | |
76 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
77 GaimAccount *account; /**< The account. */ |
4514 | 78 |
79 char *who; /**< The person on the other end of the | |
80 transfer. */ | |
81 | |
4605 | 82 char *filename; /**< The name sent over the network. */ |
83 char *local_filename; /**< The name on the local hard drive. */ | |
4514 | 84 size_t size; /**< The size of the file. */ |
85 | |
86 FILE *dest_fp; /**< The destination file pointer. */ | |
87 | |
88 char *local_ip; /**< The local IP address. */ | |
89 char *remote_ip; /**< The remote IP address. */ | |
90 int local_port; /**< The local port. */ | |
91 int remote_port; /**< The remote port. */ | |
92 | |
93 int fd; /**< The socket file descriptor. */ | |
94 int watcher; /**< Watcher. */ | |
95 | |
96 size_t bytes_sent; /**< The number of bytes sent. */ | |
97 size_t bytes_remaining; /**< The number of bytes remaining. */ | |
98 | |
7738 | 99 GaimXferCancelType canceled; /**< File Transfer is canceled. */ |
4538 | 100 gboolean completed; /**< File Transfer is completed. */ |
101 | |
4514 | 102 /* I/O operations. */ |
103 struct | |
104 { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
105 void (*init)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
106 void (*start)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
107 void (*end)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
108 void (*cancel_send)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
109 void (*cancel_recv)(GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
110 size_t (*read)(char **buffer, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
111 size_t (*write)(const char *buffer, size_t size, GaimXfer *xfer); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
112 void (*ack)(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 113 |
114 } ops; | |
115 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
116 GaimXferUiOps *ui_ops; /**< UI-specific operations. */ |
4514 | 117 void *ui_data; /**< UI-specific data. */ |
118 | |
119 void *data; /**< prpl-specific data. */ | |
120 }; | |
121 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
122 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
123 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
124 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
125 |
4514 | 126 /**************************************************************************/ |
127 /** @name File Transfer API */ | |
128 /**************************************************************************/ | |
129 /*@{*/ | |
130 | |
131 /** | |
132 * Creates a new file transfer handle. | |
133 * | |
134 * @param account The account sending or receiving the file. | |
135 * @param type The type of file transfer. | |
136 * @param who The name of the remote user. | |
137 * | |
138 * @return A file transfer handle. | |
139 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
140 GaimXfer *gaim_xfer_new(GaimAccount *account, |
4514 | 141 GaimXferType type, const char *who); |
142 | |
143 /** | |
144 * Destroys a file transfer handle. | |
145 * | |
146 * @param xfer The file transfer to destroy. | |
147 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
148 void gaim_xfer_destroy(GaimXfer *xfer); |
4514 | 149 |
150 /** | |
151 * Requests confirmation for a file transfer from the user. | |
152 * | |
153 * @param xfer The file transfer to request confirmation on. | |
154 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
155 void gaim_xfer_request(GaimXfer *xfer); |
4514 | 156 |
157 /** | |
158 * Called if the user accepts the file transfer request. | |
159 * | |
160 * @param xfer The file transfer. | |
161 * @param filename The filename. | |
162 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
163 void gaim_xfer_request_accepted(GaimXfer *xfer, char *filename); |
4514 | 164 |
165 /** | |
166 * Called if the user rejects the file transfer request. | |
167 * | |
168 * @param xfer The file transfer. | |
169 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
170 void gaim_xfer_request_denied(GaimXfer *xfer); |
4514 | 171 |
172 /** | |
173 * Returns the type of file transfer. | |
174 * | |
175 * @param xfer The file transfer. | |
176 * | |
177 * @return The type of the file transfer. | |
178 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
179 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
4514 | 180 |
181 /** | |
182 * Returns the account the file transfer is using. | |
183 * | |
184 * @param xfer The file transfer. | |
185 * | |
186 * @return The account. | |
187 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
188 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
4514 | 189 |
190 /** | |
7738 | 191 * Returns true if the file transfer was canceled. |
192 * | |
193 * @param xfer The file transfer. | |
194 * | |
195 * @return Whether or not the transfer was canceled. | |
196 */ | |
197 GaimXferCancelType gaim_xfer_is_canceled(const GaimXfer *xfer); | |
198 | |
199 /** | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
200 * Returns the completed state for a file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
201 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
202 * @param xfer The file transfer. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
203 * |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
204 * @return The completed state. |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
205 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
206 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
207 |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
208 /** |
4514 | 209 * Returns the name of the file being sent or received. |
210 * | |
211 * @param xfer The file transfer. | |
212 * | |
213 * @return The filename. | |
214 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
215 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
4514 | 216 |
217 /** | |
218 * Returns the file's destination filename, | |
219 * | |
220 * @param xfer The file transfer. | |
221 * | |
222 * @return The destination filename. | |
223 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
224 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
4514 | 225 |
226 /** | |
227 * Returns the number of bytes sent so far. | |
228 * | |
229 * @param xfer The file transfer. | |
230 * | |
231 * @return The number of bytes sent. | |
232 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
233 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
4514 | 234 |
235 /** | |
236 * Returns the number of bytes received so far. | |
237 * | |
238 * @param xfer The file transfer. | |
239 * | |
240 * @return The number of bytes received. | |
241 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
242 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
4514 | 243 |
244 /** | |
245 * Returns the size of the file being sent or received. | |
246 * | |
247 * @param xfer The file transfer. | |
248 * | |
249 * @return The total size of the file. | |
250 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
251 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
4514 | 252 |
253 /** | |
254 * Returns the current percentage of progress of the transfer. | |
255 * | |
256 * This is a number between 0 (0%) and 1 (100%). | |
257 * | |
258 * @param xfer The file transfer. | |
259 * | |
260 * @return The percentage complete. | |
261 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
262 double gaim_xfer_get_progress(const GaimXfer *xfer); |
4514 | 263 |
264 /** | |
265 * Returns the local IP address in the file transfer. | |
266 * | |
267 * @param xfer The file transfer. | |
268 * | |
269 * @return The IP address on this end. | |
270 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
271 const char *gaim_xfer_get_local_ip(const GaimXfer *xfer); |
4514 | 272 |
273 /** | |
274 * Returns the local port number in the file transfer. | |
275 * | |
276 * @param xfer The file transfer. | |
277 * | |
278 * @return The port number on this end. | |
279 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
280 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
4514 | 281 |
282 /** | |
283 * Returns the remote IP address in the file transfer. | |
284 * | |
285 * @param xfer The file transfer. | |
286 * | |
287 * @return The IP address on the other end. | |
288 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
289 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
4514 | 290 |
291 /** | |
292 * Returns the remote port number in the file transfer. | |
293 * | |
294 * @param xfer The file transfer. | |
295 * | |
296 * @return The port number on the other end. | |
297 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
298 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
4514 | 299 |
300 /** | |
4538 | 301 * Sets the completed state for the file transfer. |
302 * | |
303 * @param xfer The file transfer. | |
304 * @param completed The completed state. | |
305 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
306 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
4538 | 307 |
308 /** | |
4514 | 309 * Sets the filename for the file transfer. |
310 * | |
311 * @param xfer The file transfer. | |
312 * @param filename The filename. | |
313 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
314 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
4514 | 315 |
316 /** | |
4605 | 317 * Sets the local filename for the file transfer. |
4514 | 318 * |
319 * @param xfer The file transfer. | |
320 * @param filename The filename | |
321 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
322 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
4514 | 323 |
324 /** | |
325 * Sets the size of the file in a file transfer. | |
326 * | |
327 * @param xfer The file transfer. | |
328 * @param size The size of the file. | |
329 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
330 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
4514 | 331 |
332 /** | |
333 * Returns the UI operations structure for a file transfer. | |
334 * | |
335 * @param xfer The file transfer. | |
336 * | |
337 * @return The UI operations structure. | |
338 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
339 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
4514 | 340 |
341 /** | |
342 * Sets the read function for the file transfer. | |
343 * | |
344 * @param xfer The file transfer. | |
345 * @param fnc The read function. | |
346 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
347 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
348 size_t (*fnc)(char **, GaimXfer *)); |
4514 | 349 |
350 /** | |
351 * Sets the write function for the file transfer. | |
352 * | |
353 * @param xfer The file transfer. | |
354 * @param fnc The write function. | |
355 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
356 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
357 size_t (*fnc)(const char *, size_t, GaimXfer *)); |
4514 | 358 |
359 /** | |
360 * Sets the acknowledge function for the file transfer. | |
361 * | |
362 * @param xfer The file transfer. | |
363 * @param fnc The acknowledge function. | |
364 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
365 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
366 void (*fnc)(GaimXfer *, const char *, size_t)); |
4514 | 367 |
368 /** | |
369 * Sets the transfer initialization function for the file transfer. | |
370 * | |
371 * This function is required, and must call gaim_xfer_start() with | |
372 * the necessary parameters. This will be called if the file transfer | |
373 * is accepted by the user. | |
374 * | |
375 * @param xfer The file transfer. | |
376 * @param fnc The transfer initialization function. | |
377 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
378 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 379 |
380 /** | |
381 * Sets the start transfer function for the file transfer. | |
382 * | |
383 * @param xfer The file transfer. | |
384 * @param fnc The start transfer function. | |
385 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
386 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 387 |
388 /** | |
389 * Sets the end transfer function for the file transfer. | |
390 * | |
391 * @param xfer The file transfer. | |
392 * @param fnc The end transfer function. | |
393 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
394 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 395 |
396 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
397 * Sets the cancel send function for the file transfer. |
4514 | 398 * |
399 * @param xfer The file transfer. | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
400 * @param fnc The cancel send function. |
4514 | 401 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
402 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
|
403 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
404 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
405 * Sets the cancel receive function for the file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
406 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
407 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
408 * @param fnc The cancel receive function. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
409 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
410 void gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
4514 | 411 |
412 /** | |
413 * Reads in data from a file transfer stream. | |
414 * | |
415 * @param xfer The file transfer. | |
416 * @param buffer The buffer that will be created to contain the data. | |
417 * | |
418 * @return The number of bytes read. | |
419 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
420 size_t gaim_xfer_read(GaimXfer *xfer, char **buffer); |
4514 | 421 |
422 /** | |
423 * Writes data to a file transfer stream. | |
424 * | |
425 * @param xfer The file transfer. | |
426 * @param buffer The buffer to read the data from. | |
427 * @param size The number of bytes to write. | |
428 * | |
429 * @return The number of bytes written. | |
430 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
431 size_t gaim_xfer_write(GaimXfer *xfer, const char *buffer, size_t size); |
4514 | 432 |
433 /** | |
434 * Starts a file transfer. | |
435 * | |
436 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
437 * file receive transfer. On send, @a fd must be specified, and | |
438 * @a ip and @a port are ignored. | |
439 * | |
440 * @param xfer The file transfer. | |
441 * @param fd The file descriptor for the socket. | |
442 * @param ip The IP address to connect to. | |
443 * @param port The port to connect to. | |
444 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
445 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514 | 446 unsigned int port); |
447 | |
448 /** | |
449 * Ends a file transfer. | |
450 * | |
451 * @param xfer The file transfer. | |
452 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
453 void gaim_xfer_end(GaimXfer *xfer); |
4514 | 454 |
455 /** | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
456 * Cancels a file transfer on the local end. |
4514 | 457 * |
458 * @param xfer The file transfer. | |
459 */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
460 void gaim_xfer_cancel_local(GaimXfer *xfer); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
461 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
462 /** |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
463 * Cancels a file transfer from the remote end. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
464 * |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
465 * @param xfer The file transfer. |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
466 */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
467 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
4514 | 468 |
469 /** | |
470 * Displays a file transfer-related error message. | |
471 * | |
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
472 * This is a wrapper around gaim_notify_error(), which automatically |
4514 | 473 * specifies a title ("File transfer to <i>user</i> aborted" or |
474 * "File Transfer from <i>user</i> aborted"). | |
475 * | |
476 * @param type The type of file transfer. | |
477 * @param who The user on the other end of the transfer. | |
478 * @param msg The message to display. | |
479 */ | |
480 void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); | |
481 | |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
482 /*@}*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
483 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
484 /**************************************************************************/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
485 /** @name File Transfer Subsystem API */ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
486 /**************************************************************************/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
487 /*@{*/ |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
488 |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
489 /** |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
490 * Sets the IP address of the local system in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
491 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
492 * @param ip The local IP address. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
493 */ |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
494 void gaim_xfers_set_local_ip(const char *ip); |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
495 |
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 * Returns the IP address of the local system set in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
498 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
499 * @return The local IP address set in preferences. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
500 */ |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
501 const char *gaim_xfers_get_local_ip(void); |
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 /** |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
504 * Returns the IP address of the local system. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
505 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
506 * @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
|
507 * 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
|
508 * of the returned string. |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
509 * |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
510 * @return The local IP address. |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
511 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
512 const char *gaim_xfers_get_local_system_ip(void); |
6268
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
513 |
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 * 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
|
516 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
517 * 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
|
518 * gaim_account_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
519 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
520 * 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
|
521 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
522 * 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
|
523 * gaim_xfers_get_local_ip(). |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
524 * |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
525 * @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
|
526 * in use. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
527 * |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
528 * @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
|
529 * 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
|
530 * of the returned string. |
6268
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 * @return The local IP address to be used. |
084e1f6610a8
[gaim-migrate @ 6765]
Christian Hammond <chipx86@chipx86.com>
parents:
6263
diff
changeset
|
533 */ |
6269
0a902bd3e170
[gaim-migrate @ 6766]
Christian Hammond <chipx86@chipx86.com>
parents:
6268
diff
changeset
|
534 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
|
535 |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
536 /** |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
537 * Initializes the file transfer subsystem. |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
538 */ |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
539 void gaim_xfers_init(void); |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
540 |
4514 | 541 /*@}*/ |
542 | |
543 /**************************************************************************/ | |
544 /** @name UI Registration Functions */ | |
545 /**************************************************************************/ | |
546 /*@{*/ | |
547 | |
548 /** | |
549 * Sets the UI operations structure to be used in all gaim file transfers. | |
550 * | |
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6269
diff
changeset
|
551 * @param ops The UI operations structure. |
4514 | 552 */ |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
553 void gaim_xfers_set_ui_ops(GaimXferUiOps *ops); |
4514 | 554 |
555 /** | |
556 * Returns the UI operations structure to be used in all gaim file transfers. | |
557 * | |
558 * @return The UI operations structure. | |
559 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
560 GaimXferUiOps *gaim_xfers_get_ui_ops(void); |
4514 | 561 |
562 /*@}*/ | |
563 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
564 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
565 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
566 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
567 |
4514 | 568 #endif /* _GAIM_FT_H_ */ |