From 63ad0642aecda908ce1887a8ca1e47d242b98e36 Mon Sep 17 00:00:00 2001 From: Yuriy Chumak Date: Sun, 27 Jun 2021 05:01:50 -0700 Subject: [PATCH] UI: Specify exact service to auth login callbacks (Jim note: This gives the ability for auth login callbacks to know which specific service type is being used. For example, with something like YouTube, there's multiple variants: RTMP, RTMPS, and HLS. This way, the service login callback can determine how it wants to treat the login procedure depending on the specific type of service.) --- UI/auth-oauth.cpp | 2 +- UI/auth-oauth.hpp | 4 +++- UI/auth-restream.cpp | 2 +- UI/auth-restream.hpp | 3 ++- UI/auth-twitch.cpp | 2 +- UI/auth-twitch.hpp | 3 ++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/UI/auth-oauth.cpp b/UI/auth-oauth.cpp index 8c94a11fd..d2c15322e 100644 --- a/UI/auth-oauth.cpp +++ b/UI/auth-oauth.cpp @@ -120,7 +120,7 @@ std::shared_ptr OAuth::Login(QWidget *parent, const std::string &service) { for (auto &a : loginCBs) { if (service.find(a.def.service) != std::string::npos) { - return a.login(parent); + return a.login(parent, service); } } diff --git a/UI/auth-oauth.hpp b/UI/auth-oauth.hpp index 7cf7dc403..7421cfedb 100644 --- a/UI/auth-oauth.hpp +++ b/UI/auth-oauth.hpp @@ -35,7 +35,9 @@ class OAuth : public Auth { public: inline OAuth(const Def &d) : Auth(d) {} - typedef std::function(QWidget *)> login_cb; + typedef std::function( + QWidget *, const std::string &service_name)> + login_cb; typedef std::function delete_cookies_cb; static std::shared_ptr Login(QWidget *parent, diff --git a/UI/auth-restream.cpp b/UI/auth-restream.cpp index 1429bef6d..e57304d0f 100644 --- a/UI/auth-restream.cpp +++ b/UI/auth-restream.cpp @@ -225,7 +225,7 @@ bool RestreamAuth::RetryLogin() QT_TO_UTF8(login.GetCode()), true); } -std::shared_ptr RestreamAuth::Login(QWidget *parent) +std::shared_ptr RestreamAuth::Login(QWidget *parent, const std::string &) { OAuthLogin login(parent, RESTREAM_AUTH_URL, false); cef->add_popup_whitelist_url("about:blank", &login); diff --git a/UI/auth-restream.hpp b/UI/auth-restream.hpp index 65e52ff76..6216e7410 100644 --- a/UI/auth-restream.hpp +++ b/UI/auth-restream.hpp @@ -29,5 +29,6 @@ class RestreamAuth : public OAuthStreamKey { public: RestreamAuth(const Def &d); - static std::shared_ptr Login(QWidget *parent); + static std::shared_ptr Login(QWidget *parent, + const std::string &service_name); }; diff --git a/UI/auth-twitch.cpp b/UI/auth-twitch.cpp index 91bd6861a..5b3358f87 100644 --- a/UI/auth-twitch.cpp +++ b/UI/auth-twitch.cpp @@ -423,7 +423,7 @@ bool TwitchAuth::RetryLogin() QT_TO_UTF8(login.GetCode()), true); } -std::shared_ptr TwitchAuth::Login(QWidget *parent) +std::shared_ptr TwitchAuth::Login(QWidget *parent, const std::string &) { OAuthLogin login(parent, TWITCH_AUTH_URL, false); if (login.exec() == QDialog::Rejected) { diff --git a/UI/auth-twitch.hpp b/UI/auth-twitch.hpp index cc4079b72..ec2773aba 100644 --- a/UI/auth-twitch.hpp +++ b/UI/auth-twitch.hpp @@ -38,7 +38,8 @@ class TwitchAuth : public OAuthStreamKey { public: TwitchAuth(const Def &d); - static std::shared_ptr Login(QWidget *parent); + static std::shared_ptr Login(QWidget *parent, + const std::string &service_name); QTimer uiLoadTimer;