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. void SetWidget(QCefWidget *widget_);
  20. void SetApiChatId(const std::string &id);
  21. private slots:
  22. void SendChatMessage();
  23. void ShowErrorMessage(const QString &error);
  24. void EnableChatInput();
  25. };
  26. #endif
  27. inline const std::vector<Auth::Def> youtubeServices = {
  28. {"YouTube - RTMP", Auth::Type::OAuth_LinkedAccount, true, true},
  29. {"YouTube - RTMPS", Auth::Type::OAuth_LinkedAccount, true, true},
  30. {"YouTube - HLS", Auth::Type::OAuth_LinkedAccount, true, true}};
  31. class YoutubeAuth : public OAuthStreamKey {
  32. Q_OBJECT
  33. bool uiLoaded = false;
  34. std::mt19937 randomSeed;
  35. std::string section;
  36. #ifdef BROWSER_AVAILABLE
  37. QSharedPointer<YoutubeChatDock> chat;
  38. QSharedPointer<QAction> chatMenu;
  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. 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. };