auth-youtube.hpp 1.5 KB

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