//--------------------------------------------------------------------- bool __fastcall TPropertiesDialog::Execute(TRemoteProperties & Properties) { SetFileProperties(Properties); PageControl->ActivePage = CommonSheet; if (FAllowedChanges & cpGroup) ActiveControl = GroupComboBox; else if (FAllowedChanges & cpOwner) ActiveControl = OwnerComboBox; else if (FAllowedChanges & cpMode) ActiveControl = RightsFrame; else ActiveControl = CancelButton; ChecksumAlgEdit->Text = GUIConfiguration->ChecksumAlg; ResetChecksum(); UpdateControls(); bool Result = (ShowModal() == DefaultResult(this)); if (Result) { Properties = GetFileProperties(); } GUIConfiguration->ChecksumAlg = ChecksumAlgEdit->Text; return Result; }
//--------------------------------------------------------------------------- bool __fastcall TCopyDialog::Execute() { // at start assume that copy param is current preset FPreset = GUIConfiguration->CopyParamCurrent; DirectoryEdit->Items = CustomWinConfiguration->History[ FToRemote ? L"RemoteTarget" : L"LocalTarget"]; bool Result = (ShowModal() == DefaultResult(this)); if (Result) { Configuration->BeginUpdate(); try { if (FLAGSET(OutputOptions, cooSaveSettings) && FLAGCLEAR(FOptions, coDisableSaveSettings)) { GUIConfiguration->DefaultCopyParam = Params; } DirectoryEdit->SaveToHistory(); CustomWinConfiguration->History[FToRemote ? L"RemoteTarget" : L"LocalTarget"] = DirectoryEdit->Items; } __finally { Configuration->EndUpdate(); } } return Result; }
//--------------------------------------------------------------------------- bool __fastcall TLocationProfilesDialog::Execute() { bool Result; PageControl->ActivePage = GetProfilesSheet(); FBookmarkSelected = false; Result = (ShowModal() == DefaultResult(this)); if (Terminal) { WinConfiguration->Bookmarks[FSessionKey] = FSessionBookmarkList; WinConfiguration->SharedBookmarks = FSharedBookmarkList; WinConfiguration->UseSharedBookmarks = (PageControl->ActivePage == SharedProfilesSheet); } if (Result) { if (FBookmarkSelected) { Configuration->Usage->Inc(L"OpenedBookmark"); } else { Configuration->Usage->Inc(L"OpenedPath"); } } return Result; }
//--------------------------------------------------------------------------- bool __fastcall TCustomCommandDialog::Execute(TCustomCommandType & Command) { CommandEdit->Items = CustomWinConfiguration->History[L"CustomCommand"]; if (CommandEdit->Items->Count == 0) { for (int i = 0; i < FCustomCommandList->Count; i++) { CommandEdit->Items->Add(FCustomCommandList->Commands[i]->Name); } } DescriptionEdit->Text = Command.Name; FOrigDescription = Command.Name; CommandEdit->Text = Command.Command; SetParams(Command.Params); if (FMode != ccmAdHoc) { SetShortCutCombo(ShortCutCombo, Command.ShortCut); } bool Result = (ShowModal() == DefaultResult(this)); if (Result) { GetCommand(Command); CommandEdit->SaveToHistory(); CustomWinConfiguration->History[L"CustomCommand"] = CommandEdit->Items; } return Result; }
//--------------------------------------------------------------------------- bool __fastcall TRemoteTransferDialog::Execute(void *& Session, UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy) { FCurrentSession = -1; for (int Index = 0; Index < SessionCombo->Items->Count; Index++) { if (SessionCombo->Items->Objects[Index] == Session) { FCurrentSession = Index; SessionCombo->ItemIndex = Index; break; } } assert(FCurrentSession >= 0); DirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteTarget"]; DirectoryEdit->Text = UnixIncludeTrailingBackslash(Target) + FileMask; FDirectCopy = DirectCopy; NotDirectCopyCheck->Checked = !DirectCopy; bool Result = (ShowModal() == DefaultResult(this)); if (Result) { Session = SessionCombo->Items->Objects[SessionCombo->ItemIndex]; CustomWinConfiguration->History[L"RemoteTarget"] = DirectoryEdit->Items; Target = UnixExtractFilePath(DirectoryEdit->Text); FileMask = UnixExtractFileName(DirectoryEdit->Text); DirectCopy = !NotDirectCopyCheck->Checked; } return Result; }
//--------------------------------------------------------------------------- bool __fastcall TCreateDirectoryDialog::Execute(UnicodeString & Directory, TRemoteProperties * Properties, bool & SaveSettings) { DirectoryEdit->Text = Directory; SaveSettingsCheck->Checked = SaveSettings; if (Properties != NULL) { bool SetRights = Properties->Valid.Contains(vpRights); SetRightsCheck->Checked = SetRights; // expect sensible value even if rights are not set valid RightsFrame->Rights = Properties->Rights; } bool Result = (ShowModal() == DefaultResult(this)); if (Result) { Directory = DirectoryEdit->Text; SaveSettings = SaveSettingsCheck->Checked; if (Properties != NULL) { if (SetRightsCheck->Checked) { Properties->Valid = Properties->Valid << vpRights; Properties->Rights = RightsFrame->Rights; } else { Properties->Valid = Properties->Valid >> vpRights; } } } return Result; }
//--------------------------------------------------------------------------- void __fastcall TEditMaskDialog::FormCloseQuery(TObject * /*Sender*/, bool & /*CanClose*/) { if (ModalResult == DefaultResult(this)) { ExitActiveControl(this); } }
//--------------------------------------------------------------------------- void __fastcall TLocationProfilesDialog::ProfilesViewDblClick(TObject * Sender) { TTreeView * ProfilesView = GetProfilesView(Sender); TPoint P = ProfilesView->ScreenToClient(Mouse->CursorPos); TTreeNode * Node = ProfilesView->GetNodeAt(P.x, P.y); if (OKBtn->Enabled && Node && Node->Data && Node->Selected) { ModalResult = DefaultResult(this); } }
//--------------------------------------------------------------------------- bool __fastcall TEditMaskDialog::Execute(TFileMasks & Mask) { LoadFileMasks(Mask); bool Result = (ShowModal() == DefaultResult(this)); if (Result) { SaveFileMasks(Mask); } return Result; }
//--------------------------------------------------------------------------- void __fastcall TSelectMaskDialog::FormCloseQuery(TObject * /*Sender*/, bool & /*CanClose*/) { if (ModalResult == DefaultResult(this)) { if (MaskEdit->Focused()) { MaskEditExit(NULL); } } }
//--------------------------------------------------------------------------- void __fastcall TCustomCommandDialog::FormCloseQuery(TObject * /*Sender*/, bool & /*CanClose*/) { if (ModalResult == DefaultResult(this)) { if ((FMode == ccmAdd) || (FMode == ccmEdit)) { UnicodeString Desc = DescriptionEdit->Text; if (Desc.Pos(L"=") > 0) { DescriptionEdit->SetFocus(); throw Exception(FMTLOAD(CUSTOM_COMMAND_INVALID, (L"="))); } if (((FMode == ccmAdd) || ((FMode == ccmEdit) && (Desc != FOrigDescription))) && (FCustomCommandList->Find(Desc) != 0)) { DescriptionEdit->SetFocus(); throw Exception(FMTLOAD(CUSTOM_COMMAND_DUPLICATE, (Desc))); } } try { bool RemoteCommand = RemoteCommandButton->Checked; TRemoteCustomCommand RemoteCustomCommand; TLocalCustomCommand LocalCustomCommand; TFileCustomCommand * FileCustomCommand = (RemoteCommand ? &RemoteCustomCommand : &LocalCustomCommand); TInteractiveCustomCommand InteractiveCustomCommand(FileCustomCommand); UnicodeString Command = CommandEdit->Text; InteractiveCustomCommand.Validate(Command); Command = InteractiveCustomCommand.Complete(Command, false); FileCustomCommand->Validate(Command); } catch(...) { CommandEdit->SetFocus(); throw; } if (FOnValidate) { TCustomCommandType Command; GetCommand(Command); FOnValidate(Command); } } }
//--------------------------------------------------------------------------- bool __fastcall TSelectMaskDialog::Execute() { MaskEdit->Items = WinConfiguration->History[L"Mask"]; ActiveControl = MaskEdit; bool Result = (ShowModal() == DefaultResult(this)); if (Result) { MaskEdit->SaveToHistory(); WinConfiguration->History[L"Mask"] = MaskEdit->Items; } return Result; } /* TSelectMaskDialog::Execute */
//--------------------------------------------------------------------------- void __fastcall TEditMaskDialog::FormKeyDown( TObject * /*Sender*/, WORD & Key, TShiftState Shift) { if ((Key == VK_ESCAPE) && Shift.Empty()) { ModalResult = mrCancel; Key = 0; } else if ((Key == VK_RETURN) && Shift.Contains(ssCtrl)) { ModalResult = DefaultResult(this); Key = 0; } }
//--------------------------------------------------------------------------- bool __fastcall TFullSynchronizeDialog::Execute() { // at start assume that copy param is current preset FPreset = GUIConfiguration->CopyParamCurrent; LocalDirectoryEdit->Items = CustomWinConfiguration->History[L"LocalDirectory"]; RemoteDirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteDirectory"]; bool Result = (ShowModal() == DefaultResult(this)); if (Result) { LocalDirectoryEdit->SaveToHistory(); CustomWinConfiguration->History[L"LocalDirectory"] = LocalDirectoryEdit->Items; RemoteDirectoryEdit->SaveToHistory(); CustomWinConfiguration->History[L"RemoteDirectory"] = RemoteDirectoryEdit->Items; } return Result; }
//--------------------------------------------------------------------------- void __fastcall TFullSynchronizeDialog::FormCloseQuery(TObject * /*Sender*/, bool & CanClose) { if ((ModalResult == DefaultResult(this)) && SaveSettings && (FOrigMode != Mode) && !FSaveMode) { switch (MessageDialog(LoadStr(SAVE_SYNCHRONIZE_MODE2), qtConfirmation, qaYes | qaNo | qaCancel, HELP_SYNCHRONIZE_SAVE_MODE)) { case qaYes: FSaveMode = true; break; case qaCancel: CanClose = false; break; } } }
//--------------------------------------------------------------------------- void __fastcall TCopyDialog::FormCloseQuery(TObject * /*Sender*/, bool &CanClose) { if (ModalResult == DefaultResult(this)) { if (!RemotePaths() && ((FOptions & coTemp) == 0)) { UnicodeString Dir = Directory; UnicodeString Drive = ExtractFileDrive(Dir); if (!DirectoryExists(Dir)) { if (MessageDialog(MainInstructions(FMTLOAD(CREATE_LOCAL_DIRECTORY, (Dir))), qtConfirmation, qaOK | qaCancel, HELP_NONE) != qaCancel) { if (!ForceDirectories(Dir)) { SimpleErrorDialog(FMTLOAD(CREATE_LOCAL_DIR_ERROR, (Dir))); CanClose = false; } } else { CanClose = False; } } if (!CanClose) { DirectoryEdit->SelectAll(); DirectoryEdit->SetFocus(); } }; if (CanClose) { ExitActiveControl(this); } } }
//--------------------------------------------------------------------- bool __fastcall TSynchronizeChecklistDialog::Execute(TSynchronizeChecklist * Checklist) { FChecklist = Checklist; bool Result = (ShowModal() == DefaultResult(this)); if (Result) { for (int Index = 0; Index < ListView->Items->Count; Index++) { TListItem * Item = ListView->Items->Item[Index]; // const violation ! TSynchronizeChecklist::TItem * ChecklistItem = static_cast<TSynchronizeChecklist::TItem *>(Item->Data); ChecklistItem->Checked = Item->Checked; } TSynchronizeChecklistConfiguration FormConfiguration = CustomWinConfiguration->SynchronizeChecklist; FormConfiguration.ListParams = ListView->ColProperties->ParamsStr; UnicodeString WindowParams = FormConfiguration.WindowParams; // if there is no main window, keep previous "custom pos" indication, bool CustomPos = (StrToIntDef(::CutToChar(WindowParams, L';', true), 0) != 0); if (Application->MainForm != NULL) { CustomPos = (Application->MainForm->BoundsRect != BoundsRect); } FormConfiguration.WindowParams = FORMAT(L"%d;%s", ((CustomPos ? 1 : 0), StoreForm(this))); CustomWinConfiguration->SynchronizeChecklist = FormConfiguration; } return Result; }
//--------------------------------------------------------------------------- void __fastcall TRemoteTransferDialog::FormCloseQuery(TObject * /*Sender*/, bool & /*CanClose*/) { if (ModalResult == DefaultResult(this)) { if ((SessionCombo->ItemIndex == FCurrentSession) && (FAllowDirectCopy == drcConfirmCommandSession) && !NotDirectCopyCheck->Checked && GUIConfiguration->ConfirmCommandSession) { TMessageParams Params(mpNeverAskAgainCheck); unsigned int Answer = MessageDialog(LoadStr(REMOTE_COPY_COMMAND_SESSION2), qtConfirmation, qaOK | qaCancel, HelpKeyword, &Params); if (Answer == qaNeverAskAgain) { GUIConfiguration->ConfirmCommandSession = false; } else if (Answer != qaOK) { Abort(); } } } }
//--------------------------------------------------------------------------- bool __fastcall TAuthenticateForm::Execute(UnicodeString Status, TPanel * Panel, TWinControl * FocusControl, TButton * DefaultButton, TButton * CancelButton, bool FixHeight, bool Zoom, bool ForceLog) { TModalResult DefaultButtonResult; TAlign Align = Panel->Align; try { assert(FStatus.IsEmpty()); FStatus = Status; DefaultButton->Default = true; CancelButton->Cancel = true; DefaultButtonResult = DefaultResult(this); if (Zoom) { Panel->Align = alClient; } if (ForceLog || Visible) { if (ClientHeight < Panel->Height) { ClientHeight = Panel->Height; } // Panel being hidden gets not realigned automatically, even if it // has Align property set Panel->Top = ClientHeight - Panel->Height; Panel->Show(); TCursor PrevCursor = Screen->Cursor; try { if (Zoom) { LogView->Hide(); } else { if (LogView->Items->Count > 0) { TListItem * Item = LogView->ItemFocused; if (Item == NULL) { Item = LogView->Items->Item[LogView->Items->Count - 1]; } Item->MakeVisible(false); } } Screen->Cursor = crDefault; if (!Visible) { assert(ForceLog); ShowAsModal(); } ActiveControl = FocusControl; ModalResult = mrNone; AdjustControls(); do { Application->HandleMessage(); } while (!Application->Terminated && (ModalResult == mrNone)); } __finally { Panel->Hide(); Screen->Cursor = PrevCursor; if (Zoom) { LogView->Show(); } Repaint(); } } else { int PrevHeight = ClientHeight; int PrevMinHeight = Constraints->MinHeight; int PrevMaxHeight = Constraints->MaxHeight; try { Constraints->MinHeight = 0; ClientHeight = Panel->Height; if (FixHeight) { Constraints->MinHeight = Height; Constraints->MaxHeight = Height; } LogView->Hide(); Panel->Show(); FFocusControl = FocusControl; ShowModal(); } __finally { FFocusControl = NULL; ClientHeight = PrevHeight; Constraints->MinHeight = PrevMinHeight; Constraints->MaxHeight = PrevMaxHeight; Panel->Hide(); LogView->Show(); } } }
//--------------------------------------------------------------------------- bool __fastcall InputDialog(const UnicodeString ACaption, const UnicodeString APrompt, UnicodeString & Value, UnicodeString HelpKeyword, TStrings * History, bool PathInput, TInputDialogInitialize OnInitialize) { bool Result = False; TInputDialogToken Token; TForm * Form = new TForm(GetFormOwner(), 0); // bypass the VCL streaming (for Salamander) try { // salam needs to override this in UseSystemSettings Form->Position = poOwnerFormCenter; SetCorrectFormParent(Form); UseSystemSettingsPre(Form); // this is what TCustomForm.Loaded does // Note that this is not needed as due to use of an alternative constructor above // we are already set to default font // See TMessageForm::Create for contrary Form->Font->Assign(Application->DefaultFont); Form->ParentFont = true; Token.OnInitialize = OnInitialize; Token.PathInput = PathInput; TNotifyEvent OnShow; ((TMethod *)&OnShow)->Data = &Token; ((TMethod *)&OnShow)->Code = InputDialogShow; Form->OnShow = OnShow; Form->Canvas->Font = Form->Font; Form->BorderStyle = bsDialog; Form->Caption = ACaption; Form->ClientWidth = ScaleByTextHeightRunTime(Form, 275); Form->ClientHeight = ScaleByTextHeightRunTime(Form, 102); if (!HelpKeyword.IsEmpty()) { Form->HelpKeyword = HelpKeyword; Form->BorderIcons = TBorderIcons(Form->BorderIcons) << biHelp; } TLabel * Prompt = new TLabel(Form); Prompt->Parent = Form; Prompt->AutoSize = True; Prompt->Left = ScaleByTextHeightRunTime(Form, 10); Prompt->Top = ScaleByTextHeightRunTime(Form, 13); Prompt->Caption = APrompt; TEdit * Edit; THistoryComboBox * HistoryCombo; if (History == NULL) { Edit = new TEdit(Form); Edit->Parent = Form; Edit->Text = Value; Edit->SelectAll(); Edit->MaxLength = 255; Token.Data.Edit = Edit; Token.EditControl = Edit; } else { HistoryCombo = new THistoryComboBox(Form); HistoryCombo->Parent = Form; HistoryCombo->Text = Value; HistoryCombo->SelectAll(); HistoryCombo->Items = History; HistoryCombo->MaxLength = 255; HistoryCombo->AutoComplete = false; Token.EditControl = HistoryCombo; } Token.EditControl->Left = Prompt->Left; Token.EditControl->Top = ScaleByTextHeightRunTime(Form, 30); Token.EditControl->Width = ScaleByTextHeightRunTime(Form, 255); Prompt->FocusControl = Token.EditControl; int ButtonTop = ScaleByTextHeightRunTime(Form, 66); int ButtonSpace = ScaleByTextHeightRunTime(Form, 6); TButton * Button; Button = new TButton(Form); Button->Parent = Form; Button->Caption = Vcl_Consts_SMsgDlgOK; Button->ModalResult = mrOk; Button->Default = True; int ButtonHeight = ScaleByTextHeightRunTime(Button, Button->Height); int ButtonWidth = ScaleByTextHeightRunTime(Button, Button->Width); int ButtonsStart; if (HelpKeyword.IsEmpty()) { ButtonsStart = (Form->ClientWidth / 2) - ButtonWidth - (ButtonSpace / 2); } else { ButtonsStart = (Form->ClientWidth / 2) - (3 * ButtonWidth / 2) - ButtonSpace; } Button->SetBounds(ButtonsStart, ButtonTop, ButtonWidth, ButtonHeight); Button = new TButton(Form); Button->Parent = Form; Button->Caption = Vcl_Consts_SMsgDlgCancel; Button->ModalResult = mrCancel; Button->Cancel = True; Button->SetBounds(ButtonsStart + ButtonWidth + ButtonSpace, ButtonTop, ButtonWidth, ButtonHeight); if (!HelpKeyword.IsEmpty()) { Button = new TButton(Form); Button->Parent = Form; Button->Caption = Vcl_Consts_SMsgDlgHelp; Button->ModalResult = mrNone; Button->SetBounds(ButtonsStart + 2 * (ButtonWidth + ButtonSpace), ButtonTop, ButtonWidth, ButtonHeight); TNotifyEvent OnClick; ((TMethod*)&OnClick)->Code = InputDialogHelp; Button->OnClick = OnClick; } UseSystemSettingsPost(Form); if (Form->ShowModal() == DefaultResult(Form)) { if (History != NULL) { HistoryCombo->SaveToHistory(); History->Assign(HistoryCombo->Items); Value = HistoryCombo->Text; } else { Value = Edit->Text; } Result = true; } } __finally { delete Form; } return Result; }
//--------------------------------------------------------------------- Boolean __fastcall DoCleanupDialog(TStoredSessionList *SessionList, TConfiguration *Configuration) { Boolean Result; TCleanupDialog *CleanupDialog; try { CleanupDialog = new TCleanupDialog(Application); CleanupDialog->SessionList = SessionList; CleanupDialog->Configuration = Configuration; Result = (CleanupDialog->ShowModal() == DefaultResult(CleanupDialog)); if (Result) { Configuration->Usage->Inc(L"Cleanups"); for (int i = wdConfiguration; i <= wdTemporaryFolders; i++) { if (CleanupDialog->CleanupData[(TWinSCPData)i]) { try { switch (i) { case wdConfiguration: Configuration->CleanupConfiguration(); break; case wdStoredSessions: SessionList->Cleanup(); break; case wdHostKeys: Configuration->CleanupHostKeys(); break; case wdConfigurationIniFile: Configuration->CleanupIniFile(); break; case wdRandomSeedFile: Configuration->CleanupRandomSeedFile(); break; case wdTemporaryFolders: WinConfiguration->CleanupTemporaryFolders(); break; } } catch(Exception & E) { ShowExtendedException(&E); } } } } } __finally { delete CleanupDialog; } return Result; }