AppFile.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 bool exists_for_app(StringView app_name);
  16. static DeprecatedString file_for_app(StringView app_name);
  17. static DeprecatedString app_file_path_for_app(StringView app_name);
  18. static NonnullRefPtr<AppFile> get_for_app(StringView app_name);
  19. static NonnullRefPtr<AppFile> open(StringView path);
  20. static void for_each(Function<void(NonnullRefPtr<AppFile>)>, StringView directory = APP_FILES_DIRECTORY);
  21. ~AppFile() = default;
  22. bool is_valid() const { return m_valid; }
  23. DeprecatedString filename() const { return m_config->filename(); }
  24. DeprecatedString name() const;
  25. DeprecatedString executable() const;
  26. DeprecatedString category() const;
  27. DeprecatedString description() const;
  28. DeprecatedString working_directory() const;
  29. DeprecatedString icon_path() const;
  30. GUI::Icon icon() const;
  31. bool run_in_terminal() const;
  32. bool requires_root() const;
  33. bool exclude_from_system_menu() const;
  34. Vector<DeprecatedString> launcher_mime_types() const;
  35. Vector<DeprecatedString> launcher_file_types() const;
  36. Vector<DeprecatedString> launcher_protocols() const;
  37. bool spawn(ReadonlySpan<StringView> arguments = {}) const;
  38. private:
  39. explicit AppFile(StringView path);
  40. bool validate() const;
  41. RefPtr<Core::ConfigFile> m_config;
  42. bool m_valid { false };
  43. };
  44. }