auth-youtube.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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::string section;
  35. #ifdef BROWSER_AVAILABLE
  36. QSharedPointer<YoutubeChatDock> chat;
  37. QSharedPointer<QAction> chatMenu;
  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. void SetChatId(const QString &chat_id, const std::string &api_chat_id);
  47. void ResetChat();
  48. static std::shared_ptr<Auth> Login(QWidget *parent,
  49. const std::string &service);
  50. };