@@ -6,38 +6,38 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\Files_Trashbin\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
10 | - 'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => $baseDir . '/../lib/BackgroundJob/ExpireTrash.php', |
|
11 | - 'OCA\\Files_Trashbin\\Capabilities' => $baseDir . '/../lib/Capabilities.php', |
|
12 | - 'OCA\\Files_Trashbin\\Command\\CleanUp' => $baseDir . '/../lib/Command/CleanUp.php', |
|
13 | - 'OCA\\Files_Trashbin\\Command\\Expire' => $baseDir . '/../lib/Command/Expire.php', |
|
14 | - 'OCA\\Files_Trashbin\\Command\\ExpireTrash' => $baseDir . '/../lib/Command/ExpireTrash.php', |
|
15 | - 'OCA\\Files_Trashbin\\Controller\\PreviewController' => $baseDir . '/../lib/Controller/PreviewController.php', |
|
16 | - 'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => $baseDir . '/../lib/Events/MoveToTrashEvent.php', |
|
17 | - 'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => $baseDir . '/../lib/Exceptions/CopyRecursiveException.php', |
|
18 | - 'OCA\\Files_Trashbin\\Expiration' => $baseDir . '/../lib/Expiration.php', |
|
19 | - 'OCA\\Files_Trashbin\\Helper' => $baseDir . '/../lib/Helper.php', |
|
20 | - 'OCA\\Files_Trashbin\\Hooks' => $baseDir . '/../lib/Hooks.php', |
|
21 | - 'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => $baseDir . '/../lib/Sabre/AbstractTrash.php', |
|
22 | - 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => $baseDir . '/../lib/Sabre/AbstractTrashFile.php', |
|
23 | - 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => $baseDir . '/../lib/Sabre/AbstractTrashFolder.php', |
|
24 | - 'OCA\\Files_Trashbin\\Sabre\\ITrash' => $baseDir . '/../lib/Sabre/ITrash.php', |
|
25 | - 'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => $baseDir . '/../lib/Sabre/PropfindPlugin.php', |
|
26 | - 'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => $baseDir . '/../lib/Sabre/RestoreFolder.php', |
|
27 | - 'OCA\\Files_Trashbin\\Sabre\\RootCollection' => $baseDir . '/../lib/Sabre/RootCollection.php', |
|
28 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFile' => $baseDir . '/../lib/Sabre/TrashFile.php', |
|
29 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => $baseDir . '/../lib/Sabre/TrashFolder.php', |
|
30 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => $baseDir . '/../lib/Sabre/TrashFolderFile.php', |
|
31 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => $baseDir . '/../lib/Sabre/TrashFolderFolder.php', |
|
32 | - 'OCA\\Files_Trashbin\\Sabre\\TrashHome' => $baseDir . '/../lib/Sabre/TrashHome.php', |
|
33 | - 'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => $baseDir . '/../lib/Sabre/TrashRoot.php', |
|
34 | - 'OCA\\Files_Trashbin\\Storage' => $baseDir . '/../lib/Storage.php', |
|
35 | - 'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => $baseDir . '/../lib/Trash/BackendNotFoundException.php', |
|
36 | - 'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => $baseDir . '/../lib/Trash/ITrashBackend.php', |
|
37 | - 'OCA\\Files_Trashbin\\Trash\\ITrashItem' => $baseDir . '/../lib/Trash/ITrashItem.php', |
|
38 | - 'OCA\\Files_Trashbin\\Trash\\ITrashManager' => $baseDir . '/../lib/Trash/ITrashManager.php', |
|
39 | - 'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => $baseDir . '/../lib/Trash/LegacyTrashBackend.php', |
|
40 | - 'OCA\\Files_Trashbin\\Trash\\TrashItem' => $baseDir . '/../lib/Trash/TrashItem.php', |
|
41 | - 'OCA\\Files_Trashbin\\Trash\\TrashManager' => $baseDir . '/../lib/Trash/TrashManager.php', |
|
42 | - 'OCA\\Files_Trashbin\\Trashbin' => $baseDir . '/../lib/Trashbin.php', |
|
9 | + 'OCA\\Files_Trashbin\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
10 | + 'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => $baseDir.'/../lib/BackgroundJob/ExpireTrash.php', |
|
11 | + 'OCA\\Files_Trashbin\\Capabilities' => $baseDir.'/../lib/Capabilities.php', |
|
12 | + 'OCA\\Files_Trashbin\\Command\\CleanUp' => $baseDir.'/../lib/Command/CleanUp.php', |
|
13 | + 'OCA\\Files_Trashbin\\Command\\Expire' => $baseDir.'/../lib/Command/Expire.php', |
|
14 | + 'OCA\\Files_Trashbin\\Command\\ExpireTrash' => $baseDir.'/../lib/Command/ExpireTrash.php', |
|
15 | + 'OCA\\Files_Trashbin\\Controller\\PreviewController' => $baseDir.'/../lib/Controller/PreviewController.php', |
|
16 | + 'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => $baseDir.'/../lib/Events/MoveToTrashEvent.php', |
|
17 | + 'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => $baseDir.'/../lib/Exceptions/CopyRecursiveException.php', |
|
18 | + 'OCA\\Files_Trashbin\\Expiration' => $baseDir.'/../lib/Expiration.php', |
|
19 | + 'OCA\\Files_Trashbin\\Helper' => $baseDir.'/../lib/Helper.php', |
|
20 | + 'OCA\\Files_Trashbin\\Hooks' => $baseDir.'/../lib/Hooks.php', |
|
21 | + 'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => $baseDir.'/../lib/Sabre/AbstractTrash.php', |
|
22 | + 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => $baseDir.'/../lib/Sabre/AbstractTrashFile.php', |
|
23 | + 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => $baseDir.'/../lib/Sabre/AbstractTrashFolder.php', |
|
24 | + 'OCA\\Files_Trashbin\\Sabre\\ITrash' => $baseDir.'/../lib/Sabre/ITrash.php', |
|
25 | + 'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => $baseDir.'/../lib/Sabre/PropfindPlugin.php', |
|
26 | + 'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => $baseDir.'/../lib/Sabre/RestoreFolder.php', |
|
27 | + 'OCA\\Files_Trashbin\\Sabre\\RootCollection' => $baseDir.'/../lib/Sabre/RootCollection.php', |
|
28 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFile' => $baseDir.'/../lib/Sabre/TrashFile.php', |
|
29 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => $baseDir.'/../lib/Sabre/TrashFolder.php', |
|
30 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => $baseDir.'/../lib/Sabre/TrashFolderFile.php', |
|
31 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => $baseDir.'/../lib/Sabre/TrashFolderFolder.php', |
|
32 | + 'OCA\\Files_Trashbin\\Sabre\\TrashHome' => $baseDir.'/../lib/Sabre/TrashHome.php', |
|
33 | + 'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => $baseDir.'/../lib/Sabre/TrashRoot.php', |
|
34 | + 'OCA\\Files_Trashbin\\Storage' => $baseDir.'/../lib/Storage.php', |
|
35 | + 'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => $baseDir.'/../lib/Trash/BackendNotFoundException.php', |
|
36 | + 'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => $baseDir.'/../lib/Trash/ITrashBackend.php', |
|
37 | + 'OCA\\Files_Trashbin\\Trash\\ITrashItem' => $baseDir.'/../lib/Trash/ITrashItem.php', |
|
38 | + 'OCA\\Files_Trashbin\\Trash\\ITrashManager' => $baseDir.'/../lib/Trash/ITrashManager.php', |
|
39 | + 'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => $baseDir.'/../lib/Trash/LegacyTrashBackend.php', |
|
40 | + 'OCA\\Files_Trashbin\\Trash\\TrashItem' => $baseDir.'/../lib/Trash/TrashItem.php', |
|
41 | + 'OCA\\Files_Trashbin\\Trash\\TrashManager' => $baseDir.'/../lib/Trash/TrashManager.php', |
|
42 | + 'OCA\\Files_Trashbin\\Trashbin' => $baseDir.'/../lib/Trashbin.php', |
|
43 | 43 | ); |
@@ -6,60 +6,60 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitFiles_Trashbin |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\Files_Trashbin\\' => 19, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\Files_Trashbin\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'OCA\\Files_Trashbin\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
25 | - 'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => __DIR__ . '/..' . '/../lib/BackgroundJob/ExpireTrash.php', |
|
26 | - 'OCA\\Files_Trashbin\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', |
|
27 | - 'OCA\\Files_Trashbin\\Command\\CleanUp' => __DIR__ . '/..' . '/../lib/Command/CleanUp.php', |
|
28 | - 'OCA\\Files_Trashbin\\Command\\Expire' => __DIR__ . '/..' . '/../lib/Command/Expire.php', |
|
29 | - 'OCA\\Files_Trashbin\\Command\\ExpireTrash' => __DIR__ . '/..' . '/../lib/Command/ExpireTrash.php', |
|
30 | - 'OCA\\Files_Trashbin\\Controller\\PreviewController' => __DIR__ . '/..' . '/../lib/Controller/PreviewController.php', |
|
31 | - 'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => __DIR__ . '/..' . '/../lib/Events/MoveToTrashEvent.php', |
|
32 | - 'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => __DIR__ . '/..' . '/../lib/Exceptions/CopyRecursiveException.php', |
|
33 | - 'OCA\\Files_Trashbin\\Expiration' => __DIR__ . '/..' . '/../lib/Expiration.php', |
|
34 | - 'OCA\\Files_Trashbin\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', |
|
35 | - 'OCA\\Files_Trashbin\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', |
|
36 | - 'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrash.php', |
|
37 | - 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFile.php', |
|
38 | - 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFolder.php', |
|
39 | - 'OCA\\Files_Trashbin\\Sabre\\ITrash' => __DIR__ . '/..' . '/../lib/Sabre/ITrash.php', |
|
40 | - 'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => __DIR__ . '/..' . '/../lib/Sabre/PropfindPlugin.php', |
|
41 | - 'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => __DIR__ . '/..' . '/../lib/Sabre/RestoreFolder.php', |
|
42 | - 'OCA\\Files_Trashbin\\Sabre\\RootCollection' => __DIR__ . '/..' . '/../lib/Sabre/RootCollection.php', |
|
43 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFile' => __DIR__ . '/..' . '/../lib/Sabre/TrashFile.php', |
|
44 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolder.php', |
|
45 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolderFile.php', |
|
46 | - 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolderFolder.php', |
|
47 | - 'OCA\\Files_Trashbin\\Sabre\\TrashHome' => __DIR__ . '/..' . '/../lib/Sabre/TrashHome.php', |
|
48 | - 'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => __DIR__ . '/..' . '/../lib/Sabre/TrashRoot.php', |
|
49 | - 'OCA\\Files_Trashbin\\Storage' => __DIR__ . '/..' . '/../lib/Storage.php', |
|
50 | - 'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => __DIR__ . '/..' . '/../lib/Trash/BackendNotFoundException.php', |
|
51 | - 'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => __DIR__ . '/..' . '/../lib/Trash/ITrashBackend.php', |
|
52 | - 'OCA\\Files_Trashbin\\Trash\\ITrashItem' => __DIR__ . '/..' . '/../lib/Trash/ITrashItem.php', |
|
53 | - 'OCA\\Files_Trashbin\\Trash\\ITrashManager' => __DIR__ . '/..' . '/../lib/Trash/ITrashManager.php', |
|
54 | - 'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => __DIR__ . '/..' . '/../lib/Trash/LegacyTrashBackend.php', |
|
55 | - 'OCA\\Files_Trashbin\\Trash\\TrashItem' => __DIR__ . '/..' . '/../lib/Trash/TrashItem.php', |
|
56 | - 'OCA\\Files_Trashbin\\Trash\\TrashManager' => __DIR__ . '/..' . '/../lib/Trash/TrashManager.php', |
|
57 | - 'OCA\\Files_Trashbin\\Trashbin' => __DIR__ . '/..' . '/../lib/Trashbin.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\Files_Trashbin\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
25 | + 'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => __DIR__.'/..'.'/../lib/BackgroundJob/ExpireTrash.php', |
|
26 | + 'OCA\\Files_Trashbin\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', |
|
27 | + 'OCA\\Files_Trashbin\\Command\\CleanUp' => __DIR__.'/..'.'/../lib/Command/CleanUp.php', |
|
28 | + 'OCA\\Files_Trashbin\\Command\\Expire' => __DIR__.'/..'.'/../lib/Command/Expire.php', |
|
29 | + 'OCA\\Files_Trashbin\\Command\\ExpireTrash' => __DIR__.'/..'.'/../lib/Command/ExpireTrash.php', |
|
30 | + 'OCA\\Files_Trashbin\\Controller\\PreviewController' => __DIR__.'/..'.'/../lib/Controller/PreviewController.php', |
|
31 | + 'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => __DIR__.'/..'.'/../lib/Events/MoveToTrashEvent.php', |
|
32 | + 'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => __DIR__.'/..'.'/../lib/Exceptions/CopyRecursiveException.php', |
|
33 | + 'OCA\\Files_Trashbin\\Expiration' => __DIR__.'/..'.'/../lib/Expiration.php', |
|
34 | + 'OCA\\Files_Trashbin\\Helper' => __DIR__.'/..'.'/../lib/Helper.php', |
|
35 | + 'OCA\\Files_Trashbin\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php', |
|
36 | + 'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => __DIR__.'/..'.'/../lib/Sabre/AbstractTrash.php', |
|
37 | + 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => __DIR__.'/..'.'/../lib/Sabre/AbstractTrashFile.php', |
|
38 | + 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => __DIR__.'/..'.'/../lib/Sabre/AbstractTrashFolder.php', |
|
39 | + 'OCA\\Files_Trashbin\\Sabre\\ITrash' => __DIR__.'/..'.'/../lib/Sabre/ITrash.php', |
|
40 | + 'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => __DIR__.'/..'.'/../lib/Sabre/PropfindPlugin.php', |
|
41 | + 'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => __DIR__.'/..'.'/../lib/Sabre/RestoreFolder.php', |
|
42 | + 'OCA\\Files_Trashbin\\Sabre\\RootCollection' => __DIR__.'/..'.'/../lib/Sabre/RootCollection.php', |
|
43 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFile' => __DIR__.'/..'.'/../lib/Sabre/TrashFile.php', |
|
44 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => __DIR__.'/..'.'/../lib/Sabre/TrashFolder.php', |
|
45 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => __DIR__.'/..'.'/../lib/Sabre/TrashFolderFile.php', |
|
46 | + 'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => __DIR__.'/..'.'/../lib/Sabre/TrashFolderFolder.php', |
|
47 | + 'OCA\\Files_Trashbin\\Sabre\\TrashHome' => __DIR__.'/..'.'/../lib/Sabre/TrashHome.php', |
|
48 | + 'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => __DIR__.'/..'.'/../lib/Sabre/TrashRoot.php', |
|
49 | + 'OCA\\Files_Trashbin\\Storage' => __DIR__.'/..'.'/../lib/Storage.php', |
|
50 | + 'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => __DIR__.'/..'.'/../lib/Trash/BackendNotFoundException.php', |
|
51 | + 'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => __DIR__.'/..'.'/../lib/Trash/ITrashBackend.php', |
|
52 | + 'OCA\\Files_Trashbin\\Trash\\ITrashItem' => __DIR__.'/..'.'/../lib/Trash/ITrashItem.php', |
|
53 | + 'OCA\\Files_Trashbin\\Trash\\ITrashManager' => __DIR__.'/..'.'/../lib/Trash/ITrashManager.php', |
|
54 | + 'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => __DIR__.'/..'.'/../lib/Trash/LegacyTrashBackend.php', |
|
55 | + 'OCA\\Files_Trashbin\\Trash\\TrashItem' => __DIR__.'/..'.'/../lib/Trash/TrashItem.php', |
|
56 | + 'OCA\\Files_Trashbin\\Trash\\TrashManager' => __DIR__.'/..'.'/../lib/Trash/TrashManager.php', |
|
57 | + 'OCA\\Files_Trashbin\\Trashbin' => __DIR__.'/..'.'/../lib/Trashbin.php', |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | public static function getInitializer(ClassLoader $loader) |
61 | 61 | { |
62 | - return \Closure::bind(function () use ($loader) { |
|
62 | + return \Closure::bind(function() use ($loader) { |
|
63 | 63 | $loader->prefixLengthsPsr4 = ComposerStaticInitFiles_Trashbin::$prefixLengthsPsr4; |
64 | 64 | $loader->prefixDirsPsr4 = ComposerStaticInitFiles_Trashbin::$prefixDirsPsr4; |
65 | 65 | $loader->classMap = ComposerStaticInitFiles_Trashbin::$classMap; |
@@ -60,534 +60,534 @@ |
||
60 | 60 | */ |
61 | 61 | interface IServerContainer extends IContainer { |
62 | 62 | |
63 | - /** |
|
64 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
65 | - * providers which actual deliver the calendar information. |
|
66 | - * |
|
67 | - * @return \OCP\Calendar\IManager |
|
68 | - * @since 13.0.0 |
|
69 | - */ |
|
70 | - public function getCalendarManager(); |
|
71 | - |
|
72 | - /** |
|
73 | - * The calendar resource backend manager will act as a broker between consumers |
|
74 | - * for calendar resource information an providers which actual deliver the room information. |
|
75 | - * |
|
76 | - * @return \OCP\Calendar\Resource\IBackend |
|
77 | - * @since 14.0.0 |
|
78 | - */ |
|
79 | - public function getCalendarResourceBackendManager(); |
|
80 | - |
|
81 | - /** |
|
82 | - * The calendar room backend manager will act as a broker between consumers |
|
83 | - * for calendar room information an providers which actual deliver the room information. |
|
84 | - * |
|
85 | - * @return \OCP\Calendar\Room\IBackend |
|
86 | - * @since 14.0.0 |
|
87 | - */ |
|
88 | - public function getCalendarRoomBackendManager(); |
|
89 | - |
|
90 | - /** |
|
91 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
92 | - * providers which actual deliver the contact information. |
|
93 | - * |
|
94 | - * @return \OCP\Contacts\IManager |
|
95 | - * @since 6.0.0 |
|
96 | - */ |
|
97 | - public function getContactsManager(); |
|
98 | - |
|
99 | - /** |
|
100 | - * The current request object holding all information about the request currently being processed |
|
101 | - * is returned from this method. |
|
102 | - * In case the current execution was not initiated by a web request null is returned |
|
103 | - * |
|
104 | - * @return \OCP\IRequest |
|
105 | - * @since 6.0.0 |
|
106 | - */ |
|
107 | - public function getRequest(); |
|
108 | - |
|
109 | - /** |
|
110 | - * Returns the preview manager which can create preview images for a given file |
|
111 | - * |
|
112 | - * @return \OCP\IPreview |
|
113 | - * @since 6.0.0 |
|
114 | - */ |
|
115 | - public function getPreviewManager(); |
|
116 | - |
|
117 | - /** |
|
118 | - * Returns the tag manager which can get and set tags for different object types |
|
119 | - * |
|
120 | - * @see \OCP\ITagManager::load() |
|
121 | - * @return \OCP\ITagManager |
|
122 | - * @since 6.0.0 |
|
123 | - */ |
|
124 | - public function getTagManager(); |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns the root folder of ownCloud's data directory |
|
128 | - * |
|
129 | - * @return \OCP\Files\IRootFolder |
|
130 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
131 | - */ |
|
132 | - public function getRootFolder(); |
|
133 | - |
|
134 | - /** |
|
135 | - * Returns a view to ownCloud's files folder |
|
136 | - * |
|
137 | - * @param string $userId user ID |
|
138 | - * @return \OCP\Files\Folder |
|
139 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
140 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
141 | - */ |
|
142 | - public function getUserFolder($userId = null); |
|
143 | - |
|
144 | - /** |
|
145 | - * Returns an app-specific view in ownClouds data directory |
|
146 | - * |
|
147 | - * @return \OCP\Files\Folder |
|
148 | - * @since 6.0.0 |
|
149 | - * @deprecated 9.2.0 use IAppData |
|
150 | - */ |
|
151 | - public function getAppFolder(); |
|
152 | - |
|
153 | - /** |
|
154 | - * Returns a user manager |
|
155 | - * |
|
156 | - * @return \OCP\IUserManager |
|
157 | - * @since 8.0.0 |
|
158 | - */ |
|
159 | - public function getUserManager(); |
|
160 | - |
|
161 | - /** |
|
162 | - * Returns a group manager |
|
163 | - * |
|
164 | - * @return \OCP\IGroupManager |
|
165 | - * @since 8.0.0 |
|
166 | - */ |
|
167 | - public function getGroupManager(); |
|
168 | - |
|
169 | - /** |
|
170 | - * Returns the user session |
|
171 | - * |
|
172 | - * @return \OCP\IUserSession |
|
173 | - * @since 6.0.0 |
|
174 | - */ |
|
175 | - public function getUserSession(); |
|
176 | - |
|
177 | - /** |
|
178 | - * Returns the navigation manager |
|
179 | - * |
|
180 | - * @return \OCP\INavigationManager |
|
181 | - * @since 6.0.0 |
|
182 | - */ |
|
183 | - public function getNavigationManager(); |
|
184 | - |
|
185 | - /** |
|
186 | - * Returns the config manager |
|
187 | - * |
|
188 | - * @return \OCP\IConfig |
|
189 | - * @since 6.0.0 |
|
190 | - */ |
|
191 | - public function getConfig(); |
|
192 | - |
|
193 | - /** |
|
194 | - * Returns a Crypto instance |
|
195 | - * |
|
196 | - * @return \OCP\Security\ICrypto |
|
197 | - * @since 8.0.0 |
|
198 | - */ |
|
199 | - public function getCrypto(); |
|
200 | - |
|
201 | - /** |
|
202 | - * Returns a Hasher instance |
|
203 | - * |
|
204 | - * @return \OCP\Security\IHasher |
|
205 | - * @since 8.0.0 |
|
206 | - */ |
|
207 | - public function getHasher(); |
|
208 | - |
|
209 | - /** |
|
210 | - * Returns a SecureRandom instance |
|
211 | - * |
|
212 | - * @return \OCP\Security\ISecureRandom |
|
213 | - * @since 8.1.0 |
|
214 | - */ |
|
215 | - public function getSecureRandom(); |
|
216 | - |
|
217 | - /** |
|
218 | - * Returns a CredentialsManager instance |
|
219 | - * |
|
220 | - * @return \OCP\Security\ICredentialsManager |
|
221 | - * @since 9.0.0 |
|
222 | - */ |
|
223 | - public function getCredentialsManager(); |
|
224 | - |
|
225 | - /** |
|
226 | - * Returns the app config manager |
|
227 | - * |
|
228 | - * @return \OCP\IAppConfig |
|
229 | - * @since 7.0.0 |
|
230 | - */ |
|
231 | - public function getAppConfig(); |
|
232 | - |
|
233 | - /** |
|
234 | - * @return \OCP\L10N\IFactory |
|
235 | - * @since 8.2.0 |
|
236 | - */ |
|
237 | - public function getL10NFactory(); |
|
238 | - |
|
239 | - /** |
|
240 | - * get an L10N instance |
|
241 | - * @param string $app appid |
|
242 | - * @param string $lang |
|
243 | - * @return \OCP\IL10N |
|
244 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
245 | - */ |
|
246 | - public function getL10N($app, $lang = null); |
|
247 | - |
|
248 | - /** |
|
249 | - * @return \OC\Encryption\Manager |
|
250 | - * @since 8.1.0 |
|
251 | - */ |
|
252 | - public function getEncryptionManager(); |
|
253 | - |
|
254 | - /** |
|
255 | - * @return \OC\Encryption\File |
|
256 | - * @since 8.1.0 |
|
257 | - */ |
|
258 | - public function getEncryptionFilesHelper(); |
|
259 | - |
|
260 | - /** |
|
261 | - * @return \OCP\Encryption\Keys\IStorage |
|
262 | - * @since 8.1.0 |
|
263 | - */ |
|
264 | - public function getEncryptionKeyStorage(); |
|
265 | - |
|
266 | - /** |
|
267 | - * Returns the URL generator |
|
268 | - * |
|
269 | - * @return \OCP\IURLGenerator |
|
270 | - * @since 6.0.0 |
|
271 | - */ |
|
272 | - public function getURLGenerator(); |
|
273 | - |
|
274 | - /** |
|
275 | - * Returns an ICache instance |
|
276 | - * |
|
277 | - * @return \OCP\ICache |
|
278 | - * @since 6.0.0 |
|
279 | - */ |
|
280 | - public function getCache(); |
|
281 | - |
|
282 | - /** |
|
283 | - * Returns an \OCP\CacheFactory instance |
|
284 | - * |
|
285 | - * @return \OCP\ICacheFactory |
|
286 | - * @since 7.0.0 |
|
287 | - */ |
|
288 | - public function getMemCacheFactory(); |
|
289 | - |
|
290 | - /** |
|
291 | - * Returns the current session |
|
292 | - * |
|
293 | - * @return \OCP\ISession |
|
294 | - * @since 6.0.0 |
|
295 | - */ |
|
296 | - public function getSession(); |
|
297 | - |
|
298 | - /** |
|
299 | - * Returns the activity manager |
|
300 | - * |
|
301 | - * @return \OCP\Activity\IManager |
|
302 | - * @since 6.0.0 |
|
303 | - */ |
|
304 | - public function getActivityManager(); |
|
305 | - |
|
306 | - /** |
|
307 | - * Returns the current session |
|
308 | - * |
|
309 | - * @return \OCP\IDBConnection |
|
310 | - * @since 6.0.0 |
|
311 | - */ |
|
312 | - public function getDatabaseConnection(); |
|
313 | - |
|
314 | - /** |
|
315 | - * Returns an avatar manager, used for avatar functionality |
|
316 | - * |
|
317 | - * @return \OCP\IAvatarManager |
|
318 | - * @since 6.0.0 |
|
319 | - */ |
|
320 | - public function getAvatarManager(); |
|
321 | - |
|
322 | - /** |
|
323 | - * Returns an job list for controlling background jobs |
|
324 | - * |
|
325 | - * @return \OCP\BackgroundJob\IJobList |
|
326 | - * @since 7.0.0 |
|
327 | - */ |
|
328 | - public function getJobList(); |
|
329 | - |
|
330 | - /** |
|
331 | - * Returns a logger instance |
|
332 | - * |
|
333 | - * @return \OCP\ILogger |
|
334 | - * @since 8.0.0 |
|
335 | - */ |
|
336 | - public function getLogger(); |
|
337 | - |
|
338 | - /** |
|
339 | - * returns a log factory instance |
|
340 | - * |
|
341 | - * @return ILogFactory |
|
342 | - * @since 14.0.0 |
|
343 | - */ |
|
344 | - public function getLogFactory(); |
|
345 | - |
|
346 | - /** |
|
347 | - * Returns a router for generating and matching urls |
|
348 | - * |
|
349 | - * @return \OCP\Route\IRouter |
|
350 | - * @since 7.0.0 |
|
351 | - */ |
|
352 | - public function getRouter(); |
|
353 | - |
|
354 | - /** |
|
355 | - * Returns a search instance |
|
356 | - * |
|
357 | - * @return \OCP\ISearch |
|
358 | - * @since 7.0.0 |
|
359 | - */ |
|
360 | - public function getSearch(); |
|
361 | - |
|
362 | - /** |
|
363 | - * Get the certificate manager for the user |
|
364 | - * |
|
365 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
366 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
367 | - * @since 8.0.0 |
|
368 | - */ |
|
369 | - public function getCertificateManager($userId = null); |
|
370 | - |
|
371 | - /** |
|
372 | - * Create a new event source |
|
373 | - * |
|
374 | - * @return \OCP\IEventSource |
|
375 | - * @since 8.0.0 |
|
376 | - */ |
|
377 | - public function createEventSource(); |
|
378 | - |
|
379 | - /** |
|
380 | - * Returns an instance of the HTTP client service |
|
381 | - * |
|
382 | - * @return \OCP\Http\Client\IClientService |
|
383 | - * @since 8.1.0 |
|
384 | - */ |
|
385 | - public function getHTTPClientService(); |
|
386 | - |
|
387 | - /** |
|
388 | - * Get the active event logger |
|
389 | - * |
|
390 | - * @return \OCP\Diagnostics\IEventLogger |
|
391 | - * @since 8.0.0 |
|
392 | - */ |
|
393 | - public function getEventLogger(); |
|
394 | - |
|
395 | - /** |
|
396 | - * Get the active query logger |
|
397 | - * |
|
398 | - * The returned logger only logs data when debug mode is enabled |
|
399 | - * |
|
400 | - * @return \OCP\Diagnostics\IQueryLogger |
|
401 | - * @since 8.0.0 |
|
402 | - */ |
|
403 | - public function getQueryLogger(); |
|
404 | - |
|
405 | - /** |
|
406 | - * Get the manager for temporary files and folders |
|
407 | - * |
|
408 | - * @return \OCP\ITempManager |
|
409 | - * @since 8.0.0 |
|
410 | - */ |
|
411 | - public function getTempManager(); |
|
412 | - |
|
413 | - /** |
|
414 | - * Get the app manager |
|
415 | - * |
|
416 | - * @return \OCP\App\IAppManager |
|
417 | - * @since 8.0.0 |
|
418 | - */ |
|
419 | - public function getAppManager(); |
|
420 | - |
|
421 | - /** |
|
422 | - * Get the webroot |
|
423 | - * |
|
424 | - * @return string |
|
425 | - * @since 8.0.0 |
|
426 | - */ |
|
427 | - public function getWebRoot(); |
|
428 | - |
|
429 | - /** |
|
430 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
431 | - * @since 8.0.0 |
|
432 | - */ |
|
433 | - public function getMountProviderCollection(); |
|
434 | - |
|
435 | - /** |
|
436 | - * Get the IniWrapper |
|
437 | - * |
|
438 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
439 | - * @since 8.0.0 |
|
440 | - */ |
|
441 | - public function getIniWrapper(); |
|
442 | - /** |
|
443 | - * @return \OCP\Command\IBus |
|
444 | - * @since 8.1.0 |
|
445 | - */ |
|
446 | - public function getCommandBus(); |
|
447 | - |
|
448 | - /** |
|
449 | - * Creates a new mailer |
|
450 | - * |
|
451 | - * @return \OCP\Mail\IMailer |
|
452 | - * @since 8.1.0 |
|
453 | - */ |
|
454 | - public function getMailer(); |
|
455 | - |
|
456 | - /** |
|
457 | - * Get the locking provider |
|
458 | - * |
|
459 | - * @return \OCP\Lock\ILockingProvider |
|
460 | - * @since 8.1.0 |
|
461 | - */ |
|
462 | - public function getLockingProvider(); |
|
463 | - |
|
464 | - /** |
|
465 | - * @return \OCP\Files\Mount\IMountManager |
|
466 | - * @since 8.2.0 |
|
467 | - */ |
|
468 | - public function getMountManager(); |
|
469 | - |
|
470 | - /** |
|
471 | - * Get the MimeTypeDetector |
|
472 | - * |
|
473 | - * @return \OCP\Files\IMimeTypeDetector |
|
474 | - * @since 8.2.0 |
|
475 | - */ |
|
476 | - public function getMimeTypeDetector(); |
|
477 | - |
|
478 | - /** |
|
479 | - * Get the MimeTypeLoader |
|
480 | - * |
|
481 | - * @return \OCP\Files\IMimeTypeLoader |
|
482 | - * @since 8.2.0 |
|
483 | - */ |
|
484 | - public function getMimeTypeLoader(); |
|
485 | - |
|
486 | - /** |
|
487 | - * Get the EventDispatcher |
|
488 | - * |
|
489 | - * @return EventDispatcherInterface |
|
490 | - * @since 8.2.0 |
|
491 | - */ |
|
492 | - public function getEventDispatcher(); |
|
493 | - |
|
494 | - /** |
|
495 | - * Get the Notification Manager |
|
496 | - * |
|
497 | - * @return \OCP\Notification\IManager |
|
498 | - * @since 9.0.0 |
|
499 | - */ |
|
500 | - public function getNotificationManager(); |
|
501 | - |
|
502 | - /** |
|
503 | - * @return \OCP\Comments\ICommentsManager |
|
504 | - * @since 9.0.0 |
|
505 | - */ |
|
506 | - public function getCommentsManager(); |
|
507 | - |
|
508 | - /** |
|
509 | - * Returns the system-tag manager |
|
510 | - * |
|
511 | - * @return \OCP\SystemTag\ISystemTagManager |
|
512 | - * |
|
513 | - * @since 9.0.0 |
|
514 | - */ |
|
515 | - public function getSystemTagManager(); |
|
516 | - |
|
517 | - /** |
|
518 | - * Returns the system-tag object mapper |
|
519 | - * |
|
520 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
521 | - * |
|
522 | - * @since 9.0.0 |
|
523 | - */ |
|
524 | - public function getSystemTagObjectMapper(); |
|
525 | - |
|
526 | - /** |
|
527 | - * Returns the share manager |
|
528 | - * |
|
529 | - * @return \OCP\Share\IManager |
|
530 | - * @since 9.0.0 |
|
531 | - */ |
|
532 | - public function getShareManager(); |
|
533 | - |
|
534 | - /** |
|
535 | - * @return IContentSecurityPolicyManager |
|
536 | - * @since 9.0.0 |
|
537 | - */ |
|
538 | - public function getContentSecurityPolicyManager(); |
|
539 | - |
|
540 | - /** |
|
541 | - * @return \OCP\IDateTimeZone |
|
542 | - * @since 8.0.0 |
|
543 | - */ |
|
544 | - public function getDateTimeZone(); |
|
545 | - |
|
546 | - /** |
|
547 | - * @return \OCP\IDateTimeFormatter |
|
548 | - * @since 8.0.0 |
|
549 | - */ |
|
550 | - public function getDateTimeFormatter(); |
|
551 | - |
|
552 | - /** |
|
553 | - * @return \OCP\Federation\ICloudIdManager |
|
554 | - * @since 12.0.0 |
|
555 | - */ |
|
556 | - public function getCloudIdManager(); |
|
557 | - |
|
558 | - /** |
|
559 | - * @return \OCP\GlobalScale\IConfig |
|
560 | - * @since 14.0.0 |
|
561 | - */ |
|
562 | - public function getGlobalScaleConfig(); |
|
563 | - |
|
564 | - /** |
|
565 | - * @return ICloudFederationFactory |
|
566 | - * @since 14.0.0 |
|
567 | - */ |
|
568 | - public function getCloudFederationFactory(); |
|
569 | - |
|
570 | - /** |
|
571 | - * @return ICloudFederationProviderManager |
|
572 | - * @since 14.0.0 |
|
573 | - */ |
|
574 | - public function getCloudFederationProviderManager(); |
|
575 | - |
|
576 | - /** |
|
577 | - * @return \OCP\Remote\Api\IApiFactory |
|
578 | - * @since 13.0.0 |
|
579 | - */ |
|
580 | - public function getRemoteApiFactory(); |
|
581 | - |
|
582 | - /** |
|
583 | - * @return \OCP\Remote\IInstanceFactory |
|
584 | - * @since 13.0.0 |
|
585 | - */ |
|
586 | - public function getRemoteInstanceFactory(); |
|
587 | - |
|
588 | - /** |
|
589 | - * @return \OCP\Files\Storage\IStorageFactory |
|
590 | - * @since 15.0.0 |
|
591 | - */ |
|
592 | - public function getStorageFactory(); |
|
63 | + /** |
|
64 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
65 | + * providers which actual deliver the calendar information. |
|
66 | + * |
|
67 | + * @return \OCP\Calendar\IManager |
|
68 | + * @since 13.0.0 |
|
69 | + */ |
|
70 | + public function getCalendarManager(); |
|
71 | + |
|
72 | + /** |
|
73 | + * The calendar resource backend manager will act as a broker between consumers |
|
74 | + * for calendar resource information an providers which actual deliver the room information. |
|
75 | + * |
|
76 | + * @return \OCP\Calendar\Resource\IBackend |
|
77 | + * @since 14.0.0 |
|
78 | + */ |
|
79 | + public function getCalendarResourceBackendManager(); |
|
80 | + |
|
81 | + /** |
|
82 | + * The calendar room backend manager will act as a broker between consumers |
|
83 | + * for calendar room information an providers which actual deliver the room information. |
|
84 | + * |
|
85 | + * @return \OCP\Calendar\Room\IBackend |
|
86 | + * @since 14.0.0 |
|
87 | + */ |
|
88 | + public function getCalendarRoomBackendManager(); |
|
89 | + |
|
90 | + /** |
|
91 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
92 | + * providers which actual deliver the contact information. |
|
93 | + * |
|
94 | + * @return \OCP\Contacts\IManager |
|
95 | + * @since 6.0.0 |
|
96 | + */ |
|
97 | + public function getContactsManager(); |
|
98 | + |
|
99 | + /** |
|
100 | + * The current request object holding all information about the request currently being processed |
|
101 | + * is returned from this method. |
|
102 | + * In case the current execution was not initiated by a web request null is returned |
|
103 | + * |
|
104 | + * @return \OCP\IRequest |
|
105 | + * @since 6.0.0 |
|
106 | + */ |
|
107 | + public function getRequest(); |
|
108 | + |
|
109 | + /** |
|
110 | + * Returns the preview manager which can create preview images for a given file |
|
111 | + * |
|
112 | + * @return \OCP\IPreview |
|
113 | + * @since 6.0.0 |
|
114 | + */ |
|
115 | + public function getPreviewManager(); |
|
116 | + |
|
117 | + /** |
|
118 | + * Returns the tag manager which can get and set tags for different object types |
|
119 | + * |
|
120 | + * @see \OCP\ITagManager::load() |
|
121 | + * @return \OCP\ITagManager |
|
122 | + * @since 6.0.0 |
|
123 | + */ |
|
124 | + public function getTagManager(); |
|
125 | + |
|
126 | + /** |
|
127 | + * Returns the root folder of ownCloud's data directory |
|
128 | + * |
|
129 | + * @return \OCP\Files\IRootFolder |
|
130 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
131 | + */ |
|
132 | + public function getRootFolder(); |
|
133 | + |
|
134 | + /** |
|
135 | + * Returns a view to ownCloud's files folder |
|
136 | + * |
|
137 | + * @param string $userId user ID |
|
138 | + * @return \OCP\Files\Folder |
|
139 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
140 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
141 | + */ |
|
142 | + public function getUserFolder($userId = null); |
|
143 | + |
|
144 | + /** |
|
145 | + * Returns an app-specific view in ownClouds data directory |
|
146 | + * |
|
147 | + * @return \OCP\Files\Folder |
|
148 | + * @since 6.0.0 |
|
149 | + * @deprecated 9.2.0 use IAppData |
|
150 | + */ |
|
151 | + public function getAppFolder(); |
|
152 | + |
|
153 | + /** |
|
154 | + * Returns a user manager |
|
155 | + * |
|
156 | + * @return \OCP\IUserManager |
|
157 | + * @since 8.0.0 |
|
158 | + */ |
|
159 | + public function getUserManager(); |
|
160 | + |
|
161 | + /** |
|
162 | + * Returns a group manager |
|
163 | + * |
|
164 | + * @return \OCP\IGroupManager |
|
165 | + * @since 8.0.0 |
|
166 | + */ |
|
167 | + public function getGroupManager(); |
|
168 | + |
|
169 | + /** |
|
170 | + * Returns the user session |
|
171 | + * |
|
172 | + * @return \OCP\IUserSession |
|
173 | + * @since 6.0.0 |
|
174 | + */ |
|
175 | + public function getUserSession(); |
|
176 | + |
|
177 | + /** |
|
178 | + * Returns the navigation manager |
|
179 | + * |
|
180 | + * @return \OCP\INavigationManager |
|
181 | + * @since 6.0.0 |
|
182 | + */ |
|
183 | + public function getNavigationManager(); |
|
184 | + |
|
185 | + /** |
|
186 | + * Returns the config manager |
|
187 | + * |
|
188 | + * @return \OCP\IConfig |
|
189 | + * @since 6.0.0 |
|
190 | + */ |
|
191 | + public function getConfig(); |
|
192 | + |
|
193 | + /** |
|
194 | + * Returns a Crypto instance |
|
195 | + * |
|
196 | + * @return \OCP\Security\ICrypto |
|
197 | + * @since 8.0.0 |
|
198 | + */ |
|
199 | + public function getCrypto(); |
|
200 | + |
|
201 | + /** |
|
202 | + * Returns a Hasher instance |
|
203 | + * |
|
204 | + * @return \OCP\Security\IHasher |
|
205 | + * @since 8.0.0 |
|
206 | + */ |
|
207 | + public function getHasher(); |
|
208 | + |
|
209 | + /** |
|
210 | + * Returns a SecureRandom instance |
|
211 | + * |
|
212 | + * @return \OCP\Security\ISecureRandom |
|
213 | + * @since 8.1.0 |
|
214 | + */ |
|
215 | + public function getSecureRandom(); |
|
216 | + |
|
217 | + /** |
|
218 | + * Returns a CredentialsManager instance |
|
219 | + * |
|
220 | + * @return \OCP\Security\ICredentialsManager |
|
221 | + * @since 9.0.0 |
|
222 | + */ |
|
223 | + public function getCredentialsManager(); |
|
224 | + |
|
225 | + /** |
|
226 | + * Returns the app config manager |
|
227 | + * |
|
228 | + * @return \OCP\IAppConfig |
|
229 | + * @since 7.0.0 |
|
230 | + */ |
|
231 | + public function getAppConfig(); |
|
232 | + |
|
233 | + /** |
|
234 | + * @return \OCP\L10N\IFactory |
|
235 | + * @since 8.2.0 |
|
236 | + */ |
|
237 | + public function getL10NFactory(); |
|
238 | + |
|
239 | + /** |
|
240 | + * get an L10N instance |
|
241 | + * @param string $app appid |
|
242 | + * @param string $lang |
|
243 | + * @return \OCP\IL10N |
|
244 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
245 | + */ |
|
246 | + public function getL10N($app, $lang = null); |
|
247 | + |
|
248 | + /** |
|
249 | + * @return \OC\Encryption\Manager |
|
250 | + * @since 8.1.0 |
|
251 | + */ |
|
252 | + public function getEncryptionManager(); |
|
253 | + |
|
254 | + /** |
|
255 | + * @return \OC\Encryption\File |
|
256 | + * @since 8.1.0 |
|
257 | + */ |
|
258 | + public function getEncryptionFilesHelper(); |
|
259 | + |
|
260 | + /** |
|
261 | + * @return \OCP\Encryption\Keys\IStorage |
|
262 | + * @since 8.1.0 |
|
263 | + */ |
|
264 | + public function getEncryptionKeyStorage(); |
|
265 | + |
|
266 | + /** |
|
267 | + * Returns the URL generator |
|
268 | + * |
|
269 | + * @return \OCP\IURLGenerator |
|
270 | + * @since 6.0.0 |
|
271 | + */ |
|
272 | + public function getURLGenerator(); |
|
273 | + |
|
274 | + /** |
|
275 | + * Returns an ICache instance |
|
276 | + * |
|
277 | + * @return \OCP\ICache |
|
278 | + * @since 6.0.0 |
|
279 | + */ |
|
280 | + public function getCache(); |
|
281 | + |
|
282 | + /** |
|
283 | + * Returns an \OCP\CacheFactory instance |
|
284 | + * |
|
285 | + * @return \OCP\ICacheFactory |
|
286 | + * @since 7.0.0 |
|
287 | + */ |
|
288 | + public function getMemCacheFactory(); |
|
289 | + |
|
290 | + /** |
|
291 | + * Returns the current session |
|
292 | + * |
|
293 | + * @return \OCP\ISession |
|
294 | + * @since 6.0.0 |
|
295 | + */ |
|
296 | + public function getSession(); |
|
297 | + |
|
298 | + /** |
|
299 | + * Returns the activity manager |
|
300 | + * |
|
301 | + * @return \OCP\Activity\IManager |
|
302 | + * @since 6.0.0 |
|
303 | + */ |
|
304 | + public function getActivityManager(); |
|
305 | + |
|
306 | + /** |
|
307 | + * Returns the current session |
|
308 | + * |
|
309 | + * @return \OCP\IDBConnection |
|
310 | + * @since 6.0.0 |
|
311 | + */ |
|
312 | + public function getDatabaseConnection(); |
|
313 | + |
|
314 | + /** |
|
315 | + * Returns an avatar manager, used for avatar functionality |
|
316 | + * |
|
317 | + * @return \OCP\IAvatarManager |
|
318 | + * @since 6.0.0 |
|
319 | + */ |
|
320 | + public function getAvatarManager(); |
|
321 | + |
|
322 | + /** |
|
323 | + * Returns an job list for controlling background jobs |
|
324 | + * |
|
325 | + * @return \OCP\BackgroundJob\IJobList |
|
326 | + * @since 7.0.0 |
|
327 | + */ |
|
328 | + public function getJobList(); |
|
329 | + |
|
330 | + /** |
|
331 | + * Returns a logger instance |
|
332 | + * |
|
333 | + * @return \OCP\ILogger |
|
334 | + * @since 8.0.0 |
|
335 | + */ |
|
336 | + public function getLogger(); |
|
337 | + |
|
338 | + /** |
|
339 | + * returns a log factory instance |
|
340 | + * |
|
341 | + * @return ILogFactory |
|
342 | + * @since 14.0.0 |
|
343 | + */ |
|
344 | + public function getLogFactory(); |
|
345 | + |
|
346 | + /** |
|
347 | + * Returns a router for generating and matching urls |
|
348 | + * |
|
349 | + * @return \OCP\Route\IRouter |
|
350 | + * @since 7.0.0 |
|
351 | + */ |
|
352 | + public function getRouter(); |
|
353 | + |
|
354 | + /** |
|
355 | + * Returns a search instance |
|
356 | + * |
|
357 | + * @return \OCP\ISearch |
|
358 | + * @since 7.0.0 |
|
359 | + */ |
|
360 | + public function getSearch(); |
|
361 | + |
|
362 | + /** |
|
363 | + * Get the certificate manager for the user |
|
364 | + * |
|
365 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
366 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
367 | + * @since 8.0.0 |
|
368 | + */ |
|
369 | + public function getCertificateManager($userId = null); |
|
370 | + |
|
371 | + /** |
|
372 | + * Create a new event source |
|
373 | + * |
|
374 | + * @return \OCP\IEventSource |
|
375 | + * @since 8.0.0 |
|
376 | + */ |
|
377 | + public function createEventSource(); |
|
378 | + |
|
379 | + /** |
|
380 | + * Returns an instance of the HTTP client service |
|
381 | + * |
|
382 | + * @return \OCP\Http\Client\IClientService |
|
383 | + * @since 8.1.0 |
|
384 | + */ |
|
385 | + public function getHTTPClientService(); |
|
386 | + |
|
387 | + /** |
|
388 | + * Get the active event logger |
|
389 | + * |
|
390 | + * @return \OCP\Diagnostics\IEventLogger |
|
391 | + * @since 8.0.0 |
|
392 | + */ |
|
393 | + public function getEventLogger(); |
|
394 | + |
|
395 | + /** |
|
396 | + * Get the active query logger |
|
397 | + * |
|
398 | + * The returned logger only logs data when debug mode is enabled |
|
399 | + * |
|
400 | + * @return \OCP\Diagnostics\IQueryLogger |
|
401 | + * @since 8.0.0 |
|
402 | + */ |
|
403 | + public function getQueryLogger(); |
|
404 | + |
|
405 | + /** |
|
406 | + * Get the manager for temporary files and folders |
|
407 | + * |
|
408 | + * @return \OCP\ITempManager |
|
409 | + * @since 8.0.0 |
|
410 | + */ |
|
411 | + public function getTempManager(); |
|
412 | + |
|
413 | + /** |
|
414 | + * Get the app manager |
|
415 | + * |
|
416 | + * @return \OCP\App\IAppManager |
|
417 | + * @since 8.0.0 |
|
418 | + */ |
|
419 | + public function getAppManager(); |
|
420 | + |
|
421 | + /** |
|
422 | + * Get the webroot |
|
423 | + * |
|
424 | + * @return string |
|
425 | + * @since 8.0.0 |
|
426 | + */ |
|
427 | + public function getWebRoot(); |
|
428 | + |
|
429 | + /** |
|
430 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
431 | + * @since 8.0.0 |
|
432 | + */ |
|
433 | + public function getMountProviderCollection(); |
|
434 | + |
|
435 | + /** |
|
436 | + * Get the IniWrapper |
|
437 | + * |
|
438 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
439 | + * @since 8.0.0 |
|
440 | + */ |
|
441 | + public function getIniWrapper(); |
|
442 | + /** |
|
443 | + * @return \OCP\Command\IBus |
|
444 | + * @since 8.1.0 |
|
445 | + */ |
|
446 | + public function getCommandBus(); |
|
447 | + |
|
448 | + /** |
|
449 | + * Creates a new mailer |
|
450 | + * |
|
451 | + * @return \OCP\Mail\IMailer |
|
452 | + * @since 8.1.0 |
|
453 | + */ |
|
454 | + public function getMailer(); |
|
455 | + |
|
456 | + /** |
|
457 | + * Get the locking provider |
|
458 | + * |
|
459 | + * @return \OCP\Lock\ILockingProvider |
|
460 | + * @since 8.1.0 |
|
461 | + */ |
|
462 | + public function getLockingProvider(); |
|
463 | + |
|
464 | + /** |
|
465 | + * @return \OCP\Files\Mount\IMountManager |
|
466 | + * @since 8.2.0 |
|
467 | + */ |
|
468 | + public function getMountManager(); |
|
469 | + |
|
470 | + /** |
|
471 | + * Get the MimeTypeDetector |
|
472 | + * |
|
473 | + * @return \OCP\Files\IMimeTypeDetector |
|
474 | + * @since 8.2.0 |
|
475 | + */ |
|
476 | + public function getMimeTypeDetector(); |
|
477 | + |
|
478 | + /** |
|
479 | + * Get the MimeTypeLoader |
|
480 | + * |
|
481 | + * @return \OCP\Files\IMimeTypeLoader |
|
482 | + * @since 8.2.0 |
|
483 | + */ |
|
484 | + public function getMimeTypeLoader(); |
|
485 | + |
|
486 | + /** |
|
487 | + * Get the EventDispatcher |
|
488 | + * |
|
489 | + * @return EventDispatcherInterface |
|
490 | + * @since 8.2.0 |
|
491 | + */ |
|
492 | + public function getEventDispatcher(); |
|
493 | + |
|
494 | + /** |
|
495 | + * Get the Notification Manager |
|
496 | + * |
|
497 | + * @return \OCP\Notification\IManager |
|
498 | + * @since 9.0.0 |
|
499 | + */ |
|
500 | + public function getNotificationManager(); |
|
501 | + |
|
502 | + /** |
|
503 | + * @return \OCP\Comments\ICommentsManager |
|
504 | + * @since 9.0.0 |
|
505 | + */ |
|
506 | + public function getCommentsManager(); |
|
507 | + |
|
508 | + /** |
|
509 | + * Returns the system-tag manager |
|
510 | + * |
|
511 | + * @return \OCP\SystemTag\ISystemTagManager |
|
512 | + * |
|
513 | + * @since 9.0.0 |
|
514 | + */ |
|
515 | + public function getSystemTagManager(); |
|
516 | + |
|
517 | + /** |
|
518 | + * Returns the system-tag object mapper |
|
519 | + * |
|
520 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
521 | + * |
|
522 | + * @since 9.0.0 |
|
523 | + */ |
|
524 | + public function getSystemTagObjectMapper(); |
|
525 | + |
|
526 | + /** |
|
527 | + * Returns the share manager |
|
528 | + * |
|
529 | + * @return \OCP\Share\IManager |
|
530 | + * @since 9.0.0 |
|
531 | + */ |
|
532 | + public function getShareManager(); |
|
533 | + |
|
534 | + /** |
|
535 | + * @return IContentSecurityPolicyManager |
|
536 | + * @since 9.0.0 |
|
537 | + */ |
|
538 | + public function getContentSecurityPolicyManager(); |
|
539 | + |
|
540 | + /** |
|
541 | + * @return \OCP\IDateTimeZone |
|
542 | + * @since 8.0.0 |
|
543 | + */ |
|
544 | + public function getDateTimeZone(); |
|
545 | + |
|
546 | + /** |
|
547 | + * @return \OCP\IDateTimeFormatter |
|
548 | + * @since 8.0.0 |
|
549 | + */ |
|
550 | + public function getDateTimeFormatter(); |
|
551 | + |
|
552 | + /** |
|
553 | + * @return \OCP\Federation\ICloudIdManager |
|
554 | + * @since 12.0.0 |
|
555 | + */ |
|
556 | + public function getCloudIdManager(); |
|
557 | + |
|
558 | + /** |
|
559 | + * @return \OCP\GlobalScale\IConfig |
|
560 | + * @since 14.0.0 |
|
561 | + */ |
|
562 | + public function getGlobalScaleConfig(); |
|
563 | + |
|
564 | + /** |
|
565 | + * @return ICloudFederationFactory |
|
566 | + * @since 14.0.0 |
|
567 | + */ |
|
568 | + public function getCloudFederationFactory(); |
|
569 | + |
|
570 | + /** |
|
571 | + * @return ICloudFederationProviderManager |
|
572 | + * @since 14.0.0 |
|
573 | + */ |
|
574 | + public function getCloudFederationProviderManager(); |
|
575 | + |
|
576 | + /** |
|
577 | + * @return \OCP\Remote\Api\IApiFactory |
|
578 | + * @since 13.0.0 |
|
579 | + */ |
|
580 | + public function getRemoteApiFactory(); |
|
581 | + |
|
582 | + /** |
|
583 | + * @return \OCP\Remote\IInstanceFactory |
|
584 | + * @since 13.0.0 |
|
585 | + */ |
|
586 | + public function getRemoteInstanceFactory(); |
|
587 | + |
|
588 | + /** |
|
589 | + * @return \OCP\Files\Storage\IStorageFactory |
|
590 | + * @since 15.0.0 |
|
591 | + */ |
|
592 | + public function getStorageFactory(); |
|
593 | 593 | } |
@@ -164,1877 +164,1877 @@ |
||
164 | 164 | * TODO: hookup all manager classes |
165 | 165 | */ |
166 | 166 | class Server extends ServerContainer implements IServerContainer { |
167 | - /** @var string */ |
|
168 | - private $webRoot; |
|
169 | - |
|
170 | - /** |
|
171 | - * @param string $webRoot |
|
172 | - * @param \OC\Config $config |
|
173 | - */ |
|
174 | - public function __construct($webRoot, \OC\Config $config) { |
|
175 | - parent::__construct(); |
|
176 | - $this->webRoot = $webRoot; |
|
177 | - |
|
178 | - // To find out if we are running from CLI or not |
|
179 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
180 | - |
|
181 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
182 | - return $c; |
|
183 | - }); |
|
184 | - |
|
185 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
186 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
187 | - |
|
188 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
189 | - $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
190 | - |
|
191 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
192 | - $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
193 | - |
|
194 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
195 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
196 | - |
|
197 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
198 | - |
|
199 | - |
|
200 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
201 | - return new PreviewManager( |
|
202 | - $c->getConfig(), |
|
203 | - $c->getRootFolder(), |
|
204 | - $c->getAppDataDir('preview'), |
|
205 | - $c->getEventDispatcher(), |
|
206 | - $c->getSession()->get('user_id') |
|
207 | - ); |
|
208 | - }); |
|
209 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
210 | - |
|
211 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
212 | - return new \OC\Preview\Watcher( |
|
213 | - $c->getAppDataDir('preview') |
|
214 | - ); |
|
215 | - }); |
|
216 | - |
|
217 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
218 | - $view = new View(); |
|
219 | - $util = new Encryption\Util( |
|
220 | - $view, |
|
221 | - $c->getUserManager(), |
|
222 | - $c->getGroupManager(), |
|
223 | - $c->getConfig() |
|
224 | - ); |
|
225 | - return new Encryption\Manager( |
|
226 | - $c->getConfig(), |
|
227 | - $c->getLogger(), |
|
228 | - $c->getL10N('core'), |
|
229 | - new View(), |
|
230 | - $util, |
|
231 | - new ArrayCache() |
|
232 | - ); |
|
233 | - }); |
|
234 | - |
|
235 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
236 | - $util = new Encryption\Util( |
|
237 | - new View(), |
|
238 | - $c->getUserManager(), |
|
239 | - $c->getGroupManager(), |
|
240 | - $c->getConfig() |
|
241 | - ); |
|
242 | - return new Encryption\File( |
|
243 | - $util, |
|
244 | - $c->getRootFolder(), |
|
245 | - $c->getShareManager() |
|
246 | - ); |
|
247 | - }); |
|
248 | - |
|
249 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
250 | - $view = new View(); |
|
251 | - $util = new Encryption\Util( |
|
252 | - $view, |
|
253 | - $c->getUserManager(), |
|
254 | - $c->getGroupManager(), |
|
255 | - $c->getConfig() |
|
256 | - ); |
|
257 | - |
|
258 | - return new Encryption\Keys\Storage($view, $util); |
|
259 | - }); |
|
260 | - $this->registerService('TagMapper', function (Server $c) { |
|
261 | - return new TagMapper($c->getDatabaseConnection()); |
|
262 | - }); |
|
263 | - |
|
264 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
265 | - $tagMapper = $c->query('TagMapper'); |
|
266 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
267 | - }); |
|
268 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
269 | - |
|
270 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
271 | - $config = $c->getConfig(); |
|
272 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
273 | - return new $factoryClass($this); |
|
274 | - }); |
|
275 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
276 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
277 | - }); |
|
278 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
279 | - |
|
280 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
281 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
282 | - }); |
|
283 | - $this->registerService('RootFolder', function (Server $c) { |
|
284 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
285 | - $view = new View(); |
|
286 | - $root = new Root( |
|
287 | - $manager, |
|
288 | - $view, |
|
289 | - null, |
|
290 | - $c->getUserMountCache(), |
|
291 | - $this->getLogger(), |
|
292 | - $this->getUserManager() |
|
293 | - ); |
|
294 | - $connector = new HookConnector($root, $view); |
|
295 | - $connector->viewToNode(); |
|
296 | - |
|
297 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
298 | - $previewConnector->connectWatcher(); |
|
299 | - |
|
300 | - return $root; |
|
301 | - }); |
|
302 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
303 | - |
|
304 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
305 | - return new LazyRoot(function () use ($c) { |
|
306 | - return $c->query('RootFolder'); |
|
307 | - }); |
|
308 | - }); |
|
309 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
310 | - |
|
311 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
312 | - $config = $c->getConfig(); |
|
313 | - return new \OC\User\Manager($config); |
|
314 | - }); |
|
315 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
316 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
317 | - |
|
318 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
319 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
320 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
321 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
322 | - }); |
|
323 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
324 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
325 | - }); |
|
326 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
327 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
328 | - }); |
|
329 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
330 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
331 | - }); |
|
332 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
333 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
334 | - }); |
|
335 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
336 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
337 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
338 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
339 | - }); |
|
340 | - return $groupManager; |
|
341 | - }); |
|
342 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
343 | - |
|
344 | - $this->registerService(Store::class, function (Server $c) { |
|
345 | - $session = $c->getSession(); |
|
346 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
347 | - $tokenProvider = $c->query(IProvider::class); |
|
348 | - } else { |
|
349 | - $tokenProvider = null; |
|
350 | - } |
|
351 | - $logger = $c->getLogger(); |
|
352 | - return new Store($session, $logger, $tokenProvider); |
|
353 | - }); |
|
354 | - $this->registerAlias(IStore::class, Store::class); |
|
355 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
356 | - $dbConnection = $c->getDatabaseConnection(); |
|
357 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
358 | - }); |
|
359 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
360 | - |
|
361 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
362 | - $manager = $c->getUserManager(); |
|
363 | - $session = new \OC\Session\Memory(''); |
|
364 | - $timeFactory = new TimeFactory(); |
|
365 | - // Token providers might require a working database. This code |
|
366 | - // might however be called when ownCloud is not yet setup. |
|
367 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
368 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
369 | - } else { |
|
370 | - $defaultTokenProvider = null; |
|
371 | - } |
|
372 | - |
|
373 | - $dispatcher = $c->getEventDispatcher(); |
|
374 | - |
|
375 | - $userSession = new \OC\User\Session( |
|
376 | - $manager, |
|
377 | - $session, |
|
378 | - $timeFactory, |
|
379 | - $defaultTokenProvider, |
|
380 | - $c->getConfig(), |
|
381 | - $c->getSecureRandom(), |
|
382 | - $c->getLockdownManager(), |
|
383 | - $c->getLogger() |
|
384 | - ); |
|
385 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
386 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
387 | - }); |
|
388 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
389 | - /** @var $user \OC\User\User */ |
|
390 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
391 | - }); |
|
392 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
393 | - /** @var $user \OC\User\User */ |
|
394 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
395 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
396 | - }); |
|
397 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
398 | - /** @var $user \OC\User\User */ |
|
399 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
400 | - }); |
|
401 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
402 | - /** @var $user \OC\User\User */ |
|
403 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
404 | - }); |
|
405 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
406 | - /** @var $user \OC\User\User */ |
|
407 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
408 | - }); |
|
409 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
410 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
411 | - }); |
|
412 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
413 | - /** @var $user \OC\User\User */ |
|
414 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
415 | - }); |
|
416 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
417 | - /** @var $user \OC\User\User */ |
|
418 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
419 | - }); |
|
420 | - $userSession->listen('\OC\User', 'logout', function () { |
|
421 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
422 | - }); |
|
423 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
424 | - /** @var $user \OC\User\User */ |
|
425 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
426 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
427 | - }); |
|
428 | - return $userSession; |
|
429 | - }); |
|
430 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
431 | - |
|
432 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
433 | - |
|
434 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
435 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
436 | - |
|
437 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
438 | - return new \OC\AllConfig( |
|
439 | - $c->getSystemConfig() |
|
440 | - ); |
|
441 | - }); |
|
442 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
443 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
444 | - |
|
445 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
446 | - return new \OC\SystemConfig($config); |
|
447 | - }); |
|
448 | - |
|
449 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
450 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
451 | - }); |
|
452 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
453 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
454 | - |
|
455 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
456 | - return new \OC\L10N\Factory( |
|
457 | - $c->getConfig(), |
|
458 | - $c->getRequest(), |
|
459 | - $c->getUserSession(), |
|
460 | - \OC::$SERVERROOT |
|
461 | - ); |
|
462 | - }); |
|
463 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
464 | - |
|
465 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
466 | - $config = $c->getConfig(); |
|
467 | - $cacheFactory = $c->getMemCacheFactory(); |
|
468 | - $request = $c->getRequest(); |
|
469 | - return new \OC\URLGenerator( |
|
470 | - $config, |
|
471 | - $cacheFactory, |
|
472 | - $request |
|
473 | - ); |
|
474 | - }); |
|
475 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
476 | - |
|
477 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
478 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
479 | - |
|
480 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
481 | - return new Cache\File(); |
|
482 | - }); |
|
483 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
484 | - |
|
485 | - $this->registerService(Factory::class, function (Server $c) { |
|
486 | - |
|
487 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
488 | - ArrayCache::class, |
|
489 | - ArrayCache::class, |
|
490 | - ArrayCache::class |
|
491 | - ); |
|
492 | - $config = $c->getConfig(); |
|
493 | - $request = $c->getRequest(); |
|
494 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
495 | - |
|
496 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
497 | - $v = \OC_App::getAppVersions(); |
|
498 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
499 | - $version = implode(',', $v); |
|
500 | - $instanceId = \OC_Util::getInstanceId(); |
|
501 | - $path = \OC::$SERVERROOT; |
|
502 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
503 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
504 | - $config->getSystemValue('memcache.local', null), |
|
505 | - $config->getSystemValue('memcache.distributed', null), |
|
506 | - $config->getSystemValue('memcache.locking', null) |
|
507 | - ); |
|
508 | - } |
|
509 | - return $arrayCacheFactory; |
|
510 | - |
|
511 | - }); |
|
512 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
513 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
514 | - |
|
515 | - $this->registerService('RedisFactory', function (Server $c) { |
|
516 | - $systemConfig = $c->getSystemConfig(); |
|
517 | - return new RedisFactory($systemConfig); |
|
518 | - }); |
|
519 | - |
|
520 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
521 | - return new \OC\Activity\Manager( |
|
522 | - $c->getRequest(), |
|
523 | - $c->getUserSession(), |
|
524 | - $c->getConfig(), |
|
525 | - $c->query(IValidator::class) |
|
526 | - ); |
|
527 | - }); |
|
528 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
529 | - |
|
530 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
531 | - return new \OC\Activity\EventMerger( |
|
532 | - $c->getL10N('lib') |
|
533 | - ); |
|
534 | - }); |
|
535 | - $this->registerAlias(IValidator::class, Validator::class); |
|
536 | - |
|
537 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
538 | - return new AvatarManager( |
|
539 | - $c->query(\OC\User\Manager::class), |
|
540 | - $c->getAppDataDir('avatar'), |
|
541 | - $c->getL10N('lib'), |
|
542 | - $c->getLogger(), |
|
543 | - $c->getConfig() |
|
544 | - ); |
|
545 | - }); |
|
546 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
547 | - |
|
548 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
549 | - |
|
550 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
551 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
552 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
553 | - $logger = $factory->get($logType); |
|
554 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
555 | - |
|
556 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
557 | - }); |
|
558 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
559 | - |
|
560 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
561 | - return new LogFactory($c, $this->getSystemConfig()); |
|
562 | - }); |
|
563 | - |
|
564 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
565 | - $config = $c->getConfig(); |
|
566 | - return new \OC\BackgroundJob\JobList( |
|
567 | - $c->getDatabaseConnection(), |
|
568 | - $config, |
|
569 | - new TimeFactory() |
|
570 | - ); |
|
571 | - }); |
|
572 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
573 | - |
|
574 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
575 | - $cacheFactory = $c->getMemCacheFactory(); |
|
576 | - $logger = $c->getLogger(); |
|
577 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
578 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
579 | - } else { |
|
580 | - $router = new \OC\Route\Router($logger); |
|
581 | - } |
|
582 | - return $router; |
|
583 | - }); |
|
584 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
585 | - |
|
586 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
587 | - return new Search(); |
|
588 | - }); |
|
589 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
590 | - |
|
591 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
592 | - return new \OC\Security\RateLimiting\Limiter( |
|
593 | - $this->getUserSession(), |
|
594 | - $this->getRequest(), |
|
595 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
596 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
597 | - ); |
|
598 | - }); |
|
599 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
600 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
601 | - $this->getMemCacheFactory(), |
|
602 | - new \OC\AppFramework\Utility\TimeFactory() |
|
603 | - ); |
|
604 | - }); |
|
605 | - |
|
606 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
607 | - return new SecureRandom(); |
|
608 | - }); |
|
609 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
610 | - |
|
611 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
612 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
613 | - }); |
|
614 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
615 | - |
|
616 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
617 | - return new Hasher($c->getConfig()); |
|
618 | - }); |
|
619 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
620 | - |
|
621 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
622 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
623 | - }); |
|
624 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
625 | - |
|
626 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
627 | - $systemConfig = $c->getSystemConfig(); |
|
628 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
629 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
630 | - if (!$factory->isValidType($type)) { |
|
631 | - throw new \OC\DatabaseException('Invalid database type'); |
|
632 | - } |
|
633 | - $connectionParams = $factory->createConnectionParams(); |
|
634 | - $connection = $factory->getConnection($type, $connectionParams); |
|
635 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
636 | - return $connection; |
|
637 | - }); |
|
638 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
639 | - |
|
640 | - |
|
641 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
642 | - $user = \OC_User::getUser(); |
|
643 | - $uid = $user ? $user : null; |
|
644 | - return new ClientService( |
|
645 | - $c->getConfig(), |
|
646 | - new \OC\Security\CertificateManager( |
|
647 | - $uid, |
|
648 | - new View(), |
|
649 | - $c->getConfig(), |
|
650 | - $c->getLogger(), |
|
651 | - $c->getSecureRandom() |
|
652 | - ) |
|
653 | - ); |
|
654 | - }); |
|
655 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
656 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
657 | - $eventLogger = new EventLogger(); |
|
658 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
659 | - // In debug mode, module is being activated by default |
|
660 | - $eventLogger->activate(); |
|
661 | - } |
|
662 | - return $eventLogger; |
|
663 | - }); |
|
664 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
665 | - |
|
666 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
667 | - $queryLogger = new QueryLogger(); |
|
668 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
669 | - // In debug mode, module is being activated by default |
|
670 | - $queryLogger->activate(); |
|
671 | - } |
|
672 | - return $queryLogger; |
|
673 | - }); |
|
674 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
675 | - |
|
676 | - $this->registerService(TempManager::class, function (Server $c) { |
|
677 | - return new TempManager( |
|
678 | - $c->getLogger(), |
|
679 | - $c->getConfig() |
|
680 | - ); |
|
681 | - }); |
|
682 | - $this->registerAlias('TempManager', TempManager::class); |
|
683 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
684 | - |
|
685 | - $this->registerService(AppManager::class, function (Server $c) { |
|
686 | - return new \OC\App\AppManager( |
|
687 | - $c->getUserSession(), |
|
688 | - $c->query(\OC\AppConfig::class), |
|
689 | - $c->getGroupManager(), |
|
690 | - $c->getMemCacheFactory(), |
|
691 | - $c->getEventDispatcher() |
|
692 | - ); |
|
693 | - }); |
|
694 | - $this->registerAlias('AppManager', AppManager::class); |
|
695 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
696 | - |
|
697 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
698 | - return new DateTimeZone( |
|
699 | - $c->getConfig(), |
|
700 | - $c->getSession() |
|
701 | - ); |
|
702 | - }); |
|
703 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
704 | - |
|
705 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
706 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
707 | - |
|
708 | - return new DateTimeFormatter( |
|
709 | - $c->getDateTimeZone()->getTimeZone(), |
|
710 | - $c->getL10N('lib', $language) |
|
711 | - ); |
|
712 | - }); |
|
713 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
714 | - |
|
715 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
716 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
717 | - $listener = new UserMountCacheListener($mountCache); |
|
718 | - $listener->listen($c->getUserManager()); |
|
719 | - return $mountCache; |
|
720 | - }); |
|
721 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
722 | - |
|
723 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
724 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
725 | - $mountCache = $c->query('UserMountCache'); |
|
726 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
727 | - |
|
728 | - // builtin providers |
|
729 | - |
|
730 | - $config = $c->getConfig(); |
|
731 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
732 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
733 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
734 | - |
|
735 | - return $manager; |
|
736 | - }); |
|
737 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
738 | - |
|
739 | - $this->registerService('IniWrapper', function ($c) { |
|
740 | - return new IniGetWrapper(); |
|
741 | - }); |
|
742 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
743 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
744 | - if ($busClass) { |
|
745 | - list($app, $class) = explode('::', $busClass, 2); |
|
746 | - if ($c->getAppManager()->isInstalled($app)) { |
|
747 | - \OC_App::loadApp($app); |
|
748 | - return $c->query($class); |
|
749 | - } else { |
|
750 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
751 | - } |
|
752 | - } else { |
|
753 | - $jobList = $c->getJobList(); |
|
754 | - return new CronBus($jobList); |
|
755 | - } |
|
756 | - }); |
|
757 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
758 | - return new TrustedDomainHelper($this->getConfig()); |
|
759 | - }); |
|
760 | - $this->registerService('Throttler', function (Server $c) { |
|
761 | - return new Throttler( |
|
762 | - $c->getDatabaseConnection(), |
|
763 | - new TimeFactory(), |
|
764 | - $c->getLogger(), |
|
765 | - $c->getConfig() |
|
766 | - ); |
|
767 | - }); |
|
768 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
769 | - // IConfig and IAppManager requires a working database. This code |
|
770 | - // might however be called when ownCloud is not yet setup. |
|
771 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
772 | - $config = $c->getConfig(); |
|
773 | - $appManager = $c->getAppManager(); |
|
774 | - } else { |
|
775 | - $config = null; |
|
776 | - $appManager = null; |
|
777 | - } |
|
778 | - |
|
779 | - return new Checker( |
|
780 | - new EnvironmentHelper(), |
|
781 | - new FileAccessHelper(), |
|
782 | - new AppLocator(), |
|
783 | - $config, |
|
784 | - $c->getMemCacheFactory(), |
|
785 | - $appManager, |
|
786 | - $c->getTempManager() |
|
787 | - ); |
|
788 | - }); |
|
789 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
790 | - if (isset($this['urlParams'])) { |
|
791 | - $urlParams = $this['urlParams']; |
|
792 | - } else { |
|
793 | - $urlParams = []; |
|
794 | - } |
|
795 | - |
|
796 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
797 | - && in_array('fakeinput', stream_get_wrappers()) |
|
798 | - ) { |
|
799 | - $stream = 'fakeinput://data'; |
|
800 | - } else { |
|
801 | - $stream = 'php://input'; |
|
802 | - } |
|
803 | - |
|
804 | - return new Request( |
|
805 | - [ |
|
806 | - 'get' => $_GET, |
|
807 | - 'post' => $_POST, |
|
808 | - 'files' => $_FILES, |
|
809 | - 'server' => $_SERVER, |
|
810 | - 'env' => $_ENV, |
|
811 | - 'cookies' => $_COOKIE, |
|
812 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
813 | - ? $_SERVER['REQUEST_METHOD'] |
|
814 | - : '', |
|
815 | - 'urlParams' => $urlParams, |
|
816 | - ], |
|
817 | - $this->getSecureRandom(), |
|
818 | - $this->getConfig(), |
|
819 | - $this->getCsrfTokenManager(), |
|
820 | - $stream |
|
821 | - ); |
|
822 | - }); |
|
823 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
824 | - |
|
825 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
826 | - return new Mailer( |
|
827 | - $c->getConfig(), |
|
828 | - $c->getLogger(), |
|
829 | - $c->query(Defaults::class), |
|
830 | - $c->getURLGenerator(), |
|
831 | - $c->getL10N('lib') |
|
832 | - ); |
|
833 | - }); |
|
834 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
835 | - |
|
836 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
837 | - $config = $c->getConfig(); |
|
838 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
839 | - if (is_null($factoryClass)) { |
|
840 | - throw new \Exception('ldapProviderFactory not set'); |
|
841 | - } |
|
842 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
843 | - $factory = new $factoryClass($this); |
|
844 | - return $factory->getLDAPProvider(); |
|
845 | - }); |
|
846 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
847 | - $ini = $c->getIniWrapper(); |
|
848 | - $config = $c->getConfig(); |
|
849 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
850 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
851 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
852 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
853 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
854 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
855 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
856 | - } |
|
857 | - return new DBLockingProvider( |
|
858 | - $c->getDatabaseConnection(), |
|
859 | - $c->getLogger(), |
|
860 | - new TimeFactory(), |
|
861 | - $ttl, |
|
862 | - !\OC::$CLI |
|
863 | - ); |
|
864 | - } |
|
865 | - return new NoopLockingProvider(); |
|
866 | - }); |
|
867 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
868 | - |
|
869 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
870 | - return new \OC\Files\Mount\Manager(); |
|
871 | - }); |
|
872 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
873 | - |
|
874 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
875 | - return new \OC\Files\Type\Detection( |
|
876 | - $c->getURLGenerator(), |
|
877 | - \OC::$configDir, |
|
878 | - \OC::$SERVERROOT . '/resources/config/' |
|
879 | - ); |
|
880 | - }); |
|
881 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
882 | - |
|
883 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
884 | - return new \OC\Files\Type\Loader( |
|
885 | - $c->getDatabaseConnection() |
|
886 | - ); |
|
887 | - }); |
|
888 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
889 | - $this->registerService(BundleFetcher::class, function () { |
|
890 | - return new BundleFetcher($this->getL10N('lib')); |
|
891 | - }); |
|
892 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
893 | - return new Manager( |
|
894 | - $c->query(IValidator::class) |
|
895 | - ); |
|
896 | - }); |
|
897 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
898 | - |
|
899 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
900 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
901 | - $manager->registerCapability(function () use ($c) { |
|
902 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
903 | - }); |
|
904 | - $manager->registerCapability(function () use ($c) { |
|
905 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
906 | - }); |
|
907 | - return $manager; |
|
908 | - }); |
|
909 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
910 | - |
|
911 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
912 | - $config = $c->getConfig(); |
|
913 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
914 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
915 | - $factory = new $factoryClass($this); |
|
916 | - $manager = $factory->getManager(); |
|
917 | - |
|
918 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
919 | - $manager = $c->getUserManager(); |
|
920 | - $user = $manager->get($id); |
|
921 | - if(is_null($user)) { |
|
922 | - $l = $c->getL10N('core'); |
|
923 | - $displayName = $l->t('Unknown user'); |
|
924 | - } else { |
|
925 | - $displayName = $user->getDisplayName(); |
|
926 | - } |
|
927 | - return $displayName; |
|
928 | - }); |
|
929 | - |
|
930 | - return $manager; |
|
931 | - }); |
|
932 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
933 | - |
|
934 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
935 | - /* |
|
167 | + /** @var string */ |
|
168 | + private $webRoot; |
|
169 | + |
|
170 | + /** |
|
171 | + * @param string $webRoot |
|
172 | + * @param \OC\Config $config |
|
173 | + */ |
|
174 | + public function __construct($webRoot, \OC\Config $config) { |
|
175 | + parent::__construct(); |
|
176 | + $this->webRoot = $webRoot; |
|
177 | + |
|
178 | + // To find out if we are running from CLI or not |
|
179 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
180 | + |
|
181 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
182 | + return $c; |
|
183 | + }); |
|
184 | + |
|
185 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
186 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
187 | + |
|
188 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
189 | + $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
190 | + |
|
191 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
192 | + $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
193 | + |
|
194 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
195 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
196 | + |
|
197 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
198 | + |
|
199 | + |
|
200 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
201 | + return new PreviewManager( |
|
202 | + $c->getConfig(), |
|
203 | + $c->getRootFolder(), |
|
204 | + $c->getAppDataDir('preview'), |
|
205 | + $c->getEventDispatcher(), |
|
206 | + $c->getSession()->get('user_id') |
|
207 | + ); |
|
208 | + }); |
|
209 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
210 | + |
|
211 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
212 | + return new \OC\Preview\Watcher( |
|
213 | + $c->getAppDataDir('preview') |
|
214 | + ); |
|
215 | + }); |
|
216 | + |
|
217 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
218 | + $view = new View(); |
|
219 | + $util = new Encryption\Util( |
|
220 | + $view, |
|
221 | + $c->getUserManager(), |
|
222 | + $c->getGroupManager(), |
|
223 | + $c->getConfig() |
|
224 | + ); |
|
225 | + return new Encryption\Manager( |
|
226 | + $c->getConfig(), |
|
227 | + $c->getLogger(), |
|
228 | + $c->getL10N('core'), |
|
229 | + new View(), |
|
230 | + $util, |
|
231 | + new ArrayCache() |
|
232 | + ); |
|
233 | + }); |
|
234 | + |
|
235 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
236 | + $util = new Encryption\Util( |
|
237 | + new View(), |
|
238 | + $c->getUserManager(), |
|
239 | + $c->getGroupManager(), |
|
240 | + $c->getConfig() |
|
241 | + ); |
|
242 | + return new Encryption\File( |
|
243 | + $util, |
|
244 | + $c->getRootFolder(), |
|
245 | + $c->getShareManager() |
|
246 | + ); |
|
247 | + }); |
|
248 | + |
|
249 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
250 | + $view = new View(); |
|
251 | + $util = new Encryption\Util( |
|
252 | + $view, |
|
253 | + $c->getUserManager(), |
|
254 | + $c->getGroupManager(), |
|
255 | + $c->getConfig() |
|
256 | + ); |
|
257 | + |
|
258 | + return new Encryption\Keys\Storage($view, $util); |
|
259 | + }); |
|
260 | + $this->registerService('TagMapper', function (Server $c) { |
|
261 | + return new TagMapper($c->getDatabaseConnection()); |
|
262 | + }); |
|
263 | + |
|
264 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
265 | + $tagMapper = $c->query('TagMapper'); |
|
266 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
267 | + }); |
|
268 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
269 | + |
|
270 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
271 | + $config = $c->getConfig(); |
|
272 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
273 | + return new $factoryClass($this); |
|
274 | + }); |
|
275 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
276 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
277 | + }); |
|
278 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
279 | + |
|
280 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
281 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
282 | + }); |
|
283 | + $this->registerService('RootFolder', function (Server $c) { |
|
284 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
285 | + $view = new View(); |
|
286 | + $root = new Root( |
|
287 | + $manager, |
|
288 | + $view, |
|
289 | + null, |
|
290 | + $c->getUserMountCache(), |
|
291 | + $this->getLogger(), |
|
292 | + $this->getUserManager() |
|
293 | + ); |
|
294 | + $connector = new HookConnector($root, $view); |
|
295 | + $connector->viewToNode(); |
|
296 | + |
|
297 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
298 | + $previewConnector->connectWatcher(); |
|
299 | + |
|
300 | + return $root; |
|
301 | + }); |
|
302 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
303 | + |
|
304 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
305 | + return new LazyRoot(function () use ($c) { |
|
306 | + return $c->query('RootFolder'); |
|
307 | + }); |
|
308 | + }); |
|
309 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
310 | + |
|
311 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
312 | + $config = $c->getConfig(); |
|
313 | + return new \OC\User\Manager($config); |
|
314 | + }); |
|
315 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
316 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
317 | + |
|
318 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
319 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
320 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
321 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
322 | + }); |
|
323 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
324 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
325 | + }); |
|
326 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
327 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
328 | + }); |
|
329 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
330 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
331 | + }); |
|
332 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
333 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
334 | + }); |
|
335 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
336 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
337 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
338 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
339 | + }); |
|
340 | + return $groupManager; |
|
341 | + }); |
|
342 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
343 | + |
|
344 | + $this->registerService(Store::class, function (Server $c) { |
|
345 | + $session = $c->getSession(); |
|
346 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
347 | + $tokenProvider = $c->query(IProvider::class); |
|
348 | + } else { |
|
349 | + $tokenProvider = null; |
|
350 | + } |
|
351 | + $logger = $c->getLogger(); |
|
352 | + return new Store($session, $logger, $tokenProvider); |
|
353 | + }); |
|
354 | + $this->registerAlias(IStore::class, Store::class); |
|
355 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
356 | + $dbConnection = $c->getDatabaseConnection(); |
|
357 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
358 | + }); |
|
359 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); |
|
360 | + |
|
361 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
362 | + $manager = $c->getUserManager(); |
|
363 | + $session = new \OC\Session\Memory(''); |
|
364 | + $timeFactory = new TimeFactory(); |
|
365 | + // Token providers might require a working database. This code |
|
366 | + // might however be called when ownCloud is not yet setup. |
|
367 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
368 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
369 | + } else { |
|
370 | + $defaultTokenProvider = null; |
|
371 | + } |
|
372 | + |
|
373 | + $dispatcher = $c->getEventDispatcher(); |
|
374 | + |
|
375 | + $userSession = new \OC\User\Session( |
|
376 | + $manager, |
|
377 | + $session, |
|
378 | + $timeFactory, |
|
379 | + $defaultTokenProvider, |
|
380 | + $c->getConfig(), |
|
381 | + $c->getSecureRandom(), |
|
382 | + $c->getLockdownManager(), |
|
383 | + $c->getLogger() |
|
384 | + ); |
|
385 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
386 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
387 | + }); |
|
388 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
389 | + /** @var $user \OC\User\User */ |
|
390 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
391 | + }); |
|
392 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
393 | + /** @var $user \OC\User\User */ |
|
394 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
395 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
396 | + }); |
|
397 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
398 | + /** @var $user \OC\User\User */ |
|
399 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
400 | + }); |
|
401 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
402 | + /** @var $user \OC\User\User */ |
|
403 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
404 | + }); |
|
405 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
406 | + /** @var $user \OC\User\User */ |
|
407 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
408 | + }); |
|
409 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
410 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
411 | + }); |
|
412 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
413 | + /** @var $user \OC\User\User */ |
|
414 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
415 | + }); |
|
416 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
417 | + /** @var $user \OC\User\User */ |
|
418 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
419 | + }); |
|
420 | + $userSession->listen('\OC\User', 'logout', function () { |
|
421 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
422 | + }); |
|
423 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
424 | + /** @var $user \OC\User\User */ |
|
425 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
426 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
427 | + }); |
|
428 | + return $userSession; |
|
429 | + }); |
|
430 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
431 | + |
|
432 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); |
|
433 | + |
|
434 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
435 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
436 | + |
|
437 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
438 | + return new \OC\AllConfig( |
|
439 | + $c->getSystemConfig() |
|
440 | + ); |
|
441 | + }); |
|
442 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
443 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
444 | + |
|
445 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
446 | + return new \OC\SystemConfig($config); |
|
447 | + }); |
|
448 | + |
|
449 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
450 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
451 | + }); |
|
452 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
453 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
454 | + |
|
455 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
456 | + return new \OC\L10N\Factory( |
|
457 | + $c->getConfig(), |
|
458 | + $c->getRequest(), |
|
459 | + $c->getUserSession(), |
|
460 | + \OC::$SERVERROOT |
|
461 | + ); |
|
462 | + }); |
|
463 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
464 | + |
|
465 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
466 | + $config = $c->getConfig(); |
|
467 | + $cacheFactory = $c->getMemCacheFactory(); |
|
468 | + $request = $c->getRequest(); |
|
469 | + return new \OC\URLGenerator( |
|
470 | + $config, |
|
471 | + $cacheFactory, |
|
472 | + $request |
|
473 | + ); |
|
474 | + }); |
|
475 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
476 | + |
|
477 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
478 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
479 | + |
|
480 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
481 | + return new Cache\File(); |
|
482 | + }); |
|
483 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
484 | + |
|
485 | + $this->registerService(Factory::class, function (Server $c) { |
|
486 | + |
|
487 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
488 | + ArrayCache::class, |
|
489 | + ArrayCache::class, |
|
490 | + ArrayCache::class |
|
491 | + ); |
|
492 | + $config = $c->getConfig(); |
|
493 | + $request = $c->getRequest(); |
|
494 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
495 | + |
|
496 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
497 | + $v = \OC_App::getAppVersions(); |
|
498 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
499 | + $version = implode(',', $v); |
|
500 | + $instanceId = \OC_Util::getInstanceId(); |
|
501 | + $path = \OC::$SERVERROOT; |
|
502 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
503 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
504 | + $config->getSystemValue('memcache.local', null), |
|
505 | + $config->getSystemValue('memcache.distributed', null), |
|
506 | + $config->getSystemValue('memcache.locking', null) |
|
507 | + ); |
|
508 | + } |
|
509 | + return $arrayCacheFactory; |
|
510 | + |
|
511 | + }); |
|
512 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
513 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
514 | + |
|
515 | + $this->registerService('RedisFactory', function (Server $c) { |
|
516 | + $systemConfig = $c->getSystemConfig(); |
|
517 | + return new RedisFactory($systemConfig); |
|
518 | + }); |
|
519 | + |
|
520 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
521 | + return new \OC\Activity\Manager( |
|
522 | + $c->getRequest(), |
|
523 | + $c->getUserSession(), |
|
524 | + $c->getConfig(), |
|
525 | + $c->query(IValidator::class) |
|
526 | + ); |
|
527 | + }); |
|
528 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
529 | + |
|
530 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
531 | + return new \OC\Activity\EventMerger( |
|
532 | + $c->getL10N('lib') |
|
533 | + ); |
|
534 | + }); |
|
535 | + $this->registerAlias(IValidator::class, Validator::class); |
|
536 | + |
|
537 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
538 | + return new AvatarManager( |
|
539 | + $c->query(\OC\User\Manager::class), |
|
540 | + $c->getAppDataDir('avatar'), |
|
541 | + $c->getL10N('lib'), |
|
542 | + $c->getLogger(), |
|
543 | + $c->getConfig() |
|
544 | + ); |
|
545 | + }); |
|
546 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
547 | + |
|
548 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
549 | + |
|
550 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
551 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
552 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
553 | + $logger = $factory->get($logType); |
|
554 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
555 | + |
|
556 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
557 | + }); |
|
558 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
559 | + |
|
560 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
561 | + return new LogFactory($c, $this->getSystemConfig()); |
|
562 | + }); |
|
563 | + |
|
564 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
565 | + $config = $c->getConfig(); |
|
566 | + return new \OC\BackgroundJob\JobList( |
|
567 | + $c->getDatabaseConnection(), |
|
568 | + $config, |
|
569 | + new TimeFactory() |
|
570 | + ); |
|
571 | + }); |
|
572 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
573 | + |
|
574 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
575 | + $cacheFactory = $c->getMemCacheFactory(); |
|
576 | + $logger = $c->getLogger(); |
|
577 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
578 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
579 | + } else { |
|
580 | + $router = new \OC\Route\Router($logger); |
|
581 | + } |
|
582 | + return $router; |
|
583 | + }); |
|
584 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
585 | + |
|
586 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
587 | + return new Search(); |
|
588 | + }); |
|
589 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
590 | + |
|
591 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
592 | + return new \OC\Security\RateLimiting\Limiter( |
|
593 | + $this->getUserSession(), |
|
594 | + $this->getRequest(), |
|
595 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
596 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
597 | + ); |
|
598 | + }); |
|
599 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
600 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
601 | + $this->getMemCacheFactory(), |
|
602 | + new \OC\AppFramework\Utility\TimeFactory() |
|
603 | + ); |
|
604 | + }); |
|
605 | + |
|
606 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
607 | + return new SecureRandom(); |
|
608 | + }); |
|
609 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
610 | + |
|
611 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
612 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
613 | + }); |
|
614 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
615 | + |
|
616 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
617 | + return new Hasher($c->getConfig()); |
|
618 | + }); |
|
619 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
620 | + |
|
621 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
622 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
623 | + }); |
|
624 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
625 | + |
|
626 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
627 | + $systemConfig = $c->getSystemConfig(); |
|
628 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
629 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
630 | + if (!$factory->isValidType($type)) { |
|
631 | + throw new \OC\DatabaseException('Invalid database type'); |
|
632 | + } |
|
633 | + $connectionParams = $factory->createConnectionParams(); |
|
634 | + $connection = $factory->getConnection($type, $connectionParams); |
|
635 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
636 | + return $connection; |
|
637 | + }); |
|
638 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
639 | + |
|
640 | + |
|
641 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
642 | + $user = \OC_User::getUser(); |
|
643 | + $uid = $user ? $user : null; |
|
644 | + return new ClientService( |
|
645 | + $c->getConfig(), |
|
646 | + new \OC\Security\CertificateManager( |
|
647 | + $uid, |
|
648 | + new View(), |
|
649 | + $c->getConfig(), |
|
650 | + $c->getLogger(), |
|
651 | + $c->getSecureRandom() |
|
652 | + ) |
|
653 | + ); |
|
654 | + }); |
|
655 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
656 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
657 | + $eventLogger = new EventLogger(); |
|
658 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
659 | + // In debug mode, module is being activated by default |
|
660 | + $eventLogger->activate(); |
|
661 | + } |
|
662 | + return $eventLogger; |
|
663 | + }); |
|
664 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
665 | + |
|
666 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
667 | + $queryLogger = new QueryLogger(); |
|
668 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
669 | + // In debug mode, module is being activated by default |
|
670 | + $queryLogger->activate(); |
|
671 | + } |
|
672 | + return $queryLogger; |
|
673 | + }); |
|
674 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
675 | + |
|
676 | + $this->registerService(TempManager::class, function (Server $c) { |
|
677 | + return new TempManager( |
|
678 | + $c->getLogger(), |
|
679 | + $c->getConfig() |
|
680 | + ); |
|
681 | + }); |
|
682 | + $this->registerAlias('TempManager', TempManager::class); |
|
683 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
684 | + |
|
685 | + $this->registerService(AppManager::class, function (Server $c) { |
|
686 | + return new \OC\App\AppManager( |
|
687 | + $c->getUserSession(), |
|
688 | + $c->query(\OC\AppConfig::class), |
|
689 | + $c->getGroupManager(), |
|
690 | + $c->getMemCacheFactory(), |
|
691 | + $c->getEventDispatcher() |
|
692 | + ); |
|
693 | + }); |
|
694 | + $this->registerAlias('AppManager', AppManager::class); |
|
695 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
696 | + |
|
697 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
698 | + return new DateTimeZone( |
|
699 | + $c->getConfig(), |
|
700 | + $c->getSession() |
|
701 | + ); |
|
702 | + }); |
|
703 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
704 | + |
|
705 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
706 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
707 | + |
|
708 | + return new DateTimeFormatter( |
|
709 | + $c->getDateTimeZone()->getTimeZone(), |
|
710 | + $c->getL10N('lib', $language) |
|
711 | + ); |
|
712 | + }); |
|
713 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
714 | + |
|
715 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
716 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
717 | + $listener = new UserMountCacheListener($mountCache); |
|
718 | + $listener->listen($c->getUserManager()); |
|
719 | + return $mountCache; |
|
720 | + }); |
|
721 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
722 | + |
|
723 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
724 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
725 | + $mountCache = $c->query('UserMountCache'); |
|
726 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
727 | + |
|
728 | + // builtin providers |
|
729 | + |
|
730 | + $config = $c->getConfig(); |
|
731 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
732 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
733 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
734 | + |
|
735 | + return $manager; |
|
736 | + }); |
|
737 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
738 | + |
|
739 | + $this->registerService('IniWrapper', function ($c) { |
|
740 | + return new IniGetWrapper(); |
|
741 | + }); |
|
742 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
743 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
744 | + if ($busClass) { |
|
745 | + list($app, $class) = explode('::', $busClass, 2); |
|
746 | + if ($c->getAppManager()->isInstalled($app)) { |
|
747 | + \OC_App::loadApp($app); |
|
748 | + return $c->query($class); |
|
749 | + } else { |
|
750 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
751 | + } |
|
752 | + } else { |
|
753 | + $jobList = $c->getJobList(); |
|
754 | + return new CronBus($jobList); |
|
755 | + } |
|
756 | + }); |
|
757 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
758 | + return new TrustedDomainHelper($this->getConfig()); |
|
759 | + }); |
|
760 | + $this->registerService('Throttler', function (Server $c) { |
|
761 | + return new Throttler( |
|
762 | + $c->getDatabaseConnection(), |
|
763 | + new TimeFactory(), |
|
764 | + $c->getLogger(), |
|
765 | + $c->getConfig() |
|
766 | + ); |
|
767 | + }); |
|
768 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
769 | + // IConfig and IAppManager requires a working database. This code |
|
770 | + // might however be called when ownCloud is not yet setup. |
|
771 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
772 | + $config = $c->getConfig(); |
|
773 | + $appManager = $c->getAppManager(); |
|
774 | + } else { |
|
775 | + $config = null; |
|
776 | + $appManager = null; |
|
777 | + } |
|
778 | + |
|
779 | + return new Checker( |
|
780 | + new EnvironmentHelper(), |
|
781 | + new FileAccessHelper(), |
|
782 | + new AppLocator(), |
|
783 | + $config, |
|
784 | + $c->getMemCacheFactory(), |
|
785 | + $appManager, |
|
786 | + $c->getTempManager() |
|
787 | + ); |
|
788 | + }); |
|
789 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
790 | + if (isset($this['urlParams'])) { |
|
791 | + $urlParams = $this['urlParams']; |
|
792 | + } else { |
|
793 | + $urlParams = []; |
|
794 | + } |
|
795 | + |
|
796 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
797 | + && in_array('fakeinput', stream_get_wrappers()) |
|
798 | + ) { |
|
799 | + $stream = 'fakeinput://data'; |
|
800 | + } else { |
|
801 | + $stream = 'php://input'; |
|
802 | + } |
|
803 | + |
|
804 | + return new Request( |
|
805 | + [ |
|
806 | + 'get' => $_GET, |
|
807 | + 'post' => $_POST, |
|
808 | + 'files' => $_FILES, |
|
809 | + 'server' => $_SERVER, |
|
810 | + 'env' => $_ENV, |
|
811 | + 'cookies' => $_COOKIE, |
|
812 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
813 | + ? $_SERVER['REQUEST_METHOD'] |
|
814 | + : '', |
|
815 | + 'urlParams' => $urlParams, |
|
816 | + ], |
|
817 | + $this->getSecureRandom(), |
|
818 | + $this->getConfig(), |
|
819 | + $this->getCsrfTokenManager(), |
|
820 | + $stream |
|
821 | + ); |
|
822 | + }); |
|
823 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
824 | + |
|
825 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
826 | + return new Mailer( |
|
827 | + $c->getConfig(), |
|
828 | + $c->getLogger(), |
|
829 | + $c->query(Defaults::class), |
|
830 | + $c->getURLGenerator(), |
|
831 | + $c->getL10N('lib') |
|
832 | + ); |
|
833 | + }); |
|
834 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
835 | + |
|
836 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
837 | + $config = $c->getConfig(); |
|
838 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
839 | + if (is_null($factoryClass)) { |
|
840 | + throw new \Exception('ldapProviderFactory not set'); |
|
841 | + } |
|
842 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
843 | + $factory = new $factoryClass($this); |
|
844 | + return $factory->getLDAPProvider(); |
|
845 | + }); |
|
846 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
847 | + $ini = $c->getIniWrapper(); |
|
848 | + $config = $c->getConfig(); |
|
849 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
850 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
851 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
852 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
853 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
854 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
855 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
856 | + } |
|
857 | + return new DBLockingProvider( |
|
858 | + $c->getDatabaseConnection(), |
|
859 | + $c->getLogger(), |
|
860 | + new TimeFactory(), |
|
861 | + $ttl, |
|
862 | + !\OC::$CLI |
|
863 | + ); |
|
864 | + } |
|
865 | + return new NoopLockingProvider(); |
|
866 | + }); |
|
867 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
868 | + |
|
869 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
870 | + return new \OC\Files\Mount\Manager(); |
|
871 | + }); |
|
872 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
873 | + |
|
874 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
875 | + return new \OC\Files\Type\Detection( |
|
876 | + $c->getURLGenerator(), |
|
877 | + \OC::$configDir, |
|
878 | + \OC::$SERVERROOT . '/resources/config/' |
|
879 | + ); |
|
880 | + }); |
|
881 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
882 | + |
|
883 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
884 | + return new \OC\Files\Type\Loader( |
|
885 | + $c->getDatabaseConnection() |
|
886 | + ); |
|
887 | + }); |
|
888 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
889 | + $this->registerService(BundleFetcher::class, function () { |
|
890 | + return new BundleFetcher($this->getL10N('lib')); |
|
891 | + }); |
|
892 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
893 | + return new Manager( |
|
894 | + $c->query(IValidator::class) |
|
895 | + ); |
|
896 | + }); |
|
897 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
898 | + |
|
899 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
900 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
901 | + $manager->registerCapability(function () use ($c) { |
|
902 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
903 | + }); |
|
904 | + $manager->registerCapability(function () use ($c) { |
|
905 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
906 | + }); |
|
907 | + return $manager; |
|
908 | + }); |
|
909 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
910 | + |
|
911 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
912 | + $config = $c->getConfig(); |
|
913 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
914 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
915 | + $factory = new $factoryClass($this); |
|
916 | + $manager = $factory->getManager(); |
|
917 | + |
|
918 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
919 | + $manager = $c->getUserManager(); |
|
920 | + $user = $manager->get($id); |
|
921 | + if(is_null($user)) { |
|
922 | + $l = $c->getL10N('core'); |
|
923 | + $displayName = $l->t('Unknown user'); |
|
924 | + } else { |
|
925 | + $displayName = $user->getDisplayName(); |
|
926 | + } |
|
927 | + return $displayName; |
|
928 | + }); |
|
929 | + |
|
930 | + return $manager; |
|
931 | + }); |
|
932 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
933 | + |
|
934 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
935 | + /* |
|
936 | 936 | * Dark magic for autoloader. |
937 | 937 | * If we do a class_exists it will try to load the class which will |
938 | 938 | * make composer cache the result. Resulting in errors when enabling |
939 | 939 | * the theming app. |
940 | 940 | */ |
941 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
942 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
943 | - $classExists = true; |
|
944 | - } else { |
|
945 | - $classExists = false; |
|
946 | - } |
|
947 | - |
|
948 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
949 | - return new ThemingDefaults( |
|
950 | - $c->getConfig(), |
|
951 | - $c->getL10N('theming'), |
|
952 | - $c->getURLGenerator(), |
|
953 | - $c->getMemCacheFactory(), |
|
954 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
955 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
956 | - $c->getAppManager() |
|
957 | - ); |
|
958 | - } |
|
959 | - return new \OC_Defaults(); |
|
960 | - }); |
|
961 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
962 | - /** @var Factory $cacheFactory */ |
|
963 | - $cacheFactory = $c->query(Factory::class); |
|
964 | - return new SCSSCacher( |
|
965 | - $c->getLogger(), |
|
966 | - $c->query(\OC\Files\AppData\Factory::class), |
|
967 | - $c->getURLGenerator(), |
|
968 | - $c->getConfig(), |
|
969 | - $c->getThemingDefaults(), |
|
970 | - \OC::$SERVERROOT, |
|
971 | - $this->getMemCacheFactory(), |
|
972 | - $c->query(IconsCacher::class), |
|
973 | - new TimeFactory() |
|
974 | - ); |
|
975 | - }); |
|
976 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
977 | - /** @var Factory $cacheFactory */ |
|
978 | - $cacheFactory = $c->query(Factory::class); |
|
979 | - return new JSCombiner( |
|
980 | - $c->getAppDataDir('js'), |
|
981 | - $c->getURLGenerator(), |
|
982 | - $this->getMemCacheFactory(), |
|
983 | - $c->getSystemConfig(), |
|
984 | - $c->getLogger() |
|
985 | - ); |
|
986 | - }); |
|
987 | - $this->registerService(EventDispatcher::class, function () { |
|
988 | - return new EventDispatcher(); |
|
989 | - }); |
|
990 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
991 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
992 | - |
|
993 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
994 | - // FIXME: Instantiiated here due to cyclic dependency |
|
995 | - $request = new Request( |
|
996 | - [ |
|
997 | - 'get' => $_GET, |
|
998 | - 'post' => $_POST, |
|
999 | - 'files' => $_FILES, |
|
1000 | - 'server' => $_SERVER, |
|
1001 | - 'env' => $_ENV, |
|
1002 | - 'cookies' => $_COOKIE, |
|
1003 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1004 | - ? $_SERVER['REQUEST_METHOD'] |
|
1005 | - : null, |
|
1006 | - ], |
|
1007 | - $c->getSecureRandom(), |
|
1008 | - $c->getConfig() |
|
1009 | - ); |
|
1010 | - |
|
1011 | - return new CryptoWrapper( |
|
1012 | - $c->getConfig(), |
|
1013 | - $c->getCrypto(), |
|
1014 | - $c->getSecureRandom(), |
|
1015 | - $request |
|
1016 | - ); |
|
1017 | - }); |
|
1018 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1019 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1020 | - |
|
1021 | - return new CsrfTokenManager( |
|
1022 | - $tokenGenerator, |
|
1023 | - $c->query(SessionStorage::class) |
|
1024 | - ); |
|
1025 | - }); |
|
1026 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1027 | - return new SessionStorage($c->getSession()); |
|
1028 | - }); |
|
1029 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1030 | - return new ContentSecurityPolicyManager(); |
|
1031 | - }); |
|
1032 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1033 | - |
|
1034 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1035 | - return new ContentSecurityPolicyNonceManager( |
|
1036 | - $c->getCsrfTokenManager(), |
|
1037 | - $c->getRequest() |
|
1038 | - ); |
|
1039 | - }); |
|
1040 | - |
|
1041 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1042 | - $config = $c->getConfig(); |
|
1043 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1044 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
1045 | - $factory = new $factoryClass($this); |
|
1046 | - |
|
1047 | - $manager = new \OC\Share20\Manager( |
|
1048 | - $c->getLogger(), |
|
1049 | - $c->getConfig(), |
|
1050 | - $c->getSecureRandom(), |
|
1051 | - $c->getHasher(), |
|
1052 | - $c->getMountManager(), |
|
1053 | - $c->getGroupManager(), |
|
1054 | - $c->getL10N('lib'), |
|
1055 | - $c->getL10NFactory(), |
|
1056 | - $factory, |
|
1057 | - $c->getUserManager(), |
|
1058 | - $c->getLazyRootFolder(), |
|
1059 | - $c->getEventDispatcher(), |
|
1060 | - $c->getMailer(), |
|
1061 | - $c->getURLGenerator(), |
|
1062 | - $c->getThemingDefaults() |
|
1063 | - ); |
|
1064 | - |
|
1065 | - return $manager; |
|
1066 | - }); |
|
1067 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1068 | - |
|
1069 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1070 | - $instance = new Collaboration\Collaborators\Search($c); |
|
1071 | - |
|
1072 | - // register default plugins |
|
1073 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1074 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1075 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1076 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1077 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
1078 | - |
|
1079 | - return $instance; |
|
1080 | - }); |
|
1081 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1082 | - |
|
1083 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1084 | - |
|
1085 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1086 | - $manager = new \OC\Settings\Manager( |
|
1087 | - $c->getLogger(), |
|
1088 | - $c->getL10N('lib'), |
|
1089 | - $c->getURLGenerator(), |
|
1090 | - $c |
|
1091 | - ); |
|
1092 | - return $manager; |
|
1093 | - }); |
|
1094 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1095 | - return new \OC\Files\AppData\Factory( |
|
1096 | - $c->getRootFolder(), |
|
1097 | - $c->getSystemConfig() |
|
1098 | - ); |
|
1099 | - }); |
|
1100 | - |
|
1101 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1102 | - return new LockdownManager(function () use ($c) { |
|
1103 | - return $c->getSession(); |
|
1104 | - }); |
|
1105 | - }); |
|
1106 | - |
|
1107 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1108 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1109 | - }); |
|
1110 | - |
|
1111 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1112 | - return new CloudIdManager(); |
|
1113 | - }); |
|
1114 | - |
|
1115 | - $this->registerService(IConfig::class, function (Server $c) { |
|
1116 | - return new GlobalScale\Config($c->getConfig()); |
|
1117 | - }); |
|
1118 | - |
|
1119 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1120 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
1121 | - }); |
|
1122 | - |
|
1123 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1124 | - return new CloudFederationFactory(); |
|
1125 | - }); |
|
1126 | - |
|
1127 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1128 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1129 | - |
|
1130 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1131 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1132 | - |
|
1133 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1134 | - return new Defaults( |
|
1135 | - $c->getThemingDefaults() |
|
1136 | - ); |
|
1137 | - }); |
|
1138 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1139 | - |
|
1140 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1141 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1142 | - }); |
|
1143 | - |
|
1144 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1145 | - return new ShareHelper( |
|
1146 | - $c->query(\OCP\Share\IManager::class) |
|
1147 | - ); |
|
1148 | - }); |
|
1149 | - |
|
1150 | - $this->registerService(Installer::class, function(Server $c) { |
|
1151 | - return new Installer( |
|
1152 | - $c->getAppFetcher(), |
|
1153 | - $c->getHTTPClientService(), |
|
1154 | - $c->getTempManager(), |
|
1155 | - $c->getLogger(), |
|
1156 | - $c->getConfig() |
|
1157 | - ); |
|
1158 | - }); |
|
1159 | - |
|
1160 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
1161 | - return new ApiFactory($c->getHTTPClientService()); |
|
1162 | - }); |
|
1163 | - |
|
1164 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1165 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
1166 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1167 | - }); |
|
1168 | - |
|
1169 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
1170 | - return new ContactsStore( |
|
1171 | - $c->getContactsManager(), |
|
1172 | - $c->getConfig(), |
|
1173 | - $c->getUserManager(), |
|
1174 | - $c->getGroupManager() |
|
1175 | - ); |
|
1176 | - }); |
|
1177 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1178 | - |
|
1179 | - $this->registerService(IStorageFactory::class, function() { |
|
1180 | - return new StorageFactory(); |
|
1181 | - }); |
|
1182 | - |
|
1183 | - $this->registerAlias(IDashboardManager::class, Dashboard\DashboardManager::class); |
|
1184 | - |
|
1185 | - $this->connectDispatcher(); |
|
1186 | - } |
|
1187 | - |
|
1188 | - /** |
|
1189 | - * @return \OCP\Calendar\IManager |
|
1190 | - */ |
|
1191 | - public function getCalendarManager() { |
|
1192 | - return $this->query('CalendarManager'); |
|
1193 | - } |
|
1194 | - |
|
1195 | - /** |
|
1196 | - * @return \OCP\Calendar\Resource\IManager |
|
1197 | - */ |
|
1198 | - public function getCalendarResourceBackendManager() { |
|
1199 | - return $this->query('CalendarResourceBackendManager'); |
|
1200 | - } |
|
1201 | - |
|
1202 | - /** |
|
1203 | - * @return \OCP\Calendar\Room\IManager |
|
1204 | - */ |
|
1205 | - public function getCalendarRoomBackendManager() { |
|
1206 | - return $this->query('CalendarRoomBackendManager'); |
|
1207 | - } |
|
1208 | - |
|
1209 | - private function connectDispatcher() { |
|
1210 | - $dispatcher = $this->getEventDispatcher(); |
|
1211 | - |
|
1212 | - // Delete avatar on user deletion |
|
1213 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1214 | - $logger = $this->getLogger(); |
|
1215 | - $manager = $this->getAvatarManager(); |
|
1216 | - /** @var IUser $user */ |
|
1217 | - $user = $e->getSubject(); |
|
1218 | - |
|
1219 | - try { |
|
1220 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1221 | - $avatar->remove(); |
|
1222 | - } catch (NotFoundException $e) { |
|
1223 | - // no avatar to remove |
|
1224 | - } catch (\Exception $e) { |
|
1225 | - // Ignore exceptions |
|
1226 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1227 | - } |
|
1228 | - }); |
|
1229 | - |
|
1230 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1231 | - $manager = $this->getAvatarManager(); |
|
1232 | - /** @var IUser $user */ |
|
1233 | - $user = $e->getSubject(); |
|
1234 | - $feature = $e->getArgument('feature'); |
|
1235 | - $oldValue = $e->getArgument('oldValue'); |
|
1236 | - $value = $e->getArgument('value'); |
|
1237 | - |
|
1238 | - try { |
|
1239 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1240 | - $avatar->userChanged($feature, $oldValue, $value); |
|
1241 | - } catch (NotFoundException $e) { |
|
1242 | - // no avatar to remove |
|
1243 | - } |
|
1244 | - }); |
|
1245 | - } |
|
1246 | - |
|
1247 | - /** |
|
1248 | - * @return \OCP\Contacts\IManager |
|
1249 | - */ |
|
1250 | - public function getContactsManager() { |
|
1251 | - return $this->query('ContactsManager'); |
|
1252 | - } |
|
1253 | - |
|
1254 | - /** |
|
1255 | - * @return \OC\Encryption\Manager |
|
1256 | - */ |
|
1257 | - public function getEncryptionManager() { |
|
1258 | - return $this->query('EncryptionManager'); |
|
1259 | - } |
|
1260 | - |
|
1261 | - /** |
|
1262 | - * @return \OC\Encryption\File |
|
1263 | - */ |
|
1264 | - public function getEncryptionFilesHelper() { |
|
1265 | - return $this->query('EncryptionFileHelper'); |
|
1266 | - } |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * @return \OCP\Encryption\Keys\IStorage |
|
1270 | - */ |
|
1271 | - public function getEncryptionKeyStorage() { |
|
1272 | - return $this->query('EncryptionKeyStorage'); |
|
1273 | - } |
|
1274 | - |
|
1275 | - /** |
|
1276 | - * The current request object holding all information about the request |
|
1277 | - * currently being processed is returned from this method. |
|
1278 | - * In case the current execution was not initiated by a web request null is returned |
|
1279 | - * |
|
1280 | - * @return \OCP\IRequest |
|
1281 | - */ |
|
1282 | - public function getRequest() { |
|
1283 | - return $this->query('Request'); |
|
1284 | - } |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * Returns the preview manager which can create preview images for a given file |
|
1288 | - * |
|
1289 | - * @return \OCP\IPreview |
|
1290 | - */ |
|
1291 | - public function getPreviewManager() { |
|
1292 | - return $this->query('PreviewManager'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * Returns the tag manager which can get and set tags for different object types |
|
1297 | - * |
|
1298 | - * @see \OCP\ITagManager::load() |
|
1299 | - * @return \OCP\ITagManager |
|
1300 | - */ |
|
1301 | - public function getTagManager() { |
|
1302 | - return $this->query('TagManager'); |
|
1303 | - } |
|
1304 | - |
|
1305 | - /** |
|
1306 | - * Returns the system-tag manager |
|
1307 | - * |
|
1308 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1309 | - * |
|
1310 | - * @since 9.0.0 |
|
1311 | - */ |
|
1312 | - public function getSystemTagManager() { |
|
1313 | - return $this->query('SystemTagManager'); |
|
1314 | - } |
|
1315 | - |
|
1316 | - /** |
|
1317 | - * Returns the system-tag object mapper |
|
1318 | - * |
|
1319 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1320 | - * |
|
1321 | - * @since 9.0.0 |
|
1322 | - */ |
|
1323 | - public function getSystemTagObjectMapper() { |
|
1324 | - return $this->query('SystemTagObjectMapper'); |
|
1325 | - } |
|
1326 | - |
|
1327 | - /** |
|
1328 | - * Returns the avatar manager, used for avatar functionality |
|
1329 | - * |
|
1330 | - * @return \OCP\IAvatarManager |
|
1331 | - */ |
|
1332 | - public function getAvatarManager() { |
|
1333 | - return $this->query('AvatarManager'); |
|
1334 | - } |
|
1335 | - |
|
1336 | - /** |
|
1337 | - * Returns the root folder of ownCloud's data directory |
|
1338 | - * |
|
1339 | - * @return \OCP\Files\IRootFolder |
|
1340 | - */ |
|
1341 | - public function getRootFolder() { |
|
1342 | - return $this->query('LazyRootFolder'); |
|
1343 | - } |
|
1344 | - |
|
1345 | - /** |
|
1346 | - * Returns the root folder of ownCloud's data directory |
|
1347 | - * This is the lazy variant so this gets only initialized once it |
|
1348 | - * is actually used. |
|
1349 | - * |
|
1350 | - * @return \OCP\Files\IRootFolder |
|
1351 | - */ |
|
1352 | - public function getLazyRootFolder() { |
|
1353 | - return $this->query('LazyRootFolder'); |
|
1354 | - } |
|
1355 | - |
|
1356 | - /** |
|
1357 | - * Returns a view to ownCloud's files folder |
|
1358 | - * |
|
1359 | - * @param string $userId user ID |
|
1360 | - * @return \OCP\Files\Folder|null |
|
1361 | - */ |
|
1362 | - public function getUserFolder($userId = null) { |
|
1363 | - if ($userId === null) { |
|
1364 | - $user = $this->getUserSession()->getUser(); |
|
1365 | - if (!$user) { |
|
1366 | - return null; |
|
1367 | - } |
|
1368 | - $userId = $user->getUID(); |
|
1369 | - } |
|
1370 | - $root = $this->getRootFolder(); |
|
1371 | - return $root->getUserFolder($userId); |
|
1372 | - } |
|
1373 | - |
|
1374 | - /** |
|
1375 | - * Returns an app-specific view in ownClouds data directory |
|
1376 | - * |
|
1377 | - * @return \OCP\Files\Folder |
|
1378 | - * @deprecated since 9.2.0 use IAppData |
|
1379 | - */ |
|
1380 | - public function getAppFolder() { |
|
1381 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1382 | - $root = $this->getRootFolder(); |
|
1383 | - if (!$root->nodeExists($dir)) { |
|
1384 | - $folder = $root->newFolder($dir); |
|
1385 | - } else { |
|
1386 | - $folder = $root->get($dir); |
|
1387 | - } |
|
1388 | - return $folder; |
|
1389 | - } |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * @return \OC\User\Manager |
|
1393 | - */ |
|
1394 | - public function getUserManager() { |
|
1395 | - return $this->query('UserManager'); |
|
1396 | - } |
|
1397 | - |
|
1398 | - /** |
|
1399 | - * @return \OC\Group\Manager |
|
1400 | - */ |
|
1401 | - public function getGroupManager() { |
|
1402 | - return $this->query('GroupManager'); |
|
1403 | - } |
|
1404 | - |
|
1405 | - /** |
|
1406 | - * @return \OC\User\Session |
|
1407 | - */ |
|
1408 | - public function getUserSession() { |
|
1409 | - return $this->query('UserSession'); |
|
1410 | - } |
|
1411 | - |
|
1412 | - /** |
|
1413 | - * @return \OCP\ISession |
|
1414 | - */ |
|
1415 | - public function getSession() { |
|
1416 | - return $this->query('UserSession')->getSession(); |
|
1417 | - } |
|
1418 | - |
|
1419 | - /** |
|
1420 | - * @param \OCP\ISession $session |
|
1421 | - */ |
|
1422 | - public function setSession(\OCP\ISession $session) { |
|
1423 | - $this->query(SessionStorage::class)->setSession($session); |
|
1424 | - $this->query('UserSession')->setSession($session); |
|
1425 | - $this->query(Store::class)->setSession($session); |
|
1426 | - } |
|
1427 | - |
|
1428 | - /** |
|
1429 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1430 | - */ |
|
1431 | - public function getTwoFactorAuthManager() { |
|
1432 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1433 | - } |
|
1434 | - |
|
1435 | - /** |
|
1436 | - * @return \OC\NavigationManager |
|
1437 | - */ |
|
1438 | - public function getNavigationManager() { |
|
1439 | - return $this->query('NavigationManager'); |
|
1440 | - } |
|
1441 | - |
|
1442 | - /** |
|
1443 | - * @return \OCP\IConfig |
|
1444 | - */ |
|
1445 | - public function getConfig() { |
|
1446 | - return $this->query('AllConfig'); |
|
1447 | - } |
|
1448 | - |
|
1449 | - /** |
|
1450 | - * @return \OC\SystemConfig |
|
1451 | - */ |
|
1452 | - public function getSystemConfig() { |
|
1453 | - return $this->query('SystemConfig'); |
|
1454 | - } |
|
1455 | - |
|
1456 | - /** |
|
1457 | - * Returns the app config manager |
|
1458 | - * |
|
1459 | - * @return \OCP\IAppConfig |
|
1460 | - */ |
|
1461 | - public function getAppConfig() { |
|
1462 | - return $this->query('AppConfig'); |
|
1463 | - } |
|
1464 | - |
|
1465 | - /** |
|
1466 | - * @return \OCP\L10N\IFactory |
|
1467 | - */ |
|
1468 | - public function getL10NFactory() { |
|
1469 | - return $this->query('L10NFactory'); |
|
1470 | - } |
|
1471 | - |
|
1472 | - /** |
|
1473 | - * get an L10N instance |
|
1474 | - * |
|
1475 | - * @param string $app appid |
|
1476 | - * @param string $lang |
|
1477 | - * @return IL10N |
|
1478 | - */ |
|
1479 | - public function getL10N($app, $lang = null) { |
|
1480 | - return $this->getL10NFactory()->get($app, $lang); |
|
1481 | - } |
|
1482 | - |
|
1483 | - /** |
|
1484 | - * @return \OCP\IURLGenerator |
|
1485 | - */ |
|
1486 | - public function getURLGenerator() { |
|
1487 | - return $this->query('URLGenerator'); |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * @return AppFetcher |
|
1492 | - */ |
|
1493 | - public function getAppFetcher() { |
|
1494 | - return $this->query(AppFetcher::class); |
|
1495 | - } |
|
1496 | - |
|
1497 | - /** |
|
1498 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1499 | - * getMemCacheFactory() instead. |
|
1500 | - * |
|
1501 | - * @return \OCP\ICache |
|
1502 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1503 | - */ |
|
1504 | - public function getCache() { |
|
1505 | - return $this->query('UserCache'); |
|
1506 | - } |
|
1507 | - |
|
1508 | - /** |
|
1509 | - * Returns an \OCP\CacheFactory instance |
|
1510 | - * |
|
1511 | - * @return \OCP\ICacheFactory |
|
1512 | - */ |
|
1513 | - public function getMemCacheFactory() { |
|
1514 | - return $this->query('MemCacheFactory'); |
|
1515 | - } |
|
1516 | - |
|
1517 | - /** |
|
1518 | - * Returns an \OC\RedisFactory instance |
|
1519 | - * |
|
1520 | - * @return \OC\RedisFactory |
|
1521 | - */ |
|
1522 | - public function getGetRedisFactory() { |
|
1523 | - return $this->query('RedisFactory'); |
|
1524 | - } |
|
1525 | - |
|
1526 | - |
|
1527 | - /** |
|
1528 | - * Returns the current session |
|
1529 | - * |
|
1530 | - * @return \OCP\IDBConnection |
|
1531 | - */ |
|
1532 | - public function getDatabaseConnection() { |
|
1533 | - return $this->query('DatabaseConnection'); |
|
1534 | - } |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * Returns the activity manager |
|
1538 | - * |
|
1539 | - * @return \OCP\Activity\IManager |
|
1540 | - */ |
|
1541 | - public function getActivityManager() { |
|
1542 | - return $this->query('ActivityManager'); |
|
1543 | - } |
|
1544 | - |
|
1545 | - /** |
|
1546 | - * Returns an job list for controlling background jobs |
|
1547 | - * |
|
1548 | - * @return \OCP\BackgroundJob\IJobList |
|
1549 | - */ |
|
1550 | - public function getJobList() { |
|
1551 | - return $this->query('JobList'); |
|
1552 | - } |
|
1553 | - |
|
1554 | - /** |
|
1555 | - * Returns a logger instance |
|
1556 | - * |
|
1557 | - * @return \OCP\ILogger |
|
1558 | - */ |
|
1559 | - public function getLogger() { |
|
1560 | - return $this->query('Logger'); |
|
1561 | - } |
|
1562 | - |
|
1563 | - /** |
|
1564 | - * @return ILogFactory |
|
1565 | - * @throws \OCP\AppFramework\QueryException |
|
1566 | - */ |
|
1567 | - public function getLogFactory() { |
|
1568 | - return $this->query(ILogFactory::class); |
|
1569 | - } |
|
1570 | - |
|
1571 | - /** |
|
1572 | - * Returns a router for generating and matching urls |
|
1573 | - * |
|
1574 | - * @return \OCP\Route\IRouter |
|
1575 | - */ |
|
1576 | - public function getRouter() { |
|
1577 | - return $this->query('Router'); |
|
1578 | - } |
|
1579 | - |
|
1580 | - /** |
|
1581 | - * Returns a search instance |
|
1582 | - * |
|
1583 | - * @return \OCP\ISearch |
|
1584 | - */ |
|
1585 | - public function getSearch() { |
|
1586 | - return $this->query('Search'); |
|
1587 | - } |
|
1588 | - |
|
1589 | - /** |
|
1590 | - * Returns a SecureRandom instance |
|
1591 | - * |
|
1592 | - * @return \OCP\Security\ISecureRandom |
|
1593 | - */ |
|
1594 | - public function getSecureRandom() { |
|
1595 | - return $this->query('SecureRandom'); |
|
1596 | - } |
|
1597 | - |
|
1598 | - /** |
|
1599 | - * Returns a Crypto instance |
|
1600 | - * |
|
1601 | - * @return \OCP\Security\ICrypto |
|
1602 | - */ |
|
1603 | - public function getCrypto() { |
|
1604 | - return $this->query('Crypto'); |
|
1605 | - } |
|
1606 | - |
|
1607 | - /** |
|
1608 | - * Returns a Hasher instance |
|
1609 | - * |
|
1610 | - * @return \OCP\Security\IHasher |
|
1611 | - */ |
|
1612 | - public function getHasher() { |
|
1613 | - return $this->query('Hasher'); |
|
1614 | - } |
|
1615 | - |
|
1616 | - /** |
|
1617 | - * Returns a CredentialsManager instance |
|
1618 | - * |
|
1619 | - * @return \OCP\Security\ICredentialsManager |
|
1620 | - */ |
|
1621 | - public function getCredentialsManager() { |
|
1622 | - return $this->query('CredentialsManager'); |
|
1623 | - } |
|
1624 | - |
|
1625 | - /** |
|
1626 | - * Get the certificate manager for the user |
|
1627 | - * |
|
1628 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1629 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1630 | - */ |
|
1631 | - public function getCertificateManager($userId = '') { |
|
1632 | - if ($userId === '') { |
|
1633 | - $userSession = $this->getUserSession(); |
|
1634 | - $user = $userSession->getUser(); |
|
1635 | - if (is_null($user)) { |
|
1636 | - return null; |
|
1637 | - } |
|
1638 | - $userId = $user->getUID(); |
|
1639 | - } |
|
1640 | - return new CertificateManager( |
|
1641 | - $userId, |
|
1642 | - new View(), |
|
1643 | - $this->getConfig(), |
|
1644 | - $this->getLogger(), |
|
1645 | - $this->getSecureRandom() |
|
1646 | - ); |
|
1647 | - } |
|
1648 | - |
|
1649 | - /** |
|
1650 | - * Returns an instance of the HTTP client service |
|
1651 | - * |
|
1652 | - * @return \OCP\Http\Client\IClientService |
|
1653 | - */ |
|
1654 | - public function getHTTPClientService() { |
|
1655 | - return $this->query('HttpClientService'); |
|
1656 | - } |
|
1657 | - |
|
1658 | - /** |
|
1659 | - * Create a new event source |
|
1660 | - * |
|
1661 | - * @return \OCP\IEventSource |
|
1662 | - */ |
|
1663 | - public function createEventSource() { |
|
1664 | - return new \OC_EventSource(); |
|
1665 | - } |
|
1666 | - |
|
1667 | - /** |
|
1668 | - * Get the active event logger |
|
1669 | - * |
|
1670 | - * The returned logger only logs data when debug mode is enabled |
|
1671 | - * |
|
1672 | - * @return \OCP\Diagnostics\IEventLogger |
|
1673 | - */ |
|
1674 | - public function getEventLogger() { |
|
1675 | - return $this->query('EventLogger'); |
|
1676 | - } |
|
1677 | - |
|
1678 | - /** |
|
1679 | - * Get the active query logger |
|
1680 | - * |
|
1681 | - * The returned logger only logs data when debug mode is enabled |
|
1682 | - * |
|
1683 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1684 | - */ |
|
1685 | - public function getQueryLogger() { |
|
1686 | - return $this->query('QueryLogger'); |
|
1687 | - } |
|
1688 | - |
|
1689 | - /** |
|
1690 | - * Get the manager for temporary files and folders |
|
1691 | - * |
|
1692 | - * @return \OCP\ITempManager |
|
1693 | - */ |
|
1694 | - public function getTempManager() { |
|
1695 | - return $this->query('TempManager'); |
|
1696 | - } |
|
1697 | - |
|
1698 | - /** |
|
1699 | - * Get the app manager |
|
1700 | - * |
|
1701 | - * @return \OCP\App\IAppManager |
|
1702 | - */ |
|
1703 | - public function getAppManager() { |
|
1704 | - return $this->query('AppManager'); |
|
1705 | - } |
|
1706 | - |
|
1707 | - /** |
|
1708 | - * Creates a new mailer |
|
1709 | - * |
|
1710 | - * @return \OCP\Mail\IMailer |
|
1711 | - */ |
|
1712 | - public function getMailer() { |
|
1713 | - return $this->query('Mailer'); |
|
1714 | - } |
|
1715 | - |
|
1716 | - /** |
|
1717 | - * Get the webroot |
|
1718 | - * |
|
1719 | - * @return string |
|
1720 | - */ |
|
1721 | - public function getWebRoot() { |
|
1722 | - return $this->webRoot; |
|
1723 | - } |
|
1724 | - |
|
1725 | - /** |
|
1726 | - * @return \OC\OCSClient |
|
1727 | - */ |
|
1728 | - public function getOcsClient() { |
|
1729 | - return $this->query('OcsClient'); |
|
1730 | - } |
|
1731 | - |
|
1732 | - /** |
|
1733 | - * @return \OCP\IDateTimeZone |
|
1734 | - */ |
|
1735 | - public function getDateTimeZone() { |
|
1736 | - return $this->query('DateTimeZone'); |
|
1737 | - } |
|
1738 | - |
|
1739 | - /** |
|
1740 | - * @return \OCP\IDateTimeFormatter |
|
1741 | - */ |
|
1742 | - public function getDateTimeFormatter() { |
|
1743 | - return $this->query('DateTimeFormatter'); |
|
1744 | - } |
|
1745 | - |
|
1746 | - /** |
|
1747 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1748 | - */ |
|
1749 | - public function getMountProviderCollection() { |
|
1750 | - return $this->query('MountConfigManager'); |
|
1751 | - } |
|
1752 | - |
|
1753 | - /** |
|
1754 | - * Get the IniWrapper |
|
1755 | - * |
|
1756 | - * @return IniGetWrapper |
|
1757 | - */ |
|
1758 | - public function getIniWrapper() { |
|
1759 | - return $this->query('IniWrapper'); |
|
1760 | - } |
|
1761 | - |
|
1762 | - /** |
|
1763 | - * @return \OCP\Command\IBus |
|
1764 | - */ |
|
1765 | - public function getCommandBus() { |
|
1766 | - return $this->query('AsyncCommandBus'); |
|
1767 | - } |
|
1768 | - |
|
1769 | - /** |
|
1770 | - * Get the trusted domain helper |
|
1771 | - * |
|
1772 | - * @return TrustedDomainHelper |
|
1773 | - */ |
|
1774 | - public function getTrustedDomainHelper() { |
|
1775 | - return $this->query('TrustedDomainHelper'); |
|
1776 | - } |
|
1777 | - |
|
1778 | - /** |
|
1779 | - * Get the locking provider |
|
1780 | - * |
|
1781 | - * @return \OCP\Lock\ILockingProvider |
|
1782 | - * @since 8.1.0 |
|
1783 | - */ |
|
1784 | - public function getLockingProvider() { |
|
1785 | - return $this->query('LockingProvider'); |
|
1786 | - } |
|
1787 | - |
|
1788 | - /** |
|
1789 | - * @return \OCP\Files\Mount\IMountManager |
|
1790 | - **/ |
|
1791 | - function getMountManager() { |
|
1792 | - return $this->query('MountManager'); |
|
1793 | - } |
|
1794 | - |
|
1795 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1796 | - function getUserMountCache() { |
|
1797 | - return $this->query('UserMountCache'); |
|
1798 | - } |
|
1799 | - |
|
1800 | - /** |
|
1801 | - * Get the MimeTypeDetector |
|
1802 | - * |
|
1803 | - * @return \OCP\Files\IMimeTypeDetector |
|
1804 | - */ |
|
1805 | - public function getMimeTypeDetector() { |
|
1806 | - return $this->query('MimeTypeDetector'); |
|
1807 | - } |
|
1808 | - |
|
1809 | - /** |
|
1810 | - * Get the MimeTypeLoader |
|
1811 | - * |
|
1812 | - * @return \OCP\Files\IMimeTypeLoader |
|
1813 | - */ |
|
1814 | - public function getMimeTypeLoader() { |
|
1815 | - return $this->query('MimeTypeLoader'); |
|
1816 | - } |
|
1817 | - |
|
1818 | - /** |
|
1819 | - * Get the manager of all the capabilities |
|
1820 | - * |
|
1821 | - * @return \OC\CapabilitiesManager |
|
1822 | - */ |
|
1823 | - public function getCapabilitiesManager() { |
|
1824 | - return $this->query('CapabilitiesManager'); |
|
1825 | - } |
|
1826 | - |
|
1827 | - /** |
|
1828 | - * Get the EventDispatcher |
|
1829 | - * |
|
1830 | - * @return EventDispatcherInterface |
|
1831 | - * @since 8.2.0 |
|
1832 | - */ |
|
1833 | - public function getEventDispatcher() { |
|
1834 | - return $this->query('EventDispatcher'); |
|
1835 | - } |
|
1836 | - |
|
1837 | - /** |
|
1838 | - * Get the Notification Manager |
|
1839 | - * |
|
1840 | - * @return \OCP\Notification\IManager |
|
1841 | - * @since 8.2.0 |
|
1842 | - */ |
|
1843 | - public function getNotificationManager() { |
|
1844 | - return $this->query('NotificationManager'); |
|
1845 | - } |
|
1846 | - |
|
1847 | - /** |
|
1848 | - * @return \OCP\Comments\ICommentsManager |
|
1849 | - */ |
|
1850 | - public function getCommentsManager() { |
|
1851 | - return $this->query('CommentsManager'); |
|
1852 | - } |
|
1853 | - |
|
1854 | - /** |
|
1855 | - * @return \OCA\Theming\ThemingDefaults |
|
1856 | - */ |
|
1857 | - public function getThemingDefaults() { |
|
1858 | - return $this->query('ThemingDefaults'); |
|
1859 | - } |
|
1860 | - |
|
1861 | - /** |
|
1862 | - * @return \OC\IntegrityCheck\Checker |
|
1863 | - */ |
|
1864 | - public function getIntegrityCodeChecker() { |
|
1865 | - return $this->query('IntegrityCodeChecker'); |
|
1866 | - } |
|
1867 | - |
|
1868 | - /** |
|
1869 | - * @return \OC\Session\CryptoWrapper |
|
1870 | - */ |
|
1871 | - public function getSessionCryptoWrapper() { |
|
1872 | - return $this->query('CryptoWrapper'); |
|
1873 | - } |
|
1874 | - |
|
1875 | - /** |
|
1876 | - * @return CsrfTokenManager |
|
1877 | - */ |
|
1878 | - public function getCsrfTokenManager() { |
|
1879 | - return $this->query('CsrfTokenManager'); |
|
1880 | - } |
|
1881 | - |
|
1882 | - /** |
|
1883 | - * @return Throttler |
|
1884 | - */ |
|
1885 | - public function getBruteForceThrottler() { |
|
1886 | - return $this->query('Throttler'); |
|
1887 | - } |
|
1888 | - |
|
1889 | - /** |
|
1890 | - * @return IContentSecurityPolicyManager |
|
1891 | - */ |
|
1892 | - public function getContentSecurityPolicyManager() { |
|
1893 | - return $this->query('ContentSecurityPolicyManager'); |
|
1894 | - } |
|
1895 | - |
|
1896 | - /** |
|
1897 | - * @return ContentSecurityPolicyNonceManager |
|
1898 | - */ |
|
1899 | - public function getContentSecurityPolicyNonceManager() { |
|
1900 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1901 | - } |
|
1902 | - |
|
1903 | - /** |
|
1904 | - * Not a public API as of 8.2, wait for 9.0 |
|
1905 | - * |
|
1906 | - * @return \OCA\Files_External\Service\BackendService |
|
1907 | - */ |
|
1908 | - public function getStoragesBackendService() { |
|
1909 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1910 | - } |
|
1911 | - |
|
1912 | - /** |
|
1913 | - * Not a public API as of 8.2, wait for 9.0 |
|
1914 | - * |
|
1915 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1916 | - */ |
|
1917 | - public function getGlobalStoragesService() { |
|
1918 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1919 | - } |
|
1920 | - |
|
1921 | - /** |
|
1922 | - * Not a public API as of 8.2, wait for 9.0 |
|
1923 | - * |
|
1924 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1925 | - */ |
|
1926 | - public function getUserGlobalStoragesService() { |
|
1927 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1928 | - } |
|
1929 | - |
|
1930 | - /** |
|
1931 | - * Not a public API as of 8.2, wait for 9.0 |
|
1932 | - * |
|
1933 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1934 | - */ |
|
1935 | - public function getUserStoragesService() { |
|
1936 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1937 | - } |
|
1938 | - |
|
1939 | - /** |
|
1940 | - * @return \OCP\Share\IManager |
|
1941 | - */ |
|
1942 | - public function getShareManager() { |
|
1943 | - return $this->query('ShareManager'); |
|
1944 | - } |
|
1945 | - |
|
1946 | - /** |
|
1947 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
1948 | - */ |
|
1949 | - public function getCollaboratorSearch() { |
|
1950 | - return $this->query('CollaboratorSearch'); |
|
1951 | - } |
|
1952 | - |
|
1953 | - /** |
|
1954 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
1955 | - */ |
|
1956 | - public function getAutoCompleteManager(){ |
|
1957 | - return $this->query(IManager::class); |
|
1958 | - } |
|
1959 | - |
|
1960 | - /** |
|
1961 | - * Returns the LDAP Provider |
|
1962 | - * |
|
1963 | - * @return \OCP\LDAP\ILDAPProvider |
|
1964 | - */ |
|
1965 | - public function getLDAPProvider() { |
|
1966 | - return $this->query('LDAPProvider'); |
|
1967 | - } |
|
1968 | - |
|
1969 | - /** |
|
1970 | - * @return \OCP\Settings\IManager |
|
1971 | - */ |
|
1972 | - public function getSettingsManager() { |
|
1973 | - return $this->query('SettingsManager'); |
|
1974 | - } |
|
1975 | - |
|
1976 | - /** |
|
1977 | - * @return \OCP\Files\IAppData |
|
1978 | - */ |
|
1979 | - public function getAppDataDir($app) { |
|
1980 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1981 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1982 | - return $factory->get($app); |
|
1983 | - } |
|
1984 | - |
|
1985 | - /** |
|
1986 | - * @return \OCP\Lockdown\ILockdownManager |
|
1987 | - */ |
|
1988 | - public function getLockdownManager() { |
|
1989 | - return $this->query('LockdownManager'); |
|
1990 | - } |
|
1991 | - |
|
1992 | - /** |
|
1993 | - * @return \OCP\Federation\ICloudIdManager |
|
1994 | - */ |
|
1995 | - public function getCloudIdManager() { |
|
1996 | - return $this->query(ICloudIdManager::class); |
|
1997 | - } |
|
1998 | - |
|
1999 | - /** |
|
2000 | - * @return \OCP\GlobalScale\IConfig |
|
2001 | - */ |
|
2002 | - public function getGlobalScaleConfig() { |
|
2003 | - return $this->query(IConfig::class); |
|
2004 | - } |
|
2005 | - |
|
2006 | - /** |
|
2007 | - * @return \OCP\Federation\ICloudFederationProviderManager |
|
2008 | - */ |
|
2009 | - public function getCloudFederationProviderManager() { |
|
2010 | - return $this->query(ICloudFederationProviderManager::class); |
|
2011 | - } |
|
2012 | - |
|
2013 | - /** |
|
2014 | - * @return \OCP\Remote\Api\IApiFactory |
|
2015 | - */ |
|
2016 | - public function getRemoteApiFactory() { |
|
2017 | - return $this->query(IApiFactory::class); |
|
2018 | - } |
|
2019 | - |
|
2020 | - /** |
|
2021 | - * @return \OCP\Federation\ICloudFederationFactory |
|
2022 | - */ |
|
2023 | - public function getCloudFederationFactory() { |
|
2024 | - return $this->query(ICloudFederationFactory::class); |
|
2025 | - } |
|
2026 | - |
|
2027 | - /** |
|
2028 | - * @return \OCP\Remote\IInstanceFactory |
|
2029 | - */ |
|
2030 | - public function getRemoteInstanceFactory() { |
|
2031 | - return $this->query(IInstanceFactory::class); |
|
2032 | - } |
|
2033 | - |
|
2034 | - /** |
|
2035 | - * @return IStorageFactory |
|
2036 | - */ |
|
2037 | - public function getStorageFactory() { |
|
2038 | - return $this->query(IStorageFactory::class); |
|
2039 | - } |
|
941 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
942 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
943 | + $classExists = true; |
|
944 | + } else { |
|
945 | + $classExists = false; |
|
946 | + } |
|
947 | + |
|
948 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
949 | + return new ThemingDefaults( |
|
950 | + $c->getConfig(), |
|
951 | + $c->getL10N('theming'), |
|
952 | + $c->getURLGenerator(), |
|
953 | + $c->getMemCacheFactory(), |
|
954 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
955 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
956 | + $c->getAppManager() |
|
957 | + ); |
|
958 | + } |
|
959 | + return new \OC_Defaults(); |
|
960 | + }); |
|
961 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
962 | + /** @var Factory $cacheFactory */ |
|
963 | + $cacheFactory = $c->query(Factory::class); |
|
964 | + return new SCSSCacher( |
|
965 | + $c->getLogger(), |
|
966 | + $c->query(\OC\Files\AppData\Factory::class), |
|
967 | + $c->getURLGenerator(), |
|
968 | + $c->getConfig(), |
|
969 | + $c->getThemingDefaults(), |
|
970 | + \OC::$SERVERROOT, |
|
971 | + $this->getMemCacheFactory(), |
|
972 | + $c->query(IconsCacher::class), |
|
973 | + new TimeFactory() |
|
974 | + ); |
|
975 | + }); |
|
976 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
977 | + /** @var Factory $cacheFactory */ |
|
978 | + $cacheFactory = $c->query(Factory::class); |
|
979 | + return new JSCombiner( |
|
980 | + $c->getAppDataDir('js'), |
|
981 | + $c->getURLGenerator(), |
|
982 | + $this->getMemCacheFactory(), |
|
983 | + $c->getSystemConfig(), |
|
984 | + $c->getLogger() |
|
985 | + ); |
|
986 | + }); |
|
987 | + $this->registerService(EventDispatcher::class, function () { |
|
988 | + return new EventDispatcher(); |
|
989 | + }); |
|
990 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
991 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
992 | + |
|
993 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
994 | + // FIXME: Instantiiated here due to cyclic dependency |
|
995 | + $request = new Request( |
|
996 | + [ |
|
997 | + 'get' => $_GET, |
|
998 | + 'post' => $_POST, |
|
999 | + 'files' => $_FILES, |
|
1000 | + 'server' => $_SERVER, |
|
1001 | + 'env' => $_ENV, |
|
1002 | + 'cookies' => $_COOKIE, |
|
1003 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1004 | + ? $_SERVER['REQUEST_METHOD'] |
|
1005 | + : null, |
|
1006 | + ], |
|
1007 | + $c->getSecureRandom(), |
|
1008 | + $c->getConfig() |
|
1009 | + ); |
|
1010 | + |
|
1011 | + return new CryptoWrapper( |
|
1012 | + $c->getConfig(), |
|
1013 | + $c->getCrypto(), |
|
1014 | + $c->getSecureRandom(), |
|
1015 | + $request |
|
1016 | + ); |
|
1017 | + }); |
|
1018 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1019 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1020 | + |
|
1021 | + return new CsrfTokenManager( |
|
1022 | + $tokenGenerator, |
|
1023 | + $c->query(SessionStorage::class) |
|
1024 | + ); |
|
1025 | + }); |
|
1026 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
1027 | + return new SessionStorage($c->getSession()); |
|
1028 | + }); |
|
1029 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1030 | + return new ContentSecurityPolicyManager(); |
|
1031 | + }); |
|
1032 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1033 | + |
|
1034 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1035 | + return new ContentSecurityPolicyNonceManager( |
|
1036 | + $c->getCsrfTokenManager(), |
|
1037 | + $c->getRequest() |
|
1038 | + ); |
|
1039 | + }); |
|
1040 | + |
|
1041 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1042 | + $config = $c->getConfig(); |
|
1043 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1044 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
1045 | + $factory = new $factoryClass($this); |
|
1046 | + |
|
1047 | + $manager = new \OC\Share20\Manager( |
|
1048 | + $c->getLogger(), |
|
1049 | + $c->getConfig(), |
|
1050 | + $c->getSecureRandom(), |
|
1051 | + $c->getHasher(), |
|
1052 | + $c->getMountManager(), |
|
1053 | + $c->getGroupManager(), |
|
1054 | + $c->getL10N('lib'), |
|
1055 | + $c->getL10NFactory(), |
|
1056 | + $factory, |
|
1057 | + $c->getUserManager(), |
|
1058 | + $c->getLazyRootFolder(), |
|
1059 | + $c->getEventDispatcher(), |
|
1060 | + $c->getMailer(), |
|
1061 | + $c->getURLGenerator(), |
|
1062 | + $c->getThemingDefaults() |
|
1063 | + ); |
|
1064 | + |
|
1065 | + return $manager; |
|
1066 | + }); |
|
1067 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1068 | + |
|
1069 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1070 | + $instance = new Collaboration\Collaborators\Search($c); |
|
1071 | + |
|
1072 | + // register default plugins |
|
1073 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1074 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1075 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1076 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1077 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); |
|
1078 | + |
|
1079 | + return $instance; |
|
1080 | + }); |
|
1081 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1082 | + |
|
1083 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1084 | + |
|
1085 | + $this->registerService('SettingsManager', function (Server $c) { |
|
1086 | + $manager = new \OC\Settings\Manager( |
|
1087 | + $c->getLogger(), |
|
1088 | + $c->getL10N('lib'), |
|
1089 | + $c->getURLGenerator(), |
|
1090 | + $c |
|
1091 | + ); |
|
1092 | + return $manager; |
|
1093 | + }); |
|
1094 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1095 | + return new \OC\Files\AppData\Factory( |
|
1096 | + $c->getRootFolder(), |
|
1097 | + $c->getSystemConfig() |
|
1098 | + ); |
|
1099 | + }); |
|
1100 | + |
|
1101 | + $this->registerService('LockdownManager', function (Server $c) { |
|
1102 | + return new LockdownManager(function () use ($c) { |
|
1103 | + return $c->getSession(); |
|
1104 | + }); |
|
1105 | + }); |
|
1106 | + |
|
1107 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1108 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1109 | + }); |
|
1110 | + |
|
1111 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1112 | + return new CloudIdManager(); |
|
1113 | + }); |
|
1114 | + |
|
1115 | + $this->registerService(IConfig::class, function (Server $c) { |
|
1116 | + return new GlobalScale\Config($c->getConfig()); |
|
1117 | + }); |
|
1118 | + |
|
1119 | + $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
1120 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); |
|
1121 | + }); |
|
1122 | + |
|
1123 | + $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
1124 | + return new CloudFederationFactory(); |
|
1125 | + }); |
|
1126 | + |
|
1127 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1128 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1129 | + |
|
1130 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1131 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1132 | + |
|
1133 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1134 | + return new Defaults( |
|
1135 | + $c->getThemingDefaults() |
|
1136 | + ); |
|
1137 | + }); |
|
1138 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1139 | + |
|
1140 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1141 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1142 | + }); |
|
1143 | + |
|
1144 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
1145 | + return new ShareHelper( |
|
1146 | + $c->query(\OCP\Share\IManager::class) |
|
1147 | + ); |
|
1148 | + }); |
|
1149 | + |
|
1150 | + $this->registerService(Installer::class, function(Server $c) { |
|
1151 | + return new Installer( |
|
1152 | + $c->getAppFetcher(), |
|
1153 | + $c->getHTTPClientService(), |
|
1154 | + $c->getTempManager(), |
|
1155 | + $c->getLogger(), |
|
1156 | + $c->getConfig() |
|
1157 | + ); |
|
1158 | + }); |
|
1159 | + |
|
1160 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
1161 | + return new ApiFactory($c->getHTTPClientService()); |
|
1162 | + }); |
|
1163 | + |
|
1164 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1165 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
1166 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1167 | + }); |
|
1168 | + |
|
1169 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
1170 | + return new ContactsStore( |
|
1171 | + $c->getContactsManager(), |
|
1172 | + $c->getConfig(), |
|
1173 | + $c->getUserManager(), |
|
1174 | + $c->getGroupManager() |
|
1175 | + ); |
|
1176 | + }); |
|
1177 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1178 | + |
|
1179 | + $this->registerService(IStorageFactory::class, function() { |
|
1180 | + return new StorageFactory(); |
|
1181 | + }); |
|
1182 | + |
|
1183 | + $this->registerAlias(IDashboardManager::class, Dashboard\DashboardManager::class); |
|
1184 | + |
|
1185 | + $this->connectDispatcher(); |
|
1186 | + } |
|
1187 | + |
|
1188 | + /** |
|
1189 | + * @return \OCP\Calendar\IManager |
|
1190 | + */ |
|
1191 | + public function getCalendarManager() { |
|
1192 | + return $this->query('CalendarManager'); |
|
1193 | + } |
|
1194 | + |
|
1195 | + /** |
|
1196 | + * @return \OCP\Calendar\Resource\IManager |
|
1197 | + */ |
|
1198 | + public function getCalendarResourceBackendManager() { |
|
1199 | + return $this->query('CalendarResourceBackendManager'); |
|
1200 | + } |
|
1201 | + |
|
1202 | + /** |
|
1203 | + * @return \OCP\Calendar\Room\IManager |
|
1204 | + */ |
|
1205 | + public function getCalendarRoomBackendManager() { |
|
1206 | + return $this->query('CalendarRoomBackendManager'); |
|
1207 | + } |
|
1208 | + |
|
1209 | + private function connectDispatcher() { |
|
1210 | + $dispatcher = $this->getEventDispatcher(); |
|
1211 | + |
|
1212 | + // Delete avatar on user deletion |
|
1213 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1214 | + $logger = $this->getLogger(); |
|
1215 | + $manager = $this->getAvatarManager(); |
|
1216 | + /** @var IUser $user */ |
|
1217 | + $user = $e->getSubject(); |
|
1218 | + |
|
1219 | + try { |
|
1220 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1221 | + $avatar->remove(); |
|
1222 | + } catch (NotFoundException $e) { |
|
1223 | + // no avatar to remove |
|
1224 | + } catch (\Exception $e) { |
|
1225 | + // Ignore exceptions |
|
1226 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1227 | + } |
|
1228 | + }); |
|
1229 | + |
|
1230 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1231 | + $manager = $this->getAvatarManager(); |
|
1232 | + /** @var IUser $user */ |
|
1233 | + $user = $e->getSubject(); |
|
1234 | + $feature = $e->getArgument('feature'); |
|
1235 | + $oldValue = $e->getArgument('oldValue'); |
|
1236 | + $value = $e->getArgument('value'); |
|
1237 | + |
|
1238 | + try { |
|
1239 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1240 | + $avatar->userChanged($feature, $oldValue, $value); |
|
1241 | + } catch (NotFoundException $e) { |
|
1242 | + // no avatar to remove |
|
1243 | + } |
|
1244 | + }); |
|
1245 | + } |
|
1246 | + |
|
1247 | + /** |
|
1248 | + * @return \OCP\Contacts\IManager |
|
1249 | + */ |
|
1250 | + public function getContactsManager() { |
|
1251 | + return $this->query('ContactsManager'); |
|
1252 | + } |
|
1253 | + |
|
1254 | + /** |
|
1255 | + * @return \OC\Encryption\Manager |
|
1256 | + */ |
|
1257 | + public function getEncryptionManager() { |
|
1258 | + return $this->query('EncryptionManager'); |
|
1259 | + } |
|
1260 | + |
|
1261 | + /** |
|
1262 | + * @return \OC\Encryption\File |
|
1263 | + */ |
|
1264 | + public function getEncryptionFilesHelper() { |
|
1265 | + return $this->query('EncryptionFileHelper'); |
|
1266 | + } |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * @return \OCP\Encryption\Keys\IStorage |
|
1270 | + */ |
|
1271 | + public function getEncryptionKeyStorage() { |
|
1272 | + return $this->query('EncryptionKeyStorage'); |
|
1273 | + } |
|
1274 | + |
|
1275 | + /** |
|
1276 | + * The current request object holding all information about the request |
|
1277 | + * currently being processed is returned from this method. |
|
1278 | + * In case the current execution was not initiated by a web request null is returned |
|
1279 | + * |
|
1280 | + * @return \OCP\IRequest |
|
1281 | + */ |
|
1282 | + public function getRequest() { |
|
1283 | + return $this->query('Request'); |
|
1284 | + } |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * Returns the preview manager which can create preview images for a given file |
|
1288 | + * |
|
1289 | + * @return \OCP\IPreview |
|
1290 | + */ |
|
1291 | + public function getPreviewManager() { |
|
1292 | + return $this->query('PreviewManager'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * Returns the tag manager which can get and set tags for different object types |
|
1297 | + * |
|
1298 | + * @see \OCP\ITagManager::load() |
|
1299 | + * @return \OCP\ITagManager |
|
1300 | + */ |
|
1301 | + public function getTagManager() { |
|
1302 | + return $this->query('TagManager'); |
|
1303 | + } |
|
1304 | + |
|
1305 | + /** |
|
1306 | + * Returns the system-tag manager |
|
1307 | + * |
|
1308 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1309 | + * |
|
1310 | + * @since 9.0.0 |
|
1311 | + */ |
|
1312 | + public function getSystemTagManager() { |
|
1313 | + return $this->query('SystemTagManager'); |
|
1314 | + } |
|
1315 | + |
|
1316 | + /** |
|
1317 | + * Returns the system-tag object mapper |
|
1318 | + * |
|
1319 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1320 | + * |
|
1321 | + * @since 9.0.0 |
|
1322 | + */ |
|
1323 | + public function getSystemTagObjectMapper() { |
|
1324 | + return $this->query('SystemTagObjectMapper'); |
|
1325 | + } |
|
1326 | + |
|
1327 | + /** |
|
1328 | + * Returns the avatar manager, used for avatar functionality |
|
1329 | + * |
|
1330 | + * @return \OCP\IAvatarManager |
|
1331 | + */ |
|
1332 | + public function getAvatarManager() { |
|
1333 | + return $this->query('AvatarManager'); |
|
1334 | + } |
|
1335 | + |
|
1336 | + /** |
|
1337 | + * Returns the root folder of ownCloud's data directory |
|
1338 | + * |
|
1339 | + * @return \OCP\Files\IRootFolder |
|
1340 | + */ |
|
1341 | + public function getRootFolder() { |
|
1342 | + return $this->query('LazyRootFolder'); |
|
1343 | + } |
|
1344 | + |
|
1345 | + /** |
|
1346 | + * Returns the root folder of ownCloud's data directory |
|
1347 | + * This is the lazy variant so this gets only initialized once it |
|
1348 | + * is actually used. |
|
1349 | + * |
|
1350 | + * @return \OCP\Files\IRootFolder |
|
1351 | + */ |
|
1352 | + public function getLazyRootFolder() { |
|
1353 | + return $this->query('LazyRootFolder'); |
|
1354 | + } |
|
1355 | + |
|
1356 | + /** |
|
1357 | + * Returns a view to ownCloud's files folder |
|
1358 | + * |
|
1359 | + * @param string $userId user ID |
|
1360 | + * @return \OCP\Files\Folder|null |
|
1361 | + */ |
|
1362 | + public function getUserFolder($userId = null) { |
|
1363 | + if ($userId === null) { |
|
1364 | + $user = $this->getUserSession()->getUser(); |
|
1365 | + if (!$user) { |
|
1366 | + return null; |
|
1367 | + } |
|
1368 | + $userId = $user->getUID(); |
|
1369 | + } |
|
1370 | + $root = $this->getRootFolder(); |
|
1371 | + return $root->getUserFolder($userId); |
|
1372 | + } |
|
1373 | + |
|
1374 | + /** |
|
1375 | + * Returns an app-specific view in ownClouds data directory |
|
1376 | + * |
|
1377 | + * @return \OCP\Files\Folder |
|
1378 | + * @deprecated since 9.2.0 use IAppData |
|
1379 | + */ |
|
1380 | + public function getAppFolder() { |
|
1381 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1382 | + $root = $this->getRootFolder(); |
|
1383 | + if (!$root->nodeExists($dir)) { |
|
1384 | + $folder = $root->newFolder($dir); |
|
1385 | + } else { |
|
1386 | + $folder = $root->get($dir); |
|
1387 | + } |
|
1388 | + return $folder; |
|
1389 | + } |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * @return \OC\User\Manager |
|
1393 | + */ |
|
1394 | + public function getUserManager() { |
|
1395 | + return $this->query('UserManager'); |
|
1396 | + } |
|
1397 | + |
|
1398 | + /** |
|
1399 | + * @return \OC\Group\Manager |
|
1400 | + */ |
|
1401 | + public function getGroupManager() { |
|
1402 | + return $this->query('GroupManager'); |
|
1403 | + } |
|
1404 | + |
|
1405 | + /** |
|
1406 | + * @return \OC\User\Session |
|
1407 | + */ |
|
1408 | + public function getUserSession() { |
|
1409 | + return $this->query('UserSession'); |
|
1410 | + } |
|
1411 | + |
|
1412 | + /** |
|
1413 | + * @return \OCP\ISession |
|
1414 | + */ |
|
1415 | + public function getSession() { |
|
1416 | + return $this->query('UserSession')->getSession(); |
|
1417 | + } |
|
1418 | + |
|
1419 | + /** |
|
1420 | + * @param \OCP\ISession $session |
|
1421 | + */ |
|
1422 | + public function setSession(\OCP\ISession $session) { |
|
1423 | + $this->query(SessionStorage::class)->setSession($session); |
|
1424 | + $this->query('UserSession')->setSession($session); |
|
1425 | + $this->query(Store::class)->setSession($session); |
|
1426 | + } |
|
1427 | + |
|
1428 | + /** |
|
1429 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1430 | + */ |
|
1431 | + public function getTwoFactorAuthManager() { |
|
1432 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1433 | + } |
|
1434 | + |
|
1435 | + /** |
|
1436 | + * @return \OC\NavigationManager |
|
1437 | + */ |
|
1438 | + public function getNavigationManager() { |
|
1439 | + return $this->query('NavigationManager'); |
|
1440 | + } |
|
1441 | + |
|
1442 | + /** |
|
1443 | + * @return \OCP\IConfig |
|
1444 | + */ |
|
1445 | + public function getConfig() { |
|
1446 | + return $this->query('AllConfig'); |
|
1447 | + } |
|
1448 | + |
|
1449 | + /** |
|
1450 | + * @return \OC\SystemConfig |
|
1451 | + */ |
|
1452 | + public function getSystemConfig() { |
|
1453 | + return $this->query('SystemConfig'); |
|
1454 | + } |
|
1455 | + |
|
1456 | + /** |
|
1457 | + * Returns the app config manager |
|
1458 | + * |
|
1459 | + * @return \OCP\IAppConfig |
|
1460 | + */ |
|
1461 | + public function getAppConfig() { |
|
1462 | + return $this->query('AppConfig'); |
|
1463 | + } |
|
1464 | + |
|
1465 | + /** |
|
1466 | + * @return \OCP\L10N\IFactory |
|
1467 | + */ |
|
1468 | + public function getL10NFactory() { |
|
1469 | + return $this->query('L10NFactory'); |
|
1470 | + } |
|
1471 | + |
|
1472 | + /** |
|
1473 | + * get an L10N instance |
|
1474 | + * |
|
1475 | + * @param string $app appid |
|
1476 | + * @param string $lang |
|
1477 | + * @return IL10N |
|
1478 | + */ |
|
1479 | + public function getL10N($app, $lang = null) { |
|
1480 | + return $this->getL10NFactory()->get($app, $lang); |
|
1481 | + } |
|
1482 | + |
|
1483 | + /** |
|
1484 | + * @return \OCP\IURLGenerator |
|
1485 | + */ |
|
1486 | + public function getURLGenerator() { |
|
1487 | + return $this->query('URLGenerator'); |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * @return AppFetcher |
|
1492 | + */ |
|
1493 | + public function getAppFetcher() { |
|
1494 | + return $this->query(AppFetcher::class); |
|
1495 | + } |
|
1496 | + |
|
1497 | + /** |
|
1498 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1499 | + * getMemCacheFactory() instead. |
|
1500 | + * |
|
1501 | + * @return \OCP\ICache |
|
1502 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1503 | + */ |
|
1504 | + public function getCache() { |
|
1505 | + return $this->query('UserCache'); |
|
1506 | + } |
|
1507 | + |
|
1508 | + /** |
|
1509 | + * Returns an \OCP\CacheFactory instance |
|
1510 | + * |
|
1511 | + * @return \OCP\ICacheFactory |
|
1512 | + */ |
|
1513 | + public function getMemCacheFactory() { |
|
1514 | + return $this->query('MemCacheFactory'); |
|
1515 | + } |
|
1516 | + |
|
1517 | + /** |
|
1518 | + * Returns an \OC\RedisFactory instance |
|
1519 | + * |
|
1520 | + * @return \OC\RedisFactory |
|
1521 | + */ |
|
1522 | + public function getGetRedisFactory() { |
|
1523 | + return $this->query('RedisFactory'); |
|
1524 | + } |
|
1525 | + |
|
1526 | + |
|
1527 | + /** |
|
1528 | + * Returns the current session |
|
1529 | + * |
|
1530 | + * @return \OCP\IDBConnection |
|
1531 | + */ |
|
1532 | + public function getDatabaseConnection() { |
|
1533 | + return $this->query('DatabaseConnection'); |
|
1534 | + } |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * Returns the activity manager |
|
1538 | + * |
|
1539 | + * @return \OCP\Activity\IManager |
|
1540 | + */ |
|
1541 | + public function getActivityManager() { |
|
1542 | + return $this->query('ActivityManager'); |
|
1543 | + } |
|
1544 | + |
|
1545 | + /** |
|
1546 | + * Returns an job list for controlling background jobs |
|
1547 | + * |
|
1548 | + * @return \OCP\BackgroundJob\IJobList |
|
1549 | + */ |
|
1550 | + public function getJobList() { |
|
1551 | + return $this->query('JobList'); |
|
1552 | + } |
|
1553 | + |
|
1554 | + /** |
|
1555 | + * Returns a logger instance |
|
1556 | + * |
|
1557 | + * @return \OCP\ILogger |
|
1558 | + */ |
|
1559 | + public function getLogger() { |
|
1560 | + return $this->query('Logger'); |
|
1561 | + } |
|
1562 | + |
|
1563 | + /** |
|
1564 | + * @return ILogFactory |
|
1565 | + * @throws \OCP\AppFramework\QueryException |
|
1566 | + */ |
|
1567 | + public function getLogFactory() { |
|
1568 | + return $this->query(ILogFactory::class); |
|
1569 | + } |
|
1570 | + |
|
1571 | + /** |
|
1572 | + * Returns a router for generating and matching urls |
|
1573 | + * |
|
1574 | + * @return \OCP\Route\IRouter |
|
1575 | + */ |
|
1576 | + public function getRouter() { |
|
1577 | + return $this->query('Router'); |
|
1578 | + } |
|
1579 | + |
|
1580 | + /** |
|
1581 | + * Returns a search instance |
|
1582 | + * |
|
1583 | + * @return \OCP\ISearch |
|
1584 | + */ |
|
1585 | + public function getSearch() { |
|
1586 | + return $this->query('Search'); |
|
1587 | + } |
|
1588 | + |
|
1589 | + /** |
|
1590 | + * Returns a SecureRandom instance |
|
1591 | + * |
|
1592 | + * @return \OCP\Security\ISecureRandom |
|
1593 | + */ |
|
1594 | + public function getSecureRandom() { |
|
1595 | + return $this->query('SecureRandom'); |
|
1596 | + } |
|
1597 | + |
|
1598 | + /** |
|
1599 | + * Returns a Crypto instance |
|
1600 | + * |
|
1601 | + * @return \OCP\Security\ICrypto |
|
1602 | + */ |
|
1603 | + public function getCrypto() { |
|
1604 | + return $this->query('Crypto'); |
|
1605 | + } |
|
1606 | + |
|
1607 | + /** |
|
1608 | + * Returns a Hasher instance |
|
1609 | + * |
|
1610 | + * @return \OCP\Security\IHasher |
|
1611 | + */ |
|
1612 | + public function getHasher() { |
|
1613 | + return $this->query('Hasher'); |
|
1614 | + } |
|
1615 | + |
|
1616 | + /** |
|
1617 | + * Returns a CredentialsManager instance |
|
1618 | + * |
|
1619 | + * @return \OCP\Security\ICredentialsManager |
|
1620 | + */ |
|
1621 | + public function getCredentialsManager() { |
|
1622 | + return $this->query('CredentialsManager'); |
|
1623 | + } |
|
1624 | + |
|
1625 | + /** |
|
1626 | + * Get the certificate manager for the user |
|
1627 | + * |
|
1628 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1629 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1630 | + */ |
|
1631 | + public function getCertificateManager($userId = '') { |
|
1632 | + if ($userId === '') { |
|
1633 | + $userSession = $this->getUserSession(); |
|
1634 | + $user = $userSession->getUser(); |
|
1635 | + if (is_null($user)) { |
|
1636 | + return null; |
|
1637 | + } |
|
1638 | + $userId = $user->getUID(); |
|
1639 | + } |
|
1640 | + return new CertificateManager( |
|
1641 | + $userId, |
|
1642 | + new View(), |
|
1643 | + $this->getConfig(), |
|
1644 | + $this->getLogger(), |
|
1645 | + $this->getSecureRandom() |
|
1646 | + ); |
|
1647 | + } |
|
1648 | + |
|
1649 | + /** |
|
1650 | + * Returns an instance of the HTTP client service |
|
1651 | + * |
|
1652 | + * @return \OCP\Http\Client\IClientService |
|
1653 | + */ |
|
1654 | + public function getHTTPClientService() { |
|
1655 | + return $this->query('HttpClientService'); |
|
1656 | + } |
|
1657 | + |
|
1658 | + /** |
|
1659 | + * Create a new event source |
|
1660 | + * |
|
1661 | + * @return \OCP\IEventSource |
|
1662 | + */ |
|
1663 | + public function createEventSource() { |
|
1664 | + return new \OC_EventSource(); |
|
1665 | + } |
|
1666 | + |
|
1667 | + /** |
|
1668 | + * Get the active event logger |
|
1669 | + * |
|
1670 | + * The returned logger only logs data when debug mode is enabled |
|
1671 | + * |
|
1672 | + * @return \OCP\Diagnostics\IEventLogger |
|
1673 | + */ |
|
1674 | + public function getEventLogger() { |
|
1675 | + return $this->query('EventLogger'); |
|
1676 | + } |
|
1677 | + |
|
1678 | + /** |
|
1679 | + * Get the active query logger |
|
1680 | + * |
|
1681 | + * The returned logger only logs data when debug mode is enabled |
|
1682 | + * |
|
1683 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1684 | + */ |
|
1685 | + public function getQueryLogger() { |
|
1686 | + return $this->query('QueryLogger'); |
|
1687 | + } |
|
1688 | + |
|
1689 | + /** |
|
1690 | + * Get the manager for temporary files and folders |
|
1691 | + * |
|
1692 | + * @return \OCP\ITempManager |
|
1693 | + */ |
|
1694 | + public function getTempManager() { |
|
1695 | + return $this->query('TempManager'); |
|
1696 | + } |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * Get the app manager |
|
1700 | + * |
|
1701 | + * @return \OCP\App\IAppManager |
|
1702 | + */ |
|
1703 | + public function getAppManager() { |
|
1704 | + return $this->query('AppManager'); |
|
1705 | + } |
|
1706 | + |
|
1707 | + /** |
|
1708 | + * Creates a new mailer |
|
1709 | + * |
|
1710 | + * @return \OCP\Mail\IMailer |
|
1711 | + */ |
|
1712 | + public function getMailer() { |
|
1713 | + return $this->query('Mailer'); |
|
1714 | + } |
|
1715 | + |
|
1716 | + /** |
|
1717 | + * Get the webroot |
|
1718 | + * |
|
1719 | + * @return string |
|
1720 | + */ |
|
1721 | + public function getWebRoot() { |
|
1722 | + return $this->webRoot; |
|
1723 | + } |
|
1724 | + |
|
1725 | + /** |
|
1726 | + * @return \OC\OCSClient |
|
1727 | + */ |
|
1728 | + public function getOcsClient() { |
|
1729 | + return $this->query('OcsClient'); |
|
1730 | + } |
|
1731 | + |
|
1732 | + /** |
|
1733 | + * @return \OCP\IDateTimeZone |
|
1734 | + */ |
|
1735 | + public function getDateTimeZone() { |
|
1736 | + return $this->query('DateTimeZone'); |
|
1737 | + } |
|
1738 | + |
|
1739 | + /** |
|
1740 | + * @return \OCP\IDateTimeFormatter |
|
1741 | + */ |
|
1742 | + public function getDateTimeFormatter() { |
|
1743 | + return $this->query('DateTimeFormatter'); |
|
1744 | + } |
|
1745 | + |
|
1746 | + /** |
|
1747 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1748 | + */ |
|
1749 | + public function getMountProviderCollection() { |
|
1750 | + return $this->query('MountConfigManager'); |
|
1751 | + } |
|
1752 | + |
|
1753 | + /** |
|
1754 | + * Get the IniWrapper |
|
1755 | + * |
|
1756 | + * @return IniGetWrapper |
|
1757 | + */ |
|
1758 | + public function getIniWrapper() { |
|
1759 | + return $this->query('IniWrapper'); |
|
1760 | + } |
|
1761 | + |
|
1762 | + /** |
|
1763 | + * @return \OCP\Command\IBus |
|
1764 | + */ |
|
1765 | + public function getCommandBus() { |
|
1766 | + return $this->query('AsyncCommandBus'); |
|
1767 | + } |
|
1768 | + |
|
1769 | + /** |
|
1770 | + * Get the trusted domain helper |
|
1771 | + * |
|
1772 | + * @return TrustedDomainHelper |
|
1773 | + */ |
|
1774 | + public function getTrustedDomainHelper() { |
|
1775 | + return $this->query('TrustedDomainHelper'); |
|
1776 | + } |
|
1777 | + |
|
1778 | + /** |
|
1779 | + * Get the locking provider |
|
1780 | + * |
|
1781 | + * @return \OCP\Lock\ILockingProvider |
|
1782 | + * @since 8.1.0 |
|
1783 | + */ |
|
1784 | + public function getLockingProvider() { |
|
1785 | + return $this->query('LockingProvider'); |
|
1786 | + } |
|
1787 | + |
|
1788 | + /** |
|
1789 | + * @return \OCP\Files\Mount\IMountManager |
|
1790 | + **/ |
|
1791 | + function getMountManager() { |
|
1792 | + return $this->query('MountManager'); |
|
1793 | + } |
|
1794 | + |
|
1795 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1796 | + function getUserMountCache() { |
|
1797 | + return $this->query('UserMountCache'); |
|
1798 | + } |
|
1799 | + |
|
1800 | + /** |
|
1801 | + * Get the MimeTypeDetector |
|
1802 | + * |
|
1803 | + * @return \OCP\Files\IMimeTypeDetector |
|
1804 | + */ |
|
1805 | + public function getMimeTypeDetector() { |
|
1806 | + return $this->query('MimeTypeDetector'); |
|
1807 | + } |
|
1808 | + |
|
1809 | + /** |
|
1810 | + * Get the MimeTypeLoader |
|
1811 | + * |
|
1812 | + * @return \OCP\Files\IMimeTypeLoader |
|
1813 | + */ |
|
1814 | + public function getMimeTypeLoader() { |
|
1815 | + return $this->query('MimeTypeLoader'); |
|
1816 | + } |
|
1817 | + |
|
1818 | + /** |
|
1819 | + * Get the manager of all the capabilities |
|
1820 | + * |
|
1821 | + * @return \OC\CapabilitiesManager |
|
1822 | + */ |
|
1823 | + public function getCapabilitiesManager() { |
|
1824 | + return $this->query('CapabilitiesManager'); |
|
1825 | + } |
|
1826 | + |
|
1827 | + /** |
|
1828 | + * Get the EventDispatcher |
|
1829 | + * |
|
1830 | + * @return EventDispatcherInterface |
|
1831 | + * @since 8.2.0 |
|
1832 | + */ |
|
1833 | + public function getEventDispatcher() { |
|
1834 | + return $this->query('EventDispatcher'); |
|
1835 | + } |
|
1836 | + |
|
1837 | + /** |
|
1838 | + * Get the Notification Manager |
|
1839 | + * |
|
1840 | + * @return \OCP\Notification\IManager |
|
1841 | + * @since 8.2.0 |
|
1842 | + */ |
|
1843 | + public function getNotificationManager() { |
|
1844 | + return $this->query('NotificationManager'); |
|
1845 | + } |
|
1846 | + |
|
1847 | + /** |
|
1848 | + * @return \OCP\Comments\ICommentsManager |
|
1849 | + */ |
|
1850 | + public function getCommentsManager() { |
|
1851 | + return $this->query('CommentsManager'); |
|
1852 | + } |
|
1853 | + |
|
1854 | + /** |
|
1855 | + * @return \OCA\Theming\ThemingDefaults |
|
1856 | + */ |
|
1857 | + public function getThemingDefaults() { |
|
1858 | + return $this->query('ThemingDefaults'); |
|
1859 | + } |
|
1860 | + |
|
1861 | + /** |
|
1862 | + * @return \OC\IntegrityCheck\Checker |
|
1863 | + */ |
|
1864 | + public function getIntegrityCodeChecker() { |
|
1865 | + return $this->query('IntegrityCodeChecker'); |
|
1866 | + } |
|
1867 | + |
|
1868 | + /** |
|
1869 | + * @return \OC\Session\CryptoWrapper |
|
1870 | + */ |
|
1871 | + public function getSessionCryptoWrapper() { |
|
1872 | + return $this->query('CryptoWrapper'); |
|
1873 | + } |
|
1874 | + |
|
1875 | + /** |
|
1876 | + * @return CsrfTokenManager |
|
1877 | + */ |
|
1878 | + public function getCsrfTokenManager() { |
|
1879 | + return $this->query('CsrfTokenManager'); |
|
1880 | + } |
|
1881 | + |
|
1882 | + /** |
|
1883 | + * @return Throttler |
|
1884 | + */ |
|
1885 | + public function getBruteForceThrottler() { |
|
1886 | + return $this->query('Throttler'); |
|
1887 | + } |
|
1888 | + |
|
1889 | + /** |
|
1890 | + * @return IContentSecurityPolicyManager |
|
1891 | + */ |
|
1892 | + public function getContentSecurityPolicyManager() { |
|
1893 | + return $this->query('ContentSecurityPolicyManager'); |
|
1894 | + } |
|
1895 | + |
|
1896 | + /** |
|
1897 | + * @return ContentSecurityPolicyNonceManager |
|
1898 | + */ |
|
1899 | + public function getContentSecurityPolicyNonceManager() { |
|
1900 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1901 | + } |
|
1902 | + |
|
1903 | + /** |
|
1904 | + * Not a public API as of 8.2, wait for 9.0 |
|
1905 | + * |
|
1906 | + * @return \OCA\Files_External\Service\BackendService |
|
1907 | + */ |
|
1908 | + public function getStoragesBackendService() { |
|
1909 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1910 | + } |
|
1911 | + |
|
1912 | + /** |
|
1913 | + * Not a public API as of 8.2, wait for 9.0 |
|
1914 | + * |
|
1915 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1916 | + */ |
|
1917 | + public function getGlobalStoragesService() { |
|
1918 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1919 | + } |
|
1920 | + |
|
1921 | + /** |
|
1922 | + * Not a public API as of 8.2, wait for 9.0 |
|
1923 | + * |
|
1924 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1925 | + */ |
|
1926 | + public function getUserGlobalStoragesService() { |
|
1927 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1928 | + } |
|
1929 | + |
|
1930 | + /** |
|
1931 | + * Not a public API as of 8.2, wait for 9.0 |
|
1932 | + * |
|
1933 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1934 | + */ |
|
1935 | + public function getUserStoragesService() { |
|
1936 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1937 | + } |
|
1938 | + |
|
1939 | + /** |
|
1940 | + * @return \OCP\Share\IManager |
|
1941 | + */ |
|
1942 | + public function getShareManager() { |
|
1943 | + return $this->query('ShareManager'); |
|
1944 | + } |
|
1945 | + |
|
1946 | + /** |
|
1947 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
1948 | + */ |
|
1949 | + public function getCollaboratorSearch() { |
|
1950 | + return $this->query('CollaboratorSearch'); |
|
1951 | + } |
|
1952 | + |
|
1953 | + /** |
|
1954 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
1955 | + */ |
|
1956 | + public function getAutoCompleteManager(){ |
|
1957 | + return $this->query(IManager::class); |
|
1958 | + } |
|
1959 | + |
|
1960 | + /** |
|
1961 | + * Returns the LDAP Provider |
|
1962 | + * |
|
1963 | + * @return \OCP\LDAP\ILDAPProvider |
|
1964 | + */ |
|
1965 | + public function getLDAPProvider() { |
|
1966 | + return $this->query('LDAPProvider'); |
|
1967 | + } |
|
1968 | + |
|
1969 | + /** |
|
1970 | + * @return \OCP\Settings\IManager |
|
1971 | + */ |
|
1972 | + public function getSettingsManager() { |
|
1973 | + return $this->query('SettingsManager'); |
|
1974 | + } |
|
1975 | + |
|
1976 | + /** |
|
1977 | + * @return \OCP\Files\IAppData |
|
1978 | + */ |
|
1979 | + public function getAppDataDir($app) { |
|
1980 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1981 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1982 | + return $factory->get($app); |
|
1983 | + } |
|
1984 | + |
|
1985 | + /** |
|
1986 | + * @return \OCP\Lockdown\ILockdownManager |
|
1987 | + */ |
|
1988 | + public function getLockdownManager() { |
|
1989 | + return $this->query('LockdownManager'); |
|
1990 | + } |
|
1991 | + |
|
1992 | + /** |
|
1993 | + * @return \OCP\Federation\ICloudIdManager |
|
1994 | + */ |
|
1995 | + public function getCloudIdManager() { |
|
1996 | + return $this->query(ICloudIdManager::class); |
|
1997 | + } |
|
1998 | + |
|
1999 | + /** |
|
2000 | + * @return \OCP\GlobalScale\IConfig |
|
2001 | + */ |
|
2002 | + public function getGlobalScaleConfig() { |
|
2003 | + return $this->query(IConfig::class); |
|
2004 | + } |
|
2005 | + |
|
2006 | + /** |
|
2007 | + * @return \OCP\Federation\ICloudFederationProviderManager |
|
2008 | + */ |
|
2009 | + public function getCloudFederationProviderManager() { |
|
2010 | + return $this->query(ICloudFederationProviderManager::class); |
|
2011 | + } |
|
2012 | + |
|
2013 | + /** |
|
2014 | + * @return \OCP\Remote\Api\IApiFactory |
|
2015 | + */ |
|
2016 | + public function getRemoteApiFactory() { |
|
2017 | + return $this->query(IApiFactory::class); |
|
2018 | + } |
|
2019 | + |
|
2020 | + /** |
|
2021 | + * @return \OCP\Federation\ICloudFederationFactory |
|
2022 | + */ |
|
2023 | + public function getCloudFederationFactory() { |
|
2024 | + return $this->query(ICloudFederationFactory::class); |
|
2025 | + } |
|
2026 | + |
|
2027 | + /** |
|
2028 | + * @return \OCP\Remote\IInstanceFactory |
|
2029 | + */ |
|
2030 | + public function getRemoteInstanceFactory() { |
|
2031 | + return $this->query(IInstanceFactory::class); |
|
2032 | + } |
|
2033 | + |
|
2034 | + /** |
|
2035 | + * @return IStorageFactory |
|
2036 | + */ |
|
2037 | + public function getStorageFactory() { |
|
2038 | + return $this->query(IStorageFactory::class); |
|
2039 | + } |
|
2040 | 2040 | } |
@@ -71,848 +71,848 @@ |
||
71 | 71 | |
72 | 72 | class Filesystem { |
73 | 73 | |
74 | - /** |
|
75 | - * @var Mount\Manager $mounts |
|
76 | - */ |
|
77 | - private static $mounts; |
|
78 | - |
|
79 | - public static $loaded = false; |
|
80 | - /** |
|
81 | - * @var \OC\Files\View $defaultInstance |
|
82 | - */ |
|
83 | - static private $defaultInstance; |
|
84 | - |
|
85 | - static private $usersSetup = array(); |
|
86 | - |
|
87 | - static private $normalizedPathCache = null; |
|
88 | - |
|
89 | - static private $listeningForProviders = false; |
|
90 | - |
|
91 | - /** |
|
92 | - * classname which used for hooks handling |
|
93 | - * used as signalclass in OC_Hooks::emit() |
|
94 | - */ |
|
95 | - const CLASSNAME = 'OC_Filesystem'; |
|
96 | - |
|
97 | - /** |
|
98 | - * signalname emitted before file renaming |
|
99 | - * |
|
100 | - * @param string $oldpath |
|
101 | - * @param string $newpath |
|
102 | - */ |
|
103 | - const signal_rename = 'rename'; |
|
104 | - |
|
105 | - /** |
|
106 | - * signal emitted after file renaming |
|
107 | - * |
|
108 | - * @param string $oldpath |
|
109 | - * @param string $newpath |
|
110 | - */ |
|
111 | - const signal_post_rename = 'post_rename'; |
|
112 | - |
|
113 | - /** |
|
114 | - * signal emitted before file/dir creation |
|
115 | - * |
|
116 | - * @param string $path |
|
117 | - * @param bool $run changing this flag to false in hook handler will cancel event |
|
118 | - */ |
|
119 | - const signal_create = 'create'; |
|
120 | - |
|
121 | - /** |
|
122 | - * signal emitted after file/dir creation |
|
123 | - * |
|
124 | - * @param string $path |
|
125 | - * @param bool $run changing this flag to false in hook handler will cancel event |
|
126 | - */ |
|
127 | - const signal_post_create = 'post_create'; |
|
128 | - |
|
129 | - /** |
|
130 | - * signal emits before file/dir copy |
|
131 | - * |
|
132 | - * @param string $oldpath |
|
133 | - * @param string $newpath |
|
134 | - * @param bool $run changing this flag to false in hook handler will cancel event |
|
135 | - */ |
|
136 | - const signal_copy = 'copy'; |
|
137 | - |
|
138 | - /** |
|
139 | - * signal emits after file/dir copy |
|
140 | - * |
|
141 | - * @param string $oldpath |
|
142 | - * @param string $newpath |
|
143 | - */ |
|
144 | - const signal_post_copy = 'post_copy'; |
|
145 | - |
|
146 | - /** |
|
147 | - * signal emits before file/dir save |
|
148 | - * |
|
149 | - * @param string $path |
|
150 | - * @param bool $run changing this flag to false in hook handler will cancel event |
|
151 | - */ |
|
152 | - const signal_write = 'write'; |
|
153 | - |
|
154 | - /** |
|
155 | - * signal emits after file/dir save |
|
156 | - * |
|
157 | - * @param string $path |
|
158 | - */ |
|
159 | - const signal_post_write = 'post_write'; |
|
160 | - |
|
161 | - /** |
|
162 | - * signal emitted before file/dir update |
|
163 | - * |
|
164 | - * @param string $path |
|
165 | - * @param bool $run changing this flag to false in hook handler will cancel event |
|
166 | - */ |
|
167 | - const signal_update = 'update'; |
|
168 | - |
|
169 | - /** |
|
170 | - * signal emitted after file/dir update |
|
171 | - * |
|
172 | - * @param string $path |
|
173 | - * @param bool $run changing this flag to false in hook handler will cancel event |
|
174 | - */ |
|
175 | - const signal_post_update = 'post_update'; |
|
176 | - |
|
177 | - /** |
|
178 | - * signal emits when reading file/dir |
|
179 | - * |
|
180 | - * @param string $path |
|
181 | - */ |
|
182 | - const signal_read = 'read'; |
|
183 | - |
|
184 | - /** |
|
185 | - * signal emits when removing file/dir |
|
186 | - * |
|
187 | - * @param string $path |
|
188 | - */ |
|
189 | - const signal_delete = 'delete'; |
|
190 | - |
|
191 | - /** |
|
192 | - * parameters definitions for signals |
|
193 | - */ |
|
194 | - const signal_param_path = 'path'; |
|
195 | - const signal_param_oldpath = 'oldpath'; |
|
196 | - const signal_param_newpath = 'newpath'; |
|
197 | - |
|
198 | - /** |
|
199 | - * run - changing this flag to false in hook handler will cancel event |
|
200 | - */ |
|
201 | - const signal_param_run = 'run'; |
|
202 | - |
|
203 | - const signal_create_mount = 'create_mount'; |
|
204 | - const signal_delete_mount = 'delete_mount'; |
|
205 | - const signal_param_mount_type = 'mounttype'; |
|
206 | - const signal_param_users = 'users'; |
|
207 | - |
|
208 | - /** |
|
209 | - * @var \OC\Files\Storage\StorageFactory $loader |
|
210 | - */ |
|
211 | - private static $loader; |
|
212 | - |
|
213 | - /** @var bool */ |
|
214 | - private static $logWarningWhenAddingStorageWrapper = true; |
|
215 | - |
|
216 | - /** |
|
217 | - * @param bool $shouldLog |
|
218 | - * @return bool previous value |
|
219 | - * @internal |
|
220 | - */ |
|
221 | - public static function logWarningWhenAddingStorageWrapper($shouldLog) { |
|
222 | - $previousValue = self::$logWarningWhenAddingStorageWrapper; |
|
223 | - self::$logWarningWhenAddingStorageWrapper = (bool) $shouldLog; |
|
224 | - return $previousValue; |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * @param string $wrapperName |
|
229 | - * @param callable $wrapper |
|
230 | - * @param int $priority |
|
231 | - */ |
|
232 | - public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) { |
|
233 | - if (self::$logWarningWhenAddingStorageWrapper) { |
|
234 | - \OC::$server->getLogger()->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [ |
|
235 | - 'wrapper' => $wrapperName, |
|
236 | - 'app' => 'filesystem', |
|
237 | - ]); |
|
238 | - } |
|
239 | - |
|
240 | - $mounts = self::getMountManager()->getAll(); |
|
241 | - if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper, $priority, $mounts)) { |
|
242 | - // do not re-wrap if storage with this name already existed |
|
243 | - return; |
|
244 | - } |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Returns the storage factory |
|
249 | - * |
|
250 | - * @return IStorageFactory |
|
251 | - */ |
|
252 | - public static function getLoader() { |
|
253 | - if (!self::$loader) { |
|
254 | - self::$loader = \OC::$server->query(IStorageFactory::class); |
|
255 | - } |
|
256 | - return self::$loader; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Returns the mount manager |
|
261 | - * |
|
262 | - * @return \OC\Files\Mount\Manager |
|
263 | - */ |
|
264 | - public static function getMountManager($user = '') { |
|
265 | - if (!self::$mounts) { |
|
266 | - \OC_Util::setupFS($user); |
|
267 | - } |
|
268 | - return self::$mounts; |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * get the mountpoint of the storage object for a path |
|
273 | - * ( note: because a storage is not always mounted inside the fakeroot, the |
|
274 | - * returned mountpoint is relative to the absolute root of the filesystem |
|
275 | - * and doesn't take the chroot into account ) |
|
276 | - * |
|
277 | - * @param string $path |
|
278 | - * @return string |
|
279 | - */ |
|
280 | - static public function getMountPoint($path) { |
|
281 | - if (!self::$mounts) { |
|
282 | - \OC_Util::setupFS(); |
|
283 | - } |
|
284 | - $mount = self::$mounts->find($path); |
|
285 | - if ($mount) { |
|
286 | - return $mount->getMountPoint(); |
|
287 | - } else { |
|
288 | - return ''; |
|
289 | - } |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * get a list of all mount points in a directory |
|
294 | - * |
|
295 | - * @param string $path |
|
296 | - * @return string[] |
|
297 | - */ |
|
298 | - static public function getMountPoints($path) { |
|
299 | - if (!self::$mounts) { |
|
300 | - \OC_Util::setupFS(); |
|
301 | - } |
|
302 | - $result = array(); |
|
303 | - $mounts = self::$mounts->findIn($path); |
|
304 | - foreach ($mounts as $mount) { |
|
305 | - $result[] = $mount->getMountPoint(); |
|
306 | - } |
|
307 | - return $result; |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * get the storage mounted at $mountPoint |
|
312 | - * |
|
313 | - * @param string $mountPoint |
|
314 | - * @return \OC\Files\Storage\Storage |
|
315 | - */ |
|
316 | - public static function getStorage($mountPoint) { |
|
317 | - if (!self::$mounts) { |
|
318 | - \OC_Util::setupFS(); |
|
319 | - } |
|
320 | - $mount = self::$mounts->find($mountPoint); |
|
321 | - return $mount->getStorage(); |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * @param string $id |
|
326 | - * @return Mount\MountPoint[] |
|
327 | - */ |
|
328 | - public static function getMountByStorageId($id) { |
|
329 | - if (!self::$mounts) { |
|
330 | - \OC_Util::setupFS(); |
|
331 | - } |
|
332 | - return self::$mounts->findByStorageId($id); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * @param int $id |
|
337 | - * @return Mount\MountPoint[] |
|
338 | - */ |
|
339 | - public static function getMountByNumericId($id) { |
|
340 | - if (!self::$mounts) { |
|
341 | - \OC_Util::setupFS(); |
|
342 | - } |
|
343 | - return self::$mounts->findByNumericId($id); |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * resolve a path to a storage and internal path |
|
348 | - * |
|
349 | - * @param string $path |
|
350 | - * @return array an array consisting of the storage and the internal path |
|
351 | - */ |
|
352 | - static public function resolvePath($path) { |
|
353 | - if (!self::$mounts) { |
|
354 | - \OC_Util::setupFS(); |
|
355 | - } |
|
356 | - $mount = self::$mounts->find($path); |
|
357 | - if ($mount) { |
|
358 | - return array($mount->getStorage(), rtrim($mount->getInternalPath($path), '/')); |
|
359 | - } else { |
|
360 | - return array(null, null); |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - static public function init($user, $root) { |
|
365 | - if (self::$defaultInstance) { |
|
366 | - return false; |
|
367 | - } |
|
368 | - self::getLoader(); |
|
369 | - self::$defaultInstance = new View($root); |
|
370 | - |
|
371 | - if (!self::$mounts) { |
|
372 | - self::$mounts = \OC::$server->getMountManager(); |
|
373 | - } |
|
374 | - |
|
375 | - //load custom mount config |
|
376 | - self::initMountPoints($user); |
|
377 | - |
|
378 | - self::$loaded = true; |
|
379 | - |
|
380 | - return true; |
|
381 | - } |
|
382 | - |
|
383 | - static public function initMountManager() { |
|
384 | - if (!self::$mounts) { |
|
385 | - self::$mounts = \OC::$server->getMountManager(); |
|
386 | - } |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * Initialize system and personal mount points for a user |
|
391 | - * |
|
392 | - * @param string $user |
|
393 | - * @throws \OC\User\NoUserException if the user is not available |
|
394 | - */ |
|
395 | - public static function initMountPoints($user = '') { |
|
396 | - if ($user == '') { |
|
397 | - $user = \OC_User::getUser(); |
|
398 | - } |
|
399 | - if ($user === null || $user === false || $user === '') { |
|
400 | - throw new \OC\User\NoUserException('Attempted to initialize mount points for null user and no user in session'); |
|
401 | - } |
|
402 | - |
|
403 | - if (isset(self::$usersSetup[$user])) { |
|
404 | - return; |
|
405 | - } |
|
406 | - |
|
407 | - self::$usersSetup[$user] = true; |
|
408 | - |
|
409 | - $userManager = \OC::$server->getUserManager(); |
|
410 | - $userObject = $userManager->get($user); |
|
411 | - |
|
412 | - if (is_null($userObject)) { |
|
413 | - \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, ILogger::ERROR); |
|
414 | - // reset flag, this will make it possible to rethrow the exception if called again |
|
415 | - unset(self::$usersSetup[$user]); |
|
416 | - throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); |
|
417 | - } |
|
418 | - |
|
419 | - $realUid = $userObject->getUID(); |
|
420 | - // workaround in case of different casings |
|
421 | - if ($user !== $realUid) { |
|
422 | - $stack = json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 50)); |
|
423 | - \OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, ILogger::WARN); |
|
424 | - $user = $realUid; |
|
425 | - |
|
426 | - // again with the correct casing |
|
427 | - if (isset(self::$usersSetup[$user])) { |
|
428 | - return; |
|
429 | - } |
|
430 | - |
|
431 | - self::$usersSetup[$user] = true; |
|
432 | - } |
|
433 | - |
|
434 | - if (\OC::$server->getLockdownManager()->canAccessFilesystem()) { |
|
435 | - /** @var \OC\Files\Config\MountProviderCollection $mountConfigManager */ |
|
436 | - $mountConfigManager = \OC::$server->getMountProviderCollection(); |
|
437 | - |
|
438 | - // home mounts are handled seperate since we need to ensure this is mounted before we call the other mount providers |
|
439 | - $homeMount = $mountConfigManager->getHomeMountForUser($userObject); |
|
440 | - |
|
441 | - self::getMountManager()->addMount($homeMount); |
|
442 | - |
|
443 | - \OC\Files\Filesystem::getStorage($user); |
|
444 | - |
|
445 | - // Chance to mount for other storages |
|
446 | - if ($userObject) { |
|
447 | - $mounts = $mountConfigManager->addMountForUser($userObject, self::getMountManager()); |
|
448 | - $mounts[] = $homeMount; |
|
449 | - $mountConfigManager->registerMounts($userObject, $mounts); |
|
450 | - } |
|
451 | - |
|
452 | - self::listenForNewMountProviders($mountConfigManager, $userManager); |
|
453 | - } else { |
|
454 | - self::getMountManager()->addMount(new MountPoint( |
|
455 | - new NullStorage([]), |
|
456 | - '/' . $user |
|
457 | - )); |
|
458 | - self::getMountManager()->addMount(new MountPoint( |
|
459 | - new NullStorage([]), |
|
460 | - '/' . $user . '/files' |
|
461 | - )); |
|
462 | - } |
|
463 | - \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', array('user' => $user)); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Get mounts from mount providers that are registered after setup |
|
468 | - * |
|
469 | - * @param MountProviderCollection $mountConfigManager |
|
470 | - * @param IUserManager $userManager |
|
471 | - */ |
|
472 | - private static function listenForNewMountProviders(MountProviderCollection $mountConfigManager, IUserManager $userManager) { |
|
473 | - if (!self::$listeningForProviders) { |
|
474 | - self::$listeningForProviders = true; |
|
475 | - $mountConfigManager->listen('\OC\Files\Config', 'registerMountProvider', function (IMountProvider $provider) use ($userManager) { |
|
476 | - foreach (Filesystem::$usersSetup as $user => $setup) { |
|
477 | - $userObject = $userManager->get($user); |
|
478 | - if ($userObject) { |
|
479 | - $mounts = $provider->getMountsForUser($userObject, Filesystem::getLoader()); |
|
480 | - array_walk($mounts, array(self::$mounts, 'addMount')); |
|
481 | - } |
|
482 | - } |
|
483 | - }); |
|
484 | - } |
|
485 | - } |
|
486 | - |
|
487 | - /** |
|
488 | - * get the default filesystem view |
|
489 | - * |
|
490 | - * @return View |
|
491 | - */ |
|
492 | - static public function getView() { |
|
493 | - return self::$defaultInstance; |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * tear down the filesystem, removing all storage providers |
|
498 | - */ |
|
499 | - static public function tearDown() { |
|
500 | - self::clearMounts(); |
|
501 | - self::$defaultInstance = null; |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
505 | - * get the relative path of the root data directory for the current user |
|
506 | - * |
|
507 | - * @return string |
|
508 | - * |
|
509 | - * Returns path like /admin/files |
|
510 | - */ |
|
511 | - static public function getRoot() { |
|
512 | - if (!self::$defaultInstance) { |
|
513 | - return null; |
|
514 | - } |
|
515 | - return self::$defaultInstance->getRoot(); |
|
516 | - } |
|
517 | - |
|
518 | - /** |
|
519 | - * clear all mounts and storage backends |
|
520 | - */ |
|
521 | - public static function clearMounts() { |
|
522 | - if (self::$mounts) { |
|
523 | - self::$usersSetup = array(); |
|
524 | - self::$mounts->clear(); |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - /** |
|
529 | - * mount an \OC\Files\Storage\Storage in our virtual filesystem |
|
530 | - * |
|
531 | - * @param \OC\Files\Storage\Storage|string $class |
|
532 | - * @param array $arguments |
|
533 | - * @param string $mountpoint |
|
534 | - */ |
|
535 | - static public function mount($class, $arguments, $mountpoint) { |
|
536 | - if (!self::$mounts) { |
|
537 | - \OC_Util::setupFS(); |
|
538 | - } |
|
539 | - $mount = new Mount\MountPoint($class, $mountpoint, $arguments, self::getLoader()); |
|
540 | - self::$mounts->addMount($mount); |
|
541 | - } |
|
542 | - |
|
543 | - /** |
|
544 | - * return the path to a local version of the file |
|
545 | - * we need this because we can't know if a file is stored local or not from |
|
546 | - * outside the filestorage and for some purposes a local file is needed |
|
547 | - * |
|
548 | - * @param string $path |
|
549 | - * @return string |
|
550 | - */ |
|
551 | - static public function getLocalFile($path) { |
|
552 | - return self::$defaultInstance->getLocalFile($path); |
|
553 | - } |
|
554 | - |
|
555 | - /** |
|
556 | - * @param string $path |
|
557 | - * @return string |
|
558 | - */ |
|
559 | - static public function getLocalFolder($path) { |
|
560 | - return self::$defaultInstance->getLocalFolder($path); |
|
561 | - } |
|
562 | - |
|
563 | - /** |
|
564 | - * return path to file which reflects one visible in browser |
|
565 | - * |
|
566 | - * @param string $path |
|
567 | - * @return string |
|
568 | - */ |
|
569 | - static public function getLocalPath($path) { |
|
570 | - $datadir = \OC_User::getHome(\OC_User::getUser()) . '/files'; |
|
571 | - $newpath = $path; |
|
572 | - if (strncmp($newpath, $datadir, strlen($datadir)) == 0) { |
|
573 | - $newpath = substr($path, strlen($datadir)); |
|
574 | - } |
|
575 | - return $newpath; |
|
576 | - } |
|
577 | - |
|
578 | - /** |
|
579 | - * check if the requested path is valid |
|
580 | - * |
|
581 | - * @param string $path |
|
582 | - * @return bool |
|
583 | - */ |
|
584 | - static public function isValidPath($path) { |
|
585 | - $path = self::normalizePath($path); |
|
586 | - if (!$path || $path[0] !== '/') { |
|
587 | - $path = '/' . $path; |
|
588 | - } |
|
589 | - if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') { |
|
590 | - return false; |
|
591 | - } |
|
592 | - return true; |
|
593 | - } |
|
594 | - |
|
595 | - /** |
|
596 | - * checks if a file is blacklisted for storage in the filesystem |
|
597 | - * Listens to write and rename hooks |
|
598 | - * |
|
599 | - * @param array $data from hook |
|
600 | - */ |
|
601 | - static public function isBlacklisted($data) { |
|
602 | - if (isset($data['path'])) { |
|
603 | - $path = $data['path']; |
|
604 | - } else if (isset($data['newpath'])) { |
|
605 | - $path = $data['newpath']; |
|
606 | - } |
|
607 | - if (isset($path)) { |
|
608 | - if (self::isFileBlacklisted($path)) { |
|
609 | - $data['run'] = false; |
|
610 | - } |
|
611 | - } |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * @param string $filename |
|
616 | - * @return bool |
|
617 | - */ |
|
618 | - static public function isFileBlacklisted($filename) { |
|
619 | - $filename = self::normalizePath($filename); |
|
620 | - |
|
621 | - $blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', array('.htaccess')); |
|
622 | - $filename = strtolower(basename($filename)); |
|
623 | - return in_array($filename, $blacklist); |
|
624 | - } |
|
625 | - |
|
626 | - /** |
|
627 | - * check if the directory should be ignored when scanning |
|
628 | - * NOTE: the special directories . and .. would cause never ending recursion |
|
629 | - * |
|
630 | - * @param String $dir |
|
631 | - * @return boolean |
|
632 | - */ |
|
633 | - static public function isIgnoredDir($dir) { |
|
634 | - if ($dir === '.' || $dir === '..') { |
|
635 | - return true; |
|
636 | - } |
|
637 | - return false; |
|
638 | - } |
|
639 | - |
|
640 | - /** |
|
641 | - * following functions are equivalent to their php builtin equivalents for arguments/return values. |
|
642 | - */ |
|
643 | - static public function mkdir($path) { |
|
644 | - return self::$defaultInstance->mkdir($path); |
|
645 | - } |
|
646 | - |
|
647 | - static public function rmdir($path) { |
|
648 | - return self::$defaultInstance->rmdir($path); |
|
649 | - } |
|
650 | - |
|
651 | - static public function is_dir($path) { |
|
652 | - return self::$defaultInstance->is_dir($path); |
|
653 | - } |
|
654 | - |
|
655 | - static public function is_file($path) { |
|
656 | - return self::$defaultInstance->is_file($path); |
|
657 | - } |
|
658 | - |
|
659 | - static public function stat($path) { |
|
660 | - return self::$defaultInstance->stat($path); |
|
661 | - } |
|
662 | - |
|
663 | - static public function filetype($path) { |
|
664 | - return self::$defaultInstance->filetype($path); |
|
665 | - } |
|
666 | - |
|
667 | - static public function filesize($path) { |
|
668 | - return self::$defaultInstance->filesize($path); |
|
669 | - } |
|
670 | - |
|
671 | - static public function readfile($path) { |
|
672 | - return self::$defaultInstance->readfile($path); |
|
673 | - } |
|
674 | - |
|
675 | - static public function isCreatable($path) { |
|
676 | - return self::$defaultInstance->isCreatable($path); |
|
677 | - } |
|
678 | - |
|
679 | - static public function isReadable($path) { |
|
680 | - return self::$defaultInstance->isReadable($path); |
|
681 | - } |
|
682 | - |
|
683 | - static public function isUpdatable($path) { |
|
684 | - return self::$defaultInstance->isUpdatable($path); |
|
685 | - } |
|
686 | - |
|
687 | - static public function isDeletable($path) { |
|
688 | - return self::$defaultInstance->isDeletable($path); |
|
689 | - } |
|
690 | - |
|
691 | - static public function isSharable($path) { |
|
692 | - return self::$defaultInstance->isSharable($path); |
|
693 | - } |
|
694 | - |
|
695 | - static public function file_exists($path) { |
|
696 | - return self::$defaultInstance->file_exists($path); |
|
697 | - } |
|
698 | - |
|
699 | - static public function filemtime($path) { |
|
700 | - return self::$defaultInstance->filemtime($path); |
|
701 | - } |
|
702 | - |
|
703 | - static public function touch($path, $mtime = null) { |
|
704 | - return self::$defaultInstance->touch($path, $mtime); |
|
705 | - } |
|
706 | - |
|
707 | - /** |
|
708 | - * @return string |
|
709 | - */ |
|
710 | - static public function file_get_contents($path) { |
|
711 | - return self::$defaultInstance->file_get_contents($path); |
|
712 | - } |
|
713 | - |
|
714 | - static public function file_put_contents($path, $data) { |
|
715 | - return self::$defaultInstance->file_put_contents($path, $data); |
|
716 | - } |
|
717 | - |
|
718 | - static public function unlink($path) { |
|
719 | - return self::$defaultInstance->unlink($path); |
|
720 | - } |
|
721 | - |
|
722 | - static public function rename($path1, $path2) { |
|
723 | - return self::$defaultInstance->rename($path1, $path2); |
|
724 | - } |
|
725 | - |
|
726 | - static public function copy($path1, $path2) { |
|
727 | - return self::$defaultInstance->copy($path1, $path2); |
|
728 | - } |
|
729 | - |
|
730 | - static public function fopen($path, $mode) { |
|
731 | - return self::$defaultInstance->fopen($path, $mode); |
|
732 | - } |
|
733 | - |
|
734 | - /** |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - static public function toTmpFile($path) { |
|
738 | - return self::$defaultInstance->toTmpFile($path); |
|
739 | - } |
|
740 | - |
|
741 | - static public function fromTmpFile($tmpFile, $path) { |
|
742 | - return self::$defaultInstance->fromTmpFile($tmpFile, $path); |
|
743 | - } |
|
744 | - |
|
745 | - static public function getMimeType($path) { |
|
746 | - return self::$defaultInstance->getMimeType($path); |
|
747 | - } |
|
748 | - |
|
749 | - static public function hash($type, $path, $raw = false) { |
|
750 | - return self::$defaultInstance->hash($type, $path, $raw); |
|
751 | - } |
|
752 | - |
|
753 | - static public function free_space($path = '/') { |
|
754 | - return self::$defaultInstance->free_space($path); |
|
755 | - } |
|
756 | - |
|
757 | - static public function search($query) { |
|
758 | - return self::$defaultInstance->search($query); |
|
759 | - } |
|
760 | - |
|
761 | - /** |
|
762 | - * @param string $query |
|
763 | - */ |
|
764 | - static public function searchByMime($query) { |
|
765 | - return self::$defaultInstance->searchByMime($query); |
|
766 | - } |
|
767 | - |
|
768 | - /** |
|
769 | - * @param string|int $tag name or tag id |
|
770 | - * @param string $userId owner of the tags |
|
771 | - * @return FileInfo[] array or file info |
|
772 | - */ |
|
773 | - static public function searchByTag($tag, $userId) { |
|
774 | - return self::$defaultInstance->searchByTag($tag, $userId); |
|
775 | - } |
|
776 | - |
|
777 | - /** |
|
778 | - * check if a file or folder has been updated since $time |
|
779 | - * |
|
780 | - * @param string $path |
|
781 | - * @param int $time |
|
782 | - * @return bool |
|
783 | - */ |
|
784 | - static public function hasUpdated($path, $time) { |
|
785 | - return self::$defaultInstance->hasUpdated($path, $time); |
|
786 | - } |
|
787 | - |
|
788 | - /** |
|
789 | - * Fix common problems with a file path |
|
790 | - * |
|
791 | - * @param string $path |
|
792 | - * @param bool $stripTrailingSlash whether to strip the trailing slash |
|
793 | - * @param bool $isAbsolutePath whether the given path is absolute |
|
794 | - * @param bool $keepUnicode true to disable unicode normalization |
|
795 | - * @return string |
|
796 | - */ |
|
797 | - public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) { |
|
798 | - if (is_null(self::$normalizedPathCache)) { |
|
799 | - self::$normalizedPathCache = new CappedMemoryCache(2048); |
|
800 | - } |
|
801 | - |
|
802 | - /** |
|
803 | - * FIXME: This is a workaround for existing classes and files which call |
|
804 | - * this function with another type than a valid string. This |
|
805 | - * conversion should get removed as soon as all existing |
|
806 | - * function calls have been fixed. |
|
807 | - */ |
|
808 | - $path = (string)$path; |
|
809 | - |
|
810 | - $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]); |
|
811 | - |
|
812 | - if (isset(self::$normalizedPathCache[$cacheKey])) { |
|
813 | - return self::$normalizedPathCache[$cacheKey]; |
|
814 | - } |
|
815 | - |
|
816 | - if ($path === '') { |
|
817 | - return '/'; |
|
818 | - } |
|
819 | - |
|
820 | - //normalize unicode if possible |
|
821 | - if (!$keepUnicode) { |
|
822 | - $path = \OC_Util::normalizeUnicode($path); |
|
823 | - } |
|
824 | - |
|
825 | - //add leading slash, if it is already there we strip it anyway |
|
826 | - $path = '/' . $path; |
|
827 | - |
|
828 | - $patterns = [ |
|
829 | - '/\\\\/s', // no windows style slashes |
|
830 | - '/\/\.(\/\.)?\//s', // remove '/./' |
|
831 | - '/\/{2,}/s', // remove squence of slashes |
|
832 | - '/\/\.$/s', // remove trailing /. |
|
833 | - ]; |
|
834 | - |
|
835 | - do { |
|
836 | - $count = 0; |
|
837 | - $path = preg_replace($patterns, '/', $path, -1, $count); |
|
838 | - } while ($count > 0); |
|
839 | - |
|
840 | - //remove trailing slash |
|
841 | - if ($stripTrailingSlash && strlen($path) > 1) { |
|
842 | - $path = rtrim($path, '/'); |
|
843 | - } |
|
844 | - |
|
845 | - self::$normalizedPathCache[$cacheKey] = $path; |
|
846 | - |
|
847 | - return $path; |
|
848 | - } |
|
849 | - |
|
850 | - /** |
|
851 | - * get the filesystem info |
|
852 | - * |
|
853 | - * @param string $path |
|
854 | - * @param boolean $includeMountPoints whether to add mountpoint sizes, |
|
855 | - * defaults to true |
|
856 | - * @return \OC\Files\FileInfo|bool False if file does not exist |
|
857 | - */ |
|
858 | - public static function getFileInfo($path, $includeMountPoints = true) { |
|
859 | - return self::$defaultInstance->getFileInfo($path, $includeMountPoints); |
|
860 | - } |
|
861 | - |
|
862 | - /** |
|
863 | - * change file metadata |
|
864 | - * |
|
865 | - * @param string $path |
|
866 | - * @param array $data |
|
867 | - * @return int |
|
868 | - * |
|
869 | - * returns the fileid of the updated file |
|
870 | - */ |
|
871 | - public static function putFileInfo($path, $data) { |
|
872 | - return self::$defaultInstance->putFileInfo($path, $data); |
|
873 | - } |
|
874 | - |
|
875 | - /** |
|
876 | - * get the content of a directory |
|
877 | - * |
|
878 | - * @param string $directory path under datadirectory |
|
879 | - * @param string $mimetype_filter limit returned content to this mimetype or mimepart |
|
880 | - * @return \OC\Files\FileInfo[] |
|
881 | - */ |
|
882 | - public static function getDirectoryContent($directory, $mimetype_filter = '') { |
|
883 | - return self::$defaultInstance->getDirectoryContent($directory, $mimetype_filter); |
|
884 | - } |
|
885 | - |
|
886 | - /** |
|
887 | - * Get the path of a file by id |
|
888 | - * |
|
889 | - * Note that the resulting path is not guaranteed to be unique for the id, multiple paths can point to the same file |
|
890 | - * |
|
891 | - * @param int $id |
|
892 | - * @throws NotFoundException |
|
893 | - * @return string |
|
894 | - */ |
|
895 | - public static function getPath($id) { |
|
896 | - return self::$defaultInstance->getPath($id); |
|
897 | - } |
|
898 | - |
|
899 | - /** |
|
900 | - * Get the owner for a file or folder |
|
901 | - * |
|
902 | - * @param string $path |
|
903 | - * @return string |
|
904 | - */ |
|
905 | - public static function getOwner($path) { |
|
906 | - return self::$defaultInstance->getOwner($path); |
|
907 | - } |
|
908 | - |
|
909 | - /** |
|
910 | - * get the ETag for a file or folder |
|
911 | - * |
|
912 | - * @param string $path |
|
913 | - * @return string |
|
914 | - */ |
|
915 | - static public function getETag($path) { |
|
916 | - return self::$defaultInstance->getETag($path); |
|
917 | - } |
|
74 | + /** |
|
75 | + * @var Mount\Manager $mounts |
|
76 | + */ |
|
77 | + private static $mounts; |
|
78 | + |
|
79 | + public static $loaded = false; |
|
80 | + /** |
|
81 | + * @var \OC\Files\View $defaultInstance |
|
82 | + */ |
|
83 | + static private $defaultInstance; |
|
84 | + |
|
85 | + static private $usersSetup = array(); |
|
86 | + |
|
87 | + static private $normalizedPathCache = null; |
|
88 | + |
|
89 | + static private $listeningForProviders = false; |
|
90 | + |
|
91 | + /** |
|
92 | + * classname which used for hooks handling |
|
93 | + * used as signalclass in OC_Hooks::emit() |
|
94 | + */ |
|
95 | + const CLASSNAME = 'OC_Filesystem'; |
|
96 | + |
|
97 | + /** |
|
98 | + * signalname emitted before file renaming |
|
99 | + * |
|
100 | + * @param string $oldpath |
|
101 | + * @param string $newpath |
|
102 | + */ |
|
103 | + const signal_rename = 'rename'; |
|
104 | + |
|
105 | + /** |
|
106 | + * signal emitted after file renaming |
|
107 | + * |
|
108 | + * @param string $oldpath |
|
109 | + * @param string $newpath |
|
110 | + */ |
|
111 | + const signal_post_rename = 'post_rename'; |
|
112 | + |
|
113 | + /** |
|
114 | + * signal emitted before file/dir creation |
|
115 | + * |
|
116 | + * @param string $path |
|
117 | + * @param bool $run changing this flag to false in hook handler will cancel event |
|
118 | + */ |
|
119 | + const signal_create = 'create'; |
|
120 | + |
|
121 | + /** |
|
122 | + * signal emitted after file/dir creation |
|
123 | + * |
|
124 | + * @param string $path |
|
125 | + * @param bool $run changing this flag to false in hook handler will cancel event |
|
126 | + */ |
|
127 | + const signal_post_create = 'post_create'; |
|
128 | + |
|
129 | + /** |
|
130 | + * signal emits before file/dir copy |
|
131 | + * |
|
132 | + * @param string $oldpath |
|
133 | + * @param string $newpath |
|
134 | + * @param bool $run changing this flag to false in hook handler will cancel event |
|
135 | + */ |
|
136 | + const signal_copy = 'copy'; |
|
137 | + |
|
138 | + /** |
|
139 | + * signal emits after file/dir copy |
|
140 | + * |
|
141 | + * @param string $oldpath |
|
142 | + * @param string $newpath |
|
143 | + */ |
|
144 | + const signal_post_copy = 'post_copy'; |
|
145 | + |
|
146 | + /** |
|
147 | + * signal emits before file/dir save |
|
148 | + * |
|
149 | + * @param string $path |
|
150 | + * @param bool $run changing this flag to false in hook handler will cancel event |
|
151 | + */ |
|
152 | + const signal_write = 'write'; |
|
153 | + |
|
154 | + /** |
|
155 | + * signal emits after file/dir save |
|
156 | + * |
|
157 | + * @param string $path |
|
158 | + */ |
|
159 | + const signal_post_write = 'post_write'; |
|
160 | + |
|
161 | + /** |
|
162 | + * signal emitted before file/dir update |
|
163 | + * |
|
164 | + * @param string $path |
|
165 | + * @param bool $run changing this flag to false in hook handler will cancel event |
|
166 | + */ |
|
167 | + const signal_update = 'update'; |
|
168 | + |
|
169 | + /** |
|
170 | + * signal emitted after file/dir update |
|
171 | + * |
|
172 | + * @param string $path |
|
173 | + * @param bool $run changing this flag to false in hook handler will cancel event |
|
174 | + */ |
|
175 | + const signal_post_update = 'post_update'; |
|
176 | + |
|
177 | + /** |
|
178 | + * signal emits when reading file/dir |
|
179 | + * |
|
180 | + * @param string $path |
|
181 | + */ |
|
182 | + const signal_read = 'read'; |
|
183 | + |
|
184 | + /** |
|
185 | + * signal emits when removing file/dir |
|
186 | + * |
|
187 | + * @param string $path |
|
188 | + */ |
|
189 | + const signal_delete = 'delete'; |
|
190 | + |
|
191 | + /** |
|
192 | + * parameters definitions for signals |
|
193 | + */ |
|
194 | + const signal_param_path = 'path'; |
|
195 | + const signal_param_oldpath = 'oldpath'; |
|
196 | + const signal_param_newpath = 'newpath'; |
|
197 | + |
|
198 | + /** |
|
199 | + * run - changing this flag to false in hook handler will cancel event |
|
200 | + */ |
|
201 | + const signal_param_run = 'run'; |
|
202 | + |
|
203 | + const signal_create_mount = 'create_mount'; |
|
204 | + const signal_delete_mount = 'delete_mount'; |
|
205 | + const signal_param_mount_type = 'mounttype'; |
|
206 | + const signal_param_users = 'users'; |
|
207 | + |
|
208 | + /** |
|
209 | + * @var \OC\Files\Storage\StorageFactory $loader |
|
210 | + */ |
|
211 | + private static $loader; |
|
212 | + |
|
213 | + /** @var bool */ |
|
214 | + private static $logWarningWhenAddingStorageWrapper = true; |
|
215 | + |
|
216 | + /** |
|
217 | + * @param bool $shouldLog |
|
218 | + * @return bool previous value |
|
219 | + * @internal |
|
220 | + */ |
|
221 | + public static function logWarningWhenAddingStorageWrapper($shouldLog) { |
|
222 | + $previousValue = self::$logWarningWhenAddingStorageWrapper; |
|
223 | + self::$logWarningWhenAddingStorageWrapper = (bool) $shouldLog; |
|
224 | + return $previousValue; |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * @param string $wrapperName |
|
229 | + * @param callable $wrapper |
|
230 | + * @param int $priority |
|
231 | + */ |
|
232 | + public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) { |
|
233 | + if (self::$logWarningWhenAddingStorageWrapper) { |
|
234 | + \OC::$server->getLogger()->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [ |
|
235 | + 'wrapper' => $wrapperName, |
|
236 | + 'app' => 'filesystem', |
|
237 | + ]); |
|
238 | + } |
|
239 | + |
|
240 | + $mounts = self::getMountManager()->getAll(); |
|
241 | + if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper, $priority, $mounts)) { |
|
242 | + // do not re-wrap if storage with this name already existed |
|
243 | + return; |
|
244 | + } |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * Returns the storage factory |
|
249 | + * |
|
250 | + * @return IStorageFactory |
|
251 | + */ |
|
252 | + public static function getLoader() { |
|
253 | + if (!self::$loader) { |
|
254 | + self::$loader = \OC::$server->query(IStorageFactory::class); |
|
255 | + } |
|
256 | + return self::$loader; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Returns the mount manager |
|
261 | + * |
|
262 | + * @return \OC\Files\Mount\Manager |
|
263 | + */ |
|
264 | + public static function getMountManager($user = '') { |
|
265 | + if (!self::$mounts) { |
|
266 | + \OC_Util::setupFS($user); |
|
267 | + } |
|
268 | + return self::$mounts; |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * get the mountpoint of the storage object for a path |
|
273 | + * ( note: because a storage is not always mounted inside the fakeroot, the |
|
274 | + * returned mountpoint is relative to the absolute root of the filesystem |
|
275 | + * and doesn't take the chroot into account ) |
|
276 | + * |
|
277 | + * @param string $path |
|
278 | + * @return string |
|
279 | + */ |
|
280 | + static public function getMountPoint($path) { |
|
281 | + if (!self::$mounts) { |
|
282 | + \OC_Util::setupFS(); |
|
283 | + } |
|
284 | + $mount = self::$mounts->find($path); |
|
285 | + if ($mount) { |
|
286 | + return $mount->getMountPoint(); |
|
287 | + } else { |
|
288 | + return ''; |
|
289 | + } |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * get a list of all mount points in a directory |
|
294 | + * |
|
295 | + * @param string $path |
|
296 | + * @return string[] |
|
297 | + */ |
|
298 | + static public function getMountPoints($path) { |
|
299 | + if (!self::$mounts) { |
|
300 | + \OC_Util::setupFS(); |
|
301 | + } |
|
302 | + $result = array(); |
|
303 | + $mounts = self::$mounts->findIn($path); |
|
304 | + foreach ($mounts as $mount) { |
|
305 | + $result[] = $mount->getMountPoint(); |
|
306 | + } |
|
307 | + return $result; |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * get the storage mounted at $mountPoint |
|
312 | + * |
|
313 | + * @param string $mountPoint |
|
314 | + * @return \OC\Files\Storage\Storage |
|
315 | + */ |
|
316 | + public static function getStorage($mountPoint) { |
|
317 | + if (!self::$mounts) { |
|
318 | + \OC_Util::setupFS(); |
|
319 | + } |
|
320 | + $mount = self::$mounts->find($mountPoint); |
|
321 | + return $mount->getStorage(); |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * @param string $id |
|
326 | + * @return Mount\MountPoint[] |
|
327 | + */ |
|
328 | + public static function getMountByStorageId($id) { |
|
329 | + if (!self::$mounts) { |
|
330 | + \OC_Util::setupFS(); |
|
331 | + } |
|
332 | + return self::$mounts->findByStorageId($id); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * @param int $id |
|
337 | + * @return Mount\MountPoint[] |
|
338 | + */ |
|
339 | + public static function getMountByNumericId($id) { |
|
340 | + if (!self::$mounts) { |
|
341 | + \OC_Util::setupFS(); |
|
342 | + } |
|
343 | + return self::$mounts->findByNumericId($id); |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * resolve a path to a storage and internal path |
|
348 | + * |
|
349 | + * @param string $path |
|
350 | + * @return array an array consisting of the storage and the internal path |
|
351 | + */ |
|
352 | + static public function resolvePath($path) { |
|
353 | + if (!self::$mounts) { |
|
354 | + \OC_Util::setupFS(); |
|
355 | + } |
|
356 | + $mount = self::$mounts->find($path); |
|
357 | + if ($mount) { |
|
358 | + return array($mount->getStorage(), rtrim($mount->getInternalPath($path), '/')); |
|
359 | + } else { |
|
360 | + return array(null, null); |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + static public function init($user, $root) { |
|
365 | + if (self::$defaultInstance) { |
|
366 | + return false; |
|
367 | + } |
|
368 | + self::getLoader(); |
|
369 | + self::$defaultInstance = new View($root); |
|
370 | + |
|
371 | + if (!self::$mounts) { |
|
372 | + self::$mounts = \OC::$server->getMountManager(); |
|
373 | + } |
|
374 | + |
|
375 | + //load custom mount config |
|
376 | + self::initMountPoints($user); |
|
377 | + |
|
378 | + self::$loaded = true; |
|
379 | + |
|
380 | + return true; |
|
381 | + } |
|
382 | + |
|
383 | + static public function initMountManager() { |
|
384 | + if (!self::$mounts) { |
|
385 | + self::$mounts = \OC::$server->getMountManager(); |
|
386 | + } |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * Initialize system and personal mount points for a user |
|
391 | + * |
|
392 | + * @param string $user |
|
393 | + * @throws \OC\User\NoUserException if the user is not available |
|
394 | + */ |
|
395 | + public static function initMountPoints($user = '') { |
|
396 | + if ($user == '') { |
|
397 | + $user = \OC_User::getUser(); |
|
398 | + } |
|
399 | + if ($user === null || $user === false || $user === '') { |
|
400 | + throw new \OC\User\NoUserException('Attempted to initialize mount points for null user and no user in session'); |
|
401 | + } |
|
402 | + |
|
403 | + if (isset(self::$usersSetup[$user])) { |
|
404 | + return; |
|
405 | + } |
|
406 | + |
|
407 | + self::$usersSetup[$user] = true; |
|
408 | + |
|
409 | + $userManager = \OC::$server->getUserManager(); |
|
410 | + $userObject = $userManager->get($user); |
|
411 | + |
|
412 | + if (is_null($userObject)) { |
|
413 | + \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, ILogger::ERROR); |
|
414 | + // reset flag, this will make it possible to rethrow the exception if called again |
|
415 | + unset(self::$usersSetup[$user]); |
|
416 | + throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); |
|
417 | + } |
|
418 | + |
|
419 | + $realUid = $userObject->getUID(); |
|
420 | + // workaround in case of different casings |
|
421 | + if ($user !== $realUid) { |
|
422 | + $stack = json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 50)); |
|
423 | + \OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, ILogger::WARN); |
|
424 | + $user = $realUid; |
|
425 | + |
|
426 | + // again with the correct casing |
|
427 | + if (isset(self::$usersSetup[$user])) { |
|
428 | + return; |
|
429 | + } |
|
430 | + |
|
431 | + self::$usersSetup[$user] = true; |
|
432 | + } |
|
433 | + |
|
434 | + if (\OC::$server->getLockdownManager()->canAccessFilesystem()) { |
|
435 | + /** @var \OC\Files\Config\MountProviderCollection $mountConfigManager */ |
|
436 | + $mountConfigManager = \OC::$server->getMountProviderCollection(); |
|
437 | + |
|
438 | + // home mounts are handled seperate since we need to ensure this is mounted before we call the other mount providers |
|
439 | + $homeMount = $mountConfigManager->getHomeMountForUser($userObject); |
|
440 | + |
|
441 | + self::getMountManager()->addMount($homeMount); |
|
442 | + |
|
443 | + \OC\Files\Filesystem::getStorage($user); |
|
444 | + |
|
445 | + // Chance to mount for other storages |
|
446 | + if ($userObject) { |
|
447 | + $mounts = $mountConfigManager->addMountForUser($userObject, self::getMountManager()); |
|
448 | + $mounts[] = $homeMount; |
|
449 | + $mountConfigManager->registerMounts($userObject, $mounts); |
|
450 | + } |
|
451 | + |
|
452 | + self::listenForNewMountProviders($mountConfigManager, $userManager); |
|
453 | + } else { |
|
454 | + self::getMountManager()->addMount(new MountPoint( |
|
455 | + new NullStorage([]), |
|
456 | + '/' . $user |
|
457 | + )); |
|
458 | + self::getMountManager()->addMount(new MountPoint( |
|
459 | + new NullStorage([]), |
|
460 | + '/' . $user . '/files' |
|
461 | + )); |
|
462 | + } |
|
463 | + \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', array('user' => $user)); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Get mounts from mount providers that are registered after setup |
|
468 | + * |
|
469 | + * @param MountProviderCollection $mountConfigManager |
|
470 | + * @param IUserManager $userManager |
|
471 | + */ |
|
472 | + private static function listenForNewMountProviders(MountProviderCollection $mountConfigManager, IUserManager $userManager) { |
|
473 | + if (!self::$listeningForProviders) { |
|
474 | + self::$listeningForProviders = true; |
|
475 | + $mountConfigManager->listen('\OC\Files\Config', 'registerMountProvider', function (IMountProvider $provider) use ($userManager) { |
|
476 | + foreach (Filesystem::$usersSetup as $user => $setup) { |
|
477 | + $userObject = $userManager->get($user); |
|
478 | + if ($userObject) { |
|
479 | + $mounts = $provider->getMountsForUser($userObject, Filesystem::getLoader()); |
|
480 | + array_walk($mounts, array(self::$mounts, 'addMount')); |
|
481 | + } |
|
482 | + } |
|
483 | + }); |
|
484 | + } |
|
485 | + } |
|
486 | + |
|
487 | + /** |
|
488 | + * get the default filesystem view |
|
489 | + * |
|
490 | + * @return View |
|
491 | + */ |
|
492 | + static public function getView() { |
|
493 | + return self::$defaultInstance; |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * tear down the filesystem, removing all storage providers |
|
498 | + */ |
|
499 | + static public function tearDown() { |
|
500 | + self::clearMounts(); |
|
501 | + self::$defaultInstance = null; |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | + * get the relative path of the root data directory for the current user |
|
506 | + * |
|
507 | + * @return string |
|
508 | + * |
|
509 | + * Returns path like /admin/files |
|
510 | + */ |
|
511 | + static public function getRoot() { |
|
512 | + if (!self::$defaultInstance) { |
|
513 | + return null; |
|
514 | + } |
|
515 | + return self::$defaultInstance->getRoot(); |
|
516 | + } |
|
517 | + |
|
518 | + /** |
|
519 | + * clear all mounts and storage backends |
|
520 | + */ |
|
521 | + public static function clearMounts() { |
|
522 | + if (self::$mounts) { |
|
523 | + self::$usersSetup = array(); |
|
524 | + self::$mounts->clear(); |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + /** |
|
529 | + * mount an \OC\Files\Storage\Storage in our virtual filesystem |
|
530 | + * |
|
531 | + * @param \OC\Files\Storage\Storage|string $class |
|
532 | + * @param array $arguments |
|
533 | + * @param string $mountpoint |
|
534 | + */ |
|
535 | + static public function mount($class, $arguments, $mountpoint) { |
|
536 | + if (!self::$mounts) { |
|
537 | + \OC_Util::setupFS(); |
|
538 | + } |
|
539 | + $mount = new Mount\MountPoint($class, $mountpoint, $arguments, self::getLoader()); |
|
540 | + self::$mounts->addMount($mount); |
|
541 | + } |
|
542 | + |
|
543 | + /** |
|
544 | + * return the path to a local version of the file |
|
545 | + * we need this because we can't know if a file is stored local or not from |
|
546 | + * outside the filestorage and for some purposes a local file is needed |
|
547 | + * |
|
548 | + * @param string $path |
|
549 | + * @return string |
|
550 | + */ |
|
551 | + static public function getLocalFile($path) { |
|
552 | + return self::$defaultInstance->getLocalFile($path); |
|
553 | + } |
|
554 | + |
|
555 | + /** |
|
556 | + * @param string $path |
|
557 | + * @return string |
|
558 | + */ |
|
559 | + static public function getLocalFolder($path) { |
|
560 | + return self::$defaultInstance->getLocalFolder($path); |
|
561 | + } |
|
562 | + |
|
563 | + /** |
|
564 | + * return path to file which reflects one visible in browser |
|
565 | + * |
|
566 | + * @param string $path |
|
567 | + * @return string |
|
568 | + */ |
|
569 | + static public function getLocalPath($path) { |
|
570 | + $datadir = \OC_User::getHome(\OC_User::getUser()) . '/files'; |
|
571 | + $newpath = $path; |
|
572 | + if (strncmp($newpath, $datadir, strlen($datadir)) == 0) { |
|
573 | + $newpath = substr($path, strlen($datadir)); |
|
574 | + } |
|
575 | + return $newpath; |
|
576 | + } |
|
577 | + |
|
578 | + /** |
|
579 | + * check if the requested path is valid |
|
580 | + * |
|
581 | + * @param string $path |
|
582 | + * @return bool |
|
583 | + */ |
|
584 | + static public function isValidPath($path) { |
|
585 | + $path = self::normalizePath($path); |
|
586 | + if (!$path || $path[0] !== '/') { |
|
587 | + $path = '/' . $path; |
|
588 | + } |
|
589 | + if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') { |
|
590 | + return false; |
|
591 | + } |
|
592 | + return true; |
|
593 | + } |
|
594 | + |
|
595 | + /** |
|
596 | + * checks if a file is blacklisted for storage in the filesystem |
|
597 | + * Listens to write and rename hooks |
|
598 | + * |
|
599 | + * @param array $data from hook |
|
600 | + */ |
|
601 | + static public function isBlacklisted($data) { |
|
602 | + if (isset($data['path'])) { |
|
603 | + $path = $data['path']; |
|
604 | + } else if (isset($data['newpath'])) { |
|
605 | + $path = $data['newpath']; |
|
606 | + } |
|
607 | + if (isset($path)) { |
|
608 | + if (self::isFileBlacklisted($path)) { |
|
609 | + $data['run'] = false; |
|
610 | + } |
|
611 | + } |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * @param string $filename |
|
616 | + * @return bool |
|
617 | + */ |
|
618 | + static public function isFileBlacklisted($filename) { |
|
619 | + $filename = self::normalizePath($filename); |
|
620 | + |
|
621 | + $blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', array('.htaccess')); |
|
622 | + $filename = strtolower(basename($filename)); |
|
623 | + return in_array($filename, $blacklist); |
|
624 | + } |
|
625 | + |
|
626 | + /** |
|
627 | + * check if the directory should be ignored when scanning |
|
628 | + * NOTE: the special directories . and .. would cause never ending recursion |
|
629 | + * |
|
630 | + * @param String $dir |
|
631 | + * @return boolean |
|
632 | + */ |
|
633 | + static public function isIgnoredDir($dir) { |
|
634 | + if ($dir === '.' || $dir === '..') { |
|
635 | + return true; |
|
636 | + } |
|
637 | + return false; |
|
638 | + } |
|
639 | + |
|
640 | + /** |
|
641 | + * following functions are equivalent to their php builtin equivalents for arguments/return values. |
|
642 | + */ |
|
643 | + static public function mkdir($path) { |
|
644 | + return self::$defaultInstance->mkdir($path); |
|
645 | + } |
|
646 | + |
|
647 | + static public function rmdir($path) { |
|
648 | + return self::$defaultInstance->rmdir($path); |
|
649 | + } |
|
650 | + |
|
651 | + static public function is_dir($path) { |
|
652 | + return self::$defaultInstance->is_dir($path); |
|
653 | + } |
|
654 | + |
|
655 | + static public function is_file($path) { |
|
656 | + return self::$defaultInstance->is_file($path); |
|
657 | + } |
|
658 | + |
|
659 | + static public function stat($path) { |
|
660 | + return self::$defaultInstance->stat($path); |
|
661 | + } |
|
662 | + |
|
663 | + static public function filetype($path) { |
|
664 | + return self::$defaultInstance->filetype($path); |
|
665 | + } |
|
666 | + |
|
667 | + static public function filesize($path) { |
|
668 | + return self::$defaultInstance->filesize($path); |
|
669 | + } |
|
670 | + |
|
671 | + static public function readfile($path) { |
|
672 | + return self::$defaultInstance->readfile($path); |
|
673 | + } |
|
674 | + |
|
675 | + static public function isCreatable($path) { |
|
676 | + return self::$defaultInstance->isCreatable($path); |
|
677 | + } |
|
678 | + |
|
679 | + static public function isReadable($path) { |
|
680 | + return self::$defaultInstance->isReadable($path); |
|
681 | + } |
|
682 | + |
|
683 | + static public function isUpdatable($path) { |
|
684 | + return self::$defaultInstance->isUpdatable($path); |
|
685 | + } |
|
686 | + |
|
687 | + static public function isDeletable($path) { |
|
688 | + return self::$defaultInstance->isDeletable($path); |
|
689 | + } |
|
690 | + |
|
691 | + static public function isSharable($path) { |
|
692 | + return self::$defaultInstance->isSharable($path); |
|
693 | + } |
|
694 | + |
|
695 | + static public function file_exists($path) { |
|
696 | + return self::$defaultInstance->file_exists($path); |
|
697 | + } |
|
698 | + |
|
699 | + static public function filemtime($path) { |
|
700 | + return self::$defaultInstance->filemtime($path); |
|
701 | + } |
|
702 | + |
|
703 | + static public function touch($path, $mtime = null) { |
|
704 | + return self::$defaultInstance->touch($path, $mtime); |
|
705 | + } |
|
706 | + |
|
707 | + /** |
|
708 | + * @return string |
|
709 | + */ |
|
710 | + static public function file_get_contents($path) { |
|
711 | + return self::$defaultInstance->file_get_contents($path); |
|
712 | + } |
|
713 | + |
|
714 | + static public function file_put_contents($path, $data) { |
|
715 | + return self::$defaultInstance->file_put_contents($path, $data); |
|
716 | + } |
|
717 | + |
|
718 | + static public function unlink($path) { |
|
719 | + return self::$defaultInstance->unlink($path); |
|
720 | + } |
|
721 | + |
|
722 | + static public function rename($path1, $path2) { |
|
723 | + return self::$defaultInstance->rename($path1, $path2); |
|
724 | + } |
|
725 | + |
|
726 | + static public function copy($path1, $path2) { |
|
727 | + return self::$defaultInstance->copy($path1, $path2); |
|
728 | + } |
|
729 | + |
|
730 | + static public function fopen($path, $mode) { |
|
731 | + return self::$defaultInstance->fopen($path, $mode); |
|
732 | + } |
|
733 | + |
|
734 | + /** |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + static public function toTmpFile($path) { |
|
738 | + return self::$defaultInstance->toTmpFile($path); |
|
739 | + } |
|
740 | + |
|
741 | + static public function fromTmpFile($tmpFile, $path) { |
|
742 | + return self::$defaultInstance->fromTmpFile($tmpFile, $path); |
|
743 | + } |
|
744 | + |
|
745 | + static public function getMimeType($path) { |
|
746 | + return self::$defaultInstance->getMimeType($path); |
|
747 | + } |
|
748 | + |
|
749 | + static public function hash($type, $path, $raw = false) { |
|
750 | + return self::$defaultInstance->hash($type, $path, $raw); |
|
751 | + } |
|
752 | + |
|
753 | + static public function free_space($path = '/') { |
|
754 | + return self::$defaultInstance->free_space($path); |
|
755 | + } |
|
756 | + |
|
757 | + static public function search($query) { |
|
758 | + return self::$defaultInstance->search($query); |
|
759 | + } |
|
760 | + |
|
761 | + /** |
|
762 | + * @param string $query |
|
763 | + */ |
|
764 | + static public function searchByMime($query) { |
|
765 | + return self::$defaultInstance->searchByMime($query); |
|
766 | + } |
|
767 | + |
|
768 | + /** |
|
769 | + * @param string|int $tag name or tag id |
|
770 | + * @param string $userId owner of the tags |
|
771 | + * @return FileInfo[] array or file info |
|
772 | + */ |
|
773 | + static public function searchByTag($tag, $userId) { |
|
774 | + return self::$defaultInstance->searchByTag($tag, $userId); |
|
775 | + } |
|
776 | + |
|
777 | + /** |
|
778 | + * check if a file or folder has been updated since $time |
|
779 | + * |
|
780 | + * @param string $path |
|
781 | + * @param int $time |
|
782 | + * @return bool |
|
783 | + */ |
|
784 | + static public function hasUpdated($path, $time) { |
|
785 | + return self::$defaultInstance->hasUpdated($path, $time); |
|
786 | + } |
|
787 | + |
|
788 | + /** |
|
789 | + * Fix common problems with a file path |
|
790 | + * |
|
791 | + * @param string $path |
|
792 | + * @param bool $stripTrailingSlash whether to strip the trailing slash |
|
793 | + * @param bool $isAbsolutePath whether the given path is absolute |
|
794 | + * @param bool $keepUnicode true to disable unicode normalization |
|
795 | + * @return string |
|
796 | + */ |
|
797 | + public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) { |
|
798 | + if (is_null(self::$normalizedPathCache)) { |
|
799 | + self::$normalizedPathCache = new CappedMemoryCache(2048); |
|
800 | + } |
|
801 | + |
|
802 | + /** |
|
803 | + * FIXME: This is a workaround for existing classes and files which call |
|
804 | + * this function with another type than a valid string. This |
|
805 | + * conversion should get removed as soon as all existing |
|
806 | + * function calls have been fixed. |
|
807 | + */ |
|
808 | + $path = (string)$path; |
|
809 | + |
|
810 | + $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]); |
|
811 | + |
|
812 | + if (isset(self::$normalizedPathCache[$cacheKey])) { |
|
813 | + return self::$normalizedPathCache[$cacheKey]; |
|
814 | + } |
|
815 | + |
|
816 | + if ($path === '') { |
|
817 | + return '/'; |
|
818 | + } |
|
819 | + |
|
820 | + //normalize unicode if possible |
|
821 | + if (!$keepUnicode) { |
|
822 | + $path = \OC_Util::normalizeUnicode($path); |
|
823 | + } |
|
824 | + |
|
825 | + //add leading slash, if it is already there we strip it anyway |
|
826 | + $path = '/' . $path; |
|
827 | + |
|
828 | + $patterns = [ |
|
829 | + '/\\\\/s', // no windows style slashes |
|
830 | + '/\/\.(\/\.)?\//s', // remove '/./' |
|
831 | + '/\/{2,}/s', // remove squence of slashes |
|
832 | + '/\/\.$/s', // remove trailing /. |
|
833 | + ]; |
|
834 | + |
|
835 | + do { |
|
836 | + $count = 0; |
|
837 | + $path = preg_replace($patterns, '/', $path, -1, $count); |
|
838 | + } while ($count > 0); |
|
839 | + |
|
840 | + //remove trailing slash |
|
841 | + if ($stripTrailingSlash && strlen($path) > 1) { |
|
842 | + $path = rtrim($path, '/'); |
|
843 | + } |
|
844 | + |
|
845 | + self::$normalizedPathCache[$cacheKey] = $path; |
|
846 | + |
|
847 | + return $path; |
|
848 | + } |
|
849 | + |
|
850 | + /** |
|
851 | + * get the filesystem info |
|
852 | + * |
|
853 | + * @param string $path |
|
854 | + * @param boolean $includeMountPoints whether to add mountpoint sizes, |
|
855 | + * defaults to true |
|
856 | + * @return \OC\Files\FileInfo|bool False if file does not exist |
|
857 | + */ |
|
858 | + public static function getFileInfo($path, $includeMountPoints = true) { |
|
859 | + return self::$defaultInstance->getFileInfo($path, $includeMountPoints); |
|
860 | + } |
|
861 | + |
|
862 | + /** |
|
863 | + * change file metadata |
|
864 | + * |
|
865 | + * @param string $path |
|
866 | + * @param array $data |
|
867 | + * @return int |
|
868 | + * |
|
869 | + * returns the fileid of the updated file |
|
870 | + */ |
|
871 | + public static function putFileInfo($path, $data) { |
|
872 | + return self::$defaultInstance->putFileInfo($path, $data); |
|
873 | + } |
|
874 | + |
|
875 | + /** |
|
876 | + * get the content of a directory |
|
877 | + * |
|
878 | + * @param string $directory path under datadirectory |
|
879 | + * @param string $mimetype_filter limit returned content to this mimetype or mimepart |
|
880 | + * @return \OC\Files\FileInfo[] |
|
881 | + */ |
|
882 | + public static function getDirectoryContent($directory, $mimetype_filter = '') { |
|
883 | + return self::$defaultInstance->getDirectoryContent($directory, $mimetype_filter); |
|
884 | + } |
|
885 | + |
|
886 | + /** |
|
887 | + * Get the path of a file by id |
|
888 | + * |
|
889 | + * Note that the resulting path is not guaranteed to be unique for the id, multiple paths can point to the same file |
|
890 | + * |
|
891 | + * @param int $id |
|
892 | + * @throws NotFoundException |
|
893 | + * @return string |
|
894 | + */ |
|
895 | + public static function getPath($id) { |
|
896 | + return self::$defaultInstance->getPath($id); |
|
897 | + } |
|
898 | + |
|
899 | + /** |
|
900 | + * Get the owner for a file or folder |
|
901 | + * |
|
902 | + * @param string $path |
|
903 | + * @return string |
|
904 | + */ |
|
905 | + public static function getOwner($path) { |
|
906 | + return self::$defaultInstance->getOwner($path); |
|
907 | + } |
|
908 | + |
|
909 | + /** |
|
910 | + * get the ETag for a file or folder |
|
911 | + * |
|
912 | + * @param string $path |
|
913 | + * @return string |
|
914 | + */ |
|
915 | + static public function getETag($path) { |
|
916 | + return self::$defaultInstance->getETag($path); |
|
917 | + } |
|
918 | 918 | } |
@@ -33,302 +33,302 @@ |
||
33 | 33 | use OCP\Files\Search\ISearchQuery; |
34 | 34 | |
35 | 35 | class CacheWrapper extends Cache { |
36 | - /** |
|
37 | - * @var \OCP\Files\Cache\ICache |
|
38 | - */ |
|
39 | - protected $cache; |
|
40 | - |
|
41 | - /** |
|
42 | - * @param \OCP\Files\Cache\ICache $cache |
|
43 | - */ |
|
44 | - public function __construct($cache) { |
|
45 | - $this->cache = $cache; |
|
46 | - } |
|
47 | - |
|
48 | - protected function getCache() { |
|
49 | - return $this->cache; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Make it easy for wrappers to modify every returned cache entry |
|
54 | - * |
|
55 | - * @param ICacheEntry $entry |
|
56 | - * @return ICacheEntry |
|
57 | - */ |
|
58 | - protected function formatCacheEntry($entry) { |
|
59 | - return $entry; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * get the stored metadata of a file or folder |
|
64 | - * |
|
65 | - * @param string|int $file |
|
66 | - * @return ICacheEntry|false |
|
67 | - */ |
|
68 | - public function get($file) { |
|
69 | - $result = $this->getCache()->get($file); |
|
70 | - if ($result) { |
|
71 | - $result = $this->formatCacheEntry($result); |
|
72 | - } |
|
73 | - return $result; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * get the metadata of all files stored in $folder |
|
78 | - * |
|
79 | - * @param string $folder |
|
80 | - * @return ICacheEntry[] |
|
81 | - */ |
|
82 | - public function getFolderContents($folder) { |
|
83 | - // can't do a simple $this->getCache()->.... call here since getFolderContentsById needs to be called on this |
|
84 | - // and not the wrapped cache |
|
85 | - $fileId = $this->getId($folder); |
|
86 | - return $this->getFolderContentsById($fileId); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * get the metadata of all files stored in $folder |
|
91 | - * |
|
92 | - * @param int $fileId the file id of the folder |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function getFolderContentsById($fileId) { |
|
96 | - $results = $this->getCache()->getFolderContentsById($fileId); |
|
97 | - return array_map(array($this, 'formatCacheEntry'), $results); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * insert or update meta data for a file or folder |
|
102 | - * |
|
103 | - * @param string $file |
|
104 | - * @param array $data |
|
105 | - * |
|
106 | - * @return int file id |
|
107 | - * @throws \RuntimeException |
|
108 | - */ |
|
109 | - public function put($file, array $data) { |
|
110 | - if (($id = $this->getId($file)) > -1) { |
|
111 | - $this->update($id, $data); |
|
112 | - return $id; |
|
113 | - } else { |
|
114 | - return $this->insert($file, $data); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * insert meta data for a new file or folder |
|
120 | - * |
|
121 | - * @param string $file |
|
122 | - * @param array $data |
|
123 | - * |
|
124 | - * @return int file id |
|
125 | - * @throws \RuntimeException |
|
126 | - */ |
|
127 | - public function insert($file, array $data) { |
|
128 | - return $this->getCache()->insert($file, $data); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * update the metadata in the cache |
|
133 | - * |
|
134 | - * @param int $id |
|
135 | - * @param array $data |
|
136 | - */ |
|
137 | - public function update($id, array $data) { |
|
138 | - $this->getCache()->update($id, $data); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * get the file id for a file |
|
143 | - * |
|
144 | - * @param string $file |
|
145 | - * @return int |
|
146 | - */ |
|
147 | - public function getId($file) { |
|
148 | - return $this->getCache()->getId($file); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * get the id of the parent folder of a file |
|
153 | - * |
|
154 | - * @param string $file |
|
155 | - * @return int |
|
156 | - */ |
|
157 | - public function getParentId($file) { |
|
158 | - return $this->getCache()->getParentId($file); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * check if a file is available in the cache |
|
163 | - * |
|
164 | - * @param string $file |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - public function inCache($file) { |
|
168 | - return $this->getCache()->inCache($file); |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * remove a file or folder from the cache |
|
173 | - * |
|
174 | - * @param string $file |
|
175 | - */ |
|
176 | - public function remove($file) { |
|
177 | - $this->getCache()->remove($file); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Move a file or folder in the cache |
|
182 | - * |
|
183 | - * @param string $source |
|
184 | - * @param string $target |
|
185 | - */ |
|
186 | - public function move($source, $target) { |
|
187 | - $this->getCache()->move($source, $target); |
|
188 | - } |
|
189 | - |
|
190 | - protected function getMoveInfo($path) { |
|
191 | - /** @var Cache $cache */ |
|
192 | - $cache = $this->getCache(); |
|
193 | - return $cache->getMoveInfo($path); |
|
194 | - } |
|
195 | - |
|
196 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
197 | - $this->getCache()->moveFromCache($sourceCache, $sourcePath, $targetPath); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * remove all entries for files that are stored on the storage from the cache |
|
202 | - */ |
|
203 | - public function clear() { |
|
204 | - $this->getCache()->clear(); |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * @param string $file |
|
209 | - * |
|
210 | - * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE |
|
211 | - */ |
|
212 | - public function getStatus($file) { |
|
213 | - return $this->getCache()->getStatus($file); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * search for files matching $pattern |
|
218 | - * |
|
219 | - * @param string $pattern |
|
220 | - * @return ICacheEntry[] an array of file data |
|
221 | - */ |
|
222 | - public function search($pattern) { |
|
223 | - $results = $this->getCache()->search($pattern); |
|
224 | - return array_map(array($this, 'formatCacheEntry'), $results); |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * search for files by mimetype |
|
229 | - * |
|
230 | - * @param string $mimetype |
|
231 | - * @return ICacheEntry[] |
|
232 | - */ |
|
233 | - public function searchByMime($mimetype) { |
|
234 | - $results = $this->getCache()->searchByMime($mimetype); |
|
235 | - return array_map(array($this, 'formatCacheEntry'), $results); |
|
236 | - } |
|
237 | - |
|
238 | - public function searchQuery(ISearchQuery $query) { |
|
239 | - $results = $this->getCache()->searchQuery($query); |
|
240 | - return array_map(array($this, 'formatCacheEntry'), $results); |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * search for files by tag |
|
245 | - * |
|
246 | - * @param string|int $tag name or tag id |
|
247 | - * @param string $userId owner of the tags |
|
248 | - * @return ICacheEntry[] file data |
|
249 | - */ |
|
250 | - public function searchByTag($tag, $userId) { |
|
251 | - $results = $this->getCache()->searchByTag($tag, $userId); |
|
252 | - return array_map(array($this, 'formatCacheEntry'), $results); |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * update the folder size and the size of all parent folders |
|
257 | - * |
|
258 | - * @param string|boolean $path |
|
259 | - * @param array $data (optional) meta data of the folder |
|
260 | - */ |
|
261 | - public function correctFolderSize($path, $data = null) { |
|
262 | - if ($this->getCache() instanceof Cache) { |
|
263 | - $this->getCache()->correctFolderSize($path, $data); |
|
264 | - } |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * get the size of a folder and set it in the cache |
|
269 | - * |
|
270 | - * @param string $path |
|
271 | - * @param array $entry (optional) meta data of the folder |
|
272 | - * @return int |
|
273 | - */ |
|
274 | - public function calculateFolderSize($path, $entry = null) { |
|
275 | - if ($this->getCache() instanceof Cache) { |
|
276 | - return $this->getCache()->calculateFolderSize($path, $entry); |
|
277 | - } else { |
|
278 | - return 0; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * get all file ids on the files on the storage |
|
284 | - * |
|
285 | - * @return int[] |
|
286 | - */ |
|
287 | - public function getAll() { |
|
288 | - return $this->getCache()->getAll(); |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * find a folder in the cache which has not been fully scanned |
|
293 | - * |
|
294 | - * If multiple incomplete folders are in the cache, the one with the highest id will be returned, |
|
295 | - * use the one with the highest id gives the best result with the background scanner, since that is most |
|
296 | - * likely the folder where we stopped scanning previously |
|
297 | - * |
|
298 | - * @return string|bool the path of the folder or false when no folder matched |
|
299 | - */ |
|
300 | - public function getIncomplete() { |
|
301 | - return $this->getCache()->getIncomplete(); |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * get the path of a file on this storage by it's id |
|
306 | - * |
|
307 | - * @param int $id |
|
308 | - * @return string|null |
|
309 | - */ |
|
310 | - public function getPathById($id) { |
|
311 | - return $this->getCache()->getPathById($id); |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Returns the numeric storage id |
|
316 | - * |
|
317 | - * @return int |
|
318 | - */ |
|
319 | - public function getNumericStorageId() { |
|
320 | - return $this->getCache()->getNumericStorageId(); |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * get the storage id of the storage for a file and the internal path of the file |
|
325 | - * unlike getPathById this does not limit the search to files on this storage and |
|
326 | - * instead does a global search in the cache table |
|
327 | - * |
|
328 | - * @param int $id |
|
329 | - * @return array first element holding the storage id, second the path |
|
330 | - */ |
|
331 | - static public function getById($id) { |
|
332 | - return parent::getById($id); |
|
333 | - } |
|
36 | + /** |
|
37 | + * @var \OCP\Files\Cache\ICache |
|
38 | + */ |
|
39 | + protected $cache; |
|
40 | + |
|
41 | + /** |
|
42 | + * @param \OCP\Files\Cache\ICache $cache |
|
43 | + */ |
|
44 | + public function __construct($cache) { |
|
45 | + $this->cache = $cache; |
|
46 | + } |
|
47 | + |
|
48 | + protected function getCache() { |
|
49 | + return $this->cache; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Make it easy for wrappers to modify every returned cache entry |
|
54 | + * |
|
55 | + * @param ICacheEntry $entry |
|
56 | + * @return ICacheEntry |
|
57 | + */ |
|
58 | + protected function formatCacheEntry($entry) { |
|
59 | + return $entry; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * get the stored metadata of a file or folder |
|
64 | + * |
|
65 | + * @param string|int $file |
|
66 | + * @return ICacheEntry|false |
|
67 | + */ |
|
68 | + public function get($file) { |
|
69 | + $result = $this->getCache()->get($file); |
|
70 | + if ($result) { |
|
71 | + $result = $this->formatCacheEntry($result); |
|
72 | + } |
|
73 | + return $result; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * get the metadata of all files stored in $folder |
|
78 | + * |
|
79 | + * @param string $folder |
|
80 | + * @return ICacheEntry[] |
|
81 | + */ |
|
82 | + public function getFolderContents($folder) { |
|
83 | + // can't do a simple $this->getCache()->.... call here since getFolderContentsById needs to be called on this |
|
84 | + // and not the wrapped cache |
|
85 | + $fileId = $this->getId($folder); |
|
86 | + return $this->getFolderContentsById($fileId); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * get the metadata of all files stored in $folder |
|
91 | + * |
|
92 | + * @param int $fileId the file id of the folder |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function getFolderContentsById($fileId) { |
|
96 | + $results = $this->getCache()->getFolderContentsById($fileId); |
|
97 | + return array_map(array($this, 'formatCacheEntry'), $results); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * insert or update meta data for a file or folder |
|
102 | + * |
|
103 | + * @param string $file |
|
104 | + * @param array $data |
|
105 | + * |
|
106 | + * @return int file id |
|
107 | + * @throws \RuntimeException |
|
108 | + */ |
|
109 | + public function put($file, array $data) { |
|
110 | + if (($id = $this->getId($file)) > -1) { |
|
111 | + $this->update($id, $data); |
|
112 | + return $id; |
|
113 | + } else { |
|
114 | + return $this->insert($file, $data); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * insert meta data for a new file or folder |
|
120 | + * |
|
121 | + * @param string $file |
|
122 | + * @param array $data |
|
123 | + * |
|
124 | + * @return int file id |
|
125 | + * @throws \RuntimeException |
|
126 | + */ |
|
127 | + public function insert($file, array $data) { |
|
128 | + return $this->getCache()->insert($file, $data); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * update the metadata in the cache |
|
133 | + * |
|
134 | + * @param int $id |
|
135 | + * @param array $data |
|
136 | + */ |
|
137 | + public function update($id, array $data) { |
|
138 | + $this->getCache()->update($id, $data); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * get the file id for a file |
|
143 | + * |
|
144 | + * @param string $file |
|
145 | + * @return int |
|
146 | + */ |
|
147 | + public function getId($file) { |
|
148 | + return $this->getCache()->getId($file); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * get the id of the parent folder of a file |
|
153 | + * |
|
154 | + * @param string $file |
|
155 | + * @return int |
|
156 | + */ |
|
157 | + public function getParentId($file) { |
|
158 | + return $this->getCache()->getParentId($file); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * check if a file is available in the cache |
|
163 | + * |
|
164 | + * @param string $file |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + public function inCache($file) { |
|
168 | + return $this->getCache()->inCache($file); |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * remove a file or folder from the cache |
|
173 | + * |
|
174 | + * @param string $file |
|
175 | + */ |
|
176 | + public function remove($file) { |
|
177 | + $this->getCache()->remove($file); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Move a file or folder in the cache |
|
182 | + * |
|
183 | + * @param string $source |
|
184 | + * @param string $target |
|
185 | + */ |
|
186 | + public function move($source, $target) { |
|
187 | + $this->getCache()->move($source, $target); |
|
188 | + } |
|
189 | + |
|
190 | + protected function getMoveInfo($path) { |
|
191 | + /** @var Cache $cache */ |
|
192 | + $cache = $this->getCache(); |
|
193 | + return $cache->getMoveInfo($path); |
|
194 | + } |
|
195 | + |
|
196 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
197 | + $this->getCache()->moveFromCache($sourceCache, $sourcePath, $targetPath); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * remove all entries for files that are stored on the storage from the cache |
|
202 | + */ |
|
203 | + public function clear() { |
|
204 | + $this->getCache()->clear(); |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * @param string $file |
|
209 | + * |
|
210 | + * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE |
|
211 | + */ |
|
212 | + public function getStatus($file) { |
|
213 | + return $this->getCache()->getStatus($file); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * search for files matching $pattern |
|
218 | + * |
|
219 | + * @param string $pattern |
|
220 | + * @return ICacheEntry[] an array of file data |
|
221 | + */ |
|
222 | + public function search($pattern) { |
|
223 | + $results = $this->getCache()->search($pattern); |
|
224 | + return array_map(array($this, 'formatCacheEntry'), $results); |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * search for files by mimetype |
|
229 | + * |
|
230 | + * @param string $mimetype |
|
231 | + * @return ICacheEntry[] |
|
232 | + */ |
|
233 | + public function searchByMime($mimetype) { |
|
234 | + $results = $this->getCache()->searchByMime($mimetype); |
|
235 | + return array_map(array($this, 'formatCacheEntry'), $results); |
|
236 | + } |
|
237 | + |
|
238 | + public function searchQuery(ISearchQuery $query) { |
|
239 | + $results = $this->getCache()->searchQuery($query); |
|
240 | + return array_map(array($this, 'formatCacheEntry'), $results); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * search for files by tag |
|
245 | + * |
|
246 | + * @param string|int $tag name or tag id |
|
247 | + * @param string $userId owner of the tags |
|
248 | + * @return ICacheEntry[] file data |
|
249 | + */ |
|
250 | + public function searchByTag($tag, $userId) { |
|
251 | + $results = $this->getCache()->searchByTag($tag, $userId); |
|
252 | + return array_map(array($this, 'formatCacheEntry'), $results); |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * update the folder size and the size of all parent folders |
|
257 | + * |
|
258 | + * @param string|boolean $path |
|
259 | + * @param array $data (optional) meta data of the folder |
|
260 | + */ |
|
261 | + public function correctFolderSize($path, $data = null) { |
|
262 | + if ($this->getCache() instanceof Cache) { |
|
263 | + $this->getCache()->correctFolderSize($path, $data); |
|
264 | + } |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * get the size of a folder and set it in the cache |
|
269 | + * |
|
270 | + * @param string $path |
|
271 | + * @param array $entry (optional) meta data of the folder |
|
272 | + * @return int |
|
273 | + */ |
|
274 | + public function calculateFolderSize($path, $entry = null) { |
|
275 | + if ($this->getCache() instanceof Cache) { |
|
276 | + return $this->getCache()->calculateFolderSize($path, $entry); |
|
277 | + } else { |
|
278 | + return 0; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * get all file ids on the files on the storage |
|
284 | + * |
|
285 | + * @return int[] |
|
286 | + */ |
|
287 | + public function getAll() { |
|
288 | + return $this->getCache()->getAll(); |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * find a folder in the cache which has not been fully scanned |
|
293 | + * |
|
294 | + * If multiple incomplete folders are in the cache, the one with the highest id will be returned, |
|
295 | + * use the one with the highest id gives the best result with the background scanner, since that is most |
|
296 | + * likely the folder where we stopped scanning previously |
|
297 | + * |
|
298 | + * @return string|bool the path of the folder or false when no folder matched |
|
299 | + */ |
|
300 | + public function getIncomplete() { |
|
301 | + return $this->getCache()->getIncomplete(); |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * get the path of a file on this storage by it's id |
|
306 | + * |
|
307 | + * @param int $id |
|
308 | + * @return string|null |
|
309 | + */ |
|
310 | + public function getPathById($id) { |
|
311 | + return $this->getCache()->getPathById($id); |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Returns the numeric storage id |
|
316 | + * |
|
317 | + * @return int |
|
318 | + */ |
|
319 | + public function getNumericStorageId() { |
|
320 | + return $this->getCache()->getNumericStorageId(); |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * get the storage id of the storage for a file and the internal path of the file |
|
325 | + * unlike getPathById this does not limit the search to files on this storage and |
|
326 | + * instead does a global search in the cache table |
|
327 | + * |
|
328 | + * @param int $id |
|
329 | + * @return array first element holding the storage id, second the path |
|
330 | + */ |
|
331 | + static public function getById($id) { |
|
332 | + return parent::getById($id); |
|
333 | + } |
|
334 | 334 | } |
@@ -38,356 +38,356 @@ |
||
38 | 38 | use OCP\IUser; |
39 | 39 | |
40 | 40 | class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { |
41 | - /** |
|
42 | - * @var array $data |
|
43 | - */ |
|
44 | - private $data; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $path |
|
48 | - */ |
|
49 | - private $path; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var \OC\Files\Storage\Storage $storage |
|
53 | - */ |
|
54 | - private $storage; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var string $internalPath |
|
58 | - */ |
|
59 | - private $internalPath; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var \OCP\Files\Mount\IMountPoint |
|
63 | - */ |
|
64 | - private $mount; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var IUser |
|
68 | - */ |
|
69 | - private $owner; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var string[] |
|
73 | - */ |
|
74 | - private $childEtags = []; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var IMountPoint[] |
|
78 | - */ |
|
79 | - private $subMounts = []; |
|
80 | - |
|
81 | - private $subMountsUsed = false; |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string|boolean $path |
|
85 | - * @param Storage\Storage $storage |
|
86 | - * @param string $internalPath |
|
87 | - * @param array|ICacheEntry $data |
|
88 | - * @param \OCP\Files\Mount\IMountPoint $mount |
|
89 | - * @param \OCP\IUser|null $owner |
|
90 | - */ |
|
91 | - public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) { |
|
92 | - $this->path = $path; |
|
93 | - $this->storage = $storage; |
|
94 | - $this->internalPath = $internalPath; |
|
95 | - $this->data = $data; |
|
96 | - $this->mount = $mount; |
|
97 | - $this->owner = $owner; |
|
98 | - } |
|
99 | - |
|
100 | - public function offsetSet($offset, $value) { |
|
101 | - $this->data[$offset] = $value; |
|
102 | - } |
|
103 | - |
|
104 | - public function offsetExists($offset) { |
|
105 | - return isset($this->data[$offset]); |
|
106 | - } |
|
107 | - |
|
108 | - public function offsetUnset($offset) { |
|
109 | - unset($this->data[$offset]); |
|
110 | - } |
|
111 | - |
|
112 | - public function offsetGet($offset) { |
|
113 | - if ($offset === 'type') { |
|
114 | - return $this->getType(); |
|
115 | - } else if ($offset === 'etag') { |
|
116 | - return $this->getEtag(); |
|
117 | - } else if ($offset === 'size') { |
|
118 | - return $this->getSize(); |
|
119 | - } else if ($offset === 'mtime') { |
|
120 | - return $this->getMTime(); |
|
121 | - } elseif ($offset === 'permissions') { |
|
122 | - return $this->getPermissions(); |
|
123 | - } elseif (isset($this->data[$offset])) { |
|
124 | - return $this->data[$offset]; |
|
125 | - } else { |
|
126 | - return null; |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function getPath() { |
|
134 | - return $this->path; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @return \OCP\Files\Storage |
|
139 | - */ |
|
140 | - public function getStorage() { |
|
141 | - return $this->storage; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function getInternalPath() { |
|
148 | - return $this->internalPath; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Get FileInfo ID or null in case of part file |
|
153 | - * |
|
154 | - * @return int|null |
|
155 | - */ |
|
156 | - public function getId() { |
|
157 | - return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @return string |
|
162 | - */ |
|
163 | - public function getMimetype() { |
|
164 | - return $this->data['mimetype']; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @return string |
|
169 | - */ |
|
170 | - public function getMimePart() { |
|
171 | - return $this->data['mimepart']; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function getName() { |
|
178 | - return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath()); |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function getEtag() { |
|
185 | - $this->updateEntryfromSubMounts(); |
|
186 | - if (count($this->childEtags) > 0) { |
|
187 | - $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags); |
|
188 | - return md5($combinedEtag); |
|
189 | - } else { |
|
190 | - return $this->data['etag']; |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @return int |
|
196 | - */ |
|
197 | - public function getSize() { |
|
198 | - $this->updateEntryfromSubMounts(); |
|
199 | - return isset($this->data['size']) ? 0 + $this->data['size'] : 0; |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * @return int |
|
204 | - */ |
|
205 | - public function getMTime() { |
|
206 | - $this->updateEntryfromSubMounts(); |
|
207 | - return (int) $this->data['mtime']; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @return bool |
|
212 | - */ |
|
213 | - public function isEncrypted() { |
|
214 | - return $this->data['encrypted']; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Return the currently version used for the HMAC in the encryption app |
|
219 | - * |
|
220 | - * @return int |
|
221 | - */ |
|
222 | - public function getEncryptedVersion() { |
|
223 | - return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return int |
|
228 | - */ |
|
229 | - public function getPermissions() { |
|
230 | - $perms = (int) $this->data['permissions']; |
|
231 | - if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { |
|
232 | - $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; |
|
233 | - } |
|
234 | - return (int) $perms; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER |
|
239 | - */ |
|
240 | - public function getType() { |
|
241 | - if (!isset($this->data['type'])) { |
|
242 | - $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE; |
|
243 | - } |
|
244 | - return $this->data['type']; |
|
245 | - } |
|
246 | - |
|
247 | - public function getData() { |
|
248 | - return $this->data; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * @param int $permissions |
|
253 | - * @return bool |
|
254 | - */ |
|
255 | - protected function checkPermissions($permissions) { |
|
256 | - return ($this->getPermissions() & $permissions) === $permissions; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * @return bool |
|
261 | - */ |
|
262 | - public function isReadable() { |
|
263 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * @return bool |
|
268 | - */ |
|
269 | - public function isUpdateable() { |
|
270 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Check whether new files or folders can be created inside this folder |
|
275 | - * |
|
276 | - * @return bool |
|
277 | - */ |
|
278 | - public function isCreatable() { |
|
279 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * @return bool |
|
284 | - */ |
|
285 | - public function isDeletable() { |
|
286 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * @return bool |
|
291 | - */ |
|
292 | - public function isShareable() { |
|
293 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * Check if a file or folder is shared |
|
298 | - * |
|
299 | - * @return bool |
|
300 | - */ |
|
301 | - public function isShared() { |
|
302 | - $sid = $this->getStorage()->getId(); |
|
303 | - if (!is_null($sid)) { |
|
304 | - $sid = explode(':', $sid); |
|
305 | - return ($sid[0] === 'shared'); |
|
306 | - } |
|
307 | - |
|
308 | - return false; |
|
309 | - } |
|
310 | - |
|
311 | - public function isMounted() { |
|
312 | - $storage = $this->getStorage(); |
|
313 | - if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { |
|
314 | - return false; |
|
315 | - } |
|
316 | - $sid = $storage->getId(); |
|
317 | - if (!is_null($sid)) { |
|
318 | - $sid = explode(':', $sid); |
|
319 | - return ($sid[0] !== 'home' and $sid[0] !== 'shared'); |
|
320 | - } |
|
321 | - |
|
322 | - return false; |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * Get the mountpoint the file belongs to |
|
327 | - * |
|
328 | - * @return \OCP\Files\Mount\IMountPoint |
|
329 | - */ |
|
330 | - public function getMountPoint() { |
|
331 | - return $this->mount; |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * Get the owner of the file |
|
336 | - * |
|
337 | - * @return \OCP\IUser |
|
338 | - */ |
|
339 | - public function getOwner() { |
|
340 | - return $this->owner; |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * @param IMountPoint[] $mounts |
|
345 | - */ |
|
346 | - public function setSubMounts(array $mounts) { |
|
347 | - $this->subMounts = $mounts; |
|
348 | - } |
|
349 | - |
|
350 | - private function updateEntryfromSubMounts() { |
|
351 | - if ($this->subMountsUsed) { |
|
352 | - return; |
|
353 | - } |
|
354 | - $this->subMountsUsed = true; |
|
355 | - foreach ($this->subMounts as $mount) { |
|
356 | - $subStorage = $mount->getStorage(); |
|
357 | - if ($subStorage) { |
|
358 | - $subCache = $subStorage->getCache(''); |
|
359 | - $rootEntry = $subCache->get(''); |
|
360 | - $this->addSubEntry($rootEntry, $mount->getMountPoint()); |
|
361 | - } |
|
362 | - } |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Add a cache entry which is the child of this folder |
|
367 | - * |
|
368 | - * Sets the size, etag and size to for cross-storage childs |
|
369 | - * |
|
370 | - * @param array|ICacheEntry $data cache entry for the child |
|
371 | - * @param string $entryPath full path of the child entry |
|
372 | - */ |
|
373 | - public function addSubEntry($data, $entryPath) { |
|
374 | - $this->data['size'] += isset($data['size']) ? $data['size'] : 0; |
|
375 | - if (isset($data['mtime'])) { |
|
376 | - $this->data['mtime'] = max($this->data['mtime'], $data['mtime']); |
|
377 | - } |
|
378 | - if (isset($data['etag'])) { |
|
379 | - // prefix the etag with the relative path of the subentry to propagate etag on mount moves |
|
380 | - $relativeEntryPath = substr($entryPath, strlen($this->getPath())); |
|
381 | - // attach the permissions to propagate etag on permision changes of submounts |
|
382 | - $permissions = isset($data['permissions']) ? $data['permissions'] : 0; |
|
383 | - $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions; |
|
384 | - } |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * @inheritdoc |
|
389 | - */ |
|
390 | - public function getChecksum() { |
|
391 | - return $this->data['checksum']; |
|
392 | - } |
|
41 | + /** |
|
42 | + * @var array $data |
|
43 | + */ |
|
44 | + private $data; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $path |
|
48 | + */ |
|
49 | + private $path; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var \OC\Files\Storage\Storage $storage |
|
53 | + */ |
|
54 | + private $storage; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var string $internalPath |
|
58 | + */ |
|
59 | + private $internalPath; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var \OCP\Files\Mount\IMountPoint |
|
63 | + */ |
|
64 | + private $mount; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var IUser |
|
68 | + */ |
|
69 | + private $owner; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var string[] |
|
73 | + */ |
|
74 | + private $childEtags = []; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var IMountPoint[] |
|
78 | + */ |
|
79 | + private $subMounts = []; |
|
80 | + |
|
81 | + private $subMountsUsed = false; |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string|boolean $path |
|
85 | + * @param Storage\Storage $storage |
|
86 | + * @param string $internalPath |
|
87 | + * @param array|ICacheEntry $data |
|
88 | + * @param \OCP\Files\Mount\IMountPoint $mount |
|
89 | + * @param \OCP\IUser|null $owner |
|
90 | + */ |
|
91 | + public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) { |
|
92 | + $this->path = $path; |
|
93 | + $this->storage = $storage; |
|
94 | + $this->internalPath = $internalPath; |
|
95 | + $this->data = $data; |
|
96 | + $this->mount = $mount; |
|
97 | + $this->owner = $owner; |
|
98 | + } |
|
99 | + |
|
100 | + public function offsetSet($offset, $value) { |
|
101 | + $this->data[$offset] = $value; |
|
102 | + } |
|
103 | + |
|
104 | + public function offsetExists($offset) { |
|
105 | + return isset($this->data[$offset]); |
|
106 | + } |
|
107 | + |
|
108 | + public function offsetUnset($offset) { |
|
109 | + unset($this->data[$offset]); |
|
110 | + } |
|
111 | + |
|
112 | + public function offsetGet($offset) { |
|
113 | + if ($offset === 'type') { |
|
114 | + return $this->getType(); |
|
115 | + } else if ($offset === 'etag') { |
|
116 | + return $this->getEtag(); |
|
117 | + } else if ($offset === 'size') { |
|
118 | + return $this->getSize(); |
|
119 | + } else if ($offset === 'mtime') { |
|
120 | + return $this->getMTime(); |
|
121 | + } elseif ($offset === 'permissions') { |
|
122 | + return $this->getPermissions(); |
|
123 | + } elseif (isset($this->data[$offset])) { |
|
124 | + return $this->data[$offset]; |
|
125 | + } else { |
|
126 | + return null; |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function getPath() { |
|
134 | + return $this->path; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return \OCP\Files\Storage |
|
139 | + */ |
|
140 | + public function getStorage() { |
|
141 | + return $this->storage; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function getInternalPath() { |
|
148 | + return $this->internalPath; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Get FileInfo ID or null in case of part file |
|
153 | + * |
|
154 | + * @return int|null |
|
155 | + */ |
|
156 | + public function getId() { |
|
157 | + return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @return string |
|
162 | + */ |
|
163 | + public function getMimetype() { |
|
164 | + return $this->data['mimetype']; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @return string |
|
169 | + */ |
|
170 | + public function getMimePart() { |
|
171 | + return $this->data['mimepart']; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function getName() { |
|
178 | + return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath()); |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function getEtag() { |
|
185 | + $this->updateEntryfromSubMounts(); |
|
186 | + if (count($this->childEtags) > 0) { |
|
187 | + $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags); |
|
188 | + return md5($combinedEtag); |
|
189 | + } else { |
|
190 | + return $this->data['etag']; |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @return int |
|
196 | + */ |
|
197 | + public function getSize() { |
|
198 | + $this->updateEntryfromSubMounts(); |
|
199 | + return isset($this->data['size']) ? 0 + $this->data['size'] : 0; |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * @return int |
|
204 | + */ |
|
205 | + public function getMTime() { |
|
206 | + $this->updateEntryfromSubMounts(); |
|
207 | + return (int) $this->data['mtime']; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @return bool |
|
212 | + */ |
|
213 | + public function isEncrypted() { |
|
214 | + return $this->data['encrypted']; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Return the currently version used for the HMAC in the encryption app |
|
219 | + * |
|
220 | + * @return int |
|
221 | + */ |
|
222 | + public function getEncryptedVersion() { |
|
223 | + return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return int |
|
228 | + */ |
|
229 | + public function getPermissions() { |
|
230 | + $perms = (int) $this->data['permissions']; |
|
231 | + if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { |
|
232 | + $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; |
|
233 | + } |
|
234 | + return (int) $perms; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER |
|
239 | + */ |
|
240 | + public function getType() { |
|
241 | + if (!isset($this->data['type'])) { |
|
242 | + $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE; |
|
243 | + } |
|
244 | + return $this->data['type']; |
|
245 | + } |
|
246 | + |
|
247 | + public function getData() { |
|
248 | + return $this->data; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * @param int $permissions |
|
253 | + * @return bool |
|
254 | + */ |
|
255 | + protected function checkPermissions($permissions) { |
|
256 | + return ($this->getPermissions() & $permissions) === $permissions; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * @return bool |
|
261 | + */ |
|
262 | + public function isReadable() { |
|
263 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * @return bool |
|
268 | + */ |
|
269 | + public function isUpdateable() { |
|
270 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Check whether new files or folders can be created inside this folder |
|
275 | + * |
|
276 | + * @return bool |
|
277 | + */ |
|
278 | + public function isCreatable() { |
|
279 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * @return bool |
|
284 | + */ |
|
285 | + public function isDeletable() { |
|
286 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * @return bool |
|
291 | + */ |
|
292 | + public function isShareable() { |
|
293 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * Check if a file or folder is shared |
|
298 | + * |
|
299 | + * @return bool |
|
300 | + */ |
|
301 | + public function isShared() { |
|
302 | + $sid = $this->getStorage()->getId(); |
|
303 | + if (!is_null($sid)) { |
|
304 | + $sid = explode(':', $sid); |
|
305 | + return ($sid[0] === 'shared'); |
|
306 | + } |
|
307 | + |
|
308 | + return false; |
|
309 | + } |
|
310 | + |
|
311 | + public function isMounted() { |
|
312 | + $storage = $this->getStorage(); |
|
313 | + if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { |
|
314 | + return false; |
|
315 | + } |
|
316 | + $sid = $storage->getId(); |
|
317 | + if (!is_null($sid)) { |
|
318 | + $sid = explode(':', $sid); |
|
319 | + return ($sid[0] !== 'home' and $sid[0] !== 'shared'); |
|
320 | + } |
|
321 | + |
|
322 | + return false; |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * Get the mountpoint the file belongs to |
|
327 | + * |
|
328 | + * @return \OCP\Files\Mount\IMountPoint |
|
329 | + */ |
|
330 | + public function getMountPoint() { |
|
331 | + return $this->mount; |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * Get the owner of the file |
|
336 | + * |
|
337 | + * @return \OCP\IUser |
|
338 | + */ |
|
339 | + public function getOwner() { |
|
340 | + return $this->owner; |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * @param IMountPoint[] $mounts |
|
345 | + */ |
|
346 | + public function setSubMounts(array $mounts) { |
|
347 | + $this->subMounts = $mounts; |
|
348 | + } |
|
349 | + |
|
350 | + private function updateEntryfromSubMounts() { |
|
351 | + if ($this->subMountsUsed) { |
|
352 | + return; |
|
353 | + } |
|
354 | + $this->subMountsUsed = true; |
|
355 | + foreach ($this->subMounts as $mount) { |
|
356 | + $subStorage = $mount->getStorage(); |
|
357 | + if ($subStorage) { |
|
358 | + $subCache = $subStorage->getCache(''); |
|
359 | + $rootEntry = $subCache->get(''); |
|
360 | + $this->addSubEntry($rootEntry, $mount->getMountPoint()); |
|
361 | + } |
|
362 | + } |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Add a cache entry which is the child of this folder |
|
367 | + * |
|
368 | + * Sets the size, etag and size to for cross-storage childs |
|
369 | + * |
|
370 | + * @param array|ICacheEntry $data cache entry for the child |
|
371 | + * @param string $entryPath full path of the child entry |
|
372 | + */ |
|
373 | + public function addSubEntry($data, $entryPath) { |
|
374 | + $this->data['size'] += isset($data['size']) ? $data['size'] : 0; |
|
375 | + if (isset($data['mtime'])) { |
|
376 | + $this->data['mtime'] = max($this->data['mtime'], $data['mtime']); |
|
377 | + } |
|
378 | + if (isset($data['etag'])) { |
|
379 | + // prefix the etag with the relative path of the subentry to propagate etag on mount moves |
|
380 | + $relativeEntryPath = substr($entryPath, strlen($this->getPath())); |
|
381 | + // attach the permissions to propagate etag on permision changes of submounts |
|
382 | + $permissions = isset($data['permissions']) ? $data['permissions'] : 0; |
|
383 | + $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions; |
|
384 | + } |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * @inheritdoc |
|
389 | + */ |
|
390 | + public function getChecksum() { |
|
391 | + return $this->data['checksum']; |
|
392 | + } |
|
393 | 393 | } |