MainThread.h 4.0 KB

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