X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Faddon%2Faddon_manager.hpp;h=68e1953c4577a776853e3eb86103b487a6cc94b7;hb=417d2f8152e495270d3e1dc78be0a573d6bad20b;hp=22a2db19c5441efa5e20e6cc5a698cfafa35a959;hpb=1ca7a41254b95a52083b63496b8a18048ee55253;p=supertux.git diff --git a/src/addon/addon_manager.hpp b/src/addon/addon_manager.hpp index 22a2db19c..68e1953c4 100644 --- a/src/addon/addon_manager.hpp +++ b/src/addon/addon_manager.hpp @@ -1,5 +1,6 @@ // SuperTux - Add-on Manager // Copyright (C) 2007 Christoph Sommer +// 2014 Ingo Ruhnke // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -17,82 +18,70 @@ #ifndef HEADER_SUPERTUX_ADDON_ADDON_MANAGER_HPP #define HEADER_SUPERTUX_ADDON_ADDON_MANAGER_HPP +#include #include #include +#include "addon/downloader.hpp" #include "util/currenton.hpp" #include "util/reader_fwd.hpp" #include "util/writer_fwd.hpp" class Addon; +class AddonRepository; -/** - * Checks for, installs and removes Add-ons - */ +typedef std::string AddonId; + +/** Checks for, installs and removes Add-ons */ class AddonManager : public Currenton { +private: + typedef std::vector > AddonList; + + Downloader m_downloader; + std::string m_addon_directory; + std::string m_repository_url; + std::vector& m_ignored_addon_ids; + + AddonList m_installed_addons; + AddonList m_repository_addons; + public: - AddonManager(); + AddonManager(const std::string& addon_directory, + std::vector& enabled_addons_); ~AddonManager(); - /** - * returns a list of installed Add-ons - */ - std::vector get_addons(); - - /** - * downloads list of available Add-ons - */ + bool has_online_support() const; void check_online(); - /** - * Download and install Add-on - */ - void install(Addon* addon); - - /** - * Physically delete Add-on - */ - void remove(Addon* addon); - - /** - * Unload Add-on and mark as not to be loaded automatically - */ - void disable(Addon* addon); - - /** - * Load Add-on and mark as to be loaded automatically - */ - void enable(Addon* addon); - - /** - * Remove Add-on from search path - */ - void unload(Addon* addon); - - /** - * Add Add-on to search path - */ - void load(Addon* addon); - - /** - * Loads all enabled Add-ons, i.e. adds them to the search path - */ - void load_addons(); - - /** - * Write AddonManager configuration to Lisp - */ - void write(Writer& writer); - - /** - * Read AddonManager configuration from Lisp - */ - void read(const Reader& lisp); + std::vector get_repository_addons() const; + std::vector get_installed_addons() const; + + Addon& get_repository_addon(const AddonId& addon); + Addon& get_installed_addon(const AddonId& addon); + + void install_addon(const AddonId& addon_id); + void uninstall_addon(const AddonId& addon_id); + + void enable_addon(const AddonId& addon_id); + void disable_addon(const AddonId& addon_id); + +private: + std::vector scan_for_archives() const; + void add_installed_addons(); + AddonList parse_addon_infos(const std::string& addoninfos) const; + + /** add \a archive, given as physfs path, to the list of installed + archives */ + void add_installed_archive(const std::string& archive, const std::string& md5); + + /** search for an .nfo file in the top level directory that + originates from \a archive, \a archive is a OS path */ + std::string scan_for_info(const std::string& archive) const; private: - std::vector addons; - std::vector ignored_addon_filenames; + AddonManager(const AddonManager&) = delete; + AddonManager& operator=(const AddonManager&) = delete; }; #endif