summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.qmake.conf1
-rw-r--r--jsonstream.pro5
-rw-r--r--modules/qt_jsonstream.pri16
-rw-r--r--qtjsonstream.pro1
-rw-r--r--src/common.pri17
-rw-r--r--src/jsonstream/bson/bson.cpp (renamed from src/bson/bson.cpp)0
-rw-r--r--src/jsonstream/bson/bson.pri (renamed from src/bson/bson.pri)0
-rw-r--r--src/jsonstream/bson/bson_p.h (renamed from src/bson/bson_p.h)0
-rw-r--r--src/jsonstream/bson/platform_hacks_p.h (renamed from src/bson/platform_hacks_p.h)0
-rw-r--r--src/jsonstream/bson/qt-bson.cpp (renamed from src/bson/qt-bson.cpp)0
-rw-r--r--src/jsonstream/bson/qt-bson_p.h (renamed from src/bson/qt-bson_p.h)0
-rw-r--r--src/jsonstream/jsonstream.pro78
-rw-r--r--src/jsonstream/qjsonauthority.cpp (renamed from src/jsonauthority.cpp)38
-rw-r--r--src/jsonstream/qjsonauthority.h (renamed from src/jsonauthority.h)24
-rw-r--r--src/jsonstream/qjsonbuffer.cpp (renamed from src/jsonbuffer.cpp)48
-rw-r--r--src/jsonstream/qjsonbuffer_p.h (renamed from src/jsonbuffer_p.h)8
-rw-r--r--src/jsonstream/qjsonclient.cpp (renamed from src/jsonclient.cpp)80
-rw-r--r--src/jsonstream/qjsonclient.h (renamed from src/jsonclient.h)18
-rw-r--r--src/jsonstream/qjsonconnection.cpp (renamed from src/jsonconnection.cpp)184
-rw-r--r--src/jsonstream/qjsonconnection.h (renamed from src/jsonconnection.h)38
-rw-r--r--src/jsonstream/qjsonconnectionprocessor.cpp (renamed from src/jsonconnectionprocessor.cpp)136
-rw-r--r--src/jsonstream/qjsonconnectionprocessor_p.h (renamed from src/jsonconnectionprocessor_p.h)38
-rw-r--r--src/jsonstream/qjsonendpoint.cpp (renamed from src/jsonendpoint.cpp)72
-rw-r--r--src/jsonstream/qjsonendpoint.h (renamed from src/jsonendpoint.h)26
-rw-r--r--src/jsonstream/qjsonendpointmanager.cpp (renamed from src/jsonendpointmanager.cpp)48
-rw-r--r--src/jsonstream/qjsonendpointmanager_p.h (renamed from src/jsonendpointmanager_p.h)28
-rw-r--r--src/jsonstream/qjsonpidauthority.cpp (renamed from src/jsonpidauthority.cpp)36
-rw-r--r--src/jsonstream/qjsonpidauthority.h (renamed from src/jsonpidauthority.h)14
-rw-r--r--src/jsonstream/qjsonpipe.cpp (renamed from src/jsonpipe.cpp)96
-rw-r--r--src/jsonstream/qjsonpipe.h (renamed from src/jsonpipe.h)18
-rw-r--r--src/jsonstream/qjsonserver.cpp (renamed from src/jsonserver.cpp)198
-rw-r--r--src/jsonstream/qjsonserver.h (renamed from src/jsonserver.h)34
-rw-r--r--src/jsonstream/qjsonserverclient.cpp (renamed from src/jsonserverclient.cpp)88
-rw-r--r--src/jsonstream/qjsonserverclient.h (renamed from src/jsonserverclient.h)18
-rw-r--r--src/jsonstream/qjsonstream-global.h (renamed from src/jsonstream-global.h)16
-rw-r--r--src/jsonstream/qjsonstream.cpp (renamed from src/jsonstream.cpp)132
-rw-r--r--src/jsonstream/qjsonstream.h (renamed from src/jsonstream.h)22
-rw-r--r--src/jsonstream/qjsontokenauthority.cpp (renamed from src/jsontokenauthority.cpp)30
-rw-r--r--src/jsonstream/qjsontokenauthority.h (renamed from src/jsontokenauthority.h)14
-rw-r--r--src/jsonstream/qjsonuidauthority.cpp (renamed from src/jsonuidauthority.cpp)42
-rw-r--r--src/jsonstream/qjsonuidauthority.h (renamed from src/jsonuidauthority.h)14
-rw-r--r--src/jsonstream/qjsonuidrangeauthority.cpp (renamed from src/jsonuidrangeauthority.cpp)46
-rw-r--r--src/jsonstream/qjsonuidrangeauthority.h (renamed from src/jsonuidrangeauthority.h)14
-rw-r--r--src/jsonstream/qtjsonschema/checkpoints_p.h (renamed from src/qtjsonschema/checkpoints_p.h)18
-rw-r--r--src/jsonstream/qtjsonschema/jsonobjecttypes_impl_p.h (renamed from src/qtjsonschema/jsonobjecttypes_impl_p.h)16
-rw-r--r--src/jsonstream/qtjsonschema/jsonobjecttypes_p.h (renamed from src/qtjsonschema/jsonobjecttypes_p.h)2
-rw-r--r--src/jsonstream/qtjsonschema/qjsonschema-global.h (renamed from src/qtjsonschema/jsonschema-global.h)2
-rw-r--r--src/jsonstream/qtjsonschema/qjsonschemaerror.cpp (renamed from src/qtjsonschema/schemaerror.cpp)46
-rw-r--r--src/jsonstream/qtjsonschema/qjsonschemaerror.h (renamed from src/qtjsonschema/schemaerror.h)14
-rw-r--r--src/jsonstream/qtjsonschema/qjsonschemavalidator.cpp (renamed from src/qtjsonschema/schemavalidator.cpp)168
-rw-r--r--src/jsonstream/qtjsonschema/qjsonschemavalidator.h (renamed from src/qtjsonschema/schemavalidator.h)18
-rw-r--r--src/jsonstream/qtjsonschema/schemamanager_impl_p.h (renamed from src/qtjsonschema/schemamanager_impl_p.h)2
-rw-r--r--src/jsonstream/qtjsonschema/schemamanager_p.h (renamed from src/qtjsonschema/schemamanager_p.h)2
-rw-r--r--src/jsonstream/qtjsonschema/schemaobject_p.h (renamed from src/qtjsonschema/schemaobject_p.h)0
-rw-r--r--src/src.pro90
-rw-r--r--sync.profile7
-rw-r--r--tests/auto/jsonbuffer/tst_jsonbuffer.cpp6
-rw-r--r--tests/auto/jsonconnection/testClient/main.cpp8
-rw-r--r--tests/auto/jsonconnection/tst_jsonconnection.cpp92
-rw-r--r--tests/auto/jsonschema/tst_jsonschema.cpp8
-rw-r--r--tests/auto/jsonstream/testClient/main.cpp6
-rw-r--r--tests/auto/jsonstream/tst_jsonstream.cpp68
-rw-r--r--tests/auto/testsuite/tst_jsonclient.cpp2
-rw-r--r--tests/auto/testsuite/tst_jsonclient.h2
-rw-r--r--tests/auto/testsuite/tst_jsonserver.cpp10
-rw-r--r--tests/auto/testsuite/tst_jsonserver.h2
67 files changed, 1141 insertions, 1186 deletions
diff --git a/.gitignore b/.gitignore
index ea15212..b05d7fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,5 @@ src/qtaddonjsonstreamversion.h
lib/pkgconfig/*
Makefile.Debug
Makefile.Release
+mkspecs/*
+src/include/*
diff --git a/.qmake.conf b/.qmake.conf
new file mode 100644
index 0000000..4285ae8
--- /dev/null
+++ b/.qmake.conf
@@ -0,0 +1 @@
+load(qt_build_config) \ No newline at end of file
diff --git a/jsonstream.pro b/jsonstream.pro
deleted file mode 100644
index 3e66336..0000000
--- a/jsonstream.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = src tests
-CONFIG += ordered
-include(doc/doc.pri)
-
diff --git a/modules/qt_jsonstream.pri b/modules/qt_jsonstream.pri
deleted file mode 100644
index 53a5711..0000000
--- a/modules/qt_jsonstream.pri
+++ /dev/null
@@ -1,16 +0,0 @@
-QT.jsonstream.VERSION = 1.0.0
-QT.jsonstream.MAJOR_VERSION = 1
-QT.jsonstream.MINOR_VERSION = 0
-QT.jsonstream.PATCH_VERSION = 0
-
-QT.jsonstream.name = QtAddOnJsonStream
-QT.jsonstream.bins = $$QT_MODULE_BIN_BASE
-QT.jsonstream.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtAddOnJsonStream
-QT.jsonstream.private_includes = $$QT_MODULE_INCLUDE_BASE/QtAddOnJsonStream/$$QT.jsonstream.VERSION
-QT.jsonstream.sources = $$QT_MODULE_BASE/src
-QT.jsonstream.libs = $$QT_MODULE_LIB_BASE
-QT.jsonstream.plugins = $$QT_MODULE_PLUGIN_BASE
-QT.jsonstream.imports = $$QT_MODULE_IMPORT_BASE
-QT.jsonstream.depends = core network
-
-QT_CONFIG += jsonstream
diff --git a/qtjsonstream.pro b/qtjsonstream.pro
new file mode 100644
index 0000000..58c33f2
--- /dev/null
+++ b/qtjsonstream.pro
@@ -0,0 +1 @@
+load(qt_parts)
diff --git a/src/common.pri b/src/common.pri
deleted file mode 100644
index f17e5ff..0000000
--- a/src/common.pri
+++ /dev/null
@@ -1,17 +0,0 @@
-COMMON_PRIVATE_HEADERS = \
- $$PWD/bson/bson.h \
- $$PWD/bson/platform_hacks.h \
- $$PWD/bson/qt-bson.h
-
-COMMON_PUBLIC_HEADERS = \
- $$PWD/jsonstream.h \
- $$PWD/jsonbuffer.h
-
-COMMON_SOURCES = \
- $$PWD/jsonstream.cpp \
- $$PWD/jsonbuffer.cpp \
- $$PWD/bson/bson.cpp \
- $$PWD/bson/qt-bson.cpp \
- $$PWD/bson/bson-scriptvalue.cpp
-
-INCLUDEPATH += $$PWD $$PWD/bson
diff --git a/src/bson/bson.cpp b/src/jsonstream/bson/bson.cpp
index 09eaa46..09eaa46 100644
--- a/src/bson/bson.cpp
+++ b/src/jsonstream/bson/bson.cpp
diff --git a/src/bson/bson.pri b/src/jsonstream/bson/bson.pri
index 821cfbb..821cfbb 100644
--- a/src/bson/bson.pri
+++ b/src/jsonstream/bson/bson.pri
diff --git a/src/bson/bson_p.h b/src/jsonstream/bson/bson_p.h
index e8295d3..e8295d3 100644
--- a/src/bson/bson_p.h
+++ b/src/jsonstream/bson/bson_p.h
diff --git a/src/bson/platform_hacks_p.h b/src/jsonstream/bson/platform_hacks_p.h
index 5a2f553..5a2f553 100644
--- a/src/bson/platform_hacks_p.h
+++ b/src/jsonstream/bson/platform_hacks_p.h
diff --git a/src/bson/qt-bson.cpp b/src/jsonstream/bson/qt-bson.cpp
index da7315c..da7315c 100644
--- a/src/bson/qt-bson.cpp
+++ b/src/jsonstream/bson/qt-bson.cpp
diff --git a/src/bson/qt-bson_p.h b/src/jsonstream/bson/qt-bson_p.h
index cf24379..cf24379 100644
--- a/src/bson/qt-bson_p.h
+++ b/src/jsonstream/bson/qt-bson_p.h
diff --git a/src/jsonstream/jsonstream.pro b/src/jsonstream/jsonstream.pro
new file mode 100644
index 0000000..7d4c863
--- /dev/null
+++ b/src/jsonstream/jsonstream.pro
@@ -0,0 +1,78 @@
+TARGET = QtAddOnJsonStream
+QT += core network
+QT -= gui
+
+load(qt_module)
+
+DEFINES += QT_ADDON_JSONSTREAM_LIB
+
+unix:!mac {
+ PUBLIC_HEADERS += $$PWD/qjsonpidauthority.h
+ SOURCES += $$PWD/qjsonpidauthority.cpp
+}
+
+BSON_HEADERS = \
+ $$PWD/bson/bson_p.h \
+ $$PWD/bson/platform_hacks_p.h \
+ $$PWD/bson/qt-bson_p.h
+
+SCHEMA_PUBLIC_HEADERS = \
+ $$PWD/qtjsonschema/qjsonschema-global.h \
+ $$PWD/qtjsonschema/qjsonschemaerror.h \
+ $$PWD/qtjsonschema/qjsonschemavalidator.h
+
+SCHEMA_HEADERS = \
+ $$PWD/qtjsonschema/schemaobject_p.h \
+ $$PWD/qtjsonschema/checkpoints_p.h \
+ $$PWD/qtjsonschema/schemamanager_impl_p.h \
+ $$PWD/qtjsonschema/schemamanager_p.h \
+ $$PWD/qtjsonschema/jsonobjecttypes_p.h \
+ $$PWD/qtjsonschema/jsonobjecttypes_impl_p.h
+
+SCHEMA_SOURCES = \
+ $$PWD/qtjsonschema/qjsonschemaerror.cpp \
+ $$PWD/qtjsonschema/qjsonschemavalidator.cpp
+
+PUBLIC_HEADERS += \
+ $$PWD/qjsonstream.h \
+ $$PWD/qjsonclient.h \
+ $$PWD/qjsonauthority.h \
+ $$PWD/qjsontokenauthority.h \
+ $$PWD/qjsonuidauthority.h \
+ $$PWD/qjsonuidrangeauthority.h \
+ $$PWD/qjsonserver.h \
+ $$PWD/qjsonstream-global.h \
+ $$PWD/qjsonserverclient.h \
+ $$PWD/qjsonpipe.h \
+ $$PWD/qjsonconnection.h \
+ $$PWD/qjsonendpoint.h \
+ $$SCHEMA_PUBLIC_HEADERS
+
+HEADERS += \
+ $$PWD/qjsonbuffer_p.h \
+ $$PWD/qjsonconnectionprocessor_p.h \
+ $$PWD/qjsonendpointmanager_p.h \
+ $$BSON_HEADERS \
+ $$PUBLIC_HEADERS \
+ $$SCHEMA_HEADERS
+
+SOURCES += \
+ $$PWD/qjsonstream.cpp \
+ $$PWD/qjsonbuffer.cpp \
+ $$PWD/bson/bson.cpp \
+ $$PWD/bson/qt-bson.cpp \
+ $$PWD/qjsonclient.cpp \
+ $$PWD/qjsonauthority.cpp \
+ $$PWD/qjsontokenauthority.cpp \
+ $$PWD/qjsonuidauthority.cpp \
+ $$PWD/qjsonuidrangeauthority.cpp \
+ $$PWD/qjsonserverclient.cpp \
+ $$PWD/qjsonserver.cpp \
+ $$PWD/qjsonpipe.cpp \
+ $$PWD/qjsonconnection.cpp \
+ $$PWD/qjsonconnectionprocessor.cpp \
+ $$PWD/qjsonendpoint.cpp \
+ $$PWD/qjsonendpointmanager.cpp \
+ $$SCHEMA_SOURCES \
+
+mac:QMAKE_FRAMEWORK_BUNDLE_NAME = $$TARGET
diff --git a/src/jsonauthority.cpp b/src/jsonstream/qjsonauthority.cpp
index 35f1b30..2bda29d 100644
--- a/src/jsonauthority.cpp
+++ b/src/jsonstream/qjsonauthority.cpp
@@ -39,46 +39,46 @@
**
****************************************************************************/
-#include "jsonauthority.h"
+#include "qjsonauthority.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
/**************************************************************************************************/
/*!
- \class JsonAuthority
- \brief The JsonAuthority class is an abstract class used to authorize new Json client connections.
+ \class QJsonAuthority
+ \brief The QJsonAuthority class is an abstract class used to authorize new QJson client connections.
- The JsonAuthority class authorizes Json client connections.
+ The QJsonAuthority class authorizes QJson client connections.
- Note: Do I need an asynchronous way so that a JsonAuthority can drop a client connection
+ Note: Do I need an asynchronous way so that a QJsonAuthority can drop a client connection
after a timeout?
*/
/*!
- \enum JsonAuthority::AuthorizationState
+ \enum QJsonAuthority::AuthorizationState
This enum is returned from clientConnected() and messageReceived() calls to change the
authorization state of the connection.
- \value StateAuthorized The connection is authorized. All future messages are send to the \c JsonServer clients.
- \value StateNotAuthorized The connection is not authorized. The \c JsonServer must shut down the connection.
- \value StatePending The connection has not yet been authorized. New messages will be send to the \c JsonAuthority
- until the connection is authorized by the JsonAuthority.
+ \value StateAuthorized The connection is authorized. All future messages are send to the \c QJsonServer clients.
+ \value StateNotAuthorized The connection is not authorized. The \c QJsonServer must shut down the connection.
+ \value StatePending The connection has not yet been authorized. New messages will be send to the \c QJsonAuthority
+ until the connection is authorized by the QJsonAuthority.
*/
/*!
- Constructs a \c JsonAuthority object with the given \a parent.
+ Constructs a \c QJsonAuthority object with the given \a parent.
*/
-JsonAuthority::JsonAuthority(QObject *parent)
+QJsonAuthority::QJsonAuthority(QObject *parent)
: QObject(parent)
{
}
/*!
- Destructs the JsonAuthority object.
+ Destructs the QJsonAuthority object.
*/
-JsonAuthority::~JsonAuthority()
+QJsonAuthority::~QJsonAuthority()
{
}
@@ -87,7 +87,7 @@ JsonAuthority::~JsonAuthority()
Will only be called if a non-authorized client disconnects.
The \a stream object should not be used to send messages.
*/
-void JsonAuthority::clientDisconnected( JsonStream *stream )
+void QJsonAuthority::clientDisconnected( QJsonStream *stream )
{
Q_UNUSED(stream);
}
@@ -95,11 +95,11 @@ void JsonAuthority::clientDisconnected( JsonStream *stream )
/*!
Returns an AuthorizationRecord based on initial client connection. If the authorization state is \c Authorized,
the record's identifier must be initialized to a unique value. The \a stream object may be used to send
- messages; for example, the \c JsonAuthority object may participate in a challenge-response exchange before
+ messages; for example, the \c QJsonAuthority object may participate in a challenge-response exchange before
authorizing the connection.
*/
-AuthorizationRecord JsonAuthority::clientConnected( JsonStream *stream )
+AuthorizationRecord QJsonAuthority::clientConnected( QJsonStream *stream )
{
Q_UNUSED(stream);
return AuthorizationRecord( StateNotAuthorized );
@@ -111,13 +111,13 @@ AuthorizationRecord JsonAuthority::clientConnected( JsonStream *stream )
messages to the client.
*/
-AuthorizationRecord JsonAuthority::messageReceived(JsonStream *stream, const QJsonObject& message)
+AuthorizationRecord QJsonAuthority::messageReceived(QJsonStream *stream, const QJsonObject& message)
{
Q_UNUSED(stream);
Q_UNUSED(message);
return AuthorizationRecord( StateNotAuthorized );
}
-#include "moc_jsonauthority.cpp"
+#include "moc_qjsonauthority.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonauthority.h b/src/jsonstream/qjsonauthority.h
index fca4867..e44b745 100644
--- a/src/jsonauthority.h
+++ b/src/jsonstream/qjsonauthority.h
@@ -47,14 +47,14 @@
QT_FORWARD_DECLARE_CLASS(QLocalSocket)
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonStream;
+class QJsonStream;
class AuthorizationRecord;
-class Q_ADDON_JSONSTREAM_EXPORT JsonAuthority : public QObject
+class Q_ADDON_JSONSTREAM_EXPORT QJsonAuthority : public QObject
{
Q_OBJECT
public:
@@ -65,26 +65,26 @@ public:
};
Q_ENUMS(AuthorizationState)
- explicit JsonAuthority(QObject *parent = 0);
- virtual ~JsonAuthority();
+ explicit QJsonAuthority(QObject *parent = 0);
+ virtual ~QJsonAuthority();
- virtual AuthorizationRecord clientConnected(JsonStream *stream);
- virtual AuthorizationRecord messageReceived(JsonStream *stream, const QJsonObject &message);
- virtual void clientDisconnected(JsonStream *stream);
+ virtual AuthorizationRecord clientConnected(QJsonStream *stream);
+ virtual AuthorizationRecord messageReceived(QJsonStream *stream, const QJsonObject &message);
+ virtual void clientDisconnected(QJsonStream *stream);
};
class AuthorizationRecord {
public:
- AuthorizationRecord() : state(JsonAuthority::StateNotAuthorized) {}
- AuthorizationRecord( JsonAuthority::AuthorizationState s, QString i = QString() )
+ AuthorizationRecord() : state(QJsonAuthority::StateNotAuthorized) {}
+ AuthorizationRecord(QJsonAuthority::AuthorizationState s, QString i = QString() )
: identifier(i), state(s) {}
QString identifier;
- JsonAuthority::AuthorizationState state;
+ QJsonAuthority::AuthorizationState state;
};
QT_END_NAMESPACE_JSONSTREAM
-QT_JSONSTREAM_DECLARE_METATYPE_PTR(JsonAuthority)
+QT_JSONSTREAM_DECLARE_METATYPE_PTR(QJsonAuthority)
#endif // JSONAUTHORITY_H
diff --git a/src/jsonbuffer.cpp b/src/jsonstream/qjsonbuffer.cpp
index f34fd24..b73071d 100644
--- a/src/jsonbuffer.cpp
+++ b/src/jsonstream/qjsonbuffer.cpp
@@ -47,7 +47,7 @@
#include <unistd.h> // for ::read
-#include "jsonbuffer_p.h"
+#include "qjsonbuffer_p.h"
#include "qjsondocument.h"
#include "qjsonobject.h"
#include "bson/qt-bson_p.h"
@@ -61,21 +61,21 @@ inline bool isjsonws(T c)
}
/*!
- \class JsonBuffer
- \brief The JsonBuffer class parses data received into appropriate Json messages
+ \class QJsonBuffer
+ \brief The QJsonBuffer class parses data received into appropriate QJson messages
- The JsonBuffer class wraps an internal buffer. As you append
- data, the JsonBuffer object parses for received Json objects and
+ The QJsonBuffer class wraps an internal buffer. As you append
+ data, the QJsonBuffer object parses for received QJson objects and
raises an appropriate signal for each received object.
\warning This class does not support JSON arrays. Arrays that are received will be ignored.
*/
/*!
- Construct a JsonBuffer object with the given \a parent
+ Construct a QJsonBuffer object with the given \a parent
*/
-JsonBuffer::JsonBuffer(QObject *parent)
+QJsonBuffer::QJsonBuffer(QObject *parent)
: QObject(parent)
, mFormat(FormatUndefined)
, mParserState(ParseNormal)
@@ -91,7 +91,7 @@ JsonBuffer::JsonBuffer(QObject *parent)
}
/*!
- \fn bool JsonBuffer::isEnabled() const
+ \fn bool QJsonBuffer::isEnabled() const
Returns true if \l{readyReadMessage()} signal notifier is enabled; otherwise returns false.
@@ -99,7 +99,7 @@ JsonBuffer::JsonBuffer(QObject *parent)
*/
/*!
- \fn void JsonBuffer::setEnabled(bool enable)
+ \fn void QJsonBuffer::setEnabled(bool enable)
If \a enable is true, \l{readyReadMessage()} signal notifier is enabled;
otherwise the notifier is disabled.
@@ -113,7 +113,7 @@ JsonBuffer::JsonBuffer(QObject *parent)
*/
/*!
- \fn int JsonBuffer::size() const
+ \fn int QJsonBuffer::size() const
Returns the size of the buffer in bytes.
*/
@@ -124,7 +124,7 @@ JsonBuffer::JsonBuffer(QObject *parent)
signal may be raised.
*/
-void JsonBuffer::append(const QByteArray& data)
+void QJsonBuffer::append(const QByteArray& data)
{
{
QScopedPointer<QMutexLocker> locker(createLocker());
@@ -135,12 +135,12 @@ void JsonBuffer::append(const QByteArray& data)
}
/*!
- Append the \a data pointer with length \a len onto the JsonBuffer.
+ Append the \a data pointer with length \a len onto the QJsonBuffer.
During the execution of this function, the \l{readyReadMessage()}
signal may be raised.
*/
-void JsonBuffer::append(const char *data, int len)
+void QJsonBuffer::append(const char *data, int len)
{
{
QScopedPointer<QMutexLocker> locker(createLocker());
@@ -159,7 +159,7 @@ void JsonBuffer::append(const char *data, int len)
Returns the number of bytes read or -1 for an error condition.
*/
-int JsonBuffer::copyFromFd(int fd)
+int QJsonBuffer::copyFromFd(int fd)
{
const int maxcopy = 1024;
QScopedPointer<QMutexLocker> locker(createLocker());
@@ -181,7 +181,7 @@ int JsonBuffer::copyFromFd(int fd)
Clear the contents of the buffer.
*/
-void JsonBuffer::clear()
+void QJsonBuffer::clear()
{
QScopedPointer<QMutexLocker> locker(createLocker());
mBuffer.clear();
@@ -192,7 +192,7 @@ void JsonBuffer::clear()
\internal
*/
-bool JsonBuffer::scanUtf( int c )
+bool QJsonBuffer::scanUtf( int c )
{
switch (mParserState) {
case ParseNormal:
@@ -225,7 +225,7 @@ bool JsonBuffer::scanUtf( int c )
return false;
}
-void JsonBuffer::resetParser()
+void QJsonBuffer::resetParser()
{
mParserState = ParseNormal;
mParserDepth = 0;
@@ -239,7 +239,7 @@ void JsonBuffer::resetParser()
\internal
*/
-void JsonBuffer::processMessages()
+void QJsonBuffer::processMessages()
{
// do not process anything if disabled or if control is still inside readyReadMessage() slot
if (mEnabled && !mEmittedReadyRead) {
@@ -254,7 +254,7 @@ void JsonBuffer::processMessages()
/*!
\internal
*/
-bool JsonBuffer::messageAvailable()
+bool QJsonBuffer::messageAvailable()
{
QScopedPointer<QMutexLocker> locker(createLocker());
if (mMessageAvailable) {
@@ -399,7 +399,7 @@ bool JsonBuffer::messageAvailable()
/*!
\internal
*/
-QJsonObject JsonBuffer::readMessage()
+QJsonObject QJsonBuffer::readMessage()
{
QJsonObject obj;
if (messageAvailable()) {
@@ -482,18 +482,18 @@ QJsonObject JsonBuffer::readMessage()
Return the current encoding format used by the receive buffer
*/
-EncodingFormat JsonBuffer::format() const
+EncodingFormat QJsonBuffer::format() const
{
return mFormat;
}
-QMutexLocker *JsonBuffer::createLocker()
+QMutexLocker *QJsonBuffer::createLocker()
{
return mThreadProtection ? new QMutexLocker(&mMutex) : 0;
}
/*!
- \fn void JsonBuffer::readyReadMessage()
+ \fn void QJsonBuffer::readyReadMessage()
This signal is emitted once every time new data is appended to the buffer
and a message is ready. \b readMessage() should be used to retrieve a message
@@ -519,6 +519,6 @@ QMutexLocker *JsonBuffer::createLocker()
be reemitted.
*/
-#include "moc_jsonbuffer_p.cpp"
+#include "moc_qjsonbuffer_p.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonbuffer_p.h b/src/jsonstream/qjsonbuffer_p.h
index cb292a4..b324fce 100644
--- a/src/jsonbuffer_p.h
+++ b/src/jsonstream/qjsonbuffer_p.h
@@ -47,17 +47,17 @@
#include <QJsonObject>
#include <QMutex>
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
class QMutexLocker;
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT JsonBuffer : public QObject
+class Q_ADDON_JSONSTREAM_EXPORT QJsonBuffer : public QObject
{
Q_OBJECT
public:
- JsonBuffer(QObject *parent=0);
+ QJsonBuffer(QObject *parent=0);
void append(const QByteArray& data);
void append(const char* data, int len);
int copyFromFd(int fd);
@@ -104,7 +104,7 @@ private:
QMutex mMutex;
};
-inline QByteArray JsonBuffer::rawData(int _start, int _len) const
+inline QByteArray QJsonBuffer::rawData(int _start, int _len) const
{
return QByteArray::fromRawData(mBuffer.constData() + _start, _len);
}
diff --git a/src/jsonclient.cpp b/src/jsonstream/qjsonclient.cpp
index 40f8d0a..3ed44ce 100644
--- a/src/jsonclient.cpp
+++ b/src/jsonstream/qjsonclient.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "jsonclient.h"
-#include "jsonstream.h"
+#include "qjsonclient.h"
+#include "qjsonstream.h"
#include <QLocalSocket>
#include <QTcpSocket>
@@ -52,67 +52,67 @@ QT_BEGIN_NAMESPACE_JSONSTREAM
/****************************************************************************/
-class JsonClientPrivate
+class QJsonClientPrivate
{
public:
- JsonClientPrivate()
+ QJsonClientPrivate()
: mStream(0) {}
- JsonClientPrivate(const QJsonObject& message)
+ QJsonClientPrivate(const QJsonObject& message)
: mRegistrationMessage(message)
, mStream(0) {}
QJsonObject mRegistrationMessage;
- JsonStream mStream;
+ QJsonStream mStream;
};
/****************************************************************************/
/*!
- \class JsonClient
- \brief The JsonClient class is used to send jsons to the JsonServer.
+ \class QJsonClient
+ \brief The QJsonClient class is used to send jsons to the QJsonServer.
- Note: The JsonClient is not thread safe.
+ Note: The QJsonClient is not thread safe.
*/
/*!
- Construct a new JsonClient instance with \a registration token and optional \a parent.
+ Construct a new QJsonClient instance with \a registration token and optional \a parent.
The token will be passed in \c{{"token": registration}}. This constructor
- is designed to work with JsonTokenAuthority.
+ is designed to work with QJsonTokenAuthority.
*/
-JsonClient::JsonClient(const QString& registration, QObject* parent)
+QJsonClient::QJsonClient(const QString& registration, QObject* parent)
: QObject(parent),
- d_ptr(new JsonClientPrivate())
+ d_ptr(new QJsonClientPrivate())
{
- Q_D(JsonClient);
+ Q_D(QJsonClient);
d->mRegistrationMessage.insert(QStringLiteral("token"), registration);
}
/*!
- Construct a new JsonClient instance with registration \a message and optional \a parent.
+ Construct a new QJsonClient instance with registration \a message and optional \a parent.
*/
-JsonClient::JsonClient(const QJsonObject& message, QObject *parent)
+QJsonClient::QJsonClient(const QJsonObject& message, QObject *parent)
: QObject(parent),
- d_ptr(new JsonClientPrivate(message))
+ d_ptr(new QJsonClientPrivate(message))
{
}
/*!
- Construct a new JsonClient instance with an optional \a parent.
+ Construct a new QJsonClient instance with an optional \a parent.
*/
-JsonClient::JsonClient(QObject *parent)
+QJsonClient::QJsonClient(QObject *parent)
: QObject(parent),
- d_ptr(new JsonClientPrivate())
+ d_ptr(new QJsonClientPrivate())
{
}
/*!
- Destroy the JsonClient and shut down any active stream.
+ Destroy the QJsonClient and shut down any active stream.
*/
-JsonClient::~JsonClient()
+QJsonClient::~QJsonClient()
{
// Variant streams don't own the socket
- Q_D(JsonClient);
+ Q_D(QJsonClient);
QIODevice *device = d->mStream.device();
d->mStream.setDevice(0);
if (device)
@@ -120,18 +120,18 @@ JsonClient::~JsonClient()
}
/*!
- Connect to the JsonServer over a TCP socket at \a hostname and \a port. Send the initial registration message.
+ Connect to the QJsonServer over a TCP socket at \a hostname and \a port. Send the initial registration message.
Return true if the connection is successful.
*/
-bool JsonClient::connectTCP(const QString& hostname, int port)
+bool QJsonClient::connectTCP(const QString& hostname, int port)
{
QTcpSocket *socket = new QTcpSocket(this);
socket->connectToHost(hostname, port);
if (socket->waitForConnected()) {
connect(socket, SIGNAL(disconnected()), SLOT(handleSocketDisconnected()));
- Q_D(JsonClient);
+ Q_D(QJsonClient);
d->mStream.setDevice(socket);
connect(&d->mStream, SIGNAL(readyReadMessage()), this, SLOT(processMessages()));
@@ -142,10 +142,10 @@ bool JsonClient::connectTCP(const QString& hostname, int port)
}
/*!
- Connect to the JsonServer over a Unix local socket to \a socketname and send the initial registration message.
+ Connect to the QJsonServer over a Unix local socket to \a socketname and send the initial registration message.
Return true if the connection is successful.
*/
-bool JsonClient::connectLocal(const QString& socketname)
+bool QJsonClient::connectLocal(const QString& socketname)
{
if (!QFile::exists(socketname)) {
qWarning() << Q_FUNC_INFO << "socket does not exist";
@@ -158,7 +158,7 @@ bool JsonClient::connectLocal(const QString& socketname)
if (socket->waitForConnected()) {
connect(socket, SIGNAL(disconnected()), SLOT(handleSocketDisconnected()));
- Q_D(JsonClient);
+ Q_D(QJsonClient);
d->mStream.setDevice(socket);
connect(&d->mStream, SIGNAL(readyReadMessage()), this, SLOT(processMessages()));
// qDebug() << "Sending local socket registration message" << mRegistrationMessage;
@@ -173,10 +173,10 @@ bool JsonClient::connectLocal(const QString& socketname)
Returns true if the entire message was send/buffered or false otherwise.
*/
-bool JsonClient::send(const QJsonObject &message)
+bool QJsonClient::send(const QJsonObject &message)
{
bool ret = false;
- Q_D(JsonClient);
+ Q_D(QJsonClient);
if (d->mStream.isOpen()) {
ret = d->mStream.send(message);
} else {
@@ -190,18 +190,18 @@ bool JsonClient::send(const QJsonObject &message)
This controls how messages will be sent
*/
-void JsonClient::setFormat( EncodingFormat format )
+void QJsonClient::setFormat( EncodingFormat format )
{
- Q_D(JsonClient);
+ Q_D(QJsonClient);
d->mStream.setFormat(format);
}
/*!
\internal
*/
-void JsonClient::handleSocketDisconnected()
+void QJsonClient::handleSocketDisconnected()
{
- Q_D(JsonClient);
+ Q_D(QJsonClient);
QIODevice *device = d->mStream.device();
if (!device)
return;
@@ -215,9 +215,9 @@ void JsonClient::handleSocketDisconnected()
/*!
\internal
*/
-void JsonClient::processMessages()
+void QJsonClient::processMessages()
{
- Q_D(JsonClient);
+ Q_D(QJsonClient);
while (d->mStream.messageAvailable()) {
QJsonObject obj = d->mStream.readMessage();
if (!obj.isEmpty())
@@ -226,15 +226,15 @@ void JsonClient::processMessages()
}
/*!
- \fn void JsonClient::messageReceived(const QJsonObject &message)
+ \fn void QJsonClient::messageReceived(const QJsonObject &message)
This signal is emitted when a \a message is received from the server.
*/
/*!
- \fn void JsonClient::disconnected()
+ \fn void QJsonClient::disconnected()
This signal is emitted when the client socket is disconnected.
*/
-#include "moc_jsonclient.cpp"
+#include "moc_qjsonclient.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonclient.h b/src/jsonstream/qjsonclient.h
index 2fe683e..8e6e2b3 100644
--- a/src/jsonclient.h
+++ b/src/jsonstream/qjsonclient.h
@@ -46,19 +46,19 @@
#include <QVariant>
#include <QJsonObject>
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonClientPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonClient : public QObject
+class QJsonClientPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonClient : public QObject
{
Q_OBJECT
public:
- JsonClient(const QString& registration, QObject *parent = 0);
- JsonClient(const QJsonObject& message, QObject *parent = 0);
- JsonClient(QObject *parent = 0);
- ~JsonClient();
+ QJsonClient(const QString& registration, QObject *parent = 0);
+ QJsonClient(const QJsonObject& message, QObject *parent = 0);
+ QJsonClient(QObject *parent = 0);
+ ~QJsonClient();
bool connectTCP(const QString& hostname, int port);
bool connectLocal(const QString& socketname);
@@ -78,8 +78,8 @@ private slots:
void processMessages();
private:
- Q_DECLARE_PRIVATE(JsonClient)
- QScopedPointer<JsonClientPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonClient)
+ QScopedPointer<QJsonClientPrivate> d_ptr;
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonconnection.cpp b/src/jsonstream/qjsonconnection.cpp
index d822c36..cc48d58 100644
--- a/src/jsonconnection.cpp
+++ b/src/jsonstream/qjsonconnection.cpp
@@ -39,20 +39,20 @@
**
****************************************************************************/
-#include "jsonconnection.h"
-#include "jsonconnectionprocessor_p.h"
-#include "jsonendpoint.h"
-#include "jsonendpointmanager_p.h"
+#include "qjsonconnection.h"
+#include "qjsonconnectionprocessor_p.h"
+#include "qjsonendpoint.h"
+#include "qjsonendpointmanager_p.h"
#include <QThread>
#include <QTimer>
#include <QDebug>
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonConnectionPrivate
+class QJsonConnectionPrivate
{
public:
- JsonConnectionPrivate()
+ QJsonConnectionPrivate()
: mTcpHostPort(0)
, mAutoReconnectEnabled(false)
, mUseSeparateThread(false)
@@ -61,7 +61,7 @@ public:
, mManager(0)
, mConnected(0)
, mProcessorThread(0)
- , mError(JsonConnection::NoError)
+ , mError(QJsonConnection::NoError)
, mSubError(0) {}
QString mLocalSocketName;
@@ -71,12 +71,12 @@ public:
bool mUseSeparateThread;
qint64 mReadBufferSize;
qint64 mWriteBufferSize;
- JsonEndpointManager *mManager;
- JsonConnectionProcessor *mProcessor;
+ QJsonEndpointManager *mManager;
+ QJsonConnectionProcessor *mProcessor;
bool mConnected;
QThread *mProcessorThread;
- JsonConnection::Error mError;
+ QJsonConnection::Error mError;
int mSubError;
QString mErrorStr;
@@ -100,13 +100,13 @@ public:
/****************************************************************************/
/*!
- \class JsonConnection
- \brief The JsonConnection class ...
+ \class QJsonConnection
+ \brief The QJsonConnection class ...
*/
/*!
- \enum JsonConnection::State
+ \enum QJsonConnection::State
This enum describes the different states in which a connection can be.
@@ -115,35 +115,35 @@ public:
\value Authenticating Started authentication process.
\value Connected A connection is established.
- \sa JsonConnection::state()
+ \sa QJsonConnection::state()
*/
/*!
- Constructs a \c JsonConnection object.
+ Constructs a \c QJsonConnection object.
*/
-JsonConnection::JsonConnection(QObject *parent)
+QJsonConnection::QJsonConnection(QObject *parent)
: QObject(parent)
- , d_ptr(new JsonConnectionPrivate())
+ , d_ptr(new QJsonConnectionPrivate())
{
- Q_D(JsonConnection);
- d->mManager = new JsonEndpointManager(this);
- d->mProcessor = new JsonConnectionProcessor();
+ Q_D(QJsonConnection);
+ d->mManager = new QJsonEndpointManager(this);
+ d->mProcessor = new QJsonConnectionProcessor();
d->mProcessor->setEndpointManager(d->mManager);
connect(d->mProcessor, SIGNAL(disconnected()), SIGNAL(disconnected()));
- qRegisterMetaType<JsonConnection::State>("JsonConnection::State");
- connect(d->mProcessor, SIGNAL(stateChanged(JsonConnection::State)), SIGNAL(stateChanged(JsonConnection::State)));
- qRegisterMetaType<JsonConnection::State>("JsonConnection::Error");
- connect(d->mProcessor, SIGNAL(error(JsonConnection::Error,int,QString)), SLOT(handleError(JsonConnection::Error,int,QString)));
+ qRegisterMetaType<QJsonConnection::State>("QJsonConnection::State");
+ connect(d->mProcessor, SIGNAL(stateChanged(QJsonConnection::State)), SIGNAL(stateChanged(QJsonConnection::State)));
+ qRegisterMetaType<QJsonConnection::State>("QJsonConnection::Error");
+ connect(d->mProcessor, SIGNAL(error(QJsonConnection::Error,int,QString)), SLOT(handleError(QJsonConnection::Error,int,QString)));
}
/*!
- Deletes the \c JsonConnection object.
+ Deletes the \c QJsonConnection object.
*/
-JsonConnection::~JsonConnection()
+QJsonConnection::~QJsonConnection()
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mProcessor->setEndpointManager(0);
if (d->mProcessorThread)
d->mProcessorThread->quit();
@@ -154,9 +154,9 @@ JsonConnection::~JsonConnection()
/*!
Returns the state of the connection.
*/
-JsonConnection::State JsonConnection::state() const
+QJsonConnection::State QJsonConnection::state() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mProcessor->state();
}
@@ -166,9 +166,9 @@ JsonConnection::State JsonConnection::state() const
\sa state(), errorString(), subError()
*/
-JsonConnection::Error JsonConnection::error() const
+QJsonConnection::Error QJsonConnection::error() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mError;
}
@@ -180,9 +180,9 @@ JsonConnection::Error JsonConnection::error() const
\sa error()
*/
-int JsonConnection::subError() const
+int QJsonConnection::subError() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mSubError;
}
@@ -192,63 +192,63 @@ int JsonConnection::subError() const
\sa error()
*/
-QString JsonConnection::errorString() const
+QString QJsonConnection::errorString() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mErrorStr;
}
/*!
Returns a socket name to be used for Unix local socket connection.
*/
-QString JsonConnection::localSocketName() const
+QString QJsonConnection::localSocketName() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mLocalSocketName;
}
/*!
Sets a socket name to be used for Unix local socket connection.
*/
-void JsonConnection::setLocalSocketName(const QString &name)
+void QJsonConnection::setLocalSocketName(const QString &name)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mLocalSocketName = name;
}
/*!
Returns a host name to be used for TCP socket connection.
*/
-QString JsonConnection::tcpHostName() const
+QString QJsonConnection::tcpHostName() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mTcpHostName;
}
/*!
Sets a host name to be used for TCP socket connection.
*/
-void JsonConnection::setTcpHostName(const QString &name)
+void QJsonConnection::setTcpHostName(const QString &name)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mTcpHostName = name;
}
/*!
Returns a port number to be used for TCP socket connection.
*/
-int JsonConnection::tcpHostPort() const
+int QJsonConnection::tcpHostPort() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mTcpHostPort;
}
/*!
Sets a port number to be used for TCP socket connection.
*/
-void JsonConnection::setTcpHostPort(int port)
+void QJsonConnection::setTcpHostPort(int port)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
if (port >= 0)
d->mTcpHostPort = port;
}
@@ -256,18 +256,18 @@ void JsonConnection::setTcpHostPort(int port)
/*!
Specifies whether to reconnect when server connection is lost.
*/
-bool JsonConnection::autoReconnectEnabled() const
+bool QJsonConnection::autoReconnectEnabled() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mAutoReconnectEnabled;
}
/*!
Sets whether to reconnect when server connection is lost.
*/
-void JsonConnection::setAutoReconnectEnabled(bool enabled)
+void QJsonConnection::setAutoReconnectEnabled(bool enabled)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mAutoReconnectEnabled = enabled;
d->mProcessor->setAutoReconnectEnabled(enabled);
}
@@ -275,18 +275,18 @@ void JsonConnection::setAutoReconnectEnabled(bool enabled)
/*!
Returns a property which value in message object will be used as an endpoint name.
*/
-QString JsonConnection::endpointPropertyName() const
+QString QJsonConnection::endpointPropertyName() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mManager->endpointPropertyName();
}
/*!
Sets a property which value in message object will be used as an endpoint name.
*/
-void JsonConnection::setEndpointPropertyName(const QString &property)
+void QJsonConnection::setEndpointPropertyName(const QString &property)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
if (d->mManager) {
d->mManager->setEndpointPropertyName(property);
}
@@ -295,9 +295,9 @@ void JsonConnection::setEndpointPropertyName(const QString &property)
/*!
Returns a maximum size of the inbound message buffer.
*/
-qint64 JsonConnection::readBufferSize() const
+qint64 QJsonConnection::readBufferSize() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mReadBufferSize;
}
@@ -305,10 +305,10 @@ qint64 JsonConnection::readBufferSize() const
Sets a maximum size of the inbound message buffer to \a sz thus capping a size
of an inbound message.
*/
-void JsonConnection::setReadBufferSize(qint64 sz)
+void QJsonConnection::setReadBufferSize(qint64 sz)
{
if (sz >= 0) {
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mReadBufferSize = sz;
if (!d->mUseSeparateThread || !d->mConnected)
@@ -326,9 +326,9 @@ void JsonConnection::setReadBufferSize(qint64 sz)
Returns a maximum size of the outbound message buffer. A value of 0
means the buffer size is unlimited.
*/
-qint64 JsonConnection::writeBufferSize() const
+qint64 QJsonConnection::writeBufferSize() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mWriteBufferSize;
}
@@ -336,10 +336,10 @@ qint64 JsonConnection::writeBufferSize() const
Sets a maximum size of the outbound message buffer to \a sz thus capping a size
of an outbound message. A value of 0 means the buffer size is unlimited.
*/
-void JsonConnection::setWriteBufferSize(qint64 sz)
+void QJsonConnection::setWriteBufferSize(qint64 sz)
{
if (sz >= 0) {
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mWriteBufferSize = sz;
if (!d->mUseSeparateThread || !d->mConnected)
@@ -356,9 +356,9 @@ void JsonConnection::setWriteBufferSize(qint64 sz)
/*!
Adds endpoint to a connection.
*/
-void JsonConnection::addEndpoint(JsonEndpoint *endpoint)
+void QJsonConnection::addEndpoint(QJsonEndpoint *endpoint)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mManager->addEndpoint(endpoint);
if (endpoint->connection() != this)
endpoint->setConnection(this);
@@ -367,18 +367,18 @@ void JsonConnection::addEndpoint(JsonEndpoint *endpoint)
/*!
Removes endpoint from a connection.
*/
-void JsonConnection::removeEndpoint(JsonEndpoint *endpoint)
+void QJsonConnection::removeEndpoint(QJsonEndpoint *endpoint)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mManager->removeEndpoint(endpoint);
}
/*!
Sets whether to create a separate worker thread for a connection
*/
-void JsonConnection::setUseSeparateThreadForProcessing(bool use)
+void QJsonConnection::setUseSeparateThreadForProcessing(bool use)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
Q_ASSERT(!d->mConnected);
if (!d->mConnected)
@@ -389,9 +389,9 @@ void JsonConnection::setUseSeparateThreadForProcessing(bool use)
Returns whether a separate worker thread for a connection required
*/
-bool JsonConnection::useSeparateThreadForProcessing() const
+bool QJsonConnection::useSeparateThreadForProcessing() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mUseSeparateThread;
}
@@ -399,21 +399,21 @@ bool JsonConnection::useSeparateThreadForProcessing() const
Returns a default endpoint without name.
*/
-JsonEndpoint * JsonConnection::defaultEndpoint()
+QJsonEndpoint * QJsonConnection::defaultEndpoint()
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
return d->mManager->defaultEndpoint();
}
/*!
- Connect to the JsonServer over a TCP socket at \a hostname and \a port.
+ Connect to the QJsonServer over a TCP socket at \a hostname and \a port.
Return true if the connection is successful.
*/
-bool JsonConnection::connectTCP(const QString& hostname, int port)
+bool QJsonConnection::connectTCP(const QString& hostname, int port)
{
bool bRet = false;
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
if (!d->mConnected) {
d->mConnected = true;
@@ -442,13 +442,13 @@ bool JsonConnection::connectTCP(const QString& hostname, int port)
}
/*!
- Connect to the JsonServer over a Unix local socket to \a socketname.
+ Connect to the QJsonServer over a Unix local socket to \a socketname.
Return true if the connection is successful.
*/
-bool JsonConnection::connectLocal(const QString& socketname)
+bool QJsonConnection::connectLocal(const QString& socketname)
{
bool bRet = false;
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
if (!d->mConnected) {
d->mConnected = true;
@@ -478,9 +478,9 @@ bool JsonConnection::connectLocal(const QString& socketname)
This controls how messages will be sent
*/
-void JsonConnection::setFormat( EncodingFormat format )
+void QJsonConnection::setFormat( EncodingFormat format )
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
if (!d->mUseSeparateThread || !d->mConnected)
d->mProcessor->setFormat(format);
else
@@ -494,32 +494,32 @@ void JsonConnection::setFormat( EncodingFormat format )
/*!
\internal
*/
-JsonConnectionProcessor *JsonConnection::processor() const
+QJsonConnectionProcessor *QJsonConnection::processor() const
{
- Q_D(const JsonConnection);
+ Q_D(const QJsonConnection);
return d->mProcessor;
}
/*!
\internal
*/
-void JsonConnection::handleError(JsonConnection::Error err, int suberr, QString str)
+void QJsonConnection::handleError(QJsonConnection::Error err, int suberr, QString str)
{
- Q_D(JsonConnection);
+ Q_D(QJsonConnection);
d->mError = err;
d->mSubError = suberr;
d->mErrorStr = str;
emit error(d->mError, d->mSubError);
}
-/*! \fn JsonConnection::bytesWritten(qint64 bytes)
+/*! \fn QJsonConnection::bytesWritten(qint64 bytes)
This signal is emitted every time a payload of data has been
written to the device. The \a bytes argument is set to the number
of bytes that were written in this payload.
*/
-/*! \fn JsonConnection::readBufferOverflow(qint64 bytes)
+/*! \fn QJsonConnection::readBufferOverflow(qint64 bytes)
This signal is emitted when the read buffer is full of data that has been read
from the \l{device()}, \a bytes additional bytes are available on the device,
@@ -530,16 +530,16 @@ void JsonConnection::handleError(JsonConnection::Error err, int suberr, QString
*/
/*!
- \fn void JsonConnection::stateChanged(JsonConnection::State state)
+ \fn void QJsonConnection::stateChanged(QJsonConnection::State state)
- This signal is emitted whenever JsonConnection's state changes.
+ This signal is emitted whenever QJsonConnection's state changes.
The \a state parameter is the new state.
\sa state()
*/
/*!
- \fn void JsonConnection::error(JsonConnection::Error error, int subError)
+ \fn void QJsonConnection::error(QJsonConnection::Error error, int subError)
This signal is emitted after an error occurred. The \a error
parameter describes the type of error that occurred and \a subError
@@ -549,7 +549,7 @@ void JsonConnection::handleError(JsonConnection::Error err, int suberr, QString
*/
/*!
- \fn void JsonConnection::disconnected()
+ \fn void QJsonConnection::disconnected()
This signal is emitted when the connection has been disconnected.
@@ -557,6 +557,6 @@ void JsonConnection::handleError(JsonConnection::Error err, int suberr, QString
to it, use the \l{QObject::deleteLater()}{deleteLater()} function.
*/
-#include "moc_jsonconnection.cpp"
+#include "moc_qjsonconnection.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonconnection.h b/src/jsonstream/qjsonconnection.h
index d6c43b5..844d8b0 100644
--- a/src/jsonconnection.h
+++ b/src/jsonstream/qjsonconnection.h
@@ -42,16 +42,16 @@
#ifndef _JSON_CONNECTION_H
#define _JSON_CONNECTION_H
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
#include <QObject>
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonEndpoint;
-class JsonConnectionProcessor;
+class QJsonEndpoint;
+class QJsonConnectionProcessor;
-class JsonConnectionPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonConnection : public QObject
+class QJsonConnectionPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonConnection : public QObject
{
Q_OBJECT
Q_PROPERTY(State state READ state)
@@ -63,10 +63,10 @@ class Q_ADDON_JSONSTREAM_EXPORT JsonConnection : public QObject
Q_PROPERTY(bool useSeparateThreadForProcessing READ useSeparateThreadForProcessing WRITE setUseSeparateThreadForProcessing)
Q_PROPERTY(qint64 readBufferSize READ readBufferSize WRITE setReadBufferSize)
Q_PROPERTY(qint64 writeBufferSize READ writeBufferSize WRITE setWriteBufferSize)
- Q_PROPERTY(JsonEndpoint * defaultEndpoint READ defaultEndpoint)
+ Q_PROPERTY(QJsonEndpoint * defaultEndpoint READ defaultEndpoint)
public:
- JsonConnection(QObject *parent = 0);
- ~JsonConnection();
+ QJsonConnection(QObject *parent = 0);
+ ~QJsonConnection();
enum State {
Unconnected = 0,
@@ -117,31 +117,31 @@ public:
Q_INVOKABLE bool connectTCP(const QString& hostname = QString::null, int port = 0);
Q_INVOKABLE bool connectLocal(const QString& socketname = QString::null);
- void addEndpoint(JsonEndpoint *);
- JsonEndpoint * defaultEndpoint();
- void removeEndpoint(JsonEndpoint *);
+ void addEndpoint(QJsonEndpoint *);
+ QJsonEndpoint * defaultEndpoint();
+ void removeEndpoint(QJsonEndpoint *);
void setFormat( EncodingFormat format );
- JsonConnectionProcessor *processor() const;
+ QJsonConnectionProcessor *processor() const;
signals:
void bytesWritten(qint64);
void readBufferOverflow(qint64);
- void stateChanged(JsonConnection::State);
+ void stateChanged(QJsonConnection::State);
void disconnected();
- void error(JsonConnection::Error, int);
+ void error(QJsonConnection::Error, int);
private slots:
- void handleError(JsonConnection::Error, int, QString);
+ void handleError(QJsonConnection::Error, int, QString);
private:
- Q_DECLARE_PRIVATE(JsonConnection)
- QScopedPointer<JsonConnectionPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonConnection)
+ QScopedPointer<QJsonConnectionPrivate> d_ptr;
// forbid copy constructor
- JsonConnection(const JsonConnection &);
- void operator=(const JsonConnection &);
+ QJsonConnection(const QJsonConnection &);
+ void operator=(const QJsonConnection &);
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonconnectionprocessor.cpp b/src/jsonstream/qjsonconnectionprocessor.cpp
index 48dde27..79adf03 100644
--- a/src/jsonconnectionprocessor.cpp
+++ b/src/jsonstream/qjsonconnectionprocessor.cpp
@@ -39,12 +39,12 @@
**
****************************************************************************/
-#include "jsonconnectionprocessor_p.h"
-#include "jsonendpointmanager_p.h"
-#include "jsonclient.h"
-#include "jsonstream.h"
-#include "jsonendpoint.h"
-#include "jsonbuffer_p.h"
+#include "qjsonconnectionprocessor_p.h"
+#include "qjsonendpointmanager_p.h"
+#include "qjsonclient.h"
+#include "qjsonstream.h"
+#include "qjsonendpoint.h"
+#include "qjsonbuffer_p.h"
#include <QMap>
#include <QThread>
@@ -57,11 +57,11 @@ const int knSOCKET_READ_BUFFER_SIZE = 64*1024;
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonConnectionProcessorPrivate
+class QJsonConnectionProcessorPrivate
{
public:
- JsonConnectionProcessorPrivate()
- : mState(JsonConnection::Unconnected)
+ QJsonConnectionProcessorPrivate()
+ : mState(QJsonConnection::Unconnected)
, mManager(0)
, mDestinationEndpoint(0)
, mAutoReconnectEnabled(false)
@@ -69,12 +69,12 @@ public:
, mReconnectionTimer(0)
{}
- JsonConnection::State mState;
- JsonEndpointManager *mManager;
- JsonStream mStream;
+ QJsonConnection::State mState;
+ QJsonEndpointManager *mManager;
+ QJsonStream mStream;
QMutex mutex;
QJsonObject mObject; // buffer for single message
- JsonEndpoint *mDestinationEndpoint;
+ QJsonEndpoint *mDestinationEndpoint;
QString mServerName;
int mPort;
@@ -88,32 +88,32 @@ public:
/****************************************************************************/
/*!
- \class JsonConnectionProcessor
- \brief The JsonConnectionProcessor class ...
+ \class QJsonConnectionProcessor
+ \brief The QJsonConnectionProcessor class ...
*/
/*!
- Constructs a \c JsonConnectionProcessor object.
+ Constructs a \c QJsonConnectionProcessor object.
*/
-JsonConnectionProcessor::JsonConnectionProcessor()
+QJsonConnectionProcessor::QJsonConnectionProcessor()
: QObject(0)
- , d_ptr(new JsonConnectionProcessorPrivate())
+ , d_ptr(new QJsonConnectionProcessorPrivate())
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
d->mStream.setParent(this);
d->mStream.setThreadProtection(true);
}
/*!
- Deletes the \c JsonConnectionProcessor object.
+ Deletes the \c QJsonConnectionProcessor object.
*/
-JsonConnectionProcessor::~JsonConnectionProcessor()
+QJsonConnectionProcessor::~QJsonConnectionProcessor()
{
// Variant streams don't own the socket
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
QIODevice *device = d->mStream.device();
if (device) {
device->disconnect(this);
@@ -125,7 +125,7 @@ JsonConnectionProcessor::~JsonConnectionProcessor()
/*!
Returns the state of the connection.
*/
-JsonConnection::State JsonConnectionProcessor::state() const
+QJsonConnection::State QJsonConnectionProcessor::state() const
{
return d_func()->mState;
}
@@ -133,29 +133,29 @@ JsonConnection::State JsonConnectionProcessor::state() const
/*!
Sets whether to reconnect when server connection is lost.
*/
-void JsonConnectionProcessor::setAutoReconnectEnabled(bool enabled)
+void QJsonConnectionProcessor::setAutoReconnectEnabled(bool enabled)
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
d->mAutoReconnectEnabled = enabled;
}
-void JsonConnectionProcessor::setEndpointManager(JsonEndpointManager *manager)
+void QJsonConnectionProcessor::setEndpointManager(QJsonEndpointManager *manager)
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
QMutexLocker locker(&d->mutex);
d->mManager = manager;
}
/*!
- Connect to the JsonServer over a TCP socket at \a hostname and \a port.
+ Connect to the QJsonServer over a TCP socket at \a hostname and \a port.
Return true if the connection is successful.
*/
-bool JsonConnectionProcessor::connectTCP(const QString& hostname, int port)
+bool QJsonConnectionProcessor::connectTCP(const QString& hostname, int port)
{
- Q_D(JsonConnectionProcessor);
- if (JsonConnection::Connecting != d->mState)
- emit stateChanged(d->mState = JsonConnection::Connecting);
+ Q_D(QJsonConnectionProcessor);
+ if (QJsonConnection::Connecting != d->mState)
+ emit stateChanged(d->mState = QJsonConnection::Connecting);
QTcpSocket *socket = new QTcpSocket(this);
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
@@ -170,22 +170,22 @@ bool JsonConnectionProcessor::connectTCP(const QString& hostname, int port)
connect(&d->mStream, SIGNAL(readBufferOverflow(qint64)), this, SIGNAL(readBufferOverflow(qint64)));
d->mServerName = hostname;
d->mPort = port;
- d->mState = JsonConnection::Connected;
+ d->mState = QJsonConnection::Connected;
emit stateChanged(d->mState);
return true;
}
- d->mState = JsonConnection::Unconnected;
+ d->mState = QJsonConnection::Unconnected;
emit stateChanged(d->mState);
delete socket;
return false;
}
/*!
- Connect to the JsonServer over a Unix local socket to \a socketname.
+ Connect to the QJsonServer over a Unix local socket to \a socketname.
Return true if the connection is successful.
*/
-bool JsonConnectionProcessor::connectLocal(const QString& socketname)
+bool QJsonConnectionProcessor::connectLocal(const QString& socketname)
{
QString socketPath(socketname);
#if defined(Q_OS_UNIX)
@@ -198,9 +198,9 @@ bool JsonConnectionProcessor::connectLocal(const QString& socketname)
return false;
}
- Q_D(JsonConnectionProcessor);
- if (JsonConnection::Connecting != d->mState)
- emit stateChanged(d->mState = JsonConnection::Connecting);
+ Q_D(QJsonConnectionProcessor);
+ if (QJsonConnection::Connecting != d->mState)
+ emit stateChanged(d->mState = QJsonConnection::Connecting);
QLocalSocket *socket = new QLocalSocket(this);
connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
@@ -216,12 +216,12 @@ bool JsonConnectionProcessor::connectLocal(const QString& socketname)
connect(&d->mStream, SIGNAL(readBufferOverflow(qint64)), this, SIGNAL(readBufferOverflow(qint64)));
d->mServerName = socketname;
d->mPort = -1; // local socket
- d->mState = JsonConnection::Connected;
+ d->mState = QJsonConnection::Connected;
emit stateChanged(d->mState);
return true;
}
- d->mState = JsonConnection::Unconnected;
+ d->mState = QJsonConnection::Unconnected;
emit stateChanged(d->mState);
delete socket;
return false;
@@ -230,9 +230,9 @@ bool JsonConnectionProcessor::connectLocal(const QString& socketname)
/*!
\internal
*/
-void JsonConnectionProcessor::handleSocketDisconnected()
+void QJsonConnectionProcessor::handleSocketDisconnected()
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
QIODevice *device = d->mStream.device();
if (!device)
return;
@@ -251,14 +251,14 @@ void JsonConnectionProcessor::handleSocketDisconnected()
d->mReconnectionTimer->setInterval(knAUTO_RECONNECTION_TIMEOUT);
connect(d->mReconnectionTimer, SIGNAL(timeout()), SLOT(handleReconnect()));
}
- d->mState = JsonConnection::Connecting;
+ d->mState = QJsonConnection::Connecting;
emit stateChanged(d->mState);
d->mReconnectionTimer->start();
}
return;
}
- d->mState = JsonConnection::Unconnected;
+ d->mState = QJsonConnection::Unconnected;
emit disconnected();
emit stateChanged(d->mState);
}
@@ -266,32 +266,32 @@ void JsonConnectionProcessor::handleSocketDisconnected()
/*!
\internal
*/
-void JsonConnectionProcessor::handleSocketError(QAbstractSocket::SocketError _error)
+void QJsonConnectionProcessor::handleSocketError(QAbstractSocket::SocketError _error)
{
if (QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(sender())) {
- emit error(JsonConnection::TcpSocketError, _error, socket->errorString());
+ emit error(QJsonConnection::TcpSocketError, _error, socket->errorString());
}
}
/*!
\internal
*/
-void JsonConnectionProcessor::handleSocketError(QLocalSocket::LocalSocketError _error)
+void QJsonConnectionProcessor::handleSocketError(QLocalSocket::LocalSocketError _error)
{
if (QLocalSocket *socket = qobject_cast<QLocalSocket*>(sender())) {
- emit error(JsonConnection::LocalSocketError, _error, socket->errorString());
+ emit error(QJsonConnection::LocalSocketError, _error, socket->errorString());
}
}
/*!
\internal
*/
-void JsonConnectionProcessor::handleReconnect()
+void QJsonConnectionProcessor::handleReconnect()
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
d->mReconnectionTimer->stop();
- if (JsonConnection::Connecting == d->mState) {
+ if (QJsonConnection::Connecting == d->mState) {
if (d->mPort < 0)
connectLocal(d->mServerName);
else
@@ -304,16 +304,16 @@ void JsonConnectionProcessor::handleReconnect()
Handle a received readyReadMessage signal and emit the correct signals
*/
-void JsonConnectionProcessor::processMessage(JsonEndpoint *destination)
+void QJsonConnectionProcessor::processMessage(QJsonEndpoint *destination)
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
if (!destination)
d->mutex.lock();
if (!d->mDestinationEndpoint && d->mManager) { // no message available
if (d->mStream.messageAvailable()) {
QJsonObject obj = d->mStream.readMessage();
if (!obj.isEmpty()) {
- JsonEndpoint *endpoint = d->mManager->endpoint(obj);
+ QJsonEndpoint *endpoint = d->mManager->endpoint(obj);
if (endpoint) {
// find a corresponding endpoint and notify it
d->mDestinationEndpoint = endpoint;
@@ -343,11 +343,11 @@ void JsonConnectionProcessor::processMessage(JsonEndpoint *destination)
or \b false otherwise.
*/
-bool JsonConnectionProcessor::messageAvailable(JsonEndpoint *endpoint)
+bool QJsonConnectionProcessor::messageAvailable(QJsonEndpoint *endpoint)
{
bool ret = false;
if (endpoint) {
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
QMutexLocker locker(&d->mutex);
if (!(ret = (d->mDestinationEndpoint == endpoint))) {
if (!d->mDestinationEndpoint) {
@@ -364,11 +364,11 @@ bool JsonConnectionProcessor::messageAvailable(JsonEndpoint *endpoint)
Returns a JSON object that has been received for \a endpoint. If no message is
available, an empty JSON object is returned.
*/
-QJsonObject JsonConnectionProcessor::readMessage(JsonEndpoint *endpoint)
+QJsonObject QJsonConnectionProcessor::readMessage(QJsonEndpoint *endpoint)
{
QJsonObject obj;
if (endpoint) {
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
QMutexLocker locker(&d->mutex);
if (!d->mDestinationEndpoint) {
// check stream for more if no messages available
@@ -388,10 +388,10 @@ QJsonObject JsonConnectionProcessor::readMessage(JsonEndpoint *endpoint)
Sets a maximum size of the inbound message buffer to \a sz thus capping a size
of an inbound message.
*/
-void JsonConnectionProcessor::setReadBufferSize(qint64 sz)
+void QJsonConnectionProcessor::setReadBufferSize(qint64 sz)
{
if (sz >= 0) {
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
d->mStream.setReadBufferSize(sz);
}
}
@@ -400,10 +400,10 @@ void JsonConnectionProcessor::setReadBufferSize(qint64 sz)
Sets a maximum size of the outbound message buffer to \a sz thus capping a size
of an outbound message. A value of 0 means the buffer size is unlimited.
*/
-void JsonConnectionProcessor::setWriteBufferSize(qint64 sz)
+void QJsonConnectionProcessor::setWriteBufferSize(qint64 sz)
{
if (sz >= 0) {
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
d->mStream.setWriteBufferSize(sz);
}
}
@@ -413,9 +413,9 @@ void JsonConnectionProcessor::setWriteBufferSize(qint64 sz)
This controls how messages will be sent
*/
-void JsonConnectionProcessor::setFormat( int format )
+void QJsonConnectionProcessor::setFormat( int format )
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
d->mStream.setFormat((EncodingFormat)format); // EncodingFormat
}
@@ -424,13 +424,13 @@ void JsonConnectionProcessor::setFormat( int format )
Returns true if the entire message was send/buffered or false otherwise.
*/
-bool JsonConnectionProcessor::send(QJsonObject message)
+bool QJsonConnectionProcessor::send(QJsonObject message)
{
- Q_D(JsonConnectionProcessor);
+ Q_D(QJsonConnectionProcessor);
return d->mStream.send(message);
}
-#include "moc_jsonconnectionprocessor_p.cpp"
+#include "moc_qjsonconnectionprocessor_p.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonconnectionprocessor_p.h b/src/jsonstream/qjsonconnectionprocessor_p.h
index 9fdb3ab..17aa772 100644
--- a/src/jsonconnectionprocessor_p.h
+++ b/src/jsonstream/qjsonconnectionprocessor_p.h
@@ -42,8 +42,8 @@
#ifndef _JSON_CONNECTION_PROCESSOR_H
#define _JSON_CONNECTION_PROCESSOR_H
-#include "jsonstream-global.h"
-#include "jsonconnection.h"
+#include "qjsonstream-global.h"
+#include "qjsonconnection.h"
#include <QLocalSocket>
#include <QTcpSocket>
@@ -54,29 +54,29 @@ QT_BEGIN_NAMESPACE_JSONSTREAM
#include <QLocalSocket>
#include <QTcpSocket>
-class JsonEndpoint;
-class JsonEndpointManager;
+class QJsonEndpoint;
+class QJsonEndpointManager;
-class JsonConnectionProcessorPrivate;
-class JsonConnectionProcessor : public QObject
+class QJsonConnectionProcessorPrivate;
+class QJsonConnectionProcessor : public QObject
{
Q_OBJECT
public:
- JsonConnectionProcessor();
- ~JsonConnectionProcessor();
+ QJsonConnectionProcessor();
+ ~QJsonConnectionProcessor();
- void setEndpointManager(JsonEndpointManager *);
+ void setEndpointManager(QJsonEndpointManager *);
void setAutoReconnectEnabled(bool enabled);
- JsonConnection::State state() const;
+ QJsonConnection::State state() const;
signals:
- void stateChanged(JsonConnection::State);
+ void stateChanged(QJsonConnection::State);
void readyReadMessage();
void disconnected();
void bytesWritten(qint64);
void readBufferOverflow(qint64);
- void error(JsonConnection::Error,int,QString);
+ void error(QJsonConnection::Error,int,QString);
public slots:
bool connectTCP(const QString&,int);
@@ -85,11 +85,11 @@ public slots:
void setReadBufferSize(qint64);
void setWriteBufferSize(qint64);
bool send(QJsonObject message);
- bool messageAvailable(JsonEndpoint *);
- QJsonObject readMessage(JsonEndpoint *);
+ bool messageAvailable(QJsonEndpoint *);
+ QJsonObject readMessage(QJsonEndpoint *);
protected slots:
- void processMessage(JsonEndpoint* = 0);
+ void processMessage(QJsonEndpoint* = 0);
void handleSocketDisconnected();
void handleReconnect();
void handleSocketError(QAbstractSocket::SocketError);
@@ -98,12 +98,12 @@ protected slots:
protected:
private:
- Q_DECLARE_PRIVATE(JsonConnectionProcessor)
- QScopedPointer<JsonConnectionProcessorPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonConnectionProcessor)
+ QScopedPointer<QJsonConnectionProcessorPrivate> d_ptr;
// forbid copy constructor
- JsonConnectionProcessor(const JsonConnectionProcessor &);
- void operator=(const JsonConnectionProcessor &);
+ QJsonConnectionProcessor(const QJsonConnectionProcessor &);
+ void operator=(const QJsonConnectionProcessor &);
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonendpoint.cpp b/src/jsonstream/qjsonendpoint.cpp
index 5ef840b..6109959 100644
--- a/src/jsonendpoint.cpp
+++ b/src/jsonstream/qjsonendpoint.cpp
@@ -39,19 +39,19 @@
**
****************************************************************************/
-#include "jsonendpoint.h"
-#include "jsonconnection.h"
-#include "jsonconnectionprocessor_p.h"
+#include "qjsonendpoint.h"
+#include "qjsonconnection.h"
+#include "qjsonconnectionprocessor_p.h"
#include <qjsonobject.h>
#include <QVariant>
#include <QDebug>
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonEndpointPrivate
+class QJsonEndpointPrivate
{
public:
- JsonEndpointPrivate()
+ QJsonEndpointPrivate()
: mConnection(0)
, mEmittedReadyRead(false)
, mMessageReady(false)
@@ -59,7 +59,7 @@ public:
}
QString mName;
- JsonConnection *mConnection;
+ QJsonConnection *mConnection;
bool mEmittedReadyRead;
bool mMessageReady;
};
@@ -67,32 +67,32 @@ public:
/****************************************************************************/
/*!
- \class JsonEndpoint
- \brief The JsonEndpoint class ...
+ \class QJsonEndpoint
+ \brief The QJsonEndpoint class ...
*/
/*!
- Constructs a \c JsonEndpoint object.
+ Constructs a \c QJsonEndpoint object.
*/
-JsonEndpoint::JsonEndpoint(const QString & name, JsonConnection *connection)
+QJsonEndpoint::QJsonEndpoint(const QString & name, QJsonConnection *connection)
: QObject(0)
- , d_ptr(new JsonEndpointPrivate())
+ , d_ptr(new QJsonEndpointPrivate())
{
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
d->mName = name;
setConnection(connection);
}
/*!
- Deletes the \c JsonEndpoint object.
+ Deletes the \c QJsonEndpoint object.
*/
-JsonEndpoint::~JsonEndpoint()
+QJsonEndpoint::~QJsonEndpoint()
{
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
if (d->mConnection)
d->mConnection->removeEndpoint(this);
}
@@ -101,9 +101,9 @@ JsonEndpoint::~JsonEndpoint()
Returns a name used for message multiplexing. A default endpoint should not
have a name
*/
-QString JsonEndpoint::name() const
+QString QJsonEndpoint::name() const
{
- Q_D(const JsonEndpoint);
+ Q_D(const QJsonEndpoint);
return d->mName;
}
@@ -111,9 +111,9 @@ QString JsonEndpoint::name() const
Sets a \a name used for message multiplexing. A default endpoint should not
have a name
*/
-void JsonEndpoint::setName( const QString & name )
+void QJsonEndpoint::setName( const QString & name )
{
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
d->mName = name;
emit nameChanged();
}
@@ -121,18 +121,18 @@ void JsonEndpoint::setName( const QString & name )
/*!
Returns a connection that is used by endpoint
*/
-JsonConnection *JsonEndpoint::connection() const
+QJsonConnection *QJsonEndpoint::connection() const
{
- Q_D(const JsonEndpoint);
+ Q_D(const QJsonEndpoint);
return d->mConnection;
}
/*!
Sets a \a connection to be used by endpoint
*/
-void JsonEndpoint::setConnection(JsonConnection *connection)
+void QJsonEndpoint::setConnection(QJsonConnection *connection)
{
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
d->mConnection = connection;
if (d->mConnection)
d->mConnection->addEndpoint(this);
@@ -144,19 +144,19 @@ void JsonEndpoint::setConnection(JsonConnection *connection)
Send a QVariantMap \a message over the connection.
Returns \b true if the entire message was sent or buffered or \b false otherwise.
*/
-bool JsonEndpoint::send(const QVariantMap& message)
+bool QJsonEndpoint::send(const QVariantMap& message)
{
return send(QJsonObject::fromVariantMap(message));
}
/*!
- Send a JsonObject \a message over the connection.
+ Send a QJsonObject \a message over the connection.
Returns \b true if the entire message was sent or buffered or \b false otherwise.
*/
-bool JsonEndpoint::send(const QJsonObject& message)
+bool QJsonEndpoint::send(const QJsonObject& message)
{
bool ret = false;
- Q_D(const JsonEndpoint);
+ Q_D(const QJsonEndpoint);
if (d->mConnection) {
if (!d->mConnection->useSeparateThreadForProcessing()) {
ret = d->mConnection->processor()->send(message);
@@ -176,9 +176,9 @@ bool JsonEndpoint::send(const QJsonObject& message)
\internal
Handle a notification from connection processor and emit the correct signals
*/
-void JsonEndpoint::slotReadyReadMessage()
+void QJsonEndpoint::slotReadyReadMessage()
{
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
d->mMessageReady = true;
if (!d->mEmittedReadyRead) {
d->mEmittedReadyRead = true;
@@ -192,9 +192,9 @@ void JsonEndpoint::slotReadyReadMessage()
Returns \b true if a message is available to be read via \l{readMessage()}
or \b false otherwise.
*/
-bool JsonEndpoint::messageAvailable()
+bool QJsonEndpoint::messageAvailable()
{
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
bool ret = d->mMessageReady;
if (!d->mMessageReady) {
// check again
@@ -210,7 +210,7 @@ bool JsonEndpoint::messageAvailable()
Returns a JSON object that has been received as a variant map. If no message is
available, an empty JSON object is returned.
*/
-QVariantMap JsonEndpoint::readMessageMap()
+QVariantMap QJsonEndpoint::readMessageMap()
{
return readMessage().toVariantMap();
}
@@ -219,10 +219,10 @@ QVariantMap JsonEndpoint::readMessageMap()
Returns a JSON object that has been received. If no message is
available, an empty JSON object is returned.
*/
-QJsonObject JsonEndpoint::readMessage()
+QJsonObject QJsonEndpoint::readMessage()
{
QJsonObject obj;
- Q_D(JsonEndpoint);
+ Q_D(QJsonEndpoint);
if (d->mConnection) {
obj = d->mConnection->processor()->readMessage(this);
d->mMessageReady = false;
@@ -231,7 +231,7 @@ QJsonObject JsonEndpoint::readMessage()
}
/*!
- \fn void JsonEndpoint::readyReadMessage()
+ \fn void QJsonEndpoint::readyReadMessage()
This signal is emitted once every time new data arrives on the device
and a message is ready. \l{readMessage()} should be used to retrieve a message
@@ -259,6 +259,6 @@ QJsonObject JsonEndpoint::readMessage()
\sa readMessage(), messageAvailable()
*/
-#include "moc_jsonendpoint.cpp"
+#include "moc_qjsonendpoint.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonendpoint.h b/src/jsonstream/qjsonendpoint.h
index 00880cf..d99b9fb 100644
--- a/src/jsonendpoint.h
+++ b/src/jsonstream/qjsonendpoint.h
@@ -44,27 +44,27 @@
#include <QObject>
#include <QJsonObject>
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonConnection;
+class QJsonConnection;
-class JsonEndpointPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonEndpoint : public QObject
+class QJsonEndpointPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonEndpoint : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(JsonConnection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
+ Q_PROPERTY(QJsonConnection* connection READ connection WRITE setConnection NOTIFY connectionChanged)
public:
- JsonEndpoint(const QString & = QString::null, JsonConnection * = 0);
- virtual ~JsonEndpoint();
+ QJsonEndpoint(const QString & = QString::null, QJsonConnection * = 0);
+ virtual ~QJsonEndpoint();
QString name() const;
void setName( const QString & name );
- JsonConnection *connection() const;
- void setConnection(JsonConnection *);
+ QJsonConnection *connection() const;
+ void setConnection(QJsonConnection *);
Q_INVOKABLE bool send(const QVariantMap& message);
Q_INVOKABLE bool send(const QJsonObject& message);
@@ -84,12 +84,12 @@ protected slots:
void slotReadyReadMessage();
private:
- Q_DECLARE_PRIVATE(JsonEndpoint)
- QScopedPointer<JsonEndpointPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonEndpoint)
+ QScopedPointer<QJsonEndpointPrivate> d_ptr;
// forbid copy constructor
- JsonEndpoint(const JsonEndpoint &);
- void operator=(const JsonEndpoint &);
+ QJsonEndpoint(const QJsonEndpoint &);
+ void operator=(const QJsonEndpoint &);
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonendpointmanager.cpp b/src/jsonstream/qjsonendpointmanager.cpp
index 5d266c2..8cb7730 100644
--- a/src/jsonendpointmanager.cpp
+++ b/src/jsonstream/qjsonendpointmanager.cpp
@@ -39,9 +39,9 @@
**
****************************************************************************/
-#include "jsonendpointmanager_p.h"
-#include "jsonendpoint.h"
-#include "jsonconnection.h"
+#include "qjsonendpointmanager_p.h"
+#include "qjsonendpoint.h"
+#include "qjsonconnection.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
@@ -50,39 +50,39 @@ static const QLatin1String kstrEndpointKey("endpoint");
/****************************************************************************/
/*!
- \class JsonEndpointManager
- \brief The JsonEndpointManager class ...
+ \class QJsonEndpointManager
+ \brief The QJsonEndpointManager class ...
*/
/*!
- Constructs a \c JsonEndpointManager object.
+ Constructs a \c QJsonEndpointManager object.
*/
-JsonEndpointManager::JsonEndpointManager(JsonConnection *parent)
+QJsonEndpointManager::QJsonEndpointManager(QJsonConnection *parent)
: QObject(parent), mInit(false), mEndpointPropertyName(kstrEndpointKey), mDefaultEndpoint(0)
{
}
/*!
- Deletes the \c JsonEndpointManager object.
+ Deletes the \c QJsonEndpointManager object.
*/
-JsonEndpointManager::~JsonEndpointManager()
+QJsonEndpointManager::~QJsonEndpointManager()
{
clear();
}
-JsonEndpoint *JsonEndpointManager::defaultEndpoint()
+QJsonEndpoint *QJsonEndpointManager::defaultEndpoint()
{
- JsonEndpoint *endpoint;
+ QJsonEndpoint *endpoint;
endpoints();
if (mDefaultEndpoint) {
endpoint = mDefaultEndpoint;
}
else {
- endpoint = new JsonEndpoint();
- JsonConnection *connection = qobject_cast<JsonConnection *>(parent());
+ endpoint = new QJsonEndpoint();
+ QJsonConnection *connection = qobject_cast<QJsonConnection *>(parent());
if (connection) {
connection->addEndpoint(endpoint);
// XXX hack - i don't want the default endpoint in the endpoints list
@@ -93,7 +93,7 @@ JsonEndpoint *JsonEndpointManager::defaultEndpoint()
return endpoint;
}
-void JsonEndpointManager::addEndpoint(JsonEndpoint *endpoint)
+void QJsonEndpointManager::addEndpoint(QJsonEndpoint *endpoint)
{
if (mEndpoints.key(endpoint).isEmpty()) {
mInit = false; // rehashing required
@@ -102,19 +102,19 @@ void JsonEndpointManager::addEndpoint(JsonEndpoint *endpoint)
}
}
-void JsonEndpointManager::removeEndpoint(JsonEndpoint *endpoint)
+void QJsonEndpointManager::removeEndpoint(QJsonEndpoint *endpoint)
{
mEndpoints.remove(endpoint->name());
endpoint->setConnection(0);
}
-QHash<QString, JsonEndpoint*> & JsonEndpointManager::endpoints()
+QHash<QString, QJsonEndpoint*> & QJsonEndpointManager::endpoints()
{
if (!mInit) {
// rehash with real names
- QList<JsonEndpoint *> lst = mEndpoints.values();
+ QList<QJsonEndpoint *> lst = mEndpoints.values();
mEndpoints.clear();
- foreach (JsonEndpoint *e, lst) {
+ foreach (QJsonEndpoint *e, lst) {
mEndpoints.insert(e->name(), e);
}
mInit = true;
@@ -122,26 +122,26 @@ QHash<QString, JsonEndpoint*> & JsonEndpointManager::endpoints()
return mEndpoints;
}
-JsonEndpoint *JsonEndpointManager::endpoint(const QJsonObject &message)
+QJsonEndpoint *QJsonEndpointManager::endpoint(const QJsonObject &message)
{
return endpoints().value(message.value(mEndpointPropertyName).toString(), defaultEndpoint());
}
-void JsonEndpointManager::clear()
+void QJsonEndpointManager::clear()
{
- QList<JsonEndpoint *> lst = mEndpoints.values();
- foreach (JsonEndpoint *endpoint, lst) {
+ QList<QJsonEndpoint *> lst = mEndpoints.values();
+ foreach (QJsonEndpoint *endpoint, lst) {
endpoint->setConnection(0);
}
mEndpoints.clear();
}
-void JsonEndpointManager::handleNameChange()
+void QJsonEndpointManager::handleNameChange()
{
mInit = false; // next call to endpoints() will rehash everything
}
-#include "moc_jsonendpointmanager_p.cpp"
+#include "moc_qjsonendpointmanager_p.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonendpointmanager_p.h b/src/jsonstream/qjsonendpointmanager_p.h
index 7ad3ac8..404a438 100644
--- a/src/jsonendpointmanager_p.h
+++ b/src/jsonstream/qjsonendpointmanager_p.h
@@ -44,36 +44,36 @@
#include <QObject>
#include <QHash>
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
class QJsonObject;
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonEndpoint;
-class JsonConnection;
+class QJsonEndpoint;
+class QJsonConnection;
-class JsonEndpointManagerPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonEndpointManager : public QObject
+class QJsonEndpointManagerPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonEndpointManager : public QObject
{
Q_OBJECT
Q_PROPERTY(QString endpointPropertyName READ endpointPropertyName WRITE setEndpointPropertyName)
public:
- JsonEndpointManager(JsonConnection *parent);
- ~JsonEndpointManager();
+ QJsonEndpointManager(QJsonConnection *parent);
+ ~QJsonEndpointManager();
- JsonEndpoint *defaultEndpoint();
+ QJsonEndpoint *defaultEndpoint();
QString endpointPropertyName() const { return mEndpointPropertyName; }
void setEndpointPropertyName(const QString & name) { mEndpointPropertyName = name; }
- void addEndpoint(JsonEndpoint *);
- void removeEndpoint(JsonEndpoint *);
+ void addEndpoint(QJsonEndpoint *);
+ void removeEndpoint(QJsonEndpoint *);
void clear();
- QHash<QString, JsonEndpoint*> & endpoints();
+ QHash<QString, QJsonEndpoint*> & endpoints();
- virtual JsonEndpoint *endpoint(const QJsonObject &);
+ virtual QJsonEndpoint *endpoint(const QJsonObject &);
protected slots:
void handleNameChange();
@@ -81,8 +81,8 @@ protected slots:
protected:
bool mInit;
QString mEndpointPropertyName;
- QHash<QString, JsonEndpoint*> mEndpoints;
- JsonEndpoint *mDefaultEndpoint;
+ QHash<QString, QJsonEndpoint*> mEndpoints;
+ QJsonEndpoint *mDefaultEndpoint;
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonpidauthority.cpp b/src/jsonstream/qjsonpidauthority.cpp
index 93bd299..5ff277b 100644
--- a/src/jsonpidauthority.cpp
+++ b/src/jsonstream/qjsonpidauthority.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "jsonpidauthority.h"
-#include "jsonstream.h"
+#include "qjsonpidauthority.h"
+#include "qjsonstream.h"
#include <errno.h>
#include <sys/socket.h>
@@ -52,10 +52,10 @@
QT_BEGIN_NAMESPACE_JSONSTREAM
/*!
- \class JsonPIDAuthority
- \brief The JsonPIDAuthority class implements a PID-based authentication scheme for JsonServer.
+ \class QJsonPIDAuthority
+ \brief The QJsonPIDAuthority class implements a PID-based authentication scheme for QJsonServer.
- The JsonPIDAuthority class authorizes Json client connections based on the process ID of the
+ The QJsonPIDAuthority class authorizes QJson client connections based on the process ID of the
client. This process ID is read directly from the connected socket.
This class functions only on Linux machines. The BSD kernel used in Macintosh systems does
@@ -63,11 +63,11 @@ QT_BEGIN_NAMESPACE_JSONSTREAM
*/
/*!
- Construct a JsonPIDAuthority with optional \a parent.
+ Construct a QJsonPIDAuthority with optional \a parent.
*/
-JsonPIDAuthority::JsonPIDAuthority(QObject *parent)
- : JsonAuthority(parent)
+QJsonPIDAuthority::QJsonPIDAuthority(QObject *parent)
+ : QJsonAuthority(parent)
{
}
@@ -79,7 +79,7 @@ JsonPIDAuthority::JsonPIDAuthority(QObject *parent)
Before a process can successfully connect to the server with
its process id must be added with this method if authorization is required.
*/
-bool JsonPIDAuthority::authorize(qint64 pid, const QString &identifier)
+bool QJsonPIDAuthority::authorize(qint64 pid, const QString &identifier)
{
if (pid == 0) {
qWarning() << "PID 0 is invalid";
@@ -96,7 +96,7 @@ bool JsonPIDAuthority::authorize(qint64 pid, const QString &identifier)
Removes a process id \a pid from the list of authorized processes.
Returns true if a process with a matching PID was found.
*/
-bool JsonPIDAuthority::deauthorize(qint64 pid)
+bool QJsonPIDAuthority::deauthorize(qint64 pid)
{
return m_identifierForPid.remove(pid) != 0;
}
@@ -105,7 +105,7 @@ bool JsonPIDAuthority::deauthorize(qint64 pid)
Return true if the \a pid is authorized.
*/
-bool JsonPIDAuthority::isAuthorized(qint64 pid) const
+bool QJsonPIDAuthority::isAuthorized(qint64 pid) const
{
return m_identifierForPid.contains(pid);
}
@@ -115,7 +115,7 @@ bool JsonPIDAuthority::isAuthorized(qint64 pid) const
If no such identifier is authorized, returns an empty string.
*/
-QString JsonPIDAuthority::identifier(qint64 pid) const
+QString QJsonPIDAuthority::identifier(qint64 pid) const
{
return m_identifierForPid.value(pid);
}
@@ -125,10 +125,10 @@ QString JsonPIDAuthority::identifier(qint64 pid) const
Returns an AuthorizationRecord.
*/
-AuthorizationRecord JsonPIDAuthority::clientConnected(JsonStream *stream)
+AuthorizationRecord QJsonPIDAuthority::clientConnected(QJsonStream *stream)
{
AuthorizationRecord authRecord;
- authRecord.state = JsonAuthority::StateNotAuthorized;
+ authRecord.state = QJsonAuthority::StateNotAuthorized;
if (!stream)
return authRecord;
@@ -138,7 +138,7 @@ AuthorizationRecord JsonPIDAuthority::clientConnected(JsonStream *stream)
if (!socket)
return authRecord;
- if (socket->socketDescriptor() == (quintptr)-1) {
+ if (socket->socketDescriptor() == -1) {
qWarning() << Q_FUNC_INFO << "no socket descriptor available for connection" << socket;
return authRecord;
}
@@ -163,16 +163,16 @@ AuthorizationRecord JsonPIDAuthority::clientConnected(JsonStream *stream)
/*!
Ignore any \a message received from \a stream.
*/
-AuthorizationRecord JsonPIDAuthority::messageReceived(JsonStream *stream,
+AuthorizationRecord QJsonPIDAuthority::messageReceived(QJsonStream *stream,
const QJsonObject &message)
{
Q_UNUSED(stream);
Q_UNUSED(message);
AuthorizationRecord authRecord;
- authRecord.state = JsonAuthority::StateNotAuthorized;
+ authRecord.state = QJsonAuthority::StateNotAuthorized;
return authRecord;
}
-#include "moc_jsonpidauthority.cpp"
+#include "moc_qjsonpidauthority.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonpidauthority.h b/src/jsonstream/qjsonpidauthority.h
index 512ad0a..4095ae5 100644
--- a/src/jsonpidauthority.h
+++ b/src/jsonstream/qjsonpidauthority.h
@@ -45,24 +45,24 @@
#include <QHash>
#include <QLocalSocket>
-#include "jsonauthority.h"
-#include "jsonstream-global.h"
+#include "qjsonauthority.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT JsonPIDAuthority : public JsonAuthority
+class Q_ADDON_JSONSTREAM_EXPORT QJsonPIDAuthority : public QJsonAuthority
{
Q_OBJECT
public:
- JsonPIDAuthority(QObject *parent = 0);
+ QJsonPIDAuthority(QObject *parent = 0);
bool authorize(qint64 pid, const QString &applicationIdentifier);
bool deauthorize(qint64 pid);
bool isAuthorized(qint64 pid) const;
QString identifier(qint64 pid) const;
- virtual AuthorizationRecord clientConnected(JsonStream *stream);
- virtual AuthorizationRecord messageReceived(JsonStream *stream, const QJsonObject &message);
+ virtual AuthorizationRecord clientConnected(QJsonStream *stream);
+ virtual AuthorizationRecord messageReceived(QJsonStream *stream, const QJsonObject &message);
private:
QHash<qint64, QString> m_identifierForPid;
@@ -70,6 +70,6 @@ private:
QT_END_NAMESPACE_JSONSTREAM
-QT_JSONSTREAM_DECLARE_METATYPE_PTR(JsonPIDAuthority)
+QT_JSONSTREAM_DECLARE_METATYPE_PTR(QJsonPIDAuthority)
#endif // JSONPIDAUTHORITYPROVIDER_H
diff --git a/src/jsonpipe.cpp b/src/jsonstream/qjsonpipe.cpp
index bd63de3..241f6b1 100644
--- a/src/jsonpipe.cpp
+++ b/src/jsonstream/qjsonpipe.cpp
@@ -52,23 +52,23 @@
#include <errno.h>
#include <unistd.h> // for ::write
-#include "jsonpipe.h"
-#include "jsonbuffer_p.h"
+#include "qjsonpipe.h"
+#include "qjsonbuffer_p.h"
#include "bson/qt-bson_p.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
/****************************************************************************/
-class JsonPipePrivate
+class QJsonPipePrivate
{
public:
- JsonPipePrivate()
+ QJsonPipePrivate()
: mIn(0)
, mOut(0)
, mFormat(FormatUndefined) {}
- JsonBuffer *mInBuffer;
+ QJsonBuffer *mInBuffer;
QByteArray mOutBuffer;
QSocketNotifier *mIn;
QSocketNotifier *mOut;
@@ -78,16 +78,16 @@ public:
/****************************************************************************/
/*!
- \class JsonPipe
- \brief The JsonPipe class serializes JSON data.
+ \class QJsonPipe
+ \brief The QJsonPipe class serializes JSON data.
- The JsonPipe class is a generic interface for serializing and deserializing
+ The QJsonPipe class is a generic interface for serializing and deserializing
JSON data over pipe connections. It is designed to support multiple serialization
and deserialization formats by auto-detecting the format in use.
*/
/*!
- \enum JsonPipe::PipeError
+ \enum QJsonPipe::PipeError
This enum is passed in the \l{error()} signal indicating a problem
with a pipe connection.
@@ -99,23 +99,23 @@ public:
*/
/*!
- Constructs a \c JsonPipe object with an optional \a parent.
+ Constructs a \c QJsonPipe object with an optional \a parent.
*/
-JsonPipe::JsonPipe(QObject *parent)
+QJsonPipe::QJsonPipe(QObject *parent)
: QObject(parent)
- , d_ptr(new JsonPipePrivate())
+ , d_ptr(new QJsonPipePrivate())
{
- Q_D(JsonPipe);
- d->mInBuffer = new JsonBuffer(this);
+ Q_D(QJsonPipe);
+ d->mInBuffer = new QJsonBuffer(this);
connect(d->mInBuffer, SIGNAL(readyReadMessage()), SLOT(processMessages()));
}
/*!
- Delete the \c JsonPipe object
+ Delete the \c QJsonPipe object
*/
-JsonPipe::~JsonPipe()
+QJsonPipe::~QJsonPipe()
{
}
@@ -123,9 +123,9 @@ JsonPipe::~JsonPipe()
Return true if writing should be possible
*/
-bool JsonPipe::writeEnabled() const
+bool QJsonPipe::writeEnabled() const
{
- Q_D(const JsonPipe);
+ Q_D(const QJsonPipe);
return (d->mOut != NULL);
}
@@ -133,9 +133,9 @@ bool JsonPipe::writeEnabled() const
Return true if more data may be read
*/
-bool JsonPipe::readEnabled() const
+bool QJsonPipe::readEnabled() const
{
- Q_D(const JsonPipe);
+ Q_D(const QJsonPipe);
return (d->mIn != NULL);
}
@@ -144,9 +144,9 @@ bool JsonPipe::readEnabled() const
in_fd and the output descriptor is set to \a out_fd.
*/
-void JsonPipe::setFds(int in_fd, int out_fd)
+void QJsonPipe::setFds(int in_fd, int out_fd)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
if (d->mIn)
delete d->mIn;
if (d->mOut)
@@ -164,9 +164,9 @@ void JsonPipe::setFds(int in_fd, int out_fd)
\internal
*/
-void JsonPipe::inReady(int fd)
+void QJsonPipe::inReady(int fd)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
d->mIn->setEnabled(false);
int n = d->mInBuffer->copyFromFd(fd);
if (n <= 0) {
@@ -184,9 +184,9 @@ void JsonPipe::inReady(int fd)
Return number of byte written
*/
-int JsonPipe::writeInternal(int fd)
+int QJsonPipe::writeInternal(int fd)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
if (!d->mOutBuffer.size())
return 0;
@@ -209,9 +209,9 @@ int JsonPipe::writeInternal(int fd)
\internal
*/
-void JsonPipe::outReady(int)
+void QJsonPipe::outReady(int)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
Q_ASSERT(d->mOut);
d->mOut->setEnabled(false);
if (d->mOutBuffer.size()) {
@@ -222,14 +222,14 @@ void JsonPipe::outReady(int)
}
/*!
- Send a JsonObject \a object over the pipe. Return true if
+ Send a QJsonObject \a object over the pipe. Return true if
the object could be added to the output buffer and false if there is
no output buffer.
*/
-bool JsonPipe::send(const QJsonObject& object)
+bool QJsonPipe::send(const QJsonObject& object)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
if (!d->mOut)
return false;
@@ -272,12 +272,12 @@ bool JsonPipe::send(const QJsonObject& object)
/*!
\internal
- Handle a received Qt Binary Json \a object and emit the correct signals
+ Handle a received Qt Binary QJson \a object and emit the correct signals
*/
-void JsonPipe::objectReceived(const QJsonObject& object)
+void QJsonPipe::objectReceived(const QJsonObject& object)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
if (d->mFormat == FormatUndefined)
d->mFormat = d->mInBuffer->format();
emit messageReceived(object);
@@ -286,9 +286,9 @@ void JsonPipe::objectReceived(const QJsonObject& object)
/*!
\internal
*/
-void JsonPipe::processMessages()
+void QJsonPipe::processMessages()
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
d->mInBuffer->setEnabled(false);
while (d->mInBuffer->messageAvailable()) {
QJsonObject obj = d->mInBuffer->readMessage();
@@ -299,12 +299,12 @@ void JsonPipe::processMessages()
}
/*!
- Return the current JsonPipe::EncodingFormat.
+ Return the current QJsonPipe::EncodingFormat.
*/
-EncodingFormat JsonPipe::format() const
+EncodingFormat QJsonPipe::format() const
{
- Q_D(const JsonPipe);
+ Q_D(const QJsonPipe);
return d->mFormat;
}
@@ -312,9 +312,9 @@ EncodingFormat JsonPipe::format() const
Set the EncodingFormat to \a format.
*/
-void JsonPipe::setFormat( EncodingFormat format )
+void QJsonPipe::setFormat( EncodingFormat format )
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
d->mFormat = format;
}
@@ -325,9 +325,9 @@ void JsonPipe::setFormat( EncodingFormat format )
number of milliseconds to block before giving up.
*/
-bool JsonPipe::waitForBytesWritten(int msecs)
+bool QJsonPipe::waitForBytesWritten(int msecs)
{
- Q_D(JsonPipe);
+ Q_D(QJsonPipe);
if (!d->mOut || d->mOutBuffer.isEmpty())
return false;
@@ -363,29 +363,29 @@ bool JsonPipe::waitForBytesWritten(int msecs)
}
/*!
- \relates JsonPipe
+ \relates QJsonPipe
Sends the \a map via the \a pipe.
*/
-JsonPipe& operator<<( JsonPipe& pipe, const QJsonObject& map )
+QJsonPipe& operator<<( QJsonPipe& pipe, const QJsonObject& map )
{
pipe.send(map);
return pipe;
}
/*!
- \fn void JsonPipe::messageReceived(const QJsonObject& message)
+ \fn void QJsonPipe::messageReceived(const QJsonObject& message)
This signal is emitted when a new \a message has been received on the
pipe.
*/
/*!
- \fn void JsonPipe::error(PipeError err)
+ \fn void QJsonPipe::error(PipeError err)
This signal is emitted when there is a read or write pipe error \a
err.
*/
-#include "moc_jsonpipe.cpp"
+#include "moc_qjsonpipe.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonpipe.h b/src/jsonstream/qjsonpipe.h
index eef9d65..6f427f4 100644
--- a/src/jsonpipe.h
+++ b/src/jsonstream/qjsonpipe.h
@@ -44,21 +44,21 @@
#include <QObject>
#include <QJsonObject>
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
class QSocketNotifier;
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonBuffer;
+class QJsonBuffer;
-class JsonPipePrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonPipe : public QObject
+class QJsonPipePrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonPipe : public QObject
{
Q_OBJECT
public:
- JsonPipe(QObject *parent = 0);
- virtual ~JsonPipe();
+ QJsonPipe(QObject *parent = 0);
+ virtual ~QJsonPipe();
bool writeEnabled() const;
bool readEnabled() const;
@@ -89,11 +89,11 @@ private:
int writeInternal(int fd);
private:
- Q_DECLARE_PRIVATE(JsonPipe)
- QScopedPointer<JsonPipePrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonPipe)
+ QScopedPointer<QJsonPipePrivate> d_ptr;
};
-JsonPipe& operator<<( JsonPipe&, const QJsonObject& );
+QJsonPipe& operator<<(QJsonPipe&, const QJsonObject& );
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonserver.cpp b/src/jsonstream/qjsonserver.cpp
index fe4fbfd..78bf820 100644
--- a/src/jsonserver.cpp
+++ b/src/jsonstream/qjsonserver.cpp
@@ -44,12 +44,12 @@
#include <signal.h>
#include <sys/socket.h>
-#include "jsonstream.h"
-#include "jsonserver.h"
-#include "jsonauthority.h"
-#include "jsonserverclient.h"
+#include "qjsonstream.h"
+#include "qjsonserver.h"
+#include "qjsonauthority.h"
+#include "qjsonserverclient.h"
-#include "schemavalidator.h"
+#include "qjsonschemavalidator.h"
#include <QtCore>
#include <QtNetwork>
@@ -60,19 +60,19 @@ QT_BEGIN_NAMESPACE_JSONSTREAM
/*!
\internal
*/
-inline bool canValidate(JsonServer::ValidatorFlags flags, SchemaValidator *validator)
+inline bool canValidate(QJsonServer::ValidatorFlags flags, QJsonSchemaValidator *validator)
{
- return flags != JsonServer::NoValidation && validator && !validator->isEmpty();
+ return flags != QJsonServer::NoValidation && validator && !validator->isEmpty();
}
-class JsonServerPrivate
+class QJsonServerPrivate
{
public:
- JsonServerPrivate()
+ QJsonServerPrivate()
: m_inboundValidator(0)
, m_outboundValidator(0) {}
- ~JsonServerPrivate()
+ ~QJsonServerPrivate()
{
qDeleteAll(m_identifierToClient);
foreach (QLocalServer *server, m_localServers.keys())
@@ -85,28 +85,28 @@ public:
delete m_outboundValidator;
}
- QMap<QLocalServer *, JsonAuthority *> m_localServers;
- QMultiMap<QString, JsonServerClient *> m_identifierToClient;
+ QMap<QLocalServer *, QJsonAuthority *> m_localServers;
+ QMultiMap<QString, QJsonServerClient *> m_identifierToClient;
QMap<QString, QList<QJsonObject> > m_messageQueues;
QSet<QString> m_multipleConnections;
- JsonServer::ValidatorFlags m_validatorFlags;
- SchemaValidator *m_inboundValidator;
- SchemaValidator *m_outboundValidator;
+ QJsonServer::ValidatorFlags m_validatorFlags;
+ QJsonSchemaValidator *m_inboundValidator;
+ QJsonSchemaValidator *m_outboundValidator;
};
/**************************************************************************************************/
/*!
- \class JsonServer
- \brief The JsonServer class is the server endpoint for JSON communications.
+ \class QJsonServer
+ \brief The QJsonServer class is the server endpoint for JSON communications.
JSON communications is a interprocess communication (IPC) method between clients and a server.
It consists of the following components:
\list
- \li JsonClient, a client-side class which sends and receives JSON messages
- \li JsonServer, the server class which sends and receives JSON messages
- \li JsonAuthority, an abstract authorization class which
+ \li QJsonClient, a client-side class which sends and receives JSON messages
+ \li QJsonServer, the server class which sends and receives JSON messages
+ \li QJsonAuthority, an abstract authorization class which
approves connections from clients and assigns client names.
\endlist
@@ -121,11 +121,11 @@ public:
Once a client is authorized, a \l connectionAdded() signal will be
fired. When an authorized client disconnects, the \l
- connectionRemoved() signal fires. No JsonServer signals are sent
+ connectionRemoved() signal fires. No QJsonServer signals are sent
until a client is authorized.
After authorization, each message received will result in a \l messageReceived() signal.
- The JsonServer sends messages to clients with the \l send() slot.
+ The QJsonServer sends messages to clients with the \l send() slot.
In some cases, it is desireable to queue up messages for a client
that has not yet connected. Calling \c enableQueueing(identifier) will
@@ -134,35 +134,35 @@ public:
*/
/*!
- \property JsonServer::validatorFlags
+ \property QJsonServer::validatorFlags
The current ValidatorFlags set on this server
*/
/*!
- Constructs a new JsonServer instance with \a parent.
+ Constructs a new QJsonServer instance with \a parent.
*/
-JsonServer::JsonServer(QObject *parent)
+QJsonServer::QJsonServer(QObject *parent)
: QObject(parent)
- , d_ptr(new JsonServerPrivate())
+ , d_ptr(new QJsonServerPrivate())
{
initSchemaValidation(); // initialize validation if defined by environment
}
/*!
- Destroy this JsonServer. All connections will be immediately dropped, with no more signals.
- We destroy all of the JsonServerClient objects and remove the QLocalServer objects.
- We do not destroy the JsonAuthority objects.
+ Destroy this QJsonServer. All connections will be immediately dropped, with no more signals.
+ We destroy all of the QJsonServerClient objects and remove the QLocalServer objects.
+ We do not destroy the QJsonAuthority objects.
*/
-JsonServer::~JsonServer()
+QJsonServer::~QJsonServer()
{
}
/*!
- Configure the JsonServer to listen on a new TCP socket and \a port using JsonAuthority file \a authority.
+ Configure the QJsonServer to listen on a new TCP socket and \a port using QJsonAuthority file \a authority.
If the \a authority is omitted or NULL, all connections will be automatically authorized and
a unique identifier generated for each new connection. Returns true if the socket could be opened.
*/
-bool JsonServer::listen( int port, JsonAuthority *authority )
+bool QJsonServer::listen( int port, QJsonAuthority *authority )
{
Q_UNUSED(port);
Q_UNUSED(authority);
@@ -170,17 +170,17 @@ bool JsonServer::listen( int port, JsonAuthority *authority )
}
/*!
- Configure the JsonServer to listen on a new Unix local socket \a socketname using JsonAuthority file \a authority.
+ Configure the QJsonServer to listen on a new Unix local socket \a socketname using QJsonAuthority file \a authority.
If the \a authority is omitted or NULL, all connections will be automatically authorized and
a unique identifier generated for each new connection. Returns true if the socket could be opened.
Does \b{not} take ownership of the \a authority object.
*/
-bool JsonServer::listen(const QString &socketname, JsonAuthority *authority)
+bool QJsonServer::listen(const QString &socketname, QJsonAuthority *authority)
{
QLocalServer::removeServer(socketname);
QLocalServer *server = new QLocalServer(this);
- Q_D(JsonServer);
+ Q_D(QJsonServer);
d->m_localServers.insert(server, authority);
QObject::connect(server, SIGNAL(newConnection()), this, SLOT(handleLocalConnection()));
if (!server->listen(socketname)) {
@@ -195,7 +195,7 @@ bool JsonServer::listen(const QString &socketname, JsonAuthority *authority)
\internal
Called with an incoming connection
*/
-void JsonServer::handleLocalConnection()
+void QJsonServer::handleLocalConnection()
{
QLocalServer *server = qobject_cast<QLocalServer *>(sender());
if (!server)
@@ -203,9 +203,9 @@ void JsonServer::handleLocalConnection()
if (QLocalSocket *socket = server->nextPendingConnection()) {
socket->setReadBufferSize(64*1024);
- Q_D(JsonServer);
- JsonAuthority *authority = d->m_localServers.value(server);
- JsonServerClient *client = new JsonServerClient(this);
+ Q_D(QJsonServer);
+ QJsonAuthority *authority = d->m_localServers.value(server);
+ QJsonServerClient *client = new QJsonServerClient(this);
client->setAuthority(authority);
client->setSocket(socket);
connect(client, SIGNAL(authorized(const QString&)),
@@ -221,17 +221,17 @@ void JsonServer::handleLocalConnection()
}
/*!
- Received when a new client has been authorized by a \c JsonAuthority.
+ Received when a new client has been authorized by a \c QJsonAuthority.
The \a identifier must be unique.
Be sure to call this function if you override it in a subclass. This function
will emit \c connectionAdded with the \a identifier of the client.
t
*/
-void JsonServer::handleClientAuthorized(const QString &identifier)
+void QJsonServer::handleClientAuthorized(const QString &identifier)
{
- JsonServerClient *client = qobject_cast<JsonServerClient *>(sender());
- Q_D(JsonServer);
+ QJsonServerClient *client = qobject_cast<QJsonServerClient *>(sender());
+ Q_D(QJsonServer);
bool exists = d->m_identifierToClient.contains(identifier);
if (exists && !d->m_multipleConnections.contains(identifier)) {
@@ -254,13 +254,13 @@ void JsonServer::handleClientAuthorized(const QString &identifier)
the client.
*/
-void JsonServer::clientDisconnected(const QString &identifier) {
- JsonServerClient *client = qobject_cast<JsonServerClient *>(sender());
+void QJsonServer::clientDisconnected(const QString &identifier) {
+ QJsonServerClient *client = qobject_cast<QJsonServerClient *>(sender());
if (!client)
return;
// Only emit the connectionRemoved signal if this was a valid connection
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (!d->m_identifierToClient.remove(identifier, client))
qWarning() << "Error: Mismatched client for" << identifier;
else
@@ -272,7 +272,7 @@ void JsonServer::clientDisconnected(const QString &identifier) {
/*!
Called when authorization fails for a client.
*/
-void JsonServer::handleAuthorizationFailed()
+void QJsonServer::handleAuthorizationFailed()
{
emit authorizationFailed();
}
@@ -282,10 +282,10 @@ void JsonServer::handleAuthorizationFailed()
The messageReceived signal is emitted when this method is called.
*/
-void JsonServer::receiveMessage(const QString &identifier, const QJsonObject &message)
+void QJsonServer::receiveMessage(const QString &identifier, const QJsonObject &message)
{
// do JSON schema validation if required
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (canValidate(validatorFlags(), d->m_inboundValidator)) {
if (!d->m_inboundValidator->validateSchema(message))
{
@@ -304,9 +304,9 @@ void JsonServer::receiveMessage(const QString &identifier, const QJsonObject &me
/*!
Returns whether there is a connected client with \a identifier.
*/
-bool JsonServer::hasConnection(const QString &identifier) const
+bool QJsonServer::hasConnection(const QString &identifier) const
{
- Q_D(const JsonServer);
+ Q_D(const QJsonServer);
return d->m_identifierToClient.contains(identifier);
}
@@ -314,9 +314,9 @@ bool JsonServer::hasConnection(const QString &identifier) const
Returns a list of identifiers for all current connections.
*/
-QStringList JsonServer::connections() const
+QStringList QJsonServer::connections() const
{
- Q_D(const JsonServer);
+ Q_D(const QJsonServer);
return d->m_identifierToClient.uniqueKeys();
}
@@ -326,12 +326,12 @@ QStringList JsonServer::connections() const
The queue will be flushed to the client when it connects to the server,
and all subsequent messages will be sent directly to the client.
*/
-void JsonServer::enableQueuing(const QString &identifier)
+void QJsonServer::enableQueuing(const QString &identifier)
{
if (identifier.isEmpty())
return;
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (!d->m_messageQueues.contains(identifier))
d->m_messageQueues.insert(identifier, QList<QJsonObject>());
}
@@ -339,21 +339,21 @@ void JsonServer::enableQueuing(const QString &identifier)
/*!
Disables queuing of messages for client identified by \a identifier.
*/
-void JsonServer::disableQueuing(const QString &identifier)
+void QJsonServer::disableQueuing(const QString &identifier)
{
if (identifier.isEmpty())
return;
- Q_D(JsonServer);
+ Q_D(QJsonServer);
d->m_messageQueues.remove(identifier);
}
/*!
Returns whether queuing of messages is enabled for client identified by \a identifier.
*/
-bool JsonServer::isQueuingEnabled(const QString &identifier) const
+bool QJsonServer::isQueuingEnabled(const QString &identifier) const
{
- Q_D(const JsonServer);
+ Q_D(const QJsonServer);
return d->m_messageQueues.contains(identifier);
}
@@ -362,12 +362,12 @@ bool JsonServer::isQueuingEnabled(const QString &identifier) const
Does not disable or enable message queuing for the client.
*/
-void JsonServer::clearQueue(const QString &identifier)
+void QJsonServer::clearQueue(const QString &identifier)
{
if (identifier.isEmpty())
return;
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (d->m_messageQueues.contains(identifier))
d->m_messageQueues.insert(identifier, QList<QJsonObject>());
}
@@ -378,9 +378,9 @@ void JsonServer::clearQueue(const QString &identifier)
\a identifier.
*/
-void JsonServer::enableMultipleConnections(const QString& identifier)
+void QJsonServer::enableMultipleConnections(const QString& identifier)
{
- Q_D(JsonServer);
+ Q_D(QJsonServer);
d->m_multipleConnections.insert(identifier);
}
@@ -388,9 +388,9 @@ void JsonServer::enableMultipleConnections(const QString& identifier)
Disable multiple clients that match \a identifier.
*/
-void JsonServer::disableMultipleConnections(const QString& identifier)
+void QJsonServer::disableMultipleConnections(const QString& identifier)
{
- Q_D(JsonServer);
+ Q_D(QJsonServer);
d->m_multipleConnections.remove(identifier);
}
@@ -399,14 +399,14 @@ void JsonServer::disableMultipleConnections(const QString& identifier)
/*!
Sends an arbitrary \a message to the client application identified by \a identifier and returns true when
the client was found and the message could be sent. The return value does \b{not} indicate that
- the client actually received the message and reacted to it, only that the JsonServer had a connection
+ the client actually received the message and reacted to it, only that the QJsonServer had a connection
open to that client, and was able to dispatch the message.
*/
-bool JsonServer::send(const QString &identifier, const QJsonObject &message)
+bool QJsonServer::send(const QString &identifier, const QJsonObject &message)
{
// do JSON schema validation if required
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (canValidate(validatorFlags(), d->m_outboundValidator)) {
if (!d->m_outboundValidator->validateSchema(message))
{
@@ -426,8 +426,8 @@ bool JsonServer::send(const QString &identifier, const QJsonObject &message)
return true;
}
- QList<JsonServerClient*> clients = d->m_identifierToClient.values(identifier);
- foreach (JsonServerClient *client, clients) {
+ QList<QJsonServerClient*> clients = d->m_identifierToClient.values(identifier);
+ foreach (QJsonServerClient *client, clients) {
Q_ASSERT(client);
client->send(message);
}
@@ -438,10 +438,10 @@ bool JsonServer::send(const QString &identifier, const QJsonObject &message)
Broadcast \a message to all connected clients.
*/
-void JsonServer::broadcast(const QJsonObject &message)
+void QJsonServer::broadcast(const QJsonObject &message)
{
// do JSON schema validation if required
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (canValidate(validatorFlags(), d->m_outboundValidator)) {
if (!d->m_outboundValidator->validateSchema(message))
{
@@ -454,9 +454,9 @@ void JsonServer::broadcast(const QJsonObject &message)
}
}
- // ### No JsonServerClient should be repeated in this list
- QList<JsonServerClient*> clients = d->m_identifierToClient.values();
- foreach (JsonServerClient *client, clients) {
+ // ### No QJsonServerClient should be repeated in this list
+ QList<QJsonServerClient*> clients = d->m_identifierToClient.values();
+ foreach (QJsonServerClient *client, clients) {
Q_ASSERT(client);
client->send(message);
}
@@ -465,24 +465,24 @@ void JsonServer::broadcast(const QJsonObject &message)
/*!
Removes all connections created by the created by the application identified by \a identifier.
If no connections are found, this method does nothing.
- Note that calling this function does not change the JsonAuthority permissions, so it is
+ Note that calling this function does not change the QJsonAuthority permissions, so it is
possible that a new client will connect using the same authorization.
Calling this function will result in the \l connectionRemoved() signal being raised.
*/
-void JsonServer::removeConnection(const QString &identifier)
+void QJsonServer::removeConnection(const QString &identifier)
{
- Q_D(JsonServer);
- QList<JsonServerClient*> clients = d->m_identifierToClient.values(identifier);
+ Q_D(QJsonServer);
+ QList<QJsonServerClient*> clients = d->m_identifierToClient.values(identifier);
while (!clients.isEmpty()) {
- JsonServerClient *client = clients.takeFirst();
+ QJsonServerClient *client = clients.takeFirst();
Q_ASSERT(client);
client->stop();
}
}
/*!
- \enum JsonServer::ValidatorFlag
+ \enum QJsonServer::ValidatorFlag
This enum determines what the validators do with packets. The value is
specified by combining values from the following list using the bitwise
OR operator:
@@ -500,29 +500,29 @@ void JsonServer::removeConnection(const QString &identifier)
/*!
Return the current ValidatorFlags
*/
-JsonServer::ValidatorFlags JsonServer::validatorFlags() const
+QJsonServer::ValidatorFlags QJsonServer::validatorFlags() const
{
- Q_D(const JsonServer);
+ Q_D(const QJsonServer);
return d->m_validatorFlags;
}
/*!
Sets validatorFlags property to \a flags.
*/
-void JsonServer::setValidatorFlags(ValidatorFlags flags)
+void QJsonServer::setValidatorFlags(ValidatorFlags flags)
{
- Q_D(JsonServer);
+ Q_D(QJsonServer);
d->m_validatorFlags = flags;
}
/*!
Returns an inbound JSON schema validator object.
*/
-SchemaValidator *JsonServer::inboundValidator()
+QJsonSchemaValidator *QJsonServer::inboundValidator()
{
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (!d->m_inboundValidator) {
- d->m_inboundValidator = new SchemaValidator(this);
+ d->m_inboundValidator = new QJsonSchemaValidator(this);
}
return d->m_inboundValidator;
}
@@ -530,11 +530,11 @@ SchemaValidator *JsonServer::inboundValidator()
/*!
Returns an outbound JSON schema validator object.
*/
-SchemaValidator *JsonServer::outboundValidator()
+QJsonSchemaValidator *QJsonServer::outboundValidator()
{
- Q_D(JsonServer);
+ Q_D(QJsonServer);
if (!d->m_outboundValidator) {
- d->m_outboundValidator = new SchemaValidator(this);
+ d->m_outboundValidator = new QJsonSchemaValidator(this);
}
return d->m_outboundValidator;
}
@@ -543,7 +543,7 @@ SchemaValidator *JsonServer::outboundValidator()
\internal
Initialize validation if defined by environment
*/
-void JsonServer::initSchemaValidation()
+void QJsonServer::initSchemaValidation()
{
QString szInboundPath = QString::fromLocal8Bit(qgetenv("JSONSERVER_SCHEMA_INBOUND_PATH"));
QString szOutboundPath = QString::fromLocal8Bit(qgetenv("JSONSERVER_SCHEMA_OUTBOUND_PATH"));
@@ -579,41 +579,41 @@ void JsonServer::initSchemaValidation()
}
/*!
- \fn void JsonServer::connectionAdded(const QString &identifier)
+ \fn void QJsonServer::connectionAdded(const QString &identifier)
This signal is emitted when a connection identified by the \a identifier has connected and
been authorized.
*/
/*!
- \fn void JsonServer::connectionRemoved(const QString &identifier)
+ \fn void QJsonServer::connectionRemoved(const QString &identifier)
This signal is emitted when a connection identified by \a identifier disconnects.
Disconnection can happen if the connection is lost, or when the client process is stopped.
*/
/*!
- \fn void JsonServer::messageReceived(const QString &identifier, const QJsonObject &message)
+ \fn void QJsonServer::messageReceived(const QString &identifier, const QJsonObject &message)
This signal is emitted when a message is received from a connected client identified by the application identifier \a identifier.
\a message contains the JSON message received.
*/
/*!
- \fn void JsonServer::authorizationFailed()
+ \fn void QJsonServer::authorizationFailed()
This signal is emitted when a client fails to authorize.
*/
/*!
- \fn void JsonServer::inboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::JsonStream::SchemaError &error)
+ \fn void QJsonServer::inboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::JsonStream::SchemaError &error)
This signal is emitted when an inbound \a message message fails a JSON schema validation. The validation
error is reported in \a error.
*/
/*!
- \fn void JsonServer::outboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::JsonStream::SchemaError &error)
+ \fn void QJsonServer::outboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::JsonStream::SchemaError &error)
This signal is emitted when an outbound \a message message fails a JSON schema validation. The validation
error is reported in \a error.
*/
-#include "moc_jsonserver.cpp"
+#include "moc_qjsonserver.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonserver.h b/src/jsonstream/qjsonserver.h
index f7e1c92..0638919 100644
--- a/src/jsonserver.h
+++ b/src/jsonstream/qjsonserver.h
@@ -45,26 +45,26 @@
#include <QObject>
#include <QJsonObject>
-#include "jsonstream-global.h"
-#include "schemaerror.h"
+#include "qjsonstream-global.h"
+#include "qjsonschemaerror.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonAuthority;
-class SchemaValidator;
+class QJsonAuthority;
+class QJsonSchemaValidator;
-class JsonServerPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonServer : public QObject
+class QJsonServerPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonServer : public QObject
{
Q_OBJECT
Q_PROPERTY(ValidatorFlags validatorFlags READ validatorFlags WRITE setValidatorFlags)
public:
- JsonServer(QObject *parent = 0);
- virtual ~JsonServer();
+ QJsonServer(QObject *parent = 0);
+ virtual ~QJsonServer();
- bool listen(int port, JsonAuthority *authority = 0);
- bool listen(const QString& socketname, JsonAuthority *authority = 0);
+ bool listen(int port, QJsonAuthority *authority = 0);
+ bool listen(const QString& socketname,QJsonAuthority *authority = 0);
QStringList connections() const;
@@ -88,8 +88,8 @@ public:
ValidatorFlags validatorFlags() const;
void setValidatorFlags(ValidatorFlags);
- SchemaValidator *inboundValidator();
- SchemaValidator *outboundValidator();
+ QJsonSchemaValidator *inboundValidator();
+ QJsonSchemaValidator *outboundValidator();
public slots:
bool hasConnection(const QString &identifier) const;
@@ -103,8 +103,8 @@ signals:
void messageReceived(const QString &identifier, const QJsonObject &message);
void authorizationFailed();
- void inboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::JsonStream::SchemaError &error);
- void outboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::JsonStream::SchemaError &error);
+ void inboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::QtJsonStream::QJsonSchemaError &error);
+ void outboundMessageValidationFailed(const QJsonObject &message, const QtAddOn::QtJsonStream::QJsonSchemaError &error);
protected slots:
virtual void handleClientAuthorized(const QString &identifier);
@@ -119,11 +119,11 @@ private:
void initSchemaValidation();
private:
- Q_DECLARE_PRIVATE(JsonServer)
- QScopedPointer<JsonServerPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonServer)
+ QScopedPointer<QJsonServerPrivate> d_ptr;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(JsonServer::ValidatorFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QJsonServer::ValidatorFlags)
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonserverclient.cpp b/src/jsonstream/qjsonserverclient.cpp
index 5b53e74..489f45c 100644
--- a/src/jsonserverclient.cpp
+++ b/src/jsonstream/qjsonserverclient.cpp
@@ -42,47 +42,47 @@
#include <QtCore>
#include <QtNetwork>
-#include "jsonserverclient.h"
-#include "jsonauthority.h"
-#include "jsonstream.h"
+#include "qjsonserverclient.h"
+#include "qjsonauthority.h"
+#include "qjsonstream.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonServerClientPrivate
+class QJsonServerClientPrivate
{
public:
- JsonServerClientPrivate()
+ QJsonServerClientPrivate()
: m_socket(0)
, m_stream(0) {}
QString m_identifier;
QLocalSocket *m_socket;
- JsonStream *m_stream;
- QWeakPointer<JsonAuthority> m_authority;
+ QJsonStream *m_stream;
+ QPointer<QJsonAuthority> m_authority;
};
/****************************************************************************/
/*!
- \class JsonServerClient
- \brief The JsonServerClient class wraps an individual connection to the JsonServer.
+ \class QJsonServerClient
+ \brief The QJsonServerClient class wraps an individual connection to the QJsonServer.
*/
/*!
- Construct a JsonServerClient object with the given \a parent
+ Construct a QJsonServerClient object with the given \a parent
*/
-JsonServerClient::JsonServerClient(QObject *parent)
+QJsonServerClient::QJsonServerClient(QObject *parent)
: QObject(parent)
- , d_ptr(new JsonServerClientPrivate())
+ , d_ptr(new QJsonServerClientPrivate())
{
}
/*!
- Destructs the JsonServerClient object.
+ Destructs the QJsonServerClient object.
*/
-JsonServerClient::~JsonServerClient()
+QJsonServerClient::~QJsonServerClient()
{
}
@@ -91,9 +91,9 @@ JsonServerClient::~JsonServerClient()
Does not take ownership of the object.
*/
-void JsonServerClient::setAuthority(JsonAuthority *authority)
+void QJsonServerClient::setAuthority(QJsonAuthority *authority)
{
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
d->m_authority = authority;
}
@@ -101,9 +101,9 @@ void JsonServerClient::setAuthority(JsonAuthority *authority)
Return the internal socket object
*/
-const QLocalSocket *JsonServerClient::socket() const
+const QLocalSocket *QJsonServerClient::socket() const
{
- Q_D(const JsonServerClient);
+ Q_D(const QJsonServerClient);
return d->m_socket;
}
@@ -111,14 +111,14 @@ const QLocalSocket *JsonServerClient::socket() const
Set the internal socket object to \a socket.
*/
-void JsonServerClient::setSocket(QLocalSocket *socket)
+void QJsonServerClient::setSocket(QLocalSocket *socket)
{
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
d->m_socket = socket;
d->m_socket->setParent(this);
if (socket) {
- d->m_stream = new JsonStream(socket);
+ d->m_stream = new QJsonStream(socket);
d->m_stream->setParent(this);
connect(socket, SIGNAL(disconnected()), this, SLOT(handleDisconnect()));
connect(d->m_stream, SIGNAL(readyReadMessage()), this, SLOT(processMessages()));
@@ -129,9 +129,9 @@ void JsonServerClient::setSocket(QLocalSocket *socket)
Return the client identifier
*/
-QString JsonServerClient::identifier() const
+QString QJsonServerClient::identifier() const
{
- Q_D(const JsonServerClient);
+ Q_D(const QJsonServerClient);
return d->m_identifier;
}
@@ -140,20 +140,20 @@ QString JsonServerClient::identifier() const
only be called by the \l{JsonServer}
*/
-void JsonServerClient::start()
+void QJsonServerClient::start()
{
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
if (!d->m_authority) {
d->m_identifier = QUuid::createUuid().toString();
emit authorized(d->m_identifier);
} else {
AuthorizationRecord authRecord = d->m_authority.data()->clientConnected(d->m_stream);
switch (authRecord.state) {
- case JsonAuthority::StateAuthorized:
+ case QJsonAuthority::StateAuthorized:
d->m_identifier = authRecord.identifier;
emit authorized(d->m_identifier);
break;
- case JsonAuthority::StateNotAuthorized:
+ case QJsonAuthority::StateNotAuthorized:
emit authorizationFailed();
stop();
break;
@@ -167,18 +167,18 @@ void JsonServerClient::start()
Force the connection to stop
Once the socket disconnects, a "disconnected" signal will be emitted
*/
-void JsonServerClient::stop()
+void QJsonServerClient::stop()
{
// qDebug() << Q_FUNC_INFO;
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
disconnect(d->m_stream, SIGNAL(readyReadMessage()), this, SLOT(processMessages()));
d->m_socket->disconnectFromServer();
// qDebug() << Q_FUNC_INFO << "done";
}
-void JsonServerClient::received(const QJsonObject& message)
+void QJsonServerClient::received(const QJsonObject& message)
{
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
if (d->m_identifier.isEmpty()) {
if (d->m_authority.isNull()) {
emit authorizationFailed();
@@ -187,11 +187,11 @@ void JsonServerClient::received(const QJsonObject& message)
} else {
AuthorizationRecord authRecord = d->m_authority.data()->messageReceived(d->m_stream, message);
switch (authRecord.state) {
- case JsonAuthority::StateAuthorized:
+ case QJsonAuthority::StateAuthorized:
d->m_identifier = authRecord.identifier;
emit authorized(d->m_identifier);
break;
- case JsonAuthority::StateNotAuthorized:
+ case QJsonAuthority::StateNotAuthorized:
emit authorizationFailed();
stop();
break;
@@ -210,10 +210,10 @@ void JsonServerClient::received(const QJsonObject& message)
Returns true if the entire message was send/buffered or false otherwise.
*/
-bool JsonServerClient::send(const QJsonObject &message)
+bool QJsonServerClient::send(const QJsonObject &message)
{
bool ret = false;
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
if (d->m_stream) {
// qDebug() << "Sending message" << message;
ret = d->m_stream->send(message);
@@ -221,10 +221,10 @@ bool JsonServerClient::send(const QJsonObject &message)
return ret;
}
-void JsonServerClient::handleDisconnect()
+void QJsonServerClient::handleDisconnect()
{
// qDebug() << Q_FUNC_INFO;
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
d->m_stream->setDevice(0);
if (d->m_authority.data())
d->m_authority.data()->clientDisconnected(d->m_stream);
@@ -236,9 +236,9 @@ void JsonServerClient::handleDisconnect()
/*!
\internal
*/
-void JsonServerClient::processMessages()
+void QJsonServerClient::processMessages()
{
- Q_D(JsonServerClient);
+ Q_D(QJsonServerClient);
while (d->m_stream->messageAvailable()) {
QJsonObject obj = d->m_stream->readMessage();
if (!obj.isEmpty())
@@ -247,31 +247,31 @@ void JsonServerClient::processMessages()
}
/*!
- \fn JsonServerClient::disconnected(const QString& identifier)
+ \fn QJsonServerClient::disconnected(const QString& identifier)
This signal is emitted when the client has been disconnected. The
\a identifier property is included for convenience.
*/
/*!
- \fn JsonServerClient::messageReceived(const QString& identifier, const QJsonObject& message)
+ \fn QJsonServerClient::messageReceived(const QString& identifier, const QJsonObject& message)
This signal is emitted when a \a message has been received by the client. The
\a identifier property is included for convenience.
*/
/*!
- \fn JsonServerClient::authorized(const QString& identifier)
+ \fn QJsonServerClient::authorized(const QString& identifier)
This signal is emitted when the client has been authorized. The
\a identifier property is included for convenience.
*/
/*!
- \fn JsonServerClient::authorizationFailed()
+ \fn QJsonServerClient::authorizationFailed()
This signal is emitted when the client has failed authorization.
*/
-#include "moc_jsonserverclient.cpp"
+#include "moc_qjsonserverclient.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonserverclient.h b/src/jsonstream/qjsonserverclient.h
index 5c97dfb..fddf5fa 100644
--- a/src/jsonserverclient.h
+++ b/src/jsonstream/qjsonserverclient.h
@@ -47,26 +47,26 @@
class QLocalSocket;
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonAuthority;
+class QJsonAuthority;
-class JsonServerClientPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonServerClient : public QObject
+class QJsonServerClientPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonServerClient : public QObject
{
Q_OBJECT
public:
- JsonServerClient(QObject *parent = 0);
- ~JsonServerClient();
+ QJsonServerClient(QObject *parent = 0);
+ ~QJsonServerClient();
void start();
void stop();
bool send(const QJsonObject &message);
- void setAuthority(JsonAuthority *authority);
+ void setAuthority(QJsonAuthority *authority);
const QLocalSocket *socket() const;
void setSocket(QLocalSocket *socket);
@@ -86,8 +86,8 @@ private slots:
void processMessages();
private:
- Q_DECLARE_PRIVATE(JsonServerClient)
- QScopedPointer<JsonServerClientPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonServerClient)
+ QScopedPointer<QJsonServerClientPrivate> d_ptr;
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonstream-global.h b/src/jsonstream/qjsonstream-global.h
index 1a02fcf..b9fb669 100644
--- a/src/jsonstream-global.h
+++ b/src/jsonstream/qjsonstream-global.h
@@ -50,19 +50,19 @@
#endif
#if defined(QT_NAMESPACE)
-# define QT_BEGIN_NAMESPACE_JSONSTREAM namespace QT_NAMESPACE { namespace QtAddOn { namespace JsonStream {
+# define QT_BEGIN_NAMESPACE_JSONSTREAM namespace QT_NAMESPACE { namespace QtAddOn { namespace QtJsonStream {
# define QT_END_NAMESPACE_JSONSTREAM } } }
-# define QT_USE_NAMESPACE_JSONSTREAM using namespace QT_NAMESPACE::QtAddOn::JsonStream;
-# define QT_PREPEND_NAMESPACE_JSONSTREAM(name) ::QT_NAMESPACE::QtAddOn::JsonStream::name
+# define QT_USE_NAMESPACE_JSONSTREAM using namespace QT_NAMESPACE::QtAddOn::QtJsonStream;
+# define QT_PREPEND_NAMESPACE_JSONSTREAM(name) ::QT_NAMESPACE::QtAddOn::QtJsonStream::name
#else
-# define QT_BEGIN_NAMESPACE_JSONSTREAM namespace QtAddOn { namespace JsonStream {
+# define QT_BEGIN_NAMESPACE_JSONSTREAM namespace QtAddOn { namespace QtJsonStream {
# define QT_END_NAMESPACE_JSONSTREAM } }
-# define QT_USE_NAMESPACE_JSONSTREAM using namespace QtAddOn::JsonStream;
-# define QT_PREPEND_NAMESPACE_JSONSTREAM(name) ::QtAddOn::JsonStream::name
+# define QT_USE_NAMESPACE_JSONSTREAM using namespace QtAddOn::QtJsonStream;
+# define QT_PREPEND_NAMESPACE_JSONSTREAM(name) ::QtAddOn::QtJsonStream::name
#endif
-#define QT_JSONSTREAM_DECLARE_METATYPE_PTR(name) Q_DECLARE_METATYPE(QtAddOn::JsonStream::name *)
-#define QT_JSONSTREAM_DECLARE_METATYPE_CONST_PTR(name) Q_DECLARE_METATYPE(const QtAddOn::JsonStream::name *)
+#define QT_JSONSTREAM_DECLARE_METATYPE_PTR(name) Q_DECLARE_METATYPE(QtAddOn::QtJsonStream::name *)
+#define QT_JSONSTREAM_DECLARE_METATYPE_CONST_PTR(name) Q_DECLARE_METATYPE(const QtAddOn::QtJsonStream::name *)
QT_BEGIN_NAMESPACE_JSONSTREAM
diff --git a/src/jsonstream.cpp b/src/jsonstream/qjsonstream.cpp
index e98b501..41236ea 100644
--- a/src/jsonstream.cpp
+++ b/src/jsonstream/qjsonstream.cpp
@@ -47,8 +47,8 @@
#include <qjsondocument.h>
#include <QTextCodec>
-#include "jsonstream.h"
-#include "jsonbuffer_p.h"
+#include "qjsonstream.h"
+#include "qjsonbuffer_p.h"
#include "qjsondocument.h"
#include "qjsonobject.h"
#include "bson/qt-bson_p.h"
@@ -69,60 +69,60 @@ static QByteArray bsonToByteArray(BsonObject &bson)
/****************************************************************************/
-class JsonStreamPrivate
+class QJsonStreamPrivate
{
public:
- JsonStreamPrivate()
+ QJsonStreamPrivate()
: mDevice(0)
, mFormat(FormatUndefined)
, mReadBufferSize(0)
, mWriteBufferSize(0)
- , mLastError(JsonStream::NoError) {}
+ , mLastError(QJsonStream::NoError) {}
QIODevice *mDevice;
- JsonBuffer *mBuffer;
+ QJsonBuffer *mBuffer;
EncodingFormat mFormat;
qint64 mReadBufferSize;
qint64 mWriteBufferSize;
- JsonStream::JsonStreamError mLastError;
+ QJsonStream::QJsonStreamError mLastError;
};
/****************************************************************************/
/*!
- \class JsonStream
- \brief The JsonStream class serializes JSON data.
+ \class QJsonStream
+ \brief The QJsonStream class serializes JSON data.
- The JsonStream class is a generic interface for serializing and deserializing
+ The QJsonStream class is a generic interface for serializing and deserializing
JSON data over a socket connection. It is designed to support multiple serialization
and deserialization formats by auto-detecting the format in use.
*/
/*!
- Constructs a \c JsonStream object using the given \a device.
+ Constructs a \c QJsonStream object using the given \a device.
*/
-JsonStream::JsonStream(QIODevice *device)
+QJsonStream::QJsonStream(QIODevice *device)
: QObject(0)
- , d_ptr(new JsonStreamPrivate())
+ , d_ptr(new QJsonStreamPrivate())
{
- Q_D(JsonStream);
- d->mBuffer = new JsonBuffer(this);
+ Q_D(QJsonStream);
+ d->mBuffer = new QJsonBuffer(this);
connect(d->mBuffer, SIGNAL(readyReadMessage()), SLOT(messageReceived()));
setDevice(device);
}
/*!
- Delete the \c JsonStream object and close the connection.
+ Delete the \c QJsonStream object and close the connection.
You should call \l {setDevice()} {setDevice(0)} before calling this function.
*/
-JsonStream::~JsonStream()
+QJsonStream::~QJsonStream()
{
}
/*!
- \enum JsonStream::JsonStreamError
+ \enum QJsonStream::JsonStreamError
\value NoError
No error has occurred.
\value WriteFailedNoConnection
@@ -141,7 +141,7 @@ JsonStream::~JsonStream()
/*!
Returns the error the last operation produced, or NoError error if the last operation did not produce an error.
*/
-JsonStream::JsonStreamError JsonStream::lastError() const
+QJsonStream::QJsonStreamError QJsonStream::lastError() const
{
return d_ptr->mLastError;
}
@@ -151,9 +151,9 @@ JsonStream::JsonStreamError JsonStream::lastError() const
returns whether or not it is \c atEnd()
*/
-bool JsonStream::atEnd() const
+bool QJsonStream::atEnd() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return (d->mDevice && d->mDevice->atEnd());
}
@@ -162,32 +162,32 @@ bool JsonStream::atEnd() const
returns whether or not it is \c isOpen()
*/
-bool JsonStream::isOpen() const
+bool QJsonStream::isOpen() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return (d->mDevice && d->mDevice->isOpen());
}
/*!
- Return the current QIODevice used by the JsonStream
+ Return the current QIODevice used by the QJsonStream
*/
-QIODevice * JsonStream::device() const
+QIODevice * QJsonStream::device() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return d->mDevice;
}
/*!
- Set the \a device used by the JsonStream.
+ Set the \a device used by the QJsonStream.
Setting the device to 0 disconnects the stream but does not close
the device nor flush it.
The stream does not take ownership of the device.
*/
-void JsonStream::setDevice( QIODevice *device )
+void QJsonStream::setDevice( QIODevice *device )
{
- Q_D(JsonStream);
+ Q_D(QJsonStream);
if (d->mDevice) {
disconnect(d->mDevice, SIGNAL(readyRead()), this, SLOT(dataReadyOnSocket()));
disconnect(d->mDevice, SIGNAL(bytesWritten(qint64)), this, SIGNAL(bytesWritten(qint64)));
@@ -203,21 +203,21 @@ void JsonStream::setDevice( QIODevice *device )
}
/*!
- Send a JsonObject \a object over the stream.
+ Send a QJsonObject \a object over the stream.
Returns \b true if the entire message was sent or buffered or \b false otherwise.
- JsonStream does not have a write buffer of its own. Rather, it uses the
+ QJsonStream does not have a write buffer of its own. Rather, it uses the
write buffer of the \l{device()}. It will not cause that buffer to grow
larger than \l{writeBufferSize()} at any time. If this would occur, this
method will return \b false.
*/
-bool JsonStream::send(const QJsonObject& object)
+bool QJsonStream::send(const QJsonObject& object)
{
bool bRet(false);
QJsonDocument document(object);
- Q_D(JsonStream);
+ Q_D(QJsonStream);
switch (d->mFormat) {
case FormatUndefined:
d->mFormat = FormatQBJS;
@@ -254,12 +254,12 @@ bool JsonStream::send(const QJsonObject& object)
\internal
Send raw QByteArray \a byteArray data over the socket.
*/
-bool JsonStream::sendInternal(const QByteArray& byteArray)
+bool QJsonStream::sendInternal(const QByteArray& byteArray)
{
- Q_D(JsonStream);
+ Q_D(QJsonStream);
if (!isOpen()) {
d->mLastError = WriteFailedNoConnection;
- qWarning() << Q_FUNC_INFO << "No device in JsonStream";
+ qWarning() << Q_FUNC_INFO << "No device in QJsonStream";
return false;
}
d->mLastError = NoError;
@@ -304,9 +304,9 @@ bool JsonStream::sendInternal(const QByteArray& byteArray)
Handle a received readyReadMessage signal and emit the correct signals
*/
-void JsonStream::messageReceived()
+void QJsonStream::messageReceived()
{
- Q_D(JsonStream);
+ Q_D(QJsonStream);
if (d->mFormat == FormatUndefined)
d->mFormat = d->mBuffer->format();
emit readyReadMessage();
@@ -317,9 +317,9 @@ void JsonStream::messageReceived()
Extract data from the socket and extract received messages.
*/
-void JsonStream::dataReadyOnSocket()
+void QJsonStream::dataReadyOnSocket()
{
- Q_D(JsonStream);
+ Q_D(QJsonStream);
d->mLastError = NoError;
if (d->mReadBufferSize > 0) {
while (d->mDevice->bytesAvailable() + d->mBuffer->size() > d->mReadBufferSize) {
@@ -346,12 +346,12 @@ void JsonStream::dataReadyOnSocket()
}
/*!
- Return the current JsonStream::EncodingFormat.
+ Return the current QJsonStream::EncodingFormat.
*/
-EncodingFormat JsonStream::format() const
+EncodingFormat QJsonStream::format() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return d->mFormat;
}
@@ -359,18 +359,18 @@ EncodingFormat JsonStream::format() const
Set the EncodingFormat to \a format.
*/
-void JsonStream::setFormat( EncodingFormat format )
+void QJsonStream::setFormat( EncodingFormat format )
{
- Q_D(JsonStream);
+ Q_D(QJsonStream);
d->mFormat = format;
}
/*!
Returns a maximum size of the inbound message buffer.
*/
-qint64 JsonStream::readBufferSize() const
+qint64 QJsonStream::readBufferSize() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return d->mReadBufferSize;
}
@@ -378,10 +378,10 @@ qint64 JsonStream::readBufferSize() const
Sets a maximum size of the inbound message buffer to \a sz thus capping a size
of an inbound message.
*/
-void JsonStream::setReadBufferSize(qint64 sz)
+void QJsonStream::setReadBufferSize(qint64 sz)
{
if (sz >= 0) {
- Q_D(JsonStream);
+ Q_D(QJsonStream);
d->mReadBufferSize = sz;
}
}
@@ -390,9 +390,9 @@ void JsonStream::setReadBufferSize(qint64 sz)
Returns a maximum size of the outbound message buffer. A value of 0
means the buffer size is unlimited.
*/
-qint64 JsonStream::writeBufferSize() const
+qint64 QJsonStream::writeBufferSize() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return d->mWriteBufferSize;
}
@@ -400,10 +400,10 @@ qint64 JsonStream::writeBufferSize() const
Sets a maximum size of the outbound message buffer to \a sz thus capping a size
of an outbound message. A value of 0 means the buffer size is unlimited.
*/
-void JsonStream::setWriteBufferSize(qint64 sz)
+void QJsonStream::setWriteBufferSize(qint64 sz)
{
if (sz >= 0) {
- Q_D(JsonStream);
+ Q_D(QJsonStream);
d->mWriteBufferSize = sz;
}
}
@@ -413,9 +413,9 @@ void JsonStream::setWriteBufferSize(qint64 sz)
if \l{writeBufferSize()} is not unlimited, the largest message you can
send at any one time is (\l{writeBufferSize()} - \b bytesToWrite()) bytes.
*/
-qint64 JsonStream::bytesToWrite() const
+qint64 QJsonStream::bytesToWrite() const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return (d->mDevice ? d->mDevice->bytesToWrite() : 0);
}
@@ -423,9 +423,9 @@ qint64 JsonStream::bytesToWrite() const
Returns a JSON object that has been received. If no message is
available, an empty JSON object is returned.
*/
-QJsonObject JsonStream::readMessage()
+QJsonObject QJsonStream::readMessage()
{
- Q_D(JsonStream);
+ Q_D(QJsonStream);
return d->mBuffer->readMessage();
}
@@ -433,22 +433,22 @@ QJsonObject JsonStream::readMessage()
Returns \b true if a message is available to be read via \l{readMessage()}
or \b false otherwise.
*/
-bool JsonStream::messageAvailable()
+bool QJsonStream::messageAvailable()
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
return d->mBuffer->messageAvailable();
}
/*!
internal
*/
-void JsonStream::setThreadProtection(bool enable) const
+void QJsonStream::setThreadProtection(bool enable) const
{
- Q_D(const JsonStream);
+ Q_D(const QJsonStream);
d->mBuffer->setThreadProtection(enable);
}
-/*! \fn JsonStream::bytesWritten(qint64 bytes)
+/*! \fn QJsonStream::bytesWritten(qint64 bytes)
This signal is emitted every time a payload of data has been
written to the device. The \a bytes argument is set to the number
@@ -460,7 +460,7 @@ void JsonStream::setThreadProtection(bool enable) const
*/
/*!
- \fn void JsonStream::readyReadMessage()
+ \fn void QJsonStream::readyReadMessage()
This signal is emitted once every time new data arrives on the \l{device()}
and a message is ready. \l{readMessage()} should be used to retrieve a message
@@ -489,11 +489,11 @@ void JsonStream::setThreadProtection(bool enable) const
*/
/*!
- \fn void JsonStream::aboutToClose()
+ \fn void QJsonStream::aboutToClose()
This signal is emitted when the underlying \c QIODevice is about to close.
*/
-/*! \fn JsonStream::readBufferOverflow(qint64 bytes)
+/*! \fn QJsonStream::readBufferOverflow(qint64 bytes)
This signal is emitted when the read buffer is full of data that has been read
from the \l{device()}, \a bytes additional bytes are available on the device,
@@ -503,6 +503,6 @@ void JsonStream::setThreadProtection(bool enable) const
the connection is closed.
*/
-#include "moc_jsonstream.cpp"
+#include "moc_qjsonstream.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonstream.h b/src/jsonstream/qjsonstream.h
index e9db07a..203a35f 100644
--- a/src/jsonstream.h
+++ b/src/jsonstream/qjsonstream.h
@@ -44,19 +44,19 @@
#include <QIODevice>
#include <QJsonObject>
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class JsonBuffer;
+class QJsonBuffer;
-class JsonStreamPrivate;
-class Q_ADDON_JSONSTREAM_EXPORT JsonStream : public QObject
+class QJsonStreamPrivate;
+class Q_ADDON_JSONSTREAM_EXPORT QJsonStream : public QObject
{
Q_OBJECT
public:
- JsonStream(QIODevice *device = 0);
- virtual ~JsonStream();
+ QJsonStream(QIODevice *device = 0);
+ virtual ~QJsonStream();
bool atEnd() const;
bool isOpen() const;
@@ -80,7 +80,7 @@ public:
bool messageAvailable();
QJsonObject readMessage();
- enum JsonStreamError
+ enum QJsonStreamError
{
NoError = 0,
WriteFailedNoConnection,
@@ -90,7 +90,7 @@ public:
WriteFailedReturnedZero
};
- JsonStreamError lastError() const;
+ QJsonStreamError lastError() const;
signals:
void bytesWritten(qint64);
@@ -106,12 +106,12 @@ protected:
bool sendInternal(const QByteArray& byteArray);
private:
- friend class JsonConnectionProcessor;
+ friend class QJsonConnectionProcessor;
void setThreadProtection(bool) const;
private:
- Q_DECLARE_PRIVATE(JsonStream)
- QScopedPointer<JsonStreamPrivate> d_ptr;
+ Q_DECLARE_PRIVATE(QJsonStream)
+ QScopedPointer<QJsonStreamPrivate> d_ptr;
};
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsontokenauthority.cpp b/src/jsonstream/qjsontokenauthority.cpp
index c17e2ef..750dd5e 100644
--- a/src/jsontokenauthority.cpp
+++ b/src/jsonstream/qjsontokenauthority.cpp
@@ -41,15 +41,15 @@
#include <QUuid>
#include <QDebug>
-#include "jsontokenauthority.h"
+#include "qjsontokenauthority.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
/*!
- \class JsonTokenAuthority
- \brief The JsonTokenAuthority class implements a token-based authentication scheme for JsonServer.
+ \class QJsonTokenAuthority
+ \brief The QJsonTokenAuthority class implements a token-based authentication scheme for QJsonServer.
- The JsonTokenAuthority class authorizes Json client connections based on tokens received from the first
+ The QJsonTokenAuthority class authorizes QJson client connections based on tokens received from the first
message sent by the client to the server. The expectation is that the first message sent by the client
to the authority will be of the form:
@@ -60,11 +60,11 @@ QT_BEGIN_NAMESPACE_JSONSTREAM
*/
/*!
- Construct a \c JsonTokenAuthority with the given \a parent.
+ Construct a \c QJsonTokenAuthority with the given \a parent.
*/
-JsonTokenAuthority::JsonTokenAuthority(QObject *parent)
- : JsonAuthority(parent)
+QJsonTokenAuthority::QJsonTokenAuthority(QObject *parent)
+ : QJsonAuthority(parent)
{
}
@@ -72,7 +72,7 @@ JsonTokenAuthority::JsonTokenAuthority(QObject *parent)
Add a \a token, \a identifier pair to the valid hash table.
Return false if the token was already in the table.
*/
-bool JsonTokenAuthority::authorize(const QByteArray &token, const QString &identifier)
+bool QJsonTokenAuthority::authorize(const QByteArray &token, const QString &identifier)
{
if (identifier.isEmpty() || token.isEmpty())
return false;
@@ -88,7 +88,7 @@ bool JsonTokenAuthority::authorize(const QByteArray &token, const QString &ident
Remove a \a token from the valid hash table. Calling this function does
\b{not} disconnect any existing clients. Return true if the token was in the table, false if it was not.
*/
-bool JsonTokenAuthority::deauthorize(const QByteArray &token)
+bool QJsonTokenAuthority::deauthorize(const QByteArray &token)
{
return m_identifierForToken.remove(token);
}
@@ -96,10 +96,10 @@ bool JsonTokenAuthority::deauthorize(const QByteArray &token)
/*!
Wait for the first received message on \a stream.
*/
-AuthorizationRecord JsonTokenAuthority::clientConnected(JsonStream *stream)
+AuthorizationRecord QJsonTokenAuthority::clientConnected(QJsonStream *stream)
{
Q_UNUSED(stream);
- return AuthorizationRecord( JsonAuthority::StatePending );
+ return AuthorizationRecord( QJsonAuthority::StatePending );
}
/*!
@@ -108,7 +108,7 @@ AuthorizationRecord JsonTokenAuthority::clientConnected(JsonStream *stream)
\sa authorize()
*/
-AuthorizationRecord JsonTokenAuthority::messageReceived(JsonStream *stream,
+AuthorizationRecord QJsonTokenAuthority::messageReceived(QJsonStream *stream,
const QJsonObject &message)
{
Q_UNUSED(stream);
@@ -117,10 +117,10 @@ AuthorizationRecord JsonTokenAuthority::messageReceived(JsonStream *stream,
QString identifier = m_identifierForToken.value(token);
if (!identifier.isEmpty())
- return AuthorizationRecord( JsonAuthority::StateAuthorized, identifier );
- return AuthorizationRecord( JsonAuthority::StateNotAuthorized );
+ return AuthorizationRecord( QJsonAuthority::StateAuthorized, identifier );
+ return AuthorizationRecord( QJsonAuthority::StateNotAuthorized );
}
-#include "moc_jsontokenauthority.cpp"
+#include "moc_qjsontokenauthority.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsontokenauthority.h b/src/jsonstream/qjsontokenauthority.h
index 7ccbcae..be6a576 100644
--- a/src/jsontokenauthority.h
+++ b/src/jsonstream/qjsontokenauthority.h
@@ -43,22 +43,22 @@
#define JSONTOKENAUTHORITYPROVIDER_H
#include <QHash>
-#include "jsonauthority.h"
-#include "jsonstream-global.h"
+#include "qjsonauthority.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT JsonTokenAuthority : public JsonAuthority
+class Q_ADDON_JSONSTREAM_EXPORT QJsonTokenAuthority : public QJsonAuthority
{
Q_OBJECT
public:
- explicit JsonTokenAuthority(QObject *parent = 0);
+ explicit QJsonTokenAuthority(QObject *parent = 0);
bool authorize(const QByteArray &token, const QString &applicationIdentifier);
bool deauthorize(const QByteArray &token);
- virtual AuthorizationRecord clientConnected(JsonStream *stream);
- virtual AuthorizationRecord messageReceived(JsonStream *stream,
+ virtual AuthorizationRecord clientConnected(QJsonStream *stream);
+ virtual AuthorizationRecord messageReceived(QJsonStream *stream,
const QJsonObject &message);
private:
@@ -67,6 +67,6 @@ private:
QT_END_NAMESPACE_JSONSTREAM
-QT_JSONSTREAM_DECLARE_METATYPE_PTR(JsonTokenAuthority)
+QT_JSONSTREAM_DECLARE_METATYPE_PTR(QJsonTokenAuthority)
#endif // JSONTOKENAUTHORITYPROVIDER_H
diff --git a/src/jsonuidauthority.cpp b/src/jsonstream/qjsonuidauthority.cpp
index 60eea48..239d93d 100644
--- a/src/jsonuidauthority.cpp
+++ b/src/jsonstream/qjsonuidauthority.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "jsonuidauthority.h"
-#include "jsonstream.h"
+#include "qjsonuidauthority.h"
+#include "qjsonstream.h"
#include <errno.h>
#include <sys/socket.h>
@@ -54,23 +54,23 @@
QT_BEGIN_NAMESPACE_JSONSTREAM
/*!
- \class JsonUIDAuthority
- \brief The JsonUIDAuthority class implements a UID-based authentication scheme for JsonServer.
+ \class QJsonUIDAuthority
+ \brief The QJsonUIDAuthority class implements a UID-based authentication scheme for QJsonServer.
- The JsonUIDAuthority class authorizes Json client connections based on the user ID of the
+ The QJsonUIDAuthority class authorizes QJson client connections based on the user ID of the
client. This user ID is read directly from the connected socket.
- The name returned by the JsonUIDAuthority class is the name entry in the /etc/passwd
- database. If a name entry does not exist, the JsonUIDAuthority class sets the name equal
+ The name returned by the QJsonUIDAuthority class is the name entry in the /etc/passwd
+ database. If a name entry does not exist, the QJsonUIDAuthority class sets the name equal
to the string form of the uid.
*/
/*!
- Construct a JsonUIDAuthority with optional \a parent.
+ Construct a QJsonUIDAuthority with optional \a parent.
*/
-JsonUIDAuthority::JsonUIDAuthority(QObject *parent)
- : JsonAuthority(parent)
+QJsonUIDAuthority::QJsonUIDAuthority(QObject *parent)
+ : QJsonAuthority(parent)
{
}
@@ -81,7 +81,7 @@ JsonUIDAuthority::JsonUIDAuthority(QObject *parent)
Before a process can successfully connect to the server with
its user id must be added with this method if authorization is required.
*/
-bool JsonUIDAuthority::authorize(qint64 uid)
+bool QJsonUIDAuthority::authorize(qint64 uid)
{
if (m_nameForUid.contains(uid))
return false;
@@ -109,7 +109,7 @@ bool JsonUIDAuthority::authorize(qint64 uid)
Returns true if the name was found in the /etc/passwd file
and could be added.
*/
-bool JsonUIDAuthority::authorize(const QString& name)
+bool QJsonUIDAuthority::authorize(const QString& name)
{
errno = 0;
struct passwd *passwd = getpwnam(name.toLatin1().data());
@@ -132,7 +132,7 @@ bool JsonUIDAuthority::authorize(const QString& name)
Removes a user id \a uid from the list of authorized users.
Returns true if a process with a matching UID was found.
*/
-bool JsonUIDAuthority::deauthorize(qint64 uid)
+bool QJsonUIDAuthority::deauthorize(qint64 uid)
{
return m_nameForUid.remove(uid) != 0;
}
@@ -141,7 +141,7 @@ bool JsonUIDAuthority::deauthorize(qint64 uid)
Removes a user \a name from the list of authorized users.
Returns true if a process with a matching name was found.
*/
-bool JsonUIDAuthority::deauthorize(const QString& name)
+bool QJsonUIDAuthority::deauthorize(const QString& name)
{
QList<qint64> keylist = m_nameForUid.keys(name);
if (!keylist.length())
@@ -156,7 +156,7 @@ bool JsonUIDAuthority::deauthorize(const QString& name)
Return true if the \a uid is authorized.
*/
-bool JsonUIDAuthority::isAuthorized(qint64 uid) const
+bool QJsonUIDAuthority::isAuthorized(qint64 uid) const
{
return m_nameForUid.contains(uid);
}
@@ -166,7 +166,7 @@ bool JsonUIDAuthority::isAuthorized(qint64 uid) const
If no such name is authorized, returns an empty string.
*/
-QString JsonUIDAuthority::name(qint64 uid) const
+QString QJsonUIDAuthority::name(qint64 uid) const
{
return m_nameForUid.value(uid);
}
@@ -176,10 +176,10 @@ QString JsonUIDAuthority::name(qint64 uid) const
Returns an AuthorizationRecord.
*/
-AuthorizationRecord JsonUIDAuthority::clientConnected(JsonStream *stream)
+AuthorizationRecord QJsonUIDAuthority::clientConnected(QJsonStream *stream)
{
AuthorizationRecord authRecord;
- authRecord.state = JsonAuthority::StateNotAuthorized;
+ authRecord.state = QJsonAuthority::StateNotAuthorized;
if (!stream)
return authRecord;
@@ -223,16 +223,16 @@ AuthorizationRecord JsonUIDAuthority::clientConnected(JsonStream *stream)
/*!
Ignore any \a message received from \a stream.
*/
-AuthorizationRecord JsonUIDAuthority::messageReceived(JsonStream *stream,
+AuthorizationRecord QJsonUIDAuthority::messageReceived(QJsonStream *stream,
const QJsonObject &message)
{
Q_UNUSED(stream);
Q_UNUSED(message);
AuthorizationRecord authRecord;
- authRecord.state = JsonAuthority::StateNotAuthorized;
+ authRecord.state = QJsonAuthority::StateNotAuthorized;
return authRecord;
}
-#include "moc_jsonuidauthority.cpp"
+#include "moc_qjsonuidauthority.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonuidauthority.h b/src/jsonstream/qjsonuidauthority.h
index 3558a93..2323568 100644
--- a/src/jsonuidauthority.h
+++ b/src/jsonstream/qjsonuidauthority.h
@@ -45,16 +45,16 @@
#include <QHash>
#include <QLocalSocket>
-#include "jsonauthority.h"
-#include "jsonstream-global.h"
+#include "qjsonauthority.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT JsonUIDAuthority : public JsonAuthority
+class Q_ADDON_JSONSTREAM_EXPORT QJsonUIDAuthority : public QJsonAuthority
{
Q_OBJECT
public:
- JsonUIDAuthority(QObject *parent = 0);
+ QJsonUIDAuthority(QObject *parent = 0);
bool authorize(qint64 uid);
bool authorize(const QString& name);
@@ -65,8 +65,8 @@ public:
bool isAuthorized(qint64 uid) const;
QString name(qint64 uid) const;
- virtual AuthorizationRecord clientConnected(JsonStream *stream);
- virtual AuthorizationRecord messageReceived(JsonStream *stream, const QJsonObject &message);
+ virtual AuthorizationRecord clientConnected(QJsonStream *stream);
+ virtual AuthorizationRecord messageReceived(QJsonStream *stream, const QJsonObject &message);
private:
QHash<qint64, QString> m_nameForUid;
@@ -74,6 +74,6 @@ private:
QT_END_NAMESPACE_JSONSTREAM
-QT_JSONSTREAM_DECLARE_METATYPE_PTR(JsonUIDAuthority)
+QT_JSONSTREAM_DECLARE_METATYPE_PTR(QJsonUIDAuthority)
#endif // JSONUIDAUTHORITYPROVIDER_H
diff --git a/src/jsonuidrangeauthority.cpp b/src/jsonstream/qjsonuidrangeauthority.cpp
index da5b620..f65488f 100644
--- a/src/jsonuidrangeauthority.cpp
+++ b/src/jsonstream/qjsonuidrangeauthority.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "jsonuidrangeauthority.h"
-#include "jsonstream.h"
+#include "qjsonuidrangeauthority.h"
+#include "qjsonstream.h"
#include <errno.h>
#include <sys/socket.h>
@@ -54,17 +54,17 @@
QT_BEGIN_NAMESPACE_JSONSTREAM
/*!
- \class JsonUIDRangeAuthority
- \brief The JsonUIDRangeAuthority class authorizes clients that fall within a range of UID values.
+ \class QJsonUIDRangeAuthority
+ \brief The QJsonUIDRangeAuthority class authorizes clients that fall within a range of UID values.
- The JsonUIDRangeAuthority class authorizes Json client connections based on the user ID of the
+ The QJsonUIDRangeAuthority class authorizes QJson client connections based on the user ID of the
client. This user ID is read directly from the connected socket. The authorized range
is set with a minimum and maximum value. The range is inclusive; that is, to be authorized the client
must satisfy "minimum <= uid <= maximum". Initially the range is not set; you must set both
minimum and maximum, or all clients will be refused.
- The name returned by the JsonUIDRangeAuthority class is the name entry in the /etc/passwd
- database. If a name entry does not exist, the JsonUIDRangeAuthority class sets the name equal
+ The name returned by the QJsonUIDRangeAuthority class is the name entry in the /etc/passwd
+ database. If a name entry does not exist, the QJsonUIDRangeAuthority class sets the name equal
to the string form of the uid.
Please note that actual Posix uid_t values are unsigned integers. In theory this means that
@@ -72,21 +72,21 @@ QT_BEGIN_NAMESPACE_JSONSTREAM
*/
/*!
- \property JsonUIDRangeAuthority::minimum
+ \property QJsonUIDRangeAuthority::minimum
The minimum valid UID. This must be set to at least 0, or all connections will be refused.
*/
/*!
- \property JsonUIDRangeAuthority::maximum
+ \property QJsonUIDRangeAuthority::maximum
The maximum valid UID. This must be set to at least 0, or all connections will be refused.
*/
/*!
- Construct a JsonUIDRangeAuthority with optional \a parent.
+ Construct a QJsonUIDRangeAuthority with optional \a parent.
*/
-JsonUIDRangeAuthority::JsonUIDRangeAuthority(QObject *parent)
- : JsonAuthority(parent)
+QJsonUIDRangeAuthority::QJsonUIDRangeAuthority(QObject *parent)
+ : QJsonAuthority(parent)
, m_minimum(-1)
, m_maximum(-1)
{
@@ -96,7 +96,7 @@ JsonUIDRangeAuthority::JsonUIDRangeAuthority(QObject *parent)
Return the minimum value
*/
-int JsonUIDRangeAuthority::minimum() const
+int QJsonUIDRangeAuthority::minimum() const
{
return m_minimum;
}
@@ -105,7 +105,7 @@ int JsonUIDRangeAuthority::minimum() const
Set the minimum value to \a minimum.
*/
-void JsonUIDRangeAuthority::setMinimum(int minimum)
+void QJsonUIDRangeAuthority::setMinimum(int minimum)
{
if (m_minimum != minimum) {
m_minimum = minimum;
@@ -117,7 +117,7 @@ void JsonUIDRangeAuthority::setMinimum(int minimum)
Return the maximum value
*/
-int JsonUIDRangeAuthority::maximum() const
+int QJsonUIDRangeAuthority::maximum() const
{
return m_maximum;
}
@@ -126,7 +126,7 @@ int JsonUIDRangeAuthority::maximum() const
Set the maximum value to \a maximum.
*/
-void JsonUIDRangeAuthority::setMaximum(int maximum)
+void QJsonUIDRangeAuthority::setMaximum(int maximum)
{
if (m_maximum != maximum) {
m_maximum = maximum;
@@ -140,10 +140,10 @@ void JsonUIDRangeAuthority::setMaximum(int maximum)
Returns an AuthorizationRecord.
*/
-AuthorizationRecord JsonUIDRangeAuthority::clientConnected(JsonStream *stream)
+AuthorizationRecord QJsonUIDRangeAuthority::clientConnected(QJsonStream *stream)
{
AuthorizationRecord authRecord;
- authRecord.state = JsonAuthority::StateNotAuthorized;
+ authRecord.state = QJsonAuthority::StateNotAuthorized;
if (!stream)
return authRecord;
@@ -191,26 +191,26 @@ AuthorizationRecord JsonUIDRangeAuthority::clientConnected(JsonStream *stream)
/*!
Ignore any \a message received from \a stream.
*/
-AuthorizationRecord JsonUIDRangeAuthority::messageReceived(JsonStream *stream,
+AuthorizationRecord QJsonUIDRangeAuthority::messageReceived(QJsonStream *stream,
const QJsonObject &message)
{
Q_UNUSED(stream);
Q_UNUSED(message);
AuthorizationRecord authRecord;
- authRecord.state = JsonAuthority::StateNotAuthorized;
+ authRecord.state = QJsonAuthority::StateNotAuthorized;
return authRecord;
}
/*!
- \fn void JsonUIDRangeAuthority::minimumChanged()
+ \fn void QJsonUIDRangeAuthority::minimumChanged()
Signal emitted when the minimum value is changed.
*/
/*!
- \fn void JsonUIDRangeAuthority::maximumChanged()
+ \fn void QJsonUIDRangeAuthority::maximumChanged()
Signal emitted when the maximum value is changed.
*/
-#include "moc_jsonuidrangeauthority.cpp"
+#include "moc_qjsonuidrangeauthority.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/jsonuidrangeauthority.h b/src/jsonstream/qjsonuidrangeauthority.h
index 8bd139a..03541e6 100644
--- a/src/jsonuidrangeauthority.h
+++ b/src/jsonstream/qjsonuidrangeauthority.h
@@ -45,19 +45,19 @@
#include <QHash>
#include <QLocalSocket>
-#include "jsonauthority.h"
-#include "jsonstream-global.h"
+#include "qjsonauthority.h"
+#include "qjsonstream-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT JsonUIDRangeAuthority : public JsonAuthority
+class Q_ADDON_JSONSTREAM_EXPORT QJsonUIDRangeAuthority : public QJsonAuthority
{
Q_OBJECT
Q_PROPERTY(int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
public:
- JsonUIDRangeAuthority(QObject *parent = 0);
+ QJsonUIDRangeAuthority(QObject *parent = 0);
int minimum() const;
void setMinimum(int);
@@ -65,8 +65,8 @@ public:
int maximum() const;
void setMaximum(int);
- virtual AuthorizationRecord clientConnected(JsonStream *stream);
- virtual AuthorizationRecord messageReceived(JsonStream *stream, const QJsonObject &message);
+ virtual AuthorizationRecord clientConnected(QJsonStream *stream);
+ virtual AuthorizationRecord messageReceived(QJsonStream *stream, const QJsonObject &message);
signals:
void minimumChanged();
@@ -79,6 +79,6 @@ private:
QT_END_NAMESPACE_JSONSTREAM
-QT_JSONSTREAM_DECLARE_METATYPE_PTR(JsonUIDRangeAuthority)
+QT_JSONSTREAM_DECLARE_METATYPE_PTR(QJsonUIDRangeAuthority)
#endif // JSON_UID_RANGE_AUTHORITY_H
diff --git a/src/qtjsonschema/checkpoints_p.h b/src/jsonstream/qtjsonschema/checkpoints_p.h
index 67357bc..25bcbc1 100644
--- a/src/qtjsonschema/checkpoints_p.h
+++ b/src/jsonstream/qtjsonschema/checkpoints_p.h
@@ -53,7 +53,7 @@
QT_BEGIN_HEADER
-#include "schemaerror.h"
+#include "qjsonschemaerror.h"
QT_USE_NAMESPACE_JSONSTREAM
namespace SchemaValidation {
@@ -646,7 +646,7 @@ public:
m_min = minimum.toDouble(&ok);
if (!ok) {
- Check::m_schema->setLoadError("wrong 'minimum' value", minimum, SchemaError::SchemaWrongParamType);
+ Check::m_schema->setLoadError("wrong 'minimum' value", minimum, QJsonSchemaError::SchemaWrongParamType);
}
}
@@ -672,7 +672,7 @@ public:
m_max = maximum.toDouble(&ok);
if (!ok) {
- Check::m_schema->setLoadError("wrong 'maximum' value", maximum, SchemaError::SchemaWrongParamType);
+ Check::m_schema->setLoadError("wrong 'maximum' value", maximum, QJsonSchemaError::SchemaWrongParamType);
}
}
@@ -712,7 +712,7 @@ public:
}
if (!ok) {
- Check::m_schema->setLoadError("wrong 'exclusiveMinimum' value", _value, SchemaError::SchemaWrongParamType);
+ Check::m_schema->setLoadError("wrong 'exclusiveMinimum' value", _value, QJsonSchemaError::SchemaWrongParamType);
}
if (bExclusive) {
@@ -752,7 +752,7 @@ public:
}
if (!ok) {
- Check::m_schema->setLoadError("wrong 'exclusiveMaximum' value", _value, SchemaError::SchemaWrongParamType);
+ Check::m_schema->setLoadError("wrong 'exclusiveMaximum' value", _value, QJsonSchemaError::SchemaWrongParamType);
}
if (bExclusive) {
@@ -779,7 +779,7 @@ public:
m_min = minimum.toInt(&ok);
if (!ok) {
Check::m_schema->setLoadError("wrong 'minItems' value", minimum,
- SchemaError::SchemaWrongParamType);
+ QJsonSchemaError::SchemaWrongParamType);
}
}
@@ -804,7 +804,7 @@ public:
m_max = maximum.toInt(&ok);
if (!ok) {
Check::m_schema->setLoadError("wrong 'maxItems' value", maximum,
- SchemaError::SchemaWrongParamType);
+ QJsonSchemaError::SchemaWrongParamType);
}
}
@@ -831,7 +831,7 @@ public:
m_regexp.setPattern(patternString);
if (!ok || !m_regexp.isValid()) {
Check::m_schema->setLoadError("wrong 'pattern' value", patternValue,
- !ok ? SchemaError::SchemaWrongParamType : SchemaError::SchemaWrongParamValue);
+ !ok ? QJsonSchemaError::SchemaWrongParamType : QJsonSchemaError::SchemaWrongParamValue);
}
}
@@ -1063,7 +1063,7 @@ public:
if (!ok || m_div == 0)
Check::m_schema->setLoadError("wrong 'divisibleBy' value", value,
- !ok ? SchemaError::SchemaWrongParamType : SchemaError::SchemaWrongParamValue);
+ !ok ? QJsonSchemaError::SchemaWrongParamType : QJsonSchemaError::SchemaWrongParamValue);
}
virtual bool doCheck(const Value &value)
diff --git a/src/qtjsonschema/jsonobjecttypes_impl_p.h b/src/jsonstream/qtjsonschema/jsonobjecttypes_impl_p.h
index 052dac8..4ad031a 100644
--- a/src/qtjsonschema/jsonobjecttypes_impl_p.h
+++ b/src/jsonstream/qtjsonschema/jsonobjecttypes_impl_p.h
@@ -45,8 +45,8 @@
#include "jsonobjecttypes_p.h"
#include "schemamanager_p.h"
-#include "jsonschema-global.h"
-#include "schemaerror.h"
+#include "qjsonschema-global.h"
+#include "qjsonschemaerror.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
@@ -374,21 +374,21 @@ inline QJsonObject JsonObjectTypes::Service::error() const
inline void JsonObjectTypes::Service::setValidationError(const QString &message)
{
- m_errorMap.insert(SchemaError::kCodeStr, SchemaError::FailedSchemaValidation);
- m_errorMap.insert(SchemaError::kMessageStr, message);
+ m_errorMap.insert(QJsonSchemaError::kCodeStr, QJsonSchemaError::FailedSchemaValidation);
+ m_errorMap.insert(QJsonSchemaError::kMessageStr, message);
}
inline void JsonObjectTypes::Service::setLoadError(const QString &message)
{
- m_errorMap.insert(SchemaError::kCodeStr, SchemaError::InvalidSchemaLoading);
- m_errorMap.insert(SchemaError::kMessageStr, message);
+ m_errorMap.insert(QJsonSchemaError::kCodeStr, QJsonSchemaError::InvalidSchemaLoading);
+ m_errorMap.insert(QJsonSchemaError::kMessageStr, message);
}
inline void JsonObjectTypes::Service::setSubError(const QString &message, int errorCode)
{
QJsonObject error;
- error.insert(SchemaError::kCodeStr, errorCode);
- error.insert(SchemaError::kMessageStr, message);
+ error.insert(QJsonSchemaError::kCodeStr, errorCode);
+ error.insert(QJsonSchemaError::kMessageStr, message);
m_errorMap.insert(QString::number(m_errorMap.count()), error);
}
diff --git a/src/qtjsonschema/jsonobjecttypes_p.h b/src/jsonstream/qtjsonschema/jsonobjecttypes_p.h
index 6ee0097..4c1f474 100644
--- a/src/qtjsonschema/jsonobjecttypes_p.h
+++ b/src/jsonstream/qtjsonschema/jsonobjecttypes_p.h
@@ -48,7 +48,7 @@
#include <QJsonObject>
#include <QJsonArray>
-#include "jsonschema-global.h"
+#include "qjsonschema-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
diff --git a/src/qtjsonschema/jsonschema-global.h b/src/jsonstream/qtjsonschema/qjsonschema-global.h
index 7315c87..0621055 100644
--- a/src/qtjsonschema/jsonschema-global.h
+++ b/src/jsonstream/qtjsonschema/qjsonschema-global.h
@@ -41,6 +41,6 @@
#ifndef JSONSCHEMA_GLOBAL_H
#define JSONSCHEMA_GLOBAL_H
-#include "jsonstream-global.h"
+#include "qjsonstream-global.h"
#endif // JSONSCHEMA_GLOBAL_H
diff --git a/src/qtjsonschema/schemaerror.cpp b/src/jsonstream/qtjsonschema/qjsonschemaerror.cpp
index da5517a..1258657 100644
--- a/src/qtjsonschema/schemaerror.cpp
+++ b/src/jsonstream/qtjsonschema/qjsonschemaerror.cpp
@@ -39,22 +39,22 @@
**
****************************************************************************/
-#include "schemaerror.h"
+#include "qjsonschemaerror.h"
#include <QStringList>
#include <QDebug>
QT_BEGIN_NAMESPACE_JSONSTREAM
-const QString SchemaError::kCodeStr = QString::fromLatin1("::code");
-const QString SchemaError::kMessageStr = QString::fromLatin1("::message");
-const QString SchemaError::kSourceStr = QString::fromLatin1("::source");
-const QString SchemaError::kCounterStr = QString::fromLatin1("::count");
-const QString SchemaError::kErrorPrefixStr = QString::fromLatin1("::");
+const QString QJsonSchemaError::kCodeStr = QString::fromLatin1("::code");
+const QString QJsonSchemaError::kMessageStr = QString::fromLatin1("::message");
+const QString QJsonSchemaError::kSourceStr = QString::fromLatin1("::source");
+const QString QJsonSchemaError::kCounterStr = QString::fromLatin1("::count");
+const QString QJsonSchemaError::kErrorPrefixStr = QString::fromLatin1("::");
/*!
- \class SchemaError
- \brief The SchemaError class details error conditions from parsing or
+ \class QJsonSchemaError
+ \brief The QJsonSchemaError class details error conditions from parsing or
validating JSON objects and schemas.
The error object includes a code, human-readable message, and the JSON object
@@ -65,11 +65,11 @@ const QString SchemaError::kErrorPrefixStr = QString::fromLatin1("::");
multiple errors. In this case, each individual error can be found in
the subErrors() list.
- \sa SchemaError::ErrorCode
+ \sa QJsonSchemaError::ErrorCode
*/
/*!
- \enum SchemaError::ErrorCode
+ \enum QJsonSchemaError::ErrorCode
\omitvalue NoError
\value FailedSchemaValidation
JSON object failed schema validation
@@ -90,28 +90,28 @@ const QString SchemaError::kErrorPrefixStr = QString::fromLatin1("::");
*/
/*!
- \fn SchemaError::SchemaError()
+ \fn QJsonSchemaError::QJsonSchemaError()
Creates an empty schema error object.
*/
/*!
- \fn SchemaError::SchemaError(const QJsonObject & data)
+ \fn QJsonSchemaError::QJsonSchemaError(const QJsonObject & data)
Creates an schema error object pertaining to the JSON object \a data.
*/
/*!
- \fn QJsonObject SchemaError::object() const
+ \fn QJsonObject QJsonSchemaError::object() const
Returns the JSON object that the error pertains to. If the error is
the result of an attempt to load a schema, the object will be the schema object.
*/
/*!
- Creates SchemaError object with specified error \a code and \a message.
+ Creates QJsonSchemaError object with specified error \a code and \a message.
*/
-SchemaError::SchemaError(ErrorCode code, const QString & message)
+QJsonSchemaError::QJsonSchemaError(ErrorCode code, const QString & message)
{
m_data.insert(kCodeStr, code);
m_data.insert(kMessageStr, message);
@@ -120,15 +120,15 @@ SchemaError::SchemaError(ErrorCode code, const QString & message)
/*!
Returns an error code of the last schema error.
*/
-SchemaError::ErrorCode SchemaError::errorCode() const
+QJsonSchemaError::ErrorCode QJsonSchemaError::errorCode() const
{
- return m_data.isEmpty() ? SchemaError::NoError : (SchemaError::ErrorCode)(m_data.value(kCodeStr).toDouble());
+ return m_data.isEmpty() ? QJsonSchemaError::NoError : (QJsonSchemaError::ErrorCode)(m_data.value(kCodeStr).toDouble());
}
/*!
Returns a human readable description of the last schema error.
*/
-QString SchemaError::errorString() const
+QString QJsonSchemaError::errorString() const
{
return m_data.isEmpty() ? QString() : m_data.value(kMessageStr).toString();
}
@@ -138,7 +138,7 @@ QString SchemaError::errorString() const
or directory path. In the case where a schema or object is loaded directly from
data, this value will be empty.
*/
-QString SchemaError::errorSource() const
+QString QJsonSchemaError::errorSource() const
{
return m_data.isEmpty() ? QString() : m_data.value(kSourceStr).toString();
}
@@ -146,21 +146,21 @@ QString SchemaError::errorSource() const
/*!
Returns a list of sub errors.
*/
-QList<SchemaError> SchemaError::subErrors() const
+QList<QJsonSchemaError> QJsonSchemaError::subErrors() const
{
- QList<SchemaError> errors;
+ QList<QJsonSchemaError> errors;
foreach (QString key, m_data.keys()) {
if (!key.startsWith(kErrorPrefixStr)) {
QJsonObject object(m_data[key].toObject());
if (object.contains(kCodeStr))
- errors.append(SchemaError(object));
+ errors.append(QJsonSchemaError(object));
}
}
return errors;
}
-QDebug operator <<(QDebug dbg, const SchemaError &e)
+QDebug operator <<(QDebug dbg, const QJsonSchemaError &e)
{
dbg << "SchemaError(" << e.m_data << ")";
return dbg;
diff --git a/src/qtjsonschema/schemaerror.h b/src/jsonstream/qtjsonschema/qjsonschemaerror.h
index 185d742..9cc0b93 100644
--- a/src/qtjsonschema/schemaerror.h
+++ b/src/jsonstream/qtjsonschema/qjsonschemaerror.h
@@ -42,14 +42,14 @@
#ifndef SCHEMAERROR_H
#define SCHEMAERROR_H
-#include "jsonschema-global.h"
+#include "qjsonschema-global.h"
#include <QJsonObject>
#include <QList>
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT SchemaError
+class Q_ADDON_JSONSTREAM_EXPORT QJsonSchemaError
{
public:
enum ErrorCode {
@@ -66,15 +66,15 @@ public:
SchemaWrongParamValue
};
- SchemaError() {}
- SchemaError(const QJsonObject & _data) : m_data(_data) {}
- SchemaError(ErrorCode, const QString &);
+ QJsonSchemaError() {}
+ QJsonSchemaError(const QJsonObject & _data) : m_data(_data) {}
+ QJsonSchemaError(ErrorCode, const QString &);
ErrorCode errorCode() const;
QString errorString() const;
QString errorSource() const;
- QList<SchemaError> subErrors() const;
+ QList<QJsonSchemaError> subErrors() const;
QJsonObject object() const { return m_data; }
@@ -85,7 +85,7 @@ public:
static const QString kErrorPrefixStr;
private:
- friend Q_ADDON_JSONSTREAM_EXPORT QDebug operator<<(QDebug, const SchemaError &);
+ friend Q_ADDON_JSONSTREAM_EXPORT QDebug operator<<(QDebug, const QJsonSchemaError &);
QJsonObject m_data;
};
diff --git a/src/qtjsonschema/schemavalidator.cpp b/src/jsonstream/qtjsonschema/qjsonschemavalidator.cpp
index ebfd484..8cc3810 100644
--- a/src/qtjsonschema/schemavalidator.cpp
+++ b/src/jsonstream/qtjsonschema/qjsonschemavalidator.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "schemavalidator.h"
+#include "qjsonschemavalidator.h"
#include "schemamanager_p.h"
@@ -50,29 +50,29 @@
#include <QDir>
#include <QCoreApplication>
-#include "jsonschema-global.h"
+#include "qjsonschema-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
/*!
\internal
*/
-inline QJsonObject makeError(SchemaError::ErrorCode code, const QString &message)
+inline QJsonObject makeError(QJsonSchemaError::ErrorCode code, const QString &message)
{
- return SchemaError(code, message).object();
+ return QJsonSchemaError(code, message).object();
}
-class SchemaValidator::SchemaValidatorPrivate
+class QJsonSchemaValidator::QJsonSchemaValidatorPrivate
{
public:
- SchemaValidatorPrivate()
+ QJsonSchemaValidatorPrivate()
: m_bInit(false), m_matcher(0)
{
}
SchemaManager<QJsonObject, JsonObjectTypes> mSchemas;
- SchemaError mLastError;
+ QJsonSchemaError mLastError;
QRegExp m_filter;
bool m_bInit; // filtering & indexing status (false-todo, true-done)
@@ -82,11 +82,11 @@ public:
};
/*!
- \class SchemaValidator
+ \class QJsonSchemaValidator
- \brief The SchemaValidator class validates JSON objects against JSON schemas
+ \brief The QJsonSchemaValidator class validates JSON objects against JSON schemas
- SchemaValidator validates JSON objects against JSON schemas. Schemas are loaded
+ QJsonSchemaValidator validates JSON objects against JSON schemas. Schemas are loaded
individually from data (loadFromData()), from a file (loadFromFile())
or collectively (loadFromFolder()). Each schema is given a name, which is either
specified directly when loading, or derived from the filename of the schema file.
@@ -104,7 +104,7 @@ public:
*/
/*!
- \enum SchemaValidator::SchemaNameInitialization
+ \enum QJsonSchemaValidator::SchemaNameInitialization
Specifies how the schema loading methods should name each loaded schema.
@@ -118,10 +118,10 @@ public:
*/
/*!
- Creates a new SchemaValidator with optional \a parent.
+ Creates a new QJsonSchemaValidator with optional \a parent.
*/
-SchemaValidator::SchemaValidator(QObject *parent) :
- QObject(parent), d_ptr(new SchemaValidatorPrivate)
+QJsonSchemaValidator::QJsonSchemaValidator(QObject *parent) :
+ QObject(parent), d_ptr(new QJsonSchemaValidatorPrivate)
{
}
@@ -129,7 +129,7 @@ SchemaValidator::SchemaValidator(QObject *parent) :
\internal
*/
-SchemaValidator::~SchemaValidator()
+QJsonSchemaValidator::~QJsonSchemaValidator()
{
delete d_ptr;
}
@@ -140,7 +140,7 @@ SchemaValidator::~SchemaValidator()
\sa loadFromData(), loadFromFile(), loadFromFolder(), validateSchema()
*/
-SchemaError SchemaValidator::getLastError() const
+QJsonSchemaError QJsonSchemaValidator::getLastError() const
{
return d_ptr->mLastError;
}
@@ -148,7 +148,7 @@ SchemaError SchemaValidator::getLastError() const
/*!
Returns true if no schemas have been loaded into the validator, false otherwise.
*/
-bool SchemaValidator::isEmpty() const
+bool QJsonSchemaValidator::isEmpty() const
{
return d_ptr->mSchemas.isEmpty();
}
@@ -156,7 +156,7 @@ bool SchemaValidator::isEmpty() const
/*!
Returns a list of names of schemas which have been loaded into the validator.
*/
-QStringList SchemaValidator::schemaNames() const
+QStringList QJsonSchemaValidator::schemaNames() const
{
return d_ptr->mSchemas.names();
}
@@ -164,7 +164,7 @@ QStringList SchemaValidator::schemaNames() const
/*!
Returns true if this validator has a schema with the given \a name.
*/
-bool SchemaValidator::hasSchema(const QString & name)
+bool QJsonSchemaValidator::hasSchema(const QString & name)
{
return d_ptr->mSchemas.contains(name);
}
@@ -172,7 +172,7 @@ bool SchemaValidator::hasSchema(const QString & name)
/*!
Removes the schema with the given \a name from this validator.
*/
-void SchemaValidator::removeSchema(const QString & name)
+void QJsonSchemaValidator::removeSchema(const QString & name)
{
d_ptr->mSchemas.take(name);
d_ptr->m_bInit = false; // clear last filtering & indexing results
@@ -181,7 +181,7 @@ void SchemaValidator::removeSchema(const QString & name)
/*!
Removes all schemas from the validator.
*/
-void SchemaValidator::clear()
+void QJsonSchemaValidator::clear()
{
d_ptr->mSchemas.clear();
}
@@ -190,7 +190,7 @@ void SchemaValidator::clear()
Limits the schemas which will be used when validating an object to those
whose name matches \a filter. To use all schemas, set an empty filter.
*/
-void SchemaValidator::setValidationFilter(const QRegExp &filter)
+void QJsonSchemaValidator::setValidationFilter(const QRegExp &filter)
{
d_ptr->m_filter = filter;
d_ptr->m_bInit = false; // clear last filtering & indexing results
@@ -202,7 +202,7 @@ void SchemaValidator::setValidationFilter(const QRegExp &filter)
schemas that need to be checked, so that most of the time only one schema is checked
for a valid object.
*/
-void SchemaValidator::setSchemaNameMatcher(const SchemaNameMatcher &matcher)
+void QJsonSchemaValidator::setSchemaNameMatcher(const SchemaNameMatcher &matcher)
{
d_ptr->m_matcher = QSharedPointer<SchemaNameMatcher>(matcher.clone());
d_ptr->m_bInit = false; // clear last filtering & indexing results
@@ -218,12 +218,12 @@ void SchemaValidator::setSchemaNameMatcher(const SchemaNameMatcher &matcher)
Returns true if all schema files were loaded successfully, or false otherwise. Schema
loading error information can be retrieved using getLastError().
*/
-bool SchemaValidator::loadFromFolder(const QString & path, const QString & schemaNameProperty, const QByteArray & ext/*= "json"*/)
+bool QJsonSchemaValidator::loadFromFolder(const QString & path, const QString & schemaNameProperty, const QByteArray & ext/*= "json"*/)
{
- Q_D(SchemaValidator);
+ Q_D(QJsonSchemaValidator);
d->mLastError = _loadFromFolder(path, schemaNameProperty, ext);
d_ptr->m_bInit = false; // clear last filtering & indexing results
- return SchemaError::NoError == d->mLastError.errorCode();
+ return QJsonSchemaError::NoError == d->mLastError.errorCode();
}
/*!
@@ -236,12 +236,12 @@ bool SchemaValidator::loadFromFolder(const QString & path, const QString & schem
Returns true if the schema file was loaded successfully, or false otherwise. Schema
loading error information can be retrieved using getLastError().
*/
-bool SchemaValidator::loadFromFile(const QString &filename, SchemaNameInitialization type, const QString & schemaName)
+bool QJsonSchemaValidator::loadFromFile(const QString &filename, SchemaNameInitialization type, const QString & schemaName)
{
- Q_D(SchemaValidator);
+ Q_D(QJsonSchemaValidator);
d->mLastError = _loadFromFile(filename, type, schemaName);
d_ptr->m_bInit = false; // clear last filtering & indexing results
- return SchemaError::NoError == d->mLastError.errorCode();
+ return QJsonSchemaError::NoError == d->mLastError.errorCode();
}
/*!
@@ -253,12 +253,12 @@ bool SchemaValidator::loadFromFile(const QString &filename, SchemaNameInitializa
Returns true if the schema was loaded successfully, or false otherwise. Schema
loading error information can be retrieved using getLastError().
*/
-bool SchemaValidator::loadFromData(const QByteArray & json, const QString & name, SchemaNameInitialization type)
+bool QJsonSchemaValidator::loadFromData(const QByteArray & json, const QString & name, SchemaNameInitialization type)
{
- Q_D(SchemaValidator);
+ Q_D(QJsonSchemaValidator);
d->mLastError = _loadFromData(json, name, type);
d_ptr->m_bInit = false; // clear last filtering & indexing results
- return SchemaError::NoError == d->mLastError.errorCode();
+ return QJsonSchemaError::NoError == d->mLastError.errorCode();
}
/*!
@@ -269,7 +269,7 @@ bool SchemaValidator::loadFromData(const QByteArray & json, const QString & name
from \a schemaNameProperty property in JSON object.
Returns empty variant map at success or a map filled with error information otherwise
*/
-QJsonObject SchemaValidator::_loadFromFolder(const QString & path, const QString & schemaNameProperty, const QByteArray & ext/*= "json"*/)
+QJsonObject QJsonSchemaValidator::_loadFromFolder(const QString & path, const QString & schemaNameProperty, const QByteArray & ext/*= "json"*/)
{
QJsonObject ret;
QDir dir(!path.isEmpty() ? path : QDir::currentPath());
@@ -308,27 +308,27 @@ QJsonObject SchemaValidator::_loadFromFolder(const QString & path, const QString
if (!ret.isEmpty()) // loading errors
{
int nFailed = ret.count();
- ret.insert(SchemaError::kCodeStr, SchemaError::InvalidSchemaLoading);
- ret.insert(SchemaError::kMessageStr,
+ ret.insert(QJsonSchemaError::kCodeStr, QJsonSchemaError::InvalidSchemaLoading);
+ ret.insert(QJsonSchemaError::kMessageStr,
QString::fromLatin1("Loading failed for %1 schemas. %2 schemas are loaded successfully.").arg(nFailed).arg(nLoaded));
if (nLoaded)
- ret.insert(SchemaError::kCounterStr, nLoaded);
+ ret.insert(QJsonSchemaError::kCounterStr, nLoaded);
}
else if (!nLoaded) // no schemas were found
{
- ret = makeError(SchemaError::InvalidSchemaLoading,
+ ret = makeError(QJsonSchemaError::InvalidSchemaLoading,
QString::fromLatin1("Folder '%1' does not contain any schema.").arg(dir.path()));
}
}
else
{
- ret = makeError(SchemaError::InvalidSchemaFolder,
+ ret = makeError(QJsonSchemaError::InvalidSchemaFolder,
QString::fromLatin1("Folder '%1' does not exist.").arg(dir.path()));
}
if (!ret.isEmpty())
- ret.insert(SchemaError::kSourceStr, dir.path());
+ ret.insert(QJsonSchemaError::kSourceStr, dir.path());
return ret;
}
@@ -338,7 +338,7 @@ QJsonObject SchemaValidator::_loadFromFolder(const QString & path, const QString
Supplements a validator object with data from \a filename schema file, using \a type and \a schemaName.
Returns empty variant map at success or a map filled with error information otherwise
*/
-QJsonObject SchemaValidator::_loadFromFile(const QString &filename, SchemaNameInitialization type, const QString & shemaName)
+QJsonObject QJsonSchemaValidator::_loadFromFile(const QString &filename, SchemaNameInitialization type, const QString & shemaName)
{
QJsonObject ret;
if (!filename.isEmpty())
@@ -360,16 +360,16 @@ QJsonObject SchemaValidator::_loadFromFile(const QString &filename, SchemaNameIn
}
else
{ // file open error
- ret = makeError(SchemaError::FailedSchemaFileOpenRead,
+ ret = makeError(QJsonSchemaError::FailedSchemaFileOpenRead,
QString::fromLatin1("Can't open/read '%1' schema file.").arg(schemaFile.fileName()));
}
if (!ret.isEmpty())
- ret.insert(SchemaError::kSourceStr, schemaFile.fileName());
+ ret.insert(QJsonSchemaError::kSourceStr, schemaFile.fileName());
}
else
{
- ret = makeError(SchemaError::FailedSchemaFileOpenRead, QStringLiteral("Filename is empty"));
+ ret = makeError(QJsonSchemaError::FailedSchemaFileOpenRead, QStringLiteral("Filename is empty"));
}
return ret;
}
@@ -379,7 +379,7 @@ QJsonObject SchemaValidator::_loadFromFile(const QString &filename, SchemaNameIn
Supplements a validator object from a QByteArray \a json matching \a name and using \a type.
Returns empty variant map at success or a map filled with error information otherwise
*/
-QJsonObject SchemaValidator::_loadFromData(const QByteArray & json, const QString & name, SchemaNameInitialization type)
+QJsonObject QJsonSchemaValidator::_loadFromData(const QByteArray & json, const QString & name, SchemaNameInitialization type)
{
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(json, &err );
@@ -398,7 +398,7 @@ QJsonObject SchemaValidator::_loadFromData(const QByteArray & json, const QStrin
QString str;
str = QString::fromLatin1("JSON syntax error %1 in line %2 position %3").arg(err.error).arg(nLine).arg(nPos);
- return makeError(SchemaError::InvalidObject, str);
+ return makeError(QJsonSchemaError::InvalidObject, str);
}
QJsonObject schemaObject = doc.object();
@@ -408,7 +408,7 @@ QJsonObject SchemaValidator::_loadFromData(const QByteArray & json, const QStrin
if (doc.isNull() || schemaObject.isEmpty())
{
- return makeError(SchemaError::InvalidObject, QStringLiteral("schema data can not be empty"));
+ return makeError(QJsonSchemaError::InvalidObject, QStringLiteral("schema data can not be empty"));
}
QJsonObject ret;
@@ -425,7 +425,7 @@ QJsonObject SchemaValidator::_loadFromData(const QByteArray & json, const QStrin
else if (!name.isEmpty())
{
// property containing schema name is absent
- return makeError(SchemaError::InvalidSchemaOperation,
+ return makeError(QJsonSchemaError::InvalidSchemaOperation,
QString::fromLatin1("name property '%1' must be present").arg(name));
}
@@ -437,7 +437,7 @@ QJsonObject SchemaValidator::_loadFromData(const QByteArray & json, const QStrin
else
{
// no schema type
- ret = makeError(SchemaError::InvalidSchemaOperation,
+ ret = makeError(QJsonSchemaError::InvalidSchemaOperation,
QStringLiteral("schema name is missing"));
}
return ret;
@@ -448,11 +448,11 @@ QJsonObject SchemaValidator::_loadFromData(const QByteArray & json, const QStrin
Returns true if the object was validated successfully, or false otherwise.
Validation error information can be retrieved using getLastError().
*/
-bool SchemaValidator::validateSchema(const QString &schemaName, const QJsonObject &object)
+bool QJsonSchemaValidator::validateSchema(const QString &schemaName, const QJsonObject &object)
{
- Q_D(SchemaValidator);
+ Q_D(QJsonSchemaValidator);
d->mLastError = d->mSchemas.validate(schemaName, object);
- return SchemaError::NoError == d->mLastError.errorCode();
+ return QJsonSchemaError::NoError == d->mLastError.errorCode();
}
/*!
@@ -460,9 +460,9 @@ bool SchemaValidator::validateSchema(const QString &schemaName, const QJsonObjec
Returns true if the object was validated successfully, or false otherwise.
Validation error information can be retrieved using getLastError().
*/
-bool SchemaValidator::validateSchema(const QJsonObject &object)
+bool QJsonSchemaValidator::validateSchema(const QJsonObject &object)
{
- Q_D(SchemaValidator);
+ Q_D(QJsonSchemaValidator);
//qDebug() << "VALIDATE: " << object;
// do filtering & indexing initialization only once
@@ -522,7 +522,7 @@ bool SchemaValidator::validateSchema(const QJsonObject &object)
/*!
\internal
*/
-QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject schema)
+QJsonObject QJsonSchemaValidator::setSchema(const QString &schemaName, QJsonObject schema)
{
QJsonObject ret = d_ptr->mSchemas.insert(schemaName, schema);
//qDebug() << "setSchema::errors: " << ret;
@@ -530,9 +530,9 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
}
/*!
- \class SchemaValidator::SchemaNameMatcher
+ \class QJsonSchemaValidator::SchemaNameMatcher
\brief The SchemaNameMatcher class is an abstract class that provides schema matching
- functionality to a SchemaValidator object.
+ functionality to a QJsonSchemaValidator object.
Without schema matching, validating a JSON object involves possibly checking
every single schema until one matches. Schema matching allows the validator to
@@ -544,11 +544,11 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
returns any other schemas that may match a given JSON object. These schemas will
then be checked.
- \sa SchemaValidator::setSchemaNameMatcher()
+ \sa QJsonSchemaValidator::setSchemaNameMatcher()
*/
/*!
- \fn SchemaValidator::SchemaNameMatcher::SchemaNameMatcher(bool _bCanIndex)
+ \fn QJsonSchemaValidator::SchemaNameMatcher::SchemaNameMatcher(bool _bCanIndex)
Constructs a SchemaNameMatcher object.
\a _bCanIndex specifies whether this matcher object can index schemas for faster
@@ -559,19 +559,19 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
*/
/*!
- \fn SchemaValidator::SchemaNameMatcher::~SchemaNameMatcher()
+ \fn QJsonSchemaValidator::SchemaNameMatcher::~SchemaNameMatcher()
Deletes the \c SchemaNameMatcher object
*/
/*!
- \fn SchemaNameMatcher *SchemaValidator::SchemaNameMatcher::clone() const
+ \fn SchemaNameMatcher *QJsonSchemaValidator::SchemaNameMatcher::clone() const
Creates a copy of the \c SchemaNameMatcher object.
*/
/*!
- \fn bool SchemaValidator::SchemaNameMatcher::canIndex() const
+ \fn bool QJsonSchemaValidator::SchemaNameMatcher::canIndex() const
Returns true if the schema matcher can index schemas for faster
matching by invoking createIndex() for each available schema.
@@ -580,24 +580,24 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
*/
/*!
- \fn void SchemaValidator::SchemaNameMatcher::createIndex(const QString &schemaName, const QJsonObject &schema)
+ \fn void QJsonSchemaValidator::SchemaNameMatcher::createIndex(const QString &schemaName, const QJsonObject &schema)
This method should create an internal index for a \a schema named \a schemaName
so that later calls to getExactMatches() and getPossibleMatches() can complete faster.
*/
/*!
- \fn QStringList SchemaValidator::SchemaNameMatcher::getExactMatches(const QJsonObject &object)
+ \fn QStringList QJsonSchemaValidator::SchemaNameMatcher::getExactMatches(const QJsonObject &object)
Returns a list of names for the schemas that exactly match the specified \a object and can be used
- for its validation. Knowing exact schema name allows the SchemaValidator to optimize validation
+ for its validation. Knowing exact schema name allows the QJsonSchemaValidator to optimize validation
by checking the most likely matching schemas first.
\sa getPossibleMatches()
*/
/*!
- \fn QStringList SchemaValidator::SchemaNameMatcher::getPossibleMatches(const QJsonObject &object)
+ \fn QStringList QJsonSchemaValidator::SchemaNameMatcher::getPossibleMatches(const QJsonObject &object)
Returns a list of names for the schemas that could match the specified \a object and can be used
for its validation if validation using exact schema matches fails.
@@ -606,14 +606,14 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
*/
/*!
- \fn void SchemaValidator::SchemaNameMatcher::reset()
+ \fn void QJsonSchemaValidator::SchemaNameMatcher::reset()
Resets the object to initial state. This method is called every time a schema is added or removed
- from SchemaValidator object.
+ from QJsonSchemaValidator object.
*/
/*!
- \class SchemaValidator::SchemaPropertyNameMatcher
+ \class QJsonSchemaValidator::SchemaPropertyNameMatcher
\brief The SchemaPropertyNameMatcher class implements a name matcher for the case when
a property in the JSON object contains the name of a schema that should be used to
@@ -638,28 +638,28 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
*/
/*!
- \fn SchemaValidator::SchemaPropertyNameMatcher::SchemaPropertyNameMatcher(const QString & property)
+ \fn QJsonSchemaValidator::SchemaPropertyNameMatcher::SchemaPropertyNameMatcher(const QString & property)
Constructs a SchemaPropertyNameMatcher object where \a property specifies a property
in a JSON object that contains a schema name that should be used to validate the object.
*/
/*!
- \fn SchemaNameMatcher *SchemaValidator::SchemaPropertyNameMatcher::clone() const
+ \fn SchemaNameMatcher *QJsonSchemaValidator::SchemaPropertyNameMatcher::clone() const
Creates a copy of the \c SchemaPropertyNameMatcher object.
*/
/*!
- \fn QStringList SchemaValidator::SchemaPropertyNameMatcher::getExactMatches(const QJsonObject &object)
+ \fn QStringList QJsonSchemaValidator::SchemaPropertyNameMatcher::getExactMatches(const QJsonObject &object)
Returns a list of names for the schemas that exactly match the specified \a object and can be used
- for its validation. Knowing exact schema name allows the SchemaValidator to optimize validation
+ for its validation. Knowing exact schema name allows the QJsonSchemaValidator to optimize validation
by checking the most likely matching schemas first.
*/
/*!
- \class SchemaValidator::SchemaUniqueKeyNameMatcher
+ \class QJsonSchemaValidator::SchemaUniqueKeyNameMatcher
\brief The SchemaUniqueKeyNameMatcher class implements a schema name matcher for
the case where schemas contains a uniquely defined top-level key/property pairs
@@ -687,7 +687,7 @@ QJsonObject SchemaValidator::setSchema(const QString &schemaName, QJsonObject sc
will cause an exact match.
*/
-class SchemaValidator::SchemaUniqueKeyNameMatcher::SchemaUniqueKeyNameMatcherPrivate
+class QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::SchemaUniqueKeyNameMatcherPrivate
{
public:
QHash<QString,QStringList> m_items;
@@ -700,7 +700,7 @@ public:
for exact matching schemas.
*/
-SchemaValidator::SchemaUniqueKeyNameMatcher::SchemaUniqueKeyNameMatcher(const QString & key)
+QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::SchemaUniqueKeyNameMatcher(const QString & key)
: SchemaNameMatcher(true)
, m_key(key)
, d_ptr(new SchemaUniqueKeyNameMatcherPrivate)
@@ -711,14 +711,14 @@ SchemaValidator::SchemaUniqueKeyNameMatcher::SchemaUniqueKeyNameMatcher(const QS
Deletes the \c SchemaUniqueKeyNameMatcher object
*/
-SchemaValidator::SchemaUniqueKeyNameMatcher::~SchemaUniqueKeyNameMatcher()
+QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::~SchemaUniqueKeyNameMatcher()
{
if (d_ptr)
delete d_ptr;
}
/*!
- \fn SchemaNameMatcher *SchemaValidator::SchemaUniqueKeyNameMatcher::clone() const
+ \fn SchemaNameMatcher *QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::clone() const
Creates a copy of the \c SchemaUniqueKeyNameMatcher object.
*/
@@ -728,7 +728,7 @@ SchemaValidator::SchemaUniqueKeyNameMatcher::~SchemaUniqueKeyNameMatcher()
getExactMatches() and getPossibleMatches() can complete faster.
*/
-void SchemaValidator::SchemaUniqueKeyNameMatcher::createIndex(const QString &schemaName, const QJsonObject & schema)
+void QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::createIndex(const QString &schemaName, const QJsonObject & schema)
{
if (schema.contains(QStringLiteral("properties"))) {
QJsonValue props = schema[QStringLiteral("properties")];
@@ -758,13 +758,13 @@ void SchemaValidator::SchemaUniqueKeyNameMatcher::createIndex(const QString &sch
/*!
Returns a list of names for the schemas that exactly match the specified \a object and can be used
- for its validation. Knowing exact schema name allows the SchemaValidator to optimize validation
+ for its validation. Knowing exact schema name allows the QJsonSchemaValidator to optimize validation
by checking the most likely matching schemas first.
\sa getPossibleMatches()
*/
-QStringList SchemaValidator::SchemaUniqueKeyNameMatcher::getExactMatches(const QJsonObject &object)
+QStringList QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::getExactMatches(const QJsonObject &object)
{
QString str(!m_key.isEmpty() && object.contains(m_key) ? object[m_key].toString() : QString::null);
QHash<QString,QStringList>::const_iterator it;
@@ -778,7 +778,7 @@ QStringList SchemaValidator::SchemaUniqueKeyNameMatcher::getExactMatches(const Q
\sa getExactMatches()
*/
-QStringList SchemaValidator::SchemaUniqueKeyNameMatcher::getPossibleMatches(const QJsonObject &object)
+QStringList QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::getPossibleMatches(const QJsonObject &object)
{
Q_UNUSED(object);
return d_ptr->m_others;
@@ -786,15 +786,15 @@ QStringList SchemaValidator::SchemaUniqueKeyNameMatcher::getPossibleMatches(cons
/*!
Resets the object to initial state. This method is called every time a schema is added or removed
- from SchemaValidator object.
+ from QJsonSchemaValidator object.
*/
-void SchemaValidator::SchemaUniqueKeyNameMatcher::reset()
+void QJsonSchemaValidator::SchemaUniqueKeyNameMatcher::reset()
{
d_ptr->m_items.clear();
d_ptr->m_others.clear();
}
-#include "moc_schemavalidator.cpp"
+#include "moc_qjsonschemavalidator.cpp"
QT_END_NAMESPACE_JSONSTREAM
diff --git a/src/qtjsonschema/schemavalidator.h b/src/jsonstream/qtjsonschema/qjsonschemavalidator.h
index a04d01a..188dac8 100644
--- a/src/qtjsonschema/schemavalidator.h
+++ b/src/jsonstream/qtjsonschema/qjsonschemavalidator.h
@@ -45,17 +45,17 @@
#include <QRegExp>
#include <QStringList>
-#include "jsonschema-global.h"
-#include "schemaerror.h"
+#include "qjsonschema-global.h"
+#include "qjsonschemaerror.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
-class Q_ADDON_JSONSTREAM_EXPORT SchemaValidator : public QObject
+class Q_ADDON_JSONSTREAM_EXPORT QJsonSchemaValidator : public QObject
{
Q_OBJECT
public:
- explicit SchemaValidator(QObject *parent = 0);
- ~SchemaValidator();
+ explicit QJsonSchemaValidator(QObject *parent = 0);
+ ~QJsonSchemaValidator();
enum SchemaNameInitialization
{
@@ -71,7 +71,7 @@ public:
bool validateSchema(const QString &schemaName, const QJsonObject &object);
bool validateSchema(const QJsonObject &object);
- SchemaError getLastError() const;
+ QJsonSchemaError getLastError() const;
bool isEmpty() const;
QStringList schemaNames() const;
@@ -99,9 +99,9 @@ private:
QJsonObject _loadFromData(const QByteArray &, const QString &, SchemaNameInitialization = UseParameter);
private:
- class SchemaValidatorPrivate;
- SchemaValidatorPrivate * const d_ptr;
- Q_DECLARE_PRIVATE(SchemaValidator);
+ class QJsonSchemaValidatorPrivate;
+ QJsonSchemaValidatorPrivate * const d_ptr;
+ Q_DECLARE_PRIVATE(QJsonSchemaValidator);
public:
// helper classes
diff --git a/src/qtjsonschema/schemamanager_impl_p.h b/src/jsonstream/qtjsonschema/schemamanager_impl_p.h
index d779f35..3ea5ae7 100644
--- a/src/qtjsonschema/schemamanager_impl_p.h
+++ b/src/jsonstream/qtjsonschema/schemamanager_impl_p.h
@@ -43,7 +43,7 @@
#include "schemamanager_p.h"
#include "schemaobject_p.h"
-#include "jsonschema-global.h"
+#include "qjsonschema-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
diff --git a/src/qtjsonschema/schemamanager_p.h b/src/jsonstream/qtjsonschema/schemamanager_p.h
index 6150c22..41a668a 100644
--- a/src/qtjsonschema/schemamanager_p.h
+++ b/src/jsonstream/qtjsonschema/schemamanager_p.h
@@ -46,7 +46,7 @@
#include "schemaobject_p.h"
-#include "jsonschema-global.h"
+#include "qjsonschema-global.h"
QT_BEGIN_NAMESPACE_JSONSTREAM
diff --git a/src/qtjsonschema/schemaobject_p.h b/src/jsonstream/qtjsonschema/schemaobject_p.h
index 6e89dd8..6e89dd8 100644
--- a/src/qtjsonschema/schemaobject_p.h
+++ b/src/jsonstream/qtjsonschema/schemaobject_p.h
diff --git a/src/src.pro b/src/src.pro
index 7f8d52d..718f7db 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,89 +1,3 @@
-TEMPLATE = lib
-TARGET = $$QT.jsonstream.name
-MODULE = jsonstream
+TEMPLATE = subdirs
-load(qt_module)
-load(qt_module_config)
-
-DESTDIR = $$QT.jsonstream.libs
-VERSION = $$QT.jsonstream.VERSION
-DEFINES += QT_ADDON_JSONSTREAM_LIB
-
-QT += core network
-QT -= gui
-
-CONFIG += module create_prl
-MODULE_PRI = ../modules/qt_jsonstream.pri
-
-HEADERS += qtaddonjsonstreamversion.h
-
-unix:!mac {
- PUBLIC_HEADERS += $$PWD/jsonpidauthority.h
- SOURCES += $$PWD/jsonpidauthority.cpp
-}
-
-BSON_HEADERS = \
- $$PWD/bson/bson_p.h \
- $$PWD/bson/platform_hacks_p.h \
- $$PWD/bson/qt-bson_p.h
-
-SCHEMA_PUBLIC_HEADERS = \
- $$PWD/qtjsonschema/jsonschema-global.h \
- $$PWD/qtjsonschema/schemaerror.h \
- $$PWD/qtjsonschema/schemavalidator.h
-
-SCHEMA_HEADERS = \
- $$PWD/qtjsonschema/schemaobject_p.h \
- $$PWD/qtjsonschema/checkpoints_p.h \
- $$PWD/qtjsonschema/schemamanager_impl_p.h \
- $$PWD/qtjsonschema/schemamanager_p.h \
- $$PWD/qtjsonschema/jsonobjecttypes_p.h \
- $$PWD/qtjsonschema/jsonobjecttypes_impl_p.h
-
-SCHEMA_SOURCES = \
- $$PWD/qtjsonschema/schemaerror.cpp \
- $$PWD/qtjsonschema/schemavalidator.cpp
-
-PUBLIC_HEADERS += \
- $$PWD/jsonstream.h \
- $$PWD/jsonclient.h \
- $$PWD/jsonauthority.h \
- $$PWD/jsontokenauthority.h \
- $$PWD/jsonuidauthority.h \
- $$PWD/jsonuidrangeauthority.h \
- $$PWD/jsonserver.h \
- $$PWD/jsonstream-global.h \
- $$PWD/jsonserverclient.h \
- $$PWD/jsonpipe.h \
- $$PWD/jsonconnection.h \
- $$PWD/jsonendpoint.h \
- $$SCHEMA_PUBLIC_HEADERS
-
-HEADERS += \
- $$PWD/jsonbuffer_p.h \
- $$PWD/jsonconnectionprocessor_p.h \
- $$PWD/jsonendpointmanager_p.h \
- $$BSON_HEADERS \
- $$PUBLIC_HEADERS \
- $$SCHEMA_HEADERS
-
-SOURCES += \
- $$PWD/jsonstream.cpp \
- $$PWD/jsonbuffer.cpp \
- $$PWD/bson/bson.cpp \
- $$PWD/bson/qt-bson.cpp \
- $$PWD/jsonclient.cpp \
- $$PWD/jsonauthority.cpp \
- $$PWD/jsontokenauthority.cpp \
- $$PWD/jsonuidauthority.cpp \
- $$PWD/jsonuidrangeauthority.cpp \
- $$PWD/jsonserverclient.cpp \
- $$PWD/jsonserver.cpp \
- $$PWD/jsonpipe.cpp \
- $$PWD/jsonconnection.cpp \
- $$PWD/jsonconnectionprocessor.cpp \
- $$PWD/jsonendpoint.cpp \
- $$PWD/jsonendpointmanager.cpp \
- $$SCHEMA_SOURCES \
-
-mac:QMAKE_FRAMEWORK_BUNDLE_NAME = $$QT.jsonstream.name
+SUBDIRS = jsonstream
diff --git a/sync.profile b/sync.profile
index 6dc68e5..e7550c5 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,5 +1,5 @@
%modules = ( # path to module name map
- "QtAddOnJsonStream" => "$basedir/src",
+ "QtAddOnJsonStream" => "$basedir/src/jsonstream",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
);
@@ -10,9 +10,6 @@
"core" => "#include <QtCore/QtCore>\n",
"network" => "#include <QtNetwork/QtNetwork>\n",
);
-%modulepris = (
- "QtAddOnJsonStream" => "$basedir/modules/qt_jsonstream.pri",
-);
# Module dependencies.
# Every module that is required to build this module should have one entry.
# Each of the module version specifiers can take one of the following values:
@@ -20,5 +17,5 @@
# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
#
%dependencies = (
- "qtbase" => "refs/heads/master",
+ "qtbase" => "refs/heads/stable",
);
diff --git a/tests/auto/jsonbuffer/tst_jsonbuffer.cpp b/tests/auto/jsonbuffer/tst_jsonbuffer.cpp
index 13acf64..dd6c966 100644
--- a/tests/auto/jsonbuffer/tst_jsonbuffer.cpp
+++ b/tests/auto/jsonbuffer/tst_jsonbuffer.cpp
@@ -41,7 +41,7 @@
#include <QtTest>
-#include "private/jsonbuffer_p.h"
+#include "private/qjsonbuffer_p.h"
QT_USE_NAMESPACE_JSONSTREAM
@@ -67,7 +67,7 @@ void tst_JsonBuffer::utf8()
{
int n = sizeof(utf8spaces) / sizeof(utf8spaces[0]);
for (int i = 0 ; i < n ; i++ ) {
- JsonBuffer buf;
+ QJsonBuffer buf;
buf.append(utf8spaces[i], strlen(utf8spaces[i]));
QVERIFY(buf.messageAvailable());
@@ -103,7 +103,7 @@ PartialData utf8packets[] = { { "{\"a\":123.0", 0, 0 },
void tst_JsonBuffer::utf8extend()
{
- JsonBuffer buf;
+ QJsonBuffer buf;
int n = sizeof(utf8packets) / sizeof(utf8packets[0]);
for (int i = 0 ; i < n ; i++ ) {
PartialData& d = utf8packets[i];
diff --git a/tests/auto/jsonconnection/testClient/main.cpp b/tests/auto/jsonconnection/testClient/main.cpp
index a0afa0b..3cc19eb 100644
--- a/tests/auto/jsonconnection/testClient/main.cpp
+++ b/tests/auto/jsonconnection/testClient/main.cpp
@@ -50,8 +50,8 @@
#include <QTimer>
#include <QFile>
-#include "jsonstream.h"
-#include "jsonserver.h"
+#include "qjsonstream.h"
+#include "qjsonserver.h"
QT_USE_NAMESPACE_JSONSTREAM
@@ -99,7 +99,7 @@ private slots:
void handleConnection() {
socket = server->nextPendingConnection();
Q_ASSERT(socket);
- stream = new JsonStream(socket);
+ stream = new QJsonStream(socket);
stream->setParent(socket);
connect(socket, SIGNAL(disconnected()), SLOT(handleDisconnection()));
connect(stream, SIGNAL(readyReadMessage()), SLOT(processMessages()));
@@ -141,7 +141,7 @@ signals:
private:
QLocalServer *server;
QLocalSocket *socket;
- JsonStream *stream;
+ QJsonStream *stream;
};
class Container : public QObject
diff --git a/tests/auto/jsonconnection/tst_jsonconnection.cpp b/tests/auto/jsonconnection/tst_jsonconnection.cpp
index 458022f..6e6a8eb 100644
--- a/tests/auto/jsonconnection/tst_jsonconnection.cpp
+++ b/tests/auto/jsonconnection/tst_jsonconnection.cpp
@@ -42,9 +42,9 @@
#include <QtTest>
#include <QLocalSocket>
#include <QLocalServer>
-#include "jsonserver.h"
-#include "jsonconnection.h"
-#include "jsonendpoint.h"
+#include "qjsonserver.h"
+#include "qjsonconnection.h"
+#include "qjsonendpoint.h"
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
@@ -53,7 +53,7 @@
QT_USE_NAMESPACE_JSONSTREAM
Q_DECLARE_METATYPE(QJsonObject);
-Q_DECLARE_METATYPE(JsonConnection::State);
+Q_DECLARE_METATYPE(QJsonConnection::State);
void waitForSpy(QSignalSpy& spy, int count, int timeout=5000) {
QTime stopWatch;
@@ -138,15 +138,15 @@ class EndpointContainer : public QObject
public:
EndpointContainer(QObject *parent = 0);
- JsonEndpoint *addEndpoint(const QString & name);
+ QJsonEndpoint *addEndpoint(const QString & name);
- void sendMessage(const QString & endpointDestination = QString::null, JsonEndpoint *sender = 0);
+ void sendMessage(const QString & endpointDestination = QString::null, QJsonEndpoint *sender = 0);
void sendMessage(const QStringList & endpointDestinationList, int messagesPerEndpoint, bool grouped);
QList<QObject *> endpoints() { return mEndpoints; }
- JsonConnection *connection() { return mConnection; }
- void setConnection(JsonConnection *connection);
+ QJsonConnection *connection() { return mConnection; }
+ void setConnection(QJsonConnection *connection);
public slots:
void processMessages();
@@ -155,11 +155,11 @@ signals:
void messageReceived(const QJsonObject&, QObject *);
protected:
- void addEndpoint(JsonEndpoint *endpoint);
+ void addEndpoint(QJsonEndpoint *endpoint);
private:
- JsonConnection *mConnection;
- JsonEndpoint *mStream;
+ QJsonConnection *mConnection;
+ QJsonEndpoint *mStream;
QList<QObject *> mEndpoints;
int mCounter;
};
@@ -170,33 +170,33 @@ EndpointContainer::EndpointContainer(QObject *parent)
{
}
-JsonEndpoint *EndpointContainer::addEndpoint(const QString & name)
+QJsonEndpoint *EndpointContainer::addEndpoint(const QString & name)
{
- JsonEndpoint *endpoint = new JsonEndpoint(name, mConnection);
+ QJsonEndpoint *endpoint = new QJsonEndpoint(name, mConnection);
endpoint->setParent(mConnection);
addEndpoint(endpoint);
return endpoint;
}
-void EndpointContainer::addEndpoint(JsonEndpoint *endpoint)
+void EndpointContainer::addEndpoint(QJsonEndpoint *endpoint)
{
mStream = endpoint;
connect(mStream, SIGNAL(readyReadMessage()), SLOT(processMessages()));
mEndpoints.append(mStream);
}
-void EndpointContainer::setConnection(JsonConnection *connection)
+void EndpointContainer::setConnection(QJsonConnection *connection)
{
mConnection = connection;
foreach (QObject *obj, mEndpoints) {
- JsonEndpoint *endpoint = qobject_cast<JsonEndpoint *> (obj);
+ QJsonEndpoint *endpoint = qobject_cast<QJsonEndpoint *> (obj);
if (endpoint)
endpoint->setConnection(connection);
}
}
-void EndpointContainer::sendMessage(const QString & endpointDestination, JsonEndpoint *sender)
+void EndpointContainer::sendMessage(const QString & endpointDestination, QJsonEndpoint *sender)
{
QJsonObject msg;
msg.insert("text", QLatin1String("Standard text"));
@@ -236,7 +236,7 @@ void EndpointContainer::processMessages() {
QObject *source(sender());
QVERIFY(source && mEndpoints.contains(source));
if (mEndpoints.contains(source)) {
- JsonEndpoint *endpoint = qobject_cast< JsonEndpoint *>(source);
+ QJsonEndpoint *endpoint = qobject_cast< QJsonEndpoint *>(source);
// qDebug() << " XXX: came from: " << endpoint->name();
while (endpoint->messageAvailable()) {
QJsonObject obj = endpoint->readMessage();
@@ -257,7 +257,7 @@ public:
void doConnect();
void closeConnection() {
- JsonConnection *oldConnection = connection();
+ QJsonConnection *oldConnection = connection();
setConnection(0);
delete oldConnection;
}
@@ -273,7 +273,7 @@ ConnectionContainer::ConnectionContainer(const QString & socketName, bool bSepar
: EndpointContainer(), mSocketName(socketName)
{
qDebug() << "Creating new json client at " << socketName;
- JsonConnection *connection = new JsonConnection();
+ QJsonConnection *connection = new QJsonConnection();
connection->setUseSeparateThreadForProcessing(bSeparateThread);
connection->setFormat(FormatUTF8);
@@ -333,12 +333,12 @@ void tst_JsonConnection::connectionTest()
ConnectionContainer c(socketname,true);
- JsonEndpoint *endpoint = c.addEndpoint("test");
+ QJsonEndpoint *endpoint = c.addEndpoint("test");
QVERIFY(endpoint->name() == "test");
- QVERIFY(c.connection()->state() == JsonConnection::Unconnected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Unconnected);
c.doConnect();
- QVERIFY(c.connection()->state() == JsonConnection::Connected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connected);
c.sendMessage(endpoint->name());
QSignalSpy spy(&c, SIGNAL(messageReceived(QJsonObject,QObject *)));
@@ -380,7 +380,7 @@ void tst_JsonConnection::connectionSameThreadTest()
ConnectionContainer c(socketname, false);
- JsonEndpoint *endpoint = c.addEndpoint("test");
+ QJsonEndpoint *endpoint = c.addEndpoint("test");
QVERIFY(endpoint->name() == "test");
c.doConnect();
@@ -425,8 +425,8 @@ signals:
void tst_JsonConnection::registerQmlTypes()
{
- qmlRegisterType<JsonConnection>("Qt.json.connection.test", 1,0, "JsonConnection");
- qmlRegisterType<JsonEndpoint>("Qt.json.connection.test", 1,0, "JsonEndpoint");
+ qmlRegisterType<QJsonConnection>("Qt.json.connection.test", 1,0, "JsonConnection");
+ qmlRegisterType<QJsonEndpoint>("Qt.json.connection.test", 1,0, "JsonEndpoint");
}
static const char szData[] =
@@ -654,13 +654,13 @@ void tst_JsonConnection::multipleEndpointsTest()
QString endpointName("test");
endpointName += QString::number(i);
- JsonEndpoint *endpoint = c.addEndpoint(endpointName);
+ QJsonEndpoint *endpoint = c.addEndpoint(endpointName);
QVERIFY(endpoint->name() == endpointName);
}
- QVERIFY(c.connection()->state() == JsonConnection::Unconnected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Unconnected);
c.doConnect();
- QVERIFY(c.connection()->state() == JsonConnection::Connected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connected);
for (int i = 0; i < knEndpointsNumber; i++) {
QString endpointName("test");
@@ -677,7 +677,7 @@ void tst_JsonConnection::multipleEndpointsTest()
for (it = spy.constBegin(); it != spy.constEnd(); it++) {
QJsonObject msg = qvariant_cast<QJsonObject>(it->at(0));
- JsonEndpoint *endpoint = qobject_cast<JsonEndpoint *>(qvariant_cast<QObject *>(it->at(1)));
+ QJsonEndpoint *endpoint = qobject_cast<QJsonEndpoint *>(qvariant_cast<QObject *>(it->at(1)));
QVERIFY(endpoints.removeOne(endpoint));
QVERIFY(msg.value("endpoint").isString() && msg.value("endpoint").toString() == endpoint->name());
@@ -736,7 +736,7 @@ void tst_JsonConnection::multipleThreadTest()
endpointName += QString::number(i);
endpointNames.append(endpointName);
- JsonEndpoint *endpoint = ec->addEndpoint(endpointName);
+ QJsonEndpoint *endpoint = ec->addEndpoint(endpointName);
QVERIFY(endpoint->name() == endpointName);
QSignalSpy *spy = new QSignalSpy(ec, SIGNAL(messageReceived(QJsonObject,QObject*)));
@@ -746,9 +746,9 @@ void tst_JsonConnection::multipleThreadTest()
newThread->start();
}
- QVERIFY(c.connection()->state() == JsonConnection::Unconnected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Unconnected);
c.doConnect();
- QVERIFY(c.connection()->state() == JsonConnection::Connected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connected);
// grouped
c.sendMessage(endpointNames, knMessagesPerThread, true);
@@ -803,12 +803,12 @@ void tst_JsonConnection::autoreconnectTest()
ConnectionContainer c(socketname,true);
c.connection()->setAutoReconnectEnabled(true);
- JsonEndpoint *endpoint = c.addEndpoint("test");
+ QJsonEndpoint *endpoint = c.addEndpoint("test");
QVERIFY(endpoint->name() == "test");
- QVERIFY(c.connection()->state() == JsonConnection::Unconnected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Unconnected);
c.doConnect();
- QVERIFY(c.connection()->state() == JsonConnection::Connected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connected);
QJsonObject msg;
msg.insert("endpoint", QLatin1String("test"));
@@ -827,17 +827,17 @@ void tst_JsonConnection::autoreconnectTest()
QVERIFY(msg.value("timeout").isDouble() && msg.value("timeout").toDouble() == 2000);
// wait for disconnect -> connencting state
- QSignalSpy spy1(c.connection(), SIGNAL(stateChanged(JsonConnection::State)));
+ QSignalSpy spy1(c.connection(), SIGNAL(stateChanged(QJsonConnection::State)));
waitForSpy(spy1, 1);
- JsonConnection::State state = qvariant_cast<JsonConnection::State>(spy1.last().at(0));
- QVERIFY(state == JsonConnection::Connecting);
- QVERIFY(c.connection()->state() == JsonConnection::Connecting);
+ QJsonConnection::State state = qvariant_cast<QJsonConnection::State>(spy1.last().at(0));
+ QVERIFY(state == QJsonConnection::Connecting);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connecting);
// wait for reconnection
waitForSpy(spy1, 2, 10000);
- state = qvariant_cast<JsonConnection::State>(spy1.last().at(0));
- QVERIFY(state == JsonConnection::Connected);
- QVERIFY(c.connection()->state() == JsonConnection::Connected);
+ state = qvariant_cast<QJsonConnection::State>(spy1.last().at(0));
+ QVERIFY(state == QJsonConnection::Connected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connected);
// send a new message after reconnection and wait for a reply
msg = QJsonObject();
@@ -872,12 +872,12 @@ void tst_JsonConnection::nameChangeTest()
c.connection()->setAutoReconnectEnabled(true);
QSignalSpy spyDef(&c, SIGNAL(messageReceived(const QJsonObject&, QObject *)));;
- JsonEndpoint *endpoint = c.addEndpoint("wrong");
+ QJsonEndpoint *endpoint = c.addEndpoint("wrong");
QVERIFY(endpoint->name() == "wrong");
- QVERIFY(c.connection()->state() == JsonConnection::Unconnected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Unconnected);
c.doConnect();
- QVERIFY(c.connection()->state() == JsonConnection::Connected);
+ QVERIFY(c.connection()->state() == QJsonConnection::Connected);
c.sendMessage("test");
diff --git a/tests/auto/jsonschema/tst_jsonschema.cpp b/tests/auto/jsonschema/tst_jsonschema.cpp
index 82d1109..e7508f4 100644
--- a/tests/auto/jsonschema/tst_jsonschema.cpp
+++ b/tests/auto/jsonschema/tst_jsonschema.cpp
@@ -41,7 +41,7 @@
#include <QtTest/QtTest>
-#include "schemavalidator.h"
+#include "qjsonschemavalidator.h"
QT_USE_NAMESPACE_JSONSTREAM
@@ -103,7 +103,7 @@ private:
void tst_JsonSchema::schemaTest()
{
bool result;
- SchemaValidator validator;
+ QJsonSchemaValidator validator;
// test SchemaValidator::schemaNames() and SchemaValidator::hasSchema() with empty object
QVERIFY(validator.schemaNames().isEmpty());
@@ -135,7 +135,7 @@ void tst_JsonSchema::schemaTest()
result = validator.validateSchema("SchemaTestObject", noncompliant);
//qDebug() << "INVALID validation result: " << result << " message is:" << validator.getLastError().errorString();
- QVERIFY(!result && validator.getLastError().errorCode() == SchemaError::FailedSchemaValidation);
+ QVERIFY(!result && validator.getLastError().errorCode() == QJsonSchemaError::FailedSchemaValidation);
// test SchemaValidator::removesSchema()
validator.removeSchema("SchemaTestObject");
@@ -523,7 +523,7 @@ bool tst_JsonSchema::validate(const QJsonValue & value, const QByteArray & schem
object.insert("test", value);
//qDebug() << "object " << object;
- SchemaValidator validator;
+ QJsonSchemaValidator validator;
// wrap schema body
QByteArray schema = QString("{ \"properties\": { \"test\": %1 } }").arg(schemaBody.constData()).toUtf8();
diff --git a/tests/auto/jsonstream/testClient/main.cpp b/tests/auto/jsonstream/testClient/main.cpp
index 5ba9b65..2276e95 100644
--- a/tests/auto/jsonstream/testClient/main.cpp
+++ b/tests/auto/jsonstream/testClient/main.cpp
@@ -44,7 +44,7 @@
#include <QDebug>
#include <QJsonArray>
-#include "jsonclient.h"
+#include "qjsonclient.h"
QT_USE_NAMESPACE_JSONSTREAM
@@ -65,7 +65,7 @@ public slots:
void disconnected();
private:
- JsonClient *mClient;
+ QJsonClient *mClient;
int mCounter;
};
@@ -73,7 +73,7 @@ Container::Container()
: mCounter(0)
{
qDebug() << "Creating new json client with format" << gFormat;
- mClient = new JsonClient;
+ mClient = new QJsonClient;
connect(mClient, SIGNAL(messageReceived(const QJsonObject&)),
SLOT(received(const QJsonObject&)));
connect(mClient, SIGNAL(disconnected()), SLOT(disconnected()));
diff --git a/tests/auto/jsonstream/tst_jsonstream.cpp b/tests/auto/jsonstream/tst_jsonstream.cpp
index e54abe8..b23d077 100644
--- a/tests/auto/jsonstream/tst_jsonstream.cpp
+++ b/tests/auto/jsonstream/tst_jsonstream.cpp
@@ -42,12 +42,12 @@
#include <QtTest>
#include <QLocalSocket>
#include <QLocalServer>
-#include "jsonserver.h"
-#include "jsonstream.h"
-#include "jsonpipe.h"
-#include "jsonuidauthority.h"
-#include "jsonuidrangeauthority.h"
-#include "schemavalidator.h"
+#include "qjsonserver.h"
+#include "qjsonstream.h"
+#include "qjsonpipe.h"
+#include "qjsonuidauthority.h"
+#include "qjsonuidrangeauthority.h"
+#include "qjsonschemavalidator.h"
#include <unistd.h>
@@ -57,7 +57,7 @@ Q_DECLARE_METATYPE(QJsonObject);
class Spy {
public:
- Spy(JsonServer *server)
+ Spy(QJsonServer *server)
: addedSpy(server, SIGNAL(connectionAdded(const QString&)))
, removedSpy(server, SIGNAL(connectionRemoved(const QString&)))
, receivedSpy(server, SIGNAL(messageReceived(const QString&, const QJsonObject&)))
@@ -172,11 +172,11 @@ private:
};
/****************************/
-class TestJsonStream : public JsonStream
+class TestJsonStream : public QJsonStream
{
public:
TestJsonStream(QIODevice *device)
- : JsonStream(device) {}
+ : QJsonStream(device) {}
bool sendRaw(const QByteArray& byteArray) { return sendInternal(byteArray); }
};
@@ -188,7 +188,7 @@ class BasicServer : public QObject {
public:
BasicServer(const QString& socketname, qint64 _sz = 0, bool _handleReadBufOverflow = false)
: socket(0), stream(0), readBufferSize(_sz)
- , mHandleReadBufOverflow(_handleReadBufOverflow), mLastError(JsonStream::NoError)
+ , mHandleReadBufOverflow(_handleReadBufOverflow), mLastError(QJsonStream::NoError)
{
QLocalServer::removeServer(socketname);
server = new QLocalServer(this);
@@ -226,7 +226,7 @@ public:
return stream->format();
}
- JsonStream *jsonStream() const { return stream; }
+ QJsonStream *jsonStream() const { return stream; }
private slots:
void handleConnection() {
socket = server->nextPendingConnection();
@@ -275,7 +275,7 @@ private:
qint64 readBufferSize;
bool mHandleReadBufOverflow;
public:
- JsonStream::JsonStreamError mLastError;
+ QJsonStream::QJsonStreamError mLastError;
};
/****************************/
@@ -305,7 +305,7 @@ private slots:
void tst_JsonStream::initTestCase()
{
qRegisterMetaType<QJsonObject>();
- qRegisterMetaType<JsonPipe::PipeError>("PipeError");
+ qRegisterMetaType<QJsonPipe::PipeError>("PipeError");
}
#if defined(Q_OS_LINUX_ANDROID)
@@ -316,7 +316,7 @@ QString s_socketname = QStringLiteral("/tmp/tst_socket");
void tst_JsonStream::noAuthTest()
{
- JsonServer server;
+ QJsonServer server;
Spy spy(&server);
QVERIFY(server.listen(s_socketname));
@@ -335,9 +335,9 @@ void tst_JsonStream::noAuthTest()
void tst_JsonStream::authTest()
{
- JsonServer server;
+ QJsonServer server;
Spy spy(&server);
- JsonUIDAuthority *authority = new JsonUIDAuthority;
+ QJsonUIDAuthority *authority = new QJsonUIDAuthority;
QVERIFY(server.listen(s_socketname, authority));
authority->authorize(geteuid());
@@ -357,9 +357,9 @@ void tst_JsonStream::authTest()
void tst_JsonStream::authFail()
{
- JsonServer server;
+ QJsonServer server;
Spy spy(&server);
- JsonUIDAuthority *authority = new JsonUIDAuthority;
+ QJsonUIDAuthority *authority = new QJsonUIDAuthority;
QVERIFY(server.listen(s_socketname, authority));
// authority->authorize(geteuid());
@@ -373,9 +373,9 @@ void tst_JsonStream::authFail()
void tst_JsonStream::authRangeTest()
{
- JsonServer server;
+ QJsonServer server;
Spy spy(&server);
- JsonUIDRangeAuthority *authority = new JsonUIDRangeAuthority;
+ QJsonUIDRangeAuthority *authority = new QJsonUIDRangeAuthority;
authority->setMinimum(geteuid());
authority->setMaximum(geteuid());
@@ -397,9 +397,9 @@ void tst_JsonStream::authRangeTest()
void tst_JsonStream::authRangeFail()
{
- JsonServer server;
+ QJsonServer server;
Spy spy(&server);
- JsonUIDRangeAuthority *authority = new JsonUIDRangeAuthority;
+ QJsonUIDRangeAuthority *authority = new QJsonUIDRangeAuthority;
QVERIFY(server.listen(s_socketname, authority));
Child child("testClient/testClient", QStringList() << "-socket" << s_socketname);
@@ -590,14 +590,14 @@ void tst_JsonStream::bufferSizeTest()
server.jsonStream()->setWriteBufferSize(100);
QVERIFY(!server.send(msg));
- QVERIFY(server.jsonStream()->lastError() == JsonStream::MaxWriteBufferSizeExceeded);
+ QVERIFY(server.jsonStream()->lastError() == QJsonStream::MaxWriteBufferSizeExceeded);
QString strLarge(500000, '*');
msg.insert("large", strLarge);
msg.insert("large_size", strLarge.size());
server.jsonStream()->setWriteBufferSize(0);
QVERIFY(server.send(msg));
- QVERIFY(server.jsonStream()->lastError() == JsonStream::NoError);
+ QVERIFY(server.jsonStream()->lastError() == QJsonStream::NoError);
server.waitDisconnect();
child.waitForFinished();
@@ -624,7 +624,7 @@ void tst_JsonStream::bufferMaxReadSizeFailTest()
QVERIFY(!server.jsonStream()); //disconnected
QVERIFY(spy1.count() == 1); // overflow happend only once
- QVERIFY(server.mLastError == JsonStream::MaxReadBufferSizeExceeded);
+ QVERIFY(server.mLastError == QJsonStream::MaxReadBufferSizeExceeded);
}
void tst_JsonStream::schemaTest()
@@ -632,20 +632,20 @@ void tst_JsonStream::schemaTest()
QString strSchemasDir(QDir::currentPath() + "/" + "schemas");
QVERIFY(QFile::exists(strSchemasDir));
- JsonServer server;
+ QJsonServer server;
QVERIFY(server.inboundValidator());
QVERIFY(server.outboundValidator());
- server.setValidatorFlags(JsonServer::ValidatorFlags(JsonServer::WarnIfInvalid | JsonServer::DropIfInvalid));
+ server.setValidatorFlags(QJsonServer::ValidatorFlags(QJsonServer::WarnIfInvalid | QJsonServer::DropIfInvalid));
server.inboundValidator()->loadFromFolder(strSchemasDir);
server.inboundValidator()->setValidationFilter(QRegExp("Paint\\w+Event|BackgroundEvent"));
- server.inboundValidator()->setSchemaNameMatcher(SchemaValidator::SchemaUniqueKeyNameMatcher("event"));
+ server.inboundValidator()->setSchemaNameMatcher(QJsonSchemaValidator::SchemaUniqueKeyNameMatcher("event"));
server.outboundValidator()->loadFromFolder(strSchemasDir);
server.outboundValidator()->setValidationFilter(QRegExp("Reply\\w+"));
- server.outboundValidator()->setSchemaNameMatcher(SchemaValidator::SchemaUniqueKeyNameMatcher("event"));
+ server.outboundValidator()->setSchemaNameMatcher(QJsonSchemaValidator::SchemaUniqueKeyNameMatcher("event"));
QVERIFY(!server.inboundValidator()->isEmpty());
QVERIFY(!server.outboundValidator()->isEmpty());
@@ -692,7 +692,7 @@ public:
::close(fd2[0]);
::close(fd2[1]);
}
- void join(JsonPipe& jp1, JsonPipe& jp2) {
+ void join(QJsonPipe& jp1, QJsonPipe& jp2) {
// fd1[0] = Read end of jp1 fd1[1] = Write end of jp2
// fd2[0] = Read end of jp2 fd2[1] = Write end of jp1
jp1.setFds(fd1[0], fd2[1]);
@@ -703,7 +703,7 @@ public:
class PipeSpy {
public:
- PipeSpy(JsonPipe& jp)
+ PipeSpy(QJsonPipe& jp)
: msg(&jp, SIGNAL(messageReceived(const QJsonObject&)))
, err(&jp, SIGNAL(error(PipeError))) {}
QJsonObject at(int i) { return qvariant_cast<QJsonObject>(msg.at(i).at(0)); }
@@ -714,7 +714,7 @@ public:
void tst_JsonStream::pipeTest()
{
Pipes pipes;
- JsonPipe jpipe1, jpipe2;
+ QJsonPipe jpipe1, jpipe2;
QVERIFY(!jpipe1.writeEnabled());
QVERIFY(!jpipe1.readEnabled());
@@ -744,7 +744,7 @@ void tst_JsonStream::pipeFormatTest()
foreach (EncodingFormat format, formats) {
Pipes pipes;
- JsonPipe jpipe1, jpipe2;
+ QJsonPipe jpipe1, jpipe2;
pipes.join(jpipe1, jpipe2);
PipeSpy spy(jpipe2);
jpipe1.setFormat(format);
@@ -762,7 +762,7 @@ void tst_JsonStream::pipeFormatTest()
void tst_JsonStream::pipeWaitTest()
{
Pipes pipes;
- JsonPipe jpipe1, jpipe2;
+ QJsonPipe jpipe1, jpipe2;
pipes.join(jpipe1, jpipe2);
QJsonObject msg;
diff --git a/tests/auto/testsuite/tst_jsonclient.cpp b/tests/auto/testsuite/tst_jsonclient.cpp
index f2a3954..5bbd380 100644
--- a/tests/auto/testsuite/tst_jsonclient.cpp
+++ b/tests/auto/testsuite/tst_jsonclient.cpp
@@ -48,7 +48,7 @@ tst_JsonClient::tst_JsonClient(const QString& socketname, const QString& strMsg)
{
qDebug() << Q_FUNC_INFO;
- mClient = new JsonClient;
+ mClient = new QJsonClient;
connect(mClient, SIGNAL(messageReceived(const QJsonObject&)),
this, SLOT(messageReceived(const QJsonObject&)));
mSpyMessageReceived = new QSignalSpy(mClient, SIGNAL(messageReceived(const QJsonObject&)));
diff --git a/tests/auto/testsuite/tst_jsonclient.h b/tests/auto/testsuite/tst_jsonclient.h
index a0898df..6a0ad25 100644
--- a/tests/auto/testsuite/tst_jsonclient.h
+++ b/tests/auto/testsuite/tst_jsonclient.h
@@ -60,7 +60,7 @@ private slots:
void messageReceived(const QJsonObject& message);
private:
- JsonClient *mClient;
+ QJsonClient *mClient;
QString mMsg;
QSignalSpy *mSpyMessageReceived;
};
diff --git a/tests/auto/testsuite/tst_jsonserver.cpp b/tests/auto/testsuite/tst_jsonserver.cpp
index aa8c400..af83959 100644
--- a/tests/auto/testsuite/tst_jsonserver.cpp
+++ b/tests/auto/testsuite/tst_jsonserver.cpp
@@ -102,7 +102,7 @@ void tst_JsonServer::noAuthTest()
{
qDebug() << "Running" << Q_FUNC_INFO;
- mServer = new JsonServer;
+ mServer = new QJsonServer;
connect(mServer, SIGNAL(connectionAdded(const QString&)), this, SLOT(connectionAdded(const QString&)));
mSpyServerConnectionAdded = new QSignalSpy(mServer, SIGNAL(connectionAdded(const QString&)));
@@ -123,7 +123,7 @@ void tst_JsonServer::pidAuthorityTest()
qDebug() << "Running" << Q_FUNC_INFO;
#ifdef MMM // not implemented
- JsonPIDAuthority *auth = new JsonPIDAuthority(this);
+ QJsonPIDAuthority *auth = new QJsonPIDAuthority(this);
pid_t clientPid = getpid();
QString clientId = "pid_auth_tester";
@@ -140,7 +140,7 @@ void tst_JsonServer::pidAuthorityTest()
QVERIFY(auth->deauthorize(clientPid) == false);
#endif
- mServer = new JsonServer;
+ mServer = new QJsonServer;
connect(mServer, SIGNAL(connectionAdded(const QString&)), this, SLOT(connectionAdded(const QString&)));
mSpyServerConnectionAdded = new QSignalSpy(mServer, SIGNAL(connectionAdded(const QString&)));
@@ -160,7 +160,7 @@ void tst_JsonServer::tokenAuthorityTest()
{
qDebug() << "Running" << Q_FUNC_INFO;
- JsonTokenAuthority *auth = new JsonTokenAuthority(this);
+ QJsonTokenAuthority *auth = new QJsonTokenAuthority(this);
QString clientId = "token_auth_tester";
QString clientToken = QUuid::createUuid().toString();
@@ -179,7 +179,7 @@ void tst_JsonServer::tokenAuthorityTest()
QVERIFY(auth->authorize(clientToken, clientId));
- mServer = new JsonServer;
+ mServer = new QJsonServer;
connect(mServer, SIGNAL(connectionAdded(const QString&)), this, SLOT(connectionAdded(const QString&)));
mSpyServerConnectionAdded = new QSignalSpy(mServer, SIGNAL(connectionAdded(const QString&)));
diff --git a/tests/auto/testsuite/tst_jsonserver.h b/tests/auto/testsuite/tst_jsonserver.h
index 6725caa..cd446d9 100644
--- a/tests/auto/testsuite/tst_jsonserver.h
+++ b/tests/auto/testsuite/tst_jsonserver.h
@@ -78,7 +78,7 @@ private:
QString mId;
bool mDone;
- JsonServer *mServer;
+ QJsonServer *mServer;
QSignalSpy *mSpyServerConnectionAdded;
QSignalSpy *mSpyServerConnectionRemoved;
QSignalSpy *mSpyMessageReceived;