YoutubeAuth.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <QObject>
  3. #include <QString>
  4. #include <random>
  5. #include <string>
  6. #include "auth-oauth.hpp"
  7. #ifdef BROWSER_AVAILABLE
  8. #include "window-dock-browser.hpp"
  9. #include <QHBoxLayout>
  10. class YoutubeChatDock : public BrowserDock {
  11. Q_OBJECT
  12. private:
  13. bool isLoggedIn;
  14. public:
  15. YoutubeChatDock(const QString &title) : BrowserDock(title) {}
  16. inline void SetWidget(QCefWidget *widget_)
  17. {
  18. BrowserDock::SetWidget(widget_);
  19. QWidget::connect(cefWidget.get(), &QCefWidget::urlChanged, this, &YoutubeChatDock::YoutubeCookieCheck);
  20. }
  21. private slots:
  22. void YoutubeCookieCheck();
  23. };
  24. #endif
  25. inline const std::vector<Auth::Def> youtubeServices = {{"YouTube - RTMP", Auth::Type::OAuth_LinkedAccount, true, true},
  26. {"YouTube - RTMPS", Auth::Type::OAuth_LinkedAccount, true, true},
  27. {"YouTube - HLS", Auth::Type::OAuth_LinkedAccount, true, true}};
  28. class YoutubeAuth : public OAuthStreamKey {
  29. Q_OBJECT
  30. bool uiLoaded = false;
  31. std::string section;
  32. #ifdef BROWSER_AVAILABLE
  33. YoutubeChatDock *chat = nullptr;
  34. #endif
  35. virtual bool RetryLogin() override;
  36. virtual void SaveInternal() override;
  37. virtual bool LoadInternal() override;
  38. virtual void LoadUI() override;
  39. QString GenerateState();
  40. public:
  41. YoutubeAuth(const Def &d);
  42. ~YoutubeAuth();
  43. void SetChatId(const QString &chat_id);
  44. void ResetChat();
  45. void ReloadChat();
  46. static std::shared_ptr<Auth> Login(QWidget *parent, const std::string &service);
  47. };