OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-s60 / s60deploystep.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef S60DeployStep_H
34 #define S60DeployStep_H
35
36 #include <projectexplorer/buildstep.h>
37
38 #include <QtCore/QString>
39
40 QT_FORWARD_DECLARE_CLASS(QEventLoop)
41 QT_FORWARD_DECLARE_CLASS(QFile)
42
43 namespace SymbianUtils {
44 class SymbianDevice;
45 }
46
47 namespace trk{
48 class Launcher;
49 }
50
51 namespace Coda {
52     struct CodaCommandResult;
53     class CodaDevice;
54     class CodaEvent;
55 }
56
57 namespace ProjectExplorer {
58 class IOutputParser;
59 }
60
61 namespace Qt4ProjectManager {
62 namespace Internal {
63
64 class BuildConfiguration;
65 class S60DeviceRunConfiguration;
66 struct CommunicationChannel;
67
68 class S60DeployStepFactory : public ProjectExplorer::IBuildStepFactory
69 {
70     Q_OBJECT
71 public:
72     explicit S60DeployStepFactory(QObject *parent = 0);
73     virtual ~S60DeployStepFactory();
74
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;
79
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);
87 };
88
89 class S60DeployStep : public ProjectExplorer::BuildStep
90 {
91     Q_OBJECT
92 public:
93     friend class S60DeployStepFactory;
94
95     explicit S60DeployStep(ProjectExplorer::BuildStepList *parent);
96
97     virtual ~S60DeployStep();
98
99     virtual bool init();
100     virtual void run(QFutureInterface<bool> &fi);
101     virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
102
103     void setReleaseDeviceAfterLauncherFinish(bool);
104
105     virtual QVariantMap toMap() const;
106
107 protected:
108     virtual bool fromMap(const QVariantMap &map);
109
110 protected slots:
111     void deviceRemoved(const SymbianUtils::SymbianDevice &);
112
113 private slots:
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();
127
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);
132
133     void startInstalling();
134     void startTransferring();
135
136     void deploymentFinished(bool success);
137     void slotWaitingForTckTrkClosed(int result);
138     void showManualInstallationInfo();
139
140     void setCopyProgress(int progress);
141
142     void updateProgress(int progress);
143
144 signals:
145     void finished(bool success = true);
146     void finishNow(bool success = true);
147
148     void allFilesSent();
149     void allFilesInstalled();
150
151     void codaConnected();
152
153     void manualInstallation();
154     void copyProgressChanged(int progress);
155
156 private:
157     S60DeployStep(ProjectExplorer::BuildStepList *parent,
158                   S60DeployStep *bs);
159     void ctor();
160
161     void start();
162     void stop();
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);
168
169     void handleConnected();
170     void handleSymbianInstall(const Coda::CodaCommandResult &result);
171     void handleFileSystemOpen(const Coda::CodaCommandResult &result);
172     void handleFileSystemWrite(const Coda::CodaCommandResult &result);
173     void closeFiles();
174     void putSendNextChunk();
175     void handleFileSystemClose(const Coda::CodaCommandResult &result);
176
177     void initFileSending();
178     void initFileInstallation();
179     int copyProgress() const;
180
181     enum State {
182         StateUninit,
183         StateConnecting,
184         StateConnected,
185         StateSendingData,
186         StateInstalling
187     };
188
189     QString m_serialPortName;
190     QString m_serialPortFriendlyName;
191     QStringList m_packageFileNamesWithTarget; // Support for 4.6.1
192     QStringList m_signedPackages;
193     QString m_address;
194     unsigned short m_port;
195
196     QTimer *m_timer;
197
198     bool m_releaseDeviceAfterLauncherFinish;
199     bool m_handleDeviceRemoval;
200
201     QFutureInterface<bool> *m_futureInterface; //not owned
202
203     trk::Launcher *m_launcher;
204
205     QSharedPointer<Coda::CodaDevice> m_codaDevice;
206
207     QEventLoop *m_eventLoop;
208     bool m_deployResult;
209     char m_installationDrive;
210     bool m_silentInstall;
211
212     State m_state;
213     bool m_putWriteOk;
214     QScopedPointer<QFile> m_putFile;
215     quint64 m_putLastChunkSize;
216     QByteArray m_remoteFileHandle;
217     quint64 m_putChunkSize;
218     int m_currentFileIndex;
219     int m_channel;
220     volatile bool m_deployCanceled;
221     int m_copyProgress;
222 };
223
224 class S60DeployStepWidget : public ProjectExplorer::BuildStepConfigWidget
225 {
226     Q_OBJECT
227 public:
228     S60DeployStepWidget();
229
230     void init();
231     QString summaryText() const;
232     QString displayName() const;
233 };
234
235 } // Internal
236 } // Qt4ProjectManager
237
238 #endif // S60DeployStep_H