CoreMain.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "CoreMain.h"
  5. #include "Common.h"
  6. #include "Interface.h"
  7. #include "Configuration.h"
  8. #include "PuttyIntf.h"
  9. #ifndef NO_FILEZILLA
  10. #include "FileZillaIntf.h"
  11. #endif
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. //---------------------------------------------------------------------------
  15. TConfiguration * Configuration = NULL;
  16. TStoredSessionList * StoredSessions = NULL;
  17. //---------------------------------------------------------------------------
  18. TQueryParams::TQueryParams(unsigned int AParams, AnsiString AHelpKeyword)
  19. {
  20. Params = AParams;
  21. Aliases = NULL;
  22. AliasesCount = 0;
  23. Timer = 0;
  24. TimerEvent = NULL;
  25. TimerMessage = "";
  26. TimerAnswers = 0;
  27. Timeout = 0;
  28. TimeoutAnswer = 0;
  29. HelpKeyword = AHelpKeyword;
  30. }
  31. //---------------------------------------------------------------------------
  32. void CoreInitialize()
  33. {
  34. // configuration needs to be created before putty is initialized ...
  35. Configuration = CreateConfiguration();
  36. PuttyInitialize();
  37. #ifndef NO_FILEZILLA
  38. TFileZillaIntf::Initialize();
  39. #endif
  40. // ... but some pieces of configuration can be initialized only afterwards
  41. Configuration->Initialize();
  42. Randomize();
  43. try
  44. {
  45. Configuration->Load();
  46. }
  47. catch (Exception & E)
  48. {
  49. ShowExtendedException(&E);
  50. }
  51. StoredSessions = new TStoredSessionList();
  52. try
  53. {
  54. StoredSessions->Load();
  55. }
  56. catch (Exception & E)
  57. {
  58. ShowExtendedException(&E);
  59. }
  60. }
  61. //---------------------------------------------------------------------------
  62. void CoreFinalize()
  63. {
  64. try
  65. {
  66. Configuration->Save();
  67. }
  68. catch(Exception & E)
  69. {
  70. ShowExtendedException(&E);
  71. }
  72. delete StoredSessions;
  73. StoredSessions = NULL;
  74. delete Configuration;
  75. Configuration = NULL;
  76. #ifndef NO_FILEZILLA
  77. TFileZillaIntf::Finalize();
  78. #endif
  79. PuttyFinalize();
  80. }
  81. //---------------------------------------------------------------------------
  82. void CoreSetResourceModule(void * ResourceHandle)
  83. {
  84. #ifndef NO_FILEZILLA
  85. TFileZillaIntf::SetResourceModule(ResourceHandle);
  86. #else
  87. USEDPARAM(ResourceHandle);
  88. #endif
  89. }
  90. //---------------------------------------------------------------------------