Commit 8b34fbb8 authored by coppro's avatar coppro

Added some new update code (YET TO BE TESTED) and some fixes to the VS

templates.
Still looking to find one source of a reference to 
"futsymbol_artifact.png" (case-sensitive)
parent 3ac67c71
...@@ -164,7 +164,7 @@ card style: ...@@ -164,7 +164,7 @@ card style:
visible: visible:
script: styling.watermarkings script: styling.watermarkings
render style: image render style: image
include file: vs-common.mse-include/watermarks include file: /vs-common.mse-include/watermarks
z index: 4 z index: 4
############################# Attack/defence ############################# Attack/defence
......
...@@ -345,7 +345,7 @@ card style: ...@@ -345,7 +345,7 @@ card style:
visible: visible:
script: styling.watermarkings script: styling.watermarkings
render style: image render style: image
include file: vs-common.mse-include/watermarks include file: /vs-common.mse-include/watermarks
z index: 4 z index: 4
############################# Atack/defence ############################# Atack/defence
......
...@@ -345,7 +345,7 @@ card style: ...@@ -345,7 +345,7 @@ card style:
visible: visible:
script: styling.watermarkings script: styling.watermarkings
render style: image render style: image
include file: vs-common.mse-include/watermarks include file: /vs-common.mse-include/watermarks
z index: 4 z index: 4
############################# Atack/defence ############################# Atack/defence
......
...@@ -364,7 +364,7 @@ card style: ...@@ -364,7 +364,7 @@ card style:
visible: visible:
script: styling.watermarkings script: styling.watermarkings
render style: image render style: image
include file: vs-common.mse-include/watermarks include file: /vs-common.mse-include/watermarks
z index: 4 z index: 4
############################# Atack/defence ############################# Atack/defence
......
...@@ -342,7 +342,7 @@ card style: ...@@ -342,7 +342,7 @@ card style:
visible: visible:
script: styling.watermarkings script: styling.watermarkings
render style: image render style: image
include file: vs-common.mse-include/watermarks include file: /vs-common.mse-include/watermarks
z index: 4 z index: 4
...@@ -447,7 +447,7 @@ extra card field: ...@@ -447,7 +447,7 @@ extra card field:
name: affiliation name: affiliation
editable: false editable: false
initial: none initial: none
include file: vs-common.mse-include/watermark-names include file: /vs-common.mse-include/watermark-names
extra card style: extra card style:
playarea: playarea:
...@@ -505,4 +505,4 @@ extra card style: ...@@ -505,4 +505,4 @@ extra card style:
z index: 5 z index: 5
alignment: middle right alignment: middle right
render style: image render style: image
include file: vs-common.mse-include/affiliations include file: /vs-common.mse-include/affiliations
...@@ -367,7 +367,7 @@ card style: ...@@ -367,7 +367,7 @@ card style:
visible: visible:
script: styling.watermarkings script: styling.watermarkings
render style: image render style: image
include file: vs-common.mse-include/watermarks include file: /vs-common.mse-include/watermarks
z index: 4 z index: 4
......
...@@ -4,6 +4,9 @@ short name: VS ...@@ -4,6 +4,9 @@ short name: VS
icon: card-back.png icon: card-back.png
version: 2007-09-23 version: 2007-09-23
position hint: 3 position hint: 3
depends on:
package: vs-common.mse-include
version: 2007-09-23
############################################################## Functions & filters ############################################################## Functions & filters
# General functions # General functions
...@@ -606,7 +609,7 @@ card field: ...@@ -606,7 +609,7 @@ card field:
card field: card field:
type: choice type: choice
name: watermark name: watermark
include file: vs-common.mse-include/watermark-names include file: /vs-common.mse-include/watermark-names
editable: false editable: false
description: The Watermark for this set. description: The Watermark for this set.
......
...@@ -62,7 +62,7 @@ struct dependency_check : public unary_function<bool, PackagedP> { ...@@ -62,7 +62,7 @@ struct dependency_check : public unary_function<bool, PackagedP> {
PackageDependencyP dep; PackageDependencyP dep;
}; };
void Installer::install(bool local) { void Installer::install(bool local, bool check_dependencies) {
// Destination directory // Destination directory
String install_dir = local ? ::packages.getLocalDataDir() : ::packages.getGlobalDataDir(); String install_dir = local ? ::packages.getLocalDataDir() : ::packages.getGlobalDataDir();
if (!wxDirExists(install_dir)) { if (!wxDirExists(install_dir)) {
...@@ -92,6 +92,7 @@ void Installer::install(bool local) { ...@@ -92,6 +92,7 @@ void Installer::install(bool local) {
new_packages.push_back(pack); new_packages.push_back(pack);
} }
if (check_dependencies) {
// Check dependencies for each and every package. // Check dependencies for each and every package.
FOR_EACH(p, new_packages) { FOR_EACH(p, new_packages) {
FOR_EACH(d, p->dependencies) { FOR_EACH(d, p->dependencies) {
...@@ -101,6 +102,7 @@ void Installer::install(bool local) { ...@@ -101,6 +102,7 @@ void Installer::install(bool local) {
} }
} }
} }
}
const FileInfos& file_infos = getFileInfos(); const FileInfos& file_infos = getFileInfos();
for (FileInfos::const_iterator it = file_infos.begin() ; it != file_infos.end() ; ++it) { for (FileInfos::const_iterator it = file_infos.begin() ; it != file_infos.end() ; ++it) {
......
...@@ -37,7 +37,7 @@ class Installer : public Packaged { ...@@ -37,7 +37,7 @@ class Installer : public Packaged {
/// 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); 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);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <gui/update_checker.hpp> #include <gui/update_checker.hpp>
#include <data/settings.hpp> #include <data/settings.hpp>
#include <data/installer.hpp>
#include <util/io/package_manager.hpp> #include <util/io/package_manager.hpp>
#include <util/version.hpp> #include <util/version.hpp>
#include <util/window_id.hpp> #include <util/window_id.hpp>
...@@ -17,8 +18,11 @@ ...@@ -17,8 +18,11 @@
#include <wx/url.h> #include <wx/url.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include <wx/vlbox.h> #include <wx/vlbox.h>
#include <wx/zipstrm.h>
#include <list>
DECLARE_POINTER_TYPE(PackageVersionData); DECLARE_POINTER_TYPE(PackageVersionData);
DECLARE_POINTER_TYPE(Installer);
DECLARE_POINTER_TYPE(VersionData); DECLARE_POINTER_TYPE(VersionData);
DECLARE_TYPEOF_COLLECTION(PackageVersionDataP); DECLARE_TYPEOF_COLLECTION(PackageVersionDataP);
...@@ -358,6 +362,10 @@ UpdatesWindow::UpdatesWindow() ...@@ -358,6 +362,10 @@ UpdatesWindow::UpdatesWindow()
SetSizer(v); SetSizer(v);
} }
UpdatesWindow::~UpdatesWindow() {
(new WelcomeWindow)->Show();
}
void UpdatesWindow::onUpdateCheckFinished(wxCommandEvent&) { void UpdatesWindow::onUpdateCheckFinished(wxCommandEvent&) {
setDefaultPackageStatus(); setDefaultPackageStatus();
} }
...@@ -405,9 +413,53 @@ void UpdatesWindow::onActionChange(wxCommandEvent& ev) { ...@@ -405,9 +413,53 @@ void UpdatesWindow::onActionChange(wxCommandEvent& ev) {
} }
void UpdatesWindow::onApplyChanges(wxCommandEvent& ev) { void UpdatesWindow::onApplyChanges(wxCommandEvent& ev) {
list<PackageVersionDataP> to_install, to_remove;
FOR_EACH(pack, update_version_data->packages) { FOR_EACH(pack, update_version_data->packages) {
PackageAction action = package_data[pack].second; switch (package_data[pack].second) {
case ACTION_INSTALL:
to_install.push_back(pack);
break;
case ACTION_UPGRADE:
to_install.push_back(pack);
case ACTION_UNINSTALL:
to_remove.push_back(pack);
default:;
}
}
FOR_EACH(pack, to_remove) {
wxFileName filename (packages.openAny(pack->name, true)->absoluteFilename());
if (filename.DirExists()) {
// TODO: Recursive removal of directory.
} else {
if (!wxRemoveFile(filename.GetFullPath()))
handle_error(_("Cannot delete ") + filename.GetFullPath() + _(" to remove package ") + pack->name + _(". "
"Other packages may have been removed, including packages that this on is dependent on. Please remove manually."));
}
} }
FOR_EACH(pack, to_install) {
wxURL url(pack->url);
wxInputStream* is = url.GetInputStream();
if (!is) {
handle_error(_("Cannot fetch file ") + pack->url + _(" to install package ") + pack->name + _(". "
"Other packages may have been installed, including packages that depend on this one. "
"Please remove those packages manually or install this one manually."));
}
wxZipInputStream zis(is);
InstallerP inst(new Installer);
inst->openZipStream(&zis);
inst->install(isInstallLocal(settings.install_type), false);
delete is;
}
setDefaultPackageStatus();
updateButtons(package_list->GetSelection());
package_list->Refresh();
packages.clearPackageCache();
} }
void UpdatesWindow::updateButtons(int id) { void UpdatesWindow::updateButtons(int id) {
...@@ -446,9 +498,9 @@ void UpdatesWindow::setDefaultPackageStatus() { ...@@ -446,9 +498,9 @@ void UpdatesWindow::setDefaultPackageStatus() {
FOR_EACH(p, update_version_data->packages) { FOR_EACH(p, update_version_data->packages) {
PackagedP pack; PackagedP pack;
try { pack = packages.openAny(p->name, true); } try { pack = packages.openAny(p->name, true); }
catch (const PackageError&) { } // We couldn't open a package... wonder why? catch (PackageNotFoundError&) { } // We couldn't open a package... no cause for alarm
if (!pack) { if (!pack || !(wxFileExists(pack->absoluteFilename()) || wxDirExists(pack->absoluteFilename()))) {
// not installed // not installed
if (p->app_version > file_version) { if (p->app_version > file_version) {
package_data[p] = PackageData(STATUS_NOT_INSTALLED, ACTION_NEW_MSE); package_data[p] = PackageData(STATUS_NOT_INSTALLED, ACTION_NEW_MSE);
...@@ -512,7 +564,7 @@ void UpdatesWindow::RemovePackageDependencies (PackageVersionDataP pack) { ...@@ -512,7 +564,7 @@ void UpdatesWindow::RemovePackageDependencies (PackageVersionDataP pack) {
if (status != STATUS_NOT_INSTALLED) if (status != STATUS_NOT_INSTALLED)
action = ACTION_UNINSTALL; action = ACTION_UNINSTALL;
else // status == STATUS_NOT_INSTALLED else // status == STATUS_NOT_INSTALLED
action = p->app_version > file_version ? ACTION_NOTHING : ACTION_NEW_MSE; action = p->app_version > file_version ? ACTION_NEW_MSE : ACTION_NOTHING;
break; break;
} }
} }
...@@ -545,6 +597,8 @@ void UpdatesWindow::DowngradePackageDependencies (PackageVersionDataP pack) { ...@@ -545,6 +597,8 @@ void UpdatesWindow::DowngradePackageDependencies (PackageVersionDataP pack) {
// TODO: Decide what to do if a dependency can't be met. // TODO: Decide what to do if a dependency can't be met.
// It shouldn't happen with a decently maintained updates list. // It shouldn't happen with a decently maintained updates list.
// But it could, and we need to decide what to do in this situation. // But it could, and we need to decide what to do in this situation.
// Ideally, some sort of error should occur, such that we don't have packages
// with unmet dependencies.
} }
FOR_EACH(p, update_version_data->packages) { FOR_EACH(p, update_version_data->packages) {
...@@ -558,7 +612,7 @@ void UpdatesWindow::DowngradePackageDependencies (PackageVersionDataP pack) { ...@@ -558,7 +612,7 @@ void UpdatesWindow::DowngradePackageDependencies (PackageVersionDataP pack) {
if (status != STATUS_NOT_INSTALLED) if (status != STATUS_NOT_INSTALLED)
action = ACTION_UNINSTALL; action = ACTION_UNINSTALL;
else // status == STATUS_NOT_INSTALLED else // status == STATUS_NOT_INSTALLED
action = p->app_version > file_version ? ACTION_NOTHING : ACTION_NEW_MSE; action = p->app_version > file_version ? ACTION_NEW_MSE : ACTION_NOTHING;
break; break;
} }
} }
......
...@@ -40,7 +40,7 @@ DECLARE_POINTER_TYPE(PackageVersionData); ...@@ -40,7 +40,7 @@ DECLARE_POINTER_TYPE(PackageVersionData);
class UpdatesWindow : public Frame { class UpdatesWindow : public Frame {
public: public:
UpdatesWindow(); UpdatesWindow();
~UpdatesWindow() { (new WelcomeWindow)->Show(); } ~UpdatesWindow();
void DrawTitles(wxPaintEvent&); void DrawTitles(wxPaintEvent&);
......
...@@ -78,6 +78,11 @@ class PackageManager { ...@@ -78,6 +78,11 @@ class PackageManager {
/// Check if the given dependency is currently installed /// Check if the given dependency is currently installed
bool checkDependency(const PackageDependency& dep, bool report_errors = true); bool checkDependency(const PackageDependency& dep, bool report_errors = true);
/// Clear that cache of opened packages
/** Used by the update manager
*/
inline void clearPackageCache() { loaded_packages.clear(); }
inline String getGlobalDataDir() const { return global_data_directory; } inline String getGlobalDataDir() const { return global_data_directory; }
inline String getLocalDataDir() const { return local_data_directory; } inline String getLocalDataDir() const { return local_data_directory; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment