Mercurial > pidgin
annotate src/ft.h @ 11873:346bd669c8f2
[gaim-migrate @ 14164]
some error prevention from Casey Harkins. see patch 1340762
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Fri, 28 Oct 2005 15:43:15 +0000 |
| parents | 920a37a4c1be |
| children | cbebda5f019c |
| 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. | |
|
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
10 * |
| 4514 | 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. */ | |
| 8585 | 53 GAIM_XFER_STATUS_ACCEPTED, /**< Receive accepted, but destination file not selected yet */ |
| 7805 | 54 GAIM_XFER_STATUS_STARTED, /**< gaim_xfer_start has been called. */ |
| 55 GAIM_XFER_STATUS_DONE, /**< The xfer completed successfully. */ | |
| 56 GAIM_XFER_STATUS_CANCEL_LOCAL, /**< The xfer was canceled by us. */ | |
| 7887 | 57 GAIM_XFER_STATUS_CANCEL_REMOTE /**< The xfer was canceled by the other end, or we couldn't connect. */ |
| 7805 | 58 } GaimXferStatusType; |
| 7738 | 59 |
| 4514 | 60 /** |
| 61 * File transfer UI operations. | |
| 62 * | |
| 63 * 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
|
64 * GaimXferUiOps structure to the gaim_xfer. |
| 4514 | 65 */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
66 typedef struct |
| 4514 | 67 { |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
68 void (*new_xfer)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
69 void (*destroy)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
70 void (*add_xfer)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
71 void (*update_progress)(GaimXfer *xfer, double percent); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
72 void (*cancel_local)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
73 void (*cancel_remote)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
74 |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
75 } GaimXferUiOps; |
| 4514 | 76 |
| 77 /** | |
| 78 * A core representation of a file transfer. | |
| 79 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
80 struct _GaimXfer |
| 4514 | 81 { |
| 7887 | 82 guint ref; /**< The reference count. */ |
| 4514 | 83 GaimXferType type; /**< The type of transfer. */ |
| 84 | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
85 GaimAccount *account; /**< The account. */ |
| 4514 | 86 |
| 87 char *who; /**< The person on the other end of the | |
| 88 transfer. */ | |
| 89 | |
| 9933 | 90 char *message; /**< A message sent with the request */ |
| 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 *remote_ip; /**< The remote IP address. */ | |
| 98 int local_port; /**< The local port. */ | |
| 99 int remote_port; /**< The remote port. */ | |
| 100 | |
| 101 int fd; /**< The socket file descriptor. */ | |
| 102 int watcher; /**< Watcher. */ | |
| 103 | |
| 104 size_t bytes_sent; /**< The number of bytes sent. */ | |
| 105 size_t bytes_remaining; /**< The number of bytes remaining. */ | |
| 106 | |
| 7805 | 107 GaimXferStatusType status; /**< File Transfer's status. */ |
| 4538 | 108 |
| 4514 | 109 /* I/O operations. */ |
| 110 struct | |
| 111 { | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
112 void (*init)(GaimXfer *xfer); |
| 7805 | 113 void (*request_denied)(GaimXfer *xfer); |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
114 void (*start)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
115 void (*end)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
116 void (*cancel_send)(GaimXfer *xfer); |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
117 void (*cancel_recv)(GaimXfer *xfer); |
| 11159 | 118 ssize_t (*read)(guchar **buffer, GaimXfer *xfer); |
| 119 ssize_t (*write)(const guchar *buffer, size_t size, GaimXfer *xfer); | |
| 120 void (*ack)(GaimXfer *xfer, const guchar *buffer, size_t size); | |
| 4514 | 121 |
| 122 } ops; | |
| 123 | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
124 GaimXferUiOps *ui_ops; /**< UI-specific operations. */ |
| 4514 | 125 void *ui_data; /**< UI-specific data. */ |
| 126 | |
| 127 void *data; /**< prpl-specific data. */ | |
| 128 }; | |
| 129 | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
130 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
131 extern "C" { |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
132 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
133 |
| 4514 | 134 /**************************************************************************/ |
| 135 /** @name File Transfer API */ | |
| 136 /**************************************************************************/ | |
| 137 /*@{*/ | |
| 138 | |
| 139 /** | |
| 140 * Creates a new file transfer handle. | |
| 7805 | 141 * This is called by prpls. |
| 142 * The handle starts with a ref count of 1, and this reference | |
| 143 * is owned by the core. The prpl normally does not need to | |
| 144 * gaim_xfer_ref or unref. | |
| 4514 | 145 * |
| 146 * @param account The account sending or receiving the file. | |
| 147 * @param type The type of file transfer. | |
| 148 * @param who The name of the remote user. | |
| 149 * | |
| 150 * @return A file transfer handle. | |
| 151 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
152 GaimXfer *gaim_xfer_new(GaimAccount *account, |
| 4514 | 153 GaimXferType type, const char *who); |
| 154 | |
| 155 /** | |
| 7805 | 156 * Increases the reference count on a GaimXfer. |
| 157 * Please call gaim_xfer_unref later. | |
| 4514 | 158 * |
| 7805 | 159 * @param xfer A file transfer handle. |
| 4514 | 160 */ |
| 7805 | 161 void gaim_xfer_ref(GaimXfer *xfer); |
| 162 | |
| 163 /** | |
| 164 * Decreases the reference count on a GaimXfer. | |
| 165 * If the reference reaches 0, gaim_xfer_destroy (an internal function) | |
| 166 * will destroy the xfer. It calls the ui destroy cb first. | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8585
diff
changeset
|
167 * Since the core keeps a ref on the xfer, only an erroneous call to |
| 7805 | 168 * this function will destroy the xfer while still in use. |
| 169 * | |
| 170 * @param xfer A file transfer handle. | |
| 171 */ | |
| 172 void gaim_xfer_unref(GaimXfer *xfer); | |
| 4514 | 173 |
| 174 /** | |
| 8585 | 175 * Requests confirmation for a file transfer from the user. If receiving |
| 176 * a file which is known at this point, this requests user to accept and | |
| 177 * save the file. If the filename is unknown (not set) this only requests user | |
| 178 * to accept the file transfer. In this case protocol must call this function | |
| 179 * again once the filename is available. | |
| 4514 | 180 * |
| 181 * @param xfer The file transfer to request confirmation on. | |
| 182 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
183 void gaim_xfer_request(GaimXfer *xfer); |
| 4514 | 184 |
| 185 /** | |
| 186 * Called if the user accepts the file transfer request. | |
| 187 * | |
| 188 * @param xfer The file transfer. | |
| 189 * @param filename The filename. | |
| 190 */ | |
| 7805 | 191 void gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename); |
| 4514 | 192 |
| 193 /** | |
| 194 * Called if the user rejects the file transfer request. | |
| 195 * | |
| 196 * @param xfer The file transfer. | |
| 197 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
198 void gaim_xfer_request_denied(GaimXfer *xfer); |
| 4514 | 199 |
| 200 /** | |
| 201 * Returns the type of file transfer. | |
| 202 * | |
| 203 * @param xfer The file transfer. | |
| 204 * | |
| 205 * @return The type of the file transfer. | |
| 206 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
207 GaimXferType gaim_xfer_get_type(const GaimXfer *xfer); |
| 4514 | 208 |
| 209 /** | |
| 210 * Returns the account the file transfer is using. | |
| 211 * | |
| 212 * @param xfer The file transfer. | |
| 213 * | |
| 214 * @return The account. | |
| 215 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
216 GaimAccount *gaim_xfer_get_account(const GaimXfer *xfer); |
| 4514 | 217 |
| 218 /** | |
| 7805 | 219 * Returns the status of the xfer. |
| 220 * | |
| 221 * @param xfer The file transfer. | |
| 222 * | |
| 223 * @return The status. | |
| 224 */ | |
| 225 GaimXferStatusType gaim_xfer_get_status(const GaimXfer *xfer); | |
| 226 | |
| 227 /** | |
| 7738 | 228 * Returns true if the file transfer was canceled. |
| 229 * | |
| 230 * @param xfer The file transfer. | |
| 231 * | |
| 232 * @return Whether or not the transfer was canceled. | |
| 233 */ | |
| 7805 | 234 gboolean gaim_xfer_is_canceled(const GaimXfer *xfer); |
| 7738 | 235 |
| 236 /** | |
|
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
237 * Returns the completed state for a file transfer. |
|
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
238 * |
|
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
239 * @param xfer The file transfer. |
|
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
240 * |
|
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
241 * @return The completed state. |
|
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
242 */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
243 gboolean gaim_xfer_is_completed(const GaimXfer *xfer); |
|
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
244 |
|
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
245 /** |
| 4514 | 246 * Returns the name of the file being sent or received. |
| 247 * | |
| 248 * @param xfer The file transfer. | |
| 249 * | |
| 250 * @return The filename. | |
| 251 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
252 const char *gaim_xfer_get_filename(const GaimXfer *xfer); |
| 4514 | 253 |
| 254 /** | |
| 255 * Returns the file's destination filename, | |
| 256 * | |
| 257 * @param xfer The file transfer. | |
| 258 * | |
| 259 * @return The destination filename. | |
| 260 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
261 const char *gaim_xfer_get_local_filename(const GaimXfer *xfer); |
| 4514 | 262 |
| 263 /** | |
| 264 * Returns the number of bytes sent so far. | |
| 265 * | |
| 266 * @param xfer The file transfer. | |
| 267 * | |
| 268 * @return The number of bytes sent. | |
| 269 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
270 size_t gaim_xfer_get_bytes_sent(const GaimXfer *xfer); |
| 4514 | 271 |
| 272 /** | |
| 273 * Returns the number of bytes received so far. | |
| 274 * | |
| 275 * @param xfer The file transfer. | |
| 276 * | |
| 277 * @return The number of bytes received. | |
| 278 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
279 size_t gaim_xfer_get_bytes_remaining(const GaimXfer *xfer); |
| 4514 | 280 |
| 281 /** | |
| 282 * Returns the size of the file being sent or received. | |
| 283 * | |
| 284 * @param xfer The file transfer. | |
| 7805 | 285 * |
| 4514 | 286 * @return The total size of the file. |
| 287 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
288 size_t gaim_xfer_get_size(const GaimXfer *xfer); |
| 4514 | 289 |
| 290 /** | |
| 291 * Returns the current percentage of progress of the transfer. | |
| 292 * | |
| 293 * This is a number between 0 (0%) and 1 (100%). | |
| 294 * | |
| 295 * @param xfer The file transfer. | |
| 296 * | |
| 297 * @return The percentage complete. | |
| 298 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
299 double gaim_xfer_get_progress(const GaimXfer *xfer); |
| 4514 | 300 |
| 301 /** | |
| 302 * Returns the local port number in the file transfer. | |
| 303 * | |
| 304 * @param xfer The file transfer. | |
| 305 * | |
| 306 * @return The port number on this end. | |
| 307 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
308 unsigned int gaim_xfer_get_local_port(const GaimXfer *xfer); |
| 4514 | 309 |
| 310 /** | |
| 311 * Returns the remote IP address in the file transfer. | |
| 312 * | |
| 313 * @param xfer The file transfer. | |
| 314 * | |
| 315 * @return The IP address on the other end. | |
| 316 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
317 const char *gaim_xfer_get_remote_ip(const GaimXfer *xfer); |
| 4514 | 318 |
| 319 /** | |
| 320 * Returns the remote port number in the file transfer. | |
| 321 * | |
| 322 * @param xfer The file transfer. | |
| 323 * | |
| 324 * @return The port number on the other end. | |
| 325 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
326 unsigned int gaim_xfer_get_remote_port(const GaimXfer *xfer); |
| 4514 | 327 |
| 328 /** | |
| 4538 | 329 * Sets the completed state for the file transfer. |
| 330 * | |
| 331 * @param xfer The file transfer. | |
| 332 * @param completed The completed state. | |
| 333 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
334 void gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed); |
| 4538 | 335 |
| 336 /** | |
| 4514 | 337 * Sets the filename for the file transfer. |
| 338 * | |
| 339 * @param xfer The file transfer. | |
| 9933 | 340 * @param message The message. |
| 341 */ | |
| 342 void gaim_xfer_set_message(GaimXfer *xfer, const char *message); | |
| 343 | |
| 344 /** | |
| 345 * Sets the filename for the file transfer. | |
| 346 * | |
| 347 * @param xfer The file transfer. | |
| 4514 | 348 * @param filename The filename. |
| 349 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
350 void gaim_xfer_set_filename(GaimXfer *xfer, const char *filename); |
| 4514 | 351 |
| 352 /** | |
| 4605 | 353 * Sets the local filename for the file transfer. |
| 4514 | 354 * |
| 355 * @param xfer The file transfer. | |
| 356 * @param filename The filename | |
| 357 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
358 void gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename); |
| 4514 | 359 |
| 360 /** | |
| 361 * Sets the size of the file in a file transfer. | |
| 362 * | |
| 363 * @param xfer The file transfer. | |
| 364 * @param size The size of the file. | |
| 365 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
366 void gaim_xfer_set_size(GaimXfer *xfer, size_t size); |
| 4514 | 367 |
| 368 /** | |
| 369 * Returns the UI operations structure for a file transfer. | |
| 370 * | |
| 371 * @param xfer The file transfer. | |
| 372 * | |
| 373 * @return The UI operations structure. | |
| 374 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
375 GaimXferUiOps *gaim_xfer_get_ui_ops(const GaimXfer *xfer); |
| 4514 | 376 |
| 377 /** | |
| 378 * Sets the read function for the file transfer. | |
| 379 * | |
| 380 * @param xfer The file transfer. | |
| 381 * @param fnc The read function. | |
| 382 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
383 void gaim_xfer_set_read_fnc(GaimXfer *xfer, |
| 11159 | 384 ssize_t (*fnc)(guchar **, GaimXfer *)); |
| 4514 | 385 |
| 386 /** | |
| 387 * Sets the write function for the file transfer. | |
| 388 * | |
| 389 * @param xfer The file transfer. | |
| 390 * @param fnc The write function. | |
| 391 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
392 void gaim_xfer_set_write_fnc(GaimXfer *xfer, |
| 11159 | 393 ssize_t (*fnc)(const guchar *, size_t, GaimXfer *)); |
| 4514 | 394 |
| 395 /** | |
| 396 * Sets the acknowledge function for the file transfer. | |
| 397 * | |
| 398 * @param xfer The file transfer. | |
| 399 * @param fnc The acknowledge function. | |
| 400 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
401 void gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
| 11159 | 402 void (*fnc)(GaimXfer *, const guchar *, size_t)); |
| 4514 | 403 |
| 404 /** | |
| 7805 | 405 * Sets the function to be called if the request is denied. |
| 406 * | |
| 407 * @param xfer The file transfer. | |
| 408 * @param fnc The request denied prpl callback. | |
| 409 */ | |
| 410 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); | |
| 411 | |
| 412 /** | |
| 4514 | 413 * Sets the transfer initialization function for the file transfer. |
| 414 * | |
| 415 * This function is required, and must call gaim_xfer_start() with | |
| 416 * the necessary parameters. This will be called if the file transfer | |
| 417 * is accepted by the user. | |
| 418 * | |
| 419 * @param xfer The file transfer. | |
| 420 * @param fnc The transfer initialization function. | |
| 421 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
422 void gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
| 4514 | 423 |
| 424 /** | |
| 425 * Sets the start transfer function for the file transfer. | |
| 426 * | |
| 427 * @param xfer The file transfer. | |
| 428 * @param fnc The start transfer function. | |
| 429 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
430 void gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
| 4514 | 431 |
| 432 /** | |
| 433 * Sets the end transfer function for the file transfer. | |
| 434 * | |
| 435 * @param xfer The file transfer. | |
| 436 * @param fnc The end transfer function. | |
| 437 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
438 void gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
| 4514 | 439 |
| 440 /** | |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
441 * Sets the cancel send function for the file transfer. |
| 4514 | 442 * |
| 443 * @param xfer The file transfer. | |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
444 * @param fnc The cancel send function. |
| 4514 | 445 */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
446 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
|
447 |
|
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 * Sets the cancel receive function for the file transfer. |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
450 * |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
451 * @param xfer The file transfer. |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
452 * @param fnc The cancel receive function. |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
453 */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
454 void gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)); |
| 4514 | 455 |
| 456 /** | |
| 457 * Reads in data from a file transfer stream. | |
| 458 * | |
| 459 * @param xfer The file transfer. | |
| 460 * @param buffer The buffer that will be created to contain the data. | |
| 461 * | |
|
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
462 * @return The number of bytes read, or -1. |
| 4514 | 463 */ |
| 11159 | 464 ssize_t gaim_xfer_read(GaimXfer *xfer, guchar **buffer); |
| 4514 | 465 |
| 466 /** | |
| 467 * Writes data to a file transfer stream. | |
| 468 * | |
| 469 * @param xfer The file transfer. | |
| 470 * @param buffer The buffer to read the data from. | |
| 471 * @param size The number of bytes to write. | |
| 472 * | |
|
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8211
diff
changeset
|
473 * @return The number of bytes written, or -1. |
| 4514 | 474 */ |
| 11159 | 475 ssize_t gaim_xfer_write(GaimXfer *xfer, const guchar *buffer, size_t size); |
| 4514 | 476 |
| 477 /** | |
| 478 * Starts a file transfer. | |
| 479 * | |
| 480 * Either @a fd must be specified <i>or</i> @a ip and @a port on a | |
| 481 * file receive transfer. On send, @a fd must be specified, and | |
| 482 * @a ip and @a port are ignored. | |
| 483 * | |
| 484 * @param xfer The file transfer. | |
| 485 * @param fd The file descriptor for the socket. | |
| 486 * @param ip The IP address to connect to. | |
| 487 * @param port The port to connect to. | |
| 488 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
489 void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
| 4514 | 490 unsigned int port); |
| 491 | |
| 492 /** | |
| 493 * Ends a file transfer. | |
| 494 * | |
| 495 * @param xfer The file transfer. | |
| 496 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
497 void gaim_xfer_end(GaimXfer *xfer); |
| 4514 | 498 |
| 499 /** | |
| 8585 | 500 * Adds a new file transfer to the list of file transfers. Call this only |
| 501 * if you are not using gaim_xfer_start. | |
| 502 * | |
| 503 * @param xfer The file transfer. | |
| 504 */ | |
| 505 void gaim_xfer_add(GaimXfer *xfer); | |
| 506 | |
| 507 /** | |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
508 * Cancels a file transfer on the local end. |
| 4514 | 509 * |
| 510 * @param xfer The file transfer. | |
| 511 */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
512 void gaim_xfer_cancel_local(GaimXfer *xfer); |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
513 |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
514 /** |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
515 * Cancels a file transfer from the remote end. |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
516 * |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
517 * @param xfer The file transfer. |
|
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4605
diff
changeset
|
518 */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
519 void gaim_xfer_cancel_remote(GaimXfer *xfer); |
| 4514 | 520 |
| 521 /** | |
| 522 * Displays a file transfer-related error message. | |
| 523 * | |
|
5499
c8afb821df3e
[gaim-migrate @ 5895]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
524 * This is a wrapper around gaim_notify_error(), which automatically |
| 10654 | 525 * specifies a title ("File transfer to <i>user</i> failed" or |
| 526 * "File Transfer from <i>user</i> failed"). | |
| 4514 | 527 * |
| 10654 | 528 * @param type The type of file transfer. |
| 529 * @param account The account sending or receiving the file. | |
| 530 * @param who The user on the other end of the transfer. | |
| 531 * @param msg The message to display. | |
| 4514 | 532 */ |
| 10654 | 533 void gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg); |
| 4514 | 534 |
| 8585 | 535 /** |
| 536 * Updates file transfer progress. | |
| 537 * | |
| 538 * @param xfer The file transfer. | |
| 539 */ | |
| 540 void gaim_xfer_update_progress(GaimXfer *xfer); | |
| 541 | |
| 11084 | 542 /** |
| 543 * Displays a file transfer-related message in the conversation window | |
| 544 * | |
| 545 * This is a wrapper around gaim_conversation_write | |
| 546 * | |
| 547 * @param xfer The file transfer to which this message relates. | |
| 548 * @param message The message to display. | |
| 11129 | 549 * @param is_error Is this an error message?. |
| 11084 | 550 */ |
| 551 void gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error); | |
| 552 | |
|
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
553 /*@}*/ |
|
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
554 |
|
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6241
diff
changeset
|
555 /**************************************************************************/ |
| 4514 | 556 /** @name UI Registration Functions */ |
| 557 /**************************************************************************/ | |
| 558 /*@{*/ | |
| 559 | |
| 560 /** | |
|
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
561 * Returns the handle to the file transfer subsystem |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
562 * |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
563 * @return The handle |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
564 */ |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
565 void *gaim_xfers_get_handle(void); |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
566 |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
567 /** |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
568 * Initializes the file transfer subsystem |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
569 */ |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
570 void gaim_xfers_init(void); |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
571 |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
572 /** |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
573 * Uninitializes the file transfer subsystem |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
574 */ |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
575 void gaim_xfers_uninit(void); |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
576 |
|
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11159
diff
changeset
|
577 /** |
| 4514 | 578 * Sets the UI operations structure to be used in all gaim file transfers. |
| 579 * | |
|
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6269
diff
changeset
|
580 * @param ops The UI operations structure. |
| 4514 | 581 */ |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
582 void gaim_xfers_set_ui_ops(GaimXferUiOps *ops); |
| 4514 | 583 |
| 584 /** | |
| 585 * Returns the UI operations structure to be used in all gaim file transfers. | |
| 586 * | |
| 587 * @return The UI operations structure. | |
| 588 */ | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
589 GaimXferUiOps *gaim_xfers_get_ui_ops(void); |
| 4514 | 590 |
| 591 /*@}*/ | |
| 592 | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
593 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
594 } |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
595 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
596 |
| 4514 | 597 #endif /* _GAIM_FT_H_ */ |
