New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -7,9 +7,9 @@
|
|||
#include <qt-wrappers.hpp>
|
||||
#include <obs-app.hpp>
|
||||
|
||||
#include "window-dock-browser.hpp"
|
||||
#include "window-basic-main.hpp"
|
||||
#include "remote-text.hpp"
|
||||
#include "window-dock.hpp"
|
||||
|
||||
#include <json11.hpp>
|
||||
|
||||
|
|
@ -18,41 +18,30 @@
|
|||
|
||||
using namespace json11;
|
||||
|
||||
#include <browser-panel.hpp>
|
||||
extern QCef *cef;
|
||||
extern QCefCookieManager *panel_cookies;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define TWITCH_AUTH_URL \
|
||||
"https://obsproject.com/app-auth/twitch?action=redirect"
|
||||
#define TWITCH_TOKEN_URL \
|
||||
"https://obsproject.com/app-auth/twitch-token"
|
||||
#define ACCEPT_HEADER \
|
||||
"Accept: application/vnd.twitchtv.v5+json"
|
||||
#define TWITCH_AUTH_URL "https://obsproject.com/app-auth/twitch?action=redirect"
|
||||
#define TWITCH_TOKEN_URL "https://obsproject.com/app-auth/twitch-token"
|
||||
#define ACCEPT_HEADER "Accept: application/vnd.twitchtv.v5+json"
|
||||
|
||||
#define TWITCH_SCOPE_VERSION 1
|
||||
|
||||
static Auth::Def twitchDef = {
|
||||
"Twitch",
|
||||
Auth::Type::OAuth_StreamKey
|
||||
};
|
||||
static Auth::Def twitchDef = {"Twitch", Auth::Type::OAuth_StreamKey};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TwitchAuth::TwitchAuth(const Def &d)
|
||||
: OAuthStreamKey(d)
|
||||
TwitchAuth::TwitchAuth(const Def &d) : OAuthStreamKey(d)
|
||||
{
|
||||
if (!cef)
|
||||
return;
|
||||
|
||||
cef->add_popup_whitelist_url(
|
||||
"https://twitch.tv/popout/frankerfacez/chat?ffz-settings",
|
||||
this);
|
||||
"https://twitch.tv/popout/frankerfacez/chat?ffz-settings",
|
||||
this);
|
||||
uiLoadTimer.setSingleShot(true);
|
||||
uiLoadTimer.setInterval(500);
|
||||
connect(&uiLoadTimer, &QTimer::timeout,
|
||||
this, &TwitchAuth::TryLoadSecondaryUIPanes);
|
||||
connect(&uiLoadTimer, &QTimer::timeout, this,
|
||||
&TwitchAuth::TryLoadSecondaryUIPanes);
|
||||
}
|
||||
|
||||
bool TwitchAuth::GetChannelInfo()
|
||||
|
|
@ -82,33 +71,25 @@ try {
|
|||
|
||||
bool success = false;
|
||||
|
||||
auto func = [&] () {
|
||||
success = GetRemoteFile(
|
||||
"https://api.twitch.tv/kraken/channel",
|
||||
output,
|
||||
error,
|
||||
&error_code,
|
||||
"application/json",
|
||||
nullptr,
|
||||
headers,
|
||||
nullptr,
|
||||
5);
|
||||
auto func = [&]() {
|
||||
success = GetRemoteFile("https://api.twitch.tv/kraken/channel",
|
||||
output, error, &error_code,
|
||||
"application/json", nullptr, headers,
|
||||
nullptr, 5);
|
||||
};
|
||||
|
||||
ExecThreadedWithoutBlocking(
|
||||
func,
|
||||
QTStr("Auth.LoadingChannel.Title"),
|
||||
QTStr("Auth.LoadingChannel.Text").arg(service()));
|
||||
func, QTStr("Auth.LoadingChannel.Title"),
|
||||
QTStr("Auth.LoadingChannel.Text").arg(service()));
|
||||
if (error_code == 403) {
|
||||
OBSMessageBox::warning(OBSBasic::Get(),
|
||||
Str("TwitchAuth.TwoFactorFail.Title"),
|
||||
Str("TwitchAuth.TwoFactorFail.Text"),
|
||||
true);
|
||||
blog(LOG_WARNING, "%s: %s",
|
||||
__FUNCTION__,
|
||||
"Got 403 from Twitch, user probably does not "
|
||||
"have two-factor authentication enabled on "
|
||||
"their account");
|
||||
Str("TwitchAuth.TwoFactorFail.Title"),
|
||||
Str("TwitchAuth.TwoFactorFail.Text"),
|
||||
true);
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Got 403 from Twitch, user probably does not "
|
||||
"have two-factor authentication enabled on "
|
||||
"their account");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -125,10 +106,10 @@ try {
|
|||
if (RetryLogin()) {
|
||||
return GetChannelInfo();
|
||||
}
|
||||
throw ErrorInfo(error,
|
||||
json["message"].string_value());
|
||||
throw ErrorInfo(error, json["message"].string_value());
|
||||
}
|
||||
throw ErrorInfo(error, json["error_description"].string_value());
|
||||
throw ErrorInfo(error,
|
||||
json["error_description"].string_value());
|
||||
}
|
||||
|
||||
name = json["name"].string_value();
|
||||
|
|
@ -138,14 +119,13 @@ try {
|
|||
} catch (ErrorInfo info) {
|
||||
QString title = QTStr("Auth.ChannelFailure.Title");
|
||||
QString text = QTStr("Auth.ChannelFailure.Text")
|
||||
.arg(service(), info.message.c_str(), info.error.c_str());
|
||||
.arg(service(), info.message.c_str(),
|
||||
info.error.c_str());
|
||||
|
||||
QMessageBox::warning(OBSBasic::Get(), title, text);
|
||||
|
||||
blog(LOG_WARNING, "%s: %s: %s",
|
||||
__FUNCTION__,
|
||||
info.message.c_str(),
|
||||
info.error.c_str());
|
||||
blog(LOG_WARNING, "%s: %s: %s", __FUNCTION__, info.message.c_str(),
|
||||
info.error.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -155,15 +135,13 @@ void TwitchAuth::SaveInternal()
|
|||
config_set_string(main->Config(), service(), "Name", name.c_str());
|
||||
if (uiLoaded) {
|
||||
config_set_string(main->Config(), service(), "DockState",
|
||||
main->saveState().toBase64().constData());
|
||||
main->saveState().toBase64().constData());
|
||||
}
|
||||
OAuthStreamKey::SaveInternal();
|
||||
}
|
||||
|
||||
static inline std::string get_config_str(
|
||||
OBSBasic *main,
|
||||
const char *section,
|
||||
const char *name)
|
||||
static inline std::string get_config_str(OBSBasic *main, const char *section,
|
||||
const char *name)
|
||||
{
|
||||
const char *val = config_get_string(main->Config(), section, name);
|
||||
return val ? val : "";
|
||||
|
|
@ -180,19 +158,6 @@ bool TwitchAuth::LoadInternal()
|
|||
return OAuthStreamKey::LoadInternal();
|
||||
}
|
||||
|
||||
class TwitchWidget : public OBSDock {
|
||||
public:
|
||||
inline TwitchWidget() : OBSDock() {}
|
||||
|
||||
QScopedPointer<QCefWidget> widget;
|
||||
|
||||
inline void SetWidget(QCefWidget *widget_)
|
||||
{
|
||||
setWidget(widget_);
|
||||
widget.reset(widget_);
|
||||
}
|
||||
};
|
||||
|
||||
static const char *ffz_script = "\
|
||||
var ffz = document.createElement('script');\
|
||||
ffz.setAttribute('src','https://cdn.frankerfacez.com/script/script.min.js');\
|
||||
|
|
@ -240,7 +205,7 @@ void TwitchAuth::LoadUI()
|
|||
QSize size = main->frameSize();
|
||||
QPoint pos = main->pos();
|
||||
|
||||
chat.reset(new TwitchWidget());
|
||||
chat.reset(new BrowserDock());
|
||||
chat->setObjectName("twitchChat");
|
||||
chat->resize(300, 600);
|
||||
chat->setMinimumSize(200, 300);
|
||||
|
|
@ -266,8 +231,8 @@ void TwitchAuth::LoadUI()
|
|||
if (firstLoad) {
|
||||
chat->setVisible(true);
|
||||
} else {
|
||||
const char *dockStateStr = config_get_string(main->Config(),
|
||||
service(), "DockState");
|
||||
const char *dockStateStr = config_get_string(
|
||||
main->Config(), service(), "DockState");
|
||||
QByteArray dockState =
|
||||
QByteArray::fromBase64(QByteArray(dockStateStr));
|
||||
main->restoreState(dockState);
|
||||
|
|
@ -304,7 +269,7 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
|||
url += name;
|
||||
url += "/dashboard/live/stream-info";
|
||||
|
||||
info.reset(new TwitchWidget());
|
||||
info.reset(new BrowserDock());
|
||||
info->setObjectName("twitchInfo");
|
||||
info->resize(300, 650);
|
||||
info->setMinimumSize(200, 300);
|
||||
|
|
@ -324,7 +289,7 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
|||
url += name;
|
||||
url += "/dashboard/live/stats";
|
||||
|
||||
stat.reset(new TwitchWidget());
|
||||
stat.reset(new BrowserDock());
|
||||
stat->setObjectName("twitchStats");
|
||||
stat->resize(200, 250);
|
||||
stat->setMinimumSize(200, 150);
|
||||
|
|
@ -344,7 +309,7 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
|||
url += name;
|
||||
url += "/dashboard/live/activity-feed";
|
||||
|
||||
feed.reset(new TwitchWidget());
|
||||
feed.reset(new BrowserDock());
|
||||
feed->setObjectName("twitchFeed");
|
||||
feed->resize(300, 650);
|
||||
feed->setMinimumSize(200, 300);
|
||||
|
|
@ -367,8 +332,8 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
|||
QSize statSize = stat->frameSize();
|
||||
|
||||
info->move(pos.x() + 50, pos.y() + 50);
|
||||
stat->move(pos.x() + size.width() / 2 - statSize.width() / 2,
|
||||
pos.y() + size.height() / 2 - statSize.height() / 2);
|
||||
stat->move(pos.x() + size.width() / 2 - statSize.width() / 2,
|
||||
pos.y() + size.height() / 2 - statSize.height() / 2);
|
||||
feed->move(pos.x() + 100, pos.y() + 100);
|
||||
|
||||
if (firstLoad) {
|
||||
|
|
@ -376,15 +341,15 @@ void TwitchAuth::LoadSecondaryUIPanes()
|
|||
stat->setVisible(false);
|
||||
feed->setVisible(false);
|
||||
} else {
|
||||
uint32_t lastVersion = config_get_int(App()->GlobalConfig(), "General",
|
||||
"LastVersion");
|
||||
uint32_t lastVersion = config_get_int(App()->GlobalConfig(),
|
||||
"General", "LastVersion");
|
||||
|
||||
if (lastVersion <= MAKE_SEMANTIC_VERSION(23, 0, 2)) {
|
||||
feed->setVisible(false);
|
||||
}
|
||||
|
||||
const char *dockStateStr = config_get_string(main->Config(),
|
||||
service(), "DockState");
|
||||
const char *dockStateStr = config_get_string(
|
||||
main->Config(), service(), "DockState");
|
||||
QByteArray dockState =
|
||||
QByteArray::fromBase64(QByteArray(dockStateStr));
|
||||
main->restoreState(dockState);
|
||||
|
|
@ -405,21 +370,21 @@ void TwitchAuth::TryLoadSecondaryUIPanes()
|
|||
{
|
||||
QPointer<TwitchAuth> this_ = this;
|
||||
|
||||
auto cb = [this_] (bool found)
|
||||
{
|
||||
auto cb = [this_](bool found) {
|
||||
if (!this_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
QMetaObject::invokeMethod(&this_->uiLoadTimer,
|
||||
"start");
|
||||
QMetaObject::invokeMethod(&this_->uiLoadTimer, "start");
|
||||
} else {
|
||||
QMetaObject::invokeMethod(this_, "LoadSecondaryUIPanes");
|
||||
QMetaObject::invokeMethod(this_,
|
||||
"LoadSecondaryUIPanes");
|
||||
}
|
||||
};
|
||||
|
||||
panel_cookies->CheckForCookie("https://www.twitch.tv", "auth-token", cb);
|
||||
panel_cookies->CheckForCookie("https://www.twitch.tv", "auth-token",
|
||||
cb);
|
||||
}
|
||||
|
||||
bool TwitchAuth::RetryLogin()
|
||||
|
|
@ -429,7 +394,8 @@ bool TwitchAuth::RetryLogin()
|
|||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<TwitchAuth> auth = std::make_shared<TwitchAuth>(twitchDef);
|
||||
std::shared_ptr<TwitchAuth> auth =
|
||||
std::make_shared<TwitchAuth>(twitchDef);
|
||||
std::string client_id = TWITCH_CLIENTID;
|
||||
deobfuscate_str(&client_id[0], TWITCH_HASH);
|
||||
|
||||
|
|
@ -444,13 +410,14 @@ std::shared_ptr<Auth> TwitchAuth::Login(QWidget *parent)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<TwitchAuth> auth = std::make_shared<TwitchAuth>(twitchDef);
|
||||
std::shared_ptr<TwitchAuth> auth =
|
||||
std::make_shared<TwitchAuth>(twitchDef);
|
||||
|
||||
std::string client_id = TWITCH_CLIENTID;
|
||||
deobfuscate_str(&client_id[0], TWITCH_HASH);
|
||||
|
||||
if (!auth->GetToken(TWITCH_TOKEN_URL, client_id, TWITCH_SCOPE_VERSION,
|
||||
QT_TO_UTF8(login.GetCode()))) {
|
||||
QT_TO_UTF8(login.GetCode()))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -475,9 +442,6 @@ static void DeleteCookies()
|
|||
|
||||
void RegisterTwitchAuth()
|
||||
{
|
||||
OAuth::RegisterOAuth(
|
||||
twitchDef,
|
||||
CreateTwitchAuth,
|
||||
TwitchAuth::Login,
|
||||
DeleteCookies);
|
||||
OAuth::RegisterOAuth(twitchDef, CreateTwitchAuth, TwitchAuth::Login,
|
||||
DeleteCookies);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue