aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp22
-rw-r--r--src/plugins/Matrix.cpp28
2 files changed, 49 insertions, 1 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index c9c7603..c528056 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -7845,6 +7845,16 @@ namespace QuickMedia {
room_directory_body->set_items(std::move(room_dir_body_items));
auto matrix_room_directory_page = std::make_unique<MatrixRoomDirectoryPage>(this, matrix);
+ auto settings_body = create_body();
+ auto join_body_item = BodyItem::create("Join room");
+ join_body_item->url = "join";
+ settings_body->append_item(std::move(join_body_item));
+ auto logout_body_item = BodyItem::create("Logout");
+ logout_body_item->url = "logout";
+ settings_body->append_item(std::move(logout_body_item));
+ auto matrix_settings_page_search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
+ auto matrix_settings_page = std::make_unique<MatrixSettingsPage>(this, matrix);
+
MatrixQuickMedia matrix_handler(this, matrix, matrix_rooms_page.get(), matrix_rooms_tag_page.get(), matrix_invites_page.get(), matrix_notifications_page.get());
bool sync_cached = false;
if(!matrix->start_sync(&matrix_handler, sync_cached)) {
@@ -7860,9 +7870,19 @@ namespace QuickMedia {
tabs.push_back(Tab{std::move(rooms_body), std::move(matrix_rooms_page), std::move(rooms_page_search_bar)});
tabs.push_back(Tab{std::move(invites_body), std::move(matrix_invites_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
tabs.push_back(Tab{std::move(room_directory_body), std::move(matrix_room_directory_page), create_search_bar("Server to search on...", SEARCH_DELAY_FILTER)});
+ tabs.push_back(Tab{std::move(settings_body), std::move(matrix_settings_page), std::move(matrix_settings_page_search_bar)});
- page_loop(tabs, 2, nullptr, false);
+ const bool go_to_login_page = page_loop(tabs, 2, nullptr, false);
matrix->stop_sync();
+ if(go_to_login_page) {
+ delete matrix;
+ matrix = new Matrix();
+ current_page = PageType::CHAT_LOGIN;
+ chat_login_page();
+ after_matrix_login_page();
+ window.close();
+ exit(exit_code);
+ }
}
static int accumulate_string(char *data, int size, void *userdata) {
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 82ca583..f79b10c 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -966,6 +966,34 @@ namespace QuickMedia {
title = "Invites (0)";
}
+ PluginResult MatrixSettingsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url == "join") {
+ result_tabs.push_back(Tab{create_body(), std::make_unique<MatrixRoomInputPage>(program, matrix), create_search_bar("Enter room id...", SEARCH_DELAY_FILTER)});
+ return PluginResult::OK;
+ } else if(args.url == "logout") {
+ matrix->logout();
+ program->set_go_to_previous_page();
+ return PluginResult::OK;
+ } else {
+ return PluginResult::ERR;
+ }
+ }
+
+ PluginResult MatrixRoomInputPage::submit(const SubmitArgs &args, std::vector<Tab>&) {
+ if(args.title.empty()) {
+ show_notification("QuickMedia", "Room id can't be empty", Urgency::CRITICAL);
+ return PluginResult::OK;
+ }
+
+ if(matrix->join_room(args.title) == PluginResult::OK) {
+ show_notification("QuickMedia", "You joined " + args.title, Urgency::NORMAL);
+ program->set_go_to_previous_page();
+ } else {
+ show_notification("QuickMedia", "Failed to join " + args.title, Urgency::CRITICAL);
+ }
+ return PluginResult::OK;
+ }
+
MatrixChatPage::MatrixChatPage(Program *program, std::string room_id, MatrixRoomsPage *rooms_page, std::string jump_to_event_id) :
Page(program), room_id(std::move(room_id)), rooms_page(rooms_page), jump_to_event_id(std::move(jump_to_event_id))
{