AppFile.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibCore/ConfigFile.h>
  9. #include <LibGUI/FileIconProvider.h>
  10. #include <LibGUI/Icon.h>
  11. namespace Desktop {
  12. class AppFile : public RefCounted<AppFile> {
  13. public:
  14. static constexpr auto APP_FILES_DIRECTORY = "/res/apps"sv;
  15. static NonnullRefPtr<AppFile> get_for_app(StringView app_name);
  16. static NonnullRefPtr<AppFile> open(StringView path);
  17. static void for_each(Function<void(NonnullRefPtr<AppFile>)>, StringView directory = APP_FILES_DIRECTORY);
  18. ~AppFile() = default;
  19. bool is_valid() const { return m_valid; }
  20. DeprecatedString filename() const { return m_config->filename(); }
  21. DeprecatedString name() const;
  22. DeprecatedString executable() const;
  23. DeprecatedString category() const;
  24. DeprecatedString description() const;
  25. DeprecatedString working_directory() const;
  26. DeprecatedString icon_path() const;
  27. GUI::Icon icon() const;
  28. bool run_in_terminal() const;
  29. bool requires_root() const;
  30. bool exclude_from_system_menu() const;
  31. Vector<DeprecatedString> launcher_mime_types() const;
  32. Vector<DeprecatedString> launcher_file_types() const;
  33. Vector<DeprecatedString> launcher_protocols() const;
  34. bool spawn(ReadonlySpan<StringView> arguments = {}) const;
  35. private:
  36. explicit AppFile(StringView path);
  37. bool validate() const;
  38. RefPtr<Core::ConfigFile> m_config;
  39. bool m_valid { false };
  40. };
  41. }