From 798f0130fdb95bca468456c0051a540728cf5dfa Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Mon, 4 May 2020 15:35:28 -0400 Subject: [PATCH] misc: expose enum class value to qml client Change-Id: I03835c364640409c92942ad9a95d9133e5e07520 --- CMakeLists.txt | 2 +- src/api/account.h | 27 ++++++++++++++++++++++++++- src/api/call.h | 10 ++++++++++ src/api/conversationmodel.h | 7 +++++++ src/api/datatransfer.h | 7 +++++++ src/api/interaction.h | 10 ++++++++++ src/api/newvideo.h | 13 ++++++++++--- src/api/profile.h | 8 ++++++++ 8 files changed, 79 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10d1e41c..cd1ad493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -517,7 +517,7 @@ ENDIF() IF(NOT ${ENABLE_STATIC} MATCHES false) message(STATUS "Configuring as static lib") - add_library( ringclient_static STATIC ${libringclient_LIB_SRCS} ${LIB_HEADER_MOC} ) + add_library( ringclient_static STATIC ${libringclient_LIB_SRCS} ${libringclient_api_LIB_HDRS} ${LIB_HEADER_MOC} ) target_link_libraries(ringclient_static Qt5::Core) target_link_libraries(ringclient_static Qt5::Gui) target_link_libraries( ringclient_static diff --git a/src/api/account.h b/src/api/account.h index 7eeb6189..481d501c 100644 --- a/src/api/account.h +++ b/src/api/account.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (C) 2017-2020 Savoir-faire Linux Inc. * + * Copyright (C) 2017-2020 Savoir-faire Linux Inc. * * Author: Nicolas Jäger <nicolas.jager@savoirfairelinux.com> * * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> * * * @@ -42,12 +42,19 @@ class PeerDiscoveryModel; namespace account { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif enum class Type { INVALID, RING, SIP }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Type) +#endif #pragma push_macro("REGISTERED") #undef REGISTERED @@ -60,6 +67,9 @@ enum class Status { TRYING, REGISTERED }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Status) +#endif static inline account::Status to_status(const QString& type) @@ -84,6 +94,9 @@ enum class KeyExchangeProtocol { NONE, SDES }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(KeyExchangeProtocol) +#endif enum class TlsMethod { DEFAULT, @@ -91,6 +104,9 @@ enum class TlsMethod { TLSv1_1, TLSv1_2 }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(TlsMethod) +#endif struct ConfProperties_t { QString mailbox; @@ -201,6 +217,9 @@ enum class ExportOnRingStatus { NETWORK_ERROR = 2, INVALID }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(ExportOnRingStatus) +#endif enum class RegisterNameStatus { SUCCESS = 0, @@ -210,6 +229,9 @@ enum class RegisterNameStatus { NETWORK_ERROR = 4, INVALID }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(RegisterNameStatus) +#endif enum class LookupStatus { SUCCESS = 0, @@ -218,6 +240,9 @@ enum class LookupStatus { ERROR = 3, INVALID }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(LookupStatus) +#endif struct Info { diff --git a/src/api/call.h b/src/api/call.h index c95e6fb1..c59703ae 100644 --- a/src/api/call.h +++ b/src/api/call.h @@ -36,6 +36,10 @@ namespace api namespace call { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif enum class Status { INVALID, @@ -52,6 +56,9 @@ enum class Status { TERMINATING, CONNECTED }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Status) +#endif static inline QString to_string(const call::Status& status) @@ -126,6 +133,9 @@ enum class Type { DIALOG, CONFERENCE }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Type) +#endif enum class Layout { GRID, diff --git a/src/api/conversationmodel.h b/src/api/conversationmodel.h index 0c498542..6aee13f8 100644 --- a/src/api/conversationmodel.h +++ b/src/api/conversationmodel.h @@ -40,6 +40,10 @@ class Database; namespace api { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif namespace account { struct Info; } namespace interaction { struct Info; } @@ -52,6 +56,9 @@ enum class ConferenceableItem { CALL, CONTACT }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(ConferenceableItem) +#endif struct AccountConversation { diff --git a/src/api/datatransfer.h b/src/api/datatransfer.h index 5d0dcf8a..e78788a7 100644 --- a/src/api/datatransfer.h +++ b/src/api/datatransfer.h @@ -28,6 +28,10 @@ namespace lrc { namespace api { namespace datatransfer { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif enum class Status { on_connection, // outgoing tx: wait for connection/acceptance, incoming tx: wait for local acceptance @@ -41,6 +45,9 @@ enum class Status { unsupported, // error: unable to do the transfer (generic error) INVALID }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Status) +#endif static inline const QString to_string(const Status& status) diff --git a/src/api/interaction.h b/src/api/interaction.h index fbb46741..956f5736 100644 --- a/src/api/interaction.h +++ b/src/api/interaction.h @@ -30,6 +30,10 @@ namespace api namespace interaction { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif enum class Type { INVALID, @@ -39,6 +43,9 @@ enum class Type { DATA_TRANSFER, COUNT__ }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Type) +#endif static inline const QString to_string(const Type& type) @@ -93,6 +100,9 @@ enum class Status { TRANSFER_FINISHED, COUNT__ }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Status) +#endif static inline const QString to_string(const Status& status) diff --git a/src/api/newvideo.h b/src/api/newvideo.h index 2c8b4259..c5163ede 100644 --- a/src/api/newvideo.h +++ b/src/api/newvideo.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (C) 2018-2020 Savoir-faire Linux Inc. * + * Copyright (C) 2018-2020 Savoir-faire Linux Inc. * * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> * * * * This library is free software; you can redistribute it and/or * @@ -45,6 +45,10 @@ namespace api namespace video { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif constexpr static const char PREVIEW_RENDERER_ID[] = "local"; @@ -71,13 +75,16 @@ struct Frame { unsigned int width { 0 }; }; -enum DeviceType +enum class DeviceType { CAMERA, DISPLAY, FILE, INVALID }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(DeviceType) +#endif /** * This class describes the current rendered device @@ -85,7 +92,7 @@ enum DeviceType struct RenderedDevice { QString name; - DeviceType type = INVALID; + DeviceType type = DeviceType::INVALID; }; /** diff --git a/src/api/profile.h b/src/api/profile.h index 681220d3..d08acf75 100644 --- a/src/api/profile.h +++ b/src/api/profile.h @@ -18,6 +18,7 @@ ***************************************************************************/ #pragma once +#include <QObject> #include <QString> namespace lrc @@ -28,6 +29,10 @@ namespace api namespace profile { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_NAMESPACE +Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") +#endif enum class Type { INVALID, @@ -37,6 +42,9 @@ enum class Type { TEMPORARY, COUNT__ }; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +Q_ENUM_NS(Type) +#endif static inline const QString to_string(const Type& type) -- GitLab