]> git.mxchange.org Git - simgear.git/blob - simgear/package/Install.hxx
Tweak HTTP code to always sleep.
[simgear.git] / simgear / package / Install.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_INSTALL_HXX
19 #define SG_PACKAGE_INSTALL_HXX
20
21 #include <vector>
22
23 #include <simgear/misc/sg_path.hxx>
24 #include <simgear/package/Delegate.hxx>
25
26 namespace simgear
27 {
28     
29 namespace pkg
30 {
31
32 // forward decls
33 class Package;
34 class Catalog;
35     
36 /**
37  *
38  */
39 class Install
40 {
41 public:
42     /**
43      * create from a directory on disk, or fail.
44      */
45     static Install* createFromPath(const SGPath& aPath, Catalog* aCat);
46     
47     unsigned int revsion() const
48         { return m_revision; }
49     
50     Package* package() const
51         { return m_package; } 
52     
53     SGPath path() const
54         { return m_path; }
55     
56     bool hasUpdate() const;
57     
58     void startUpdate();
59     
60     void uninstall();
61     
62 // boost signals time?
63     // failure
64     // progress
65     // completed
66     
67 private:
68     friend class Package;
69     
70     class PackageArchiveDownloader;
71     friend class PackageArchiveDownloader;
72     
73     Install(Package* aPkg, const SGPath& aPath);
74     
75     void parseRevision();
76     void writeRevisionFile();
77     
78     void installResult(Delegate::FailureCode aReason);
79     void installProgress(unsigned int aBytes, unsigned int aTotal);
80     
81     Package* m_package;
82     unsigned int m_revision; ///< revision on disk
83     SGPath m_path; ///< installation point on disk
84     
85     PackageArchiveDownloader* m_download;
86 };
87     
88     
89 } // of namespace pkg
90
91 } // of namespace simgear
92
93 #endif // of SG_PACKAGE_CATALOG_HXX