Mail: Use LibConfig instead of Core::ConfigFile

This also tightens the pledges.
This commit is contained in:
Luke Wilde 2021-08-28 15:01:59 +01:00 committed by Andreas Kling
parent 585edb8cff
commit d486560aee
Notes: sideshowbarker 2024-07-18 05:07:49 +09:00
3 changed files with 11 additions and 10 deletions

View File

@ -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)

View File

@ -8,7 +8,7 @@
#include <AK/Base64.h>
#include <AK/GenericLexer.h>
#include <Applications/Mail/MailWindowGML.h>
#include <LibCore/ConfigFile.h>
#include <LibConfig/Client.h>
#include <LibDesktop/Launcher.h>
#include <LibGUI/Action.h>
#include <LibGUI/Clipboard.h>
@ -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;

View File

@ -5,6 +5,7 @@
*/
#include "MailWidget.h"
#include <LibConfig/Client.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
@ -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");