AppFile.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 char const* APP_FILES_DIRECTORY = "/res/apps";
  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. String filename() const { return m_config->filename(); }
  21. String name() const;
  22. String executable() const;
  23. String category() const;
  24. String description() const;
  25. String icon_path() const;
  26. GUI::Icon icon() const;
  27. bool run_in_terminal() const;
  28. Vector<String> launcher_file_types() const;
  29. Vector<String> launcher_protocols() const;
  30. bool spawn() const;
  31. private:
  32. explicit AppFile(StringView path);
  33. bool validate() const;
  34. RefPtr<Core::ConfigFile> m_config;
  35. bool m_valid { false };
  36. };
  37. }