]> git.mxchange.org Git - simgear.git/blob - simgear/package/Delegate.hxx
Packages: handle catalog versions better
[simgear.git] / simgear / package / Delegate.hxx
1 // Copyright (C) 2013  James Turner - zakalawe@mac.com
2 //
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.
7 //
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.
12 //
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.
16 //
17
18 #ifndef SG_PACKAGE_DELEGATE_HXX
19 #define SG_PACKAGE_DELEGATE_HXX
20
21 #include <simgear/misc/stdint.hxx>
22 #include <simgear/structure/SGSharedPtr.hxx>
23
24 namespace simgear
25 {
26
27 namespace pkg
28 {
29
30 class Install;
31 class Catalog;
32
33 typedef SGSharedPtr<Catalog> CatalogRef;
34 typedef SGSharedPtr<Install> InstallRef;
35
36 /**
37  * package delegate is the mechanism to discover progress / completion /
38  * errors in packaging steps asynchronously.
39  */
40 class Delegate
41 {
42 public:
43     typedef enum {
44         STATUS_SUCCESS = 0,
45         FAIL_UNKNOWN = 1,
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
53         STATUS_REFRESHED,
54         USER_CANCELLED
55     } StatusCode;
56
57
58     virtual ~Delegate() { }
59
60
61     /**
62      * emitted when a catalog refesh completes, either success or failure
63      * If catalog is null, this means /all/ catalogs have been refreshed
64      */
65     virtual void catalogRefreshed(CatalogRef, StatusCode aReason) = 0;
66
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;
70
71     /**
72      * Notification when catalogs/packages are added or removed
73      */
74     virtual void availablePackagesChanged() {}
75
76     virtual void dataForThumbnail(const std::string& aThumbnailUrl,
77                                   size_t lenth, const uint8_t* bytes) {}
78 };
79
80 } // of namespace pkg
81
82 } // of namespace simgear
83
84 #endif // of SG_PACKAGE_DELEGATE_HXX