1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 // Copyright (C) 2003 John Dallaway
7 // This program is part of the eCos host tools.
9 // This program is free software; you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by the Free
11 // Software Foundation; either version 2 of the License, or (at your option)
14 // This program is distributed in the hope that it will be useful, but WITHOUT
15 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 // You should have received a copy of the GNU General Public License along with
20 // this program; if not, write to the Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // ----------------------------------------------------------------------------
25 //####COPYRIGHTEND####
28 //===========================================================================
29 //#####DESCRIPTIONBEGIN####
31 // Author(s): julians, jld
32 // Contact(s): julians
36 // Description: Implementation file for the ecSettings
43 //####DESCRIPTIONEND####
45 //===========================================================================
47 // ============================================================================
49 // ============================================================================
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 #pragma implementation "appsettings.h"
58 // Includes other headers for precompiled compilation
65 #include "wx/config.h"
68 #include "appsettings.h"
69 #include "configtree.h"
70 #include "outputwin.h"
71 #include "shortdescrwin.h"
77 #include "wx/msw/winundef.h"
78 #if defined(GetTempPath) && !defined(__CYGWIN__)
84 * User-changeable and other settings to be saved between sessions
87 IMPLEMENT_DYNAMIC_CLASS(ecSettings, wxObject)
89 ecSettings::ecSettings()
92 m_frameSize = wxRect(0, 0, 600, 500);
93 m_appName = _("eCos Configuration Tool");
94 m_showSplashScreen = TRUE;
95 m_userName = wxEmptyString;
97 m_frameStatus = ecSHOW_STATUS_NORMAL;
99 m_treeSashSize = wxSize(400, 1000);
100 m_conflictsSashSize = wxSize(1000, 80);
101 m_propertiesSashSize = wxSize(1000, 80);
102 m_shortDescrSashSize = wxSize(1000, 80);
103 m_memorySashSize = wxSize(1000, 50);
104 m_outputSashSize = wxSize(1000, 50);
105 m_configPaneWidth = 200;
107 m_showConflictsWindow = FALSE;
108 m_showPropertiesWindow = TRUE;
109 m_showShortDescrWindow = TRUE;
110 m_showMemoryWindow = FALSE;
111 m_showOutputWindow = TRUE;
113 m_showMacroNames = FALSE;
115 m_bUseCustomViewer = FALSE;
116 m_bUseExternalBrowser = FALSE;
117 m_eUseCustomBrowser = ecAssociatedExternal;
119 m_nRuleChecking = Immediate|Deferred|SuggestFixes ;
122 m_strViewer = wxT("notepad");
125 // Find dialog settings
126 m_findText = wxEmptyString;
127 m_findMatchWholeWord = FALSE;
128 m_findMatchCase = FALSE;
129 m_findDirection = TRUE; // Down is TRUE, Up is FALSE
130 m_findSearchWhat = _("Macro names"); // Macro names, item names etc.
131 m_findDialogPos = wxPoint(-1, -1);
133 m_editSaveFileOnly = FALSE;
135 // Packages dialog settings
136 m_omitHardwarePackages = FALSE;
137 m_matchPackageNamesExactly = FALSE;
141 ecSettings::ecSettings(const ecSettings& settings)
146 void ecSettings::Copy(const ecSettings& settings)
148 m_showToolBar = settings.m_showToolBar;
149 m_frameSize = settings.m_frameSize;
150 m_showSplashScreen = settings.m_showSplashScreen;
151 m_userName = settings.m_userName;
152 m_serialNumber = settings.m_serialNumber;
154 m_treeSashSize = settings.m_treeSashSize;
155 m_conflictsSashSize = settings.m_conflictsSashSize;
156 m_propertiesSashSize = settings.m_propertiesSashSize;
157 m_memorySashSize = settings.m_memorySashSize;
158 m_outputSashSize = settings.m_outputSashSize;
159 m_configPaneWidth = settings.m_configPaneWidth;
160 m_showMacroNames = settings.m_showMacroNames;
162 m_bUseCustomViewer = settings.m_bUseCustomViewer;
163 m_bUseExternalBrowser = settings.m_bUseExternalBrowser;
164 m_eUseCustomBrowser = settings.m_eUseCustomBrowser;
165 m_bHex = settings.m_bHex;
166 m_nRuleChecking = settings.m_nRuleChecking;
168 // Find dialog settings
169 m_findText = settings.m_findText;
170 m_findMatchWholeWord = settings.m_findMatchWholeWord;
171 m_findMatchCase = settings.m_findMatchCase;
172 m_findDirection = settings.m_findDirection; // Down is TRUE, Up is FALSE
173 m_findSearchWhat = settings.m_findSearchWhat;
174 m_findDialogPos = settings.m_findDialogPos;
176 // Run tests settings
177 m_runTestsSettings = settings.m_runTestsSettings;
179 m_userToolsDir = settings.m_userToolsDir;
180 m_buildToolsDir = settings.m_buildToolsDir;
182 m_editSaveFileOnly = settings.m_editSaveFileOnly;
184 // Packages dialog settings
185 m_omitHardwarePackages = settings.m_omitHardwarePackages;
186 m_matchPackageNamesExactly = settings.m_matchPackageNamesExactly;
189 ecSettings::~ecSettings()
193 // Do some initialisation within ecApp::OnInit
194 bool ecSettings::Init()
199 // Get a name suitable for the configuration file on all platforms:
200 // e.g. eCos Configuration Tool on Windows, .eCosConfigTool on Unix
201 wxString ecSettings::GetConfigAppName() const
204 return wxString(wxT("eCosConfigTool"));
211 // Create new filename
212 wxString ecSettings::GenerateFilename(const wxString& rootName)
215 if (!m_lastFilename.IsEmpty())
216 path = wxPathOnly(m_lastFilename);
218 // path = wxGetApp().GetAppDir();
221 wxString filename(path);
222 if (filename.Last() != wxFILE_SEP_PATH )
223 filename += wxFILE_SEP_PATH;
224 filename += rootName;
226 wxString fullFilename = filename + wxT(".ecc");
229 while (wxFileExists(fullFilename))
232 postfixStr.Printf("%d", i);
233 fullFilename = filename + postfixStr + wxT(".ecc");
236 m_lastFilename = fullFilename;
241 bool ecSettings::LoadConfig()
243 wxConfig config(wxGetApp().GetSettings().GetConfigAppName());
245 config.Read(_("/Window Status/FrameStatus"), & m_frameStatus);
246 config.Read(_("/Window Status/ShowToolBar"), (bool*) & m_showToolBar);
247 config.Read(_("/Window Status/ShowSplashScreen"), (bool*) & m_showSplashScreen);
248 config.Read(_("/Window Status/ShowConflictsWindow"), (bool*) & m_showConflictsWindow);
249 config.Read(_("/Window Status/ShowPropertiesWindow"), (bool*) & m_showPropertiesWindow);
250 config.Read(_("/Window Status/ShowShortDescrWindow"), (bool*) & m_showShortDescrWindow);
251 config.Read(_("/Window Status/ShowMemoryWindow"), (bool*) & m_showMemoryWindow);
252 config.Read(_("/Window Status/ShowOutputWindow"), (bool*) & m_showOutputWindow);
254 config.Read(_("/Files/LastFile"), & m_lastFilename);
256 config.Read(_("/Window Size/WindowX"), & m_frameSize.x);
257 config.Read(_("/Window Size/WindowY"), & m_frameSize.y);
258 config.Read(_("/Window Size/WindowWidth"), & m_frameSize.width);
259 config.Read(_("/Window Size/WindowHeight"), & m_frameSize.height);
261 config.Read(_("/Window Size/TreeSashWidth"), & m_treeSashSize.x);
262 config.Read(_("/Window Size/TreeSashHeight"), & m_treeSashSize.y);
263 config.Read(_("/Window Size/ConfigPaneWidth"), & m_configPaneWidth);
264 config.Read(_("/Window Size/ConflictsWidth"), & m_conflictsSashSize.x);
265 config.Read(_("/Window Size/ConflictsHeight"), & m_conflictsSashSize.y);
266 config.Read(_("/Window Size/PropertiesWidth"), & m_propertiesSashSize.x);
267 config.Read(_("/Window Size/PropertiesHeight"), & m_propertiesSashSize.y);
268 config.Read(_("/Window Size/ShortDescrWidth"), & m_shortDescrSashSize.x);
269 config.Read(_("/Window Size/ShortDescrHeight"), & m_shortDescrSashSize.y);
270 config.Read(_("/Window Size/OutputWidth"), & m_outputSashSize.x);
271 config.Read(_("/Window Size/OutputHeight"), & m_outputSashSize.y);
272 config.Read(_("/Window Size/MemoryWidth"), & m_memorySashSize.x);
273 config.Read(_("/Window Size/MemoryHeight"), & m_memorySashSize.y);
275 config.Read(_("/Options/ShowMacroNames"), (bool*) & m_showMacroNames);
276 config.Read(_("/Options/UseCustomViewer"), (bool*) & m_bUseCustomViewer);
277 config.Read(_("/Options/UseExternalBrowser"), (bool*) & m_bUseExternalBrowser);
279 int tmp = (int) m_eUseCustomBrowser;
280 config.Read(_("/Options/UseCustomBrowser"), & tmp);
281 m_eUseCustomBrowser = (ecBrowserType) tmp;
283 config.Read(_("/Options/Browser"), & m_strBrowser);
284 config.Read(_("/Options/Viewer"), & m_strViewer);
285 config.Read(_("/Options/HexDisplay"), (bool*) & m_bHex);
286 config.Read(_("/Options/UseDefaultFonts"), (bool*) & m_windowSettings.m_useDefaults);
287 config.Read(_("/Rule/Checking"), & m_nRuleChecking);
289 // Find dialog settings
290 config.Read(_("/Find/Text"), & m_findText);
291 config.Read(_("/Find/MatchWholeWord"), (bool*) & m_findMatchWholeWord);
292 config.Read(_("/Find/MatchCase"), & m_findMatchCase);
293 config.Read(_("/Find/Direction"), (bool*) & m_findDirection);
294 config.Read(_("/Find/SearchWhat"), & m_findSearchWhat);
295 config.Read(_("/Find/DialogX"), & m_findDialogPos.x);
296 config.Read(_("/Find/DialogY"), & m_findDialogPos.y);
298 // Package dialog settings
299 config.Read(_("/Packages/OmitHardwarePackages"), & m_omitHardwarePackages);
300 config.Read(_("/Packages/MatchPackageNamesExactly"), & m_matchPackageNamesExactly);
302 // Run tests settings
303 m_runTestsSettings.LoadConfig(config);
306 m_windowSettings.LoadConfig(config);
308 if (!config.Read(_("/Paths/UserToolsDir"), & m_userToolsDir))
310 // Use the default provided by the installer
311 config.Read(_("Default User Tools Path"), & m_userToolsDir);
314 // Only to be used if we fail to find the information installed
315 // with the Configuration Tool.
316 config.Read(_("/Paths/BuildToolsDir"), & m_buildToolsDir);
318 if (!config.Read(_("/Build/Make Options"), & m_strMakeOptions))
321 SYSTEM_INFO SystemInfo;
322 GetSystemInfo(&SystemInfo);
323 // disable -j option for now due to problem with Cygwin 1.3.18
324 // m_strMakeOptions.Printf(_T("-j%d"),SystemInfo.dwNumberOfProcessors);
328 // Set default build tools binary directories as specified by the installer
329 ecFileName strDefaultBuildToolsPath;
333 // This should look in HKEY_LOCAL_MACHINE
335 wxConfig config2(wxT("eCos"), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_LOCAL_FILE);
337 wxString versionKey = GetInstallVersionKey();
338 wxConfigPathChanger path(& config2, wxString(wxT("/")) + versionKey + wxT("/"));
340 if (!versionKey.IsEmpty() && config2.Read(wxT("Default Build Tools Path"), & strDefaultBuildToolsPath))
343 wxString gccExe(wxT("*-gcc.exe"));
345 wxString gccExe(wxT("*-gcc"));
348 // Note that this is not a recursive search. Compilers for
349 // different targets may be in the same directory. This finds all targets.
351 // look for *-gcc[.exe] in the default build tools directory
353 wxDir finder(strDefaultBuildToolsPath);
356 if (finder.IsOpened())
358 bool bMore = finder.GetFirst(& filename, gccExe);
361 wxString targetName = filename.Left(filename.Find(wxT("-gcc")));
362 m_arstrBinDirs.Set(targetName, strDefaultBuildToolsPath);
364 bMore = finder.GetNext(& filename);
372 // Look in the PATH for build tools, under Unix
375 if (wxGetEnv(wxT("PATH"), & strPath))
377 wxString gccExe(wxT("*-gcc"));
379 wxArrayString arstrPath;
380 ecUtils::Chop(strPath, arstrPath, wxT(':'));
382 for (int i = arstrPath.GetCount()-1;i >= 0; --i)
383 { // Reverse order is important to treat path correctly
385 wxDir finder(arstrPath[i]);
388 if (finder.IsOpened())
390 bool bMore = finder.GetFirst(& filename, gccExe);
393 wxString targetName = filename.Left(filename.Find(wxT("-gcc")));
394 m_arstrBinDirs.Set(targetName, arstrPath[i]);
396 bMore = finder.GetNext(& filename);
404 // Read build tools directories (current user)
407 wxConfigPathChanger path(& config, wxT("/Build Tools/"));
408 //config.SetPath(wxT("/Build Tools"));
409 wxString key(wxT(""));
411 bool bMore = config.GetFirstEntry(key, index);
415 if (config.Read(key, & value))
417 m_arstrBinDirs.Set(key, value);
419 bMore = config.GetNextEntry(key, index);
423 // Read toolchain paths (local machine again)
425 wxArrayString arstrToolChainPaths;
427 // Use eCos just as a test.
428 //GetRepositoryRegistryClues(arstrToolChainPaths,_T("eCos"));
429 GetRepositoryRegistryClues(arstrToolChainPaths,_T("GNUPro eCos"));
432 for (i = (size_t) 0; i < arstrToolChainPaths.GetCount(); i++)
434 ecFileName strDir(arstrToolChainPaths[i]);
435 strDir += wxT("H-i686-cygwin32\\bin");
439 // This is a potential toolchain location. Look for *-gcc.exe
441 wxDir finder(strDefaultBuildToolsPath);
444 if (finder.IsOpened())
446 bool bMore = finder.GetFirst(& filename, wxT("*-gcc.exe"));
449 // TODO: if there is more than one path, we will have to
450 // check the existance of this target name in m_arstrBinDirs and
451 // append to the end, or something.
452 wxString targetName = filename.Left(filename.Find(wxT("-gcc")));
453 m_arstrBinDirs.Set(targetName, strDefaultBuildToolsPath);
455 bMore = finder.GetNext(& filename);
461 // The official user tools are now Cygwin 00r1. If you can't find these,
462 // try GNUPro unsupported.
463 GetRepositoryRegistryClues(m_userToolPaths, wxT("GNUPro 00r1"));
464 if (m_userToolPaths.GetCount() == 0)
466 GetRepositoryRegistryClues(m_userToolPaths, wxT("Cygwin 00r1"));
469 if (m_userToolPaths.GetCount() > 0)
471 for ( i = (size_t) 0 ; i < m_userToolPaths.GetCount(); i++)
473 ecFileName str(m_userToolPaths[i]);
474 str += "H-i686-cygwin32\\bin";
477 m_userToolPaths[i] = str;
480 m_userToolPaths.Remove(i);
487 GetRepositoryRegistryClues(m_userToolPaths, wxT("GNUPro unsupported"));
489 for ( i = (size_t) 0 ; i < m_userToolPaths.GetCount(); i++)
491 ecFileName str(m_userToolPaths[i]);
492 str += "H-i686-cygwin32\\bin";
495 m_userToolPaths[i] = str;
498 m_userToolPaths.Remove(i);
505 // Include the path in the set of potential user paths
508 if (wxGetEnv(wxT("PATH"), & strPath))
510 wxArrayString arstrPath;
511 ecUtils::Chop(strPath, arstrPath, wxT(';'));
513 for (int i = arstrPath.GetCount()-1;i >= 0; --i)
514 { // Reverse order is important to treat path correctly
516 const ecFileName &strFolder = arstrPath[i];
517 ecFileName strFile(strFolder);
518 strFile += wxT("ls.exe");
519 if ( strFile.Exists() )
521 if (!wxArrayStringIsMember(m_userToolPaths, strFolder))
523 m_userToolPaths.Add(strFolder);
526 if ( m_userToolsDir.IsEmpty() )
528 m_userToolsDir = strFolder;
535 // Load current repository from eCos Configuration Tool/Paths/RepositoryDir
537 wxConfig eCosConfig(wxGetApp().GetSettings().GetConfigAppName(), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_LOCAL_FILE);
538 wxConfigPathChanger path(& config, wxT("/Repository/"));
540 //if (!eCosConfig.Read(wxT("Folder"), & m_strRepository))
541 if (!eCosConfig.Read(wxT("/Paths/RepositoryDir"), & m_strRepository))
544 // If we can't find the current folder, look for clues in the registry.
546 switch (GetRepositoryRegistryClues(arstr, wxT("eCos")))
552 m_strRepository = arstr[0];
555 #elif defined(__WXGTK__)
556 // If we can't find the current folder, look for the latest version
558 m_strRepository = FindLatestVersion();
560 // Unsupported platform
561 m_strRepositor = wxEmptyString;
565 // If we have set ECOS_REPOSITORY, this overrides whatever we have
567 wxString envVarValue = wxGetenv(wxT("ECOS_REPOSITORY"));
568 if (!envVarValue.IsEmpty())
570 // Note that ECOS_REPOSITORY has the packages (or ecc) folder in the name.
571 // In order to be in the form that is compatible with configtool operation,
572 // it needs to have that stripped off.
573 wxString packagesName = wxFileNameFromPath(envVarValue);
574 if (packagesName == wxT("ecc") || packagesName == wxT("packages"))
575 envVarValue = wxPathOnly(envVarValue);
577 m_strRepository = envVarValue;
582 if (m_userToolsDir.IsEmpty())
583 m_userToolsDir = wxT("/bin");
590 bool ecSettings::SaveConfig()
592 wxConfig config(wxGetApp().GetSettings().GetConfigAppName());
594 config.Write(_("/Files/LastFile"), m_lastFilename);
596 config.Write(_("/Window Status/FrameStatus"), (long) m_frameStatus);
597 config.Write(_("/Window Status/ShowToolBar"), m_showToolBar);
598 config.Write(_("/Window Status/ShowSplashScreen"), m_showSplashScreen);
599 config.Write(_("/Window Status/ShowConflictsWindow"), m_showConflictsWindow);
600 config.Write(_("/Window Status/ShowPropertiesWindow"), m_showPropertiesWindow);
601 config.Write(_("/Window Status/ShowShortDescrWindow"), m_showShortDescrWindow);
602 config.Write(_("/Window Status/ShowMemoryWindow"), m_showMemoryWindow);
603 config.Write(_("/Window Status/ShowOutputWindow"), m_showOutputWindow);
605 config.Write(_("/Window Size/WindowX"), (long) m_frameSize.x);
606 config.Write(_("/Window Size/WindowY"), (long) m_frameSize.y);
607 config.Write(_("/Window Size/WindowWidth"), (long) m_frameSize.width);
608 config.Write(_("/Window Size/WindowHeight"), (long) m_frameSize.height);
609 config.Write(_("/Window Size/TreeSashWidth"), (long) m_treeSashSize.x);
610 config.Write(_("/Window Size/TreeSashHeight"), (long) m_treeSashSize.y);
611 config.Write(_("/Window Size/ConfigPaneWidth"), (long) m_configPaneWidth);
612 config.Write(_("/Window Size/ConflictsWidth"), (long) m_conflictsSashSize.x);
613 config.Write(_("/Window Size/ConflictsHeight"), (long) m_conflictsSashSize.y);
614 config.Write(_("/Window Size/PropertiesWidth"), (long) m_propertiesSashSize.x);
615 config.Write(_("/Window Size/PropertiesHeight"), (long) m_propertiesSashSize.y);
616 config.Write(_("/Window Size/ShortDescrWidth"), (long) m_shortDescrSashSize.x);
617 config.Write(_("/Window Size/ShortDescrHeight"), (long) m_shortDescrSashSize.y);
618 config.Write(_("/Window Size/OutputWidth"), (long) m_outputSashSize.x);
619 config.Write(_("/Window Size/OutputHeight"), (long) m_outputSashSize.y);
620 config.Write(_("/Window Size/MemoryWidth"), (long) m_memorySashSize.x);
621 config.Write(_("/Window Size/MemoryHeight"), (long) m_memorySashSize.y);
623 config.Write(_("/Options/ShowMacroNames"), m_showMacroNames);
624 config.Write(_("/Options/UseCustomViewer"), m_bUseCustomViewer);
625 config.Write(_("/Options/UseExternalBrowser"), m_bUseExternalBrowser);
626 config.Write(_("/Options/UseCustomBrowser"), (long) m_eUseCustomBrowser);
627 config.Write(_("/Options/Browser"), m_strBrowser);
628 config.Write(_("/Options/Viewer"), m_strViewer);
629 config.Write(_("/Options/HexDisplay"), m_bHex);
630 config.Write(_("/Options/UseDefaultFonts"), m_windowSettings.m_useDefaults);
632 config.Write(_("/Rule/Checking"), (long) m_nRuleChecking);
634 config.Write(_("/Paths/UserToolsDir"), m_userToolsDir);
635 config.Write(_("/Paths/BuildToolsDir"), m_buildToolsDir);
637 config.Write(_("/Build/Make Options"), m_strMakeOptions);
639 // Find dialog settings
640 config.Write(_("/Find/Text"), m_findText);
641 config.Write(_("/Find/MatchWholeWord"), m_findMatchWholeWord);
642 config.Write(_("/Find/MatchCase"), m_findMatchCase);
643 config.Write(_("/Find/Direction"), m_findDirection);
644 config.Write(_("/Find/SearchWhat"), m_findSearchWhat);
645 config.Write(_("/Find/DialogX"), (long) m_findDialogPos.x);
646 config.Write(_("/Find/DialogY"), (long) m_findDialogPos.y);
648 // Package dialog settings
649 config.Write(_("/Packages/OmitHardwarePackages"), m_omitHardwarePackages);
650 config.Write(_("/Packages/MatchPackageNamesExactly"), m_matchPackageNamesExactly);
652 // Save current repository to eCos Configuration Tool/Paths/RepositoryDir
653 // UNLESS it was overridden by ECOS_REPOSITORY
655 wxString envVarValue = wxGetenv(wxT("ECOS_REPOSITORY"));
656 if (m_strRepository == envVarValue)
658 // Don't override the value in the local settings
661 config.Write(wxT("/Paths/RepositoryDir"), m_strRepository);
664 // Run tests settings
665 m_runTestsSettings.SaveConfig(config);
668 m_windowSettings.SaveConfig(config);
673 void ecSettings::ShowSettingsDialog(const wxString& page)
676 ecSettingsDialog* dialog = new ecSettingsDialog(wxGetApp().GetTopWindow());
678 dialog->GetNotebook()->SetSelection(ecFindNotebookPage(dialog->GetNotebook(), page));
680 int ret = dialog->ShowModal();
686 #define MAX_PATH 1024
689 // TODO for non-Windows platforms
690 const ecFileName& ecSettings::DefaultExternalBrowser()
693 static bool bFirstTime=TRUE;
695 const ecFileName strFile(ecFileName::GetTempPath()+wxT("index.html"));
697 if(f.Create(strFile, TRUE))
700 bool rc=((int) ::FindExecutable(strFile,wxT("."),m_strDefaultExternalBrowser.GetWriteBuf(MAX_PATH))>32);
701 m_strDefaultExternalBrowser.UngetWriteBuf();
703 m_strDefaultExternalBrowser=wxT("");
705 wxRemoveFile(strFile);
710 return m_strDefaultExternalBrowser;
713 ecFileName ecSettings::m_strDefaultExternalBrowser;
715 // Go looking for potential candidates in SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
716 int ecSettings::GetRepositoryRegistryClues(wxArrayString& arstr, const wxString& pszPrefix)
721 wxConfig config(wxT("Windows"), wxT("Microsoft"), wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE);
722 config.SetPath(wxT("/CurrentVersion/App Paths"));
724 wxString key(wxT(""));
726 bool bMore = config.GetFirstGroup(key, index);
729 if (key.Find(pszPrefix) == 0)
732 //wxString key2(wxString(wxT("/")) + key + wxString(wxT("/Path")));
733 wxString key2(key + wxString(wxT("/Path")));
734 if (config.Read(key2, & value))
739 bMore = config.GetNextGroup(key, index);
741 return arstr.GetCount();
747 // Finds the path of the latest installed eCos
748 wxString ecSettings::FindLatestVersion()
751 wxString ecosRoot(wxT("/opt/ecos"));
756 wxString latestVersion;
761 bool cont = dir.GetFirst(& filename, wxT("ecos-*"), wxDIR_DIRS);
764 wxString ver(filename.Mid(5));
765 if (latestVersion.IsEmpty() || latestVersion.CompareTo(ver) < 0)
768 latestDir = ecosRoot + wxT("/") + filename;
771 cont = dir.GetNext(& filename);
774 if (latestDir.IsEmpty())
775 latestDir = wxGetCwd();
778 wxMessageBox(wxT("FindLatestVersion() is only implemented for Unix."));
779 return wxEmptyString;
783 wxString ecSettings::GetInstallVersionKey ()
788 #define MAX_PATH 1024
791 wxString strKey = wxT("SOFTWARE\\eCos");
792 wxString strVersionKey = wxT("");
793 wxString rc = wxT("");
794 wxChar pszBuffer [MAX_PATH + 1];
797 // get the greatest eCos version subkey
798 if (ERROR_SUCCESS == RegOpenKeyEx (HKEY_LOCAL_MACHINE, strKey, 0L, KEY_READ, &hKey)) {
800 while (ERROR_SUCCESS == RegEnumKey (hKey, dwIndex++, (LPTSTR) pszBuffer, sizeof (pszBuffer))) {
801 if (strVersionKey.CompareTo (pszBuffer) < 0) {
802 strVersionKey = pszBuffer;
807 return strVersionKey;
809 wxMessageBox(wxT("GetInstallVersionKey() is only implemented for Windows."));
810 return wxEmptyString;
816 * Settings relating to running tests
819 IMPLEMENT_DYNAMIC_CLASS(ecRunTestsSettings, wxObject)
821 ecRunTestsSettings::ecRunTestsSettings():
822 m_ep(CeCosTest::ExecutionParameters::RUN),
824 m_nDownloadTimeout(120),
825 m_nTimeoutType(TIMEOUT_AUTOMATIC),
826 m_nDownloadTimeoutType(TIMEOUT_SPECIFIED),
829 m_strPort(wxT("COM1")),
831 m_nLocalTCPIPPort(1),
832 m_nReset(RESET_MANUAL),
836 m_strRemoteHost(wxT("")),
837 m_strResourceHost(wxT("")),
838 m_strLocalTCPIPHost(wxT("")),
843 ecRunTestsSettings::ecRunTestsSettings(const ecRunTestsSettings& settings)
848 void ecRunTestsSettings::Copy(const ecRunTestsSettings& settings)
850 m_nTimeoutType = settings.m_nTimeoutType;
851 m_nDownloadTimeoutType = settings.m_nDownloadTimeoutType;
852 m_bRemote = settings.m_bRemote;
853 m_bSerial = settings.m_bSerial;
854 m_strPort = settings.m_strPort;
855 m_nBaud = settings.m_nBaud;
856 m_nLocalTCPIPPort = settings.m_nLocalTCPIPPort;
857 m_nReset = settings.m_nReset;
858 m_nResourcePort = settings.m_nResourcePort;
859 m_nRemotePort = settings.m_nRemotePort;
860 m_bFarmed = settings.m_bFarmed;
861 m_strTarget = settings.m_strTarget;
862 m_strRemoteHost = settings.m_strRemoteHost;
863 m_strResourceHost = settings.m_strResourceHost;
864 m_strLocalTCPIPHost = settings.m_strLocalTCPIPHost;
865 m_strReset = settings.m_strReset;
868 bool ecRunTestsSettings::LoadConfig(wxConfig& config)
870 config.Read(_("/Run Tests/TimeoutType"), & m_nTimeoutType);
871 config.Read(_("/Run Tests/DownloadTimeoutType"), & m_nDownloadTimeoutType);
872 config.Read(_("/Run Tests/Remote"), (bool*) & m_bRemote);
873 config.Read(_("/Run Tests/Serial"), (bool*) & m_bSerial);
874 config.Read(_("/Run Tests/Port"), & m_strPort);
875 config.Read(_("/Run Tests/Baud"), & m_nBaud);
876 config.Read(_("/Run Tests/LocalTCPIPHost"), & m_strLocalTCPIPHost);
877 config.Read(_("/Run Tests/LocalTCPIPPort"), & m_nLocalTCPIPPort);
878 // Reset type is determined at run-time for standalone configtool
879 // config.Read(_("/Run Tests/ResetType"), & m_nReset);
880 config.Read(_("/Run Tests/ResetString"), & m_strReset);
881 config.Read(_("/Run Tests/ResourceHost"), & m_strResourceHost);
882 config.Read(_("/Run Tests/ResourcePort"), & m_nResourcePort);
883 config.Read(_("/Run Tests/RemoteHost"), & m_strRemoteHost);
884 config.Read(_("/Run Tests/RemotePort"), & m_nRemotePort);
885 config.Read(_("/Run Tests/Farmed"), (bool*) & m_bFarmed);
890 bool ecRunTestsSettings::SaveConfig(wxConfig& config)
892 config.Write(_("/Run Tests/TimeoutType"), (long) m_nTimeoutType);
893 config.Write(_("/Run Tests/DownloadTimeoutType"), (long) m_nDownloadTimeoutType);
894 config.Write(_("/Run Tests/Remote"), m_bRemote);
895 config.Write(_("/Run Tests/Serial"), m_bSerial);
896 config.Write(_("/Run Tests/Port"), m_strPort);
897 config.Write(_("/Run Tests/Baud"), (long) m_nBaud);
898 config.Write(_("/Run Tests/LocalTCPIPHost"), m_strLocalTCPIPHost);
899 config.Write(_("/Run Tests/LocalTCPIPPort"), (long) m_nLocalTCPIPPort);
900 config.Write(_("/Run Tests/ResetType"), (long) m_nReset);
901 config.Write(_("/Run Tests/ResetString"), m_strReset);
902 config.Write(_("/Run Tests/ResourceHost"), m_strResourceHost);
903 config.Write(_("/Run Tests/ResourcePort"), (long) m_nResourcePort);
904 config.Write(_("/Run Tests/RemoteHost"), m_strRemoteHost);
905 config.Write(_("/Run Tests/RemotePort"), (long) m_nRemotePort);
906 config.Write(_("/Run Tests/Farmed"), m_bFarmed);