X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fpackage%2FRoot.hxx;h=69ac4804cbfa57d91db16051d2e51b850abfd45c;hb=32181a3956a8e7e1cb4bdb5338a260df7d343534;hp=176651091e98429e44f5777b886f16266653539c;hpb=fe9caad391ea0c839fe551525228d310461b2a84;p=simgear.git diff --git a/simgear/package/Root.hxx b/simgear/package/Root.hxx index 17665109..69ac4804 100644 --- a/simgear/package/Root.hxx +++ b/simgear/package/Root.hxx @@ -24,6 +24,9 @@ #include #include +#include +#include + class SGPropertyNode; namespace simgear @@ -41,11 +44,15 @@ namespace pkg class Package; class Catalog; class Install; + +typedef SGSharedPtr PackageRef; +typedef SGSharedPtr CatalogRef; +typedef SGSharedPtr InstallRef; + +typedef std::vector PackageList; +typedef std::vector CatalogList; -typedef std::vector PackageList; -typedef std::vector CatalogList; - -class Root +class Root : public SGReferenced { public: Root(const SGPath& aPath, const std::string& aVersion); @@ -55,8 +62,10 @@ public: void setLocale(const std::string& aLocale); - void setDelegate(Delegate* aDelegate); - + void addDelegate(Delegate* aDelegate); + + void removeDelegate(Delegate* aDelegate); + std::string getLocale() const; CatalogList catalogs() const; @@ -72,19 +81,35 @@ public: * set yet. */ void makeHTTPRequest(HTTP::Request* req); + + /** + * Cancel an HTTP request. + */ + void cancelHTTPRequest(HTTP::Request* req, const std::string& reason); /** - * the version string of the root. Catalogs must match this version, + * The catalog XML/property version in use. This is used to make incomaptible + * changes to the package/catalog syntax + */ + int catalogVersion() const; + + /** + * the version string of the application. Catalogs must match this version, * or they will be ignored / rejected. */ - std::string catalogVersion() const; - + std::string applicationVersion() const; + /** * refresh catalogs which are more than the maximum age (24 hours by default) * set force to true, to download all catalogs regardless of age. */ void refresh(bool aForce = false); + /** + * + */ + PackageList allPackages() const; + /** * retrieve packages matching a filter. * filter consists of required / minimum values, AND-ed together. @@ -97,30 +122,50 @@ public: */ PackageList packagesNeedingUpdate() const; - Package* getPackageById(const std::string& aId) const; + PackageRef getPackageById(const std::string& aId) const; + + CatalogRef getCatalogById(const std::string& aId) const; - Catalog* getCatalogById(const std::string& aId) const; + void scheduleToUpdate(InstallRef aInstall); + + /** + * remove a catalog. Will uninstall all packages originating + * from the catalog too. + */ + bool removeCatalogById(const std::string& aId); + + /** + * request thumbnail data from the cache / network + */ + void requestThumbnailData(const std::string& aUrl); - void scheduleToUpdate(Install* aInstall); + bool isInstallQueued(InstallRef aInstall) const; private: friend class Install; friend class Catalog; + friend class Package; - - void catalogRefreshBegin(Catalog* aCat); - void catalogRefreshComplete(Catalog* aCat, Delegate::FailureCode aReason); + InstallRef existingInstallForPackage(PackageRef p) const; + + void catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason); - void startNext(Install* aCurrent); + void startNext(InstallRef aCurrent); - void startInstall(Install* aInstall); - void installProgress(Install* aInstall, unsigned int aBytes, unsigned int aTotal); - void finishInstall(Install* aInstall); - void failedInstall(Install* aInstall, Delegate::FailureCode aReason); - + void startInstall(InstallRef aInstall); + void installProgress(InstallRef aInstall, unsigned int aBytes, unsigned int aTotal); + void finishInstall(InstallRef aInstall, Delegate::StatusCode aReason); + void cancelDownload(InstallRef aInstall); + + void registerInstall(InstallRef ins); + void unregisterInstall(InstallRef ins); + + class ThumbnailDownloader; class RootPrivate; std::auto_ptr d; }; - + +typedef SGSharedPtr RootRef; + } // of namespace pkg } // of namespace simgear