PageRenderTime 53ms CodeModel.GetById 43ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llmessage/llxfer.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 117 lines | 64 code | 28 blank | 25 comment | 0 complexity | e4d5a13084797ae64d882f6404c65f2c MD5 | raw file
  1/** 
  2 * @file llxfer.h
  3 * @brief definition of LLXfer class for a single xfer
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLXFER_H
 28#define LL_LLXFER_H
 29
 30#include "message.h"
 31#include "lltimer.h"
 32
 33const S32 LL_XFER_LARGE_PAYLOAD = 7680;
 34
 35typedef enum ELLXferStatus {
 36	e_LL_XFER_UNINITIALIZED,
 37	e_LL_XFER_REGISTERED,         // a buffer which has been registered as available for a request
 38	e_LL_XFER_PENDING,            // a transfer which has been requested but is waiting for a free slot
 39	e_LL_XFER_IN_PROGRESS,
 40	e_LL_XFER_COMPLETE,
 41	e_LL_XFER_ABORTED,
 42	e_LL_XFER_NONE
 43} ELLXferStatus;
 44
 45class LLXfer
 46{
 47 private:
 48 protected:
 49        S32 mChunkSize;
 50  
 51 public:
 52	LLXfer *mNext;
 53	U64 mID;
 54	S32 mPacketNum;
 55
 56	LLHost mRemoteHost;
 57	S32 mXferSize;
 58
 59	char *mBuffer;
 60	U32 mBufferLength;
 61	U32 mBufferStartOffset;
 62	BOOL mBufferContainsEOF;
 63
 64	ELLXferStatus mStatus;
 65
 66	BOOL mWaitingForACK;
 67
 68	void (*mCallback)(void **,S32,LLExtStat);	
 69	void **mCallbackDataHandle;
 70	S32 mCallbackResult;
 71
 72	LLTimer ACKTimer;
 73	S32 mRetries;
 74
 75	static const U32 XFER_FILE;
 76	static const U32 XFER_VFILE;
 77	static const U32 XFER_MEM;
 78
 79 private:
 80 protected:
 81 public:
 82	LLXfer (S32 chunk_size);
 83	virtual ~LLXfer();
 84
 85	void init(S32 chunk_size);
 86	virtual void cleanup();
 87
 88	virtual S32 startSend (U64 xfer_id, const LLHost &remote_host);
 89	virtual void sendPacket(S32 packet_num);
 90	virtual void sendNextPacket();
 91	virtual void resendLastPacket();
 92	virtual S32 processEOF();
 93	virtual S32 startDownload();
 94	virtual S32 receiveData (char *datap, S32 data_size);
 95	virtual void abort(S32);
 96
 97	virtual S32 suck(S32 start_position);
 98	virtual S32 flush();
 99	
100	virtual S32 encodePacketNum(S32 packet_num, BOOL is_eof);	
101	virtual void setXferSize (S32 data_size);
102	virtual S32  getMaxBufferSize();
103
104	virtual std::string getFileName();
105
106	virtual U32 getXferTypeTag();
107
108	friend std::ostream& operator<< (std::ostream& os, LLXfer &hh);
109
110};
111
112#endif
113
114
115
116
117