1 // Copyright (C) 2013 James Turner - zakalawe@mac.com
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #ifndef SG_PACKAGE_ROOT_HXX
19 #define SG_PACKAGE_ROOT_HXX
22 #include <memory> // for auto_ptr
24 #include <simgear/misc/sg_path.hxx>
25 #include <simgear/package/Delegate.hxx>
45 typedef std::vector<Package*> PackageList;
46 typedef std::vector<Catalog*> CatalogList;
51 Root(const SGPath& aPath, const std::string& aVersion);
56 void setLocale(const std::string& aLocale);
58 void setDelegate(Delegate* aDelegate);
60 std::string getLocale() const;
62 CatalogList catalogs() const;
64 void setMaxAgeSeconds(unsigned int seconds);
65 unsigned int maxAgeSeconds() const;
67 void setHTTPClient(HTTP::Client* aHTTP);
70 * Submit an HTTP request. The Root may delay or queue requests if it needs
71 * too, for example during startup when the HTTP engine may not have been
74 void makeHTTPRequest(HTTP::Request* req);
77 * the version string of the root. Catalogs must match this version,
78 * or they will be ignored / rejected.
80 std::string catalogVersion() const;
83 * refresh catalogs which are more than the maximum age (24 hours by default)
84 * set force to true, to download all catalogs regardless of age.
86 void refresh(bool aForce = false);
89 * retrieve packages matching a filter.
90 * filter consists of required / minimum values, AND-ed together.
92 PackageList packagesMatching(const SGPropertyNode* aFilter) const;
95 * retrieve all the packages which are installed
96 * and have a pending update
98 PackageList packagesNeedingUpdate() const;
100 Package* getPackageById(const std::string& aId) const;
102 Catalog* getCatalogById(const std::string& aId) const;
104 void scheduleToUpdate(Install* aInstall);
106 friend class Install;
107 friend class Catalog;
110 void catalogRefreshBegin(Catalog* aCat);
111 void catalogRefreshComplete(Catalog* aCat, Delegate::FailureCode aReason);
113 void startNext(Install* aCurrent);
115 void startInstall(Install* aInstall);
116 void installProgress(Install* aInstall, unsigned int aBytes, unsigned int aTotal);
117 void finishInstall(Install* aInstall);
118 void failedInstall(Install* aInstall, Delegate::FailureCode aReason);
121 std::auto_ptr<RootPrivate> d;
124 } // of namespace pkg
126 } // of namespace simgear
128 #endif // of SG_PACKAGE_ROOT_HXX