aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/connection.cpp1
-rw-r--r--lib/converters.h31
-rw-r--r--lib/csapi/account-data.h1
-rw-r--r--lib/csapi/admin.cpp2
-rw-r--r--lib/csapi/admin.h2
-rw-r--r--lib/csapi/administrative_contact.cpp2
-rw-r--r--lib/csapi/administrative_contact.h2
-rw-r--r--lib/csapi/banning.h1
-rw-r--r--lib/csapi/content-repo.h1
-rw-r--r--lib/csapi/create_room.cpp2
-rw-r--r--lib/csapi/create_room.h2
-rw-r--r--lib/csapi/directory.h1
-rw-r--r--lib/csapi/event_context.h1
-rw-r--r--lib/csapi/inviting.h1
-rw-r--r--lib/csapi/joining.cpp2
-rw-r--r--lib/csapi/joining.h2
-rw-r--r--lib/csapi/kicking.h1
-rw-r--r--lib/csapi/leaving.h1
-rw-r--r--lib/csapi/list_joined_rooms.h1
-rw-r--r--lib/csapi/list_public_rooms.cpp2
-rw-r--r--lib/csapi/list_public_rooms.h2
-rw-r--r--lib/csapi/login.h1
-rw-r--r--lib/csapi/logout.h1
-rw-r--r--lib/csapi/message_pagination.h1
-rw-r--r--lib/csapi/notifications.cpp2
-rw-r--r--lib/csapi/notifications.h2
-rw-r--r--lib/csapi/profile.h1
-rw-r--r--lib/csapi/pusher.cpp2
-rw-r--r--lib/csapi/pusher.h2
-rw-r--r--lib/csapi/receipts.h1
-rw-r--r--lib/csapi/redaction.h1
-rw-r--r--lib/csapi/room_send.h1
-rw-r--r--lib/csapi/room_state.h1
-rw-r--r--lib/csapi/search.cpp2
-rw-r--r--lib/csapi/search.h2
-rw-r--r--lib/csapi/tags.h1
-rw-r--r--lib/csapi/third_party_membership.h1
-rw-r--r--lib/csapi/to_device.h1
-rw-r--r--lib/csapi/typing.h1
-rw-r--r--lib/csapi/users.cpp2
-rw-r--r--lib/csapi/users.h2
-rw-r--r--lib/csapi/versions.h1
-rw-r--r--lib/csapi/whoami.h1
-rw-r--r--lib/jobs/basejob.cpp1
-rw-r--r--lib/jobs/basejob.h3
-rw-r--r--lib/room.cpp1
-rw-r--r--lib/variant_converters.h56
-rw-r--r--libqmatrixclient.pri3
48 files changed, 79 insertions, 76 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 24bf1af9..f21d6973 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -33,6 +33,7 @@
#include "jobs/syncjob.h"
#include "jobs/mediathumbnailjob.h"
#include "jobs/downloadfilejob.h"
+#include "variant_converters.h"
#include <QtNetwork/QDnsLookup>
#include <QtCore/QFile>
diff --git a/lib/converters.h b/lib/converters.h
index 68005c0d..1b70fba4 100644
--- a/lib/converters.h
+++ b/lib/converters.h
@@ -21,7 +21,6 @@
#include <QtCore/QJsonObject>
#include <QtCore/QJsonArray> // Includes <QtCore/QJsonValue>
#include <QtCore/QDate>
-#include <QtCore/QVariant>
#include <unordered_map>
@@ -75,18 +74,6 @@ namespace QMatrixClient
return QJsonValue(bytes.constData());
}
- inline QJsonObject toJson(const QVariantMap& map)
- {
- return QJsonObject::fromVariantMap(map);
- }
-
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
- inline QJsonObject toJson(const QVariantHash& hMap)
- {
- return QJsonObject::fromVariantHash(hMap);
- }
-#endif
-
template <typename T>
inline QJsonObject toJson(const QHash<QString, T>& hashMap)
{
@@ -221,24 +208,6 @@ namespace QMatrixClient
}
};
- template <> struct FromJson<QVariantMap>
- {
- auto operator()(const QJsonValue& jv) const
- {
- return jv.toObject().toVariantMap();
- }
- };
-
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
- template <> struct FromJson<QVariantHash>
- {
- auto operator()(const QJsonValue& jv) const
- {
- return jv.toObject().toVariantHash();
- }
- };
-#endif
-
template <typename T> struct FromJson<QHash<QString, T>>
{
auto operator()(const QJsonValue& jv) const
diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h
index 784b8b4b..9ee565df 100644
--- a/lib/csapi/account-data.h
+++ b/lib/csapi/account-data.h
@@ -8,7 +8,6 @@
#include <QtCore/QJsonObject>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp
index b325d746..18bac4c9 100644
--- a/lib/csapi/admin.cpp
+++ b/lib/csapi/admin.cpp
@@ -4,6 +4,8 @@
#include "admin.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h
index ada5a8ca..74de8e08 100644
--- a/lib/csapi/admin.h
+++ b/lib/csapi/admin.h
@@ -9,8 +9,6 @@
#include <QtCore/QHash>
#include <QtCore/QVector>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp
index ec7c77c3..eeb7cb68 100644
--- a/lib/csapi/administrative_contact.cpp
+++ b/lib/csapi/administrative_contact.cpp
@@ -4,6 +4,8 @@
#include "administrative_contact.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h
index 0d1ace3d..55786389 100644
--- a/lib/csapi/administrative_contact.h
+++ b/lib/csapi/administrative_contact.h
@@ -8,8 +8,6 @@
#include <QtCore/QVector>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h
index 5d9bae2b..0f6eabf8 100644
--- a/lib/csapi/banning.h
+++ b/lib/csapi/banning.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h
index 4c799b2d..63a55c8f 100644
--- a/lib/csapi/content-repo.h
+++ b/lib/csapi/content-repo.h
@@ -8,7 +8,6 @@
#include <QtCore/QIODevice>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp
index 0a7eb208..3764eeab 100644
--- a/lib/csapi/create_room.cpp
+++ b/lib/csapi/create_room.cpp
@@ -4,6 +4,8 @@
#include "create_room.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h
index 8ade7a9c..a93215ea 100644
--- a/lib/csapi/create_room.h
+++ b/lib/csapi/create_room.h
@@ -10,8 +10,6 @@
#include <QtCore/QJsonObject>
#include <QtCore/QStringList>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h
index b6e62b6a..bf37170a 100644
--- a/lib/csapi/directory.h
+++ b/lib/csapi/directory.h
@@ -8,7 +8,6 @@
#include <QtCore/QStringList>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h
index caf1dfd4..7929c492 100644
--- a/lib/csapi/event_context.h
+++ b/lib/csapi/event_context.h
@@ -8,7 +8,6 @@
#include "events/event.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h
index 3119de6a..4fb15155 100644
--- a/lib/csapi/inviting.h
+++ b/lib/csapi/inviting.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp
index 705e8f83..71c93867 100644
--- a/lib/csapi/joining.cpp
+++ b/lib/csapi/joining.cpp
@@ -4,6 +4,8 @@
#include "joining.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h
index ccaed04e..f6200dff 100644
--- a/lib/csapi/joining.h
+++ b/lib/csapi/joining.h
@@ -8,8 +8,6 @@
#include <QtCore/QJsonObject>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h
index 030dff88..2a2d44b1 100644
--- a/lib/csapi/kicking.h
+++ b/lib/csapi/kicking.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h
index f6711c32..d571367b 100644
--- a/lib/csapi/leaving.h
+++ b/lib/csapi/leaving.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h
index e590fa18..0a4a585f 100644
--- a/lib/csapi/list_joined_rooms.h
+++ b/lib/csapi/list_joined_rooms.h
@@ -8,7 +8,6 @@
#include <QtCore/QStringList>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp
index b27bdd58..65ffd3a3 100644
--- a/lib/csapi/list_public_rooms.cpp
+++ b/lib/csapi/list_public_rooms.cpp
@@ -4,6 +4,8 @@
#include "list_public_rooms.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h
index 76d78577..fc30ad32 100644
--- a/lib/csapi/list_public_rooms.h
+++ b/lib/csapi/list_public_rooms.h
@@ -9,8 +9,6 @@
#include <QtCore/QVector>
#include <QtCore/QStringList>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/login.h b/lib/csapi/login.h
index 2adbdb4d..f30bef57 100644
--- a/lib/csapi/login.h
+++ b/lib/csapi/login.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h
index 7993335f..3d60ad48 100644
--- a/lib/csapi/logout.h
+++ b/lib/csapi/logout.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h
index 61e7323f..c9ede1f1 100644
--- a/lib/csapi/message_pagination.h
+++ b/lib/csapi/message_pagination.h
@@ -8,7 +8,6 @@
#include "events/event.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp
index 04ad0175..19b2e058 100644
--- a/lib/csapi/notifications.cpp
+++ b/lib/csapi/notifications.cpp
@@ -4,6 +4,8 @@
#include "notifications.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h
index 61da518b..1e19471b 100644
--- a/lib/csapi/notifications.h
+++ b/lib/csapi/notifications.h
@@ -10,8 +10,6 @@
#include <QtCore/QJsonObject>
#include <QtCore/QVector>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h
index 604291b4..77eebdfa 100644
--- a/lib/csapi/profile.h
+++ b/lib/csapi/profile.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp
index dea7cf8b..324f7991 100644
--- a/lib/csapi/pusher.cpp
+++ b/lib/csapi/pusher.cpp
@@ -4,6 +4,8 @@
#include "pusher.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h
index 97e3ba38..36aa540a 100644
--- a/lib/csapi/pusher.h
+++ b/lib/csapi/pusher.h
@@ -8,8 +8,6 @@
#include <QtCore/QVector>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h
index b109282e..3c11bcb1 100644
--- a/lib/csapi/receipts.h
+++ b/lib/csapi/receipts.h
@@ -8,7 +8,6 @@
#include <QtCore/QJsonObject>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h
index 56645ee5..e74c9ce4 100644
--- a/lib/csapi/redaction.h
+++ b/lib/csapi/redaction.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h
index 3bfb48c4..27bea13d 100644
--- a/lib/csapi/room_send.h
+++ b/lib/csapi/room_send.h
@@ -8,7 +8,6 @@
#include <QtCore/QJsonObject>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h
index 5c42b868..a9e859c2 100644
--- a/lib/csapi/room_state.h
+++ b/lib/csapi/room_state.h
@@ -8,7 +8,6 @@
#include <QtCore/QJsonObject>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp
index 21a195c2..9e56c24d 100644
--- a/lib/csapi/search.cpp
+++ b/lib/csapi/search.cpp
@@ -4,6 +4,8 @@
#include "search.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/search.h b/lib/csapi/search.h
index cde160a9..c487f01c 100644
--- a/lib/csapi/search.h
+++ b/lib/csapi/search.h
@@ -13,8 +13,6 @@
#include <QtCore/QStringList>
#include <QtCore/QVector>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h
index e437cee8..29359745 100644
--- a/lib/csapi/tags.h
+++ b/lib/csapi/tags.h
@@ -8,7 +8,6 @@
#include <QtCore/QJsonObject>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h
index 9cf6e6f6..d0c9f811 100644
--- a/lib/csapi/third_party_membership.h
+++ b/lib/csapi/third_party_membership.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h
index 7743b883..e3f3b9e8 100644
--- a/lib/csapi/to_device.h
+++ b/lib/csapi/to_device.h
@@ -9,7 +9,6 @@
#include <QtCore/QJsonObject>
#include <QtCore/QHash>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h
index 0506c77b..7cf27ef6 100644
--- a/lib/csapi/typing.h
+++ b/lib/csapi/typing.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp
index fd2944e4..80081885 100644
--- a/lib/csapi/users.cpp
+++ b/lib/csapi/users.cpp
@@ -4,6 +4,8 @@
#include "users.h"
+#include "converters.h"
+
#include <QtCore/QStringBuilder>
using namespace QMatrixClient;
diff --git a/lib/csapi/users.h b/lib/csapi/users.h
index 85ebd47c..2efcf640 100644
--- a/lib/csapi/users.h
+++ b/lib/csapi/users.h
@@ -8,8 +8,6 @@
#include <QtCore/QVector>
-#include "converters.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h
index c386f0af..ab00eaa8 100644
--- a/lib/csapi/versions.h
+++ b/lib/csapi/versions.h
@@ -8,7 +8,6 @@
#include <QtCore/QStringList>
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h
index 08fcb5a3..b9be8e70 100644
--- a/lib/csapi/whoami.h
+++ b/lib/csapi/whoami.h
@@ -7,7 +7,6 @@
#include "jobs/basejob.h"
-
namespace QMatrixClient
{
// Operations
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index 2d41650a..7c3cb13b 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -25,6 +25,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtCore/QTimer>
#include <QtCore/QRegularExpression>
+#include <QtCore/QJsonObject>
#include <array>
diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h
index 763ef75a..319fc8a4 100644
--- a/lib/jobs/basejob.h
+++ b/lib/jobs/basejob.h
@@ -23,10 +23,7 @@
#include <QtCore/QObject>
#include <QtCore/QUrlQuery>
-
-// Any job that parses the response will need the below two.
#include <QtCore/QJsonDocument>
-#include <QtCore/QJsonObject>
class QNetworkReply;
class QSslError;
diff --git a/lib/room.cpp b/lib/room.cpp
index 73a0491f..c1639ec6 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -40,6 +40,7 @@
#include "avatar.h"
#include "connection.h"
#include "user.h"
+#include "variant_converters.h"
#include <QtCore/QHash>
#include <QtCore/QStringBuilder> // for efficient string concats (operator%)
diff --git a/lib/variant_converters.h b/lib/variant_converters.h
new file mode 100644
index 00000000..76c395e1
--- /dev/null
+++ b/lib/variant_converters.h
@@ -0,0 +1,56 @@
+/******************************************************************************
+* Copyright (C) 2018 Kitsune Ral <kitsune-ral@users.sf.net>
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#pragma once
+
+#include <QtCore/QVariant>
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ inline QJsonObject toJson(const QVariantMap& map)
+ {
+ return QJsonObject::fromVariantMap(map);
+ }
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
+ inline QJsonObject toJson(const QVariantHash& hMap)
+ {
+ return QJsonObject::fromVariantHash(hMap);
+ }
+#endif
+
+ template <> struct FromJson<QVariantMap>
+ {
+ auto operator()(const QJsonValue& jv) const
+ {
+ return jv.toObject().toVariantMap();
+ }
+ };
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
+ template <> struct FromJson<QVariantHash>
+ {
+ auto operator()(const QJsonValue& jv) const
+ {
+ return jv.toObject().toVariantHash();
+ }
+ };
+#endif
+}
diff --git a/libqmatrixclient.pri b/libqmatrixclient.pri
index 4085e84d..bbf8eb14 100644
--- a/libqmatrixclient.pri
+++ b/libqmatrixclient.pri
@@ -43,7 +43,8 @@ HEADERS += \
$$SRCPATH/logging.h \
$$SRCPATH/settings.h \
$$SRCPATH/networksettings.h \
- $$SRCPATH/networkaccessmanager.h
+ $$SRCPATH/networkaccessmanager.h \
+ $$PWD/lib/variant_converters.h
SOURCES += \
$$SRCPATH/connectiondata.cpp \