MainThread.h 4.1 KB

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