OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-s60 / s60createpackagestep.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef S60CREATEPACKAGESTEP_H
34 #define S60CREATEPACKAGESTEP_H
35
36 #include "ui_s60createpackagestep.h"
37
38 #include <projectexplorer/buildstep.h>
39 #include <qt4projectmanager/makestep.h>
40
41 #include <QtCore/QMutex>
42 #include <QtCore/QWaitCondition>
43
44 QT_BEGIN_NAMESPACE
45 class QSettings;
46 QT_END_NAMESPACE
47
48 namespace Utils {
49 class CheckableMessageBox;
50 } // namespace Utils
51
52 namespace Qt4ProjectManager {
53 namespace Internal {
54
55 class S60CreatePackageParser;
56
57 class S60CreatePackageStepFactory : public ProjectExplorer::IBuildStepFactory
58 {
59     Q_OBJECT
60 public:
61     explicit S60CreatePackageStepFactory(QObject *parent = 0);
62     ~S60CreatePackageStepFactory();
63
64     // used to show the list of possible additons to a target, returns a list of types
65     QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const;
66     // used to translate the types to names to display to the user
67     QString displayNameForId(const QString &id) const;
68
69     bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const;
70     ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id);
71     // used to recreate the runConfigurations when restoring settings
72     bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const;
73     ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map);
74     bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const;
75     ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product);
76 };
77
78
79 class S60CreatePackageStep : public ProjectExplorer::BuildStep
80 {
81     Q_OBJECT
82     friend class S60CreatePackageStepFactory;
83
84 public:
85     enum SigningMode {
86         SignSelf = 0,
87         SignCustom = 1,
88         NotSigned = 2
89     };
90
91     explicit S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl);
92     virtual ~S60CreatePackageStep();
93
94     virtual bool init();
95     virtual void run(QFutureInterface<bool> &fi);
96     virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
97     virtual bool immutable() const;
98
99     QVariantMap toMap() const;
100
101     SigningMode signingMode() const;
102     void setSigningMode(SigningMode mode);
103     QString customSignaturePath() const;
104     void setCustomSignaturePath(const QString &path);
105     QString customKeyPath() const;
106     void setCustomKeyPath(const QString &path);
107     QString passphrase() const   ;
108     void setPassphrase(const QString &passphrase);
109     QString keyId() const;
110     void setKeyId(const QString &keyId);
111     bool createsSmartInstaller() const;
112     void setCreatesSmartInstaller(bool value);
113
114     void resetPassphrases();
115
116 signals:
117     void badPassphrase();
118     void warnAboutPatching();
119
120 protected:
121     S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, S60CreatePackageStep *bs);
122     S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, const QString &id);
123     bool fromMap(const QVariantMap &map);
124
125     Qt4BuildConfiguration *qt4BuildConfiguration() const;
126
127 private slots:
128     void packageWarningDialogDone();
129     void packageDone(int, QProcess::ExitStatus);
130     void processReadyReadStdOutput();
131     void processReadyReadStdError();
132     void checkForCancel();
133     void definePassphrase();
134
135     void packageWasPatched(const QString &, const QStringList &);
136     void handleWarnAboutPatching();
137
138 private:
139     void stdOutput(const QString &line);
140     void stdError(const QString &line);
141
142     void reportPackageStepIssue(const QString &message, bool isError );
143     void setupProcess();
144     bool createOnePackage();
145     bool validateCustomSigningResources(const QStringList &capabilitiesInPro);
146
147     QString generateKeyId(const QString &keyPath) const;
148     QString loadPassphraseForKey(const QString &keyId);
149     void savePassphraseForKey(const QString &keyId, const QString &passphrase);
150     QString elucidatePassphrase(QByteArray obfuscatedPassphrase, const QString &key) const;
151     QByteArray obfuscatePassphrase(const QString &passphrase, const QString &key) const;
152
153     QStringList m_workingDirectories;
154
155     QString m_makeCmd;
156     Utils::Environment m_environment;
157     QStringList m_args;
158
159     void ctor_package();
160
161     SigningMode m_signingMode;
162     QString m_customSignaturePath;
163     QString m_customKeyPath;
164     QString m_passphrase;
165     QString m_keyId;
166     bool m_createSmartInstaller;
167     ProjectExplorer::IOutputParser *m_outputParserChain;
168
169     QProcess *m_process;
170     QTimer *m_timer;
171     QEventLoop *m_eventLoop;
172     QFutureInterface<bool> *m_futureInterface;
173
174     QWaitCondition m_waitCondition;
175     QMutex m_mutex;
176
177     bool m_cancel;
178
179     QSettings *m_passphrases;
180     S60CreatePackageParser *m_parser;
181     QList<QPair<QString, QStringList> > m_packageChanges;
182
183     bool m_suppressPatchWarningDialog;
184     Utils::CheckableMessageBox *m_patchWarningDialog;
185 };
186
187 class S60CreatePackageStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
188 {
189     Q_OBJECT
190 public:
191     S60CreatePackageStepConfigWidget(S60CreatePackageStep *signStep);
192     QString displayName() const;
193     void init();
194     QString summaryText() const;
195
196 private slots:
197     void updateUi();
198     void updateFromUi();
199     void resetPassphrases();
200     void signatureChanged(QString certFile);
201     void displayCertificateDetails();
202
203 private:
204     S60CreatePackageStep *m_signStep;
205
206     Ui::S60CreatePackageStepWidget m_ui;
207 };
208
209 } // Internal
210 } // Qt4ProjectManager
211
212 #endif // S60CREATEPACKAGESTEP_H