mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
Everywhere: Use Core::ConfigFile::AllowWriting::Yes to allow writing
This commit is contained in:
parent
54bbe52b51
commit
938051feb8
Notes:
sideshowbarker
2024-07-18 05:25:22 +09:00
Author: https://github.com/networkException Commit: https://github.com/SerenityOS/serenity/commit/938051feb8d Pull-request: https://github.com/SerenityOS/serenity/pull/9501 Reviewed-by: https://github.com/awesomekling
25 changed files with 29 additions and 29 deletions
|
@ -211,7 +211,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = Core::ConfigFile::get_for_app("AudioApplet");
|
auto config = Core::ConfigFile::get_for_app("AudioApplet", Core::ConfigFile::AllowWriting::Yes);
|
||||||
// To not upset the audio server state, we responsibly read this once.
|
// To not upset the audio server state, we responsibly read this once.
|
||||||
auto audio_master_config = Core::ConfigFile::get_for_app("Audio");
|
auto audio_master_config = Core::ConfigFile::get_for_app("Audio");
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ void BrowserWindow::build_menus()
|
||||||
|
|
||||||
m_change_homepage_action = GUI::Action::create(
|
m_change_homepage_action = GUI::Action::create(
|
||||||
"Set Homepage URL", [this](auto&) {
|
"Set Homepage URL", [this](auto&) {
|
||||||
auto config = Core::ConfigFile::get_for_app("Browser");
|
auto config = Core::ConfigFile::get_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
||||||
String homepage_url = config->read_entry("Preferences", "Home", "about:blank");
|
String homepage_url = config->read_entry("Preferences", "Home", "about:blank");
|
||||||
if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecOK) {
|
if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecOK) {
|
||||||
if (URL(homepage_url).is_valid()) {
|
if (URL(homepage_url).is_valid()) {
|
||||||
|
@ -300,7 +300,7 @@ void BrowserWindow::build_menus()
|
||||||
auto action = GUI::Action::create_checkable(
|
auto action = GUI::Action::create_checkable(
|
||||||
name, [&](auto&) {
|
name, [&](auto&) {
|
||||||
g_search_engine = url_format;
|
g_search_engine = url_format;
|
||||||
auto config = Core::ConfigFile::get_for_app("Browser");
|
auto config = Core::ConfigFile::get_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
||||||
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
|
@ -317,7 +317,7 @@ void BrowserWindow::build_menus()
|
||||||
m_disable_search_engine_action = GUI::Action::create_checkable(
|
m_disable_search_engine_action = GUI::Action::create_checkable(
|
||||||
"Disable", [](auto&) {
|
"Disable", [](auto&) {
|
||||||
g_search_engine = {};
|
g_search_engine = {};
|
||||||
auto config = Core::ConfigFile::get_for_app("Browser");
|
auto config = Core::ConfigFile::get_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
||||||
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
|
@ -347,7 +347,7 @@ void BrowserWindow::build_menus()
|
||||||
}
|
}
|
||||||
|
|
||||||
g_search_engine = search_engine;
|
g_search_engine = search_engine;
|
||||||
auto config = Core::ConfigFile::get_for_app("Browser");
|
auto config = Core::ConfigFile::get_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
||||||
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
||||||
action.set_status_tip(search_engine);
|
action.set_status_tip(search_engine);
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,7 +90,7 @@ DownloadWidget::DownloadWidget(const URL& url)
|
||||||
m_close_on_finish_checkbox->set_checked(close_on_finish);
|
m_close_on_finish_checkbox->set_checked(close_on_finish);
|
||||||
|
|
||||||
m_close_on_finish_checkbox->on_checked = [&](bool checked) {
|
m_close_on_finish_checkbox->on_checked = [&](bool checked) {
|
||||||
auto browser_config = Core::ConfigFile::get_for_app("Browser");
|
auto browser_config = Core::ConfigFile::get_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
||||||
browser_config->write_bool_entry("Preferences", "CloseDownloadWidgetOnFinish", checked);
|
browser_config->write_bool_entry("Preferences", "CloseDownloadWidgetOnFinish", checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ void BackgroundSettingsWidget::load_current_settings()
|
||||||
|
|
||||||
void BackgroundSettingsWidget::apply_settings()
|
void BackgroundSettingsWidget::apply_settings()
|
||||||
{
|
{
|
||||||
auto wm_config = Core::ConfigFile::get_for_app("WindowManager");
|
auto wm_config = Core::ConfigFile::get_for_app("WindowManager", Core::ConfigFile::AllowWriting::Yes);
|
||||||
wm_config->write_entry("Background", "Wallpaper", m_monitor_widget->wallpaper());
|
wm_config->write_entry("Background", "Wallpaper", m_monitor_widget->wallpaper());
|
||||||
|
|
||||||
if (!m_monitor_widget->wallpaper().is_empty()) {
|
if (!m_monitor_widget->wallpaper().is_empty()) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("FileManager");
|
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("FileManager", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
bool is_desktop_mode { false }, is_selection_mode { false }, ignore_path_resolution { false };
|
bool is_desktop_mode { false }, is_selection_mode { false }, ignore_path_resolution { false };
|
||||||
|
|
|
@ -35,7 +35,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
{
|
{
|
||||||
load_from_gml(hex_editor_window_gml);
|
load_from_gml(hex_editor_window_gml);
|
||||||
|
|
||||||
m_config = Core::ConfigFile::get_for_app("HexEditor");
|
m_config = Core::ConfigFile::get_for_app("HexEditor", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
||||||
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
||||||
|
|
|
@ -47,7 +47,7 @@ IRCClient::IRCClient(String server, int port)
|
||||||
: m_nickname("seren1ty")
|
: m_nickname("seren1ty")
|
||||||
, m_client_window_list_model(IRCWindowListModel::create(*this))
|
, m_client_window_list_model(IRCWindowListModel::create(*this))
|
||||||
, m_log(IRCLogBuffer::create())
|
, m_log(IRCLogBuffer::create())
|
||||||
, m_config(Core::ConfigFile::get_for_app("IRCClient"))
|
, m_config(Core::ConfigFile::get_for_app("IRCClient", Core::ConfigFile::AllowWriting::Yes))
|
||||||
{
|
{
|
||||||
struct passwd* user_pw = getpwuid(getuid());
|
struct passwd* user_pw = getpwuid(getuid());
|
||||||
m_socket = Core::TCPSocket::construct(this);
|
m_socket = Core::TCPSocket::construct(this);
|
||||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = Core::ConfigFile::get_for_app("KeyboardSettings");
|
auto config = Core::ConfigFile::get_for_app("KeyboardSettings", Core::ConfigFile::AllowWriting::Yes);
|
||||||
if (unveil(config->filename().characters(), "rwc") < 0) {
|
if (unveil(config->filename().characters(), "rwc") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -43,7 +43,7 @@ void MailSettingsWindow::write_values()
|
||||||
|
|
||||||
MailSettingsWindow::MailSettingsWindow()
|
MailSettingsWindow::MailSettingsWindow()
|
||||||
{
|
{
|
||||||
m_config = Core::ConfigFile::get_for_app("Mail");
|
m_config = Core::ConfigFile::get_for_app("Mail", Core::ConfigFile::AllowWriting::Yes);
|
||||||
if (unveil(m_config->filename().characters(), "rwc") < 0) {
|
if (unveil(m_config->filename().characters(), "rwc") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
GUI::Application::the()->quit();
|
GUI::Application::the()->quit();
|
||||||
|
|
|
@ -291,7 +291,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
|
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal", Core::ConfigFile::AllowWriting::Yes);
|
||||||
Core::File::ensure_parent_directories(config->filename());
|
Core::File::ensure_parent_directories(config->filename());
|
||||||
|
|
||||||
int ptm_fd;
|
int ptm_fd;
|
||||||
|
|
|
@ -47,7 +47,7 @@ MainWidget::MainWidget()
|
||||||
{
|
{
|
||||||
load_from_gml(text_editor_window_gml);
|
load_from_gml(text_editor_window_gml);
|
||||||
|
|
||||||
m_config = Core::ConfigFile::get_for_app("TextEditor");
|
m_config = Core::ConfigFile::get_for_app("TextEditor", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
||||||
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
||||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
|
|
||||||
auto config = Core::ConfigFile::get_for_app("2048");
|
auto config = Core::ConfigFile::get_for_app("2048", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
size_t board_size = config->read_num_entry("", "board_size", 4);
|
size_t board_size = config->read_num_entry("", "board_size", 4);
|
||||||
u32 target_tile = config->read_num_entry("", "target_tile", 2048);
|
u32 target_tile = config->read_num_entry("", "target_tile", 2048);
|
||||||
|
|
|
@ -26,7 +26,7 @@ int main(int argc, char** argv)
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
auto& widget = window->set_main_widget<ChessWidget>();
|
auto& widget = window->set_main_widget<ChessWidget>();
|
||||||
|
|
||||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Chess");
|
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Chess", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
if (pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec", nullptr) < 0) {
|
if (pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
|
|
|
@ -22,7 +22,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
auto config = Core::ConfigFile::get_for_app("FlappyBug");
|
auto config = Core::ConfigFile::get_for_app("FlappyBug", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
if (pledge("stdio rpath wpath cpath recvfd sendfd", nullptr) < 0) {
|
if (pledge("stdio rpath wpath cpath recvfd sendfd", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
|
|
|
@ -26,7 +26,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
auto app_icon = GUI::Icon::default_icon("app-hearts");
|
auto app_icon = GUI::Icon::default_icon("app-hearts");
|
||||||
auto config = Core::ConfigFile::get_for_app("Hearts");
|
auto config = Core::ConfigFile::get_for_app("Hearts", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
if (pledge("stdio recvfd sendfd rpath wpath cpath", nullptr) < 0) {
|
if (pledge("stdio recvfd sendfd rpath wpath cpath", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
|
|
|
@ -488,7 +488,7 @@ void Field::set_field_size(size_t rows, size_t columns, size_t mine_count)
|
||||||
if (m_rows == rows && m_columns == columns && m_mine_count == mine_count)
|
if (m_rows == rows && m_columns == columns && m_mine_count == mine_count)
|
||||||
return;
|
return;
|
||||||
{
|
{
|
||||||
auto config = Core::ConfigFile::get_for_app("Minesweeper");
|
auto config = Core::ConfigFile::get_for_app("Minesweeper", Core::ConfigFile::AllowWriting::Yes);
|
||||||
config->write_num_entry("Game", "MineCount", mine_count);
|
config->write_num_entry("Game", "MineCount", mine_count);
|
||||||
config->write_num_entry("Game", "Rows", rows);
|
config->write_num_entry("Game", "Rows", rows);
|
||||||
config->write_num_entry("Game", "Columns", columns);
|
config->write_num_entry("Game", "Columns", columns);
|
||||||
|
@ -503,7 +503,7 @@ void Field::set_field_size(size_t rows, size_t columns, size_t mine_count)
|
||||||
|
|
||||||
void Field::set_single_chording(bool enabled)
|
void Field::set_single_chording(bool enabled)
|
||||||
{
|
{
|
||||||
auto config = Core::ConfigFile::get_for_app("Minesweeper");
|
auto config = Core::ConfigFile::get_for_app("Minesweeper", Core::ConfigFile::AllowWriting::Yes);
|
||||||
m_single_chording = enabled;
|
m_single_chording = enabled;
|
||||||
config->write_bool_entry("Minesweeper", "SingleChording", m_single_chording);
|
config->write_bool_entry("Minesweeper", "SingleChording", m_single_chording);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ void SnakeGame::timer_event(Core::TimerEvent&)
|
||||||
m_high_score = m_score;
|
m_high_score = m_score;
|
||||||
m_high_score_text = String::formatted("Best: {}", m_high_score);
|
m_high_score_text = String::formatted("Best: {}", m_high_score);
|
||||||
update(high_score_rect());
|
update(high_score_rect());
|
||||||
auto config = Core::ConfigFile::get_for_app("Snake");
|
auto config = Core::ConfigFile::get_for_app("Snake", Core::ConfigFile::AllowWriting::Yes);
|
||||||
config->write_num_entry("Snake", "HighScore", m_high_score);
|
config->write_num_entry("Snake", "HighScore", m_high_score);
|
||||||
}
|
}
|
||||||
update(score_rect());
|
update(score_rect());
|
||||||
|
|
|
@ -24,7 +24,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
auto app_icon = GUI::Icon::default_icon("app-solitaire");
|
auto app_icon = GUI::Icon::default_icon("app-solitaire");
|
||||||
auto config = Core::ConfigFile::get_for_app("Solitaire");
|
auto config = Core::ConfigFile::get_for_app("Solitaire", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
if (pledge("stdio recvfd sendfd rpath wpath cpath", nullptr) < 0) {
|
if (pledge("stdio recvfd sendfd rpath wpath cpath", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
|
|
|
@ -39,7 +39,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
auto app_icon = GUI::Icon::default_icon("app-spider");
|
auto app_icon = GUI::Icon::default_icon("app-spider");
|
||||||
auto config = Core::ConfigFile::get_for_app("Spider");
|
auto config = Core::ConfigFile::get_for_app("Spider", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
if (pledge("stdio recvfd sendfd rpath wpath cpath", nullptr) < 0) {
|
if (pledge("stdio recvfd sendfd rpath wpath cpath", nullptr) < 0) {
|
||||||
perror("pledge");
|
perror("pledge");
|
||||||
|
|
|
@ -59,7 +59,7 @@ bool Desktop::set_wallpaper(const StringView& path, bool save_config)
|
||||||
auto ret_val = WindowServerConnection::the().wait_for_specific_message<Messages::WindowClient::SetWallpaperFinished>()->success();
|
auto ret_val = WindowServerConnection::the().wait_for_specific_message<Messages::WindowClient::SetWallpaperFinished>()->success();
|
||||||
|
|
||||||
if (ret_val && save_config) {
|
if (ret_val && save_config) {
|
||||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager");
|
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("WindowManager", Core::ConfigFile::AllowWriting::Yes);
|
||||||
dbgln("Saving wallpaper path '{}' to config file at {}", path, config->filename());
|
dbgln("Saving wallpaper path '{}' to config file at {}", path, config->filename());
|
||||||
config->write_entry("Background", "Wallpaper", path);
|
config->write_entry("Background", "Wallpaper", path);
|
||||||
config->sync();
|
config->sync();
|
||||||
|
|
|
@ -17,7 +17,7 @@ int main(int, char**)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = Core::ConfigFile::get_for_app("Audio");
|
auto config = Core::ConfigFile::get_for_app("Audio", Core::ConfigFile::AllowWriting::Yes);
|
||||||
if (unveil(config->filename().characters(), "rwc") < 0) {
|
if (unveil(config->filename().characters(), "rwc") < 0) {
|
||||||
perror("unveil");
|
perror("unveil");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -777,7 +777,7 @@ Messages::WindowServer::SetSystemFontsResponse ClientConnection::set_system_font
|
||||||
|
|
||||||
WindowManager::the().invalidate_after_theme_or_font_change();
|
WindowManager::the().invalidate_after_theme_or_font_change();
|
||||||
|
|
||||||
auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini");
|
auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini", Core::ConfigFile::AllowWriting::Yes);
|
||||||
wm_config->write_entry("Fonts", "Default", default_font_query);
|
wm_config->write_entry("Fonts", "Default", default_font_query);
|
||||||
wm_config->write_entry("Fonts", "FixedWidth", fixed_width_font_query);
|
wm_config->write_entry("Fonts", "FixedWidth", fixed_width_font_query);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -66,7 +66,7 @@ RefPtr<Cursor> WindowManager::get_cursor(String const& name)
|
||||||
|
|
||||||
void WindowManager::reload_config()
|
void WindowManager::reload_config()
|
||||||
{
|
{
|
||||||
m_config = Core::ConfigFile::open("/etc/WindowServer.ini");
|
m_config = Core::ConfigFile::open("/etc/WindowServer.ini", Core::ConfigFile::AllowWriting::Yes);
|
||||||
|
|
||||||
unsigned virtual_desktop_rows = (unsigned)m_config->read_num_entry("VirtualDesktop", "Rows", default_window_stack_rows);
|
unsigned virtual_desktop_rows = (unsigned)m_config->read_num_entry("VirtualDesktop", "Rows", default_window_stack_rows);
|
||||||
unsigned virtual_desktop_columns = (unsigned)m_config->read_num_entry("VirtualDesktop", "Columns", default_window_stack_columns);
|
unsigned virtual_desktop_columns = (unsigned)m_config->read_num_entry("VirtualDesktop", "Columns", default_window_stack_columns);
|
||||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = Core::ConfigFile::open(path);
|
auto config = Core::ConfigFile::open(path, value_to_write ? Core::ConfigFile::AllowWriting::Yes : Core::ConfigFile::AllowWriting::No);
|
||||||
|
|
||||||
if (value_to_write) {
|
if (value_to_write) {
|
||||||
config->write_entry(group, key, value_to_write);
|
config->write_entry(group, key, value_to_write);
|
||||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mapper_config(Core::ConfigFile::open("/etc/Keyboard.ini"));
|
auto mapper_config(Core::ConfigFile::open("/etc/Keyboard.ini", Core::ConfigFile::AllowWriting::Yes));
|
||||||
mapper_config->write_entry("Mapping", "Keymap", path);
|
mapper_config->write_entry("Mapping", "Keymap", path);
|
||||||
mapper_config->sync();
|
mapper_config->sync();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue