mw_srvc_ft.h
Go to the documentation of this file.
/*
Meanwhile - Unofficial Lotus Sametime Community Client Library
Copyright (C) 2004 Christopher (siege) O'Brien
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _MW_SRVC_FT_H
#define _MW_SRVC_FT_H
#include "mw_common.h"
#ifdef __cplusplus
extern "C" {
#endif
struct mwServiceFileTransfer;
struct mwFileTransfer;
#define mwService_FILE_TRANSFER 0x00000038
enum mwFileTransferState {
mwFileTransfer_NEW,
mwFileTransfer_PENDING,
mwFileTransfer_OPEN,
mwFileTransfer_CANCEL_LOCAL,
mwFileTransfer_CANCEL_REMOTE,
mwFileTransfer_DONE,
mwFileTransfer_ERROR,
mwFileTransfer_UNKNOWN,
};
#define mwFileTransfer_isState(ft, state) \
(mwFileTransfer_getState(ft) == (state))
#define mwFileTransfer_isNew(ft) \
mwFileTransfer_isState((ft), mwFileTransfer_NEW)
#define mwFileTransfer_isPending(ft) \
mwFileTransfer_isState((ft), mwFileTransfer_PENDING)
#define mwFileTransfer_isOpen(ft) \
mwFileTransfer_isState((ft), mwFileTransfer_OPEN)
#define mwFileTransfer_isDone(ft) \
mwFileTransfer_isState((ft), mwFileTransfer_DONE)
#define mwFileTransfer_isCancelLocal(ft) \
mwFileTransfer_isState((ft), mwFileTransfer_CANCEL_LOCAL)
#define mwFileTransfer_isCancelRemote(ft) \
mwFileTransfer_isState((ft), mwFileTransfer_CANCEL_REMOTE)
enum mwFileTranferCode {
mwFileTransfer_SUCCESS = 0x00000000,
mwFileTransfer_REJECTED = 0x08000606,
};
struct mwFileTransferHandler {
void (*ft_offered)(struct mwFileTransfer *ft);
void (*ft_opened)(struct mwFileTransfer *ft);
void (*ft_closed)(struct mwFileTransfer *ft, guint32 code);
void (*ft_recv)(struct mwFileTransfer *ft, struct mwOpaque *data);
void (*ft_ack)(struct mwFileTransfer *ft);
void (*clear)(struct mwServiceFileTransfer *srvc);
};
struct mwServiceFileTransfer *
mwServiceFileTransfer_new(struct mwSession *session,
struct mwFileTransferHandler *handler);
struct mwFileTransferHandler *
mwServiceFileTransfer_getHandler(struct mwServiceFileTransfer *srvc);
const GList *
mwServiceFileTransfer_getTransfers(struct mwServiceFileTransfer *srvc);
struct mwFileTransfer *
mwFileTransfer_new(struct mwServiceFileTransfer *srvc,
const struct mwIdBlock *who, const char *msg,
const char *filename, guint32 filesize);
void
mwFileTransfer_free(struct mwFileTransfer *ft);
enum mwFileTransferState
mwFileTransfer_getState(struct mwFileTransfer *ft);
struct mwServiceFileTransfer *
mwFileTransfer_getService(struct mwFileTransfer *ft);
const struct mwIdBlock *
mwFileTransfer_getUser(struct mwFileTransfer *ft);
const char *
mwFileTransfer_getMessage(struct mwFileTransfer *ft);
const char *
mwFileTransfer_getFileName(struct mwFileTransfer *ft);
guint32 mwFileTransfer_getFileSize(struct mwFileTransfer *ft);
guint32 mwFileTransfer_getRemaining(struct mwFileTransfer *ft);
#define mwFileTransfer_getSent(ft) \
(mwFileTransfer_getFileSize(ft) - mwFileTransfer_getRemaining(ft))
int mwFileTransfer_offer(struct mwFileTransfer *ft);
int mwFileTransfer_accept(struct mwFileTransfer *ft);
#define mwFileTransfer_reject(ft) \
mwFileTransfer_close((ft), mwFileTransfer_REJECTED)
#define mwFileTransfer_cancel(ft) \
mwFileTransfer_close((ft), mwFileTransfer_SUCCESS);
int mwFileTransfer_close(struct mwFileTransfer *ft, guint32 code);
int mwFileTransfer_send(struct mwFileTransfer *ft,
struct mwOpaque *data);
int mwFileTransfer_ack(struct mwFileTransfer *ft);
void mwFileTransfer_setClientData(struct mwFileTransfer *ft,
gpointer data, GDestroyNotify clean);
gpointer mwFileTransfer_getClientData(struct mwFileTransfer *ft);
void mwFileTransfer_removeClientData(struct mwFileTransfer *ft);
#ifdef __cplusplus
}
#endif
#endif /* _MW_SRVC_FT_H */
mw_common.h
Common data types and functions for handling those types.
mwFileTransfer_removeClientData
void mwFileTransfer_removeClientData(struct mwFileTransfer *ft)
mwFileTransfer_new
struct mwFileTransfer * mwFileTransfer_new(struct mwServiceFileTransfer *srvc, const struct mwIdBlock *who, const char *msg, const char *filename, guint32 filesize)
mwFileTransfer_getMessage
const char * mwFileTransfer_getMessage(struct mwFileTransfer *ft)
the message sent along with an offered file transfer
mwFileTransfer_accept
int mwFileTransfer_accept(struct mwFileTransfer *ft)
accept an incoming file transfer
mwFileTransfer_send
int mwFileTransfer_send(struct mwFileTransfer *ft, struct mwOpaque *data)
send a chunk of data over an outbound file transfer.
mwFileTransfer_getRemaining
guint32 mwFileTransfer_getRemaining(struct mwFileTransfer *ft)
bytes remaining to be received/send
mwFileTransfer_getUser
const struct mwIdBlock * mwFileTransfer_getUser(struct mwFileTransfer *ft)
the user on the other end of the file transfer
mwServiceFileTransfer_getHandler
struct mwFileTransferHandler * mwServiceFileTransfer_getHandler(struct mwServiceFileTransfer *srvc)
mwFileTransfer_getService
struct mwServiceFileTransfer * mwFileTransfer_getService(struct mwFileTransfer *ft)
mwFileTransfer_getClientData
gpointer mwFileTransfer_getClientData(struct mwFileTransfer *ft)
mwFileTransfer_getState
enum mwFileTransferState mwFileTransfer_getState(struct mwFileTransfer *ft)
the status of this file transfer
mwFileTransfer_getFileName
const char * mwFileTransfer_getFileName(struct mwFileTransfer *ft)
the publicized file name.
mwFileTransfer_ack
int mwFileTransfer_ack(struct mwFileTransfer *ft)
acknowledge the receipt of a chunk of data from an inbound file transfer.
mwFileTranferCode
mwFileTranferCode
Definition mw_srvc_ft.h:90
mwFileTransfer_REJECTED
@ mwFileTransfer_REJECTED
Definition mw_srvc_ft.h:92
mwFileTransfer_SUCCESS
@ mwFileTransfer_SUCCESS
Definition mw_srvc_ft.h:91
mwServiceFileTransfer_new
struct mwServiceFileTransfer * mwServiceFileTransfer_new(struct mwSession *session, struct mwFileTransferHandler *handler)
mwFileTransfer_getFileSize
guint32 mwFileTransfer_getFileSize(struct mwFileTransfer *ft)
total bytes intended to be sent/received
mwServiceFileTransfer_getTransfers
const GList * mwServiceFileTransfer_getTransfers(struct mwServiceFileTransfer *srvc)
mwFileTransferState
mwFileTransferState
Definition mw_srvc_ft.h:56
mwFileTransfer_UNKNOWN
@ mwFileTransfer_UNKNOWN
unknown state
Definition mw_srvc_ft.h:64
mwFileTransfer_PENDING
@ mwFileTransfer_PENDING
file transfer is opening
Definition mw_srvc_ft.h:58
mwFileTransfer_NEW
@ mwFileTransfer_NEW
file transfer is not open
Definition mw_srvc_ft.h:57
mwFileTransfer_CANCEL_LOCAL
@ mwFileTransfer_CANCEL_LOCAL
Definition mw_srvc_ft.h:60
mwFileTransfer_OPEN
@ mwFileTransfer_OPEN
file transfer is open
Definition mw_srvc_ft.h:59
mwFileTransfer_DONE
@ mwFileTransfer_DONE
Definition mw_srvc_ft.h:62
mwFileTransfer_ERROR
@ mwFileTransfer_ERROR
error in file transfer
Definition mw_srvc_ft.h:63
mwFileTransfer_CANCEL_REMOTE
@ mwFileTransfer_CANCEL_REMOTE
Definition mw_srvc_ft.h:61
mwFileTransfer_setClientData
void mwFileTransfer_setClientData(struct mwFileTransfer *ft, gpointer data, GDestroyNotify clean)
mwFileTransfer_close
int mwFileTransfer_close(struct mwFileTransfer *ft, guint32 code)
Close a file transfer.
mwFileTransfer_offer
int mwFileTransfer_offer(struct mwFileTransfer *ft)
initiate an outgoing file transfer
mwFileTransfer_free
void mwFileTransfer_free(struct mwFileTransfer *ft)
deallocate a file transfer.
mwFileTransferHandler
Definition mw_srvc_ft.h:96
mwFileTransferHandler::ft_opened
void(* ft_opened)(struct mwFileTransfer *ft)
a file transfer has been fully initiated
Definition mw_srvc_ft.h:102
mwFileTransferHandler::clear
void(* clear)(struct mwServiceFileTransfer *srvc)
optional.
Definition mw_srvc_ft.h:118
mwFileTransferHandler::ft_closed
void(* ft_closed)(struct mwFileTransfer *ft, guint32 code)
a file transfer has been closed.
Definition mw_srvc_ft.h:107
mwFileTransferHandler::ft_recv
void(* ft_recv)(struct mwFileTransfer *ft, struct mwOpaque *data)
receive a chunk of a file from an inbound file transfer.
Definition mw_srvc_ft.h:110
mwFileTransferHandler::ft_ack
void(* ft_ack)(struct mwFileTransfer *ft)
received an ack for a sent chunk on an outbound file transfer.
Definition mw_srvc_ft.h:115
mwFileTransferHandler::ft_offered
void(* ft_offered)(struct mwFileTransfer *ft)
an incoming file transfer has been offered
Definition mw_srvc_ft.h:99
mwFileTransfer
A single file trasfer session.
mwIdBlock
Definition mw_common.h:178
mwOpaque
A length of binary data, not null-terminated.
Definition mw_common.h:79
mwServiceFileTransfer
File transfer service.
mwSession
Represents a Sametime client session.