Mercurial > pidgin
diff libpurple/ft.h @ 27872:4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Patch from Jan "HanzZ" Kaluza with a few changes by darkrain42.
committer: Paul Aurich <paul@darkrain42.org>
author | hanzz@soc.pidgin.im |
---|---|
date | Mon, 10 Aug 2009 15:57:35 +0000 |
parents | b99d6d21cd79 |
children | 6adbdd4b2963 |
line wrap: on
line diff
--- a/libpurple/ft.h Mon Aug 10 04:40:54 2009 +0000 +++ b/libpurple/ft.h Mon Aug 10 15:57:35 2009 +0000 @@ -77,10 +77,50 @@ void (*cancel_local)(PurpleXfer *xfer); void (*cancel_remote)(PurpleXfer *xfer); + /** + * UI op to write data received from the prpl. The UI must deal with the + * entire buffer and return size, or it is treated as an error. + * + * @param xfer The file transfer structure + * @param buffer The buffer to write + * @param size The size of the buffer + * + * @return size if the write was successful, or a value between 0 and + * size on error. + * @since 2.6.0 + */ + gssize (*write)(PurpleXfer *xfer, const guchar *buffer, gssize size); + + /** + * UI op to read data to send to the prpl for a file transfer. + * + * @param xfer The file transfer structure + * @param buffer A pointer to a buffer. The UI must allocate this buffer. + * libpurple will free the data. + * @param size The maximum amount of data to put in the buffer. + * + * @returns The amount of data in the buffer, 0 if nothing is available, + * and a negative value if an error occurred and the transfer + * should be cancelled (libpurple will cancel). + * @since 2.6.0 + */ + gssize (*read)(PurpleXfer *xfer, guchar **buffer, gssize size); + + /** + * Op to notify the UI that not all the data read in was written. The UI + * should re-enqueue this data and return it the next time read is called. + * + * This MUST be implemented if read and write are implemented. + * + * @param xfer The file transfer structure + * @param buffer A pointer to the beginning of the unwritten data. + * @param size The amount of unwritten data. + * + * @since 2.6.0 + */ + void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size); + void (*_purple_reserved1)(void); - void (*_purple_reserved2)(void); - void (*_purple_reserved3)(void); - void (*_purple_reserved4)(void); } PurpleXferUiOps; /** @@ -132,7 +172,6 @@ gssize (*read)(guchar **buffer, PurpleXfer *xfer); gssize (*write)(const guchar *buffer, size_t size, PurpleXfer *xfer); void (*ack)(PurpleXfer *xfer, const guchar *buffer, size_t size); - } ops; PurpleXferUiOps *ui_ops; /**< UI-specific operations. */ @@ -617,6 +656,16 @@ */ void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error); +/** + * Allows the UI to signal it's ready to send/receive data (depending on + * the direction of the file transfer. + * + * @param xfer The file transfer for which data is ready. + * + * @since 2.6.0 + */ +void purple_xfer_ui_ready(PurpleXfer *xfer); + /*@}*/ /**************************************************************************/