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:
visible:
script: styling.watermarkings
render style: image
include file: vs-common.mse-include/watermarks
include file: /vs-common.mse-include/watermarks
z index: 4
############################# Attack/defence
......
......@@ -345,7 +345,7 @@ card style:
visible:
script: styling.watermarkings
render style: image
include file: vs-common.mse-include/watermarks
include file: /vs-common.mse-include/watermarks
z index: 4
############################# Atack/defence
......
......@@ -345,7 +345,7 @@ card style:
visible:
script: styling.watermarkings
render style: image
include file: vs-common.mse-include/watermarks
include file: /vs-common.mse-include/watermarks
z index: 4
############################# Atack/defence
......
......@@ -364,7 +364,7 @@ card style:
visible:
script: styling.watermarkings
render style: image
include file: vs-common.mse-include/watermarks
include file: /vs-common.mse-include/watermarks
z index: 4
############################# Atack/defence
......
......@@ -342,7 +342,7 @@ card style:
visible:
script: styling.watermarkings
render style: image
include file: vs-common.mse-include/watermarks
include file: /vs-common.mse-include/watermarks
z index: 4
......@@ -447,7 +447,7 @@ extra card field:
name: affiliation
editable: false
initial: none
include file: vs-common.mse-include/watermark-names
include file: /vs-common.mse-include/watermark-names
extra card style:
playarea:
......@@ -505,4 +505,4 @@ extra card style:
z index: 5
alignment: middle right
render style: image
include file: vs-common.mse-include/affiliations
include file: /vs-common.mse-include/affiliations
......@@ -367,7 +367,7 @@ card style:
visible:
script: styling.watermarkings
render style: image
include file: vs-common.mse-include/watermarks
include file: /vs-common.mse-include/watermarks
z index: 4
......
......@@ -4,6 +4,9 @@ short name: VS
icon: card-back.png
version: 2007-09-23
position hint: 3
depends on:
package: vs-common.mse-include
version: 2007-09-23
############################################################## Functions & filters
# General functions
......@@ -606,7 +609,7 @@ card field:
card field:
type: choice
name: watermark
include file: vs-common.mse-include/watermark-names
include file: /vs-common.mse-include/watermark-names
editable: false
description: The Watermark for this set.
......
......@@ -62,7 +62,7 @@ struct dependency_check : public unary_function<bool, PackagedP> {
PackageDependencyP dep;
};
void Installer::install(bool local) {
void Installer::install(bool local, bool check_dependencies) {
// Destination directory
String install_dir = local ? ::packages.getLocalDataDir() : ::packages.getGlobalDataDir();
if (!wxDirExists(install_dir)) {
......@@ -92,6 +92,7 @@ void Installer::install(bool local) {
new_packages.push_back(pack);
}
if (check_dependencies) {
// Check dependencies for each and every package.
FOR_EACH(p, new_packages) {
FOR_EACH(d, p->dependencies) {
......@@ -101,6 +102,7 @@ void Installer::install(bool local) {
}
}
}
}
const FileInfos& file_infos = getFileInfos();
for (FileInfos::const_iterator it = file_infos.begin() ; it != file_infos.end() ; ++it) {
......
......@@ -37,7 +37,7 @@ class Installer : public Packaged {
/// Load an installer from a file, and run it
static void installFrom(const String& filename, bool message_on_success, bool local);
/// Install all the packages
void install(bool local);
void install(bool local, bool check_dependencies = true);
/// Install a specific package
void install(const String& package);
......
......@@ -8,6 +8,7 @@
#include <gui/update_checker.hpp>
#include <data/settings.hpp>
#include <data/installer.hpp>
#include <util/io/package_manager.hpp>
#include <util/version.hpp>
#include <util/window_id.hpp>
......@@ -17,8 +18,11 @@
#include <wx/url.h>
#include <wx/html/htmlwin.h>
#include <wx/vlbox.h>
#include <wx/zipstrm.h>
#include <list>
DECLARE_POINTER_TYPE(PackageVersionData);
DECLARE_POINTER_TYPE(Installer);
DECLARE_POINTER_TYPE(VersionData);
DECLARE_TYPEOF_COLLECTION(PackageVersionDataP);
......@@ -358,6 +362,10 @@ UpdatesWindow::UpdatesWindow()
SetSizer(v);
}
UpdatesWindow::~UpdatesWindow() {
(new WelcomeWindow)->Show();
}
void UpdatesWindow::onUpdateCheckFinished(wxCommandEvent&) {
setDefaultPackageStatus();
}
......@@ -405,9 +413,53 @@ void UpdatesWindow::onActionChange(wxCommandEvent& ev) {
}
void UpdatesWindow::onApplyChanges(wxCommandEvent& ev) {
list<PackageVersionDataP> to_install, to_remove;
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) {
......@@ -446,9 +498,9 @@ void UpdatesWindow::setDefaultPackageStatus() {
FOR_EACH(p, update_version_data->packages) {
PackagedP pack;
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
if (p->app_version > file_version) {
package_data[p] = PackageData(STATUS_NOT_INSTALLED, ACTION_NEW_MSE);
......@@ -512,7 +564,7 @@ void UpdatesWindow::RemovePackageDependencies (PackageVersionDataP pack) {
if (status != STATUS_NOT_INSTALLED)
action = ACTION_UNINSTALL;
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;
}
}
......@@ -545,6 +597,8 @@ void UpdatesWindow::DowngradePackageDependencies (PackageVersionDataP pack) {
// TODO: Decide what to do if a dependency can't be met.
// It shouldn't happen with a decently maintained updates list.
// 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) {
......@@ -558,7 +612,7 @@ void UpdatesWindow::DowngradePackageDependencies (PackageVersionDataP pack) {
if (status != STATUS_NOT_INSTALLED)
action = ACTION_UNINSTALL;
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;
}
}
......
......@@ -40,7 +40,7 @@ DECLARE_POINTER_TYPE(PackageVersionData);
class UpdatesWindow : public Frame {
public:
UpdatesWindow();
~UpdatesWindow() { (new WelcomeWindow)->Show(); }
~UpdatesWindow();
void DrawTitles(wxPaintEvent&);
......
......@@ -78,6 +78,11 @@ class PackageManager {
/// Check if the given dependency is currently installed
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 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