Frameworks/libpurple.framework/Versions/0.6.2/Headers/ft.h
changeset 2592 e8d15275025e
parent 1739 8b0daad9656c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/ft.h	Fri Aug 21 13:25:11 2009 -0700
     1.3 @@ -0,0 +1,731 @@
     1.4 +/**
     1.5 + * @file ft.h File Transfer API
     1.6 + * @ingroup core
     1.7 + * @see @ref xfer-signals
     1.8 + */
     1.9 +
    1.10 +/* purple
    1.11 + *
    1.12 + * Purple is the legal property of its developers, whose names are too numerous
    1.13 + * to list here.  Please refer to the COPYRIGHT file distributed with this
    1.14 + * source distribution.
    1.15 + *
    1.16 + * This program is free software; you can redistribute it and/or modify
    1.17 + * it under the terms of the GNU General Public License as published by
    1.18 + * the Free Software Foundation; either version 2 of the License, or
    1.19 + * (at your option) any later version.
    1.20 + *
    1.21 + * This program is distributed in the hope that it will be useful,
    1.22 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.23 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.24 + * GNU General Public License for more details.
    1.25 + *
    1.26 + * You should have received a copy of the GNU General Public License
    1.27 + * along with this program; if not, write to the Free Software
    1.28 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    1.29 + */
    1.30 +#ifndef _PURPLE_FT_H_
    1.31 +#define _PURPLE_FT_H_
    1.32 +
    1.33 +/**************************************************************************/
    1.34 +/** Data Structures                                                       */
    1.35 +/**************************************************************************/
    1.36 +typedef struct _PurpleXfer PurpleXfer;
    1.37 +
    1.38 +#include <glib.h>
    1.39 +#include <stdio.h>
    1.40 +
    1.41 +#include "account.h"
    1.42 +
    1.43 +/**
    1.44 + * Types of file transfers.
    1.45 + */
    1.46 +typedef enum
    1.47 +{
    1.48 +	PURPLE_XFER_UNKNOWN = 0,  /**< Unknown file transfer type. */
    1.49 +	PURPLE_XFER_SEND,         /**< File sending.               */
    1.50 +	PURPLE_XFER_RECEIVE       /**< File receiving.             */
    1.51 +
    1.52 +} PurpleXferType;
    1.53 +
    1.54 +/**
    1.55 + * The different states of the xfer.
    1.56 + */
    1.57 +typedef enum
    1.58 +{
    1.59 +	PURPLE_XFER_STATUS_UNKNOWN = 0,   /**< Unknown, the xfer may be null. */
    1.60 +	PURPLE_XFER_STATUS_NOT_STARTED,   /**< It hasn't started yet. */
    1.61 +	PURPLE_XFER_STATUS_ACCEPTED,      /**< Receive accepted, but destination file not selected yet */
    1.62 +	PURPLE_XFER_STATUS_STARTED,       /**< purple_xfer_start has been called. */
    1.63 +	PURPLE_XFER_STATUS_DONE,          /**< The xfer completed successfully. */
    1.64 +	PURPLE_XFER_STATUS_CANCEL_LOCAL,  /**< The xfer was canceled by us. */
    1.65 +	PURPLE_XFER_STATUS_CANCEL_REMOTE  /**< The xfer was canceled by the other end, or we couldn't connect. */
    1.66 +} PurpleXferStatusType;
    1.67 +
    1.68 +/**
    1.69 + * File transfer UI operations.
    1.70 + *
    1.71 + * Any UI representing a file transfer must assign a filled-out
    1.72 + * PurpleXferUiOps structure to the purple_xfer.
    1.73 + */
    1.74 +typedef struct
    1.75 +{
    1.76 +	void (*new_xfer)(PurpleXfer *xfer);
    1.77 +	void (*destroy)(PurpleXfer *xfer);
    1.78 +	void (*add_xfer)(PurpleXfer *xfer);
    1.79 +	void (*update_progress)(PurpleXfer *xfer, double percent);
    1.80 +	void (*cancel_local)(PurpleXfer *xfer);
    1.81 +	void (*cancel_remote)(PurpleXfer *xfer);
    1.82 +
    1.83 +	/**
    1.84 +	 * UI op to write data received from the prpl. The UI must deal with the
    1.85 +	 * entire buffer and return size, or it is treated as an error.
    1.86 +	 *
    1.87 +	 * @param xfer    The file transfer structure
    1.88 +	 * @param buffer  The buffer to write
    1.89 +	 * @param size    The size of the buffer
    1.90 +	 *
    1.91 +	 * @return size if the write was successful, or a value between 0 and
    1.92 +	 *         size on error.
    1.93 +	 * @since 2.6.0
    1.94 +	 */
    1.95 +	gssize (*ui_write)(PurpleXfer *xfer, const guchar *buffer, gssize size);
    1.96 +
    1.97 +	/**
    1.98 +	 * UI op to read data to send to the prpl for a file transfer.
    1.99 +	 *
   1.100 +	 * @param xfer    The file transfer structure
   1.101 +	 * @param buffer  A pointer to a buffer. The UI must allocate this buffer.
   1.102 +	 *                libpurple will free the data.
   1.103 +	 * @param size    The maximum amount of data to put in the buffer.
   1.104 +	 *
   1.105 +	 * @returns The amount of data in the buffer, 0 if nothing is available,
   1.106 +	 *          and a negative value if an error occurred and the transfer
   1.107 +	 *          should be cancelled (libpurple will cancel).
   1.108 +	 * @since 2.6.0
   1.109 +	 */
   1.110 +	gssize (*ui_read)(PurpleXfer *xfer, guchar **buffer, gssize size);
   1.111 +
   1.112 +	/**
   1.113 +	 * Op to notify the UI that not all the data read in was written. The UI
   1.114 +	 * should re-enqueue this data and return it the next time read is called.
   1.115 +	 *
   1.116 +	 * This MUST be implemented if read and write are implemented.
   1.117 +	 *
   1.118 +	 * @param xfer    The file transfer structure
   1.119 +	 * @param buffer  A pointer to the beginning of the unwritten data.
   1.120 +	 * @param size    The amount of unwritten data.
   1.121 +	 *
   1.122 +	 * @since 2.6.0
   1.123 +	 */
   1.124 +	void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size);
   1.125 +
   1.126 +	void (*_purple_reserved1)(void);
   1.127 +} PurpleXferUiOps;
   1.128 +
   1.129 +/**
   1.130 + * A core representation of a file transfer.
   1.131 + */
   1.132 +struct _PurpleXfer
   1.133 +{
   1.134 +	guint ref;                    /**< The reference count.                */
   1.135 +	PurpleXferType type;            /**< The type of transfer.               */
   1.136 +
   1.137 +	PurpleAccount *account;         /**< The account.                        */
   1.138 +
   1.139 +	char *who;                    /**< The person on the other end of the
   1.140 +	                                   transfer.                           */
   1.141 +
   1.142 +	char *message;                /**< A message sent with the request     */
   1.143 +	char *filename;               /**< The name sent over the network.     */
   1.144 +	char *local_filename;         /**< The name on the local hard drive.   */
   1.145 +	size_t size;                  /**< The size of the file.               */
   1.146 +
   1.147 +	FILE *dest_fp;                /**< The destination file pointer.       */
   1.148 +
   1.149 +	char *remote_ip;              /**< The remote IP address.              */
   1.150 +	int local_port;               /**< The local port.                     */
   1.151 +	int remote_port;              /**< The remote port.                    */
   1.152 +
   1.153 +	int fd;                       /**< The socket file descriptor.         */
   1.154 +	int watcher;                  /**< Watcher.                            */
   1.155 +
   1.156 +	size_t bytes_sent;            /**< The number of bytes sent.           */
   1.157 +	size_t bytes_remaining;       /**< The number of bytes remaining.      */
   1.158 +	time_t start_time;            /**< When the transfer of data began.    */
   1.159 +	time_t end_time;              /**< When the transfer of data ended.    */
   1.160 +
   1.161 +	size_t current_buffer_size;   /**< This gradually increases for fast
   1.162 +	                                   network connections. */
   1.163 +
   1.164 +	PurpleXferStatusType status;    /**< File Transfer's status.             */
   1.165 +
   1.166 +	/* I/O operations. */
   1.167 +	struct
   1.168 +	{
   1.169 +		void (*init)(PurpleXfer *xfer);
   1.170 +		void (*request_denied)(PurpleXfer *xfer);
   1.171 +		void (*start)(PurpleXfer *xfer);
   1.172 +		void (*end)(PurpleXfer *xfer);
   1.173 +		void (*cancel_send)(PurpleXfer *xfer);
   1.174 +		void (*cancel_recv)(PurpleXfer *xfer);
   1.175 +		gssize (*read)(guchar **buffer, PurpleXfer *xfer);
   1.176 +		gssize (*write)(const guchar *buffer, size_t size, PurpleXfer *xfer);
   1.177 +		void (*ack)(PurpleXfer *xfer, const guchar *buffer, size_t size);
   1.178 +	} ops;
   1.179 +
   1.180 +	PurpleXferUiOps *ui_ops;            /**< UI-specific operations. */
   1.181 +	void *ui_data;                    /**< UI-specific data.       */
   1.182 +
   1.183 +	void *data;                       /**< prpl-specific data.     */
   1.184 +};
   1.185 +
   1.186 +#ifdef __cplusplus
   1.187 +extern "C" {
   1.188 +#endif
   1.189 +
   1.190 +/**************************************************************************/
   1.191 +/** @name File Transfer API                                               */
   1.192 +/**************************************************************************/
   1.193 +/*@{*/
   1.194 +
   1.195 +/**
   1.196 + * Creates a new file transfer handle.
   1.197 + * This is called by prpls.
   1.198 + * The handle starts with a ref count of 1, and this reference
   1.199 + * is owned by the core. The prpl normally does not need to
   1.200 + * purple_xfer_ref or unref.
   1.201 + *
   1.202 + * @param account The account sending or receiving the file.
   1.203 + * @param type    The type of file transfer.
   1.204 + * @param who     The name of the remote user.
   1.205 + *
   1.206 + * @return A file transfer handle.
   1.207 + */
   1.208 +PurpleXfer *purple_xfer_new(PurpleAccount *account,
   1.209 +								PurpleXferType type, const char *who);
   1.210 +
   1.211 +/**
   1.212 + * Returns all xfers
   1.213 + *
   1.214 + * @return all current xfers with refs
   1.215 + */
   1.216 +GList *purple_xfers_get_all(void);
   1.217 +
   1.218 +/**
   1.219 + * Increases the reference count on a PurpleXfer.
   1.220 + * Please call purple_xfer_unref later.
   1.221 + *
   1.222 + * @param xfer A file transfer handle.
   1.223 + */
   1.224 +void purple_xfer_ref(PurpleXfer *xfer);
   1.225 +
   1.226 +/**
   1.227 + * Decreases the reference count on a PurpleXfer.
   1.228 + * If the reference reaches 0, purple_xfer_destroy (an internal function)
   1.229 + * will destroy the xfer. It calls the ui destroy cb first.
   1.230 + * Since the core keeps a ref on the xfer, only an erroneous call to
   1.231 + * this function will destroy the xfer while still in use.
   1.232 + *
   1.233 + * @param xfer A file transfer handle.
   1.234 + */
   1.235 +void purple_xfer_unref(PurpleXfer *xfer);
   1.236 +
   1.237 +/**
   1.238 + * Requests confirmation for a file transfer from the user. If receiving
   1.239 + * a file which is known at this point, this requests user to accept and
   1.240 + * save the file. If the filename is unknown (not set) this only requests user
   1.241 + * to accept the file transfer. In this case protocol must call this function
   1.242 + * again once the filename is available.
   1.243 + *
   1.244 + * @param xfer The file transfer to request confirmation on.
   1.245 + */
   1.246 +void purple_xfer_request(PurpleXfer *xfer);
   1.247 +
   1.248 +/**
   1.249 + * Called if the user accepts the file transfer request.
   1.250 + *
   1.251 + * @param xfer     The file transfer.
   1.252 + * @param filename The filename.
   1.253 + */
   1.254 +void purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename);
   1.255 +
   1.256 +/**
   1.257 + * Called if the user rejects the file transfer request.
   1.258 + *
   1.259 + * @param xfer The file transfer.
   1.260 + */
   1.261 +void purple_xfer_request_denied(PurpleXfer *xfer);
   1.262 +
   1.263 +/**
   1.264 + * Returns the type of file transfer.
   1.265 + *
   1.266 + * @param xfer The file transfer.
   1.267 + *
   1.268 + * @return The type of the file transfer.
   1.269 + */
   1.270 +PurpleXferType purple_xfer_get_type(const PurpleXfer *xfer);
   1.271 +
   1.272 +/**
   1.273 + * Returns the account the file transfer is using.
   1.274 + *
   1.275 + * @param xfer The file transfer.
   1.276 + *
   1.277 + * @return The account.
   1.278 + */
   1.279 +PurpleAccount *purple_xfer_get_account(const PurpleXfer *xfer);
   1.280 +
   1.281 +/**
   1.282 + * Returns the name of the remote user.
   1.283 + *
   1.284 + * @param xfer The file transfer.
   1.285 + *
   1.286 + * @return The name of the remote user.
   1.287 + *
   1.288 + * @since 2.1.0
   1.289 + */
   1.290 +const char *purple_xfer_get_remote_user(const PurpleXfer *xfer);
   1.291 +
   1.292 +/**
   1.293 + * Returns the status of the xfer.
   1.294 + *
   1.295 + * @param xfer The file transfer.
   1.296 + *
   1.297 + * @return The status.
   1.298 + */
   1.299 +PurpleXferStatusType purple_xfer_get_status(const PurpleXfer *xfer);
   1.300 +
   1.301 +/**
   1.302 + * Returns true if the file transfer was canceled.
   1.303 + *
   1.304 + * @param xfer The file transfer.
   1.305 + *
   1.306 + * @return Whether or not the transfer was canceled.
   1.307 + */
   1.308 +gboolean purple_xfer_is_canceled(const PurpleXfer *xfer);
   1.309 +
   1.310 +/**
   1.311 + * Returns the completed state for a file transfer.
   1.312 + *
   1.313 + * @param xfer The file transfer.
   1.314 + *
   1.315 + * @return The completed state.
   1.316 + */
   1.317 +gboolean purple_xfer_is_completed(const PurpleXfer *xfer);
   1.318 +
   1.319 +/**
   1.320 + * Returns the name of the file being sent or received.
   1.321 + *
   1.322 + * @param xfer The file transfer.
   1.323 + *
   1.324 + * @return The filename.
   1.325 + */
   1.326 +const char *purple_xfer_get_filename(const PurpleXfer *xfer);
   1.327 +
   1.328 +/**
   1.329 + * Returns the file's destination filename,
   1.330 + *
   1.331 + * @param xfer The file transfer.
   1.332 + *
   1.333 + * @return The destination filename.
   1.334 + */
   1.335 +const char *purple_xfer_get_local_filename(const PurpleXfer *xfer);
   1.336 +
   1.337 +/**
   1.338 + * Returns the number of bytes sent (or received) so far.
   1.339 + *
   1.340 + * @param xfer The file transfer.
   1.341 + *
   1.342 + * @return The number of bytes sent.
   1.343 + */
   1.344 +size_t purple_xfer_get_bytes_sent(const PurpleXfer *xfer);
   1.345 +
   1.346 +/**
   1.347 + * Returns the number of bytes remaining to send or receive.
   1.348 + *
   1.349 + * @param xfer The file transfer.
   1.350 + *
   1.351 + * @return The number of bytes remaining.
   1.352 + */
   1.353 +size_t purple_xfer_get_bytes_remaining(const PurpleXfer *xfer);
   1.354 +
   1.355 +/**
   1.356 + * Returns the size of the file being sent or received.
   1.357 + *
   1.358 + * @param xfer The file transfer.
   1.359 + *
   1.360 + * @return The total size of the file.
   1.361 + */
   1.362 +size_t purple_xfer_get_size(const PurpleXfer *xfer);
   1.363 +
   1.364 +/**
   1.365 + * Returns the current percentage of progress of the transfer.
   1.366 + *
   1.367 + * This is a number between 0 (0%) and 1 (100%).
   1.368 + *
   1.369 + * @param xfer The file transfer.
   1.370 + *
   1.371 + * @return The percentage complete.
   1.372 + */
   1.373 +double purple_xfer_get_progress(const PurpleXfer *xfer);
   1.374 +
   1.375 +/**
   1.376 + * Returns the local port number in the file transfer.
   1.377 + *
   1.378 + * @param xfer The file transfer.
   1.379 + *
   1.380 + * @return The port number on this end.
   1.381 + */
   1.382 +unsigned int purple_xfer_get_local_port(const PurpleXfer *xfer);
   1.383 +
   1.384 +/**
   1.385 + * Returns the remote IP address in the file transfer.
   1.386 + *
   1.387 + * @param xfer The file transfer.
   1.388 + *
   1.389 + * @return The IP address on the other end.
   1.390 + */
   1.391 +const char *purple_xfer_get_remote_ip(const PurpleXfer *xfer);
   1.392 +
   1.393 +/**
   1.394 + * Returns the remote port number in the file transfer.
   1.395 + *
   1.396 + * @param xfer The file transfer.
   1.397 + *
   1.398 + * @return The port number on the other end.
   1.399 + */
   1.400 +unsigned int purple_xfer_get_remote_port(const PurpleXfer *xfer);
   1.401 +
   1.402 +/**
   1.403 + * Returns the time the transfer of a file started.
   1.404 + *
   1.405 + * @param xfer  The file transfer.
   1.406 + *
   1.407 + * @return The time when the transfer started.
   1.408 + * @since 2.4.0
   1.409 + */
   1.410 +time_t purple_xfer_get_start_time(const PurpleXfer *xfer);
   1.411 +
   1.412 +/**
   1.413 + * Returns the time the transfer of a file ended.
   1.414 + *
   1.415 + * @param xfer  The file transfer.
   1.416 + *
   1.417 + * @return The time when the transfer ended.
   1.418 + * @since 2.4.0
   1.419 + */
   1.420 +time_t purple_xfer_get_end_time(const PurpleXfer *xfer);
   1.421 +
   1.422 +/**
   1.423 + * Sets the completed state for the file transfer.
   1.424 + *
   1.425 + * @param xfer      The file transfer.
   1.426 + * @param completed The completed state.
   1.427 + */
   1.428 +void purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed);
   1.429 +
   1.430 +/**
   1.431 + * Sets the filename for the file transfer.
   1.432 + *
   1.433 + * @param xfer     The file transfer.
   1.434 + * @param message The message.
   1.435 + */
   1.436 +void purple_xfer_set_message(PurpleXfer *xfer, const char *message);
   1.437 +
   1.438 +/**
   1.439 + * Sets the filename for the file transfer.
   1.440 + *
   1.441 + * @param xfer     The file transfer.
   1.442 + * @param filename The filename.
   1.443 + */
   1.444 +void purple_xfer_set_filename(PurpleXfer *xfer, const char *filename);
   1.445 +
   1.446 +/**
   1.447 + * Sets the local filename for the file transfer.
   1.448 + *
   1.449 + * @param xfer     The file transfer.
   1.450 + * @param filename The filename
   1.451 + */
   1.452 +void purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename);
   1.453 +
   1.454 +/**
   1.455 + * Sets the size of the file in a file transfer.
   1.456 + *
   1.457 + * @param xfer The file transfer.
   1.458 + * @param size The size of the file.
   1.459 + */
   1.460 +void purple_xfer_set_size(PurpleXfer *xfer, size_t size);
   1.461 +
   1.462 +/**
   1.463 + * Sets the current working position in the active file transfer.  This
   1.464 + * can be used to jump backward in the file if the protocol detects
   1.465 + * that some bit of data needs to be resent or has been sent twice.
   1.466 + *
   1.467 + * It's used for pausing and resuming an oscar file transfer.
   1.468 + *
   1.469 + * @param xfer       The file transfer.
   1.470 + * @param bytes_sent The new current position in the file.  If we're
   1.471 + *                   sending a file then this is the byte that we will
   1.472 + *                   send.  If we're receiving a file, this is the
   1.473 + *                   next byte that we expect to receive.
   1.474 + */
   1.475 +void purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent);
   1.476 +
   1.477 +/**
   1.478 + * Returns the UI operations structure for a file transfer.
   1.479 + *
   1.480 + * @param xfer The file transfer.
   1.481 + *
   1.482 + * @return The UI operations structure.
   1.483 + */
   1.484 +PurpleXferUiOps *purple_xfer_get_ui_ops(const PurpleXfer *xfer);
   1.485 +
   1.486 +/**
   1.487 + * Sets the read function for the file transfer.
   1.488 + *
   1.489 + * @param xfer The file transfer.
   1.490 + * @param fnc  The read function.
   1.491 + */
   1.492 +void purple_xfer_set_read_fnc(PurpleXfer *xfer,
   1.493 +		gssize (*fnc)(guchar **, PurpleXfer *));
   1.494 +
   1.495 +/**
   1.496 + * Sets the write function for the file transfer.
   1.497 + *
   1.498 + * @param xfer The file transfer.
   1.499 + * @param fnc  The write function.
   1.500 + */
   1.501 +void purple_xfer_set_write_fnc(PurpleXfer *xfer,
   1.502 +		gssize (*fnc)(const guchar *, size_t, PurpleXfer *));
   1.503 +
   1.504 +/**
   1.505 + * Sets the acknowledge function for the file transfer.
   1.506 + *
   1.507 + * @param xfer The file transfer.
   1.508 + * @param fnc  The acknowledge function.
   1.509 + */
   1.510 +void purple_xfer_set_ack_fnc(PurpleXfer *xfer,
   1.511 +		void (*fnc)(PurpleXfer *, const guchar *, size_t));
   1.512 +
   1.513 +/**
   1.514 + * Sets the function to be called if the request is denied.
   1.515 + *
   1.516 + * @param xfer The file transfer.
   1.517 + * @param fnc The request denied prpl callback.
   1.518 + */
   1.519 +void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
   1.520 +
   1.521 +/**
   1.522 + * Sets the transfer initialization function for the file transfer.
   1.523 + *
   1.524 + * This function is required, and must call purple_xfer_start() with
   1.525 + * the necessary parameters. This will be called if the file transfer
   1.526 + * is accepted by the user.
   1.527 + *
   1.528 + * @param xfer The file transfer.
   1.529 + * @param fnc  The transfer initialization function.
   1.530 + */
   1.531 +void purple_xfer_set_init_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
   1.532 +
   1.533 +/**
   1.534 + * Sets the start transfer function for the file transfer.
   1.535 + *
   1.536 + * @param xfer The file transfer.
   1.537 + * @param fnc  The start transfer function.
   1.538 + */
   1.539 +void purple_xfer_set_start_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
   1.540 +
   1.541 +/**
   1.542 + * Sets the end transfer function for the file transfer.
   1.543 + *
   1.544 + * @param xfer The file transfer.
   1.545 + * @param fnc  The end transfer function.
   1.546 + */
   1.547 +void purple_xfer_set_end_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
   1.548 +
   1.549 +/**
   1.550 + * Sets the cancel send function for the file transfer.
   1.551 + *
   1.552 + * @param xfer The file transfer.
   1.553 + * @param fnc  The cancel send function.
   1.554 + */
   1.555 +void purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
   1.556 +
   1.557 +/**
   1.558 + * Sets the cancel receive function for the file transfer.
   1.559 + *
   1.560 + * @param xfer The file transfer.
   1.561 + * @param fnc  The cancel receive function.
   1.562 + */
   1.563 +void purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
   1.564 +
   1.565 +/**
   1.566 + * Reads in data from a file transfer stream.
   1.567 + *
   1.568 + * @param xfer   The file transfer.
   1.569 + * @param buffer The buffer that will be created to contain the data.
   1.570 + *
   1.571 + * @return The number of bytes read, or -1.
   1.572 + */
   1.573 +gssize purple_xfer_read(PurpleXfer *xfer, guchar **buffer);
   1.574 +
   1.575 +/**
   1.576 + * Writes data to a file transfer stream.
   1.577 + *
   1.578 + * @param xfer   The file transfer.
   1.579 + * @param buffer The buffer to read the data from.
   1.580 + * @param size   The number of bytes to write.
   1.581 + *
   1.582 + * @return The number of bytes written, or -1.
   1.583 + */
   1.584 +gssize purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size);
   1.585 +
   1.586 +/**
   1.587 + * Starts a file transfer.
   1.588 + *
   1.589 + * Either @a fd must be specified <i>or</i> @a ip and @a port on a
   1.590 + * file receive transfer. On send, @a fd must be specified, and
   1.591 + * @a ip and @a port are ignored.
   1.592 + *
   1.593 + * Prior to libpurple 2.6.0, passing '0' to @a fd was special-cased to
   1.594 + * allow the protocol plugin to facilitate the file transfer itself. As of
   1.595 + * 2.6.0, this is supported (for backward compatibility), but will be
   1.596 + * removed in libpurple 3.0.0. If a prpl detects that the running libpurple
   1.597 + * is running 2.6.0 or higher, it should use the invalid fd '-1'.
   1.598 + *
   1.599 + * @param xfer The file transfer.
   1.600 + * @param fd   The file descriptor for the socket.
   1.601 + * @param ip   The IP address to connect to.
   1.602 + * @param port The port to connect to.
   1.603 + */
   1.604 +void purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip,
   1.605 +					 unsigned int port);
   1.606 +
   1.607 +/**
   1.608 + * Ends a file transfer.
   1.609 + *
   1.610 + * @param xfer The file transfer.
   1.611 + */
   1.612 +void purple_xfer_end(PurpleXfer *xfer);
   1.613 +
   1.614 +/**
   1.615 + * Adds a new file transfer to the list of file transfers. Call this only
   1.616 + * if you are not using purple_xfer_start.
   1.617 + *
   1.618 + * @param xfer The file transfer.
   1.619 + */
   1.620 +void purple_xfer_add(PurpleXfer *xfer);
   1.621 +
   1.622 +/**
   1.623 + * Cancels a file transfer on the local end.
   1.624 + *
   1.625 + * @param xfer The file transfer.
   1.626 + */
   1.627 +void purple_xfer_cancel_local(PurpleXfer *xfer);
   1.628 +
   1.629 +/**
   1.630 + * Cancels a file transfer from the remote end.
   1.631 + *
   1.632 + * @param xfer The file transfer.
   1.633 + */
   1.634 +void purple_xfer_cancel_remote(PurpleXfer *xfer);
   1.635 +
   1.636 +/**
   1.637 + * Displays a file transfer-related error message.
   1.638 + *
   1.639 + * This is a wrapper around purple_notify_error(), which automatically
   1.640 + * specifies a title ("File transfer to <i>user</i> failed" or
   1.641 + * "File Transfer from <i>user</i> failed").
   1.642 + *
   1.643 + * @param type    The type of file transfer.
   1.644 + * @param account The account sending or receiving the file.
   1.645 + * @param who     The user on the other end of the transfer.
   1.646 + * @param msg     The message to display.
   1.647 + */
   1.648 +void purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg);
   1.649 +
   1.650 +/**
   1.651 + * Updates file transfer progress.
   1.652 + *
   1.653 + * @param xfer      The file transfer.
   1.654 + */
   1.655 +void purple_xfer_update_progress(PurpleXfer *xfer);
   1.656 +
   1.657 +/**
   1.658 + * Displays a file transfer-related message in the conversation window
   1.659 + *
   1.660 + * This is a wrapper around purple_conversation_write
   1.661 + *
   1.662 + * @param xfer The file transfer to which this message relates.
   1.663 + * @param message The message to display.
   1.664 + * @param is_error Is this an error message?.
   1.665 + */
   1.666 +void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error);
   1.667 +
   1.668 +/**
   1.669 + * Allows the UI to signal it's ready to send/receive data (depending on
   1.670 + * the direction of the file transfer. Used when the UI is providing
   1.671 + * read/write/data_not_sent UI ops.
   1.672 + *
   1.673 + * @param xfer The file transfer which is ready.
   1.674 + *
   1.675 + * @since 2.6.0
   1.676 + */
   1.677 +void purple_xfer_ui_ready(PurpleXfer *xfer);
   1.678 +
   1.679 +/**
   1.680 + * Allows the prpl to signal it's readh to send/receive data (depending on
   1.681 + * the direction of the file transfer. Used when the prpl provides read/write
   1.682 + * ops and cannot/does not provide a raw fd to the core.
   1.683 + *
   1.684 + * @param xfer The file transfer which is ready.
   1.685 + *
   1.686 + * @since 2.6.0
   1.687 + */
   1.688 +void purple_xfer_prpl_ready(PurpleXfer *xfer);
   1.689 +
   1.690 +/*@}*/
   1.691 +
   1.692 +/**************************************************************************/
   1.693 +/** @name UI Registration Functions                                       */
   1.694 +/**************************************************************************/
   1.695 +/*@{*/
   1.696 +
   1.697 +/**
   1.698 + * Returns the handle to the file transfer subsystem
   1.699 + *
   1.700 + * @return The handle
   1.701 + */
   1.702 +void *purple_xfers_get_handle(void);
   1.703 +
   1.704 +/**
   1.705 + * Initializes the file transfer subsystem
   1.706 + */
   1.707 +void purple_xfers_init(void);
   1.708 +
   1.709 +/**
   1.710 + * Uninitializes the file transfer subsystem
   1.711 + */
   1.712 +void purple_xfers_uninit(void);
   1.713 +
   1.714 +/**
   1.715 + * Sets the UI operations structure to be used in all purple file transfers.
   1.716 + *
   1.717 + * @param ops The UI operations structure.
   1.718 + */
   1.719 +void purple_xfers_set_ui_ops(PurpleXferUiOps *ops);
   1.720 +
   1.721 +/**
   1.722 + * Returns the UI operations structure to be used in all purple file transfers.
   1.723 + *
   1.724 + * @return The UI operations structure.
   1.725 + */
   1.726 +PurpleXferUiOps *purple_xfers_get_ui_ops(void);
   1.727 +
   1.728 +/*@}*/
   1.729 +
   1.730 +#ifdef __cplusplus
   1.731 +}
   1.732 +#endif
   1.733 +
   1.734 +#endif /* _PURPLE_FT_H_ */