2021-07-22 20:44:59 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
2021-11-09 15:17:57 +03:00
|
|
|
* Copyright (c) 2021, Undefine <cqundefine@gmail.com>
|
2021-07-22 20:44:59 +03:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "MailWidget.h"
|
2021-08-28 17:01:59 +03:00
|
|
|
#include <LibConfig/Client.h>
|
2021-11-23 12:59:50 +03:00
|
|
|
#include <LibCore/System.h>
|
2021-11-09 15:17:57 +03:00
|
|
|
#include <LibDesktop/Launcher.h>
|
2021-07-22 20:44:59 +03:00
|
|
|
#include <LibGUI/Application.h>
|
|
|
|
#include <LibGUI/Icon.h>
|
|
|
|
#include <LibGUI/Menu.h>
|
|
|
|
#include <LibGUI/Menubar.h>
|
|
|
|
#include <LibGUI/Window.h>
|
2021-11-23 01:25:38 +03:00
|
|
|
#include <LibMain/Main.h>
|
2021-07-22 20:44:59 +03:00
|
|
|
|
2021-11-23 01:25:38 +03:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2021-07-22 20:44:59 +03:00
|
|
|
{
|
2021-11-28 01:26:34 +03:00
|
|
|
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix inet"));
|
2021-07-22 20:44:59 +03:00
|
|
|
|
2022-04-16 19:17:39 +03:00
|
|
|
auto app = TRY(GUI::Application::try_create(arguments));
|
2021-07-22 20:44:59 +03:00
|
|
|
|
2022-02-11 19:33:09 +03:00
|
|
|
Config::pledge_domain("Mail");
|
2021-08-28 17:01:59 +03:00
|
|
|
|
2021-11-23 12:59:50 +03:00
|
|
|
TRY(Core::System::unveil("/res", "r"));
|
|
|
|
TRY(Core::System::unveil("/etc", "r"));
|
|
|
|
TRY(Core::System::unveil("/tmp/portal/webcontent", "rw"));
|
|
|
|
TRY(Core::System::unveil("/tmp/portal/lookup", "rw"));
|
2022-07-17 16:41:01 +03:00
|
|
|
TRY(Core::System::unveil("/tmp/100/portal/launch", "rw"));
|
2021-11-23 12:59:50 +03:00
|
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
2021-08-28 17:02:12 +03:00
|
|
|
|
2021-11-09 15:17:57 +03:00
|
|
|
TRY(Desktop::Launcher::add_allowed_url(URL::create_with_file_protocol("/bin/MailSettings")));
|
|
|
|
TRY(Desktop::Launcher::add_allowed_handler_with_any_url("/bin/MailSettings"));
|
|
|
|
TRY(Desktop::Launcher::seal_allowlist());
|
|
|
|
|
2021-07-22 20:44:59 +03:00
|
|
|
auto window = GUI::Window::construct();
|
|
|
|
|
2022-07-11 20:32:29 +03:00
|
|
|
auto app_icon = GUI::Icon::default_icon("app-mail"sv);
|
2021-07-22 20:44:59 +03:00
|
|
|
window->set_icon(app_icon.bitmap_for_size(16));
|
|
|
|
|
2022-01-07 17:06:17 +03:00
|
|
|
auto mail_widget = TRY(window->try_set_main_widget<MailWidget>());
|
2021-07-22 20:44:59 +03:00
|
|
|
|
|
|
|
window->set_title("Mail");
|
|
|
|
window->resize(640, 400);
|
|
|
|
|
2021-07-29 13:08:34 +03:00
|
|
|
auto& file_menu = window->add_menu("&File");
|
2021-07-22 20:44:59 +03:00
|
|
|
|
|
|
|
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
2022-01-07 17:06:17 +03:00
|
|
|
mail_widget->on_window_close();
|
2021-07-22 20:44:59 +03:00
|
|
|
app->quit();
|
|
|
|
}));
|
|
|
|
|
2021-07-29 13:08:34 +03:00
|
|
|
auto& help_menu = window->add_menu("&Help");
|
2021-07-22 20:44:59 +03:00
|
|
|
help_menu.add_action(GUI::CommonActions::make_about_action("Mail", app_icon, window));
|
|
|
|
|
|
|
|
window->on_close_request = [&] {
|
2022-01-07 17:06:17 +03:00
|
|
|
mail_widget->on_window_close();
|
2021-07-22 20:44:59 +03:00
|
|
|
return GUI::Window::CloseRequestDecision::Close;
|
|
|
|
};
|
|
|
|
|
|
|
|
window->show();
|
|
|
|
|
2022-01-07 17:06:17 +03:00
|
|
|
bool should_continue = mail_widget->connect_and_login();
|
2021-07-22 20:44:59 +03:00
|
|
|
if (!should_continue)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return app->exec();
|
|
|
|
}
|