meanwhile: mw_srvc_ft.h Source File

- Main Page
- Related Pages
- Data Structures
- Files

# mw_srvc_ft.h

Go to the documentation of this file.

    00001
    00002 /*
    00003   Meanwhile - Unofficial Lotus Sametime Community Client Library
    00004   Copyright (C) 2004  Christopher (siege) O'Brien
    00005
    00006   This library is free software; you can redistribute it and/or
    00007   modify it under the terms of the GNU Library General Public
    00008   License as published by the Free Software Foundation; either
    00009   version 2 of the License, or (at your option) any later version.
    00010
    00011   This library is distributed in the hope that it will be useful,
    00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014   Library General Public License for more details.
    00015
    00016   You should have received a copy of the GNU Library General Public
    00017   License along with this library; if not, write to the Free
    00018   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00019 */
    00020
    00021
    00022 #ifndef _MW_SRVC_FT_H
    00023 #define _MW_SRVC_FT_H
    00024
    00025
    00033 #include "mw_common.h"
    00034
    00035
    00036 #ifdef __cplusplus
    00037 extern "C" {
    00038 #endif
    00039
    00040
    00044 struct mwServiceFileTransfer;
    00045
    00046
    00050 struct mwFileTransfer;
    00051
    00052
    00053 #define mwService_FILE_TRANSFER  0x00000038
    00054
    00055
    00056 enum mwFileTransferState {
    00057   mwFileTransfer_NEW,
    00058   mwFileTransfer_PENDING,
    00059   mwFileTransfer_OPEN,
    00060   mwFileTransfer_CANCEL_LOCAL,
    00061   mwFileTransfer_CANCEL_REMOTE,
    00062   mwFileTransfer_DONE,
    00063   mwFileTransfer_ERROR,
    00064   mwFileTransfer_UNKNOWN,
    00065 };
    00066
    00067
    00068 #define mwFileTransfer_isState(ft, state) \
    00069   (mwFileTransfer_getState(ft) == (state))
    00070
    00071 #define mwFileTransfer_isNew(ft) \
    00072   mwFileTransfer_isState((ft), mwFileTransfer_NEW)
    00073
    00074 #define mwFileTransfer_isPending(ft) \
    00075   mwFileTransfer_isState((ft), mwFileTransfer_PENDING)
    00076
    00077 #define mwFileTransfer_isOpen(ft) \
    00078   mwFileTransfer_isState((ft), mwFileTransfer_OPEN)
    00079
    00080 #define mwFileTransfer_isDone(ft) \
    00081   mwFileTransfer_isState((ft), mwFileTransfer_DONE)
    00082
    00083 #define mwFileTransfer_isCancelLocal(ft) \
    00084   mwFileTransfer_isState((ft), mwFileTransfer_CANCEL_LOCAL)
    00085
    00086 #define mwFileTransfer_isCancelRemote(ft) \
    00087   mwFileTransfer_isState((ft), mwFileTransfer_CANCEL_REMOTE)
    00088
    00089
    00090 enum mwFileTranferCode {
    00091   mwFileTransfer_SUCCESS   = 0x00000000,
    00092   mwFileTransfer_REJECTED  = 0x08000606,
    00093 };
    00094
    00095
    00096 struct mwFileTransferHandler {
    00097
    00099   void (*ft_offered)(struct mwFileTransfer *ft);
    00100
    00102   void (*ft_opened)(struct mwFileTransfer *ft);
    00103
    00107   void (*ft_closed)(struct mwFileTransfer *ft, guint32 code);
    00108
    00110   void (*ft_recv)(struct mwFileTransfer *ft, struct mwOpaque *data);
    00111
    00115   void (*ft_ack)(struct mwFileTransfer *ft);
    00116
    00118   void (*clear)(struct mwServiceFileTransfer *srvc);
    00119 };
    00120
    00121
    00122 struct mwServiceFileTransfer *
    00123 mwServiceFileTransfer_new(struct mwSession *session,
    00124                           struct mwFileTransferHandler *handler);
    00125
    00126
    00127 struct mwFileTransferHandler *
    00128 mwServiceFileTransfer_getHandler(struct mwServiceFileTransfer *srvc);
    00129
    00130
    00131 const GList *
    00132 mwServiceFileTransfer_getTransfers(struct mwServiceFileTransfer *srvc);
    00133
    00134
    00135 struct mwFileTransfer *
    00136 mwFileTransfer_new(struct mwServiceFileTransfer *srvc,
    00137                    const struct mwIdBlock *who, const char *msg,
    00138                    const char *filename, guint32 filesize);
    00139
    00140
    00143 void
    00144 mwFileTransfer_free(struct mwFileTransfer *ft);
    00145
    00146
    00148 enum mwFileTransferState
    00149 mwFileTransfer_getState(struct mwFileTransfer *ft);
    00150
    00151
    00152 struct mwServiceFileTransfer *
    00153 mwFileTransfer_getService(struct mwFileTransfer *ft);
    00154
    00155
    00157 const struct mwIdBlock *
    00158 mwFileTransfer_getUser(struct mwFileTransfer *ft);
    00159
    00160
    00162 const char *
    00163 mwFileTransfer_getMessage(struct mwFileTransfer *ft);
    00164
    00165
    00168 const char *
    00169 mwFileTransfer_getFileName(struct mwFileTransfer *ft);
    00170
    00171
    00173 guint32 mwFileTransfer_getFileSize(struct mwFileTransfer *ft);
    00174
    00175
    00177 guint32 mwFileTransfer_getRemaining(struct mwFileTransfer *ft);
    00178
    00179
    00181 #define mwFileTransfer_getSent(ft) \
    00182   (mwFileTransfer_getFileSize(ft) - mwFileTransfer_getRemaining(ft))
    00183
    00184
    00186 int mwFileTransfer_offer(struct mwFileTransfer *ft);
    00187
    00188
    00190 int mwFileTransfer_accept(struct mwFileTransfer *ft);
    00191
    00192
    00194 #define mwFileTransfer_reject(ft) \
    00195   mwFileTransfer_close((ft), mwFileTransfer_REJECTED)
    00196
    00197
    00199 #define mwFileTransfer_cancel(ft) \
    00200   mwFileTransfer_close((ft), mwFileTransfer_SUCCESS);
    00201
    00202
    00209 int mwFileTransfer_close(struct mwFileTransfer *ft, guint32 code);
    00210
    00211
    00218 int mwFileTransfer_send(struct mwFileTransfer *ft,
    00219                         struct mwOpaque *data);
    00220
    00221
    00231 int mwFileTransfer_ack(struct mwFileTransfer *ft);
    00232
    00233
    00234 void mwFileTransfer_setClientData(struct mwFileTransfer *ft,
    00235                                   gpointer data, GDestroyNotify clean);
    00236
    00237
    00238 gpointer mwFileTransfer_getClientData(struct mwFileTransfer *ft);
    00239
    00240
    00241 void mwFileTransfer_removeClientData(struct mwFileTransfer *ft);
    00242
    00243
    00244 #ifdef __cplusplus
    00245 }
    00246 #endif
    00247
    00248
    00249 #endif /* _MW_SRVC_FT_H */