void HelpSystem::ShowHelpDialog(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal) { AudacityProject * pProj = GetActiveProject(); wxString HelpMode = wxT("Local"); if( pProj ) { HelpMode = pProj->mHelpPref; // these next lines are for legacy cfg files (pre 2.0) where we had different modes if( (HelpMode == wxT("Standard")) || (HelpMode == wxT("InBrowser")) ) { HelpMode = wxT("Local"); pProj->mHelpPref = HelpMode; gPrefs->Write(wxT("/GUI/Help"), HelpMode); gPrefs->Flush(); } } // Anchors (URLs with a '#' in them) are not supported by many OSs for local file names // See, for example, https://groups.google.com/forum/#!topic/wx-users/pC0uOZJalRQ // Problems have been reported on Win, Mac and some versions of Linux. // So we set HelpMode to use the internet if an anchor is found. if (localFileName.Find('#', true) != wxNOT_FOUND) HelpMode = wxT("FromInternet"); // Until a solution is found for this, the next few lines are irrelevant. // Obtain the local file system file name, without the anchor if present. wxString localfile; if (localFileName.Find('#', true) != wxNOT_FOUND) localfile = localFileName.BeforeLast('#'); else localfile = localFileName; if( (HelpMode == wxT("FromInternet")) && !remoteURL.IsEmpty() ) { // Always go to remote URL. Use External browser. OpenInDefaultBrowser( remoteURL ); } else if( !wxFileExists( localfile )) { // If you give an empty remote URL, you should have already ensured // that the file exists! wxASSERT( !remoteURL.IsEmpty() ); // I can't find it'. // Use Built-in browser to suggest you use the remote url. wxString Text = HelpText( wxT("remotehelp") ); Text.Replace( wxT("*URL*"), remoteURL ); ShowHtmlText( parent, _("Help on the Internet"), Text, false, bModal ); } else if( HelpMode == wxT("Local") ) { // Local file, External browser OpenInDefaultBrowser( wxString(wxT("file:"))+localFileName ); } else { // Local file, Built-in browser ShowHtmlText( parent, wxT(""), localFileName, true, bModal ); } }
void HelpSystem::ShowHelpDialog(wxWindow *parent, const wxString &PageName, bool bModal) { wxString localHelpPage; wxString webHelpPath; wxString webHelpPage; wxString releasePageName; wxString anchor; // optional part of URL after (and including) the '#' if (PageName.Find('#', true) != wxNOT_FOUND) { // need to split anchor off into separate variable releasePageName= PageName.BeforeLast('#'); anchor = wxT("#") + PageName.AfterLast('#'); } else { releasePageName = PageName; anchor = wxT(""); } // The wiki pages are transformed to static HTML by // scripts/mw2html_audacity/mw2html.py // The name is first transformed to lower case, then all // 'special characters' are replaced by underscores. Spaces are // transformed to "+". // // The transformations are handled in mw2html by first applying // 'urllib.parse.quote_plus' (escape chars that are not in "always safe" list) // then replacing escape characters (%xx) with underscores, // and finally removing duplicate / redundant underscores. // // The front page and 'quick_help' are treated as special cases and placed in // the root of the help directory rather than the "/man/" sub-directory. if (releasePageName == wxT("Main_Page")) { releasePageName = wxT("index") + HelpSystem::ReleaseSuffix + anchor; localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath(); webHelpPath = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir; } else if (releasePageName == wxT("Quick_Help")) { releasePageName = wxT("quick_help") + HelpSystem::ReleaseSuffix + anchor; localHelpPage = wxFileName(FileNames::HtmlHelpDir(), releasePageName).GetFullPath(); webHelpPath = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerHomeDir; } else { // Handle all other pages. // Change to lower case. releasePageName = releasePageName.Lower(); wxRegEx re; // replace 'special characters' with underscores. // RFC 2396 defines the characters a-z, A-Z, 0-9 and ".-_" as "always safe" // mw2html also replaces "-" with "_" so replace that too. // If PageName contains a %xx code, mw2html will transform it: // '%xx' => '%25xx' => '_' re.Compile(wxT("%..")); re.ReplaceAll(&releasePageName, (wxT("_"))); // Now replace all other 'not-safe' characters. re.Compile(wxT("[^[:alnum:] . [:space:]]")); re.ReplaceAll(&releasePageName, (wxT("_"))); // Replace spaces with "+" releasePageName.Replace(wxT(" "), wxT("+"), true); // Reduce multiple underscores to single underscores re.Compile(wxT("__+")); re.ReplaceAll(&releasePageName, (wxT("_"))); // Replace "_." with "." releasePageName.Replace(wxT("_."), wxT("."), true); // Concatenate file name with file extension and anchor. releasePageName = releasePageName + HelpSystem::ReleaseSuffix + anchor; // Other than index and quick_help, all local pages are in subdirectory 'LocalHelpManDir'. localHelpPage = wxFileName(FileNames::HtmlHelpDir() + LocalHelpManDir, releasePageName).GetFullPath(); // Other than index and quick_help, all on-line pages are in subdirectory 'HelpServerManDir'. webHelpPath = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerManDir; } #if IS_ALPHA webHelpPage = webHelpPath + PageName; #else webHelpPage = webHelpPath + releasePageName; #endif wxLogMessage(wxT("Help button pressed: PageName %s, releasePageName %s"), PageName.c_str(), releasePageName.c_str()); wxLogMessage(wxT("webHelpPage %s, localHelpPage %s"), webHelpPage.c_str(), localHelpPage.c_str()); HelpSystem::ShowHelpDialog( parent, localHelpPage, webHelpPage, bModal); }
void VcImporter::RemoveGershaim(wxString& str) { TrimString(str); str = str.AfterFirst(wxT('"')); str = str.BeforeLast(wxT('"')); }
//////////////////////////////////////////////////////////// // installation and removal bool installService(const wxString &serviceName, const wxString &executable, const wxString &args, const wxString &displayname, const wxString &user, const wxString &password) { DWORD dwData; bool done = false; SC_HANDLE manager = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS); if (manager) { wxString cmd = executable + wxT(" ") + args; wxString quser; if (!user.Contains(wxT("\\"))) quser = wxT(".\\") + user; else quser = user; SC_HANDLE service = CreateService(manager, serviceName.c_str(), displayname.c_str(), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, cmd.c_str(), 0, 0, 0, quser.c_str(), password.c_str()); if (service) { done = true; CloseServiceHandle(service); } else { LPVOID lpMsgBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); wxString error; error.Printf(wxT("%s"), lpMsgBuf); LogMessage(error, LOG_ERROR); } CloseServiceHandle(manager); } // Setup the event message DLL wxRegKey *msgKey = new wxRegKey(wxT("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\") + serviceName); if(!msgKey->Exists()) { if (!msgKey->Create()) LogMessage(_("Could not open the message source registry key."), LOG_WARNING); } wxString path = executable.BeforeLast('\\') + wxT("\\pgaevent.dll"); if (!msgKey->SetValue(wxT("EventMessageFile"), path)) LogMessage(_("Could not set the event message file registry value."), LOG_WARNING); dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; if (!msgKey->SetValue(wxT("TypesSupported"), dwData)) LogMessage(_("Could not set the supported types."), LOG_WARNING);; return done; }
static wxString wxGetRichTextStyle(const wxString& style) { return style.BeforeLast(wxT('|')); }
bool SjVirtKeybdLayout::LoadLayoutFromFile(const wxString& file__, wxArrayString* allNames) { // split index from file name wxString file; long currIndex = -1, wantedIndex = 0; if( file__.Find(wxT(','), TRUE) <= file__.Find(wxT('.'), TRUE) ) { file = file__; } else { if( !file__.AfterLast(wxT(',')).ToLong(&wantedIndex, 10) ) { wantedIndex = 0; } file = file__.BeforeLast(wxT(',')); } // init m_keys.Clear(); m_file = file; m_name = file; m_lineCount = 1; m_totalRelWidth = 0; if( allNames ) { allNames->Clear(); } // read file content wxFileSystem fs; wxFSFile* fsFile = fs.OpenFile(file); if( fsFile == NULL ) { return FALSE; } wxString fileContent = SjTools::GetFileContent(fsFile->GetStream(), &wxConvISO8859_1); delete fsFile; // parse file fileContent.Replace(wxT(";"), wxT("\n")); SjLineTokenizer tkz(fileContent); wxChar* linePtr; wxString line, lineType, lineValue; SjVirtKeybdKey* currKey = NULL; while( (linePtr=tkz.GetNextLine()) != NULL ) { line = linePtr; // get key'n'value pair (currLine is already trimmed aleft and aright) if( line.Find('=') != -1 ) { lineType = line.BeforeFirst('=').Trim().Lower(); lineValue = line.AfterFirst('=').Trim(FALSE); } else { lineType = line.Lower(); lineValue.Empty(); } if( lineType == wxT("layout") ) { if( allNames ) { allNames->Add(lineValue); } currIndex++; if( currIndex == wantedIndex ) { m_name = lineValue; } } else if( currIndex != wantedIndex ) { ; } else if( lineType == wxT("key") ) { currKey = new SjVirtKeybdKey(lineValue); m_keys.Add(currKey); } else if( lineType == wxT("spacer") || lineType == wxT("nextline") ) { currKey = new SjVirtKeybdKey(lineType); m_keys.Add(currKey); } else if( currKey ) { if( lineType == wxT("width") ) { currKey->SetRelWidth(lineValue); } else { currKey->SetKey(lineType, lineValue); } } } if( currIndex < wantedIndex ) { return FALSE; // layout not found } // calculate the max. relative width and the rel. x-positions float currX = 0.0; float lineRelWidth = 0.0; long i, iCount = m_keys.GetCount(); for( i = 0; i < iCount; i++ ) { currKey = &(m_keys[i]); if( currKey->IsNextLine() ) { if( lineRelWidth > m_totalRelWidth ) { m_totalRelWidth = lineRelWidth; } lineRelWidth = 0; m_lineCount++; currX = 0.0; } else { if( currKey->IsEnter() ) { m_enterKey = currKey; } else if( currKey->IsEnterCont() ) { m_enterCont = currKey; } currKey->SetRelXPos(currX); currX += currKey->GetRelWidth(); lineRelWidth += currKey->GetRelWidth(); } } return TRUE; }
std::unique_ptr<Vamp::Plugin> VampEffectsModule::FindPlugin(const wxString & path, int & output, bool & hasParameters) { PluginLoader::PluginKey key = path.BeforeLast(wxT('/')).ToUTF8().data(); std::unique_ptr<Plugin> vp{ PluginLoader::getInstance()->loadPlugin(key, 48000) }; // rate doesn't matter here if (!vp) { return nullptr; } // We limit the listed plugin outputs to those whose results can // readily be displayed in an Audacity label track. // // - Any output whose features have no values (time instants only), // with or without duration, is fine // // - Any output whose features have more than one value, or an // unknown or variable number of values, is right out // // - Any output whose features have exactly one value, with // variable sample rate or with duration, should be OK -- // this implies a sparse feature, of which the time and/or // duration are significant aspects worth displaying // // - An output whose features have exactly one value, with // fixed sample rate and no duration, cannot be usefully // displayed -- the value is the only significant piece of // data there and we have no good value plot Plugin::OutputList outputs = vp->getOutputDescriptors(); output = 0; hasParameters = !vp->getParameterDescriptors().empty(); for (Plugin::OutputList::iterator j = outputs.begin(); j != outputs.end(); ++j) { if (j->sampleType == Plugin::OutputDescriptor::FixedSampleRate || j->sampleType == Plugin::OutputDescriptor::OneSamplePerStep || !j->hasFixedBinCount || (j->hasFixedBinCount && j->binCount > 1)) { // All of these qualities disqualify (see notes above) ++output; continue; } wxString name = wxString::FromUTF8(vp->getName().c_str()); if (outputs.size() > 1) { // This is not the plugin's only output. // Use "plugin name: output name" as the effect name, // unless the output name is the same as the plugin name wxString outputName = wxString::FromUTF8(j->name.c_str()); if (outputName != name) { name = wxString::Format(wxT("%s: %s"), name, outputName); } } if (wxString::FromUTF8(key.c_str()) + wxT("/") + name == path) { return vp; } ++output; } return {}; }