diff --git a/src/libs/libs.pro b/src/libs/libs.pro index 085d7a0a6a91f57c3f6c60807cf6708a8ad221ab..86c7ecea0549f2573bf4d311046807c8784d2baa 100644 --- a/src/libs/libs.pro +++ b/src/libs/libs.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs CONFIG += ordered +QT += core gui SUBDIRS = \ qtconcurrent \ @@ -8,7 +9,8 @@ SUBDIRS = \ utils \ utils/process_stub.pro \ cplusplus \ - qmljs + qmljs \ + symbianutils SUPPORT_QT_MAEMO = $$(QTCREATOR_WITH_MAEMO) !isEmpty(SUPPORT_QT_MAEMO) { diff --git a/src/libs/symbianutils/symbianutils.pri b/src/libs/symbianutils/symbianutils.pri new file mode 100644 index 0000000000000000000000000000000000000000..d650f9557f0ac6fce7b9e3877d09e06456906bce --- /dev/null +++ b/src/libs/symbianutils/symbianutils.pri @@ -0,0 +1,3 @@ +INCLUDEPATH *= $$PWD/../../shared/trk +DEPENDPATH += $$PWD/../../shared/trk +LIBS *= -l$$qtLibraryTarget(symbianutils) diff --git a/src/libs/symbianutils/symbianutils.pro b/src/libs/symbianutils/symbianutils.pro new file mode 100644 index 0000000000000000000000000000000000000000..30e7fefae6d47bc2a6832a7803693b0531818959 --- /dev/null +++ b/src/libs/symbianutils/symbianutils.pro @@ -0,0 +1,6 @@ +TEMPLATE = lib +CONFIG+=dll +TARGET = symbianutils +DEFINES += SYMBIANUTILS_BUILD_LIB +include(../../qtcreatorlibrary.pri) +include(../../shared/trk/trk.pri) diff --git a/src/plugins/debugger/gdb/gdb.pri b/src/plugins/debugger/gdb/gdb.pri index ad27702938604e28c495353983d4f31f370f70ab..873186c21aefa4bda7a82e47f08f810f550adca7 100644 --- a/src/plugins/debugger/gdb/gdb.pri +++ b/src/plugins/debugger/gdb/gdb.pri @@ -1,5 +1,4 @@ -include(../../../shared/trk/trk.pri) - +include(../../../libs/symbianutils/symbianutils.pri) HEADERS += \ $$PWD/gdbmi.h \ $$PWD/gdbengine.h \ diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index 0767a4b530789eec06c95a5146f64e5f8ac4db71..14397205092b222b4ec06cb1c54645069520d543 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -75,6 +75,8 @@ namespace Internal { enum { KnownRegisters = RegisterPSGdb + 1}; +static inline void appendByte(QByteArray *ba, trk::byte b) { ba->append(b); } + static const char *registerNames[KnownRegisters] = { "A1", "A2", "A3", "A4", @@ -330,7 +332,7 @@ QByteArray TrkGdbAdapter::trkReadRegistersMessage() return ba; } -QByteArray TrkGdbAdapter::trkWriteRegisterMessage(byte reg, uint value) + QByteArray TrkGdbAdapter::trkWriteRegisterMessage(trk::byte reg, uint value) { QByteArray ba; appendByte(&ba, 0); // ? @@ -372,7 +374,7 @@ QByteArray TrkGdbAdapter::trkWriteMemoryMessage(uint addr, const QByteArray &dat return ba; } -QByteArray TrkGdbAdapter::trkStepRangeMessage(byte option) +QByteArray TrkGdbAdapter::trkStepRangeMessage(trk::byte option) { QByteArray ba; ba.reserve(17); @@ -510,7 +512,7 @@ void TrkGdbAdapter::readGdbServerCommand() } //logMessage(QString("Packet checksum: %1").arg(checkSum)); - byte sum = 0; + trk::byte sum = 0; for (int i = 0; i < pos; ++i) sum += ba.at(i); @@ -557,7 +559,7 @@ void TrkGdbAdapter::sendGdbServerAck() void TrkGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArray &logNote) { - byte sum = 0; + trk::byte sum = 0; for (int i = 0; i != msg.size(); ++i) sum += msg.at(i); @@ -1071,7 +1073,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) } } -void TrkGdbAdapter::sendTrkMessage(byte code, TrkCallback callback, +void TrkGdbAdapter::sendTrkMessage(trk::byte code, TrkCallback callback, const QByteArray &data, const QVariant &cookie) { if (m_verbose >= 2) @@ -1080,7 +1082,7 @@ void TrkGdbAdapter::sendTrkMessage(byte code, TrkCallback callback, m_trkDevice->sendTrkMessage(code, callback, data, cookie); } -void TrkGdbAdapter::sendTrkAck(byte token) +void TrkGdbAdapter::sendTrkAck(trk::byte token) { //logMessage(QString("SENDING ACKNOWLEDGEMENT FOR TOKEN %1").arg(int(token))); m_trkDevice->sendTrkAck(token); @@ -1184,9 +1186,9 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result) debugMessage(_("RESET SNAPSHOT (NOTIFY CREATED)")); m_snapshot.reset(); const char *data = result.data.data(); - const byte error = result.data.at(0); + const trk::byte error = result.data.at(0); // type: 1 byte; for dll item, this value is 2. - const byte type = result.data.at(1); + const trk::byte type = result.data.at(1); const uint pid = extractInt(data + 2); const uint tid = extractInt(data + 6); const uint codeseg = extractInt(data + 10); diff --git a/src/plugins/debugger/gdb/trkgdbadapter.h b/src/plugins/debugger/gdb/trkgdbadapter.h index 2ddb6093ef43a250e28868d9b853f4bd06bda2c1..c4c5da2bf1bb411bcc87f476a3748c574a1166d8 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.h +++ b/src/plugins/debugger/gdb/trkgdbadapter.h @@ -186,7 +186,7 @@ private: // // TRK // - void sendTrkMessage(byte code, + void sendTrkMessage(trk::byte code, TrkCallback callback = TrkCallback(), const QByteArray &data = QByteArray(), const QVariant &cookie = QVariant()); @@ -194,7 +194,7 @@ private: Q_SLOT void handleTrkError(const QString &msg); // convenience messages - void sendTrkAck(byte token); + void sendTrkAck(trk::byte token); void handleCpuType(const TrkResult &result); void handleCreateProcess(const TrkResult &result); @@ -245,12 +245,12 @@ private: QByteArray trkContinueMessage(); QByteArray trkReadRegistersMessage(); - QByteArray trkWriteRegisterMessage(byte reg, uint value); + QByteArray trkWriteRegisterMessage(trk::byte reg, uint value); QByteArray trkReadMemoryMessage(const MemoryRange &range); QByteArray trkReadMemoryMessage(uint addr, uint len); QByteArray trkWriteMemoryMessage(uint addr, const QByteArray &date); QByteArray trkBreakpointMessage(uint addr, uint len, bool armMode = true); - QByteArray trkStepRangeMessage(byte option); + QByteArray trkStepRangeMessage(trk::byte option); QByteArray trkDeleteProcessMessage(); QByteArray trkInterruptMessage(); diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri index ca916885a0a312a424da5cc58e175a806afb3753..8937b5b0b83b63fc4210e0c98e04da3dfa36ab63 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri +++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri @@ -31,4 +31,4 @@ HEADERS += $$PWD/s60devices.h \ $$PWD/rvctparser.h \ $$PWD/winscwparser.h FORMS += $$PWD/s60devicespreferencepane.ui -include(../../../shared/trk/trk.pri)||error("could not include trk.pri") +include(../../libs/symbianutils/symbianutils.pri)||error("could not include symbianutils.pri") diff --git a/src/shared/trk/bluetoothlistener.h b/src/shared/trk/bluetoothlistener.h index a20ba3075349d4f5afb0a78cfb497f35b29a26f7..eebd963a525166682ff54c5987cdf493f3ea4e47 100644 --- a/src/shared/trk/bluetoothlistener.h +++ b/src/shared/trk/bluetoothlistener.h @@ -30,6 +30,8 @@ #ifndef BLUETOOTHLISTENER_H #define BLUETOOTHLISTENER_H +#include "symbianutils_global.h" + #include <QtCore/QObject> #include <QtCore/QProcess> @@ -41,7 +43,7 @@ struct BluetoothListenerPrivate; * The rfcomm command is used. It process can be started in the background * while connection attempts (TrkDevice::open()) are made in the foreground. */ -class BluetoothListener : public QObject +class SYMBIANUTILS_EXPORT BluetoothListener : public QObject { Q_OBJECT Q_DISABLE_COPY(BluetoothListener) diff --git a/src/shared/trk/bluetoothlistener_gui.cpp b/src/shared/trk/bluetoothlistener_gui.cpp index 7463a0306077c08190992033946f6e980dc633a6..27c91346d8eeaf5047c68d5b709e0e69aac6ac58 100644 --- a/src/shared/trk/bluetoothlistener_gui.cpp +++ b/src/shared/trk/bluetoothlistener_gui.cpp @@ -38,7 +38,7 @@ namespace trk { -PromptStartCommunicationResult +SYMBIANUTILS_EXPORT PromptStartCommunicationResult promptStartCommunication(BaseCommunicationStarter &starter, const QString &msgBoxTitle, const QString &msgBoxText, @@ -76,7 +76,7 @@ PromptStartCommunicationResult return PromptStartCommunicationConnected; } -PromptStartCommunicationResult +SYMBIANUTILS_EXPORT PromptStartCommunicationResult promptStartSerial(BaseCommunicationStarter &starter, QWidget *msgBoxParent, QString *errorMessage) @@ -86,7 +86,7 @@ PromptStartCommunicationResult return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage); } -PromptStartCommunicationResult +SYMBIANUTILS_EXPORT PromptStartCommunicationResult promptStartBluetooth(BaseCommunicationStarter &starter, QWidget *msgBoxParent, QString *errorMessage) diff --git a/src/shared/trk/bluetoothlistener_gui.h b/src/shared/trk/bluetoothlistener_gui.h index 83cce425ea35ce6e4cae1463ef22ce16c78630ca..82226fd97f0b8e62883480ea0245f13d3ae63714 100644 --- a/src/shared/trk/bluetoothlistener_gui.h +++ b/src/shared/trk/bluetoothlistener_gui.h @@ -30,6 +30,8 @@ #ifndef BLUETOOTHLISTENER_GUI_H #define BLUETOOTHLISTENER_GUI_H +#include "symbianutils_global.h" + #include <QtCore/QtGlobal> QT_BEGIN_NAMESPACE @@ -50,7 +52,7 @@ enum PromptStartCommunicationResult { PromptStartCommunicationError }; -PromptStartCommunicationResult +SYMBIANUTILS_EXPORT PromptStartCommunicationResult promptStartCommunication(BaseCommunicationStarter &starter, const QString &msgBoxTitle, const QString &msgBoxText, @@ -59,14 +61,14 @@ PromptStartCommunicationResult // Convenience to start a serial connection (messages prompting // to launch Trk). -PromptStartCommunicationResult +SYMBIANUTILS_EXPORT PromptStartCommunicationResult promptStartSerial(BaseCommunicationStarter &starter, QWidget *msgBoxParent, QString *errorMessage); // Convenience to start blue tooth connection (messages // prompting to connect). -PromptStartCommunicationResult +SYMBIANUTILS_EXPORT PromptStartCommunicationResult promptStartBluetooth(BaseCommunicationStarter &starter, QWidget *msgBoxParent, QString *errorMessage); diff --git a/src/shared/trk/callback.h b/src/shared/trk/callback.h index 375f1671350932139c39fe1de7e8fba1586cadb7..eb555153d16930d8d41b6a44d0a236b227b06f73 100644 --- a/src/shared/trk/callback.h +++ b/src/shared/trk/callback.h @@ -30,7 +30,7 @@ #ifndef DEBUGGER_CALLBACK_H #define DEBUGGER_CALLBACK_H -#include <QtCore/QtGlobal> +#include "symbianutils_global.h" namespace trk { namespace Internal { diff --git a/src/shared/trk/communicationstarter.h b/src/shared/trk/communicationstarter.h index 6f9f6d1e434530ad0013687e02827f697e15b030..304ec06f73cd6cea38783cf55bbd56c582e24650 100644 --- a/src/shared/trk/communicationstarter.h +++ b/src/shared/trk/communicationstarter.h @@ -30,6 +30,8 @@ #ifndef COMMUNICATIONSTARTER_H #define COMMUNICATIONSTARTER_H +#include "symbianutils_global.h" + #include <QtCore/QSharedPointer> #include <QtCore/QObject> @@ -48,7 +50,7 @@ struct BaseCommunicationStarterPrivate; * The base class can be used as is to prompt the user to launch App TRK for a * serial communication as this requires no further resource setup. */ -class BaseCommunicationStarter : public QObject { +class SYMBIANUTILS_EXPORT BaseCommunicationStarter : public QObject { Q_OBJECT Q_DISABLE_COPY(BaseCommunicationStarter) public: @@ -105,7 +107,7 @@ private: * implement as a factory function that creates and sets up the * listener (mode, message connection, etc). */ -class AbstractBluetoothStarter : public BaseCommunicationStarter { +class SYMBIANUTILS_EXPORT AbstractBluetoothStarter : public BaseCommunicationStarter { Q_OBJECT Q_DISABLE_COPY(AbstractBluetoothStarter) public: @@ -122,7 +124,7 @@ protected: /* ConsoleBluetoothStarter: Convenience class for console processes. Creates a * listener in "Listen" mode with the messages redirected to standard output. */ -class ConsoleBluetoothStarter : public AbstractBluetoothStarter { +class SYMBIANUTILS_EXPORT ConsoleBluetoothStarter : public AbstractBluetoothStarter { Q_OBJECT Q_DISABLE_COPY(ConsoleBluetoothStarter) public: diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index fc2f05ad7e8572a6f14694f9525ec75eb907ace6..e927c4122635a0bb3c938ed090bf66485960e614 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -29,6 +29,7 @@ #include "launcher.h" #include "trkutils.h" +#include "trkutils_p.h" #include "trkdevice.h" #include "bluetoothlistener.h" @@ -604,9 +605,7 @@ void Launcher::cleanUp() // Sub Cmd: Delete Process //ProcessID: 0x0000071F (1823) // [41 24 00 00 00 00 07 1F] - QByteArray ba; - appendByte(&ba, 0x00); - appendByte(&ba, 0x00); + QByteArray ba(2, char(0)); appendInt(&ba, d->m_session.pid); d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(), ba, "Delete process"); @@ -659,7 +658,7 @@ void Launcher::copyFileToRemote() { emit copyingStarted(); QByteArray ba; - appendByte(&ba, 0x10); + ba.append(char(10)); appendString(&ba, d->m_copyState.destinationFileName.toLocal8Bit(), TargetByteOrder, false); d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba); } @@ -668,7 +667,7 @@ void Launcher::installRemotePackageSilently() { emit installingStarted(); QByteArray ba; - appendByte(&ba, 'C'); + ba.append('C'); appendString(&ba, d->m_installFileName.toLocal8Bit(), TargetByteOrder, false); d->m_device->sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba); } @@ -695,7 +694,7 @@ QByteArray Launcher::startProcessMessage(const QString &executable, // It's not started yet QByteArray ba; appendShort(&ba, 0, TargetByteOrder); // create new process - appendByte(&ba, 0); // options - currently unused + ba.append(char(0)); // options - currently unused if(arguments.isEmpty()) { appendString(&ba, executable.toLocal8Bit(), TargetByteOrder); return ba; diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index 9cd4b968e738c8d5aaf3d57e07464dc1f824f2e8..b9b68e400d6c0f0f200914ad98130cd2f14f28a8 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -43,7 +43,7 @@ struct LauncherPrivate; typedef QSharedPointer<TrkDevice> TrkDevicePtr; -class Launcher : public QObject +class SYMBIANUTILS_EXPORT Launcher : public QObject { Q_OBJECT Q_DISABLE_COPY(Launcher) diff --git a/src/shared/trk/symbianutils_global.h b/src/shared/trk/symbianutils_global.h new file mode 100644 index 0000000000000000000000000000000000000000..e0981715f6b9dfe996bb6c17b454c4c85100c88c --- /dev/null +++ b/src/shared/trk/symbianutils_global.h @@ -0,0 +1,43 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SYMBIANUTILS_GLOBAL_H +#define SYMBIANUTILS_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(SYMBIANUTILS_BUILD_LIB) +# define SYMBIANUTILS_EXPORT Q_DECL_EXPORT +#elif defined(SYMBIANUTILS_BUILD_STATIC_LIB) || defined(SYMBIANUTILS_INCLUDE_PRI) +# define SYMBIANUTILS_EXPORT +#else +# define SYMBIANUTILS_EXPORT Q_DECL_IMPORT +#endif + +#endif // SYMBIANUTILS_GLOBAL_H diff --git a/src/shared/trk/trk.pri b/src/shared/trk/trk.pri index 2ce17c0a6c68980811b893171e4c73022a21d603..a54df76968ec0246d7b61e7c2f1b9fe66b207d77 100644 --- a/src/shared/trk/trk.pri +++ b/src/shared/trk/trk.pri @@ -1,8 +1,10 @@ INCLUDEPATH *= $$PWD # Input -HEADERS += $$PWD/callback.h \ +HEADERS += $$PWD/symbianutils_global.h \ + $$PWD/callback.h \ $$PWD/trkutils.h \ + $$PWD/trkutils_p.h \ $$PWD/trkdevice.h \ $$PWD/launcher.h \ $$PWD/bluetoothlistener.h \ diff --git a/src/shared/trk/trkdevice.cpp b/src/shared/trk/trkdevice.cpp index ff3cd1df9e10a72795ce5b3a756f2489d05c9b52..e7fb8c4f78822e0afee05513d2f5688a4948c078 100644 --- a/src/shared/trk/trkdevice.cpp +++ b/src/shared/trk/trkdevice.cpp @@ -29,6 +29,7 @@ #include "trkdevice.h" #include "trkutils.h" +#include "trkutils_p.h" #include <QtCore/QString> #include <QtCore/QDebug> @@ -844,8 +845,8 @@ void UnixReaderThread::terminate() { // Trigger select() by writing to the pipe char c = 0; - int written = write(m_terminatePipeFileDescriptors[1], &c, 1); - // FIXME: Use result. + const int written = write(m_terminatePipeFileDescriptors[1], &c, 1); + Q_UNUSED(written) wait(); } diff --git a/src/shared/trk/trkdevice.h b/src/shared/trk/trkdevice.h index 948ba8cd1bc5ec22c66423820ee0fc8b409955bd..7a906e5cec5b2c41e6a7e5f9b0c630a5cb8bf750 100644 --- a/src/shared/trk/trkdevice.h +++ b/src/shared/trk/trkdevice.h @@ -30,6 +30,7 @@ #ifndef TRKDEVICE_H #define TRKDEVICE_H +#include "symbianutils_global.h" #include "callback.h" #include <QtCore/QObject> @@ -62,7 +63,7 @@ enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f }; typedef trk::Callback<const TrkResult &> TrkCallback; -class TrkDevice : public QObject +class SYMBIANUTILS_EXPORT TrkDevice : public QObject { Q_OBJECT Q_PROPERTY(bool serialFrame READ serialFrame WRITE setSerialFrame) diff --git a/src/shared/trk/trkutils.cpp b/src/shared/trk/trkutils.cpp index ce5d5867000444178bc0ef1bb7d95bc66e791240..7a6d7b68a3e3e2b3879498278a21184b64762ddc 100644 --- a/src/shared/trk/trkutils.cpp +++ b/src/shared/trk/trkutils.cpp @@ -74,7 +74,7 @@ void Session::reset() trkAppVersion.reset(); } -QString formatCpu(int major, int minor) +static QString formatCpu(int major, int minor) { //: CPU description of an S60 device //: %1 major verison, %2 minor version @@ -131,6 +131,38 @@ QString Session::deviceDescription(unsigned verbose) const return msg.arg(formatTrkVersion(trkAppVersion)); } +// -------------- + +QByteArray decode7d(const QByteArray &ba) +{ + QByteArray res; + res.reserve(ba.size()); + for (int i = 0; i < ba.size(); ++i) { + byte c = byte(ba.at(i)); + if (c == 0x7d) { + ++i; + c = 0x20 ^ byte(ba.at(i)); + } + res.append(c); + } + return res; +} + +QByteArray encode7d(const QByteArray &ba) +{ + QByteArray res; + res.reserve(ba.size() + 2); + for (int i = 0; i < ba.size(); ++i) { + byte c = byte(ba.at(i)); + if (c == 0x7e || c == 0x7d) { + res.append(0x7d); + res.append(0x20 ^ c); + } else { + res.append(c); + } + } + return res; +} // FIXME: Use the QByteArray based version below? static inline QString stringFromByte(byte c) @@ -138,7 +170,7 @@ static inline QString stringFromByte(byte c) return QString::fromLatin1("%1").arg(c, 2, 16, QChar('0')); } -QString stringFromArray(const QByteArray &ba, int maxLen) +SYMBIANUTILS_EXPORT QString stringFromArray(const QByteArray &ba, int maxLen) { QString str; QString ascii; @@ -158,7 +190,7 @@ QString stringFromArray(const QByteArray &ba, int maxLen) return str + " " + ascii; } -QByteArray hexNumber(uint n, int digits) +SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits) { QByteArray ba = QByteArray::number(n, 16); if (digits == 0 || ba.size() == digits) @@ -166,7 +198,7 @@ QByteArray hexNumber(uint n, int digits) return QByteArray(digits - ba.size(), '0') + ba; } -QByteArray hexxNumber(uint n, int digits) +SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits) { return "0x" + hexNumber(n, digits); } @@ -295,12 +327,12 @@ bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByt return true; } -ushort extractShort(const char *data) +SYMBIANUTILS_EXPORT ushort extractShort(const char *data) { return byte(data[0]) * 256 + byte(data[1]); } -uint extractInt(const char *data) +SYMBIANUTILS_EXPORT uint extractInt(const char *data) { uint res = byte(data[0]); res *= 256; res += byte(data[1]); @@ -309,7 +341,7 @@ uint extractInt(const char *data) return res; } -QString quoteUnprintableLatin1(const QByteArray &ba) +SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba) { QString res; char buf[10]; @@ -325,49 +357,7 @@ QString quoteUnprintableLatin1(const QByteArray &ba) return res; } -QByteArray decode7d(const QByteArray &ba) -{ - QByteArray res; - res.reserve(ba.size()); - for (int i = 0; i < ba.size(); ++i) { - byte c = byte(ba.at(i)); - if (c == 0x7d) { - ++i; - c = 0x20 ^ byte(ba.at(i)); - } - res.append(c); - } - //if (res != ba) - // logMessage("DECODED: " << stringFromArray(ba) - // << " -> " << stringFromArray(res)); - return res; -} - -QByteArray encode7d(const QByteArray &ba) -{ - QByteArray res; - res.reserve(ba.size() + 2); - for (int i = 0; i < ba.size(); ++i) { - byte c = byte(ba.at(i)); - if (c == 0x7e || c == 0x7d) { - res.append(0x7d); - res.append(0x20 ^ c); - } else { - res.append(c); - } - } - //if (res != ba) - // logMessage("ENCODED: " << stringFromArray(ba) - // << " -> " << stringFromArray(res)); - return res; -} - -void appendByte(QByteArray *ba, byte b) -{ - ba->append(b); -} - -void appendShort(QByteArray *ba, ushort s, Endianness endian) +SYMBIANUTILS_EXPORT void appendShort(QByteArray *ba, ushort s, Endianness endian) { if (endian == BigEndian) { ba->append(s / 256); @@ -378,7 +368,7 @@ void appendShort(QByteArray *ba, ushort s, Endianness endian) } } -void appendInt(QByteArray *ba, uint i, Endianness endian) +SYMBIANUTILS_EXPORT void appendInt(QByteArray *ba, uint i, Endianness endian) { const uchar b3 = i % 256; i /= 256; const uchar b2 = i % 256; i /= 256; diff --git a/src/shared/trk/trkutils.h b/src/shared/trk/trkutils.h index 0e23338d86fd5d949286874a51f77832380de1b0..3e6fcc0bc0daef5200768c929e56972b71818934 100644 --- a/src/shared/trk/trkutils.h +++ b/src/shared/trk/trkutils.h @@ -30,19 +30,21 @@ #ifndef DEBUGGER_TRK_UTILS #define DEBUGGER_TRK_UTILS +#include "symbianutils_global.h" + #include <QtCore/QByteArray> #include <QtCore/QHash> #include <QtCore/QStringList> #include <QtCore/QVariant> -typedef unsigned char byte; - QT_BEGIN_NAMESPACE class QDateTime; QT_END_NAMESPACE namespace trk { +typedef unsigned char byte; + enum Command { TrkPing = 0x00, TrkConnect = 0x01, @@ -73,17 +75,14 @@ enum Command { TrkNotifyProcessorReset = 0xa7 }; -QByteArray decode7d(const QByteArray &ba); -QByteArray encode7d(const QByteArray &ba); - inline byte extractByte(const char *data) { return *data; } -ushort extractShort(const char *data); -uint extractInt(const char *data); +SYMBIANUTILS_EXPORT ushort extractShort(const char *data); +SYMBIANUTILS_EXPORT uint extractInt(const char *data); -QString quoteUnprintableLatin1(const QByteArray &ba); +SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba); // produces "xx xx xx " -QString stringFromArray(const QByteArray &ba, int maxLen = - 1); +SYMBIANUTILS_EXPORT QString stringFromArray(const QByteArray &ba, int maxLen = - 1); enum Endianness { @@ -92,13 +91,11 @@ enum Endianness TargetByteOrder = BigEndian, }; -void appendByte(QByteArray *ba, byte b); -void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder); -void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder); -void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true); -void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder); +SYMBIANUTILS_EXPORT void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder); +SYMBIANUTILS_EXPORT void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder); +SYMBIANUTILS_EXPORT void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true); -struct Library +struct SYMBIANUTILS_EXPORT Library { Library() {} @@ -107,7 +104,7 @@ struct Library uint dataseg; }; -struct TrkAppVersion +struct SYMBIANUTILS_EXPORT TrkAppVersion { TrkAppVersion(); void reset(); @@ -118,7 +115,7 @@ struct TrkAppVersion int protocolMinor; }; -struct Session +struct SYMBIANUTILS_EXPORT Session { Session(); void reset(); @@ -151,7 +148,7 @@ struct Session QStringList modules; }; -struct TrkResult +struct SYMBIANUTILS_EXPORT TrkResult { TrkResult(); void clear(); @@ -167,15 +164,10 @@ struct TrkResult bool isDebugOutput; }; -// returns a QByteArray containing optionally -// the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e -QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame); -ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame); -bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0); -QByteArray errorMessage(byte code); -QByteArray hexNumber(uint n, int digits = 0); -QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too -uint swapEndian(uint in); +SYMBIANUTILS_EXPORT QByteArray errorMessage(byte code); +SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits = 0); +SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too +SYMBIANUTILS_EXPORT uint swapEndian(uint in); } // namespace trk diff --git a/src/shared/trk/trkutils_p.h b/src/shared/trk/trkutils_p.h new file mode 100644 index 0000000000000000000000000000000000000000..64f4a56d9388f4be596bd914c2f4e6bcd83d4174 --- /dev/null +++ b/src/shared/trk/trkutils_p.h @@ -0,0 +1,50 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef DEBUGGER_TRK_PRIVATE_UTILS +#define DEBUGGER_TRK_PRIVATE_UTILS + +#include "trkutils.h" +#include "symbianutils_global.h" + +QT_BEGIN_NAMESPACE +class QDateTime; +QT_END_NAMESPACE + +namespace trk { + +void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder); +// returns a QByteArray containing optionally +// the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e +QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame); +bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0); + +} // namespace trk + +#endif // DEBUGGER_TRK_PRIVATE_UTILS diff --git a/tests/manual/trklauncher/trklauncher.pro b/tests/manual/trklauncher/trklauncher.pro index 943afde4ada2fde33c17e08c97ff4dedb55d095e..4290534ea52d239f9beffdbe8ebf3365a8bce07b 100644 --- a/tests/manual/trklauncher/trklauncher.pro +++ b/tests/manual/trklauncher/trklauncher.pro @@ -1,5 +1,6 @@ TEMPLATE = app QT = core +DEFINES += SYMBIANUTILS_INCLUDE_PRI CONFIG += console include(../../../src/shared/trk/trk.pri) SOURCES += main.cpp