Commit 6d6baa12 authored by twanvl's avatar twanvl

Renamed global PackageManager object to package_manager to reduce confusion

parent 4b5980b6
...@@ -57,7 +57,7 @@ String PackageChoiceValue::toString() const { ...@@ -57,7 +57,7 @@ String PackageChoiceValue::toString() const {
PackagedP PackageChoiceValue::getPackage() const { PackagedP PackageChoiceValue::getPackage() const {
if (package_name.empty()) return nullptr; if (package_name.empty()) return nullptr;
else return packages.openAny(package_name, true); else return package_manager.openAny(package_name, true);
} }
bool PackageChoiceValue::update(Context& ctx) { bool PackageChoiceValue::update(Context& ctx) {
......
...@@ -30,7 +30,7 @@ Game::Game() ...@@ -30,7 +30,7 @@ Game::Game()
{} {}
GameP Game::byName(const String& name) { GameP Game::byName(const String& name) {
return packages.open<Game>(name + _(".mse-game")); return package_manager.open<Game>(name + _(".mse-game"));
} }
bool Game::isMagic() const { bool Game::isMagic() const {
......
...@@ -151,7 +151,7 @@ void Installer::addPackage(const String& package) { ...@@ -151,7 +151,7 @@ void Installer::addPackage(const String& package) {
if (fn.GetExt() == _("mse-installer")) { if (fn.GetExt() == _("mse-installer")) {
prefered_filename = package; prefered_filename = package;
} else { } else {
PackagedP p = ::packages.openAny(package); PackagedP p = package_manager.openAny(package);
addPackage(*p); addPackage(*p);
} }
} }
......
...@@ -27,7 +27,7 @@ LocaleP the_locale; ...@@ -27,7 +27,7 @@ LocaleP the_locale;
String Locale::typeName() const { return _("locale"); } String Locale::typeName() const { return _("locale"); }
LocaleP Locale::byName(const String& name) { LocaleP Locale::byName(const String& name) {
return packages.open<Locale>(name + _(".mse-locale")); return package_manager.open<Locale>(name + _(".mse-locale"));
} }
IMPLEMENT_REFLECTION_NO_SCRIPT(Locale) { IMPLEMENT_REFLECTION_NO_SCRIPT(Locale) {
......
...@@ -33,9 +33,9 @@ StyleSheetP StyleSheet::byGameAndName(const Game& game, const String& name) { ...@@ -33,9 +33,9 @@ StyleSheetP StyleSheet::byGameAndName(const Game& game, const String& name) {
try { try {
map<String, String>::const_iterator it = stylesheet_alternatives.find(full_name); map<String, String>::const_iterator it = stylesheet_alternatives.find(full_name);
if (it != stylesheet_alternatives.end()) { if (it != stylesheet_alternatives.end()) {
return packages.open<StyleSheet>(it->second); return package_manager.open<StyleSheet>(it->second);
} else { } else {
return packages.open<StyleSheet>(full_name); return package_manager.open<StyleSheet>(full_name);
} }
} catch (PackageNotFoundError& e) { } catch (PackageNotFoundError& e) {
if (stylesheet_for_reading()) { if (stylesheet_for_reading()) {
......
...@@ -42,7 +42,7 @@ String SymbolFont::typeNameStatic() { return _("symbol-font"); } ...@@ -42,7 +42,7 @@ String SymbolFont::typeNameStatic() { return _("symbol-font"); }
String SymbolFont::typeName() const { return _("symbol-font"); } String SymbolFont::typeName() const { return _("symbol-font"); }
SymbolFontP SymbolFont::byName(const String& name) { SymbolFontP SymbolFont::byName(const String& name) {
return packages.open<SymbolFont>( return package_manager.open<SymbolFont>(
name.size() > 16 && is_substr(name, name.size() - 16, _(".mse-symbol-font")) name.size() > 16 && is_substr(name, name.size() - 16, _(".mse-symbol-font"))
? name : name + _(".mse-symbol-font")); ? name : name + _(".mse-symbol-font"));
} }
......
...@@ -62,7 +62,7 @@ void PackageList::showData(const String& pattern) { ...@@ -62,7 +62,7 @@ void PackageList::showData(const String& pattern) {
packages.clear(); packages.clear();
// find matching packages // find matching packages
vector<PackagedP> matching; vector<PackagedP> matching;
::packages.findMatching(pattern, matching); package_manager.findMatching(pattern, matching);
FOR_EACH(p, matching) { FOR_EACH(p, matching) {
// open image // open image
InputStreamP stream = p->openIconFile(); InputStreamP stream = p->openIconFile();
......
...@@ -182,7 +182,7 @@ void PackagesWindow::init(Window* parent, bool show_only_installable) { ...@@ -182,7 +182,7 @@ void PackagesWindow::init(Window* parent, bool show_only_installable) {
// get packages // get packages
wxBusyCursor busy; wxBusyCursor busy;
packages.installedPackages(installable_packages); package_manager.findAllInstalledPackages(installable_packages);
FOR_EACH(p, installable_packages) p->determineStatus(); FOR_EACH(p, installable_packages) p->determineStatus();
checkInstallerList(false); checkInstallerList(false);
...@@ -254,12 +254,12 @@ void PackagesWindow::onOk(wxCommandEvent& ev) { ...@@ -254,12 +254,12 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_SMOOTH wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_SMOOTH
); );
// Clear package list // Clear package list
packages.reset(); package_manager.reset();
// Download installers // Download installers
int package_pos = 0, progress = 0; int package_pos = 0, step = 0;
FOR_EACH(ip, installable_packages) { FOR_EACH(ip, installable_packages) {
++package_pos; ++progress; ++package_pos; ++step;
if (!progress.Update(progress, String::Format(_ERROR_("downloading updates"), package_pos, total))) { if (!progress.Update(step, String::Format(_ERROR_("downloading updates"), package_pos, total))) {
return; // aborted return; // aborted
} }
if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) { if ((ip->action & PACKAGE_INSTALL) && ip->installer && !ip->installer->installer) {
...@@ -281,11 +281,11 @@ void PackagesWindow::onOk(wxCommandEvent& ev) { ...@@ -281,11 +281,11 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
// Install stuff // Install stuff
package_pos = 0 ; package_pos = 0 ;
FOR_EACH(ip, installable_packages) { FOR_EACH(ip, installable_packages) {
++package_pos; ++progress; ++package_pos; ++step;
if (!progress.Update(progress, String::Format(_ERROR_("installing updates"), package_pos, total))) { if (!progress.Update(step, String::Format(_ERROR_("installing updates"), package_pos, total))) {
// don't allow abort. // don't allow abort.
} }
packages.install(*ip); package_manager.install(*ip);
} }
// Done // Done
// Continue event propagation into the dialog window so that it closes. // Continue event propagation into the dialog window so that it closes.
......
...@@ -139,7 +139,7 @@ GlobalPreferencesPage::GlobalPreferencesPage(Window* parent) ...@@ -139,7 +139,7 @@ GlobalPreferencesPage::GlobalPreferencesPage(Window* parent)
language = new wxComboBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); language = new wxComboBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
// set values // set values
vector<PackagedP> locales; vector<PackagedP> locales;
::packages.findMatching(_("*.mse-locale"), locales); package_manager.findMatching(_("*.mse-locale"), locales);
sort(locales.begin(), locales.end(), compare_package_name); sort(locales.begin(), locales.end(), compare_package_name);
int n = 0; int n = 0;
FOR_EACH(package, locales) { FOR_EACH(package, locales) {
......
...@@ -564,8 +564,8 @@ void SetWindow::onFileReload(wxCommandEvent&) { ...@@ -564,8 +564,8 @@ void SetWindow::onFileReload(wxCommandEvent&) {
vector<CardP>::const_iterator card_it = find(set->cards.begin(), set->cards.end(), current_panel->selectedCard()); vector<CardP>::const_iterator card_it = find(set->cards.begin(), set->cards.end(), current_panel->selectedCard());
if (card_it != set->cards.end()) card_pos = card_it - set->cards.begin(); if (card_it != set->cards.end()) card_pos = card_it - set->cards.begin();
} }
packages.reset(); // unload all packages package_manager.reset(); // unload all packages
settings.read(); // reload settings settings.read(); // reload settings
setSet(import_set(filename)); setSet(import_set(filename));
// reselect card // reselect card
if (card_pos < set->cards.size()) { if (card_pos < set->cards.size()) {
......
...@@ -75,7 +75,7 @@ bool update_available() { ...@@ -75,7 +75,7 @@ bool update_available() {
FOR_EACH_CONST(p, update_version_data->packages) { FOR_EACH_CONST(p, update_version_data->packages) {
if (!settings.check_updates_all && p->package != mse_package) continue; if (!settings.check_updates_all && p->package != mse_package) continue;
Version v; Version v;
if (packages.installedVersion(p->package, v) && v < p->version) { if (package_manager.installedVersion(p->package, v) && v < p->version) {
return true; return true;
} }
} }
......
...@@ -79,7 +79,7 @@ int MSE::OnRun() { ...@@ -79,7 +79,7 @@ int MSE::OnRun() {
wxFileSystem::AddHandler(new wxInternetFSHandler); // needed for update checker wxFileSystem::AddHandler(new wxInternetFSHandler); // needed for update checker
init_script_variables(); init_script_variables();
init_file_formats(); init_file_formats();
packages.init(); package_manager.init();
settings.read(); settings.read();
the_locale = Locale::byName(settings.locale); the_locale = Locale::byName(settings.locale);
check_updates(); check_updates();
...@@ -212,7 +212,7 @@ int MSE::OnRun() { ...@@ -212,7 +212,7 @@ int MSE::OnRun() {
int MSE::OnExit() { int MSE::OnExit() {
thumbnail_thread.abortAll(); thumbnail_thread.abortAll();
settings.write(); settings.write();
packages.destroy(); package_manager.destroy();
return 0; return 0;
} }
......
...@@ -29,7 +29,7 @@ struct PackageChoiceValueViewer::ComparePackagePosHint { ...@@ -29,7 +29,7 @@ struct PackageChoiceValueViewer::ComparePackagePosHint {
void PackageChoiceValueViewer::initItems() { void PackageChoiceValueViewer::initItems() {
vector<PackagedP> choices; vector<PackagedP> choices;
packages.findMatching(field().match, choices); package_manager.findMatching(field().match, choices);
sort(choices.begin(), choices.end(), ComparePackagePosHint()); sort(choices.begin(), choices.end(), ComparePackagePosHint());
FOR_EACH(p, choices) { FOR_EACH(p, choices) {
Item i; Item i;
......
...@@ -194,7 +194,7 @@ void TokenIterator::readToken() { ...@@ -194,7 +194,7 @@ void TokenIterator::readToken() {
// read the entire file, and start at the beginning of it // read the entire file, and start at the beginning of it
pos = 0; pos = 0;
filename = include_file; filename = include_file;
InputStreamP is = packages.openFileFromPackage(package, include_file); InputStreamP is = package_manager.openFileFromPackage(package, include_file);
input = read_utf8_line(*is, true, true); input = read_utf8_line(*is, true, true);
} else if (isAlpha(c) || c == _('_')) { } else if (isAlpha(c) || c == _('_')) {
// name // name
......
...@@ -179,7 +179,7 @@ InputStreamP Package::openIn(const String& file) { ...@@ -179,7 +179,7 @@ InputStreamP Package::openIn(const String& file) {
if (!file.empty() && file.GetChar(0) == _('/')) { if (!file.empty() && file.GetChar(0) == _('/')) {
// absolute path, open file from another package // absolute path, open file from another package
Packaged* p = dynamic_cast<Packaged*>(this); Packaged* p = dynamic_cast<Packaged*>(this);
return packages.openFileFromPackage(p, file); return package_manager.openFileFromPackage(p, file);
} }
FileInfos::iterator it = files.find(normalize_internal_filename(file)); FileInfos::iterator it = files.find(normalize_internal_filename(file));
if (it == files.end()) { if (it == files.end()) {
...@@ -547,7 +547,7 @@ void Packaged::validate(Version) { ...@@ -547,7 +547,7 @@ void Packaged::validate(Version) {
} }
// check dependencies // check dependencies
FOR_EACH(dep, dependencies) { FOR_EACH(dep, dependencies) {
packages.checkDependency(*dep, true); package_manager.checkDependency(*dep, true);
} }
} }
......
...@@ -24,7 +24,7 @@ DECLARE_TYPEOF_COLLECTION(PackageVersion::FileInfo); ...@@ -24,7 +24,7 @@ DECLARE_TYPEOF_COLLECTION(PackageVersion::FileInfo);
// ----------------------------------------------------------------------------- : PackageManager : in memory // ----------------------------------------------------------------------------- : PackageManager : in memory
PackageManager packages; PackageManager package_manager;
void PackageManager::init() { void PackageManager::init() {
...@@ -148,7 +148,7 @@ bool PackageManager::installedVersion(const String& package_name, Version& versi ...@@ -148,7 +148,7 @@ bool PackageManager::installedVersion(const String& package_name, Version& versi
} }
} }
void PackageManager::installedPackages(vector<InstallablePackageP>& packages) { void PackageManager::findAllInstalledPackages(vector<InstallablePackageP>& packages) {
// from directories // from directories
vector<InstallablePackageP> more_packages; vector<InstallablePackageP> more_packages;
global.installedPackages(packages); global.installedPackages(packages);
...@@ -229,7 +229,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o ...@@ -229,7 +229,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
if (it1 == packages.end() || (*it1)->name > *it2) { if (it1 == packages.end() || (*it1)->name > *it2) {
// add new package to db // add new package to db
try { try {
PackagedP pack = ::packages.openAny(*it2, true); PackagedP pack = package_manager.openAny(*it2, true);
db_changed = true; db_changed = true;
PackageVersionP ver(new PackageVersion( PackageVersionP ver(new PackageVersion(
is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL)); is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL));
...@@ -244,7 +244,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o ...@@ -244,7 +244,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
} else { } else {
// ok, a package already in the db // ok, a package already in the db
try { try {
PackagedP pack = ::packages.openAny(*it2, true); PackagedP pack = package_manager.openAny(*it2, true);
(*it1)->check_status(*pack); (*it1)->check_status(*pack);
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), *it1)); packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), *it1));
} catch (const Error&) { db_changed = true; } } catch (const Error&) { db_changed = true; }
......
...@@ -149,7 +149,7 @@ class PackageManager { ...@@ -149,7 +149,7 @@ class PackageManager {
bool installedVersion(const String& pkg, Version& version_out); bool installedVersion(const String& pkg, Version& version_out);
/// Get all installed packages /// Get all installed packages
void installedPackages(vector<InstallablePackageP>& packages); void findAllInstalledPackages(vector<InstallablePackageP>& packages);
/// Install/uninstall a package /// Install/uninstall a package
void install(const InstallablePackage& package); void install(const InstallablePackage& package);
...@@ -162,7 +162,7 @@ class PackageManager { ...@@ -162,7 +162,7 @@ class PackageManager {
}; };
/// The global PackageManager instance /// The global PackageManager instance
extern PackageManager packages; extern PackageManager package_manager;
// ----------------------------------------------------------------------------- : PackageVersion // ----------------------------------------------------------------------------- : PackageVersion
......
...@@ -29,7 +29,7 @@ Reader::Reader(Packaged* pkg, const String& filename) ...@@ -29,7 +29,7 @@ Reader::Reader(Packaged* pkg, const String& filename)
: indent(0), expected_indent(0), state(OUTSIDE) : indent(0), expected_indent(0), state(OUTSIDE)
, ignore_invalid(false) , ignore_invalid(false)
, filename(filename), package(pkg), line_number(0), previous_line_number(0) , filename(filename), package(pkg), line_number(0), previous_line_number(0)
, input(packages.openFileFromPackage(package, filename)) , input(package_manager.openFileFromPackage(package, filename))
{ {
moveNext(); moveNext();
handleAppVersion(); handleAppVersion();
......
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