summaryrefslogtreecommitdiffstats
path: root/tools/runonphone/symbianutils/trkdevice.cpp
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2010-02-09 10:56:37 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2010-02-09 19:09:41 (GMT)
commit39709d61fbd4a17edf5f141877d312d3872ccce0 (patch)
tree44e2026ca93d4d3b4723eee37a601f23b8ae173c /tools/runonphone/symbianutils/trkdevice.cpp
parent9965d0e0484882d905c1f8a3bdf19f6eecd30226 (diff)
downloadQt-39709d61fbd4a17edf5f141877d312d3872ccce0.zip
Qt-39709d61fbd4a17edf5f141877d312d3872ccce0.tar.gz
Qt-39709d61fbd4a17edf5f141877d312d3872ccce0.tar.bz2
Catch up symbianutils to creator 3efdb87682a5785bac7b90f9f9a8bb819a1cb053
commit 3efdb87682a5785bac7b90f9f9a8bb819a1cb053 Author: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Mon Feb 8 14:10:51 2010 +0100 S60/Trk: Make the port a property of TrkDevice. Associate the port with the device instead of passing it to open for better handling. commit 76872c6ed8a1477f1914266d6917ee4aad6ff7e9 Author: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Fri Feb 5 17:34:02 2010 +0100 S60: Move serialdevicelister.cpp to symbianutils/symbiandevicemanager.cpp
Diffstat (limited to 'tools/runonphone/symbianutils/trkdevice.cpp')
-rw-r--r--tools/runonphone/symbianutils/trkdevice.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/tools/runonphone/symbianutils/trkdevice.cpp b/tools/runonphone/symbianutils/trkdevice.cpp
index d587135..b327ab3 100644
--- a/tools/runonphone/symbianutils/trkdevice.cpp
+++ b/tools/runonphone/symbianutils/trkdevice.cpp
@@ -883,6 +883,7 @@ struct TrkDevicePrivate
QByteArray trkReadBuffer;
int verbose;
QString errorString;
+ QString port;
};
///////////////////////////////////////////////////////////////////////
@@ -914,13 +915,19 @@ TrkDevice::~TrkDevice()
delete d;
}
-bool TrkDevice::open(const QString &port, QString *errorMessage)
+bool TrkDevice::open(QString *errorMessage)
{
if (d->verbose)
- qDebug() << "Opening" << port << "is open: " << isOpen() << " serialFrame=" << serialFrame();
+ qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame();
+ if (d->port.isEmpty()) {
+ *errorMessage = QLatin1String("Internal error: No port set on TrkDevice");
+ return false;
+ }
+
close();
#ifdef Q_OS_WIN
- d->deviceContext->device = CreateFile(QString("\\\\.\\").append(port).toStdWString().c_str(),
+ const QString fullPort = QLatin1String("\\\\.\\") + d->port;
+ d->deviceContext->device = CreateFile(reinterpret_cast<const WCHAR*>(fullPort.utf16()),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
@@ -929,7 +936,7 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
NULL);
if (INVALID_HANDLE_VALUE == d->deviceContext->device) {
- *errorMessage = QString::fromLatin1("Could not open device '%1': %2").arg(port, winErrorMessage(GetLastError()));
+ *errorMessage = QString::fromLatin1("Could not open device '%1': %2").arg(port(), winErrorMessage(GetLastError()));
return false;
}
memset(&d->deviceContext->readOverlapped, 0, sizeof(OVERLAPPED));
@@ -941,9 +948,9 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
return false;
}
#else
- d->deviceContext->file.setFileName(port);
+ d->deviceContext->file.setFileName(d->port);
if (!d->deviceContext->file.open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
- *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(port, d->deviceContext->file.errorString());
+ *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(d->port, d->deviceContext->file.errorString());
return false;
}
@@ -982,7 +989,7 @@ bool TrkDevice::open(const QString &port, QString *errorMessage)
d->writerThread->start();
if (d->verbose)
- qDebug() << "Opened" << port;
+ qDebug() << "Opened" << d->port;
return true;
}
@@ -1016,6 +1023,16 @@ bool TrkDevice::isOpen() const
#endif
}
+QString TrkDevice::port() const
+{
+ return d->port;
+}
+
+void TrkDevice::setPort(const QString &p)
+{
+ d->port = p;
+}
+
QString TrkDevice::errorString() const
{
return d->errorString;