ImageBoard.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include "Page.hpp"
  3. namespace QuickMedia {
  4. struct PostResult {
  5. enum class Type {
  6. OK,
  7. TRY_AGAIN,
  8. INVALID_CAPTCHA,
  9. BANNED,
  10. //FILE_TOO_LARGE,
  11. NO_SUCH_FILE,
  12. FILE_TYPE_NOT_ALLOWED,
  13. UPLOAD_FAILED,
  14. ERR
  15. };
  16. PostResult(Type type) : type(type) {}
  17. Type type;
  18. std::string err_msg;
  19. };
  20. class ImageBoardBodyItemData : public BodyItemExtra {
  21. public:
  22. std::vector<size_t> replies_to;
  23. std::vector<size_t> replies;
  24. int64_t post_id = 0;
  25. };
  26. // All fields are optional
  27. struct ImageBoardCaptchaChallenge {
  28. std::string challenge_id;
  29. std::string img_data;
  30. std::string bg_data;
  31. int ttl = 0;
  32. };
  33. class ImageBoardThreadPage : public LazyFetchPage {
  34. public:
  35. ImageBoardThreadPage(Program *program, std::string board_id, std::string thread_id, std::string post_id) :
  36. LazyFetchPage(program), board_id(std::move(board_id)), thread_id(std::move(thread_id)), post_id(std::move(post_id)) {}
  37. const char* get_title() const override { return ""; }
  38. PageTypez get_type() const override { return PageTypez::IMAGE_BOARD_THREAD; }
  39. void copy_to_clipboard(const BodyItem *body_item) override;
  40. // If |filepath| is empty then no file is uploaded
  41. virtual PostResult post_comment(const std::string &captcha_id, const std::string &captcha_solution, const std::string &comment, const std::string &filepath = "") = 0;
  42. virtual const std::string& get_pass_id();
  43. virtual PluginResult request_captcha_challenge(ImageBoardCaptchaChallenge &challenge_response) = 0;
  44. const std::string board_id;
  45. const std::string thread_id;
  46. const std::string post_id;
  47. };
  48. class ImageBoardVideoPage : public VideoPage {
  49. public:
  50. ImageBoardVideoPage(Program *program) : VideoPage(program, "") {}
  51. const char* get_title() const override { return ""; }
  52. bool autoplay_next_item() override { return true; }
  53. };
  54. }