]> git.mxchange.org Git - simgear.git/blob - simgear/package/Delegate.hxx
Catalog install feedback.
[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 namespace simgear
22 {
23         
24 namespace pkg
25 {
26     
27 class Install;
28 class Catalog;
29     
30 /**
31  * package delegate is the mechanism to discover progress / completion /
32  * errors in packaging steps asynchronously.
33  */
34 class Delegate
35 {
36 public:
37     typedef enum {
38         FAIL_SUCCESS = 0, ///< not a failure :)
39         FAIL_UNKNOWN = 1,
40         FAIL_IN_PROGRESS, ///< downloading/installation in progress (not a failure :P)
41         FAIL_CHECKSUM,  ///< package MD5 verificstion failed
42         FAIL_DOWNLOAD,  ///< network issue
43         FAIL_EXTRACT,   ///< package archive failed to extract cleanly
44         FAIL_FILESYSTEM,    ///< unknown filesystem error occurred
45         FAIL_VERSION, ///< version check mismatch
46         CATALOG_REFRESHED
47     } FailureCode;
48     
49     
50     virtual ~Delegate() { }
51     
52     /**
53      * invoked when all catalogs have finished refreshing - either successfully
54      * or with a failure.
55      */
56     virtual void refreshComplete() = 0;
57     
58     /**
59      * emitted when a catalog fails to refresh, due to a network issue or
60      * some other failure.
61      */
62     virtual void failedRefresh(Catalog*, FailureCode aReason) = 0;
63     
64     virtual void startInstall(Install* aInstall) = 0;
65     virtual void installProgress(Install* aInstall, unsigned int aBytes, unsigned int aTotal) = 0;
66     virtual void finishInstall(Install* aInstall) = 0;
67     
68    
69     virtual void failedInstall(Install* aInstall, FailureCode aReason) = 0;
70     
71 };  
72     
73 } // of namespace pkg
74
75 } // of namespace simgear
76
77 #endif // of SG_PACKAGE_DELEGATE_HXX