Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions UI/auth-restream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,28 @@ using namespace json11;
#define RESTREAM_STREAMKEY_URL "https://api.restream.io/v2/user/streamKey"
#define RESTREAM_SCOPE_VERSION 1

#define RESTREAM_CHAT_DOCK_NAME "restreamChat"
#define RESTREAM_INFO_DOCK_NAME "restreamInfo"
#define RESTREAM_CHANNELS_DOCK_NAME "restreamChannel"

static Auth::Def restreamDef = {"Restream", Auth::Type::OAuth_StreamKey};

/* ------------------------------------------------------------------------- */

RestreamAuth::RestreamAuth(const Def &d) : OAuthStreamKey(d) {}

RestreamAuth::~RestreamAuth()
{
if (!uiLoaded)
return;

OBSBasic *main = OBSBasic::Get();

main->RemoveDockWidget(RESTREAM_CHAT_DOCK_NAME);
main->RemoveDockWidget(RESTREAM_INFO_DOCK_NAME);
main->RemoveDockWidget(RESTREAM_CHANNELS_DOCK_NAME);
}

bool RestreamAuth::GetChannelInfo()
try {
std::string client_id = RESTREAM_CLIENTID;
Expand Down Expand Up @@ -134,52 +150,49 @@ void RestreamAuth::LoadUI()
QSize size = main->frameSize();
QPoint pos = main->pos();

chat.reset(new BrowserDock());
chat->setObjectName("restreamChat");
BrowserDock *chat = new BrowserDock();
chat->setObjectName(RESTREAM_CHAT_DOCK_NAME);
chat->resize(420, 600);
chat->setMinimumSize(200, 300);
chat->setWindowTitle(QTStr("Auth.Chat"));
chat->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(chat.data(), url, panel_cookies);
browser = cef->create_widget(chat, url, panel_cookies);
chat->SetWidget(browser);

main->addDockWidget(Qt::RightDockWidgetArea, chat.data());
chatMenu.reset(main->AddDockWidget(chat.data()));
main->AddDockWidget(chat, Qt::RightDockWidgetArea);

/* ----------------------------------- */

url = "https://restream.io/titles/embed";

info.reset(new BrowserDock());
info->setObjectName("restreamInfo");
BrowserDock *info = new BrowserDock();
info->setObjectName(RESTREAM_INFO_DOCK_NAME);
info->resize(410, 600);
info->setMinimumSize(200, 150);
info->setWindowTitle(QTStr("Auth.StreamInfo"));
info->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(info.data(), url, panel_cookies);
browser = cef->create_widget(info, url, panel_cookies);
info->SetWidget(browser);

main->addDockWidget(Qt::LeftDockWidgetArea, info.data());
infoMenu.reset(main->AddDockWidget(info.data()));
main->AddDockWidget(info, Qt::LeftDockWidgetArea);

/* ----------------------------------- */

url = "https://restream.io/channel/embed";

channels.reset(new BrowserDock());
channels->setObjectName("restreamChannel");
BrowserDock *channels = new BrowserDock();
channels->setObjectName(RESTREAM_CHANNELS_DOCK_NAME);
channels->resize(410, 600);
channels->setMinimumSize(410, 300);
channels->setWindowTitle(QTStr("RestreamAuth.Channels"));
channels->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(channels.data(), url, panel_cookies);
browser = cef->create_widget(channels, url, panel_cookies);
channels->SetWidget(browser);

main->addDockWidget(Qt::LeftDockWidgetArea, channels.data());
channelMenu.reset(main->AddDockWidget(channels.data()));
main->AddDockWidget(channels, Qt::LeftDockWidgetArea);

/* ----------------------------------- */

Expand Down
9 changes: 1 addition & 8 deletions UI/auth-restream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ class BrowserDock;
class RestreamAuth : public OAuthStreamKey {
Q_OBJECT

QSharedPointer<BrowserDock> chat;
QSharedPointer<BrowserDock> info;
QSharedPointer<BrowserDock> channels;

QSharedPointer<QAction> chatMenu;
QSharedPointer<QAction> infoMenu;
QSharedPointer<QAction> channelMenu;

bool uiLoaded = false;

virtual bool RetryLogin() override;
Expand All @@ -28,6 +20,7 @@ class RestreamAuth : public OAuthStreamKey {

public:
RestreamAuth(const Def &d);
~RestreamAuth();

static std::shared_ptr<Auth> Login(QWidget *parent,
const std::string &service_name);
Expand Down
76 changes: 45 additions & 31 deletions UI/auth-twitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ using namespace json11;

#define TWITCH_SCOPE_VERSION 1

#define TWITCH_CHAT_DOCK_NAME "twitchChat"
#define TWITCH_INFO_DOCK_NAME "twitchInfo"
#define TWITCH_STATS_DOCK_NAME "twitchStats"
#define TWITCH_FEED_DOCK_NAME "twitchFeed"

static Auth::Def twitchDef = {"Twitch", Auth::Type::OAuth_StreamKey};

/* ------------------------------------------------------------------------- */
Expand All @@ -49,6 +54,19 @@ TwitchAuth::TwitchAuth(const Def &d) : OAuthStreamKey(d)
&TwitchAuth::TryLoadSecondaryUIPanes);
}

TwitchAuth::~TwitchAuth()
{
if (!uiLoaded)
return;

OBSBasic *main = OBSBasic::Get();

main->RemoveDockWidget(TWITCH_CHAT_DOCK_NAME);
main->RemoveDockWidget(TWITCH_INFO_DOCK_NAME);
main->RemoveDockWidget(TWITCH_STATS_DOCK_NAME);
main->RemoveDockWidget(TWITCH_FEED_DOCK_NAME);
}

bool TwitchAuth::MakeApiRequest(const char *path, Json &json_out)
{
std::string client_id = TWITCH_CLIENTID;
Expand Down Expand Up @@ -233,16 +251,16 @@ void TwitchAuth::LoadUI()
QSize size = main->frameSize();
QPoint pos = main->pos();

chat.reset(new BrowserDock());
chat->setObjectName("twitchChat");
BrowserDock *chat = new BrowserDock();
chat->setObjectName(TWITCH_CHAT_DOCK_NAME);
chat->resize(300, 600);
chat->setMinimumSize(200, 300);
chat->setWindowTitle(QTStr("Auth.Chat"));
chat->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(chat.data(), url, panel_cookies);
browser = cef->create_widget(chat, url, panel_cookies);
chat->SetWidget(browser);
cef->add_force_popup_url(moderation_tools_url, chat.data());
cef->add_force_popup_url(moderation_tools_url, chat);

if (App()->IsThemeDark()) {
script = "localStorage.setItem('twilight.theme', 1);";
Expand All @@ -261,8 +279,7 @@ void TwitchAuth::LoadUI()

browser->setStartupScript(script);

main->addDockWidget(Qt::RightDockWidgetArea, chat.data());
chatMenu.reset(main->AddDockWidget(chat.data()));
main->AddDockWidget(chat, Qt::RightDockWidgetArea);

/* ----------------------------------- */

Expand Down Expand Up @@ -323,39 +340,37 @@ void TwitchAuth::LoadSecondaryUIPanes()
url += name;
url += "/stream-manager/edit-stream-info";

info.reset(new BrowserDock());
info->setObjectName("twitchInfo");
BrowserDock *info = new BrowserDock();
info->setObjectName(TWITCH_INFO_DOCK_NAME);
info->resize(300, 650);
info->setMinimumSize(200, 300);
info->setWindowTitle(QTStr("Auth.StreamInfo"));
info->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(info.data(), url, panel_cookies);
browser = cef->create_widget(info, url, panel_cookies);
info->SetWidget(browser);
browser->setStartupScript(script);

main->addDockWidget(Qt::RightDockWidgetArea, info.data());
infoMenu.reset(main->AddDockWidget(info.data()));
main->AddDockWidget(info, Qt::RightDockWidgetArea);

/* ----------------------------------- */

url = "https://www.twitch.tv/popout/";
url += name;
url += "/dashboard/live/stats";

stat.reset(new BrowserDock());
stat->setObjectName("twitchStats");
stat->resize(200, 250);
stat->setMinimumSize(200, 150);
stat->setWindowTitle(QTStr("TwitchAuth.Stats"));
stat->setAllowedAreas(Qt::AllDockWidgetAreas);
BrowserDock *stats = new BrowserDock();
stats->setObjectName(TWITCH_STATS_DOCK_NAME);
stats->resize(200, 250);
stats->setMinimumSize(200, 150);
stats->setWindowTitle(QTStr("TwitchAuth.Stats"));
stats->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(stat.data(), url, panel_cookies);
stat->SetWidget(browser);
browser = cef->create_widget(stats, url, panel_cookies);
stats->SetWidget(browser);
browser->setStartupScript(script);

main->addDockWidget(Qt::RightDockWidgetArea, stat.data());
statMenu.reset(main->AddDockWidget(stat.data()));
main->AddDockWidget(stats, Qt::RightDockWidgetArea);

/* ----------------------------------- */

Expand All @@ -364,36 +379,35 @@ void TwitchAuth::LoadSecondaryUIPanes()
url += "/stream-manager/activity-feed";
url += "?uuid=" + uuid;

feed.reset(new BrowserDock());
feed->setObjectName("twitchFeed");
BrowserDock *feed = new BrowserDock();
feed->setObjectName(TWITCH_FEED_DOCK_NAME);
feed->resize(300, 650);
feed->setMinimumSize(200, 300);
feed->setWindowTitle(QTStr("TwitchAuth.Feed"));
feed->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(feed.data(), url, panel_cookies);
browser = cef->create_widget(feed, url, panel_cookies);
feed->SetWidget(browser);
browser->setStartupScript(script);

main->addDockWidget(Qt::RightDockWidgetArea, feed.data());
feedMenu.reset(main->AddDockWidget(feed.data()));
main->AddDockWidget(feed, Qt::RightDockWidgetArea);

/* ----------------------------------- */

info->setFloating(true);
stat->setFloating(true);
stats->setFloating(true);
feed->setFloating(true);

QSize statSize = stat->frameSize();
QSize statSize = stats->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);
stats->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) {
info->setVisible(true);
stat->setVisible(false);
stats->setVisible(false);
feed->setVisible(false);
} else {
uint32_t lastVersion = config_get_int(App()->GlobalConfig(),
Expand Down
9 changes: 1 addition & 8 deletions UI/auth-twitch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ class TwitchAuth : public OAuthStreamKey {

friend class TwitchLogin;

QSharedPointer<BrowserDock> chat;
QSharedPointer<BrowserDock> info;
QSharedPointer<BrowserDock> stat;
QSharedPointer<BrowserDock> feed;
QSharedPointer<QAction> chatMenu;
QSharedPointer<QAction> infoMenu;
QSharedPointer<QAction> statMenu;
QSharedPointer<QAction> feedMenu;
bool uiLoaded = false;

std::string name;
Expand All @@ -40,6 +32,7 @@ class TwitchAuth : public OAuthStreamKey {

public:
TwitchAuth(const Def &d);
~TwitchAuth();

static std::shared_ptr<Auth> Login(QWidget *parent,
const std::string &service_name);
Expand Down
24 changes: 19 additions & 5 deletions UI/auth-youtube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ using namespace json11;
#define YOUTUBE_CHAT_POPOUT_URL \
"https://www.youtube.com/live_chat?is_popout=1&dark_theme=1&v=%1"

#define YOUTUBE_CHAT_DOCK_NAME "ytChat"

static const char allowedChars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
static const int allowedCount = static_cast<int>(sizeof(allowedChars) - 1);
Expand Down Expand Up @@ -71,6 +73,19 @@ YoutubeAuth::YoutubeAuth(const Def &d)
{
}

YoutubeAuth::~YoutubeAuth()
{
if (!uiLoaded)
return;

#ifdef BROWSER_AVAILABLE
OBSBasic *main = OBSBasic::Get();

main->RemoveDockWidget(YOUTUBE_CHAT_DOCK_NAME);
chat = nullptr;
#endif
}

bool YoutubeAuth::RetryLogin()
{
return true;
Expand Down Expand Up @@ -139,20 +154,19 @@ void YoutubeAuth::LoadUI()
QSize size = main->frameSize();
QPoint pos = main->pos();

chat.reset(new YoutubeChatDock());
chat->setObjectName("ytChat");
chat = new YoutubeChatDock();
chat->setObjectName(YOUTUBE_CHAT_DOCK_NAME);
chat->resize(300, 600);
chat->setMinimumSize(200, 300);
chat->setWindowTitle(QTStr("Auth.Chat"));
chat->setAllowedAreas(Qt::AllDockWidgetAreas);

browser = cef->create_widget(chat.data(), YOUTUBE_CHAT_PLACEHOLDER_URL,
browser = cef->create_widget(chat, YOUTUBE_CHAT_PLACEHOLDER_URL,
panel_cookies);
browser->setStartupScript(ytchat_script);

chat->SetWidget(browser);
main->addDockWidget(Qt::RightDockWidgetArea, chat.data());
chatMenu.reset(main->AddDockWidget(chat.data()));
main->AddDockWidget(chat, Qt::RightDockWidgetArea);

chat->setFloating(true);
chat->move(pos.x() + size.width() - chat->width() - 50, pos.y() + 50);
Expand Down
4 changes: 2 additions & 2 deletions UI/auth-youtube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class YoutubeAuth : public OAuthStreamKey {
std::string section;

#ifdef BROWSER_AVAILABLE
QSharedPointer<YoutubeChatDock> chat;
QSharedPointer<QAction> chatMenu;
YoutubeChatDock *chat;
#endif

virtual bool RetryLogin() override;
Expand All @@ -56,6 +55,7 @@ class YoutubeAuth : public OAuthStreamKey {

public:
YoutubeAuth(const Def &d);
~YoutubeAuth();

void SetChatId(const QString &chat_id, const std::string &api_chat_id);
void ResetChat();
Expand Down
Loading