From a2520bae3677be9df0abcef7681a138a6c4ad849 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 14 Jun 2020 17:23:54 +0200 Subject: quotient_common.h for common namespace things The two main cases for this header file are: * namespace QMatrixClient = Quotient should occur exactly once, to respect ODR. * Q_NAMESPACE for namespace Quotient (to enable Q_ENUM_NS, particularly) must be defined exactly once, for the same reason. --- lib/connection.h | 11 +---------- lib/quotient_common.h | 29 +++++++++++++++++++++++++++++ lib/util.h | 2 -- libquotient.pri | 1 + 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 lib/quotient_common.h diff --git a/lib/connection.h b/lib/connection.h index e8373a10..47d1844e 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -21,6 +21,7 @@ #include "ssosession.h" #include "joinstate.h" #include "qt_connection_util.h" +#include "quotient_common.h" #include "csapi/login.h" #include "csapi/create_room.h" @@ -41,7 +42,6 @@ class Account; Q_DECLARE_METATYPE(Quotient::GetLoginFlowsJob::LoginFlow) namespace Quotient { -Q_NAMESPACE class Room; class User; @@ -114,15 +114,6 @@ static inline user_factory_t defaultUserFactory() return [](Connection* c, const QString& id) { return new T(id, c); }; } -/** Enumeration with flags defining the network job running policy - * So far only background/foreground flags are available. - * - * \sa Connection::callApi, Connection::run - */ -enum RunningPolicy { ForegroundRequest = 0x0, BackgroundRequest = 0x1 }; - -Q_ENUM_NS(RunningPolicy) - // Room ids, rather than room pointers, are used in the direct chat // map types because the library keeps Invite rooms separate from // rooms in Join and Leave state; and direct chats in account data diff --git a/lib/quotient_common.h b/lib/quotient_common.h new file mode 100644 index 00000000..44541b42 --- /dev/null +++ b/lib/quotient_common.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +namespace Quotient { +Q_NAMESPACE + +/** Enumeration with flags defining the network job running policy + * So far only background/foreground flags are available. + * + * \sa Connection::callApi, Connection::run + */ +enum RunningPolicy { ForegroundRequest = 0x0, BackgroundRequest = 0x1 }; + +Q_ENUM_NS(RunningPolicy) + +enum ResourceResolveResult : short { + StillResolving = -1, + Resolved = 0, + UnknownMatrixId, + MalformedMatrixId, + NoAccount, + EmptyMatrixId +}; +Q_ENUM_NS(ResourceResolveResult) + +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; diff --git a/lib/util.h b/lib/util.h index 81add1ac..943ff8db 100644 --- a/lib/util.h +++ b/lib/util.h @@ -294,5 +294,3 @@ qreal stringToHueF(const QString& s); /** Extract the serverpart from MXID */ QString serverPart(const QString& mxId); } // namespace Quotient -/// \deprecated Use namespace Quotient instead -namespace QMatrixClient = Quotient; diff --git a/libquotient.pri b/libquotient.pri index 68e7b590..53f018c3 100644 --- a/libquotient.pri +++ b/libquotient.pri @@ -35,6 +35,7 @@ HEADERS += \ $$SRCPATH/user.h \ $$SRCPATH/avatar.h \ $$SRCPATH/syncdata.h \ + $$SRCPATH/quotient_common.h $$SRCPATH/util.h \ $$SRCPATH/qt_connection_util.h \ $$SRCPATH/events/event.h \ -- cgit v1.2.3