s60devicerunconfiguration.h 8.29 KB
Newer Older
con's avatar
con committed
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
28
29
**
**************************************************************************/

30
31
32
#ifndef S60DEVICERUNCONFIGURATION_H
#define S60DEVICERUNCONFIGURATION_H

con's avatar
con committed
33
34
#include "launcher.h"

35
#include <projectexplorer/runconfiguration.h>
36
#include <projectexplorer/toolchain.h>
37

38
#include <QtCore/QProcess>
39
#include <QtCore/QFutureInterface>
40

41
42
43
44
45
QT_BEGIN_NAMESPACE
class QMessageBox;
class QWidget;
QT_END_NAMESPACE

46
namespace Debugger {
47
class DebuggerStartParameters;
48
}
49

50
51
52
53
namespace SymbianUtils {
class SymbianDevice;
}

54
namespace Qt4ProjectManager {
55
class QtVersion;
dt's avatar
dt committed
56

57
namespace Internal {
58
class Qt4ProFileNode;
Tobias Hunger's avatar
Tobias Hunger committed
59
class Qt4Target;
60
class S60DeviceRunConfigurationFactory;
61
62
63
64

class S60DeviceRunConfiguration : public ProjectExplorer::RunConfiguration
{
    Q_OBJECT
65
66
    friend class S60DeviceRunConfigurationFactory;

67
public:
Tobias Hunger's avatar
Tobias Hunger committed
68
    S60DeviceRunConfiguration(ProjectExplorer::Target *parent, const QString &proFilePath);
69
    virtual ~S60DeviceRunConfiguration();
70

Tobias Hunger's avatar
Tobias Hunger committed
71
    Qt4Target *qt4Target() const;
dt's avatar
dt committed
72

73
    bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const;
74
    QWidget *createConfigurationWidget();
75

con's avatar
con committed
76
77
    QString serialPortName() const;
    void setSerialPortName(const QString &name);
78

79
    QString targetName() const;
con's avatar
con committed
80
    QString packageFileNameWithTargetInfo() const;
81
82
    QString symbianPlatform() const;
    QString symbianTarget() const;
Friedemann Kleint's avatar
Friedemann Kleint committed
83
    bool isDebug() const;
84
    QString packageTemplateFileName() const;
85

86
    QString localExecutableFileName() const;
87
    QString signedPackage() const;
88
    const QtVersion *qtVersion() const;
89

90
91
92
    QStringList commandLineArguments() const;
    void setCommandLineArguments(const QStringList &args);

93
94
    ProjectExplorer::ToolChain::ToolChainType toolChainType() const;

95
96
    QVariantMap toMap() const;

97
98
signals:
    void targetInformationChanged();
con's avatar
con committed
99
    void serialPortNameChanged();
100
101

private slots:
102
    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
103

104
protected:
Tobias Hunger's avatar
Tobias Hunger committed
105
    S60DeviceRunConfiguration(ProjectExplorer::Target *parent, S60DeviceRunConfiguration *source);
106
107
    virtual bool fromMap(const QVariantMap &map);

108
private:
109
    ProjectExplorer::ToolChain::ToolChainType toolChainType(ProjectExplorer::BuildConfiguration *configuration) const;
110
    void ctor();
111
112

    QString m_proFilePath;
con's avatar
con committed
113
    QString m_serialPortName;
114
    QStringList m_commandLineArguments;
115
116
117
118
119
};

class S60DeviceRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
    Q_OBJECT
120

121
public:
122
    explicit S60DeviceRunConfigurationFactory(QObject *parent = 0);
123
    ~S60DeviceRunConfigurationFactory();
124

Tobias Hunger's avatar
Tobias Hunger committed
125
126
127
128
129
130
    bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
    ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
    bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
    ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
    bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
    ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
131

Tobias Hunger's avatar
Tobias Hunger committed
132
    QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
133
134
    // used to translate the ids to names to display to the user
    QString displayNameForId(const QString &id) const;
135
136
};

137
138
139
/* S60DeviceRunControlBase: Builds the package and starts launcher
 * to deploy. Subclasses can configure the launcher to run or start a debugger.
 * Building the  package comprises for:
140
 * GnuPoc: run 'make sis' with environment variables for signing set
141
 * Other:  run the makesis.exe tool, run signsis */
142

143
class S60DeviceRunControlBase : public ProjectExplorer::RunControl
144
145
146
{
    Q_OBJECT
public:
147
    explicit S60DeviceRunControlBase(ProjectExplorer::RunConfiguration *runConfiguration);
148
    ~S60DeviceRunControlBase();
149
150
151
152
    virtual void start();
    virtual void stop();
    virtual bool isRunning() const;

153
154
    static QMessageBox *createTrkWaitingMessageBox(const QString &port, QWidget *parent = 0);

155
156
157
protected:
    virtual void initLauncher(const QString &executable, trk::Launcher *) = 0;
    virtual void handleLauncherFinished() = 0;
158
159
160
    virtual bool checkConfiguration(QString *errorMessage,
                                    QString *settingsCategory,
                                    QString *settingsPage) const;
161
    void setReleaseDeviceAfterLauncherFinish(bool);
162

Friedemann Kleint's avatar
Friedemann Kleint committed
163
protected slots:
164
    void printApplicationOutput(const QString &output, bool onStdErr);
165
    void printApplicationOutput(const QString &output);
166
    void deviceRemoved(const SymbianUtils::SymbianDevice &);
Friedemann Kleint's avatar
Friedemann Kleint committed
167

168
private slots:
169
    void processStopped(uint pc, uint pid, uint tid, const QString& reason);
170
    void printConnectFailed(const QString &errorMessage);
con's avatar
con committed
171
    void printCopyingNotice();
172
    void printCreateFileFailed(const QString &filename, const QString &errorMessage);
173
    void printWriteFileFailed(const QString &filename, const QString &errorMessage);
174
    void printCloseFileFailed(const QString &filename, const QString &errorMessage);
con's avatar
con committed
175
    void printCopyProgress(int progress);
con's avatar
con committed
176
    void printInstallingNotice();
177
    void printInstallFailed(const QString &filename, const QString &errorMessage);
178
    void printInstallingFinished();
179
    void launcherFinished();
180
181
    void slotLauncherStateChanged(int);
    void slotWaitingForTrkClosed();
182
    void reportDeployFinished();
183

184
private:
185
    void startDeployment();
186

187
    ProjectExplorer::ToolChain::ToolChainType m_toolChain;
con's avatar
con committed
188
    QString m_serialPortName;
189
    QString m_serialPortFriendlyName;
190
    QString m_targetName;
191
    QStringList m_commandLineArguments;
con's avatar
con committed
192
    QString m_workingDirectory;
193
    QString m_executableFileName;
194
    QString m_qtDir;
con's avatar
con committed
195
    QString m_packageFileNameWithTarget; // Support for 4.6.1
196
    QString m_signedPackage;
197
    QString m_qtBinPath;
198
199
    bool m_releaseDeviceAfterLauncherFinish;
    bool m_handleDeviceRemoval;
200
    QFutureInterface<void> *m_deployProgress;
201
    trk::Launcher *m_launcher;
202
203
};

204
205
206
207
208
// Configure launcher to run the application
class S60DeviceRunControl : public S60DeviceRunControlBase
{
    Q_OBJECT
public:
209
    explicit S60DeviceRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227

protected:
    virtual void initLauncher(const QString &executable, trk::Launcher *);
    virtual void handleLauncherFinished();

private slots:
    void printStartingNotice();
    void printRunNotice(uint pid);
    void printRunFailNotice(const QString &errorMessage);

private:
};

class S60DeviceDebugRunControl : public S60DeviceRunControlBase
{
    Q_DISABLE_COPY(S60DeviceDebugRunControl)
    Q_OBJECT
public:
228
    explicit S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration);
229
230
231
232
    virtual ~S60DeviceDebugRunControl();

    virtual void stop();

233
protected:
234
235
    virtual void initLauncher(const QString &executable, trk::Launcher *);
    virtual void handleLauncherFinished();
236
237
238
    virtual bool checkConfiguration(QString *errorMessage,
                                    QString *settingsCategory,
                                    QString *settingsPage) const;
239
240
241
242
243

private slots:
    void debuggingFinished();
private:
    QSharedPointer<Debugger::DebuggerStartParameters> m_startParams;
244
    QString m_localExecutableFileName;
245
246
};

247
248
249
250
} // namespace Internal
} // namespace Qt4ProjectManager

#endif // S60DEVICERUNCONFIGURATION_H