Fix an incorrect call to soup_message_set_request.
[pidgin-git.git] / libpurple / xfer.h
blobdb303808140f34c23c3dbdb00e650f9a3fb02ebf
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_XFER_H
23 #define PURPLE_XFER_H
24 /**
25 * SECTION:xfer
26 * @section_id: libpurple-xfer
27 * @short_description: <filename>xfer.h</filename>
28 * @title: File Transfer API
29 * @see_also: <link linkend="chapter-signals-xfer">File Transfer signals</link>
32 #define PURPLE_TYPE_XFER_UI_OPS (purple_xfer_ui_ops_get_type())
34 #define PURPLE_TYPE_PROTOCOL_XFER (purple_protocol_xfer_get_type())
35 #define PURPLE_PROTOCOL_XFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL_XFER, PurpleProtocolXfer))
36 #define PURPLE_IS_PROTOCOL_XFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_XFER))
37 #define PURPLE_PROTOCOL_XFER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_XFER, PurpleProtocolXferInterface))
39 /**************************************************************************/
40 /* Data Structures */
41 /**************************************************************************/
42 typedef struct _PurpleXferUiOps PurpleXferUiOps;
44 typedef struct _PurpleProtocolXfer PurpleProtocolXfer;
45 typedef struct _PurpleProtocolXferInterface PurpleProtocolXferInterface;
47 #include <glib.h>
48 #include <stdio.h>
50 #include "account.h"
51 #include "connection.h"
53 /**
54 * PurpleXferType:
55 * @PURPLE_XFER_TYPE_UNKNOWN: Unknown file transfer type.
56 * @PURPLE_XFER_TYPE_SEND: File sending.
57 * @PURPLE_XFER_TYPE_RECEIVE: File receiving.
59 * Types of file transfers.
61 typedef enum
63 PURPLE_XFER_TYPE_UNKNOWN = 0,
64 PURPLE_XFER_TYPE_SEND,
65 PURPLE_XFER_TYPE_RECEIVE
66 } PurpleXferType;
68 /**
69 * PurpleXferStatus:
70 * @PURPLE_XFER_STATUS_UNKNOWN: Unknown, the xfer may be null.
71 * @PURPLE_XFER_STATUS_NOT_STARTED: It hasn't started yet.
72 * @PURPLE_XFER_STATUS_ACCEPTED: Receive accepted, but destination file
73 * not selected yet.
74 * @PURPLE_XFER_STATUS_STARTED: purple_xfer_start has been called.
75 * @PURPLE_XFER_STATUS_DONE: The xfer completed successfully.
76 * @PURPLE_XFER_STATUS_CANCEL_LOCAL: The xfer was cancelled by us.
77 * @PURPLE_XFER_STATUS_CANCEL_REMOTE: The xfer was cancelled by the other end,
78 * or we couldn't connect.
80 * The different states of the xfer.
82 typedef enum
84 PURPLE_XFER_STATUS_UNKNOWN = 0,
85 PURPLE_XFER_STATUS_NOT_STARTED,
86 PURPLE_XFER_STATUS_ACCEPTED,
87 PURPLE_XFER_STATUS_STARTED,
88 PURPLE_XFER_STATUS_DONE,
89 PURPLE_XFER_STATUS_CANCEL_LOCAL,
90 PURPLE_XFER_STATUS_CANCEL_REMOTE
91 } PurpleXferStatus;
93 G_BEGIN_DECLS
95 #define PURPLE_TYPE_XFER (purple_xfer_get_type())
97 G_DECLARE_DERIVABLE_TYPE(PurpleXfer, purple_xfer, PURPLE, XFER, GObject)
99 /**
100 * PurpleXferUiOps:
101 * @new_xfer: UI op that's called after a new transfer is created.
102 * @destroy: UI op that's called when a transfer is being destroyed.
103 * @add_xfer: UI op that's called when a transfer should be added to the UI.
104 * @update_progress: UI op that's called when a transfer's progress has been
105 * updated.
106 * @cancel_local: UI op that's called when a transfer has been cancelled on the
107 * local end.
108 * @cancel_remote: UI op that's called when a transfer has been cancelled on
109 * the remote end.
110 * @ui_write: UI op to write data received from the protocol. The UI must deal
111 * with the entire buffer and return size, or it is treated as an
112 * error.
113 * <sbr/>@xfer: The file transfer structure
114 * <sbr/>@buffer: The buffer to write
115 * <sbr/>@size: The size of the buffer
116 * <sbr/>Returns: size if the write was successful, or a value
117 * between 0 and size on error.
118 * @ui_read: UI op to read data to send to the protocol for a file transfer.
119 * <sbr/>@xfer: The file transfer structure
120 * <sbr/>@buffer: A pointer to a buffer. The UI must allocate this
121 * buffer. libpurple will free the data.
122 * <sbr/>@size: The maximum amount of data to put in the buffer.
123 * <sbr/>Returns: The amount of data in the buffer, 0 if nothing is
124 * available, and a negative value if an error occurred
125 * and the transfer should be cancelled (libpurple will
126 * cancel).
127 * @data_not_sent: Op to notify the UI that not all the data read in was
128 * written. The UI should re-enqueue this data and return it the
129 * next time read is called.
130 * <sbr/>This <emphasis>MUST</emphasis> be implemented if read
131 * and write are implemented.
132 * <sbr/>@xfer: The file transfer structure
133 * <sbr/>@buffer: A pointer to the beginning of the unwritten
134 * data.
135 * <sbr/>@size: The amount of unwritten data.
136 * @add_thumbnail: Op to create a thumbnail image for a file transfer
138 * File transfer UI operations.
140 * Any UI representing a file transfer must assign a filled-out
141 * PurpleXferUiOps structure to the purple_xfer.
143 struct _PurpleXferUiOps
145 void (*new_xfer)(PurpleXfer *xfer);
146 void (*destroy)(PurpleXfer *xfer);
147 void (*add_xfer)(PurpleXfer *xfer);
148 void (*update_progress)(PurpleXfer *xfer, double percent);
149 void (*cancel_local)(PurpleXfer *xfer);
150 void (*cancel_remote)(PurpleXfer *xfer);
151 gssize (*ui_write)(PurpleXfer *xfer, const guchar *buffer, gssize size);
152 gssize (*ui_read)(PurpleXfer *xfer, guchar **buffer, gssize size);
153 void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size);
154 void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
158 * PurpleXferClass:
159 * @init: Called when the file transfer is accepted by the user. Must call
160 * purple_xfer_start() and must be implemented.
161 * @request_denied: Called when the file transfer is denied by the other side.
162 * @start: Called to start the file transfer.
163 * @end: Called when the file transfer should end.
164 * @cancel_send: Handler for cancelling a sending file transfer.
165 * @cancel_recv: Handler for cancelling a receiving file transfer.
166 * @read: Called when reading data from the file transfer.
167 * @write: Called when writing data to the file transfer.
168 * @ack: Called when a file transfer is acknowledged.
170 * Base class for all #PurpleXfer's
172 struct _PurpleXferClass
174 GObjectClass parent_class;
176 void (*init)(PurpleXfer *xfer);
177 void (*request_denied)(PurpleXfer *xfer);
178 void (*start)(PurpleXfer *xfer);
179 void (*end)(PurpleXfer *xfer);
180 void (*cancel_send)(PurpleXfer *xfer);
181 void (*cancel_recv)(PurpleXfer *xfer);
182 gssize (*read)(PurpleXfer *xfer, guchar **buffer, gsize size);
183 gssize (*write)(PurpleXfer *xfer, const guchar *buffer, gsize size);
184 void (*ack)(PurpleXfer *xfer, const guchar *buffer, gsize size);
186 /*< private >*/
187 gpointer reserved[4];
191 * PurpleProtocolXferInterface:
192 * @can_receive: A method to determine if we can receive a file.
193 * @send_file: A method to determine if we can send a file.
194 * @new_xfer: A method to create a new file transfer.
196 * The protocol file transfer interface.
198 * This interface provides file transfer callbacks for the protocol.
200 struct _PurpleProtocolXferInterface
202 /*< private >*/
203 GTypeInterface parent_iface;
205 /*< public >*/
206 gboolean (*can_receive)(PurpleProtocolXfer *prplxfer,
207 PurpleConnection *connection, const gchar *who);
209 void (*send_file)(PurpleProtocolXfer *prplxfer,
210 PurpleConnection *connection, const gchar *who,
211 const gchar *filename);
213 PurpleXfer *(*new_xfer)(PurpleProtocolXfer *prplxfer,
214 PurpleConnection *connection, const gchar *who);
217 /**************************************************************************/
218 /* File Transfer API */
219 /**************************************************************************/
222 * purple_xfer_new:
223 * @account: The account sending or receiving the file.
224 * @type: The type of file transfer.
225 * @who: The name of the remote user.
227 * Creates a new file transfer handle.
228 * This is called by protocols.
230 * Returns: A file transfer handle.
232 PurpleXfer *purple_xfer_new(PurpleAccount *account,
233 PurpleXferType type, const char *who);
236 * purple_xfer_request:
237 * @xfer: The file transfer to request confirmation on.
239 * Requests confirmation for a file transfer from the user. If receiving
240 * a file which is known at this point, this requests user to accept and
241 * save the file. If the filename is unknown (not set) this only requests user
242 * to accept the file transfer. In this case protocol must call this function
243 * again once the filename is available.
245 void purple_xfer_request(PurpleXfer *xfer);
248 * purple_xfer_request_accepted:
249 * @xfer: The file transfer.
250 * @filename: The filename.
252 * Called if the user accepts the file transfer request.
254 void purple_xfer_request_accepted(PurpleXfer *xfer, const gchar *filename);
257 * purple_xfer_request_denied:
258 * @xfer: The file transfer.
260 * Called if the user rejects the file transfer request.
262 void purple_xfer_request_denied(PurpleXfer *xfer);
265 * purple_xfer_get_fd:
266 * @xfer: The file transfer.
268 * Returns the socket file descriptor.
270 * Returns: The socket file descriptor.
272 int purple_xfer_get_fd(PurpleXfer *xfer);
275 * purple_xfer_get_watcher:
276 * @xfer: The file transfer.
278 * Returns the Watcher for the transfer.
280 * Returns: The watcher.
282 int purple_xfer_get_watcher(PurpleXfer *xfer);
285 * purple_xfer_get_xfer_type:
286 * @xfer: The file transfer.
288 * Returns the type of file transfer.
290 * Returns: The type of the file transfer.
292 PurpleXferType purple_xfer_get_xfer_type(PurpleXfer *xfer);
295 * purple_xfer_get_account:
296 * @xfer: The file transfer.
298 * Returns the account the file transfer is using.
300 * Returns: (transfer none): The account.
302 PurpleAccount *purple_xfer_get_account(PurpleXfer *xfer);
305 * purple_xfer_set_remote_user:
306 * @xfer: The file transfer.
307 * @who: The name of the remote user.
309 * Sets the name of the remote user.
311 void purple_xfer_set_remote_user(PurpleXfer *xfer, const char *who);
314 * purple_xfer_get_remote_user:
315 * @xfer: The file transfer.
317 * Returns the name of the remote user.
319 * Returns: The name of the remote user.
321 const char *purple_xfer_get_remote_user(PurpleXfer *xfer);
324 * purple_xfer_get_status:
325 * @xfer: The file transfer.
327 * Returns the status of the xfer.
329 * Returns: The status.
331 PurpleXferStatus purple_xfer_get_status(PurpleXfer *xfer);
334 * purple_xfer_is_cancelled:
335 * @xfer: The file transfer.
337 * Returns true if the file transfer was cancelled.
339 * Returns: Whether or not the transfer was cancelled.
341 gboolean purple_xfer_is_cancelled(PurpleXfer *xfer);
344 * purple_xfer_is_completed:
345 * @xfer: The file transfer.
347 * Returns the completed state for a file transfer.
349 * Returns: The completed state.
351 gboolean purple_xfer_is_completed(PurpleXfer *xfer);
354 * purple_xfer_get_filename:
355 * @xfer: The file transfer.
357 * Returns the name of the file being sent or received.
359 * Returns: The filename.
361 const char *purple_xfer_get_filename(PurpleXfer *xfer);
364 * purple_xfer_get_local_filename:
365 * @xfer: The file transfer.
367 * Returns the file's destination filename,
369 * Returns: The destination filename.
371 const char *purple_xfer_get_local_filename(PurpleXfer *xfer);
374 * purple_xfer_get_bytes_sent:
375 * @xfer: The file transfer.
377 * Returns the number of bytes sent (or received) so far.
379 * Returns: The number of bytes sent.
381 goffset purple_xfer_get_bytes_sent(PurpleXfer *xfer);
384 * purple_xfer_get_bytes_remaining:
385 * @xfer: The file transfer.
387 * Returns the number of bytes remaining to send or receive.
389 * Returns: The number of bytes remaining.
391 goffset purple_xfer_get_bytes_remaining(PurpleXfer *xfer);
394 * purple_xfer_get_size:
395 * @xfer: The file transfer.
397 * Returns the size of the file being sent or received.
399 * Returns: The total size of the file.
401 goffset purple_xfer_get_size(PurpleXfer *xfer);
404 * purple_xfer_get_progress:
405 * @xfer: The file transfer.
407 * Returns the current percentage of progress of the transfer.
409 * This is a number between 0 (0%) and 1 (100%).
411 * Returns: The percentage complete.
413 double purple_xfer_get_progress(PurpleXfer *xfer);
416 * purple_xfer_get_local_port:
417 * @xfer: The file transfer.
419 * Returns the local port number in the file transfer.
421 * Returns: The port number on this end.
423 guint16 purple_xfer_get_local_port(PurpleXfer *xfer);
426 * purple_xfer_get_remote_ip:
427 * @xfer: The file transfer.
429 * Returns the remote IP address in the file transfer.
431 * Returns: The IP address on the other end.
433 const char *purple_xfer_get_remote_ip(PurpleXfer *xfer);
436 * purple_xfer_get_remote_port:
437 * @xfer: The file transfer.
439 * Returns the remote port number in the file transfer.
441 * Returns: The port number on the other end.
443 guint16 purple_xfer_get_remote_port(PurpleXfer *xfer);
446 * purple_xfer_get_start_time:
447 * @xfer: The file transfer.
449 * Returns the time the transfer of a file started.
451 * Returns: The monotonic time when the transfer started.
453 gint64 purple_xfer_get_start_time(PurpleXfer *xfer);
456 * purple_xfer_get_end_time:
457 * @xfer: The file transfer.
459 * Returns the time the transfer of a file ended.
461 * Returns: The monotonic time when the transfer ended.
463 gint64 purple_xfer_get_end_time(PurpleXfer *xfer);
466 * purple_xfer_set_fd:
467 * @xfer: The file transfer.
468 * @fd: The file descriptor.
470 * Sets the socket file descriptor.
472 void purple_xfer_set_fd(PurpleXfer *xfer, int fd);
475 * purple_xfer_set_watcher:
476 * @xfer: The file transfer.
477 * @watcher: The watcher.
479 * Sets the watcher for the file transfer.
481 void purple_xfer_set_watcher(PurpleXfer *xfer, int watcher);
484 * purple_xfer_set_completed:
485 * @xfer: The file transfer.
486 * @completed: The completed state.
488 * Sets the completed state for the file transfer.
490 void purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed);
493 * purple_xfer_set_status:
494 * @xfer: The file transfer.
495 * @status: The current status.
497 * Sets the current status for the file transfer.
499 void purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatus status);
502 * purple_xfer_set_message:
503 * @xfer: The file transfer.
504 * @message: The message.
506 * Sets the message for the file transfer.
508 void purple_xfer_set_message(PurpleXfer *xfer, const char *message);
511 * purple_xfer_get_message:
512 * @xfer: The file transfer.
514 * Returns the message for the file transfer.
516 * Returns: The message.
518 const char *purple_xfer_get_message(PurpleXfer *xfer);
521 * purple_xfer_set_filename:
522 * @xfer: The file transfer.
523 * @filename: The filename.
525 * Sets the filename for the file transfer.
527 void purple_xfer_set_filename(PurpleXfer *xfer, const char *filename);
530 * purple_xfer_set_local_filename:
531 * @xfer: The file transfer.
532 * @filename: The filename
534 * Sets the local filename for the file transfer.
536 void purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename);
539 * purple_xfer_set_size:
540 * @xfer: The file transfer.
541 * @size: The size of the file.
543 * Sets the size of the file in a file transfer.
545 void purple_xfer_set_size(PurpleXfer *xfer, goffset size);
548 * purple_xfer_set_local_port:
549 * @xfer: The file transfer.
550 * @local_port: The local port.
552 * Sets the local port of the file transfer.
554 void purple_xfer_set_local_port(PurpleXfer *xfer, guint16 local_port);
557 * purple_xfer_set_bytes_sent:
558 * @xfer: The file transfer.
559 * @bytes_sent: The new current position in the file. If we're
560 * sending a file then this is the next byte that we
561 * will send. If we're receiving a file, this is the
562 * next byte that we expect to receive.
564 * Sets the current working position in the active file transfer. This
565 * can be used to jump backward in the file if the protocol detects
566 * that some bit of data needs to be resent or has been sent twice.
568 * It's used for pausing and resuming an oscar file transfer.
570 void purple_xfer_set_bytes_sent(PurpleXfer *xfer, goffset bytes_sent);
573 * purple_xfer_get_ui_ops:
574 * @xfer: The file transfer.
576 * Returns the UI operations structure for a file transfer.
578 * Returns: The UI operations structure.
580 PurpleXferUiOps *purple_xfer_get_ui_ops(PurpleXfer *xfer);
583 * purple_xfer_read:
584 * @xfer: The file transfer.
585 * @buffer: The buffer that will be created to contain the data.
587 * Reads in data from a file transfer stream.
589 * Returns: The number of bytes read, or -1.
591 gssize purple_xfer_read(PurpleXfer *xfer, guchar **buffer);
594 * purple_xfer_write:
595 * @xfer: The file transfer.
596 * @buffer: The buffer to read the data from.
597 * @size: The number of bytes to write.
599 * Writes data to a file transfer stream.
601 * Returns: The number of bytes written, or -1.
603 gssize purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size);
606 * purple_xfer_write_file:
607 * @xfer: The file transfer.
608 * @buffer: The buffer to read the data from.
609 * @size: The number of bytes to write.
611 * Writes chunk of received file.
613 * Returns: TRUE on success, FALSE otherwise.
615 gboolean
616 purple_xfer_write_file(PurpleXfer *xfer, const guchar *buffer, gsize size);
619 * purple_xfer_read_file:
620 * @xfer: The file transfer.
621 * @buffer: The buffer to write the data to.
622 * @size: The size of buffer.
624 * Writes chunk of file being sent.
626 * Returns: Number of bytes written (0 means, the device is busy), or -1 on
627 * failure.
629 gssize
630 purple_xfer_read_file(PurpleXfer *xfer, guchar *buffer, gsize size);
633 * purple_xfer_start:
634 * @xfer: The file transfer.
635 * @fd: The file descriptor for the socket.
636 * @ip: The IP address to connect to.
637 * @port: The port to connect to.
639 * Starts a file transfer.
641 * Either @fd must be specified <emphasis>or</emphasis> @ip and @port on a
642 * file receive transfer. On send, @fd must be specified, and
643 * @ip and @port are ignored.
645 * Passing @fd as '-1' is a special-case and indicates to the
646 * protocol to facilitate the file transfer itself.
648 void purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, guint16 port);
651 * purple_xfer_end:
652 * @xfer: The file transfer.
654 * Ends a file transfer.
656 void purple_xfer_end(PurpleXfer *xfer);
659 * purple_xfer_add:
660 * @xfer: The file transfer.
662 * Adds a new file transfer to the list of file transfers. Call this only
663 * if you are not using purple_xfer_start.
665 void purple_xfer_add(PurpleXfer *xfer);
668 * purple_xfer_cancel_local:
669 * @xfer: The file transfer.
671 * Cancels a file transfer on the local end.
673 void purple_xfer_cancel_local(PurpleXfer *xfer);
676 * purple_xfer_cancel_remote:
677 * @xfer: The file transfer.
679 * Cancels a file transfer from the remote end.
681 void purple_xfer_cancel_remote(PurpleXfer *xfer);
684 * purple_xfer_error:
685 * @type: The type of file transfer.
686 * @account: The account sending or receiving the file.
687 * @who: The user on the other end of the transfer.
688 * @msg: The message to display.
690 * Displays a file transfer-related error message.
692 * This is a wrapper around purple_notify_error(), which automatically
693 * specifies a title ("File transfer to <literal>user</literal> failed" or
694 * "File Transfer from <literal>user</literal> failed").
696 void purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg);
699 * purple_xfer_update_progress:
700 * @xfer: The file transfer.
702 * Updates file transfer progress.
704 void purple_xfer_update_progress(PurpleXfer *xfer);
707 * purple_xfer_conversation_write:
708 * @xfer: The file transfer to which this message relates.
709 * @message: The message to display.
710 * @is_error: Is this an error message?.
712 * Displays a file transfer-related message in the conversation window
714 * This is a wrapper around purple_conversation_write_system_message
716 void purple_xfer_conversation_write(PurpleXfer *xfer, const gchar *message, gboolean is_error);
719 * purple_xfer_ui_ready:
720 * @xfer: The file transfer which is ready.
722 * Allows the UI to signal it's ready to send/receive data (depending on
723 * the direction of the file transfer. Used when the UI is providing
724 * read/write/data_not_sent UI ops.
726 void purple_xfer_ui_ready(PurpleXfer *xfer);
729 * purple_xfer_protocol_ready:
730 * @xfer: The file transfer which is ready.
732 * Allows the protocol to signal it's ready to send/receive data (depending on
733 * the direction of the file transfer. Used when the protocol provides read/write
734 * ops and cannot/does not provide a raw fd to the core.
736 void purple_xfer_protocol_ready(PurpleXfer *xfer);
739 * purple_xfer_get_thumbnail:
740 * @xfer: The file transfer to get the thumbnail for
741 * @len: If not %NULL, the length of the thumbnail data returned
742 * will be set in the location pointed to by this.
744 * Gets the thumbnail data for a transfer
746 * Returns: The thumbnail data, or NULL if there is no thumbnail
748 gconstpointer purple_xfer_get_thumbnail(PurpleXfer *xfer, gsize *len);
751 * purple_xfer_get_thumbnail_mimetype:
752 * @xfer: The file transfer to get the mimetype for
754 * Gets the mimetype of the thumbnail preview for a transfer
756 * Returns: The mimetype of the thumbnail, or %NULL if not thumbnail is set
758 const gchar *purple_xfer_get_thumbnail_mimetype(PurpleXfer *xfer);
762 * purple_xfer_set_thumbnail:
763 * @xfer: The file transfer to set the data for
764 * @thumbnail: A pointer to the thumbnail data, this will be copied
765 * @size: The size in bytes of the passed in thumbnail data
766 * @mimetype: The mimetype of the generated thumbnail
768 * Sets the thumbnail data for a transfer
770 void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
771 gsize size, const gchar *mimetype);
774 * purple_xfer_prepare_thumbnail:
775 * @xfer: The file transfer to create a thumbnail for
776 * @formats: A comma-separated list of mimetypes for image formats
777 * the protocols can use for thumbnails.
779 * Prepare a thumbnail for a transfer (if the UI supports it)
780 * will be no-op in case the UI doesn't implement thumbnail creation
782 void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats);
785 * purple_xfer_set_ui_data:
786 * @xfer: The file transfer.
787 * @ui_data: A pointer to associate with this file transfer.
789 * Set the UI data associated with this file transfer.
791 void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data);
794 * purple_xfer_get_ui_data:
795 * @xfer: The file transfer.
797 * Get the UI data associated with this file transfer.
799 * Returns: The UI data associated with this file transfer. This is a
800 * convenience field provided to the UIs--it is not
801 * used by the libpurple core.
803 gpointer purple_xfer_get_ui_data(PurpleXfer *xfer);
805 /**************************************************************************/
806 /* File Transfer Subsystem API */
807 /**************************************************************************/
810 * purple_xfer_ui_ops_get_type:
812 * Returns: The #GType for the #PurpleXferUiOps boxed structure.
814 GType purple_xfer_ui_ops_get_type(void);
817 * purple_xfers_get_all:
819 * Returns all xfers
821 * Returns: (element-type Purple.Xfer) (transfer none): all current xfers
822 * with refs
824 GList *purple_xfers_get_all(void);
827 * purple_xfers_get_handle:
829 * Returns the handle to the file transfer subsystem
831 * Returns: The handle
833 void *purple_xfers_get_handle(void);
836 * purple_xfers_init:
838 * Initializes the file transfer subsystem
840 void purple_xfers_init(void);
843 * purple_xfers_uninit:
845 * Uninitializes the file transfer subsystem
847 void purple_xfers_uninit(void);
850 * purple_xfers_set_ui_ops:
851 * @ops: The UI operations structure.
853 * Sets the UI operations structure to be used in all purple file transfers.
855 void purple_xfers_set_ui_ops(PurpleXferUiOps *ops);
858 * purple_xfers_get_ui_ops:
860 * Returns the UI operations structure to be used in all purple file transfers.
862 * Returns: The UI operations structure.
864 PurpleXferUiOps *purple_xfers_get_ui_ops(void);
866 /******************************************************************************
867 * Protocol Interface
868 *****************************************************************************/
871 * purple_protocol_xfer_get_type:
873 * Returns: The #GType for the protocol xfer interface.
875 GType purple_protocol_xfer_get_type(void);
878 * purple_protocol_xfer_can_receive:
879 * @prplxfer: The #PurpleProtocolXfer implementer instance
880 * @connection: The #PurpleConnection that we're checking
881 * @who: The user that we want to send a file transfer to.
883 * Checks whether or not we can transfer a file to @who.
885 * Returns: TRUE on success, FALSE otherwise.
887 gboolean purple_protocol_xfer_can_receive(PurpleProtocolXfer *prplxfer, PurpleConnection *connection, const gchar *who);
890 * purple_protocol_xfer_send_file:
891 * @prplxfer: The #PurpleProtocolXfer implementer instance
892 * @connection: The #PurpleConnection that we're checking
893 * @who: The user that we want to set a file transfer to.
894 * @filename: The name of the file to send.
896 * Sends @filename to @who.
898 void purple_protocol_xfer_send_file(PurpleProtocolXfer *prplxfer, PurpleConnection *connection, const gchar *who, const gchar *filename);
901 * purple_protocol_xfer_new_xfer:
902 * @prplxfer: The #PurpleProtocolXfer implementer instance
903 * @connection: The #PurpleConnection that we're checking
904 * @who: The user that we want to send a file transfer to.
906 * Creates a new #PurpleXfer to @who.
908 * Returns: (transfer full): A new #PurpleXfer instance.
910 PurpleXfer *purple_protocol_xfer_new_xfer(PurpleProtocolXfer *prplxfer, PurpleConnection *connection, const gchar *who);
912 G_END_DECLS
914 #endif /* PURPLE_XFER_H */