GUIConfiguration.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. //---------------------------------------------------------------------------
  2. #ifndef GUIConfigurationH
  3. #define GUIConfigurationH
  4. //---------------------------------------------------------------------------
  5. #include "Configuration.h"
  6. #include "CopyParam.h"
  7. //---------------------------------------------------------------------------
  8. class TGUIConfiguration;
  9. class TStoredSessionList;
  10. enum TLogView { lvNone, lvWindow, pvPanel };
  11. enum TInterface { ifCommander, ifExplorer };
  12. //---------------------------------------------------------------------------
  13. extern const int ccLocal;
  14. extern const int ccShowResults;
  15. extern const int ccCopyResults;
  16. extern const int ccSet;
  17. extern const int ccRemoteFiles;
  18. //---------------------------------------------------------------------------
  19. const int soRecurse = 0x01;
  20. const int soSynchronize = 0x02;
  21. const int soSynchronizeAsk = 0x04;
  22. const int soContinueOnError = 0x08;
  23. //---------------------------------------------------------------------------
  24. class TGUICopyParamType : public TCopyParamType
  25. {
  26. public:
  27. __fastcall TGUICopyParamType();
  28. __fastcall TGUICopyParamType(const TCopyParamType & Source);
  29. __fastcall TGUICopyParamType(const TGUICopyParamType & Source);
  30. void __fastcall Load(THierarchicalStorage * Storage);
  31. void __fastcall Save(THierarchicalStorage * Storage);
  32. virtual void __fastcall Default();
  33. virtual void __fastcall Assign(const TCopyParamType * Source);
  34. TGUICopyParamType & __fastcall operator =(const TGUICopyParamType & rhp);
  35. TGUICopyParamType & __fastcall operator =(const TCopyParamType & rhp);
  36. __property bool Queue = { read = FQueue, write = FQueue };
  37. __property bool QueueNoConfirmation = { read = FQueueNoConfirmation, write = FQueueNoConfirmation };
  38. __property bool QueueIndividually = { read = FQueueIndividually, write = FQueueIndividually };
  39. protected:
  40. void __fastcall GUIDefault();
  41. void __fastcall GUIAssign(const TGUICopyParamType * Source);
  42. private:
  43. bool FQueue;
  44. bool FQueueNoConfirmation;
  45. bool FQueueIndividually;
  46. };
  47. //---------------------------------------------------------------------------
  48. struct TCopyParamRuleData
  49. {
  50. UnicodeString HostName;
  51. UnicodeString UserName;
  52. UnicodeString RemoteDirectory;
  53. UnicodeString LocalDirectory;
  54. void __fastcall Default();
  55. };
  56. //---------------------------------------------------------------------------
  57. class TCopyParamRule
  58. {
  59. public:
  60. __fastcall TCopyParamRule();
  61. __fastcall TCopyParamRule(const TCopyParamRuleData & Data);
  62. __fastcall TCopyParamRule(const TCopyParamRule & Source);
  63. bool __fastcall Matches(const TCopyParamRuleData & Value) const;
  64. void __fastcall Load(THierarchicalStorage * Storage);
  65. void __fastcall Save(THierarchicalStorage * Storage) const;
  66. UnicodeString __fastcall GetInfoStr(UnicodeString Separator) const;
  67. bool __fastcall operator ==(const TCopyParamRule & rhp) const;
  68. __property TCopyParamRuleData Data = { read = FData, write = FData };
  69. __property bool IsEmpty = { read = GetEmpty };
  70. private:
  71. TCopyParamRuleData FData;
  72. inline bool __fastcall Match(const UnicodeString & Mask,
  73. const UnicodeString & Value, bool Path, bool Local, int ForceDirectoryMasks) const;
  74. bool __fastcall GetEmpty() const;
  75. };
  76. //---------------------------------------------------------------------------
  77. class TCopyParamList
  78. {
  79. friend class TGUIConfiguration;
  80. public:
  81. __fastcall TCopyParamList();
  82. virtual __fastcall ~TCopyParamList();
  83. int __fastcall Find(const TCopyParamRuleData & Value) const;
  84. void __fastcall Load(THierarchicalStorage * Storage, int Count);
  85. void __fastcall Save(THierarchicalStorage * Storage) const;
  86. static void __fastcall ValidateName(const UnicodeString Name);
  87. TCopyParamList & __fastcall operator=(const TCopyParamList & rhl);
  88. bool __fastcall operator==(const TCopyParamList & rhl) const;
  89. void __fastcall Clear();
  90. void __fastcall Add(const UnicodeString Name,
  91. TCopyParamType * CopyParam, TCopyParamRule * Rule);
  92. void __fastcall Insert(int Index, const UnicodeString Name,
  93. TCopyParamType * CopyParam, TCopyParamRule * Rule);
  94. void __fastcall Change(int Index, const UnicodeString Name,
  95. TCopyParamType * CopyParam, TCopyParamRule * Rule);
  96. void __fastcall Move(int CurIndex, int NewIndex);
  97. void __fastcall Delete(int Index);
  98. int __fastcall IndexOfName(const UnicodeString Name) const;
  99. __property int Count = { read = GetCount };
  100. __property UnicodeString Names[int Index] = { read = GetName };
  101. __property const TCopyParamRule * Rules[int Index] = { read = GetRule };
  102. __property const TCopyParamType * CopyParams[int Index] = { read = GetCopyParam };
  103. __property bool Modified = { read = FModified };
  104. __property TStrings * NameList = { read = GetNameList };
  105. __property bool AnyRule = { read = GetAnyRule };
  106. private:
  107. static UnicodeString FInvalidChars;
  108. TList * FRules;
  109. TList * FCopyParams;
  110. TStrings * FNames;
  111. mutable TStrings * FNameList;
  112. bool FModified;
  113. int __fastcall GetCount() const;
  114. const TCopyParamRule * __fastcall GetRule(int Index) const;
  115. const TCopyParamType * __fastcall GetCopyParam(int Index) const;
  116. UnicodeString __fastcall GetName(int Index) const;
  117. TStrings * __fastcall GetNameList() const;
  118. bool __fastcall GetAnyRule() const;
  119. void __fastcall Init();
  120. void __fastcall Reset();
  121. void __fastcall Modify();
  122. bool __fastcall CompareItem(int Index, const TCopyParamType * CopyParam,
  123. const TCopyParamRule * Rule) const;
  124. };
  125. //---------------------------------------------------------------------------
  126. class TGUIConfiguration : public TConfiguration
  127. {
  128. private:
  129. TStrings * FLocales;
  130. UnicodeString FLastLocalesExts;
  131. bool FContinueOnError;
  132. bool FConfirmCommandSession;
  133. UnicodeString FPuttyPath;
  134. UnicodeString FPSftpPath;
  135. bool FPuttyPassword;
  136. bool FTelnetForFtpInPutty;
  137. UnicodeString FPuttySession;
  138. int FSynchronizeParams;
  139. int FSynchronizeOptions;
  140. int FSynchronizeModeAuto;
  141. int FSynchronizeMode;
  142. int FMaxWatchDirectories;
  143. TDateTime FIgnoreCancelBeforeFinish;
  144. bool FQueueAutoPopup;
  145. bool FSessionRememberPassword;
  146. int FQueueTransfersLimit;
  147. bool FQueueKeepDoneItems;
  148. int FQueueKeepDoneItemsFor;
  149. TGUICopyParamType FDefaultCopyParam;
  150. bool FBeepOnFinish;
  151. TDateTime FBeepOnFinishAfter;
  152. UnicodeString FDefaultPuttyPathOnly;
  153. UnicodeString FDefaultPuttyPath;
  154. TCopyParamList * FCopyParamList;
  155. bool FCopyParamListDefaults;
  156. UnicodeString FCopyParamCurrent;
  157. TRemoteProperties FNewDirectoryProperties;
  158. int FKeepUpToDateChangeDelay;
  159. UnicodeString FChecksumAlg;
  160. int FSessionReopenAutoIdle;
  161. LCID FAppliedLocale;
  162. protected:
  163. LCID FLocale;
  164. UnicodeString FLocaleModuleName;
  165. virtual void __fastcall SaveData(THierarchicalStorage * Storage, bool All);
  166. virtual void __fastcall LoadData(THierarchicalStorage * Storage);
  167. virtual LCID __fastcall GetLocale();
  168. void __fastcall SetLocale(LCID value);
  169. void __fastcall SetLocaleSafe(LCID value);
  170. virtual HINSTANCE __fastcall LoadNewResourceModule(LCID Locale,
  171. UnicodeString & FileName);
  172. HANDLE __fastcall GetResourceModule();
  173. void __fastcall SetResourceModule(HINSTANCE Instance);
  174. TStrings * __fastcall GetLocales();
  175. void __fastcall FreeResourceModule(HANDLE Instance);
  176. void __fastcall SetDefaultCopyParam(const TGUICopyParamType & value);
  177. virtual bool __fastcall GetRememberPassword();
  178. const TCopyParamList * __fastcall GetCopyParamList();
  179. void __fastcall SetCopyParamList(const TCopyParamList * value);
  180. virtual void __fastcall DefaultLocalized();
  181. int __fastcall GetCopyParamIndex();
  182. TGUICopyParamType __fastcall GetCurrentCopyParam();
  183. TGUICopyParamType __fastcall GetCopyParamPreset(UnicodeString Name);
  184. bool __fastcall GetHasCopyParamPreset(UnicodeString Name);
  185. void __fastcall SetCopyParamIndex(int value);
  186. void __fastcall SetCopyParamCurrent(UnicodeString value);
  187. void __fastcall SetNewDirectoryProperties(const TRemoteProperties & value);
  188. virtual void __fastcall Saved();
  189. void __fastcall SetQueueTransfersLimit(int value);
  190. void __fastcall SetQueueKeepDoneItems(bool value);
  191. void __fastcall SetQueueKeepDoneItemsFor(int value);
  192. void __fastcall SetLocaleInternal(LCID value, bool Safe);
  193. void __fastcall SetInitialLocale(LCID value);
  194. bool __fastcall GetCanApplyLocaleImmediately();
  195. public:
  196. __fastcall TGUIConfiguration();
  197. virtual __fastcall ~TGUIConfiguration();
  198. virtual void __fastcall Default();
  199. virtual void __fastcall UpdateStaticUsage();
  200. HANDLE __fastcall ChangeResourceModule(HANDLE Instance);
  201. LCID __fastcall InternalLocale();
  202. UnicodeString __fastcall LocaleCopyright();
  203. UnicodeString __fastcall LocaleVersion();
  204. TStoredSessionList * __fastcall SelectPuttySessionsForImport(TStoredSessionList * Sessions, UnicodeString & Error);
  205. bool __fastcall AnyPuttySessionForImport(TStoredSessionList * Sessions);
  206. __property bool ContinueOnError = { read = FContinueOnError, write = FContinueOnError };
  207. __property bool ConfirmCommandSession = { read = FConfirmCommandSession, write = FConfirmCommandSession };
  208. __property int SynchronizeParams = { read = FSynchronizeParams, write = FSynchronizeParams };
  209. __property int SynchronizeOptions = { read = FSynchronizeOptions, write = FSynchronizeOptions };
  210. __property int SynchronizeModeAuto = { read = FSynchronizeModeAuto, write = FSynchronizeModeAuto };
  211. __property int SynchronizeMode = { read = FSynchronizeMode, write = FSynchronizeMode };
  212. __property int MaxWatchDirectories = { read = FMaxWatchDirectories, write = FMaxWatchDirectories };
  213. __property int QueueTransfersLimit = { read = FQueueTransfersLimit, write = SetQueueTransfersLimit };
  214. __property bool QueueKeepDoneItems = { read = FQueueKeepDoneItems, write = SetQueueKeepDoneItems };
  215. __property int QueueKeepDoneItemsFor = { read = FQueueKeepDoneItemsFor, write = SetQueueKeepDoneItemsFor };
  216. __property bool QueueAutoPopup = { read = FQueueAutoPopup, write = FQueueAutoPopup };
  217. __property bool SessionRememberPassword = { read = FSessionRememberPassword, write = FSessionRememberPassword };
  218. __property LCID Locale = { read = GetLocale, write = SetLocale };
  219. __property LCID LocaleSafe = { read = GetLocale, write = SetLocaleSafe };
  220. __property TStrings * Locales = { read = GetLocales };
  221. __property UnicodeString PuttyPath = { read = FPuttyPath, write = FPuttyPath };
  222. __property UnicodeString DefaultPuttyPath = { read = FDefaultPuttyPath };
  223. __property UnicodeString PSftpPath = { read = FPSftpPath, write = FPSftpPath };
  224. __property bool PuttyPassword = { read = FPuttyPassword, write = FPuttyPassword };
  225. __property bool TelnetForFtpInPutty = { read = FTelnetForFtpInPutty, write = FTelnetForFtpInPutty };
  226. __property UnicodeString PuttySession = { read = FPuttySession, write = FPuttySession };
  227. __property TDateTime IgnoreCancelBeforeFinish = { read = FIgnoreCancelBeforeFinish, write = FIgnoreCancelBeforeFinish };
  228. __property TGUICopyParamType DefaultCopyParam = { read = FDefaultCopyParam, write = SetDefaultCopyParam };
  229. __property bool BeepOnFinish = { read = FBeepOnFinish, write = FBeepOnFinish };
  230. __property TDateTime BeepOnFinishAfter = { read = FBeepOnFinishAfter, write = FBeepOnFinishAfter };
  231. __property const TCopyParamList * CopyParamList = { read = GetCopyParamList, write = SetCopyParamList };
  232. __property UnicodeString CopyParamCurrent = { read = FCopyParamCurrent, write = SetCopyParamCurrent };
  233. __property int CopyParamIndex = { read = GetCopyParamIndex, write = SetCopyParamIndex };
  234. __property TGUICopyParamType CurrentCopyParam = { read = GetCurrentCopyParam };
  235. __property TGUICopyParamType CopyParamPreset[UnicodeString Name] = { read = GetCopyParamPreset };
  236. __property bool HasCopyParamPreset[UnicodeString Name] = { read = GetHasCopyParamPreset };
  237. __property TRemoteProperties NewDirectoryProperties = { read = FNewDirectoryProperties, write = SetNewDirectoryProperties };
  238. __property int KeepUpToDateChangeDelay = { read = FKeepUpToDateChangeDelay, write = FKeepUpToDateChangeDelay };
  239. __property UnicodeString ChecksumAlg = { read = FChecksumAlg, write = FChecksumAlg };
  240. __property int SessionReopenAutoIdle = { read = FSessionReopenAutoIdle, write = FSessionReopenAutoIdle };
  241. __property bool CanApplyLocaleImmediately = { read = GetCanApplyLocaleImmediately };
  242. __property LCID AppliedLocale = { read = FAppliedLocale };
  243. };
  244. //---------------------------------------------------------------------------
  245. extern TGUIConfiguration * GUIConfiguration;
  246. //---------------------------------------------------------------------------
  247. #endif