From 928f2525c29929de0c2ab520f48c82b5cb882aa7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 30 Oct 2020 16:47:40 +0100 Subject: Matrix: re-add /logout, cancel task immediately Cancel video download when pressing escape, other fixes.. --- include/AsyncTask.hpp | 9 +++++++++ include/Body.hpp | 3 +-- include/Program.h | 48 ------------------------------------------------ include/Program.hpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/QuickMedia.hpp | 1 + 5 files changed, 55 insertions(+), 50 deletions(-) create mode 100644 include/AsyncTask.hpp delete mode 100644 include/Program.h create mode 100644 include/Program.hpp (limited to 'include') diff --git a/include/AsyncTask.hpp b/include/AsyncTask.hpp new file mode 100644 index 0000000..81be1ee --- /dev/null +++ b/include/AsyncTask.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include +#include +#include + +namespace QuickMedia { + +} \ No newline at end of file diff --git a/include/Body.hpp b/include/Body.hpp index 9cdcd7b..1dc1fe8 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -147,14 +147,13 @@ namespace QuickMedia { // Select next item, ignoring invisible items. Returns true if the item was changed. This can be used to check if the bottom was hit when wrap_around is set to false bool select_next_item(); - void set_selected_item(int item); + void set_selected_item(int item, bool reset_prev_selected_item = true); // Returns -1 if item can't be found int get_index_by_body_item(BodyItem *body_item); void select_first_item(); void select_last_item(); - void reset_selected(); void clear_items(); void prepend_items(BodyItems new_items); void append_items(BodyItems new_items); diff --git a/include/Program.h b/include/Program.h deleted file mode 100644 index cab8d26..0000000 --- a/include/Program.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef QUICKMEDIA_PROGRAM_H -#define QUICKMEDIA_PROGRAM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - pid_t pid; - int read_fd; -} ReadProgram; - -/* Return 0 if you want to continue reading. @data is null-terminated */ -typedef int (*ProgramOutputCallback)(char *data, int size, void *userdata); - -/* - @args need to have at least 2 arguments. The first which is the program name - and the last which is NULL, which indicates end of args -*/ -int exec_program_pipe(const char **args, ReadProgram *read_program); - -/* - @args need to have at least 2 arguments. The first which is the program name - and the last which is NULL, which indicates end of args -*/ -int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata); - -// Return the exit status, or a negative value if waiting failed -int wait_program(pid_t process_id); - -/* Returns 1 if the program quit and exited properly (non-0 exit codes also count as exiting properly) */ -int wait_program_non_blocking(pid_t process_id, int *status); - -/* - @args need to have at least 2 arguments. The first which is the program name - and the last which is NULL, which indicates end of args. - @result_process_id should be set to NULL if you are not interested in the exit status of the child process - and you want the child process to be cleaned up automatically when it dies. -*/ -int exec_program_async(const char **args, pid_t *result_process_id); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/Program.hpp b/include/Program.hpp new file mode 100644 index 0000000..8ac2d2d --- /dev/null +++ b/include/Program.hpp @@ -0,0 +1,44 @@ +#ifndef QUICKMEDIA_PROGRAM_HPP +#define QUICKMEDIA_PROGRAM_HPP + +#include +#include + +typedef struct { + pid_t pid; + int read_fd; +} ReadProgram; + +/* Return 0 if you want to continue reading. @data is null-terminated */ +typedef int (*ProgramOutputCallback)(char *data, int size, void *userdata); + +/* + @args need to have at least 2 arguments. The first which is the program name + and the last which is NULL, which indicates end of args +*/ +int exec_program_pipe(const char **args, ReadProgram *read_program); + +/* + @args need to have at least 2 arguments. The first which is the program name + and the last which is NULL, which indicates end of args +*/ +int exec_program(const char **args, ProgramOutputCallback output_callback, void *userdata); + +// Return the exit status, or a negative value if waiting failed +int wait_program(pid_t process_id); + +/* Returns 1 if the program quit and exited properly (non-0 exit codes also count as exiting properly) */ +int wait_program_non_blocking(pid_t process_id, int *status); + +/* + @args need to have at least 2 arguments. The first which is the program name + and the last which is NULL, which indicates end of args. + @result_process_id should be set to NULL if you are not interested in the exit status of the child process + and you want the child process to be cleaned up automatically when it dies. +*/ +int exec_program_async(const char **args, pid_t *result_process_id); + +void program_clear_current_thread(); +void program_kill_in_thread(const std::thread::id &thread_id); + +#endif /* QUICKMEDIA_PROGRAM_HPP */ diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index 99bab7a..6f8e3ff 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -63,6 +63,7 @@ namespace QuickMedia { void image_board_thread_page(ImageBoardThreadPage *thread_page, Body *thread_body); void chat_login_page(); void chat_page(MatrixChatPage *chat_page, RoomData *current_room); + void after_matrix_login_page(); enum class LoadImageResult { OK, -- cgit v1.2.3