Login.h 17 KB

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