DownloadManager.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: DownloadManager.h //////////////////////////////////////////////////////
  24. // Generals download class definitions
  25. // Author: Matthew D. Campbell, July 2002
  26. #pragma once
  27. #ifndef __DOWNLOADMANAGER_H__
  28. #define __DOWNLOADMANAGER_H__
  29. #include "WWDownload/downloadDefs.h"
  30. #include "WWDownload/download.h"
  31. class CDownload;
  32. class QueuedDownload
  33. {
  34. public:
  35. AsciiString server;
  36. AsciiString userName;
  37. AsciiString password;
  38. AsciiString file;
  39. AsciiString localFile;
  40. AsciiString regKey;
  41. Bool tryResume;
  42. };
  43. /////////////////////////////////////////////////////////////////////////////
  44. // DownloadManager
  45. class DownloadManager : public IDownload
  46. {
  47. public:
  48. DownloadManager();
  49. virtual ~DownloadManager();
  50. public:
  51. void init( void );
  52. HRESULT update( void );
  53. void reset( void );
  54. virtual HRESULT OnError( Int error );
  55. virtual HRESULT OnEnd();
  56. virtual HRESULT OnQueryResume();
  57. virtual HRESULT OnProgressUpdate( Int bytesread, Int totalsize, Int timetaken, Int timeleft );
  58. virtual HRESULT OnStatusUpdate( Int status );
  59. virtual HRESULT downloadFile( AsciiString server, AsciiString username, AsciiString password, AsciiString file, AsciiString localfile, AsciiString regkey, Bool tryResume );
  60. AsciiString getLastLocalFile( void );
  61. Bool isDone( void ) { return m_sawEnd || m_wasError; }
  62. Bool isOk( void ) { return m_sawEnd; }
  63. Bool wasError( void ) { return m_wasError; }
  64. UnicodeString getStatusString( void ) { return m_statusString; }
  65. UnicodeString getErrorString( void ) { return m_errorString; }
  66. void queueFileForDownload( AsciiString server, AsciiString username, AsciiString password, AsciiString file, AsciiString localfile, AsciiString regkey, Bool tryResume );
  67. Bool isFileQueuedForDownload( void ) { return !m_queuedDownloads.empty(); }
  68. HRESULT downloadNextQueuedFile( void );
  69. private:
  70. Bool m_winsockInit;
  71. CDownload *m_download;
  72. Bool m_wasError;
  73. Bool m_sawEnd;
  74. UnicodeString m_errorString;
  75. UnicodeString m_statusString;
  76. protected:
  77. std::list<QueuedDownload> m_queuedDownloads;
  78. };
  79. extern DownloadManager *TheDownloadManager;
  80. #endif // __DOWNLOADMANAGER_H__