]> git.mxchange.org Git - simgear.git/blob - simgear/package/Delegate.hxx
Make nasal/iolib.h available to flightgear (for io.open)
[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     } FailureCode;
47     
48     
49     virtual ~Delegate() { }
50     
51     /**
52      * invoked when all catalogs have finished refreshing - either successfully
53      * or with a failure.
54      */
55     virtual void refreshComplete() = 0;
56     
57     /**
58      * emitted when a catalog fails to refresh, due to a network issue or
59      * some other failure.
60      */
61     virtual void failedRefresh(Catalog*, FailureCode aReason) = 0;
62     
63     virtual void startInstall(Install* aInstall) = 0;
64     virtual void installProgress(Install* aInstall, unsigned int aBytes, unsigned int aTotal) = 0;
65     virtual void finishInstall(Install* aInstall) = 0;
66     
67    
68     virtual void failedInstall(Install* aInstall, FailureCode aReason) = 0;
69     
70 };  
71     
72 } // of namespace pkg
73
74 } // of namespace simgear
75
76 #endif // of SG_PACKAGE_DELEGATE_HXX