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_DELEGATE_HXX
19 #define SG_PACKAGE_DELEGATE_HXX
21 #include <simgear/misc/stdint.hxx>
22 #include <simgear/structure/SGSharedPtr.hxx>
33 typedef SGSharedPtr<Catalog> CatalogRef;
34 typedef SGSharedPtr<Install> InstallRef;
37 * package delegate is the mechanism to discover progress / completion /
38 * errors in packaging steps asynchronously.
46 STATUS_IN_PROGRESS, ///< downloading/installation in progress
47 FAIL_CHECKSUM, ///< package MD5 verificstion failed
48 FAIL_DOWNLOAD, ///< network issue
49 FAIL_EXTRACT, ///< package archive failed to extract cleanly
50 FAIL_FILESYSTEM, ///< unknown filesystem error occurred
51 FAIL_VERSION, ///< version check mismatch
52 FAIL_NOT_FOUND, ///< package URL returned a 404
58 virtual ~Delegate() { }
62 * emitted when a catalog refesh completes, either success or failure
63 * If catalog is null, this means /all/ catalogs have been refreshed
65 virtual void catalogRefreshed(CatalogRef, StatusCode aReason) = 0;
67 virtual void startInstall(InstallRef aInstall) = 0;
68 virtual void installProgress(InstallRef aInstall, unsigned int aBytes, unsigned int aTotal) = 0;
69 virtual void finishInstall(InstallRef aInstall, StatusCode aReason) = 0;
72 * Notification when catalogs/packages are added or removed
74 virtual void availablePackagesChanged() {}
76 virtual void dataForThumbnail(const std::string& aThumbnailUrl,
77 size_t lenth, const uint8_t* bytes) {}
82 } // of namespace simgear
84 #endif // of SG_PACKAGE_DELEGATE_HXX