diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index b6ab4402e53419ed1d9b30f262268970ea55332f..ef435734827a562625dfe51d34595692976f77a0 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -628,6 +628,7 @@ void S60DeviceRunControlBase::signsisProcessFinished() connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished())); connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice())); connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(printCreateFileFailed(QString,QString))); + connect(m_launcher, SIGNAL(canNotWriteFile(QString,QString)), this, SLOT(printWriteFileFailed(QString,QString))); connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice())); connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int))); @@ -655,10 +656,14 @@ void S60DeviceRunControlBase::printCreateFileFailed(const QString &filename, con emit addToOutputWindow(this, tr("Could not create file %1 on device: %2").arg(filename, errorMessage)); } +void S60DeviceRunControlBase::printWriteFileFailed(const QString &filename, const QString &errorMessage) +{ + emit addToOutputWindow(this, tr("Could not write to file %1 on device: %2").arg(filename, errorMessage)); +} + void S60DeviceRunControlBase::printCopyingNotice() { emit addToOutputWindow(this, tr("Copying install file...")); - emit addToOutputWindow(this, tr("0% copied.")); } void S60DeviceRunControlBase::printCopyProgress(int progress) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 274ab6a28045ce5c493e18fe7760588ce90112b8..fd67e5431cbd8ce686d7bbde78d3969a0dbe0de4 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -172,6 +172,7 @@ private slots: void signsisProcessFinished(); void printCopyingNotice(); void printCreateFileFailed(const QString &filename, const QString &errorMessage); + void printWriteFileFailed(const QString &filename, const QString &errorMessage); void printCopyProgress(int progress); void printInstallingNotice(); void launcherFinished(); diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index cfad2379d970c2812f1bf456272fb76c69fef09c..0c6a76deb341a2abf025c6d8a1b0aff00e1432be 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -299,7 +299,7 @@ void Launcher::handleTrkVersion(const TrkResult &result) void Launcher::handleFileCreation(const TrkResult &result) { if (result.errorCode() || result.data.size() < 6) { - emit canNotCreateFile(d->m_copyState.destinationFileName, errorMessage(result.errorCode())); + emit canNotCreateFile(d->m_copyState.destinationFileName, result.errorString()); emit finished(); return; } @@ -315,15 +315,19 @@ void Launcher::handleFileCreation(const TrkResult &result) void Launcher::handleCopy(const TrkResult &result) { - Q_UNUSED(result) - - continueCopying(); + if (result.errorCode() || result.data.size() < 4) { + closeRemoteFile(true); + emit canNotWriteFile(d->m_copyState.destinationFileName, result.errorString()); + emit finished(); + } else { + continueCopying(extractShort(result.data.data() + 2)); + } } -void Launcher::continueCopying() +void Launcher::continueCopying(uint lastCopiedBlockSize) { - static const int BLOCKSIZE = 1024; int size = d->m_copyState.data->length(); + d->m_copyState.position += lastCopiedBlockSize; if (size == 0) emit copyProgress(100); else { @@ -333,18 +337,24 @@ void Launcher::continueCopying() if (d->m_copyState.position < size) { QByteArray ba; appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder); - appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, BLOCKSIZE), TargetByteOrder, false); - d->m_copyState.position += BLOCKSIZE; + appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, 2048), TargetByteOrder, false); d->m_device.sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba); } else { - QByteArray ba; - appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder); - appendInt(&ba, QDateTime::currentDateTime().toTime_t(), TargetByteOrder); - d->m_device.sendTrkMessage(TrkCloseFile, TrkCallback(this, &Launcher::handleFileCopied), ba); - d->m_copyState.data.reset(); + closeRemoteFile(); } } +void Launcher::closeRemoteFile(bool failed) +{ + QByteArray ba; + appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder); + appendInt(&ba, QDateTime::currentDateTime().toTime_t(), TargetByteOrder); + d->m_device.sendTrkMessage(TrkCloseFile, + failed ? TrkCallback() : TrkCallback(this, &Launcher::handleFileCopied), + ba); + d->m_copyState.data.reset(); +} + void Launcher::handleFileCopied(const TrkResult &result) { Q_UNUSED(result) @@ -372,7 +382,7 @@ void Launcher::handleCpuType(const TrkResult &result) void Launcher::handleCreateProcess(const TrkResult &result) { if (result.errorCode()) { - emit canNotRun(errorMessage(result.errorCode())); + emit canNotRun(result.errorString()); emit finished(); return; } diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index ec1048885caff804aac1635600df44bcfabe28d7..9a33a57dbf7593122b0cbfa86652e46d2254b3fb 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -58,6 +58,7 @@ public: signals: void copyingStarted(); void canNotCreateFile(const QString &filename, const QString &errorMessage); + void canNotWriteFile(const QString &filename, const QString &errorMessage); void installingStarted(); void startingApplication(); void applicationRunning(uint pid); @@ -78,7 +79,8 @@ private: void handleFileCreation(const TrkResult &result); void handleCopy(const TrkResult &result); - void continueCopying(); + void continueCopying(uint lastCopiedBlockSize = 0); + void closeRemoteFile(bool failed = false); void handleFileCopied(const TrkResult &result); void handleInstallPackageFinished(const TrkResult &result); void handleCpuType(const TrkResult &result);