mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
PACKAGE_INSTALL now stands for both installation and upgrades
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@795 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+28
-26
@@ -38,6 +38,7 @@ IMPLEMENT_REFLECTION(Installer) {
|
|||||||
REFLECT(packages);
|
REFLECT(packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// ----------------------------------------------------------------------------- : Installing
|
// ----------------------------------------------------------------------------- : Installing
|
||||||
|
|
||||||
void Installer::installFrom(const String& filename, bool message_on_success, bool local) {
|
void Installer::installFrom(const String& filename, bool message_on_success, bool local) {
|
||||||
@@ -134,12 +135,12 @@ void Installer::install(bool local, bool check_dependencies) {
|
|||||||
}
|
}
|
||||||
os.Write(*is);
|
os.Write(*is);
|
||||||
}
|
}
|
||||||
*/
|
* /
|
||||||
}
|
}
|
||||||
|
|
||||||
void Installer::install(const String& package) {
|
void Installer::install(const String& package) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Creating
|
// ----------------------------------------------------------------------------- : Creating
|
||||||
|
|
||||||
@@ -191,10 +192,6 @@ PackageDescription::PackageDescription(const Packaged& package)
|
|||||||
, dependencies(package.dependencies)
|
, dependencies(package.dependencies)
|
||||||
{
|
{
|
||||||
// name
|
// name
|
||||||
if (short_name.empty()) {
|
|
||||||
if (!full_name.empty()) short_name = full_name;
|
|
||||||
else short_name = package.name();
|
|
||||||
}
|
|
||||||
if (full_name.empty()) full_name = short_name;
|
if (full_name.empty()) full_name = short_name;
|
||||||
// installer group
|
// installer group
|
||||||
if (installer_group.empty()) {
|
if (installer_group.empty()) {
|
||||||
@@ -238,17 +235,26 @@ DownloadableInstaller::~DownloadableInstaller() {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Installable package
|
// ----------------------------------------------------------------------------- : Installable package
|
||||||
|
|
||||||
InstallablePackage::InstallablePackage() : action(PACKAGE_NOTHING) {}
|
|
||||||
InstallablePackage::InstallablePackage(const PackageVersionP& installed, const PackageDescriptionP& description)
|
InstallablePackage::InstallablePackage(const PackageVersionP& installed, const PackageDescriptionP& description)
|
||||||
: installed(installed)
|
: installed(installed)
|
||||||
, description(description)
|
, description(description)
|
||||||
, action(PACKAGE_NOTHING)
|
, action(PACKAGE_NOTHING)
|
||||||
|
, status(PACKAGE_INSTALLED)
|
||||||
|
{}
|
||||||
|
InstallablePackage::InstallablePackage(const PackageDescriptionP& description , const DownloadableInstallerP& installer)
|
||||||
|
: description(description)
|
||||||
|
, installer(installer)
|
||||||
|
, action(PACKAGE_NOTHING)
|
||||||
|
, status(PACKAGE_INSTALLABLE)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void InstallablePackage::determineStatus() {
|
void InstallablePackage::determineStatus() {
|
||||||
status = PACKAGE_NOT_INSTALLED;
|
status = PACKAGE_NOT_INSTALLED;
|
||||||
if (installer) {
|
if (installer) {
|
||||||
status = (PackageStatus)(status | PACKAGE_INSTALLABLE);
|
status = (PackageStatus)(status | PACKAGE_INSTALLER);
|
||||||
|
if (!installed || installed->version < description->version) {
|
||||||
|
status = (PackageStatus)(status | PACKAGE_INSTALLABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (installed) {
|
if (installed) {
|
||||||
status = (PackageStatus)(status | PACKAGE_INSTALLED);
|
status = (PackageStatus)(status | PACKAGE_INSTALLED);
|
||||||
@@ -256,19 +262,19 @@ void InstallablePackage::determineStatus() {
|
|||||||
status = (PackageStatus)(status | PACKAGE_REMOVABLE);
|
status = (PackageStatus)(status | PACKAGE_REMOVABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (installed && installed->version < description->version) {
|
|
||||||
status = (PackageStatus)(status | PACKAGE_UPDATES);
|
|
||||||
}
|
|
||||||
if (installed && (installed->status & PackageVersion::STATUS_MODIFIED)) {
|
if (installed && (installed->status & PackageVersion::STATUS_MODIFIED)) {
|
||||||
status = (PackageStatus)(status | PACKAGE_MODIFIED);
|
status = (PackageStatus)(status | PACKAGE_MODIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InstallablePackage::willBeInstalled() const {
|
||||||
|
return (action & PACKAGE_INSTALL) ||
|
||||||
|
((status & PACKAGE_INSTALLED) && !(action & PACKAGE_REMOVE));
|
||||||
|
}
|
||||||
bool InstallablePackage::can(PackageAction act) const {
|
bool InstallablePackage::can(PackageAction act) const {
|
||||||
if (act & PACKAGE_INSTALL) return (status & PACKAGE_INSTALLABLE) == PACKAGE_INSTALLABLE;
|
if (act & PACKAGE_INSTALL) return flag(status, PACKAGE_INSTALLABLE);
|
||||||
if (act & PACKAGE_UPGRADE) return (status & PACKAGE_UPDATES) == PACKAGE_UPDATES;
|
|
||||||
if (act & PACKAGE_REMOVE) {
|
if (act & PACKAGE_REMOVE) {
|
||||||
bool ok = (status & PACKAGE_REMOVABLE) == PACKAGE_REMOVABLE;
|
bool ok = flag(status, PACKAGE_REMOVABLE);
|
||||||
if (!(act & PACKAGE_GLOBAL) && installed && PackageVersion::STATUS_GLOBAL) {
|
if (!(act & PACKAGE_GLOBAL) && installed && PackageVersion::STATUS_GLOBAL) {
|
||||||
// package installed globally can't be removed locally
|
// package installed globally can't be removed locally
|
||||||
return false;
|
return false;
|
||||||
@@ -322,17 +328,14 @@ void merge(InstallablePackages& list1, const InstallablePackages& list2) {
|
|||||||
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) {
|
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) {
|
||||||
InstallablePackages ips;
|
InstallablePackages ips;
|
||||||
FOR_EACH(p, installer->packages) {
|
FOR_EACH(p, installer->packages) {
|
||||||
InstallablePackageP ip(new InstallablePackage);
|
ips.push_back(new_intrusive2<InstallablePackage>(p,installer));
|
||||||
ip->description = p;
|
|
||||||
ip->installer = installer;
|
|
||||||
ips.push_back(ip);
|
|
||||||
}
|
}
|
||||||
sort(ips);
|
sort(ips);
|
||||||
merge(installed, ips);
|
merge(installed, ips);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool add_package_dependency(InstallablePackages& packages, const PackageDependency& dep, int where, bool set) {
|
bool add_package_dependency(InstallablePackages& packages, const PackageDependency& dep, PackageAction where, bool set) {
|
||||||
FOR_EACH(p, packages) {
|
FOR_EACH(p, packages) {
|
||||||
if (p->description->name == dep.package) {
|
if (p->description->name == dep.package) {
|
||||||
// Some package depends on this package, so install it if needed
|
// Some package depends on this package, so install it if needed
|
||||||
@@ -340,7 +343,7 @@ bool add_package_dependency(InstallablePackages& packages, const PackageDependen
|
|||||||
// if !set then instead the dependency is no longer needed because we are not installing the package
|
// if !set then instead the dependency is no longer needed because we are not installing the package
|
||||||
if (!p->installed || p->installed->version < dep.version) {
|
if (!p->installed || p->installed->version < dep.version) {
|
||||||
bool change = false;
|
bool change = false;
|
||||||
if (p->action & (PACKAGE_INSTALL | PACKAGE_UPGRADE)) {
|
if (p->action & PACKAGE_INSTALL) {
|
||||||
// this package is already scheduled for installation
|
// this package is already scheduled for installation
|
||||||
if (p->automatic) {
|
if (p->automatic) {
|
||||||
// we are already automatically depending on this package
|
// we are already automatically depending on this package
|
||||||
@@ -352,8 +355,7 @@ bool add_package_dependency(InstallablePackages& packages, const PackageDependen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (set) {
|
} else if (set) {
|
||||||
p->action = (PackageAction)(where |
|
p->action = where | PACKAGE_INSTALL;
|
||||||
(p->installed ? PACKAGE_UPGRADE : PACKAGE_INSTALL));
|
|
||||||
p->automatic = 1;
|
p->automatic = 1;
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
@@ -370,7 +372,7 @@ bool add_package_dependency(InstallablePackages& packages, const PackageDependen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_package_dependency(InstallablePackages& packages, const PackageDescription& ver, int where, bool set) {
|
void remove_package_dependency(InstallablePackages& packages, const PackageDescription& ver, PackageAction where, bool set) {
|
||||||
FOR_EACH(p, packages) {
|
FOR_EACH(p, packages) {
|
||||||
FOR_EACH(dep, p->description->dependencies) {
|
FOR_EACH(dep, p->description->dependencies) {
|
||||||
if (dep->package == ver.name) {
|
if (dep->package == ver.name) {
|
||||||
@@ -385,7 +387,7 @@ void remove_package_dependency(InstallablePackages& packages, const PackageDescr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (set) {
|
} else if (set) {
|
||||||
p->action = (PackageAction)(where | PACKAGE_REMOVE);
|
p->action = where | PACKAGE_REMOVE;
|
||||||
p->automatic = 1;
|
p->automatic = 1;
|
||||||
remove_package_dependency(packages, *p->description, where, set);
|
remove_package_dependency(packages, *p->description, where, set);
|
||||||
}
|
}
|
||||||
@@ -396,8 +398,8 @@ void remove_package_dependency(InstallablePackages& packages, const PackageDescr
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool set_package_action_unsafe(InstallablePackages& packages, const InstallablePackageP& package, PackageAction action) {
|
bool set_package_action_unsafe(InstallablePackages& packages, const InstallablePackageP& package, PackageAction action) {
|
||||||
int where = action & PACKAGE_WHERE;
|
PackageAction where = (PackageAction)(action & PACKAGE_WHERE);
|
||||||
if ((action & PACKAGE_INSTALL) || (action & PACKAGE_UPGRADE) || ((action & PACKAGE_NOTHING) && (package->status & PACKAGE_INSTALLED))) {
|
if ((action & PACKAGE_INSTALL) || ((action & PACKAGE_NOTHING) && (package->status & PACKAGE_INSTALLED))) {
|
||||||
// need the package
|
// need the package
|
||||||
package->automatic = 0;
|
package->automatic = 0;
|
||||||
package->action = action;
|
package->action = action;
|
||||||
|
|||||||
+15
-7
@@ -26,13 +26,15 @@ class Installer : public Packaged {
|
|||||||
String prefered_filename; ///< What filename should be used (by default)
|
String prefered_filename; ///< What filename should be used (by default)
|
||||||
vector<PackageDescriptionP> packages; ///< Packages to install
|
vector<PackageDescriptionP> packages; ///< Packages to install
|
||||||
|
|
||||||
|
/*
|
||||||
/// Load an installer from a file, and run it
|
/// Load an installer from a file, and run it
|
||||||
static void installFrom(const String& filename, bool message_on_success, bool local);
|
static void installFrom(const String& filename, bool message_on_success, bool local);
|
||||||
/// Install all the packages
|
/// Install all the packages
|
||||||
void install(bool local, bool check_dependencies = true);
|
void install(bool local, bool check_dependencies = true);
|
||||||
/// Install a specific package
|
/// Install a specific package
|
||||||
void install(const String& package);
|
void install(const String& package);
|
||||||
|
*/
|
||||||
|
|
||||||
/// Add a package to the installer (if it is not already added).
|
/// Add a package to the installer (if it is not already added).
|
||||||
/** If the package is named *.mse-installer uses it as the filename instead */
|
/** If the package is named *.mse-installer uses it as the filename instead */
|
||||||
void addPackage(const String& package);
|
void addPackage(const String& package);
|
||||||
@@ -99,7 +101,8 @@ enum PackageStatus
|
|||||||
{ PACKAGE_NOT_INSTALLED = 0x0000
|
{ PACKAGE_NOT_INSTALLED = 0x0000
|
||||||
, PACKAGE_INSTALLED = 0x0001
|
, PACKAGE_INSTALLED = 0x0001
|
||||||
, PACKAGE_REMOVABLE = 0x0002
|
, PACKAGE_REMOVABLE = 0x0002
|
||||||
, PACKAGE_INSTALLABLE = 0x0010
|
, PACKAGE_INSTALLER = 0x0010 ///< Package can be installed (there is an installer)
|
||||||
|
, PACKAGE_INSTALLABLE = 0x0110 ///< Package can be installed (it makes sense to do so)
|
||||||
, PACKAGE_UPDATES = 0x0111 ///< Remote updates available
|
, PACKAGE_UPDATES = 0x0111 ///< Remote updates available
|
||||||
, PACKAGE_MODIFIED = 0x1001 ///< Local changes made
|
, PACKAGE_MODIFIED = 0x1001 ///< Local changes made
|
||||||
, PACKAGE_CONFLICTS = PACKAGE_UPDATES | PACKAGE_MODIFIED
|
, PACKAGE_CONFLICTS = PACKAGE_UPDATES | PACKAGE_MODIFIED
|
||||||
@@ -108,18 +111,21 @@ enum PackageStatus
|
|||||||
/// (un)install a package?
|
/// (un)install a package?
|
||||||
enum PackageAction
|
enum PackageAction
|
||||||
{ PACKAGE_NOTHING = 0x001 ///< Don't change anything
|
{ PACKAGE_NOTHING = 0x001 ///< Don't change anything
|
||||||
, PACKAGE_INSTALL = 0x002 ///< Install the package
|
, PACKAGE_INSTALL = 0x002 ///< Install or upgrade the package
|
||||||
, PACKAGE_UPGRADE = 0x004 ///< Upgrade the package
|
, PACKAGE_REMOVE = 0x004 ///< Remove the package (if it was installed)
|
||||||
, PACKAGE_REMOVE = 0x008 ///< Remove the package
|
|
||||||
, PACKAGE_LOCAL = 0x010 ///< In the local package directory
|
, PACKAGE_LOCAL = 0x010 ///< In the local package directory
|
||||||
, PACKAGE_GLOBAL = 0x020 ///< In the global package directory
|
, PACKAGE_GLOBAL = 0x020 ///< In the global package directory
|
||||||
, PACKAGE_WHERE = PACKAGE_LOCAL | PACKAGE_GLOBAL
|
, PACKAGE_WHERE = PACKAGE_LOCAL | PACKAGE_GLOBAL
|
||||||
};
|
};
|
||||||
|
// bit twidling
|
||||||
|
inline PackageAction operator | (PackageAction a, PackageAction b) { return (PackageAction)((int)a | (int) b); }
|
||||||
|
inline bool flag(int flags, int flag) { return (flags & flag) == flag; }
|
||||||
|
|
||||||
/// A package that can be installed, or is already installed
|
/// A package that can be installed, or is already installed
|
||||||
class InstallablePackage : public IntrusivePtrVirtualBase {
|
class InstallablePackage : public IntrusivePtrVirtualBase {
|
||||||
public:
|
public:
|
||||||
InstallablePackage();
|
//InstallablePackage();
|
||||||
|
InstallablePackage(const PackageDescriptionP&, const DownloadableInstallerP&);
|
||||||
InstallablePackage(const PackageVersionP&, const PackageDescriptionP&);
|
InstallablePackage(const PackageVersionP&, const PackageDescriptionP&);
|
||||||
|
|
||||||
PackageVersionP installed; ///< The information of the installed package (if installed)
|
PackageVersionP installed; ///< The information of the installed package (if installed)
|
||||||
@@ -130,12 +136,14 @@ class InstallablePackage : public IntrusivePtrVirtualBase {
|
|||||||
|
|
||||||
int automatic; ///< Install/upgrade/remove automaticly to satisfy this many packages
|
int automatic; ///< Install/upgrade/remove automaticly to satisfy this many packages
|
||||||
|
|
||||||
|
|
||||||
PackageAction old_action;
|
PackageAction old_action;
|
||||||
int old_automatic;
|
int old_automatic;
|
||||||
|
|
||||||
void determineStatus();
|
void determineStatus();
|
||||||
|
|
||||||
|
/// After the action, will the package be installed?
|
||||||
|
bool willBeInstalled() const;
|
||||||
|
|
||||||
/// Is the action possible?
|
/// Is the action possible?
|
||||||
bool can(PackageAction act) const;
|
bool can(PackageAction act) const;
|
||||||
/// Is the action currently selected?
|
/// Is the action currently selected?
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ DECLARE_TYPEOF(map<String COMMA String>);
|
|||||||
DECLARE_TYPEOF(map<String COMMA KeyValidator>);
|
DECLARE_TYPEOF(map<String COMMA KeyValidator>);
|
||||||
|
|
||||||
void Locale::validate(Version ver) {
|
void Locale::validate(Version ver) {
|
||||||
|
Packaged::validate(ver);
|
||||||
// load locale validator
|
// load locale validator
|
||||||
LocaleValidator v;
|
LocaleValidator v;
|
||||||
Reader r(load_resource_text(_("expected_locale_keys")), nullptr, _("expected_locale_keys"));
|
Reader r(load_resource_text(_("expected_locale_keys")), nullptr, _("expected_locale_keys"));
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ void fix_value_207(const ValueP& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Set::validate(Version file_app_version) {
|
void Set::validate(Version file_app_version) {
|
||||||
|
Packaged::validate(file_app_version);
|
||||||
// are the
|
// are the
|
||||||
if (!game) {
|
if (!game) {
|
||||||
throw Error(_ERROR_("no game specified for the set"));
|
throw Error(_ERROR_("no game specified for the set"));
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ String StyleSheet::stylesheetName() const {
|
|||||||
String StyleSheet::typeNameStatic() { return _("style"); }
|
String StyleSheet::typeNameStatic() { return _("style"); }
|
||||||
String StyleSheet::typeName() const { return _("style"); }
|
String StyleSheet::typeName() const { return _("style"); }
|
||||||
|
|
||||||
void StyleSheet::validate(Version) {
|
void StyleSheet::validate(Version ver) {
|
||||||
|
Packaged::validate(ver);
|
||||||
if (!game) {
|
if (!game) {
|
||||||
throw Error(_ERROR_("no game specified for stylesheet"));
|
throw Error(_ERROR_("no game specified for stylesheet"));
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-28
@@ -204,10 +204,7 @@ void PackageUpdateList::TreeItem::toItems(vector<TreeList::ItemP>& items) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PackageUpdateList::TreeItem::highlight() const {
|
bool PackageUpdateList::TreeItem::highlight() const {
|
||||||
if (package && ((package->installed && !(package->action & PACKAGE_REMOVE))
|
if (package && package->willBeInstalled()) return true;
|
||||||
|| package->action & (PACKAGE_INSTALL | PACKAGE_UPGRADE))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
FOR_EACH_CONST(c,children) if (c->highlight()) return true;
|
FOR_EACH_CONST(c,children) if (c->highlight()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -281,11 +278,13 @@ void PackageUpdateList::drawItem(DC& dc, size_t index, size_t column, int x, int
|
|||||||
// Action
|
// Action
|
||||||
int act = ti.package->action;
|
int act = ti.package->action;
|
||||||
if (act & PACKAGE_INSTALL) {
|
if (act & PACKAGE_INSTALL) {
|
||||||
dc.SetTextForeground(lerp(color,Color(0,255,0),0.5));
|
if (ti.package->status & PACKAGE_INSTALLED) {
|
||||||
dc.DrawText(_LABEL_("install package"), x+1,y+2);
|
dc.SetTextForeground(lerp(color,Color(0,0,255),0.5));
|
||||||
} else if (act & PACKAGE_UPGRADE) {
|
dc.DrawText(_LABEL_("upgrade package"), x+1,y+2);
|
||||||
dc.SetTextForeground(lerp(color,Color(0,0,255),0.5));
|
} else {
|
||||||
dc.DrawText(_LABEL_("upgrade package"), x+1,y+2);
|
dc.SetTextForeground(lerp(color,Color(0,255,0),0.5));
|
||||||
|
dc.DrawText(_LABEL_("install package"), x+1,y+2);
|
||||||
|
}
|
||||||
} else if (act & PACKAGE_REMOVE) {
|
} else if (act & PACKAGE_REMOVE) {
|
||||||
dc.SetTextForeground(lerp(color,Color(255,0,0),0.5));
|
dc.SetTextForeground(lerp(color,Color(255,0,0),0.5));
|
||||||
dc.DrawText(_LABEL_("remove package"), x+1,y+2);
|
dc.DrawText(_LABEL_("remove package"), x+1,y+2);
|
||||||
@@ -364,6 +363,7 @@ BEGIN_EVENT_TABLE(PackageInfoPanel, wxPanel)
|
|||||||
EVT_PAINT(PackageInfoPanel::onPaint)
|
EVT_PAINT(PackageInfoPanel::onPaint)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : PackagesWindow
|
// ----------------------------------------------------------------------------- : PackagesWindow
|
||||||
|
|
||||||
PackagesWindow::PackagesWindow(Window* parent, bool download_package_list)
|
PackagesWindow::PackagesWindow(Window* parent, bool download_package_list)
|
||||||
@@ -377,7 +377,7 @@ PackagesWindow::PackagesWindow(Window* parent, bool download_package_list)
|
|||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
packages.installedPackages(installable_packages);
|
packages.installedPackages(installable_packages);
|
||||||
FOR_EACH(p, installable_packages) p->determineStatus();
|
FOR_EACH(p, installable_packages) p->determineStatus();
|
||||||
checkInstallerList();
|
checkInstallerList(false);
|
||||||
|
|
||||||
// ui elements
|
// ui elements
|
||||||
SetIcon(wxIcon());
|
SetIcon(wxIcon());
|
||||||
@@ -420,13 +420,13 @@ void PackagesWindow::onPackageSelect(wxCommandEvent& ev) {
|
|||||||
void PackagesWindow::onActionChange(wxCommandEvent& ev) {
|
void PackagesWindow::onActionChange(wxCommandEvent& ev) {
|
||||||
if (package) {
|
if (package) {
|
||||||
PackageAction act = ev.GetId() == ID_INSTALL ? PACKAGE_INSTALL
|
PackageAction act = ev.GetId() == ID_INSTALL ? PACKAGE_INSTALL
|
||||||
: ev.GetId() == ID_UPGRADE ? PACKAGE_UPGRADE
|
: ev.GetId() == ID_UPGRADE ? PACKAGE_INSTALL
|
||||||
: ev.GetId() == ID_REMOVE ? PACKAGE_REMOVE
|
: ev.GetId() == ID_REMOVE ? PACKAGE_REMOVE
|
||||||
: PACKAGE_NOTHING;
|
: PACKAGE_NOTHING;
|
||||||
act = (PackageAction)(act | where);
|
act = act | where;
|
||||||
// toggle action
|
// toggle action
|
||||||
if (package->has(act)) {
|
if (package->has(act)) {
|
||||||
set_package_action(installable_packages, package, (PackageAction)(PACKAGE_NOTHING | where));
|
set_package_action(installable_packages, package, PACKAGE_NOTHING | where);
|
||||||
} else {
|
} else {
|
||||||
set_package_action(installable_packages, package, act);
|
set_package_action(installable_packages, package, act);
|
||||||
}
|
}
|
||||||
@@ -455,7 +455,7 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
|
|||||||
if (!progress.Update(n, String::Format(_ERROR_("downloading updates"), n, total))) {
|
if (!progress.Update(n, String::Format(_ERROR_("downloading updates"), n, total))) {
|
||||||
return; // aborted
|
return; // aborted
|
||||||
}
|
}
|
||||||
if ((ip->action & (PACKAGE_INSTALL | PACKAGE_UPGRADE)) && ip->installer && !ip->installer->installer) {
|
if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) {
|
||||||
// download installer
|
// download installer
|
||||||
wxURL url(ip->installer->installer_url);
|
wxURL url(ip->installer->installer_url);
|
||||||
wxInputStream* is = url.GetInputStream();
|
wxInputStream* is = url.GetInputStream();
|
||||||
@@ -487,17 +487,17 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
|
|||||||
void PackagesWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
void PackagesWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||||
switch (ev.GetId()) {
|
switch (ev.GetId()) {
|
||||||
case ID_INSTALL:
|
case ID_INSTALL:
|
||||||
case ID_UPGRADE:
|
ev.Check (package && package->has(PACKAGE_INSTALL | where) && !package->installed);
|
||||||
case ID_REMOVE: {
|
ev.Enable(package && package->can(PACKAGE_INSTALL | where) && !package->installed);
|
||||||
PackageAction act = ev.GetId() == ID_INSTALL ? PACKAGE_INSTALL
|
break;
|
||||||
: ev.GetId() == ID_UPGRADE ? PACKAGE_UPGRADE
|
case ID_UPGRADE:
|
||||||
: ev.GetId() == ID_REMOVE ? PACKAGE_REMOVE
|
ev.Check (package && package->has(PACKAGE_INSTALL | where) && package->installed);
|
||||||
: PACKAGE_NOTHING;
|
ev.Enable(package && package->can(PACKAGE_INSTALL | where) && package->installed);
|
||||||
act = (PackageAction)(act | where);
|
break;
|
||||||
ev.Check (package && package->has(act));
|
case ID_REMOVE:
|
||||||
ev.Enable(package && package->can(act));
|
ev.Check (package && package->has(PACKAGE_REMOVE | where));
|
||||||
|
ev.Enable(package && package->can(PACKAGE_REMOVE | where));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ void PackagesWindow::onIdle(wxIdleEvent& ev) {
|
|||||||
ev.RequestMore(!checkInstallerList());
|
ev.RequestMore(!checkInstallerList());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackagesWindow::checkInstallerList() {
|
bool PackagesWindow::checkInstallerList(bool refresh) {
|
||||||
if (!waiting_for_list) return true;
|
if (!waiting_for_list) return true;
|
||||||
if (!downloadable_installers.done()) return false;
|
if (!downloadable_installers.done()) return false;
|
||||||
waiting_for_list = false;
|
waiting_for_list = false;
|
||||||
@@ -515,9 +515,11 @@ bool PackagesWindow::checkInstallerList() {
|
|||||||
}
|
}
|
||||||
FOR_EACH(p, installable_packages) p->determineStatus();
|
FOR_EACH(p, installable_packages) p->determineStatus();
|
||||||
// refresh
|
// refresh
|
||||||
package_list->rebuild();
|
if (refresh) {
|
||||||
package_info->setPackage(package = package_list->getSelection());
|
package_list->rebuild();
|
||||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
package_info->setPackage(package = package_list->getSelection());
|
||||||
|
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,21 +11,9 @@
|
|||||||
|
|
||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <data/installer.hpp>
|
#include <data/installer.hpp>
|
||||||
// #include <gui/welcome_window.hpp> //???
|
|
||||||
|
|
||||||
class PackageUpdateList;
|
class PackageUpdateList;
|
||||||
class PackageInfoPanel;
|
class PackageInfoPanel;
|
||||||
//class wxHtmlWindow;
|
|
||||||
|
|
||||||
//DECLARE_POINTER_TYPE(PackageVersionData);
|
|
||||||
|
|
||||||
//DECLARE_POINTER_TYPE(PackageVersion);
|
|
||||||
//DECLARE_POINTER_TYPE(PackageDescription);
|
|
||||||
//DECLARE_POINTER_TYPE(InstallableInstaller);
|
|
||||||
DECLARE_POINTER_TYPE(InstallablePackage);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Available Packages
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Packages window
|
// ----------------------------------------------------------------------------- : Packages window
|
||||||
|
|
||||||
@@ -54,26 +42,7 @@ class PackagesWindow : public wxDialog {
|
|||||||
void onUpdateUI(wxUpdateUIEvent&);
|
void onUpdateUI(wxUpdateUIEvent&);
|
||||||
void onIdle(wxIdleEvent&);
|
void onIdle(wxIdleEvent&);
|
||||||
|
|
||||||
bool checkInstallerList();
|
bool checkInstallerList(bool refresh = true);
|
||||||
/*
|
|
||||||
wxHtmlWindow* description_window;
|
|
||||||
|
|
||||||
wxButton *install_button, *upgrade_button, *remove_button, *cancel_button, *apply_button;
|
|
||||||
|
|
||||||
void onUpdateCheckFinished(wxCommandEvent&);
|
|
||||||
void onPackageSelect(wxCommandEvent&);
|
|
||||||
void onActionChange(wxCommandEvent&);
|
|
||||||
void onApplyChanges(wxCommandEvent&);
|
|
||||||
|
|
||||||
void SelectPackageDependencies (PackageVersionDataP);
|
|
||||||
void RemovePackageDependencies (PackageVersionDataP);
|
|
||||||
void DowngradePackageDependencies(PackageVersionDataP);
|
|
||||||
|
|
||||||
/// Update the buttons to indicate that this is selected.
|
|
||||||
void updateButtons(const PackageVersionDataP& pack);
|
|
||||||
|
|
||||||
void setDefaultPackageStatus();
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
|||||||
@@ -541,7 +541,10 @@ void Packaged::saveAs(const String& package, bool remove_unused) {
|
|||||||
|
|
||||||
void Packaged::validate(Version) {
|
void Packaged::validate(Version) {
|
||||||
// a default for the short name
|
// a default for the short name
|
||||||
if (short_name.empty()) short_name = name();
|
if (short_name.empty()) {
|
||||||
|
if (!full_name.empty()) short_name = full_name;
|
||||||
|
short_name = name();
|
||||||
|
}
|
||||||
// check dependencies
|
// check dependencies
|
||||||
FOR_EACH(dep, dependencies) {
|
FOR_EACH(dep, dependencies) {
|
||||||
packages.checkDependency(*dep, true);
|
packages.checkDependency(*dep, true);
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ bool PackageDirectory::install(const InstallablePackage& package) {
|
|||||||
String n = name(package.description->name);
|
String n = name(package.description->name);
|
||||||
if (package.action & PACKAGE_REMOVE) {
|
if (package.action & PACKAGE_REMOVE) {
|
||||||
remove_file_or_dir(n);
|
remove_file_or_dir(n);
|
||||||
} else if ((package.action & PACKAGE_UPGRADE) || (package.action & PACKAGE_INSTALL)) {
|
} else if (package.action & PACKAGE_INSTALL) {
|
||||||
remove_file_or_dir(n + _(".new"));
|
remove_file_or_dir(n + _(".new"));
|
||||||
bool ok = actual_install(package, n + _(".new"));
|
bool ok = actual_install(package, n + _(".new"));
|
||||||
if (!ok) return false;
|
if (!ok) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user