llxfer_file.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * @file llxfer_file.h
  3. * @brief definition of LLXfer_File class for a single xfer_file.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLXFER_FILE_H
  33. #define LL_LLXFER_FILE_H
  34. #include "lldir.h"
  35. #include "llpreprocessor.h"
  36. #include "llxfer.h"
  37. class LLXfer_File : public LLXfer
  38. {
  39. protected:
  40. LOG_CLASS(LLXfer_File);
  41. public:
  42. LLXfer_File(S32 chunk_size);
  43. LLXfer_File(const std::string& local_filename,
  44. bool delete_local_on_completion, S32 chunk_size);
  45. virtual ~LLXfer_File();
  46. virtual void init(const std::string& local_filename,
  47. bool delete_local_on_completion, S32 chunk_size);
  48. virtual void cleanup();
  49. virtual S32 initializeRequest(U64 xfer_id,
  50. const std::string& local_filename,
  51. const std::string& remote_filename,
  52. ELLPath remote_path,
  53. const LLHost& remote_host,
  54. bool delete_remote_on_completion,
  55. void (*callback)(void**, S32, LLExtStat),
  56. void** user_data);
  57. virtual S32 startDownload();
  58. virtual S32 processEOF();
  59. virtual S32 startSend(U64 xfer_id, const LLHost& remote_host);
  60. virtual void closeFileHandle();
  61. virtual S32 reopenFileHandle();
  62. virtual S32 suck(S32 start_position);
  63. virtual S32 flush();
  64. LL_INLINE virtual bool matchesLocalFilename(const std::string& filename)
  65. {
  66. return filename == mLocalFilename;
  67. }
  68. LL_INLINE virtual bool matchesRemoteFilename(const std::string& filename,
  69. ELLPath remote_path)
  70. {
  71. return filename == mRemoteFilename && remote_path == mRemotePath;
  72. }
  73. LL_INLINE virtual S32 getMaxBufferSize() { return LL_MAX_XFER_FILE_BUFFER; }
  74. // Hacky: doesn't matter what this is as long as it's different from the
  75. // other classes:
  76. LL_INLINE virtual U32 getXferTypeTag() { return LLXfer::XFER_FILE; }
  77. LL_INLINE virtual std::string getFileName() { return mLocalFilename; }
  78. protected:
  79. LLFILE* mFp;
  80. ELLPath mRemotePath;
  81. bool mDeleteLocalOnCompletion;
  82. bool mDeleteRemoteOnCompletion;
  83. std::string mLocalFilename;
  84. std::string mRemoteFilename;
  85. std::string mTempFilename;
  86. };
  87. #endif