mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
MailSettings: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
This commit is contained in:
parent
173ba4e19b
commit
9e6d8f7c25
Notes:
sideshowbarker
2024-07-18 05:07:41 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/9e6d8f7c258 Pull-request: https://github.com/SerenityOS/serenity/pull/9663
4 changed files with 15 additions and 30 deletions
|
@ -14,4 +14,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(MailSettings ICON app-mail)
|
||||
target_link_libraries(MailSettings LibGUI)
|
||||
target_link_libraries(MailSettings LibConfig LibGUI)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue