Sat, 12 Jul 2003 04:31:30 +0000
[gaim-migrate @ 6557]
height is spelled with an e.
| 4514 | 1 | /** |
| 2 | * @file ft.h The file transfer interface | |
|
5034
077678f7b048
[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 | /**************************************************************************/ | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
29 | struct gaim_xfer; |
| 4514 | 30 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
31 | #include "account.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
32 | |
| 4514 | 33 | /** |
| 34 | * Types of file transfers. | |
| 35 | */ | |
| 36 | typedef enum | |
| 37 | { | |
| 38 | GAIM_XFER_UNKNOWN = 0, /**< Unknown file transfer type. */ | |
| 39 | GAIM_XFER_SEND, /**< File sending. */ | |
| 40 | GAIM_XFER_RECEIVE /**< File receiving. */ | |
| 41 | ||
| 42 | } GaimXferType; | |
| 43 | ||
| 44 | /** | |
| 45 | * File transfer UI operations. | |
| 46 | * | |
| 47 | * Any UI representing a file transfer must assign a filled-out | |
| 48 | * gaim_xfer_ui_ops structure to the gaim_xfer. | |
| 49 | */ | |
| 50 | struct gaim_xfer_ui_ops | |
| 51 | { | |
|
5169
091d71968b59
[gaim-migrate @ 5533]
Mark Doliner <markdoliner@pidgin.im>
parents:
5034
diff
changeset
|
52 | void (*new)(struct gaim_xfer *xfer); |
| 4514 | 53 | void (*destroy)(struct gaim_xfer *xfer); |
| 54 | void (*request_file)(struct gaim_xfer *xfer); | |
| 55 | void (*ask_cancel)(struct gaim_xfer *xfer); | |
| 56 | void (*add_xfer)(struct gaim_xfer *xfer); | |
| 57 | void (*update_progress)(struct gaim_xfer *xfer, double percent); | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
58 | void (*cancel_local)(struct gaim_xfer *xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
59 | void (*cancel_remote)(struct gaim_xfer *xfer); |
| 4514 | 60 | }; |
| 61 | ||
| 62 | /** | |
| 63 | * A core representation of a file transfer. | |
| 64 | */ | |
| 65 | struct gaim_xfer | |
| 66 | { | |
| 67 | GaimXferType type; /**< The type of transfer. */ | |
| 68 | ||
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5499
diff
changeset
|
69 | GaimAccount *account; /**< The account. */ |
| 4514 | 70 | |
| 71 | char *who; /**< The person on the other end of the | |
| 72 | transfer. */ | |
| 73 | ||
|
4605
67526771e679
[gaim-migrate @ 4892]
Mark Doliner <markdoliner@pidgin.im>
parents:
4595
diff
changeset
|
74 | char *filename; /**< The name sent over the network. */ |
|
67526771e679
[gaim-migrate @ 4892]
Mark Doliner <markdoliner@pidgin.im>
parents:
4595
diff
changeset
|
75 | char *local_filename; /**< The name on the local hard drive. */ |
| 4514 | 76 | size_t size; /**< The size of the file. */ |
| 77 | ||
| 78 | FILE *dest_fp; /**< The destination file pointer. */ | |
| 79 | ||
| 80 | char *local_ip; /**< The local IP address. */ | |
| 81 | char *remote_ip; /**< The remote IP address. */ | |
| 82 | int local_port; /**< The local port. */ | |
| 83 | int remote_port; /**< The remote port. */ | |
| 84 | ||
| 85 | int fd; /**< The socket file descriptor. */ | |
| 86 | int watcher; /**< Watcher. */ | |
| 87 | ||
| 88 | size_t bytes_sent; /**< The number of bytes sent. */ | |
| 89 | size_t bytes_remaining; /**< The number of bytes remaining. */ | |
| 90 | ||
| 4538 | 91 | gboolean completed; /**< File Transfer is completed. */ |
| 92 | ||
| 4514 | 93 | /* I/O operations. */ |
| 94 | struct | |
| 95 | { | |
| 96 | void (*init)(struct gaim_xfer *xfer); | |
| 97 | void (*start)(struct gaim_xfer *xfer); | |
| 98 | void (*end)(struct gaim_xfer *xfer); | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
99 | void (*cancel_send)(struct gaim_xfer *xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
100 | void (*cancel_recv)(struct gaim_xfer *xfer); |
|
5495
c4527631aea4
[gaim-migrate @ 5891]
Herman Bloggs <herman@bluedigits.com>
parents:
5494
diff
changeset
|
101 | size_t (*read)(char **buffer, struct gaim_xfer *xfer); |
|
c4527631aea4
[gaim-migrate @ 5891]
Herman Bloggs <herman@bluedigits.com>
parents:
5494
diff
changeset
|
102 | size_t (*write)(const char *buffer, size_t size, |
|
4518
7ef89224fd04
[gaim-migrate @ 4796]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
103 | struct gaim_xfer *xfer); |
|
4594
a96954344300
[gaim-migrate @ 4879]
Mark Doliner <markdoliner@pidgin.im>
parents:
4539
diff
changeset
|
104 | void (*ack)(struct gaim_xfer *xfer, const char *buffer, |
|
a96954344300
[gaim-migrate @ 4879]
Mark Doliner <markdoliner@pidgin.im>
parents:
4539
diff
changeset
|
105 | size_t size); |
| 4514 | 106 | |
| 107 | } ops; | |
| 108 | ||
| 109 | struct gaim_xfer_ui_ops *ui_ops; /**< UI-specific operations. */ | |
| 110 | void *ui_data; /**< UI-specific data. */ | |
| 111 | ||
| 112 | void *data; /**< prpl-specific data. */ | |
| 113 | }; | |
| 114 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
115 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
116 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
117 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
118 | |
| 4514 | 119 | /**************************************************************************/ |
| 120 | /** @name File Transfer API */ | |
| 121 | /**************************************************************************/ | |
| 122 | /*@{*/ | |
| 123 | ||
| 124 | /** | |
| 125 | * Creates a new file transfer handle. | |
| 126 | * | |
| 127 | * @param account The account sending or receiving the file. | |
| 128 | * @param type The type of file transfer. | |
| 129 | * @param who The name of the remote user. | |
| 130 | * | |
| 131 | * @return A file transfer handle. | |
| 132 | */ | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5499
diff
changeset
|
133 | struct gaim_xfer *gaim_xfer_new(GaimAccount *account, |
| 4514 | 134 | GaimXferType type, const char *who); |
| 135 | ||
| 136 | /** | |
| 137 | * Destroys a file transfer handle. | |
| 138 | * | |
| 139 | * @param xfer The file transfer to destroy. | |
| 140 | */ | |
| 141 | void gaim_xfer_destroy(struct gaim_xfer *xfer); | |
| 142 | ||
| 143 | /** | |
| 144 | * Requests confirmation for a file transfer from the user. | |
| 145 | * | |
| 146 | * @param xfer The file transfer to request confirmation on. | |
| 147 | */ | |
| 148 | void gaim_xfer_request(struct gaim_xfer *xfer); | |
| 149 | ||
| 150 | /** | |
| 151 | * Called if the user accepts the file transfer request. | |
| 152 | * | |
| 153 | * @param xfer The file transfer. | |
| 154 | * @param filename The filename. | |
| 155 | */ | |
| 156 | void gaim_xfer_request_accepted(struct gaim_xfer *xfer, char *filename); | |
| 157 | ||
| 158 | /** | |
| 159 | * Called if the user rejects the file transfer request. | |
| 160 | * | |
| 161 | * @param xfer The file transfer. | |
| 162 | */ | |
| 163 | void gaim_xfer_request_denied(struct gaim_xfer *xfer); | |
| 164 | ||
| 165 | /** | |
| 166 | * Returns the type of file transfer. | |
| 167 | * | |
| 168 | * @param xfer The file transfer. | |
| 169 | * | |
| 170 | * @return The type of the file transfer. | |
| 171 | */ | |
| 172 | GaimXferType gaim_xfer_get_type(const struct gaim_xfer *xfer); | |
| 173 | ||
| 174 | /** | |
| 175 | * Returns the account the file transfer is using. | |
| 176 | * | |
| 177 | * @param xfer The file transfer. | |
| 178 | * | |
| 179 | * @return The account. | |
| 180 | */ | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5499
diff
changeset
|
181 | GaimAccount *gaim_xfer_get_account(const struct gaim_xfer *xfer); |
| 4514 | 182 | |
| 183 | /** | |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
184 | * Returns the completed state for a file transfer. |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
185 | * |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
186 | * @param xfer The file transfer. |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
187 | * |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
188 | * @return The completed state. |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
189 | */ |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
190 | gboolean gaim_xfer_is_completed(const struct gaim_xfer *xfer); |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
191 | |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
192 | /** |
| 4514 | 193 | * Returns the name of the file being sent or received. |
| 194 | * | |
| 195 | * @param xfer The file transfer. | |
| 196 | * | |
| 197 | * @return The filename. | |
| 198 | */ | |
| 199 | const char *gaim_xfer_get_filename(const struct gaim_xfer *xfer); | |
| 200 | ||
| 201 | /** | |
| 202 | * Returns the file's destination filename, | |
| 203 | * | |
| 204 | * @param xfer The file transfer. | |
| 205 | * | |
| 206 | * @return The destination filename. | |
| 207 | */ | |
|
4605
67526771e679
[gaim-migrate @ 4892]
Mark Doliner <markdoliner@pidgin.im>
parents:
4595
diff
changeset
|
208 | const char *gaim_xfer_get_local_filename(const struct gaim_xfer *xfer); |
| 4514 | 209 | |
| 210 | /** | |
| 211 | * Returns the number of bytes sent so far. | |
| 212 | * | |
| 213 | * @param xfer The file transfer. | |
| 214 | * | |
| 215 | * @return The number of bytes sent. | |
| 216 | */ | |
| 217 | size_t gaim_xfer_get_bytes_sent(const struct gaim_xfer *xfer); | |
| 218 | ||
| 219 | /** | |
| 220 | * Returns the number of bytes received so far. | |
| 221 | * | |
| 222 | * @param xfer The file transfer. | |
| 223 | * | |
| 224 | * @return The number of bytes received. | |
| 225 | */ | |
| 226 | size_t gaim_xfer_get_bytes_remaining(const struct gaim_xfer *xfer); | |
| 227 | ||
| 228 | /** | |
| 229 | * Returns the size of the file being sent or received. | |
| 230 | * | |
| 231 | * @param xfer The file transfer. | |
| 232 | * | |
| 233 | * @return The total size of the file. | |
| 234 | */ | |
| 235 | size_t gaim_xfer_get_size(const struct gaim_xfer *xfer); | |
| 236 | ||
| 237 | /** | |
| 238 | * Returns the current percentage of progress of the transfer. | |
| 239 | * | |
| 240 | * This is a number between 0 (0%) and 1 (100%). | |
| 241 | * | |
| 242 | * @param xfer The file transfer. | |
| 243 | * | |
| 244 | * @return The percentage complete. | |
| 245 | */ | |
| 246 | double gaim_xfer_get_progress(const struct gaim_xfer *xfer); | |
| 247 | ||
| 248 | /** | |
| 249 | * Returns the local IP address in the file transfer. | |
| 250 | * | |
| 251 | * @param xfer The file transfer. | |
| 252 | * | |
| 253 | * @return The IP address on this end. | |
| 254 | */ | |
| 255 | const char *gaim_xfer_get_local_ip(const struct gaim_xfer *xfer); | |
| 256 | ||
| 257 | /** | |
| 258 | * Returns the local port number in the file transfer. | |
| 259 | * | |
| 260 | * @param xfer The file transfer. | |
| 261 | * | |
| 262 | * @return The port number on this end. | |
| 263 | */ | |
| 264 | unsigned int gaim_xfer_get_local_port(const struct gaim_xfer *xfer); | |
| 265 | ||
| 266 | /** | |
| 267 | * Returns the remote IP address in the file transfer. | |
| 268 | * | |
| 269 | * @param xfer The file transfer. | |
| 270 | * | |
| 271 | * @return The IP address on the other end. | |
| 272 | */ | |
| 273 | const char *gaim_xfer_get_remote_ip(const struct gaim_xfer *xfer); | |
| 274 | ||
| 275 | /** | |
| 276 | * Returns the remote port number in the file transfer. | |
| 277 | * | |
| 278 | * @param xfer The file transfer. | |
| 279 | * | |
| 280 | * @return The port number on the other end. | |
| 281 | */ | |
| 282 | unsigned int gaim_xfer_get_remote_port(const struct gaim_xfer *xfer); | |
| 283 | ||
| 284 | /** | |
| 4538 | 285 | * Sets the completed state for the file transfer. |
| 286 | * | |
| 287 | * @param xfer The file transfer. | |
| 288 | * @param completed The completed state. | |
| 289 | */ | |
| 290 | void gaim_xfer_set_completed(struct gaim_xfer *xfer, gboolean completed); | |
| 291 | ||
| 292 | /** | |
| 4514 | 293 | * Sets the filename for the file transfer. |
| 294 | * | |
| 295 | * @param xfer The file transfer. | |
| 296 | * @param filename The filename. | |
| 297 | */ | |
| 298 | void gaim_xfer_set_filename(struct gaim_xfer *xfer, const char *filename); | |
| 299 | ||
| 300 | /** | |
|
4605
67526771e679
[gaim-migrate @ 4892]
Mark Doliner <markdoliner@pidgin.im>
parents:
4595
diff
changeset
|
301 | * Sets the local filename for the file transfer. |
| 4514 | 302 | * |
| 303 | * @param xfer The file transfer. | |
| 304 | * @param filename The filename | |
| 305 | */ | |
|
4605
67526771e679
[gaim-migrate @ 4892]
Mark Doliner <markdoliner@pidgin.im>
parents:
4595
diff
changeset
|
306 | void gaim_xfer_set_local_filename(struct gaim_xfer *xfer, const char *filename); |
| 4514 | 307 | |
| 308 | /** | |
| 309 | * Sets the size of the file in a file transfer. | |
| 310 | * | |
| 311 | * @param xfer The file transfer. | |
| 312 | * @param size The size of the file. | |
| 313 | */ | |
| 314 | void gaim_xfer_set_size(struct gaim_xfer *xfer, size_t size); | |
| 315 | ||
| 316 | /** | |
| 317 | * Returns the UI operations structure for a file transfer. | |
| 318 | * | |
| 319 | * @param xfer The file transfer. | |
| 320 | * | |
| 321 | * @return The UI operations structure. | |
| 322 | */ | |
| 323 | struct gaim_xfer_ui_ops *gaim_xfer_get_ui_ops(const struct gaim_xfer *xfer); | |
| 324 | ||
| 325 | /** | |
| 326 | * Sets the read function for the file transfer. | |
| 327 | * | |
| 328 | * @param xfer The file transfer. | |
| 329 | * @param fnc The read function. | |
| 330 | */ | |
| 331 | void gaim_xfer_set_read_fnc(struct gaim_xfer *xfer, | |
|
4518
7ef89224fd04
[gaim-migrate @ 4796]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
332 | size_t (*fnc)(char **, struct gaim_xfer *)); |
| 4514 | 333 | |
| 334 | /** | |
| 335 | * Sets the write function for the file transfer. | |
| 336 | * | |
| 337 | * @param xfer The file transfer. | |
| 338 | * @param fnc The write function. | |
| 339 | */ | |
| 340 | void gaim_xfer_set_write_fnc(struct gaim_xfer *xfer, | |
|
4518
7ef89224fd04
[gaim-migrate @ 4796]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
341 | size_t (*fnc)(const char *, size_t, struct gaim_xfer *)); |
| 4514 | 342 | |
| 343 | /** | |
| 344 | * Sets the acknowledge function for the file transfer. | |
| 345 | * | |
| 346 | * @param xfer The file transfer. | |
| 347 | * @param fnc The acknowledge function. | |
| 348 | */ | |
| 349 | void gaim_xfer_set_ack_fnc(struct gaim_xfer *xfer, | |
|
4595
398fc487bf7b
[gaim-migrate @ 4880]
Mark Doliner <markdoliner@pidgin.im>
parents:
4594
diff
changeset
|
350 | void (*fnc)(struct gaim_xfer *, const char *, size_t)); |
| 4514 | 351 | |
| 352 | /** | |
| 353 | * Sets the transfer initialization function for the file transfer. | |
| 354 | * | |
| 355 | * This function is required, and must call gaim_xfer_start() with | |
| 356 | * the necessary parameters. This will be called if the file transfer | |
| 357 | * is accepted by the user. | |
| 358 | * | |
| 359 | * @param xfer The file transfer. | |
| 360 | * @param fnc The transfer initialization function. | |
| 361 | */ | |
| 362 | void gaim_xfer_set_init_fnc(struct gaim_xfer *xfer, | |
| 363 | void (*fnc)(struct gaim_xfer *)); | |
| 364 | ||
| 365 | /** | |
| 366 | * Sets the start transfer function for the file transfer. | |
| 367 | * | |
| 368 | * @param xfer The file transfer. | |
| 369 | * @param fnc The start transfer function. | |
| 370 | */ | |
| 371 | void gaim_xfer_set_start_fnc(struct gaim_xfer *xfer, | |
| 372 | void (*fnc)(struct gaim_xfer *)); | |
| 373 | ||
| 374 | /** | |
| 375 | * Sets the end transfer function for the file transfer. | |
| 376 | * | |
| 377 | * @param xfer The file transfer. | |
| 378 | * @param fnc The end transfer function. | |
| 379 | */ | |
| 380 | void gaim_xfer_set_end_fnc(struct gaim_xfer *xfer, | |
| 381 | void (*fnc)(struct gaim_xfer *)); | |
| 382 | ||
| 383 | /** | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
384 | * Sets the cancel send function for the file transfer. |
| 4514 | 385 | * |
| 386 | * @param xfer The file transfer. | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
387 | * @param fnc The cancel send function. |
| 4514 | 388 | */ |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
389 | void gaim_xfer_set_cancel_send_fnc(struct gaim_xfer *xfer, |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
390 | void (*fnc)(struct gaim_xfer *)); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
391 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
392 | /** |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
393 | * Sets the cancel receive function for the file transfer. |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
394 | * |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
395 | * @param xfer The file transfer. |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
396 | * @param fnc The cancel receive function. |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
397 | */ |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
398 | void gaim_xfer_set_cancel_recv_fnc(struct gaim_xfer *xfer, |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
399 | void (*fnc)(struct gaim_xfer *)); |
| 4514 | 400 | |
| 401 | /** | |
| 402 | * Reads in data from a file transfer stream. | |
| 403 | * | |
| 404 | * @param xfer The file transfer. | |
| 405 | * @param buffer The buffer that will be created to contain the data. | |
| 406 | * | |
| 407 | * @return The number of bytes read. | |
| 408 | */ | |
| 409 | size_t gaim_xfer_read(struct gaim_xfer *xfer, char **buffer); | |
| 410 | ||
| 411 | /** | |
| 412 | * Writes data to a file transfer stream. | |
| 413 | * | |
| 414 | * @param xfer The file transfer. | |
| 415 | * @param buffer The buffer to read the data from. | |
| 416 | * @param size The number of bytes to write. | |
| 417 | * | |
| 418 | * @return The number of bytes written. | |
| 419 | */ | |
| 420 | size_t gaim_xfer_write(struct gaim_xfer *xfer, const char *buffer, | |
| 421 | size_t size); | |
| 422 | ||
| 423 | /** | |
| 424 | * Starts a file transfer. | |
| 425 | * | |
| 426 | * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
| 427 | * file receive transfer. On send, @a fd must be specified, and | |
| 428 | * @a ip and @a port are ignored. | |
| 429 | * | |
| 430 | * @param xfer The file transfer. | |
| 431 | * @param fd The file descriptor for the socket. | |
| 432 | * @param ip The IP address to connect to. | |
| 433 | * @param port The port to connect to. | |
| 434 | */ | |
| 435 | void gaim_xfer_start(struct gaim_xfer *xfer, int fd, const char *ip, | |
| 436 | unsigned int port); | |
| 437 | ||
| 438 | /** | |
| 439 | * Ends a file transfer. | |
| 440 | * | |
| 441 | * @param xfer The file transfer. | |
| 442 | */ | |
| 443 | void gaim_xfer_end(struct gaim_xfer *xfer); | |
| 444 | ||
| 445 | /** | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
446 | * Cancels a file transfer on the local end. |
| 4514 | 447 | * |
| 448 | * @param xfer The file transfer. | |
| 449 | */ | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
450 | void gaim_xfer_cancel_local(struct gaim_xfer *xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
451 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
452 | /** |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
453 | * Cancels a file transfer from the remote end. |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
454 | * |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
455 | * @param xfer The file transfer. |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
456 | */ |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
457 | void gaim_xfer_cancel_remote(struct gaim_xfer *xfer); |
| 4514 | 458 | |
| 459 | /** | |
| 460 | * Displays a file transfer-related error message. | |
| 461 | * | |
|
5499
3490d628be1d
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
462 | * This is a wrapper around gaim_notify_error(), which automatically |
| 4514 | 463 | * specifies a title ("File transfer to <i>user</i> aborted" or |
| 464 | * "File Transfer from <i>user</i> aborted"). | |
| 465 | * | |
| 466 | * @param type The type of file transfer. | |
| 467 | * @param who The user on the other end of the transfer. | |
| 468 | * @param msg The message to display. | |
| 469 | */ | |
| 470 | void gaim_xfer_error(GaimXferType type, const char *who, const char *msg); | |
| 471 | ||
| 472 | /*@}*/ | |
| 473 | ||
| 474 | /**************************************************************************/ | |
| 475 | /** @name UI Registration Functions */ | |
| 476 | /**************************************************************************/ | |
| 477 | /*@{*/ | |
| 478 | ||
| 479 | /** | |
| 480 | * Sets the UI operations structure to be used in all gaim file transfers. | |
| 481 | * | |
| 482 | * @param fnc The function. | |
| 483 | */ | |
| 484 | void gaim_set_xfer_ui_ops(struct gaim_xfer_ui_ops *ops); | |
| 485 | ||
| 486 | /** | |
| 487 | * Returns the UI operations structure to be used in all gaim file transfers. | |
| 488 | * | |
| 489 | * @return The UI operations structure. | |
| 490 | */ | |
| 491 | struct gaim_xfer_ui_ops *gaim_get_xfer_ui_ops(void); | |
| 492 | ||
| 493 | /*@}*/ | |
| 494 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
495 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
496 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
497 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
498 | |
| 4514 | 499 | #endif /* _GAIM_FT_H_ */ |