1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:27:34 +00:00

Launcher: Provide launcher details to LibDesktop

This allows applications to get additional information,
such as name or icons, for each launch handler.
This commit is contained in:
Tom 2020-07-13 18:55:09 -06:00 committed by Andreas Kling
parent 7498024805
commit 535113bac4
7 changed files with 208 additions and 26 deletions

View file

@ -34,10 +34,21 @@
namespace LaunchServer {
struct Handler {
enum class Type {
Default = 0,
UserPreferred,
UserDefault
};
Type handler_type;
String name;
String executable;
HashTable<String> file_types;
HashTable<String> protocols;
HashTable<String> file_types {};
HashTable<String> protocols {};
HashMap<String, String> icons {};
static String name_from_executable(const StringView&);
void from_executable(Type, const String&);
String to_details_str() const;
};
class Launcher {
@ -49,14 +60,16 @@ public:
void load_config(const Core::ConfigFile&);
bool open_url(const URL&, const String& handler_name);
Vector<String> handlers_for_url(const URL&);
Vector<String> handlers_with_details_for_url(const URL&);
private:
HashMap<String, Handler> m_handlers;
HashMap<String, String> m_protocol_handlers;
HashMap<String, String> m_file_handlers;
Vector<String> handlers_for(const String& key, HashMap<String, String>& user_preferences, Function<bool(Handler&, const String&)> handler_matches);
Vector<String> handlers_for_path(const String&);
Handler get_handler_for_executable(Handler::Type, const String&) const;
void for_each_handler(const String& key, HashMap<String, String>& user_preferences, Function<bool(const Handler&)> f);
void for_each_handler_for_path(const String&, Function<bool(const Handler&)> f);
bool open_file_url(const URL&);
bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String key, const String argument, const String default_program);
bool open_with_handler_name(const URL&, const String& handler_name);