1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef S60DeployStep_H
34 #define S60DeployStep_H
36 #include <projectexplorer/buildstep.h>
38 #include <QtCore/QString>
40 QT_FORWARD_DECLARE_CLASS(QEventLoop)
41 QT_FORWARD_DECLARE_CLASS(QFile)
43 namespace SymbianUtils {
52 struct CodaCommandResult;
57 namespace ProjectExplorer {
61 namespace Qt4ProjectManager {
64 class BuildConfiguration;
65 class S60DeviceRunConfiguration;
66 struct CommunicationChannel;
68 class S60DeployStepFactory : public ProjectExplorer::IBuildStepFactory
72 explicit S60DeployStepFactory(QObject *parent = 0);
73 virtual ~S60DeployStepFactory();
75 // used to show the list of possible additons to a target, returns a list of types
76 QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const;
77 // used to translate the types to names to display to the user
78 QString displayNameForId(const QString &id) const;
80 bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const;
81 ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id);
82 // used to recreate the runConfigurations when restoring settings
83 bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const;
84 ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map);
85 bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const;
86 ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product);
89 class S60DeployStep : public ProjectExplorer::BuildStep
93 friend class S60DeployStepFactory;
95 explicit S60DeployStep(ProjectExplorer::BuildStepList *parent);
97 virtual ~S60DeployStep();
100 virtual void run(QFutureInterface<bool> &fi);
101 virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
103 void setReleaseDeviceAfterLauncherFinish(bool);
105 virtual QVariantMap toMap() const;
108 virtual bool fromMap(const QVariantMap &map);
111 void deviceRemoved(const SymbianUtils::SymbianDevice &);
114 void connectFailed(const QString &errorMessage);
115 void printCopyingNotice(const QString &fileName);
116 void createFileFailed(const QString &filename, const QString &errorMessage);
117 void writeFileFailed(const QString &filename, const QString &errorMessage);
118 void closeFileFailed(const QString &filename, const QString &errorMessage);
119 void printInstallingNotice(const QString &packageName);
120 void installFailed(const QString &filename, const QString &errorMessage);
121 void printInstallingFinished();
122 void launcherFinished(bool success = true);
123 void slotLauncherStateChanged(int);
124 void slotWaitingForTrkClosed();
125 void checkForCancel();
126 void checkForTimeout();
128 void slotError(const QString &error);
129 void slotTrkLogMessage(const QString &log);
130 void slotSerialPong(const QString &message);
131 void slotCodaEvent(const Coda::CodaEvent &event);
133 void startInstalling();
134 void startTransferring();
136 void deploymentFinished(bool success);
137 void slotWaitingForTckTrkClosed(int result);
138 void showManualInstallationInfo();
140 void setCopyProgress(int progress);
142 void updateProgress(int progress);
145 void finished(bool success = true);
146 void finishNow(bool success = true);
149 void allFilesInstalled();
151 void codaConnected();
153 void manualInstallation();
154 void copyProgressChanged(int progress);
157 S60DeployStep(ProjectExplorer::BuildStepList *parent,
163 void startDeployment();
164 bool processPackageName(QString &errorMessage);
165 void setupConnections();
166 void appendMessage(const QString &error, bool isError);
167 void reportError(const QString &error);
169 void handleConnected();
170 void handleSymbianInstall(const Coda::CodaCommandResult &result);
171 void handleFileSystemOpen(const Coda::CodaCommandResult &result);
172 void handleFileSystemWrite(const Coda::CodaCommandResult &result);
174 void putSendNextChunk();
175 void handleFileSystemClose(const Coda::CodaCommandResult &result);
177 void initFileSending();
178 void initFileInstallation();
179 int copyProgress() const;
189 QString m_serialPortName;
190 QString m_serialPortFriendlyName;
191 QStringList m_packageFileNamesWithTarget; // Support for 4.6.1
192 QStringList m_signedPackages;
194 unsigned short m_port;
198 bool m_releaseDeviceAfterLauncherFinish;
199 bool m_handleDeviceRemoval;
201 QFutureInterface<bool> *m_futureInterface; //not owned
203 trk::Launcher *m_launcher;
205 QSharedPointer<Coda::CodaDevice> m_codaDevice;
207 QEventLoop *m_eventLoop;
209 char m_installationDrive;
210 bool m_silentInstall;
214 QScopedPointer<QFile> m_putFile;
215 quint64 m_putLastChunkSize;
216 QByteArray m_remoteFileHandle;
217 quint64 m_putChunkSize;
218 int m_currentFileIndex;
220 volatile bool m_deployCanceled;
224 class S60DeployStepWidget : public ProjectExplorer::BuildStepConfigWidget
228 S60DeployStepWidget();
231 QString summaryText() const;
232 QString displayName() const;
236 } // Qt4ProjectManager
238 #endif // S60DeployStep_H