comparison libpurple/ft.h @ 32368:ca4714f51bb1

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 0c3ef8388ce0f274d695767f513518b859889979) to branch 'im.pidgin.pidgin' (head 8ee87bdc7a99e5d58bf700eaf08abe409ae4ede8)
author Ethan Blanton <elb@pidgin.im>
date Tue, 29 Nov 2011 03:59:09 +0000
parents 5525312cf589
children 98520ee78f12
comparison
equal deleted inserted replaced
32367:00ea5f8ef509 32368:ca4714f51bb1
85 * @param buffer The buffer to write 85 * @param buffer The buffer to write
86 * @param size The size of the buffer 86 * @param size The size of the buffer
87 * 87 *
88 * @return size if the write was successful, or a value between 0 and 88 * @return size if the write was successful, or a value between 0 and
89 * size on error. 89 * size on error.
90 * @since 2.6.0
91 */ 90 */
92 gssize (*ui_write)(PurpleXfer *xfer, const guchar *buffer, gssize size); 91 gssize (*ui_write)(PurpleXfer *xfer, const guchar *buffer, gssize size);
93 92
94 /** 93 /**
95 * UI op to read data to send to the prpl for a file transfer. 94 * UI op to read data to send to the prpl for a file transfer.
100 * @param size The maximum amount of data to put in the buffer. 99 * @param size The maximum amount of data to put in the buffer.
101 * 100 *
102 * @returns The amount of data in the buffer, 0 if nothing is available, 101 * @returns The amount of data in the buffer, 0 if nothing is available,
103 * and a negative value if an error occurred and the transfer 102 * and a negative value if an error occurred and the transfer
104 * should be cancelled (libpurple will cancel). 103 * should be cancelled (libpurple will cancel).
105 * @since 2.6.0
106 */ 104 */
107 gssize (*ui_read)(PurpleXfer *xfer, guchar **buffer, gssize size); 105 gssize (*ui_read)(PurpleXfer *xfer, guchar **buffer, gssize size);
108 106
109 /** 107 /**
110 * Op to notify the UI that not all the data read in was written. The UI 108 * Op to notify the UI that not all the data read in was written. The UI
113 * This MUST be implemented if read and write are implemented. 111 * This MUST be implemented if read and write are implemented.
114 * 112 *
115 * @param xfer The file transfer structure 113 * @param xfer The file transfer structure
116 * @param buffer A pointer to the beginning of the unwritten data. 114 * @param buffer A pointer to the beginning of the unwritten data.
117 * @param size The amount of unwritten data. 115 * @param size The amount of unwritten data.
118 *
119 * @since 2.6.0
120 */ 116 */
121 void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size); 117 void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size);
122 118
123 /** 119 /**
124 * Op to create a thumbnail image for a file transfer 120 * Op to create a thumbnail image for a file transfer
142 transfer. */ 138 transfer. */
143 139
144 char *message; /**< A message sent with the request */ 140 char *message; /**< A message sent with the request */
145 char *filename; /**< The name sent over the network. */ 141 char *filename; /**< The name sent over the network. */
146 char *local_filename; /**< The name on the local hard drive. */ 142 char *local_filename; /**< The name on the local hard drive. */
147 size_t size; /**< The size of the file. */ 143 goffset size; /**< The size of the file. */
148 144
149 FILE *dest_fp; /**< The destination file pointer. */ 145 FILE *dest_fp; /**< The destination file pointer. */
150 146
151 char *remote_ip; /**< The remote IP address. */ 147 char *remote_ip; /**< The remote IP address. */
152 int local_port; /**< The local port. */ 148 int local_port; /**< The local port. */
153 int remote_port; /**< The remote port. */ 149 int remote_port; /**< The remote port. */
154 150
155 int fd; /**< The socket file descriptor. */ 151 int fd; /**< The socket file descriptor. */
156 int watcher; /**< Watcher. */ 152 int watcher; /**< Watcher. */
157 153
158 size_t bytes_sent; /**< The number of bytes sent. */ 154 goffset bytes_sent; /**< The number of bytes sent. */
159 size_t bytes_remaining; /**< The number of bytes remaining. */ 155 goffset bytes_remaining; /**< The number of bytes remaining. */
160 time_t start_time; /**< When the transfer of data began. */ 156 time_t start_time; /**< When the transfer of data began. */
161 time_t end_time; /**< When the transfer of data ended. */ 157 time_t end_time; /**< When the transfer of data ended. */
162 158
163 size_t current_buffer_size; /**< This gradually increases for fast 159 size_t current_buffer_size; /**< This gradually increases for fast
164 network connections. */ 160 network connections. */
183 } ops; 179 } ops;
184 180
185 PurpleXferUiOps *ui_ops; /**< UI-specific operations. */ 181 PurpleXferUiOps *ui_ops; /**< UI-specific operations. */
186 void *ui_data; /**< UI-specific data. */ 182 void *ui_data; /**< UI-specific data. */
187 183
188 void *data; /**< prpl-specific data. */ 184 void *proto_data; /**< prpl-specific data. */
189 }; 185 };
190 186
191 #ifdef __cplusplus 187 #ifdef __cplusplus
192 extern "C" { 188 extern "C" {
193 #endif 189 #endif
264 * @param xfer The file transfer. 260 * @param xfer The file transfer.
265 */ 261 */
266 void purple_xfer_request_denied(PurpleXfer *xfer); 262 void purple_xfer_request_denied(PurpleXfer *xfer);
267 263
268 /** 264 /**
265 * Returns the socket file descriptor.
266 *
267 * @param xfer The file transfer.
268 *
269 * @return The socket file descriptor.
270 */
271 int purple_xfer_get_fd(PurpleXfer *xfer);
272
273 /**
274 * Returns the Watcher for the transfer.
275 *
276 * @param xfer The file transfer.
277 *
278 * @return The watcher.
279 */
280 int purple_xfer_get_watcher(PurpleXfer *xfer);
281
282 /**
269 * Returns the type of file transfer. 283 * Returns the type of file transfer.
270 * 284 *
271 * @param xfer The file transfer. 285 * @param xfer The file transfer.
272 * 286 *
273 * @return The type of the file transfer. 287 * @return The type of the file transfer.
287 * Returns the name of the remote user. 301 * Returns the name of the remote user.
288 * 302 *
289 * @param xfer The file transfer. 303 * @param xfer The file transfer.
290 * 304 *
291 * @return The name of the remote user. 305 * @return The name of the remote user.
292 *
293 * @since 2.1.0
294 */ 306 */
295 const char *purple_xfer_get_remote_user(const PurpleXfer *xfer); 307 const char *purple_xfer_get_remote_user(const PurpleXfer *xfer);
296 308
297 /** 309 /**
298 * Returns the status of the xfer. 310 * Returns the status of the xfer.
307 * Returns true if the file transfer was cancelled. 319 * Returns true if the file transfer was cancelled.
308 * 320 *
309 * @param xfer The file transfer. 321 * @param xfer The file transfer.
310 * 322 *
311 * @return Whether or not the transfer was cancelled. 323 * @return Whether or not the transfer was cancelled.
312 * FIXME: This should be renamed using cancelled for 3.0.0. 324 */
313 */ 325 gboolean purple_xfer_is_cancelled(const PurpleXfer *xfer);
314 gboolean purple_xfer_is_canceled(const PurpleXfer *xfer);
315 326
316 /** 327 /**
317 * Returns the completed state for a file transfer. 328 * Returns the completed state for a file transfer.
318 * 329 *
319 * @param xfer The file transfer. 330 * @param xfer The file transfer.
345 * 356 *
346 * @param xfer The file transfer. 357 * @param xfer The file transfer.
347 * 358 *
348 * @return The number of bytes sent. 359 * @return The number of bytes sent.
349 */ 360 */
350 size_t purple_xfer_get_bytes_sent(const PurpleXfer *xfer); 361 goffset purple_xfer_get_bytes_sent(const PurpleXfer *xfer);
351 362
352 /** 363 /**
353 * Returns the number of bytes remaining to send or receive. 364 * Returns the number of bytes remaining to send or receive.
354 * 365 *
355 * @param xfer The file transfer. 366 * @param xfer The file transfer.
356 * 367 *
357 * @return The number of bytes remaining. 368 * @return The number of bytes remaining.
358 */ 369 */
359 size_t purple_xfer_get_bytes_remaining(const PurpleXfer *xfer); 370 goffset purple_xfer_get_bytes_remaining(const PurpleXfer *xfer);
360 371
361 /** 372 /**
362 * Returns the size of the file being sent or received. 373 * Returns the size of the file being sent or received.
363 * 374 *
364 * @param xfer The file transfer. 375 * @param xfer The file transfer.
365 * 376 *
366 * @return The total size of the file. 377 * @return The total size of the file.
367 */ 378 */
368 size_t purple_xfer_get_size(const PurpleXfer *xfer); 379 goffset purple_xfer_get_size(const PurpleXfer *xfer);
369 380
370 /** 381 /**
371 * Returns the current percentage of progress of the transfer. 382 * Returns the current percentage of progress of the transfer.
372 * 383 *
373 * This is a number between 0 (0%) and 1 (100%). 384 * This is a number between 0 (0%) and 1 (100%).
409 * Returns the time the transfer of a file started. 420 * Returns the time the transfer of a file started.
410 * 421 *
411 * @param xfer The file transfer. 422 * @param xfer The file transfer.
412 * 423 *
413 * @return The time when the transfer started. 424 * @return The time when the transfer started.
414 * @since 2.4.0
415 */ 425 */
416 time_t purple_xfer_get_start_time(const PurpleXfer *xfer); 426 time_t purple_xfer_get_start_time(const PurpleXfer *xfer);
417 427
418 /** 428 /**
419 * Returns the time the transfer of a file ended. 429 * Returns the time the transfer of a file ended.
420 * 430 *
421 * @param xfer The file transfer. 431 * @param xfer The file transfer.
422 * 432 *
423 * @return The time when the transfer ended. 433 * @return The time when the transfer ended.
424 * @since 2.4.0
425 */ 434 */
426 time_t purple_xfer_get_end_time(const PurpleXfer *xfer); 435 time_t purple_xfer_get_end_time(const PurpleXfer *xfer);
436
437 /**
438 * Sets the socket file descriptor.
439 *
440 * @param xfer The file transfer.
441 * @param fd The file descriptor.
442 */
443 void purple_xfer_set_fd(PurpleXfer *xfer, int fd);
444
445 /**
446 * Sets the watcher for the file transfer.
447 *
448 * @param xfer The file transfer.
449 * @param watcher The watcher.
450 */
451 void purple_xfer_set_watcher(PurpleXfer *xfer, int watcher);
427 452
428 /** 453 /**
429 * Sets the completed state for the file transfer. 454 * Sets the completed state for the file transfer.
430 * 455 *
431 * @param xfer The file transfer. 456 * @param xfer The file transfer.
432 * @param completed The completed state. 457 * @param completed The completed state.
433 */ 458 */
434 void purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed); 459 void purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed);
435 460
436 /** 461 /**
462 * Sets the current status for the file transfer.
463 *
464 * @param xfer The file transfer.
465 * @param status The current status.
466 */
467 void purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatusType status);
468
469 /**
437 * Sets the filename for the file transfer. 470 * Sets the filename for the file transfer.
438 * 471 *
439 * @param xfer The file transfer. 472 * @param xfer The file transfer.
440 * @param message The message. 473 * @param message The message.
441 */ 474 */
461 * Sets the size of the file in a file transfer. 494 * Sets the size of the file in a file transfer.
462 * 495 *
463 * @param xfer The file transfer. 496 * @param xfer The file transfer.
464 * @param size The size of the file. 497 * @param size The size of the file.
465 */ 498 */
466 void purple_xfer_set_size(PurpleXfer *xfer, size_t size); 499 void purple_xfer_set_size(PurpleXfer *xfer, goffset size);
500
501 /**
502 * Sets the local port of the file transfer.
503 *
504 * @param xfer The file transfer.
505 * @param local_port The local port.
506 */
507 void purple_xfer_set_local_port(PurpleXfer *xfer, unsigned int local_port);
467 508
468 /** 509 /**
469 * Sets the current working position in the active file transfer. This 510 * Sets the current working position in the active file transfer. This
470 * can be used to jump backward in the file if the protocol detects 511 * can be used to jump backward in the file if the protocol detects
471 * that some bit of data needs to be resent or has been sent twice. 512 * that some bit of data needs to be resent or has been sent twice.
476 * @param bytes_sent The new current position in the file. If we're 517 * @param bytes_sent The new current position in the file. If we're
477 * sending a file then this is the byte that we will 518 * sending a file then this is the byte that we will
478 * send. If we're receiving a file, this is the 519 * send. If we're receiving a file, this is the
479 * next byte that we expect to receive. 520 * next byte that we expect to receive.
480 */ 521 */
481 void purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent); 522 void purple_xfer_set_bytes_sent(PurpleXfer *xfer, goffset bytes_sent);
482 523
483 /** 524 /**
484 * Returns the UI operations structure for a file transfer. 525 * Returns the UI operations structure for a file transfer.
485 * 526 *
486 * @param xfer The file transfer. 527 * @param xfer The file transfer.
594 * 635 *
595 * Either @a fd must be specified <i>or</i> @a ip and @a port on a 636 * Either @a fd must be specified <i>or</i> @a ip and @a port on a
596 * file receive transfer. On send, @a fd must be specified, and 637 * file receive transfer. On send, @a fd must be specified, and
597 * @a ip and @a port are ignored. 638 * @a ip and @a port are ignored.
598 * 639 *
599 * Prior to libpurple 2.6.0, passing '0' to @a fd was special-cased to 640 * Passing @a fd as '-1' is a special-case and indicates to the
600 * allow the protocol plugin to facilitate the file transfer itself. As of 641 * protocol plugin to facilitate the file transfer itself.
601 * 2.6.0, this is supported (for backward compatibility), but will be
602 * removed in libpurple 3.0.0. If a prpl detects that the running libpurple
603 * is running 2.6.0 or higher, it should use the invalid fd '-1'.
604 * 642 *
605 * @param xfer The file transfer. 643 * @param xfer The file transfer.
606 * @param fd The file descriptor for the socket. 644 * @param fd The file descriptor for the socket.
607 * @param ip The IP address to connect to. 645 * @param ip The IP address to connect to.
608 * @param port The port to connect to. 646 * @param port The port to connect to.
675 * Allows the UI to signal it's ready to send/receive data (depending on 713 * Allows the UI to signal it's ready to send/receive data (depending on
676 * the direction of the file transfer. Used when the UI is providing 714 * the direction of the file transfer. Used when the UI is providing
677 * read/write/data_not_sent UI ops. 715 * read/write/data_not_sent UI ops.
678 * 716 *
679 * @param xfer The file transfer which is ready. 717 * @param xfer The file transfer which is ready.
680 *
681 * @since 2.6.0
682 */ 718 */
683 void purple_xfer_ui_ready(PurpleXfer *xfer); 719 void purple_xfer_ui_ready(PurpleXfer *xfer);
684 720
685 /** 721 /**
686 * Allows the prpl to signal it's ready to send/receive data (depending on 722 * Allows the prpl to signal it's ready to send/receive data (depending on
687 * the direction of the file transfer. Used when the prpl provides read/write 723 * the direction of the file transfer. Used when the prpl provides read/write
688 * ops and cannot/does not provide a raw fd to the core. 724 * ops and cannot/does not provide a raw fd to the core.
689 * 725 *
690 * @param xfer The file transfer which is ready. 726 * @param xfer The file transfer which is ready.
691 *
692 * @since 2.6.0
693 */ 727 */
694 void purple_xfer_prpl_ready(PurpleXfer *xfer); 728 void purple_xfer_prpl_ready(PurpleXfer *xfer);
695 729
696 /** 730 /**
697 * Gets the thumbnail data for a transfer 731 * Gets the thumbnail data for a transfer
698 * 732 *
699 * @param xfer The file transfer to get the thumbnail for 733 * @param xfer The file transfer to get the thumbnail for
700 * @param len If not @c NULL, the length of the thumbnail data returned 734 * @param len If not @c NULL, the length of the thumbnail data returned
701 * will be set in the location pointed to by this. 735 * will be set in the location pointed to by this.
702 * @return The thumbnail data, or NULL if there is no thumbnail 736 * @return The thumbnail data, or NULL if there is no thumbnail
703 * @since 2.7.0
704 */ 737 */
705 gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len); 738 gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len);
706 739
707 /** 740 /**
708 * Gets the mimetype of the thumbnail preview for a transfer 741 * Gets the mimetype of the thumbnail preview for a transfer
709 * 742 *
710 * @param xfer The file transfer to get the mimetype for 743 * @param xfer The file transfer to get the mimetype for
711 * @return The mimetype of the thumbnail, or @c NULL if not thumbnail is set 744 * @return The mimetype of the thumbnail, or @c NULL if not thumbnail is set
712 * @since 2.7.0
713 */ 745 */
714 const gchar *purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer); 746 const gchar *purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer);
715 747
716 748
717 /** 749 /**
719 * 751 *
720 * @param xfer The file transfer to set the data for 752 * @param xfer The file transfer to set the data for
721 * @param thumbnail A pointer to the thumbnail data, this will be copied 753 * @param thumbnail A pointer to the thumbnail data, this will be copied
722 * @param size The size in bytes of the passed in thumbnail data 754 * @param size The size in bytes of the passed in thumbnail data
723 * @param mimetype The mimetype of the generated thumbnail 755 * @param mimetype The mimetype of the generated thumbnail
724 * @since 2.7.0
725 */ 756 */
726 void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail, 757 void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
727 gsize size, const gchar *mimetype); 758 gsize size, const gchar *mimetype);
728 759
729 /** 760 /**
731 * will be no-op in case the UI doesn't implement thumbnail creation 762 * will be no-op in case the UI doesn't implement thumbnail creation
732 * 763 *
733 * @param xfer The file transfer to create a thumbnail for 764 * @param xfer The file transfer to create a thumbnail for
734 * @param formats A comma-separated list of mimetypes for image formats 765 * @param formats A comma-separated list of mimetypes for image formats
735 * the protocols can use for thumbnails. 766 * the protocols can use for thumbnails.
736 * @since 2.7.0
737 */ 767 */
738 void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats); 768 void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats);
739 769
770 /**
771 * Sets the protocol data for a file transfer.
772 *
773 * @param xfer The file transfer.
774 * @param proto_data The protocol data to set for the file transfer.
775 */
776 void purple_xfer_set_protocol_data(PurpleXfer *xfer, gpointer proto_data);
777
778 /**
779 * Gets the protocol data for a file transfer.
780 *
781 * @param xfer The file transfer.
782 *
783 * @return The protocol data for the file transfer.
784 */
785 gpointer purple_xfer_get_protocol_data(const PurpleXfer *xfer);
786
787 /**
788 * Set the UI data associated with this file transfer.
789 *
790 * @param xfer The file transfer.
791 * @param ui_data A pointer to associate with this file transfer.
792 */
793 void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data);
794
795 /**
796 * Get the UI data associated with this file transfer.
797 *
798 * @param xfer The file transfer.
799 *
800 * @return The UI data associated with this file transfer. This is a
801 * convenience field provided to the UIs--it is not
802 * used by the libpurple core.
803 */
804 gpointer purple_xfer_get_ui_data(const PurpleXfer *xfer);
740 805
741 /*@}*/ 806 /*@}*/
742 807
743 /**************************************************************************/ 808 /**************************************************************************/
744 /** @name UI Registration Functions */ 809 /** @name UI Registration Functions */
781 #ifdef __cplusplus 846 #ifdef __cplusplus
782 } 847 }
783 #endif 848 #endif
784 849
785 #endif /* _PURPLE_FT_H_ */ 850 #endif /* _PURPLE_FT_H_ */
851