PageRenderTime 26ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/lltransfertargetfile.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 75 lines | 38 code | 12 blank | 25 comment | 0 complexity | 70015a3ee76873d372764697782aa232 MD5 | raw file
 1/** 
 2 * @file lltransfertargetfile.h
 3 * @brief Transfer system for receiving a file.
 4 *
 5 * $LicenseInfo:firstyear=2006&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_LLTRANSFERTARGETFILE_H
28#define LL_LLTRANSFERTARGETFILE_H
29
30#include "lltransfermanager.h"
31
32typedef void (*LLTTFCompleteCallback)(const LLTSCode status, void *user_data);
33
34class LLTransferTargetParamsFile : public LLTransferTargetParams
35{
36public:
37	LLTransferTargetParamsFile()
38		: LLTransferTargetParams(LLTTT_FILE),
39
40		mCompleteCallback(NULL),
41		mUserData(NULL)
42	{}
43	void setFilename(const std::string& filename)	{ mFilename = filename; }
44	void setCallback(LLTTFCompleteCallback cb, void *user_data)		{ mCompleteCallback = cb; mUserData = user_data; }
45
46	friend class LLTransferTargetFile;
47protected:
48	std::string				mFilename;
49	LLTTFCompleteCallback	mCompleteCallback;
50	void *					mUserData;
51};
52
53
54class LLTransferTargetFile : public LLTransferTarget
55{
56public:
57	LLTransferTargetFile(const LLUUID& uuid, LLTransferSourceType src_type);
58	virtual ~LLTransferTargetFile();
59
60	static void requestTransfer(LLTransferTargetChannel *channelp,
61								const char *local_filename,
62								const LLTransferSourceParams &source_params,
63								LLTTFCompleteCallback callback);
64protected:
65	virtual bool unpackParams(LLDataPacker& dp);
66	/*virtual*/ void applyParams(const LLTransferTargetParams &params);
67	/*virtual*/ LLTSCode dataCallback(const S32 packet_id, U8 *in_datap, const S32 in_size);
68	/*virtual*/ void completionCallback(const LLTSCode status);
69
70	LLTransferTargetParamsFile mParams;
71
72	LLFILE *mFP;
73};
74
75#endif // LL_LLTRANSFERTARGETFILE_H