Loading...
Searching...
No Matches
ft.h
Go to the documentation of this file.
/* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef _PURPLE_FT_H_
#define _PURPLE_FT_H_
/**************************************************************************/
/**************************************************************************/
typedef struct _PurpleXfer PurpleXfer;
#include <glib.h>
#include <stdio.h>
#include "account.h"
typedef enum
{
PURPLE_XFER_UNKNOWN = 0,
PURPLE_XFER_SEND,
PURPLE_XFER_RECEIVE
} PurpleXferType;
typedef enum
{
PURPLE_XFER_STATUS_UNKNOWN = 0,
PURPLE_XFER_STATUS_NOT_STARTED,
PURPLE_XFER_STATUS_ACCEPTED,
PURPLE_XFER_STATUS_STARTED,
PURPLE_XFER_STATUS_DONE,
PURPLE_XFER_STATUS_CANCEL_LOCAL,
PURPLE_XFER_STATUS_CANCEL_REMOTE
} PurpleXferStatusType;
typedef struct
{
void (*new_xfer)(PurpleXfer *xfer);
void (*destroy)(PurpleXfer *xfer);
void (*add_xfer)(PurpleXfer *xfer);
void (*update_progress)(PurpleXfer *xfer, double percent);
void (*cancel_local)(PurpleXfer *xfer);
void (*cancel_remote)(PurpleXfer *xfer);
gssize (*ui_write)(PurpleXfer *xfer, const guchar *buffer, gssize size);
gssize (*ui_read)(PurpleXfer *xfer, guchar **buffer, gssize size);
void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size);
void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
} PurpleXferUiOps;
struct _PurpleXfer
{
guint ref;
PurpleXferType type;
PurpleAccount *account;
char *who;
char *message;
char *filename;
char *local_filename;
size_t size;
FILE *dest_fp;
char *remote_ip;
int local_port;
int remote_port;
int fd;
int watcher;
size_t bytes_sent;
size_t bytes_remaining;
time_t start_time;
time_t end_time;
size_t current_buffer_size;
PurpleXferStatusType status;
struct
{
void (*init)(PurpleXfer *xfer);
void (*request_denied)(PurpleXfer *xfer);
void (*start)(PurpleXfer *xfer);
void (*end)(PurpleXfer *xfer);
void (*cancel_send)(PurpleXfer *xfer);
void (*cancel_recv)(PurpleXfer *xfer);
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;
void *ui_data;
void *data;
};
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************/
/**************************************************************************/
PurpleXfer *purple_xfer_new(PurpleAccount *account,
PurpleXferType type, const char *who);
GList *purple_xfers_get_all(void);
void purple_xfer_ref(PurpleXfer *xfer);
void purple_xfer_unref(PurpleXfer *xfer);
void purple_xfer_request(PurpleXfer *xfer);
void purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename);
void purple_xfer_request_denied(PurpleXfer *xfer);
PurpleXferType purple_xfer_get_type(const PurpleXfer *xfer);
PurpleAccount *purple_xfer_get_account(const PurpleXfer *xfer);
const char *purple_xfer_get_remote_user(const PurpleXfer *xfer);
PurpleXferStatusType purple_xfer_get_status(const PurpleXfer *xfer);
gboolean purple_xfer_is_canceled(const PurpleXfer *xfer);
gboolean purple_xfer_is_completed(const PurpleXfer *xfer);
const char *purple_xfer_get_filename(const PurpleXfer *xfer);
const char *purple_xfer_get_local_filename(const PurpleXfer *xfer);
size_t purple_xfer_get_bytes_sent(const PurpleXfer *xfer);
size_t purple_xfer_get_bytes_remaining(const PurpleXfer *xfer);
size_t purple_xfer_get_size(const PurpleXfer *xfer);
double purple_xfer_get_progress(const PurpleXfer *xfer);
unsigned int purple_xfer_get_local_port(const PurpleXfer *xfer);
const char *purple_xfer_get_remote_ip(const PurpleXfer *xfer);
unsigned int purple_xfer_get_remote_port(const PurpleXfer *xfer);
time_t purple_xfer_get_start_time(const PurpleXfer *xfer);
time_t purple_xfer_get_end_time(const PurpleXfer *xfer);
void purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed);
void purple_xfer_set_message(PurpleXfer *xfer, const char *message);
void purple_xfer_set_filename(PurpleXfer *xfer, const char *filename);
void purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename);
void purple_xfer_set_size(PurpleXfer *xfer, size_t size);
void purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent);
PurpleXferUiOps *purple_xfer_get_ui_ops(const PurpleXfer *xfer);
void purple_xfer_set_read_fnc(PurpleXfer *xfer,
gssize (*fnc)(guchar **, PurpleXfer *));
void purple_xfer_set_write_fnc(PurpleXfer *xfer,
gssize (*fnc)(const guchar *, size_t, PurpleXfer *));
void purple_xfer_set_ack_fnc(PurpleXfer *xfer,
void (*fnc)(PurpleXfer *, const guchar *, size_t));
void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
void purple_xfer_set_init_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
void purple_xfer_set_start_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
void purple_xfer_set_end_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
void purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
void purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *));
gssize purple_xfer_read(PurpleXfer *xfer, guchar **buffer);
gssize purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size);
gboolean
purple_xfer_write_file(PurpleXfer *xfer, const guchar *buffer, gsize size);
gssize
purple_xfer_read_file(PurpleXfer *xfer, guchar *buffer, gsize size);
void purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip,
unsigned int port);
void purple_xfer_end(PurpleXfer *xfer);
void purple_xfer_add(PurpleXfer *xfer);
void purple_xfer_cancel_local(PurpleXfer *xfer);
void purple_xfer_cancel_remote(PurpleXfer *xfer);
void purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg);
void purple_xfer_update_progress(PurpleXfer *xfer);
void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error);
void purple_xfer_ui_ready(PurpleXfer *xfer);
void purple_xfer_prpl_ready(PurpleXfer *xfer);
gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len);
const gchar *purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer);
void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
gsize size, const gchar *mimetype);
void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats);
/**************************************************************************/
/**************************************************************************/
void *purple_xfers_get_handle(void);
void purple_xfers_init(void);
void purple_xfers_uninit(void);
void purple_xfers_set_ui_ops(PurpleXferUiOps *ops);
PurpleXferUiOps *purple_xfers_get_ui_ops(void);
#ifdef __cplusplus
}
#endif
#endif /* _PURPLE_FT_H_ */
account.h
Account API.
PurpleAccount
struct _PurpleAccount PurpleAccount
Structure representing an account.
Definition account.h:38
purple_xfer_get_local_filename
const char * purple_xfer_get_local_filename(const PurpleXfer *xfer)
Returns the file's destination filename,.
purple_xfers_init
void purple_xfers_init(void)
Initializes the file transfer subsystem.
purple_xfer_conversation_write
void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error)
Displays a file transfer-related message in the conversation window.
purple_xfer_get_account
PurpleAccount * purple_xfer_get_account(const PurpleXfer *xfer)
Returns the account the file transfer is using.
purple_xfer_prepare_thumbnail
void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats)
Prepare a thumbnail for a transfer (if the UI supports it) will be no-op in case the UI doesn't imple...
purple_xfer_get_ui_ops
PurpleXferUiOps * purple_xfer_get_ui_ops(const PurpleXfer *xfer)
Returns the UI operations structure for a file transfer.
purple_xfer_get_local_port
unsigned int purple_xfer_get_local_port(const PurpleXfer *xfer)
Returns the local port number in the file transfer.
purple_xfer_read_file
gssize purple_xfer_read_file(PurpleXfer *xfer, guchar *buffer, gsize size)
Writes chunk of file being sent.
purple_xfers_uninit
void purple_xfers_uninit(void)
Uninitializes the file transfer subsystem.
purple_xfer_set_end_fnc
void purple_xfer_set_end_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *))
Sets the end transfer function for the file transfer.
purple_xfer_set_ack_fnc
void purple_xfer_set_ack_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *, const guchar *, size_t))
Sets the acknowledge function for the file transfer.
PurpleXferStatusType
PurpleXferStatusType
The different states of the xfer.
Definition ft.h:55
PURPLE_XFER_STATUS_STARTED
@ PURPLE_XFER_STATUS_STARTED
purple_xfer_start has been called.
Definition ft.h:59
PURPLE_XFER_STATUS_NOT_STARTED
@ PURPLE_XFER_STATUS_NOT_STARTED
It hasn't started yet.
Definition ft.h:57
PURPLE_XFER_STATUS_UNKNOWN
@ PURPLE_XFER_STATUS_UNKNOWN
Unknown, the xfer may be null.
Definition ft.h:56
PURPLE_XFER_STATUS_CANCEL_REMOTE
@ PURPLE_XFER_STATUS_CANCEL_REMOTE
The xfer was cancelled by the other end, or we couldn't connect.
Definition ft.h:62
PURPLE_XFER_STATUS_DONE
@ PURPLE_XFER_STATUS_DONE
The xfer completed successfully.
Definition ft.h:60
PURPLE_XFER_STATUS_ACCEPTED
@ PURPLE_XFER_STATUS_ACCEPTED
Receive accepted, but destination file not selected yet.
Definition ft.h:58
PURPLE_XFER_STATUS_CANCEL_LOCAL
@ PURPLE_XFER_STATUS_CANCEL_LOCAL
The xfer was cancelled by us.
Definition ft.h:61
purple_xfer_get_size
size_t purple_xfer_get_size(const PurpleXfer *xfer)
Returns the size of the file being sent or received.
purple_xfer_set_init_fnc
void purple_xfer_set_init_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *))
Sets the transfer initialization function for the file transfer.
purple_xfer_request
void purple_xfer_request(PurpleXfer *xfer)
Requests confirmation for a file transfer from the user.
purple_xfer_write
gssize purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size)
Writes data to a file transfer stream.
purple_xfer_get_type
PurpleXferType purple_xfer_get_type(const PurpleXfer *xfer)
Returns the type of file transfer.
purple_xfer_get_bytes_sent
size_t purple_xfer_get_bytes_sent(const PurpleXfer *xfer)
Returns the number of bytes sent (or received) so far.
purple_xfer_get_bytes_remaining
size_t purple_xfer_get_bytes_remaining(const PurpleXfer *xfer)
Returns the number of bytes remaining to send or receive.
purple_xfer_get_thumbnail_mimetype
const gchar * purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer)
Gets the mimetype of the thumbnail preview for a transfer.
purple_xfer_get_remote_port
unsigned int purple_xfer_get_remote_port(const PurpleXfer *xfer)
Returns the remote port number in the file transfer.
purple_xfer_set_completed
void purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed)
Sets the completed state for the file transfer.
purple_xfer_get_remote_user
const char * purple_xfer_get_remote_user(const PurpleXfer *xfer)
Returns the name of the remote user.
purple_xfer_get_thumbnail
gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len)
Gets the thumbnail data for a transfer.
purple_xfer_get_status
PurpleXferStatusType purple_xfer_get_status(const PurpleXfer *xfer)
Returns the status of the xfer.
purple_xfer_set_write_fnc
void purple_xfer_set_write_fnc(PurpleXfer *xfer, gssize(*fnc)(const guchar *, size_t, PurpleXfer *))
Sets the write function for the file transfer.
purple_xfer_get_remote_ip
const char * purple_xfer_get_remote_ip(const PurpleXfer *xfer)
Returns the remote IP address in the file transfer.
PurpleXferType
PurpleXferType
Types of file transfers.
Definition ft.h:44
PURPLE_XFER_UNKNOWN
@ PURPLE_XFER_UNKNOWN
Unknown file transfer type.
Definition ft.h:45
PURPLE_XFER_RECEIVE
@ PURPLE_XFER_RECEIVE
File receiving.
Definition ft.h:47
PURPLE_XFER_SEND
@ PURPLE_XFER_SEND
File sending.
Definition ft.h:46
purple_xfer_set_cancel_send_fnc
void purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *))
Sets the cancel send function for the file transfer.
purple_xfers_get_all
GList * purple_xfers_get_all(void)
Returns all xfers.
purple_xfer_cancel_remote
void purple_xfer_cancel_remote(PurpleXfer *xfer)
Cancels a file transfer from the remote end.
purple_xfer_unref
void purple_xfer_unref(PurpleXfer *xfer)
Decreases the reference count on a PurpleXfer.
purple_xfer_request_accepted
void purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename)
Called if the user accepts the file transfer request.
purple_xfer_read
gssize purple_xfer_read(PurpleXfer *xfer, guchar **buffer)
Reads in data from a file transfer stream.
purple_xfer_set_local_filename
void purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename)
Sets the local filename for the file transfer.
purple_xfer_get_end_time
time_t purple_xfer_get_end_time(const PurpleXfer *xfer)
Returns the time the transfer of a file ended.
purple_xfer_set_thumbnail
void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail, gsize size, const gchar *mimetype)
Sets the thumbnail data for a transfer.
purple_xfer_get_progress
double purple_xfer_get_progress(const PurpleXfer *xfer)
Returns the current percentage of progress of the transfer.
purple_xfer_ref
void purple_xfer_ref(PurpleXfer *xfer)
Increases the reference count on a PurpleXfer.
purple_xfers_get_handle
void * purple_xfers_get_handle(void)
Returns the handle to the file transfer subsystem.
purple_xfers_get_ui_ops
PurpleXferUiOps * purple_xfers_get_ui_ops(void)
Returns the UI operations structure to be used in all purple file transfers.
purple_xfer_new
PurpleXfer * purple_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who)
Creates a new file transfer handle.
purple_xfer_is_completed
gboolean purple_xfer_is_completed(const PurpleXfer *xfer)
Returns the completed state for a file transfer.
purple_xfer_set_request_denied_fnc
void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *))
Sets the function to be called if the request is denied.
purple_xfer_add
void purple_xfer_add(PurpleXfer *xfer)
Adds a new file transfer to the list of file transfers.
PurpleXfer
struct _PurpleXfer PurpleXfer
Data Structures.
Definition ft.h:33
purple_xfer_write_file
gboolean purple_xfer_write_file(PurpleXfer *xfer, const guchar *buffer, gsize size)
Writes chunk of received file.
purple_xfer_set_filename
void purple_xfer_set_filename(PurpleXfer *xfer, const char *filename)
Sets the filename for the file transfer.
purple_xfer_get_start_time
time_t purple_xfer_get_start_time(const PurpleXfer *xfer)
Returns the time the transfer of a file started.
purple_xfer_ui_ready
void purple_xfer_ui_ready(PurpleXfer *xfer)
Allows the UI to signal it's ready to send/receive data (depending on the direction of the file trans...
purple_xfer_end
void purple_xfer_end(PurpleXfer *xfer)
Ends a file transfer.
purple_xfer_set_size
void purple_xfer_set_size(PurpleXfer *xfer, size_t size)
Sets the size of the file in a file transfer.
purple_xfer_set_start_fnc
void purple_xfer_set_start_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *))
Sets the start transfer function for the file transfer.
purple_xfer_request_denied
void purple_xfer_request_denied(PurpleXfer *xfer)
Called if the user rejects the file transfer request.
purple_xfer_start
void purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, unsigned int port)
Starts a file transfer.
purple_xfer_prpl_ready
void purple_xfer_prpl_ready(PurpleXfer *xfer)
Allows the prpl to signal it's ready to send/receive data (depending on the direction of the file tra...
purple_xfer_set_message
void purple_xfer_set_message(PurpleXfer *xfer, const char *message)
Sets the filename for the file transfer.
purple_xfer_update_progress
void purple_xfer_update_progress(PurpleXfer *xfer)
Updates file transfer progress.
purple_xfer_cancel_local
void purple_xfer_cancel_local(PurpleXfer *xfer)
Cancels a file transfer on the local end.
purple_xfer_set_read_fnc
void purple_xfer_set_read_fnc(PurpleXfer *xfer, gssize(*fnc)(guchar **, PurpleXfer *))
Sets the read function for the file transfer.
purple_xfer_is_canceled
gboolean purple_xfer_is_canceled(const PurpleXfer *xfer)
Returns true if the file transfer was cancelled.
purple_xfer_error
void purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg)
Displays a file transfer-related error message.
purple_xfer_set_bytes_sent
void purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent)
Sets the current working position in the active file transfer.
purple_xfers_set_ui_ops
void purple_xfers_set_ui_ops(PurpleXferUiOps *ops)
Sets the UI operations structure to be used in all purple file transfers.
purple_xfer_get_filename
const char * purple_xfer_get_filename(const PurpleXfer *xfer)
Returns the name of the file being sent or received.
purple_xfer_set_cancel_recv_fnc
void purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void(*fnc)(PurpleXfer *))
Sets the cancel receive function for the file transfer.
PurpleXferUiOps
File transfer UI operations.
Definition ft.h:72
PurpleXferUiOps::add_thumbnail
void(* add_thumbnail)(PurpleXfer *xfer, const gchar *formats)
Op to create a thumbnail image for a file transfer.
Definition ft.h:128
PurpleXferUiOps::ui_read
gssize(* ui_read)(PurpleXfer *xfer, guchar **buffer, gssize size)
UI op to read data to send to the prpl for a file transfer.
Definition ft.h:107
PurpleXferUiOps::data_not_sent
void(* data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size)
Op to notify the UI that not all the data read in was written.
Definition ft.h:121
PurpleXferUiOps::ui_write
gssize(* ui_write)(PurpleXfer *xfer, const guchar *buffer, gssize size)
UI op to write data received from the prpl.
Definition ft.h:92
_PurpleXfer
A core representation of a file transfer.
Definition ft.h:135
_PurpleXfer::type
PurpleXferType type
The type of transfer.
Definition ft.h:137
_PurpleXfer::current_buffer_size
size_t current_buffer_size
This gradually increases for fast network connections.
Definition ft.h:163
_PurpleXfer::bytes_sent
size_t bytes_sent
The number of bytes sent.
Definition ft.h:158
_PurpleXfer::local_filename
char * local_filename
The name on the local hard drive.
Definition ft.h:146
_PurpleXfer::filename
char * filename
The name sent over the network.
Definition ft.h:145
_PurpleXfer::account
PurpleAccount * account
The account.
Definition ft.h:139
_PurpleXfer::data
void * data
prpl-specific data.
Definition ft.h:188
_PurpleXfer::fd
int fd
The socket file descriptor.
Definition ft.h:155
_PurpleXfer::remote_port
int remote_port
The remote port.
Definition ft.h:153
_PurpleXfer::start_time
time_t start_time
When the transfer of data began.
Definition ft.h:160
_PurpleXfer::bytes_remaining
size_t bytes_remaining
The number of bytes remaining.
Definition ft.h:159
_PurpleXfer::ref
guint ref
The reference count.
Definition ft.h:136
_PurpleXfer::who
char * who
The person on the other end of the transfer.
Definition ft.h:141
_PurpleXfer::watcher
int watcher
Watcher.
Definition ft.h:156
_PurpleXfer::ui_ops
PurpleXferUiOps * ui_ops
UI-specific operations.
Definition ft.h:185
_PurpleXfer::remote_ip
char * remote_ip
The remote IP address.
Definition ft.h:151
_PurpleXfer::dest_fp
FILE * dest_fp
The destination file pointer.
Definition ft.h:149
_PurpleXfer::ops
struct _PurpleXfer::@037100266001046237332134250077302054310027223211 ops
I/O operations, which should be set by the prpl using purple_xfer_set_init_fnc() and friends.
_PurpleXfer::status
PurpleXferStatusType status
File Transfer's status.
Definition ft.h:166
_PurpleXfer::local_port
int local_port
The local port.
Definition ft.h:152
_PurpleXfer::ui_data
void * ui_data
UI-specific data.
Definition ft.h:186
_PurpleXfer::size
size_t size
The size of the file.
Definition ft.h:147
_PurpleXfer::message
char * message
A message sent with the request.
Definition ft.h:144
_PurpleXfer::end_time
time_t end_time
When the transfer of data ended.
Definition ft.h:161