mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
Mail: Use LibConfig instead of Core::ConfigFile
This also tightens the pledges.
This commit is contained in:
parent
585edb8cff
commit
d486560aee
3 changed files with 11 additions and 10 deletions
|
@ -16,4 +16,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(Mail ICON app-mail)
|
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/Base64.h>
|
||||||
#include <AK/GenericLexer.h>
|
#include <AK/GenericLexer.h>
|
||||||
#include <Applications/Mail/MailWindowGML.h>
|
#include <Applications/Mail/MailWindowGML.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Clipboard.h>
|
#include <LibGUI/Clipboard.h>
|
||||||
|
@ -100,9 +100,7 @@ MailWidget::~MailWidget()
|
||||||
|
|
||||||
bool MailWidget::connect_and_login()
|
bool MailWidget::connect_and_login()
|
||||||
{
|
{
|
||||||
auto config = Core::ConfigFile::open_for_app("Mail");
|
auto server = Config::read_string("Mail", "Connection", "Server", {});
|
||||||
|
|
||||||
auto server = config->read_entry("Connection", "Server", {});
|
|
||||||
|
|
||||||
if (server.is_empty()) {
|
if (server.is_empty()) {
|
||||||
GUI::MessageBox::show_error(window(), "Mail has no servers configured. Refer to the Mail(1) man page for more information.");
|
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.
|
// Assume TLS by default, which is on port 993.
|
||||||
auto port = config->read_num_entry("Connection", "Port", 993);
|
auto port = Config::read_i32("Mail", "Connection", "Port", 993);
|
||||||
auto tls = config->read_bool_entry("Connection", "TLS", true);
|
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()) {
|
if (username.is_empty()) {
|
||||||
GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information.");
|
GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto password = config->read_entry("User", "Password", {});
|
auto password = Config::read_string("Mail", "User", "Password", {});
|
||||||
while (password.is_empty()) {
|
while (password.is_empty()) {
|
||||||
if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecOK)
|
if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecOK)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MailWidget.h"
|
#include "MailWidget.h"
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
|
@ -15,13 +16,15 @@
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
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");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
|
||||||
|
Config::pledge_domains("Mail");
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
|
|
||||||
auto app_icon = GUI::Icon::default_icon("app-mail");
|
auto app_icon = GUI::Icon::default_icon("app-mail");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue