Configuration.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. //---------------------------------------------------------------------------
  2. #ifndef ConfigurationH
  3. #define ConfigurationH
  4. #include <set>
  5. #include "RemoteFiles.h"
  6. #include "FileBuffer.h"
  7. #include "HierarchicalStorage.h"
  8. #include "Usage.h"
  9. //---------------------------------------------------------------------------
  10. #define SET_CONFIG_PROPERTY_EX(PROPERTY, APPLY) \
  11. if (PROPERTY != value) { F ## PROPERTY = value; Changed(); APPLY; }
  12. #define SET_CONFIG_PROPERTY(PROPERTY) \
  13. SET_CONFIG_PROPERTY_EX(PROPERTY, )
  14. //---------------------------------------------------------------------------
  15. extern const wchar_t * AutoSwitchNames;
  16. extern const wchar_t * NotAutoSwitchNames;
  17. enum TAutoSwitch { asOn, asOff, asAuto }; // Has to match PuTTY FORCE_ON, FORCE_OFF, AUTO
  18. //---------------------------------------------------------------------------
  19. class TStoredSessionList;
  20. class TCopyParamType;
  21. //---------------------------------------------------------------------------
  22. class TConfiguration : public TObject
  23. {
  24. private:
  25. bool FDontSave;
  26. bool FForceSave;
  27. bool FChanged;
  28. int FUpdating;
  29. TNotifyEvent FOnChange;
  30. void * FApplicationInfo;
  31. TUsage * FUsage;
  32. bool FLogging;
  33. bool FPermanentLogging;
  34. UnicodeString FLogFileName;
  35. UnicodeString FPermanentLogFileName;
  36. int FLogWindowLines;
  37. bool FLogFileAppend;
  38. bool FLogSensitive;
  39. bool FPermanentLogSensitive;
  40. __int64 FLogMaxSize;
  41. __int64 FPermanentLogMaxSize;
  42. int FLogMaxCount;
  43. int FPermanentLogMaxCount;
  44. int FLogProtocol;
  45. int FPermanentLogProtocol;
  46. int FActualLogProtocol;
  47. bool FLogActions;
  48. bool FPermanentLogActions;
  49. bool FLogActionsRequired;
  50. UnicodeString FActionsLogFileName;
  51. UnicodeString FPermanentActionsLogFileName;
  52. bool FConfirmOverwriting;
  53. bool FConfirmResume;
  54. bool FAutoReadDirectoryAfterOp;
  55. int FSessionReopenAuto;
  56. int FSessionReopenBackground;
  57. int FSessionReopenTimeout;
  58. int FSessionReopenAutoStall;
  59. UnicodeString FCustomIniFileStorageName;
  60. UnicodeString FIniFileStorageName;
  61. UnicodeString FVirtualIniFileStorageName;
  62. std::unique_ptr<TStrings> FOptionsStorage;
  63. int FProgramIniPathWrittable;
  64. int FTunnelLocalPortNumberLow;
  65. int FTunnelLocalPortNumberHigh;
  66. int FCacheDirectoryChangesMaxSize;
  67. bool FShowFtpWelcomeMessage;
  68. UnicodeString FDefaultRandomSeedFile;
  69. UnicodeString FRandomSeedFile;
  70. UnicodeString FPuttyRegistryStorageKey;
  71. UnicodeString FExternalIpAddress;
  72. bool FTryFtpWhenSshFails;
  73. int FParallelDurationThreshold;
  74. bool FScripting;
  75. UnicodeString FMimeTypes;
  76. int FDontReloadMoreThanSessions;
  77. int FScriptProgressFileNameLimit;
  78. bool FDisablePasswordStoring;
  79. bool FForceBanners;
  80. bool FDisableAcceptingHostKeys;
  81. bool FDefaultCollectUsage;
  82. TVSFixedFileInfo *__fastcall GetFixedApplicationInfo();
  83. void * __fastcall GetApplicationInfo();
  84. virtual UnicodeString __fastcall GetVersionStr();
  85. virtual UnicodeString __fastcall GetVersion();
  86. UnicodeString __fastcall GetProductVersion();
  87. UnicodeString __fastcall GetProductName();
  88. UnicodeString __fastcall GetCompanyName();
  89. UnicodeString __fastcall GetFileVersion(TVSFixedFileInfo * Info);
  90. UnicodeString __fastcall GetStoredSessionsSubKey();
  91. UnicodeString __fastcall GetPuttySessionsKey();
  92. void __fastcall SetRandomSeedFile(UnicodeString value);
  93. UnicodeString __fastcall GetRandomSeedFileName();
  94. void __fastcall SetPuttyRegistryStorageKey(UnicodeString value);
  95. UnicodeString __fastcall GetSshHostKeysSubKey();
  96. UnicodeString __fastcall GetRootKeyStr();
  97. UnicodeString __fastcall GetConfigurationSubKey();
  98. TEOLType __fastcall GetLocalEOLType();
  99. void __fastcall SetLogging(bool value);
  100. bool __fastcall GetLogging();
  101. void __fastcall SetLogFileName(UnicodeString value);
  102. UnicodeString __fastcall GetLogFileName();
  103. bool __fastcall GetLogToFile();
  104. void __fastcall SetLogFileAppend(bool value);
  105. void __fastcall SetLogSensitive(bool value);
  106. void __fastcall SetLogMaxSize(__int64 value);
  107. __int64 __fastcall GetLogMaxSize();
  108. void __fastcall SetLogMaxCount(int value);
  109. int __fastcall GetLogMaxCount();
  110. void __fastcall SetLogProtocol(int value);
  111. void __fastcall SetLogActions(bool value);
  112. bool __fastcall GetLogActions();
  113. void __fastcall SetActionsLogFileName(UnicodeString value);
  114. UnicodeString __fastcall GetPermanentActionsLogFileName();
  115. UnicodeString __fastcall GetActionsLogFileName();
  116. UnicodeString __fastcall GetDefaultLogFileName();
  117. UnicodeString __fastcall GetTimeFormat();
  118. UnicodeString __fastcall GetRegistryStorageKey();
  119. UnicodeString __fastcall GetIniFileStorageNameForReadingWriting();
  120. UnicodeString __fastcall GetIniFileStorageNameForReading();
  121. UnicodeString __fastcall GetIniFileStorageName(bool ReadingOnly);
  122. void __fastcall SetIniFileStorageName(UnicodeString value);
  123. void __fastcall SetOptionsStorage(TStrings * value);
  124. TStrings * __fastcall GetOptionsStorage();
  125. UnicodeString __fastcall GetPartialExt() const;
  126. UnicodeString __fastcall GetFileInfoString(const UnicodeString Key);
  127. void __fastcall SetSessionReopenAuto(int value);
  128. void __fastcall SetSessionReopenBackground(int value);
  129. void __fastcall SetSessionReopenTimeout(int value);
  130. void __fastcall SetSessionReopenAutoStall(int value);
  131. void __fastcall SetTunnelLocalPortNumberLow(int value);
  132. void __fastcall SetTunnelLocalPortNumberHigh(int value);
  133. void __fastcall SetCacheDirectoryChangesMaxSize(int value);
  134. void __fastcall SetShowFtpWelcomeMessage(bool value);
  135. int __fastcall GetCompoundVersion();
  136. void __fastcall UpdateActualLogProtocol();
  137. void __fastcall SetExternalIpAddress(UnicodeString value);
  138. void __fastcall SetTryFtpWhenSshFails(bool value);
  139. void __fastcall SetParallelDurationThreshold(int value);
  140. void __fastcall SetMimeTypes(UnicodeString value);
  141. bool __fastcall GetCollectUsage();
  142. void __fastcall SetCollectUsage(bool value);
  143. bool __fastcall GetIsUnofficial();
  144. bool __fastcall GetPersistent();
  145. protected:
  146. TStorage FStorage;
  147. TCriticalSection * FCriticalSection;
  148. virtual TStorage __fastcall GetStorage();
  149. virtual void __fastcall Changed();
  150. virtual void __fastcall SaveData(THierarchicalStorage * Storage, bool All);
  151. virtual void __fastcall LoadData(THierarchicalStorage * Storage);
  152. virtual void __fastcall LoadFrom(THierarchicalStorage * Storage);
  153. virtual void __fastcall CopyData(THierarchicalStorage * Source, THierarchicalStorage * Target);
  154. virtual void __fastcall LoadAdmin(THierarchicalStorage * Storage);
  155. virtual UnicodeString __fastcall GetDefaultKeyFile();
  156. virtual void __fastcall Saved();
  157. void __fastcall CleanupRegistry(UnicodeString CleanupSubKey);
  158. void __fastcall CopyAllStringsInSubKey(
  159. THierarchicalStorage * Source, THierarchicalStorage * Target, const UnicodeString & Name);
  160. bool __fastcall CopySubKey(THierarchicalStorage * Source, THierarchicalStorage * Target, const UnicodeString & Name);
  161. UnicodeString __fastcall BannerHash(const UnicodeString & Banner);
  162. void __fastcall SetBannerData(const UnicodeString & SessionKey, const UnicodeString & BannerHash, unsigned int Params);
  163. void __fastcall GetBannerData(const UnicodeString & SessionKey, UnicodeString & BannerHash, unsigned int & Params);
  164. static UnicodeString __fastcall PropertyToKey(const UnicodeString & Property);
  165. virtual void __fastcall DoSave(bool All, bool Explicit);
  166. UnicodeString __fastcall FormatFingerprintKey(const UnicodeString & SiteKey, const UnicodeString & FingerprintType);
  167. THierarchicalStorage * OpenDirectoryStatisticsCache(bool CanCreate);
  168. UnicodeString __fastcall GetDirectoryStatisticsCacheKey(
  169. const UnicodeString & SessionKey, const UnicodeString & Path, const TCopyParamType & CopyParam);
  170. virtual bool __fastcall GetConfirmOverwriting();
  171. virtual void __fastcall SetConfirmOverwriting(bool value);
  172. bool __fastcall GetConfirmResume();
  173. void __fastcall SetConfirmResume(bool value);
  174. bool __fastcall GetAutoReadDirectoryAfterOp();
  175. void __fastcall SetAutoReadDirectoryAfterOp(bool value);
  176. virtual bool __fastcall GetRememberPassword();
  177. UnicodeString __fastcall GetReleaseType();
  178. UnicodeString __fastcall LoadCustomIniFileStorageName();
  179. void __fastcall SaveCustomIniFileStorageName();
  180. UnicodeString __fastcall GetRegistryStorageOverrideKey();
  181. virtual UnicodeString __fastcall ModuleFileName();
  182. UnicodeString __fastcall GetFileFileInfoString(const UnicodeString Key,
  183. const UnicodeString FileName, bool AllowEmpty = false);
  184. void * __fastcall GetFileApplicationInfo(const UnicodeString FileName);
  185. UnicodeString __fastcall GetFileProductVersion(const UnicodeString FileName);
  186. UnicodeString __fastcall GetFileProductName(const UnicodeString FileName);
  187. UnicodeString __fastcall GetFileCompanyName(const UnicodeString FileName);
  188. __property bool PermanentLogging = { read=GetLogging, write=SetLogging };
  189. __property UnicodeString PermanentLogFileName = { read=GetLogFileName, write=SetLogFileName };
  190. __property bool PermanentLogActions = { read=GetLogActions, write=SetLogActions };
  191. __property UnicodeString PermanentActionsLogFileName = { read=GetPermanentActionsLogFileName, write=SetActionsLogFileName };
  192. __property int PermanentLogProtocol = { read=FPermanentLogProtocol, write=SetLogProtocol };
  193. __property bool PermanentLogSensitive = { read=FPermanentLogSensitive, write=SetLogSensitive };
  194. __property __int64 PermanentLogMaxSize = { read=GetLogMaxSize, write=SetLogMaxSize };
  195. __property int PermanentLogMaxCount = { read=GetLogMaxCount, write=SetLogMaxCount };
  196. public:
  197. __fastcall TConfiguration();
  198. virtual __fastcall ~TConfiguration();
  199. virtual void __fastcall Default();
  200. virtual void __fastcall UpdateStaticUsage();
  201. void __fastcall Load(THierarchicalStorage * Storage);
  202. void __fastcall Save();
  203. void __fastcall SaveExplicit();
  204. void __fastcall MoveStorage(TStorage AStorage, const UnicodeString & ACustomIniFileStorageName);
  205. void __fastcall ScheduleCustomIniFileStorageUse(const UnicodeString & ACustomIniFileStorageName);
  206. void __fastcall SetNulStorage();
  207. void __fastcall SetDefaultStorage();
  208. UnicodeString __fastcall GetAutomaticIniFileStorageName(bool ReadingOnly);
  209. UnicodeString __fastcall GetDefaultIniFileExportPath();
  210. void __fastcall Export(const UnicodeString & FileName);
  211. void __fastcall Import(const UnicodeString & FileName);
  212. void __fastcall CleanupConfiguration();
  213. void __fastcall CleanupIniFile();
  214. void __fastcall CleanupHostKeys();
  215. void __fastcall CleanupRandomSeedFile();
  216. void __fastcall BeginUpdate();
  217. void __fastcall EndUpdate();
  218. void __fastcall DontSave();
  219. void __fastcall LoadDirectoryChangesCache(const UnicodeString SessionKey,
  220. TRemoteDirectoryChangesCache * DirectoryChangesCache);
  221. void __fastcall SaveDirectoryChangesCache(const UnicodeString SessionKey,
  222. TRemoteDirectoryChangesCache * DirectoryChangesCache);
  223. TStrings * __fastcall LoadDirectoryStatisticsCache(
  224. const UnicodeString & SessionKey, const UnicodeString & Path, const TCopyParamType & CopyParam);
  225. void __fastcall SaveDirectoryStatisticsCache(
  226. const UnicodeString & SessionKey, const UnicodeString & Path, const TCopyParamType & CopyParam, TStrings * DataList);
  227. bool __fastcall ShowBanner(const UnicodeString & SessionKey, const UnicodeString & Banner, unsigned int & Params);
  228. void __fastcall NeverShowBanner(const UnicodeString & SessionKey, const UnicodeString & Banner);
  229. void __fastcall SetBannerParams(const UnicodeString & SessionKey, unsigned int Params);
  230. void __fastcall RememberLastFingerprint(const UnicodeString & SiteKey, const UnicodeString & FingerprintType, const UnicodeString & Fingerprint);
  231. UnicodeString __fastcall LastFingerprint(const UnicodeString & SiteKey, const UnicodeString & FingerprintType);
  232. THierarchicalStorage * CreateConfigStorage();
  233. virtual THierarchicalStorage * CreateScpStorage(bool & SessionList);
  234. void __fastcall TemporaryLogging(const UnicodeString ALogFileName);
  235. void __fastcall TemporaryActionsLogging(const UnicodeString ALogFileName);
  236. void __fastcall TemporaryLogProtocol(int ALogProtocol);
  237. void __fastcall TemporaryLogSensitive(bool ALogSensitive);
  238. void __fastcall TemporaryLogMaxSize(__int64 ALogMaxSize);
  239. void __fastcall TemporaryLogMaxCount(int ALogMaxCount);
  240. virtual RawByteString __fastcall EncryptPassword(UnicodeString Password, UnicodeString Key);
  241. virtual UnicodeString __fastcall DecryptPassword(RawByteString Password, UnicodeString Key);
  242. virtual RawByteString __fastcall StronglyRecryptPassword(RawByteString Password, UnicodeString Key);
  243. UnicodeString __fastcall GetFileDescription(const UnicodeString & FileName);
  244. UnicodeString __fastcall GetFileVersion(const UnicodeString & FileName);
  245. UnicodeString __fastcall GetFileMimeType(const UnicodeString & FileName);
  246. TStoredSessionList * __fastcall SelectFilezillaSessionsForImport(
  247. TStoredSessionList * Sessions, UnicodeString & Error);
  248. bool __fastcall AnyFilezillaSessionForImport(TStoredSessionList * Sessions);
  249. TStoredSessionList * __fastcall SelectKnownHostsSessionsForImport(
  250. TStoredSessionList * Sessions, UnicodeString & Error);
  251. TStoredSessionList * __fastcall SelectKnownHostsSessionsForImport(
  252. TStrings * Lines, TStoredSessionList * Sessions, UnicodeString & Error);
  253. __property TVSFixedFileInfo *FixedApplicationInfo = { read=GetFixedApplicationInfo };
  254. __property void * ApplicationInfo = { read=GetApplicationInfo };
  255. __property TUsage * Usage = { read = FUsage };
  256. __property bool CollectUsage = { read = GetCollectUsage, write = SetCollectUsage };
  257. __property UnicodeString StoredSessionsSubKey = {read=GetStoredSessionsSubKey};
  258. __property UnicodeString PuttyRegistryStorageKey = { read=FPuttyRegistryStorageKey, write=SetPuttyRegistryStorageKey };
  259. __property UnicodeString PuttySessionsKey = { read=GetPuttySessionsKey };
  260. __property UnicodeString RandomSeedFile = { read=FRandomSeedFile, write=SetRandomSeedFile };
  261. __property UnicodeString RandomSeedFileName = { read=GetRandomSeedFileName };
  262. __property UnicodeString SshHostKeysSubKey = { read=GetSshHostKeysSubKey };
  263. __property UnicodeString RootKeyStr = { read=GetRootKeyStr };
  264. __property UnicodeString ConfigurationSubKey = { read=GetConfigurationSubKey };
  265. __property TEOLType LocalEOLType = { read = GetLocalEOLType };
  266. __property UnicodeString VersionStr = { read=GetVersionStr };
  267. __property UnicodeString Version = { read=GetVersion };
  268. __property int CompoundVersion = { read=GetCompoundVersion };
  269. __property UnicodeString ProductVersion = { read=GetProductVersion };
  270. __property UnicodeString ProductName = { read=GetProductName };
  271. __property UnicodeString CompanyName = { read=GetCompanyName };
  272. __property bool IsUnofficial = { read = GetIsUnofficial };
  273. __property bool Logging = { read=FLogging, write=SetLogging };
  274. __property UnicodeString LogFileName = { read=FLogFileName, write=SetLogFileName };
  275. __property bool LogToFile = { read=GetLogToFile };
  276. __property bool LogFileAppend = { read=FLogFileAppend, write=SetLogFileAppend };
  277. __property bool LogSensitive = { read=FLogSensitive, write=SetLogSensitive };
  278. __property __int64 LogMaxSize = { read=FLogMaxSize, write=SetLogMaxSize };
  279. __property int LogMaxCount = { read=FLogMaxCount, write=SetLogMaxCount };
  280. __property int LogProtocol = { read=FLogProtocol, write=SetLogProtocol };
  281. __property int ActualLogProtocol = { read=FActualLogProtocol };
  282. __property bool LogActions = { read=FLogActions, write=SetLogActions };
  283. __property bool LogActionsRequired = { read=FLogActionsRequired, write=FLogActionsRequired };
  284. __property UnicodeString ActionsLogFileName = { read=GetActionsLogFileName, write=SetActionsLogFileName };
  285. __property UnicodeString DefaultLogFileName = { read=GetDefaultLogFileName };
  286. __property TNotifyEvent OnChange = { read = FOnChange, write = FOnChange };
  287. __property bool ConfirmOverwriting = { read = GetConfirmOverwriting, write = SetConfirmOverwriting};
  288. __property bool ConfirmResume = { read = GetConfirmResume, write = SetConfirmResume};
  289. __property bool AutoReadDirectoryAfterOp = { read = GetAutoReadDirectoryAfterOp, write = SetAutoReadDirectoryAfterOp};
  290. __property bool RememberPassword = { read = GetRememberPassword };
  291. __property UnicodeString PartialExt = {read=GetPartialExt};
  292. __property int SessionReopenAuto = { read = FSessionReopenAuto, write = SetSessionReopenAuto };
  293. __property int SessionReopenBackground = { read = FSessionReopenBackground, write = SetSessionReopenBackground };
  294. __property int SessionReopenTimeout = { read = FSessionReopenTimeout, write = SetSessionReopenTimeout };
  295. __property int SessionReopenAutoStall = { read = FSessionReopenAutoStall, write = SetSessionReopenAutoStall };
  296. __property int TunnelLocalPortNumberLow = { read = FTunnelLocalPortNumberLow, write = SetTunnelLocalPortNumberLow };
  297. __property int TunnelLocalPortNumberHigh = { read = FTunnelLocalPortNumberHigh, write = SetTunnelLocalPortNumberHigh };
  298. __property int CacheDirectoryChangesMaxSize = { read = FCacheDirectoryChangesMaxSize, write = SetCacheDirectoryChangesMaxSize };
  299. __property bool ShowFtpWelcomeMessage = { read = FShowFtpWelcomeMessage, write = SetShowFtpWelcomeMessage };
  300. __property UnicodeString ExternalIpAddress = { read = FExternalIpAddress, write = SetExternalIpAddress };
  301. __property bool TryFtpWhenSshFails = { read = FTryFtpWhenSshFails, write = SetTryFtpWhenSshFails };
  302. __property int ParallelDurationThreshold = { read = FParallelDurationThreshold, write = SetParallelDurationThreshold };
  303. __property UnicodeString MimeTypes = { read = FMimeTypes, write = SetMimeTypes };
  304. __property int DontReloadMoreThanSessions = { read = FDontReloadMoreThanSessions, write = FDontReloadMoreThanSessions };
  305. __property int ScriptProgressFileNameLimit = { read = FScriptProgressFileNameLimit, write = FScriptProgressFileNameLimit };
  306. __property UnicodeString TimeFormat = { read = GetTimeFormat };
  307. __property TStorage Storage = { read=GetStorage };
  308. __property UnicodeString RegistryStorageKey = { read=GetRegistryStorageKey };
  309. __property UnicodeString CustomIniFileStorageName = { read=FCustomIniFileStorageName };
  310. __property UnicodeString IniFileStorageName = { read=GetIniFileStorageNameForReadingWriting, write=SetIniFileStorageName };
  311. __property UnicodeString IniFileStorageNameForReading = { read=GetIniFileStorageNameForReading };
  312. __property TStrings * OptionsStorage = { read = GetOptionsStorage, write = SetOptionsStorage };
  313. __property bool Persistent = { read = GetPersistent };
  314. __property bool ForceSave = { read = FForceSave, write = FForceSave };
  315. __property bool Scripting = { read = FScripting, write = FScripting };
  316. __property UnicodeString DefaultKeyFile = { read = GetDefaultKeyFile };
  317. __property bool DisablePasswordStoring = { read = FDisablePasswordStoring };
  318. __property bool ForceBanners = { read = FForceBanners };
  319. __property bool DisableAcceptingHostKeys = { read = FDisableAcceptingHostKeys };
  320. };
  321. //---------------------------------------------------------------------------
  322. class TShortCuts
  323. {
  324. public:
  325. void __fastcall Add(TShortCut ShortCut);
  326. bool __fastcall Has(TShortCut ShortCut) const;
  327. private:
  328. std::set<TShortCut> FShortCuts;
  329. };
  330. //---------------------------------------------------------------------------
  331. extern const UnicodeString OriginalPuttyRegistryStorageKey;
  332. extern const UnicodeString KittyRegistryStorageKey;
  333. extern const UnicodeString OriginalPuttyExecutable;
  334. extern const UnicodeString KittyExecutable;
  335. //---------------------------------------------------------------------------
  336. extern const UnicodeString Sha1ChecksumAlg;
  337. extern const UnicodeString Sha224ChecksumAlg;
  338. extern const UnicodeString Sha256ChecksumAlg;
  339. extern const UnicodeString Sha384ChecksumAlg;
  340. extern const UnicodeString Sha512ChecksumAlg;
  341. extern const UnicodeString Md5ChecksumAlg;
  342. extern const UnicodeString Crc32ChecksumAlg;
  343. //---------------------------------------------------------------------------
  344. extern const UnicodeString SshFingerprintType;
  345. extern const UnicodeString TlsFingerprintType;
  346. //---------------------------------------------------------------------------
  347. extern const UnicodeString FtpsCertificateStorageKey;
  348. extern const UnicodeString HttpsCertificateStorageKey;
  349. //---------------------------------------------------------------------------
  350. #endif