NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
pluginrepodialog.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2021 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef PLUGINREPODIALOG_HPP
20#define PLUGINREPODIALOG_HPP
21
22#define PACKAGE_REPO_BROWSER_TITLE "NumeRe: Package Manager"
23
24#include <wx/wx.h>
25#include <wx/thread.h>
26#include "../controls/treelistctrl.h"
27#include "../compositions/viewerframe.hpp"
28#include "../terminal/terminal.hpp"
29#include <string>
30#include <vector>
31
37class PackageRepoBrowser : public ViewerFrame, public wxThreadHelper
38{
39 private:
42 std::string m_scriptPath;
44
45 wxcode::wxTreeListCtrl* m_listCtrl;
46 wxButton* m_installButton;
48
49 // Threading part
50 wxGauge* m_progress;
51 wxStaticText* m_statusText;
52
54 {
58 };
59
62 std::vector<std::string> m_vUrls;
63
64 void StartThread(ThreadTask task);
65 virtual wxThread::ExitCode Entry();
66 void OnThreadUpdate(wxThreadEvent& event);
67 void OnClose(wxCloseEvent& event);
68 // End threading part
69
70 std::vector<std::string> getRepoList(const std::string& sRepoUrl);
71 void populatePackageList(const std::string& sUrl);
72
73 void OnInstall(wxCommandEvent& event);
74 void OnUninstall(wxCommandEvent& event);
75 void OnItemSelect(wxTreeEvent& event);
76
77 std::string createSalt();
78
79 bool isInstallable(const wxTreeItemId& item);
80 bool isUpdateable(const wxTreeItemId& item);
81 std::string getEntry(const wxTreeItemId& item, const std::string& sIdentifier);
82 std::string getUrl(const wxTreeItemId& item);
83 std::string getDependencies(const wxTreeItemId& item);
84 wxTreeItemId findPackage(const std::string& sPackageFileName);
85 void resolveDependencies(std::string sDepList, std::vector<std::string>& vDeps);
86
87 bool getFileFromRepo(const std::string& sUrl);
88
89 public:
90 PackageRepoBrowser(wxWindow* parent, NumeReTerminal* terminal, IconManager* icons);
92
94};
95
96
97#endif // PLUGINREPODIALOG_HPP
98
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
Definition: terminal.hpp:46
This class represents a simple browser for the package repository with an install and uninstall capab...
std::string m_fileNameToInstall
std::string getDependencies(const wxTreeItemId &item)
Return the package dependencies.
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>...
std::string createSalt()
Simple function to make the URL more unique to avoid server caching (which might resolve in a very de...
std::string getUrl(const wxTreeItemId &item)
Return the package URL.
virtual wxThread::ExitCode Entry()
Secondary thread worker function.
wxButton * m_uninstallButton
void resolveDependencies(std::string sDepList, std::vector< std::string > &vDeps)
This member function resolves the dependencies of a selected file using a recursion....
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.
wxcode::wxTreeListCtrl * m_listCtrl
bool isUpdateable(const wxTreeItemId &item)
Returns, whether the current item is an updateable package (already installed but newer version avail...
NumeReTerminal * m_terminal
wxStaticText * m_statusText
bool isInstallable(const wxTreeItemId &item)
Returns, whether the current item is an installable package (not already installed).
void OnClose(wxCloseEvent &event)
OnClose event handler. Will terminate the thread, if it's running.
void StartThread(ThreadTask task)
Start a new thread with the passed task.
void OnInstall(wxCommandEvent &event)
Button event handler linked to the "install/update" button.
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 ...
void OnUninstall(wxCommandEvent &event)
Button event handler linked to the "uninstall" button.
PackageRepoBrowser(wxWindow *parent, NumeReTerminal *terminal, IconManager *icons)
PackageRepositoryBrowser constructor. Starts the file loading task.
void OnItemSelect(wxTreeEvent &event)
Item select event handler to enable or disable the buttons depending on the state of the package or w...
wxTreeItemId findPackage(const std::string &sPackageFileName)
Find a package entry from its file name. The returned ID must be checked for validness via wxTreeItem...
std::vector< std::string > m_vUrls
void DetectInstalledPackages()
Detect installed packages by loading the list of installed and comparing them to the loaded contents ...
void populatePackageList(const std::string &sUrl)
Gets an URL and retrieve its counterpart from the repository. If the link does not reference a file b...
void OnThreadUpdate(wxThreadEvent &event)
Thread update event handler. Will trigger the actual installation, if the files were loaded successfu...
This class generalizes a set of basic floating window functionalities like being closable by pressing...
Definition: viewerframe.hpp:31