OperationStatus.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "OperationStatus.h"
  5. #include <Common.h>
  6. #include <TextsWin.h>
  7. #include <VCLCommon.h>
  8. //---------------------------------------------------------------------------
  9. const int ConnectionStatusStrings[] =
  10. { STATUS_CLOSED, STATUS_INITWINSOCK, STATUS_LOOKUPHOST, STATUS_CONNECT,
  11. STATUS_AUTHENTICATE, STATUS_AUTHENTICATED, STATUS_STARTUP,
  12. STATUS_OPEN_DIRECTORY, STATUS_READY };
  13. #define ConnectionStatusStringsCount (sizeof(ConnectionStatusStrings) / sizeof(int))
  14. //---------------------------------------------------------------------------
  15. #pragma package(smart_init)
  16. #pragma resource "*.dfm"
  17. //---------------------------------------------------------------------------
  18. __fastcall TOperationStatusForm::TOperationStatusForm(TComponent* Owner)
  19. : TForm(Owner)
  20. {
  21. FSecureShell = NULL;
  22. UseSystemSettings(this);
  23. FShowAsModalStorage = NULL;
  24. }
  25. //---------------------------------------------------------------------------
  26. __fastcall TOperationStatusForm::~TOperationStatusForm()
  27. {
  28. SecureShell = NULL;
  29. ReleaseAsModal(this, FShowAsModalStorage);
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TOperationStatusForm::SecureShellUpdateStatus(TObject * /*Sender*/)
  33. {
  34. assert(FSecureShell && (FSecureShell->Status >= 0) &&
  35. (FSecureShell->Status < ConnectionStatusStringsCount) && Application);
  36. Status = LoadStr((int)ConnectionStatusStrings[FSecureShell->Status]);
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TOperationStatusForm::SetSecureShell(TSecureShell * value)
  40. {
  41. if (SecureShell != value)
  42. {
  43. if (SecureShell)
  44. {
  45. if (SecureShell->OnUpdateStatus == SecureShellUpdateStatus)
  46. {
  47. SecureShell->OnUpdateStatus = FPrevOnUpdateStatus;
  48. }
  49. }
  50. FSecureShell = value;
  51. if (SecureShell)
  52. {
  53. FPrevOnUpdateStatus = SecureShell->OnUpdateStatus;
  54. SecureShell->OnUpdateStatus = SecureShellUpdateStatus;
  55. SecureShellUpdateStatus(SecureShell);
  56. }
  57. }
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TOperationStatusForm::SetStatus(const AnsiString value)
  61. {
  62. if (StatusLabel->Caption != value)
  63. {
  64. StatusLabel->Caption = value;
  65. Application->ProcessMessages();
  66. }
  67. }
  68. //---------------------------------------------------------------------------
  69. AnsiString __fastcall TOperationStatusForm::GetStatus()
  70. {
  71. return StatusLabel->Caption;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TOperationStatusForm::ShowAsModal()
  75. {
  76. ::ShowAsModal(this, FShowAsModalStorage);
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TOperationStatusForm::HideAsModal()
  80. {
  81. ::HideAsModal(this, FShowAsModalStorage);
  82. }