diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2010-01-06 14:22:21 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-01-06 14:22:21 (GMT) |
commit | a24d87f6469fa491624590383617b43c2b3dda32 (patch) | |
tree | ee6a76cecf35e3f20951f5b13785aaaef12bbade /tools/runonphone/trksignalhandler.cpp | |
parent | da19e7f6b6b822f7a473c4eb2dff001a3434353a (diff) | |
parent | 2f8e66b326c3d6748d530ab5abbf4fe5a91a6a3f (diff) | |
download | Qt-a24d87f6469fa491624590383617b43c2b3dda32.zip Qt-a24d87f6469fa491624590383617b43c2b3dda32.tar.gz Qt-a24d87f6469fa491624590383617b43c2b3dda32.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'tools/runonphone/trksignalhandler.cpp')
-rw-r--r-- | tools/runonphone/trksignalhandler.cpp | 98 |
1 files changed, 83 insertions, 15 deletions
diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index 9323373..4fa79f1 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -41,81 +41,149 @@ #include <QDebug> #include <QCoreApplication> +#include <QObject> #include "trksignalhandler.h" +class TrkSignalHandlerPrivate +{ + friend class TrkSignalHandler; +public: + TrkSignalHandlerPrivate(); + ~TrkSignalHandlerPrivate(); +private: + QTextStream out; + QTextStream err; + int loglevel; +}; + void TrkSignalHandler::copyingStarted() { - qDebug() << "Copying...\n"; + if(d->loglevel > 0) + d->out << "Copying..." << endl; } void TrkSignalHandler::canNotConnect(const QString &errorMessage) { - qWarning() << "Cannot Connect - " << errorMessage; + d->err << "Cannot Connect - " << errorMessage << endl; } void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage) { - qWarning() << "Cannot create file (" << filename << ") - " << errorMessage << "\n"; + d->err << "Cannot create file (" << filename << ") - " << errorMessage << endl; } void TrkSignalHandler::canNotWriteFile(const QString &filename, const QString &errorMessage) { - qWarning() << "Cannot write file (" << filename << ") - " << errorMessage << "\n"; + d->err << "Cannot write file (" << filename << ") - " << errorMessage << endl; } void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &errorMessage) { - qWarning() << "Cannot close file (" << filename << ") - " << errorMessage << "\n"; + d->err << "Cannot close file (" << filename << ") - " << errorMessage << endl; } void TrkSignalHandler::installingStarted() { - qDebug() << "Installing...\n"; + if(d->loglevel > 0) + d->out << "Installing..." << endl; } void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QString &errorMessage) { - qWarning() << "Cannot install file (" << packageFilename << ") - " << errorMessage << "\n"; + d->err << "Cannot install file (" << packageFilename << ") - " << errorMessage << endl; } void TrkSignalHandler::installingFinished() { - qDebug() << "Installing finished\n"; + if(d->loglevel > 0) + d->out << "Installing finished" << endl; } void TrkSignalHandler::startingApplication() { - qDebug() << "Starting app...\n"; + if(d->loglevel > 0) + d->out << "Starting app..." << endl; } void TrkSignalHandler::applicationRunning(uint pid) { - qDebug() << "Running...\n"; + if(d->loglevel > 0) + d->out << "Running..." << endl; } void TrkSignalHandler::canNotRun(const QString &errorMessage) { - qWarning() << "Cannot run - " << errorMessage << "\n"; + d->err << "Cannot run - " << errorMessage << endl; } void TrkSignalHandler::finished() { - qDebug() << "Done.\n"; + if(d->loglevel > 0) + d->out << "Done." << endl; QCoreApplication::quit(); } void TrkSignalHandler::applicationOutputReceived(const QString &output) { - qDebug() << "> " << output; + d->out << output; } void TrkSignalHandler::copyProgress(int percent) { - qDebug() << percent << "%"; + if(d->loglevel > 0) { + d->out << percent << "% "; + d->out.flush(); + if(percent==100) + d->out << endl; + } } void TrkSignalHandler::stateChanged(int state) { - qDebug() << "State" << state; + if(d->loglevel > 1) + d->out << "State" << state << endl; +} + +void TrkSignalHandler::setLogLevel(int level) +{ + d->loglevel = level; +} + +void TrkSignalHandler::stopped(uint pc, uint pid, uint tid, const QString& reason) +{ + d->err << "STOPPED: pc=" << hex << pc << " pid=" << pid + << " tid=" << tid << dec << " - " << reason << endl; + // if it was a breakpoint, then we could continue with "emit resume(pid, tid);" + // since we have set no breakpoints, it will be a just in time debug of a panic / exception + emit terminate(); +} + +void TrkSignalHandler::timeout() +{ + d->err << "FAILED: stopping test due to timeout" << endl; + emit terminate(); } +TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : + out(stdout), + err(stderr), + loglevel(0) +{ + +} + +TrkSignalHandlerPrivate::~TrkSignalHandlerPrivate() +{ + out.flush(); + err.flush(); +} + +TrkSignalHandler::TrkSignalHandler() +{ + d = new TrkSignalHandlerPrivate(); +} + +TrkSignalHandler::~TrkSignalHandler() +{ + delete d; +} |