From 9592fb0caadd2d601a6f1d0e285cd80974188ca5 Mon Sep 17 00:00:00 2001 From: Konrad Kujawa Date: Fri, 12 May 2023 10:35:17 +0200 Subject: [PATCH] Remove QAbstractGrpcCredentials and QGrpcCredentials Remove unused parts of old credentials system. QAbstractGrpcCredentials and QGrpcCredentials provided combination class for both Channel and Call. Now, channel and call credentials are used separately in channel and call options. Task-number: QTBUG-111037 Change-Id: Id1e62c249148cb9bc1a66050308c23fdbae19735 Reviewed-by: Alexey Edelev --- src/grpc/CMakeLists.txt | 1 - src/grpc/qabstractgrpccredentials.cpp | 48 ---------------- src/grpc/qabstractgrpccredentials.h | 27 --------- src/grpc/qgrpcchannel.cpp | 1 - src/grpc/qgrpcchannel.h | 1 - src/grpc/qgrpcchannel_p.h | 1 - src/grpc/qgrpccredentials.cpp | 64 ++++------------------ src/grpc/qgrpccredentials.h | 60 ++------------------ src/grpc/qgrpchttp2channel.h | 1 - tests/auto/grpc/client/tst_grpc_client.cpp | 1 - 10 files changed, 15 insertions(+), 190 deletions(-) delete mode 100644 src/grpc/qabstractgrpccredentials.cpp delete mode 100644 src/grpc/qabstractgrpccredentials.h diff --git a/src/grpc/CMakeLists.txt b/src/grpc/CMakeLists.txt index 3b763116..0b7fd3e1 100644 --- a/src/grpc/CMakeLists.txt +++ b/src/grpc/CMakeLists.txt @@ -10,7 +10,6 @@ qt_internal_add_module(Grpc qabstractgrpcchannel.h qabstractgrpcchannel_p.h qabstractgrpcchannel.cpp qgrpchttp2channel.h qgrpchttp2channel.cpp qabstractgrpcclient.h qabstractgrpcclient.cpp - qabstractgrpccredentials.h qabstractgrpccredentials.cpp qgrpccredentials.h qgrpccredentials.cpp qgrpcuserpasswordcredentials.h qgrpcuserpasswordcredentials.cpp qgrpccalloptions.h qgrpccalloptions.cpp diff --git a/src/grpc/qabstractgrpccredentials.cpp b/src/grpc/qabstractgrpccredentials.cpp deleted file mode 100644 index 05053da8..00000000 --- a/src/grpc/qabstractgrpccredentials.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -#include "qabstractgrpccredentials.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QAbstractGrpcCredentials - \inmodule QtGrpc - \brief The QAbstractGrpcClient is an abstract storage class used by authentication parameters. - - QAbstractGrpcCredentials provides a set of functions to access the call and - the channel credentials that are used by gRPC channels to communicate with the services. - - You may implement this interface to create your own authentication provider class, but we - recommend using the QGrpcCredentials with QGrpcUserPasswordCredentials and QGrpcSslCredentials. -*/ - -/*! - \typealias QGrpcCredentialMap - \relates QAbstractGrpcCredentials - - Alias for \c{QMap}. - This is the key-value map of credentials, such as user-password credentials - or session parameters. -*/ - -/*! - \fn virtual QGrpcCredentialMap QAbstractGrpcCredentials::callCredentials() const = 0 - - This pure virtual function returns a key-value map of the credentials for RPC calls. - - This function is called to obtain the QGrpcCredentialMap for the call. -*/ - -/*! - \fn virtual QGrpcCredentialMap QAbstractGrpcCredentials::channelCredentials() const = 0 - - This pure virtual function shall return a key-value map of session parameters - for the specific channel. - - This function is called to obtain the QGrpcCredentialMap for the channel. -*/ - -QAbstractGrpcCredentials::~QAbstractGrpcCredentials() = default; - -QT_END_NAMESPACE diff --git a/src/grpc/qabstractgrpccredentials.h b/src/grpc/qabstractgrpccredentials.h deleted file mode 100644 index f16a2832..00000000 --- a/src/grpc/qabstractgrpccredentials.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// Copyright (C) 2019 Alexey Edelev -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -#ifndef QABSTRACTGRPCCREDENTIALS_H -#define QABSTRACTGRPCCREDENTIALS_H - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE -using QGrpcCredentialMap = QMap; - -class Q_GRPC_EXPORT QAbstractGrpcCredentials -{ -public: - virtual ~QAbstractGrpcCredentials(); - virtual QGrpcCredentialMap callCredentials() const = 0; - virtual QGrpcCredentialMap channelCredentials() const = 0; -}; - -QT_END_NAMESPACE - -#endif // QABSTRACTGRPCCREDENTIALS_H diff --git a/src/grpc/qgrpcchannel.cpp b/src/grpc/qgrpcchannel.cpp index 0bf0bc67..c1a800d4 100644 --- a/src/grpc/qgrpcchannel.cpp +++ b/src/grpc/qgrpcchannel.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/grpc/qgrpcchannel.h b/src/grpc/qgrpcchannel.h index e571feb8..a336ca30 100644 --- a/src/grpc/qgrpcchannel.h +++ b/src/grpc/qgrpcchannel.h @@ -15,7 +15,6 @@ QT_BEGIN_NAMESPACE -class QAbstractGrpcCredentials; struct QGrpcChannelPrivate; class Q_GRPC_EXPORT QGrpcChannel final : public QAbstractGrpcChannel diff --git a/src/grpc/qgrpcchannel_p.h b/src/grpc/qgrpcchannel_p.h index e4fa92cc..ecf5780e 100644 --- a/src/grpc/qgrpcchannel_p.h +++ b/src/grpc/qgrpcchannel_p.h @@ -17,7 +17,6 @@ // #include -#include #include #include #include diff --git a/src/grpc/qgrpccredentials.cpp b/src/grpc/qgrpccredentials.cpp index b7a378e7..e008ed44 100644 --- a/src/grpc/qgrpccredentials.cpp +++ b/src/grpc/qgrpccredentials.cpp @@ -6,6 +6,16 @@ QT_BEGIN_NAMESPACE +/*! + \typealias QGrpcCredentialMap + \relates QGrpcCallCredentials + \relates QGrpcChannelCredentials + + Alias for \c{QMap}. + This is the key-value map of credentials, such as user-password credentials + or session parameters. +*/ + /*! \class QGrpcCallCredentials \inmodule QtGrpc @@ -51,60 +61,6 @@ QT_BEGIN_NAMESPACE This function is called to obtain the QGrpcCredentialMap for the channel. */ -/*! - \class QGrpcCredentials - \inmodule QtGrpc - - \brief The QGrpcCredentials class is a combination of call - and channel credentials that is used by gRPC channels to communicate - with services, using the given authentication parameters. -*/ - -/*! - \fn template QGrpcCredentials::QGrpcCredentials(const Call &call, - const Channel &channel) - - Constructs QGrpcCredentials with \a call and \a channel credentials. - The Call type must be the base of QGrpcCallCredentials and - the Channel type must be the base of QGrpcChannelCredentials. -*/ - -/*! - \fn template QGrpcCredentials::QGrpcCredentials(const Call &call) - - Constructs QGrpcCredentials with \a call credentials. - The Call type must be the base of QGrpcCallCredentials. -*/ - -/*! - \fn template QGrpcCredentials::QGrpcCredentials(const Channel &channel) - - Constructs QGrpcCredentials with \a channel credentials. - The Channel type must be the base of QGrpcChannelCredentials. -*/ - -/*! - \fn template QGrpcCredentials::~QGrpcCredentials() - - Destroys the QGrpcCredentials object. -*/ - -/*! - \fn template QGrpcCredentialMap QGrpcCredentials::callCredentials() const - - Returns a map of call credentials by calling QGrpcCallCredentials::operator() - on a stored Call object. -*/ - -/*! - \fn template QGrpcCredentialMap QGrpcCredentials::channelCredentials() const - - Returns a map of channel credentials by calling QGrpcChannelCredentials::channelCredentials() - on a stored Channel object. -*/ - -const char *SslConfigCredential = "sslConfig"; - QGrpcCallCredentials::~QGrpcCallCredentials() = default; QGrpcChannelCredentials::~QGrpcChannelCredentials() = default; diff --git a/src/grpc/qgrpccredentials.h b/src/grpc/qgrpccredentials.h index 354c442c..71bd01b4 100644 --- a/src/grpc/qgrpccredentials.h +++ b/src/grpc/qgrpccredentials.h @@ -5,13 +5,16 @@ #ifndef QGRPCCREDENTIALS_H #define QGRPCCREDENTIALS_H -#include #include -#include +#include +#include +#include QT_BEGIN_NAMESPACE +using QGrpcCredentialMap = QMap; + class Q_GRPC_EXPORT QGrpcCallCredentials { public: @@ -26,59 +29,6 @@ public: virtual QGrpcCredentialMap channelCredentials() const = 0; }; -#ifdef Q_QDOC -template -#else -template , - std::is_base_of>, - int> = 0> -#endif -class QGrpcCredentials final : public QAbstractGrpcCredentials -{ -public: - explicit QGrpcCredentials(const Call &call, const Channel &channel) - : mCall(call), mChannel(channel) - { - } - explicit QGrpcCredentials(const Call &call) : mCall(call) { } - explicit QGrpcCredentials(const Channel &channel) : mChannel(channel) { } - ~QGrpcCredentials() override = default; - - QGrpcCredentialMap callCredentials() const override { return mCall(); } - - QGrpcCredentialMap channelCredentials() const override { return mChannel.channelCredentials(); } - -private: - QGrpcCredentials() = default; - - Call mCall; - Channel mChannel; -}; - -extern Q_GRPC_EXPORT const char *SslConfigCredential; - -template , - std::is_base_of>, - int> = 0> -std::unique_ptr operator|(const Call &call, const Channel &channel) -{ - return std::make_unique>(call, channel); -} - -template , - std::is_base_of>, - int> = 0> -std::unique_ptr operator|(const Channel &channel, const Call &call) -{ - return std::make_unique>(call, channel); -} - QT_END_NAMESPACE #endif // QGRPCCREDENTIALS_H diff --git a/src/grpc/qgrpchttp2channel.h b/src/grpc/qgrpchttp2channel.h index e0ef24bf..3c6cd712 100644 --- a/src/grpc/qgrpchttp2channel.h +++ b/src/grpc/qgrpchttp2channel.h @@ -13,7 +13,6 @@ QT_BEGIN_NAMESPACE -class QAbstractGrpcCredentials; struct QGrpcHttp2ChannelPrivate; class Q_GRPC_EXPORT QGrpcHttp2Channel final : public QAbstractGrpcChannel diff --git a/tests/auto/grpc/client/tst_grpc_client.cpp b/tests/auto/grpc/client/tst_grpc_client.cpp index e3ab7491..3096f765 100644 --- a/tests/auto/grpc/client/tst_grpc_client.cpp +++ b/tests/auto/grpc/client/tst_grpc_client.cpp @@ -6,7 +6,6 @@ #if QT_CONFIG(native_grpc) # include #endif -#include #include #include