Download.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // Download.h : Declaration of the CDownload
  19. #ifndef __DOWNLOAD_H_
  20. #define __DOWNLOAD_H_
  21. //#include "../resource.h" // main symbols
  22. #include "WWDownload/ftp.h"
  23. #include "WWDownload/downloaddefs.h"
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CDownload
  26. class IDownload
  27. {
  28. public:
  29. virtual HRESULT OnError( int error )=0;
  30. virtual HRESULT OnEnd()=0;
  31. virtual HRESULT OnQueryResume()=0;
  32. virtual HRESULT OnProgressUpdate(int bytesread, int totalsize, int timetaken, int timeleft)=0;
  33. virtual HRESULT OnStatusUpdate(int status)=0;
  34. };
  35. class CDownload
  36. {
  37. public:
  38. CDownload(IDownload *listener) :
  39. Listener(listener)
  40. {
  41. m_Status = DOWNLOADSTATUS_NONE;
  42. m_TimeStarted = 0;
  43. m_StartPosition = 0;
  44. m_FileSize = 0;
  45. m_BytesRead = 0;
  46. m_Server[ 0 ] = '\0';
  47. m_Login[ 0 ] = '\0';
  48. m_Password[ 0 ] = '\0';
  49. m_File[ 0 ] = '\0';
  50. m_LocalFile[ 0 ] = '\0';
  51. m_RegKey[ 0 ] = '\0';
  52. m_Ftp = new( Cftp );
  53. m_TryResume = false;
  54. m_predictions = 0;
  55. for (int i=0; i<8; ++i)
  56. {
  57. m_predictionTimes[i] = 0;
  58. }
  59. }
  60. ~CDownload() { delete m_Ftp; }
  61. public:
  62. virtual HRESULT PumpMessages();
  63. virtual HRESULT Abort();
  64. virtual HRESULT DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password, LPCSTR file, LPCSTR localfile, LPCSTR regkey, bool tryresume=true);
  65. virtual HRESULT GetLastLocalFile(char *local_file, int maxlen);
  66. private:
  67. char m_Server[ 256 ];
  68. char m_Login[ 64 ];
  69. char m_Password[ 64 ];
  70. char m_File[ 256 ];
  71. char m_LocalFile[ 256 ];
  72. char m_LastLocalFile[ 256 ];
  73. char m_RegKey[ 256 ];
  74. int m_Status;
  75. int m_TimeStarted;
  76. int m_StartPosition;
  77. int m_FileSize;
  78. int m_BytesRead;
  79. bool m_TryResume;
  80. int m_predictions;
  81. int m_predictionTimes[8];
  82. Cftp *m_Ftp;
  83. IDownload *Listener;
  84. };
  85. #endif //__DOWNLOAD_H_