maemodeploystep.h 5.87 KB
Newer Older
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
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 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.
**
**************************************************************************/

30
31
32
#ifndef MAEMODEPLOYSTEP_H
#define MAEMODEPLOYSTEP_H

33
34
#include "maemodeployable.h"
#include "maemodeviceconfigurations.h"
35
#include "maemomountspecification.h"
36
37

#include <coreplugin/ssh/sftpdefs.h>
38
39
#include <projectexplorer/buildstep.h>

40
41
42
43
44
45
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QPair>
#include <QtCore/QSharedPointer>

ck's avatar
ck committed
46
47
// #define DEPLOY_VIA_MOUNT

48
49
QT_BEGIN_NAMESPACE
class QEventLoop;
ck's avatar
ck committed
50
51
52
#ifdef DEPLOY_VIA_MOUNT
class QTimer;
#endif
53
54
55
QT_END_NAMESPACE

namespace Core {
ck's avatar
ck committed
56
#ifndef DEPLOY_VIA_MOUNT
57
class SftpChannel;
ck's avatar
ck committed
58
#endif
59
60
61
62
class SshConnection;
class SshRemoteProcess;
}

63
64
namespace Qt4ProjectManager {
namespace Internal {
ck's avatar
ck committed
65
66
67
#ifdef DEPLOY_VIA_MOUNT
class MaemoRemoteMounter;
#endif
68
class MaemoDeployables;
69
class MaemoDeviceConfigListModel;
70
class MaemoPackageCreationStep;
71
72
73
74
75
76

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

79
80
    virtual ~MaemoDeployStep();
    MaemoDeviceConfig deviceConfig() const;
81
    MaemoDeviceConfigListModel *deviceConfigModel() const { return m_deviceConfigModel; }
82
83
84
    bool currentlyNeedsDeployment(const QString &host,
        const MaemoDeployable &deployable) const;
    void setDeployed(const QString &host, const MaemoDeployable &deployable);
85
    MaemoDeployables *deployables() const { return m_deployables; }
86
87
88
89
90
91
92

signals:
    void done();
    void error();

private slots:
    void start();
93
    void stop();
94
95
    void handleConnected();
    void handleConnectionFailure();
ck's avatar
ck committed
96
97
98
99
100
101
102
103
#ifdef DEPLOY_VIA_MOUNT
    void handleMounted();
    void handleUnmounted();
    void handleMountError(const QString &errorMsg);
    void handleProgressReport(const QString &progressMsg);
    void handleCopyProcessFinished(int exitStatus);
    void handleCleanupTimeout();
#else
104
105
106
107
    void handleSftpChannelInitialized();
    void handleSftpChannelInitializationFailed(const QString &error);
    void handleSftpJobFinished(Core::SftpJobId job, const QString &error);
    void handleLinkProcessFinished(int exitStatus);
ck's avatar
ck committed
108
#endif
109
110
111
    void handleInstallationFinished(int exitStatus);
    void handleInstallerOutput(const QByteArray &output);
    void handleInstallerErrorOutput(const QByteArray &output);
112
113

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

    void ctor();
    void raiseError(const QString &error);
125
    void writeOutput(const QString &text, ProjectExplorer::BuildStep::OutputFormat = BuildStep::NormalOutput);
126
127
128
    void addDeployTimesToMap(QVariantMap &map) const;
    void getDeployTimesFromMap(const QVariantMap &map);
    const MaemoPackageCreationStep *packagingStep() const;
ck's avatar
ck committed
129
130
131
#ifdef DEPLOY_VIA_MOUNT
    QString deployMountPoint() const;
    void deployNextFile();
132
    bool addMountSpecification(const MaemoMountSpecification &mountSpec);
ck's avatar
ck committed
133
#else
134
    bool deploy(const MaemoDeployable &deployable);
ck's avatar
ck committed
135
136
137
#endif

#ifndef DEPLOY_VIA_MOUNT
138
    QString uploadDir() const;
ck's avatar
ck committed
139
#endif
140
141

    static const QLatin1String Id;
142

143
    MaemoDeployables * const m_deployables;
144
    QSharedPointer<Core::SshConnection> m_connection;
ck's avatar
ck committed
145
146
147
148
149
150
151
152
#ifdef DEPLOY_VIA_MOUNT
    typedef QPair<MaemoDeployable, QSharedPointer<Core::SshRemoteProcess> > DeployAction;
    QScopedPointer<DeployAction> m_currentDeployAction;
    QList<MaemoDeployable> m_filesToCopy;
    MaemoRemoteMounter *m_mounter;
    QTimer *m_cleanupTimer;
    bool m_canStart;
#else
153
154
155
156
    QSharedPointer<Core::SftpChannel> m_uploader;
    typedef QPair<MaemoDeployable, QString> DeployInfo;
    QMap<Core::SftpJobId, DeployInfo> m_uploadsInProgress;
    QMap<QSharedPointer<Core::SshRemoteProcess>, MaemoDeployable> m_linksInProgress;
ck's avatar
ck committed
157
158
159
#endif
    QSharedPointer<Core::SshRemoteProcess> m_installer;

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