diff options
author | Luke Wilde <lukew@serenityos.org> | 2021-08-28 15:04:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-28 23:29:28 +0200 |
commit | 9e6d8f7c2580a513c435d360dcfb5848b4aa3622 (patch) | |
tree | 1e7deb8f2fed309a044e5baa78101ec7d188f006 /Userland/Applications | |
parent | 173ba4e19bf30c2fcdc2ee18b30de88c8444072f (diff) | |
download | serenity-9e6d8f7c2580a513c435d360dcfb5848b4aa3622.zip |
MailSettings: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
Diffstat (limited to 'Userland/Applications')
4 files changed, 15 insertions, 30 deletions
diff --git a/Userland/Applications/MailSettings/CMakeLists.txt b/Userland/Applications/MailSettings/CMakeLists.txt index 2204c395f2..feeadeccfb 100644 --- a/Userland/Applications/MailSettings/CMakeLists.txt +++ b/Userland/Applications/MailSettings/CMakeLists.txt @@ -14,4 +14,4 @@ set(SOURCES ) serenity_app(MailSettings ICON app-mail) -target_link_libraries(MailSettings LibGUI) +target_link_libraries(MailSettings LibConfig LibGUI) diff --git a/Userland/Applications/MailSettings/MailSettingsWindow.cpp b/Userland/Applications/MailSettings/MailSettingsWindow.cpp index 813efdb3b2..66c5041276 100644 --- a/Userland/Applications/MailSettings/MailSettingsWindow.cpp +++ b/Userland/Applications/MailSettings/MailSettingsWindow.cpp @@ -6,7 +6,7 @@ #include "MailSettingsWindow.h" #include <Applications/MailSettings/MailSettingsWindowGML.h> -#include <LibCore/ConfigFile.h> +#include <LibConfig/Client.h> #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> @@ -34,31 +34,14 @@ void MailSettingsWindow::write_values() m_tls = m_tls_checkbox->is_checked(); m_email = m_email_inputbox->get_text(); - m_config->write_entry("Connection", "Server", m_server); - m_config->write_entry("Connection", "Port", m_port); - m_config->write_bool_entry("Connection", "TLS", m_tls); - m_config->write_entry("User", "Username", m_email); - m_config->sync(); + Config::write_string("Mail", "Connection", "Server", m_server); + Config::write_string("Mail", "Connection", "Port", m_port); + Config::write_bool("Mail", "Connection", "TLS", m_tls); + Config::write_string("Mail", "User", "Username", m_email); } MailSettingsWindow::MailSettingsWindow() { - m_config = Core::ConfigFile::open_for_app("Mail", Core::ConfigFile::AllowWriting::Yes); - if (unveil(m_config->filename().characters(), "rwc") < 0) { - perror("unveil"); - GUI::Application::the()->quit(); - } - - if (unveil("/res", "r") < 0) { - perror("unveil"); - GUI::Application::the()->quit(); - } - - if (unveil(nullptr, nullptr)) { - perror("unveil"); - GUI::Application::the()->quit(); - } - //Common port values for email fetching m_common_ports.append("143"); m_common_ports.append("993"); @@ -80,18 +63,18 @@ MailSettingsWindow::MailSettingsWindow() user_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-user-settings.png")); m_server_inputbox = *main_widget.find_descendant_of_type_named<GUI::TextBox>("server_input"); - m_server_inputbox->set_text(m_config->read_entry("Connection", "Server", "")); + m_server_inputbox->set_text(Config::read_string("Mail", "Connection", "Server", "")); m_port_combobox = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("port_input"); - m_port_combobox->set_text(m_config->read_entry("Connection", "Port", "993")); + m_port_combobox->set_text(Config::read_string("Mail", "Connection", "Port", "993")); m_port_combobox->set_only_allow_values_from_model(false); m_port_combobox->set_model(*GUI::ItemListModel<String>::create(m_common_ports)); m_tls_checkbox = *main_widget.find_descendant_of_type_named<GUI::CheckBox>("tls_input"); - m_tls_checkbox->set_checked(m_config->read_bool_entry("Connection", "TLS", false)); + m_tls_checkbox->set_checked(Config::read_bool("Mail", "Connection", "TLS", false)); m_email_inputbox = *main_widget.find_descendant_of_type_named<GUI::TextBox>("email_input"); - m_email_inputbox->set_text(m_config->read_entry("User", "Username", "")); + m_email_inputbox->set_text(Config::read_string("Mail", "User", "Username", "")); auto& button_container = main_widget.add<GUI::Widget>(); button_container.set_shrink_to_fit(true); diff --git a/Userland/Applications/MailSettings/MailSettingsWindow.h b/Userland/Applications/MailSettings/MailSettingsWindow.h index e7d4fdd83c..6f6f041ca0 100644 --- a/Userland/Applications/MailSettings/MailSettingsWindow.h +++ b/Userland/Applications/MailSettings/MailSettingsWindow.h @@ -23,7 +23,6 @@ private: bool m_tls { false }; String m_email; Vector<String> m_common_ports; - RefPtr<Core::ConfigFile> m_config; RefPtr<GUI::TextBox> m_server_inputbox; RefPtr<GUI::ComboBox> m_port_combobox; diff --git a/Userland/Applications/MailSettings/main.cpp b/Userland/Applications/MailSettings/main.cpp index ee4f8cd461..cebbbe2639 100644 --- a/Userland/Applications/MailSettings/main.cpp +++ b/Userland/Applications/MailSettings/main.cpp @@ -5,20 +5,23 @@ */ #include "MailSettingsWindow.h" +#include <LibConfig/Client.h> #include <LibGUI/Application.h> #include <LibGUI/Icon.h> #include <unistd.h> int main(int argc, char** argv) { - if (pledge("stdio rpath cpath wpath recvfd sendfd unix", nullptr) < 0) { + if (pledge("stdio rpath recvfd sendfd unix", nullptr) < 0) { perror("pledge"); return 1; } auto app = GUI::Application::construct(argc, argv); - if (pledge("stdio rpath cpath wpath recvfd sendfd", nullptr) < 0) { + Config::pledge_domains("Mail"); + + if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { perror("pledge"); return 1; } |