aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-01 15:13:35 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-01 15:13:35 +0100
commit3ac82fad6bc883d979090e8cd56f3611703d6e14 (patch)
tree5960826029f56101065fac99e3bc3a1665a50ca7 /plugins
parent29d3f495e3b3be801cbb8c8dbd3f7250ec22415a (diff)
Make login a bit generalized, readd 4chan login (not tested)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Fourchan.hpp37
-rw-r--r--plugins/ImageBoard.hpp1
-rw-r--r--plugins/Page.hpp11
3 files changed, 45 insertions, 4 deletions
diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp
index 05fb784..83fb293 100644
--- a/plugins/Fourchan.hpp
+++ b/plugins/Fourchan.hpp
@@ -11,24 +11,55 @@ namespace QuickMedia {
void get_boards(BodyItems &result_items);
const std::string resources_root;
+ std::string pass_id;
+ };
+
+ class FourchanLoginPage : public LazyFetchPage {
+ public:
+ FourchanLoginPage(Program *program, std::string title, FourchanBoardsPage *boards_page, std::vector<Tab> *tabs, size_t tab_index) :
+ LazyFetchPage(program), title(std::move(title)), boards_page(boards_page), tabs(tabs), tab_index(tab_index) {}
+ const char* get_title() const override { return title.c_str(); }
+ PluginResult submit(const SubmitArgs&, std::vector<Tab>&) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+
+ bool submit_is_async() const override { return true; }
+ bool allow_submit_no_selection() const override { return true; }
+ bool lazy_fetch_is_loader() override { return true; }
+ void login_finish();
+
+ const LoginInputs *login_inputs;
+ private:
+ enum class LoggedIn {
+ Unknown,
+ Yes,
+ No
+ };
+
+ std::string title;
+ FourchanBoardsPage *boards_page;
+ std::vector<Tab> *tabs;
+ size_t tab_index;
+ LoggedIn logged_in = LoggedIn::Unknown;
};
class FourchanThreadListPage : public LazyFetchPage {
public:
- FourchanThreadListPage(Program *program, std::string title, std::string board_id) : LazyFetchPage(program), title(std::move(title)), board_id(std::move(board_id)) {}
+ FourchanThreadListPage(Program *program, std::string title, std::string board_id, std::string pass_id) :
+ LazyFetchPage(program), title(std::move(title)), board_id(std::move(board_id)), pass_id(std::move(pass_id)) {}
const char* get_title() const override { return title.c_str(); }
PluginResult submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
const std::string title;
const std::string board_id;
+ std::string pass_id;
};
class FourchanThreadPage : public ImageBoardThreadPage {
public:
- FourchanThreadPage(Program *program, std::string board_id, std::string thread_id) : ImageBoardThreadPage(program, std::move(board_id), std::move(thread_id)) {}
+ FourchanThreadPage(Program *program, std::string board_id, std::string thread_id, std::string pass_id) :
+ ImageBoardThreadPage(program, std::move(board_id), std::move(thread_id)), pass_id(std::move(pass_id)) {}
- PluginResult login(const std::string &token, const std::string &pin, std::string &response_msg) override;
PostResult post_comment(const std::string &captcha_id, const std::string &captcha_solution, const std::string &comment, const std::string &filepath = "") override;
const std::string& get_pass_id() override;
PluginResult request_captcha_challenge(ImageBoardCaptchaChallenge &challenge_response) override;
diff --git a/plugins/ImageBoard.hpp b/plugins/ImageBoard.hpp
index b6d84a1..157ac1c 100644
--- a/plugins/ImageBoard.hpp
+++ b/plugins/ImageBoard.hpp
@@ -32,7 +32,6 @@ namespace QuickMedia {
void copy_to_clipboard(const BodyItem *body_item) override;
bool autoplay_next_item() override { return true; }
- virtual PluginResult login(const std::string &token, const std::string &pin, std::string &response_msg);
// 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();
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index f5b4b3a..da6405c 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -197,4 +197,15 @@ namespace QuickMedia {
Page *redirect_page;
bool local_thumbnail;
};
+
+ class LoginPage : public Page {
+ public:
+ LoginPage(Program *program) : Page(program) {}
+ bool submit_is_async() const override { return true; }
+ bool allow_submit_no_selection() const override { return true; }
+ void login_finish();
+ bool logged_in() const;
+ private:
+ bool login_finished = false;
+ };
} \ No newline at end of file