mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
MailSettings: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
This commit is contained in:
parent
173ba4e19b
commit
9e6d8f7c25
4 changed files with 15 additions and 30 deletions
|
@ -14,4 +14,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(MailSettings ICON app-mail)
|
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 "MailSettingsWindow.h"
|
||||||
#include <Applications/MailSettings/MailSettingsWindowGML.h>
|
#include <Applications/MailSettings/MailSettingsWindowGML.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
|
@ -34,31 +34,14 @@ void MailSettingsWindow::write_values()
|
||||||
m_tls = m_tls_checkbox->is_checked();
|
m_tls = m_tls_checkbox->is_checked();
|
||||||
m_email = m_email_inputbox->get_text();
|
m_email = m_email_inputbox->get_text();
|
||||||
|
|
||||||
m_config->write_entry("Connection", "Server", m_server);
|
Config::write_string("Mail", "Connection", "Server", m_server);
|
||||||
m_config->write_entry("Connection", "Port", m_port);
|
Config::write_string("Mail", "Connection", "Port", m_port);
|
||||||
m_config->write_bool_entry("Connection", "TLS", m_tls);
|
Config::write_bool("Mail", "Connection", "TLS", m_tls);
|
||||||
m_config->write_entry("User", "Username", m_email);
|
Config::write_string("Mail", "User", "Username", m_email);
|
||||||
m_config->sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MailSettingsWindow::MailSettingsWindow()
|
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
|
//Common port values for email fetching
|
||||||
m_common_ports.append("143");
|
m_common_ports.append("143");
|
||||||
m_common_ports.append("993");
|
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"));
|
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 = *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 = *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_only_allow_values_from_model(false);
|
||||||
m_port_combobox->set_model(*GUI::ItemListModel<String>::create(m_common_ports));
|
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 = *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 = *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>();
|
auto& button_container = main_widget.add<GUI::Widget>();
|
||||||
button_container.set_shrink_to_fit(true);
|
button_container.set_shrink_to_fit(true);
|
||||||
|
|
|
@ -23,7 +23,6 @@ private:
|
||||||
bool m_tls { false };
|
bool m_tls { false };
|
||||||
String m_email;
|
String m_email;
|
||||||
Vector<String> m_common_ports;
|
Vector<String> m_common_ports;
|
||||||
RefPtr<Core::ConfigFile> m_config;
|
|
||||||
|
|
||||||
RefPtr<GUI::TextBox> m_server_inputbox;
|
RefPtr<GUI::TextBox> m_server_inputbox;
|
||||||
RefPtr<GUI::ComboBox> m_port_combobox;
|
RefPtr<GUI::ComboBox> m_port_combobox;
|
||||||
|
|
|
@ -5,20 +5,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MailSettingsWindow.h"
|
#include "MailSettingsWindow.h"
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
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");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
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");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue