aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h
blob: 94ca55fe2e960c69640361a0b43cee8cbf4c53f8 (plain)
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** 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
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

#ifndef MAEMORUNCONFIGURATION_H
#define MAEMORUNCONFIGURATION_H

#include "maemodeviceconfigurations.h"

#include <QtCore/QDateTime>
#include <QtGui/QWidget>

#include <debugger/debuggermanager.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/applicationlauncher.h>

namespace Qt4ProjectManager {
class Qt4Project;

namespace Internal {

class MaemoManager;
class MaemoToolChain;
class Qt4ProFileNode;

#define USE_SSL_PASSWORD 0

class ErrorDumper : public QObject
{
    Q_OBJECT
public:
    ErrorDumper(QObject *parent = 0)
        : QObject(parent) {}

public slots:
    void printToStream(QProcess::ProcessError error);
};


class MaemoRunConfiguration : public ProjectExplorer::RunConfiguration
{
    Q_OBJECT
public:
    MaemoRunConfiguration(ProjectExplorer::Project *project,
                          const QString &proFilePath);
    ~MaemoRunConfiguration();

    QString type() const;
    bool isEnabled(ProjectExplorer::BuildConfiguration *config) const;
    using RunConfiguration::isEnabled;
    QWidget *configurationWidget();
    Qt4Project *project() const;

    void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
    void restore(const ProjectExplorer::PersistentSettingsReader &reader);

    bool currentlyNeedsDeployment() const;
    void wasDeployed();

    bool hasDebuggingHelpers() const;
    bool debuggingHelpersNeedDeployment() const;
    void debuggingHelpersDeployed();

    QString maddeRoot() const;
    QString executable() const;
    const QString sysRoot() const;
    const QStringList arguments() const;
    void setArguments(const QStringList &args);
    void setDeviceConfig(const MaemoDeviceConfig &deviceConfig);
    MaemoDeviceConfig deviceConfig() const;

    QString simulator() const;
    QString simulatorArgs() const;
    QString simulatorPath() const;
    QString visibleSimulatorParameter() const;

    const QString sshCmd() const;
    const QString scpCmd() const;
    const QString gdbCmd() const;
    const QString dumperLib() const;

    bool isQemuRunning() const;

#if USE_SSL_PASSWORD
    // Only valid if remoteHostRequiresPassword() == true.
    void setRemotePassword(const QString &password);
    const QString remoteUserPassword() const { return m_remoteUserPassword; }

    void setRemoteHostRequiresPassword(bool requiresPassword);
    bool remoteHostRequiresPassword() const { return m_remoteHostRequiresPassword; }
#endif

signals:
    void deviceConfigurationsUpdated();
    void targetInformationChanged();
    void cachedSimulatorInformationChanged();
    void qemuProcessStatus(bool running);

private slots:
    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
    void updateDeviceConfigurations();
    void invalidateCachedTargetInformation();

    void setUserSimulatorPath(const QString &path);
    void invalidateCachedSimulatorInformation();
    void resetCachedSimulatorInformation();

    void startStopQemu();
    void qemuProcessFinished();

    void enabledStateChanged();

private:
    void updateTarget();
    void updateSimulatorInformation();
    const QString cmd(const QString &cmdName) const;
    const MaemoToolChain *toolchain() const;
    bool fileNeedsDeployment(const QString &path, const QDateTime &lastDeployed) const;

private:
    QString m_executable;
    QString m_proFilePath;
    bool m_cachedTargetInformationValid;

    QString m_simulator;
    QString m_simulatorArgs;
    QString m_simulatorPath;
    QString m_visibleSimulatorParameter;
    bool m_cachedSimulatorInformationValid;

    bool m_isUserSetSimulator;
    QString m_userSimulatorPath;

    QString m_gdbPath;

    MaemoDeviceConfig m_devConfig;
    QStringList m_arguments;

    QDateTime m_lastDeployed;
    QDateTime m_debuggingHelpersLastDeployed;

    QProcess *qemu;
    ErrorDumper dumper;

#if USE_SSL_PASSWORD
    QString m_remoteUserPassword;
    bool m_remoteHostRequiresPassword;
#endif
};


class MaemoRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
    Q_OBJECT
public:
    MaemoRunConfigurationFactory(QObject *parent);
    ~MaemoRunConfigurationFactory();

    bool canRestore(const QString &type) const;
    QStringList availableCreationTypes(ProjectExplorer::Project *project) const;
    QString displayNameForType(const QString &type) const;
    ProjectExplorer::RunConfiguration *create(ProjectExplorer::Project *project,
                                              const QString &type);


private slots:
    void addedRunConfiguration(ProjectExplorer::Project* project);
    void removedRunConfiguration(ProjectExplorer::Project* project);

    void projectAdded(ProjectExplorer::Project* project);
    void projectRemoved(ProjectExplorer::Project* project);
    void currentProjectChanged(ProjectExplorer::Project* project);
};


class MaemoRunControlFactory : public ProjectExplorer::IRunControlFactory
{
    Q_OBJECT
public:
    MaemoRunControlFactory(QObject *parent = 0);
    bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
                const QString &mode) const;
    ProjectExplorer::RunControl* create(ProjectExplorer::RunConfiguration *runConfiguration,
                                        const QString &mode);
    QString displayName() const;
    QWidget *configurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
};

} // namespace Internal
} // namespace Qt4ProjectManager


#endif // MAEMORUNCONFIGURATION_H