mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LaunchServer: Make all file handlers configurable including directories
This commit gets rid of hard coded file handlers in Launcher.cpp in favor of using values in the LaunchServer.ini config file. The previous commit adds checks for the existence of handler programs while registering handlers. This commit takes advantage of that and ensures that LaunchServer will not attempt to open a file with a nonexistent program and can properly report failure before spawning a new child process. Resolves #8120
This commit is contained in:
parent
f29980a15b
commit
5ac9494483
2 changed files with 20 additions and 9 deletions
|
@ -17,6 +17,7 @@ font=/bin/FontEditor
|
||||||
sheets=/bin/Spreadsheet
|
sheets=/bin/Spreadsheet
|
||||||
gml=/bin/Playground
|
gml=/bin/Playground
|
||||||
pdf=/bin/PDFViewer
|
pdf=/bin/PDFViewer
|
||||||
|
directory=/bin/FileManager
|
||||||
*=/bin/TextEditor
|
*=/bin/TextEditor
|
||||||
|
|
||||||
[Protocol]
|
[Protocol]
|
||||||
|
|
|
@ -257,9 +257,12 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make directory opening configurable
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
f(get_handler_for_executable(Handler::Type::Default, "/bin/FileManager"));
|
auto handler_optional = m_file_handlers.get("directory");
|
||||||
|
if (!handler_optional.has_value())
|
||||||
|
return;
|
||||||
|
auto& handler = handler_optional.value();
|
||||||
|
f(get_handler_for_executable(Handler::Type::Default, handler));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +286,6 @@ bool Launcher::open_file_url(const URL& url)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make directory opening configurable
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
Vector<String> fm_arguments;
|
Vector<String> fm_arguments;
|
||||||
if (url.fragment().is_empty()) {
|
if (url.fragment().is_empty()) {
|
||||||
|
@ -293,7 +295,13 @@ bool Launcher::open_file_url(const URL& url)
|
||||||
fm_arguments.append("-r");
|
fm_arguments.append("-r");
|
||||||
fm_arguments.append(String::formatted("{}/{}", url.path(), url.fragment()));
|
fm_arguments.append(String::formatted("{}/{}", url.path(), url.fragment()));
|
||||||
}
|
}
|
||||||
return spawn("/bin/FileManager", fm_arguments);
|
|
||||||
|
auto handler_optional = m_file_handlers.get("directory");
|
||||||
|
if (!handler_optional.has_value())
|
||||||
|
return false;
|
||||||
|
auto& handler = handler_optional.value();
|
||||||
|
|
||||||
|
return spawn(handler, fm_arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((st.st_mode & S_IFMT) == S_IFREG && st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
|
if ((st.st_mode & S_IFMT) == S_IFREG && st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
|
||||||
|
@ -304,7 +312,12 @@ bool Launcher::open_file_url(const URL& url)
|
||||||
if (extension_parts.size() > 1)
|
if (extension_parts.size() > 1)
|
||||||
extension = extension_parts.last();
|
extension = extension_parts.last();
|
||||||
|
|
||||||
// Additional parameters parsing, specific for the file protocol and TextEditor
|
auto handler_optional = m_file_handlers.get("txt");
|
||||||
|
if (!handler_optional.has_value())
|
||||||
|
return false;
|
||||||
|
auto& default_handler = handler_optional.value();
|
||||||
|
|
||||||
|
// Additional parameters parsing, specific for the file protocol and txt file handlers
|
||||||
Vector<String> additional_parameters;
|
Vector<String> additional_parameters;
|
||||||
String filepath = url.path();
|
String filepath = url.path();
|
||||||
|
|
||||||
|
@ -318,9 +331,6 @@ bool Launcher::open_file_url(const URL& url)
|
||||||
filepath = String::formatted("{}:{}", filepath, line.value());
|
filepath = String::formatted("{}:{}", filepath, line.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return open_with_user_preferences(m_file_handlers, extension, additional_parameters, default_handler);
|
||||||
additional_parameters.append(filepath);
|
|
||||||
|
|
||||||
return open_with_user_preferences(m_file_handlers, extension, additional_parameters, "/bin/TextEditor");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue