AppFile.h 1.2 KB

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