maemodeploystep.h 6.33 KB
Newer Older
1
2
3
4
5
6
7
8
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
con's avatar
con committed
9
** No Commercial Usage
10
**
con's avatar
con committed
11
12
13
14
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
15
16
17
18
19
20
21
22
23
24
**
** 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.
**
con's avatar
con committed
25
26
27
28
29
30
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
31
32
33
**
**************************************************************************/

34
35
36
#ifndef MAEMODEPLOYSTEP_H
#define MAEMODEPLOYSTEP_H

37
38
#include "maemodeployable.h"
#include "maemodeviceconfigurations.h"
39
#include "maemomountspecification.h"
40
41

#include <coreplugin/ssh/sftpdefs.h>
42
43
#include <projectexplorer/buildstep.h>

44
45
46
47
48
49
50
51
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QPair>
#include <QtCore/QSharedPointer>

QT_BEGIN_NAMESPACE
class QEventLoop;
Christian Kandeler's avatar
Christian Kandeler committed
52
class QProcess;
ck's avatar
ck committed
53
class QTimer;
54
55
56
57
58
59
60
61
QT_END_NAMESPACE

namespace Core {
class SftpChannel;
class SshConnection;
class SshRemoteProcess;
}

62
63
namespace Qt4ProjectManager {
namespace Internal {
ck's avatar
ck committed
64
class MaemoRemoteMounter;
65
class MaemoDeployables;
66
class MaemoDeviceConfigListModel;
67
class MaemoPackageCreationStep;
Christian Kandeler's avatar
Christian Kandeler committed
68
class MaemoToolChain;
69
70
71
72
73
74

class MaemoDeployStep : public ProjectExplorer::BuildStep
{
    Q_OBJECT
    friend class MaemoDeployStepFactory;
public:
Tobias Hunger's avatar
Tobias Hunger committed
75
    MaemoDeployStep(ProjectExplorer::BuildStepList *bc);
76

77
78
    virtual ~MaemoDeployStep();
    MaemoDeviceConfig deviceConfig() const;
79
    MaemoDeviceConfigListModel *deviceConfigModel() const { return m_deviceConfigModel; }
80
81
82
    bool currentlyNeedsDeployment(const QString &host,
        const MaemoDeployable &deployable) const;
    void setDeployed(const QString &host, const MaemoDeployable &deployable);
83
    MaemoDeployables *deployables() const { return m_deployables; }
84
    QSharedPointer<Core::SshConnection> sshConnection() const { return m_connection; }
85

86
87
    bool isDeployToSysrootEnabled() const { return m_deployToSysroot; }
    void setDeployToSysrootEnabled(bool deploy) { m_deployToSysroot = deploy; }
Christian Kandeler's avatar
Christian Kandeler committed
88

89
90
91
92
93
94
signals:
    void done();
    void error();

private slots:
    void start();
95
    void stop();
96
97
    void handleConnected();
    void handleConnectionFailure();
ck's avatar
ck committed
98
99
100
    void handleMounted();
    void handleUnmounted();
    void handleMountError(const QString &errorMsg);
101
    void handleMountDebugOutput(const QString &output);
ck's avatar
ck committed
102
103
104
    void handleProgressReport(const QString &progressMsg);
    void handleCopyProcessFinished(int exitStatus);
    void handleCleanupTimeout();
Christian Kandeler's avatar
Christian Kandeler committed
105
106
107
    void handleSysrootInstallerFinished();
    void handleSysrootInstallerOutput();
    void handleSysrootInstallerErrorOutput();
108
109
110
111
    void handleSftpChannelInitialized();
    void handleSftpChannelInitializationFailed(const QString &error);
    void handleSftpJobFinished(Core::SftpJobId job, const QString &error);
    void handleInstallationFinished(int exitStatus);
Christian Kandeler's avatar
Christian Kandeler committed
112
113
    void handleDeviceInstallerOutput(const QByteArray &output);
    void handleDeviceInstallerErrorOutput(const QByteArray &output);
114
115

private:
Tobias Hunger's avatar
Tobias Hunger committed
116
    MaemoDeployStep(ProjectExplorer::BuildStepList *bc,
117
118
119
120
121
        MaemoDeployStep *other);
    virtual bool init();
    virtual void run(QFutureInterface<bool> &fi);
    virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
    virtual bool immutable() const { return true; }
122
123
124
125
126
    virtual QVariantMap toMap() const;
    virtual bool fromMap(const QVariantMap &map);

    void ctor();
    void raiseError(const QString &error);
Christian Kandeler's avatar
Christian Kandeler committed
127
    void writeOutput(const QString &text, OutputFormat = MessageOutput);
128
129
130
    void addDeployTimesToMap(QVariantMap &map) const;
    void getDeployTimesFromMap(const QVariantMap &map);
    const MaemoPackageCreationStep *packagingStep() const;
ck's avatar
ck committed
131
    QString deployMountPoint() const;
Christian Kandeler's avatar
Christian Kandeler committed
132
    const MaemoToolChain *toolChain() const;
133
    void copyNextFileToDevice();
134
    bool addMountSpecification(const MaemoMountSpecification &mountSpec);
Christian Kandeler's avatar
Christian Kandeler committed
135
    void installToSysroot();
136
    QString uploadDir() const;
137
138
139
140
141
    void connectToDevice();
    void unmountOldDirs();
    void setupMount();
    void prepareSftpConnection();
    void runDpkg(const QString &packageFilePath);
142
143

    static const QLatin1String Id;
144

145
    MaemoDeployables * const m_deployables;
146
    QSharedPointer<Core::SshConnection> m_connection;
Christian Kandeler's avatar
Christian Kandeler committed
147
    QProcess *m_sysrootInstaller;
148
149
    typedef QPair<MaemoDeployable, QSharedPointer<Core::SshRemoteProcess> > DeviceDeployAction;
    QScopedPointer<DeviceDeployAction> m_currentDeviceDeployAction;
ck's avatar
ck committed
150
151
152
153
    QList<MaemoDeployable> m_filesToCopy;
    MaemoRemoteMounter *m_mounter;
    QTimer *m_cleanupTimer;
    bool m_canStart;
Christian Kandeler's avatar
Christian Kandeler committed
154
155
156
    bool m_deployToSysroot;
    enum UnmountState { OldDirsUnmount, CurrentDirsUnmount, CurrentMountsUnmount };
    UnmountState m_unmountState;
157
    QSharedPointer<Core::SftpChannel> m_uploader;
Christian Kandeler's avatar
Christian Kandeler committed
158
    QSharedPointer<Core::SshRemoteProcess> m_deviceInstaller;
ck's avatar
ck committed
159

160
    bool m_stopped;
ck's avatar
ck committed
161
162
    bool m_needsInstall;
    bool m_connecting;
163
164
    typedef QPair<MaemoDeployable, QString> DeployablePerHost;
    QHash<DeployablePerHost, QDateTime> m_lastDeployed;
165
    MaemoDeviceConfigListModel *m_deviceConfigModel;
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
};

class MaemoDeployEventHandler : public QObject
{
    Q_OBJECT
public:
    MaemoDeployEventHandler(MaemoDeployStep *deployStep,
        QFutureInterface<bool> &future);

private slots:
    void handleDeployingDone();
    void handleDeployingFailed();
    void checkForCanceled();

private:
    const MaemoDeployStep * const m_deployStep;
    const QFutureInterface<bool> m_future;
    QEventLoop * const m_eventLoop;
184
185
186
187
188
189
};

} // namespace Internal
} // namespace Qt4ProjectManager

#endif // MAEMODEPLOYSTEP_H