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