source: trunk/tools/runonphone/symbianutils/trkdevice.h@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 4.6 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the tools applications of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef TRKDEVICE_H
43#define TRKDEVICE_H
44
45#include "symbianutils_global.h"
46#include "callback.h"
47
48#include <QtCore/QObject>
49#include <QtCore/QVariant>
50#include <QtCore/QByteArray>
51#include <QtCore/QSharedPointer>
52
53QT_BEGIN_NAMESPACE
54class QIODevice;
55QT_END_NAMESPACE
56
57namespace trk {
58
59struct TrkResult;
60struct TrkMessage;
61struct TrkDevicePrivate;
62
63/* TrkDevice: Implements a Windows COM or Linux device for
64 * Trk communications. Provides synchronous write and asynchronous
65 * read operation.
66 * The serialFrames property specifies whether packets are encapsulated in
67 * "0x90 <length>" frames, which is currently the case for serial ports.
68 * Contains a write message queue allowing
69 * for queueing messages with a notification callback. If the message receives
70 * an ACK, the callback is invoked.
71 * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronisation.
72 * The respective message will not be sent, the callback is just invoked. */
73
74enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f };
75
76typedef trk::Callback<const TrkResult &> TrkCallback;
77
78class SYMBIANUTILS_EXPORT TrkDevice : public QObject
79{
80 Q_OBJECT
81 Q_PROPERTY(bool serialFrame READ serialFrame WRITE setSerialFrame)
82 Q_PROPERTY(bool verbose READ verbose WRITE setVerbose)
83 Q_PROPERTY(QString port READ port WRITE setPort)
84public:
85 explicit TrkDevice(QObject *parent = 0);
86 virtual ~TrkDevice();
87
88 bool open(QString *errorMessage);
89 bool isOpen() const;
90
91 QString port() const;
92 void setPort(const QString &p);
93
94 QString errorString() const;
95
96 bool serialFrame() const;
97 void setSerialFrame(bool f);
98
99 int verbose() const;
100 void setVerbose(int b);
101
102 // Enqueue a message with a notification callback.
103 void sendTrkMessage(unsigned char code,
104 TrkCallback callBack = TrkCallback(),
105 const QByteArray &data = QByteArray(),
106 const QVariant &cookie = QVariant());
107
108 // Enqeue an initial ping
109 void sendTrkInitialPing();
110
111 // Send an Ack synchronously, bypassing the queue
112 bool sendTrkAck(unsigned char token);
113
114signals:
115 void messageReceived(const trk::TrkResult &result);
116 // Emitted with the contents of messages enclosed in 07e, not for log output
117 void rawDataReceived(const QByteArray &data);
118 void error(const QString &msg);
119 void logMessage(const QString &msg);
120
121private slots:
122 void slotMessageReceived(const trk::TrkResult &result, const QByteArray &a);
123
124protected slots:
125 void emitError(const QString &msg);
126 void emitLogMessage(const QString &msg);
127
128public slots:
129 void close();
130
131private:
132 void readMessages();
133 TrkDevicePrivate *d;
134};
135
136} // namespace trk
137
138#endif // TRKDEVICE_H
Note: See TracBrowser for help on using the repository browser.