auth-youtube.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 "lineedit-autoresize.hpp"
  10. #include <QHBoxLayout>
  11. class YoutubeChatDock : public BrowserDock {
  12. Q_OBJECT
  13. private:
  14. std::string apiChatId;
  15. bool isLoggedIn;
  16. LineEditAutoResize *lineEdit;
  17. QPushButton *sendButton;
  18. QHBoxLayout *chatLayout;
  19. public:
  20. YoutubeChatDock(const QString &title);
  21. void SetWidget(QCefWidget *widget_);
  22. void SetApiChatId(const std::string &id);
  23. private slots:
  24. void YoutubeCookieCheck();
  25. void SendChatMessage();
  26. void ShowErrorMessage(const QString &error);
  27. void EnableChatInput(bool visible);
  28. };
  29. #endif
  30. inline const std::vector<Auth::Def> youtubeServices = {{"YouTube - RTMP", Auth::Type::OAuth_LinkedAccount, true, true},
  31. {"YouTube - RTMPS", Auth::Type::OAuth_LinkedAccount, true, true},
  32. {"YouTube - HLS", Auth::Type::OAuth_LinkedAccount, true, true}};
  33. class YoutubeAuth : public OAuthStreamKey {
  34. Q_OBJECT
  35. bool uiLoaded = false;
  36. std::string section;
  37. #ifdef BROWSER_AVAILABLE
  38. YoutubeChatDock *chat = nullptr;
  39. #endif
  40. virtual bool RetryLogin() override;
  41. virtual void SaveInternal() override;
  42. virtual bool LoadInternal() override;
  43. virtual void LoadUI() override;
  44. QString GenerateState();
  45. public:
  46. YoutubeAuth(const Def &d);
  47. ~YoutubeAuth();
  48. void SetChatId(const QString &chat_id, const std::string &api_chat_id);
  49. void ResetChat();
  50. void ReloadChat();
  51. static std::shared_ptr<Auth> Login(QWidget *parent, const std::string &service);
  52. };