MainThread.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. void SendDirectoryListing(t_directory * pDirectoryToSend);
  56. #ifndef MPEXT
  57. void SetOption(int nOption, int nValue);
  58. int GetOption(int nOption);
  59. #else
  60. bool UsingMlsd();
  61. bool UsingUtf8();
  62. std::string GetTlsVersionStr();
  63. std::string GetCipherName();
  64. #endif
  65. t_command m_LastCommand;
  66. #ifndef MPEXT_NO_CACHE
  67. CDirectoryCache *m_pDirectoryCache;
  68. #endif
  69. void SetCurrentPath(CServerPath path);
  70. void Quit();
  71. BOOL GetCurrentServer(t_server &server);
  72. bool GetCurrentPath(CServerPath &dir);
  73. CServerPath GetCurrentPath();
  74. void SetConnected(BOOL bConnected = TRUE);
  75. BOOL m_bConnected;
  76. void SetBusy(BOOL bBusy);
  77. BOOL LastOperationSuccessful();
  78. void Command(const t_command& command);
  79. BOOL IsBusy();
  80. HWND m_hOwnerWnd;
  81. CFileZillaTools * m_pTools;
  82. BOOL m_bBusy;
  83. unsigned int m_nReplyMessageID;
  84. unsigned int m_nInternalMessageID;
  85. BOOL IsConnected();
  86. __int64 GetAsyncRequestID() const;
  87. __int64 GetNextAsyncRequestID();
  88. virtual int OnThreadMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
  89. DWORD SuspendThread();
  90. DWORD ResumeThread();
  91. BOOL PostThreadMessage( UINT message , WPARAM wParam, LPARAM lParam);
  92. BOOL IsValid() const;
  93. protected:
  94. BOOL InitInstance();
  95. DWORD ExitInstance();
  96. DWORD Run();
  97. static DWORD WINAPI ThreadProc(LPVOID lpParameter);
  98. CCriticalSection m_CriticalSection;
  99. void ShowStatus(CString status,int type);
  100. void ShowStatus(UINT nID, int type);
  101. CControlSocket *m_pControlSocket;
  102. CFtpControlSocket *m_pFtpControlSocket;
  103. #ifndef MPEXT_NO_SFTP
  104. CSFtpControlSocket *m_pSFtpControlSocket;
  105. #endif
  106. __int64 m_nAsyncRequestID;
  107. void OnTimer(WPARAM wParam,LPARAM lParam);
  108. // Überschreibungen
  109. // Implementierung
  110. protected:
  111. #ifndef MPEXT_NO_IDENT
  112. CIdentServerControl *m_pIdentServer;
  113. #endif
  114. t_directory *m_pWorkingDir;
  115. std::map<int, int> m_Options;
  116. BOOL m_bQuit;
  117. t_command *m_pPostKeepAliveCommand;
  118. CServerPath m_CurrentPath;
  119. UINT m_nTimerID;
  120. virtual ~CMainThread();
  121. CEvent m_EventStarted;
  122. };
  123. /////////////////////////////////////////////////////////////////////////////