GUIConfiguration.h 11 KB

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