/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. #ifndef LL_LLXFER_H
  27. #define LL_LLXFER_H
  28. #include "message.h"
  29. #include "lltimer.h"
  30. const S32 LL_XFER_LARGE_PAYLOAD = 7680;
  31. typedef enum ELLXferStatus {
  32. e_LL_XFER_UNINITIALIZED,
  33. e_LL_XFER_REGISTERED, // a buffer which has been registered as available for a request
  34. e_LL_XFER_PENDING, // a transfer which has been requested but is waiting for a free slot
  35. e_LL_XFER_IN_PROGRESS,
  36. e_LL_XFER_COMPLETE,
  37. e_LL_XFER_ABORTED,
  38. e_LL_XFER_NONE
  39. } ELLXferStatus;
  40. class LLXfer
  41. {
  42. private:
  43. protected:
  44. S32 mChunkSize;
  45. public:
  46. LLXfer *mNext;
  47. U64 mID;
  48. S32 mPacketNum;
  49. LLHost mRemoteHost;
  50. S32 mXferSize;
  51. char *mBuffer;
  52. U32 mBufferLength;
  53. U32 mBufferStartOffset;
  54. BOOL mBufferContainsEOF;
  55. ELLXferStatus mStatus;
  56. BOOL mWaitingForACK;
  57. void (*mCallback)(void **,S32,LLExtStat);
  58. void **mCallbackDataHandle;
  59. S32 mCallbackResult;
  60. LLTimer ACKTimer;
  61. S32 mRetries;
  62. static const U32 XFER_FILE;
  63. static const U32 XFER_VFILE;
  64. static const U32 XFER_MEM;
  65. private:
  66. protected:
  67. public:
  68. LLXfer (S32 chunk_size);
  69. virtual ~LLXfer();
  70. void init(S32 chunk_size);
  71. virtual void cleanup();
  72. virtual S32 startSend (U64 xfer_id, const LLHost &remote_host);
  73. virtual void sendPacket(S32 packet_num);
  74. virtual void sendNextPacket();
  75. virtual void resendLastPacket();
  76. virtual S32 processEOF();
  77. virtual S32 startDownload();
  78. virtual S32 receiveData (char *datap, S32 data_size);
  79. virtual void abort(S32);
  80. virtual S32 suck(S32 start_position);
  81. virtual S32 flush();
  82. virtual S32 encodePacketNum(S32 packet_num, BOOL is_eof);
  83. virtual void setXferSize (S32 data_size);
  84. virtual S32 getMaxBufferSize();
  85. virtual std::string getFileName();
  86. virtual U32 getXferTypeTag();
  87. friend std::ostream& operator<< (std::ostream& os, LLXfer &hh);
  88. };
  89. #endif