IAppManager.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\App;
  8. use OCP\IGroup;
  9. use OCP\IUser;
  10. /**
  11. * Interface IAppManager
  12. *
  13. * @warning This interface shouldn't be included with dependency injection in
  14. * classes used for installing Nextcloud.
  15. *
  16. * @since 8.0.0
  17. */
  18. interface IAppManager {
  19. /**
  20. * @since 30.0.0
  21. */
  22. public const BACKEND_CALDAV = 'caldav';
  23. /**
  24. * Returns the app information from "appinfo/info.xml".
  25. *
  26. * @param string|null $lang
  27. * @return array|null
  28. * @since 14.0.0
  29. */
  30. public function getAppInfo(string $appId, bool $path = false, $lang = null);
  31. /**
  32. * Returns the app information from "appinfo/info.xml".
  33. *
  34. * @param string $appId
  35. * @param bool $useCache
  36. * @return string
  37. * @since 14.0.0
  38. */
  39. public function getAppVersion(string $appId, bool $useCache = true): string;
  40. /**
  41. * Returns the app icon or null if none is found
  42. *
  43. * @param string $appId
  44. * @param bool $dark Enable to request a dark icon variant, default is a white icon
  45. * @return string|null
  46. * @since 29.0.0
  47. */
  48. public function getAppIcon(string $appId, bool $dark = false): string|null;
  49. /**
  50. * Check if an app is enabled for user
  51. *
  52. * @param string $appId
  53. * @param \OCP\IUser|null $user (optional) if not defined, the currently loggedin user will be used
  54. * @return bool
  55. * @since 8.0.0
  56. */
  57. public function isEnabledForUser($appId, $user = null);
  58. /**
  59. * Check if an app is enabled in the instance
  60. *
  61. * Notice: This actually checks if the app is enabled and not only if it is installed.
  62. *
  63. * @param string $appId
  64. * @return bool
  65. * @since 8.0.0
  66. */
  67. public function isInstalled($appId);
  68. /**
  69. * Check if an app should be enabled by default
  70. *
  71. * Notice: This actually checks if the app should be enabled by default
  72. * and not if currently installed/enabled
  73. *
  74. * @param string $appId ID of the app
  75. * @since 25.0.0
  76. */
  77. public function isDefaultEnabled(string $appId):bool;
  78. /**
  79. * Load an app, if not already loaded
  80. * @param string $app app id
  81. * @since 27.0.0
  82. */
  83. public function loadApp(string $app): void;
  84. /**
  85. * Check if an app is loaded
  86. * @param string $app app id
  87. * @since 27.0.0
  88. */
  89. public function isAppLoaded(string $app): bool;
  90. /**
  91. * Enable an app for every user
  92. *
  93. * @param string $appId
  94. * @param bool $forceEnable
  95. * @throws AppPathNotFoundException
  96. * @since 8.0.0
  97. */
  98. public function enableApp(string $appId, bool $forceEnable = false): void;
  99. /**
  100. * Whether a list of types contains a protected app type
  101. *
  102. * @param string[] $types
  103. * @return bool
  104. * @since 12.0.0
  105. */
  106. public function hasProtectedAppType($types);
  107. /**
  108. * Enable an app only for specific groups
  109. *
  110. * @param string $appId
  111. * @param \OCP\IGroup[] $groups
  112. * @param bool $forceEnable
  113. * @throws \Exception
  114. * @since 8.0.0
  115. */
  116. public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void;
  117. /**
  118. * Disable an app for every user
  119. *
  120. * @param string $appId
  121. * @param bool $automaticDisabled
  122. * @since 8.0.0
  123. */
  124. public function disableApp($appId, $automaticDisabled = false);
  125. /**
  126. * Get the directory for the given app.
  127. *
  128. * @param string $appId
  129. * @return string
  130. * @since 11.0.0
  131. * @throws AppPathNotFoundException
  132. */
  133. public function getAppPath($appId);
  134. /**
  135. * Get the web path for the given app.
  136. *
  137. * @param string $appId
  138. * @return string
  139. * @since 18.0.0
  140. * @throws AppPathNotFoundException
  141. */
  142. public function getAppWebPath(string $appId): string;
  143. /**
  144. * List all apps enabled for a user
  145. *
  146. * @param \OCP\IUser $user
  147. * @return string[]
  148. * @since 8.1.0
  149. */
  150. public function getEnabledAppsForUser(IUser $user);
  151. /**
  152. * List all installed apps
  153. *
  154. * @return string[]
  155. * @since 8.1.0
  156. */
  157. public function getInstalledApps();
  158. /**
  159. * Clear the cached list of apps when enabling/disabling an app
  160. * @since 8.1.0
  161. */
  162. public function clearAppsCache();
  163. /**
  164. * @param string $appId
  165. * @return boolean
  166. * @since 9.0.0
  167. */
  168. public function isShipped($appId);
  169. /**
  170. * Loads all apps
  171. *
  172. * @param string[] $types
  173. * @return bool
  174. *
  175. * This function walks through the Nextcloud directory and loads all apps
  176. * it can find. A directory contains an app if the file /appinfo/info.xml
  177. * exists.
  178. *
  179. * if $types is set to non-empty array, only apps of those types will be loaded
  180. * @since 27.0.0
  181. */
  182. public function loadApps(array $types = []): bool;
  183. /**
  184. * Check if an app is of a specific type
  185. * @since 27.0.0
  186. */
  187. public function isType(string $app, array $types): bool;
  188. /**
  189. * @return string[]
  190. * @since 9.0.0
  191. */
  192. public function getAlwaysEnabledApps();
  193. /**
  194. * @return string[] app IDs
  195. * @since 25.0.0
  196. */
  197. public function getDefaultEnabledApps(): array;
  198. /**
  199. * @param \OCP\IGroup $group
  200. * @return String[]
  201. * @since 17.0.0
  202. */
  203. public function getEnabledAppsForGroup(IGroup $group): array;
  204. /**
  205. * @param String $appId
  206. * @return string[]
  207. * @since 17.0.0
  208. */
  209. public function getAppRestriction(string $appId): array;
  210. /**
  211. * Returns the id of the user's default app
  212. *
  213. * If `user` is not passed, the currently logged in user will be used
  214. *
  215. * @param ?IUser $user User to query default app for
  216. * @param bool $withFallbacks Include fallback values if no default app was configured manually
  217. * Before falling back to predefined default apps,
  218. * the user defined app order is considered and the first app would be used as the fallback.
  219. *
  220. * @since 25.0.6
  221. * @since 28.0.0 Added optional $withFallbacks parameter
  222. */
  223. public function getDefaultAppForUser(?IUser $user = null, bool $withFallbacks = true): string;
  224. /**
  225. * Get the global default apps with fallbacks
  226. *
  227. * @return string[] The default applications
  228. * @since 28.0.0
  229. */
  230. public function getDefaultApps(): array;
  231. /**
  232. * Set the global default apps with fallbacks
  233. *
  234. * @param string[] $appId
  235. * @throws \InvalidArgumentException If any of the apps is not installed
  236. * @since 28.0.0
  237. */
  238. public function setDefaultApps(array $defaultApps): void;
  239. /**
  240. * Check whether the given backend is required by at least one app.
  241. *
  242. * @param self::BACKEND_* $backend Name of the backend, one of `self::BACKEND_*`
  243. * @return bool True if at least one app requires the backend
  244. *
  245. * @since 30.0.0
  246. */
  247. public function isBackendRequired(string $backend): bool;
  248. }