-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.h
168 lines (148 loc) · 5.2 KB
/
package.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* Copyright (c) 2012 Holger Schletz <[email protected]>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PACKAGE_H
#define PACKAGE_H
#include <QMap>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QVariant>
#include "version.h"
#include "Installer/nsis.h"
/**
* @brief Base class for all packages
*
* This class should not be instantiated directly, but always by a subclass. It
* provides some helper methods useful for all packages.
*/
class Package : public QObject
{
Q_OBJECT
public:
/**
* @brief Constructor
* @param name %Package name, can later be queried via className()
* @param %minVersion Minimum supported version (optional)
*/
explicit Package(const char *name, const char *minVersion=0);
/**
* @brief Destructor
*/
virtual ~Package();
/**
* @brief Get a list of all configured packages
* @return QMap<QString, Package *>
*/
static QMap<QString, Package *> getPackages();
/**
* @brief Get minimum supported version
*
* Gets the minimum software version supported by the package class. Older
* versions might work or not, but are untested and not officially
* supported.
*
* The default implementation returns no version, meaning that the latest
* version gets downloaded automatically.
* @return Version
*/
Version getMinVersion();
/**
* @brief Build the package via the configured installer
*/
void build(QString version);
/**
* @brief Build the package via %NSIS
* @param installer NSIS instance
* @param version Requested version
*/
virtual void build(NSIS *installer, Version version);
/**
* @brief Get configured output file to build
*
* If the file already exists, a confirmation dialog is displayed.
* @return QString Full path to output file or empty on error/abort.
*/
QString getOutputFile();
/**
* @brief Clean up temporary files according to "Keep temp files" option
*/
void cleanup();
protected:
/**
* @brief Return a resource as string
* @param name Resource name
* @return QString Resource content
* @exception If resource name is invalid (programming error - should never happen in production)
*/
QString loadResource(QString name);
/**
* @brief Return a list of supported browser process names
*
* This is useful for the installation of browser plugins. The generated
* installer can check for running instances of supported browsers and force
* termination of browsers before proceeding.
* @return QStringList
*/
QStringList browsers();
/**
* @brief Delete a path (file or directory) recursively.
* @param path Path to delete
* @return bool Success
*/
bool rmPath(QString path);
/**
* @brief Extract a 7z archive to the working directory
*
* This requires an external command which is configured through the global
* "7z extraction command" and "7z extraction args" options.
* @param archive Archive file
* @return bool Success
*/
bool extract7zArchive(QString archive);
/**
* @brief List of temporary files
*
* Every temporary file generated during the package building process (by
* download or other means) should be noted in this list. They will then be
* cleaned up automatically according to the "Keep temp files" option.
*/
QStringList tempFiles;
/**
* @brief Error flag
*/
bool isError;
/**
* @brief Minimum supported version
*/
Version minVersion;
/**
* @brief Get a value from package's section in the config file
* @param key Key name, without package prefix
* @param defaultValue Value to return if no value is present in the config file
* @return QVariant
*/
QVariant getConfig(const QString &key, const QVariant &defaultValue=QVariant());
};
#endif // PACKAGE_H