@@ -32,36 +32,36 @@ |
||
32 | 32 | */ |
33 | 33 | interface IBackend { |
34 | 34 | |
35 | - /** |
|
36 | - * get a list of all rooms in this backend |
|
37 | - * |
|
38 | - * @throws BackendTemporarilyUnavailableException |
|
39 | - * @return IRoom[] |
|
40 | - */ |
|
41 | - public function getAllRooms():array; |
|
35 | + /** |
|
36 | + * get a list of all rooms in this backend |
|
37 | + * |
|
38 | + * @throws BackendTemporarilyUnavailableException |
|
39 | + * @return IRoom[] |
|
40 | + */ |
|
41 | + public function getAllRooms():array; |
|
42 | 42 | |
43 | - /** |
|
44 | - * get a list of all room identifiers in this backend |
|
45 | - * |
|
46 | - * @throws BackendTemporarilyUnavailableException |
|
47 | - * @return string[] |
|
48 | - */ |
|
49 | - public function listAllRooms():array; |
|
43 | + /** |
|
44 | + * get a list of all room identifiers in this backend |
|
45 | + * |
|
46 | + * @throws BackendTemporarilyUnavailableException |
|
47 | + * @return string[] |
|
48 | + */ |
|
49 | + public function listAllRooms():array; |
|
50 | 50 | |
51 | - /** |
|
52 | - * get a room by it's id |
|
53 | - * |
|
54 | - * @param string $id |
|
55 | - * @throws BackendTemporarilyUnavailableException |
|
56 | - * @return IRoom|null |
|
57 | - */ |
|
58 | - public function getRoom($id); |
|
51 | + /** |
|
52 | + * get a room by it's id |
|
53 | + * |
|
54 | + * @param string $id |
|
55 | + * @throws BackendTemporarilyUnavailableException |
|
56 | + * @return IRoom|null |
|
57 | + */ |
|
58 | + public function getRoom($id); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get unique identifier of the backend |
|
62 | - * |
|
63 | - * @return string |
|
64 | - * @since 14.0.0 |
|
65 | - */ |
|
66 | - public function getBackendIdentifier():string; |
|
60 | + /** |
|
61 | + * Get unique identifier of the backend |
|
62 | + * |
|
63 | + * @return string |
|
64 | + * @since 14.0.0 |
|
65 | + */ |
|
66 | + public function getBackendIdentifier():string; |
|
67 | 67 | } |
@@ -31,50 +31,50 @@ |
||
31 | 31 | */ |
32 | 32 | interface IRoom { |
33 | 33 | |
34 | - /** |
|
35 | - * get the room id |
|
36 | - * |
|
37 | - * This id has to be unique within the backend |
|
38 | - * |
|
39 | - * @return string |
|
40 | - * @since 14.0.0 |
|
41 | - */ |
|
42 | - public function getId():string; |
|
34 | + /** |
|
35 | + * get the room id |
|
36 | + * |
|
37 | + * This id has to be unique within the backend |
|
38 | + * |
|
39 | + * @return string |
|
40 | + * @since 14.0.0 |
|
41 | + */ |
|
42 | + public function getId():string; |
|
43 | 43 | |
44 | - /** |
|
45 | - * get the display name for a room |
|
46 | - * |
|
47 | - * @return string |
|
48 | - * @since 14.0.0 |
|
49 | - */ |
|
50 | - public function getDisplayName():string; |
|
44 | + /** |
|
45 | + * get the display name for a room |
|
46 | + * |
|
47 | + * @return string |
|
48 | + * @since 14.0.0 |
|
49 | + */ |
|
50 | + public function getDisplayName():string; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get a list of groupIds that are allowed to access this room |
|
54 | - * |
|
55 | - * If an empty array is returned, no group restrictions are |
|
56 | - * applied. |
|
57 | - * |
|
58 | - * @return string[] |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - public function getGroupRestrictions():array; |
|
52 | + /** |
|
53 | + * Get a list of groupIds that are allowed to access this room |
|
54 | + * |
|
55 | + * If an empty array is returned, no group restrictions are |
|
56 | + * applied. |
|
57 | + * |
|
58 | + * @return string[] |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + public function getGroupRestrictions():array; |
|
62 | 62 | |
63 | - /** |
|
64 | - * get email-address for room |
|
65 | - * |
|
66 | - * The email address has to be globally unique |
|
67 | - * |
|
68 | - * @return string |
|
69 | - * @since 14.0.0 |
|
70 | - */ |
|
71 | - public function getEMail():string; |
|
63 | + /** |
|
64 | + * get email-address for room |
|
65 | + * |
|
66 | + * The email address has to be globally unique |
|
67 | + * |
|
68 | + * @return string |
|
69 | + * @since 14.0.0 |
|
70 | + */ |
|
71 | + public function getEMail():string; |
|
72 | 72 | |
73 | - /** |
|
74 | - * Get corresponding backend object |
|
75 | - * |
|
76 | - * @return IBackend |
|
77 | - * @since 14.0.0 |
|
78 | - */ |
|
79 | - public function getBackend():IBackend; |
|
73 | + /** |
|
74 | + * Get corresponding backend object |
|
75 | + * |
|
76 | + * @return IBackend |
|
77 | + * @since 14.0.0 |
|
78 | + */ |
|
79 | + public function getBackend():IBackend; |
|
80 | 80 | } |
@@ -25,40 +25,40 @@ |
||
25 | 25 | |
26 | 26 | interface IManager { |
27 | 27 | |
28 | - /** |
|
29 | - * Registers a room backend |
|
30 | - * |
|
31 | - * @param IBackend $backend |
|
32 | - * @return void |
|
33 | - * @since 14.0.0 |
|
34 | - */ |
|
35 | - public function registerBackend(IBackend $backend); |
|
28 | + /** |
|
29 | + * Registers a room backend |
|
30 | + * |
|
31 | + * @param IBackend $backend |
|
32 | + * @return void |
|
33 | + * @since 14.0.0 |
|
34 | + */ |
|
35 | + public function registerBackend(IBackend $backend); |
|
36 | 36 | |
37 | - /** |
|
38 | - * Unregisters a room backend |
|
39 | - * |
|
40 | - * @param IBackend $backend |
|
41 | - * @return void |
|
42 | - * @since 14.0.0 |
|
43 | - */ |
|
44 | - public function unregisterBackend(IBackend $backend); |
|
37 | + /** |
|
38 | + * Unregisters a room backend |
|
39 | + * |
|
40 | + * @param IBackend $backend |
|
41 | + * @return void |
|
42 | + * @since 14.0.0 |
|
43 | + */ |
|
44 | + public function unregisterBackend(IBackend $backend); |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return IBackend[] |
|
48 | - * @since 14.0.0 |
|
49 | - */ |
|
50 | - public function getBackends():array; |
|
46 | + /** |
|
47 | + * @return IBackend[] |
|
48 | + * @since 14.0.0 |
|
49 | + */ |
|
50 | + public function getBackends():array; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string $backendId |
|
54 | - * @return IBackend |
|
55 | - */ |
|
56 | - public function getBackend($backendId):IBackend; |
|
52 | + /** |
|
53 | + * @param string $backendId |
|
54 | + * @return IBackend |
|
55 | + */ |
|
56 | + public function getBackend($backendId):IBackend; |
|
57 | 57 | |
58 | - /** |
|
59 | - * removes all registered backend instances |
|
60 | - * @return void |
|
61 | - * @since 14.0.0 |
|
62 | - */ |
|
63 | - public function clear(); |
|
58 | + /** |
|
59 | + * removes all registered backend instances |
|
60 | + * @return void |
|
61 | + * @since 14.0.0 |
|
62 | + */ |
|
63 | + public function clear(); |
|
64 | 64 | } |
@@ -58,510 +58,510 @@ |
||
58 | 58 | */ |
59 | 59 | interface IServerContainer extends IContainer { |
60 | 60 | |
61 | - /** |
|
62 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
63 | - * providers which actual deliver the calendar information. |
|
64 | - * |
|
65 | - * @return \OCP\Calendar\IManager |
|
66 | - * @since 13.0.0 |
|
67 | - */ |
|
68 | - public function getCalendarManager(); |
|
69 | - |
|
70 | - /** |
|
71 | - * The calendar resource backend manager will act as a broker between consumers |
|
72 | - * for calendar resource information an providers which actual deliver the room information. |
|
73 | - * |
|
74 | - * @return \OCP\Calendar\Resource\IBackend |
|
75 | - * @since 14.0.0 |
|
76 | - */ |
|
77 | - public function getCalendarResourceBackendManager(); |
|
78 | - |
|
79 | - /** |
|
80 | - * The calendar room backend manager will act as a broker between consumers |
|
81 | - * for calendar room information an providers which actual deliver the room information. |
|
82 | - * |
|
83 | - * @return \OCP\Calendar\Room\IBackend |
|
84 | - * @since 14.0.0 |
|
85 | - */ |
|
86 | - public function getCalendarRoomBackendManager(); |
|
87 | - |
|
88 | - /** |
|
89 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
90 | - * providers which actual deliver the contact information. |
|
91 | - * |
|
92 | - * @return \OCP\Contacts\IManager |
|
93 | - * @since 6.0.0 |
|
94 | - */ |
|
95 | - public function getContactsManager(); |
|
96 | - |
|
97 | - /** |
|
98 | - * The current request object holding all information about the request currently being processed |
|
99 | - * is returned from this method. |
|
100 | - * In case the current execution was not initiated by a web request null is returned |
|
101 | - * |
|
102 | - * @return \OCP\IRequest |
|
103 | - * @since 6.0.0 |
|
104 | - */ |
|
105 | - public function getRequest(); |
|
106 | - |
|
107 | - /** |
|
108 | - * Returns the preview manager which can create preview images for a given file |
|
109 | - * |
|
110 | - * @return \OCP\IPreview |
|
111 | - * @since 6.0.0 |
|
112 | - */ |
|
113 | - public function getPreviewManager(); |
|
114 | - |
|
115 | - /** |
|
116 | - * Returns the tag manager which can get and set tags for different object types |
|
117 | - * |
|
118 | - * @see \OCP\ITagManager::load() |
|
119 | - * @return \OCP\ITagManager |
|
120 | - * @since 6.0.0 |
|
121 | - */ |
|
122 | - public function getTagManager(); |
|
123 | - |
|
124 | - /** |
|
125 | - * Returns the root folder of ownCloud's data directory |
|
126 | - * |
|
127 | - * @return \OCP\Files\IRootFolder |
|
128 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
129 | - */ |
|
130 | - public function getRootFolder(); |
|
131 | - |
|
132 | - /** |
|
133 | - * Returns a view to ownCloud's files folder |
|
134 | - * |
|
135 | - * @param string $userId user ID |
|
136 | - * @return \OCP\Files\Folder |
|
137 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
138 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
139 | - */ |
|
140 | - public function getUserFolder($userId = null); |
|
141 | - |
|
142 | - /** |
|
143 | - * Returns an app-specific view in ownClouds data directory |
|
144 | - * |
|
145 | - * @return \OCP\Files\Folder |
|
146 | - * @since 6.0.0 |
|
147 | - * @deprecated 9.2.0 use IAppData |
|
148 | - */ |
|
149 | - public function getAppFolder(); |
|
150 | - |
|
151 | - /** |
|
152 | - * Returns a user manager |
|
153 | - * |
|
154 | - * @return \OCP\IUserManager |
|
155 | - * @since 8.0.0 |
|
156 | - */ |
|
157 | - public function getUserManager(); |
|
158 | - |
|
159 | - /** |
|
160 | - * Returns a group manager |
|
161 | - * |
|
162 | - * @return \OCP\IGroupManager |
|
163 | - * @since 8.0.0 |
|
164 | - */ |
|
165 | - public function getGroupManager(); |
|
166 | - |
|
167 | - /** |
|
168 | - * Returns the user session |
|
169 | - * |
|
170 | - * @return \OCP\IUserSession |
|
171 | - * @since 6.0.0 |
|
172 | - */ |
|
173 | - public function getUserSession(); |
|
174 | - |
|
175 | - /** |
|
176 | - * Returns the navigation manager |
|
177 | - * |
|
178 | - * @return \OCP\INavigationManager |
|
179 | - * @since 6.0.0 |
|
180 | - */ |
|
181 | - public function getNavigationManager(); |
|
182 | - |
|
183 | - /** |
|
184 | - * Returns the config manager |
|
185 | - * |
|
186 | - * @return \OCP\IConfig |
|
187 | - * @since 6.0.0 |
|
188 | - */ |
|
189 | - public function getConfig(); |
|
190 | - |
|
191 | - /** |
|
192 | - * Returns a Crypto instance |
|
193 | - * |
|
194 | - * @return \OCP\Security\ICrypto |
|
195 | - * @since 8.0.0 |
|
196 | - */ |
|
197 | - public function getCrypto(); |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns a Hasher instance |
|
201 | - * |
|
202 | - * @return \OCP\Security\IHasher |
|
203 | - * @since 8.0.0 |
|
204 | - */ |
|
205 | - public function getHasher(); |
|
206 | - |
|
207 | - /** |
|
208 | - * Returns a SecureRandom instance |
|
209 | - * |
|
210 | - * @return \OCP\Security\ISecureRandom |
|
211 | - * @since 8.1.0 |
|
212 | - */ |
|
213 | - public function getSecureRandom(); |
|
214 | - |
|
215 | - /** |
|
216 | - * Returns a CredentialsManager instance |
|
217 | - * |
|
218 | - * @return \OCP\Security\ICredentialsManager |
|
219 | - * @since 9.0.0 |
|
220 | - */ |
|
221 | - public function getCredentialsManager(); |
|
222 | - |
|
223 | - /** |
|
224 | - * Returns the app config manager |
|
225 | - * |
|
226 | - * @return \OCP\IAppConfig |
|
227 | - * @since 7.0.0 |
|
228 | - */ |
|
229 | - public function getAppConfig(); |
|
230 | - |
|
231 | - /** |
|
232 | - * @return \OCP\L10N\IFactory |
|
233 | - * @since 8.2.0 |
|
234 | - */ |
|
235 | - public function getL10NFactory(); |
|
236 | - |
|
237 | - /** |
|
238 | - * get an L10N instance |
|
239 | - * @param string $app appid |
|
240 | - * @param string $lang |
|
241 | - * @return \OCP\IL10N |
|
242 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
243 | - */ |
|
244 | - public function getL10N($app, $lang = null); |
|
245 | - |
|
246 | - /** |
|
247 | - * @return \OC\Encryption\Manager |
|
248 | - * @since 8.1.0 |
|
249 | - */ |
|
250 | - public function getEncryptionManager(); |
|
251 | - |
|
252 | - /** |
|
253 | - * @return \OC\Encryption\File |
|
254 | - * @since 8.1.0 |
|
255 | - */ |
|
256 | - public function getEncryptionFilesHelper(); |
|
257 | - |
|
258 | - /** |
|
259 | - * @return \OCP\Encryption\Keys\IStorage |
|
260 | - * @since 8.1.0 |
|
261 | - */ |
|
262 | - public function getEncryptionKeyStorage(); |
|
263 | - |
|
264 | - /** |
|
265 | - * Returns the URL generator |
|
266 | - * |
|
267 | - * @return \OCP\IURLGenerator |
|
268 | - * @since 6.0.0 |
|
269 | - */ |
|
270 | - public function getURLGenerator(); |
|
271 | - |
|
272 | - /** |
|
273 | - * Returns an ICache instance |
|
274 | - * |
|
275 | - * @return \OCP\ICache |
|
276 | - * @since 6.0.0 |
|
277 | - */ |
|
278 | - public function getCache(); |
|
279 | - |
|
280 | - /** |
|
281 | - * Returns an \OCP\CacheFactory instance |
|
282 | - * |
|
283 | - * @return \OCP\ICacheFactory |
|
284 | - * @since 7.0.0 |
|
285 | - */ |
|
286 | - public function getMemCacheFactory(); |
|
287 | - |
|
288 | - /** |
|
289 | - * Returns the current session |
|
290 | - * |
|
291 | - * @return \OCP\ISession |
|
292 | - * @since 6.0.0 |
|
293 | - */ |
|
294 | - public function getSession(); |
|
295 | - |
|
296 | - /** |
|
297 | - * Returns the activity manager |
|
298 | - * |
|
299 | - * @return \OCP\Activity\IManager |
|
300 | - * @since 6.0.0 |
|
301 | - */ |
|
302 | - public function getActivityManager(); |
|
303 | - |
|
304 | - /** |
|
305 | - * Returns the current session |
|
306 | - * |
|
307 | - * @return \OCP\IDBConnection |
|
308 | - * @since 6.0.0 |
|
309 | - */ |
|
310 | - public function getDatabaseConnection(); |
|
311 | - |
|
312 | - /** |
|
313 | - * Returns an avatar manager, used for avatar functionality |
|
314 | - * |
|
315 | - * @return \OCP\IAvatarManager |
|
316 | - * @since 6.0.0 |
|
317 | - */ |
|
318 | - public function getAvatarManager(); |
|
319 | - |
|
320 | - /** |
|
321 | - * Returns an job list for controlling background jobs |
|
322 | - * |
|
323 | - * @return \OCP\BackgroundJob\IJobList |
|
324 | - * @since 7.0.0 |
|
325 | - */ |
|
326 | - public function getJobList(); |
|
327 | - |
|
328 | - /** |
|
329 | - * Returns a logger instance |
|
330 | - * |
|
331 | - * @return \OCP\ILogger |
|
332 | - * @since 8.0.0 |
|
333 | - */ |
|
334 | - public function getLogger(); |
|
335 | - |
|
336 | - /** |
|
337 | - * returns a log factory instance |
|
338 | - * |
|
339 | - * @return ILogFactory |
|
340 | - * @since 14.0.0 |
|
341 | - */ |
|
342 | - public function getLogFactory(); |
|
343 | - |
|
344 | - /** |
|
345 | - * Returns a router for generating and matching urls |
|
346 | - * |
|
347 | - * @return \OCP\Route\IRouter |
|
348 | - * @since 7.0.0 |
|
349 | - */ |
|
350 | - public function getRouter(); |
|
351 | - |
|
352 | - /** |
|
353 | - * Returns a search instance |
|
354 | - * |
|
355 | - * @return \OCP\ISearch |
|
356 | - * @since 7.0.0 |
|
357 | - */ |
|
358 | - public function getSearch(); |
|
359 | - |
|
360 | - /** |
|
361 | - * Get the certificate manager for the user |
|
362 | - * |
|
363 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
364 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
365 | - * @since 8.0.0 |
|
366 | - */ |
|
367 | - public function getCertificateManager($userId = null); |
|
368 | - |
|
369 | - /** |
|
370 | - * Create a new event source |
|
371 | - * |
|
372 | - * @return \OCP\IEventSource |
|
373 | - * @since 8.0.0 |
|
374 | - */ |
|
375 | - public function createEventSource(); |
|
376 | - |
|
377 | - /** |
|
378 | - * Returns an instance of the HTTP client service |
|
379 | - * |
|
380 | - * @return \OCP\Http\Client\IClientService |
|
381 | - * @since 8.1.0 |
|
382 | - */ |
|
383 | - public function getHTTPClientService(); |
|
384 | - |
|
385 | - /** |
|
386 | - * Get the active event logger |
|
387 | - * |
|
388 | - * @return \OCP\Diagnostics\IEventLogger |
|
389 | - * @since 8.0.0 |
|
390 | - */ |
|
391 | - public function getEventLogger(); |
|
392 | - |
|
393 | - /** |
|
394 | - * Get the active query logger |
|
395 | - * |
|
396 | - * The returned logger only logs data when debug mode is enabled |
|
397 | - * |
|
398 | - * @return \OCP\Diagnostics\IQueryLogger |
|
399 | - * @since 8.0.0 |
|
400 | - */ |
|
401 | - public function getQueryLogger(); |
|
402 | - |
|
403 | - /** |
|
404 | - * Get the manager for temporary files and folders |
|
405 | - * |
|
406 | - * @return \OCP\ITempManager |
|
407 | - * @since 8.0.0 |
|
408 | - */ |
|
409 | - public function getTempManager(); |
|
410 | - |
|
411 | - /** |
|
412 | - * Get the app manager |
|
413 | - * |
|
414 | - * @return \OCP\App\IAppManager |
|
415 | - * @since 8.0.0 |
|
416 | - */ |
|
417 | - public function getAppManager(); |
|
418 | - |
|
419 | - /** |
|
420 | - * Get the webroot |
|
421 | - * |
|
422 | - * @return string |
|
423 | - * @since 8.0.0 |
|
424 | - */ |
|
425 | - public function getWebRoot(); |
|
426 | - |
|
427 | - /** |
|
428 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
429 | - * @since 8.0.0 |
|
430 | - */ |
|
431 | - public function getMountProviderCollection(); |
|
432 | - |
|
433 | - /** |
|
434 | - * Get the IniWrapper |
|
435 | - * |
|
436 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
437 | - * @since 8.0.0 |
|
438 | - */ |
|
439 | - public function getIniWrapper(); |
|
440 | - /** |
|
441 | - * @return \OCP\Command\IBus |
|
442 | - * @since 8.1.0 |
|
443 | - */ |
|
444 | - public function getCommandBus(); |
|
445 | - |
|
446 | - /** |
|
447 | - * Creates a new mailer |
|
448 | - * |
|
449 | - * @return \OCP\Mail\IMailer |
|
450 | - * @since 8.1.0 |
|
451 | - */ |
|
452 | - public function getMailer(); |
|
453 | - |
|
454 | - /** |
|
455 | - * Get the locking provider |
|
456 | - * |
|
457 | - * @return \OCP\Lock\ILockingProvider |
|
458 | - * @since 8.1.0 |
|
459 | - */ |
|
460 | - public function getLockingProvider(); |
|
461 | - |
|
462 | - /** |
|
463 | - * @return \OCP\Files\Mount\IMountManager |
|
464 | - * @since 8.2.0 |
|
465 | - */ |
|
466 | - public function getMountManager(); |
|
467 | - |
|
468 | - /** |
|
469 | - * Get the MimeTypeDetector |
|
470 | - * |
|
471 | - * @return \OCP\Files\IMimeTypeDetector |
|
472 | - * @since 8.2.0 |
|
473 | - */ |
|
474 | - public function getMimeTypeDetector(); |
|
475 | - |
|
476 | - /** |
|
477 | - * Get the MimeTypeLoader |
|
478 | - * |
|
479 | - * @return \OCP\Files\IMimeTypeLoader |
|
480 | - * @since 8.2.0 |
|
481 | - */ |
|
482 | - public function getMimeTypeLoader(); |
|
483 | - |
|
484 | - /** |
|
485 | - * Get the EventDispatcher |
|
486 | - * |
|
487 | - * @return EventDispatcherInterface |
|
488 | - * @since 8.2.0 |
|
489 | - */ |
|
490 | - public function getEventDispatcher(); |
|
491 | - |
|
492 | - /** |
|
493 | - * Get the Notification Manager |
|
494 | - * |
|
495 | - * @return \OCP\Notification\IManager |
|
496 | - * @since 9.0.0 |
|
497 | - */ |
|
498 | - public function getNotificationManager(); |
|
499 | - |
|
500 | - /** |
|
501 | - * @return \OCP\Comments\ICommentsManager |
|
502 | - * @since 9.0.0 |
|
503 | - */ |
|
504 | - public function getCommentsManager(); |
|
505 | - |
|
506 | - /** |
|
507 | - * Returns the system-tag manager |
|
508 | - * |
|
509 | - * @return \OCP\SystemTag\ISystemTagManager |
|
510 | - * |
|
511 | - * @since 9.0.0 |
|
512 | - */ |
|
513 | - public function getSystemTagManager(); |
|
514 | - |
|
515 | - /** |
|
516 | - * Returns the system-tag object mapper |
|
517 | - * |
|
518 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
519 | - * |
|
520 | - * @since 9.0.0 |
|
521 | - */ |
|
522 | - public function getSystemTagObjectMapper(); |
|
523 | - |
|
524 | - /** |
|
525 | - * Returns the share manager |
|
526 | - * |
|
527 | - * @return \OCP\Share\IManager |
|
528 | - * @since 9.0.0 |
|
529 | - */ |
|
530 | - public function getShareManager(); |
|
531 | - |
|
532 | - /** |
|
533 | - * @return IContentSecurityPolicyManager |
|
534 | - * @since 9.0.0 |
|
535 | - */ |
|
536 | - public function getContentSecurityPolicyManager(); |
|
537 | - |
|
538 | - /** |
|
539 | - * @return \OCP\IDateTimeZone |
|
540 | - * @since 8.0.0 |
|
541 | - */ |
|
542 | - public function getDateTimeZone(); |
|
543 | - |
|
544 | - /** |
|
545 | - * @return \OCP\IDateTimeFormatter |
|
546 | - * @since 8.0.0 |
|
547 | - */ |
|
548 | - public function getDateTimeFormatter(); |
|
549 | - |
|
550 | - /** |
|
551 | - * @return \OCP\Federation\ICloudIdManager |
|
552 | - * @since 12.0.0 |
|
553 | - */ |
|
554 | - public function getCloudIdManager(); |
|
555 | - |
|
556 | - /** |
|
557 | - * @return \OCP\Remote\Api\IApiFactory |
|
558 | - * @since 13.0.0 |
|
559 | - */ |
|
560 | - public function getRemoteApiFactory(); |
|
561 | - |
|
562 | - /** |
|
563 | - * @return \OCP\Remote\IInstanceFactory |
|
564 | - * @since 13.0.0 |
|
565 | - */ |
|
566 | - public function getRemoteInstanceFactory(); |
|
61 | + /** |
|
62 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
63 | + * providers which actual deliver the calendar information. |
|
64 | + * |
|
65 | + * @return \OCP\Calendar\IManager |
|
66 | + * @since 13.0.0 |
|
67 | + */ |
|
68 | + public function getCalendarManager(); |
|
69 | + |
|
70 | + /** |
|
71 | + * The calendar resource backend manager will act as a broker between consumers |
|
72 | + * for calendar resource information an providers which actual deliver the room information. |
|
73 | + * |
|
74 | + * @return \OCP\Calendar\Resource\IBackend |
|
75 | + * @since 14.0.0 |
|
76 | + */ |
|
77 | + public function getCalendarResourceBackendManager(); |
|
78 | + |
|
79 | + /** |
|
80 | + * The calendar room backend manager will act as a broker between consumers |
|
81 | + * for calendar room information an providers which actual deliver the room information. |
|
82 | + * |
|
83 | + * @return \OCP\Calendar\Room\IBackend |
|
84 | + * @since 14.0.0 |
|
85 | + */ |
|
86 | + public function getCalendarRoomBackendManager(); |
|
87 | + |
|
88 | + /** |
|
89 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
90 | + * providers which actual deliver the contact information. |
|
91 | + * |
|
92 | + * @return \OCP\Contacts\IManager |
|
93 | + * @since 6.0.0 |
|
94 | + */ |
|
95 | + public function getContactsManager(); |
|
96 | + |
|
97 | + /** |
|
98 | + * The current request object holding all information about the request currently being processed |
|
99 | + * is returned from this method. |
|
100 | + * In case the current execution was not initiated by a web request null is returned |
|
101 | + * |
|
102 | + * @return \OCP\IRequest |
|
103 | + * @since 6.0.0 |
|
104 | + */ |
|
105 | + public function getRequest(); |
|
106 | + |
|
107 | + /** |
|
108 | + * Returns the preview manager which can create preview images for a given file |
|
109 | + * |
|
110 | + * @return \OCP\IPreview |
|
111 | + * @since 6.0.0 |
|
112 | + */ |
|
113 | + public function getPreviewManager(); |
|
114 | + |
|
115 | + /** |
|
116 | + * Returns the tag manager which can get and set tags for different object types |
|
117 | + * |
|
118 | + * @see \OCP\ITagManager::load() |
|
119 | + * @return \OCP\ITagManager |
|
120 | + * @since 6.0.0 |
|
121 | + */ |
|
122 | + public function getTagManager(); |
|
123 | + |
|
124 | + /** |
|
125 | + * Returns the root folder of ownCloud's data directory |
|
126 | + * |
|
127 | + * @return \OCP\Files\IRootFolder |
|
128 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
129 | + */ |
|
130 | + public function getRootFolder(); |
|
131 | + |
|
132 | + /** |
|
133 | + * Returns a view to ownCloud's files folder |
|
134 | + * |
|
135 | + * @param string $userId user ID |
|
136 | + * @return \OCP\Files\Folder |
|
137 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
138 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
139 | + */ |
|
140 | + public function getUserFolder($userId = null); |
|
141 | + |
|
142 | + /** |
|
143 | + * Returns an app-specific view in ownClouds data directory |
|
144 | + * |
|
145 | + * @return \OCP\Files\Folder |
|
146 | + * @since 6.0.0 |
|
147 | + * @deprecated 9.2.0 use IAppData |
|
148 | + */ |
|
149 | + public function getAppFolder(); |
|
150 | + |
|
151 | + /** |
|
152 | + * Returns a user manager |
|
153 | + * |
|
154 | + * @return \OCP\IUserManager |
|
155 | + * @since 8.0.0 |
|
156 | + */ |
|
157 | + public function getUserManager(); |
|
158 | + |
|
159 | + /** |
|
160 | + * Returns a group manager |
|
161 | + * |
|
162 | + * @return \OCP\IGroupManager |
|
163 | + * @since 8.0.0 |
|
164 | + */ |
|
165 | + public function getGroupManager(); |
|
166 | + |
|
167 | + /** |
|
168 | + * Returns the user session |
|
169 | + * |
|
170 | + * @return \OCP\IUserSession |
|
171 | + * @since 6.0.0 |
|
172 | + */ |
|
173 | + public function getUserSession(); |
|
174 | + |
|
175 | + /** |
|
176 | + * Returns the navigation manager |
|
177 | + * |
|
178 | + * @return \OCP\INavigationManager |
|
179 | + * @since 6.0.0 |
|
180 | + */ |
|
181 | + public function getNavigationManager(); |
|
182 | + |
|
183 | + /** |
|
184 | + * Returns the config manager |
|
185 | + * |
|
186 | + * @return \OCP\IConfig |
|
187 | + * @since 6.0.0 |
|
188 | + */ |
|
189 | + public function getConfig(); |
|
190 | + |
|
191 | + /** |
|
192 | + * Returns a Crypto instance |
|
193 | + * |
|
194 | + * @return \OCP\Security\ICrypto |
|
195 | + * @since 8.0.0 |
|
196 | + */ |
|
197 | + public function getCrypto(); |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns a Hasher instance |
|
201 | + * |
|
202 | + * @return \OCP\Security\IHasher |
|
203 | + * @since 8.0.0 |
|
204 | + */ |
|
205 | + public function getHasher(); |
|
206 | + |
|
207 | + /** |
|
208 | + * Returns a SecureRandom instance |
|
209 | + * |
|
210 | + * @return \OCP\Security\ISecureRandom |
|
211 | + * @since 8.1.0 |
|
212 | + */ |
|
213 | + public function getSecureRandom(); |
|
214 | + |
|
215 | + /** |
|
216 | + * Returns a CredentialsManager instance |
|
217 | + * |
|
218 | + * @return \OCP\Security\ICredentialsManager |
|
219 | + * @since 9.0.0 |
|
220 | + */ |
|
221 | + public function getCredentialsManager(); |
|
222 | + |
|
223 | + /** |
|
224 | + * Returns the app config manager |
|
225 | + * |
|
226 | + * @return \OCP\IAppConfig |
|
227 | + * @since 7.0.0 |
|
228 | + */ |
|
229 | + public function getAppConfig(); |
|
230 | + |
|
231 | + /** |
|
232 | + * @return \OCP\L10N\IFactory |
|
233 | + * @since 8.2.0 |
|
234 | + */ |
|
235 | + public function getL10NFactory(); |
|
236 | + |
|
237 | + /** |
|
238 | + * get an L10N instance |
|
239 | + * @param string $app appid |
|
240 | + * @param string $lang |
|
241 | + * @return \OCP\IL10N |
|
242 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
243 | + */ |
|
244 | + public function getL10N($app, $lang = null); |
|
245 | + |
|
246 | + /** |
|
247 | + * @return \OC\Encryption\Manager |
|
248 | + * @since 8.1.0 |
|
249 | + */ |
|
250 | + public function getEncryptionManager(); |
|
251 | + |
|
252 | + /** |
|
253 | + * @return \OC\Encryption\File |
|
254 | + * @since 8.1.0 |
|
255 | + */ |
|
256 | + public function getEncryptionFilesHelper(); |
|
257 | + |
|
258 | + /** |
|
259 | + * @return \OCP\Encryption\Keys\IStorage |
|
260 | + * @since 8.1.0 |
|
261 | + */ |
|
262 | + public function getEncryptionKeyStorage(); |
|
263 | + |
|
264 | + /** |
|
265 | + * Returns the URL generator |
|
266 | + * |
|
267 | + * @return \OCP\IURLGenerator |
|
268 | + * @since 6.0.0 |
|
269 | + */ |
|
270 | + public function getURLGenerator(); |
|
271 | + |
|
272 | + /** |
|
273 | + * Returns an ICache instance |
|
274 | + * |
|
275 | + * @return \OCP\ICache |
|
276 | + * @since 6.0.0 |
|
277 | + */ |
|
278 | + public function getCache(); |
|
279 | + |
|
280 | + /** |
|
281 | + * Returns an \OCP\CacheFactory instance |
|
282 | + * |
|
283 | + * @return \OCP\ICacheFactory |
|
284 | + * @since 7.0.0 |
|
285 | + */ |
|
286 | + public function getMemCacheFactory(); |
|
287 | + |
|
288 | + /** |
|
289 | + * Returns the current session |
|
290 | + * |
|
291 | + * @return \OCP\ISession |
|
292 | + * @since 6.0.0 |
|
293 | + */ |
|
294 | + public function getSession(); |
|
295 | + |
|
296 | + /** |
|
297 | + * Returns the activity manager |
|
298 | + * |
|
299 | + * @return \OCP\Activity\IManager |
|
300 | + * @since 6.0.0 |
|
301 | + */ |
|
302 | + public function getActivityManager(); |
|
303 | + |
|
304 | + /** |
|
305 | + * Returns the current session |
|
306 | + * |
|
307 | + * @return \OCP\IDBConnection |
|
308 | + * @since 6.0.0 |
|
309 | + */ |
|
310 | + public function getDatabaseConnection(); |
|
311 | + |
|
312 | + /** |
|
313 | + * Returns an avatar manager, used for avatar functionality |
|
314 | + * |
|
315 | + * @return \OCP\IAvatarManager |
|
316 | + * @since 6.0.0 |
|
317 | + */ |
|
318 | + public function getAvatarManager(); |
|
319 | + |
|
320 | + /** |
|
321 | + * Returns an job list for controlling background jobs |
|
322 | + * |
|
323 | + * @return \OCP\BackgroundJob\IJobList |
|
324 | + * @since 7.0.0 |
|
325 | + */ |
|
326 | + public function getJobList(); |
|
327 | + |
|
328 | + /** |
|
329 | + * Returns a logger instance |
|
330 | + * |
|
331 | + * @return \OCP\ILogger |
|
332 | + * @since 8.0.0 |
|
333 | + */ |
|
334 | + public function getLogger(); |
|
335 | + |
|
336 | + /** |
|
337 | + * returns a log factory instance |
|
338 | + * |
|
339 | + * @return ILogFactory |
|
340 | + * @since 14.0.0 |
|
341 | + */ |
|
342 | + public function getLogFactory(); |
|
343 | + |
|
344 | + /** |
|
345 | + * Returns a router for generating and matching urls |
|
346 | + * |
|
347 | + * @return \OCP\Route\IRouter |
|
348 | + * @since 7.0.0 |
|
349 | + */ |
|
350 | + public function getRouter(); |
|
351 | + |
|
352 | + /** |
|
353 | + * Returns a search instance |
|
354 | + * |
|
355 | + * @return \OCP\ISearch |
|
356 | + * @since 7.0.0 |
|
357 | + */ |
|
358 | + public function getSearch(); |
|
359 | + |
|
360 | + /** |
|
361 | + * Get the certificate manager for the user |
|
362 | + * |
|
363 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
364 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
365 | + * @since 8.0.0 |
|
366 | + */ |
|
367 | + public function getCertificateManager($userId = null); |
|
368 | + |
|
369 | + /** |
|
370 | + * Create a new event source |
|
371 | + * |
|
372 | + * @return \OCP\IEventSource |
|
373 | + * @since 8.0.0 |
|
374 | + */ |
|
375 | + public function createEventSource(); |
|
376 | + |
|
377 | + /** |
|
378 | + * Returns an instance of the HTTP client service |
|
379 | + * |
|
380 | + * @return \OCP\Http\Client\IClientService |
|
381 | + * @since 8.1.0 |
|
382 | + */ |
|
383 | + public function getHTTPClientService(); |
|
384 | + |
|
385 | + /** |
|
386 | + * Get the active event logger |
|
387 | + * |
|
388 | + * @return \OCP\Diagnostics\IEventLogger |
|
389 | + * @since 8.0.0 |
|
390 | + */ |
|
391 | + public function getEventLogger(); |
|
392 | + |
|
393 | + /** |
|
394 | + * Get the active query logger |
|
395 | + * |
|
396 | + * The returned logger only logs data when debug mode is enabled |
|
397 | + * |
|
398 | + * @return \OCP\Diagnostics\IQueryLogger |
|
399 | + * @since 8.0.0 |
|
400 | + */ |
|
401 | + public function getQueryLogger(); |
|
402 | + |
|
403 | + /** |
|
404 | + * Get the manager for temporary files and folders |
|
405 | + * |
|
406 | + * @return \OCP\ITempManager |
|
407 | + * @since 8.0.0 |
|
408 | + */ |
|
409 | + public function getTempManager(); |
|
410 | + |
|
411 | + /** |
|
412 | + * Get the app manager |
|
413 | + * |
|
414 | + * @return \OCP\App\IAppManager |
|
415 | + * @since 8.0.0 |
|
416 | + */ |
|
417 | + public function getAppManager(); |
|
418 | + |
|
419 | + /** |
|
420 | + * Get the webroot |
|
421 | + * |
|
422 | + * @return string |
|
423 | + * @since 8.0.0 |
|
424 | + */ |
|
425 | + public function getWebRoot(); |
|
426 | + |
|
427 | + /** |
|
428 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
429 | + * @since 8.0.0 |
|
430 | + */ |
|
431 | + public function getMountProviderCollection(); |
|
432 | + |
|
433 | + /** |
|
434 | + * Get the IniWrapper |
|
435 | + * |
|
436 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
437 | + * @since 8.0.0 |
|
438 | + */ |
|
439 | + public function getIniWrapper(); |
|
440 | + /** |
|
441 | + * @return \OCP\Command\IBus |
|
442 | + * @since 8.1.0 |
|
443 | + */ |
|
444 | + public function getCommandBus(); |
|
445 | + |
|
446 | + /** |
|
447 | + * Creates a new mailer |
|
448 | + * |
|
449 | + * @return \OCP\Mail\IMailer |
|
450 | + * @since 8.1.0 |
|
451 | + */ |
|
452 | + public function getMailer(); |
|
453 | + |
|
454 | + /** |
|
455 | + * Get the locking provider |
|
456 | + * |
|
457 | + * @return \OCP\Lock\ILockingProvider |
|
458 | + * @since 8.1.0 |
|
459 | + */ |
|
460 | + public function getLockingProvider(); |
|
461 | + |
|
462 | + /** |
|
463 | + * @return \OCP\Files\Mount\IMountManager |
|
464 | + * @since 8.2.0 |
|
465 | + */ |
|
466 | + public function getMountManager(); |
|
467 | + |
|
468 | + /** |
|
469 | + * Get the MimeTypeDetector |
|
470 | + * |
|
471 | + * @return \OCP\Files\IMimeTypeDetector |
|
472 | + * @since 8.2.0 |
|
473 | + */ |
|
474 | + public function getMimeTypeDetector(); |
|
475 | + |
|
476 | + /** |
|
477 | + * Get the MimeTypeLoader |
|
478 | + * |
|
479 | + * @return \OCP\Files\IMimeTypeLoader |
|
480 | + * @since 8.2.0 |
|
481 | + */ |
|
482 | + public function getMimeTypeLoader(); |
|
483 | + |
|
484 | + /** |
|
485 | + * Get the EventDispatcher |
|
486 | + * |
|
487 | + * @return EventDispatcherInterface |
|
488 | + * @since 8.2.0 |
|
489 | + */ |
|
490 | + public function getEventDispatcher(); |
|
491 | + |
|
492 | + /** |
|
493 | + * Get the Notification Manager |
|
494 | + * |
|
495 | + * @return \OCP\Notification\IManager |
|
496 | + * @since 9.0.0 |
|
497 | + */ |
|
498 | + public function getNotificationManager(); |
|
499 | + |
|
500 | + /** |
|
501 | + * @return \OCP\Comments\ICommentsManager |
|
502 | + * @since 9.0.0 |
|
503 | + */ |
|
504 | + public function getCommentsManager(); |
|
505 | + |
|
506 | + /** |
|
507 | + * Returns the system-tag manager |
|
508 | + * |
|
509 | + * @return \OCP\SystemTag\ISystemTagManager |
|
510 | + * |
|
511 | + * @since 9.0.0 |
|
512 | + */ |
|
513 | + public function getSystemTagManager(); |
|
514 | + |
|
515 | + /** |
|
516 | + * Returns the system-tag object mapper |
|
517 | + * |
|
518 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
519 | + * |
|
520 | + * @since 9.0.0 |
|
521 | + */ |
|
522 | + public function getSystemTagObjectMapper(); |
|
523 | + |
|
524 | + /** |
|
525 | + * Returns the share manager |
|
526 | + * |
|
527 | + * @return \OCP\Share\IManager |
|
528 | + * @since 9.0.0 |
|
529 | + */ |
|
530 | + public function getShareManager(); |
|
531 | + |
|
532 | + /** |
|
533 | + * @return IContentSecurityPolicyManager |
|
534 | + * @since 9.0.0 |
|
535 | + */ |
|
536 | + public function getContentSecurityPolicyManager(); |
|
537 | + |
|
538 | + /** |
|
539 | + * @return \OCP\IDateTimeZone |
|
540 | + * @since 8.0.0 |
|
541 | + */ |
|
542 | + public function getDateTimeZone(); |
|
543 | + |
|
544 | + /** |
|
545 | + * @return \OCP\IDateTimeFormatter |
|
546 | + * @since 8.0.0 |
|
547 | + */ |
|
548 | + public function getDateTimeFormatter(); |
|
549 | + |
|
550 | + /** |
|
551 | + * @return \OCP\Federation\ICloudIdManager |
|
552 | + * @since 12.0.0 |
|
553 | + */ |
|
554 | + public function getCloudIdManager(); |
|
555 | + |
|
556 | + /** |
|
557 | + * @return \OCP\Remote\Api\IApiFactory |
|
558 | + * @since 13.0.0 |
|
559 | + */ |
|
560 | + public function getRemoteApiFactory(); |
|
561 | + |
|
562 | + /** |
|
563 | + * @return \OCP\Remote\IInstanceFactory |
|
564 | + * @since 13.0.0 |
|
565 | + */ |
|
566 | + public function getRemoteInstanceFactory(); |
|
567 | 567 | } |
@@ -27,57 +27,57 @@ |
||
27 | 27 | |
28 | 28 | class Manager implements \OCP\Calendar\Resource\IManager { |
29 | 29 | |
30 | - /** @var IBackend[] holds all registered resource backends */ |
|
31 | - private $backends; |
|
30 | + /** @var IBackend[] holds all registered resource backends */ |
|
31 | + private $backends; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Registers a resource backend |
|
35 | - * |
|
36 | - * @param IBackend $backend |
|
37 | - * @return void |
|
38 | - * @since 14.0.0 |
|
39 | - */ |
|
40 | - public function registerBackend(IBackend $backend) { |
|
41 | - $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
42 | - } |
|
33 | + /** |
|
34 | + * Registers a resource backend |
|
35 | + * |
|
36 | + * @param IBackend $backend |
|
37 | + * @return void |
|
38 | + * @since 14.0.0 |
|
39 | + */ |
|
40 | + public function registerBackend(IBackend $backend) { |
|
41 | + $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Unregisters a resource backend |
|
46 | - * |
|
47 | - * @param IBackend $backend |
|
48 | - * @return void |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - public function unregisterBackend(IBackend $backend) { |
|
52 | - unset($this->backends[$backend->getBackendIdentifier()]); |
|
53 | - } |
|
44 | + /** |
|
45 | + * Unregisters a resource backend |
|
46 | + * |
|
47 | + * @param IBackend $backend |
|
48 | + * @return void |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + public function unregisterBackend(IBackend $backend) { |
|
52 | + unset($this->backends[$backend->getBackendIdentifier()]); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return IBackend[] |
|
57 | - * @since 14.0.0 |
|
58 | - */ |
|
59 | - public function getBackends():array { |
|
60 | - return array_values($this->backends); |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return IBackend[] |
|
57 | + * @since 14.0.0 |
|
58 | + */ |
|
59 | + public function getBackends():array { |
|
60 | + return array_values($this->backends); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param string $backendId |
|
65 | - * @return IBackend|null |
|
66 | - */ |
|
67 | - public function getBackend($backendId):IBackend { |
|
68 | - if (!isset($this->backends[$backendId])) { |
|
69 | - return null; |
|
70 | - } |
|
63 | + /** |
|
64 | + * @param string $backendId |
|
65 | + * @return IBackend|null |
|
66 | + */ |
|
67 | + public function getBackend($backendId):IBackend { |
|
68 | + if (!isset($this->backends[$backendId])) { |
|
69 | + return null; |
|
70 | + } |
|
71 | 71 | |
72 | - return $this->backends[$backendId]; |
|
73 | - } |
|
72 | + return $this->backends[$backendId]; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * removes all registered backend instances |
|
77 | - * @return void |
|
78 | - * @since 14.0.0 |
|
79 | - */ |
|
80 | - public function clear() { |
|
81 | - $this->backends = []; |
|
82 | - } |
|
75 | + /** |
|
76 | + * removes all registered backend instances |
|
77 | + * @return void |
|
78 | + * @since 14.0.0 |
|
79 | + */ |
|
80 | + public function clear() { |
|
81 | + $this->backends = []; |
|
82 | + } |
|
83 | 83 | } |
@@ -27,57 +27,57 @@ |
||
27 | 27 | |
28 | 28 | class Manager implements \OCP\Calendar\Room\IManager { |
29 | 29 | |
30 | - /** @var IBackend[] holds all registered resource backends */ |
|
31 | - private $backends; |
|
30 | + /** @var IBackend[] holds all registered resource backends */ |
|
31 | + private $backends; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Registers a resource backend |
|
35 | - * |
|
36 | - * @param IBackend $backend |
|
37 | - * @return void |
|
38 | - * @since 14.0.0 |
|
39 | - */ |
|
40 | - public function registerBackend(IBackend $backend) { |
|
41 | - $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
42 | - } |
|
33 | + /** |
|
34 | + * Registers a resource backend |
|
35 | + * |
|
36 | + * @param IBackend $backend |
|
37 | + * @return void |
|
38 | + * @since 14.0.0 |
|
39 | + */ |
|
40 | + public function registerBackend(IBackend $backend) { |
|
41 | + $this->backends[$backend->getBackendIdentifier()] = $backend; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Unregisters a resource backend |
|
46 | - * |
|
47 | - * @param IBackend $backend |
|
48 | - * @return void |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - public function unregisterBackend(IBackend $backend) { |
|
52 | - unset($this->backends[$backend->getBackendIdentifier()]); |
|
53 | - } |
|
44 | + /** |
|
45 | + * Unregisters a resource backend |
|
46 | + * |
|
47 | + * @param IBackend $backend |
|
48 | + * @return void |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + public function unregisterBackend(IBackend $backend) { |
|
52 | + unset($this->backends[$backend->getBackendIdentifier()]); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return IBackend[] |
|
57 | - * @since 14.0.0 |
|
58 | - */ |
|
59 | - public function getBackends():array { |
|
60 | - return array_values($this->backends); |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return IBackend[] |
|
57 | + * @since 14.0.0 |
|
58 | + */ |
|
59 | + public function getBackends():array { |
|
60 | + return array_values($this->backends); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param string $backendId |
|
65 | - * @return IBackend|null |
|
66 | - */ |
|
67 | - public function getBackend($backendId):IBackend { |
|
68 | - if (!isset($this->backends[$backendId])) { |
|
69 | - return null; |
|
70 | - } |
|
63 | + /** |
|
64 | + * @param string $backendId |
|
65 | + * @return IBackend|null |
|
66 | + */ |
|
67 | + public function getBackend($backendId):IBackend { |
|
68 | + if (!isset($this->backends[$backendId])) { |
|
69 | + return null; |
|
70 | + } |
|
71 | 71 | |
72 | - return $this->backends[$backendId]; |
|
73 | - } |
|
72 | + return $this->backends[$backendId]; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * removes all registered backend instances |
|
77 | - * @return void |
|
78 | - * @since 14.0.0 |
|
79 | - */ |
|
80 | - public function clear() { |
|
81 | - $this->backends = []; |
|
82 | - } |
|
75 | + /** |
|
76 | + * removes all registered backend instances |
|
77 | + * @return void |
|
78 | + * @since 14.0.0 |
|
79 | + */ |
|
80 | + public function clear() { |
|
81 | + $this->backends = []; |
|
82 | + } |
|
83 | 83 | } |
@@ -153,1856 +153,1856 @@ |
||
153 | 153 | * TODO: hookup all manager classes |
154 | 154 | */ |
155 | 155 | class Server extends ServerContainer implements IServerContainer { |
156 | - /** @var string */ |
|
157 | - private $webRoot; |
|
158 | - |
|
159 | - /** |
|
160 | - * @param string $webRoot |
|
161 | - * @param \OC\Config $config |
|
162 | - */ |
|
163 | - public function __construct($webRoot, \OC\Config $config) { |
|
164 | - parent::__construct(); |
|
165 | - $this->webRoot = $webRoot; |
|
166 | - |
|
167 | - // To find out if we are running from CLI or not |
|
168 | - $this->registerParameter('isCLI', \OC::$CLI); |
|
169 | - |
|
170 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
171 | - return $c; |
|
172 | - }); |
|
173 | - |
|
174 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
175 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
176 | - |
|
177 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
178 | - $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
179 | - |
|
180 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
181 | - $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
182 | - |
|
183 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
184 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
185 | - |
|
186 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
187 | - |
|
188 | - |
|
189 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
190 | - return new PreviewManager( |
|
191 | - $c->getConfig(), |
|
192 | - $c->getRootFolder(), |
|
193 | - $c->getAppDataDir('preview'), |
|
194 | - $c->getEventDispatcher(), |
|
195 | - $c->getSession()->get('user_id') |
|
196 | - ); |
|
197 | - }); |
|
198 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
199 | - |
|
200 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
201 | - return new \OC\Preview\Watcher( |
|
202 | - $c->getAppDataDir('preview') |
|
203 | - ); |
|
204 | - }); |
|
205 | - |
|
206 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
207 | - $view = new View(); |
|
208 | - $util = new Encryption\Util( |
|
209 | - $view, |
|
210 | - $c->getUserManager(), |
|
211 | - $c->getGroupManager(), |
|
212 | - $c->getConfig() |
|
213 | - ); |
|
214 | - return new Encryption\Manager( |
|
215 | - $c->getConfig(), |
|
216 | - $c->getLogger(), |
|
217 | - $c->getL10N('core'), |
|
218 | - new View(), |
|
219 | - $util, |
|
220 | - new ArrayCache() |
|
221 | - ); |
|
222 | - }); |
|
223 | - |
|
224 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
225 | - $util = new Encryption\Util( |
|
226 | - new View(), |
|
227 | - $c->getUserManager(), |
|
228 | - $c->getGroupManager(), |
|
229 | - $c->getConfig() |
|
230 | - ); |
|
231 | - return new Encryption\File( |
|
232 | - $util, |
|
233 | - $c->getRootFolder(), |
|
234 | - $c->getShareManager() |
|
235 | - ); |
|
236 | - }); |
|
237 | - |
|
238 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
239 | - $view = new View(); |
|
240 | - $util = new Encryption\Util( |
|
241 | - $view, |
|
242 | - $c->getUserManager(), |
|
243 | - $c->getGroupManager(), |
|
244 | - $c->getConfig() |
|
245 | - ); |
|
246 | - |
|
247 | - return new Encryption\Keys\Storage($view, $util); |
|
248 | - }); |
|
249 | - $this->registerService('TagMapper', function (Server $c) { |
|
250 | - return new TagMapper($c->getDatabaseConnection()); |
|
251 | - }); |
|
252 | - |
|
253 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
254 | - $tagMapper = $c->query('TagMapper'); |
|
255 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
256 | - }); |
|
257 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
258 | - |
|
259 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
260 | - $config = $c->getConfig(); |
|
261 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
262 | - return new $factoryClass($this); |
|
263 | - }); |
|
264 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
265 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
266 | - }); |
|
267 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
268 | - |
|
269 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
270 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
271 | - }); |
|
272 | - $this->registerService('RootFolder', function (Server $c) { |
|
273 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
274 | - $view = new View(); |
|
275 | - $root = new Root( |
|
276 | - $manager, |
|
277 | - $view, |
|
278 | - null, |
|
279 | - $c->getUserMountCache(), |
|
280 | - $this->getLogger(), |
|
281 | - $this->getUserManager() |
|
282 | - ); |
|
283 | - $connector = new HookConnector($root, $view); |
|
284 | - $connector->viewToNode(); |
|
285 | - |
|
286 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
287 | - $previewConnector->connectWatcher(); |
|
288 | - |
|
289 | - return $root; |
|
290 | - }); |
|
291 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
292 | - |
|
293 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
294 | - return new LazyRoot(function () use ($c) { |
|
295 | - return $c->query('RootFolder'); |
|
296 | - }); |
|
297 | - }); |
|
298 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
299 | - |
|
300 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
301 | - $config = $c->getConfig(); |
|
302 | - return new \OC\User\Manager($config); |
|
303 | - }); |
|
304 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
305 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
306 | - |
|
307 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
308 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
309 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
310 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
311 | - }); |
|
312 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
313 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
314 | - }); |
|
315 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
316 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
317 | - }); |
|
318 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
319 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
320 | - }); |
|
321 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
322 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
323 | - }); |
|
324 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
325 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
326 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
327 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
328 | - }); |
|
329 | - return $groupManager; |
|
330 | - }); |
|
331 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
332 | - |
|
333 | - $this->registerService(Store::class, function (Server $c) { |
|
334 | - $session = $c->getSession(); |
|
335 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
336 | - $tokenProvider = $c->query(IProvider::class); |
|
337 | - } else { |
|
338 | - $tokenProvider = null; |
|
339 | - } |
|
340 | - $logger = $c->getLogger(); |
|
341 | - return new Store($session, $logger, $tokenProvider); |
|
342 | - }); |
|
343 | - $this->registerAlias(IStore::class, Store::class); |
|
344 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
345 | - $dbConnection = $c->getDatabaseConnection(); |
|
346 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
347 | - }); |
|
348 | - $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
349 | - $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
|
350 | - $crypto = $c->getCrypto(); |
|
351 | - $config = $c->getConfig(); |
|
352 | - $logger = $c->getLogger(); |
|
353 | - $timeFactory = new TimeFactory(); |
|
354 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
355 | - }); |
|
356 | - $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
|
357 | - |
|
358 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
359 | - $manager = $c->getUserManager(); |
|
360 | - $session = new \OC\Session\Memory(''); |
|
361 | - $timeFactory = new TimeFactory(); |
|
362 | - // Token providers might require a working database. This code |
|
363 | - // might however be called when ownCloud is not yet setup. |
|
364 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
365 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
366 | - } else { |
|
367 | - $defaultTokenProvider = null; |
|
368 | - } |
|
369 | - |
|
370 | - $dispatcher = $c->getEventDispatcher(); |
|
371 | - |
|
372 | - $userSession = new \OC\User\Session( |
|
373 | - $manager, |
|
374 | - $session, |
|
375 | - $timeFactory, |
|
376 | - $defaultTokenProvider, |
|
377 | - $c->getConfig(), |
|
378 | - $c->getSecureRandom(), |
|
379 | - $c->getLockdownManager(), |
|
380 | - $c->getLogger() |
|
381 | - ); |
|
382 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
383 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
384 | - }); |
|
385 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
386 | - /** @var $user \OC\User\User */ |
|
387 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
388 | - }); |
|
389 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
390 | - /** @var $user \OC\User\User */ |
|
391 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
392 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
393 | - }); |
|
394 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
395 | - /** @var $user \OC\User\User */ |
|
396 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
397 | - }); |
|
398 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
399 | - /** @var $user \OC\User\User */ |
|
400 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
401 | - }); |
|
402 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
403 | - /** @var $user \OC\User\User */ |
|
404 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
405 | - }); |
|
406 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
407 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
408 | - }); |
|
409 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
410 | - /** @var $user \OC\User\User */ |
|
411 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
412 | - }); |
|
413 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
414 | - /** @var $user \OC\User\User */ |
|
415 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
416 | - }); |
|
417 | - $userSession->listen('\OC\User', 'logout', function () { |
|
418 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
419 | - }); |
|
420 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
421 | - /** @var $user \OC\User\User */ |
|
422 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
423 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
424 | - }); |
|
425 | - return $userSession; |
|
426 | - }); |
|
427 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
428 | - |
|
429 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
430 | - return new \OC\Authentication\TwoFactorAuth\Manager( |
|
431 | - $c->getAppManager(), |
|
432 | - $c->getSession(), |
|
433 | - $c->getConfig(), |
|
434 | - $c->getActivityManager(), |
|
435 | - $c->getLogger(), |
|
436 | - $c->query(IProvider::class), |
|
437 | - $c->query(ITimeFactory::class), |
|
438 | - $c->query(EventDispatcherInterface::class) |
|
439 | - ); |
|
440 | - }); |
|
441 | - |
|
442 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
443 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
444 | - |
|
445 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
446 | - return new \OC\AllConfig( |
|
447 | - $c->getSystemConfig() |
|
448 | - ); |
|
449 | - }); |
|
450 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
451 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
452 | - |
|
453 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
454 | - return new \OC\SystemConfig($config); |
|
455 | - }); |
|
456 | - |
|
457 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
458 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
459 | - }); |
|
460 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
461 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
462 | - |
|
463 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
464 | - return new \OC\L10N\Factory( |
|
465 | - $c->getConfig(), |
|
466 | - $c->getRequest(), |
|
467 | - $c->getUserSession(), |
|
468 | - \OC::$SERVERROOT |
|
469 | - ); |
|
470 | - }); |
|
471 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
472 | - |
|
473 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
474 | - $config = $c->getConfig(); |
|
475 | - $cacheFactory = $c->getMemCacheFactory(); |
|
476 | - $request = $c->getRequest(); |
|
477 | - return new \OC\URLGenerator( |
|
478 | - $config, |
|
479 | - $cacheFactory, |
|
480 | - $request |
|
481 | - ); |
|
482 | - }); |
|
483 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
484 | - |
|
485 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
486 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
487 | - |
|
488 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
489 | - return new Cache\File(); |
|
490 | - }); |
|
491 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
492 | - |
|
493 | - $this->registerService(Factory::class, function (Server $c) { |
|
494 | - |
|
495 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
496 | - ArrayCache::class, |
|
497 | - ArrayCache::class, |
|
498 | - ArrayCache::class |
|
499 | - ); |
|
500 | - $config = $c->getConfig(); |
|
501 | - $request = $c->getRequest(); |
|
502 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
503 | - |
|
504 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
505 | - $v = \OC_App::getAppVersions(); |
|
506 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
507 | - $version = implode(',', $v); |
|
508 | - $instanceId = \OC_Util::getInstanceId(); |
|
509 | - $path = \OC::$SERVERROOT; |
|
510 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
511 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
512 | - $config->getSystemValue('memcache.local', null), |
|
513 | - $config->getSystemValue('memcache.distributed', null), |
|
514 | - $config->getSystemValue('memcache.locking', null) |
|
515 | - ); |
|
516 | - } |
|
517 | - return $arrayCacheFactory; |
|
518 | - |
|
519 | - }); |
|
520 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
521 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
522 | - |
|
523 | - $this->registerService('RedisFactory', function (Server $c) { |
|
524 | - $systemConfig = $c->getSystemConfig(); |
|
525 | - return new RedisFactory($systemConfig); |
|
526 | - }); |
|
527 | - |
|
528 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
529 | - return new \OC\Activity\Manager( |
|
530 | - $c->getRequest(), |
|
531 | - $c->getUserSession(), |
|
532 | - $c->getConfig(), |
|
533 | - $c->query(IValidator::class) |
|
534 | - ); |
|
535 | - }); |
|
536 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
537 | - |
|
538 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
539 | - return new \OC\Activity\EventMerger( |
|
540 | - $c->getL10N('lib') |
|
541 | - ); |
|
542 | - }); |
|
543 | - $this->registerAlias(IValidator::class, Validator::class); |
|
544 | - |
|
545 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
546 | - return new AvatarManager( |
|
547 | - $c->query(\OC\User\Manager::class), |
|
548 | - $c->getAppDataDir('avatar'), |
|
549 | - $c->getL10N('lib'), |
|
550 | - $c->getLogger(), |
|
551 | - $c->getConfig() |
|
552 | - ); |
|
553 | - }); |
|
554 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
555 | - |
|
556 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
557 | - |
|
558 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
559 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
560 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
561 | - $logger = $factory->get($logType); |
|
562 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
563 | - |
|
564 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
565 | - }); |
|
566 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
567 | - |
|
568 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
569 | - return new LogFactory($c, $this->getSystemConfig()); |
|
570 | - }); |
|
571 | - |
|
572 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
573 | - $config = $c->getConfig(); |
|
574 | - return new \OC\BackgroundJob\JobList( |
|
575 | - $c->getDatabaseConnection(), |
|
576 | - $config, |
|
577 | - new TimeFactory() |
|
578 | - ); |
|
579 | - }); |
|
580 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
581 | - |
|
582 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
583 | - $cacheFactory = $c->getMemCacheFactory(); |
|
584 | - $logger = $c->getLogger(); |
|
585 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
586 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
587 | - } else { |
|
588 | - $router = new \OC\Route\Router($logger); |
|
589 | - } |
|
590 | - return $router; |
|
591 | - }); |
|
592 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
593 | - |
|
594 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
595 | - return new Search(); |
|
596 | - }); |
|
597 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
598 | - |
|
599 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
600 | - return new \OC\Security\RateLimiting\Limiter( |
|
601 | - $this->getUserSession(), |
|
602 | - $this->getRequest(), |
|
603 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
604 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
605 | - ); |
|
606 | - }); |
|
607 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
608 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
609 | - $this->getMemCacheFactory(), |
|
610 | - new \OC\AppFramework\Utility\TimeFactory() |
|
611 | - ); |
|
612 | - }); |
|
613 | - |
|
614 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
615 | - return new SecureRandom(); |
|
616 | - }); |
|
617 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
618 | - |
|
619 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
620 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
621 | - }); |
|
622 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
623 | - |
|
624 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
625 | - return new Hasher($c->getConfig()); |
|
626 | - }); |
|
627 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
628 | - |
|
629 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
630 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
631 | - }); |
|
632 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
633 | - |
|
634 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
635 | - $systemConfig = $c->getSystemConfig(); |
|
636 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
637 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
638 | - if (!$factory->isValidType($type)) { |
|
639 | - throw new \OC\DatabaseException('Invalid database type'); |
|
640 | - } |
|
641 | - $connectionParams = $factory->createConnectionParams(); |
|
642 | - $connection = $factory->getConnection($type, $connectionParams); |
|
643 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
644 | - return $connection; |
|
645 | - }); |
|
646 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
647 | - |
|
648 | - |
|
649 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
650 | - $user = \OC_User::getUser(); |
|
651 | - $uid = $user ? $user : null; |
|
652 | - return new ClientService( |
|
653 | - $c->getConfig(), |
|
654 | - new \OC\Security\CertificateManager( |
|
655 | - $uid, |
|
656 | - new View(), |
|
657 | - $c->getConfig(), |
|
658 | - $c->getLogger(), |
|
659 | - $c->getSecureRandom() |
|
660 | - ) |
|
661 | - ); |
|
662 | - }); |
|
663 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
664 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
665 | - $eventLogger = new EventLogger(); |
|
666 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
667 | - // In debug mode, module is being activated by default |
|
668 | - $eventLogger->activate(); |
|
669 | - } |
|
670 | - return $eventLogger; |
|
671 | - }); |
|
672 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
673 | - |
|
674 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
675 | - $queryLogger = new QueryLogger(); |
|
676 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
677 | - // In debug mode, module is being activated by default |
|
678 | - $queryLogger->activate(); |
|
679 | - } |
|
680 | - return $queryLogger; |
|
681 | - }); |
|
682 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
683 | - |
|
684 | - $this->registerService(TempManager::class, function (Server $c) { |
|
685 | - return new TempManager( |
|
686 | - $c->getLogger(), |
|
687 | - $c->getConfig() |
|
688 | - ); |
|
689 | - }); |
|
690 | - $this->registerAlias('TempManager', TempManager::class); |
|
691 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
692 | - |
|
693 | - $this->registerService(AppManager::class, function (Server $c) { |
|
694 | - return new \OC\App\AppManager( |
|
695 | - $c->getUserSession(), |
|
696 | - $c->query(\OC\AppConfig::class), |
|
697 | - $c->getGroupManager(), |
|
698 | - $c->getMemCacheFactory(), |
|
699 | - $c->getEventDispatcher() |
|
700 | - ); |
|
701 | - }); |
|
702 | - $this->registerAlias('AppManager', AppManager::class); |
|
703 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
704 | - |
|
705 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
706 | - return new DateTimeZone( |
|
707 | - $c->getConfig(), |
|
708 | - $c->getSession() |
|
709 | - ); |
|
710 | - }); |
|
711 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
712 | - |
|
713 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
714 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
715 | - |
|
716 | - return new DateTimeFormatter( |
|
717 | - $c->getDateTimeZone()->getTimeZone(), |
|
718 | - $c->getL10N('lib', $language) |
|
719 | - ); |
|
720 | - }); |
|
721 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
722 | - |
|
723 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
724 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
725 | - $listener = new UserMountCacheListener($mountCache); |
|
726 | - $listener->listen($c->getUserManager()); |
|
727 | - return $mountCache; |
|
728 | - }); |
|
729 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
730 | - |
|
731 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
732 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
733 | - $mountCache = $c->query('UserMountCache'); |
|
734 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
735 | - |
|
736 | - // builtin providers |
|
737 | - |
|
738 | - $config = $c->getConfig(); |
|
739 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
740 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
741 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
742 | - |
|
743 | - return $manager; |
|
744 | - }); |
|
745 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
746 | - |
|
747 | - $this->registerService('IniWrapper', function ($c) { |
|
748 | - return new IniGetWrapper(); |
|
749 | - }); |
|
750 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
751 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
752 | - if ($busClass) { |
|
753 | - list($app, $class) = explode('::', $busClass, 2); |
|
754 | - if ($c->getAppManager()->isInstalled($app)) { |
|
755 | - \OC_App::loadApp($app); |
|
756 | - return $c->query($class); |
|
757 | - } else { |
|
758 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
759 | - } |
|
760 | - } else { |
|
761 | - $jobList = $c->getJobList(); |
|
762 | - return new CronBus($jobList); |
|
763 | - } |
|
764 | - }); |
|
765 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
766 | - return new TrustedDomainHelper($this->getConfig()); |
|
767 | - }); |
|
768 | - $this->registerService('Throttler', function (Server $c) { |
|
769 | - return new Throttler( |
|
770 | - $c->getDatabaseConnection(), |
|
771 | - new TimeFactory(), |
|
772 | - $c->getLogger(), |
|
773 | - $c->getConfig() |
|
774 | - ); |
|
775 | - }); |
|
776 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
777 | - // IConfig and IAppManager requires a working database. This code |
|
778 | - // might however be called when ownCloud is not yet setup. |
|
779 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
780 | - $config = $c->getConfig(); |
|
781 | - $appManager = $c->getAppManager(); |
|
782 | - } else { |
|
783 | - $config = null; |
|
784 | - $appManager = null; |
|
785 | - } |
|
786 | - |
|
787 | - return new Checker( |
|
788 | - new EnvironmentHelper(), |
|
789 | - new FileAccessHelper(), |
|
790 | - new AppLocator(), |
|
791 | - $config, |
|
792 | - $c->getMemCacheFactory(), |
|
793 | - $appManager, |
|
794 | - $c->getTempManager() |
|
795 | - ); |
|
796 | - }); |
|
797 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
798 | - if (isset($this['urlParams'])) { |
|
799 | - $urlParams = $this['urlParams']; |
|
800 | - } else { |
|
801 | - $urlParams = []; |
|
802 | - } |
|
803 | - |
|
804 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
805 | - && in_array('fakeinput', stream_get_wrappers()) |
|
806 | - ) { |
|
807 | - $stream = 'fakeinput://data'; |
|
808 | - } else { |
|
809 | - $stream = 'php://input'; |
|
810 | - } |
|
811 | - |
|
812 | - return new Request( |
|
813 | - [ |
|
814 | - 'get' => $_GET, |
|
815 | - 'post' => $_POST, |
|
816 | - 'files' => $_FILES, |
|
817 | - 'server' => $_SERVER, |
|
818 | - 'env' => $_ENV, |
|
819 | - 'cookies' => $_COOKIE, |
|
820 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
821 | - ? $_SERVER['REQUEST_METHOD'] |
|
822 | - : '', |
|
823 | - 'urlParams' => $urlParams, |
|
824 | - ], |
|
825 | - $this->getSecureRandom(), |
|
826 | - $this->getConfig(), |
|
827 | - $this->getCsrfTokenManager(), |
|
828 | - $stream |
|
829 | - ); |
|
830 | - }); |
|
831 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
832 | - |
|
833 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
834 | - return new Mailer( |
|
835 | - $c->getConfig(), |
|
836 | - $c->getLogger(), |
|
837 | - $c->query(Defaults::class), |
|
838 | - $c->getURLGenerator(), |
|
839 | - $c->getL10N('lib') |
|
840 | - ); |
|
841 | - }); |
|
842 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
843 | - |
|
844 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
845 | - $config = $c->getConfig(); |
|
846 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
847 | - if (is_null($factoryClass)) { |
|
848 | - throw new \Exception('ldapProviderFactory not set'); |
|
849 | - } |
|
850 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
851 | - $factory = new $factoryClass($this); |
|
852 | - return $factory->getLDAPProvider(); |
|
853 | - }); |
|
854 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
855 | - $ini = $c->getIniWrapper(); |
|
856 | - $config = $c->getConfig(); |
|
857 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
858 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
859 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
860 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
861 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
862 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
863 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
864 | - } |
|
865 | - return new DBLockingProvider( |
|
866 | - $c->getDatabaseConnection(), |
|
867 | - $c->getLogger(), |
|
868 | - new TimeFactory(), |
|
869 | - $ttl, |
|
870 | - !\OC::$CLI |
|
871 | - ); |
|
872 | - } |
|
873 | - return new NoopLockingProvider(); |
|
874 | - }); |
|
875 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
876 | - |
|
877 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
878 | - return new \OC\Files\Mount\Manager(); |
|
879 | - }); |
|
880 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
881 | - |
|
882 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
883 | - return new \OC\Files\Type\Detection( |
|
884 | - $c->getURLGenerator(), |
|
885 | - \OC::$configDir, |
|
886 | - \OC::$SERVERROOT . '/resources/config/' |
|
887 | - ); |
|
888 | - }); |
|
889 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
890 | - |
|
891 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
892 | - return new \OC\Files\Type\Loader( |
|
893 | - $c->getDatabaseConnection() |
|
894 | - ); |
|
895 | - }); |
|
896 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
897 | - $this->registerService(BundleFetcher::class, function () { |
|
898 | - return new BundleFetcher($this->getL10N('lib')); |
|
899 | - }); |
|
900 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
901 | - return new Manager( |
|
902 | - $c->query(IValidator::class) |
|
903 | - ); |
|
904 | - }); |
|
905 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
906 | - |
|
907 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
908 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
909 | - $manager->registerCapability(function () use ($c) { |
|
910 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
911 | - }); |
|
912 | - $manager->registerCapability(function () use ($c) { |
|
913 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
914 | - }); |
|
915 | - return $manager; |
|
916 | - }); |
|
917 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
918 | - |
|
919 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
920 | - $config = $c->getConfig(); |
|
921 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
922 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
923 | - $factory = new $factoryClass($this); |
|
924 | - $manager = $factory->getManager(); |
|
925 | - |
|
926 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
927 | - $manager = $c->getUserManager(); |
|
928 | - $user = $manager->get($id); |
|
929 | - if(is_null($user)) { |
|
930 | - $l = $c->getL10N('core'); |
|
931 | - $displayName = $l->t('Unknown user'); |
|
932 | - } else { |
|
933 | - $displayName = $user->getDisplayName(); |
|
934 | - } |
|
935 | - return $displayName; |
|
936 | - }); |
|
937 | - |
|
938 | - return $manager; |
|
939 | - }); |
|
940 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
941 | - |
|
942 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
943 | - /* |
|
156 | + /** @var string */ |
|
157 | + private $webRoot; |
|
158 | + |
|
159 | + /** |
|
160 | + * @param string $webRoot |
|
161 | + * @param \OC\Config $config |
|
162 | + */ |
|
163 | + public function __construct($webRoot, \OC\Config $config) { |
|
164 | + parent::__construct(); |
|
165 | + $this->webRoot = $webRoot; |
|
166 | + |
|
167 | + // To find out if we are running from CLI or not |
|
168 | + $this->registerParameter('isCLI', \OC::$CLI); |
|
169 | + |
|
170 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
171 | + return $c; |
|
172 | + }); |
|
173 | + |
|
174 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
175 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
176 | + |
|
177 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); |
|
178 | + $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); |
|
179 | + |
|
180 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); |
|
181 | + $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); |
|
182 | + |
|
183 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
184 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
185 | + |
|
186 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
187 | + |
|
188 | + |
|
189 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
190 | + return new PreviewManager( |
|
191 | + $c->getConfig(), |
|
192 | + $c->getRootFolder(), |
|
193 | + $c->getAppDataDir('preview'), |
|
194 | + $c->getEventDispatcher(), |
|
195 | + $c->getSession()->get('user_id') |
|
196 | + ); |
|
197 | + }); |
|
198 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
199 | + |
|
200 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
201 | + return new \OC\Preview\Watcher( |
|
202 | + $c->getAppDataDir('preview') |
|
203 | + ); |
|
204 | + }); |
|
205 | + |
|
206 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
207 | + $view = new View(); |
|
208 | + $util = new Encryption\Util( |
|
209 | + $view, |
|
210 | + $c->getUserManager(), |
|
211 | + $c->getGroupManager(), |
|
212 | + $c->getConfig() |
|
213 | + ); |
|
214 | + return new Encryption\Manager( |
|
215 | + $c->getConfig(), |
|
216 | + $c->getLogger(), |
|
217 | + $c->getL10N('core'), |
|
218 | + new View(), |
|
219 | + $util, |
|
220 | + new ArrayCache() |
|
221 | + ); |
|
222 | + }); |
|
223 | + |
|
224 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
225 | + $util = new Encryption\Util( |
|
226 | + new View(), |
|
227 | + $c->getUserManager(), |
|
228 | + $c->getGroupManager(), |
|
229 | + $c->getConfig() |
|
230 | + ); |
|
231 | + return new Encryption\File( |
|
232 | + $util, |
|
233 | + $c->getRootFolder(), |
|
234 | + $c->getShareManager() |
|
235 | + ); |
|
236 | + }); |
|
237 | + |
|
238 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
239 | + $view = new View(); |
|
240 | + $util = new Encryption\Util( |
|
241 | + $view, |
|
242 | + $c->getUserManager(), |
|
243 | + $c->getGroupManager(), |
|
244 | + $c->getConfig() |
|
245 | + ); |
|
246 | + |
|
247 | + return new Encryption\Keys\Storage($view, $util); |
|
248 | + }); |
|
249 | + $this->registerService('TagMapper', function (Server $c) { |
|
250 | + return new TagMapper($c->getDatabaseConnection()); |
|
251 | + }); |
|
252 | + |
|
253 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
254 | + $tagMapper = $c->query('TagMapper'); |
|
255 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
256 | + }); |
|
257 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
258 | + |
|
259 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
260 | + $config = $c->getConfig(); |
|
261 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
262 | + return new $factoryClass($this); |
|
263 | + }); |
|
264 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
265 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
266 | + }); |
|
267 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
268 | + |
|
269 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
270 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
271 | + }); |
|
272 | + $this->registerService('RootFolder', function (Server $c) { |
|
273 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
274 | + $view = new View(); |
|
275 | + $root = new Root( |
|
276 | + $manager, |
|
277 | + $view, |
|
278 | + null, |
|
279 | + $c->getUserMountCache(), |
|
280 | + $this->getLogger(), |
|
281 | + $this->getUserManager() |
|
282 | + ); |
|
283 | + $connector = new HookConnector($root, $view); |
|
284 | + $connector->viewToNode(); |
|
285 | + |
|
286 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
287 | + $previewConnector->connectWatcher(); |
|
288 | + |
|
289 | + return $root; |
|
290 | + }); |
|
291 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
292 | + |
|
293 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
294 | + return new LazyRoot(function () use ($c) { |
|
295 | + return $c->query('RootFolder'); |
|
296 | + }); |
|
297 | + }); |
|
298 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
299 | + |
|
300 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
301 | + $config = $c->getConfig(); |
|
302 | + return new \OC\User\Manager($config); |
|
303 | + }); |
|
304 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
305 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
306 | + |
|
307 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
308 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
309 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
310 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
311 | + }); |
|
312 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
313 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
314 | + }); |
|
315 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
316 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
317 | + }); |
|
318 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
319 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
320 | + }); |
|
321 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
322 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
323 | + }); |
|
324 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
325 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
326 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
327 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
328 | + }); |
|
329 | + return $groupManager; |
|
330 | + }); |
|
331 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
332 | + |
|
333 | + $this->registerService(Store::class, function (Server $c) { |
|
334 | + $session = $c->getSession(); |
|
335 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
336 | + $tokenProvider = $c->query(IProvider::class); |
|
337 | + } else { |
|
338 | + $tokenProvider = null; |
|
339 | + } |
|
340 | + $logger = $c->getLogger(); |
|
341 | + return new Store($session, $logger, $tokenProvider); |
|
342 | + }); |
|
343 | + $this->registerAlias(IStore::class, Store::class); |
|
344 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
345 | + $dbConnection = $c->getDatabaseConnection(); |
|
346 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
347 | + }); |
|
348 | + $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
349 | + $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
|
350 | + $crypto = $c->getCrypto(); |
|
351 | + $config = $c->getConfig(); |
|
352 | + $logger = $c->getLogger(); |
|
353 | + $timeFactory = new TimeFactory(); |
|
354 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
355 | + }); |
|
356 | + $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
|
357 | + |
|
358 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
359 | + $manager = $c->getUserManager(); |
|
360 | + $session = new \OC\Session\Memory(''); |
|
361 | + $timeFactory = new TimeFactory(); |
|
362 | + // Token providers might require a working database. This code |
|
363 | + // might however be called when ownCloud is not yet setup. |
|
364 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
365 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
366 | + } else { |
|
367 | + $defaultTokenProvider = null; |
|
368 | + } |
|
369 | + |
|
370 | + $dispatcher = $c->getEventDispatcher(); |
|
371 | + |
|
372 | + $userSession = new \OC\User\Session( |
|
373 | + $manager, |
|
374 | + $session, |
|
375 | + $timeFactory, |
|
376 | + $defaultTokenProvider, |
|
377 | + $c->getConfig(), |
|
378 | + $c->getSecureRandom(), |
|
379 | + $c->getLockdownManager(), |
|
380 | + $c->getLogger() |
|
381 | + ); |
|
382 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
383 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
384 | + }); |
|
385 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
386 | + /** @var $user \OC\User\User */ |
|
387 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
388 | + }); |
|
389 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
390 | + /** @var $user \OC\User\User */ |
|
391 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
392 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
393 | + }); |
|
394 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
395 | + /** @var $user \OC\User\User */ |
|
396 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
397 | + }); |
|
398 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
399 | + /** @var $user \OC\User\User */ |
|
400 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
401 | + }); |
|
402 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
403 | + /** @var $user \OC\User\User */ |
|
404 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
405 | + }); |
|
406 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
407 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
408 | + }); |
|
409 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
410 | + /** @var $user \OC\User\User */ |
|
411 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
412 | + }); |
|
413 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
414 | + /** @var $user \OC\User\User */ |
|
415 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
416 | + }); |
|
417 | + $userSession->listen('\OC\User', 'logout', function () { |
|
418 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
419 | + }); |
|
420 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
421 | + /** @var $user \OC\User\User */ |
|
422 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
423 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
424 | + }); |
|
425 | + return $userSession; |
|
426 | + }); |
|
427 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
428 | + |
|
429 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
430 | + return new \OC\Authentication\TwoFactorAuth\Manager( |
|
431 | + $c->getAppManager(), |
|
432 | + $c->getSession(), |
|
433 | + $c->getConfig(), |
|
434 | + $c->getActivityManager(), |
|
435 | + $c->getLogger(), |
|
436 | + $c->query(IProvider::class), |
|
437 | + $c->query(ITimeFactory::class), |
|
438 | + $c->query(EventDispatcherInterface::class) |
|
439 | + ); |
|
440 | + }); |
|
441 | + |
|
442 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
443 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
444 | + |
|
445 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
446 | + return new \OC\AllConfig( |
|
447 | + $c->getSystemConfig() |
|
448 | + ); |
|
449 | + }); |
|
450 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
451 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
452 | + |
|
453 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
454 | + return new \OC\SystemConfig($config); |
|
455 | + }); |
|
456 | + |
|
457 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
458 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
459 | + }); |
|
460 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
461 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
462 | + |
|
463 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
464 | + return new \OC\L10N\Factory( |
|
465 | + $c->getConfig(), |
|
466 | + $c->getRequest(), |
|
467 | + $c->getUserSession(), |
|
468 | + \OC::$SERVERROOT |
|
469 | + ); |
|
470 | + }); |
|
471 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
472 | + |
|
473 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
474 | + $config = $c->getConfig(); |
|
475 | + $cacheFactory = $c->getMemCacheFactory(); |
|
476 | + $request = $c->getRequest(); |
|
477 | + return new \OC\URLGenerator( |
|
478 | + $config, |
|
479 | + $cacheFactory, |
|
480 | + $request |
|
481 | + ); |
|
482 | + }); |
|
483 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
484 | + |
|
485 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
486 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
487 | + |
|
488 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
489 | + return new Cache\File(); |
|
490 | + }); |
|
491 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
492 | + |
|
493 | + $this->registerService(Factory::class, function (Server $c) { |
|
494 | + |
|
495 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
496 | + ArrayCache::class, |
|
497 | + ArrayCache::class, |
|
498 | + ArrayCache::class |
|
499 | + ); |
|
500 | + $config = $c->getConfig(); |
|
501 | + $request = $c->getRequest(); |
|
502 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
503 | + |
|
504 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
505 | + $v = \OC_App::getAppVersions(); |
|
506 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
507 | + $version = implode(',', $v); |
|
508 | + $instanceId = \OC_Util::getInstanceId(); |
|
509 | + $path = \OC::$SERVERROOT; |
|
510 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
511 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
512 | + $config->getSystemValue('memcache.local', null), |
|
513 | + $config->getSystemValue('memcache.distributed', null), |
|
514 | + $config->getSystemValue('memcache.locking', null) |
|
515 | + ); |
|
516 | + } |
|
517 | + return $arrayCacheFactory; |
|
518 | + |
|
519 | + }); |
|
520 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
521 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
522 | + |
|
523 | + $this->registerService('RedisFactory', function (Server $c) { |
|
524 | + $systemConfig = $c->getSystemConfig(); |
|
525 | + return new RedisFactory($systemConfig); |
|
526 | + }); |
|
527 | + |
|
528 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
529 | + return new \OC\Activity\Manager( |
|
530 | + $c->getRequest(), |
|
531 | + $c->getUserSession(), |
|
532 | + $c->getConfig(), |
|
533 | + $c->query(IValidator::class) |
|
534 | + ); |
|
535 | + }); |
|
536 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
537 | + |
|
538 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
539 | + return new \OC\Activity\EventMerger( |
|
540 | + $c->getL10N('lib') |
|
541 | + ); |
|
542 | + }); |
|
543 | + $this->registerAlias(IValidator::class, Validator::class); |
|
544 | + |
|
545 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
546 | + return new AvatarManager( |
|
547 | + $c->query(\OC\User\Manager::class), |
|
548 | + $c->getAppDataDir('avatar'), |
|
549 | + $c->getL10N('lib'), |
|
550 | + $c->getLogger(), |
|
551 | + $c->getConfig() |
|
552 | + ); |
|
553 | + }); |
|
554 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
555 | + |
|
556 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
557 | + |
|
558 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
559 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
560 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
561 | + $logger = $factory->get($logType); |
|
562 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
563 | + |
|
564 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
565 | + }); |
|
566 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
567 | + |
|
568 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
569 | + return new LogFactory($c, $this->getSystemConfig()); |
|
570 | + }); |
|
571 | + |
|
572 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
573 | + $config = $c->getConfig(); |
|
574 | + return new \OC\BackgroundJob\JobList( |
|
575 | + $c->getDatabaseConnection(), |
|
576 | + $config, |
|
577 | + new TimeFactory() |
|
578 | + ); |
|
579 | + }); |
|
580 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
581 | + |
|
582 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
583 | + $cacheFactory = $c->getMemCacheFactory(); |
|
584 | + $logger = $c->getLogger(); |
|
585 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
586 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
587 | + } else { |
|
588 | + $router = new \OC\Route\Router($logger); |
|
589 | + } |
|
590 | + return $router; |
|
591 | + }); |
|
592 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
593 | + |
|
594 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
595 | + return new Search(); |
|
596 | + }); |
|
597 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
598 | + |
|
599 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
600 | + return new \OC\Security\RateLimiting\Limiter( |
|
601 | + $this->getUserSession(), |
|
602 | + $this->getRequest(), |
|
603 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
604 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
605 | + ); |
|
606 | + }); |
|
607 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
608 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
609 | + $this->getMemCacheFactory(), |
|
610 | + new \OC\AppFramework\Utility\TimeFactory() |
|
611 | + ); |
|
612 | + }); |
|
613 | + |
|
614 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
615 | + return new SecureRandom(); |
|
616 | + }); |
|
617 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
618 | + |
|
619 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
620 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
621 | + }); |
|
622 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
623 | + |
|
624 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
625 | + return new Hasher($c->getConfig()); |
|
626 | + }); |
|
627 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
628 | + |
|
629 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
630 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
631 | + }); |
|
632 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
633 | + |
|
634 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
635 | + $systemConfig = $c->getSystemConfig(); |
|
636 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
637 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
638 | + if (!$factory->isValidType($type)) { |
|
639 | + throw new \OC\DatabaseException('Invalid database type'); |
|
640 | + } |
|
641 | + $connectionParams = $factory->createConnectionParams(); |
|
642 | + $connection = $factory->getConnection($type, $connectionParams); |
|
643 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
644 | + return $connection; |
|
645 | + }); |
|
646 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
647 | + |
|
648 | + |
|
649 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
650 | + $user = \OC_User::getUser(); |
|
651 | + $uid = $user ? $user : null; |
|
652 | + return new ClientService( |
|
653 | + $c->getConfig(), |
|
654 | + new \OC\Security\CertificateManager( |
|
655 | + $uid, |
|
656 | + new View(), |
|
657 | + $c->getConfig(), |
|
658 | + $c->getLogger(), |
|
659 | + $c->getSecureRandom() |
|
660 | + ) |
|
661 | + ); |
|
662 | + }); |
|
663 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
664 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
665 | + $eventLogger = new EventLogger(); |
|
666 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
667 | + // In debug mode, module is being activated by default |
|
668 | + $eventLogger->activate(); |
|
669 | + } |
|
670 | + return $eventLogger; |
|
671 | + }); |
|
672 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
673 | + |
|
674 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
675 | + $queryLogger = new QueryLogger(); |
|
676 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
677 | + // In debug mode, module is being activated by default |
|
678 | + $queryLogger->activate(); |
|
679 | + } |
|
680 | + return $queryLogger; |
|
681 | + }); |
|
682 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
683 | + |
|
684 | + $this->registerService(TempManager::class, function (Server $c) { |
|
685 | + return new TempManager( |
|
686 | + $c->getLogger(), |
|
687 | + $c->getConfig() |
|
688 | + ); |
|
689 | + }); |
|
690 | + $this->registerAlias('TempManager', TempManager::class); |
|
691 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
692 | + |
|
693 | + $this->registerService(AppManager::class, function (Server $c) { |
|
694 | + return new \OC\App\AppManager( |
|
695 | + $c->getUserSession(), |
|
696 | + $c->query(\OC\AppConfig::class), |
|
697 | + $c->getGroupManager(), |
|
698 | + $c->getMemCacheFactory(), |
|
699 | + $c->getEventDispatcher() |
|
700 | + ); |
|
701 | + }); |
|
702 | + $this->registerAlias('AppManager', AppManager::class); |
|
703 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
704 | + |
|
705 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
706 | + return new DateTimeZone( |
|
707 | + $c->getConfig(), |
|
708 | + $c->getSession() |
|
709 | + ); |
|
710 | + }); |
|
711 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
712 | + |
|
713 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
714 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
715 | + |
|
716 | + return new DateTimeFormatter( |
|
717 | + $c->getDateTimeZone()->getTimeZone(), |
|
718 | + $c->getL10N('lib', $language) |
|
719 | + ); |
|
720 | + }); |
|
721 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
722 | + |
|
723 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
724 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
725 | + $listener = new UserMountCacheListener($mountCache); |
|
726 | + $listener->listen($c->getUserManager()); |
|
727 | + return $mountCache; |
|
728 | + }); |
|
729 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
730 | + |
|
731 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
732 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
733 | + $mountCache = $c->query('UserMountCache'); |
|
734 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
735 | + |
|
736 | + // builtin providers |
|
737 | + |
|
738 | + $config = $c->getConfig(); |
|
739 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
740 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
741 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
742 | + |
|
743 | + return $manager; |
|
744 | + }); |
|
745 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
746 | + |
|
747 | + $this->registerService('IniWrapper', function ($c) { |
|
748 | + return new IniGetWrapper(); |
|
749 | + }); |
|
750 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
751 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
752 | + if ($busClass) { |
|
753 | + list($app, $class) = explode('::', $busClass, 2); |
|
754 | + if ($c->getAppManager()->isInstalled($app)) { |
|
755 | + \OC_App::loadApp($app); |
|
756 | + return $c->query($class); |
|
757 | + } else { |
|
758 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
759 | + } |
|
760 | + } else { |
|
761 | + $jobList = $c->getJobList(); |
|
762 | + return new CronBus($jobList); |
|
763 | + } |
|
764 | + }); |
|
765 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
766 | + return new TrustedDomainHelper($this->getConfig()); |
|
767 | + }); |
|
768 | + $this->registerService('Throttler', function (Server $c) { |
|
769 | + return new Throttler( |
|
770 | + $c->getDatabaseConnection(), |
|
771 | + new TimeFactory(), |
|
772 | + $c->getLogger(), |
|
773 | + $c->getConfig() |
|
774 | + ); |
|
775 | + }); |
|
776 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
777 | + // IConfig and IAppManager requires a working database. This code |
|
778 | + // might however be called when ownCloud is not yet setup. |
|
779 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
780 | + $config = $c->getConfig(); |
|
781 | + $appManager = $c->getAppManager(); |
|
782 | + } else { |
|
783 | + $config = null; |
|
784 | + $appManager = null; |
|
785 | + } |
|
786 | + |
|
787 | + return new Checker( |
|
788 | + new EnvironmentHelper(), |
|
789 | + new FileAccessHelper(), |
|
790 | + new AppLocator(), |
|
791 | + $config, |
|
792 | + $c->getMemCacheFactory(), |
|
793 | + $appManager, |
|
794 | + $c->getTempManager() |
|
795 | + ); |
|
796 | + }); |
|
797 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
798 | + if (isset($this['urlParams'])) { |
|
799 | + $urlParams = $this['urlParams']; |
|
800 | + } else { |
|
801 | + $urlParams = []; |
|
802 | + } |
|
803 | + |
|
804 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
805 | + && in_array('fakeinput', stream_get_wrappers()) |
|
806 | + ) { |
|
807 | + $stream = 'fakeinput://data'; |
|
808 | + } else { |
|
809 | + $stream = 'php://input'; |
|
810 | + } |
|
811 | + |
|
812 | + return new Request( |
|
813 | + [ |
|
814 | + 'get' => $_GET, |
|
815 | + 'post' => $_POST, |
|
816 | + 'files' => $_FILES, |
|
817 | + 'server' => $_SERVER, |
|
818 | + 'env' => $_ENV, |
|
819 | + 'cookies' => $_COOKIE, |
|
820 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
821 | + ? $_SERVER['REQUEST_METHOD'] |
|
822 | + : '', |
|
823 | + 'urlParams' => $urlParams, |
|
824 | + ], |
|
825 | + $this->getSecureRandom(), |
|
826 | + $this->getConfig(), |
|
827 | + $this->getCsrfTokenManager(), |
|
828 | + $stream |
|
829 | + ); |
|
830 | + }); |
|
831 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
832 | + |
|
833 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
834 | + return new Mailer( |
|
835 | + $c->getConfig(), |
|
836 | + $c->getLogger(), |
|
837 | + $c->query(Defaults::class), |
|
838 | + $c->getURLGenerator(), |
|
839 | + $c->getL10N('lib') |
|
840 | + ); |
|
841 | + }); |
|
842 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
843 | + |
|
844 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
845 | + $config = $c->getConfig(); |
|
846 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
847 | + if (is_null($factoryClass)) { |
|
848 | + throw new \Exception('ldapProviderFactory not set'); |
|
849 | + } |
|
850 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
851 | + $factory = new $factoryClass($this); |
|
852 | + return $factory->getLDAPProvider(); |
|
853 | + }); |
|
854 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
855 | + $ini = $c->getIniWrapper(); |
|
856 | + $config = $c->getConfig(); |
|
857 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
858 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
859 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
860 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
861 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
862 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
863 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
864 | + } |
|
865 | + return new DBLockingProvider( |
|
866 | + $c->getDatabaseConnection(), |
|
867 | + $c->getLogger(), |
|
868 | + new TimeFactory(), |
|
869 | + $ttl, |
|
870 | + !\OC::$CLI |
|
871 | + ); |
|
872 | + } |
|
873 | + return new NoopLockingProvider(); |
|
874 | + }); |
|
875 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
876 | + |
|
877 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
878 | + return new \OC\Files\Mount\Manager(); |
|
879 | + }); |
|
880 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
881 | + |
|
882 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
883 | + return new \OC\Files\Type\Detection( |
|
884 | + $c->getURLGenerator(), |
|
885 | + \OC::$configDir, |
|
886 | + \OC::$SERVERROOT . '/resources/config/' |
|
887 | + ); |
|
888 | + }); |
|
889 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
890 | + |
|
891 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
892 | + return new \OC\Files\Type\Loader( |
|
893 | + $c->getDatabaseConnection() |
|
894 | + ); |
|
895 | + }); |
|
896 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
897 | + $this->registerService(BundleFetcher::class, function () { |
|
898 | + return new BundleFetcher($this->getL10N('lib')); |
|
899 | + }); |
|
900 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
901 | + return new Manager( |
|
902 | + $c->query(IValidator::class) |
|
903 | + ); |
|
904 | + }); |
|
905 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
906 | + |
|
907 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
908 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
909 | + $manager->registerCapability(function () use ($c) { |
|
910 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
911 | + }); |
|
912 | + $manager->registerCapability(function () use ($c) { |
|
913 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
914 | + }); |
|
915 | + return $manager; |
|
916 | + }); |
|
917 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
918 | + |
|
919 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
920 | + $config = $c->getConfig(); |
|
921 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
922 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
923 | + $factory = new $factoryClass($this); |
|
924 | + $manager = $factory->getManager(); |
|
925 | + |
|
926 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
927 | + $manager = $c->getUserManager(); |
|
928 | + $user = $manager->get($id); |
|
929 | + if(is_null($user)) { |
|
930 | + $l = $c->getL10N('core'); |
|
931 | + $displayName = $l->t('Unknown user'); |
|
932 | + } else { |
|
933 | + $displayName = $user->getDisplayName(); |
|
934 | + } |
|
935 | + return $displayName; |
|
936 | + }); |
|
937 | + |
|
938 | + return $manager; |
|
939 | + }); |
|
940 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
941 | + |
|
942 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
943 | + /* |
|
944 | 944 | * Dark magic for autoloader. |
945 | 945 | * If we do a class_exists it will try to load the class which will |
946 | 946 | * make composer cache the result. Resulting in errors when enabling |
947 | 947 | * the theming app. |
948 | 948 | */ |
949 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
950 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
951 | - $classExists = true; |
|
952 | - } else { |
|
953 | - $classExists = false; |
|
954 | - } |
|
955 | - |
|
956 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
957 | - return new ThemingDefaults( |
|
958 | - $c->getConfig(), |
|
959 | - $c->getL10N('theming'), |
|
960 | - $c->getURLGenerator(), |
|
961 | - $c->getMemCacheFactory(), |
|
962 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
963 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
964 | - $c->getAppManager() |
|
965 | - ); |
|
966 | - } |
|
967 | - return new \OC_Defaults(); |
|
968 | - }); |
|
969 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
970 | - /** @var Factory $cacheFactory */ |
|
971 | - $cacheFactory = $c->query(Factory::class); |
|
972 | - return new SCSSCacher( |
|
973 | - $c->getLogger(), |
|
974 | - $c->query(\OC\Files\AppData\Factory::class), |
|
975 | - $c->getURLGenerator(), |
|
976 | - $c->getConfig(), |
|
977 | - $c->getThemingDefaults(), |
|
978 | - \OC::$SERVERROOT, |
|
979 | - $this->getMemCacheFactory() |
|
980 | - ); |
|
981 | - }); |
|
982 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
983 | - /** @var Factory $cacheFactory */ |
|
984 | - $cacheFactory = $c->query(Factory::class); |
|
985 | - return new JSCombiner( |
|
986 | - $c->getAppDataDir('js'), |
|
987 | - $c->getURLGenerator(), |
|
988 | - $this->getMemCacheFactory(), |
|
989 | - $c->getSystemConfig(), |
|
990 | - $c->getLogger() |
|
991 | - ); |
|
992 | - }); |
|
993 | - $this->registerService(EventDispatcher::class, function () { |
|
994 | - return new EventDispatcher(); |
|
995 | - }); |
|
996 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
997 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
998 | - |
|
999 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
1000 | - // FIXME: Instantiiated here due to cyclic dependency |
|
1001 | - $request = new Request( |
|
1002 | - [ |
|
1003 | - 'get' => $_GET, |
|
1004 | - 'post' => $_POST, |
|
1005 | - 'files' => $_FILES, |
|
1006 | - 'server' => $_SERVER, |
|
1007 | - 'env' => $_ENV, |
|
1008 | - 'cookies' => $_COOKIE, |
|
1009 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1010 | - ? $_SERVER['REQUEST_METHOD'] |
|
1011 | - : null, |
|
1012 | - ], |
|
1013 | - $c->getSecureRandom(), |
|
1014 | - $c->getConfig() |
|
1015 | - ); |
|
1016 | - |
|
1017 | - return new CryptoWrapper( |
|
1018 | - $c->getConfig(), |
|
1019 | - $c->getCrypto(), |
|
1020 | - $c->getSecureRandom(), |
|
1021 | - $request |
|
1022 | - ); |
|
1023 | - }); |
|
1024 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1025 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1026 | - |
|
1027 | - return new CsrfTokenManager( |
|
1028 | - $tokenGenerator, |
|
1029 | - $c->query(SessionStorage::class) |
|
1030 | - ); |
|
1031 | - }); |
|
1032 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1033 | - return new SessionStorage($c->getSession()); |
|
1034 | - }); |
|
1035 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1036 | - return new ContentSecurityPolicyManager(); |
|
1037 | - }); |
|
1038 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1039 | - |
|
1040 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1041 | - return new ContentSecurityPolicyNonceManager( |
|
1042 | - $c->getCsrfTokenManager(), |
|
1043 | - $c->getRequest() |
|
1044 | - ); |
|
1045 | - }); |
|
1046 | - |
|
1047 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1048 | - $config = $c->getConfig(); |
|
1049 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1050 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
1051 | - $factory = new $factoryClass($this); |
|
1052 | - |
|
1053 | - $manager = new \OC\Share20\Manager( |
|
1054 | - $c->getLogger(), |
|
1055 | - $c->getConfig(), |
|
1056 | - $c->getSecureRandom(), |
|
1057 | - $c->getHasher(), |
|
1058 | - $c->getMountManager(), |
|
1059 | - $c->getGroupManager(), |
|
1060 | - $c->getL10N('lib'), |
|
1061 | - $c->getL10NFactory(), |
|
1062 | - $factory, |
|
1063 | - $c->getUserManager(), |
|
1064 | - $c->getLazyRootFolder(), |
|
1065 | - $c->getEventDispatcher(), |
|
1066 | - $c->getMailer(), |
|
1067 | - $c->getURLGenerator(), |
|
1068 | - $c->getThemingDefaults() |
|
1069 | - ); |
|
1070 | - |
|
1071 | - return $manager; |
|
1072 | - }); |
|
1073 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1074 | - |
|
1075 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1076 | - $instance = new Collaboration\Collaborators\Search($c); |
|
1077 | - |
|
1078 | - // register default plugins |
|
1079 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1080 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1081 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1082 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1083 | - |
|
1084 | - return $instance; |
|
1085 | - }); |
|
1086 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1087 | - |
|
1088 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1089 | - |
|
1090 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1091 | - $manager = new \OC\Settings\Manager( |
|
1092 | - $c->getLogger(), |
|
1093 | - $c->getDatabaseConnection(), |
|
1094 | - $c->getL10N('lib'), |
|
1095 | - $c->getConfig(), |
|
1096 | - $c->getEncryptionManager(), |
|
1097 | - $c->getUserManager(), |
|
1098 | - $c->getLockingProvider(), |
|
1099 | - $c->getRequest(), |
|
1100 | - $c->getURLGenerator(), |
|
1101 | - $c->query(AccountManager::class), |
|
1102 | - $c->getGroupManager(), |
|
1103 | - $c->getL10NFactory(), |
|
1104 | - $c->getAppManager() |
|
1105 | - ); |
|
1106 | - return $manager; |
|
1107 | - }); |
|
1108 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1109 | - return new \OC\Files\AppData\Factory( |
|
1110 | - $c->getRootFolder(), |
|
1111 | - $c->getSystemConfig() |
|
1112 | - ); |
|
1113 | - }); |
|
1114 | - |
|
1115 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1116 | - return new LockdownManager(function () use ($c) { |
|
1117 | - return $c->getSession(); |
|
1118 | - }); |
|
1119 | - }); |
|
1120 | - |
|
1121 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1122 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1123 | - }); |
|
1124 | - |
|
1125 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1126 | - return new CloudIdManager(); |
|
1127 | - }); |
|
1128 | - |
|
1129 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1130 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1131 | - |
|
1132 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1133 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1134 | - |
|
1135 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1136 | - return new Defaults( |
|
1137 | - $c->getThemingDefaults() |
|
1138 | - ); |
|
1139 | - }); |
|
1140 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1141 | - |
|
1142 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1143 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1144 | - }); |
|
1145 | - |
|
1146 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1147 | - return new ShareHelper( |
|
1148 | - $c->query(\OCP\Share\IManager::class) |
|
1149 | - ); |
|
1150 | - }); |
|
1151 | - |
|
1152 | - $this->registerService(Installer::class, function(Server $c) { |
|
1153 | - return new Installer( |
|
1154 | - $c->getAppFetcher(), |
|
1155 | - $c->getHTTPClientService(), |
|
1156 | - $c->getTempManager(), |
|
1157 | - $c->getLogger(), |
|
1158 | - $c->getConfig() |
|
1159 | - ); |
|
1160 | - }); |
|
1161 | - |
|
1162 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
1163 | - return new ApiFactory($c->getHTTPClientService()); |
|
1164 | - }); |
|
1165 | - |
|
1166 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1167 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
1168 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1169 | - }); |
|
1170 | - |
|
1171 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
1172 | - return new ContactsStore( |
|
1173 | - $c->getContactsManager(), |
|
1174 | - $c->getConfig(), |
|
1175 | - $c->getUserManager(), |
|
1176 | - $c->getGroupManager() |
|
1177 | - ); |
|
1178 | - }); |
|
1179 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1180 | - |
|
1181 | - $this->connectDispatcher(); |
|
1182 | - } |
|
1183 | - |
|
1184 | - /** |
|
1185 | - * @return \OCP\Calendar\IManager |
|
1186 | - */ |
|
1187 | - public function getCalendarManager() { |
|
1188 | - return $this->query('CalendarManager'); |
|
1189 | - } |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * @return \OCP\Calendar\Resource\IManager |
|
1193 | - */ |
|
1194 | - public function getCalendarResourceBackendManager() { |
|
1195 | - return $this->query('CalendarResourceBackendManager'); |
|
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * @return \OCP\Calendar\Room\IManager |
|
1200 | - */ |
|
1201 | - public function getCalendarRoomBackendManager() { |
|
1202 | - return $this->query('CalendarRoomBackendManager'); |
|
1203 | - } |
|
1204 | - |
|
1205 | - private function connectDispatcher() { |
|
1206 | - $dispatcher = $this->getEventDispatcher(); |
|
1207 | - |
|
1208 | - // Delete avatar on user deletion |
|
1209 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1210 | - $logger = $this->getLogger(); |
|
1211 | - $manager = $this->getAvatarManager(); |
|
1212 | - /** @var IUser $user */ |
|
1213 | - $user = $e->getSubject(); |
|
1214 | - |
|
1215 | - try { |
|
1216 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1217 | - $avatar->remove(); |
|
1218 | - } catch (NotFoundException $e) { |
|
1219 | - // no avatar to remove |
|
1220 | - } catch (\Exception $e) { |
|
1221 | - // Ignore exceptions |
|
1222 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1223 | - } |
|
1224 | - }); |
|
1225 | - |
|
1226 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1227 | - $manager = $this->getAvatarManager(); |
|
1228 | - /** @var IUser $user */ |
|
1229 | - $user = $e->getSubject(); |
|
1230 | - $feature = $e->getArgument('feature'); |
|
1231 | - $oldValue = $e->getArgument('oldValue'); |
|
1232 | - $value = $e->getArgument('value'); |
|
1233 | - |
|
1234 | - try { |
|
1235 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1236 | - $avatar->userChanged($feature, $oldValue, $value); |
|
1237 | - } catch (NotFoundException $e) { |
|
1238 | - // no avatar to remove |
|
1239 | - } |
|
1240 | - }); |
|
1241 | - } |
|
1242 | - |
|
1243 | - /** |
|
1244 | - * @return \OCP\Contacts\IManager |
|
1245 | - */ |
|
1246 | - public function getContactsManager() { |
|
1247 | - return $this->query('ContactsManager'); |
|
1248 | - } |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * @return \OC\Encryption\Manager |
|
1252 | - */ |
|
1253 | - public function getEncryptionManager() { |
|
1254 | - return $this->query('EncryptionManager'); |
|
1255 | - } |
|
1256 | - |
|
1257 | - /** |
|
1258 | - * @return \OC\Encryption\File |
|
1259 | - */ |
|
1260 | - public function getEncryptionFilesHelper() { |
|
1261 | - return $this->query('EncryptionFileHelper'); |
|
1262 | - } |
|
1263 | - |
|
1264 | - /** |
|
1265 | - * @return \OCP\Encryption\Keys\IStorage |
|
1266 | - */ |
|
1267 | - public function getEncryptionKeyStorage() { |
|
1268 | - return $this->query('EncryptionKeyStorage'); |
|
1269 | - } |
|
1270 | - |
|
1271 | - /** |
|
1272 | - * The current request object holding all information about the request |
|
1273 | - * currently being processed is returned from this method. |
|
1274 | - * In case the current execution was not initiated by a web request null is returned |
|
1275 | - * |
|
1276 | - * @return \OCP\IRequest |
|
1277 | - */ |
|
1278 | - public function getRequest() { |
|
1279 | - return $this->query('Request'); |
|
1280 | - } |
|
1281 | - |
|
1282 | - /** |
|
1283 | - * Returns the preview manager which can create preview images for a given file |
|
1284 | - * |
|
1285 | - * @return \OCP\IPreview |
|
1286 | - */ |
|
1287 | - public function getPreviewManager() { |
|
1288 | - return $this->query('PreviewManager'); |
|
1289 | - } |
|
1290 | - |
|
1291 | - /** |
|
1292 | - * Returns the tag manager which can get and set tags for different object types |
|
1293 | - * |
|
1294 | - * @see \OCP\ITagManager::load() |
|
1295 | - * @return \OCP\ITagManager |
|
1296 | - */ |
|
1297 | - public function getTagManager() { |
|
1298 | - return $this->query('TagManager'); |
|
1299 | - } |
|
1300 | - |
|
1301 | - /** |
|
1302 | - * Returns the system-tag manager |
|
1303 | - * |
|
1304 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1305 | - * |
|
1306 | - * @since 9.0.0 |
|
1307 | - */ |
|
1308 | - public function getSystemTagManager() { |
|
1309 | - return $this->query('SystemTagManager'); |
|
1310 | - } |
|
1311 | - |
|
1312 | - /** |
|
1313 | - * Returns the system-tag object mapper |
|
1314 | - * |
|
1315 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1316 | - * |
|
1317 | - * @since 9.0.0 |
|
1318 | - */ |
|
1319 | - public function getSystemTagObjectMapper() { |
|
1320 | - return $this->query('SystemTagObjectMapper'); |
|
1321 | - } |
|
1322 | - |
|
1323 | - /** |
|
1324 | - * Returns the avatar manager, used for avatar functionality |
|
1325 | - * |
|
1326 | - * @return \OCP\IAvatarManager |
|
1327 | - */ |
|
1328 | - public function getAvatarManager() { |
|
1329 | - return $this->query('AvatarManager'); |
|
1330 | - } |
|
1331 | - |
|
1332 | - /** |
|
1333 | - * Returns the root folder of ownCloud's data directory |
|
1334 | - * |
|
1335 | - * @return \OCP\Files\IRootFolder |
|
1336 | - */ |
|
1337 | - public function getRootFolder() { |
|
1338 | - return $this->query('LazyRootFolder'); |
|
1339 | - } |
|
1340 | - |
|
1341 | - /** |
|
1342 | - * Returns the root folder of ownCloud's data directory |
|
1343 | - * This is the lazy variant so this gets only initialized once it |
|
1344 | - * is actually used. |
|
1345 | - * |
|
1346 | - * @return \OCP\Files\IRootFolder |
|
1347 | - */ |
|
1348 | - public function getLazyRootFolder() { |
|
1349 | - return $this->query('LazyRootFolder'); |
|
1350 | - } |
|
1351 | - |
|
1352 | - /** |
|
1353 | - * Returns a view to ownCloud's files folder |
|
1354 | - * |
|
1355 | - * @param string $userId user ID |
|
1356 | - * @return \OCP\Files\Folder|null |
|
1357 | - */ |
|
1358 | - public function getUserFolder($userId = null) { |
|
1359 | - if ($userId === null) { |
|
1360 | - $user = $this->getUserSession()->getUser(); |
|
1361 | - if (!$user) { |
|
1362 | - return null; |
|
1363 | - } |
|
1364 | - $userId = $user->getUID(); |
|
1365 | - } |
|
1366 | - $root = $this->getRootFolder(); |
|
1367 | - return $root->getUserFolder($userId); |
|
1368 | - } |
|
1369 | - |
|
1370 | - /** |
|
1371 | - * Returns an app-specific view in ownClouds data directory |
|
1372 | - * |
|
1373 | - * @return \OCP\Files\Folder |
|
1374 | - * @deprecated since 9.2.0 use IAppData |
|
1375 | - */ |
|
1376 | - public function getAppFolder() { |
|
1377 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1378 | - $root = $this->getRootFolder(); |
|
1379 | - if (!$root->nodeExists($dir)) { |
|
1380 | - $folder = $root->newFolder($dir); |
|
1381 | - } else { |
|
1382 | - $folder = $root->get($dir); |
|
1383 | - } |
|
1384 | - return $folder; |
|
1385 | - } |
|
1386 | - |
|
1387 | - /** |
|
1388 | - * @return \OC\User\Manager |
|
1389 | - */ |
|
1390 | - public function getUserManager() { |
|
1391 | - return $this->query('UserManager'); |
|
1392 | - } |
|
1393 | - |
|
1394 | - /** |
|
1395 | - * @return \OC\Group\Manager |
|
1396 | - */ |
|
1397 | - public function getGroupManager() { |
|
1398 | - return $this->query('GroupManager'); |
|
1399 | - } |
|
1400 | - |
|
1401 | - /** |
|
1402 | - * @return \OC\User\Session |
|
1403 | - */ |
|
1404 | - public function getUserSession() { |
|
1405 | - return $this->query('UserSession'); |
|
1406 | - } |
|
1407 | - |
|
1408 | - /** |
|
1409 | - * @return \OCP\ISession |
|
1410 | - */ |
|
1411 | - public function getSession() { |
|
1412 | - return $this->query('UserSession')->getSession(); |
|
1413 | - } |
|
1414 | - |
|
1415 | - /** |
|
1416 | - * @param \OCP\ISession $session |
|
1417 | - */ |
|
1418 | - public function setSession(\OCP\ISession $session) { |
|
1419 | - $this->query(SessionStorage::class)->setSession($session); |
|
1420 | - $this->query('UserSession')->setSession($session); |
|
1421 | - $this->query(Store::class)->setSession($session); |
|
1422 | - } |
|
1423 | - |
|
1424 | - /** |
|
1425 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1426 | - */ |
|
1427 | - public function getTwoFactorAuthManager() { |
|
1428 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1429 | - } |
|
1430 | - |
|
1431 | - /** |
|
1432 | - * @return \OC\NavigationManager |
|
1433 | - */ |
|
1434 | - public function getNavigationManager() { |
|
1435 | - return $this->query('NavigationManager'); |
|
1436 | - } |
|
1437 | - |
|
1438 | - /** |
|
1439 | - * @return \OCP\IConfig |
|
1440 | - */ |
|
1441 | - public function getConfig() { |
|
1442 | - return $this->query('AllConfig'); |
|
1443 | - } |
|
1444 | - |
|
1445 | - /** |
|
1446 | - * @return \OC\SystemConfig |
|
1447 | - */ |
|
1448 | - public function getSystemConfig() { |
|
1449 | - return $this->query('SystemConfig'); |
|
1450 | - } |
|
1451 | - |
|
1452 | - /** |
|
1453 | - * Returns the app config manager |
|
1454 | - * |
|
1455 | - * @return \OCP\IAppConfig |
|
1456 | - */ |
|
1457 | - public function getAppConfig() { |
|
1458 | - return $this->query('AppConfig'); |
|
1459 | - } |
|
1460 | - |
|
1461 | - /** |
|
1462 | - * @return \OCP\L10N\IFactory |
|
1463 | - */ |
|
1464 | - public function getL10NFactory() { |
|
1465 | - return $this->query('L10NFactory'); |
|
1466 | - } |
|
1467 | - |
|
1468 | - /** |
|
1469 | - * get an L10N instance |
|
1470 | - * |
|
1471 | - * @param string $app appid |
|
1472 | - * @param string $lang |
|
1473 | - * @return IL10N |
|
1474 | - */ |
|
1475 | - public function getL10N($app, $lang = null) { |
|
1476 | - return $this->getL10NFactory()->get($app, $lang); |
|
1477 | - } |
|
1478 | - |
|
1479 | - /** |
|
1480 | - * @return \OCP\IURLGenerator |
|
1481 | - */ |
|
1482 | - public function getURLGenerator() { |
|
1483 | - return $this->query('URLGenerator'); |
|
1484 | - } |
|
1485 | - |
|
1486 | - /** |
|
1487 | - * @return AppFetcher |
|
1488 | - */ |
|
1489 | - public function getAppFetcher() { |
|
1490 | - return $this->query(AppFetcher::class); |
|
1491 | - } |
|
1492 | - |
|
1493 | - /** |
|
1494 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1495 | - * getMemCacheFactory() instead. |
|
1496 | - * |
|
1497 | - * @return \OCP\ICache |
|
1498 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1499 | - */ |
|
1500 | - public function getCache() { |
|
1501 | - return $this->query('UserCache'); |
|
1502 | - } |
|
1503 | - |
|
1504 | - /** |
|
1505 | - * Returns an \OCP\CacheFactory instance |
|
1506 | - * |
|
1507 | - * @return \OCP\ICacheFactory |
|
1508 | - */ |
|
1509 | - public function getMemCacheFactory() { |
|
1510 | - return $this->query('MemCacheFactory'); |
|
1511 | - } |
|
1512 | - |
|
1513 | - /** |
|
1514 | - * Returns an \OC\RedisFactory instance |
|
1515 | - * |
|
1516 | - * @return \OC\RedisFactory |
|
1517 | - */ |
|
1518 | - public function getGetRedisFactory() { |
|
1519 | - return $this->query('RedisFactory'); |
|
1520 | - } |
|
1521 | - |
|
1522 | - |
|
1523 | - /** |
|
1524 | - * Returns the current session |
|
1525 | - * |
|
1526 | - * @return \OCP\IDBConnection |
|
1527 | - */ |
|
1528 | - public function getDatabaseConnection() { |
|
1529 | - return $this->query('DatabaseConnection'); |
|
1530 | - } |
|
1531 | - |
|
1532 | - /** |
|
1533 | - * Returns the activity manager |
|
1534 | - * |
|
1535 | - * @return \OCP\Activity\IManager |
|
1536 | - */ |
|
1537 | - public function getActivityManager() { |
|
1538 | - return $this->query('ActivityManager'); |
|
1539 | - } |
|
1540 | - |
|
1541 | - /** |
|
1542 | - * Returns an job list for controlling background jobs |
|
1543 | - * |
|
1544 | - * @return \OCP\BackgroundJob\IJobList |
|
1545 | - */ |
|
1546 | - public function getJobList() { |
|
1547 | - return $this->query('JobList'); |
|
1548 | - } |
|
1549 | - |
|
1550 | - /** |
|
1551 | - * Returns a logger instance |
|
1552 | - * |
|
1553 | - * @return \OCP\ILogger |
|
1554 | - */ |
|
1555 | - public function getLogger() { |
|
1556 | - return $this->query('Logger'); |
|
1557 | - } |
|
1558 | - |
|
1559 | - /** |
|
1560 | - * @return ILogFactory |
|
1561 | - * @throws \OCP\AppFramework\QueryException |
|
1562 | - */ |
|
1563 | - public function getLogFactory() { |
|
1564 | - return $this->query(ILogFactory::class); |
|
1565 | - } |
|
1566 | - |
|
1567 | - /** |
|
1568 | - * Returns a router for generating and matching urls |
|
1569 | - * |
|
1570 | - * @return \OCP\Route\IRouter |
|
1571 | - */ |
|
1572 | - public function getRouter() { |
|
1573 | - return $this->query('Router'); |
|
1574 | - } |
|
1575 | - |
|
1576 | - /** |
|
1577 | - * Returns a search instance |
|
1578 | - * |
|
1579 | - * @return \OCP\ISearch |
|
1580 | - */ |
|
1581 | - public function getSearch() { |
|
1582 | - return $this->query('Search'); |
|
1583 | - } |
|
1584 | - |
|
1585 | - /** |
|
1586 | - * Returns a SecureRandom instance |
|
1587 | - * |
|
1588 | - * @return \OCP\Security\ISecureRandom |
|
1589 | - */ |
|
1590 | - public function getSecureRandom() { |
|
1591 | - return $this->query('SecureRandom'); |
|
1592 | - } |
|
1593 | - |
|
1594 | - /** |
|
1595 | - * Returns a Crypto instance |
|
1596 | - * |
|
1597 | - * @return \OCP\Security\ICrypto |
|
1598 | - */ |
|
1599 | - public function getCrypto() { |
|
1600 | - return $this->query('Crypto'); |
|
1601 | - } |
|
1602 | - |
|
1603 | - /** |
|
1604 | - * Returns a Hasher instance |
|
1605 | - * |
|
1606 | - * @return \OCP\Security\IHasher |
|
1607 | - */ |
|
1608 | - public function getHasher() { |
|
1609 | - return $this->query('Hasher'); |
|
1610 | - } |
|
1611 | - |
|
1612 | - /** |
|
1613 | - * Returns a CredentialsManager instance |
|
1614 | - * |
|
1615 | - * @return \OCP\Security\ICredentialsManager |
|
1616 | - */ |
|
1617 | - public function getCredentialsManager() { |
|
1618 | - return $this->query('CredentialsManager'); |
|
1619 | - } |
|
1620 | - |
|
1621 | - /** |
|
1622 | - * Get the certificate manager for the user |
|
1623 | - * |
|
1624 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1625 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1626 | - */ |
|
1627 | - public function getCertificateManager($userId = '') { |
|
1628 | - if ($userId === '') { |
|
1629 | - $userSession = $this->getUserSession(); |
|
1630 | - $user = $userSession->getUser(); |
|
1631 | - if (is_null($user)) { |
|
1632 | - return null; |
|
1633 | - } |
|
1634 | - $userId = $user->getUID(); |
|
1635 | - } |
|
1636 | - return new CertificateManager( |
|
1637 | - $userId, |
|
1638 | - new View(), |
|
1639 | - $this->getConfig(), |
|
1640 | - $this->getLogger(), |
|
1641 | - $this->getSecureRandom() |
|
1642 | - ); |
|
1643 | - } |
|
1644 | - |
|
1645 | - /** |
|
1646 | - * Returns an instance of the HTTP client service |
|
1647 | - * |
|
1648 | - * @return \OCP\Http\Client\IClientService |
|
1649 | - */ |
|
1650 | - public function getHTTPClientService() { |
|
1651 | - return $this->query('HttpClientService'); |
|
1652 | - } |
|
1653 | - |
|
1654 | - /** |
|
1655 | - * Create a new event source |
|
1656 | - * |
|
1657 | - * @return \OCP\IEventSource |
|
1658 | - */ |
|
1659 | - public function createEventSource() { |
|
1660 | - return new \OC_EventSource(); |
|
1661 | - } |
|
1662 | - |
|
1663 | - /** |
|
1664 | - * Get the active event logger |
|
1665 | - * |
|
1666 | - * The returned logger only logs data when debug mode is enabled |
|
1667 | - * |
|
1668 | - * @return \OCP\Diagnostics\IEventLogger |
|
1669 | - */ |
|
1670 | - public function getEventLogger() { |
|
1671 | - return $this->query('EventLogger'); |
|
1672 | - } |
|
1673 | - |
|
1674 | - /** |
|
1675 | - * Get the active query logger |
|
1676 | - * |
|
1677 | - * The returned logger only logs data when debug mode is enabled |
|
1678 | - * |
|
1679 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1680 | - */ |
|
1681 | - public function getQueryLogger() { |
|
1682 | - return $this->query('QueryLogger'); |
|
1683 | - } |
|
1684 | - |
|
1685 | - /** |
|
1686 | - * Get the manager for temporary files and folders |
|
1687 | - * |
|
1688 | - * @return \OCP\ITempManager |
|
1689 | - */ |
|
1690 | - public function getTempManager() { |
|
1691 | - return $this->query('TempManager'); |
|
1692 | - } |
|
1693 | - |
|
1694 | - /** |
|
1695 | - * Get the app manager |
|
1696 | - * |
|
1697 | - * @return \OCP\App\IAppManager |
|
1698 | - */ |
|
1699 | - public function getAppManager() { |
|
1700 | - return $this->query('AppManager'); |
|
1701 | - } |
|
1702 | - |
|
1703 | - /** |
|
1704 | - * Creates a new mailer |
|
1705 | - * |
|
1706 | - * @return \OCP\Mail\IMailer |
|
1707 | - */ |
|
1708 | - public function getMailer() { |
|
1709 | - return $this->query('Mailer'); |
|
1710 | - } |
|
1711 | - |
|
1712 | - /** |
|
1713 | - * Get the webroot |
|
1714 | - * |
|
1715 | - * @return string |
|
1716 | - */ |
|
1717 | - public function getWebRoot() { |
|
1718 | - return $this->webRoot; |
|
1719 | - } |
|
1720 | - |
|
1721 | - /** |
|
1722 | - * @return \OC\OCSClient |
|
1723 | - */ |
|
1724 | - public function getOcsClient() { |
|
1725 | - return $this->query('OcsClient'); |
|
1726 | - } |
|
1727 | - |
|
1728 | - /** |
|
1729 | - * @return \OCP\IDateTimeZone |
|
1730 | - */ |
|
1731 | - public function getDateTimeZone() { |
|
1732 | - return $this->query('DateTimeZone'); |
|
1733 | - } |
|
1734 | - |
|
1735 | - /** |
|
1736 | - * @return \OCP\IDateTimeFormatter |
|
1737 | - */ |
|
1738 | - public function getDateTimeFormatter() { |
|
1739 | - return $this->query('DateTimeFormatter'); |
|
1740 | - } |
|
1741 | - |
|
1742 | - /** |
|
1743 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1744 | - */ |
|
1745 | - public function getMountProviderCollection() { |
|
1746 | - return $this->query('MountConfigManager'); |
|
1747 | - } |
|
1748 | - |
|
1749 | - /** |
|
1750 | - * Get the IniWrapper |
|
1751 | - * |
|
1752 | - * @return IniGetWrapper |
|
1753 | - */ |
|
1754 | - public function getIniWrapper() { |
|
1755 | - return $this->query('IniWrapper'); |
|
1756 | - } |
|
1757 | - |
|
1758 | - /** |
|
1759 | - * @return \OCP\Command\IBus |
|
1760 | - */ |
|
1761 | - public function getCommandBus() { |
|
1762 | - return $this->query('AsyncCommandBus'); |
|
1763 | - } |
|
1764 | - |
|
1765 | - /** |
|
1766 | - * Get the trusted domain helper |
|
1767 | - * |
|
1768 | - * @return TrustedDomainHelper |
|
1769 | - */ |
|
1770 | - public function getTrustedDomainHelper() { |
|
1771 | - return $this->query('TrustedDomainHelper'); |
|
1772 | - } |
|
1773 | - |
|
1774 | - /** |
|
1775 | - * Get the locking provider |
|
1776 | - * |
|
1777 | - * @return \OCP\Lock\ILockingProvider |
|
1778 | - * @since 8.1.0 |
|
1779 | - */ |
|
1780 | - public function getLockingProvider() { |
|
1781 | - return $this->query('LockingProvider'); |
|
1782 | - } |
|
1783 | - |
|
1784 | - /** |
|
1785 | - * @return \OCP\Files\Mount\IMountManager |
|
1786 | - **/ |
|
1787 | - function getMountManager() { |
|
1788 | - return $this->query('MountManager'); |
|
1789 | - } |
|
1790 | - |
|
1791 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1792 | - function getUserMountCache() { |
|
1793 | - return $this->query('UserMountCache'); |
|
1794 | - } |
|
1795 | - |
|
1796 | - /** |
|
1797 | - * Get the MimeTypeDetector |
|
1798 | - * |
|
1799 | - * @return \OCP\Files\IMimeTypeDetector |
|
1800 | - */ |
|
1801 | - public function getMimeTypeDetector() { |
|
1802 | - return $this->query('MimeTypeDetector'); |
|
1803 | - } |
|
1804 | - |
|
1805 | - /** |
|
1806 | - * Get the MimeTypeLoader |
|
1807 | - * |
|
1808 | - * @return \OCP\Files\IMimeTypeLoader |
|
1809 | - */ |
|
1810 | - public function getMimeTypeLoader() { |
|
1811 | - return $this->query('MimeTypeLoader'); |
|
1812 | - } |
|
1813 | - |
|
1814 | - /** |
|
1815 | - * Get the manager of all the capabilities |
|
1816 | - * |
|
1817 | - * @return \OC\CapabilitiesManager |
|
1818 | - */ |
|
1819 | - public function getCapabilitiesManager() { |
|
1820 | - return $this->query('CapabilitiesManager'); |
|
1821 | - } |
|
1822 | - |
|
1823 | - /** |
|
1824 | - * Get the EventDispatcher |
|
1825 | - * |
|
1826 | - * @return EventDispatcherInterface |
|
1827 | - * @since 8.2.0 |
|
1828 | - */ |
|
1829 | - public function getEventDispatcher() { |
|
1830 | - return $this->query('EventDispatcher'); |
|
1831 | - } |
|
1832 | - |
|
1833 | - /** |
|
1834 | - * Get the Notification Manager |
|
1835 | - * |
|
1836 | - * @return \OCP\Notification\IManager |
|
1837 | - * @since 8.2.0 |
|
1838 | - */ |
|
1839 | - public function getNotificationManager() { |
|
1840 | - return $this->query('NotificationManager'); |
|
1841 | - } |
|
1842 | - |
|
1843 | - /** |
|
1844 | - * @return \OCP\Comments\ICommentsManager |
|
1845 | - */ |
|
1846 | - public function getCommentsManager() { |
|
1847 | - return $this->query('CommentsManager'); |
|
1848 | - } |
|
1849 | - |
|
1850 | - /** |
|
1851 | - * @return \OCA\Theming\ThemingDefaults |
|
1852 | - */ |
|
1853 | - public function getThemingDefaults() { |
|
1854 | - return $this->query('ThemingDefaults'); |
|
1855 | - } |
|
1856 | - |
|
1857 | - /** |
|
1858 | - * @return \OC\IntegrityCheck\Checker |
|
1859 | - */ |
|
1860 | - public function getIntegrityCodeChecker() { |
|
1861 | - return $this->query('IntegrityCodeChecker'); |
|
1862 | - } |
|
1863 | - |
|
1864 | - /** |
|
1865 | - * @return \OC\Session\CryptoWrapper |
|
1866 | - */ |
|
1867 | - public function getSessionCryptoWrapper() { |
|
1868 | - return $this->query('CryptoWrapper'); |
|
1869 | - } |
|
1870 | - |
|
1871 | - /** |
|
1872 | - * @return CsrfTokenManager |
|
1873 | - */ |
|
1874 | - public function getCsrfTokenManager() { |
|
1875 | - return $this->query('CsrfTokenManager'); |
|
1876 | - } |
|
1877 | - |
|
1878 | - /** |
|
1879 | - * @return Throttler |
|
1880 | - */ |
|
1881 | - public function getBruteForceThrottler() { |
|
1882 | - return $this->query('Throttler'); |
|
1883 | - } |
|
1884 | - |
|
1885 | - /** |
|
1886 | - * @return IContentSecurityPolicyManager |
|
1887 | - */ |
|
1888 | - public function getContentSecurityPolicyManager() { |
|
1889 | - return $this->query('ContentSecurityPolicyManager'); |
|
1890 | - } |
|
1891 | - |
|
1892 | - /** |
|
1893 | - * @return ContentSecurityPolicyNonceManager |
|
1894 | - */ |
|
1895 | - public function getContentSecurityPolicyNonceManager() { |
|
1896 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1897 | - } |
|
1898 | - |
|
1899 | - /** |
|
1900 | - * Not a public API as of 8.2, wait for 9.0 |
|
1901 | - * |
|
1902 | - * @return \OCA\Files_External\Service\BackendService |
|
1903 | - */ |
|
1904 | - public function getStoragesBackendService() { |
|
1905 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1906 | - } |
|
1907 | - |
|
1908 | - /** |
|
1909 | - * Not a public API as of 8.2, wait for 9.0 |
|
1910 | - * |
|
1911 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1912 | - */ |
|
1913 | - public function getGlobalStoragesService() { |
|
1914 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1915 | - } |
|
1916 | - |
|
1917 | - /** |
|
1918 | - * Not a public API as of 8.2, wait for 9.0 |
|
1919 | - * |
|
1920 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1921 | - */ |
|
1922 | - public function getUserGlobalStoragesService() { |
|
1923 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1924 | - } |
|
1925 | - |
|
1926 | - /** |
|
1927 | - * Not a public API as of 8.2, wait for 9.0 |
|
1928 | - * |
|
1929 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1930 | - */ |
|
1931 | - public function getUserStoragesService() { |
|
1932 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1933 | - } |
|
1934 | - |
|
1935 | - /** |
|
1936 | - * @return \OCP\Share\IManager |
|
1937 | - */ |
|
1938 | - public function getShareManager() { |
|
1939 | - return $this->query('ShareManager'); |
|
1940 | - } |
|
1941 | - |
|
1942 | - /** |
|
1943 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
1944 | - */ |
|
1945 | - public function getCollaboratorSearch() { |
|
1946 | - return $this->query('CollaboratorSearch'); |
|
1947 | - } |
|
1948 | - |
|
1949 | - /** |
|
1950 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
1951 | - */ |
|
1952 | - public function getAutoCompleteManager(){ |
|
1953 | - return $this->query(IManager::class); |
|
1954 | - } |
|
1955 | - |
|
1956 | - /** |
|
1957 | - * Returns the LDAP Provider |
|
1958 | - * |
|
1959 | - * @return \OCP\LDAP\ILDAPProvider |
|
1960 | - */ |
|
1961 | - public function getLDAPProvider() { |
|
1962 | - return $this->query('LDAPProvider'); |
|
1963 | - } |
|
1964 | - |
|
1965 | - /** |
|
1966 | - * @return \OCP\Settings\IManager |
|
1967 | - */ |
|
1968 | - public function getSettingsManager() { |
|
1969 | - return $this->query('SettingsManager'); |
|
1970 | - } |
|
1971 | - |
|
1972 | - /** |
|
1973 | - * @return \OCP\Files\IAppData |
|
1974 | - */ |
|
1975 | - public function getAppDataDir($app) { |
|
1976 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1977 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1978 | - return $factory->get($app); |
|
1979 | - } |
|
1980 | - |
|
1981 | - /** |
|
1982 | - * @return \OCP\Lockdown\ILockdownManager |
|
1983 | - */ |
|
1984 | - public function getLockdownManager() { |
|
1985 | - return $this->query('LockdownManager'); |
|
1986 | - } |
|
1987 | - |
|
1988 | - /** |
|
1989 | - * @return \OCP\Federation\ICloudIdManager |
|
1990 | - */ |
|
1991 | - public function getCloudIdManager() { |
|
1992 | - return $this->query(ICloudIdManager::class); |
|
1993 | - } |
|
1994 | - |
|
1995 | - /** |
|
1996 | - * @return \OCP\Remote\Api\IApiFactory |
|
1997 | - */ |
|
1998 | - public function getRemoteApiFactory() { |
|
1999 | - return $this->query(IApiFactory::class); |
|
2000 | - } |
|
2001 | - |
|
2002 | - /** |
|
2003 | - * @return \OCP\Remote\IInstanceFactory |
|
2004 | - */ |
|
2005 | - public function getRemoteInstanceFactory() { |
|
2006 | - return $this->query(IInstanceFactory::class); |
|
2007 | - } |
|
949 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
950 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
951 | + $classExists = true; |
|
952 | + } else { |
|
953 | + $classExists = false; |
|
954 | + } |
|
955 | + |
|
956 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
957 | + return new ThemingDefaults( |
|
958 | + $c->getConfig(), |
|
959 | + $c->getL10N('theming'), |
|
960 | + $c->getURLGenerator(), |
|
961 | + $c->getMemCacheFactory(), |
|
962 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
963 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), |
|
964 | + $c->getAppManager() |
|
965 | + ); |
|
966 | + } |
|
967 | + return new \OC_Defaults(); |
|
968 | + }); |
|
969 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
970 | + /** @var Factory $cacheFactory */ |
|
971 | + $cacheFactory = $c->query(Factory::class); |
|
972 | + return new SCSSCacher( |
|
973 | + $c->getLogger(), |
|
974 | + $c->query(\OC\Files\AppData\Factory::class), |
|
975 | + $c->getURLGenerator(), |
|
976 | + $c->getConfig(), |
|
977 | + $c->getThemingDefaults(), |
|
978 | + \OC::$SERVERROOT, |
|
979 | + $this->getMemCacheFactory() |
|
980 | + ); |
|
981 | + }); |
|
982 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
983 | + /** @var Factory $cacheFactory */ |
|
984 | + $cacheFactory = $c->query(Factory::class); |
|
985 | + return new JSCombiner( |
|
986 | + $c->getAppDataDir('js'), |
|
987 | + $c->getURLGenerator(), |
|
988 | + $this->getMemCacheFactory(), |
|
989 | + $c->getSystemConfig(), |
|
990 | + $c->getLogger() |
|
991 | + ); |
|
992 | + }); |
|
993 | + $this->registerService(EventDispatcher::class, function () { |
|
994 | + return new EventDispatcher(); |
|
995 | + }); |
|
996 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
997 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
998 | + |
|
999 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
1000 | + // FIXME: Instantiiated here due to cyclic dependency |
|
1001 | + $request = new Request( |
|
1002 | + [ |
|
1003 | + 'get' => $_GET, |
|
1004 | + 'post' => $_POST, |
|
1005 | + 'files' => $_FILES, |
|
1006 | + 'server' => $_SERVER, |
|
1007 | + 'env' => $_ENV, |
|
1008 | + 'cookies' => $_COOKIE, |
|
1009 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1010 | + ? $_SERVER['REQUEST_METHOD'] |
|
1011 | + : null, |
|
1012 | + ], |
|
1013 | + $c->getSecureRandom(), |
|
1014 | + $c->getConfig() |
|
1015 | + ); |
|
1016 | + |
|
1017 | + return new CryptoWrapper( |
|
1018 | + $c->getConfig(), |
|
1019 | + $c->getCrypto(), |
|
1020 | + $c->getSecureRandom(), |
|
1021 | + $request |
|
1022 | + ); |
|
1023 | + }); |
|
1024 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1025 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1026 | + |
|
1027 | + return new CsrfTokenManager( |
|
1028 | + $tokenGenerator, |
|
1029 | + $c->query(SessionStorage::class) |
|
1030 | + ); |
|
1031 | + }); |
|
1032 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
1033 | + return new SessionStorage($c->getSession()); |
|
1034 | + }); |
|
1035 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1036 | + return new ContentSecurityPolicyManager(); |
|
1037 | + }); |
|
1038 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1039 | + |
|
1040 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1041 | + return new ContentSecurityPolicyNonceManager( |
|
1042 | + $c->getCsrfTokenManager(), |
|
1043 | + $c->getRequest() |
|
1044 | + ); |
|
1045 | + }); |
|
1046 | + |
|
1047 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1048 | + $config = $c->getConfig(); |
|
1049 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1050 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
1051 | + $factory = new $factoryClass($this); |
|
1052 | + |
|
1053 | + $manager = new \OC\Share20\Manager( |
|
1054 | + $c->getLogger(), |
|
1055 | + $c->getConfig(), |
|
1056 | + $c->getSecureRandom(), |
|
1057 | + $c->getHasher(), |
|
1058 | + $c->getMountManager(), |
|
1059 | + $c->getGroupManager(), |
|
1060 | + $c->getL10N('lib'), |
|
1061 | + $c->getL10NFactory(), |
|
1062 | + $factory, |
|
1063 | + $c->getUserManager(), |
|
1064 | + $c->getLazyRootFolder(), |
|
1065 | + $c->getEventDispatcher(), |
|
1066 | + $c->getMailer(), |
|
1067 | + $c->getURLGenerator(), |
|
1068 | + $c->getThemingDefaults() |
|
1069 | + ); |
|
1070 | + |
|
1071 | + return $manager; |
|
1072 | + }); |
|
1073 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1074 | + |
|
1075 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1076 | + $instance = new Collaboration\Collaborators\Search($c); |
|
1077 | + |
|
1078 | + // register default plugins |
|
1079 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1080 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1081 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1082 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1083 | + |
|
1084 | + return $instance; |
|
1085 | + }); |
|
1086 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1087 | + |
|
1088 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1089 | + |
|
1090 | + $this->registerService('SettingsManager', function (Server $c) { |
|
1091 | + $manager = new \OC\Settings\Manager( |
|
1092 | + $c->getLogger(), |
|
1093 | + $c->getDatabaseConnection(), |
|
1094 | + $c->getL10N('lib'), |
|
1095 | + $c->getConfig(), |
|
1096 | + $c->getEncryptionManager(), |
|
1097 | + $c->getUserManager(), |
|
1098 | + $c->getLockingProvider(), |
|
1099 | + $c->getRequest(), |
|
1100 | + $c->getURLGenerator(), |
|
1101 | + $c->query(AccountManager::class), |
|
1102 | + $c->getGroupManager(), |
|
1103 | + $c->getL10NFactory(), |
|
1104 | + $c->getAppManager() |
|
1105 | + ); |
|
1106 | + return $manager; |
|
1107 | + }); |
|
1108 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1109 | + return new \OC\Files\AppData\Factory( |
|
1110 | + $c->getRootFolder(), |
|
1111 | + $c->getSystemConfig() |
|
1112 | + ); |
|
1113 | + }); |
|
1114 | + |
|
1115 | + $this->registerService('LockdownManager', function (Server $c) { |
|
1116 | + return new LockdownManager(function () use ($c) { |
|
1117 | + return $c->getSession(); |
|
1118 | + }); |
|
1119 | + }); |
|
1120 | + |
|
1121 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1122 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1123 | + }); |
|
1124 | + |
|
1125 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1126 | + return new CloudIdManager(); |
|
1127 | + }); |
|
1128 | + |
|
1129 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1130 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1131 | + |
|
1132 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1133 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1134 | + |
|
1135 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1136 | + return new Defaults( |
|
1137 | + $c->getThemingDefaults() |
|
1138 | + ); |
|
1139 | + }); |
|
1140 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1141 | + |
|
1142 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1143 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1144 | + }); |
|
1145 | + |
|
1146 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
1147 | + return new ShareHelper( |
|
1148 | + $c->query(\OCP\Share\IManager::class) |
|
1149 | + ); |
|
1150 | + }); |
|
1151 | + |
|
1152 | + $this->registerService(Installer::class, function(Server $c) { |
|
1153 | + return new Installer( |
|
1154 | + $c->getAppFetcher(), |
|
1155 | + $c->getHTTPClientService(), |
|
1156 | + $c->getTempManager(), |
|
1157 | + $c->getLogger(), |
|
1158 | + $c->getConfig() |
|
1159 | + ); |
|
1160 | + }); |
|
1161 | + |
|
1162 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
1163 | + return new ApiFactory($c->getHTTPClientService()); |
|
1164 | + }); |
|
1165 | + |
|
1166 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1167 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
1168 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1169 | + }); |
|
1170 | + |
|
1171 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
1172 | + return new ContactsStore( |
|
1173 | + $c->getContactsManager(), |
|
1174 | + $c->getConfig(), |
|
1175 | + $c->getUserManager(), |
|
1176 | + $c->getGroupManager() |
|
1177 | + ); |
|
1178 | + }); |
|
1179 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1180 | + |
|
1181 | + $this->connectDispatcher(); |
|
1182 | + } |
|
1183 | + |
|
1184 | + /** |
|
1185 | + * @return \OCP\Calendar\IManager |
|
1186 | + */ |
|
1187 | + public function getCalendarManager() { |
|
1188 | + return $this->query('CalendarManager'); |
|
1189 | + } |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * @return \OCP\Calendar\Resource\IManager |
|
1193 | + */ |
|
1194 | + public function getCalendarResourceBackendManager() { |
|
1195 | + return $this->query('CalendarResourceBackendManager'); |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * @return \OCP\Calendar\Room\IManager |
|
1200 | + */ |
|
1201 | + public function getCalendarRoomBackendManager() { |
|
1202 | + return $this->query('CalendarRoomBackendManager'); |
|
1203 | + } |
|
1204 | + |
|
1205 | + private function connectDispatcher() { |
|
1206 | + $dispatcher = $this->getEventDispatcher(); |
|
1207 | + |
|
1208 | + // Delete avatar on user deletion |
|
1209 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1210 | + $logger = $this->getLogger(); |
|
1211 | + $manager = $this->getAvatarManager(); |
|
1212 | + /** @var IUser $user */ |
|
1213 | + $user = $e->getSubject(); |
|
1214 | + |
|
1215 | + try { |
|
1216 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1217 | + $avatar->remove(); |
|
1218 | + } catch (NotFoundException $e) { |
|
1219 | + // no avatar to remove |
|
1220 | + } catch (\Exception $e) { |
|
1221 | + // Ignore exceptions |
|
1222 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1223 | + } |
|
1224 | + }); |
|
1225 | + |
|
1226 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1227 | + $manager = $this->getAvatarManager(); |
|
1228 | + /** @var IUser $user */ |
|
1229 | + $user = $e->getSubject(); |
|
1230 | + $feature = $e->getArgument('feature'); |
|
1231 | + $oldValue = $e->getArgument('oldValue'); |
|
1232 | + $value = $e->getArgument('value'); |
|
1233 | + |
|
1234 | + try { |
|
1235 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1236 | + $avatar->userChanged($feature, $oldValue, $value); |
|
1237 | + } catch (NotFoundException $e) { |
|
1238 | + // no avatar to remove |
|
1239 | + } |
|
1240 | + }); |
|
1241 | + } |
|
1242 | + |
|
1243 | + /** |
|
1244 | + * @return \OCP\Contacts\IManager |
|
1245 | + */ |
|
1246 | + public function getContactsManager() { |
|
1247 | + return $this->query('ContactsManager'); |
|
1248 | + } |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * @return \OC\Encryption\Manager |
|
1252 | + */ |
|
1253 | + public function getEncryptionManager() { |
|
1254 | + return $this->query('EncryptionManager'); |
|
1255 | + } |
|
1256 | + |
|
1257 | + /** |
|
1258 | + * @return \OC\Encryption\File |
|
1259 | + */ |
|
1260 | + public function getEncryptionFilesHelper() { |
|
1261 | + return $this->query('EncryptionFileHelper'); |
|
1262 | + } |
|
1263 | + |
|
1264 | + /** |
|
1265 | + * @return \OCP\Encryption\Keys\IStorage |
|
1266 | + */ |
|
1267 | + public function getEncryptionKeyStorage() { |
|
1268 | + return $this->query('EncryptionKeyStorage'); |
|
1269 | + } |
|
1270 | + |
|
1271 | + /** |
|
1272 | + * The current request object holding all information about the request |
|
1273 | + * currently being processed is returned from this method. |
|
1274 | + * In case the current execution was not initiated by a web request null is returned |
|
1275 | + * |
|
1276 | + * @return \OCP\IRequest |
|
1277 | + */ |
|
1278 | + public function getRequest() { |
|
1279 | + return $this->query('Request'); |
|
1280 | + } |
|
1281 | + |
|
1282 | + /** |
|
1283 | + * Returns the preview manager which can create preview images for a given file |
|
1284 | + * |
|
1285 | + * @return \OCP\IPreview |
|
1286 | + */ |
|
1287 | + public function getPreviewManager() { |
|
1288 | + return $this->query('PreviewManager'); |
|
1289 | + } |
|
1290 | + |
|
1291 | + /** |
|
1292 | + * Returns the tag manager which can get and set tags for different object types |
|
1293 | + * |
|
1294 | + * @see \OCP\ITagManager::load() |
|
1295 | + * @return \OCP\ITagManager |
|
1296 | + */ |
|
1297 | + public function getTagManager() { |
|
1298 | + return $this->query('TagManager'); |
|
1299 | + } |
|
1300 | + |
|
1301 | + /** |
|
1302 | + * Returns the system-tag manager |
|
1303 | + * |
|
1304 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1305 | + * |
|
1306 | + * @since 9.0.0 |
|
1307 | + */ |
|
1308 | + public function getSystemTagManager() { |
|
1309 | + return $this->query('SystemTagManager'); |
|
1310 | + } |
|
1311 | + |
|
1312 | + /** |
|
1313 | + * Returns the system-tag object mapper |
|
1314 | + * |
|
1315 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1316 | + * |
|
1317 | + * @since 9.0.0 |
|
1318 | + */ |
|
1319 | + public function getSystemTagObjectMapper() { |
|
1320 | + return $this->query('SystemTagObjectMapper'); |
|
1321 | + } |
|
1322 | + |
|
1323 | + /** |
|
1324 | + * Returns the avatar manager, used for avatar functionality |
|
1325 | + * |
|
1326 | + * @return \OCP\IAvatarManager |
|
1327 | + */ |
|
1328 | + public function getAvatarManager() { |
|
1329 | + return $this->query('AvatarManager'); |
|
1330 | + } |
|
1331 | + |
|
1332 | + /** |
|
1333 | + * Returns the root folder of ownCloud's data directory |
|
1334 | + * |
|
1335 | + * @return \OCP\Files\IRootFolder |
|
1336 | + */ |
|
1337 | + public function getRootFolder() { |
|
1338 | + return $this->query('LazyRootFolder'); |
|
1339 | + } |
|
1340 | + |
|
1341 | + /** |
|
1342 | + * Returns the root folder of ownCloud's data directory |
|
1343 | + * This is the lazy variant so this gets only initialized once it |
|
1344 | + * is actually used. |
|
1345 | + * |
|
1346 | + * @return \OCP\Files\IRootFolder |
|
1347 | + */ |
|
1348 | + public function getLazyRootFolder() { |
|
1349 | + return $this->query('LazyRootFolder'); |
|
1350 | + } |
|
1351 | + |
|
1352 | + /** |
|
1353 | + * Returns a view to ownCloud's files folder |
|
1354 | + * |
|
1355 | + * @param string $userId user ID |
|
1356 | + * @return \OCP\Files\Folder|null |
|
1357 | + */ |
|
1358 | + public function getUserFolder($userId = null) { |
|
1359 | + if ($userId === null) { |
|
1360 | + $user = $this->getUserSession()->getUser(); |
|
1361 | + if (!$user) { |
|
1362 | + return null; |
|
1363 | + } |
|
1364 | + $userId = $user->getUID(); |
|
1365 | + } |
|
1366 | + $root = $this->getRootFolder(); |
|
1367 | + return $root->getUserFolder($userId); |
|
1368 | + } |
|
1369 | + |
|
1370 | + /** |
|
1371 | + * Returns an app-specific view in ownClouds data directory |
|
1372 | + * |
|
1373 | + * @return \OCP\Files\Folder |
|
1374 | + * @deprecated since 9.2.0 use IAppData |
|
1375 | + */ |
|
1376 | + public function getAppFolder() { |
|
1377 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1378 | + $root = $this->getRootFolder(); |
|
1379 | + if (!$root->nodeExists($dir)) { |
|
1380 | + $folder = $root->newFolder($dir); |
|
1381 | + } else { |
|
1382 | + $folder = $root->get($dir); |
|
1383 | + } |
|
1384 | + return $folder; |
|
1385 | + } |
|
1386 | + |
|
1387 | + /** |
|
1388 | + * @return \OC\User\Manager |
|
1389 | + */ |
|
1390 | + public function getUserManager() { |
|
1391 | + return $this->query('UserManager'); |
|
1392 | + } |
|
1393 | + |
|
1394 | + /** |
|
1395 | + * @return \OC\Group\Manager |
|
1396 | + */ |
|
1397 | + public function getGroupManager() { |
|
1398 | + return $this->query('GroupManager'); |
|
1399 | + } |
|
1400 | + |
|
1401 | + /** |
|
1402 | + * @return \OC\User\Session |
|
1403 | + */ |
|
1404 | + public function getUserSession() { |
|
1405 | + return $this->query('UserSession'); |
|
1406 | + } |
|
1407 | + |
|
1408 | + /** |
|
1409 | + * @return \OCP\ISession |
|
1410 | + */ |
|
1411 | + public function getSession() { |
|
1412 | + return $this->query('UserSession')->getSession(); |
|
1413 | + } |
|
1414 | + |
|
1415 | + /** |
|
1416 | + * @param \OCP\ISession $session |
|
1417 | + */ |
|
1418 | + public function setSession(\OCP\ISession $session) { |
|
1419 | + $this->query(SessionStorage::class)->setSession($session); |
|
1420 | + $this->query('UserSession')->setSession($session); |
|
1421 | + $this->query(Store::class)->setSession($session); |
|
1422 | + } |
|
1423 | + |
|
1424 | + /** |
|
1425 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1426 | + */ |
|
1427 | + public function getTwoFactorAuthManager() { |
|
1428 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1429 | + } |
|
1430 | + |
|
1431 | + /** |
|
1432 | + * @return \OC\NavigationManager |
|
1433 | + */ |
|
1434 | + public function getNavigationManager() { |
|
1435 | + return $this->query('NavigationManager'); |
|
1436 | + } |
|
1437 | + |
|
1438 | + /** |
|
1439 | + * @return \OCP\IConfig |
|
1440 | + */ |
|
1441 | + public function getConfig() { |
|
1442 | + return $this->query('AllConfig'); |
|
1443 | + } |
|
1444 | + |
|
1445 | + /** |
|
1446 | + * @return \OC\SystemConfig |
|
1447 | + */ |
|
1448 | + public function getSystemConfig() { |
|
1449 | + return $this->query('SystemConfig'); |
|
1450 | + } |
|
1451 | + |
|
1452 | + /** |
|
1453 | + * Returns the app config manager |
|
1454 | + * |
|
1455 | + * @return \OCP\IAppConfig |
|
1456 | + */ |
|
1457 | + public function getAppConfig() { |
|
1458 | + return $this->query('AppConfig'); |
|
1459 | + } |
|
1460 | + |
|
1461 | + /** |
|
1462 | + * @return \OCP\L10N\IFactory |
|
1463 | + */ |
|
1464 | + public function getL10NFactory() { |
|
1465 | + return $this->query('L10NFactory'); |
|
1466 | + } |
|
1467 | + |
|
1468 | + /** |
|
1469 | + * get an L10N instance |
|
1470 | + * |
|
1471 | + * @param string $app appid |
|
1472 | + * @param string $lang |
|
1473 | + * @return IL10N |
|
1474 | + */ |
|
1475 | + public function getL10N($app, $lang = null) { |
|
1476 | + return $this->getL10NFactory()->get($app, $lang); |
|
1477 | + } |
|
1478 | + |
|
1479 | + /** |
|
1480 | + * @return \OCP\IURLGenerator |
|
1481 | + */ |
|
1482 | + public function getURLGenerator() { |
|
1483 | + return $this->query('URLGenerator'); |
|
1484 | + } |
|
1485 | + |
|
1486 | + /** |
|
1487 | + * @return AppFetcher |
|
1488 | + */ |
|
1489 | + public function getAppFetcher() { |
|
1490 | + return $this->query(AppFetcher::class); |
|
1491 | + } |
|
1492 | + |
|
1493 | + /** |
|
1494 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1495 | + * getMemCacheFactory() instead. |
|
1496 | + * |
|
1497 | + * @return \OCP\ICache |
|
1498 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1499 | + */ |
|
1500 | + public function getCache() { |
|
1501 | + return $this->query('UserCache'); |
|
1502 | + } |
|
1503 | + |
|
1504 | + /** |
|
1505 | + * Returns an \OCP\CacheFactory instance |
|
1506 | + * |
|
1507 | + * @return \OCP\ICacheFactory |
|
1508 | + */ |
|
1509 | + public function getMemCacheFactory() { |
|
1510 | + return $this->query('MemCacheFactory'); |
|
1511 | + } |
|
1512 | + |
|
1513 | + /** |
|
1514 | + * Returns an \OC\RedisFactory instance |
|
1515 | + * |
|
1516 | + * @return \OC\RedisFactory |
|
1517 | + */ |
|
1518 | + public function getGetRedisFactory() { |
|
1519 | + return $this->query('RedisFactory'); |
|
1520 | + } |
|
1521 | + |
|
1522 | + |
|
1523 | + /** |
|
1524 | + * Returns the current session |
|
1525 | + * |
|
1526 | + * @return \OCP\IDBConnection |
|
1527 | + */ |
|
1528 | + public function getDatabaseConnection() { |
|
1529 | + return $this->query('DatabaseConnection'); |
|
1530 | + } |
|
1531 | + |
|
1532 | + /** |
|
1533 | + * Returns the activity manager |
|
1534 | + * |
|
1535 | + * @return \OCP\Activity\IManager |
|
1536 | + */ |
|
1537 | + public function getActivityManager() { |
|
1538 | + return $this->query('ActivityManager'); |
|
1539 | + } |
|
1540 | + |
|
1541 | + /** |
|
1542 | + * Returns an job list for controlling background jobs |
|
1543 | + * |
|
1544 | + * @return \OCP\BackgroundJob\IJobList |
|
1545 | + */ |
|
1546 | + public function getJobList() { |
|
1547 | + return $this->query('JobList'); |
|
1548 | + } |
|
1549 | + |
|
1550 | + /** |
|
1551 | + * Returns a logger instance |
|
1552 | + * |
|
1553 | + * @return \OCP\ILogger |
|
1554 | + */ |
|
1555 | + public function getLogger() { |
|
1556 | + return $this->query('Logger'); |
|
1557 | + } |
|
1558 | + |
|
1559 | + /** |
|
1560 | + * @return ILogFactory |
|
1561 | + * @throws \OCP\AppFramework\QueryException |
|
1562 | + */ |
|
1563 | + public function getLogFactory() { |
|
1564 | + return $this->query(ILogFactory::class); |
|
1565 | + } |
|
1566 | + |
|
1567 | + /** |
|
1568 | + * Returns a router for generating and matching urls |
|
1569 | + * |
|
1570 | + * @return \OCP\Route\IRouter |
|
1571 | + */ |
|
1572 | + public function getRouter() { |
|
1573 | + return $this->query('Router'); |
|
1574 | + } |
|
1575 | + |
|
1576 | + /** |
|
1577 | + * Returns a search instance |
|
1578 | + * |
|
1579 | + * @return \OCP\ISearch |
|
1580 | + */ |
|
1581 | + public function getSearch() { |
|
1582 | + return $this->query('Search'); |
|
1583 | + } |
|
1584 | + |
|
1585 | + /** |
|
1586 | + * Returns a SecureRandom instance |
|
1587 | + * |
|
1588 | + * @return \OCP\Security\ISecureRandom |
|
1589 | + */ |
|
1590 | + public function getSecureRandom() { |
|
1591 | + return $this->query('SecureRandom'); |
|
1592 | + } |
|
1593 | + |
|
1594 | + /** |
|
1595 | + * Returns a Crypto instance |
|
1596 | + * |
|
1597 | + * @return \OCP\Security\ICrypto |
|
1598 | + */ |
|
1599 | + public function getCrypto() { |
|
1600 | + return $this->query('Crypto'); |
|
1601 | + } |
|
1602 | + |
|
1603 | + /** |
|
1604 | + * Returns a Hasher instance |
|
1605 | + * |
|
1606 | + * @return \OCP\Security\IHasher |
|
1607 | + */ |
|
1608 | + public function getHasher() { |
|
1609 | + return $this->query('Hasher'); |
|
1610 | + } |
|
1611 | + |
|
1612 | + /** |
|
1613 | + * Returns a CredentialsManager instance |
|
1614 | + * |
|
1615 | + * @return \OCP\Security\ICredentialsManager |
|
1616 | + */ |
|
1617 | + public function getCredentialsManager() { |
|
1618 | + return $this->query('CredentialsManager'); |
|
1619 | + } |
|
1620 | + |
|
1621 | + /** |
|
1622 | + * Get the certificate manager for the user |
|
1623 | + * |
|
1624 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1625 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1626 | + */ |
|
1627 | + public function getCertificateManager($userId = '') { |
|
1628 | + if ($userId === '') { |
|
1629 | + $userSession = $this->getUserSession(); |
|
1630 | + $user = $userSession->getUser(); |
|
1631 | + if (is_null($user)) { |
|
1632 | + return null; |
|
1633 | + } |
|
1634 | + $userId = $user->getUID(); |
|
1635 | + } |
|
1636 | + return new CertificateManager( |
|
1637 | + $userId, |
|
1638 | + new View(), |
|
1639 | + $this->getConfig(), |
|
1640 | + $this->getLogger(), |
|
1641 | + $this->getSecureRandom() |
|
1642 | + ); |
|
1643 | + } |
|
1644 | + |
|
1645 | + /** |
|
1646 | + * Returns an instance of the HTTP client service |
|
1647 | + * |
|
1648 | + * @return \OCP\Http\Client\IClientService |
|
1649 | + */ |
|
1650 | + public function getHTTPClientService() { |
|
1651 | + return $this->query('HttpClientService'); |
|
1652 | + } |
|
1653 | + |
|
1654 | + /** |
|
1655 | + * Create a new event source |
|
1656 | + * |
|
1657 | + * @return \OCP\IEventSource |
|
1658 | + */ |
|
1659 | + public function createEventSource() { |
|
1660 | + return new \OC_EventSource(); |
|
1661 | + } |
|
1662 | + |
|
1663 | + /** |
|
1664 | + * Get the active event logger |
|
1665 | + * |
|
1666 | + * The returned logger only logs data when debug mode is enabled |
|
1667 | + * |
|
1668 | + * @return \OCP\Diagnostics\IEventLogger |
|
1669 | + */ |
|
1670 | + public function getEventLogger() { |
|
1671 | + return $this->query('EventLogger'); |
|
1672 | + } |
|
1673 | + |
|
1674 | + /** |
|
1675 | + * Get the active query logger |
|
1676 | + * |
|
1677 | + * The returned logger only logs data when debug mode is enabled |
|
1678 | + * |
|
1679 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1680 | + */ |
|
1681 | + public function getQueryLogger() { |
|
1682 | + return $this->query('QueryLogger'); |
|
1683 | + } |
|
1684 | + |
|
1685 | + /** |
|
1686 | + * Get the manager for temporary files and folders |
|
1687 | + * |
|
1688 | + * @return \OCP\ITempManager |
|
1689 | + */ |
|
1690 | + public function getTempManager() { |
|
1691 | + return $this->query('TempManager'); |
|
1692 | + } |
|
1693 | + |
|
1694 | + /** |
|
1695 | + * Get the app manager |
|
1696 | + * |
|
1697 | + * @return \OCP\App\IAppManager |
|
1698 | + */ |
|
1699 | + public function getAppManager() { |
|
1700 | + return $this->query('AppManager'); |
|
1701 | + } |
|
1702 | + |
|
1703 | + /** |
|
1704 | + * Creates a new mailer |
|
1705 | + * |
|
1706 | + * @return \OCP\Mail\IMailer |
|
1707 | + */ |
|
1708 | + public function getMailer() { |
|
1709 | + return $this->query('Mailer'); |
|
1710 | + } |
|
1711 | + |
|
1712 | + /** |
|
1713 | + * Get the webroot |
|
1714 | + * |
|
1715 | + * @return string |
|
1716 | + */ |
|
1717 | + public function getWebRoot() { |
|
1718 | + return $this->webRoot; |
|
1719 | + } |
|
1720 | + |
|
1721 | + /** |
|
1722 | + * @return \OC\OCSClient |
|
1723 | + */ |
|
1724 | + public function getOcsClient() { |
|
1725 | + return $this->query('OcsClient'); |
|
1726 | + } |
|
1727 | + |
|
1728 | + /** |
|
1729 | + * @return \OCP\IDateTimeZone |
|
1730 | + */ |
|
1731 | + public function getDateTimeZone() { |
|
1732 | + return $this->query('DateTimeZone'); |
|
1733 | + } |
|
1734 | + |
|
1735 | + /** |
|
1736 | + * @return \OCP\IDateTimeFormatter |
|
1737 | + */ |
|
1738 | + public function getDateTimeFormatter() { |
|
1739 | + return $this->query('DateTimeFormatter'); |
|
1740 | + } |
|
1741 | + |
|
1742 | + /** |
|
1743 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1744 | + */ |
|
1745 | + public function getMountProviderCollection() { |
|
1746 | + return $this->query('MountConfigManager'); |
|
1747 | + } |
|
1748 | + |
|
1749 | + /** |
|
1750 | + * Get the IniWrapper |
|
1751 | + * |
|
1752 | + * @return IniGetWrapper |
|
1753 | + */ |
|
1754 | + public function getIniWrapper() { |
|
1755 | + return $this->query('IniWrapper'); |
|
1756 | + } |
|
1757 | + |
|
1758 | + /** |
|
1759 | + * @return \OCP\Command\IBus |
|
1760 | + */ |
|
1761 | + public function getCommandBus() { |
|
1762 | + return $this->query('AsyncCommandBus'); |
|
1763 | + } |
|
1764 | + |
|
1765 | + /** |
|
1766 | + * Get the trusted domain helper |
|
1767 | + * |
|
1768 | + * @return TrustedDomainHelper |
|
1769 | + */ |
|
1770 | + public function getTrustedDomainHelper() { |
|
1771 | + return $this->query('TrustedDomainHelper'); |
|
1772 | + } |
|
1773 | + |
|
1774 | + /** |
|
1775 | + * Get the locking provider |
|
1776 | + * |
|
1777 | + * @return \OCP\Lock\ILockingProvider |
|
1778 | + * @since 8.1.0 |
|
1779 | + */ |
|
1780 | + public function getLockingProvider() { |
|
1781 | + return $this->query('LockingProvider'); |
|
1782 | + } |
|
1783 | + |
|
1784 | + /** |
|
1785 | + * @return \OCP\Files\Mount\IMountManager |
|
1786 | + **/ |
|
1787 | + function getMountManager() { |
|
1788 | + return $this->query('MountManager'); |
|
1789 | + } |
|
1790 | + |
|
1791 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1792 | + function getUserMountCache() { |
|
1793 | + return $this->query('UserMountCache'); |
|
1794 | + } |
|
1795 | + |
|
1796 | + /** |
|
1797 | + * Get the MimeTypeDetector |
|
1798 | + * |
|
1799 | + * @return \OCP\Files\IMimeTypeDetector |
|
1800 | + */ |
|
1801 | + public function getMimeTypeDetector() { |
|
1802 | + return $this->query('MimeTypeDetector'); |
|
1803 | + } |
|
1804 | + |
|
1805 | + /** |
|
1806 | + * Get the MimeTypeLoader |
|
1807 | + * |
|
1808 | + * @return \OCP\Files\IMimeTypeLoader |
|
1809 | + */ |
|
1810 | + public function getMimeTypeLoader() { |
|
1811 | + return $this->query('MimeTypeLoader'); |
|
1812 | + } |
|
1813 | + |
|
1814 | + /** |
|
1815 | + * Get the manager of all the capabilities |
|
1816 | + * |
|
1817 | + * @return \OC\CapabilitiesManager |
|
1818 | + */ |
|
1819 | + public function getCapabilitiesManager() { |
|
1820 | + return $this->query('CapabilitiesManager'); |
|
1821 | + } |
|
1822 | + |
|
1823 | + /** |
|
1824 | + * Get the EventDispatcher |
|
1825 | + * |
|
1826 | + * @return EventDispatcherInterface |
|
1827 | + * @since 8.2.0 |
|
1828 | + */ |
|
1829 | + public function getEventDispatcher() { |
|
1830 | + return $this->query('EventDispatcher'); |
|
1831 | + } |
|
1832 | + |
|
1833 | + /** |
|
1834 | + * Get the Notification Manager |
|
1835 | + * |
|
1836 | + * @return \OCP\Notification\IManager |
|
1837 | + * @since 8.2.0 |
|
1838 | + */ |
|
1839 | + public function getNotificationManager() { |
|
1840 | + return $this->query('NotificationManager'); |
|
1841 | + } |
|
1842 | + |
|
1843 | + /** |
|
1844 | + * @return \OCP\Comments\ICommentsManager |
|
1845 | + */ |
|
1846 | + public function getCommentsManager() { |
|
1847 | + return $this->query('CommentsManager'); |
|
1848 | + } |
|
1849 | + |
|
1850 | + /** |
|
1851 | + * @return \OCA\Theming\ThemingDefaults |
|
1852 | + */ |
|
1853 | + public function getThemingDefaults() { |
|
1854 | + return $this->query('ThemingDefaults'); |
|
1855 | + } |
|
1856 | + |
|
1857 | + /** |
|
1858 | + * @return \OC\IntegrityCheck\Checker |
|
1859 | + */ |
|
1860 | + public function getIntegrityCodeChecker() { |
|
1861 | + return $this->query('IntegrityCodeChecker'); |
|
1862 | + } |
|
1863 | + |
|
1864 | + /** |
|
1865 | + * @return \OC\Session\CryptoWrapper |
|
1866 | + */ |
|
1867 | + public function getSessionCryptoWrapper() { |
|
1868 | + return $this->query('CryptoWrapper'); |
|
1869 | + } |
|
1870 | + |
|
1871 | + /** |
|
1872 | + * @return CsrfTokenManager |
|
1873 | + */ |
|
1874 | + public function getCsrfTokenManager() { |
|
1875 | + return $this->query('CsrfTokenManager'); |
|
1876 | + } |
|
1877 | + |
|
1878 | + /** |
|
1879 | + * @return Throttler |
|
1880 | + */ |
|
1881 | + public function getBruteForceThrottler() { |
|
1882 | + return $this->query('Throttler'); |
|
1883 | + } |
|
1884 | + |
|
1885 | + /** |
|
1886 | + * @return IContentSecurityPolicyManager |
|
1887 | + */ |
|
1888 | + public function getContentSecurityPolicyManager() { |
|
1889 | + return $this->query('ContentSecurityPolicyManager'); |
|
1890 | + } |
|
1891 | + |
|
1892 | + /** |
|
1893 | + * @return ContentSecurityPolicyNonceManager |
|
1894 | + */ |
|
1895 | + public function getContentSecurityPolicyNonceManager() { |
|
1896 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1897 | + } |
|
1898 | + |
|
1899 | + /** |
|
1900 | + * Not a public API as of 8.2, wait for 9.0 |
|
1901 | + * |
|
1902 | + * @return \OCA\Files_External\Service\BackendService |
|
1903 | + */ |
|
1904 | + public function getStoragesBackendService() { |
|
1905 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1906 | + } |
|
1907 | + |
|
1908 | + /** |
|
1909 | + * Not a public API as of 8.2, wait for 9.0 |
|
1910 | + * |
|
1911 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1912 | + */ |
|
1913 | + public function getGlobalStoragesService() { |
|
1914 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1915 | + } |
|
1916 | + |
|
1917 | + /** |
|
1918 | + * Not a public API as of 8.2, wait for 9.0 |
|
1919 | + * |
|
1920 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1921 | + */ |
|
1922 | + public function getUserGlobalStoragesService() { |
|
1923 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1924 | + } |
|
1925 | + |
|
1926 | + /** |
|
1927 | + * Not a public API as of 8.2, wait for 9.0 |
|
1928 | + * |
|
1929 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1930 | + */ |
|
1931 | + public function getUserStoragesService() { |
|
1932 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1933 | + } |
|
1934 | + |
|
1935 | + /** |
|
1936 | + * @return \OCP\Share\IManager |
|
1937 | + */ |
|
1938 | + public function getShareManager() { |
|
1939 | + return $this->query('ShareManager'); |
|
1940 | + } |
|
1941 | + |
|
1942 | + /** |
|
1943 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
1944 | + */ |
|
1945 | + public function getCollaboratorSearch() { |
|
1946 | + return $this->query('CollaboratorSearch'); |
|
1947 | + } |
|
1948 | + |
|
1949 | + /** |
|
1950 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
1951 | + */ |
|
1952 | + public function getAutoCompleteManager(){ |
|
1953 | + return $this->query(IManager::class); |
|
1954 | + } |
|
1955 | + |
|
1956 | + /** |
|
1957 | + * Returns the LDAP Provider |
|
1958 | + * |
|
1959 | + * @return \OCP\LDAP\ILDAPProvider |
|
1960 | + */ |
|
1961 | + public function getLDAPProvider() { |
|
1962 | + return $this->query('LDAPProvider'); |
|
1963 | + } |
|
1964 | + |
|
1965 | + /** |
|
1966 | + * @return \OCP\Settings\IManager |
|
1967 | + */ |
|
1968 | + public function getSettingsManager() { |
|
1969 | + return $this->query('SettingsManager'); |
|
1970 | + } |
|
1971 | + |
|
1972 | + /** |
|
1973 | + * @return \OCP\Files\IAppData |
|
1974 | + */ |
|
1975 | + public function getAppDataDir($app) { |
|
1976 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1977 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1978 | + return $factory->get($app); |
|
1979 | + } |
|
1980 | + |
|
1981 | + /** |
|
1982 | + * @return \OCP\Lockdown\ILockdownManager |
|
1983 | + */ |
|
1984 | + public function getLockdownManager() { |
|
1985 | + return $this->query('LockdownManager'); |
|
1986 | + } |
|
1987 | + |
|
1988 | + /** |
|
1989 | + * @return \OCP\Federation\ICloudIdManager |
|
1990 | + */ |
|
1991 | + public function getCloudIdManager() { |
|
1992 | + return $this->query(ICloudIdManager::class); |
|
1993 | + } |
|
1994 | + |
|
1995 | + /** |
|
1996 | + * @return \OCP\Remote\Api\IApiFactory |
|
1997 | + */ |
|
1998 | + public function getRemoteApiFactory() { |
|
1999 | + return $this->query(IApiFactory::class); |
|
2000 | + } |
|
2001 | + |
|
2002 | + /** |
|
2003 | + * @return \OCP\Remote\IInstanceFactory |
|
2004 | + */ |
|
2005 | + public function getRemoteInstanceFactory() { |
|
2006 | + return $this->query(IInstanceFactory::class); |
|
2007 | + } |
|
2008 | 2008 | } |
@@ -65,237 +65,237 @@ |
||
65 | 65 | |
66 | 66 | class Server { |
67 | 67 | |
68 | - /** @var IRequest */ |
|
69 | - private $request; |
|
68 | + /** @var IRequest */ |
|
69 | + private $request; |
|
70 | 70 | |
71 | - /** @var string */ |
|
72 | - private $baseUri; |
|
71 | + /** @var string */ |
|
72 | + private $baseUri; |
|
73 | 73 | |
74 | - /** @var Connector\Sabre\Server */ |
|
75 | - public $server; |
|
74 | + /** @var Connector\Sabre\Server */ |
|
75 | + public $server; |
|
76 | 76 | |
77 | - public function __construct(IRequest $request, $baseUri) { |
|
78 | - $this->request = $request; |
|
79 | - $this->baseUri = $baseUri; |
|
80 | - $logger = \OC::$server->getLogger(); |
|
81 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
77 | + public function __construct(IRequest $request, $baseUri) { |
|
78 | + $this->request = $request; |
|
79 | + $this->baseUri = $baseUri; |
|
80 | + $logger = \OC::$server->getLogger(); |
|
81 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
82 | 82 | |
83 | - $root = new RootCollection(); |
|
84 | - $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
83 | + $root = new RootCollection(); |
|
84 | + $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
85 | 85 | |
86 | - // Add maintenance plugin |
|
87 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
86 | + // Add maintenance plugin |
|
87 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
88 | 88 | |
89 | - // Backends |
|
90 | - $authBackend = new Auth( |
|
91 | - \OC::$server->getSession(), |
|
92 | - \OC::$server->getUserSession(), |
|
93 | - \OC::$server->getRequest(), |
|
94 | - \OC::$server->getTwoFactorAuthManager(), |
|
95 | - \OC::$server->getBruteForceThrottler() |
|
96 | - ); |
|
89 | + // Backends |
|
90 | + $authBackend = new Auth( |
|
91 | + \OC::$server->getSession(), |
|
92 | + \OC::$server->getUserSession(), |
|
93 | + \OC::$server->getRequest(), |
|
94 | + \OC::$server->getTwoFactorAuthManager(), |
|
95 | + \OC::$server->getBruteForceThrottler() |
|
96 | + ); |
|
97 | 97 | |
98 | - // Set URL explicitly due to reverse-proxy situations |
|
99 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
100 | - $this->server->setBaseUri($this->baseUri); |
|
98 | + // Set URL explicitly due to reverse-proxy situations |
|
99 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
100 | + $this->server->setBaseUri($this->baseUri); |
|
101 | 101 | |
102 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
103 | - $this->server->addPlugin(new AnonymousOptionsPlugin()); |
|
104 | - $authPlugin = new Plugin(); |
|
105 | - $authPlugin->addBackend(new PublicAuth()); |
|
106 | - $this->server->addPlugin($authPlugin); |
|
102 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
103 | + $this->server->addPlugin(new AnonymousOptionsPlugin()); |
|
104 | + $authPlugin = new Plugin(); |
|
105 | + $authPlugin->addBackend(new PublicAuth()); |
|
106 | + $this->server->addPlugin($authPlugin); |
|
107 | 107 | |
108 | - // allow setup of additional auth backends |
|
109 | - $event = new SabrePluginEvent($this->server); |
|
110 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
108 | + // allow setup of additional auth backends |
|
109 | + $event = new SabrePluginEvent($this->server); |
|
110 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
111 | 111 | |
112 | - $bearerAuthBackend = new BearerAuth( |
|
113 | - \OC::$server->getUserSession(), |
|
114 | - \OC::$server->getSession(), |
|
115 | - \OC::$server->getRequest() |
|
116 | - ); |
|
117 | - $authPlugin->addBackend($bearerAuthBackend); |
|
118 | - // because we are throwing exceptions this plugin has to be the last one |
|
119 | - $authPlugin->addBackend($authBackend); |
|
112 | + $bearerAuthBackend = new BearerAuth( |
|
113 | + \OC::$server->getUserSession(), |
|
114 | + \OC::$server->getSession(), |
|
115 | + \OC::$server->getRequest() |
|
116 | + ); |
|
117 | + $authPlugin->addBackend($bearerAuthBackend); |
|
118 | + // because we are throwing exceptions this plugin has to be the last one |
|
119 | + $authPlugin->addBackend($authBackend); |
|
120 | 120 | |
121 | - // debugging |
|
122 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
123 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
124 | - } else { |
|
125 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
126 | - } |
|
121 | + // debugging |
|
122 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
123 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
124 | + } else { |
|
125 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
126 | + } |
|
127 | 127 | |
128 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
129 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
130 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
128 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
129 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
130 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
131 | 131 | |
132 | - // acl |
|
133 | - $acl = new DavAclPlugin(); |
|
134 | - $acl->principalCollectionSet = [ |
|
135 | - 'principals/users', 'principals/groups', |
|
136 | - 'principals/calendar-resources', |
|
137 | - 'principals/calendar-rooms', |
|
138 | - ]; |
|
139 | - $acl->defaultUsernamePath = 'principals/users'; |
|
140 | - $this->server->addPlugin($acl); |
|
132 | + // acl |
|
133 | + $acl = new DavAclPlugin(); |
|
134 | + $acl->principalCollectionSet = [ |
|
135 | + 'principals/users', 'principals/groups', |
|
136 | + 'principals/calendar-resources', |
|
137 | + 'principals/calendar-rooms', |
|
138 | + ]; |
|
139 | + $acl->defaultUsernamePath = 'principals/users'; |
|
140 | + $this->server->addPlugin($acl); |
|
141 | 141 | |
142 | - // calendar plugins |
|
143 | - if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) { |
|
144 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
145 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
146 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
147 | - if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') { |
|
148 | - $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
149 | - } |
|
150 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
151 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
152 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
153 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
154 | - \OC::$server->getConfig(), |
|
155 | - \OC::$server->getURLGenerator() |
|
156 | - )); |
|
157 | - } |
|
142 | + // calendar plugins |
|
143 | + if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) { |
|
144 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
145 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
146 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
147 | + if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') { |
|
148 | + $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
149 | + } |
|
150 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
151 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
152 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
153 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
154 | + \OC::$server->getConfig(), |
|
155 | + \OC::$server->getURLGenerator() |
|
156 | + )); |
|
157 | + } |
|
158 | 158 | |
159 | - // addressbook plugins |
|
160 | - if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { |
|
161 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
162 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
163 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
164 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
165 | - } |
|
159 | + // addressbook plugins |
|
160 | + if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { |
|
161 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
162 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
163 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
164 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
165 | + } |
|
166 | 166 | |
167 | - // system tags plugins |
|
168 | - $this->server->addPlugin(new SystemTagPlugin( |
|
169 | - \OC::$server->getSystemTagManager(), |
|
170 | - \OC::$server->getGroupManager(), |
|
171 | - \OC::$server->getUserSession() |
|
172 | - )); |
|
167 | + // system tags plugins |
|
168 | + $this->server->addPlugin(new SystemTagPlugin( |
|
169 | + \OC::$server->getSystemTagManager(), |
|
170 | + \OC::$server->getGroupManager(), |
|
171 | + \OC::$server->getUserSession() |
|
172 | + )); |
|
173 | 173 | |
174 | - // comments plugin |
|
175 | - $this->server->addPlugin(new CommentsPlugin( |
|
176 | - \OC::$server->getCommentsManager(), |
|
177 | - \OC::$server->getUserSession() |
|
178 | - )); |
|
174 | + // comments plugin |
|
175 | + $this->server->addPlugin(new CommentsPlugin( |
|
176 | + \OC::$server->getCommentsManager(), |
|
177 | + \OC::$server->getUserSession() |
|
178 | + )); |
|
179 | 179 | |
180 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
181 | - $this->server->addPlugin(new ChunkingPlugin()); |
|
180 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
181 | + $this->server->addPlugin(new ChunkingPlugin()); |
|
182 | 182 | |
183 | - // allow setup of additional plugins |
|
184 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
183 | + // allow setup of additional plugins |
|
184 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
185 | 185 | |
186 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
187 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
188 | - if($request->isUserAgent([ |
|
189 | - '/WebDAVFS/', |
|
190 | - '/OneNote/', |
|
191 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
192 | - ])) { |
|
193 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
194 | - } |
|
186 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
187 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
188 | + if($request->isUserAgent([ |
|
189 | + '/WebDAVFS/', |
|
190 | + '/OneNote/', |
|
191 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
192 | + ])) { |
|
193 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
194 | + } |
|
195 | 195 | |
196 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
197 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
198 | - } |
|
196 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
197 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
198 | + } |
|
199 | 199 | |
200 | - // wait with registering these until auth is handled and the filesystem is setup |
|
201 | - $this->server->on('beforeMethod', function () use ($root) { |
|
202 | - // custom properties plugin must be the last one |
|
203 | - $userSession = \OC::$server->getUserSession(); |
|
204 | - $user = $userSession->getUser(); |
|
205 | - if ($user !== null) { |
|
206 | - $view = \OC\Files\Filesystem::getView(); |
|
207 | - $this->server->addPlugin( |
|
208 | - new FilesPlugin( |
|
209 | - $this->server->tree, |
|
210 | - \OC::$server->getConfig(), |
|
211 | - $this->request, |
|
212 | - \OC::$server->getPreviewManager(), |
|
213 | - false, |
|
214 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
215 | - ) |
|
216 | - ); |
|
200 | + // wait with registering these until auth is handled and the filesystem is setup |
|
201 | + $this->server->on('beforeMethod', function () use ($root) { |
|
202 | + // custom properties plugin must be the last one |
|
203 | + $userSession = \OC::$server->getUserSession(); |
|
204 | + $user = $userSession->getUser(); |
|
205 | + if ($user !== null) { |
|
206 | + $view = \OC\Files\Filesystem::getView(); |
|
207 | + $this->server->addPlugin( |
|
208 | + new FilesPlugin( |
|
209 | + $this->server->tree, |
|
210 | + \OC::$server->getConfig(), |
|
211 | + $this->request, |
|
212 | + \OC::$server->getPreviewManager(), |
|
213 | + false, |
|
214 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
215 | + ) |
|
216 | + ); |
|
217 | 217 | |
218 | - $this->server->addPlugin( |
|
219 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
220 | - new CustomPropertiesBackend( |
|
221 | - $this->server->tree, |
|
222 | - \OC::$server->getDatabaseConnection(), |
|
223 | - \OC::$server->getUserSession()->getUser() |
|
224 | - ) |
|
225 | - ) |
|
226 | - ); |
|
227 | - if ($view !== null) { |
|
228 | - $this->server->addPlugin( |
|
229 | - new QuotaPlugin($view, false)); |
|
230 | - } |
|
231 | - $this->server->addPlugin( |
|
232 | - new TagsPlugin( |
|
233 | - $this->server->tree, \OC::$server->getTagManager() |
|
234 | - ) |
|
235 | - ); |
|
236 | - // TODO: switch to LazyUserFolder |
|
237 | - $userFolder = \OC::$server->getUserFolder(); |
|
238 | - $this->server->addPlugin(new SharesPlugin( |
|
239 | - $this->server->tree, |
|
240 | - $userSession, |
|
241 | - $userFolder, |
|
242 | - \OC::$server->getShareManager() |
|
243 | - )); |
|
244 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
245 | - \OC::$server->getCommentsManager(), |
|
246 | - $userSession |
|
247 | - )); |
|
248 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
249 | - if ($view !== null) { |
|
250 | - $this->server->addPlugin(new FilesReportPlugin( |
|
251 | - $this->server->tree, |
|
252 | - $view, |
|
253 | - \OC::$server->getSystemTagManager(), |
|
254 | - \OC::$server->getSystemTagObjectMapper(), |
|
255 | - \OC::$server->getTagManager(), |
|
256 | - $userSession, |
|
257 | - \OC::$server->getGroupManager(), |
|
258 | - $userFolder |
|
259 | - )); |
|
260 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
261 | - $this->server->tree, |
|
262 | - $user, |
|
263 | - \OC::$server->getRootFolder(), |
|
264 | - \OC::$server->getShareManager(), |
|
265 | - $view |
|
266 | - ))); |
|
267 | - } |
|
268 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin( |
|
269 | - \OC::$server->getConfig(), |
|
270 | - \OC::$server->query(BirthdayService::class) |
|
271 | - )); |
|
272 | - } |
|
218 | + $this->server->addPlugin( |
|
219 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
220 | + new CustomPropertiesBackend( |
|
221 | + $this->server->tree, |
|
222 | + \OC::$server->getDatabaseConnection(), |
|
223 | + \OC::$server->getUserSession()->getUser() |
|
224 | + ) |
|
225 | + ) |
|
226 | + ); |
|
227 | + if ($view !== null) { |
|
228 | + $this->server->addPlugin( |
|
229 | + new QuotaPlugin($view, false)); |
|
230 | + } |
|
231 | + $this->server->addPlugin( |
|
232 | + new TagsPlugin( |
|
233 | + $this->server->tree, \OC::$server->getTagManager() |
|
234 | + ) |
|
235 | + ); |
|
236 | + // TODO: switch to LazyUserFolder |
|
237 | + $userFolder = \OC::$server->getUserFolder(); |
|
238 | + $this->server->addPlugin(new SharesPlugin( |
|
239 | + $this->server->tree, |
|
240 | + $userSession, |
|
241 | + $userFolder, |
|
242 | + \OC::$server->getShareManager() |
|
243 | + )); |
|
244 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
245 | + \OC::$server->getCommentsManager(), |
|
246 | + $userSession |
|
247 | + )); |
|
248 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
249 | + if ($view !== null) { |
|
250 | + $this->server->addPlugin(new FilesReportPlugin( |
|
251 | + $this->server->tree, |
|
252 | + $view, |
|
253 | + \OC::$server->getSystemTagManager(), |
|
254 | + \OC::$server->getSystemTagObjectMapper(), |
|
255 | + \OC::$server->getTagManager(), |
|
256 | + $userSession, |
|
257 | + \OC::$server->getGroupManager(), |
|
258 | + $userFolder |
|
259 | + )); |
|
260 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
261 | + $this->server->tree, |
|
262 | + $user, |
|
263 | + \OC::$server->getRootFolder(), |
|
264 | + \OC::$server->getShareManager(), |
|
265 | + $view |
|
266 | + ))); |
|
267 | + } |
|
268 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin( |
|
269 | + \OC::$server->getConfig(), |
|
270 | + \OC::$server->query(BirthdayService::class) |
|
271 | + )); |
|
272 | + } |
|
273 | 273 | |
274 | - // register plugins from apps |
|
275 | - $pluginManager = new PluginManager( |
|
276 | - \OC::$server, |
|
277 | - \OC::$server->getAppManager() |
|
278 | - ); |
|
279 | - foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
280 | - $this->server->addPlugin($appPlugin); |
|
281 | - } |
|
282 | - foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
283 | - $root->addChild($appCollection); |
|
284 | - } |
|
285 | - }); |
|
286 | - } |
|
274 | + // register plugins from apps |
|
275 | + $pluginManager = new PluginManager( |
|
276 | + \OC::$server, |
|
277 | + \OC::$server->getAppManager() |
|
278 | + ); |
|
279 | + foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
280 | + $this->server->addPlugin($appPlugin); |
|
281 | + } |
|
282 | + foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
283 | + $root->addChild($appCollection); |
|
284 | + } |
|
285 | + }); |
|
286 | + } |
|
287 | 287 | |
288 | - public function exec() { |
|
289 | - $this->server->exec(); |
|
290 | - } |
|
288 | + public function exec() { |
|
289 | + $this->server->exec(); |
|
290 | + } |
|
291 | 291 | |
292 | - private function requestIsForSubtree(array $subTrees): bool { |
|
293 | - foreach ($subTrees as $subTree) { |
|
294 | - $subTree = trim($subTree, ' /'); |
|
295 | - if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { |
|
296 | - return true; |
|
297 | - } |
|
298 | - } |
|
299 | - return false; |
|
300 | - } |
|
292 | + private function requestIsForSubtree(array $subTrees): bool { |
|
293 | + foreach ($subTrees as $subTree) { |
|
294 | + $subTree = trim($subTree, ' /'); |
|
295 | + if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { |
|
296 | + return true; |
|
297 | + } |
|
298 | + } |
|
299 | + return false; |
|
300 | + } |
|
301 | 301 | } |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | $cachedResourceIds = $this->getCachedResourceIds($cachedResources); |
101 | 101 | |
102 | 102 | $remoteResourceIds = []; |
103 | - foreach($resourceBackends as $resourceBackend) { |
|
103 | + foreach ($resourceBackends as $resourceBackend) { |
|
104 | 104 | try { |
105 | 105 | $remoteResourceIds[$resourceBackend->getBackendIdentifier()] = |
106 | 106 | $resourceBackend->listAllResources(); |
107 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
107 | + } catch (BackendTemporarilyUnavailableException $ex) { |
|
108 | 108 | // If the backend is temporarily unavailable |
109 | 109 | // ignore this backend in this execution |
110 | 110 | unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]); |
@@ -113,20 +113,20 @@ discard block |
||
113 | 113 | |
114 | 114 | $sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds); |
115 | 115 | |
116 | - foreach($sortedResources['new'] as $backendId => $newResources) { |
|
116 | + foreach ($sortedResources['new'] as $backendId => $newResources) { |
|
117 | 117 | foreach ($newResources as $newResource) { |
118 | 118 | $resource = $this->resourceManager->getBackend($backendId) |
119 | 119 | ->getResource($newResource); |
120 | 120 | $this->addToCache($this->resourceDbTable, $resource); |
121 | 121 | } |
122 | 122 | } |
123 | - foreach($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
123 | + foreach ($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
124 | 124 | foreach ($deletedResources as $deletedResource) { |
125 | 125 | $this->deleteFromCache($this->resourceDbTable, |
126 | 126 | $this->resourcePrincipalUri, $backendId, $deletedResource); |
127 | 127 | } |
128 | 128 | } |
129 | - foreach($sortedResources['edited'] as $backendId => $editedResources) { |
|
129 | + foreach ($sortedResources['edited'] as $backendId => $editedResources) { |
|
130 | 130 | foreach ($editedResources as $editedResource) { |
131 | 131 | $resource = $this->resourceManager->getBackend($backendId) |
132 | 132 | ->getResource($editedResource); |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | $cachedRoomIds = $this->getCachedRoomIds($cachedRooms); |
145 | 145 | |
146 | 146 | $remoteRoomIds = []; |
147 | - foreach($roomBackends as $roomBackend) { |
|
147 | + foreach ($roomBackends as $roomBackend) { |
|
148 | 148 | try { |
149 | 149 | $remoteRoomIds[$roomBackend->getBackendIdentifier()] = |
150 | 150 | $roomBackend->listAllRooms(); |
151 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
151 | + } catch (BackendTemporarilyUnavailableException $ex) { |
|
152 | 152 | // If the backend is temporarily unavailable |
153 | 153 | // ignore this backend in this execution |
154 | 154 | unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]); |
@@ -157,20 +157,20 @@ discard block |
||
157 | 157 | |
158 | 158 | $sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds); |
159 | 159 | |
160 | - foreach($sortedRooms['new'] as $backendId => $newRooms) { |
|
160 | + foreach ($sortedRooms['new'] as $backendId => $newRooms) { |
|
161 | 161 | foreach ($newRooms as $newRoom) { |
162 | 162 | $resource = $this->roomManager->getBackend($backendId) |
163 | 163 | ->getRoom($newRoom); |
164 | 164 | $this->addToCache($this->roomDbTable, $resource); |
165 | 165 | } |
166 | 166 | } |
167 | - foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
167 | + foreach ($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
168 | 168 | foreach ($deletedRooms as $deletedRoom) { |
169 | 169 | $this->deleteFromCache($this->roomDbTable, |
170 | 170 | $this->roomPrincipalUri, $backendId, $deletedRoom); |
171 | 171 | } |
172 | 172 | } |
173 | - foreach($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
173 | + foreach ($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
174 | 174 | foreach ($editedRooms as $editedRoom) { |
175 | 175 | $resource = $this->roomManager->getBackend($backendId) |
176 | 176 | ->getRoom($editedRoom); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $rows = []; |
192 | 192 | $stmt = $query->execute(); |
193 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
193 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
194 | 194 | $rows[] = $row; |
195 | 195 | } |
196 | 196 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | ]; |
272 | 272 | |
273 | 273 | $backendIds = array_merge(array_keys($cached), array_keys($remote)); |
274 | - foreach($backendIds as $backendId) { |
|
274 | + foreach ($backendIds as $backendId) { |
|
275 | 275 | if (!isset($cached[$backendId])) { |
276 | 276 | $sorted['new'][$backendId] = $remote[$backendId]; |
277 | 277 | } elseif (!isset($remote[$backendId])) { |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | try { |
327 | 327 | $calendar = $this->calDavBackend->getCalendarByUri($principalUri, implode('-', [$backendId, $resourceId])); |
328 | 328 | $this->calDavBackend->deleteCalendar($calendar['id']); |
329 | - } catch() { |
|
329 | + } catch () { |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | // todo - delete corresponding calendar incl. calendar objects |
@@ -34,305 +34,305 @@ |
||
34 | 34 | |
35 | 35 | class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob { |
36 | 36 | |
37 | - /** @var IResourceManager */ |
|
38 | - private $resourceManager; |
|
39 | - |
|
40 | - /** @var IRoomManager */ |
|
41 | - private $roomManager; |
|
42 | - |
|
43 | - /** @var IDBConnection */ |
|
44 | - private $db; |
|
45 | - |
|
46 | - /** @var CalDavBackend */ |
|
47 | - private $calDavBackend; |
|
48 | - |
|
49 | - /** @var string */ |
|
50 | - private $resourceDbTable; |
|
51 | - |
|
52 | - /** @var string */ |
|
53 | - private $resourcePrincipalUri; |
|
54 | - |
|
55 | - /** @var string */ |
|
56 | - private $roomDbTable; |
|
57 | - |
|
58 | - /** @var string */ |
|
59 | - private $roomPrincipalUri; |
|
60 | - |
|
61 | - /** |
|
62 | - * UpdateCalendarResourcesRoomsBackgroundJob constructor. |
|
63 | - * |
|
64 | - * @param IResourceManager $resourceManager |
|
65 | - * @param IRoomManager $roomManager |
|
66 | - * @param IDBConnection $dbConnection |
|
67 | - * @param CalDavBackend $calDavBackend |
|
68 | - */ |
|
69 | - public function __construct(IResourceManager $resourceManager, IRoomManager $roomManager, |
|
70 | - IDBConnection $dbConnection, CalDavBackend $calDavBackend) { |
|
71 | - $this->resourceManager = $resourceManager; |
|
72 | - $this->roomManager = $roomManager; |
|
73 | - $this->db = $dbConnection; |
|
74 | - $this->calDavBackend = $calDavBackend; |
|
75 | - $this->resourceDbTable = 'calendar_resources_cache'; |
|
76 | - $this->resourcePrincipalUri = 'principals/calendar-resources'; |
|
77 | - $this->roomDbTable = 'calendar_rooms_cache'; |
|
78 | - $this->roomPrincipalUri = 'principals/calendar-rooms'; |
|
79 | - |
|
80 | - // run once an hour |
|
81 | - $this->setInterval(60 * 60); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param $argument |
|
86 | - */ |
|
87 | - public function run($argument) { |
|
88 | - $this->runResources(); |
|
89 | - $this->runRooms(); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * run timed job for resources |
|
94 | - */ |
|
95 | - private function runResources() { |
|
96 | - $resourceBackends = $this->resourceManager->getBackends(); |
|
97 | - $cachedResources = $this->getCached($this->resourceDbTable); |
|
98 | - $cachedResourceIds = $this->getCachedResourceIds($cachedResources); |
|
99 | - |
|
100 | - $remoteResourceIds = []; |
|
101 | - foreach($resourceBackends as $resourceBackend) { |
|
102 | - try { |
|
103 | - $remoteResourceIds[$resourceBackend->getBackendIdentifier()] = |
|
104 | - $resourceBackend->listAllResources(); |
|
105 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
106 | - // If the backend is temporarily unavailable |
|
107 | - // ignore this backend in this execution |
|
108 | - unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - $sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds); |
|
113 | - |
|
114 | - foreach($sortedResources['new'] as $backendId => $newResources) { |
|
115 | - foreach ($newResources as $newResource) { |
|
116 | - $resource = $this->resourceManager->getBackend($backendId) |
|
117 | - ->getResource($newResource); |
|
118 | - $this->addToCache($this->resourceDbTable, $resource); |
|
119 | - } |
|
120 | - } |
|
121 | - foreach($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
122 | - foreach ($deletedResources as $deletedResource) { |
|
123 | - $this->deleteFromCache($this->resourceDbTable, |
|
124 | - $this->resourcePrincipalUri, $backendId, $deletedResource); |
|
125 | - } |
|
126 | - } |
|
127 | - foreach($sortedResources['edited'] as $backendId => $editedResources) { |
|
128 | - foreach ($editedResources as $editedResource) { |
|
129 | - $resource = $this->resourceManager->getBackend($backendId) |
|
130 | - ->getResource($editedResource); |
|
131 | - $this->updateCache($this->resourceDbTable, $resource); |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * run timed job for rooms |
|
138 | - */ |
|
139 | - private function runRooms() { |
|
140 | - $roomBackends = $this->roomManager->getBackends(); |
|
141 | - $cachedRooms = $this->getCached($this->roomDbTable); |
|
142 | - $cachedRoomIds = $this->getCachedRoomIds($cachedRooms); |
|
143 | - |
|
144 | - $remoteRoomIds = []; |
|
145 | - foreach($roomBackends as $roomBackend) { |
|
146 | - try { |
|
147 | - $remoteRoomIds[$roomBackend->getBackendIdentifier()] = |
|
148 | - $roomBackend->listAllRooms(); |
|
149 | - } catch(BackendTemporarilyUnavailableException $ex) { |
|
150 | - // If the backend is temporarily unavailable |
|
151 | - // ignore this backend in this execution |
|
152 | - unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - $sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds); |
|
157 | - |
|
158 | - foreach($sortedRooms['new'] as $backendId => $newRooms) { |
|
159 | - foreach ($newRooms as $newRoom) { |
|
160 | - $resource = $this->roomManager->getBackend($backendId) |
|
161 | - ->getRoom($newRoom); |
|
162 | - $this->addToCache($this->roomDbTable, $resource); |
|
163 | - } |
|
164 | - } |
|
165 | - foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
166 | - foreach ($deletedRooms as $deletedRoom) { |
|
167 | - $this->deleteFromCache($this->roomDbTable, |
|
168 | - $this->roomPrincipalUri, $backendId, $deletedRoom); |
|
169 | - } |
|
170 | - } |
|
171 | - foreach($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
172 | - foreach ($editedRooms as $editedRoom) { |
|
173 | - $resource = $this->roomManager->getBackend($backendId) |
|
174 | - ->getRoom($editedRoom); |
|
175 | - $this->updateCache($this->roomDbTable, $resource); |
|
176 | - } |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * get cached db rows for resources / rooms |
|
182 | - * @param string $tableName |
|
183 | - * @return array |
|
184 | - */ |
|
185 | - private function getCached($tableName):array { |
|
186 | - $query = $this->db->getQueryBuilder(); |
|
187 | - $query->select('*')->from($tableName); |
|
188 | - |
|
189 | - $rows = []; |
|
190 | - $stmt = $query->execute(); |
|
191 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
192 | - $rows[] = $row; |
|
193 | - } |
|
194 | - |
|
195 | - return $rows; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * @param array $cachedResources |
|
200 | - * @return array |
|
201 | - */ |
|
202 | - private function getCachedResourceIds(array $cachedResources):array { |
|
203 | - $cachedResourceIds = []; |
|
204 | - foreach ($cachedResources as $cachedResource) { |
|
205 | - if (!isset($cachedResourceIds[$cachedResource['backend_id']])) { |
|
206 | - $cachedResourceIds[$cachedResource['backend_id']] = []; |
|
207 | - } |
|
208 | - |
|
209 | - $cachedResourceIds[$cachedResource['backend_id']][] = |
|
210 | - $cachedResource['resource_id']; |
|
211 | - } |
|
212 | - |
|
213 | - return $cachedResourceIds; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * @param array $cachedRooms |
|
218 | - * @return array |
|
219 | - */ |
|
220 | - private function getCachedRoomIds(array $cachedRooms):array { |
|
221 | - $cachedRoomIds = []; |
|
222 | - foreach ($cachedRooms as $cachedRoom) { |
|
223 | - if (!isset($cachedRoomIds[$cachedRoom['backend_id']])) { |
|
224 | - $cachedRoomIds[$cachedRoom['backend_id']] = []; |
|
225 | - } |
|
226 | - |
|
227 | - $cachedRoomIds[$cachedRoom['backend_id']][] = |
|
228 | - $cachedRoom['resource_id']; |
|
229 | - } |
|
230 | - |
|
231 | - return $cachedRoomIds; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * sort list of ids by whether they appear only in the backend / |
|
236 | - * only in the cache / in both |
|
237 | - * |
|
238 | - * @param array $cached |
|
239 | - * @param array $remote |
|
240 | - * @return array |
|
241 | - */ |
|
242 | - private function sortByNewDeletedExisting(array $cached, array $remote):array { |
|
243 | - $sorted = [ |
|
244 | - 'new' => [], |
|
245 | - 'deleted' => [], |
|
246 | - 'existing' => [], |
|
247 | - ]; |
|
248 | - |
|
249 | - $backendIds = array_merge(array_keys($cached), array_keys($remote)); |
|
250 | - foreach($backendIds as $backendId) { |
|
251 | - if (!isset($cached[$backendId])) { |
|
252 | - $sorted['new'][$backendId] = $remote[$backendId]; |
|
253 | - } elseif (!isset($remote[$backendId])) { |
|
254 | - $sorted['deleted'][$backendId] = $remote[$backendId]; |
|
255 | - } else { |
|
256 | - $sorted['new'][$backendId] = array_diff($remote[$backendId], $cached[$backendId]); |
|
257 | - $sorted['deleted'][$backendId] = array_diff($cached[$backendId], $remote[$backendId]); |
|
258 | - $sorted['existing'][$backendId] = array_intersect($remote[$backendId], $cached[$backendId]); |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - return $sorted; |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * add entry to cache that exists remotely but not yet in cache |
|
267 | - * |
|
268 | - * @param string $table |
|
269 | - * @param IResource|IRoom $remote |
|
270 | - */ |
|
271 | - private function addToCache($table, $remote) { |
|
272 | - $query = $this->db->getQueryBuilder(); |
|
273 | - $query->insert($table) |
|
274 | - ->values([ |
|
275 | - 'backend_id' => $query->createNamedParameter($remote->getBackend()), |
|
276 | - 'resource_id' => $query->createNamedParameter($remote->getId()), |
|
277 | - 'email' => $query->createNamedParameter($remote->getEMail()), |
|
278 | - 'displayname' => $query->createNamedParameter($remote->getDisplayName()), |
|
279 | - 'group_restrictions' => $query->createNamedParameter( |
|
280 | - $this->serializeGroupRestrictions( |
|
281 | - $remote->getGroupRestrictions() |
|
282 | - )) |
|
283 | - ]) |
|
284 | - ->execute(); |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * delete entry from cache that does not exist anymore remotely |
|
289 | - * |
|
290 | - * @param string $table |
|
291 | - * @param string $principalUri |
|
292 | - * @param string $backendId |
|
293 | - * @param string $resourceId |
|
294 | - */ |
|
295 | - private function deleteFromCache($table, $principalUri, $backendId, $resourceId) { |
|
296 | - $query = $this->db->getQueryBuilder(); |
|
297 | - $query->delete($table) |
|
298 | - ->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId))) |
|
299 | - ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId))) |
|
300 | - ->execute(); |
|
301 | - |
|
302 | - try { |
|
303 | - $calendar = $this->calDavBackend->getCalendarByUri($principalUri, implode('-', [$backendId, $resourceId])); |
|
304 | - $this->calDavBackend->deleteCalendar($calendar['id']); |
|
305 | - } catch() { |
|
306 | - |
|
307 | - } |
|
308 | - // todo - delete corresponding calendar incl. calendar objects |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * update an existing entry in cache |
|
313 | - * |
|
314 | - * @param string $table |
|
315 | - * @param IResource|IRoom $remote |
|
316 | - */ |
|
317 | - private function updateCache($table, $remote) { |
|
318 | - $query = $this->db->getQueryBuilder(); |
|
319 | - $query->update($table) |
|
320 | - ->set('email', $query->createNamedParameter($remote->getEMail())) |
|
321 | - ->set('displayname', $query->createNamedParameter($remote->getDisplayName())) |
|
322 | - ->set('group_restrictions', $query->createNamedParameter( |
|
323 | - $this->serializeGroupRestrictions( |
|
324 | - $remote->getGroupRestrictions() |
|
325 | - ))) |
|
326 | - ->execute(); |
|
327 | - } |
|
328 | - |
|
329 | - /** |
|
330 | - * serialize array of group restrictions to store them in database |
|
331 | - * |
|
332 | - * @param array $groups |
|
333 | - * @return string |
|
334 | - */ |
|
335 | - private function serializeGroupRestrictions(array $groups):string { |
|
336 | - return \json_encode($groups); |
|
337 | - } |
|
37 | + /** @var IResourceManager */ |
|
38 | + private $resourceManager; |
|
39 | + |
|
40 | + /** @var IRoomManager */ |
|
41 | + private $roomManager; |
|
42 | + |
|
43 | + /** @var IDBConnection */ |
|
44 | + private $db; |
|
45 | + |
|
46 | + /** @var CalDavBackend */ |
|
47 | + private $calDavBackend; |
|
48 | + |
|
49 | + /** @var string */ |
|
50 | + private $resourceDbTable; |
|
51 | + |
|
52 | + /** @var string */ |
|
53 | + private $resourcePrincipalUri; |
|
54 | + |
|
55 | + /** @var string */ |
|
56 | + private $roomDbTable; |
|
57 | + |
|
58 | + /** @var string */ |
|
59 | + private $roomPrincipalUri; |
|
60 | + |
|
61 | + /** |
|
62 | + * UpdateCalendarResourcesRoomsBackgroundJob constructor. |
|
63 | + * |
|
64 | + * @param IResourceManager $resourceManager |
|
65 | + * @param IRoomManager $roomManager |
|
66 | + * @param IDBConnection $dbConnection |
|
67 | + * @param CalDavBackend $calDavBackend |
|
68 | + */ |
|
69 | + public function __construct(IResourceManager $resourceManager, IRoomManager $roomManager, |
|
70 | + IDBConnection $dbConnection, CalDavBackend $calDavBackend) { |
|
71 | + $this->resourceManager = $resourceManager; |
|
72 | + $this->roomManager = $roomManager; |
|
73 | + $this->db = $dbConnection; |
|
74 | + $this->calDavBackend = $calDavBackend; |
|
75 | + $this->resourceDbTable = 'calendar_resources_cache'; |
|
76 | + $this->resourcePrincipalUri = 'principals/calendar-resources'; |
|
77 | + $this->roomDbTable = 'calendar_rooms_cache'; |
|
78 | + $this->roomPrincipalUri = 'principals/calendar-rooms'; |
|
79 | + |
|
80 | + // run once an hour |
|
81 | + $this->setInterval(60 * 60); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @param $argument |
|
86 | + */ |
|
87 | + public function run($argument) { |
|
88 | + $this->runResources(); |
|
89 | + $this->runRooms(); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * run timed job for resources |
|
94 | + */ |
|
95 | + private function runResources() { |
|
96 | + $resourceBackends = $this->resourceManager->getBackends(); |
|
97 | + $cachedResources = $this->getCached($this->resourceDbTable); |
|
98 | + $cachedResourceIds = $this->getCachedResourceIds($cachedResources); |
|
99 | + |
|
100 | + $remoteResourceIds = []; |
|
101 | + foreach($resourceBackends as $resourceBackend) { |
|
102 | + try { |
|
103 | + $remoteResourceIds[$resourceBackend->getBackendIdentifier()] = |
|
104 | + $resourceBackend->listAllResources(); |
|
105 | + } catch(BackendTemporarilyUnavailableException $ex) { |
|
106 | + // If the backend is temporarily unavailable |
|
107 | + // ignore this backend in this execution |
|
108 | + unset($cachedResourceIds[$resourceBackend->getBackendIdentifier()]); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + $sortedResources = $this->sortByNewDeletedExisting($cachedResourceIds, $remoteResourceIds); |
|
113 | + |
|
114 | + foreach($sortedResources['new'] as $backendId => $newResources) { |
|
115 | + foreach ($newResources as $newResource) { |
|
116 | + $resource = $this->resourceManager->getBackend($backendId) |
|
117 | + ->getResource($newResource); |
|
118 | + $this->addToCache($this->resourceDbTable, $resource); |
|
119 | + } |
|
120 | + } |
|
121 | + foreach($sortedResources['deleted'] as $backendId => $deletedResources) { |
|
122 | + foreach ($deletedResources as $deletedResource) { |
|
123 | + $this->deleteFromCache($this->resourceDbTable, |
|
124 | + $this->resourcePrincipalUri, $backendId, $deletedResource); |
|
125 | + } |
|
126 | + } |
|
127 | + foreach($sortedResources['edited'] as $backendId => $editedResources) { |
|
128 | + foreach ($editedResources as $editedResource) { |
|
129 | + $resource = $this->resourceManager->getBackend($backendId) |
|
130 | + ->getResource($editedResource); |
|
131 | + $this->updateCache($this->resourceDbTable, $resource); |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * run timed job for rooms |
|
138 | + */ |
|
139 | + private function runRooms() { |
|
140 | + $roomBackends = $this->roomManager->getBackends(); |
|
141 | + $cachedRooms = $this->getCached($this->roomDbTable); |
|
142 | + $cachedRoomIds = $this->getCachedRoomIds($cachedRooms); |
|
143 | + |
|
144 | + $remoteRoomIds = []; |
|
145 | + foreach($roomBackends as $roomBackend) { |
|
146 | + try { |
|
147 | + $remoteRoomIds[$roomBackend->getBackendIdentifier()] = |
|
148 | + $roomBackend->listAllRooms(); |
|
149 | + } catch(BackendTemporarilyUnavailableException $ex) { |
|
150 | + // If the backend is temporarily unavailable |
|
151 | + // ignore this backend in this execution |
|
152 | + unset($cachedRoomIds[$roomBackend->getBackendIdentifier()]); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + $sortedRooms = $this->sortByNewDeletedExisting($cachedRoomIds, $remoteRoomIds); |
|
157 | + |
|
158 | + foreach($sortedRooms['new'] as $backendId => $newRooms) { |
|
159 | + foreach ($newRooms as $newRoom) { |
|
160 | + $resource = $this->roomManager->getBackend($backendId) |
|
161 | + ->getRoom($newRoom); |
|
162 | + $this->addToCache($this->roomDbTable, $resource); |
|
163 | + } |
|
164 | + } |
|
165 | + foreach($sortedRooms['deleted'] as $backendId => $deletedRooms) { |
|
166 | + foreach ($deletedRooms as $deletedRoom) { |
|
167 | + $this->deleteFromCache($this->roomDbTable, |
|
168 | + $this->roomPrincipalUri, $backendId, $deletedRoom); |
|
169 | + } |
|
170 | + } |
|
171 | + foreach($sortedRooms['edited'] as $backendId => $editedRooms) { |
|
172 | + foreach ($editedRooms as $editedRoom) { |
|
173 | + $resource = $this->roomManager->getBackend($backendId) |
|
174 | + ->getRoom($editedRoom); |
|
175 | + $this->updateCache($this->roomDbTable, $resource); |
|
176 | + } |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * get cached db rows for resources / rooms |
|
182 | + * @param string $tableName |
|
183 | + * @return array |
|
184 | + */ |
|
185 | + private function getCached($tableName):array { |
|
186 | + $query = $this->db->getQueryBuilder(); |
|
187 | + $query->select('*')->from($tableName); |
|
188 | + |
|
189 | + $rows = []; |
|
190 | + $stmt = $query->execute(); |
|
191 | + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
192 | + $rows[] = $row; |
|
193 | + } |
|
194 | + |
|
195 | + return $rows; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * @param array $cachedResources |
|
200 | + * @return array |
|
201 | + */ |
|
202 | + private function getCachedResourceIds(array $cachedResources):array { |
|
203 | + $cachedResourceIds = []; |
|
204 | + foreach ($cachedResources as $cachedResource) { |
|
205 | + if (!isset($cachedResourceIds[$cachedResource['backend_id']])) { |
|
206 | + $cachedResourceIds[$cachedResource['backend_id']] = []; |
|
207 | + } |
|
208 | + |
|
209 | + $cachedResourceIds[$cachedResource['backend_id']][] = |
|
210 | + $cachedResource['resource_id']; |
|
211 | + } |
|
212 | + |
|
213 | + return $cachedResourceIds; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * @param array $cachedRooms |
|
218 | + * @return array |
|
219 | + */ |
|
220 | + private function getCachedRoomIds(array $cachedRooms):array { |
|
221 | + $cachedRoomIds = []; |
|
222 | + foreach ($cachedRooms as $cachedRoom) { |
|
223 | + if (!isset($cachedRoomIds[$cachedRoom['backend_id']])) { |
|
224 | + $cachedRoomIds[$cachedRoom['backend_id']] = []; |
|
225 | + } |
|
226 | + |
|
227 | + $cachedRoomIds[$cachedRoom['backend_id']][] = |
|
228 | + $cachedRoom['resource_id']; |
|
229 | + } |
|
230 | + |
|
231 | + return $cachedRoomIds; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * sort list of ids by whether they appear only in the backend / |
|
236 | + * only in the cache / in both |
|
237 | + * |
|
238 | + * @param array $cached |
|
239 | + * @param array $remote |
|
240 | + * @return array |
|
241 | + */ |
|
242 | + private function sortByNewDeletedExisting(array $cached, array $remote):array { |
|
243 | + $sorted = [ |
|
244 | + 'new' => [], |
|
245 | + 'deleted' => [], |
|
246 | + 'existing' => [], |
|
247 | + ]; |
|
248 | + |
|
249 | + $backendIds = array_merge(array_keys($cached), array_keys($remote)); |
|
250 | + foreach($backendIds as $backendId) { |
|
251 | + if (!isset($cached[$backendId])) { |
|
252 | + $sorted['new'][$backendId] = $remote[$backendId]; |
|
253 | + } elseif (!isset($remote[$backendId])) { |
|
254 | + $sorted['deleted'][$backendId] = $remote[$backendId]; |
|
255 | + } else { |
|
256 | + $sorted['new'][$backendId] = array_diff($remote[$backendId], $cached[$backendId]); |
|
257 | + $sorted['deleted'][$backendId] = array_diff($cached[$backendId], $remote[$backendId]); |
|
258 | + $sorted['existing'][$backendId] = array_intersect($remote[$backendId], $cached[$backendId]); |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + return $sorted; |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * add entry to cache that exists remotely but not yet in cache |
|
267 | + * |
|
268 | + * @param string $table |
|
269 | + * @param IResource|IRoom $remote |
|
270 | + */ |
|
271 | + private function addToCache($table, $remote) { |
|
272 | + $query = $this->db->getQueryBuilder(); |
|
273 | + $query->insert($table) |
|
274 | + ->values([ |
|
275 | + 'backend_id' => $query->createNamedParameter($remote->getBackend()), |
|
276 | + 'resource_id' => $query->createNamedParameter($remote->getId()), |
|
277 | + 'email' => $query->createNamedParameter($remote->getEMail()), |
|
278 | + 'displayname' => $query->createNamedParameter($remote->getDisplayName()), |
|
279 | + 'group_restrictions' => $query->createNamedParameter( |
|
280 | + $this->serializeGroupRestrictions( |
|
281 | + $remote->getGroupRestrictions() |
|
282 | + )) |
|
283 | + ]) |
|
284 | + ->execute(); |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * delete entry from cache that does not exist anymore remotely |
|
289 | + * |
|
290 | + * @param string $table |
|
291 | + * @param string $principalUri |
|
292 | + * @param string $backendId |
|
293 | + * @param string $resourceId |
|
294 | + */ |
|
295 | + private function deleteFromCache($table, $principalUri, $backendId, $resourceId) { |
|
296 | + $query = $this->db->getQueryBuilder(); |
|
297 | + $query->delete($table) |
|
298 | + ->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId))) |
|
299 | + ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId))) |
|
300 | + ->execute(); |
|
301 | + |
|
302 | + try { |
|
303 | + $calendar = $this->calDavBackend->getCalendarByUri($principalUri, implode('-', [$backendId, $resourceId])); |
|
304 | + $this->calDavBackend->deleteCalendar($calendar['id']); |
|
305 | + } catch() { |
|
306 | + |
|
307 | + } |
|
308 | + // todo - delete corresponding calendar incl. calendar objects |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * update an existing entry in cache |
|
313 | + * |
|
314 | + * @param string $table |
|
315 | + * @param IResource|IRoom $remote |
|
316 | + */ |
|
317 | + private function updateCache($table, $remote) { |
|
318 | + $query = $this->db->getQueryBuilder(); |
|
319 | + $query->update($table) |
|
320 | + ->set('email', $query->createNamedParameter($remote->getEMail())) |
|
321 | + ->set('displayname', $query->createNamedParameter($remote->getDisplayName())) |
|
322 | + ->set('group_restrictions', $query->createNamedParameter( |
|
323 | + $this->serializeGroupRestrictions( |
|
324 | + $remote->getGroupRestrictions() |
|
325 | + ))) |
|
326 | + ->execute(); |
|
327 | + } |
|
328 | + |
|
329 | + /** |
|
330 | + * serialize array of group restrictions to store them in database |
|
331 | + * |
|
332 | + * @param array $groups |
|
333 | + * @return string |
|
334 | + */ |
|
335 | + private function serializeGroupRestrictions(array $groups):string { |
|
336 | + return \json_encode($groups); |
|
337 | + } |
|
338 | 338 | } |