3 #ifndef SG_PACKAGE_ROOT_HXX
4 #define SG_PACKAGE_ROOT_HXX
11 #include <simgear/misc/sg_path.hxx>
12 #include <simgear/package/Delegate.hxx>
19 namespace HTTP { class Client; }
29 typedef std::vector<Package*> PackageList;
30 typedef std::vector<Catalog*> CatalogList;
32 typedef std::map<std::string, Catalog*> CatalogDict;
37 Root(const SGPath& aPath);
43 void setLocale(const std::string& aLocale);
45 void setDelegate(Delegate* aDelegate);
47 std::string getLocale() const;
49 CatalogList catalogs() const;
51 void setMaxAgeSeconds(int seconds);
53 void setHTTPClient(HTTP::Client* aHTTP);
55 HTTP::Client* getHTTPClient() const;
58 * refresh catalogs which are more than the maximum age (24 hours by default)
59 * set force to true, to download all catalogs regardless of age.
61 void refresh(bool aForce = false);
64 * retrieve packages matching a filter.
65 * filter consists of required / minimum values, AND-ed together.
67 PackageList packagesMatching(const SGPropertyNode* aFilter) const;
70 * retrieve all the packages which are installed
71 * and have a pending update
73 PackageList packagesNeedingUpdate() const;
75 Package* getPackageById(const std::string& aId) const;
77 Catalog* getCatalogById(const std::string& aId) const;
79 void scheduleToUpdate(Install* aInstall);
85 void catalogRefreshBegin(Catalog* aCat);
86 void catalogRefreshComplete(Catalog* aCat, bool aSuccess);
88 void startNext(Install* aCurrent);
90 void startInstall(Install* aInstall);
91 void installProgress(Install* aInstall, unsigned int aBytes, unsigned int aTotal);
92 void finishInstall(Install* aInstall);
93 void failedInstall(Install* aInstall, Delegate::FailureCode aReason);
98 CatalogDict m_catalogs;
99 unsigned int m_maxAgeSeconds;
100 Delegate* m_delegate;
102 std::set<Catalog*> m_refreshing;
103 std::deque<Install*> m_updateDeque;
106 } // of namespace pkg
108 } // of namespace simgear
110 #endif // of SG_PACKAGE_ROOT_HXX