X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Faddon%2Faddon_manager.hpp;h=fafebb0daf4392a11ee36b627c9ec7325e08dbdf;hb=9af7ca781183b7d57410e5cd3b8bc7f8128ed1b0;hp=57ae3de9edb2f085a53e361444fe609ab7ad5aa7;hpb=0dee41ef4b863479e1dd92891ace3d048d987de7;p=supertux.git diff --git a/src/addon/addon_manager.hpp b/src/addon/addon_manager.hpp index 57ae3de9e..fafebb0da 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,63 +18,79 @@ #ifndef HEADER_SUPERTUX_ADDON_ADDON_MANAGER_HPP #define HEADER_SUPERTUX_ADDON_ADDON_MANAGER_HPP +#include #include #include #include #include "addon/downloader.hpp" +#include "supertux/gameconfig.hpp" #include "util/currenton.hpp" #include "util/reader_fwd.hpp" #include "util/writer_fwd.hpp" class Addon; +class AddonRepository; +class TransferStatus; +using TransferStatusPtr = std::shared_ptr; -typedef int AddonId; +typedef std::string AddonId; /** Checks for, installs and removes Add-ons */ class AddonManager : public Currenton { +private: + using AddonList = std::vector >; + + Downloader m_downloader; + std::string m_addon_directory; + std::string m_repository_url; + std::vector& m_addon_config; + + AddonList m_installed_addons; + AddonList m_repository_addons; + + bool m_has_been_updated; + + TransferStatusPtr m_transfer_status; + public: AddonManager(const std::string& addon_directory, - std::vector& ignored_addon_filenames_); + std::vector& addon_config); ~AddonManager(); - /** returns a list of installed Add-ons */ - const std::vector >& get_addons() const; - - /** Returns true if online support is available */ bool has_online_support() const; - - /** downloads list of available Add-ons */ + bool has_been_updated() const; void check_online(); + TransferStatusPtr request_check_online(); - /** Download and install Add-on */ - void install(Addon& addon); - /** Physically delete Add-on */ - void remove(Addon& addon); + std::vector get_repository_addons() const; + std::vector get_installed_addons() const; - /** Load Add-on and mark as to be loaded automatically */ - void enable(Addon& addon); - /** Unload Add-on and mark as not to be loaded automatically */ - void disable(Addon& addon); + Addon& get_repository_addon(const AddonId& addon); + Addon& get_installed_addon(const AddonId& addon); - Addon& get_addon(int id); - int get_num_addons() const { return static_cast(m_addons.size()); } + TransferStatusPtr request_install_addon(const AddonId& addon_id); + void install_addon(const AddonId& addon_id); + void uninstall_addon(const AddonId& addon_id); - /** Loads all enabled Add-ons, i.e. adds them to the search path */ - void load_addons(); + void enable_addon(const AddonId& addon_id); + void disable_addon(const AddonId& addon_id); -private: - /** Add Add-on to search path */ - void load(Addon& addon); - /** Remove Add-on from search path */ - void unload(Addon& addon); + void update(); private: - Downloader m_downloader; - std::string m_addon_directory; - std::vector > m_addons; - std::vector& m_ignored_addon_filenames; + std::vector scan_for_archives() const; + void add_installed_addons(); + AddonList parse_addon_infos(const std::string& filename) 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: AddonManager(const AddonManager&) = delete;