//--------------------------------------------------------------------------- void __fastcall TGUIConfiguration::DefaultLocalized() { if (FCopyParamListDefaults) { FCopyParamList->Clear(); // guard against "empty resource string" from obsolete traslations // (DefaultLocalized is called for the first time before detection of // obsolete translations) if (!LoadStr(COPY_PARAM_PRESET_ASCII).IsEmpty()) { TCopyParamType * CopyParam; CopyParam = new TCopyParamType(FDefaultCopyParam); CopyParam->TransferMode = tmAscii; FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_ASCII), CopyParam, NULL); CopyParam = new TCopyParamType(FDefaultCopyParam); CopyParam->TransferMode = tmBinary; FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_BINARY), CopyParam, NULL); CopyParam = new TCopyParamType(FDefaultCopyParam); CopyParam->NewerOnly = true; FCopyParamList->Add(LoadStr(COPY_PARAM_NEWER_ONLY), CopyParam, NULL); } FCopyParamList->Reset(); } }
void CopySpeedLimits(TStrings * Source, TStrings * Dest) { std::unique_ptr<TStringList> Temp(new TStringList()); bool Unlimited = false; for (intptr_t Index = 0; Index < Source->GetCount(); ++Index) { UnicodeString Text = Source->GetString(Index); uintptr_t Speed; bool Valid = TryGetSpeedLimit(Text, Speed); if ((!Valid || (Speed == 0)) && !Unlimited) { Temp->Add(LoadStr(SPEED_UNLIMITED)); Unlimited = true; } else if (Valid && (Speed > 0)) { Temp->Add(Text); } } if (!Unlimited) { Temp->Insert(0, LoadStr(SPEED_UNLIMITED)); } Dest->Assign(Temp.get()); }
void __fastcall TIBEAEventsEditor::FormCreate(TObject *Sender) { for(int i=1; i < MaxEvents; i++ ) cEvents->Cells[0][i-1] = System::String(i); RequestedEvents->Caption = LoadStr(57810); bOK->Caption = LoadStr(57811); bCancel->Caption = LoadStr(57812); }
//--------------------------------------------------------------------------- __fastcall TEditMaskDialog::TEditMaskDialog(TComponent* Owner) : TForm(Owner) { UseSystemSettings(this); HintLabel(MaskHintText, FORMAT(L"%s\n \n%s\n \n%s\n \n%s", (LoadStr(MASK_HINT2), LoadStr(FILE_MASK_EX_HINT), LoadStr(PATH_MASK_HINT2), LoadStr(MASK_HELP)))); ReadOnlyControl(MaskMemo); }
void WriteToLog(String S) { HANDLE LogFile; String LogPath; String LogFileName; DWORD dwSize; AnsiString SS; TDateTime DateTime; LPDWORD NumberOfBytesWritten = new DWORD; try { // except DateTime = Now(); LogPath = ExtractFilePath(Application->ExeName) + LoadStr(IDS_LOG_PATH); if (!DirectoryExists(LogPath)) CreateDir(LogPath); LogFileName = IncludeTrailingPathDelimiter(LogPath) + ChangeFileExt(ExtractFileName(Application->ExeName), LoadStr(IDS_LOG_EXT)); LogFile = CreateFile(LogFileName.w_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); dwSize = 0; if (LogFile != INVALID_HANDLE_VALUE) { dwSize = GetFileSize(LogFile, NULL); CloseHandle(LogFile); } if (dwSize > MaxLogSize) { String NewFileName = IncludeTrailingPathDelimiter(LogPath) + OnlyFileName(Application->ExeName) + SPACE + FormatDateTime (LoadStr(IDS_DATETIME_FORMAT_FILENAME), DateTime) + LoadStr(IDS_LOG_EXT); MoveFile(LogFileName.w_str(), NewFileName.w_str()); } LogFile = CreateFile(LogFileName.w_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_COMPRESSED, 0); if (LogFile != INVALID_HANDLE_VALUE) { SS = AnsiString(FormatDateTime(LoadStr(IDS_DATETIME_FORMAT_LOG), DateTime) + "; " + AnsiReplaceStr(S, sLineBreak, SPACE) + sLineBreak); if (SetFilePointer(LogFile, 0, NULL, FILE_END) != INVALID_SET_FILE_POINTER) WriteFile(LogFile, SS.c_str(), SS.Length(), NumberOfBytesWritten, NULL); CloseHandle(LogFile); } } catch (...) { } }
//--------------------------------------------------------------------------- __fastcall TSelectMaskDialog::TSelectMaskDialog(TComponent* Owner) : TForm(Owner) { DefaultFileFilter(FFileFilter); SetFileFilter(FFileFilter); UseSystemSettings(this); HintLabel(HintText, FORMAT(L"%s\n \n%s\n \n%s\n \n%s", (LoadStr(MASK_HINT2), LoadStr(FILE_MASK_EX_HINT), LoadStr(COMBINING_MASKS_HINT), LoadStr(MASK_HELP)))); }
//--------------------------------------------------------------------- __fastcall TBookmarkFolderDialog::TBookmarkFolderDialog(TStrings * Folders) : TCustomDialog(HELP_LOCATION_PROFILE_MOVE) { Caption = LoadStr(MOVE_BOOKMARK_CAPTION); NameCombo = new TComboBox(this); NameCombo->AutoComplete = false; AddComboBox(NameCombo, CreateLabel(LoadStr(MOVE_BOOKMARK_PROMPT))); NameCombo->Items = Folders; }
UnicodeString TConfiguration::GetVersionStr() const { UnicodeString Result; TGuard Guard(FCriticalSection); try { TVSFixedFileInfo * Info = GetFixedApplicationInfo(); /*return FMTLOAD(VERSION, HIWORD(Info->dwFileVersionMS), LOWORD(Info->dwFileVersionMS), HIWORD(Info->dwFileVersionLS), LOWORD(Info->dwFileVersionLS));*/ UnicodeString BuildStr; if (!GetIsUnofficial()) { BuildStr = LoadStr(VERSION_BUILD); } else { #ifdef _DEBUG BuildStr = LoadStr(VERSION_DEBUG_BUILD); #else BuildStr = LoadStr(VERSION_DEV_BUILD); #endif } int Build = LOWORD(Info->dwFileVersionLS); if (Build > 0) { BuildStr += L" " + ::IntToStr(Build); } // #ifndef BUILD_OFFICIAL // UnicodeString BuildDate = __DATE__; // UnicodeString MonthStr = CutToChar(BuildDate, L' ', true); // int Month = ParseShortEngMonthName(MonthStr); // int Day = StrToInt64(CutToChar(BuildDate, L' ', true)); // int Year = StrToInt64(Trim(BuildDate)); // UnicodeString DateStr = FORMAT("%d-%2.2d-%2.2d", Year, Month, Day); // AddToList(BuildStr, DateStr, L" "); // #endif Result = FMTLOAD(VERSION2, GetVersion().c_str(), Build); // #ifndef BUILD_OFFICIAL // Result += L" " + LoadStr(VERSION_DONT_DISTRIBUTE); // #endif } catch (Exception & E) { throw ExtException(&E, "Can't get application version"); } return Result; }
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::Feed(TFeedFileSystemData AddItem) { AddItem(ServerView, FSINFO_REMOTE_SYSTEM, FFileSystemInfo.RemoteSystem); AddItem(ServerView, FSINFO_FS_PROTOCOL, FFileSystemInfo.ProtocolName); AddItem(ServerView, FSINFO_CRYPTOGRAPHIC_PROTOCOL, FSessionInfo.SecurityProtocolName); AddItem(ServerView, FSINFO_SSH_IMPLEMENTATION, FSessionInfo.SshImplementation); UnicodeString Str = FSessionInfo.CSCipher; if (FSessionInfo.CSCipher != FSessionInfo.SCCipher) { Str += FORMAT(L"/%s", (FSessionInfo.SCCipher)); } AddItem(ServerView, FSINFO_CIPHER, Str); Str = DefaultStr(FSessionInfo.CSCompression, LoadStr(NO_STR)); if (FSessionInfo.CSCompression != FSessionInfo.SCCompression) { Str += FORMAT(L"/%s", (DefaultStr(FSessionInfo.SCCompression, LoadStr(NO_STR)))); } AddItem(ServerView, FSINFO_COMPRESSION, Str); AddItem(HostKeyFingerprintEdit, 0, FSessionInfo.HostKeyFingerprint); AddItem(CertificateFingerprintEdit, 0, FSessionInfo.CertificateFingerprint); AddItem(ProtocolView, FSINFO_MODE_CHANGING, CapabilityStr(fcModeChanging)); AddItem(ProtocolView, FSINFO_OWNER_GROUP_CHANGING, CapabilityStr(fcGroupChanging)); UnicodeString AnyCommand; if (!FFileSystemInfo.IsCapable[fcShellAnyCommand] && FFileSystemInfo.IsCapable[fcAnyCommand]) { AnyCommand = LoadStr(FSINFO_PROTOCOL_ANY_COMMAND); } else { AnyCommand = CapabilityStr(fcAnyCommand); } AddItem(ProtocolView, FSINFO_ANY_COMMAND, AnyCommand); AddItem(ProtocolView, FSINFO_SYMBOLIC_HARD_LINK, CapabilityStr(fcSymbolicLink, fcHardLink)); AddItem(ProtocolView, FSINFO_USER_GROUP_LISTING, CapabilityStr(fcUserGroupListing)); AddItem(ProtocolView, FSINFO_REMOTE_COPY, CapabilityStr(fcRemoteCopy)); AddItem(ProtocolView, FSINFO_CHECKING_SPACE_AVAILABLE, CapabilityStr(fcCheckingSpaceAvailable)); AddItem(ProtocolView, FSINFO_CALCULATING_CHECKSUM, CapabilityStr(fcCalculatingChecksum)); AddItem(ProtocolView, FSINFO_NATIVE_TEXT_MODE, CapabilityStr(fcNativeTextMode)); AddItem(InfoMemo, 0, FFileSystemInfo.AdditionalInfo); AddItem(SpaceAvailableView, FSINFO_BYTES_ON_DEVICE, SpaceStr(FSpaceAvailable.BytesOnDevice)); AddItem(SpaceAvailableView, FSINFO_UNUSED_BYTES_ON_DEVICE, SpaceStr(FSpaceAvailable.UnusedBytesOnDevice)); AddItem(SpaceAvailableView, FSINFO_BYTES_AVAILABLE_TO_USER, SpaceStr(FSpaceAvailable.BytesAvailableToUser)); AddItem(SpaceAvailableView, FSINFO_UNUSED_BYTES_AVAILABLE_TO_USER, SpaceStr(FSpaceAvailable.UnusedBytesAvailableToUser)); AddItem(SpaceAvailableView, FSINFO_BYTES_PER_ALLOCATION_UNIT, SpaceStr(FSpaceAvailable.BytesPerAllocationUnit)); }
//--------------------------------------------------------------------------- void __fastcall TFileFindDialog::UpdateControls() { bool Finding = IsFinding(); Caption = LoadStr(Finding ? FIND_FILE_FINDING : FIND_FILE_TITLE); UnicodeString StartStopCaption; if (Finding) { EnableControl(StartStopButton, true); StartStopCaption = LoadStr(FIND_FILE_STOP); } else { EnableControl(StartStopButton, !RemoteDirectoryEdit->Text.IsEmpty()); StartStopCaption = LoadStr(FIND_FILE_START); } StartStopButton->Caption = StartStopCaption; CancelButton->Visible = !Finding; EnableControl(FilterGroup, !Finding); MinimizeButton->Visible = Finding; EnableControl(FocusButton, (FileView->ItemFocused != NULL)); switch (FState) { case ffInit: StatusBar->SimpleText = L""; case ffFinding: case ffAborting: if (!FFindingInDirectory.IsEmpty()) { StatusBar->SimpleText = FMTLOAD(FIND_FILE_IN_DIRECTORY, (FFindingInDirectory)); } else { StatusBar->SimpleText = L""; } break; case ffAborted: StatusBar->SimpleText = LoadStr(FIND_FILE_ABORTED); break; case ffDone: StatusBar->SimpleText = LoadStr(FIND_FILE_DONE); break; default: assert(false); break; } }
static int isModified(void) { char cfg[128]; char tmpstring[128]; char wifiippass[128]; //int idx=0; int changeflag = 0; memset(cfg, 0x00, sizeof(cfg)); memset(tmpstring, 0, sizeof(tmpstring)); LoadStr("SSID", cfg); GetWindowText(WifiWnd[0], tmpstring, sizeof(tmpstring)); if(strncmp(cfg, tmpstring, sizeof(tmpstring))!=0) { changeflag = 1; } memset(tmpstring, 0, sizeof(tmpstring)); if(SendMessage(WifiWnd[2], CB_GETCURSEL, 0, 0)!=gOptions.wifidhcpfunon) { changeflag = 1; } if(get_new_ip() ==0) { return 0; } if(strncmp(oldip[0], newip[0], sizeof(newip[0]))!=0){ changeflag = 1; } if(strncmp(oldip[1], newip[1], sizeof(newip[1]))!=0) { changeflag = 1; } if(strncmp(oldip[2], newip[2], sizeof(newip[2]))!=0) { changeflag = 1; } memset(tmpstring, 0, sizeof(tmpstring)); memset(wifiippass, 0, sizeof(wifiippass)); LoadStr("wifipasswd", wifiippass); GetWindowText(WifiWnd[1], tmpstring, sizeof(tmpstring)); if(strncmp(wifiippass, tmpstring, strlen(tmpstring)) != 0) { changeflag = 1; } return changeflag; }
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::ClipboardAddItem(TControl * Control, int Label, UnicodeString Value) { if (Control->Enabled && !Value.IsEmpty()) { if (FLastFeededControl != Control) { if (FLastFeededControl != NULL) { FClipboard += UnicodeString::StringOfChar(L'-', 60) + L"\r\n"; } FLastFeededControl = Control; } if (dynamic_cast<TListView *>(Control) == NULL) { TGroupBox * Group = dynamic_cast<TGroupBox *>(Control->Parent); assert(Group != NULL); if ((Value.Length() >= 2) && (Value.SubString(Value.Length() - 1, 2) == L"\r\n")) { Value.SetLength(Value.Length() - 2); } FClipboard += FORMAT(L"%s\r\n%s\r\n", (Group->Caption, Value)); } else { assert(dynamic_cast<TListView *>(Control) != NULL); FClipboard += FORMAT(L"%s = %s\r\n", (LoadStr(Label), Value)); } } }
//--------------------------------------------------------------------------- void __fastcall TEditorForm::GoToLine() { UnicodeString Str; if (InputDialog(LoadStr(EDITOR_GO_TO_LINE), LoadStr(EDITOR_LINE_NUMBER), Str)) { int Line = StrToIntDef(Str, -1); if (Line <= 0 || Line > EditorMemo->Lines->Count) { throw Exception(MainInstructions(LoadStr(EDITOR_INVALID_LINE))); } else { EditorMemo->CaretPos = TPoint(0, Line-1); } } }
//--------------------------------------------------------------------------- TForm * __fastcall ShowEditorForm(const UnicodeString FileName, TCustomForm * ParentForm, TNotifyEvent OnFileChanged, TNotifyEvent OnFileReload, TFileClosedEvent OnClose, const UnicodeString Caption) { TEditorForm * Dialog = new TEditorForm(Application); try { Dialog->FileName = FileName; Dialog->ParentForm = ParentForm; UnicodeString ACaption = Caption.IsEmpty() ? FileName : Caption; Dialog->Caption = ACaption + L" - " + LoadStr(EDITOR_CAPTION) + L" - " + AppName; Dialog->OnFileChanged = OnFileChanged; Dialog->OnFileReload = OnFileReload; // load before showing, so when loading failes, // we do not show an empty editor Dialog->LoadFile(); Dialog->Show(); // make sure editor closing is announced only if it was ever successfully shown // (at least current implementation of the events cannot handle that) Dialog->OnWindowClose = OnClose; } catch(...) { delete Dialog; throw; } return Dialog; }
//--------------------------------------------------------------------------- __fastcall TRemoteTransferDialog::TRemoteTransferDialog(TComponent * Owner) : TForm(Owner) { UseSystemSettings(this); Caption = LoadStr(REMOTE_COPY_TITLE); }
//--------------------------------------------------------------------------- bool __fastcall AppendExceptionStackTraceAndForget(TStrings *& MoreMessages) { bool Result = false; TGuard Guard(StackTraceCriticalSection.get()); TStackTraceMap::iterator Iterator = StackTraceMap.find(GetCurrentThreadId()); if (Iterator != StackTraceMap.end()) { std::unique_ptr<TStrings> OwnedMoreMessages; if (MoreMessages == NULL) { OwnedMoreMessages.reset(new TStringList()); MoreMessages = OwnedMoreMessages.get(); Result = true; } if (!MoreMessages->Text.IsEmpty()) { MoreMessages->Text = MoreMessages->Text + "\n"; } MoreMessages->Text = MoreMessages->Text + LoadStr(STACK_TRACE) + "\n"; MoreMessages->AddStrings(Iterator->second); delete Iterator->second; StackTraceMap.erase(Iterator); OwnedMoreMessages.release(); } return Result; }
//--------------------------------------------------------------------------- void __fastcall TSynchronizeDialog::StartButtonClick(TObject * /*Sender*/) { bool Synchronize; bool Continue = true; if (SynchronizeSynchronizeCheck->State == cbGrayed) { TMessageParams Params(mpNeverAskAgainCheck); switch (MoreMessageDialog(LoadStr(SYNCHRONISE_BEFORE_KEEPUPTODATE2), NULL, qtConfirmation, qaYes | qaNo | qaCancel, HELP_KEEPUPTODATE_SYNCHRONIZE, &Params)) { case qaNeverAskAgain: SynchronizeSynchronizeCheck->State = cbChecked; // fall thru case qaYes: Synchronize = true; break; case qaNo: Synchronize = false; break; default: case qaCancel: Continue = false; break; }; } else { Synchronize = SynchronizeSynchronizeCheck->Checked; } if (Continue) { assert(!FSynchronizing); LocalDirectoryEdit->SaveToHistory(); CustomWinConfiguration->History[L"LocalDirectory"] = LocalDirectoryEdit->Items; RemoteDirectoryEdit->SaveToHistory(); CustomWinConfiguration->History[L"RemoteDirectory"] = RemoteDirectoryEdit->Items; FSynchronizing = true; try { UpdateControls(); Repaint(); FAbort = false; DoStartStop(true, Synchronize); } catch(...) { FSynchronizing = false; UpdateControls(); throw; } } }
String __fastcall TPieEditor::GetVerb(Integer Index) { if (Index == 0) return LoadStr(EditAngle_RC); else return String(""); }
//--------------------------------------------------------------------------- void __fastcall TCopyDialog::AdjustControls() { RemoteDirectoryEdit->Visible = false; LocalDirectoryEdit->Visible = false; DirectoryEdit->Visible = FLAGCLEAR(FOptions, coTemp); EnableControl(DirectoryEdit, FLAGCLEAR(FOptions, coDisableDirectory)); EnableControl(DirectoryLabel, DirectoryEdit->Enabled); EnableControl(LocalDirectoryBrowseButton, DirectoryEdit->Enabled); DirectoryLabel->FocusControl = DirectoryEdit; UnicodeString QueueLabel = LoadStr(COPY_BACKGROUND); if (FLAGCLEAR(FOptions, coNoQueue)) { QueueLabel = FMTLOAD(COPY_QUEUE, (QueueLabel)); } QueueCheck2->Caption = QueueLabel; AdjustTransferControls(); LocalDirectoryBrowseButton->Visible = !FToRemote && FLAGCLEAR(FOptions, coTemp); if (FLAGCLEAR(FOptions, coDoNotShowAgain)) { NeverShowAgainCheck->Visible = false; ClientHeight = NeverShowAgainCheck->Top; } UpdateControls(); }
void TSessionLog::Add(TLogLineType Type, UnicodeString ALine) { DebugAssert(FConfiguration); if (GetLogging()) { try { if (FParent != nullptr) { DoAdd(Type, ALine, nb::bind(&TSessionLog::DoAddToParent, this)); } else { TGuard Guard(FCriticalSection); DoAdd(Type, ALine, nb::bind(&TSessionLog::DoAddToSelf, this)); } } catch (Exception &E) { // We failed logging, turn it off and notify user. FConfiguration->SetLogging(false); try { throw ExtException(&E, LoadStr(LOG_GEN_ERROR)); } catch (Exception &E2) { AddException(&E2); FUI->HandleExtendedException(&E2); } } } }
//--------------------------------------------------------------------------- unsigned int __fastcall FatalExceptionMessageDialog(Exception * E, TQueryType Type, int SessionReopenTimeout, const UnicodeString MessageFormat, unsigned int Answers, UnicodeString HelpKeyword, const TMessageParams * Params) { assert(FLAGCLEAR(Answers, qaRetry)); Answers |= qaRetry; TQueryButtonAlias Aliases[1]; Aliases[0].Button = qaRetry; Aliases[0].Alias = LoadStr(RECONNECT_BUTTON); TMessageParams AParams; if (Params != NULL) { AParams = *Params; } assert(AParams.Timeout == 0); // the condition is de facto excess if (SessionReopenTimeout > 0) { AParams.Timeout = SessionReopenTimeout; AParams.TimeoutAnswer = qaRetry; } assert(AParams.Aliases == NULL); AParams.Aliases = Aliases; AParams.AliasesCount = LENOF(Aliases); return ExceptionMessageDialog(E, Type, MessageFormat, Answers, HelpKeyword, &AParams); }
void CDelPipesDialog::OnOK() { // TODO: добавьте специализированный код или вызов базового класса CDialog::OnOK(); CString str; str.Format(LoadStr(IDS_DEL_PIPES_Q), m_listbox.GetSelCount()); if (AfxMessageBox(str, MB_YESNO) == IDYES) { m_pDoc->vecSel.clear(); for (int i = 0; i < m_listbox.GetCount(); i++) if (m_listbox.GetSel(i)) { DWORD_PTR dw = m_listbox.GetItemData(i); int NAYZ = LOWORD(dw), KOYZ = HIWORD(dw); m_pDoc->vecSel.insert(SelStr(NAYZ, KOYZ)); } if (!m_pDoc->IsSelConnected()) { AfxMessageBox(IDS_PARTS_NOT_CONNECTED, MB_OK | MB_ICONEXCLAMATION); return; } m_pDoc->DeleteSelected(); } }
/* Window 生成時の CallBack */ BOOL TSetupDlg::EvCreate(LPARAM lParam) { setup_list.AttachWnd(GetDlgItem(SETUP_LIST)); for (int i=0; i < MAX_SETUP_SHEET; i++) { sheet[i].Create(SETUP_SHEET1 + i, cfg, this); setup_list.SendMessage(LB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_SETUP_SHEET1 + i)); } SetSheet(); if (rect.left == CW_USEDEFAULT) { GetWindowRect(&rect); int xsize = rect.right - rect.left, ysize = rect.bottom - rect.top; int cx = ::GetSystemMetrics(SM_CXFULLSCREEN), cy = ::GetSystemMetrics(SM_CYFULLSCREEN); int x = (cx - xsize)/2; int y = (cy - ysize)/2; MoveWindow((x < 0) ? 0 : x % (cx - xsize), (y < 0) ? 0 : y % (cy - ysize), xsize, ysize, FALSE); } else MoveWindow(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, FALSE); return TRUE; }
//--------------------------------------------------------------------------- void TActionLog::OpenLogFile() { try { assert(FFile == nullptr); assert(FConfiguration != nullptr); FCurrentLogFileName = FConfiguration->GetActionsLogFileName(); FFile = OpenFile(FCurrentLogFileName, FSessionData, false, FCurrentFileName); } catch (Exception & E) { // We failed logging to file, turn it off and notify user. FCurrentLogFileName = L""; FCurrentFileName = L""; FConfiguration->SetLogActions(false); try { throw ExtException(&E, LoadStr(LOG_GEN_ERROR)); } catch (Exception & E) { FUI->HandleExtendedException(&E); } } }
//--------------------------------------------------------------------------- void TSessionLog::OpenLogFile() { try { assert(FFile == nullptr); assert(FConfiguration != nullptr); FCurrentLogFileName = FConfiguration->GetLogFileName(); FFile = OpenFile(FCurrentLogFileName, FSessionData, FConfiguration->GetLogFileAppend(), FCurrentFileName); } catch (Exception & E) { // We failed logging to file, turn it off and notify user. FCurrentLogFileName = L""; FCurrentFileName = L""; FConfiguration->SetLogFileName(UnicodeString()); try { throw ExtException(&E, LoadStr(LOG_GEN_ERROR)); } catch (Exception & E) { AddException(&E); FUI->HandleExtendedException(&E); } } StateChange(); }
//--------------------------------------------------------------------------- void TActionLog::Add(const UnicodeString & Line) { assert(FConfiguration); if (FLogging) { try { TGuard Guard(FCriticalSection); if (FFile == nullptr) { OpenLogFile(); } if (FFile != nullptr) { UTF8String UtfLine = UTF8String(Line); fwrite(UtfLine.c_str(), 1, UtfLine.Length(), (FILE *)FFile); fwrite("\n", 1, 1, (FILE *)FFile); } } catch (Exception &E) { // We failed logging, turn it off and notify user. FConfiguration->SetLogActions(false); try { throw ExtException(&E, LoadStr(LOG_GEN_ERROR)); } catch (Exception &E) { FUI->HandleExtendedException(&E); } } } }
//--------------------------------------------------------------------------- void __fastcall TCustomWinConfiguration::DefaultHistory() { ClearHistory(); std::unique_ptr<THistoryStrings> Strings; // Defaults for speed limits. Strings.reset(new THistoryStrings()); // This is language-specifics, what has to be dealt with when changing language. // There's ad-hoc workaround in CopySpeedLimits. // If we need to solve this for another history, we should introduce // a generic solution, like language-specific history ("SpeedLimitEN") Strings->Add(LoadStr(SPEED_UNLIMITED)); unsigned long Speed = 8192; while (Speed >= 8) { Strings->Add(IntToStr(int(Speed))); Speed = Speed / 2; } FHistory->AddObject(L"SpeedLimit", Strings.release()); Strings.reset(new THistoryStrings()); Strings->Add(FormatCommand(DefaultPuttyPath, L"")); Strings->Add(FormatCommand(DefaultPuttyPath, L"-t -m \"%TEMP%\\putty.txt\" !`cmd.exe /c echo cd '!/' ; /bin/bash -login > \"%TEMP%\\putty.txt\"`")); Strings->Add(KittyExecutable); Strings->Add(FORMAT(L"%s -cmd \"cd '!/'\" !U@!@ -P !# -title \"!N\"", (KittyExecutable))); FHistory->AddObject(L"PuttyPath", Strings.release()); }
int TMain::CheckPing() { int Result = ID_NO; String Host, Phone, S = ""; ShowWaitCursor(); TFileIni* FileIni = CreateINIFile(); for (int i = 1; i <= FileIni->ReadInteger("DB", "Count", 0); i++) { ProcMess(); Host = FileIni->ReadString("DB", "Ping" + IntToStr(i), ""); if (Host != "") if (!Ping(Host)) S = ConcatStrings(S, Format(IDS_PING_ERROR, ARRAYOFCONST((FileIni->ReadString("DB", "Name" + IntToStr(i), ""), FileIni->ReadString("DB", "Phone" + IntToStr(i), "")))), (String) sLineBreak + (String) sLineBreak); } FileIni->Free(); RestoreCursor(); if (S != "") Result = MsgBox(S + sLineBreak + sLineBreak + LoadStr(IDS_PING_RESULT), MB_YESNOCANCEL | MB_ICONQUESTION); return Result; }
BOOL TShellExtDlg::ReflectStatus(void) { BOOL isRegister = shellExt.IsRegisterDllProc(isAdmin); int flags; SetDlgItemText(IDSHELLEXT_OK, isRegister ? LoadStr(IDS_SHELLEXT_MODIFY) : LoadStr(IDS_SHELLEXT_EXEC)); ::EnableWindow(GetDlgItem(IDSHELLEXT_CANCEL), isRegister); if ((flags = shellExt.GetMenuFlagsProc(isAdmin)) == -1) { flags = (SHEXT_RIGHT_COPY|SHEXT_RIGHT_DELETE|SHEXT_DD_COPY|SHEXT_DD_MOVE); // for old shellext } // if ((flags & SHEXT_MENUFLG_EX) == 0) { // old shellext // ::EnableWindow(GetDlgItem(RIGHT_PASTE_CHECK), FALSE); // } if (flags & SHEXT_ISSTOREOPT) { shCfg->noConfirm = (flags & SHEXT_NOCONFIRM) ? TRUE : FALSE; shCfg->noConfirmDel = (flags & SHEXT_NOCONFIRMDEL) ? TRUE : FALSE; shCfg->taskTray = (flags & SHEXT_TASKTRAY) ? TRUE : FALSE; shCfg->autoClose = (flags & SHEXT_AUTOCLOSE) ? TRUE : FALSE; } CheckDlgButton(RIGHT_COPY_CHECK, flags & SHEXT_RIGHT_COPY); CheckDlgButton(RIGHT_DELETE_CHECK, flags & SHEXT_RIGHT_DELETE); CheckDlgButton(RIGHT_PASTE_CHECK, flags & SHEXT_RIGHT_PASTE); CheckDlgButton(RIGHT_SUBMENU_CHECK, flags & SHEXT_SUBMENU_RIGHT); CheckDlgButton(DD_COPY_CHECK, flags & SHEXT_DD_COPY); CheckDlgButton(DD_MOVE_CHECK, flags & SHEXT_DD_MOVE); CheckDlgButton(DD_SUBMENU_CHECK, flags & SHEXT_SUBMENU_DD); CheckDlgButton(NOCONFIRM_CHECK, shCfg->noConfirm); CheckDlgButton(NOCONFIRMDEL_CHECK, shCfg->noConfirmDel); CheckDlgButton(TASKTRAY_CHECK, shCfg->taskTray); CheckDlgButton(AUTOCLOSE_CHECK, shCfg->autoClose); SetWindowText(LoadStr(isAdmin ? IDS_SHELLEXT_ADMIN : IDS_SHELLEXT_USER)); if (isAdmin && !::IsUserAnAdmin()) { SetDlgItemText(SHELL_STATIC, LoadStr(IDS_SHELLEXT_NEEDADMIN)); ::EnableWindow(GetDlgItem(IDSHELLEXT_OK), FALSE); ::EnableWindow(GetDlgItem(IDSHELLEXT_CANCEL), FALSE); } return TRUE; }
//--------------------------------------------------------------------- void __fastcall TFileSystemInfoDialog::ControlsAddItem(TControl * Control, int Label, UnicodeString Value) { if (FLastFeededControl != Control) { // TODO, we should clear excess list view items here, but it // actually should not happen as of now FLastFeededControl = Control; FLastListItem = 0; } if (Control == HostKeyFingerprintEdit) { EnableControl(HostKeyGroup, !Value.IsEmpty()); HostKeyGroup->Visible = !Value.IsEmpty(); HostKeyFingerprintEdit->Text = Value; } else if (Control == CertificateFingerprintEdit) { EnableControl(CertificateGroup, !Value.IsEmpty()); CertificateGroup->Visible = !Value.IsEmpty(); CertificateFingerprintEdit->Text = Value; } else if (Control == InfoMemo) { EnableControl(InfoGroup, !Value.IsEmpty()); InfoGroup->Visible = !Value.IsEmpty(); InfoMemo->Lines->Text = Value; } else { TListView * ListView = dynamic_cast<TListView *>(Control); assert(ListView != NULL); if (!Value.IsEmpty()) { TListItem * Item; if (ListView->Items->Count > FLastListItem) { Item = ListView->Items->Item[FLastListItem]; } else { Item = ListView->Items->Add(); } FLastListItem++; Item->Caption = LoadStr(Label); if (Item->SubItems->Count > 0) { Item->SubItems->Strings[0] = Value; } else { Item->SubItems->Add(Value); } } } }