1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef MAEMODEPLOYSTEP_H
35 #define MAEMODEPLOYSTEP_H
37 #include "maemodeployable.h"
38 #include "maemodeployables.h"
39 #include "maemodeviceconfigurations.h"
40 #include "maemomountspecification.h"
42 #include <coreplugin/ssh/sftpdefs.h>
43 #include <projectexplorer/buildstep.h>
45 #include <QtCore/QHash>
46 #include <QtCore/QList>
47 #include <QtCore/QMap>
48 #include <QtCore/QPair>
49 #include <QtCore/QSharedPointer>
60 class SshRemoteProcess;
63 namespace Qt4ProjectManager {
65 class MaemoRemoteMounter;
66 class MaemoDeviceConfigListModel;
67 class MaemoPackageCreationStep;
69 class MaemoUsedPortsGatherer;
71 class MaemoDeployStep : public ProjectExplorer::BuildStep
74 friend class MaemoDeployStepFactory;
76 MaemoDeployStep(ProjectExplorer::BuildStepList *bc);
78 virtual ~MaemoDeployStep();
79 MaemoDeviceConfig deviceConfig() const;
80 MaemoDeviceConfigListModel *deviceConfigModel() const { return m_deviceConfigModel; }
81 bool currentlyNeedsDeployment(const QString &host,
82 const MaemoDeployable &deployable) const;
83 void setDeployed(const QString &host, const MaemoDeployable &deployable);
84 QSharedPointer<MaemoDeployables> deployables() const { return m_deployables; }
85 QSharedPointer<Core::SshConnection> sshConnection() const { return m_connection; }
87 bool isDeployToSysrootEnabled() const { return m_deployToSysroot; }
88 void setDeployToSysrootEnabled(bool deploy) { m_deployToSysroot = deploy; }
90 Q_INVOKABLE void stop();
98 void handleConnected();
99 void handleConnectionFailure();
100 void handleMounted();
101 void handleUnmounted();
102 void handleMountError(const QString &errorMsg);
103 void handleMountDebugOutput(const QString &output);
104 void handleProgressReport(const QString &progressMsg);
105 void handleCopyProcessFinished(int exitStatus);
106 void handleSysrootInstallerFinished();
107 void handleSysrootInstallerOutput();
108 void handleSysrootInstallerErrorOutput();
109 void handleSftpChannelInitialized();
110 void handleSftpChannelInitializationFailed(const QString &error);
111 void handleSftpJobFinished(Core::SftpJobId job, const QString &error);
112 void handleSftpChannelClosed();
113 void handleInstallationFinished(int exitStatus);
114 void handleDeviceInstallerOutput(const QByteArray &output);
115 void handleDeviceInstallerErrorOutput(const QByteArray &output);
116 void handlePortsGathererError(const QString &errorMsg);
117 void handlePortListReady();
121 Inactive, StopRequested, InstallingToSysroot, Connecting,
122 UnmountingOldDirs, UnmountingCurrentDirs, GatheringPorts, Mounting,
123 InstallingToDevice, UnmountingCurrentMounts, CopyingFile,
124 InitializingSftp, Uploading
127 MaemoDeployStep(ProjectExplorer::BuildStepList *bc,
128 MaemoDeployStep *other);
130 virtual void run(QFutureInterface<bool> &fi);
131 virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
132 virtual bool immutable() const { return true; }
133 virtual QVariantMap toMap() const;
134 virtual bool fromMap(const QVariantMap &map);
137 void raiseError(const QString &error);
138 void writeOutput(const QString &text, OutputFormat = MessageOutput);
139 void addDeployTimesToMap(QVariantMap &map) const;
140 void getDeployTimesFromMap(const QVariantMap &map);
141 const MaemoPackageCreationStep *packagingStep() const;
142 QString deployMountPoint() const;
143 const MaemoToolChain *toolChain() const;
144 void copyNextFileToDevice();
145 void installToSysroot();
146 QString uploadDir() const;
147 void connectToDevice();
148 void unmountOldDirs();
150 void prepareSftpConnection();
151 void runDpkg(const QString &packageFilePath);
152 void setState(State newState);
155 static const QLatin1String Id;
157 QSharedPointer<MaemoDeployables> m_deployables;
158 QSharedPointer<Core::SshConnection> m_connection;
159 QProcess *m_sysrootInstaller;
160 typedef QPair<MaemoDeployable, QSharedPointer<Core::SshRemoteProcess> > DeviceDeployAction;
161 QScopedPointer<DeviceDeployAction> m_currentDeviceDeployAction;
162 QList<MaemoDeployable> m_filesToCopy;
163 MaemoRemoteMounter *m_mounter;
164 bool m_deployToSysroot;
165 QSharedPointer<Core::SftpChannel> m_uploader;
166 QSharedPointer<Core::SshRemoteProcess> m_deviceInstaller;
169 typedef QPair<MaemoDeployable, QString> DeployablePerHost;
170 QHash<DeployablePerHost, QDateTime> m_lastDeployed;
171 MaemoDeviceConfigListModel *m_deviceConfigModel;
172 MaemoUsedPortsGatherer *m_portsGatherer;
173 MaemoPortList m_freePorts;
177 class MaemoDeployEventHandler : public QObject
181 MaemoDeployEventHandler(MaemoDeployStep *deployStep,
182 QFutureInterface<bool> &future);
185 void handleDeployingDone();
186 void handleDeployingFailed();
187 void checkForCanceled();
190 MaemoDeployStep * const m_deployStep;
191 const QFutureInterface<bool> m_future;
192 QEventLoop * const m_eventLoop;
196 } // namespace Internal
197 } // namespace Qt4ProjectManager
199 #endif // MAEMODEPLOYSTEP_H