mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 09:14:21 +03:00
Mail: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
This commit is contained in:
parent
585edb8cff
commit
d486560aee
Notes:
sideshowbarker
2024-07-18 05:07:49 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/d486560aeec Pull-request: https://github.com/SerenityOS/serenity/pull/9663
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user