2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-07-29 14:15:12 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-07-29 14:15:12 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-07-29 14:15:12 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-07-29 14:15:12 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2011-04-13 08:42:33 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-07-29 14:15:12 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
#ifndef QMLDEBUGCLIENT_H
|
|
|
|
|
#define QMLDEBUGCLIENT_H
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
#include "qmldebug_global.h"
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <qtcpsocket.h>
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2013-11-02 20:54:18 +02:00
|
|
|
#include <QDataStream>
|
|
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
namespace QmlDebug {
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
class QmlDebugConnectionPrivate;
|
|
|
|
|
class QMLDEBUG_EXPORT QmlDebugConnection : public QIODevice
|
2010-07-29 14:15:12 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2012-04-18 12:06:10 +02:00
|
|
|
Q_DISABLE_COPY(QmlDebugConnection)
|
2010-07-29 14:15:12 +02:00
|
|
|
public:
|
2012-04-18 12:06:10 +02:00
|
|
|
QmlDebugConnection(QObject * = 0);
|
|
|
|
|
~QmlDebugConnection();
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2011-02-23 12:10:51 +01:00
|
|
|
void connectToHost(const QString &hostName, quint16 port);
|
|
|
|
|
|
|
|
|
|
qint64 bytesAvailable() const;
|
2010-07-29 14:15:12 +02:00
|
|
|
bool isConnected() const;
|
2011-02-23 12:10:51 +01:00
|
|
|
QAbstractSocket::SocketState state() const;
|
|
|
|
|
void flush();
|
|
|
|
|
bool isSequential() const;
|
|
|
|
|
void close();
|
2011-08-31 12:55:08 +02:00
|
|
|
bool waitForConnected(int msecs = 30000);
|
2011-02-23 12:10:51 +01:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void connected();
|
|
|
|
|
void stateChanged(QAbstractSocket::SocketState socketState);
|
|
|
|
|
void error(QAbstractSocket::SocketError socketError);
|
|
|
|
|
|
2011-08-31 12:55:08 +02:00
|
|
|
protected:
|
2011-02-23 12:10:51 +01:00
|
|
|
qint64 readData(char *data, qint64 maxSize);
|
|
|
|
|
qint64 writeData(const char *data, qint64 maxSize);
|
|
|
|
|
|
2011-10-07 15:00:05 +02:00
|
|
|
private slots:
|
|
|
|
|
void internalError(QAbstractSocket::SocketError error);
|
|
|
|
|
|
2010-07-29 14:15:12 +02:00
|
|
|
private:
|
2012-04-18 12:06:10 +02:00
|
|
|
QmlDebugConnectionPrivate *d;
|
|
|
|
|
friend class QmlDebugClient;
|
|
|
|
|
friend class QmlDebugClientPrivate;
|
2010-07-29 14:15:12 +02:00
|
|
|
};
|
|
|
|
|
|
2012-05-10 10:29:11 +02:00
|
|
|
enum ClientStatus {
|
|
|
|
|
NotConnected,
|
|
|
|
|
Unavailable,
|
|
|
|
|
Enabled
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
class QmlDebugClientPrivate;
|
|
|
|
|
class QMLDEBUG_EXPORT QmlDebugClient : public QObject
|
2010-07-29 14:15:12 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2012-04-18 12:06:10 +02:00
|
|
|
Q_DECLARE_PRIVATE(QmlDebugClient)
|
|
|
|
|
Q_DISABLE_COPY(QmlDebugClient)
|
2010-07-29 14:15:12 +02:00
|
|
|
|
|
|
|
|
public:
|
2012-04-18 12:06:10 +02:00
|
|
|
QmlDebugClient(const QString &, QmlDebugConnection *parent);
|
|
|
|
|
~QmlDebugClient();
|
2010-07-29 14:15:12 +02:00
|
|
|
|
|
|
|
|
QString name() const;
|
2011-12-15 17:56:58 +01:00
|
|
|
float serviceVersion() const;
|
2012-05-10 10:29:11 +02:00
|
|
|
ClientStatus status() const;
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2011-07-26 16:22:49 +02:00
|
|
|
virtual void sendMessage(const QByteArray &);
|
2010-07-29 14:15:12 +02:00
|
|
|
|
|
|
|
|
protected:
|
2012-05-10 10:29:11 +02:00
|
|
|
virtual void statusChanged(ClientStatus);
|
2010-07-29 14:15:12 +02:00
|
|
|
virtual void messageReceived(const QByteArray &);
|
|
|
|
|
|
|
|
|
|
private:
|
2012-04-18 12:06:10 +02:00
|
|
|
friend class QmlDebugConnection;
|
|
|
|
|
friend class QmlDebugConnectionPrivate;
|
|
|
|
|
QScopedPointer<QmlDebugClientPrivate> d_ptr;
|
2013-11-01 09:58:44 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static int s_dataStreamVersion;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QMLDEBUG_EXPORT QmlDebugStream : public QDataStream
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QmlDebugStream();
|
|
|
|
|
explicit QmlDebugStream(QIODevice *d);
|
|
|
|
|
QmlDebugStream(QByteArray *ba, QIODevice::OpenMode flags);
|
|
|
|
|
QmlDebugStream(const QByteArray &ba);
|
2010-07-29 14:15:12 +02:00
|
|
|
};
|
|
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
} // namespace QmlDebug
|
2010-07-29 14:15:12 +02:00
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
#endif // QMLDEBUGCLIENT_H
|