]> git.mxchange.org Git - simgear.git/blob - simgear/package/Install.hxx
utf8ToLatin1: return original instead of crashing on non-UTF-8 input
[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 #include <simgear/structure/SGReferenced.hxx>
27 #include <simgear/structure/SGSharedPtr.hxx>
28
29 namespace simgear
30 {
31     
32 namespace pkg
33 {
34
35 // forward decls
36 class Package;
37 class Catalog;
38 class Install;
39   
40 typedef SGSharedPtr<Package> PackageRef;
41 typedef SGSharedPtr<Catalog> CatalogRef;  
42 typedef SGSharedPtr<Install> InstallRef;
43   
44 /**
45  *
46  */
47 class Install : public SGReferenced
48 {
49 public:
50     /**
51      * create from a directory on disk, or fail.
52      */
53     static InstallRef createFromPath(const SGPath& aPath, CatalogRef aCat);
54     
55     unsigned int revsion() const
56         { return m_revision; }
57     
58     PackageRef package() const
59         { return m_package; } 
60     
61     SGPath path() const
62         { return m_path; }
63     
64     bool hasUpdate() const;
65     
66     void startUpdate();
67     
68     void uninstall();
69     
70 // boost signals time?
71     // failure
72     // progress
73     // completed
74     
75 private:
76     friend class Package;
77     
78     class PackageArchiveDownloader;
79     friend class PackageArchiveDownloader;
80     
81     Install(PackageRef aPkg, const SGPath& aPath);
82     
83     void parseRevision();
84     void writeRevisionFile();
85     
86     void installResult(Delegate::FailureCode aReason);
87     void installProgress(unsigned int aBytes, unsigned int aTotal);
88     
89     PackageRef m_package;
90     unsigned int m_revision; ///< revision on disk
91     SGPath m_path; ///< installation point on disk
92     
93     PackageArchiveDownloader* m_download;
94 };
95     
96     
97 } // of namespace pkg
98
99 } // of namespace simgear
100
101 #endif // of SG_PACKAGE_CATALOG_HXX