NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class represents a simple browser for the package repository with an install and uninstall capability. More...
#include <pluginrepodialog.hpp>
Public Member Functions | |
PackageRepoBrowser (wxWindow *parent, NumeReTerminal *terminal, IconManager *icons) | |
PackageRepositoryBrowser constructor. Starts the file loading task. More... | |
void | DetectInstalledPackages () |
Detect installed packages by loading the list of installed and comparing them to the loaded contents from the repository. More... | |
Public Member Functions inherited from ViewerFrame | |
ViewerFrame (wxWindow *parent, const wxString &title) | |
void | OnKeyDown (wxKeyEvent &event) |
This event handler closes the frame, if the user presses ESC. More... | |
void | OnFocus (wxFocusEvent &event) |
This event handler passes the keyboard focus down to the first child in the window list, if the frame gets keyboard focus. More... | |
void | OnEnter (wxMouseEvent &event) |
This event handler get the keyboard focus, if the user enters with the mouse. More... | |
void | OnClose (wxCloseEvent &event) |
This event handler informs all child windows that this frame will now close. It furthermore automatically unregisters itself in the opened window list. More... | |
DECLARE_EVENT_TABLE () | |
Private Types | |
enum | ThreadTask { TASK_NONE , TASK_LOADREPO , TASK_LOADFILES } |
Private Member Functions | |
void | StartThread (ThreadTask task) |
Start a new thread with the passed task. More... | |
virtual wxThread::ExitCode | Entry () |
Secondary thread worker function. More... | |
void | OnThreadUpdate (wxThreadEvent &event) |
Thread update event handler. Will trigger the actual installation, if the files were loaded successfully. More... | |
void | OnClose (wxCloseEvent &event) |
OnClose event handler. Will terminate the thread, if it's running. More... | |
std::vector< std::string > | getRepoList (const std::string &sRepoUrl) |
This member function fetches the repository main page as HTML and extracts the list of item links in it. These may be files and folders. More... | |
void | populatePackageList (const std::string &sUrl) |
Gets an URL and retrieve its counterpart from the repository. If the link does not reference a file but a folder, a recursion is started to resolve the contents of the folder. More... | |
void | OnInstall (wxCommandEvent &event) |
Button event handler linked to the "install/update" button. More... | |
void | OnUninstall (wxCommandEvent &event) |
Button event handler linked to the "uninstall" button. More... | |
void | OnItemSelect (wxTreeEvent &event) |
Item select event handler to enable or disable the buttons depending on the state of the package or whether the actual package headline was selected. More... | |
std::string | createSalt () |
Simple function to make the URL more unique to avoid server caching (which might resolve in a very delated update of the package list as the server will respond with the already cached contents rather than the current file versions). More... | |
bool | isInstallable (const wxTreeItemId &item) |
Returns, whether the current item is an installable package (not already installed). More... | |
bool | isUpdateable (const wxTreeItemId &item) |
Returns, whether the current item is an updateable package (already installed but newer version available). More... | |
std::string | getEntry (const wxTreeItemId &item, const std::string &sIdentifier) |
Returns the value of the selected identifier or an empty string, if the identifier cannot be found. More... | |
std::string | getUrl (const wxTreeItemId &item) |
Return the package URL. More... | |
std::string | getDependencies (const wxTreeItemId &item) |
Return the package dependencies. More... | |
wxTreeItemId | findPackage (const std::string &sPackageFileName) |
Find a package entry from its file name. The returned ID must be checked for validness via wxTreeItemId::IsOk() to detect, if the package has been found. More... | |
void | resolveDependencies (std::string sDepList, std::vector< std::string > &vDeps) |
This member function resolves the dependencies of a selected file using a recursion. Only files, which are updateable or installable are returned. Dependencies, which are not part of the repository, are ignored. More... | |
bool | getFileFromRepo (const std::string &sUrl) |
Returns the contents of the passed URL as a file and writes it to its counterpart in the <SCRIPTPATH>/packages directory. More... | |
Private Attributes | |
NumeReTerminal * | m_terminal |
IconManager * | m_icons |
std::string | m_scriptPath |
std::string | m_fileNameToInstall |
wxcode::wxTreeListCtrl * | m_listCtrl |
wxButton * | m_installButton |
wxButton * | m_uninstallButton |
wxGauge * | m_progress |
wxStaticText * | m_statusText |
ThreadTask | m_task |
bool | m_filesLoaded |
std::vector< std::string > | m_vUrls |
This class represents a simple browser for the package repository with an install and uninstall capability.
Definition at line 37 of file pluginrepodialog.hpp.
|
private |
Enumerator | |
---|---|
TASK_NONE | |
TASK_LOADREPO | |
TASK_LOADFILES |
Definition at line 53 of file pluginrepodialog.hpp.
PackageRepoBrowser::PackageRepoBrowser | ( | wxWindow * | parent, |
NumeReTerminal * | terminal, | ||
IconManager * | icons | ||
) |
PackageRepositoryBrowser constructor. Starts the file loading task.
parent | wxWindow* |
terminal | NumeReTerminal* |
icons | IconManager* |
Definition at line 316 of file pluginrepodialog.cpp.
References GroupPanel::AddStaticText(), GroupPanel::CreateButton(), GroupPanel::CreateGauge(), GroupPanel::createGroup(), GroupPanel::CreateWxcTreeListCtrl(), IconManager::GetImageList(), GroupPanel::getMainSizer(), NumeReTerminal::getPathSettings(), ID_REPODLG_INSTALL, ID_REPODLG_UNINSTALL, m_filesLoaded, m_icons, m_installButton, m_listCtrl, m_progress, m_scriptPath, m_statusText, m_terminal, m_uninstallButton, SCRIPTPATH, StartThread(), TASK_LOADREPO, WINDOWHEIGHT, and WINDOWWIDTH.
|
private |
Simple function to make the URL more unique to avoid server caching (which might resolve in a very delated update of the package list as the server will respond with the already cached contents rather than the current file versions).
Definition at line 974 of file pluginrepodialog.cpp.
Referenced by getRepoList(), and populatePackageList().
void PackageRepoBrowser::DetectInstalledPackages | ( | ) |
Detect installed packages by loading the list of installed and comparing them to the loaded contents from the repository.
Definition at line 360 of file pluginrepodialog.cpp.
References CHANGELOGLENGTH, getEntry(), IconManager::GetIconIndex(), NumeReTerminal::getInstalledPackages(), INSTALLEDCOLOUR, INSTALLEDCOLUMN, LOCALCOLOUR, m_icons, m_listCtrl, m_progress, m_statusText, m_terminal, NEWERCOLOUR, OUTDATEDVERSIONCOLOUR, PACKAGCOLUMN, replaceAll(), REPOCOLUMN, sVersion, UPDATECOLOUR, and versionToInt().
Referenced by Entry().
|
privatevirtual |
Secondary thread worker function.
Definition at line 561 of file pluginrepodialog.cpp.
References DetectInstalledPackages(), getFileFromRepo(), getRepoList(), m_filesLoaded, m_listCtrl, m_progress, m_statusText, m_task, m_vUrls, populatePackageList(), REPO_LOCATION, TASK_LOADFILES, TASK_LOADREPO, TASK_NONE, and url::Error::what().
|
private |
Find a package entry from its file name. The returned ID must be checked for validness via wxTreeItemId::IsOk() to detect, if the package has been found.
sPackageFileName | const std::string& |
Definition at line 1075 of file pluginrepodialog.cpp.
References getUrl(), and m_listCtrl.
Referenced by OnInstall(), and resolveDependencies().
|
private |
Return the package dependencies.
item | const wxTreeItemId& |
Definition at line 1059 of file pluginrepodialog.cpp.
References DEPENDENCIES, and getEntry().
Referenced by OnInstall(), and resolveDependencies().
|
private |
Returns the value of the selected identifier or an empty string, if the identifier cannot be found.
item | const wxTreeItemId& |
sIdentifier | const std::string& |
Definition at line 1019 of file pluginrepodialog.cpp.
References m_listCtrl, and REPOCOLUMN.
Referenced by DetectInstalledPackages(), getDependencies(), and getUrl().
|
private |
Returns the contents of the passed URL as a file and writes it to its counterpart in the <SCRIPTPATH>/packages directory.
sUrl | const std::string& |
Definition at line 1132 of file pluginrepodialog.cpp.
References url::get(), m_scriptPath, and date::detail::trunc().
Referenced by Entry().
|
private |
This member function fetches the repository main page as HTML and extracts the list of item links in it. These may be files and folders.
sRepoUrl | const std::string& |
Definition at line 701 of file pluginrepodialog.cpp.
References createSalt(), and url::get().
Referenced by Entry(), and populatePackageList().
|
private |
Return the package URL.
item | const wxTreeItemId& |
Definition at line 1046 of file pluginrepodialog.cpp.
References getEntry(), and REPO_URL.
Referenced by findPackage(), and OnInstall().
|
private |
Returns, whether the current item is an installable package (not already installed).
item | const wxTreeItemId& |
Definition at line 988 of file pluginrepodialog.cpp.
References m_listCtrl.
Referenced by OnItemSelect(), and resolveDependencies().
|
private |
Returns, whether the current item is an updateable package (already installed but newer version available).
item | const wxTreeItemId& |
Definition at line 1003 of file pluginrepodialog.cpp.
References m_listCtrl, and UPDATECOLOUR.
Referenced by OnItemSelect(), and resolveDependencies().
|
private |
OnClose event handler. Will terminate the thread, if it's running.
event | wxCloseEvent& |
Definition at line 679 of file pluginrepodialog.cpp.
|
private |
Button event handler linked to the "install/update" button.
event | wxCommandEvent& |
Definition at line 871 of file pluginrepodialog.cpp.
References findPackage(), getDependencies(), getUrl(), INSTALLEDCOLOUR, INSTALLEDCOLUMN, m_fileNameToInstall, m_filesLoaded, m_installButton, m_listCtrl, m_vUrls, resolveDependencies(), StartThread(), and TASK_LOADFILES.
|
private |
Item select event handler to enable or disable the buttons depending on the state of the package or whether the actual package headline was selected.
event | wxTreeEvent& |
Definition at line 943 of file pluginrepodialog.cpp.
References isInstallable(), isUpdateable(), m_installButton, m_listCtrl, m_task, m_uninstallButton, OUTDATEDVERSIONCOLOUR, and TASK_NONE.
|
private |
Thread update event handler. Will trigger the actual installation, if the files were loaded successfully.
event | wxThreadEvent& |
Definition at line 645 of file pluginrepodialog.cpp.
References INSTALLEDCOLUMN, m_fileNameToInstall, m_filesLoaded, m_listCtrl, m_progress, m_terminal, and NumeReTerminal::pass_command().
|
private |
Button event handler linked to the "uninstall" button.
event | wxCommandEvent& |
Definition at line 917 of file pluginrepodialog.cpp.
References INSTALLEDCOLUMN, m_installButton, m_listCtrl, m_terminal, m_uninstallButton, and NumeReTerminal::pass_command().
|
private |
Gets an URL and retrieve its counterpart from the repository. If the link does not reference a file but a folder, a recursion is started to resolve the contents of the folder.
sUrl | const std::string& |
Definition at line 740 of file pluginrepodialog.cpp.
References CHANGELOGLENGTH, createSalt(), DEPENDENCIES, url::get(), IconManager::GetIconIndex(), getRepoList(), getTagValue(), m_icons, m_listCtrl, PACKAGCOLUMN, populatePackageList(), replaceAll(), REPO_URL, and REPOCOLUMN.
Referenced by Entry(), and populatePackageList().
|
private |
This member function resolves the dependencies of a selected file using a recursion. Only files, which are updateable or installable are returned. Dependencies, which are not part of the repository, are ignored.
sDepList | std::string |
vDeps | std::vector<std::string>& |
Definition at line 1107 of file pluginrepodialog.cpp.
References findPackage(), getDependencies(), getNextArgument(), isInstallable(), isUpdateable(), and resolveDependencies().
Referenced by OnInstall(), and resolveDependencies().
|
private |
Start a new thread with the passed task.
task | ThreadTask |
Definition at line 540 of file pluginrepodialog.cpp.
References m_task.
Referenced by OnInstall(), and PackageRepoBrowser().
|
private |
Definition at line 43 of file pluginrepodialog.hpp.
Referenced by OnInstall(), and OnThreadUpdate().
|
private |
Definition at line 61 of file pluginrepodialog.hpp.
Referenced by Entry(), OnInstall(), OnThreadUpdate(), and PackageRepoBrowser().
|
private |
Definition at line 41 of file pluginrepodialog.hpp.
Referenced by DetectInstalledPackages(), PackageRepoBrowser(), and populatePackageList().
|
private |
Definition at line 46 of file pluginrepodialog.hpp.
Referenced by OnInstall(), OnItemSelect(), OnUninstall(), and PackageRepoBrowser().
|
private |
Definition at line 45 of file pluginrepodialog.hpp.
Referenced by DetectInstalledPackages(), Entry(), findPackage(), getEntry(), isInstallable(), isUpdateable(), OnInstall(), OnItemSelect(), OnThreadUpdate(), OnUninstall(), PackageRepoBrowser(), and populatePackageList().
|
private |
Definition at line 50 of file pluginrepodialog.hpp.
Referenced by DetectInstalledPackages(), Entry(), OnThreadUpdate(), and PackageRepoBrowser().
|
private |
Definition at line 42 of file pluginrepodialog.hpp.
Referenced by getFileFromRepo(), and PackageRepoBrowser().
|
private |
Definition at line 51 of file pluginrepodialog.hpp.
Referenced by DetectInstalledPackages(), Entry(), and PackageRepoBrowser().
|
private |
Definition at line 60 of file pluginrepodialog.hpp.
Referenced by Entry(), OnClose(), OnItemSelect(), and StartThread().
|
private |
Definition at line 40 of file pluginrepodialog.hpp.
Referenced by DetectInstalledPackages(), OnThreadUpdate(), OnUninstall(), and PackageRepoBrowser().
|
private |
Definition at line 47 of file pluginrepodialog.hpp.
Referenced by OnItemSelect(), OnUninstall(), and PackageRepoBrowser().
|
private |
Definition at line 62 of file pluginrepodialog.hpp.
Referenced by Entry(), and OnInstall().