MainThread.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // FileZilla - a Windows ftp client
  2. // Copyright (C) 2002-2004 - Tim Kosse <[email protected]>
  3. // This program is free software; you can redistribute it and/or
  4. // modify it under the terms of the GNU General Public License
  5. // as published by the Free Software Foundation; either version 2
  6. // of the License, or (at your option) any later version.
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program; if not, write to the Free Software
  13. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. /*CMainThread
  15. Main thread of FileZilla. Processes the command messages passed by the main window
  16. */
  17. #ifndef MPEXT_NO_CACHE
  18. #include "DirectoryCache.h" // Hinzugefügt von der Klassenansicht
  19. #endif
  20. #pragma once
  21. #include "controlsocket.h"
  22. #ifndef MPEXT_NO_SFTP
  23. #include "SFtpControlSocket.h"
  24. #endif
  25. #include "FtpControlSocket.h"
  26. #include "structures.h" // Hinzugefügt von der Klassenansicht
  27. #include "FileZillaApi.h" // Hinzugefügt von der Klassenansicht
  28. #include "ApiLog.h"
  29. /////////////////////////////////////////////////////////////////////////////
  30. // Thread CMainThread
  31. #define FZAPI_THREADMSG_PROCESSREPLY 0
  32. #define FZAPI_THREADMSG_COMMAND 1
  33. #define FZAPI_THREADMSG_TRANSFEREND 2
  34. #define FZAPI_THREADMSG_CANCEL 3
  35. #define FZAPI_THREADMSG_DISCONNECT 4
  36. #define FZAPI_THREADMSG_ASYNCREQUESTREPLY 5
  37. #define FZAPI_THREADMSG_POSTKEEPALIVE 6
  38. #ifndef MPEXT_NO_IDENT
  39. class CIdentServerControl;
  40. #endif
  41. class CMainThread : public CApiLog
  42. {
  43. protected:
  44. CMainThread(); // Dynamische Erstellung verwendet geschützten Konstruktor
  45. // Attribute
  46. public:
  47. // Operationen
  48. public:
  49. DWORD m_dwThreadId;
  50. HANDLE m_hThread;
  51. static CMainThread *Create(int nPriority = THREAD_PRIORITY_NORMAL, DWORD dwCreateFlags = 0);
  52. bool GetWorkingDirPath(CServerPath &path);
  53. void SetWorkingDir(t_directory *pWorkingDir);
  54. BOOL GetWorkingDir(t_directory* pWorkingDir);
  55. #ifndef MPEXT
  56. void SetOption(int nOption, int nValue);
  57. int GetOption(int nOption);
  58. #else
  59. bool UsingMlsd();
  60. std::string GetTlsVersionStr();
  61. std::string GetCipherName();
  62. #endif
  63. t_command m_LastCommand;
  64. #ifndef MPEXT_NO_CACHE
  65. CDirectoryCache *m_pDirectoryCache;
  66. #endif
  67. void SetCurrentPath(CServerPath path);
  68. void Quit();
  69. BOOL GetCurrentServer(t_server &server);
  70. bool GetCurrentPath(CServerPath &dir);
  71. CServerPath GetCurrentPath();
  72. void SetConnected(BOOL bConnected = TRUE);
  73. BOOL m_bConnected;
  74. void SetBusy(BOOL bBusy);
  75. BOOL LastOperationSuccessful();
  76. void Command(const t_command& command);
  77. BOOL IsBusy();
  78. HWND m_hOwnerWnd;
  79. CFileZillaTools * m_pTools;
  80. BOOL m_bBusy;
  81. unsigned int m_nReplyMessageID;
  82. unsigned int m_nInternalMessageID;
  83. BOOL IsConnected();
  84. __int64 GetAsyncRequestID() const;
  85. __int64 GetNextAsyncRequestID();
  86. virtual int OnThreadMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
  87. DWORD SuspendThread();
  88. DWORD ResumeThread();
  89. BOOL PostThreadMessage( UINT message , WPARAM wParam, LPARAM lParam);
  90. BOOL IsValid() const;
  91. protected:
  92. BOOL InitInstance();
  93. DWORD ExitInstance();
  94. DWORD Run();
  95. static DWORD WINAPI ThreadProc(LPVOID lpParameter);
  96. CCriticalSection m_CriticalSection;
  97. void ShowStatus(CString status,int type);
  98. void ShowStatus(UINT nID, int type);
  99. CControlSocket *m_pControlSocket;
  100. CFtpControlSocket *m_pFtpControlSocket;
  101. #ifndef MPEXT_NO_SFTP
  102. CSFtpControlSocket *m_pSFtpControlSocket;
  103. #endif
  104. __int64 m_nAsyncRequestID;
  105. void OnTimer(WPARAM wParam,LPARAM lParam);
  106. // Überschreibungen
  107. // Implementierung
  108. protected:
  109. #ifndef MPEXT_NO_IDENT
  110. CIdentServerControl *m_pIdentServer;
  111. #endif
  112. t_directory *m_pWorkingDir;
  113. std::map<int, int> m_Options;
  114. BOOL m_bQuit;
  115. t_command *m_pPostKeepAliveCommand;
  116. CServerPath m_CurrentPath;
  117. UINT m_nTimerID;
  118. virtual ~CMainThread();
  119. CEvent m_EventStarted;
  120. };
  121. /////////////////////////////////////////////////////////////////////////////