Skip to content
Snippets Groups Projects
Commit fa2ca2de authored by Robert Loehning's avatar Robert Loehning
Browse files

Trk: Checking for write errors when writing file to device.

Reviewed-by: con
parent 961fe9ed
No related branches found
No related tags found
No related merge requests found
...@@ -628,6 +628,7 @@ void S60DeviceRunControlBase::signsisProcessFinished() ...@@ -628,6 +628,7 @@ void S60DeviceRunControlBase::signsisProcessFinished()
connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished())); connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished()));
connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice())); connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice()));
connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(printCreateFileFailed(QString,QString))); 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(installingStarted()), this, SLOT(printInstallingNotice()));
connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int))); connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int)));
...@@ -655,10 +656,14 @@ void S60DeviceRunControlBase::printCreateFileFailed(const QString &filename, con ...@@ -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)); 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() void S60DeviceRunControlBase::printCopyingNotice()
{ {
emit addToOutputWindow(this, tr("Copying install file...")); emit addToOutputWindow(this, tr("Copying install file..."));
emit addToOutputWindow(this, tr("0% copied."));
} }
void S60DeviceRunControlBase::printCopyProgress(int progress) void S60DeviceRunControlBase::printCopyProgress(int progress)
......
...@@ -172,6 +172,7 @@ private slots: ...@@ -172,6 +172,7 @@ private slots:
void signsisProcessFinished(); void signsisProcessFinished();
void printCopyingNotice(); void printCopyingNotice();
void printCreateFileFailed(const QString &filename, const QString &errorMessage); void printCreateFileFailed(const QString &filename, const QString &errorMessage);
void printWriteFileFailed(const QString &filename, const QString &errorMessage);
void printCopyProgress(int progress); void printCopyProgress(int progress);
void printInstallingNotice(); void printInstallingNotice();
void launcherFinished(); void launcherFinished();
......
...@@ -299,7 +299,7 @@ void Launcher::handleTrkVersion(const TrkResult &result) ...@@ -299,7 +299,7 @@ void Launcher::handleTrkVersion(const TrkResult &result)
void Launcher::handleFileCreation(const TrkResult &result) void Launcher::handleFileCreation(const TrkResult &result)
{ {
if (result.errorCode() || result.data.size() < 6) { 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(); emit finished();
return; return;
} }
...@@ -315,15 +315,19 @@ void Launcher::handleFileCreation(const TrkResult &result) ...@@ -315,15 +315,19 @@ void Launcher::handleFileCreation(const TrkResult &result)
void Launcher::handleCopy(const TrkResult &result) void Launcher::handleCopy(const TrkResult &result)
{ {
Q_UNUSED(result) if (result.errorCode() || result.data.size() < 4) {
closeRemoteFile(true);
continueCopying(); 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(); int size = d->m_copyState.data->length();
d->m_copyState.position += lastCopiedBlockSize;
if (size == 0) if (size == 0)
emit copyProgress(100); emit copyProgress(100);
else { else {
...@@ -333,18 +337,24 @@ void Launcher::continueCopying() ...@@ -333,18 +337,24 @@ void Launcher::continueCopying()
if (d->m_copyState.position < size) { if (d->m_copyState.position < size) {
QByteArray ba; QByteArray ba;
appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder); appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder);
appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, BLOCKSIZE), TargetByteOrder, false); appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, 2048), TargetByteOrder, false);
d->m_copyState.position += BLOCKSIZE;
d->m_device.sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba); d->m_device.sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba);
} else { } else {
QByteArray ba; closeRemoteFile();
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();
} }
} }
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) void Launcher::handleFileCopied(const TrkResult &result)
{ {
Q_UNUSED(result) Q_UNUSED(result)
...@@ -372,7 +382,7 @@ void Launcher::handleCpuType(const TrkResult &result) ...@@ -372,7 +382,7 @@ void Launcher::handleCpuType(const TrkResult &result)
void Launcher::handleCreateProcess(const TrkResult &result) void Launcher::handleCreateProcess(const TrkResult &result)
{ {
if (result.errorCode()) { if (result.errorCode()) {
emit canNotRun(errorMessage(result.errorCode())); emit canNotRun(result.errorString());
emit finished(); emit finished();
return; return;
} }
......
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
signals: signals:
void copyingStarted(); void copyingStarted();
void canNotCreateFile(const QString &filename, const QString &errorMessage); void canNotCreateFile(const QString &filename, const QString &errorMessage);
void canNotWriteFile(const QString &filename, const QString &errorMessage);
void installingStarted(); void installingStarted();
void startingApplication(); void startingApplication();
void applicationRunning(uint pid); void applicationRunning(uint pid);
...@@ -78,7 +79,8 @@ private: ...@@ -78,7 +79,8 @@ private:
void handleFileCreation(const TrkResult &result); void handleFileCreation(const TrkResult &result);
void handleCopy(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 handleFileCopied(const TrkResult &result);
void handleInstallPackageFinished(const TrkResult &result); void handleInstallPackageFinished(const TrkResult &result);
void handleCpuType(const TrkResult &result); void handleCpuType(const TrkResult &result);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment