From d486560aeec97cdc68e8f283ce8c19555c36c81a Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Sat, 28 Aug 2021 15:01:59 +0100 Subject: [PATCH] Mail: Use LibConfig instead of Core::ConfigFile This also tightens the pledges. --- Userland/Applications/Mail/CMakeLists.txt | 2 +- Userland/Applications/Mail/MailWidget.cpp | 14 ++++++-------- Userland/Applications/Mail/main.cpp | 5 ++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Userland/Applications/Mail/CMakeLists.txt b/Userland/Applications/Mail/CMakeLists.txt index 6479aa3447..f70d28df8b 100644 --- a/Userland/Applications/Mail/CMakeLists.txt +++ b/Userland/Applications/Mail/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES ) serenity_app(Mail ICON app-mail) -target_link_libraries(Mail LibCore LibDesktop LibGfx LibGUI LibIMAP LibWeb) +target_link_libraries(Mail LibConfig LibCore LibDesktop LibGfx LibGUI LibIMAP LibWeb) diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp index b032232760..d2804e5143 100644 --- a/Userland/Applications/Mail/MailWidget.cpp +++ b/Userland/Applications/Mail/MailWidget.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -100,9 +100,7 @@ MailWidget::~MailWidget() bool MailWidget::connect_and_login() { - auto config = Core::ConfigFile::open_for_app("Mail"); - - auto server = config->read_entry("Connection", "Server", {}); + auto server = Config::read_string("Mail", "Connection", "Server", {}); if (server.is_empty()) { GUI::MessageBox::show_error(window(), "Mail has no servers configured. Refer to the Mail(1) man page for more information."); @@ -110,16 +108,16 @@ bool MailWidget::connect_and_login() } // Assume TLS by default, which is on port 993. - auto port = config->read_num_entry("Connection", "Port", 993); - auto tls = config->read_bool_entry("Connection", "TLS", true); + auto port = Config::read_i32("Mail", "Connection", "Port", 993); + auto tls = Config::read_bool("Mail", "Connection", "TLS", true); - auto username = config->read_entry("User", "Username", {}); + auto username = Config::read_string("Mail", "User", "Username", {}); if (username.is_empty()) { GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information."); return false; } - auto password = config->read_entry("User", "Password", {}); + auto password = Config::read_string("Mail", "User", "Password", {}); while (password.is_empty()) { if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecOK) return false; diff --git a/Userland/Applications/Mail/main.cpp b/Userland/Applications/Mail/main.cpp index 4532de314b..c6f8f01e2e 100644 --- a/Userland/Applications/Mail/main.cpp +++ b/Userland/Applications/Mail/main.cpp @@ -5,6 +5,7 @@ */ #include "MailWidget.h" +#include #include #include #include @@ -15,13 +16,15 @@ int main(int argc, char** argv) { - if (pledge("stdio recvfd sendfd rpath unix cpath wpath thread inet", nullptr) < 0) { + if (pledge("stdio recvfd sendfd rpath unix inet", nullptr) < 0) { perror("pledge"); return 1; } auto app = GUI::Application::construct(argc, argv); + Config::pledge_domains("Mail"); + auto window = GUI::Window::construct(); auto app_icon = GUI::Icon::default_icon("app-mail");