Login.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. //----------------------------------------------------------------------------
  2. #ifndef LoginH
  3. #define LoginH
  4. //----------------------------------------------------------------------------
  5. #include "ComboEdit.hpp"
  6. #include "PasswordEdit.hpp"
  7. #include "UpDownEdit.hpp"
  8. #include "PngImageList.hpp"
  9. #include <System.Classes.hpp>
  10. #include <Vcl.ActnList.hpp>
  11. #include <Vcl.ComCtrls.hpp>
  12. #include <Vcl.Controls.hpp>
  13. #include <Vcl.ExtCtrls.hpp>
  14. #include <Vcl.Forms.hpp>
  15. #include <Vcl.ImgList.hpp>
  16. #include <Vcl.Mask.hpp>
  17. #include <Vcl.Menus.hpp>
  18. #include <Vcl.StdCtrls.hpp>
  19. //----------------------------------------------------------------------------
  20. #include <Configuration.h>
  21. #include <CustomWinConfiguration.h>
  22. #include <SessionData.h>
  23. #include <PasTools.hpp>
  24. #include <System.Actions.hpp>
  25. //----------------------------------------------------------------------------
  26. class TLoginDialog : public TForm
  27. {
  28. __published:
  29. TButton *LoginButton;
  30. TButton *CloseButton;
  31. TActionList *ActionList;
  32. TAction *EditSessionAction;
  33. TAction *SaveSessionAction;
  34. TAction *DeleteSessionAction;
  35. TAction *ImportSessionsAction;
  36. TAction *LoginAction;
  37. TAction *AboutAction;
  38. TAction *CleanUpAction;
  39. TAction *ResetNewSessionAction;
  40. TPanel *MainPanel;
  41. TTreeView *SessionTree;
  42. TAction *SetDefaultSessionAction;
  43. TButton *ToolsMenuButton;
  44. TPopupMenu *ToolsPopupMenu;
  45. TMenuItem *Import1;
  46. TMenuItem *Cleanup1;
  47. TAction *DesktopIconAction;
  48. TAction *SendToHookAction;
  49. TAction *CheckForUpdatesAction;
  50. TMenuItem *CheckForUpdates1;
  51. TButton *SaveButton;
  52. TButton *HelpButton;
  53. TAction *RenameSessionAction;
  54. TPngImageList *SessionImageList;
  55. TAction *NewSessionFolderAction;
  56. TPopupMenu *SaveDropDownMenu;
  57. TMenuItem *SaveSessionMenuItem;
  58. TMenuItem *Setdefaults1;
  59. TMenuItem *N1;
  60. TMenuItem *N2;
  61. TMenuItem *Pageant1;
  62. TMenuItem *Puttygen1;
  63. TAction *RunPageantAction;
  64. TAction *RunPuttygenAction;
  65. TAction *ImportAction;
  66. TAction *ExportAction;
  67. TMenuItem *N3;
  68. TMenuItem *ImportConfiguration1;
  69. TMenuItem *ExportConfiguration1;
  70. TStaticText *SitesIncrementalSearchLabel;
  71. TAction *PreferencesAction;
  72. TMenuItem *N4;
  73. TMenuItem *Preferences1;
  74. TMenuItem *About1;
  75. TPanel *SitesPanel;
  76. TPanel *ContentsPanel;
  77. TGroupBox *ContentsGroupBox;
  78. TLabel *ContentsLabel;
  79. TEdit *ContentsNameEdit;
  80. TMemo *ContentsMemo;
  81. TPanel *SitePanel;
  82. TGroupBox *BasicGroup;
  83. TLabel *Label1;
  84. TLabel *Label2;
  85. TLabel *UserNameLabel;
  86. TLabel *PasswordLabel;
  87. TLabel *Label22;
  88. TLabel *FtpsLabel;
  89. TLabel *WebDavsLabel;
  90. TEdit *HostNameEdit;
  91. TEdit *UserNameEdit;
  92. TPasswordEdit *PasswordEdit;
  93. TUpDownEdit *PortNumberEdit;
  94. TComboBox *TransferProtocolCombo;
  95. TComboBox *FtpsCombo;
  96. TComboBox *WebDavsCombo;
  97. TPanel *BasicFtpPanel;
  98. TCheckBox *AnonymousLoginCheck;
  99. TPanel *BasicSshPanel;
  100. TButton *AdvancedButton;
  101. TButton *ManageButton;
  102. TPopupMenu *ManageSitePopupMenu;
  103. TMenuItem *Edit1;
  104. TMenuItem *Delete1;
  105. TMenuItem *Rename1;
  106. TMenuItem *Newfolder1;
  107. TMenuItem *DesktopIcon2;
  108. TMenuItem *ExplorersSendToShortcut2;
  109. TMenuItem *Shellicon2;
  110. TMenuItem *N5;
  111. TMenuItem *Shellicon1;
  112. TMenuItem *N6;
  113. TPopupMenu *ManageFolderPopupMenu;
  114. TMenuItem *MenuItem1;
  115. TMenuItem *MenuItem3;
  116. TMenuItem *MenuItem4;
  117. TMenuItem *MenuItem5;
  118. TMenuItem *MenuItem6;
  119. TMenuItem *MenuItem7;
  120. TMenuItem *MenuItem8;
  121. TPopupMenu *ManageNewSitePopupMenu;
  122. TMenuItem *MenuItem12;
  123. TMenuItem *MenuItem13;
  124. TMenuItem *MenuItem16;
  125. TMenuItem *MenuItem17;
  126. TMenuItem *MenuItem21;
  127. TMenuItem *MenuItem22;
  128. TMenuItem *Setdefaults2;
  129. TMenuItem *Reset1;
  130. TPopupMenu *ManageWorkspacePopupMenu;
  131. TMenuItem *MenuItem2;
  132. TMenuItem *MenuItem10;
  133. TMenuItem *MenuItem11;
  134. TMenuItem *MenuItem18;
  135. TMenuItem *MenuItem19;
  136. TButton *EditCancelButton;
  137. TAction *EditCancelAction;
  138. TButton *EditButton;
  139. TAction *SaveAsSessionAction;
  140. TMenuItem *SaveAsSessionMenuItem;
  141. TMenuItem *N7;
  142. TEdit *TransferProtocolView;
  143. TEdit *EncryptionView;
  144. TPanel *ButtonPanel;
  145. TPopupMenu *SessionAdvancedPopupMenu;
  146. TMenuItem *MenuItem9;
  147. TMenuItem *MenuItem14;
  148. TAction *SessionAdvancedAction;
  149. TAction *PreferencesLoggingAction;
  150. TMenuItem *PreferencesLoggingAction1;
  151. TMenuItem *Session1;
  152. TPngImageList *ActionImageList;
  153. TAction *CloneToNewSiteAction;
  154. TMenuItem *SiteClonetoNewSiteMenuItem;
  155. TAction *PuttyAction;
  156. TPopupMenu *LoginDropDownMenu;
  157. TMenuItem *Login1;
  158. TMenuItem *OpeninPuTTY1;
  159. TMenuItem *Login2;
  160. TMenuItem *N8;
  161. TMenuItem *Login3;
  162. TMenuItem *N9;
  163. TMenuItem *SiteLoginMenuItem;
  164. TMenuItem *N10;
  165. TMenuItem *Login5;
  166. TMenuItem *N11;
  167. TMenuItem *OpeninPuTTY2;
  168. TMenuItem *OpeninPuTTY3;
  169. TAction *PasteUrlAction;
  170. TMenuItem *Paste1;
  171. TAction *GenerateUrlAction2;
  172. TMenuItem *GenerateSessionURL1;
  173. TMenuItem *GenerateSessionURL2;
  174. TAction *CopyParamRuleAction;
  175. TMenuItem *TransferSettingsRule1;
  176. TGroupBox *NoteGroup;
  177. TMemo *NoteMemo;
  178. TPanel *ComponentsPanel;
  179. TPngImageList *SessionImageList120;
  180. TPngImageList *ActionImageList120;
  181. TAction *SearchSiteNameStartOnlyAction;
  182. TAction *SearchSiteNameAction;
  183. TAction *SearchSiteAction;
  184. TMenuItem *Options1;
  185. TMenuItem *IncrementalSearch1;
  186. TMenuItem *SearchSiteNameStartOnly1;
  187. TMenuItem *SearchSiteName1;
  188. TMenuItem *SearchSite1;
  189. TMenuItem *Options2;
  190. TMenuItem *IncrementalSearch2;
  191. TMenuItem *AllMajorSiteFields1;
  192. TMenuItem *AnyPartofSiteName1;
  193. TMenuItem *BeginningofSiteNameOnly1;
  194. TMenuItem *Options3;
  195. TMenuItem *IncrementalSearch3;
  196. TMenuItem *AllMajorSiteFields2;
  197. TMenuItem *AnyPartofSiteName2;
  198. TMenuItem *BeginningofSiteNameOnly2;
  199. TMenuItem *Options4;
  200. TMenuItem *IncrementalSearch4;
  201. TMenuItem *AllMajorSiteFields3;
  202. TMenuItem *AnyPartofSiteName3;
  203. TMenuItem *BeginningofSiteNameOnly3;
  204. TPngImageList *SessionImageList144;
  205. TPngImageList *SessionImageList192;
  206. TPngImageList *ActionImageList144;
  207. TPngImageList *ActionImageList192;
  208. void __fastcall DataChange(TObject *Sender);
  209. void __fastcall FormShow(TObject *Sender);
  210. void __fastcall SessionTreeDblClick(TObject *Sender);
  211. void __fastcall SessionTreeKeyDown(TObject *Sender, WORD &Key,
  212. TShiftState Shift);
  213. void __fastcall EditSessionActionExecute(TObject *Sender);
  214. void __fastcall SaveSessionActionExecute(TObject *Sender);
  215. void __fastcall DeleteSessionActionExecute(TObject *Sender);
  216. void __fastcall ImportSessionsActionExecute(TObject *Sender);
  217. void __fastcall CleanUpActionExecute(TObject *Sender);
  218. void __fastcall AboutActionExecute(TObject *Sender);
  219. void __fastcall ActionListUpdate(TBasicAction *Action,
  220. bool &Handled);
  221. void __fastcall PreferencesActionExecute(TObject *Sender);
  222. void __fastcall ResetNewSessionActionExecute(TObject *Sender);
  223. void __fastcall SetDefaultSessionActionExecute(TObject *Sender);
  224. void __fastcall ToolsMenuButtonClick(TObject *Sender);
  225. void __fastcall DesktopIconActionExecute(TObject *Sender);
  226. void __fastcall SendToHookActionExecute(TObject *Sender);
  227. void __fastcall CheckForUpdatesActionExecute(TObject *Sender);
  228. void __fastcall HelpButtonClick(TObject *Sender);
  229. void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
  230. void __fastcall RenameSessionActionExecute(TObject * Sender);
  231. void __fastcall TransferProtocolComboChange(TObject *Sender);
  232. void __fastcall NavigationTreeCollapsing(TObject *Sender,
  233. TTreeNode *Node, bool &AllowCollapse);
  234. void __fastcall SessionTreeChange(TObject *Sender, TTreeNode *Node);
  235. void __fastcall SessionTreeEdited(TObject *Sender, TTreeNode *Node,
  236. UnicodeString &S);
  237. void __fastcall SessionTreeEditing(TObject *Sender, TTreeNode *Node,
  238. bool &AllowEdit);
  239. void __fastcall SessionTreeCustomDrawItem(TCustomTreeView *Sender,
  240. TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw);
  241. void __fastcall SessionTreeExpandedCollapsed(TObject *Sender, TTreeNode *Node);
  242. void __fastcall SessionTreeCompare(TObject *Sender, TTreeNode *Node1,
  243. TTreeNode *Node2, int Data, int &Compare);
  244. void __fastcall NewSessionFolderActionExecute(TObject *Sender);
  245. void __fastcall SessionTreeStartDrag(TObject *Sender,
  246. TDragObject *&DragObject);
  247. void __fastcall SessionTreeDragDrop(TObject *Sender, TObject *Source,
  248. int X, int Y);
  249. void __fastcall SessionTreeMouseMove(TObject *Sender, TShiftState Shift,
  250. int X, int Y);
  251. void __fastcall SessionTreeEndDrag(TObject *Sender, TObject *Target,
  252. int X, int Y);
  253. void __fastcall AnonymousLoginCheckClick(TObject *Sender);
  254. void __fastcall SaveButtonDropDownClick(TObject *Sender);
  255. void __fastcall SessionTreeExpanding(TObject *Sender, TTreeNode *Node, bool &AllowExpansion);
  256. void __fastcall RunPageantActionExecute(TObject *Sender);
  257. void __fastcall RunPuttygenActionExecute(TObject *Sender);
  258. void __fastcall PortNumberEditChange(TObject *Sender);
  259. void __fastcall ExportActionExecute(TObject *Sender);
  260. void __fastcall ImportActionExecute(TObject *Sender);
  261. void __fastcall SessionTreeKeyPress(TObject *Sender, System::WideChar &Key);
  262. void __fastcall SessionTreeExit(TObject *Sender);
  263. void __fastcall SessionTreeChanging(TObject *Sender, TTreeNode *Node, bool &AllowChange);
  264. void __fastcall SessionAdvancedActionExecute(TObject *Sender);
  265. void __fastcall ManageButtonClick(TObject *Sender);
  266. void __fastcall SessionTreeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
  267. int X, int Y);
  268. void __fastcall SessionTreeContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled);
  269. void __fastcall EditCancelActionExecute(TObject *Sender);
  270. void __fastcall SaveAsSessionActionExecute(TObject *Sender);
  271. void __fastcall AdvancedButtonDropDownClick(TObject *Sender);
  272. void __fastcall PreferencesLoggingActionExecute(TObject *Sender);
  273. void __fastcall CloneToNewSiteActionExecute(TObject *Sender);
  274. void __fastcall LoginActionExecute(TObject *Sender);
  275. void __fastcall PuttyActionExecute(TObject *Sender);
  276. void __fastcall LoginButtonDropDownClick(TObject *Sender);
  277. void __fastcall PasteUrlActionExecute(TObject *Sender);
  278. void __fastcall HostNameEditExit(TObject *Sender);
  279. void __fastcall GenerateUrlAction2Execute(TObject *Sender);
  280. void __fastcall CopyParamRuleActionExecute(TObject *Sender);
  281. void __fastcall SearchSiteNameStartOnlyActionExecute(TObject *Sender);
  282. void __fastcall SearchSiteNameActionExecute(TObject *Sender);
  283. void __fastcall SearchSiteActionExecute(TObject *Sender);
  284. private:
  285. int NoUpdate;
  286. TSessionData * FNewSiteData;
  287. bool FNewSiteKeepName;
  288. TSessionData * FSessionData;
  289. TStoredSessionList * FStoredSessions;
  290. bool FInitialized;
  291. TWndMethod FOldSessionTreeProc;
  292. TTreeNode * FHintNode;
  293. TTreeViewScrollOnDragOver * FScrollOnDragOver;
  294. int FDefaultPort;
  295. TList * FDataList;
  296. bool FUpdatePortWithProtocol;
  297. UnicodeString FSitesIncrementalSearch;
  298. int FIncrementalSearching;
  299. bool FSitesIncrementalSearchHaveNext;
  300. int FBasicGroupBaseHeight;
  301. int FNoteGroupOffset;
  302. bool FEditing;
  303. bool FRenaming;
  304. bool FForceNewSite;
  305. bool FLoading;
  306. bool FSortEnablePending;
  307. std::unique_ptr<TImageList> FButtonImageList;
  308. TSiteSearch FSiteSearch;
  309. TForm * FLinkedForm;
  310. TPoint FPrevPos;
  311. int FSiteButtonsPadding;
  312. void __fastcall LoadSession(TSessionData * SessionData);
  313. void __fastcall LoadContents();
  314. void __fastcall UpdateControls();
  315. void __fastcall SetSessionData(TSessionData * value);
  316. TSessionData * __fastcall GetSessionData();
  317. void __fastcall SaveSession(TSessionData * aStoredSession);
  318. void __fastcall LoadSessions();
  319. TSessionData * __fastcall GetSelectedSession();
  320. void __fastcall CMDialogKey(TWMKeyDown & Message);
  321. int __fastcall FSProtocolToIndex(TFSProtocol FSProtocol, bool & AllowScpFallback);
  322. TFSProtocol __fastcall IndexToFSProtocol(int Index, bool AllowScpFallback);
  323. int __fastcall FtpsToIndex(TFtps Ftps);
  324. TFtps __fastcall GetFtps();
  325. TFSProtocol __fastcall GetFSProtocol(bool RequireScpFallbackDistinction);
  326. void __fastcall UpdateFolderNode(TTreeNode * Node);
  327. TTreeNode * __fastcall AddSession(TSessionData * Data);
  328. TTreeNode * __fastcall AddSessionPath(UnicodeString Path,
  329. bool CanCreate, bool IsWorkspace);
  330. void __fastcall DestroySession(TSessionData * Data);
  331. void __fastcall CheckDuplicateFolder(TTreeNode * Parent, UnicodeString Text,
  332. TTreeNode * Node);
  333. void __fastcall CheckIsSessionFolder(TTreeNode * Node);
  334. void __fastcall NewSessionFolderInputDialogInitialize(
  335. TObject * Sender, TInputDialogData * Data);
  336. UnicodeString __fastcall SessionNodePath(TTreeNode * Node);
  337. TTreeNode * __fastcall SessionFolderNode(TTreeNode * Node);
  338. TTreeNode * __fastcall CurrentSessionFolderNode();
  339. void __fastcall SessionTreeProc(TMessage & Message);
  340. TTreeNode * __fastcall NormalizeDropTarget(TTreeNode * DropTarget);
  341. bool __fastcall SessionAllowDrop(TTreeNode * DropTarget);
  342. int __fastcall DefaultPort();
  343. void __fastcall MasterPasswordRecrypt(TObject * Sender);
  344. void __fastcall LoadOpenedStoredSessionFolders(
  345. TTreeNode * Node, TStrings * OpenedStoredSessionFolders);
  346. bool __fastcall HasNodeAnySession(TTreeNode * Node, bool NeedCanLogin = false);
  347. void __fastcall SaveDataList(TList * DataList);
  348. inline bool __fastcall IsFolderNode(TTreeNode * Node);
  349. inline bool __fastcall IsWorkspaceNode(TTreeNode * Node);
  350. inline bool __fastcall IsFolderOrWorkspaceNode(TTreeNode * Node);
  351. inline bool __fastcall IsSessionNode(TTreeNode * Node);
  352. inline bool __fastcall IsSiteNode(TTreeNode * Node);
  353. inline bool __fastcall IsNewSiteNode(TTreeNode * Node);
  354. TTreeNode * __fastcall GetNewSiteNode();
  355. void __fastcall SetNewSiteNodeLabel();
  356. inline TSessionData * __fastcall GetNodeSession(TTreeNode * Node);
  357. void __fastcall ExecuteTool(const UnicodeString & Name);
  358. void __fastcall ReloadSessions(const UnicodeString & SelectSite);
  359. void __fastcall ResetSitesIncrementalSearch();
  360. bool __fastcall SitesIncrementalSearch(const UnicodeString & Text,
  361. bool SkipCurrent, bool Reverse);
  362. TTreeNode * __fastcall SearchSite(const UnicodeString & Text,
  363. bool AllowExpanding, bool SkipCurrent, bool Reverse);
  364. TTreeNode * __fastcall GetNextNode(TTreeNode * Node, bool Reverse);
  365. UnicodeString __fastcall GetFolderOrWorkspaceContents(
  366. TTreeNode * Node, const UnicodeString & Indent, const UnicodeString & CommonRoot);
  367. TPopupMenu * __fastcall GetSelectedNodePopupMenu();
  368. void __fastcall PersistNewSiteIfNeeded();
  369. TTreeNode * __fastcall FindSessionNode(TSessionData * SessionData, bool ByName);
  370. void __fastcall UpdateButtonVisibility(TButton * Button);
  371. void __fastcall Idle();
  372. TSessionData * __fastcall GetEditingSessionData();
  373. void __fastcall SaveAsSession(bool ForceDialog);
  374. void __fastcall InvalidateSessionData();
  375. bool __fastcall CanLogin();
  376. bool __fastcall IsCloneToNewSiteDefault();
  377. bool __fastcall IsDefaultResult(TModalResult Result);
  378. void __fastcall UpdateNodeImage(TTreeNode * Node);
  379. void __fastcall UpdateNodeImages();
  380. int __fastcall GetSessionImageIndex(TSessionData * Data);
  381. void __fastcall SetNodeImage(TTreeNode * Node, int ImageIndex);
  382. void __fastcall CancelEditing();
  383. bool __fastcall EnsureNotEditing();
  384. bool __fastcall IsEditable();
  385. TSessionData * __fastcall CloneSelectedSession();
  386. void __fastcall CloneToNewSite();
  387. void __fastcall ParseUrl(const UnicodeString & Url);
  388. void __fastcall ParseHostName();
  389. void __fastcall ResetNewSiteData();
  390. TModalResult __fastcall DefaultResult();
  391. int __fastcall AddLoginButtonImage(bool Enabled);
  392. void __fastcall WMMoving(TMessage & Message);
  393. protected:
  394. void __fastcall Default();
  395. void __fastcall NewSite();
  396. void __fastcall SaveConfiguration();
  397. void __fastcall LoadState();
  398. void __fastcall SaveState();
  399. void __fastcall ShowPreferencesDialog(TPreferencesMode PreferencesMode);
  400. virtual void __fastcall Dispatch(void * Message);
  401. void __fastcall Init();
  402. void __fastcall InitControls();
  403. void __fastcall EditSession();
  404. void __fastcall Login();
  405. __property TSessionData * SelectedSession = { read=GetSelectedSession };
  406. public:
  407. virtual __fastcall TLoginDialog(TComponent* AOwner);
  408. __fastcall ~TLoginDialog();
  409. void __fastcall Init(TStoredSessionList *SessionList, TForm * LinkedForm);
  410. bool __fastcall Execute(TList * DataList);
  411. };
  412. //----------------------------------------------------------------------------
  413. #endif