aboutsummaryrefslogtreecommitdiff
path: root/plugins/ImageBoard.hpp
blob: 634162234d74c13b480c6c88d0fbeb5a7446d564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include "Page.hpp"

namespace QuickMedia {
    struct PostResult {
        enum class Type {
            OK,
            TRY_AGAIN,
            INVALID_CAPTCHA,
            BANNED,
            //FILE_TOO_LARGE,
            NO_SUCH_FILE,
            FILE_TYPE_NOT_ALLOWED,
            UPLOAD_FAILED,
            ERR
        };

        PostResult(Type type) : type(type) {}

        Type type;
        std::string err_msg;
    };

    class ImageBoardBodyItemData : public BodyItemExtra {
    public:
        std::vector<size_t> replies_to;
        std::vector<size_t> replies;
        int64_t post_id = 0;
    };

    // All fields are optional
    struct ImageBoardCaptchaChallenge {
        std::string challenge_id;
        std::string img_data;
        std::string bg_data;
        int ttl = 0;
    };

    class ImageBoardThreadPage : public LazyFetchPage {
    public:
        ImageBoardThreadPage(Program *program, std::string board_id, std::string thread_id, std::string post_id) :
            LazyFetchPage(program), board_id(std::move(board_id)), thread_id(std::move(thread_id)), post_id(std::move(post_id)) {}
        const char* get_title() const override { return ""; }
        PageTypez get_type() const override { return PageTypez::IMAGE_BOARD_THREAD; }

        void copy_to_clipboard(const BodyItem *body_item) override;

        // If |filepath| is empty then no file is uploaded
        virtual PostResult post_comment(const std::string &captcha_id, const std::string &captcha_solution, const std::string &comment, const std::string &filepath = "") = 0;
        virtual const std::string& get_pass_id();

        virtual PluginResult request_captcha_challenge(ImageBoardCaptchaChallenge &challenge_response) = 0;

        const std::string board_id;
        const std::string thread_id;
        const std::string post_id;
    };

    class ImageBoardVideoPage : public VideoPage {
    public:
        ImageBoardVideoPage(Program *program) : VideoPage(program, "") {}
        const char* get_title() const override { return ""; }
        bool autoplay_next_item() override { return true; }
    };
}