Passed
Push — master ( 7a0ac3...8d02ee )
by Morris
14:29 queued 11s
created
lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,31 +31,31 @@
 block discarded – undo
31 31
 
32 32
 class AddCheckForUserCertificatesJob implements IRepairStep {
33 33
 
34
-	/** @var IJobList */
35
-	protected $jobList;
36
-	/** @var IConfig */
37
-	private $config;
38
-
39
-	public function __construct(IConfig $config, IJobList $jobList) {
40
-		$this->jobList = $jobList;
41
-		$this->config = $config;
42
-	}
43
-
44
-	public function getName() {
45
-		return 'Queue a one-time job to check for user uploaded certificates';
46
-	}
47
-
48
-	private function shouldRun() {
49
-		$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
50
-
51
-		// was added to 21.0.0.2
52
-		return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<');
53
-	}
54
-
55
-	public function run(IOutput $output) {
56
-		if ($this->shouldRun()) {
57
-			$this->config->setAppValue('files_external', 'user_certificate_scan', 'not-run-yet');
58
-			$this->jobList->add(CheckForUserCertificates::class);
59
-		}
60
-	}
34
+    /** @var IJobList */
35
+    protected $jobList;
36
+    /** @var IConfig */
37
+    private $config;
38
+
39
+    public function __construct(IConfig $config, IJobList $jobList) {
40
+        $this->jobList = $jobList;
41
+        $this->config = $config;
42
+    }
43
+
44
+    public function getName() {
45
+        return 'Queue a one-time job to check for user uploaded certificates';
46
+    }
47
+
48
+    private function shouldRun() {
49
+        $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
50
+
51
+        // was added to 21.0.0.2
52
+        return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<');
53
+    }
54
+
55
+    public function run(IOutput $output) {
56
+        if ($this->shouldRun()) {
57
+            $this->config->setAppValue('files_external', 'user_certificate_scan', 'not-run-yet');
58
+            $this->jobList->add(CheckForUserCertificates::class);
59
+        }
60
+    }
61 61
 }
Please login to merge, or discard this patch.
lib/private/Http/Client/Client.php 2 patches
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -48,361 +48,361 @@
 block discarded – undo
48 48
  * @package OC\Http
49 49
  */
50 50
 class Client implements IClient {
51
-	/** @var GuzzleClient */
52
-	private $client;
53
-	/** @var IConfig */
54
-	private $config;
55
-	/** @var ILogger */
56
-	private $logger;
57
-	/** @var ICertificateManager */
58
-	private $certificateManager;
59
-
60
-	public function __construct(
61
-		IConfig $config,
62
-		ILogger $logger,
63
-		ICertificateManager $certificateManager,
64
-		GuzzleClient $client
65
-	) {
66
-		$this->config = $config;
67
-		$this->logger = $logger;
68
-		$this->client = $client;
69
-		$this->certificateManager = $certificateManager;
70
-	}
71
-
72
-	private function buildRequestOptions(array $options): array {
73
-		$proxy = $this->getProxyUri();
74
-
75
-		$defaults = [
76
-			RequestOptions::VERIFY => $this->getCertBundle(),
77
-			RequestOptions::TIMEOUT => 30,
78
-		];
79
-
80
-		// Only add RequestOptions::PROXY if Nextcloud is explicitly
81
-		// configured to use a proxy. This is needed in order not to override
82
-		// Guzzle default values.
83
-		if ($proxy !== null) {
84
-			$defaults[RequestOptions::PROXY] = $proxy;
85
-		}
86
-
87
-		$options = array_merge($defaults, $options);
88
-
89
-		if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
90
-			$options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
91
-		}
92
-
93
-		if (!isset($options[RequestOptions::HEADERS]['Accept-Encoding'])) {
94
-			$options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
95
-		}
96
-
97
-		return $options;
98
-	}
99
-
100
-	private function getCertBundle(): string {
101
-		// If the instance is not yet setup we need to use the static path as
102
-		// $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
103
-		// a view
104
-		if ($this->config->getSystemValue('installed', false) === false) {
105
-			return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
106
-		}
107
-
108
-		return $this->certificateManager->getAbsoluteBundlePath();
109
-	}
110
-
111
-	/**
112
-	 * Returns a null or an associative array specifiying the proxy URI for
113
-	 * 'http' and 'https' schemes, in addition to a 'no' key value pair
114
-	 * providing a list of host names that should not be proxied to.
115
-	 *
116
-	 * @return array|null
117
-	 *
118
-	 * The return array looks like:
119
-	 * [
120
-	 *   'http' => 'username:[email protected]',
121
-	 *   'https' => 'username:[email protected]',
122
-	 *   'no' => ['foo.com', 'bar.com']
123
-	 * ]
124
-	 *
125
-	 */
126
-	private function getProxyUri(): ?array {
127
-		$proxyHost = $this->config->getSystemValue('proxy', '');
128
-
129
-		if ($proxyHost === '' || $proxyHost === null) {
130
-			return null;
131
-		}
132
-
133
-		$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
134
-		if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
135
-			$proxyHost = $proxyUserPwd . '@' . $proxyHost;
136
-		}
137
-
138
-		$proxy = [
139
-			'http' => $proxyHost,
140
-			'https' => $proxyHost,
141
-		];
142
-
143
-		$proxyExclude = $this->config->getSystemValue('proxyexclude', []);
144
-		if ($proxyExclude !== [] && $proxyExclude !== null) {
145
-			$proxy['no'] = $proxyExclude;
146
-		}
147
-
148
-		return $proxy;
149
-	}
150
-
151
-	protected function preventLocalAddress(string $uri, array $options): void {
152
-		if (($options['nextcloud']['allow_local_address'] ?? false) ||
153
-			$this->config->getSystemValueBool('allow_local_remote_servers', false)) {
154
-			return;
155
-		}
156
-
157
-		$host = parse_url($uri, PHP_URL_HOST);
158
-		if ($host === false || $host === null) {
159
-			$this->logger->warning("Could not detect any host in $uri");
160
-			throw new LocalServerException('Could not detect any host');
161
-		}
162
-
163
-		$host = strtolower($host);
164
-		// remove brackets from IPv6 addresses
165
-		if (strpos($host, '[') === 0 && substr($host, -1) === ']') {
166
-			$host = substr($host, 1, -1);
167
-		}
168
-
169
-		// Disallow localhost and local network
170
-		if ($host === 'localhost' || substr($host, -6) === '.local' || substr($host, -10) === '.localhost') {
171
-			$this->logger->warning("Host $host was not connected to because it violates local access rules");
172
-			throw new LocalServerException('Host violates local access rules');
173
-		}
174
-
175
-		// Disallow hostname only
176
-		if (substr_count($host, '.') === 0) {
177
-			$this->logger->warning("Host $host was not connected to because it violates local access rules");
178
-			throw new LocalServerException('Host violates local access rules');
179
-		}
180
-
181
-		if ((bool)filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
182
-			$this->logger->warning("Host $host was not connected to because it violates local access rules");
183
-			throw new LocalServerException('Host violates local access rules');
184
-		}
185
-
186
-		// Also check for IPv6 IPv4 nesting, because that's not covered by filter_var
187
-		if ((bool)filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) {
188
-			$delimiter = strrpos($host, ':'); // Get last colon
189
-			$ipv4Address = substr($host, $delimiter + 1);
190
-
191
-			if (!filter_var($ipv4Address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
192
-				$this->logger->warning("Host $host was not connected to because it violates local access rules");
193
-				throw new LocalServerException('Host violates local access rules');
194
-			}
195
-		}
196
-	}
197
-
198
-	/**
199
-	 * Sends a GET request
200
-	 *
201
-	 * @param string $uri
202
-	 * @param array $options Array such as
203
-	 *              'query' => [
204
-	 *                  'field' => 'abc',
205
-	 *                  'other_field' => '123',
206
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
207
-	 *              ],
208
-	 *              'headers' => [
209
-	 *                  'foo' => 'bar',
210
-	 *              ],
211
-	 *              'cookies' => ['
212
-	 *                  'foo' => 'bar',
213
-	 *              ],
214
-	 *              'allow_redirects' => [
215
-	 *                   'max'       => 10,  // allow at most 10 redirects.
216
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
217
-	 *                   'referer'   => true,     // add a Referer header
218
-	 *                   'protocols' => ['https'] // only allow https URLs
219
-	 *              ],
220
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
221
-	 *              'verify' => true, // bool or string to CA file
222
-	 *              'debug' => true,
223
-	 *              'timeout' => 5,
224
-	 * @return IResponse
225
-	 * @throws \Exception If the request could not get completed
226
-	 */
227
-	public function get(string $uri, array $options = []): IResponse {
228
-		$this->preventLocalAddress($uri, $options);
229
-		$response = $this->client->request('get', $uri, $this->buildRequestOptions($options));
230
-		$isStream = isset($options['stream']) && $options['stream'];
231
-		return new Response($response, $isStream);
232
-	}
233
-
234
-	/**
235
-	 * Sends a HEAD request
236
-	 *
237
-	 * @param string $uri
238
-	 * @param array $options Array such as
239
-	 *              'headers' => [
240
-	 *                  'foo' => 'bar',
241
-	 *              ],
242
-	 *              'cookies' => ['
243
-	 *                  'foo' => 'bar',
244
-	 *              ],
245
-	 *              'allow_redirects' => [
246
-	 *                   'max'       => 10,  // allow at most 10 redirects.
247
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
248
-	 *                   'referer'   => true,     // add a Referer header
249
-	 *                   'protocols' => ['https'] // only allow https URLs
250
-	 *              ],
251
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
252
-	 *              'verify' => true, // bool or string to CA file
253
-	 *              'debug' => true,
254
-	 *              'timeout' => 5,
255
-	 * @return IResponse
256
-	 * @throws \Exception If the request could not get completed
257
-	 */
258
-	public function head(string $uri, array $options = []): IResponse {
259
-		$this->preventLocalAddress($uri, $options);
260
-		$response = $this->client->request('head', $uri, $this->buildRequestOptions($options));
261
-		return new Response($response);
262
-	}
263
-
264
-	/**
265
-	 * Sends a POST request
266
-	 *
267
-	 * @param string $uri
268
-	 * @param array $options Array such as
269
-	 *              'body' => [
270
-	 *                  'field' => 'abc',
271
-	 *                  'other_field' => '123',
272
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
273
-	 *              ],
274
-	 *              'headers' => [
275
-	 *                  'foo' => 'bar',
276
-	 *              ],
277
-	 *              'cookies' => ['
278
-	 *                  'foo' => 'bar',
279
-	 *              ],
280
-	 *              'allow_redirects' => [
281
-	 *                   'max'       => 10,  // allow at most 10 redirects.
282
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
283
-	 *                   'referer'   => true,     // add a Referer header
284
-	 *                   'protocols' => ['https'] // only allow https URLs
285
-	 *              ],
286
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
287
-	 *              'verify' => true, // bool or string to CA file
288
-	 *              'debug' => true,
289
-	 *              'timeout' => 5,
290
-	 * @return IResponse
291
-	 * @throws \Exception If the request could not get completed
292
-	 */
293
-	public function post(string $uri, array $options = []): IResponse {
294
-		$this->preventLocalAddress($uri, $options);
295
-
296
-		if (isset($options['body']) && is_array($options['body'])) {
297
-			$options['form_params'] = $options['body'];
298
-			unset($options['body']);
299
-		}
300
-		$response = $this->client->request('post', $uri, $this->buildRequestOptions($options));
301
-		return new Response($response);
302
-	}
303
-
304
-	/**
305
-	 * Sends a PUT request
306
-	 *
307
-	 * @param string $uri
308
-	 * @param array $options Array such as
309
-	 *              'body' => [
310
-	 *                  'field' => 'abc',
311
-	 *                  'other_field' => '123',
312
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
313
-	 *              ],
314
-	 *              'headers' => [
315
-	 *                  'foo' => 'bar',
316
-	 *              ],
317
-	 *              'cookies' => ['
318
-	 *                  'foo' => 'bar',
319
-	 *              ],
320
-	 *              'allow_redirects' => [
321
-	 *                   'max'       => 10,  // allow at most 10 redirects.
322
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
323
-	 *                   'referer'   => true,     // add a Referer header
324
-	 *                   'protocols' => ['https'] // only allow https URLs
325
-	 *              ],
326
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
327
-	 *              'verify' => true, // bool or string to CA file
328
-	 *              'debug' => true,
329
-	 *              'timeout' => 5,
330
-	 * @return IResponse
331
-	 * @throws \Exception If the request could not get completed
332
-	 */
333
-	public function put(string $uri, array $options = []): IResponse {
334
-		$this->preventLocalAddress($uri, $options);
335
-		$response = $this->client->request('put', $uri, $this->buildRequestOptions($options));
336
-		return new Response($response);
337
-	}
338
-
339
-	/**
340
-	 * Sends a DELETE request
341
-	 *
342
-	 * @param string $uri
343
-	 * @param array $options Array such as
344
-	 *              'body' => [
345
-	 *                  'field' => 'abc',
346
-	 *                  'other_field' => '123',
347
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
348
-	 *              ],
349
-	 *              'headers' => [
350
-	 *                  'foo' => 'bar',
351
-	 *              ],
352
-	 *              'cookies' => ['
353
-	 *                  'foo' => 'bar',
354
-	 *              ],
355
-	 *              'allow_redirects' => [
356
-	 *                   'max'       => 10,  // allow at most 10 redirects.
357
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
358
-	 *                   'referer'   => true,     // add a Referer header
359
-	 *                   'protocols' => ['https'] // only allow https URLs
360
-	 *              ],
361
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
362
-	 *              'verify' => true, // bool or string to CA file
363
-	 *              'debug' => true,
364
-	 *              'timeout' => 5,
365
-	 * @return IResponse
366
-	 * @throws \Exception If the request could not get completed
367
-	 */
368
-	public function delete(string $uri, array $options = []): IResponse {
369
-		$this->preventLocalAddress($uri, $options);
370
-		$response = $this->client->request('delete', $uri, $this->buildRequestOptions($options));
371
-		return new Response($response);
372
-	}
373
-
374
-	/**
375
-	 * Sends a options request
376
-	 *
377
-	 * @param string $uri
378
-	 * @param array $options Array such as
379
-	 *              'body' => [
380
-	 *                  'field' => 'abc',
381
-	 *                  'other_field' => '123',
382
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
383
-	 *              ],
384
-	 *              'headers' => [
385
-	 *                  'foo' => 'bar',
386
-	 *              ],
387
-	 *              'cookies' => ['
388
-	 *                  'foo' => 'bar',
389
-	 *              ],
390
-	 *              'allow_redirects' => [
391
-	 *                   'max'       => 10,  // allow at most 10 redirects.
392
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
393
-	 *                   'referer'   => true,     // add a Referer header
394
-	 *                   'protocols' => ['https'] // only allow https URLs
395
-	 *              ],
396
-	 *              'save_to' => '/path/to/file', // save to a file or a stream
397
-	 *              'verify' => true, // bool or string to CA file
398
-	 *              'debug' => true,
399
-	 *              'timeout' => 5,
400
-	 * @return IResponse
401
-	 * @throws \Exception If the request could not get completed
402
-	 */
403
-	public function options(string $uri, array $options = []): IResponse {
404
-		$this->preventLocalAddress($uri, $options);
405
-		$response = $this->client->request('options', $uri, $this->buildRequestOptions($options));
406
-		return new Response($response);
407
-	}
51
+    /** @var GuzzleClient */
52
+    private $client;
53
+    /** @var IConfig */
54
+    private $config;
55
+    /** @var ILogger */
56
+    private $logger;
57
+    /** @var ICertificateManager */
58
+    private $certificateManager;
59
+
60
+    public function __construct(
61
+        IConfig $config,
62
+        ILogger $logger,
63
+        ICertificateManager $certificateManager,
64
+        GuzzleClient $client
65
+    ) {
66
+        $this->config = $config;
67
+        $this->logger = $logger;
68
+        $this->client = $client;
69
+        $this->certificateManager = $certificateManager;
70
+    }
71
+
72
+    private function buildRequestOptions(array $options): array {
73
+        $proxy = $this->getProxyUri();
74
+
75
+        $defaults = [
76
+            RequestOptions::VERIFY => $this->getCertBundle(),
77
+            RequestOptions::TIMEOUT => 30,
78
+        ];
79
+
80
+        // Only add RequestOptions::PROXY if Nextcloud is explicitly
81
+        // configured to use a proxy. This is needed in order not to override
82
+        // Guzzle default values.
83
+        if ($proxy !== null) {
84
+            $defaults[RequestOptions::PROXY] = $proxy;
85
+        }
86
+
87
+        $options = array_merge($defaults, $options);
88
+
89
+        if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
90
+            $options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
91
+        }
92
+
93
+        if (!isset($options[RequestOptions::HEADERS]['Accept-Encoding'])) {
94
+            $options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
95
+        }
96
+
97
+        return $options;
98
+    }
99
+
100
+    private function getCertBundle(): string {
101
+        // If the instance is not yet setup we need to use the static path as
102
+        // $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
103
+        // a view
104
+        if ($this->config->getSystemValue('installed', false) === false) {
105
+            return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
106
+        }
107
+
108
+        return $this->certificateManager->getAbsoluteBundlePath();
109
+    }
110
+
111
+    /**
112
+     * Returns a null or an associative array specifiying the proxy URI for
113
+     * 'http' and 'https' schemes, in addition to a 'no' key value pair
114
+     * providing a list of host names that should not be proxied to.
115
+     *
116
+     * @return array|null
117
+     *
118
+     * The return array looks like:
119
+     * [
120
+     *   'http' => 'username:[email protected]',
121
+     *   'https' => 'username:[email protected]',
122
+     *   'no' => ['foo.com', 'bar.com']
123
+     * ]
124
+     *
125
+     */
126
+    private function getProxyUri(): ?array {
127
+        $proxyHost = $this->config->getSystemValue('proxy', '');
128
+
129
+        if ($proxyHost === '' || $proxyHost === null) {
130
+            return null;
131
+        }
132
+
133
+        $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
134
+        if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
135
+            $proxyHost = $proxyUserPwd . '@' . $proxyHost;
136
+        }
137
+
138
+        $proxy = [
139
+            'http' => $proxyHost,
140
+            'https' => $proxyHost,
141
+        ];
142
+
143
+        $proxyExclude = $this->config->getSystemValue('proxyexclude', []);
144
+        if ($proxyExclude !== [] && $proxyExclude !== null) {
145
+            $proxy['no'] = $proxyExclude;
146
+        }
147
+
148
+        return $proxy;
149
+    }
150
+
151
+    protected function preventLocalAddress(string $uri, array $options): void {
152
+        if (($options['nextcloud']['allow_local_address'] ?? false) ||
153
+            $this->config->getSystemValueBool('allow_local_remote_servers', false)) {
154
+            return;
155
+        }
156
+
157
+        $host = parse_url($uri, PHP_URL_HOST);
158
+        if ($host === false || $host === null) {
159
+            $this->logger->warning("Could not detect any host in $uri");
160
+            throw new LocalServerException('Could not detect any host');
161
+        }
162
+
163
+        $host = strtolower($host);
164
+        // remove brackets from IPv6 addresses
165
+        if (strpos($host, '[') === 0 && substr($host, -1) === ']') {
166
+            $host = substr($host, 1, -1);
167
+        }
168
+
169
+        // Disallow localhost and local network
170
+        if ($host === 'localhost' || substr($host, -6) === '.local' || substr($host, -10) === '.localhost') {
171
+            $this->logger->warning("Host $host was not connected to because it violates local access rules");
172
+            throw new LocalServerException('Host violates local access rules');
173
+        }
174
+
175
+        // Disallow hostname only
176
+        if (substr_count($host, '.') === 0) {
177
+            $this->logger->warning("Host $host was not connected to because it violates local access rules");
178
+            throw new LocalServerException('Host violates local access rules');
179
+        }
180
+
181
+        if ((bool)filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
182
+            $this->logger->warning("Host $host was not connected to because it violates local access rules");
183
+            throw new LocalServerException('Host violates local access rules');
184
+        }
185
+
186
+        // Also check for IPv6 IPv4 nesting, because that's not covered by filter_var
187
+        if ((bool)filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) {
188
+            $delimiter = strrpos($host, ':'); // Get last colon
189
+            $ipv4Address = substr($host, $delimiter + 1);
190
+
191
+            if (!filter_var($ipv4Address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
192
+                $this->logger->warning("Host $host was not connected to because it violates local access rules");
193
+                throw new LocalServerException('Host violates local access rules');
194
+            }
195
+        }
196
+    }
197
+
198
+    /**
199
+     * Sends a GET request
200
+     *
201
+     * @param string $uri
202
+     * @param array $options Array such as
203
+     *              'query' => [
204
+     *                  'field' => 'abc',
205
+     *                  'other_field' => '123',
206
+     *                  'file_name' => fopen('/path/to/file', 'r'),
207
+     *              ],
208
+     *              'headers' => [
209
+     *                  'foo' => 'bar',
210
+     *              ],
211
+     *              'cookies' => ['
212
+     *                  'foo' => 'bar',
213
+     *              ],
214
+     *              'allow_redirects' => [
215
+     *                   'max'       => 10,  // allow at most 10 redirects.
216
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
217
+     *                   'referer'   => true,     // add a Referer header
218
+     *                   'protocols' => ['https'] // only allow https URLs
219
+     *              ],
220
+     *              'save_to' => '/path/to/file', // save to a file or a stream
221
+     *              'verify' => true, // bool or string to CA file
222
+     *              'debug' => true,
223
+     *              'timeout' => 5,
224
+     * @return IResponse
225
+     * @throws \Exception If the request could not get completed
226
+     */
227
+    public function get(string $uri, array $options = []): IResponse {
228
+        $this->preventLocalAddress($uri, $options);
229
+        $response = $this->client->request('get', $uri, $this->buildRequestOptions($options));
230
+        $isStream = isset($options['stream']) && $options['stream'];
231
+        return new Response($response, $isStream);
232
+    }
233
+
234
+    /**
235
+     * Sends a HEAD request
236
+     *
237
+     * @param string $uri
238
+     * @param array $options Array such as
239
+     *              'headers' => [
240
+     *                  'foo' => 'bar',
241
+     *              ],
242
+     *              'cookies' => ['
243
+     *                  'foo' => 'bar',
244
+     *              ],
245
+     *              'allow_redirects' => [
246
+     *                   'max'       => 10,  // allow at most 10 redirects.
247
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
248
+     *                   'referer'   => true,     // add a Referer header
249
+     *                   'protocols' => ['https'] // only allow https URLs
250
+     *              ],
251
+     *              'save_to' => '/path/to/file', // save to a file or a stream
252
+     *              'verify' => true, // bool or string to CA file
253
+     *              'debug' => true,
254
+     *              'timeout' => 5,
255
+     * @return IResponse
256
+     * @throws \Exception If the request could not get completed
257
+     */
258
+    public function head(string $uri, array $options = []): IResponse {
259
+        $this->preventLocalAddress($uri, $options);
260
+        $response = $this->client->request('head', $uri, $this->buildRequestOptions($options));
261
+        return new Response($response);
262
+    }
263
+
264
+    /**
265
+     * Sends a POST request
266
+     *
267
+     * @param string $uri
268
+     * @param array $options Array such as
269
+     *              'body' => [
270
+     *                  'field' => 'abc',
271
+     *                  'other_field' => '123',
272
+     *                  'file_name' => fopen('/path/to/file', 'r'),
273
+     *              ],
274
+     *              'headers' => [
275
+     *                  'foo' => 'bar',
276
+     *              ],
277
+     *              'cookies' => ['
278
+     *                  'foo' => 'bar',
279
+     *              ],
280
+     *              'allow_redirects' => [
281
+     *                   'max'       => 10,  // allow at most 10 redirects.
282
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
283
+     *                   'referer'   => true,     // add a Referer header
284
+     *                   'protocols' => ['https'] // only allow https URLs
285
+     *              ],
286
+     *              'save_to' => '/path/to/file', // save to a file or a stream
287
+     *              'verify' => true, // bool or string to CA file
288
+     *              'debug' => true,
289
+     *              'timeout' => 5,
290
+     * @return IResponse
291
+     * @throws \Exception If the request could not get completed
292
+     */
293
+    public function post(string $uri, array $options = []): IResponse {
294
+        $this->preventLocalAddress($uri, $options);
295
+
296
+        if (isset($options['body']) && is_array($options['body'])) {
297
+            $options['form_params'] = $options['body'];
298
+            unset($options['body']);
299
+        }
300
+        $response = $this->client->request('post', $uri, $this->buildRequestOptions($options));
301
+        return new Response($response);
302
+    }
303
+
304
+    /**
305
+     * Sends a PUT request
306
+     *
307
+     * @param string $uri
308
+     * @param array $options Array such as
309
+     *              'body' => [
310
+     *                  'field' => 'abc',
311
+     *                  'other_field' => '123',
312
+     *                  'file_name' => fopen('/path/to/file', 'r'),
313
+     *              ],
314
+     *              'headers' => [
315
+     *                  'foo' => 'bar',
316
+     *              ],
317
+     *              'cookies' => ['
318
+     *                  'foo' => 'bar',
319
+     *              ],
320
+     *              'allow_redirects' => [
321
+     *                   'max'       => 10,  // allow at most 10 redirects.
322
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
323
+     *                   'referer'   => true,     // add a Referer header
324
+     *                   'protocols' => ['https'] // only allow https URLs
325
+     *              ],
326
+     *              'save_to' => '/path/to/file', // save to a file or a stream
327
+     *              'verify' => true, // bool or string to CA file
328
+     *              'debug' => true,
329
+     *              'timeout' => 5,
330
+     * @return IResponse
331
+     * @throws \Exception If the request could not get completed
332
+     */
333
+    public function put(string $uri, array $options = []): IResponse {
334
+        $this->preventLocalAddress($uri, $options);
335
+        $response = $this->client->request('put', $uri, $this->buildRequestOptions($options));
336
+        return new Response($response);
337
+    }
338
+
339
+    /**
340
+     * Sends a DELETE request
341
+     *
342
+     * @param string $uri
343
+     * @param array $options Array such as
344
+     *              'body' => [
345
+     *                  'field' => 'abc',
346
+     *                  'other_field' => '123',
347
+     *                  'file_name' => fopen('/path/to/file', 'r'),
348
+     *              ],
349
+     *              'headers' => [
350
+     *                  'foo' => 'bar',
351
+     *              ],
352
+     *              'cookies' => ['
353
+     *                  'foo' => 'bar',
354
+     *              ],
355
+     *              'allow_redirects' => [
356
+     *                   'max'       => 10,  // allow at most 10 redirects.
357
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
358
+     *                   'referer'   => true,     // add a Referer header
359
+     *                   'protocols' => ['https'] // only allow https URLs
360
+     *              ],
361
+     *              'save_to' => '/path/to/file', // save to a file or a stream
362
+     *              'verify' => true, // bool or string to CA file
363
+     *              'debug' => true,
364
+     *              'timeout' => 5,
365
+     * @return IResponse
366
+     * @throws \Exception If the request could not get completed
367
+     */
368
+    public function delete(string $uri, array $options = []): IResponse {
369
+        $this->preventLocalAddress($uri, $options);
370
+        $response = $this->client->request('delete', $uri, $this->buildRequestOptions($options));
371
+        return new Response($response);
372
+    }
373
+
374
+    /**
375
+     * Sends a options request
376
+     *
377
+     * @param string $uri
378
+     * @param array $options Array such as
379
+     *              'body' => [
380
+     *                  'field' => 'abc',
381
+     *                  'other_field' => '123',
382
+     *                  'file_name' => fopen('/path/to/file', 'r'),
383
+     *              ],
384
+     *              'headers' => [
385
+     *                  'foo' => 'bar',
386
+     *              ],
387
+     *              'cookies' => ['
388
+     *                  'foo' => 'bar',
389
+     *              ],
390
+     *              'allow_redirects' => [
391
+     *                   'max'       => 10,  // allow at most 10 redirects.
392
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
393
+     *                   'referer'   => true,     // add a Referer header
394
+     *                   'protocols' => ['https'] // only allow https URLs
395
+     *              ],
396
+     *              'save_to' => '/path/to/file', // save to a file or a stream
397
+     *              'verify' => true, // bool or string to CA file
398
+     *              'debug' => true,
399
+     *              'timeout' => 5,
400
+     * @return IResponse
401
+     * @throws \Exception If the request could not get completed
402
+     */
403
+    public function options(string $uri, array $options = []): IResponse {
404
+        $this->preventLocalAddress($uri, $options);
405
+        $response = $this->client->request('options', $uri, $this->buildRequestOptions($options));
406
+        return new Response($response);
407
+    }
408 408
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		// $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
103 103
 		// a view
104 104
 		if ($this->config->getSystemValue('installed', false) === false) {
105
-			return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
105
+			return \OC::$SERVERROOT.'/resources/config/ca-bundle.crt';
106 106
 		}
107 107
 
108 108
 		return $this->certificateManager->getAbsoluteBundlePath();
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 		$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
134 134
 		if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
135
-			$proxyHost = $proxyUserPwd . '@' . $proxyHost;
135
+			$proxyHost = $proxyUserPwd.'@'.$proxyHost;
136 136
 		}
137 137
 
138 138
 		$proxy = [
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 			throw new LocalServerException('Host violates local access rules');
179 179
 		}
180 180
 
181
-		if ((bool)filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
181
+		if ((bool) filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
182 182
 			$this->logger->warning("Host $host was not connected to because it violates local access rules");
183 183
 			throw new LocalServerException('Host violates local access rules');
184 184
 		}
185 185
 
186 186
 		// Also check for IPv6 IPv4 nesting, because that's not covered by filter_var
187
-		if ((bool)filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) {
187
+		if ((bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($host, '.') > 0) {
188 188
 			$delimiter = strrpos($host, ':'); // Get last colon
189 189
 			$ipv4Address = substr($host, $delimiter + 1);
190 190
 
Please login to merge, or discard this patch.
lib/private/Repair.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -72,181 +72,181 @@
 block discarded – undo
72 72
 
73 73
 class Repair implements IOutput {
74 74
 
75
-	/** @var IRepairStep[] */
76
-	private $repairSteps;
77
-
78
-	/** @var EventDispatcherInterface */
79
-	private $dispatcher;
80
-
81
-	/** @var string */
82
-	private $currentStep;
83
-
84
-	/**
85
-	 * Creates a new repair step runner
86
-	 *
87
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
88
-	 * @param EventDispatcherInterface $dispatcher
89
-	 */
90
-	public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
91
-		$this->repairSteps = $repairSteps;
92
-		$this->dispatcher = $dispatcher;
93
-	}
94
-
95
-	/**
96
-	 * Run a series of repair steps for common problems
97
-	 */
98
-	public function run() {
99
-		if (count($this->repairSteps) === 0) {
100
-			$this->emit('\OC\Repair', 'info', ['No repair steps available']);
101
-
102
-			return;
103
-		}
104
-		// run each repair step
105
-		foreach ($this->repairSteps as $step) {
106
-			$this->currentStep = $step->getName();
107
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
108
-			$step->run($this);
109
-		}
110
-	}
111
-
112
-	/**
113
-	 * Add repair step
114
-	 *
115
-	 * @param IRepairStep|string $repairStep repair step
116
-	 * @throws \Exception
117
-	 */
118
-	public function addStep($repairStep) {
119
-		if (is_string($repairStep)) {
120
-			try {
121
-				$s = \OC::$server->query($repairStep);
122
-			} catch (QueryException $e) {
123
-				if (class_exists($repairStep)) {
124
-					$s = new $repairStep();
125
-				} else {
126
-					throw new \Exception("Repair step '$repairStep' is unknown");
127
-				}
128
-			}
129
-
130
-			if ($s instanceof IRepairStep) {
131
-				$this->repairSteps[] = $s;
132
-			} else {
133
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
134
-			}
135
-		} else {
136
-			$this->repairSteps[] = $repairStep;
137
-		}
138
-	}
139
-
140
-	/**
141
-	 * Returns the default repair steps to be run on the
142
-	 * command line or after an upgrade.
143
-	 *
144
-	 * @return IRepairStep[]
145
-	 */
146
-	public static function getRepairSteps() {
147
-		return [
148
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
149
-			new RepairMimeTypes(\OC::$server->getConfig()),
150
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
151
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
152
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
153
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
154
-			new AddLogRotateJob(\OC::$server->getJobList()),
155
-			new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
156
-			new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
157
-			new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
158
-			new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
159
-			new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
160
-			new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
161
-			new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
162
-			new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
163
-			\OC::$server->query(ResetGeneratedAvatarFlag::class),
164
-			\OC::$server->query(EncryptionLegacyCipher::class),
165
-			\OC::$server->query(EncryptionMigration::class),
166
-			\OC::$server->get(ShippedDashboardEnable::class),
167
-			\OC::$server->get(AddBruteForceCleanupJob::class),
168
-			\OC::$server->get(AddCheckForUserCertificatesJob::class),
169
-		];
170
-	}
171
-
172
-	/**
173
-	 * Returns expensive repair steps to be run on the
174
-	 * command line with a special option.
175
-	 *
176
-	 * @return IRepairStep[]
177
-	 */
178
-	public static function getExpensiveRepairSteps() {
179
-		return [
180
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
181
-		];
182
-	}
183
-
184
-	/**
185
-	 * Returns the repair steps to be run before an
186
-	 * upgrade.
187
-	 *
188
-	 * @return IRepairStep[]
189
-	 */
190
-	public static function getBeforeUpgradeRepairSteps() {
191
-		$connection = \OC::$server->getDatabaseConnection();
192
-		$config = \OC::$server->getConfig();
193
-		$steps = [
194
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
195
-			new SqliteAutoincrement($connection),
196
-			new SaveAccountsTableData($connection, $config),
197
-			new DropAccountTermsTable($connection)
198
-		];
199
-
200
-		return $steps;
201
-	}
202
-
203
-	/**
204
-	 * @param string $scope
205
-	 * @param string $method
206
-	 * @param array $arguments
207
-	 */
208
-	public function emit($scope, $method, array $arguments = []) {
209
-		if (!is_null($this->dispatcher)) {
210
-			$this->dispatcher->dispatch("$scope::$method",
211
-				new GenericEvent("$scope::$method", $arguments));
212
-		}
213
-	}
214
-
215
-	public function info($string) {
216
-		// for now just emit as we did in the past
217
-		$this->emit('\OC\Repair', 'info', [$string]);
218
-	}
219
-
220
-	/**
221
-	 * @param string $message
222
-	 */
223
-	public function warning($message) {
224
-		// for now just emit as we did in the past
225
-		$this->emit('\OC\Repair', 'warning', [$message]);
226
-	}
227
-
228
-	/**
229
-	 * @param int $max
230
-	 */
231
-	public function startProgress($max = 0) {
232
-		// for now just emit as we did in the past
233
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
234
-	}
235
-
236
-	/**
237
-	 * @param int $step
238
-	 * @param string $description
239
-	 */
240
-	public function advance($step = 1, $description = '') {
241
-		// for now just emit as we did in the past
242
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
243
-	}
244
-
245
-	/**
246
-	 * @param int $max
247
-	 */
248
-	public function finishProgress() {
249
-		// for now just emit as we did in the past
250
-		$this->emit('\OC\Repair', 'finishProgress', []);
251
-	}
75
+    /** @var IRepairStep[] */
76
+    private $repairSteps;
77
+
78
+    /** @var EventDispatcherInterface */
79
+    private $dispatcher;
80
+
81
+    /** @var string */
82
+    private $currentStep;
83
+
84
+    /**
85
+     * Creates a new repair step runner
86
+     *
87
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
88
+     * @param EventDispatcherInterface $dispatcher
89
+     */
90
+    public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
91
+        $this->repairSteps = $repairSteps;
92
+        $this->dispatcher = $dispatcher;
93
+    }
94
+
95
+    /**
96
+     * Run a series of repair steps for common problems
97
+     */
98
+    public function run() {
99
+        if (count($this->repairSteps) === 0) {
100
+            $this->emit('\OC\Repair', 'info', ['No repair steps available']);
101
+
102
+            return;
103
+        }
104
+        // run each repair step
105
+        foreach ($this->repairSteps as $step) {
106
+            $this->currentStep = $step->getName();
107
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
108
+            $step->run($this);
109
+        }
110
+    }
111
+
112
+    /**
113
+     * Add repair step
114
+     *
115
+     * @param IRepairStep|string $repairStep repair step
116
+     * @throws \Exception
117
+     */
118
+    public function addStep($repairStep) {
119
+        if (is_string($repairStep)) {
120
+            try {
121
+                $s = \OC::$server->query($repairStep);
122
+            } catch (QueryException $e) {
123
+                if (class_exists($repairStep)) {
124
+                    $s = new $repairStep();
125
+                } else {
126
+                    throw new \Exception("Repair step '$repairStep' is unknown");
127
+                }
128
+            }
129
+
130
+            if ($s instanceof IRepairStep) {
131
+                $this->repairSteps[] = $s;
132
+            } else {
133
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
134
+            }
135
+        } else {
136
+            $this->repairSteps[] = $repairStep;
137
+        }
138
+    }
139
+
140
+    /**
141
+     * Returns the default repair steps to be run on the
142
+     * command line or after an upgrade.
143
+     *
144
+     * @return IRepairStep[]
145
+     */
146
+    public static function getRepairSteps() {
147
+        return [
148
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
149
+            new RepairMimeTypes(\OC::$server->getConfig()),
150
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
151
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
152
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
153
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
154
+            new AddLogRotateJob(\OC::$server->getJobList()),
155
+            new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
156
+            new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
157
+            new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
158
+            new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
159
+            new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
160
+            new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
161
+            new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
162
+            new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
163
+            \OC::$server->query(ResetGeneratedAvatarFlag::class),
164
+            \OC::$server->query(EncryptionLegacyCipher::class),
165
+            \OC::$server->query(EncryptionMigration::class),
166
+            \OC::$server->get(ShippedDashboardEnable::class),
167
+            \OC::$server->get(AddBruteForceCleanupJob::class),
168
+            \OC::$server->get(AddCheckForUserCertificatesJob::class),
169
+        ];
170
+    }
171
+
172
+    /**
173
+     * Returns expensive repair steps to be run on the
174
+     * command line with a special option.
175
+     *
176
+     * @return IRepairStep[]
177
+     */
178
+    public static function getExpensiveRepairSteps() {
179
+        return [
180
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
181
+        ];
182
+    }
183
+
184
+    /**
185
+     * Returns the repair steps to be run before an
186
+     * upgrade.
187
+     *
188
+     * @return IRepairStep[]
189
+     */
190
+    public static function getBeforeUpgradeRepairSteps() {
191
+        $connection = \OC::$server->getDatabaseConnection();
192
+        $config = \OC::$server->getConfig();
193
+        $steps = [
194
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
195
+            new SqliteAutoincrement($connection),
196
+            new SaveAccountsTableData($connection, $config),
197
+            new DropAccountTermsTable($connection)
198
+        ];
199
+
200
+        return $steps;
201
+    }
202
+
203
+    /**
204
+     * @param string $scope
205
+     * @param string $method
206
+     * @param array $arguments
207
+     */
208
+    public function emit($scope, $method, array $arguments = []) {
209
+        if (!is_null($this->dispatcher)) {
210
+            $this->dispatcher->dispatch("$scope::$method",
211
+                new GenericEvent("$scope::$method", $arguments));
212
+        }
213
+    }
214
+
215
+    public function info($string) {
216
+        // for now just emit as we did in the past
217
+        $this->emit('\OC\Repair', 'info', [$string]);
218
+    }
219
+
220
+    /**
221
+     * @param string $message
222
+     */
223
+    public function warning($message) {
224
+        // for now just emit as we did in the past
225
+        $this->emit('\OC\Repair', 'warning', [$message]);
226
+    }
227
+
228
+    /**
229
+     * @param int $max
230
+     */
231
+    public function startProgress($max = 0) {
232
+        // for now just emit as we did in the past
233
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
234
+    }
235
+
236
+    /**
237
+     * @param int $step
238
+     * @param string $description
239
+     */
240
+    public function advance($step = 1, $description = '') {
241
+        // for now just emit as we did in the past
242
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
243
+    }
244
+
245
+    /**
246
+     * @param int $max
247
+     */
248
+    public function finishProgress() {
249
+        // for now just emit as we did in the past
250
+        $this->emit('\OC\Repair', 'finishProgress', []);
251
+    }
252 252
 }
Please login to merge, or discard this patch.
lib/private/Files/Storage/DAV.php 2 patches
Indentation   +809 added lines, -809 removed lines patch added patch discarded remove patch
@@ -64,813 +64,813 @@
 block discarded – undo
64 64
  * @package OC\Files\Storage
65 65
  */
66 66
 class DAV extends Common {
67
-	/** @var string */
68
-	protected $password;
69
-	/** @var string */
70
-	protected $user;
71
-	/** @var string */
72
-	protected $authType;
73
-	/** @var string */
74
-	protected $host;
75
-	/** @var bool */
76
-	protected $secure;
77
-	/** @var string */
78
-	protected $root;
79
-	/** @var string */
80
-	protected $certPath;
81
-	/** @var bool */
82
-	protected $ready;
83
-	/** @var Client */
84
-	protected $client;
85
-	/** @var ArrayCache */
86
-	protected $statCache;
87
-	/** @var IClientService */
88
-	protected $httpClientService;
89
-	/** @var ICertificateManager */
90
-	protected $certManager;
91
-
92
-	/**
93
-	 * @param array $params
94
-	 * @throws \Exception
95
-	 */
96
-	public function __construct($params) {
97
-		$this->statCache = new ArrayCache();
98
-		$this->httpClientService = \OC::$server->getHTTPClientService();
99
-		if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
100
-			$host = $params['host'];
101
-			//remove leading http[s], will be generated in createBaseUri()
102
-			if (substr($host, 0, 8) == "https://") {
103
-				$host = substr($host, 8);
104
-			} elseif (substr($host, 0, 7) == "http://") {
105
-				$host = substr($host, 7);
106
-			}
107
-			$this->host = $host;
108
-			$this->user = $params['user'];
109
-			$this->password = $params['password'];
110
-			if (isset($params['authType'])) {
111
-				$this->authType = $params['authType'];
112
-			}
113
-			if (isset($params['secure'])) {
114
-				if (is_string($params['secure'])) {
115
-					$this->secure = ($params['secure'] === 'true');
116
-				} else {
117
-					$this->secure = (bool)$params['secure'];
118
-				}
119
-			} else {
120
-				$this->secure = false;
121
-			}
122
-			if ($this->secure === true) {
123
-				// inject mock for testing
124
-				$this->certManager = \OC::$server->getCertificateManager();
125
-			}
126
-			$this->root = $params['root'] ?? '/';
127
-			$this->root = '/' . ltrim($this->root, '/');
128
-			$this->root = rtrim($this->root, '/') . '/';
129
-		} else {
130
-			throw new \Exception('Invalid webdav storage configuration');
131
-		}
132
-	}
133
-
134
-	protected function init() {
135
-		if ($this->ready) {
136
-			return;
137
-		}
138
-		$this->ready = true;
139
-
140
-		$settings = [
141
-			'baseUri' => $this->createBaseUri(),
142
-			'userName' => $this->user,
143
-			'password' => $this->password,
144
-		];
145
-		if (isset($this->authType)) {
146
-			$settings['authType'] = $this->authType;
147
-		}
148
-
149
-		$proxy = \OC::$server->getConfig()->getSystemValue('proxy', '');
150
-		if ($proxy !== '') {
151
-			$settings['proxy'] = $proxy;
152
-		}
153
-
154
-		$this->client = new Client($settings);
155
-		$this->client->setThrowExceptions(true);
156
-
157
-		if ($this->secure === true) {
158
-			$certPath = $this->certManager->getAbsoluteBundlePath();
159
-			if (file_exists($certPath)) {
160
-				$this->certPath = $certPath;
161
-			}
162
-			if ($this->certPath) {
163
-				$this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
164
-			}
165
-		}
166
-	}
167
-
168
-	/**
169
-	 * Clear the stat cache
170
-	 */
171
-	public function clearStatCache() {
172
-		$this->statCache->clear();
173
-	}
174
-
175
-	/** {@inheritdoc} */
176
-	public function getId() {
177
-		return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
178
-	}
179
-
180
-	/** {@inheritdoc} */
181
-	public function createBaseUri() {
182
-		$baseUri = 'http';
183
-		if ($this->secure) {
184
-			$baseUri .= 's';
185
-		}
186
-		$baseUri .= '://' . $this->host . $this->root;
187
-		return $baseUri;
188
-	}
189
-
190
-	/** {@inheritdoc} */
191
-	public function mkdir($path) {
192
-		$this->init();
193
-		$path = $this->cleanPath($path);
194
-		$result = $this->simpleResponse('MKCOL', $path, null, 201);
195
-		if ($result) {
196
-			$this->statCache->set($path, true);
197
-		}
198
-		return $result;
199
-	}
200
-
201
-	/** {@inheritdoc} */
202
-	public function rmdir($path) {
203
-		$this->init();
204
-		$path = $this->cleanPath($path);
205
-		// FIXME: some WebDAV impl return 403 when trying to DELETE
206
-		// a non-empty folder
207
-		$result = $this->simpleResponse('DELETE', $path . '/', null, 204);
208
-		$this->statCache->clear($path . '/');
209
-		$this->statCache->remove($path);
210
-		return $result;
211
-	}
212
-
213
-	/** {@inheritdoc} */
214
-	public function opendir($path) {
215
-		$this->init();
216
-		$path = $this->cleanPath($path);
217
-		try {
218
-			$response = $this->client->propFind(
219
-				$this->encodePath($path),
220
-				['{DAV:}getetag'],
221
-				1
222
-			);
223
-			if ($response === false) {
224
-				return false;
225
-			}
226
-			$content = [];
227
-			$files = array_keys($response);
228
-			array_shift($files); //the first entry is the current directory
229
-
230
-			if (!$this->statCache->hasKey($path)) {
231
-				$this->statCache->set($path, true);
232
-			}
233
-			foreach ($files as $file) {
234
-				$file = urldecode($file);
235
-				// do not store the real entry, we might not have all properties
236
-				if (!$this->statCache->hasKey($path)) {
237
-					$this->statCache->set($file, true);
238
-				}
239
-				$file = basename($file);
240
-				$content[] = $file;
241
-			}
242
-			return IteratorDirectory::wrap($content);
243
-		} catch (\Exception $e) {
244
-			$this->convertException($e, $path);
245
-		}
246
-		return false;
247
-	}
248
-
249
-	/**
250
-	 * Propfind call with cache handling.
251
-	 *
252
-	 * First checks if information is cached.
253
-	 * If not, request it from the server then store to cache.
254
-	 *
255
-	 * @param string $path path to propfind
256
-	 *
257
-	 * @return array|boolean propfind response or false if the entry was not found
258
-	 *
259
-	 * @throws ClientHttpException
260
-	 */
261
-	protected function propfind($path) {
262
-		$path = $this->cleanPath($path);
263
-		$cachedResponse = $this->statCache->get($path);
264
-		// we either don't know it, or we know it exists but need more details
265
-		if (is_null($cachedResponse) || $cachedResponse === true) {
266
-			$this->init();
267
-			try {
268
-				$response = $this->client->propFind(
269
-					$this->encodePath($path),
270
-					[
271
-						'{DAV:}getlastmodified',
272
-						'{DAV:}getcontentlength',
273
-						'{DAV:}getcontenttype',
274
-						'{http://owncloud.org/ns}permissions',
275
-						'{http://open-collaboration-services.org/ns}share-permissions',
276
-						'{DAV:}resourcetype',
277
-						'{DAV:}getetag',
278
-					]
279
-				);
280
-				$this->statCache->set($path, $response);
281
-			} catch (ClientHttpException $e) {
282
-				if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) {
283
-					$this->statCache->clear($path . '/');
284
-					$this->statCache->set($path, false);
285
-					return false;
286
-				}
287
-				$this->convertException($e, $path);
288
-			} catch (\Exception $e) {
289
-				$this->convertException($e, $path);
290
-			}
291
-		} else {
292
-			$response = $cachedResponse;
293
-		}
294
-		return $response;
295
-	}
296
-
297
-	/** {@inheritdoc} */
298
-	public function filetype($path) {
299
-		try {
300
-			$response = $this->propfind($path);
301
-			if ($response === false) {
302
-				return false;
303
-			}
304
-			$responseType = [];
305
-			if (isset($response["{DAV:}resourcetype"])) {
306
-				/** @var ResourceType[] $response */
307
-				$responseType = $response["{DAV:}resourcetype"]->getValue();
308
-			}
309
-			return (count($responseType) > 0 and $responseType[0] == "{DAV:}collection") ? 'dir' : 'file';
310
-		} catch (\Exception $e) {
311
-			$this->convertException($e, $path);
312
-		}
313
-		return false;
314
-	}
315
-
316
-	/** {@inheritdoc} */
317
-	public function file_exists($path) {
318
-		try {
319
-			$path = $this->cleanPath($path);
320
-			$cachedState = $this->statCache->get($path);
321
-			if ($cachedState === false) {
322
-				// we know the file doesn't exist
323
-				return false;
324
-			} elseif (!is_null($cachedState)) {
325
-				return true;
326
-			}
327
-			// need to get from server
328
-			return ($this->propfind($path) !== false);
329
-		} catch (\Exception $e) {
330
-			$this->convertException($e, $path);
331
-		}
332
-		return false;
333
-	}
334
-
335
-	/** {@inheritdoc} */
336
-	public function unlink($path) {
337
-		$this->init();
338
-		$path = $this->cleanPath($path);
339
-		$result = $this->simpleResponse('DELETE', $path, null, 204);
340
-		$this->statCache->clear($path . '/');
341
-		$this->statCache->remove($path);
342
-		return $result;
343
-	}
344
-
345
-	/** {@inheritdoc} */
346
-	public function fopen($path, $mode) {
347
-		$this->init();
348
-		$path = $this->cleanPath($path);
349
-		switch ($mode) {
350
-			case 'r':
351
-			case 'rb':
352
-				try {
353
-					$response = $this->httpClientService
354
-						->newClient()
355
-						->get($this->createBaseUri() . $this->encodePath($path), [
356
-							'auth' => [$this->user, $this->password],
357
-							'stream' => true
358
-						]);
359
-				} catch (\GuzzleHttp\Exception\ClientException $e) {
360
-					if ($e->getResponse() instanceof ResponseInterface
361
-						&& $e->getResponse()->getStatusCode() === 404) {
362
-						return false;
363
-					} else {
364
-						throw $e;
365
-					}
366
-				}
367
-
368
-				if ($response->getStatusCode() !== Http::STATUS_OK) {
369
-					if ($response->getStatusCode() === Http::STATUS_LOCKED) {
370
-						throw new \OCP\Lock\LockedException($path);
371
-					} else {
372
-						Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR);
373
-					}
374
-				}
375
-
376
-				return $response->getBody();
377
-			case 'w':
378
-			case 'wb':
379
-			case 'a':
380
-			case 'ab':
381
-			case 'r+':
382
-			case 'w+':
383
-			case 'wb+':
384
-			case 'a+':
385
-			case 'x':
386
-			case 'x+':
387
-			case 'c':
388
-			case 'c+':
389
-				//emulate these
390
-				$tempManager = \OC::$server->getTempManager();
391
-				if (strrpos($path, '.') !== false) {
392
-					$ext = substr($path, strrpos($path, '.'));
393
-				} else {
394
-					$ext = '';
395
-				}
396
-				if ($this->file_exists($path)) {
397
-					if (!$this->isUpdatable($path)) {
398
-						return false;
399
-					}
400
-					if ($mode === 'w' or $mode === 'w+') {
401
-						$tmpFile = $tempManager->getTemporaryFile($ext);
402
-					} else {
403
-						$tmpFile = $this->getCachedFile($path);
404
-					}
405
-				} else {
406
-					if (!$this->isCreatable(dirname($path))) {
407
-						return false;
408
-					}
409
-					$tmpFile = $tempManager->getTemporaryFile($ext);
410
-				}
411
-				$handle = fopen($tmpFile, $mode);
412
-				return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
413
-					$this->writeBack($tmpFile, $path);
414
-				});
415
-		}
416
-	}
417
-
418
-	/**
419
-	 * @param string $tmpFile
420
-	 */
421
-	public function writeBack($tmpFile, $path) {
422
-		$this->uploadFile($tmpFile, $path);
423
-		unlink($tmpFile);
424
-	}
425
-
426
-	/** {@inheritdoc} */
427
-	public function free_space($path) {
428
-		$this->init();
429
-		$path = $this->cleanPath($path);
430
-		try {
431
-			// TODO: cacheable ?
432
-			$response = $this->client->propfind($this->encodePath($path), ['{DAV:}quota-available-bytes']);
433
-			if ($response === false) {
434
-				return FileInfo::SPACE_UNKNOWN;
435
-			}
436
-			if (isset($response['{DAV:}quota-available-bytes'])) {
437
-				return (int)$response['{DAV:}quota-available-bytes'];
438
-			} else {
439
-				return FileInfo::SPACE_UNKNOWN;
440
-			}
441
-		} catch (\Exception $e) {
442
-			return FileInfo::SPACE_UNKNOWN;
443
-		}
444
-	}
445
-
446
-	/** {@inheritdoc} */
447
-	public function touch($path, $mtime = null) {
448
-		$this->init();
449
-		if (is_null($mtime)) {
450
-			$mtime = time();
451
-		}
452
-		$path = $this->cleanPath($path);
453
-
454
-		// if file exists, update the mtime, else create a new empty file
455
-		if ($this->file_exists($path)) {
456
-			try {
457
-				$this->statCache->remove($path);
458
-				$this->client->proppatch($this->encodePath($path), ['{DAV:}lastmodified' => $mtime]);
459
-				// non-owncloud clients might not have accepted the property, need to recheck it
460
-				$response = $this->client->propfind($this->encodePath($path), ['{DAV:}getlastmodified'], 0);
461
-				if ($response === false) {
462
-					return false;
463
-				}
464
-				if (isset($response['{DAV:}getlastmodified'])) {
465
-					$remoteMtime = strtotime($response['{DAV:}getlastmodified']);
466
-					if ($remoteMtime !== $mtime) {
467
-						// server has not accepted the mtime
468
-						return false;
469
-					}
470
-				}
471
-			} catch (ClientHttpException $e) {
472
-				if ($e->getHttpStatus() === 501) {
473
-					return false;
474
-				}
475
-				$this->convertException($e, $path);
476
-				return false;
477
-			} catch (\Exception $e) {
478
-				$this->convertException($e, $path);
479
-				return false;
480
-			}
481
-		} else {
482
-			$this->file_put_contents($path, '');
483
-		}
484
-		return true;
485
-	}
486
-
487
-	/**
488
-	 * @param string $path
489
-	 * @param string $data
490
-	 * @return int
491
-	 */
492
-	public function file_put_contents($path, $data) {
493
-		$path = $this->cleanPath($path);
494
-		$result = parent::file_put_contents($path, $data);
495
-		$this->statCache->remove($path);
496
-		return $result;
497
-	}
498
-
499
-	/**
500
-	 * @param string $path
501
-	 * @param string $target
502
-	 */
503
-	protected function uploadFile($path, $target) {
504
-		$this->init();
505
-
506
-		// invalidate
507
-		$target = $this->cleanPath($target);
508
-		$this->statCache->remove($target);
509
-		$source = fopen($path, 'r');
510
-
511
-		$this->httpClientService
512
-			->newClient()
513
-			->put($this->createBaseUri() . $this->encodePath($target), [
514
-				'body' => $source,
515
-				'auth' => [$this->user, $this->password]
516
-			]);
517
-
518
-		$this->removeCachedFile($target);
519
-	}
520
-
521
-	/** {@inheritdoc} */
522
-	public function rename($path1, $path2) {
523
-		$this->init();
524
-		$path1 = $this->cleanPath($path1);
525
-		$path2 = $this->cleanPath($path2);
526
-		try {
527
-			// overwrite directory ?
528
-			if ($this->is_dir($path2)) {
529
-				// needs trailing slash in destination
530
-				$path2 = rtrim($path2, '/') . '/';
531
-			}
532
-			$this->client->request(
533
-				'MOVE',
534
-				$this->encodePath($path1),
535
-				null,
536
-				[
537
-					'Destination' => $this->createBaseUri() . $this->encodePath($path2),
538
-				]
539
-			);
540
-			$this->statCache->clear($path1 . '/');
541
-			$this->statCache->clear($path2 . '/');
542
-			$this->statCache->set($path1, false);
543
-			$this->statCache->set($path2, true);
544
-			$this->removeCachedFile($path1);
545
-			$this->removeCachedFile($path2);
546
-			return true;
547
-		} catch (\Exception $e) {
548
-			$this->convertException($e);
549
-		}
550
-		return false;
551
-	}
552
-
553
-	/** {@inheritdoc} */
554
-	public function copy($path1, $path2) {
555
-		$this->init();
556
-		$path1 = $this->cleanPath($path1);
557
-		$path2 = $this->cleanPath($path2);
558
-		try {
559
-			// overwrite directory ?
560
-			if ($this->is_dir($path2)) {
561
-				// needs trailing slash in destination
562
-				$path2 = rtrim($path2, '/') . '/';
563
-			}
564
-			$this->client->request(
565
-				'COPY',
566
-				$this->encodePath($path1),
567
-				null,
568
-				[
569
-					'Destination' => $this->createBaseUri() . $this->encodePath($path2),
570
-				]
571
-			);
572
-			$this->statCache->clear($path2 . '/');
573
-			$this->statCache->set($path2, true);
574
-			$this->removeCachedFile($path2);
575
-			return true;
576
-		} catch (\Exception $e) {
577
-			$this->convertException($e);
578
-		}
579
-		return false;
580
-	}
581
-
582
-	/** {@inheritdoc} */
583
-	public function stat($path) {
584
-		try {
585
-			$response = $this->propfind($path);
586
-			if (!$response) {
587
-				return false;
588
-			}
589
-			return [
590
-				'mtime' => strtotime($response['{DAV:}getlastmodified']),
591
-				'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
592
-			];
593
-		} catch (\Exception $e) {
594
-			$this->convertException($e, $path);
595
-		}
596
-		return [];
597
-	}
598
-
599
-	/** {@inheritdoc} */
600
-	public function getMimeType($path) {
601
-		$remoteMimetype = $this->getMimeTypeFromRemote($path);
602
-		if ($remoteMimetype === 'application/octet-stream') {
603
-			return \OC::$server->getMimeTypeDetector()->detectPath($path);
604
-		} else {
605
-			return $remoteMimetype;
606
-		}
607
-	}
608
-
609
-	public function getMimeTypeFromRemote($path) {
610
-		try {
611
-			$response = $this->propfind($path);
612
-			if ($response === false) {
613
-				return false;
614
-			}
615
-			$responseType = [];
616
-			if (isset($response["{DAV:}resourcetype"])) {
617
-				/** @var ResourceType[] $response */
618
-				$responseType = $response["{DAV:}resourcetype"]->getValue();
619
-			}
620
-			$type = (count($responseType) > 0 and $responseType[0] == "{DAV:}collection") ? 'dir' : 'file';
621
-			if ($type == 'dir') {
622
-				return 'httpd/unix-directory';
623
-			} elseif (isset($response['{DAV:}getcontenttype'])) {
624
-				return $response['{DAV:}getcontenttype'];
625
-			} else {
626
-				return 'application/octet-stream';
627
-			}
628
-		} catch (\Exception $e) {
629
-			return false;
630
-		}
631
-	}
632
-
633
-	/**
634
-	 * @param string $path
635
-	 * @return string
636
-	 */
637
-	public function cleanPath($path) {
638
-		if ($path === '') {
639
-			return $path;
640
-		}
641
-		$path = Filesystem::normalizePath($path);
642
-		// remove leading slash
643
-		return substr($path, 1);
644
-	}
645
-
646
-	/**
647
-	 * URL encodes the given path but keeps the slashes
648
-	 *
649
-	 * @param string $path to encode
650
-	 * @return string encoded path
651
-	 */
652
-	protected function encodePath($path) {
653
-		// slashes need to stay
654
-		return str_replace('%2F', '/', rawurlencode($path));
655
-	}
656
-
657
-	/**
658
-	 * @param string $method
659
-	 * @param string $path
660
-	 * @param string|resource|null $body
661
-	 * @param int $expected
662
-	 * @return bool
663
-	 * @throws StorageInvalidException
664
-	 * @throws StorageNotAvailableException
665
-	 */
666
-	protected function simpleResponse($method, $path, $body, $expected) {
667
-		$path = $this->cleanPath($path);
668
-		try {
669
-			$response = $this->client->request($method, $this->encodePath($path), $body);
670
-			return $response['statusCode'] == $expected;
671
-		} catch (ClientHttpException $e) {
672
-			if ($e->getHttpStatus() === 404 && $method === 'DELETE') {
673
-				$this->statCache->clear($path . '/');
674
-				$this->statCache->set($path, false);
675
-				return false;
676
-			}
677
-
678
-			$this->convertException($e, $path);
679
-		} catch (\Exception $e) {
680
-			$this->convertException($e, $path);
681
-		}
682
-		return false;
683
-	}
684
-
685
-	/**
686
-	 * check if curl is installed
687
-	 */
688
-	public static function checkDependencies() {
689
-		return true;
690
-	}
691
-
692
-	/** {@inheritdoc} */
693
-	public function isUpdatable($path) {
694
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
695
-	}
696
-
697
-	/** {@inheritdoc} */
698
-	public function isCreatable($path) {
699
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
700
-	}
701
-
702
-	/** {@inheritdoc} */
703
-	public function isSharable($path) {
704
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
705
-	}
706
-
707
-	/** {@inheritdoc} */
708
-	public function isDeletable($path) {
709
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
710
-	}
711
-
712
-	/** {@inheritdoc} */
713
-	public function getPermissions($path) {
714
-		$this->init();
715
-		$path = $this->cleanPath($path);
716
-		$response = $this->propfind($path);
717
-		if ($response === false) {
718
-			return 0;
719
-		}
720
-		if (isset($response['{http://owncloud.org/ns}permissions'])) {
721
-			return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
722
-		} elseif ($this->is_dir($path)) {
723
-			return Constants::PERMISSION_ALL;
724
-		} elseif ($this->file_exists($path)) {
725
-			return Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE;
726
-		} else {
727
-			return 0;
728
-		}
729
-	}
730
-
731
-	/** {@inheritdoc} */
732
-	public function getETag($path) {
733
-		$this->init();
734
-		$path = $this->cleanPath($path);
735
-		$response = $this->propfind($path);
736
-		if ($response === false) {
737
-			return null;
738
-		}
739
-		if (isset($response['{DAV:}getetag'])) {
740
-			$etag = trim($response['{DAV:}getetag'], '"');
741
-			if (strlen($etag) > 40) {
742
-				$etag = md5($etag);
743
-			}
744
-			return $etag;
745
-		}
746
-		return parent::getEtag($path);
747
-	}
748
-
749
-	/**
750
-	 * @param string $permissionsString
751
-	 * @return int
752
-	 */
753
-	protected function parsePermissions($permissionsString) {
754
-		$permissions = Constants::PERMISSION_READ;
755
-		if (strpos($permissionsString, 'R') !== false) {
756
-			$permissions |= Constants::PERMISSION_SHARE;
757
-		}
758
-		if (strpos($permissionsString, 'D') !== false) {
759
-			$permissions |= Constants::PERMISSION_DELETE;
760
-		}
761
-		if (strpos($permissionsString, 'W') !== false) {
762
-			$permissions |= Constants::PERMISSION_UPDATE;
763
-		}
764
-		if (strpos($permissionsString, 'CK') !== false) {
765
-			$permissions |= Constants::PERMISSION_CREATE;
766
-			$permissions |= Constants::PERMISSION_UPDATE;
767
-		}
768
-		return $permissions;
769
-	}
770
-
771
-	/**
772
-	 * check if a file or folder has been updated since $time
773
-	 *
774
-	 * @param string $path
775
-	 * @param int $time
776
-	 * @throws \OCP\Files\StorageNotAvailableException
777
-	 * @return bool
778
-	 */
779
-	public function hasUpdated($path, $time) {
780
-		$this->init();
781
-		$path = $this->cleanPath($path);
782
-		try {
783
-			// force refresh for $path
784
-			$this->statCache->remove($path);
785
-			$response = $this->propfind($path);
786
-			if ($response === false) {
787
-				if ($path === '') {
788
-					// if root is gone it means the storage is not available
789
-					throw new StorageNotAvailableException('root is gone');
790
-				}
791
-				return false;
792
-			}
793
-			if (isset($response['{DAV:}getetag'])) {
794
-				$cachedData = $this->getCache()->get($path);
795
-				$etag = null;
796
-				if (isset($response['{DAV:}getetag'])) {
797
-					$etag = trim($response['{DAV:}getetag'], '"');
798
-				}
799
-				if (!empty($etag) && $cachedData['etag'] !== $etag) {
800
-					return true;
801
-				} elseif (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
802
-					$sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions'];
803
-					return $sharePermissions !== $cachedData['permissions'];
804
-				} elseif (isset($response['{http://owncloud.org/ns}permissions'])) {
805
-					$permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
806
-					return $permissions !== $cachedData['permissions'];
807
-				} else {
808
-					return false;
809
-				}
810
-			} else {
811
-				$remoteMtime = strtotime($response['{DAV:}getlastmodified']);
812
-				return $remoteMtime > $time;
813
-			}
814
-		} catch (ClientHttpException $e) {
815
-			if ($e->getHttpStatus() === 405) {
816
-				if ($path === '') {
817
-					// if root is gone it means the storage is not available
818
-					throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
819
-				}
820
-				return false;
821
-			}
822
-			$this->convertException($e, $path);
823
-			return false;
824
-		} catch (\Exception $e) {
825
-			$this->convertException($e, $path);
826
-			return false;
827
-		}
828
-	}
829
-
830
-	/**
831
-	 * Interpret the given exception and decide whether it is due to an
832
-	 * unavailable storage, invalid storage or other.
833
-	 * This will either throw StorageInvalidException, StorageNotAvailableException
834
-	 * or do nothing.
835
-	 *
836
-	 * @param Exception $e sabre exception
837
-	 * @param string $path optional path from the operation
838
-	 *
839
-	 * @throws StorageInvalidException if the storage is invalid, for example
840
-	 * when the authentication expired or is invalid
841
-	 * @throws StorageNotAvailableException if the storage is not available,
842
-	 * which might be temporary
843
-	 * @throws ForbiddenException if the action is not allowed
844
-	 */
845
-	protected function convertException(Exception $e, $path = '') {
846
-		\OC::$server->getLogger()->logException($e, ['app' => 'files_external', 'level' => ILogger::DEBUG]);
847
-		if ($e instanceof ClientHttpException) {
848
-			if ($e->getHttpStatus() === Http::STATUS_LOCKED) {
849
-				throw new \OCP\Lock\LockedException($path);
850
-			}
851
-			if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) {
852
-				// either password was changed or was invalid all along
853
-				throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage());
854
-			} elseif ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
855
-				// ignore exception for MethodNotAllowed, false will be returned
856
-				return;
857
-			} elseif ($e->getHttpStatus() === Http::STATUS_FORBIDDEN) {
858
-				// The operation is forbidden. Fail somewhat gracefully
859
-				throw new ForbiddenException(get_class($e) . ':' . $e->getMessage(), false);
860
-			}
861
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
862
-		} elseif ($e instanceof ClientException) {
863
-			// connection timeout or refused, server could be temporarily down
864
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
865
-		} elseif ($e instanceof \InvalidArgumentException) {
866
-			// parse error because the server returned HTML instead of XML,
867
-			// possibly temporarily down
868
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
869
-		} elseif (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) {
870
-			// rethrow
871
-			throw $e;
872
-		}
873
-
874
-		// TODO: only log for now, but in the future need to wrap/rethrow exception
875
-	}
67
+    /** @var string */
68
+    protected $password;
69
+    /** @var string */
70
+    protected $user;
71
+    /** @var string */
72
+    protected $authType;
73
+    /** @var string */
74
+    protected $host;
75
+    /** @var bool */
76
+    protected $secure;
77
+    /** @var string */
78
+    protected $root;
79
+    /** @var string */
80
+    protected $certPath;
81
+    /** @var bool */
82
+    protected $ready;
83
+    /** @var Client */
84
+    protected $client;
85
+    /** @var ArrayCache */
86
+    protected $statCache;
87
+    /** @var IClientService */
88
+    protected $httpClientService;
89
+    /** @var ICertificateManager */
90
+    protected $certManager;
91
+
92
+    /**
93
+     * @param array $params
94
+     * @throws \Exception
95
+     */
96
+    public function __construct($params) {
97
+        $this->statCache = new ArrayCache();
98
+        $this->httpClientService = \OC::$server->getHTTPClientService();
99
+        if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
100
+            $host = $params['host'];
101
+            //remove leading http[s], will be generated in createBaseUri()
102
+            if (substr($host, 0, 8) == "https://") {
103
+                $host = substr($host, 8);
104
+            } elseif (substr($host, 0, 7) == "http://") {
105
+                $host = substr($host, 7);
106
+            }
107
+            $this->host = $host;
108
+            $this->user = $params['user'];
109
+            $this->password = $params['password'];
110
+            if (isset($params['authType'])) {
111
+                $this->authType = $params['authType'];
112
+            }
113
+            if (isset($params['secure'])) {
114
+                if (is_string($params['secure'])) {
115
+                    $this->secure = ($params['secure'] === 'true');
116
+                } else {
117
+                    $this->secure = (bool)$params['secure'];
118
+                }
119
+            } else {
120
+                $this->secure = false;
121
+            }
122
+            if ($this->secure === true) {
123
+                // inject mock for testing
124
+                $this->certManager = \OC::$server->getCertificateManager();
125
+            }
126
+            $this->root = $params['root'] ?? '/';
127
+            $this->root = '/' . ltrim($this->root, '/');
128
+            $this->root = rtrim($this->root, '/') . '/';
129
+        } else {
130
+            throw new \Exception('Invalid webdav storage configuration');
131
+        }
132
+    }
133
+
134
+    protected function init() {
135
+        if ($this->ready) {
136
+            return;
137
+        }
138
+        $this->ready = true;
139
+
140
+        $settings = [
141
+            'baseUri' => $this->createBaseUri(),
142
+            'userName' => $this->user,
143
+            'password' => $this->password,
144
+        ];
145
+        if (isset($this->authType)) {
146
+            $settings['authType'] = $this->authType;
147
+        }
148
+
149
+        $proxy = \OC::$server->getConfig()->getSystemValue('proxy', '');
150
+        if ($proxy !== '') {
151
+            $settings['proxy'] = $proxy;
152
+        }
153
+
154
+        $this->client = new Client($settings);
155
+        $this->client->setThrowExceptions(true);
156
+
157
+        if ($this->secure === true) {
158
+            $certPath = $this->certManager->getAbsoluteBundlePath();
159
+            if (file_exists($certPath)) {
160
+                $this->certPath = $certPath;
161
+            }
162
+            if ($this->certPath) {
163
+                $this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
164
+            }
165
+        }
166
+    }
167
+
168
+    /**
169
+     * Clear the stat cache
170
+     */
171
+    public function clearStatCache() {
172
+        $this->statCache->clear();
173
+    }
174
+
175
+    /** {@inheritdoc} */
176
+    public function getId() {
177
+        return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
178
+    }
179
+
180
+    /** {@inheritdoc} */
181
+    public function createBaseUri() {
182
+        $baseUri = 'http';
183
+        if ($this->secure) {
184
+            $baseUri .= 's';
185
+        }
186
+        $baseUri .= '://' . $this->host . $this->root;
187
+        return $baseUri;
188
+    }
189
+
190
+    /** {@inheritdoc} */
191
+    public function mkdir($path) {
192
+        $this->init();
193
+        $path = $this->cleanPath($path);
194
+        $result = $this->simpleResponse('MKCOL', $path, null, 201);
195
+        if ($result) {
196
+            $this->statCache->set($path, true);
197
+        }
198
+        return $result;
199
+    }
200
+
201
+    /** {@inheritdoc} */
202
+    public function rmdir($path) {
203
+        $this->init();
204
+        $path = $this->cleanPath($path);
205
+        // FIXME: some WebDAV impl return 403 when trying to DELETE
206
+        // a non-empty folder
207
+        $result = $this->simpleResponse('DELETE', $path . '/', null, 204);
208
+        $this->statCache->clear($path . '/');
209
+        $this->statCache->remove($path);
210
+        return $result;
211
+    }
212
+
213
+    /** {@inheritdoc} */
214
+    public function opendir($path) {
215
+        $this->init();
216
+        $path = $this->cleanPath($path);
217
+        try {
218
+            $response = $this->client->propFind(
219
+                $this->encodePath($path),
220
+                ['{DAV:}getetag'],
221
+                1
222
+            );
223
+            if ($response === false) {
224
+                return false;
225
+            }
226
+            $content = [];
227
+            $files = array_keys($response);
228
+            array_shift($files); //the first entry is the current directory
229
+
230
+            if (!$this->statCache->hasKey($path)) {
231
+                $this->statCache->set($path, true);
232
+            }
233
+            foreach ($files as $file) {
234
+                $file = urldecode($file);
235
+                // do not store the real entry, we might not have all properties
236
+                if (!$this->statCache->hasKey($path)) {
237
+                    $this->statCache->set($file, true);
238
+                }
239
+                $file = basename($file);
240
+                $content[] = $file;
241
+            }
242
+            return IteratorDirectory::wrap($content);
243
+        } catch (\Exception $e) {
244
+            $this->convertException($e, $path);
245
+        }
246
+        return false;
247
+    }
248
+
249
+    /**
250
+     * Propfind call with cache handling.
251
+     *
252
+     * First checks if information is cached.
253
+     * If not, request it from the server then store to cache.
254
+     *
255
+     * @param string $path path to propfind
256
+     *
257
+     * @return array|boolean propfind response or false if the entry was not found
258
+     *
259
+     * @throws ClientHttpException
260
+     */
261
+    protected function propfind($path) {
262
+        $path = $this->cleanPath($path);
263
+        $cachedResponse = $this->statCache->get($path);
264
+        // we either don't know it, or we know it exists but need more details
265
+        if (is_null($cachedResponse) || $cachedResponse === true) {
266
+            $this->init();
267
+            try {
268
+                $response = $this->client->propFind(
269
+                    $this->encodePath($path),
270
+                    [
271
+                        '{DAV:}getlastmodified',
272
+                        '{DAV:}getcontentlength',
273
+                        '{DAV:}getcontenttype',
274
+                        '{http://owncloud.org/ns}permissions',
275
+                        '{http://open-collaboration-services.org/ns}share-permissions',
276
+                        '{DAV:}resourcetype',
277
+                        '{DAV:}getetag',
278
+                    ]
279
+                );
280
+                $this->statCache->set($path, $response);
281
+            } catch (ClientHttpException $e) {
282
+                if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) {
283
+                    $this->statCache->clear($path . '/');
284
+                    $this->statCache->set($path, false);
285
+                    return false;
286
+                }
287
+                $this->convertException($e, $path);
288
+            } catch (\Exception $e) {
289
+                $this->convertException($e, $path);
290
+            }
291
+        } else {
292
+            $response = $cachedResponse;
293
+        }
294
+        return $response;
295
+    }
296
+
297
+    /** {@inheritdoc} */
298
+    public function filetype($path) {
299
+        try {
300
+            $response = $this->propfind($path);
301
+            if ($response === false) {
302
+                return false;
303
+            }
304
+            $responseType = [];
305
+            if (isset($response["{DAV:}resourcetype"])) {
306
+                /** @var ResourceType[] $response */
307
+                $responseType = $response["{DAV:}resourcetype"]->getValue();
308
+            }
309
+            return (count($responseType) > 0 and $responseType[0] == "{DAV:}collection") ? 'dir' : 'file';
310
+        } catch (\Exception $e) {
311
+            $this->convertException($e, $path);
312
+        }
313
+        return false;
314
+    }
315
+
316
+    /** {@inheritdoc} */
317
+    public function file_exists($path) {
318
+        try {
319
+            $path = $this->cleanPath($path);
320
+            $cachedState = $this->statCache->get($path);
321
+            if ($cachedState === false) {
322
+                // we know the file doesn't exist
323
+                return false;
324
+            } elseif (!is_null($cachedState)) {
325
+                return true;
326
+            }
327
+            // need to get from server
328
+            return ($this->propfind($path) !== false);
329
+        } catch (\Exception $e) {
330
+            $this->convertException($e, $path);
331
+        }
332
+        return false;
333
+    }
334
+
335
+    /** {@inheritdoc} */
336
+    public function unlink($path) {
337
+        $this->init();
338
+        $path = $this->cleanPath($path);
339
+        $result = $this->simpleResponse('DELETE', $path, null, 204);
340
+        $this->statCache->clear($path . '/');
341
+        $this->statCache->remove($path);
342
+        return $result;
343
+    }
344
+
345
+    /** {@inheritdoc} */
346
+    public function fopen($path, $mode) {
347
+        $this->init();
348
+        $path = $this->cleanPath($path);
349
+        switch ($mode) {
350
+            case 'r':
351
+            case 'rb':
352
+                try {
353
+                    $response = $this->httpClientService
354
+                        ->newClient()
355
+                        ->get($this->createBaseUri() . $this->encodePath($path), [
356
+                            'auth' => [$this->user, $this->password],
357
+                            'stream' => true
358
+                        ]);
359
+                } catch (\GuzzleHttp\Exception\ClientException $e) {
360
+                    if ($e->getResponse() instanceof ResponseInterface
361
+                        && $e->getResponse()->getStatusCode() === 404) {
362
+                        return false;
363
+                    } else {
364
+                        throw $e;
365
+                    }
366
+                }
367
+
368
+                if ($response->getStatusCode() !== Http::STATUS_OK) {
369
+                    if ($response->getStatusCode() === Http::STATUS_LOCKED) {
370
+                        throw new \OCP\Lock\LockedException($path);
371
+                    } else {
372
+                        Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR);
373
+                    }
374
+                }
375
+
376
+                return $response->getBody();
377
+            case 'w':
378
+            case 'wb':
379
+            case 'a':
380
+            case 'ab':
381
+            case 'r+':
382
+            case 'w+':
383
+            case 'wb+':
384
+            case 'a+':
385
+            case 'x':
386
+            case 'x+':
387
+            case 'c':
388
+            case 'c+':
389
+                //emulate these
390
+                $tempManager = \OC::$server->getTempManager();
391
+                if (strrpos($path, '.') !== false) {
392
+                    $ext = substr($path, strrpos($path, '.'));
393
+                } else {
394
+                    $ext = '';
395
+                }
396
+                if ($this->file_exists($path)) {
397
+                    if (!$this->isUpdatable($path)) {
398
+                        return false;
399
+                    }
400
+                    if ($mode === 'w' or $mode === 'w+') {
401
+                        $tmpFile = $tempManager->getTemporaryFile($ext);
402
+                    } else {
403
+                        $tmpFile = $this->getCachedFile($path);
404
+                    }
405
+                } else {
406
+                    if (!$this->isCreatable(dirname($path))) {
407
+                        return false;
408
+                    }
409
+                    $tmpFile = $tempManager->getTemporaryFile($ext);
410
+                }
411
+                $handle = fopen($tmpFile, $mode);
412
+                return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
413
+                    $this->writeBack($tmpFile, $path);
414
+                });
415
+        }
416
+    }
417
+
418
+    /**
419
+     * @param string $tmpFile
420
+     */
421
+    public function writeBack($tmpFile, $path) {
422
+        $this->uploadFile($tmpFile, $path);
423
+        unlink($tmpFile);
424
+    }
425
+
426
+    /** {@inheritdoc} */
427
+    public function free_space($path) {
428
+        $this->init();
429
+        $path = $this->cleanPath($path);
430
+        try {
431
+            // TODO: cacheable ?
432
+            $response = $this->client->propfind($this->encodePath($path), ['{DAV:}quota-available-bytes']);
433
+            if ($response === false) {
434
+                return FileInfo::SPACE_UNKNOWN;
435
+            }
436
+            if (isset($response['{DAV:}quota-available-bytes'])) {
437
+                return (int)$response['{DAV:}quota-available-bytes'];
438
+            } else {
439
+                return FileInfo::SPACE_UNKNOWN;
440
+            }
441
+        } catch (\Exception $e) {
442
+            return FileInfo::SPACE_UNKNOWN;
443
+        }
444
+    }
445
+
446
+    /** {@inheritdoc} */
447
+    public function touch($path, $mtime = null) {
448
+        $this->init();
449
+        if (is_null($mtime)) {
450
+            $mtime = time();
451
+        }
452
+        $path = $this->cleanPath($path);
453
+
454
+        // if file exists, update the mtime, else create a new empty file
455
+        if ($this->file_exists($path)) {
456
+            try {
457
+                $this->statCache->remove($path);
458
+                $this->client->proppatch($this->encodePath($path), ['{DAV:}lastmodified' => $mtime]);
459
+                // non-owncloud clients might not have accepted the property, need to recheck it
460
+                $response = $this->client->propfind($this->encodePath($path), ['{DAV:}getlastmodified'], 0);
461
+                if ($response === false) {
462
+                    return false;
463
+                }
464
+                if (isset($response['{DAV:}getlastmodified'])) {
465
+                    $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
466
+                    if ($remoteMtime !== $mtime) {
467
+                        // server has not accepted the mtime
468
+                        return false;
469
+                    }
470
+                }
471
+            } catch (ClientHttpException $e) {
472
+                if ($e->getHttpStatus() === 501) {
473
+                    return false;
474
+                }
475
+                $this->convertException($e, $path);
476
+                return false;
477
+            } catch (\Exception $e) {
478
+                $this->convertException($e, $path);
479
+                return false;
480
+            }
481
+        } else {
482
+            $this->file_put_contents($path, '');
483
+        }
484
+        return true;
485
+    }
486
+
487
+    /**
488
+     * @param string $path
489
+     * @param string $data
490
+     * @return int
491
+     */
492
+    public function file_put_contents($path, $data) {
493
+        $path = $this->cleanPath($path);
494
+        $result = parent::file_put_contents($path, $data);
495
+        $this->statCache->remove($path);
496
+        return $result;
497
+    }
498
+
499
+    /**
500
+     * @param string $path
501
+     * @param string $target
502
+     */
503
+    protected function uploadFile($path, $target) {
504
+        $this->init();
505
+
506
+        // invalidate
507
+        $target = $this->cleanPath($target);
508
+        $this->statCache->remove($target);
509
+        $source = fopen($path, 'r');
510
+
511
+        $this->httpClientService
512
+            ->newClient()
513
+            ->put($this->createBaseUri() . $this->encodePath($target), [
514
+                'body' => $source,
515
+                'auth' => [$this->user, $this->password]
516
+            ]);
517
+
518
+        $this->removeCachedFile($target);
519
+    }
520
+
521
+    /** {@inheritdoc} */
522
+    public function rename($path1, $path2) {
523
+        $this->init();
524
+        $path1 = $this->cleanPath($path1);
525
+        $path2 = $this->cleanPath($path2);
526
+        try {
527
+            // overwrite directory ?
528
+            if ($this->is_dir($path2)) {
529
+                // needs trailing slash in destination
530
+                $path2 = rtrim($path2, '/') . '/';
531
+            }
532
+            $this->client->request(
533
+                'MOVE',
534
+                $this->encodePath($path1),
535
+                null,
536
+                [
537
+                    'Destination' => $this->createBaseUri() . $this->encodePath($path2),
538
+                ]
539
+            );
540
+            $this->statCache->clear($path1 . '/');
541
+            $this->statCache->clear($path2 . '/');
542
+            $this->statCache->set($path1, false);
543
+            $this->statCache->set($path2, true);
544
+            $this->removeCachedFile($path1);
545
+            $this->removeCachedFile($path2);
546
+            return true;
547
+        } catch (\Exception $e) {
548
+            $this->convertException($e);
549
+        }
550
+        return false;
551
+    }
552
+
553
+    /** {@inheritdoc} */
554
+    public function copy($path1, $path2) {
555
+        $this->init();
556
+        $path1 = $this->cleanPath($path1);
557
+        $path2 = $this->cleanPath($path2);
558
+        try {
559
+            // overwrite directory ?
560
+            if ($this->is_dir($path2)) {
561
+                // needs trailing slash in destination
562
+                $path2 = rtrim($path2, '/') . '/';
563
+            }
564
+            $this->client->request(
565
+                'COPY',
566
+                $this->encodePath($path1),
567
+                null,
568
+                [
569
+                    'Destination' => $this->createBaseUri() . $this->encodePath($path2),
570
+                ]
571
+            );
572
+            $this->statCache->clear($path2 . '/');
573
+            $this->statCache->set($path2, true);
574
+            $this->removeCachedFile($path2);
575
+            return true;
576
+        } catch (\Exception $e) {
577
+            $this->convertException($e);
578
+        }
579
+        return false;
580
+    }
581
+
582
+    /** {@inheritdoc} */
583
+    public function stat($path) {
584
+        try {
585
+            $response = $this->propfind($path);
586
+            if (!$response) {
587
+                return false;
588
+            }
589
+            return [
590
+                'mtime' => strtotime($response['{DAV:}getlastmodified']),
591
+                'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
592
+            ];
593
+        } catch (\Exception $e) {
594
+            $this->convertException($e, $path);
595
+        }
596
+        return [];
597
+    }
598
+
599
+    /** {@inheritdoc} */
600
+    public function getMimeType($path) {
601
+        $remoteMimetype = $this->getMimeTypeFromRemote($path);
602
+        if ($remoteMimetype === 'application/octet-stream') {
603
+            return \OC::$server->getMimeTypeDetector()->detectPath($path);
604
+        } else {
605
+            return $remoteMimetype;
606
+        }
607
+    }
608
+
609
+    public function getMimeTypeFromRemote($path) {
610
+        try {
611
+            $response = $this->propfind($path);
612
+            if ($response === false) {
613
+                return false;
614
+            }
615
+            $responseType = [];
616
+            if (isset($response["{DAV:}resourcetype"])) {
617
+                /** @var ResourceType[] $response */
618
+                $responseType = $response["{DAV:}resourcetype"]->getValue();
619
+            }
620
+            $type = (count($responseType) > 0 and $responseType[0] == "{DAV:}collection") ? 'dir' : 'file';
621
+            if ($type == 'dir') {
622
+                return 'httpd/unix-directory';
623
+            } elseif (isset($response['{DAV:}getcontenttype'])) {
624
+                return $response['{DAV:}getcontenttype'];
625
+            } else {
626
+                return 'application/octet-stream';
627
+            }
628
+        } catch (\Exception $e) {
629
+            return false;
630
+        }
631
+    }
632
+
633
+    /**
634
+     * @param string $path
635
+     * @return string
636
+     */
637
+    public function cleanPath($path) {
638
+        if ($path === '') {
639
+            return $path;
640
+        }
641
+        $path = Filesystem::normalizePath($path);
642
+        // remove leading slash
643
+        return substr($path, 1);
644
+    }
645
+
646
+    /**
647
+     * URL encodes the given path but keeps the slashes
648
+     *
649
+     * @param string $path to encode
650
+     * @return string encoded path
651
+     */
652
+    protected function encodePath($path) {
653
+        // slashes need to stay
654
+        return str_replace('%2F', '/', rawurlencode($path));
655
+    }
656
+
657
+    /**
658
+     * @param string $method
659
+     * @param string $path
660
+     * @param string|resource|null $body
661
+     * @param int $expected
662
+     * @return bool
663
+     * @throws StorageInvalidException
664
+     * @throws StorageNotAvailableException
665
+     */
666
+    protected function simpleResponse($method, $path, $body, $expected) {
667
+        $path = $this->cleanPath($path);
668
+        try {
669
+            $response = $this->client->request($method, $this->encodePath($path), $body);
670
+            return $response['statusCode'] == $expected;
671
+        } catch (ClientHttpException $e) {
672
+            if ($e->getHttpStatus() === 404 && $method === 'DELETE') {
673
+                $this->statCache->clear($path . '/');
674
+                $this->statCache->set($path, false);
675
+                return false;
676
+            }
677
+
678
+            $this->convertException($e, $path);
679
+        } catch (\Exception $e) {
680
+            $this->convertException($e, $path);
681
+        }
682
+        return false;
683
+    }
684
+
685
+    /**
686
+     * check if curl is installed
687
+     */
688
+    public static function checkDependencies() {
689
+        return true;
690
+    }
691
+
692
+    /** {@inheritdoc} */
693
+    public function isUpdatable($path) {
694
+        return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
695
+    }
696
+
697
+    /** {@inheritdoc} */
698
+    public function isCreatable($path) {
699
+        return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
700
+    }
701
+
702
+    /** {@inheritdoc} */
703
+    public function isSharable($path) {
704
+        return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
705
+    }
706
+
707
+    /** {@inheritdoc} */
708
+    public function isDeletable($path) {
709
+        return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
710
+    }
711
+
712
+    /** {@inheritdoc} */
713
+    public function getPermissions($path) {
714
+        $this->init();
715
+        $path = $this->cleanPath($path);
716
+        $response = $this->propfind($path);
717
+        if ($response === false) {
718
+            return 0;
719
+        }
720
+        if (isset($response['{http://owncloud.org/ns}permissions'])) {
721
+            return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
722
+        } elseif ($this->is_dir($path)) {
723
+            return Constants::PERMISSION_ALL;
724
+        } elseif ($this->file_exists($path)) {
725
+            return Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE;
726
+        } else {
727
+            return 0;
728
+        }
729
+    }
730
+
731
+    /** {@inheritdoc} */
732
+    public function getETag($path) {
733
+        $this->init();
734
+        $path = $this->cleanPath($path);
735
+        $response = $this->propfind($path);
736
+        if ($response === false) {
737
+            return null;
738
+        }
739
+        if (isset($response['{DAV:}getetag'])) {
740
+            $etag = trim($response['{DAV:}getetag'], '"');
741
+            if (strlen($etag) > 40) {
742
+                $etag = md5($etag);
743
+            }
744
+            return $etag;
745
+        }
746
+        return parent::getEtag($path);
747
+    }
748
+
749
+    /**
750
+     * @param string $permissionsString
751
+     * @return int
752
+     */
753
+    protected function parsePermissions($permissionsString) {
754
+        $permissions = Constants::PERMISSION_READ;
755
+        if (strpos($permissionsString, 'R') !== false) {
756
+            $permissions |= Constants::PERMISSION_SHARE;
757
+        }
758
+        if (strpos($permissionsString, 'D') !== false) {
759
+            $permissions |= Constants::PERMISSION_DELETE;
760
+        }
761
+        if (strpos($permissionsString, 'W') !== false) {
762
+            $permissions |= Constants::PERMISSION_UPDATE;
763
+        }
764
+        if (strpos($permissionsString, 'CK') !== false) {
765
+            $permissions |= Constants::PERMISSION_CREATE;
766
+            $permissions |= Constants::PERMISSION_UPDATE;
767
+        }
768
+        return $permissions;
769
+    }
770
+
771
+    /**
772
+     * check if a file or folder has been updated since $time
773
+     *
774
+     * @param string $path
775
+     * @param int $time
776
+     * @throws \OCP\Files\StorageNotAvailableException
777
+     * @return bool
778
+     */
779
+    public function hasUpdated($path, $time) {
780
+        $this->init();
781
+        $path = $this->cleanPath($path);
782
+        try {
783
+            // force refresh for $path
784
+            $this->statCache->remove($path);
785
+            $response = $this->propfind($path);
786
+            if ($response === false) {
787
+                if ($path === '') {
788
+                    // if root is gone it means the storage is not available
789
+                    throw new StorageNotAvailableException('root is gone');
790
+                }
791
+                return false;
792
+            }
793
+            if (isset($response['{DAV:}getetag'])) {
794
+                $cachedData = $this->getCache()->get($path);
795
+                $etag = null;
796
+                if (isset($response['{DAV:}getetag'])) {
797
+                    $etag = trim($response['{DAV:}getetag'], '"');
798
+                }
799
+                if (!empty($etag) && $cachedData['etag'] !== $etag) {
800
+                    return true;
801
+                } elseif (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
802
+                    $sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions'];
803
+                    return $sharePermissions !== $cachedData['permissions'];
804
+                } elseif (isset($response['{http://owncloud.org/ns}permissions'])) {
805
+                    $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
806
+                    return $permissions !== $cachedData['permissions'];
807
+                } else {
808
+                    return false;
809
+                }
810
+            } else {
811
+                $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
812
+                return $remoteMtime > $time;
813
+            }
814
+        } catch (ClientHttpException $e) {
815
+            if ($e->getHttpStatus() === 405) {
816
+                if ($path === '') {
817
+                    // if root is gone it means the storage is not available
818
+                    throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
819
+                }
820
+                return false;
821
+            }
822
+            $this->convertException($e, $path);
823
+            return false;
824
+        } catch (\Exception $e) {
825
+            $this->convertException($e, $path);
826
+            return false;
827
+        }
828
+    }
829
+
830
+    /**
831
+     * Interpret the given exception and decide whether it is due to an
832
+     * unavailable storage, invalid storage or other.
833
+     * This will either throw StorageInvalidException, StorageNotAvailableException
834
+     * or do nothing.
835
+     *
836
+     * @param Exception $e sabre exception
837
+     * @param string $path optional path from the operation
838
+     *
839
+     * @throws StorageInvalidException if the storage is invalid, for example
840
+     * when the authentication expired or is invalid
841
+     * @throws StorageNotAvailableException if the storage is not available,
842
+     * which might be temporary
843
+     * @throws ForbiddenException if the action is not allowed
844
+     */
845
+    protected function convertException(Exception $e, $path = '') {
846
+        \OC::$server->getLogger()->logException($e, ['app' => 'files_external', 'level' => ILogger::DEBUG]);
847
+        if ($e instanceof ClientHttpException) {
848
+            if ($e->getHttpStatus() === Http::STATUS_LOCKED) {
849
+                throw new \OCP\Lock\LockedException($path);
850
+            }
851
+            if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) {
852
+                // either password was changed or was invalid all along
853
+                throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage());
854
+            } elseif ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
855
+                // ignore exception for MethodNotAllowed, false will be returned
856
+                return;
857
+            } elseif ($e->getHttpStatus() === Http::STATUS_FORBIDDEN) {
858
+                // The operation is forbidden. Fail somewhat gracefully
859
+                throw new ForbiddenException(get_class($e) . ':' . $e->getMessage(), false);
860
+            }
861
+            throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
862
+        } elseif ($e instanceof ClientException) {
863
+            // connection timeout or refused, server could be temporarily down
864
+            throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
865
+        } elseif ($e instanceof \InvalidArgumentException) {
866
+            // parse error because the server returned HTML instead of XML,
867
+            // possibly temporarily down
868
+            throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
869
+        } elseif (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) {
870
+            // rethrow
871
+            throw $e;
872
+        }
873
+
874
+        // TODO: only log for now, but in the future need to wrap/rethrow exception
875
+    }
876 876
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 				if (is_string($params['secure'])) {
115 115
 					$this->secure = ($params['secure'] === 'true');
116 116
 				} else {
117
-					$this->secure = (bool)$params['secure'];
117
+					$this->secure = (bool) $params['secure'];
118 118
 				}
119 119
 			} else {
120 120
 				$this->secure = false;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 				$this->certManager = \OC::$server->getCertificateManager();
125 125
 			}
126 126
 			$this->root = $params['root'] ?? '/';
127
-			$this->root = '/' . ltrim($this->root, '/');
128
-			$this->root = rtrim($this->root, '/') . '/';
127
+			$this->root = '/'.ltrim($this->root, '/');
128
+			$this->root = rtrim($this->root, '/').'/';
129 129
 		} else {
130 130
 			throw new \Exception('Invalid webdav storage configuration');
131 131
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 	/** {@inheritdoc} */
176 176
 	public function getId() {
177
-		return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
177
+		return 'webdav::'.$this->user.'@'.$this->host.'/'.$this->root;
178 178
 	}
179 179
 
180 180
 	/** {@inheritdoc} */
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		if ($this->secure) {
184 184
 			$baseUri .= 's';
185 185
 		}
186
-		$baseUri .= '://' . $this->host . $this->root;
186
+		$baseUri .= '://'.$this->host.$this->root;
187 187
 		return $baseUri;
188 188
 	}
189 189
 
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 		$path = $this->cleanPath($path);
205 205
 		// FIXME: some WebDAV impl return 403 when trying to DELETE
206 206
 		// a non-empty folder
207
-		$result = $this->simpleResponse('DELETE', $path . '/', null, 204);
208
-		$this->statCache->clear($path . '/');
207
+		$result = $this->simpleResponse('DELETE', $path.'/', null, 204);
208
+		$this->statCache->clear($path.'/');
209 209
 		$this->statCache->remove($path);
210 210
 		return $result;
211 211
 	}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 				$this->statCache->set($path, $response);
281 281
 			} catch (ClientHttpException $e) {
282 282
 				if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) {
283
-					$this->statCache->clear($path . '/');
283
+					$this->statCache->clear($path.'/');
284 284
 					$this->statCache->set($path, false);
285 285
 					return false;
286 286
 				}
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		$this->init();
338 338
 		$path = $this->cleanPath($path);
339 339
 		$result = $this->simpleResponse('DELETE', $path, null, 204);
340
-		$this->statCache->clear($path . '/');
340
+		$this->statCache->clear($path.'/');
341 341
 		$this->statCache->remove($path);
342 342
 		return $result;
343 343
 	}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				try {
353 353
 					$response = $this->httpClientService
354 354
 						->newClient()
355
-						->get($this->createBaseUri() . $this->encodePath($path), [
355
+						->get($this->createBaseUri().$this->encodePath($path), [
356 356
 							'auth' => [$this->user, $this->password],
357 357
 							'stream' => true
358 358
 						]);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 					if ($response->getStatusCode() === Http::STATUS_LOCKED) {
370 370
 						throw new \OCP\Lock\LockedException($path);
371 371
 					} else {
372
-						Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR);
372
+						Util::writeLog("webdav client", 'Guzzle get returned status code '.$response->getStatusCode(), ILogger::ERROR);
373 373
 					}
374 374
 				}
375 375
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 					$tmpFile = $tempManager->getTemporaryFile($ext);
410 410
 				}
411 411
 				$handle = fopen($tmpFile, $mode);
412
-				return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
412
+				return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) {
413 413
 					$this->writeBack($tmpFile, $path);
414 414
 				});
415 415
 		}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 				return FileInfo::SPACE_UNKNOWN;
435 435
 			}
436 436
 			if (isset($response['{DAV:}quota-available-bytes'])) {
437
-				return (int)$response['{DAV:}quota-available-bytes'];
437
+				return (int) $response['{DAV:}quota-available-bytes'];
438 438
 			} else {
439 439
 				return FileInfo::SPACE_UNKNOWN;
440 440
 			}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 
511 511
 		$this->httpClientService
512 512
 			->newClient()
513
-			->put($this->createBaseUri() . $this->encodePath($target), [
513
+			->put($this->createBaseUri().$this->encodePath($target), [
514 514
 				'body' => $source,
515 515
 				'auth' => [$this->user, $this->password]
516 516
 			]);
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
 			// overwrite directory ?
528 528
 			if ($this->is_dir($path2)) {
529 529
 				// needs trailing slash in destination
530
-				$path2 = rtrim($path2, '/') . '/';
530
+				$path2 = rtrim($path2, '/').'/';
531 531
 			}
532 532
 			$this->client->request(
533 533
 				'MOVE',
534 534
 				$this->encodePath($path1),
535 535
 				null,
536 536
 				[
537
-					'Destination' => $this->createBaseUri() . $this->encodePath($path2),
537
+					'Destination' => $this->createBaseUri().$this->encodePath($path2),
538 538
 				]
539 539
 			);
540
-			$this->statCache->clear($path1 . '/');
541
-			$this->statCache->clear($path2 . '/');
540
+			$this->statCache->clear($path1.'/');
541
+			$this->statCache->clear($path2.'/');
542 542
 			$this->statCache->set($path1, false);
543 543
 			$this->statCache->set($path2, true);
544 544
 			$this->removeCachedFile($path1);
@@ -559,17 +559,17 @@  discard block
 block discarded – undo
559 559
 			// overwrite directory ?
560 560
 			if ($this->is_dir($path2)) {
561 561
 				// needs trailing slash in destination
562
-				$path2 = rtrim($path2, '/') . '/';
562
+				$path2 = rtrim($path2, '/').'/';
563 563
 			}
564 564
 			$this->client->request(
565 565
 				'COPY',
566 566
 				$this->encodePath($path1),
567 567
 				null,
568 568
 				[
569
-					'Destination' => $this->createBaseUri() . $this->encodePath($path2),
569
+					'Destination' => $this->createBaseUri().$this->encodePath($path2),
570 570
 				]
571 571
 			);
572
-			$this->statCache->clear($path2 . '/');
572
+			$this->statCache->clear($path2.'/');
573 573
 			$this->statCache->set($path2, true);
574 574
 			$this->removeCachedFile($path2);
575 575
 			return true;
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 			}
589 589
 			return [
590 590
 				'mtime' => strtotime($response['{DAV:}getlastmodified']),
591
-				'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
591
+				'size' => (int) isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
592 592
 			];
593 593
 		} catch (\Exception $e) {
594 594
 			$this->convertException($e, $path);
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 			return $response['statusCode'] == $expected;
671 671
 		} catch (ClientHttpException $e) {
672 672
 			if ($e->getHttpStatus() === 404 && $method === 'DELETE') {
673
-				$this->statCache->clear($path . '/');
673
+				$this->statCache->clear($path.'/');
674 674
 				$this->statCache->set($path, false);
675 675
 				return false;
676 676
 			}
@@ -691,22 +691,22 @@  discard block
 block discarded – undo
691 691
 
692 692
 	/** {@inheritdoc} */
693 693
 	public function isUpdatable($path) {
694
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
694
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
695 695
 	}
696 696
 
697 697
 	/** {@inheritdoc} */
698 698
 	public function isCreatable($path) {
699
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
699
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_CREATE);
700 700
 	}
701 701
 
702 702
 	/** {@inheritdoc} */
703 703
 	public function isSharable($path) {
704
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
704
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_SHARE);
705 705
 	}
706 706
 
707 707
 	/** {@inheritdoc} */
708 708
 	public function isDeletable($path) {
709
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
709
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_DELETE);
710 710
 	}
711 711
 
712 712
 	/** {@inheritdoc} */
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 				if (!empty($etag) && $cachedData['etag'] !== $etag) {
800 800
 					return true;
801 801
 				} elseif (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
802
-					$sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions'];
802
+					$sharePermissions = (int) $response['{http://open-collaboration-services.org/ns}share-permissions'];
803 803
 					return $sharePermissions !== $cachedData['permissions'];
804 804
 				} elseif (isset($response['{http://owncloud.org/ns}permissions'])) {
805 805
 					$permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 			if ($e->getHttpStatus() === 405) {
816 816
 				if ($path === '') {
817 817
 					// if root is gone it means the storage is not available
818
-					throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
818
+					throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
819 819
 				}
820 820
 				return false;
821 821
 			}
@@ -850,22 +850,22 @@  discard block
 block discarded – undo
850 850
 			}
851 851
 			if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) {
852 852
 				// either password was changed or was invalid all along
853
-				throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage());
853
+				throw new StorageInvalidException(get_class($e).': '.$e->getMessage());
854 854
 			} elseif ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
855 855
 				// ignore exception for MethodNotAllowed, false will be returned
856 856
 				return;
857 857
 			} elseif ($e->getHttpStatus() === Http::STATUS_FORBIDDEN) {
858 858
 				// The operation is forbidden. Fail somewhat gracefully
859
-				throw new ForbiddenException(get_class($e) . ':' . $e->getMessage(), false);
859
+				throw new ForbiddenException(get_class($e).':'.$e->getMessage(), false);
860 860
 			}
861
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
861
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
862 862
 		} elseif ($e instanceof ClientException) {
863 863
 			// connection timeout or refused, server could be temporarily down
864
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
864
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
865 865
 		} elseif ($e instanceof \InvalidArgumentException) {
866 866
 			// parse error because the server returned HTML instead of XML,
867 867
 			// possibly temporarily down
868
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
868
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
869 869
 		} elseif (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) {
870 870
 			// rethrow
871 871
 			throw $e;
Please login to merge, or discard this patch.
lib/private/Server.php 2 patches
Indentation   +2049 added lines, -2049 removed lines patch added patch discarded remove patch
@@ -247,2058 +247,2058 @@
 block discarded – undo
247 247
  */
248 248
 class Server extends ServerContainer implements IServerContainer {
249 249
 
250
-	/** @var string */
251
-	private $webRoot;
252
-
253
-	/**
254
-	 * @param string $webRoot
255
-	 * @param \OC\Config $config
256
-	 */
257
-	public function __construct($webRoot, \OC\Config $config) {
258
-		parent::__construct();
259
-		$this->webRoot = $webRoot;
260
-
261
-		// To find out if we are running from CLI or not
262
-		$this->registerParameter('isCLI', \OC::$CLI);
263
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
264
-
265
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
266
-			return $c;
267
-		});
268
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
269
-			return $c;
270
-		});
271
-
272
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
273
-		/** @deprecated 19.0.0 */
274
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
275
-
276
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
277
-		/** @deprecated 19.0.0 */
278
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
279
-
280
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
281
-		/** @deprecated 19.0.0 */
282
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
283
-
284
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
285
-		/** @deprecated 19.0.0 */
286
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
287
-
288
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
289
-
290
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
291
-
292
-
293
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
294
-			return new PreviewManager(
295
-				$c->get(\OCP\IConfig::class),
296
-				$c->get(IRootFolder::class),
297
-				new \OC\Preview\Storage\Root(
298
-					$c->get(IRootFolder::class),
299
-					$c->get(SystemConfig::class)
300
-				),
301
-				$c->get(SymfonyAdapter::class),
302
-				$c->get(GeneratorHelper::class),
303
-				$c->get(ISession::class)->get('user_id')
304
-			);
305
-		});
306
-		/** @deprecated 19.0.0 */
307
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
308
-
309
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
310
-			return new \OC\Preview\Watcher(
311
-				new \OC\Preview\Storage\Root(
312
-					$c->get(IRootFolder::class),
313
-					$c->get(SystemConfig::class)
314
-				)
315
-			);
316
-		});
317
-
318
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
319
-			$view = new View();
320
-			$util = new Encryption\Util(
321
-				$view,
322
-				$c->get(IUserManager::class),
323
-				$c->get(IGroupManager::class),
324
-				$c->get(\OCP\IConfig::class)
325
-			);
326
-			return new Encryption\Manager(
327
-				$c->get(\OCP\IConfig::class),
328
-				$c->get(ILogger::class),
329
-				$c->getL10N('core'),
330
-				new View(),
331
-				$util,
332
-				new ArrayCache()
333
-			);
334
-		});
335
-		/** @deprecated 19.0.0 */
336
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
337
-
338
-		$this->registerService('EncryptionFileHelper', function (ContainerInterface $c) {
339
-			$util = new Encryption\Util(
340
-				new View(),
341
-				$c->get(IUserManager::class),
342
-				$c->get(IGroupManager::class),
343
-				$c->get(\OCP\IConfig::class)
344
-			);
345
-			return new Encryption\File(
346
-				$util,
347
-				$c->get(IRootFolder::class),
348
-				$c->get(\OCP\Share\IManager::class)
349
-			);
350
-		});
351
-
352
-		$this->registerService('EncryptionKeyStorage', function (ContainerInterface $c) {
353
-			$view = new View();
354
-			$util = new Encryption\Util(
355
-				$view,
356
-				$c->get(IUserManager::class),
357
-				$c->get(IGroupManager::class),
358
-				$c->get(\OCP\IConfig::class)
359
-			);
360
-
361
-			return new Encryption\Keys\Storage(
362
-				$view,
363
-				$util,
364
-				$c->get(ICrypto::class),
365
-				$c->get(\OCP\IConfig::class)
366
-			);
367
-		});
368
-		/** @deprecated 20.0.0 */
369
-		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
370
-
371
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
372
-		/** @deprecated 19.0.0 */
373
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
374
-
375
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
376
-			/** @var \OCP\IConfig $config */
377
-			$config = $c->get(\OCP\IConfig::class);
378
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
379
-			return new $factoryClass($this);
380
-		});
381
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
382
-			return $c->get('SystemTagManagerFactory')->getManager();
383
-		});
384
-		/** @deprecated 19.0.0 */
385
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
386
-
387
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
388
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
389
-		});
390
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
391
-			$manager = \OC\Files\Filesystem::getMountManager(null);
392
-			$view = new View();
393
-			$root = new Root(
394
-				$manager,
395
-				$view,
396
-				null,
397
-				$c->get(IUserMountCache::class),
398
-				$this->get(ILogger::class),
399
-				$this->get(IUserManager::class)
400
-			);
401
-
402
-			$previewConnector = new \OC\Preview\WatcherConnector(
403
-				$root,
404
-				$c->get(SystemConfig::class)
405
-			);
406
-			$previewConnector->connectWatcher();
407
-
408
-			return $root;
409
-		});
410
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
411
-			return new HookConnector(
412
-				$c->get(IRootFolder::class),
413
-				new View(),
414
-				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
415
-				$c->get(IEventDispatcher::class)
416
-			);
417
-		});
418
-
419
-		/** @deprecated 19.0.0 */
420
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
421
-
422
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
423
-			return new LazyRoot(function () use ($c) {
424
-				return $c->get('RootFolder');
425
-			});
426
-		});
427
-		/** @deprecated 19.0.0 */
428
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
429
-
430
-		/** @deprecated 19.0.0 */
431
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
432
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
433
-
434
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
435
-			$groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class));
436
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
437
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]);
438
-
439
-				/** @var IEventDispatcher $dispatcher */
440
-				$dispatcher = $this->get(IEventDispatcher::class);
441
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
442
-			});
443
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
444
-				\OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]);
445
-
446
-				/** @var IEventDispatcher $dispatcher */
447
-				$dispatcher = $this->get(IEventDispatcher::class);
448
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
449
-			});
450
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
451
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]);
452
-
453
-				/** @var IEventDispatcher $dispatcher */
454
-				$dispatcher = $this->get(IEventDispatcher::class);
455
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
456
-			});
457
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
458
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]);
459
-
460
-				/** @var IEventDispatcher $dispatcher */
461
-				$dispatcher = $this->get(IEventDispatcher::class);
462
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
463
-			});
464
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
465
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]);
466
-
467
-				/** @var IEventDispatcher $dispatcher */
468
-				$dispatcher = $this->get(IEventDispatcher::class);
469
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
470
-			});
471
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
472
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
473
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
474
-				\OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
475
-
476
-				/** @var IEventDispatcher $dispatcher */
477
-				$dispatcher = $this->get(IEventDispatcher::class);
478
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
479
-			});
480
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
481
-				/** @var IEventDispatcher $dispatcher */
482
-				$dispatcher = $this->get(IEventDispatcher::class);
483
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
484
-			});
485
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
486
-				/** @var IEventDispatcher $dispatcher */
487
-				$dispatcher = $this->get(IEventDispatcher::class);
488
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
489
-			});
490
-			return $groupManager;
491
-		});
492
-		/** @deprecated 19.0.0 */
493
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
494
-
495
-		$this->registerService(Store::class, function (ContainerInterface $c) {
496
-			$session = $c->get(ISession::class);
497
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
498
-				$tokenProvider = $c->get(IProvider::class);
499
-			} else {
500
-				$tokenProvider = null;
501
-			}
502
-			$logger = $c->get(LoggerInterface::class);
503
-			return new Store($session, $logger, $tokenProvider);
504
-		});
505
-		$this->registerAlias(IStore::class, Store::class);
506
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
507
-
508
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
509
-			$manager = $c->get(IUserManager::class);
510
-			$session = new \OC\Session\Memory('');
511
-			$timeFactory = new TimeFactory();
512
-			// Token providers might require a working database. This code
513
-			// might however be called when ownCloud is not yet setup.
514
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
515
-				$defaultTokenProvider = $c->get(IProvider::class);
516
-			} else {
517
-				$defaultTokenProvider = null;
518
-			}
519
-
520
-			$legacyDispatcher = $c->get(SymfonyAdapter::class);
521
-
522
-			$userSession = new \OC\User\Session(
523
-				$manager,
524
-				$session,
525
-				$timeFactory,
526
-				$defaultTokenProvider,
527
-				$c->get(\OCP\IConfig::class),
528
-				$c->get(ISecureRandom::class),
529
-				$c->getLockdownManager(),
530
-				$c->get(ILogger::class),
531
-				$c->get(IEventDispatcher::class)
532
-			);
533
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
534
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
535
-
536
-				/** @var IEventDispatcher $dispatcher */
537
-				$dispatcher = $this->get(IEventDispatcher::class);
538
-				$dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
539
-			});
540
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
541
-				/** @var \OC\User\User $user */
542
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
543
-
544
-				/** @var IEventDispatcher $dispatcher */
545
-				$dispatcher = $this->get(IEventDispatcher::class);
546
-				$dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
547
-			});
548
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
549
-				/** @var \OC\User\User $user */
550
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
551
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
552
-
553
-				/** @var IEventDispatcher $dispatcher */
554
-				$dispatcher = $this->get(IEventDispatcher::class);
555
-				$dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
556
-			});
557
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
558
-				/** @var \OC\User\User $user */
559
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
560
-
561
-				/** @var IEventDispatcher $dispatcher */
562
-				$dispatcher = $this->get(IEventDispatcher::class);
563
-				$dispatcher->dispatchTyped(new UserDeletedEvent($user));
564
-			});
565
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
566
-				/** @var \OC\User\User $user */
567
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
568
-
569
-				/** @var IEventDispatcher $dispatcher */
570
-				$dispatcher = $this->get(IEventDispatcher::class);
571
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
572
-			});
573
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
574
-				/** @var \OC\User\User $user */
575
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
576
-
577
-				/** @var IEventDispatcher $dispatcher */
578
-				$dispatcher = $this->get(IEventDispatcher::class);
579
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
580
-			});
581
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
582
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
583
-
584
-				/** @var IEventDispatcher $dispatcher */
585
-				$dispatcher = $this->get(IEventDispatcher::class);
586
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
587
-			});
588
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
589
-				/** @var \OC\User\User $user */
590
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
591
-
592
-				/** @var IEventDispatcher $dispatcher */
593
-				$dispatcher = $this->get(IEventDispatcher::class);
594
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
595
-			});
596
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
597
-				/** @var IEventDispatcher $dispatcher */
598
-				$dispatcher = $this->get(IEventDispatcher::class);
599
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
600
-			});
601
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
602
-				/** @var \OC\User\User $user */
603
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
604
-
605
-				/** @var IEventDispatcher $dispatcher */
606
-				$dispatcher = $this->get(IEventDispatcher::class);
607
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
608
-			});
609
-			$userSession->listen('\OC\User', 'logout', function ($user) {
610
-				\OC_Hook::emit('OC_User', 'logout', []);
611
-
612
-				/** @var IEventDispatcher $dispatcher */
613
-				$dispatcher = $this->get(IEventDispatcher::class);
614
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
615
-			});
616
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
617
-				/** @var IEventDispatcher $dispatcher */
618
-				$dispatcher = $this->get(IEventDispatcher::class);
619
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
620
-			});
621
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
622
-				/** @var \OC\User\User $user */
623
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
624
-
625
-				/** @var IEventDispatcher $dispatcher */
626
-				$dispatcher = $this->get(IEventDispatcher::class);
627
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
628
-			});
629
-			return $userSession;
630
-		});
631
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
632
-		/** @deprecated 19.0.0 */
633
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
634
-
635
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
636
-
637
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
638
-		/** @deprecated 19.0.0 */
639
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
640
-
641
-		/** @deprecated 19.0.0 */
642
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
643
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
644
-
645
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
646
-			return new \OC\SystemConfig($config);
647
-		});
648
-		/** @deprecated 19.0.0 */
649
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
650
-
651
-		/** @deprecated 19.0.0 */
652
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
653
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
654
-
655
-		$this->registerService(IFactory::class, function (Server $c) {
656
-			return new \OC\L10N\Factory(
657
-				$c->get(\OCP\IConfig::class),
658
-				$c->getRequest(),
659
-				$c->get(IUserSession::class),
660
-				\OC::$SERVERROOT
661
-			);
662
-		});
663
-		/** @deprecated 19.0.0 */
664
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
665
-
666
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
667
-		/** @deprecated 19.0.0 */
668
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
669
-
670
-		/** @deprecated 19.0.0 */
671
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
672
-		/** @deprecated 19.0.0 */
673
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
674
-
675
-		$this->registerService(ICache::class, function ($c) {
676
-			return new Cache\File();
677
-		});
678
-		/** @deprecated 19.0.0 */
679
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
680
-
681
-		$this->registerService(Factory::class, function (Server $c) {
682
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class),
683
-				ArrayCache::class,
684
-				ArrayCache::class,
685
-				ArrayCache::class
686
-			);
687
-			/** @var \OCP\IConfig $config */
688
-			$config = $c->get(\OCP\IConfig::class);
689
-
690
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
691
-				$v = \OC_App::getAppVersions();
692
-				$v['core'] = implode(',', \OC_Util::getVersion());
693
-				$version = implode(',', $v);
694
-				$instanceId = \OC_Util::getInstanceId();
695
-				$path = \OC::$SERVERROOT;
696
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
697
-				return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class),
698
-					$config->getSystemValue('memcache.local', null),
699
-					$config->getSystemValue('memcache.distributed', null),
700
-					$config->getSystemValue('memcache.locking', null)
701
-				);
702
-			}
703
-			return $arrayCacheFactory;
704
-		});
705
-		/** @deprecated 19.0.0 */
706
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
707
-		$this->registerAlias(ICacheFactory::class, Factory::class);
708
-
709
-		$this->registerService('RedisFactory', function (Server $c) {
710
-			$systemConfig = $c->get(SystemConfig::class);
711
-			return new RedisFactory($systemConfig);
712
-		});
713
-
714
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
715
-			$l10n = $this->get(IFactory::class)->get('lib');
716
-			return new \OC\Activity\Manager(
717
-				$c->getRequest(),
718
-				$c->get(IUserSession::class),
719
-				$c->get(\OCP\IConfig::class),
720
-				$c->get(IValidator::class),
721
-				$l10n
722
-			);
723
-		});
724
-		/** @deprecated 19.0.0 */
725
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
726
-
727
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
728
-			return new \OC\Activity\EventMerger(
729
-				$c->getL10N('lib')
730
-			);
731
-		});
732
-		$this->registerAlias(IValidator::class, Validator::class);
733
-
734
-		$this->registerService(AvatarManager::class, function (Server $c) {
735
-			return new AvatarManager(
736
-				$c->get(\OC\User\Manager::class),
737
-				$c->getAppDataDir('avatar'),
738
-				$c->getL10N('lib'),
739
-				$c->get(ILogger::class),
740
-				$c->get(\OCP\IConfig::class)
741
-			);
742
-		});
743
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
744
-		/** @deprecated 19.0.0 */
745
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
746
-
747
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
748
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
749
-
750
-		$this->registerService(\OC\Log::class, function (Server $c) {
751
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
752
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
753
-			$logger = $factory->get($logType);
754
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
755
-
756
-			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
757
-		});
758
-		$this->registerAlias(ILogger::class, \OC\Log::class);
759
-		/** @deprecated 19.0.0 */
760
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
761
-		// PSR-3 logger
762
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
763
-
764
-		$this->registerService(ILogFactory::class, function (Server $c) {
765
-			return new LogFactory($c, $this->get(SystemConfig::class));
766
-		});
767
-
768
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
769
-		/** @deprecated 19.0.0 */
770
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
771
-
772
-		$this->registerService(IRouter::class, function (Server $c) {
773
-			$cacheFactory = $c->get(ICacheFactory::class);
774
-			$logger = $c->get(ILogger::class);
775
-			if ($cacheFactory->isLocalCacheAvailable()) {
776
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
777
-			} else {
778
-				$router = new \OC\Route\Router($logger);
779
-			}
780
-			return $router;
781
-		});
782
-		/** @deprecated 19.0.0 */
783
-		$this->registerDeprecatedAlias('Router', IRouter::class);
784
-
785
-		$this->registerAlias(ISearch::class, Search::class);
786
-		/** @deprecated 19.0.0 */
787
-		$this->registerDeprecatedAlias('Search', ISearch::class);
788
-
789
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
790
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
791
-				$this->get(ICacheFactory::class),
792
-				new \OC\AppFramework\Utility\TimeFactory()
793
-			);
794
-		});
795
-
796
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
797
-		/** @deprecated 19.0.0 */
798
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
799
-
800
-		$this->registerAlias(ICrypto::class, Crypto::class);
801
-		/** @deprecated 19.0.0 */
802
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
803
-
804
-		$this->registerAlias(IHasher::class, Hasher::class);
805
-		/** @deprecated 19.0.0 */
806
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
807
-
808
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
809
-		/** @deprecated 19.0.0 */
810
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
811
-
812
-		$this->registerService(IDBConnection::class, function (Server $c) {
813
-			$systemConfig = $c->get(SystemConfig::class);
814
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
815
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
816
-			if (!$factory->isValidType($type)) {
817
-				throw new \OC\DatabaseException('Invalid database type');
818
-			}
819
-			$connectionParams = $factory->createConnectionParams();
820
-			$connection = $factory->getConnection($type, $connectionParams);
821
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
822
-			return $connection;
823
-		});
824
-		/** @deprecated 19.0.0 */
825
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
826
-
827
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
828
-		$this->registerAlias(IClientService::class, ClientService::class);
829
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
830
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
831
-			$eventLogger = new EventLogger();
832
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
833
-				// In debug mode, module is being activated by default
834
-				$eventLogger->activate();
835
-			}
836
-			return $eventLogger;
837
-		});
838
-		/** @deprecated 19.0.0 */
839
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
840
-
841
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
842
-			$queryLogger = new QueryLogger();
843
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
844
-				// In debug mode, module is being activated by default
845
-				$queryLogger->activate();
846
-			}
847
-			return $queryLogger;
848
-		});
849
-		/** @deprecated 19.0.0 */
850
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
851
-
852
-		/** @deprecated 19.0.0 */
853
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
854
-		$this->registerAlias(ITempManager::class, TempManager::class);
855
-
856
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
857
-			// TODO: use auto-wiring
858
-			return new \OC\App\AppManager(
859
-				$c->get(IUserSession::class),
860
-				$c->get(\OCP\IConfig::class),
861
-				$c->get(\OC\AppConfig::class),
862
-				$c->get(IGroupManager::class),
863
-				$c->get(ICacheFactory::class),
864
-				$c->get(SymfonyAdapter::class),
865
-				$c->get(ILogger::class)
866
-			);
867
-		});
868
-		/** @deprecated 19.0.0 */
869
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
870
-		$this->registerAlias(IAppManager::class, AppManager::class);
871
-
872
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
873
-		/** @deprecated 19.0.0 */
874
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
875
-
876
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
877
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
878
-
879
-			return new DateTimeFormatter(
880
-				$c->get(IDateTimeZone::class)->getTimeZone(),
881
-				$c->getL10N('lib', $language)
882
-			);
883
-		});
884
-		/** @deprecated 19.0.0 */
885
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
886
-
887
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
888
-			$mountCache = new UserMountCache(
889
-				$c->get(IDBConnection::class),
890
-				$c->get(IUserManager::class),
891
-				$c->get(ILogger::class)
892
-			);
893
-			$listener = new UserMountCacheListener($mountCache);
894
-			$listener->listen($c->get(IUserManager::class));
895
-			return $mountCache;
896
-		});
897
-		/** @deprecated 19.0.0 */
898
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
899
-
900
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
901
-			$loader = \OC\Files\Filesystem::getLoader();
902
-			$mountCache = $c->get(IUserMountCache::class);
903
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
904
-
905
-			// builtin providers
906
-
907
-			$config = $c->get(\OCP\IConfig::class);
908
-			$logger = $c->get(ILogger::class);
909
-			$manager->registerProvider(new CacheMountProvider($config));
910
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
911
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
912
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
913
-
914
-			return $manager;
915
-		});
916
-		/** @deprecated 19.0.0 */
917
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
918
-
919
-		/** @deprecated 20.0.0 */
920
-		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
921
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
922
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
923
-			if ($busClass) {
924
-				[$app, $class] = explode('::', $busClass, 2);
925
-				if ($c->get(IAppManager::class)->isInstalled($app)) {
926
-					\OC_App::loadApp($app);
927
-					return $c->get($class);
928
-				} else {
929
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
930
-				}
931
-			} else {
932
-				$jobList = $c->get(IJobList::class);
933
-				return new CronBus($jobList);
934
-			}
935
-		});
936
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
937
-		/** @deprecated 20.0.0 */
938
-		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
939
-		/** @deprecated 19.0.0 */
940
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
941
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
942
-			// IConfig and IAppManager requires a working database. This code
943
-			// might however be called when ownCloud is not yet setup.
944
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
945
-				$config = $c->get(\OCP\IConfig::class);
946
-				$appManager = $c->get(IAppManager::class);
947
-			} else {
948
-				$config = null;
949
-				$appManager = null;
950
-			}
951
-
952
-			return new Checker(
953
-				new EnvironmentHelper(),
954
-				new FileAccessHelper(),
955
-				new AppLocator(),
956
-				$config,
957
-				$c->get(ICacheFactory::class),
958
-				$appManager,
959
-				$c->get(ITempManager::class),
960
-				$c->get(IMimeTypeDetector::class)
961
-			);
962
-		});
963
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
964
-			if (isset($this['urlParams'])) {
965
-				$urlParams = $this['urlParams'];
966
-			} else {
967
-				$urlParams = [];
968
-			}
969
-
970
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
971
-				&& in_array('fakeinput', stream_get_wrappers())
972
-			) {
973
-				$stream = 'fakeinput://data';
974
-			} else {
975
-				$stream = 'php://input';
976
-			}
977
-
978
-			return new Request(
979
-				[
980
-					'get' => $_GET,
981
-					'post' => $_POST,
982
-					'files' => $_FILES,
983
-					'server' => $_SERVER,
984
-					'env' => $_ENV,
985
-					'cookies' => $_COOKIE,
986
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
987
-						? $_SERVER['REQUEST_METHOD']
988
-						: '',
989
-					'urlParams' => $urlParams,
990
-				],
991
-				$this->get(ISecureRandom::class),
992
-				$this->get(\OCP\IConfig::class),
993
-				$this->get(CsrfTokenManager::class),
994
-				$stream
995
-			);
996
-		});
997
-		/** @deprecated 19.0.0 */
998
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
999
-
1000
-		$this->registerService(IMailer::class, function (Server $c) {
1001
-			return new Mailer(
1002
-				$c->get(\OCP\IConfig::class),
1003
-				$c->get(ILogger::class),
1004
-				$c->get(Defaults::class),
1005
-				$c->get(IURLGenerator::class),
1006
-				$c->getL10N('lib'),
1007
-				$c->get(IEventDispatcher::class),
1008
-				$c->get(IFactory::class)
1009
-			);
1010
-		});
1011
-		/** @deprecated 19.0.0 */
1012
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1013
-
1014
-		$this->registerService('LDAPProvider', function (ContainerInterface $c) {
1015
-			$config = $c->get(\OCP\IConfig::class);
1016
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1017
-			if (is_null($factoryClass)) {
1018
-				throw new \Exception('ldapProviderFactory not set');
1019
-			}
1020
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1021
-			$factory = new $factoryClass($this);
1022
-			return $factory->getLDAPProvider();
1023
-		});
1024
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1025
-			$ini = $c->get(IniGetWrapper::class);
1026
-			$config = $c->get(\OCP\IConfig::class);
1027
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1028
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1029
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1030
-				$memcacheFactory = $c->get(ICacheFactory::class);
1031
-				$memcache = $memcacheFactory->createLocking('lock');
1032
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1033
-					return new MemcacheLockingProvider($memcache, $ttl);
1034
-				}
1035
-				return new DBLockingProvider(
1036
-					$c->get(IDBConnection::class),
1037
-					$c->get(ILogger::class),
1038
-					new TimeFactory(),
1039
-					$ttl,
1040
-					!\OC::$CLI
1041
-				);
1042
-			}
1043
-			return new NoopLockingProvider();
1044
-		});
1045
-		/** @deprecated 19.0.0 */
1046
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1047
-
1048
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1049
-		/** @deprecated 19.0.0 */
1050
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1051
-
1052
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1053
-			return new \OC\Files\Type\Detection(
1054
-				$c->get(IURLGenerator::class),
1055
-				$c->get(ILogger::class),
1056
-				\OC::$configDir,
1057
-				\OC::$SERVERROOT . '/resources/config/'
1058
-			);
1059
-		});
1060
-		/** @deprecated 19.0.0 */
1061
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1062
-
1063
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1064
-		/** @deprecated 19.0.0 */
1065
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1066
-		$this->registerService(BundleFetcher::class, function () {
1067
-			return new BundleFetcher($this->getL10N('lib'));
1068
-		});
1069
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1070
-		/** @deprecated 19.0.0 */
1071
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1072
-
1073
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1074
-			$manager = new CapabilitiesManager($c->get(ILogger::class));
1075
-			$manager->registerCapability(function () use ($c) {
1076
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1077
-			});
1078
-			$manager->registerCapability(function () use ($c) {
1079
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1080
-			});
1081
-			return $manager;
1082
-		});
1083
-		/** @deprecated 19.0.0 */
1084
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1085
-
1086
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1087
-			$config = $c->get(\OCP\IConfig::class);
1088
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1089
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1090
-			$factory = new $factoryClass($this);
1091
-			$manager = $factory->getManager();
1092
-
1093
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1094
-				$manager = $c->get(IUserManager::class);
1095
-				$user = $manager->get($id);
1096
-				if (is_null($user)) {
1097
-					$l = $c->getL10N('core');
1098
-					$displayName = $l->t('Unknown user');
1099
-				} else {
1100
-					$displayName = $user->getDisplayName();
1101
-				}
1102
-				return $displayName;
1103
-			});
1104
-
1105
-			return $manager;
1106
-		});
1107
-		/** @deprecated 19.0.0 */
1108
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1109
-
1110
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1111
-		$this->registerService('ThemingDefaults', function (Server $c) {
1112
-			/*
250
+    /** @var string */
251
+    private $webRoot;
252
+
253
+    /**
254
+     * @param string $webRoot
255
+     * @param \OC\Config $config
256
+     */
257
+    public function __construct($webRoot, \OC\Config $config) {
258
+        parent::__construct();
259
+        $this->webRoot = $webRoot;
260
+
261
+        // To find out if we are running from CLI or not
262
+        $this->registerParameter('isCLI', \OC::$CLI);
263
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
264
+
265
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
266
+            return $c;
267
+        });
268
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
269
+            return $c;
270
+        });
271
+
272
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
273
+        /** @deprecated 19.0.0 */
274
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
275
+
276
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
277
+        /** @deprecated 19.0.0 */
278
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
279
+
280
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
281
+        /** @deprecated 19.0.0 */
282
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
283
+
284
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
285
+        /** @deprecated 19.0.0 */
286
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
287
+
288
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
289
+
290
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
291
+
292
+
293
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
294
+            return new PreviewManager(
295
+                $c->get(\OCP\IConfig::class),
296
+                $c->get(IRootFolder::class),
297
+                new \OC\Preview\Storage\Root(
298
+                    $c->get(IRootFolder::class),
299
+                    $c->get(SystemConfig::class)
300
+                ),
301
+                $c->get(SymfonyAdapter::class),
302
+                $c->get(GeneratorHelper::class),
303
+                $c->get(ISession::class)->get('user_id')
304
+            );
305
+        });
306
+        /** @deprecated 19.0.0 */
307
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
308
+
309
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
310
+            return new \OC\Preview\Watcher(
311
+                new \OC\Preview\Storage\Root(
312
+                    $c->get(IRootFolder::class),
313
+                    $c->get(SystemConfig::class)
314
+                )
315
+            );
316
+        });
317
+
318
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
319
+            $view = new View();
320
+            $util = new Encryption\Util(
321
+                $view,
322
+                $c->get(IUserManager::class),
323
+                $c->get(IGroupManager::class),
324
+                $c->get(\OCP\IConfig::class)
325
+            );
326
+            return new Encryption\Manager(
327
+                $c->get(\OCP\IConfig::class),
328
+                $c->get(ILogger::class),
329
+                $c->getL10N('core'),
330
+                new View(),
331
+                $util,
332
+                new ArrayCache()
333
+            );
334
+        });
335
+        /** @deprecated 19.0.0 */
336
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
337
+
338
+        $this->registerService('EncryptionFileHelper', function (ContainerInterface $c) {
339
+            $util = new Encryption\Util(
340
+                new View(),
341
+                $c->get(IUserManager::class),
342
+                $c->get(IGroupManager::class),
343
+                $c->get(\OCP\IConfig::class)
344
+            );
345
+            return new Encryption\File(
346
+                $util,
347
+                $c->get(IRootFolder::class),
348
+                $c->get(\OCP\Share\IManager::class)
349
+            );
350
+        });
351
+
352
+        $this->registerService('EncryptionKeyStorage', function (ContainerInterface $c) {
353
+            $view = new View();
354
+            $util = new Encryption\Util(
355
+                $view,
356
+                $c->get(IUserManager::class),
357
+                $c->get(IGroupManager::class),
358
+                $c->get(\OCP\IConfig::class)
359
+            );
360
+
361
+            return new Encryption\Keys\Storage(
362
+                $view,
363
+                $util,
364
+                $c->get(ICrypto::class),
365
+                $c->get(\OCP\IConfig::class)
366
+            );
367
+        });
368
+        /** @deprecated 20.0.0 */
369
+        $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
370
+
371
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
372
+        /** @deprecated 19.0.0 */
373
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
374
+
375
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
376
+            /** @var \OCP\IConfig $config */
377
+            $config = $c->get(\OCP\IConfig::class);
378
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
379
+            return new $factoryClass($this);
380
+        });
381
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
382
+            return $c->get('SystemTagManagerFactory')->getManager();
383
+        });
384
+        /** @deprecated 19.0.0 */
385
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
386
+
387
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
388
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
389
+        });
390
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
391
+            $manager = \OC\Files\Filesystem::getMountManager(null);
392
+            $view = new View();
393
+            $root = new Root(
394
+                $manager,
395
+                $view,
396
+                null,
397
+                $c->get(IUserMountCache::class),
398
+                $this->get(ILogger::class),
399
+                $this->get(IUserManager::class)
400
+            );
401
+
402
+            $previewConnector = new \OC\Preview\WatcherConnector(
403
+                $root,
404
+                $c->get(SystemConfig::class)
405
+            );
406
+            $previewConnector->connectWatcher();
407
+
408
+            return $root;
409
+        });
410
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
411
+            return new HookConnector(
412
+                $c->get(IRootFolder::class),
413
+                new View(),
414
+                $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
415
+                $c->get(IEventDispatcher::class)
416
+            );
417
+        });
418
+
419
+        /** @deprecated 19.0.0 */
420
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
421
+
422
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
423
+            return new LazyRoot(function () use ($c) {
424
+                return $c->get('RootFolder');
425
+            });
426
+        });
427
+        /** @deprecated 19.0.0 */
428
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
429
+
430
+        /** @deprecated 19.0.0 */
431
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
432
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
433
+
434
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
435
+            $groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class));
436
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
437
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]);
438
+
439
+                /** @var IEventDispatcher $dispatcher */
440
+                $dispatcher = $this->get(IEventDispatcher::class);
441
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
442
+            });
443
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
444
+                \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]);
445
+
446
+                /** @var IEventDispatcher $dispatcher */
447
+                $dispatcher = $this->get(IEventDispatcher::class);
448
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
449
+            });
450
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
451
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]);
452
+
453
+                /** @var IEventDispatcher $dispatcher */
454
+                $dispatcher = $this->get(IEventDispatcher::class);
455
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
456
+            });
457
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
458
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]);
459
+
460
+                /** @var IEventDispatcher $dispatcher */
461
+                $dispatcher = $this->get(IEventDispatcher::class);
462
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
463
+            });
464
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
465
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]);
466
+
467
+                /** @var IEventDispatcher $dispatcher */
468
+                $dispatcher = $this->get(IEventDispatcher::class);
469
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
470
+            });
471
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
472
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
473
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
474
+                \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
475
+
476
+                /** @var IEventDispatcher $dispatcher */
477
+                $dispatcher = $this->get(IEventDispatcher::class);
478
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
479
+            });
480
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
481
+                /** @var IEventDispatcher $dispatcher */
482
+                $dispatcher = $this->get(IEventDispatcher::class);
483
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
484
+            });
485
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
486
+                /** @var IEventDispatcher $dispatcher */
487
+                $dispatcher = $this->get(IEventDispatcher::class);
488
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
489
+            });
490
+            return $groupManager;
491
+        });
492
+        /** @deprecated 19.0.0 */
493
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
494
+
495
+        $this->registerService(Store::class, function (ContainerInterface $c) {
496
+            $session = $c->get(ISession::class);
497
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
498
+                $tokenProvider = $c->get(IProvider::class);
499
+            } else {
500
+                $tokenProvider = null;
501
+            }
502
+            $logger = $c->get(LoggerInterface::class);
503
+            return new Store($session, $logger, $tokenProvider);
504
+        });
505
+        $this->registerAlias(IStore::class, Store::class);
506
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
507
+
508
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
509
+            $manager = $c->get(IUserManager::class);
510
+            $session = new \OC\Session\Memory('');
511
+            $timeFactory = new TimeFactory();
512
+            // Token providers might require a working database. This code
513
+            // might however be called when ownCloud is not yet setup.
514
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
515
+                $defaultTokenProvider = $c->get(IProvider::class);
516
+            } else {
517
+                $defaultTokenProvider = null;
518
+            }
519
+
520
+            $legacyDispatcher = $c->get(SymfonyAdapter::class);
521
+
522
+            $userSession = new \OC\User\Session(
523
+                $manager,
524
+                $session,
525
+                $timeFactory,
526
+                $defaultTokenProvider,
527
+                $c->get(\OCP\IConfig::class),
528
+                $c->get(ISecureRandom::class),
529
+                $c->getLockdownManager(),
530
+                $c->get(ILogger::class),
531
+                $c->get(IEventDispatcher::class)
532
+            );
533
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
534
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
535
+
536
+                /** @var IEventDispatcher $dispatcher */
537
+                $dispatcher = $this->get(IEventDispatcher::class);
538
+                $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
539
+            });
540
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
541
+                /** @var \OC\User\User $user */
542
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
543
+
544
+                /** @var IEventDispatcher $dispatcher */
545
+                $dispatcher = $this->get(IEventDispatcher::class);
546
+                $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
547
+            });
548
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
549
+                /** @var \OC\User\User $user */
550
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
551
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
552
+
553
+                /** @var IEventDispatcher $dispatcher */
554
+                $dispatcher = $this->get(IEventDispatcher::class);
555
+                $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
556
+            });
557
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
558
+                /** @var \OC\User\User $user */
559
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
560
+
561
+                /** @var IEventDispatcher $dispatcher */
562
+                $dispatcher = $this->get(IEventDispatcher::class);
563
+                $dispatcher->dispatchTyped(new UserDeletedEvent($user));
564
+            });
565
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
566
+                /** @var \OC\User\User $user */
567
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
568
+
569
+                /** @var IEventDispatcher $dispatcher */
570
+                $dispatcher = $this->get(IEventDispatcher::class);
571
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
572
+            });
573
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
574
+                /** @var \OC\User\User $user */
575
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
576
+
577
+                /** @var IEventDispatcher $dispatcher */
578
+                $dispatcher = $this->get(IEventDispatcher::class);
579
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
580
+            });
581
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
582
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
583
+
584
+                /** @var IEventDispatcher $dispatcher */
585
+                $dispatcher = $this->get(IEventDispatcher::class);
586
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
587
+            });
588
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
589
+                /** @var \OC\User\User $user */
590
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
591
+
592
+                /** @var IEventDispatcher $dispatcher */
593
+                $dispatcher = $this->get(IEventDispatcher::class);
594
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
595
+            });
596
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
597
+                /** @var IEventDispatcher $dispatcher */
598
+                $dispatcher = $this->get(IEventDispatcher::class);
599
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
600
+            });
601
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
602
+                /** @var \OC\User\User $user */
603
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
604
+
605
+                /** @var IEventDispatcher $dispatcher */
606
+                $dispatcher = $this->get(IEventDispatcher::class);
607
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
608
+            });
609
+            $userSession->listen('\OC\User', 'logout', function ($user) {
610
+                \OC_Hook::emit('OC_User', 'logout', []);
611
+
612
+                /** @var IEventDispatcher $dispatcher */
613
+                $dispatcher = $this->get(IEventDispatcher::class);
614
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
615
+            });
616
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
617
+                /** @var IEventDispatcher $dispatcher */
618
+                $dispatcher = $this->get(IEventDispatcher::class);
619
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
620
+            });
621
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
622
+                /** @var \OC\User\User $user */
623
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
624
+
625
+                /** @var IEventDispatcher $dispatcher */
626
+                $dispatcher = $this->get(IEventDispatcher::class);
627
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
628
+            });
629
+            return $userSession;
630
+        });
631
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
632
+        /** @deprecated 19.0.0 */
633
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
634
+
635
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
636
+
637
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
638
+        /** @deprecated 19.0.0 */
639
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
640
+
641
+        /** @deprecated 19.0.0 */
642
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
643
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
644
+
645
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
646
+            return new \OC\SystemConfig($config);
647
+        });
648
+        /** @deprecated 19.0.0 */
649
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
650
+
651
+        /** @deprecated 19.0.0 */
652
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
653
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
654
+
655
+        $this->registerService(IFactory::class, function (Server $c) {
656
+            return new \OC\L10N\Factory(
657
+                $c->get(\OCP\IConfig::class),
658
+                $c->getRequest(),
659
+                $c->get(IUserSession::class),
660
+                \OC::$SERVERROOT
661
+            );
662
+        });
663
+        /** @deprecated 19.0.0 */
664
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
665
+
666
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
667
+        /** @deprecated 19.0.0 */
668
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
669
+
670
+        /** @deprecated 19.0.0 */
671
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
672
+        /** @deprecated 19.0.0 */
673
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
674
+
675
+        $this->registerService(ICache::class, function ($c) {
676
+            return new Cache\File();
677
+        });
678
+        /** @deprecated 19.0.0 */
679
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
680
+
681
+        $this->registerService(Factory::class, function (Server $c) {
682
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class),
683
+                ArrayCache::class,
684
+                ArrayCache::class,
685
+                ArrayCache::class
686
+            );
687
+            /** @var \OCP\IConfig $config */
688
+            $config = $c->get(\OCP\IConfig::class);
689
+
690
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
691
+                $v = \OC_App::getAppVersions();
692
+                $v['core'] = implode(',', \OC_Util::getVersion());
693
+                $version = implode(',', $v);
694
+                $instanceId = \OC_Util::getInstanceId();
695
+                $path = \OC::$SERVERROOT;
696
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
697
+                return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class),
698
+                    $config->getSystemValue('memcache.local', null),
699
+                    $config->getSystemValue('memcache.distributed', null),
700
+                    $config->getSystemValue('memcache.locking', null)
701
+                );
702
+            }
703
+            return $arrayCacheFactory;
704
+        });
705
+        /** @deprecated 19.0.0 */
706
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
707
+        $this->registerAlias(ICacheFactory::class, Factory::class);
708
+
709
+        $this->registerService('RedisFactory', function (Server $c) {
710
+            $systemConfig = $c->get(SystemConfig::class);
711
+            return new RedisFactory($systemConfig);
712
+        });
713
+
714
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
715
+            $l10n = $this->get(IFactory::class)->get('lib');
716
+            return new \OC\Activity\Manager(
717
+                $c->getRequest(),
718
+                $c->get(IUserSession::class),
719
+                $c->get(\OCP\IConfig::class),
720
+                $c->get(IValidator::class),
721
+                $l10n
722
+            );
723
+        });
724
+        /** @deprecated 19.0.0 */
725
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
726
+
727
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
728
+            return new \OC\Activity\EventMerger(
729
+                $c->getL10N('lib')
730
+            );
731
+        });
732
+        $this->registerAlias(IValidator::class, Validator::class);
733
+
734
+        $this->registerService(AvatarManager::class, function (Server $c) {
735
+            return new AvatarManager(
736
+                $c->get(\OC\User\Manager::class),
737
+                $c->getAppDataDir('avatar'),
738
+                $c->getL10N('lib'),
739
+                $c->get(ILogger::class),
740
+                $c->get(\OCP\IConfig::class)
741
+            );
742
+        });
743
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
744
+        /** @deprecated 19.0.0 */
745
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
746
+
747
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
748
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
749
+
750
+        $this->registerService(\OC\Log::class, function (Server $c) {
751
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
752
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
753
+            $logger = $factory->get($logType);
754
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
755
+
756
+            return new Log($logger, $this->get(SystemConfig::class), null, $registry);
757
+        });
758
+        $this->registerAlias(ILogger::class, \OC\Log::class);
759
+        /** @deprecated 19.0.0 */
760
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
761
+        // PSR-3 logger
762
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
763
+
764
+        $this->registerService(ILogFactory::class, function (Server $c) {
765
+            return new LogFactory($c, $this->get(SystemConfig::class));
766
+        });
767
+
768
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
769
+        /** @deprecated 19.0.0 */
770
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
771
+
772
+        $this->registerService(IRouter::class, function (Server $c) {
773
+            $cacheFactory = $c->get(ICacheFactory::class);
774
+            $logger = $c->get(ILogger::class);
775
+            if ($cacheFactory->isLocalCacheAvailable()) {
776
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
777
+            } else {
778
+                $router = new \OC\Route\Router($logger);
779
+            }
780
+            return $router;
781
+        });
782
+        /** @deprecated 19.0.0 */
783
+        $this->registerDeprecatedAlias('Router', IRouter::class);
784
+
785
+        $this->registerAlias(ISearch::class, Search::class);
786
+        /** @deprecated 19.0.0 */
787
+        $this->registerDeprecatedAlias('Search', ISearch::class);
788
+
789
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
790
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
791
+                $this->get(ICacheFactory::class),
792
+                new \OC\AppFramework\Utility\TimeFactory()
793
+            );
794
+        });
795
+
796
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
797
+        /** @deprecated 19.0.0 */
798
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
799
+
800
+        $this->registerAlias(ICrypto::class, Crypto::class);
801
+        /** @deprecated 19.0.0 */
802
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
803
+
804
+        $this->registerAlias(IHasher::class, Hasher::class);
805
+        /** @deprecated 19.0.0 */
806
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
807
+
808
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
809
+        /** @deprecated 19.0.0 */
810
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
811
+
812
+        $this->registerService(IDBConnection::class, function (Server $c) {
813
+            $systemConfig = $c->get(SystemConfig::class);
814
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
815
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
816
+            if (!$factory->isValidType($type)) {
817
+                throw new \OC\DatabaseException('Invalid database type');
818
+            }
819
+            $connectionParams = $factory->createConnectionParams();
820
+            $connection = $factory->getConnection($type, $connectionParams);
821
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
822
+            return $connection;
823
+        });
824
+        /** @deprecated 19.0.0 */
825
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
826
+
827
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
828
+        $this->registerAlias(IClientService::class, ClientService::class);
829
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
830
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
831
+            $eventLogger = new EventLogger();
832
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
833
+                // In debug mode, module is being activated by default
834
+                $eventLogger->activate();
835
+            }
836
+            return $eventLogger;
837
+        });
838
+        /** @deprecated 19.0.0 */
839
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
840
+
841
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
842
+            $queryLogger = new QueryLogger();
843
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
844
+                // In debug mode, module is being activated by default
845
+                $queryLogger->activate();
846
+            }
847
+            return $queryLogger;
848
+        });
849
+        /** @deprecated 19.0.0 */
850
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
851
+
852
+        /** @deprecated 19.0.0 */
853
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
854
+        $this->registerAlias(ITempManager::class, TempManager::class);
855
+
856
+        $this->registerService(AppManager::class, function (ContainerInterface $c) {
857
+            // TODO: use auto-wiring
858
+            return new \OC\App\AppManager(
859
+                $c->get(IUserSession::class),
860
+                $c->get(\OCP\IConfig::class),
861
+                $c->get(\OC\AppConfig::class),
862
+                $c->get(IGroupManager::class),
863
+                $c->get(ICacheFactory::class),
864
+                $c->get(SymfonyAdapter::class),
865
+                $c->get(ILogger::class)
866
+            );
867
+        });
868
+        /** @deprecated 19.0.0 */
869
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
870
+        $this->registerAlias(IAppManager::class, AppManager::class);
871
+
872
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
873
+        /** @deprecated 19.0.0 */
874
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
875
+
876
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
877
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
878
+
879
+            return new DateTimeFormatter(
880
+                $c->get(IDateTimeZone::class)->getTimeZone(),
881
+                $c->getL10N('lib', $language)
882
+            );
883
+        });
884
+        /** @deprecated 19.0.0 */
885
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
886
+
887
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
888
+            $mountCache = new UserMountCache(
889
+                $c->get(IDBConnection::class),
890
+                $c->get(IUserManager::class),
891
+                $c->get(ILogger::class)
892
+            );
893
+            $listener = new UserMountCacheListener($mountCache);
894
+            $listener->listen($c->get(IUserManager::class));
895
+            return $mountCache;
896
+        });
897
+        /** @deprecated 19.0.0 */
898
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
899
+
900
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
901
+            $loader = \OC\Files\Filesystem::getLoader();
902
+            $mountCache = $c->get(IUserMountCache::class);
903
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
904
+
905
+            // builtin providers
906
+
907
+            $config = $c->get(\OCP\IConfig::class);
908
+            $logger = $c->get(ILogger::class);
909
+            $manager->registerProvider(new CacheMountProvider($config));
910
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
911
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
912
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
913
+
914
+            return $manager;
915
+        });
916
+        /** @deprecated 19.0.0 */
917
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
918
+
919
+        /** @deprecated 20.0.0 */
920
+        $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
921
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
922
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
923
+            if ($busClass) {
924
+                [$app, $class] = explode('::', $busClass, 2);
925
+                if ($c->get(IAppManager::class)->isInstalled($app)) {
926
+                    \OC_App::loadApp($app);
927
+                    return $c->get($class);
928
+                } else {
929
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
930
+                }
931
+            } else {
932
+                $jobList = $c->get(IJobList::class);
933
+                return new CronBus($jobList);
934
+            }
935
+        });
936
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
937
+        /** @deprecated 20.0.0 */
938
+        $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
939
+        /** @deprecated 19.0.0 */
940
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
941
+        $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
942
+            // IConfig and IAppManager requires a working database. This code
943
+            // might however be called when ownCloud is not yet setup.
944
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
945
+                $config = $c->get(\OCP\IConfig::class);
946
+                $appManager = $c->get(IAppManager::class);
947
+            } else {
948
+                $config = null;
949
+                $appManager = null;
950
+            }
951
+
952
+            return new Checker(
953
+                new EnvironmentHelper(),
954
+                new FileAccessHelper(),
955
+                new AppLocator(),
956
+                $config,
957
+                $c->get(ICacheFactory::class),
958
+                $appManager,
959
+                $c->get(ITempManager::class),
960
+                $c->get(IMimeTypeDetector::class)
961
+            );
962
+        });
963
+        $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
964
+            if (isset($this['urlParams'])) {
965
+                $urlParams = $this['urlParams'];
966
+            } else {
967
+                $urlParams = [];
968
+            }
969
+
970
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
971
+                && in_array('fakeinput', stream_get_wrappers())
972
+            ) {
973
+                $stream = 'fakeinput://data';
974
+            } else {
975
+                $stream = 'php://input';
976
+            }
977
+
978
+            return new Request(
979
+                [
980
+                    'get' => $_GET,
981
+                    'post' => $_POST,
982
+                    'files' => $_FILES,
983
+                    'server' => $_SERVER,
984
+                    'env' => $_ENV,
985
+                    'cookies' => $_COOKIE,
986
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
987
+                        ? $_SERVER['REQUEST_METHOD']
988
+                        : '',
989
+                    'urlParams' => $urlParams,
990
+                ],
991
+                $this->get(ISecureRandom::class),
992
+                $this->get(\OCP\IConfig::class),
993
+                $this->get(CsrfTokenManager::class),
994
+                $stream
995
+            );
996
+        });
997
+        /** @deprecated 19.0.0 */
998
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
999
+
1000
+        $this->registerService(IMailer::class, function (Server $c) {
1001
+            return new Mailer(
1002
+                $c->get(\OCP\IConfig::class),
1003
+                $c->get(ILogger::class),
1004
+                $c->get(Defaults::class),
1005
+                $c->get(IURLGenerator::class),
1006
+                $c->getL10N('lib'),
1007
+                $c->get(IEventDispatcher::class),
1008
+                $c->get(IFactory::class)
1009
+            );
1010
+        });
1011
+        /** @deprecated 19.0.0 */
1012
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
1013
+
1014
+        $this->registerService('LDAPProvider', function (ContainerInterface $c) {
1015
+            $config = $c->get(\OCP\IConfig::class);
1016
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1017
+            if (is_null($factoryClass)) {
1018
+                throw new \Exception('ldapProviderFactory not set');
1019
+            }
1020
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1021
+            $factory = new $factoryClass($this);
1022
+            return $factory->getLDAPProvider();
1023
+        });
1024
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1025
+            $ini = $c->get(IniGetWrapper::class);
1026
+            $config = $c->get(\OCP\IConfig::class);
1027
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1028
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1029
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1030
+                $memcacheFactory = $c->get(ICacheFactory::class);
1031
+                $memcache = $memcacheFactory->createLocking('lock');
1032
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1033
+                    return new MemcacheLockingProvider($memcache, $ttl);
1034
+                }
1035
+                return new DBLockingProvider(
1036
+                    $c->get(IDBConnection::class),
1037
+                    $c->get(ILogger::class),
1038
+                    new TimeFactory(),
1039
+                    $ttl,
1040
+                    !\OC::$CLI
1041
+                );
1042
+            }
1043
+            return new NoopLockingProvider();
1044
+        });
1045
+        /** @deprecated 19.0.0 */
1046
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1047
+
1048
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1049
+        /** @deprecated 19.0.0 */
1050
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1051
+
1052
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1053
+            return new \OC\Files\Type\Detection(
1054
+                $c->get(IURLGenerator::class),
1055
+                $c->get(ILogger::class),
1056
+                \OC::$configDir,
1057
+                \OC::$SERVERROOT . '/resources/config/'
1058
+            );
1059
+        });
1060
+        /** @deprecated 19.0.0 */
1061
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1062
+
1063
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
1064
+        /** @deprecated 19.0.0 */
1065
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1066
+        $this->registerService(BundleFetcher::class, function () {
1067
+            return new BundleFetcher($this->getL10N('lib'));
1068
+        });
1069
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1070
+        /** @deprecated 19.0.0 */
1071
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1072
+
1073
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1074
+            $manager = new CapabilitiesManager($c->get(ILogger::class));
1075
+            $manager->registerCapability(function () use ($c) {
1076
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1077
+            });
1078
+            $manager->registerCapability(function () use ($c) {
1079
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1080
+            });
1081
+            return $manager;
1082
+        });
1083
+        /** @deprecated 19.0.0 */
1084
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1085
+
1086
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1087
+            $config = $c->get(\OCP\IConfig::class);
1088
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1089
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1090
+            $factory = new $factoryClass($this);
1091
+            $manager = $factory->getManager();
1092
+
1093
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1094
+                $manager = $c->get(IUserManager::class);
1095
+                $user = $manager->get($id);
1096
+                if (is_null($user)) {
1097
+                    $l = $c->getL10N('core');
1098
+                    $displayName = $l->t('Unknown user');
1099
+                } else {
1100
+                    $displayName = $user->getDisplayName();
1101
+                }
1102
+                return $displayName;
1103
+            });
1104
+
1105
+            return $manager;
1106
+        });
1107
+        /** @deprecated 19.0.0 */
1108
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1109
+
1110
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1111
+        $this->registerService('ThemingDefaults', function (Server $c) {
1112
+            /*
1113 1113
 			 * Dark magic for autoloader.
1114 1114
 			 * If we do a class_exists it will try to load the class which will
1115 1115
 			 * make composer cache the result. Resulting in errors when enabling
1116 1116
 			 * the theming app.
1117 1117
 			 */
1118
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1119
-			if (isset($prefixes['OCA\\Theming\\'])) {
1120
-				$classExists = true;
1121
-			} else {
1122
-				$classExists = false;
1123
-			}
1124
-
1125
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1126
-				return new ThemingDefaults(
1127
-					$c->get(\OCP\IConfig::class),
1128
-					$c->getL10N('theming'),
1129
-					$c->get(IURLGenerator::class),
1130
-					$c->get(ICacheFactory::class),
1131
-					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1132
-					new ImageManager(
1133
-						$c->get(\OCP\IConfig::class),
1134
-						$c->getAppDataDir('theming'),
1135
-						$c->get(IURLGenerator::class),
1136
-						$this->get(ICacheFactory::class),
1137
-						$this->get(ILogger::class),
1138
-						$this->get(ITempManager::class)
1139
-					),
1140
-					$c->get(IAppManager::class),
1141
-					$c->get(INavigationManager::class)
1142
-				);
1143
-			}
1144
-			return new \OC_Defaults();
1145
-		});
1146
-		$this->registerService(JSCombiner::class, function (Server $c) {
1147
-			return new JSCombiner(
1148
-				$c->getAppDataDir('js'),
1149
-				$c->get(IURLGenerator::class),
1150
-				$this->get(ICacheFactory::class),
1151
-				$c->get(SystemConfig::class),
1152
-				$c->get(ILogger::class)
1153
-			);
1154
-		});
1155
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1156
-		/** @deprecated 19.0.0 */
1157
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1158
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1159
-
1160
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1161
-			// FIXME: Instantiiated here due to cyclic dependency
1162
-			$request = new Request(
1163
-				[
1164
-					'get' => $_GET,
1165
-					'post' => $_POST,
1166
-					'files' => $_FILES,
1167
-					'server' => $_SERVER,
1168
-					'env' => $_ENV,
1169
-					'cookies' => $_COOKIE,
1170
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1171
-						? $_SERVER['REQUEST_METHOD']
1172
-						: null,
1173
-				],
1174
-				$c->get(ISecureRandom::class),
1175
-				$c->get(\OCP\IConfig::class)
1176
-			);
1177
-
1178
-			return new CryptoWrapper(
1179
-				$c->get(\OCP\IConfig::class),
1180
-				$c->get(ICrypto::class),
1181
-				$c->get(ISecureRandom::class),
1182
-				$request
1183
-			);
1184
-		});
1185
-		/** @deprecated 19.0.0 */
1186
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1187
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1188
-			return new SessionStorage($c->get(ISession::class));
1189
-		});
1190
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1191
-		/** @deprecated 19.0.0 */
1192
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1193
-
1194
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1195
-			$config = $c->get(\OCP\IConfig::class);
1196
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1197
-			/** @var \OCP\Share\IProviderFactory $factory */
1198
-			$factory = new $factoryClass($this);
1199
-
1200
-			$manager = new \OC\Share20\Manager(
1201
-				$c->get(ILogger::class),
1202
-				$c->get(\OCP\IConfig::class),
1203
-				$c->get(ISecureRandom::class),
1204
-				$c->get(IHasher::class),
1205
-				$c->get(IMountManager::class),
1206
-				$c->get(IGroupManager::class),
1207
-				$c->getL10N('lib'),
1208
-				$c->get(IFactory::class),
1209
-				$factory,
1210
-				$c->get(IUserManager::class),
1211
-				$c->get(IRootFolder::class),
1212
-				$c->get(SymfonyAdapter::class),
1213
-				$c->get(IMailer::class),
1214
-				$c->get(IURLGenerator::class),
1215
-				$c->get('ThemingDefaults'),
1216
-				$c->get(IEventDispatcher::class)
1217
-			);
1218
-
1219
-			return $manager;
1220
-		});
1221
-		/** @deprecated 19.0.0 */
1222
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1223
-
1224
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1225
-			$instance = new Collaboration\Collaborators\Search($c);
1226
-
1227
-			// register default plugins
1228
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1229
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1230
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1231
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1232
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1233
-
1234
-			return $instance;
1235
-		});
1236
-		/** @deprecated 19.0.0 */
1237
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1238
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1239
-
1240
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1241
-
1242
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1243
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1244
-
1245
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1246
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1247
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1248
-			return new \OC\Files\AppData\Factory(
1249
-				$c->get(IRootFolder::class),
1250
-				$c->get(SystemConfig::class)
1251
-			);
1252
-		});
1253
-
1254
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1255
-			return new LockdownManager(function () use ($c) {
1256
-				return $c->get(ISession::class);
1257
-			});
1258
-		});
1259
-
1260
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1261
-			return new DiscoveryService(
1262
-				$c->get(ICacheFactory::class),
1263
-				$c->get(IClientService::class)
1264
-			);
1265
-		});
1266
-
1267
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1268
-			return new CloudIdManager();
1269
-		});
1270
-
1271
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1272
-
1273
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1274
-			return new CloudFederationProviderManager(
1275
-				$c->get(IAppManager::class),
1276
-				$c->get(IClientService::class),
1277
-				$c->get(ICloudIdManager::class),
1278
-				$c->get(ILogger::class)
1279
-			);
1280
-		});
1281
-
1282
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1283
-			return new CloudFederationFactory();
1284
-		});
1285
-
1286
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1287
-		/** @deprecated 19.0.0 */
1288
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1289
-
1290
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1291
-		/** @deprecated 19.0.0 */
1292
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1293
-
1294
-		$this->registerService(Defaults::class, function (Server $c) {
1295
-			return new Defaults(
1296
-				$c->getThemingDefaults()
1297
-			);
1298
-		});
1299
-		/** @deprecated 19.0.0 */
1300
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1301
-
1302
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1303
-			return $c->get(\OCP\IUserSession::class)->getSession();
1304
-		}, false);
1305
-
1306
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1307
-			return new ShareHelper(
1308
-				$c->get(\OCP\Share\IManager::class)
1309
-			);
1310
-		});
1311
-
1312
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1313
-			return new Installer(
1314
-				$c->get(AppFetcher::class),
1315
-				$c->get(IClientService::class),
1316
-				$c->get(ITempManager::class),
1317
-				$c->get(ILogger::class),
1318
-				$c->get(\OCP\IConfig::class),
1319
-				\OC::$CLI
1320
-			);
1321
-		});
1322
-
1323
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1324
-			return new ApiFactory($c->get(IClientService::class));
1325
-		});
1326
-
1327
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1328
-			$memcacheFactory = $c->get(ICacheFactory::class);
1329
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1330
-		});
1331
-
1332
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1333
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1334
-
1335
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1336
-
1337
-		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1338
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1339
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1340
-
1341
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1342
-
1343
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1344
-
1345
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1346
-
1347
-		$this->connectDispatcher();
1348
-	}
1349
-
1350
-	public function boot() {
1351
-		/** @var HookConnector $hookConnector */
1352
-		$hookConnector = $this->get(HookConnector::class);
1353
-		$hookConnector->viewToNode();
1354
-	}
1355
-
1356
-	/**
1357
-	 * @return \OCP\Calendar\IManager
1358
-	 * @deprecated 20.0.0
1359
-	 */
1360
-	public function getCalendarManager() {
1361
-		return $this->get(\OC\Calendar\Manager::class);
1362
-	}
1363
-
1364
-	/**
1365
-	 * @return \OCP\Calendar\Resource\IManager
1366
-	 * @deprecated 20.0.0
1367
-	 */
1368
-	public function getCalendarResourceBackendManager() {
1369
-		return $this->get(\OC\Calendar\Resource\Manager::class);
1370
-	}
1371
-
1372
-	/**
1373
-	 * @return \OCP\Calendar\Room\IManager
1374
-	 * @deprecated 20.0.0
1375
-	 */
1376
-	public function getCalendarRoomBackendManager() {
1377
-		return $this->get(\OC\Calendar\Room\Manager::class);
1378
-	}
1379
-
1380
-	private function connectDispatcher() {
1381
-		$dispatcher = $this->get(SymfonyAdapter::class);
1382
-
1383
-		// Delete avatar on user deletion
1384
-		$dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1385
-			$logger = $this->get(ILogger::class);
1386
-			$manager = $this->getAvatarManager();
1387
-			/** @var IUser $user */
1388
-			$user = $e->getSubject();
1389
-
1390
-			try {
1391
-				$avatar = $manager->getAvatar($user->getUID());
1392
-				$avatar->remove();
1393
-			} catch (NotFoundException $e) {
1394
-				// no avatar to remove
1395
-			} catch (\Exception $e) {
1396
-				// Ignore exceptions
1397
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1398
-			}
1399
-		});
1400
-
1401
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1402
-			$manager = $this->getAvatarManager();
1403
-			/** @var IUser $user */
1404
-			$user = $e->getSubject();
1405
-			$feature = $e->getArgument('feature');
1406
-			$oldValue = $e->getArgument('oldValue');
1407
-			$value = $e->getArgument('value');
1408
-
1409
-			// We only change the avatar on display name changes
1410
-			if ($feature !== 'displayName') {
1411
-				return;
1412
-			}
1413
-
1414
-			try {
1415
-				$avatar = $manager->getAvatar($user->getUID());
1416
-				$avatar->userChanged($feature, $oldValue, $value);
1417
-			} catch (NotFoundException $e) {
1418
-				// no avatar to remove
1419
-			}
1420
-		});
1421
-
1422
-		/** @var IEventDispatcher $eventDispatched */
1423
-		$eventDispatched = $this->get(IEventDispatcher::class);
1424
-		$eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1425
-		$eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1426
-	}
1427
-
1428
-	/**
1429
-	 * @return \OCP\Contacts\IManager
1430
-	 * @deprecated 20.0.0
1431
-	 */
1432
-	public function getContactsManager() {
1433
-		return $this->get(\OCP\Contacts\IManager::class);
1434
-	}
1435
-
1436
-	/**
1437
-	 * @return \OC\Encryption\Manager
1438
-	 * @deprecated 20.0.0
1439
-	 */
1440
-	public function getEncryptionManager() {
1441
-		return $this->get(\OCP\Encryption\IManager::class);
1442
-	}
1443
-
1444
-	/**
1445
-	 * @return \OC\Encryption\File
1446
-	 * @deprecated 20.0.0
1447
-	 */
1448
-	public function getEncryptionFilesHelper() {
1449
-		return $this->get('EncryptionFileHelper');
1450
-	}
1451
-
1452
-	/**
1453
-	 * @return \OCP\Encryption\Keys\IStorage
1454
-	 * @deprecated 20.0.0
1455
-	 */
1456
-	public function getEncryptionKeyStorage() {
1457
-		return $this->get('EncryptionKeyStorage');
1458
-	}
1459
-
1460
-	/**
1461
-	 * The current request object holding all information about the request
1462
-	 * currently being processed is returned from this method.
1463
-	 * In case the current execution was not initiated by a web request null is returned
1464
-	 *
1465
-	 * @return \OCP\IRequest
1466
-	 * @deprecated 20.0.0
1467
-	 */
1468
-	public function getRequest() {
1469
-		return $this->get(IRequest::class);
1470
-	}
1471
-
1472
-	/**
1473
-	 * Returns the preview manager which can create preview images for a given file
1474
-	 *
1475
-	 * @return IPreview
1476
-	 * @deprecated 20.0.0
1477
-	 */
1478
-	public function getPreviewManager() {
1479
-		return $this->get(IPreview::class);
1480
-	}
1481
-
1482
-	/**
1483
-	 * Returns the tag manager which can get and set tags for different object types
1484
-	 *
1485
-	 * @see \OCP\ITagManager::load()
1486
-	 * @return ITagManager
1487
-	 * @deprecated 20.0.0
1488
-	 */
1489
-	public function getTagManager() {
1490
-		return $this->get(ITagManager::class);
1491
-	}
1492
-
1493
-	/**
1494
-	 * Returns the system-tag manager
1495
-	 *
1496
-	 * @return ISystemTagManager
1497
-	 *
1498
-	 * @since 9.0.0
1499
-	 * @deprecated 20.0.0
1500
-	 */
1501
-	public function getSystemTagManager() {
1502
-		return $this->get(ISystemTagManager::class);
1503
-	}
1504
-
1505
-	/**
1506
-	 * Returns the system-tag object mapper
1507
-	 *
1508
-	 * @return ISystemTagObjectMapper
1509
-	 *
1510
-	 * @since 9.0.0
1511
-	 * @deprecated 20.0.0
1512
-	 */
1513
-	public function getSystemTagObjectMapper() {
1514
-		return $this->get(ISystemTagObjectMapper::class);
1515
-	}
1516
-
1517
-	/**
1518
-	 * Returns the avatar manager, used for avatar functionality
1519
-	 *
1520
-	 * @return IAvatarManager
1521
-	 * @deprecated 20.0.0
1522
-	 */
1523
-	public function getAvatarManager() {
1524
-		return $this->get(IAvatarManager::class);
1525
-	}
1526
-
1527
-	/**
1528
-	 * Returns the root folder of ownCloud's data directory
1529
-	 *
1530
-	 * @return IRootFolder
1531
-	 * @deprecated 20.0.0
1532
-	 */
1533
-	public function getRootFolder() {
1534
-		return $this->get(IRootFolder::class);
1535
-	}
1536
-
1537
-	/**
1538
-	 * Returns the root folder of ownCloud's data directory
1539
-	 * This is the lazy variant so this gets only initialized once it
1540
-	 * is actually used.
1541
-	 *
1542
-	 * @return IRootFolder
1543
-	 * @deprecated 20.0.0
1544
-	 */
1545
-	public function getLazyRootFolder() {
1546
-		return $this->get(IRootFolder::class);
1547
-	}
1548
-
1549
-	/**
1550
-	 * Returns a view to ownCloud's files folder
1551
-	 *
1552
-	 * @param string $userId user ID
1553
-	 * @return \OCP\Files\Folder|null
1554
-	 * @deprecated 20.0.0
1555
-	 */
1556
-	public function getUserFolder($userId = null) {
1557
-		if ($userId === null) {
1558
-			$user = $this->get(IUserSession::class)->getUser();
1559
-			if (!$user) {
1560
-				return null;
1561
-			}
1562
-			$userId = $user->getUID();
1563
-		}
1564
-		$root = $this->get(IRootFolder::class);
1565
-		return $root->getUserFolder($userId);
1566
-	}
1567
-
1568
-	/**
1569
-	 * @return \OC\User\Manager
1570
-	 * @deprecated 20.0.0
1571
-	 */
1572
-	public function getUserManager() {
1573
-		return $this->get(IUserManager::class);
1574
-	}
1575
-
1576
-	/**
1577
-	 * @return \OC\Group\Manager
1578
-	 * @deprecated 20.0.0
1579
-	 */
1580
-	public function getGroupManager() {
1581
-		return $this->get(IGroupManager::class);
1582
-	}
1583
-
1584
-	/**
1585
-	 * @return \OC\User\Session
1586
-	 * @deprecated 20.0.0
1587
-	 */
1588
-	public function getUserSession() {
1589
-		return $this->get(IUserSession::class);
1590
-	}
1591
-
1592
-	/**
1593
-	 * @return \OCP\ISession
1594
-	 * @deprecated 20.0.0
1595
-	 */
1596
-	public function getSession() {
1597
-		return $this->get(IUserSession::class)->getSession();
1598
-	}
1599
-
1600
-	/**
1601
-	 * @param \OCP\ISession $session
1602
-	 */
1603
-	public function setSession(\OCP\ISession $session) {
1604
-		$this->get(SessionStorage::class)->setSession($session);
1605
-		$this->get(IUserSession::class)->setSession($session);
1606
-		$this->get(Store::class)->setSession($session);
1607
-	}
1608
-
1609
-	/**
1610
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1611
-	 * @deprecated 20.0.0
1612
-	 */
1613
-	public function getTwoFactorAuthManager() {
1614
-		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1615
-	}
1616
-
1617
-	/**
1618
-	 * @return \OC\NavigationManager
1619
-	 * @deprecated 20.0.0
1620
-	 */
1621
-	public function getNavigationManager() {
1622
-		return $this->get(INavigationManager::class);
1623
-	}
1624
-
1625
-	/**
1626
-	 * @return \OCP\IConfig
1627
-	 * @deprecated 20.0.0
1628
-	 */
1629
-	public function getConfig() {
1630
-		return $this->get(AllConfig::class);
1631
-	}
1632
-
1633
-	/**
1634
-	 * @return \OC\SystemConfig
1635
-	 * @deprecated 20.0.0
1636
-	 */
1637
-	public function getSystemConfig() {
1638
-		return $this->get(SystemConfig::class);
1639
-	}
1640
-
1641
-	/**
1642
-	 * Returns the app config manager
1643
-	 *
1644
-	 * @return IAppConfig
1645
-	 * @deprecated 20.0.0
1646
-	 */
1647
-	public function getAppConfig() {
1648
-		return $this->get(IAppConfig::class);
1649
-	}
1650
-
1651
-	/**
1652
-	 * @return IFactory
1653
-	 * @deprecated 20.0.0
1654
-	 */
1655
-	public function getL10NFactory() {
1656
-		return $this->get(IFactory::class);
1657
-	}
1658
-
1659
-	/**
1660
-	 * get an L10N instance
1661
-	 *
1662
-	 * @param string $app appid
1663
-	 * @param string $lang
1664
-	 * @return IL10N
1665
-	 * @deprecated 20.0.0
1666
-	 */
1667
-	public function getL10N($app, $lang = null) {
1668
-		return $this->get(IFactory::class)->get($app, $lang);
1669
-	}
1670
-
1671
-	/**
1672
-	 * @return IURLGenerator
1673
-	 * @deprecated 20.0.0
1674
-	 */
1675
-	public function getURLGenerator() {
1676
-		return $this->get(IURLGenerator::class);
1677
-	}
1678
-
1679
-	/**
1680
-	 * @return AppFetcher
1681
-	 * @deprecated 20.0.0
1682
-	 */
1683
-	public function getAppFetcher() {
1684
-		return $this->get(AppFetcher::class);
1685
-	}
1686
-
1687
-	/**
1688
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1689
-	 * getMemCacheFactory() instead.
1690
-	 *
1691
-	 * @return ICache
1692
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1693
-	 */
1694
-	public function getCache() {
1695
-		return $this->get(ICache::class);
1696
-	}
1697
-
1698
-	/**
1699
-	 * Returns an \OCP\CacheFactory instance
1700
-	 *
1701
-	 * @return \OCP\ICacheFactory
1702
-	 * @deprecated 20.0.0
1703
-	 */
1704
-	public function getMemCacheFactory() {
1705
-		return $this->get(ICacheFactory::class);
1706
-	}
1707
-
1708
-	/**
1709
-	 * Returns an \OC\RedisFactory instance
1710
-	 *
1711
-	 * @return \OC\RedisFactory
1712
-	 * @deprecated 20.0.0
1713
-	 */
1714
-	public function getGetRedisFactory() {
1715
-		return $this->get('RedisFactory');
1716
-	}
1717
-
1718
-
1719
-	/**
1720
-	 * Returns the current session
1721
-	 *
1722
-	 * @return \OCP\IDBConnection
1723
-	 * @deprecated 20.0.0
1724
-	 */
1725
-	public function getDatabaseConnection() {
1726
-		return $this->get(IDBConnection::class);
1727
-	}
1728
-
1729
-	/**
1730
-	 * Returns the activity manager
1731
-	 *
1732
-	 * @return \OCP\Activity\IManager
1733
-	 * @deprecated 20.0.0
1734
-	 */
1735
-	public function getActivityManager() {
1736
-		return $this->get(\OCP\Activity\IManager::class);
1737
-	}
1738
-
1739
-	/**
1740
-	 * Returns an job list for controlling background jobs
1741
-	 *
1742
-	 * @return IJobList
1743
-	 * @deprecated 20.0.0
1744
-	 */
1745
-	public function getJobList() {
1746
-		return $this->get(IJobList::class);
1747
-	}
1748
-
1749
-	/**
1750
-	 * Returns a logger instance
1751
-	 *
1752
-	 * @return ILogger
1753
-	 * @deprecated 20.0.0
1754
-	 */
1755
-	public function getLogger() {
1756
-		return $this->get(ILogger::class);
1757
-	}
1758
-
1759
-	/**
1760
-	 * @return ILogFactory
1761
-	 * @throws \OCP\AppFramework\QueryException
1762
-	 * @deprecated 20.0.0
1763
-	 */
1764
-	public function getLogFactory() {
1765
-		return $this->get(ILogFactory::class);
1766
-	}
1767
-
1768
-	/**
1769
-	 * Returns a router for generating and matching urls
1770
-	 *
1771
-	 * @return IRouter
1772
-	 * @deprecated 20.0.0
1773
-	 */
1774
-	public function getRouter() {
1775
-		return $this->get(IRouter::class);
1776
-	}
1777
-
1778
-	/**
1779
-	 * Returns a search instance
1780
-	 *
1781
-	 * @return ISearch
1782
-	 * @deprecated 20.0.0
1783
-	 */
1784
-	public function getSearch() {
1785
-		return $this->get(ISearch::class);
1786
-	}
1787
-
1788
-	/**
1789
-	 * Returns a SecureRandom instance
1790
-	 *
1791
-	 * @return \OCP\Security\ISecureRandom
1792
-	 * @deprecated 20.0.0
1793
-	 */
1794
-	public function getSecureRandom() {
1795
-		return $this->get(ISecureRandom::class);
1796
-	}
1797
-
1798
-	/**
1799
-	 * Returns a Crypto instance
1800
-	 *
1801
-	 * @return ICrypto
1802
-	 * @deprecated 20.0.0
1803
-	 */
1804
-	public function getCrypto() {
1805
-		return $this->get(ICrypto::class);
1806
-	}
1807
-
1808
-	/**
1809
-	 * Returns a Hasher instance
1810
-	 *
1811
-	 * @return IHasher
1812
-	 * @deprecated 20.0.0
1813
-	 */
1814
-	public function getHasher() {
1815
-		return $this->get(IHasher::class);
1816
-	}
1817
-
1818
-	/**
1819
-	 * Returns a CredentialsManager instance
1820
-	 *
1821
-	 * @return ICredentialsManager
1822
-	 * @deprecated 20.0.0
1823
-	 */
1824
-	public function getCredentialsManager() {
1825
-		return $this->get(ICredentialsManager::class);
1826
-	}
1827
-
1828
-	/**
1829
-	 * Get the certificate manager
1830
-	 *
1831
-	 * @return \OCP\ICertificateManager
1832
-	 */
1833
-	public function getCertificateManager() {
1834
-		return $this->get(ICertificateManager::class);
1835
-	}
1836
-
1837
-	/**
1838
-	 * Returns an instance of the HTTP client service
1839
-	 *
1840
-	 * @return IClientService
1841
-	 * @deprecated 20.0.0
1842
-	 */
1843
-	public function getHTTPClientService() {
1844
-		return $this->get(IClientService::class);
1845
-	}
1846
-
1847
-	/**
1848
-	 * Create a new event source
1849
-	 *
1850
-	 * @return \OCP\IEventSource
1851
-	 * @deprecated 20.0.0
1852
-	 */
1853
-	public function createEventSource() {
1854
-		return new \OC_EventSource();
1855
-	}
1856
-
1857
-	/**
1858
-	 * Get the active event logger
1859
-	 *
1860
-	 * The returned logger only logs data when debug mode is enabled
1861
-	 *
1862
-	 * @return IEventLogger
1863
-	 * @deprecated 20.0.0
1864
-	 */
1865
-	public function getEventLogger() {
1866
-		return $this->get(IEventLogger::class);
1867
-	}
1868
-
1869
-	/**
1870
-	 * Get the active query logger
1871
-	 *
1872
-	 * The returned logger only logs data when debug mode is enabled
1873
-	 *
1874
-	 * @return IQueryLogger
1875
-	 * @deprecated 20.0.0
1876
-	 */
1877
-	public function getQueryLogger() {
1878
-		return $this->get(IQueryLogger::class);
1879
-	}
1880
-
1881
-	/**
1882
-	 * Get the manager for temporary files and folders
1883
-	 *
1884
-	 * @return \OCP\ITempManager
1885
-	 * @deprecated 20.0.0
1886
-	 */
1887
-	public function getTempManager() {
1888
-		return $this->get(ITempManager::class);
1889
-	}
1890
-
1891
-	/**
1892
-	 * Get the app manager
1893
-	 *
1894
-	 * @return \OCP\App\IAppManager
1895
-	 * @deprecated 20.0.0
1896
-	 */
1897
-	public function getAppManager() {
1898
-		return $this->get(IAppManager::class);
1899
-	}
1900
-
1901
-	/**
1902
-	 * Creates a new mailer
1903
-	 *
1904
-	 * @return IMailer
1905
-	 * @deprecated 20.0.0
1906
-	 */
1907
-	public function getMailer() {
1908
-		return $this->get(IMailer::class);
1909
-	}
1910
-
1911
-	/**
1912
-	 * Get the webroot
1913
-	 *
1914
-	 * @return string
1915
-	 * @deprecated 20.0.0
1916
-	 */
1917
-	public function getWebRoot() {
1918
-		return $this->webRoot;
1919
-	}
1920
-
1921
-	/**
1922
-	 * @return \OC\OCSClient
1923
-	 * @deprecated 20.0.0
1924
-	 */
1925
-	public function getOcsClient() {
1926
-		return $this->get('OcsClient');
1927
-	}
1928
-
1929
-	/**
1930
-	 * @return IDateTimeZone
1931
-	 * @deprecated 20.0.0
1932
-	 */
1933
-	public function getDateTimeZone() {
1934
-		return $this->get(IDateTimeZone::class);
1935
-	}
1936
-
1937
-	/**
1938
-	 * @return IDateTimeFormatter
1939
-	 * @deprecated 20.0.0
1940
-	 */
1941
-	public function getDateTimeFormatter() {
1942
-		return $this->get(IDateTimeFormatter::class);
1943
-	}
1944
-
1945
-	/**
1946
-	 * @return IMountProviderCollection
1947
-	 * @deprecated 20.0.0
1948
-	 */
1949
-	public function getMountProviderCollection() {
1950
-		return $this->get(IMountProviderCollection::class);
1951
-	}
1952
-
1953
-	/**
1954
-	 * Get the IniWrapper
1955
-	 *
1956
-	 * @return IniGetWrapper
1957
-	 * @deprecated 20.0.0
1958
-	 */
1959
-	public function getIniWrapper() {
1960
-		return $this->get(IniGetWrapper::class);
1961
-	}
1962
-
1963
-	/**
1964
-	 * @return \OCP\Command\IBus
1965
-	 * @deprecated 20.0.0
1966
-	 */
1967
-	public function getCommandBus() {
1968
-		return $this->get(IBus::class);
1969
-	}
1970
-
1971
-	/**
1972
-	 * Get the trusted domain helper
1973
-	 *
1974
-	 * @return TrustedDomainHelper
1975
-	 * @deprecated 20.0.0
1976
-	 */
1977
-	public function getTrustedDomainHelper() {
1978
-		return $this->get(TrustedDomainHelper::class);
1979
-	}
1980
-
1981
-	/**
1982
-	 * Get the locking provider
1983
-	 *
1984
-	 * @return ILockingProvider
1985
-	 * @since 8.1.0
1986
-	 * @deprecated 20.0.0
1987
-	 */
1988
-	public function getLockingProvider() {
1989
-		return $this->get(ILockingProvider::class);
1990
-	}
1991
-
1992
-	/**
1993
-	 * @return IMountManager
1994
-	 * @deprecated 20.0.0
1995
-	 **/
1996
-	public function getMountManager() {
1997
-		return $this->get(IMountManager::class);
1998
-	}
1999
-
2000
-	/**
2001
-	 * @return IUserMountCache
2002
-	 * @deprecated 20.0.0
2003
-	 */
2004
-	public function getUserMountCache() {
2005
-		return $this->get(IUserMountCache::class);
2006
-	}
2007
-
2008
-	/**
2009
-	 * Get the MimeTypeDetector
2010
-	 *
2011
-	 * @return IMimeTypeDetector
2012
-	 * @deprecated 20.0.0
2013
-	 */
2014
-	public function getMimeTypeDetector() {
2015
-		return $this->get(IMimeTypeDetector::class);
2016
-	}
2017
-
2018
-	/**
2019
-	 * Get the MimeTypeLoader
2020
-	 *
2021
-	 * @return IMimeTypeLoader
2022
-	 * @deprecated 20.0.0
2023
-	 */
2024
-	public function getMimeTypeLoader() {
2025
-		return $this->get(IMimeTypeLoader::class);
2026
-	}
2027
-
2028
-	/**
2029
-	 * Get the manager of all the capabilities
2030
-	 *
2031
-	 * @return CapabilitiesManager
2032
-	 * @deprecated 20.0.0
2033
-	 */
2034
-	public function getCapabilitiesManager() {
2035
-		return $this->get(CapabilitiesManager::class);
2036
-	}
2037
-
2038
-	/**
2039
-	 * Get the EventDispatcher
2040
-	 *
2041
-	 * @return EventDispatcherInterface
2042
-	 * @since 8.2.0
2043
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2044
-	 */
2045
-	public function getEventDispatcher() {
2046
-		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2047
-	}
2048
-
2049
-	/**
2050
-	 * Get the Notification Manager
2051
-	 *
2052
-	 * @return \OCP\Notification\IManager
2053
-	 * @since 8.2.0
2054
-	 * @deprecated 20.0.0
2055
-	 */
2056
-	public function getNotificationManager() {
2057
-		return $this->get(\OCP\Notification\IManager::class);
2058
-	}
2059
-
2060
-	/**
2061
-	 * @return ICommentsManager
2062
-	 * @deprecated 20.0.0
2063
-	 */
2064
-	public function getCommentsManager() {
2065
-		return $this->get(ICommentsManager::class);
2066
-	}
2067
-
2068
-	/**
2069
-	 * @return \OCA\Theming\ThemingDefaults
2070
-	 * @deprecated 20.0.0
2071
-	 */
2072
-	public function getThemingDefaults() {
2073
-		return $this->get('ThemingDefaults');
2074
-	}
2075
-
2076
-	/**
2077
-	 * @return \OC\IntegrityCheck\Checker
2078
-	 * @deprecated 20.0.0
2079
-	 */
2080
-	public function getIntegrityCodeChecker() {
2081
-		return $this->get('IntegrityCodeChecker');
2082
-	}
2083
-
2084
-	/**
2085
-	 * @return \OC\Session\CryptoWrapper
2086
-	 * @deprecated 20.0.0
2087
-	 */
2088
-	public function getSessionCryptoWrapper() {
2089
-		return $this->get('CryptoWrapper');
2090
-	}
2091
-
2092
-	/**
2093
-	 * @return CsrfTokenManager
2094
-	 * @deprecated 20.0.0
2095
-	 */
2096
-	public function getCsrfTokenManager() {
2097
-		return $this->get(CsrfTokenManager::class);
2098
-	}
2099
-
2100
-	/**
2101
-	 * @return Throttler
2102
-	 * @deprecated 20.0.0
2103
-	 */
2104
-	public function getBruteForceThrottler() {
2105
-		return $this->get(Throttler::class);
2106
-	}
2107
-
2108
-	/**
2109
-	 * @return IContentSecurityPolicyManager
2110
-	 * @deprecated 20.0.0
2111
-	 */
2112
-	public function getContentSecurityPolicyManager() {
2113
-		return $this->get(ContentSecurityPolicyManager::class);
2114
-	}
2115
-
2116
-	/**
2117
-	 * @return ContentSecurityPolicyNonceManager
2118
-	 * @deprecated 20.0.0
2119
-	 */
2120
-	public function getContentSecurityPolicyNonceManager() {
2121
-		return $this->get(ContentSecurityPolicyNonceManager::class);
2122
-	}
2123
-
2124
-	/**
2125
-	 * Not a public API as of 8.2, wait for 9.0
2126
-	 *
2127
-	 * @return \OCA\Files_External\Service\BackendService
2128
-	 * @deprecated 20.0.0
2129
-	 */
2130
-	public function getStoragesBackendService() {
2131
-		return $this->get(BackendService::class);
2132
-	}
2133
-
2134
-	/**
2135
-	 * Not a public API as of 8.2, wait for 9.0
2136
-	 *
2137
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2138
-	 * @deprecated 20.0.0
2139
-	 */
2140
-	public function getGlobalStoragesService() {
2141
-		return $this->get(GlobalStoragesService::class);
2142
-	}
2143
-
2144
-	/**
2145
-	 * Not a public API as of 8.2, wait for 9.0
2146
-	 *
2147
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2148
-	 * @deprecated 20.0.0
2149
-	 */
2150
-	public function getUserGlobalStoragesService() {
2151
-		return $this->get(UserGlobalStoragesService::class);
2152
-	}
2153
-
2154
-	/**
2155
-	 * Not a public API as of 8.2, wait for 9.0
2156
-	 *
2157
-	 * @return \OCA\Files_External\Service\UserStoragesService
2158
-	 * @deprecated 20.0.0
2159
-	 */
2160
-	public function getUserStoragesService() {
2161
-		return $this->get(UserStoragesService::class);
2162
-	}
2163
-
2164
-	/**
2165
-	 * @return \OCP\Share\IManager
2166
-	 * @deprecated 20.0.0
2167
-	 */
2168
-	public function getShareManager() {
2169
-		return $this->get(\OCP\Share\IManager::class);
2170
-	}
2171
-
2172
-	/**
2173
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2174
-	 * @deprecated 20.0.0
2175
-	 */
2176
-	public function getCollaboratorSearch() {
2177
-		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2178
-	}
2179
-
2180
-	/**
2181
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2182
-	 * @deprecated 20.0.0
2183
-	 */
2184
-	public function getAutoCompleteManager() {
2185
-		return $this->get(IManager::class);
2186
-	}
2187
-
2188
-	/**
2189
-	 * Returns the LDAP Provider
2190
-	 *
2191
-	 * @return \OCP\LDAP\ILDAPProvider
2192
-	 * @deprecated 20.0.0
2193
-	 */
2194
-	public function getLDAPProvider() {
2195
-		return $this->get('LDAPProvider');
2196
-	}
2197
-
2198
-	/**
2199
-	 * @return \OCP\Settings\IManager
2200
-	 * @deprecated 20.0.0
2201
-	 */
2202
-	public function getSettingsManager() {
2203
-		return $this->get(\OC\Settings\Manager::class);
2204
-	}
2205
-
2206
-	/**
2207
-	 * @return \OCP\Files\IAppData
2208
-	 * @deprecated 20.0.0
2209
-	 */
2210
-	public function getAppDataDir($app) {
2211
-		/** @var \OC\Files\AppData\Factory $factory */
2212
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
2213
-		return $factory->get($app);
2214
-	}
2215
-
2216
-	/**
2217
-	 * @return \OCP\Lockdown\ILockdownManager
2218
-	 * @deprecated 20.0.0
2219
-	 */
2220
-	public function getLockdownManager() {
2221
-		return $this->get('LockdownManager');
2222
-	}
2223
-
2224
-	/**
2225
-	 * @return \OCP\Federation\ICloudIdManager
2226
-	 * @deprecated 20.0.0
2227
-	 */
2228
-	public function getCloudIdManager() {
2229
-		return $this->get(ICloudIdManager::class);
2230
-	}
2231
-
2232
-	/**
2233
-	 * @return \OCP\GlobalScale\IConfig
2234
-	 * @deprecated 20.0.0
2235
-	 */
2236
-	public function getGlobalScaleConfig() {
2237
-		return $this->get(IConfig::class);
2238
-	}
2239
-
2240
-	/**
2241
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2242
-	 * @deprecated 20.0.0
2243
-	 */
2244
-	public function getCloudFederationProviderManager() {
2245
-		return $this->get(ICloudFederationProviderManager::class);
2246
-	}
2247
-
2248
-	/**
2249
-	 * @return \OCP\Remote\Api\IApiFactory
2250
-	 * @deprecated 20.0.0
2251
-	 */
2252
-	public function getRemoteApiFactory() {
2253
-		return $this->get(IApiFactory::class);
2254
-	}
2255
-
2256
-	/**
2257
-	 * @return \OCP\Federation\ICloudFederationFactory
2258
-	 * @deprecated 20.0.0
2259
-	 */
2260
-	public function getCloudFederationFactory() {
2261
-		return $this->get(ICloudFederationFactory::class);
2262
-	}
2263
-
2264
-	/**
2265
-	 * @return \OCP\Remote\IInstanceFactory
2266
-	 * @deprecated 20.0.0
2267
-	 */
2268
-	public function getRemoteInstanceFactory() {
2269
-		return $this->get(IInstanceFactory::class);
2270
-	}
2271
-
2272
-	/**
2273
-	 * @return IStorageFactory
2274
-	 * @deprecated 20.0.0
2275
-	 */
2276
-	public function getStorageFactory() {
2277
-		return $this->get(IStorageFactory::class);
2278
-	}
2279
-
2280
-	/**
2281
-	 * Get the Preview GeneratorHelper
2282
-	 *
2283
-	 * @return GeneratorHelper
2284
-	 * @since 17.0.0
2285
-	 * @deprecated 20.0.0
2286
-	 */
2287
-	public function getGeneratorHelper() {
2288
-		return $this->get(\OC\Preview\GeneratorHelper::class);
2289
-	}
2290
-
2291
-	private function registerDeprecatedAlias(string $alias, string $target) {
2292
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2293
-			try {
2294
-				/** @var ILogger $logger */
2295
-				$logger = $container->get(ILogger::class);
2296
-				$logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2297
-			} catch (ContainerExceptionInterface $e) {
2298
-				// Could not get logger. Continue
2299
-			}
2300
-
2301
-			return $container->get($target);
2302
-		}, false);
2303
-	}
1118
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1119
+            if (isset($prefixes['OCA\\Theming\\'])) {
1120
+                $classExists = true;
1121
+            } else {
1122
+                $classExists = false;
1123
+            }
1124
+
1125
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1126
+                return new ThemingDefaults(
1127
+                    $c->get(\OCP\IConfig::class),
1128
+                    $c->getL10N('theming'),
1129
+                    $c->get(IURLGenerator::class),
1130
+                    $c->get(ICacheFactory::class),
1131
+                    new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1132
+                    new ImageManager(
1133
+                        $c->get(\OCP\IConfig::class),
1134
+                        $c->getAppDataDir('theming'),
1135
+                        $c->get(IURLGenerator::class),
1136
+                        $this->get(ICacheFactory::class),
1137
+                        $this->get(ILogger::class),
1138
+                        $this->get(ITempManager::class)
1139
+                    ),
1140
+                    $c->get(IAppManager::class),
1141
+                    $c->get(INavigationManager::class)
1142
+                );
1143
+            }
1144
+            return new \OC_Defaults();
1145
+        });
1146
+        $this->registerService(JSCombiner::class, function (Server $c) {
1147
+            return new JSCombiner(
1148
+                $c->getAppDataDir('js'),
1149
+                $c->get(IURLGenerator::class),
1150
+                $this->get(ICacheFactory::class),
1151
+                $c->get(SystemConfig::class),
1152
+                $c->get(ILogger::class)
1153
+            );
1154
+        });
1155
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1156
+        /** @deprecated 19.0.0 */
1157
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1158
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1159
+
1160
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1161
+            // FIXME: Instantiiated here due to cyclic dependency
1162
+            $request = new Request(
1163
+                [
1164
+                    'get' => $_GET,
1165
+                    'post' => $_POST,
1166
+                    'files' => $_FILES,
1167
+                    'server' => $_SERVER,
1168
+                    'env' => $_ENV,
1169
+                    'cookies' => $_COOKIE,
1170
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1171
+                        ? $_SERVER['REQUEST_METHOD']
1172
+                        : null,
1173
+                ],
1174
+                $c->get(ISecureRandom::class),
1175
+                $c->get(\OCP\IConfig::class)
1176
+            );
1177
+
1178
+            return new CryptoWrapper(
1179
+                $c->get(\OCP\IConfig::class),
1180
+                $c->get(ICrypto::class),
1181
+                $c->get(ISecureRandom::class),
1182
+                $request
1183
+            );
1184
+        });
1185
+        /** @deprecated 19.0.0 */
1186
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1187
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1188
+            return new SessionStorage($c->get(ISession::class));
1189
+        });
1190
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1191
+        /** @deprecated 19.0.0 */
1192
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1193
+
1194
+        $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1195
+            $config = $c->get(\OCP\IConfig::class);
1196
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1197
+            /** @var \OCP\Share\IProviderFactory $factory */
1198
+            $factory = new $factoryClass($this);
1199
+
1200
+            $manager = new \OC\Share20\Manager(
1201
+                $c->get(ILogger::class),
1202
+                $c->get(\OCP\IConfig::class),
1203
+                $c->get(ISecureRandom::class),
1204
+                $c->get(IHasher::class),
1205
+                $c->get(IMountManager::class),
1206
+                $c->get(IGroupManager::class),
1207
+                $c->getL10N('lib'),
1208
+                $c->get(IFactory::class),
1209
+                $factory,
1210
+                $c->get(IUserManager::class),
1211
+                $c->get(IRootFolder::class),
1212
+                $c->get(SymfonyAdapter::class),
1213
+                $c->get(IMailer::class),
1214
+                $c->get(IURLGenerator::class),
1215
+                $c->get('ThemingDefaults'),
1216
+                $c->get(IEventDispatcher::class)
1217
+            );
1218
+
1219
+            return $manager;
1220
+        });
1221
+        /** @deprecated 19.0.0 */
1222
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1223
+
1224
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1225
+            $instance = new Collaboration\Collaborators\Search($c);
1226
+
1227
+            // register default plugins
1228
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1229
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1230
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1231
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1232
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1233
+
1234
+            return $instance;
1235
+        });
1236
+        /** @deprecated 19.0.0 */
1237
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1238
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1239
+
1240
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1241
+
1242
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1243
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1244
+
1245
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1246
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1247
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1248
+            return new \OC\Files\AppData\Factory(
1249
+                $c->get(IRootFolder::class),
1250
+                $c->get(SystemConfig::class)
1251
+            );
1252
+        });
1253
+
1254
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1255
+            return new LockdownManager(function () use ($c) {
1256
+                return $c->get(ISession::class);
1257
+            });
1258
+        });
1259
+
1260
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1261
+            return new DiscoveryService(
1262
+                $c->get(ICacheFactory::class),
1263
+                $c->get(IClientService::class)
1264
+            );
1265
+        });
1266
+
1267
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1268
+            return new CloudIdManager();
1269
+        });
1270
+
1271
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1272
+
1273
+        $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1274
+            return new CloudFederationProviderManager(
1275
+                $c->get(IAppManager::class),
1276
+                $c->get(IClientService::class),
1277
+                $c->get(ICloudIdManager::class),
1278
+                $c->get(ILogger::class)
1279
+            );
1280
+        });
1281
+
1282
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1283
+            return new CloudFederationFactory();
1284
+        });
1285
+
1286
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1287
+        /** @deprecated 19.0.0 */
1288
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1289
+
1290
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1291
+        /** @deprecated 19.0.0 */
1292
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1293
+
1294
+        $this->registerService(Defaults::class, function (Server $c) {
1295
+            return new Defaults(
1296
+                $c->getThemingDefaults()
1297
+            );
1298
+        });
1299
+        /** @deprecated 19.0.0 */
1300
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1301
+
1302
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1303
+            return $c->get(\OCP\IUserSession::class)->getSession();
1304
+        }, false);
1305
+
1306
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1307
+            return new ShareHelper(
1308
+                $c->get(\OCP\Share\IManager::class)
1309
+            );
1310
+        });
1311
+
1312
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1313
+            return new Installer(
1314
+                $c->get(AppFetcher::class),
1315
+                $c->get(IClientService::class),
1316
+                $c->get(ITempManager::class),
1317
+                $c->get(ILogger::class),
1318
+                $c->get(\OCP\IConfig::class),
1319
+                \OC::$CLI
1320
+            );
1321
+        });
1322
+
1323
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1324
+            return new ApiFactory($c->get(IClientService::class));
1325
+        });
1326
+
1327
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1328
+            $memcacheFactory = $c->get(ICacheFactory::class);
1329
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1330
+        });
1331
+
1332
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1333
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1334
+
1335
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1336
+
1337
+        $this->registerAlias(IDashboardManager::class, DashboardManager::class);
1338
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1339
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1340
+
1341
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1342
+
1343
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1344
+
1345
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1346
+
1347
+        $this->connectDispatcher();
1348
+    }
1349
+
1350
+    public function boot() {
1351
+        /** @var HookConnector $hookConnector */
1352
+        $hookConnector = $this->get(HookConnector::class);
1353
+        $hookConnector->viewToNode();
1354
+    }
1355
+
1356
+    /**
1357
+     * @return \OCP\Calendar\IManager
1358
+     * @deprecated 20.0.0
1359
+     */
1360
+    public function getCalendarManager() {
1361
+        return $this->get(\OC\Calendar\Manager::class);
1362
+    }
1363
+
1364
+    /**
1365
+     * @return \OCP\Calendar\Resource\IManager
1366
+     * @deprecated 20.0.0
1367
+     */
1368
+    public function getCalendarResourceBackendManager() {
1369
+        return $this->get(\OC\Calendar\Resource\Manager::class);
1370
+    }
1371
+
1372
+    /**
1373
+     * @return \OCP\Calendar\Room\IManager
1374
+     * @deprecated 20.0.0
1375
+     */
1376
+    public function getCalendarRoomBackendManager() {
1377
+        return $this->get(\OC\Calendar\Room\Manager::class);
1378
+    }
1379
+
1380
+    private function connectDispatcher() {
1381
+        $dispatcher = $this->get(SymfonyAdapter::class);
1382
+
1383
+        // Delete avatar on user deletion
1384
+        $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1385
+            $logger = $this->get(ILogger::class);
1386
+            $manager = $this->getAvatarManager();
1387
+            /** @var IUser $user */
1388
+            $user = $e->getSubject();
1389
+
1390
+            try {
1391
+                $avatar = $manager->getAvatar($user->getUID());
1392
+                $avatar->remove();
1393
+            } catch (NotFoundException $e) {
1394
+                // no avatar to remove
1395
+            } catch (\Exception $e) {
1396
+                // Ignore exceptions
1397
+                $logger->info('Could not cleanup avatar of ' . $user->getUID());
1398
+            }
1399
+        });
1400
+
1401
+        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1402
+            $manager = $this->getAvatarManager();
1403
+            /** @var IUser $user */
1404
+            $user = $e->getSubject();
1405
+            $feature = $e->getArgument('feature');
1406
+            $oldValue = $e->getArgument('oldValue');
1407
+            $value = $e->getArgument('value');
1408
+
1409
+            // We only change the avatar on display name changes
1410
+            if ($feature !== 'displayName') {
1411
+                return;
1412
+            }
1413
+
1414
+            try {
1415
+                $avatar = $manager->getAvatar($user->getUID());
1416
+                $avatar->userChanged($feature, $oldValue, $value);
1417
+            } catch (NotFoundException $e) {
1418
+                // no avatar to remove
1419
+            }
1420
+        });
1421
+
1422
+        /** @var IEventDispatcher $eventDispatched */
1423
+        $eventDispatched = $this->get(IEventDispatcher::class);
1424
+        $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1425
+        $eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1426
+    }
1427
+
1428
+    /**
1429
+     * @return \OCP\Contacts\IManager
1430
+     * @deprecated 20.0.0
1431
+     */
1432
+    public function getContactsManager() {
1433
+        return $this->get(\OCP\Contacts\IManager::class);
1434
+    }
1435
+
1436
+    /**
1437
+     * @return \OC\Encryption\Manager
1438
+     * @deprecated 20.0.0
1439
+     */
1440
+    public function getEncryptionManager() {
1441
+        return $this->get(\OCP\Encryption\IManager::class);
1442
+    }
1443
+
1444
+    /**
1445
+     * @return \OC\Encryption\File
1446
+     * @deprecated 20.0.0
1447
+     */
1448
+    public function getEncryptionFilesHelper() {
1449
+        return $this->get('EncryptionFileHelper');
1450
+    }
1451
+
1452
+    /**
1453
+     * @return \OCP\Encryption\Keys\IStorage
1454
+     * @deprecated 20.0.0
1455
+     */
1456
+    public function getEncryptionKeyStorage() {
1457
+        return $this->get('EncryptionKeyStorage');
1458
+    }
1459
+
1460
+    /**
1461
+     * The current request object holding all information about the request
1462
+     * currently being processed is returned from this method.
1463
+     * In case the current execution was not initiated by a web request null is returned
1464
+     *
1465
+     * @return \OCP\IRequest
1466
+     * @deprecated 20.0.0
1467
+     */
1468
+    public function getRequest() {
1469
+        return $this->get(IRequest::class);
1470
+    }
1471
+
1472
+    /**
1473
+     * Returns the preview manager which can create preview images for a given file
1474
+     *
1475
+     * @return IPreview
1476
+     * @deprecated 20.0.0
1477
+     */
1478
+    public function getPreviewManager() {
1479
+        return $this->get(IPreview::class);
1480
+    }
1481
+
1482
+    /**
1483
+     * Returns the tag manager which can get and set tags for different object types
1484
+     *
1485
+     * @see \OCP\ITagManager::load()
1486
+     * @return ITagManager
1487
+     * @deprecated 20.0.0
1488
+     */
1489
+    public function getTagManager() {
1490
+        return $this->get(ITagManager::class);
1491
+    }
1492
+
1493
+    /**
1494
+     * Returns the system-tag manager
1495
+     *
1496
+     * @return ISystemTagManager
1497
+     *
1498
+     * @since 9.0.0
1499
+     * @deprecated 20.0.0
1500
+     */
1501
+    public function getSystemTagManager() {
1502
+        return $this->get(ISystemTagManager::class);
1503
+    }
1504
+
1505
+    /**
1506
+     * Returns the system-tag object mapper
1507
+     *
1508
+     * @return ISystemTagObjectMapper
1509
+     *
1510
+     * @since 9.0.0
1511
+     * @deprecated 20.0.0
1512
+     */
1513
+    public function getSystemTagObjectMapper() {
1514
+        return $this->get(ISystemTagObjectMapper::class);
1515
+    }
1516
+
1517
+    /**
1518
+     * Returns the avatar manager, used for avatar functionality
1519
+     *
1520
+     * @return IAvatarManager
1521
+     * @deprecated 20.0.0
1522
+     */
1523
+    public function getAvatarManager() {
1524
+        return $this->get(IAvatarManager::class);
1525
+    }
1526
+
1527
+    /**
1528
+     * Returns the root folder of ownCloud's data directory
1529
+     *
1530
+     * @return IRootFolder
1531
+     * @deprecated 20.0.0
1532
+     */
1533
+    public function getRootFolder() {
1534
+        return $this->get(IRootFolder::class);
1535
+    }
1536
+
1537
+    /**
1538
+     * Returns the root folder of ownCloud's data directory
1539
+     * This is the lazy variant so this gets only initialized once it
1540
+     * is actually used.
1541
+     *
1542
+     * @return IRootFolder
1543
+     * @deprecated 20.0.0
1544
+     */
1545
+    public function getLazyRootFolder() {
1546
+        return $this->get(IRootFolder::class);
1547
+    }
1548
+
1549
+    /**
1550
+     * Returns a view to ownCloud's files folder
1551
+     *
1552
+     * @param string $userId user ID
1553
+     * @return \OCP\Files\Folder|null
1554
+     * @deprecated 20.0.0
1555
+     */
1556
+    public function getUserFolder($userId = null) {
1557
+        if ($userId === null) {
1558
+            $user = $this->get(IUserSession::class)->getUser();
1559
+            if (!$user) {
1560
+                return null;
1561
+            }
1562
+            $userId = $user->getUID();
1563
+        }
1564
+        $root = $this->get(IRootFolder::class);
1565
+        return $root->getUserFolder($userId);
1566
+    }
1567
+
1568
+    /**
1569
+     * @return \OC\User\Manager
1570
+     * @deprecated 20.0.0
1571
+     */
1572
+    public function getUserManager() {
1573
+        return $this->get(IUserManager::class);
1574
+    }
1575
+
1576
+    /**
1577
+     * @return \OC\Group\Manager
1578
+     * @deprecated 20.0.0
1579
+     */
1580
+    public function getGroupManager() {
1581
+        return $this->get(IGroupManager::class);
1582
+    }
1583
+
1584
+    /**
1585
+     * @return \OC\User\Session
1586
+     * @deprecated 20.0.0
1587
+     */
1588
+    public function getUserSession() {
1589
+        return $this->get(IUserSession::class);
1590
+    }
1591
+
1592
+    /**
1593
+     * @return \OCP\ISession
1594
+     * @deprecated 20.0.0
1595
+     */
1596
+    public function getSession() {
1597
+        return $this->get(IUserSession::class)->getSession();
1598
+    }
1599
+
1600
+    /**
1601
+     * @param \OCP\ISession $session
1602
+     */
1603
+    public function setSession(\OCP\ISession $session) {
1604
+        $this->get(SessionStorage::class)->setSession($session);
1605
+        $this->get(IUserSession::class)->setSession($session);
1606
+        $this->get(Store::class)->setSession($session);
1607
+    }
1608
+
1609
+    /**
1610
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1611
+     * @deprecated 20.0.0
1612
+     */
1613
+    public function getTwoFactorAuthManager() {
1614
+        return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1615
+    }
1616
+
1617
+    /**
1618
+     * @return \OC\NavigationManager
1619
+     * @deprecated 20.0.0
1620
+     */
1621
+    public function getNavigationManager() {
1622
+        return $this->get(INavigationManager::class);
1623
+    }
1624
+
1625
+    /**
1626
+     * @return \OCP\IConfig
1627
+     * @deprecated 20.0.0
1628
+     */
1629
+    public function getConfig() {
1630
+        return $this->get(AllConfig::class);
1631
+    }
1632
+
1633
+    /**
1634
+     * @return \OC\SystemConfig
1635
+     * @deprecated 20.0.0
1636
+     */
1637
+    public function getSystemConfig() {
1638
+        return $this->get(SystemConfig::class);
1639
+    }
1640
+
1641
+    /**
1642
+     * Returns the app config manager
1643
+     *
1644
+     * @return IAppConfig
1645
+     * @deprecated 20.0.0
1646
+     */
1647
+    public function getAppConfig() {
1648
+        return $this->get(IAppConfig::class);
1649
+    }
1650
+
1651
+    /**
1652
+     * @return IFactory
1653
+     * @deprecated 20.0.0
1654
+     */
1655
+    public function getL10NFactory() {
1656
+        return $this->get(IFactory::class);
1657
+    }
1658
+
1659
+    /**
1660
+     * get an L10N instance
1661
+     *
1662
+     * @param string $app appid
1663
+     * @param string $lang
1664
+     * @return IL10N
1665
+     * @deprecated 20.0.0
1666
+     */
1667
+    public function getL10N($app, $lang = null) {
1668
+        return $this->get(IFactory::class)->get($app, $lang);
1669
+    }
1670
+
1671
+    /**
1672
+     * @return IURLGenerator
1673
+     * @deprecated 20.0.0
1674
+     */
1675
+    public function getURLGenerator() {
1676
+        return $this->get(IURLGenerator::class);
1677
+    }
1678
+
1679
+    /**
1680
+     * @return AppFetcher
1681
+     * @deprecated 20.0.0
1682
+     */
1683
+    public function getAppFetcher() {
1684
+        return $this->get(AppFetcher::class);
1685
+    }
1686
+
1687
+    /**
1688
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1689
+     * getMemCacheFactory() instead.
1690
+     *
1691
+     * @return ICache
1692
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1693
+     */
1694
+    public function getCache() {
1695
+        return $this->get(ICache::class);
1696
+    }
1697
+
1698
+    /**
1699
+     * Returns an \OCP\CacheFactory instance
1700
+     *
1701
+     * @return \OCP\ICacheFactory
1702
+     * @deprecated 20.0.0
1703
+     */
1704
+    public function getMemCacheFactory() {
1705
+        return $this->get(ICacheFactory::class);
1706
+    }
1707
+
1708
+    /**
1709
+     * Returns an \OC\RedisFactory instance
1710
+     *
1711
+     * @return \OC\RedisFactory
1712
+     * @deprecated 20.0.0
1713
+     */
1714
+    public function getGetRedisFactory() {
1715
+        return $this->get('RedisFactory');
1716
+    }
1717
+
1718
+
1719
+    /**
1720
+     * Returns the current session
1721
+     *
1722
+     * @return \OCP\IDBConnection
1723
+     * @deprecated 20.0.0
1724
+     */
1725
+    public function getDatabaseConnection() {
1726
+        return $this->get(IDBConnection::class);
1727
+    }
1728
+
1729
+    /**
1730
+     * Returns the activity manager
1731
+     *
1732
+     * @return \OCP\Activity\IManager
1733
+     * @deprecated 20.0.0
1734
+     */
1735
+    public function getActivityManager() {
1736
+        return $this->get(\OCP\Activity\IManager::class);
1737
+    }
1738
+
1739
+    /**
1740
+     * Returns an job list for controlling background jobs
1741
+     *
1742
+     * @return IJobList
1743
+     * @deprecated 20.0.0
1744
+     */
1745
+    public function getJobList() {
1746
+        return $this->get(IJobList::class);
1747
+    }
1748
+
1749
+    /**
1750
+     * Returns a logger instance
1751
+     *
1752
+     * @return ILogger
1753
+     * @deprecated 20.0.0
1754
+     */
1755
+    public function getLogger() {
1756
+        return $this->get(ILogger::class);
1757
+    }
1758
+
1759
+    /**
1760
+     * @return ILogFactory
1761
+     * @throws \OCP\AppFramework\QueryException
1762
+     * @deprecated 20.0.0
1763
+     */
1764
+    public function getLogFactory() {
1765
+        return $this->get(ILogFactory::class);
1766
+    }
1767
+
1768
+    /**
1769
+     * Returns a router for generating and matching urls
1770
+     *
1771
+     * @return IRouter
1772
+     * @deprecated 20.0.0
1773
+     */
1774
+    public function getRouter() {
1775
+        return $this->get(IRouter::class);
1776
+    }
1777
+
1778
+    /**
1779
+     * Returns a search instance
1780
+     *
1781
+     * @return ISearch
1782
+     * @deprecated 20.0.0
1783
+     */
1784
+    public function getSearch() {
1785
+        return $this->get(ISearch::class);
1786
+    }
1787
+
1788
+    /**
1789
+     * Returns a SecureRandom instance
1790
+     *
1791
+     * @return \OCP\Security\ISecureRandom
1792
+     * @deprecated 20.0.0
1793
+     */
1794
+    public function getSecureRandom() {
1795
+        return $this->get(ISecureRandom::class);
1796
+    }
1797
+
1798
+    /**
1799
+     * Returns a Crypto instance
1800
+     *
1801
+     * @return ICrypto
1802
+     * @deprecated 20.0.0
1803
+     */
1804
+    public function getCrypto() {
1805
+        return $this->get(ICrypto::class);
1806
+    }
1807
+
1808
+    /**
1809
+     * Returns a Hasher instance
1810
+     *
1811
+     * @return IHasher
1812
+     * @deprecated 20.0.0
1813
+     */
1814
+    public function getHasher() {
1815
+        return $this->get(IHasher::class);
1816
+    }
1817
+
1818
+    /**
1819
+     * Returns a CredentialsManager instance
1820
+     *
1821
+     * @return ICredentialsManager
1822
+     * @deprecated 20.0.0
1823
+     */
1824
+    public function getCredentialsManager() {
1825
+        return $this->get(ICredentialsManager::class);
1826
+    }
1827
+
1828
+    /**
1829
+     * Get the certificate manager
1830
+     *
1831
+     * @return \OCP\ICertificateManager
1832
+     */
1833
+    public function getCertificateManager() {
1834
+        return $this->get(ICertificateManager::class);
1835
+    }
1836
+
1837
+    /**
1838
+     * Returns an instance of the HTTP client service
1839
+     *
1840
+     * @return IClientService
1841
+     * @deprecated 20.0.0
1842
+     */
1843
+    public function getHTTPClientService() {
1844
+        return $this->get(IClientService::class);
1845
+    }
1846
+
1847
+    /**
1848
+     * Create a new event source
1849
+     *
1850
+     * @return \OCP\IEventSource
1851
+     * @deprecated 20.0.0
1852
+     */
1853
+    public function createEventSource() {
1854
+        return new \OC_EventSource();
1855
+    }
1856
+
1857
+    /**
1858
+     * Get the active event logger
1859
+     *
1860
+     * The returned logger only logs data when debug mode is enabled
1861
+     *
1862
+     * @return IEventLogger
1863
+     * @deprecated 20.0.0
1864
+     */
1865
+    public function getEventLogger() {
1866
+        return $this->get(IEventLogger::class);
1867
+    }
1868
+
1869
+    /**
1870
+     * Get the active query logger
1871
+     *
1872
+     * The returned logger only logs data when debug mode is enabled
1873
+     *
1874
+     * @return IQueryLogger
1875
+     * @deprecated 20.0.0
1876
+     */
1877
+    public function getQueryLogger() {
1878
+        return $this->get(IQueryLogger::class);
1879
+    }
1880
+
1881
+    /**
1882
+     * Get the manager for temporary files and folders
1883
+     *
1884
+     * @return \OCP\ITempManager
1885
+     * @deprecated 20.0.0
1886
+     */
1887
+    public function getTempManager() {
1888
+        return $this->get(ITempManager::class);
1889
+    }
1890
+
1891
+    /**
1892
+     * Get the app manager
1893
+     *
1894
+     * @return \OCP\App\IAppManager
1895
+     * @deprecated 20.0.0
1896
+     */
1897
+    public function getAppManager() {
1898
+        return $this->get(IAppManager::class);
1899
+    }
1900
+
1901
+    /**
1902
+     * Creates a new mailer
1903
+     *
1904
+     * @return IMailer
1905
+     * @deprecated 20.0.0
1906
+     */
1907
+    public function getMailer() {
1908
+        return $this->get(IMailer::class);
1909
+    }
1910
+
1911
+    /**
1912
+     * Get the webroot
1913
+     *
1914
+     * @return string
1915
+     * @deprecated 20.0.0
1916
+     */
1917
+    public function getWebRoot() {
1918
+        return $this->webRoot;
1919
+    }
1920
+
1921
+    /**
1922
+     * @return \OC\OCSClient
1923
+     * @deprecated 20.0.0
1924
+     */
1925
+    public function getOcsClient() {
1926
+        return $this->get('OcsClient');
1927
+    }
1928
+
1929
+    /**
1930
+     * @return IDateTimeZone
1931
+     * @deprecated 20.0.0
1932
+     */
1933
+    public function getDateTimeZone() {
1934
+        return $this->get(IDateTimeZone::class);
1935
+    }
1936
+
1937
+    /**
1938
+     * @return IDateTimeFormatter
1939
+     * @deprecated 20.0.0
1940
+     */
1941
+    public function getDateTimeFormatter() {
1942
+        return $this->get(IDateTimeFormatter::class);
1943
+    }
1944
+
1945
+    /**
1946
+     * @return IMountProviderCollection
1947
+     * @deprecated 20.0.0
1948
+     */
1949
+    public function getMountProviderCollection() {
1950
+        return $this->get(IMountProviderCollection::class);
1951
+    }
1952
+
1953
+    /**
1954
+     * Get the IniWrapper
1955
+     *
1956
+     * @return IniGetWrapper
1957
+     * @deprecated 20.0.0
1958
+     */
1959
+    public function getIniWrapper() {
1960
+        return $this->get(IniGetWrapper::class);
1961
+    }
1962
+
1963
+    /**
1964
+     * @return \OCP\Command\IBus
1965
+     * @deprecated 20.0.0
1966
+     */
1967
+    public function getCommandBus() {
1968
+        return $this->get(IBus::class);
1969
+    }
1970
+
1971
+    /**
1972
+     * Get the trusted domain helper
1973
+     *
1974
+     * @return TrustedDomainHelper
1975
+     * @deprecated 20.0.0
1976
+     */
1977
+    public function getTrustedDomainHelper() {
1978
+        return $this->get(TrustedDomainHelper::class);
1979
+    }
1980
+
1981
+    /**
1982
+     * Get the locking provider
1983
+     *
1984
+     * @return ILockingProvider
1985
+     * @since 8.1.0
1986
+     * @deprecated 20.0.0
1987
+     */
1988
+    public function getLockingProvider() {
1989
+        return $this->get(ILockingProvider::class);
1990
+    }
1991
+
1992
+    /**
1993
+     * @return IMountManager
1994
+     * @deprecated 20.0.0
1995
+     **/
1996
+    public function getMountManager() {
1997
+        return $this->get(IMountManager::class);
1998
+    }
1999
+
2000
+    /**
2001
+     * @return IUserMountCache
2002
+     * @deprecated 20.0.0
2003
+     */
2004
+    public function getUserMountCache() {
2005
+        return $this->get(IUserMountCache::class);
2006
+    }
2007
+
2008
+    /**
2009
+     * Get the MimeTypeDetector
2010
+     *
2011
+     * @return IMimeTypeDetector
2012
+     * @deprecated 20.0.0
2013
+     */
2014
+    public function getMimeTypeDetector() {
2015
+        return $this->get(IMimeTypeDetector::class);
2016
+    }
2017
+
2018
+    /**
2019
+     * Get the MimeTypeLoader
2020
+     *
2021
+     * @return IMimeTypeLoader
2022
+     * @deprecated 20.0.0
2023
+     */
2024
+    public function getMimeTypeLoader() {
2025
+        return $this->get(IMimeTypeLoader::class);
2026
+    }
2027
+
2028
+    /**
2029
+     * Get the manager of all the capabilities
2030
+     *
2031
+     * @return CapabilitiesManager
2032
+     * @deprecated 20.0.0
2033
+     */
2034
+    public function getCapabilitiesManager() {
2035
+        return $this->get(CapabilitiesManager::class);
2036
+    }
2037
+
2038
+    /**
2039
+     * Get the EventDispatcher
2040
+     *
2041
+     * @return EventDispatcherInterface
2042
+     * @since 8.2.0
2043
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2044
+     */
2045
+    public function getEventDispatcher() {
2046
+        return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2047
+    }
2048
+
2049
+    /**
2050
+     * Get the Notification Manager
2051
+     *
2052
+     * @return \OCP\Notification\IManager
2053
+     * @since 8.2.0
2054
+     * @deprecated 20.0.0
2055
+     */
2056
+    public function getNotificationManager() {
2057
+        return $this->get(\OCP\Notification\IManager::class);
2058
+    }
2059
+
2060
+    /**
2061
+     * @return ICommentsManager
2062
+     * @deprecated 20.0.0
2063
+     */
2064
+    public function getCommentsManager() {
2065
+        return $this->get(ICommentsManager::class);
2066
+    }
2067
+
2068
+    /**
2069
+     * @return \OCA\Theming\ThemingDefaults
2070
+     * @deprecated 20.0.0
2071
+     */
2072
+    public function getThemingDefaults() {
2073
+        return $this->get('ThemingDefaults');
2074
+    }
2075
+
2076
+    /**
2077
+     * @return \OC\IntegrityCheck\Checker
2078
+     * @deprecated 20.0.0
2079
+     */
2080
+    public function getIntegrityCodeChecker() {
2081
+        return $this->get('IntegrityCodeChecker');
2082
+    }
2083
+
2084
+    /**
2085
+     * @return \OC\Session\CryptoWrapper
2086
+     * @deprecated 20.0.0
2087
+     */
2088
+    public function getSessionCryptoWrapper() {
2089
+        return $this->get('CryptoWrapper');
2090
+    }
2091
+
2092
+    /**
2093
+     * @return CsrfTokenManager
2094
+     * @deprecated 20.0.0
2095
+     */
2096
+    public function getCsrfTokenManager() {
2097
+        return $this->get(CsrfTokenManager::class);
2098
+    }
2099
+
2100
+    /**
2101
+     * @return Throttler
2102
+     * @deprecated 20.0.0
2103
+     */
2104
+    public function getBruteForceThrottler() {
2105
+        return $this->get(Throttler::class);
2106
+    }
2107
+
2108
+    /**
2109
+     * @return IContentSecurityPolicyManager
2110
+     * @deprecated 20.0.0
2111
+     */
2112
+    public function getContentSecurityPolicyManager() {
2113
+        return $this->get(ContentSecurityPolicyManager::class);
2114
+    }
2115
+
2116
+    /**
2117
+     * @return ContentSecurityPolicyNonceManager
2118
+     * @deprecated 20.0.0
2119
+     */
2120
+    public function getContentSecurityPolicyNonceManager() {
2121
+        return $this->get(ContentSecurityPolicyNonceManager::class);
2122
+    }
2123
+
2124
+    /**
2125
+     * Not a public API as of 8.2, wait for 9.0
2126
+     *
2127
+     * @return \OCA\Files_External\Service\BackendService
2128
+     * @deprecated 20.0.0
2129
+     */
2130
+    public function getStoragesBackendService() {
2131
+        return $this->get(BackendService::class);
2132
+    }
2133
+
2134
+    /**
2135
+     * Not a public API as of 8.2, wait for 9.0
2136
+     *
2137
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2138
+     * @deprecated 20.0.0
2139
+     */
2140
+    public function getGlobalStoragesService() {
2141
+        return $this->get(GlobalStoragesService::class);
2142
+    }
2143
+
2144
+    /**
2145
+     * Not a public API as of 8.2, wait for 9.0
2146
+     *
2147
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2148
+     * @deprecated 20.0.0
2149
+     */
2150
+    public function getUserGlobalStoragesService() {
2151
+        return $this->get(UserGlobalStoragesService::class);
2152
+    }
2153
+
2154
+    /**
2155
+     * Not a public API as of 8.2, wait for 9.0
2156
+     *
2157
+     * @return \OCA\Files_External\Service\UserStoragesService
2158
+     * @deprecated 20.0.0
2159
+     */
2160
+    public function getUserStoragesService() {
2161
+        return $this->get(UserStoragesService::class);
2162
+    }
2163
+
2164
+    /**
2165
+     * @return \OCP\Share\IManager
2166
+     * @deprecated 20.0.0
2167
+     */
2168
+    public function getShareManager() {
2169
+        return $this->get(\OCP\Share\IManager::class);
2170
+    }
2171
+
2172
+    /**
2173
+     * @return \OCP\Collaboration\Collaborators\ISearch
2174
+     * @deprecated 20.0.0
2175
+     */
2176
+    public function getCollaboratorSearch() {
2177
+        return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2178
+    }
2179
+
2180
+    /**
2181
+     * @return \OCP\Collaboration\AutoComplete\IManager
2182
+     * @deprecated 20.0.0
2183
+     */
2184
+    public function getAutoCompleteManager() {
2185
+        return $this->get(IManager::class);
2186
+    }
2187
+
2188
+    /**
2189
+     * Returns the LDAP Provider
2190
+     *
2191
+     * @return \OCP\LDAP\ILDAPProvider
2192
+     * @deprecated 20.0.0
2193
+     */
2194
+    public function getLDAPProvider() {
2195
+        return $this->get('LDAPProvider');
2196
+    }
2197
+
2198
+    /**
2199
+     * @return \OCP\Settings\IManager
2200
+     * @deprecated 20.0.0
2201
+     */
2202
+    public function getSettingsManager() {
2203
+        return $this->get(\OC\Settings\Manager::class);
2204
+    }
2205
+
2206
+    /**
2207
+     * @return \OCP\Files\IAppData
2208
+     * @deprecated 20.0.0
2209
+     */
2210
+    public function getAppDataDir($app) {
2211
+        /** @var \OC\Files\AppData\Factory $factory */
2212
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
2213
+        return $factory->get($app);
2214
+    }
2215
+
2216
+    /**
2217
+     * @return \OCP\Lockdown\ILockdownManager
2218
+     * @deprecated 20.0.0
2219
+     */
2220
+    public function getLockdownManager() {
2221
+        return $this->get('LockdownManager');
2222
+    }
2223
+
2224
+    /**
2225
+     * @return \OCP\Federation\ICloudIdManager
2226
+     * @deprecated 20.0.0
2227
+     */
2228
+    public function getCloudIdManager() {
2229
+        return $this->get(ICloudIdManager::class);
2230
+    }
2231
+
2232
+    /**
2233
+     * @return \OCP\GlobalScale\IConfig
2234
+     * @deprecated 20.0.0
2235
+     */
2236
+    public function getGlobalScaleConfig() {
2237
+        return $this->get(IConfig::class);
2238
+    }
2239
+
2240
+    /**
2241
+     * @return \OCP\Federation\ICloudFederationProviderManager
2242
+     * @deprecated 20.0.0
2243
+     */
2244
+    public function getCloudFederationProviderManager() {
2245
+        return $this->get(ICloudFederationProviderManager::class);
2246
+    }
2247
+
2248
+    /**
2249
+     * @return \OCP\Remote\Api\IApiFactory
2250
+     * @deprecated 20.0.0
2251
+     */
2252
+    public function getRemoteApiFactory() {
2253
+        return $this->get(IApiFactory::class);
2254
+    }
2255
+
2256
+    /**
2257
+     * @return \OCP\Federation\ICloudFederationFactory
2258
+     * @deprecated 20.0.0
2259
+     */
2260
+    public function getCloudFederationFactory() {
2261
+        return $this->get(ICloudFederationFactory::class);
2262
+    }
2263
+
2264
+    /**
2265
+     * @return \OCP\Remote\IInstanceFactory
2266
+     * @deprecated 20.0.0
2267
+     */
2268
+    public function getRemoteInstanceFactory() {
2269
+        return $this->get(IInstanceFactory::class);
2270
+    }
2271
+
2272
+    /**
2273
+     * @return IStorageFactory
2274
+     * @deprecated 20.0.0
2275
+     */
2276
+    public function getStorageFactory() {
2277
+        return $this->get(IStorageFactory::class);
2278
+    }
2279
+
2280
+    /**
2281
+     * Get the Preview GeneratorHelper
2282
+     *
2283
+     * @return GeneratorHelper
2284
+     * @since 17.0.0
2285
+     * @deprecated 20.0.0
2286
+     */
2287
+    public function getGeneratorHelper() {
2288
+        return $this->get(\OC\Preview\GeneratorHelper::class);
2289
+    }
2290
+
2291
+    private function registerDeprecatedAlias(string $alias, string $target) {
2292
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2293
+            try {
2294
+                /** @var ILogger $logger */
2295
+                $logger = $container->get(ILogger::class);
2296
+                $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2297
+            } catch (ContainerExceptionInterface $e) {
2298
+                // Could not get logger. Continue
2299
+            }
2300
+
2301
+            return $container->get($target);
2302
+        }, false);
2303
+    }
2304 2304
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 		$this->registerParameter('isCLI', \OC::$CLI);
263 263
 		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
264 264
 
265
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
265
+		$this->registerService(ContainerInterface::class, function(ContainerInterface $c) {
266 266
 			return $c;
267 267
 		});
268
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
268
+		$this->registerService(\OCP\IServerContainer::class, function(ContainerInterface $c) {
269 269
 			return $c;
270 270
 		});
271 271
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		$this->registerAlias(IActionFactory::class, ActionFactory::class);
291 291
 
292 292
 
293
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
293
+		$this->registerService(IPreview::class, function(ContainerInterface $c) {
294 294
 			return new PreviewManager(
295 295
 				$c->get(\OCP\IConfig::class),
296 296
 				$c->get(IRootFolder::class),
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		/** @deprecated 19.0.0 */
307 307
 		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
308 308
 
309
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
309
+		$this->registerService(\OC\Preview\Watcher::class, function(ContainerInterface $c) {
310 310
 			return new \OC\Preview\Watcher(
311 311
 				new \OC\Preview\Storage\Root(
312 312
 					$c->get(IRootFolder::class),
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 			);
316 316
 		});
317 317
 
318
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
318
+		$this->registerService(\OCP\Encryption\IManager::class, function(Server $c) {
319 319
 			$view = new View();
320 320
 			$util = new Encryption\Util(
321 321
 				$view,
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		/** @deprecated 19.0.0 */
336 336
 		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
337 337
 
338
-		$this->registerService('EncryptionFileHelper', function (ContainerInterface $c) {
338
+		$this->registerService('EncryptionFileHelper', function(ContainerInterface $c) {
339 339
 			$util = new Encryption\Util(
340 340
 				new View(),
341 341
 				$c->get(IUserManager::class),
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 			);
350 350
 		});
351 351
 
352
-		$this->registerService('EncryptionKeyStorage', function (ContainerInterface $c) {
352
+		$this->registerService('EncryptionKeyStorage', function(ContainerInterface $c) {
353 353
 			$view = new View();
354 354
 			$util = new Encryption\Util(
355 355
 				$view,
@@ -372,22 +372,22 @@  discard block
 block discarded – undo
372 372
 		/** @deprecated 19.0.0 */
373 373
 		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
374 374
 
375
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
375
+		$this->registerService('SystemTagManagerFactory', function(ContainerInterface $c) {
376 376
 			/** @var \OCP\IConfig $config */
377 377
 			$config = $c->get(\OCP\IConfig::class);
378 378
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
379 379
 			return new $factoryClass($this);
380 380
 		});
381
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
381
+		$this->registerService(ISystemTagManager::class, function(ContainerInterface $c) {
382 382
 			return $c->get('SystemTagManagerFactory')->getManager();
383 383
 		});
384 384
 		/** @deprecated 19.0.0 */
385 385
 		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
386 386
 
387
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
387
+		$this->registerService(ISystemTagObjectMapper::class, function(ContainerInterface $c) {
388 388
 			return $c->get('SystemTagManagerFactory')->getObjectMapper();
389 389
 		});
390
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
390
+		$this->registerService('RootFolder', function(ContainerInterface $c) {
391 391
 			$manager = \OC\Files\Filesystem::getMountManager(null);
392 392
 			$view = new View();
393 393
 			$root = new Root(
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
 			return $root;
409 409
 		});
410
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
410
+		$this->registerService(HookConnector::class, function(ContainerInterface $c) {
411 411
 			return new HookConnector(
412 412
 				$c->get(IRootFolder::class),
413 413
 				new View(),
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 		/** @deprecated 19.0.0 */
420 420
 		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
421 421
 
422
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
423
-			return new LazyRoot(function () use ($c) {
422
+		$this->registerService(IRootFolder::class, function(ContainerInterface $c) {
423
+			return new LazyRoot(function() use ($c) {
424 424
 				return $c->get('RootFolder');
425 425
 			});
426 426
 		});
@@ -431,44 +431,44 @@  discard block
 block discarded – undo
431 431
 		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
432 432
 		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
433 433
 
434
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
434
+		$this->registerService(\OCP\IGroupManager::class, function(ContainerInterface $c) {
435 435
 			$groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class));
436
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
436
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
437 437
 				\OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]);
438 438
 
439 439
 				/** @var IEventDispatcher $dispatcher */
440 440
 				$dispatcher = $this->get(IEventDispatcher::class);
441 441
 				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
442 442
 			});
443
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
443
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $group) {
444 444
 				\OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]);
445 445
 
446 446
 				/** @var IEventDispatcher $dispatcher */
447 447
 				$dispatcher = $this->get(IEventDispatcher::class);
448 448
 				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
449 449
 			});
450
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
450
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
451 451
 				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]);
452 452
 
453 453
 				/** @var IEventDispatcher $dispatcher */
454 454
 				$dispatcher = $this->get(IEventDispatcher::class);
455 455
 				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
456 456
 			});
457
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
457
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
458 458
 				\OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]);
459 459
 
460 460
 				/** @var IEventDispatcher $dispatcher */
461 461
 				$dispatcher = $this->get(IEventDispatcher::class);
462 462
 				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
463 463
 			});
464
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
464
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
465 465
 				\OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]);
466 466
 
467 467
 				/** @var IEventDispatcher $dispatcher */
468 468
 				$dispatcher = $this->get(IEventDispatcher::class);
469 469
 				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
470 470
 			});
471
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
471
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
472 472
 				\OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
473 473
 				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
474 474
 				\OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
@@ -477,12 +477,12 @@  discard block
 block discarded – undo
477 477
 				$dispatcher = $this->get(IEventDispatcher::class);
478 478
 				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
479 479
 			});
480
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
480
+			$groupManager->listen('\OC\Group', 'preRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) {
481 481
 				/** @var IEventDispatcher $dispatcher */
482 482
 				$dispatcher = $this->get(IEventDispatcher::class);
483 483
 				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
484 484
 			});
485
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
485
+			$groupManager->listen('\OC\Group', 'postRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) {
486 486
 				/** @var IEventDispatcher $dispatcher */
487 487
 				$dispatcher = $this->get(IEventDispatcher::class);
488 488
 				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 		/** @deprecated 19.0.0 */
493 493
 		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
494 494
 
495
-		$this->registerService(Store::class, function (ContainerInterface $c) {
495
+		$this->registerService(Store::class, function(ContainerInterface $c) {
496 496
 			$session = $c->get(ISession::class);
497 497
 			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
498 498
 				$tokenProvider = $c->get(IProvider::class);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 		$this->registerAlias(IStore::class, Store::class);
506 506
 		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
507 507
 
508
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
508
+		$this->registerService(\OC\User\Session::class, function(Server $c) {
509 509
 			$manager = $c->get(IUserManager::class);
510 510
 			$session = new \OC\Session\Memory('');
511 511
 			$timeFactory = new TimeFactory();
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
 				$c->get(ILogger::class),
531 531
 				$c->get(IEventDispatcher::class)
532 532
 			);
533
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
533
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
534 534
 				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
535 535
 
536 536
 				/** @var IEventDispatcher $dispatcher */
537 537
 				$dispatcher = $this->get(IEventDispatcher::class);
538 538
 				$dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
539 539
 			});
540
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
540
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
541 541
 				/** @var \OC\User\User $user */
542 542
 				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
543 543
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 				$dispatcher = $this->get(IEventDispatcher::class);
546 546
 				$dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
547 547
 			});
548
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
548
+			$userSession->listen('\OC\User', 'preDelete', function($user) use ($legacyDispatcher) {
549 549
 				/** @var \OC\User\User $user */
550 550
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
551 551
 				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 				$dispatcher = $this->get(IEventDispatcher::class);
555 555
 				$dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
556 556
 			});
557
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
557
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
558 558
 				/** @var \OC\User\User $user */
559 559
 				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
560 560
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				$dispatcher = $this->get(IEventDispatcher::class);
563 563
 				$dispatcher->dispatchTyped(new UserDeletedEvent($user));
564 564
 			});
565
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
565
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
566 566
 				/** @var \OC\User\User $user */
567 567
 				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
568 568
 
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 				$dispatcher = $this->get(IEventDispatcher::class);
571 571
 				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
572 572
 			});
573
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
573
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
574 574
 				/** @var \OC\User\User $user */
575 575
 				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
576 576
 
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
 				$dispatcher = $this->get(IEventDispatcher::class);
579 579
 				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
580 580
 			});
581
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
581
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
582 582
 				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
583 583
 
584 584
 				/** @var IEventDispatcher $dispatcher */
585 585
 				$dispatcher = $this->get(IEventDispatcher::class);
586 586
 				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
587 587
 			});
588
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
588
+			$userSession->listen('\OC\User', 'postLogin', function($user, $loginName, $password, $isTokenLogin) {
589 589
 				/** @var \OC\User\User $user */
590 590
 				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
591 591
 
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
 				$dispatcher = $this->get(IEventDispatcher::class);
594 594
 				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
595 595
 			});
596
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
596
+			$userSession->listen('\OC\User', 'preRememberedLogin', function($uid) {
597 597
 				/** @var IEventDispatcher $dispatcher */
598 598
 				$dispatcher = $this->get(IEventDispatcher::class);
599 599
 				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
600 600
 			});
601
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
601
+			$userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) {
602 602
 				/** @var \OC\User\User $user */
603 603
 				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
604 604
 
@@ -606,19 +606,19 @@  discard block
 block discarded – undo
606 606
 				$dispatcher = $this->get(IEventDispatcher::class);
607 607
 				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
608 608
 			});
609
-			$userSession->listen('\OC\User', 'logout', function ($user) {
609
+			$userSession->listen('\OC\User', 'logout', function($user) {
610 610
 				\OC_Hook::emit('OC_User', 'logout', []);
611 611
 
612 612
 				/** @var IEventDispatcher $dispatcher */
613 613
 				$dispatcher = $this->get(IEventDispatcher::class);
614 614
 				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
615 615
 			});
616
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
616
+			$userSession->listen('\OC\User', 'postLogout', function($user) {
617 617
 				/** @var IEventDispatcher $dispatcher */
618 618
 				$dispatcher = $this->get(IEventDispatcher::class);
619 619
 				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
620 620
 			});
621
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
621
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) {
622 622
 				/** @var \OC\User\User $user */
623 623
 				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
624 624
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
643 643
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
644 644
 
645
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
645
+		$this->registerService(\OC\SystemConfig::class, function($c) use ($config) {
646 646
 			return new \OC\SystemConfig($config);
647 647
 		});
648 648
 		/** @deprecated 19.0.0 */
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
653 653
 		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
654 654
 
655
-		$this->registerService(IFactory::class, function (Server $c) {
655
+		$this->registerService(IFactory::class, function(Server $c) {
656 656
 			return new \OC\L10N\Factory(
657 657
 				$c->get(\OCP\IConfig::class),
658 658
 				$c->getRequest(),
@@ -672,13 +672,13 @@  discard block
 block discarded – undo
672 672
 		/** @deprecated 19.0.0 */
673 673
 		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
674 674
 
675
-		$this->registerService(ICache::class, function ($c) {
675
+		$this->registerService(ICache::class, function($c) {
676 676
 			return new Cache\File();
677 677
 		});
678 678
 		/** @deprecated 19.0.0 */
679 679
 		$this->registerDeprecatedAlias('UserCache', ICache::class);
680 680
 
681
-		$this->registerService(Factory::class, function (Server $c) {
681
+		$this->registerService(Factory::class, function(Server $c) {
682 682
 			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class),
683 683
 				ArrayCache::class,
684 684
 				ArrayCache::class,
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 				$version = implode(',', $v);
694 694
 				$instanceId = \OC_Util::getInstanceId();
695 695
 				$path = \OC::$SERVERROOT;
696
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
696
+				$prefix = md5($instanceId.'-'.$version.'-'.$path);
697 697
 				return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class),
698 698
 					$config->getSystemValue('memcache.local', null),
699 699
 					$config->getSystemValue('memcache.distributed', null),
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
 		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
707 707
 		$this->registerAlias(ICacheFactory::class, Factory::class);
708 708
 
709
-		$this->registerService('RedisFactory', function (Server $c) {
709
+		$this->registerService('RedisFactory', function(Server $c) {
710 710
 			$systemConfig = $c->get(SystemConfig::class);
711 711
 			return new RedisFactory($systemConfig);
712 712
 		});
713 713
 
714
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
714
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
715 715
 			$l10n = $this->get(IFactory::class)->get('lib');
716 716
 			return new \OC\Activity\Manager(
717 717
 				$c->getRequest(),
@@ -724,14 +724,14 @@  discard block
 block discarded – undo
724 724
 		/** @deprecated 19.0.0 */
725 725
 		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
726 726
 
727
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
727
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
728 728
 			return new \OC\Activity\EventMerger(
729 729
 				$c->getL10N('lib')
730 730
 			);
731 731
 		});
732 732
 		$this->registerAlias(IValidator::class, Validator::class);
733 733
 
734
-		$this->registerService(AvatarManager::class, function (Server $c) {
734
+		$this->registerService(AvatarManager::class, function(Server $c) {
735 735
 			return new AvatarManager(
736 736
 				$c->get(\OC\User\Manager::class),
737 737
 				$c->getAppDataDir('avatar'),
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
748 748
 		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
749 749
 
750
-		$this->registerService(\OC\Log::class, function (Server $c) {
750
+		$this->registerService(\OC\Log::class, function(Server $c) {
751 751
 			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
752 752
 			$factory = new LogFactory($c, $this->get(SystemConfig::class));
753 753
 			$logger = $factory->get($logType);
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		// PSR-3 logger
762 762
 		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
763 763
 
764
-		$this->registerService(ILogFactory::class, function (Server $c) {
764
+		$this->registerService(ILogFactory::class, function(Server $c) {
765 765
 			return new LogFactory($c, $this->get(SystemConfig::class));
766 766
 		});
767 767
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 		/** @deprecated 19.0.0 */
770 770
 		$this->registerDeprecatedAlias('JobList', IJobList::class);
771 771
 
772
-		$this->registerService(IRouter::class, function (Server $c) {
772
+		$this->registerService(IRouter::class, function(Server $c) {
773 773
 			$cacheFactory = $c->get(ICacheFactory::class);
774 774
 			$logger = $c->get(ILogger::class);
775 775
 			if ($cacheFactory->isLocalCacheAvailable()) {
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 		/** @deprecated 19.0.0 */
787 787
 		$this->registerDeprecatedAlias('Search', ISearch::class);
788 788
 
789
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
789
+		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
790 790
 			return new \OC\Security\RateLimiting\Backend\MemoryCache(
791 791
 				$this->get(ICacheFactory::class),
792 792
 				new \OC\AppFramework\Utility\TimeFactory()
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		/** @deprecated 19.0.0 */
810 810
 		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
811 811
 
812
-		$this->registerService(IDBConnection::class, function (Server $c) {
812
+		$this->registerService(IDBConnection::class, function(Server $c) {
813 813
 			$systemConfig = $c->get(SystemConfig::class);
814 814
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
815 815
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
828 828
 		$this->registerAlias(IClientService::class, ClientService::class);
829 829
 		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
830
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
830
+		$this->registerService(IEventLogger::class, function(ContainerInterface $c) {
831 831
 			$eventLogger = new EventLogger();
832 832
 			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
833 833
 				// In debug mode, module is being activated by default
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		/** @deprecated 19.0.0 */
839 839
 		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
840 840
 
841
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
841
+		$this->registerService(IQueryLogger::class, function(ContainerInterface $c) {
842 842
 			$queryLogger = new QueryLogger();
843 843
 			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
844 844
 				// In debug mode, module is being activated by default
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 		$this->registerDeprecatedAlias('TempManager', TempManager::class);
854 854
 		$this->registerAlias(ITempManager::class, TempManager::class);
855 855
 
856
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
856
+		$this->registerService(AppManager::class, function(ContainerInterface $c) {
857 857
 			// TODO: use auto-wiring
858 858
 			return new \OC\App\AppManager(
859 859
 				$c->get(IUserSession::class),
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 		/** @deprecated 19.0.0 */
874 874
 		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
875 875
 
876
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
876
+		$this->registerService(IDateTimeFormatter::class, function(Server $c) {
877 877
 			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
878 878
 
879 879
 			return new DateTimeFormatter(
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 		/** @deprecated 19.0.0 */
885 885
 		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
886 886
 
887
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
887
+		$this->registerService(IUserMountCache::class, function(ContainerInterface $c) {
888 888
 			$mountCache = new UserMountCache(
889 889
 				$c->get(IDBConnection::class),
890 890
 				$c->get(IUserManager::class),
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 		/** @deprecated 19.0.0 */
898 898
 		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
899 899
 
900
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
900
+		$this->registerService(IMountProviderCollection::class, function(ContainerInterface $c) {
901 901
 			$loader = \OC\Files\Filesystem::getLoader();
902 902
 			$mountCache = $c->get(IUserMountCache::class);
903 903
 			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 
919 919
 		/** @deprecated 20.0.0 */
920 920
 		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
921
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
921
+		$this->registerService(IBus::class, function(ContainerInterface $c) {
922 922
 			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
923 923
 			if ($busClass) {
924 924
 				[$app, $class] = explode('::', $busClass, 2);
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
939 939
 		/** @deprecated 19.0.0 */
940 940
 		$this->registerDeprecatedAlias('Throttler', Throttler::class);
941
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
941
+		$this->registerService('IntegrityCodeChecker', function(ContainerInterface $c) {
942 942
 			// IConfig and IAppManager requires a working database. This code
943 943
 			// might however be called when ownCloud is not yet setup.
944 944
 			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 				$c->get(IMimeTypeDetector::class)
961 961
 			);
962 962
 		});
963
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
963
+		$this->registerService(\OCP\IRequest::class, function(ContainerInterface $c) {
964 964
 			if (isset($this['urlParams'])) {
965 965
 				$urlParams = $this['urlParams'];
966 966
 			} else {
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 		/** @deprecated 19.0.0 */
998 998
 		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
999 999
 
1000
-		$this->registerService(IMailer::class, function (Server $c) {
1000
+		$this->registerService(IMailer::class, function(Server $c) {
1001 1001
 			return new Mailer(
1002 1002
 				$c->get(\OCP\IConfig::class),
1003 1003
 				$c->get(ILogger::class),
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 		/** @deprecated 19.0.0 */
1012 1012
 		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1013 1013
 
1014
-		$this->registerService('LDAPProvider', function (ContainerInterface $c) {
1014
+		$this->registerService('LDAPProvider', function(ContainerInterface $c) {
1015 1015
 			$config = $c->get(\OCP\IConfig::class);
1016 1016
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1017 1017
 			if (is_null($factoryClass)) {
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 			$factory = new $factoryClass($this);
1022 1022
 			return $factory->getLDAPProvider();
1023 1023
 		});
1024
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1024
+		$this->registerService(ILockingProvider::class, function(ContainerInterface $c) {
1025 1025
 			$ini = $c->get(IniGetWrapper::class);
1026 1026
 			$config = $c->get(\OCP\IConfig::class);
1027 1027
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -1049,12 +1049,12 @@  discard block
 block discarded – undo
1049 1049
 		/** @deprecated 19.0.0 */
1050 1050
 		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1051 1051
 
1052
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1052
+		$this->registerService(IMimeTypeDetector::class, function(ContainerInterface $c) {
1053 1053
 			return new \OC\Files\Type\Detection(
1054 1054
 				$c->get(IURLGenerator::class),
1055 1055
 				$c->get(ILogger::class),
1056 1056
 				\OC::$configDir,
1057
-				\OC::$SERVERROOT . '/resources/config/'
1057
+				\OC::$SERVERROOT.'/resources/config/'
1058 1058
 			);
1059 1059
 		});
1060 1060
 		/** @deprecated 19.0.0 */
@@ -1063,19 +1063,19 @@  discard block
 block discarded – undo
1063 1063
 		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1064 1064
 		/** @deprecated 19.0.0 */
1065 1065
 		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1066
-		$this->registerService(BundleFetcher::class, function () {
1066
+		$this->registerService(BundleFetcher::class, function() {
1067 1067
 			return new BundleFetcher($this->getL10N('lib'));
1068 1068
 		});
1069 1069
 		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1070 1070
 		/** @deprecated 19.0.0 */
1071 1071
 		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1072 1072
 
1073
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1073
+		$this->registerService(CapabilitiesManager::class, function(ContainerInterface $c) {
1074 1074
 			$manager = new CapabilitiesManager($c->get(ILogger::class));
1075
-			$manager->registerCapability(function () use ($c) {
1075
+			$manager->registerCapability(function() use ($c) {
1076 1076
 				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1077 1077
 			});
1078
-			$manager->registerCapability(function () use ($c) {
1078
+			$manager->registerCapability(function() use ($c) {
1079 1079
 				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1080 1080
 			});
1081 1081
 			return $manager;
@@ -1083,14 +1083,14 @@  discard block
 block discarded – undo
1083 1083
 		/** @deprecated 19.0.0 */
1084 1084
 		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1085 1085
 
1086
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1086
+		$this->registerService(ICommentsManager::class, function(Server $c) {
1087 1087
 			$config = $c->get(\OCP\IConfig::class);
1088 1088
 			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1089 1089
 			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1090 1090
 			$factory = new $factoryClass($this);
1091 1091
 			$manager = $factory->getManager();
1092 1092
 
1093
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1093
+			$manager->registerDisplayNameResolver('user', function($id) use ($c) {
1094 1094
 				$manager = $c->get(IUserManager::class);
1095 1095
 				$user = $manager->get($id);
1096 1096
 				if (is_null($user)) {
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1109 1109
 
1110 1110
 		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1111
-		$this->registerService('ThemingDefaults', function (Server $c) {
1111
+		$this->registerService('ThemingDefaults', function(Server $c) {
1112 1112
 			/*
1113 1113
 			 * Dark magic for autoloader.
1114 1114
 			 * If we do a class_exists it will try to load the class which will
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 			}
1144 1144
 			return new \OC_Defaults();
1145 1145
 		});
1146
-		$this->registerService(JSCombiner::class, function (Server $c) {
1146
+		$this->registerService(JSCombiner::class, function(Server $c) {
1147 1147
 			return new JSCombiner(
1148 1148
 				$c->getAppDataDir('js'),
1149 1149
 				$c->get(IURLGenerator::class),
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1158 1158
 		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1159 1159
 
1160
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1160
+		$this->registerService('CryptoWrapper', function(ContainerInterface $c) {
1161 1161
 			// FIXME: Instantiiated here due to cyclic dependency
1162 1162
 			$request = new Request(
1163 1163
 				[
@@ -1184,14 +1184,14 @@  discard block
 block discarded – undo
1184 1184
 		});
1185 1185
 		/** @deprecated 19.0.0 */
1186 1186
 		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1187
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1187
+		$this->registerService(SessionStorage::class, function(ContainerInterface $c) {
1188 1188
 			return new SessionStorage($c->get(ISession::class));
1189 1189
 		});
1190 1190
 		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1191 1191
 		/** @deprecated 19.0.0 */
1192 1192
 		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1193 1193
 
1194
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1194
+		$this->registerService(\OCP\Share\IManager::class, function(IServerContainer $c) {
1195 1195
 			$config = $c->get(\OCP\IConfig::class);
1196 1196
 			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1197 1197
 			/** @var \OCP\Share\IProviderFactory $factory */
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 		/** @deprecated 19.0.0 */
1222 1222
 		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1223 1223
 
1224
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1224
+		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1225 1225
 			$instance = new Collaboration\Collaborators\Search($c);
1226 1226
 
1227 1227
 			// register default plugins
@@ -1244,33 +1244,33 @@  discard block
 block discarded – undo
1244 1244
 
1245 1245
 		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1246 1246
 		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1247
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1247
+		$this->registerService(\OC\Files\AppData\Factory::class, function(ContainerInterface $c) {
1248 1248
 			return new \OC\Files\AppData\Factory(
1249 1249
 				$c->get(IRootFolder::class),
1250 1250
 				$c->get(SystemConfig::class)
1251 1251
 			);
1252 1252
 		});
1253 1253
 
1254
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1255
-			return new LockdownManager(function () use ($c) {
1254
+		$this->registerService('LockdownManager', function(ContainerInterface $c) {
1255
+			return new LockdownManager(function() use ($c) {
1256 1256
 				return $c->get(ISession::class);
1257 1257
 			});
1258 1258
 		});
1259 1259
 
1260
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1260
+		$this->registerService(\OCP\OCS\IDiscoveryService::class, function(ContainerInterface $c) {
1261 1261
 			return new DiscoveryService(
1262 1262
 				$c->get(ICacheFactory::class),
1263 1263
 				$c->get(IClientService::class)
1264 1264
 			);
1265 1265
 		});
1266 1266
 
1267
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1267
+		$this->registerService(ICloudIdManager::class, function(ContainerInterface $c) {
1268 1268
 			return new CloudIdManager();
1269 1269
 		});
1270 1270
 
1271 1271
 		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1272 1272
 
1273
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1273
+		$this->registerService(ICloudFederationProviderManager::class, function(ContainerInterface $c) {
1274 1274
 			return new CloudFederationProviderManager(
1275 1275
 				$c->get(IAppManager::class),
1276 1276
 				$c->get(IClientService::class),
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 			);
1280 1280
 		});
1281 1281
 
1282
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1282
+		$this->registerService(ICloudFederationFactory::class, function(Server $c) {
1283 1283
 			return new CloudFederationFactory();
1284 1284
 		});
1285 1285
 
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 		/** @deprecated 19.0.0 */
1292 1292
 		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1293 1293
 
1294
-		$this->registerService(Defaults::class, function (Server $c) {
1294
+		$this->registerService(Defaults::class, function(Server $c) {
1295 1295
 			return new Defaults(
1296 1296
 				$c->getThemingDefaults()
1297 1297
 			);
@@ -1299,17 +1299,17 @@  discard block
 block discarded – undo
1299 1299
 		/** @deprecated 19.0.0 */
1300 1300
 		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1301 1301
 
1302
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1302
+		$this->registerService(\OCP\ISession::class, function(ContainerInterface $c) {
1303 1303
 			return $c->get(\OCP\IUserSession::class)->getSession();
1304 1304
 		}, false);
1305 1305
 
1306
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1306
+		$this->registerService(IShareHelper::class, function(ContainerInterface $c) {
1307 1307
 			return new ShareHelper(
1308 1308
 				$c->get(\OCP\Share\IManager::class)
1309 1309
 			);
1310 1310
 		});
1311 1311
 
1312
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1312
+		$this->registerService(Installer::class, function(ContainerInterface $c) {
1313 1313
 			return new Installer(
1314 1314
 				$c->get(AppFetcher::class),
1315 1315
 				$c->get(IClientService::class),
@@ -1320,11 +1320,11 @@  discard block
 block discarded – undo
1320 1320
 			);
1321 1321
 		});
1322 1322
 
1323
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1323
+		$this->registerService(IApiFactory::class, function(ContainerInterface $c) {
1324 1324
 			return new ApiFactory($c->get(IClientService::class));
1325 1325
 		});
1326 1326
 
1327
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1327
+		$this->registerService(IInstanceFactory::class, function(ContainerInterface $c) {
1328 1328
 			$memcacheFactory = $c->get(ICacheFactory::class);
1329 1329
 			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1330 1330
 		});
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 		$dispatcher = $this->get(SymfonyAdapter::class);
1382 1382
 
1383 1383
 		// Delete avatar on user deletion
1384
-		$dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1384
+		$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) {
1385 1385
 			$logger = $this->get(ILogger::class);
1386 1386
 			$manager = $this->getAvatarManager();
1387 1387
 			/** @var IUser $user */
@@ -1394,11 +1394,11 @@  discard block
 block discarded – undo
1394 1394
 				// no avatar to remove
1395 1395
 			} catch (\Exception $e) {
1396 1396
 				// Ignore exceptions
1397
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1397
+				$logger->info('Could not cleanup avatar of '.$user->getUID());
1398 1398
 			}
1399 1399
 		});
1400 1400
 
1401
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1401
+		$dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) {
1402 1402
 			$manager = $this->getAvatarManager();
1403 1403
 			/** @var IUser $user */
1404 1404
 			$user = $e->getSubject();
@@ -2289,11 +2289,11 @@  discard block
 block discarded – undo
2289 2289
 	}
2290 2290
 
2291 2291
 	private function registerDeprecatedAlias(string $alias, string $target) {
2292
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2292
+		$this->registerService($alias, function(ContainerInterface $container) use ($target, $alias) {
2293 2293
 			try {
2294 2294
 				/** @var ILogger $logger */
2295 2295
 				$logger = $container->get(ILogger::class);
2296
-				$logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2296
+				$logger->debug('The requested alias "'.$alias.'" is depreacted. Please request "'.$target.'" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2297 2297
 			} catch (ContainerExceptionInterface $e) {
2298 2298
 				// Could not get logger. Continue
2299 2299
 			}
Please login to merge, or discard this patch.
lib/private/Security/CertificateManager.php 2 patches
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -39,242 +39,242 @@
 block discarded – undo
39 39
  * Manage trusted certificates for users
40 40
  */
41 41
 class CertificateManager implements ICertificateManager {
42
-	/**
43
-	 * @var \OC\Files\View
44
-	 */
45
-	protected $view;
46
-
47
-	/**
48
-	 * @var IConfig
49
-	 */
50
-	protected $config;
51
-
52
-	/**
53
-	 * @var ILogger
54
-	 */
55
-	protected $logger;
56
-
57
-	/** @var ISecureRandom */
58
-	protected $random;
59
-
60
-	/**
61
-	 * @param \OC\Files\View $view relative to data/
62
-	 * @param IConfig $config
63
-	 * @param ILogger $logger
64
-	 * @param ISecureRandom $random
65
-	 */
66
-	public function __construct(\OC\Files\View $view,
67
-								IConfig $config,
68
-								ILogger $logger,
69
-								ISecureRandom $random) {
70
-		$this->view = $view;
71
-		$this->config = $config;
72
-		$this->logger = $logger;
73
-		$this->random = $random;
74
-	}
75
-
76
-	/**
77
-	 * Returns all certificates trusted by the user
78
-	 *
79
-	 * @return \OCP\ICertificate[]
80
-	 */
81
-	public function listCertificates() {
82
-		if (!$this->config->getSystemValue('installed', false)) {
83
-			return [];
84
-		}
85
-
86
-		$path = $this->getPathToCertificates() . 'uploads/';
87
-		if (!$this->view->is_dir($path)) {
88
-			return [];
89
-		}
90
-		$result = [];
91
-		$handle = $this->view->opendir($path);
92
-		if (!is_resource($handle)) {
93
-			return [];
94
-		}
95
-		while (false !== ($file = readdir($handle))) {
96
-			if ($file != '.' && $file != '..') {
97
-				try {
98
-					$result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
99
-				} catch (\Exception $e) {
100
-				}
101
-			}
102
-		}
103
-		closedir($handle);
104
-		return $result;
105
-	}
106
-
107
-	private function hasCertificates(): bool {
108
-		if (!$this->config->getSystemValue('installed', false)) {
109
-			return false;
110
-		}
111
-
112
-		$path = $this->getPathToCertificates() . 'uploads/';
113
-		if (!$this->view->is_dir($path)) {
114
-			return false;
115
-		}
116
-		$result = [];
117
-		$handle = $this->view->opendir($path);
118
-		if (!is_resource($handle)) {
119
-			return false;
120
-		}
121
-		while (false !== ($file = readdir($handle))) {
122
-			if ($file !== '.' && $file !== '..') {
123
-				return true;
124
-			}
125
-		}
126
-		closedir($handle);
127
-		return false;
128
-	}
129
-
130
-	/**
131
-	 * create the certificate bundle of all trusted certificated
132
-	 */
133
-	public function createCertificateBundle() {
134
-		$path = $this->getPathToCertificates();
135
-		$certs = $this->listCertificates();
136
-
137
-		if (!$this->view->file_exists($path)) {
138
-			$this->view->mkdir($path);
139
-		}
140
-
141
-		$defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
142
-		if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle
143
-			// log as exception so we have a stacktrace
144
-			$this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'));
145
-			return;
146
-		}
147
-
148
-		$certPath = $path . 'rootcerts.crt';
149
-		$tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
150
-		$fhCerts = $this->view->fopen($tmpPath, 'w');
151
-
152
-		// Write user certificates
153
-		foreach ($certs as $cert) {
154
-			$file = $path . '/uploads/' . $cert->getName();
155
-			$data = $this->view->file_get_contents($file);
156
-			if (strpos($data, 'BEGIN CERTIFICATE')) {
157
-				fwrite($fhCerts, $data);
158
-				fwrite($fhCerts, "\r\n");
159
-			}
160
-		}
161
-
162
-		// Append the default certificates
163
-		fwrite($fhCerts, $defaultCertificates);
164
-
165
-		// Append the system certificate bundle
166
-		$systemBundle = $this->getCertificateBundle();
167
-		if ($systemBundle !== $certPath && $this->view->file_exists($systemBundle)) {
168
-			$systemCertificates = $this->view->file_get_contents($systemBundle);
169
-			fwrite($fhCerts, $systemCertificates);
170
-		}
171
-
172
-		fclose($fhCerts);
173
-
174
-		$this->view->rename($tmpPath, $certPath);
175
-	}
176
-
177
-	/**
178
-	 * Save the certificate and re-generate the certificate bundle
179
-	 *
180
-	 * @param string $certificate the certificate data
181
-	 * @param string $name the filename for the certificate
182
-	 * @return \OCP\ICertificate
183
-	 * @throws \Exception If the certificate could not get added
184
-	 */
185
-	public function addCertificate($certificate, $name) {
186
-		if (!Filesystem::isValidPath($name) or Filesystem::isFileBlacklisted($name)) {
187
-			throw new \Exception('Filename is not valid');
188
-		}
189
-
190
-		$dir = $this->getPathToCertificates() . 'uploads/';
191
-		if (!$this->view->file_exists($dir)) {
192
-			$this->view->mkdir($dir);
193
-		}
194
-
195
-		try {
196
-			$file = $dir . $name;
197
-			$certificateObject = new Certificate($certificate, $name);
198
-			$this->view->file_put_contents($file, $certificate);
199
-			$this->createCertificateBundle();
200
-			return $certificateObject;
201
-		} catch (\Exception $e) {
202
-			throw $e;
203
-		}
204
-	}
205
-
206
-	/**
207
-	 * Remove the certificate and re-generate the certificate bundle
208
-	 *
209
-	 * @param string $name
210
-	 * @return bool
211
-	 */
212
-	public function removeCertificate($name) {
213
-		if (!Filesystem::isValidPath($name)) {
214
-			return false;
215
-		}
216
-		$path = $this->getPathToCertificates() . 'uploads/';
217
-		if ($this->view->file_exists($path . $name)) {
218
-			$this->view->unlink($path . $name);
219
-			$this->createCertificateBundle();
220
-		}
221
-		return true;
222
-	}
223
-
224
-	/**
225
-	 * Get the path to the certificate bundle
226
-	 *
227
-	 * @return string
228
-	 */
229
-	public function getCertificateBundle() {
230
-		return $this->getPathToCertificates() . 'rootcerts.crt';
231
-	}
232
-
233
-	/**
234
-	 * Get the full local path to the certificate bundle
235
-	 *
236
-	 * @return string
237
-	 */
238
-	public function getAbsoluteBundlePath() {
239
-		if (!$this->hasCertificates()) {
240
-			return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
241
-		}
242
-
243
-		if ($this->needsRebundling()) {
244
-			$this->createCertificateBundle();
245
-		}
246
-
247
-		return $this->view->getLocalFile($this->getCertificateBundle());
248
-	}
249
-
250
-	/**
251
-	 * @return string
252
-	 */
253
-	private function getPathToCertificates() {
254
-		return '/files_external/';
255
-	}
256
-
257
-	/**
258
-	 * Check if we need to re-bundle the certificates because one of the sources has updated
259
-	 *
260
-	 * @return bool
261
-	 */
262
-	private function needsRebundling() {
263
-		$targetBundle = $this->getCertificateBundle();
264
-		if (!$this->view->file_exists($targetBundle)) {
265
-			return true;
266
-		}
267
-
268
-		$sourceMTime = $this->getFilemtimeOfCaBundle();
269
-		return $sourceMTime > $this->view->filemtime($targetBundle);
270
-	}
271
-
272
-	/**
273
-	 * get mtime of ca-bundle shipped by Nextcloud
274
-	 *
275
-	 * @return int
276
-	 */
277
-	protected function getFilemtimeOfCaBundle() {
278
-		return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
279
-	}
42
+    /**
43
+     * @var \OC\Files\View
44
+     */
45
+    protected $view;
46
+
47
+    /**
48
+     * @var IConfig
49
+     */
50
+    protected $config;
51
+
52
+    /**
53
+     * @var ILogger
54
+     */
55
+    protected $logger;
56
+
57
+    /** @var ISecureRandom */
58
+    protected $random;
59
+
60
+    /**
61
+     * @param \OC\Files\View $view relative to data/
62
+     * @param IConfig $config
63
+     * @param ILogger $logger
64
+     * @param ISecureRandom $random
65
+     */
66
+    public function __construct(\OC\Files\View $view,
67
+                                IConfig $config,
68
+                                ILogger $logger,
69
+                                ISecureRandom $random) {
70
+        $this->view = $view;
71
+        $this->config = $config;
72
+        $this->logger = $logger;
73
+        $this->random = $random;
74
+    }
75
+
76
+    /**
77
+     * Returns all certificates trusted by the user
78
+     *
79
+     * @return \OCP\ICertificate[]
80
+     */
81
+    public function listCertificates() {
82
+        if (!$this->config->getSystemValue('installed', false)) {
83
+            return [];
84
+        }
85
+
86
+        $path = $this->getPathToCertificates() . 'uploads/';
87
+        if (!$this->view->is_dir($path)) {
88
+            return [];
89
+        }
90
+        $result = [];
91
+        $handle = $this->view->opendir($path);
92
+        if (!is_resource($handle)) {
93
+            return [];
94
+        }
95
+        while (false !== ($file = readdir($handle))) {
96
+            if ($file != '.' && $file != '..') {
97
+                try {
98
+                    $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
99
+                } catch (\Exception $e) {
100
+                }
101
+            }
102
+        }
103
+        closedir($handle);
104
+        return $result;
105
+    }
106
+
107
+    private function hasCertificates(): bool {
108
+        if (!$this->config->getSystemValue('installed', false)) {
109
+            return false;
110
+        }
111
+
112
+        $path = $this->getPathToCertificates() . 'uploads/';
113
+        if (!$this->view->is_dir($path)) {
114
+            return false;
115
+        }
116
+        $result = [];
117
+        $handle = $this->view->opendir($path);
118
+        if (!is_resource($handle)) {
119
+            return false;
120
+        }
121
+        while (false !== ($file = readdir($handle))) {
122
+            if ($file !== '.' && $file !== '..') {
123
+                return true;
124
+            }
125
+        }
126
+        closedir($handle);
127
+        return false;
128
+    }
129
+
130
+    /**
131
+     * create the certificate bundle of all trusted certificated
132
+     */
133
+    public function createCertificateBundle() {
134
+        $path = $this->getPathToCertificates();
135
+        $certs = $this->listCertificates();
136
+
137
+        if (!$this->view->file_exists($path)) {
138
+            $this->view->mkdir($path);
139
+        }
140
+
141
+        $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
142
+        if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle
143
+            // log as exception so we have a stacktrace
144
+            $this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'));
145
+            return;
146
+        }
147
+
148
+        $certPath = $path . 'rootcerts.crt';
149
+        $tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
150
+        $fhCerts = $this->view->fopen($tmpPath, 'w');
151
+
152
+        // Write user certificates
153
+        foreach ($certs as $cert) {
154
+            $file = $path . '/uploads/' . $cert->getName();
155
+            $data = $this->view->file_get_contents($file);
156
+            if (strpos($data, 'BEGIN CERTIFICATE')) {
157
+                fwrite($fhCerts, $data);
158
+                fwrite($fhCerts, "\r\n");
159
+            }
160
+        }
161
+
162
+        // Append the default certificates
163
+        fwrite($fhCerts, $defaultCertificates);
164
+
165
+        // Append the system certificate bundle
166
+        $systemBundle = $this->getCertificateBundle();
167
+        if ($systemBundle !== $certPath && $this->view->file_exists($systemBundle)) {
168
+            $systemCertificates = $this->view->file_get_contents($systemBundle);
169
+            fwrite($fhCerts, $systemCertificates);
170
+        }
171
+
172
+        fclose($fhCerts);
173
+
174
+        $this->view->rename($tmpPath, $certPath);
175
+    }
176
+
177
+    /**
178
+     * Save the certificate and re-generate the certificate bundle
179
+     *
180
+     * @param string $certificate the certificate data
181
+     * @param string $name the filename for the certificate
182
+     * @return \OCP\ICertificate
183
+     * @throws \Exception If the certificate could not get added
184
+     */
185
+    public function addCertificate($certificate, $name) {
186
+        if (!Filesystem::isValidPath($name) or Filesystem::isFileBlacklisted($name)) {
187
+            throw new \Exception('Filename is not valid');
188
+        }
189
+
190
+        $dir = $this->getPathToCertificates() . 'uploads/';
191
+        if (!$this->view->file_exists($dir)) {
192
+            $this->view->mkdir($dir);
193
+        }
194
+
195
+        try {
196
+            $file = $dir . $name;
197
+            $certificateObject = new Certificate($certificate, $name);
198
+            $this->view->file_put_contents($file, $certificate);
199
+            $this->createCertificateBundle();
200
+            return $certificateObject;
201
+        } catch (\Exception $e) {
202
+            throw $e;
203
+        }
204
+    }
205
+
206
+    /**
207
+     * Remove the certificate and re-generate the certificate bundle
208
+     *
209
+     * @param string $name
210
+     * @return bool
211
+     */
212
+    public function removeCertificate($name) {
213
+        if (!Filesystem::isValidPath($name)) {
214
+            return false;
215
+        }
216
+        $path = $this->getPathToCertificates() . 'uploads/';
217
+        if ($this->view->file_exists($path . $name)) {
218
+            $this->view->unlink($path . $name);
219
+            $this->createCertificateBundle();
220
+        }
221
+        return true;
222
+    }
223
+
224
+    /**
225
+     * Get the path to the certificate bundle
226
+     *
227
+     * @return string
228
+     */
229
+    public function getCertificateBundle() {
230
+        return $this->getPathToCertificates() . 'rootcerts.crt';
231
+    }
232
+
233
+    /**
234
+     * Get the full local path to the certificate bundle
235
+     *
236
+     * @return string
237
+     */
238
+    public function getAbsoluteBundlePath() {
239
+        if (!$this->hasCertificates()) {
240
+            return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
241
+        }
242
+
243
+        if ($this->needsRebundling()) {
244
+            $this->createCertificateBundle();
245
+        }
246
+
247
+        return $this->view->getLocalFile($this->getCertificateBundle());
248
+    }
249
+
250
+    /**
251
+     * @return string
252
+     */
253
+    private function getPathToCertificates() {
254
+        return '/files_external/';
255
+    }
256
+
257
+    /**
258
+     * Check if we need to re-bundle the certificates because one of the sources has updated
259
+     *
260
+     * @return bool
261
+     */
262
+    private function needsRebundling() {
263
+        $targetBundle = $this->getCertificateBundle();
264
+        if (!$this->view->file_exists($targetBundle)) {
265
+            return true;
266
+        }
267
+
268
+        $sourceMTime = $this->getFilemtimeOfCaBundle();
269
+        return $sourceMTime > $this->view->filemtime($targetBundle);
270
+    }
271
+
272
+    /**
273
+     * get mtime of ca-bundle shipped by Nextcloud
274
+     *
275
+     * @return int
276
+     */
277
+    protected function getFilemtimeOfCaBundle() {
278
+        return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
279
+    }
280 280
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			return [];
84 84
 		}
85 85
 
86
-		$path = $this->getPathToCertificates() . 'uploads/';
86
+		$path = $this->getPathToCertificates().'uploads/';
87 87
 		if (!$this->view->is_dir($path)) {
88 88
 			return [];
89 89
 		}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		while (false !== ($file = readdir($handle))) {
96 96
 			if ($file != '.' && $file != '..') {
97 97
 				try {
98
-					$result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
98
+					$result[] = new Certificate($this->view->file_get_contents($path.$file), $file);
99 99
 				} catch (\Exception $e) {
100 100
 				}
101 101
 			}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			return false;
110 110
 		}
111 111
 
112
-		$path = $this->getPathToCertificates() . 'uploads/';
112
+		$path = $this->getPathToCertificates().'uploads/';
113 113
 		if (!$this->view->is_dir($path)) {
114 114
 			return false;
115 115
 		}
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
 			$this->view->mkdir($path);
139 139
 		}
140 140
 
141
-		$defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
141
+		$defaultCertificates = file_get_contents(\OC::$SERVERROOT.'/resources/config/ca-bundle.crt');
142 142
 		if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle
143 143
 			// log as exception so we have a stacktrace
144 144
 			$this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'));
145 145
 			return;
146 146
 		}
147 147
 
148
-		$certPath = $path . 'rootcerts.crt';
149
-		$tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
148
+		$certPath = $path.'rootcerts.crt';
149
+		$tmpPath = $certPath.'.tmp'.$this->random->generate(10, ISecureRandom::CHAR_DIGITS);
150 150
 		$fhCerts = $this->view->fopen($tmpPath, 'w');
151 151
 
152 152
 		// Write user certificates
153 153
 		foreach ($certs as $cert) {
154
-			$file = $path . '/uploads/' . $cert->getName();
154
+			$file = $path.'/uploads/'.$cert->getName();
155 155
 			$data = $this->view->file_get_contents($file);
156 156
 			if (strpos($data, 'BEGIN CERTIFICATE')) {
157 157
 				fwrite($fhCerts, $data);
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 			throw new \Exception('Filename is not valid');
188 188
 		}
189 189
 
190
-		$dir = $this->getPathToCertificates() . 'uploads/';
190
+		$dir = $this->getPathToCertificates().'uploads/';
191 191
 		if (!$this->view->file_exists($dir)) {
192 192
 			$this->view->mkdir($dir);
193 193
 		}
194 194
 
195 195
 		try {
196
-			$file = $dir . $name;
196
+			$file = $dir.$name;
197 197
 			$certificateObject = new Certificate($certificate, $name);
198 198
 			$this->view->file_put_contents($file, $certificate);
199 199
 			$this->createCertificateBundle();
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 		if (!Filesystem::isValidPath($name)) {
214 214
 			return false;
215 215
 		}
216
-		$path = $this->getPathToCertificates() . 'uploads/';
217
-		if ($this->view->file_exists($path . $name)) {
218
-			$this->view->unlink($path . $name);
216
+		$path = $this->getPathToCertificates().'uploads/';
217
+		if ($this->view->file_exists($path.$name)) {
218
+			$this->view->unlink($path.$name);
219 219
 			$this->createCertificateBundle();
220 220
 		}
221 221
 		return true;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @return string
228 228
 	 */
229 229
 	public function getCertificateBundle() {
230
-		return $this->getPathToCertificates() . 'rootcerts.crt';
230
+		return $this->getPathToCertificates().'rootcerts.crt';
231 231
 	}
232 232
 
233 233
 	/**
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function getAbsoluteBundlePath() {
239 239
 		if (!$this->hasCertificates()) {
240
-			return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
240
+			return \OC::$SERVERROOT.'/resources/config/ca-bundle.crt';
241 241
 		}
242 242
 
243 243
 		if ($this->needsRebundling()) {
@@ -275,6 +275,6 @@  discard block
 block discarded – undo
275 275
 	 * @return int
276 276
 	 */
277 277
 	protected function getFilemtimeOfCaBundle() {
278
-		return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
278
+		return filemtime(\OC::$SERVERROOT.'/resources/config/ca-bundle.crt');
279 279
 	}
280 280
 }
Please login to merge, or discard this patch.
lib/public/ICertificateManager.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -29,42 +29,42 @@
 block discarded – undo
29 29
  * @since 8.0.0
30 30
  */
31 31
 interface ICertificateManager {
32
-	/**
33
-	 * Returns all certificates trusted by the system
34
-	 *
35
-	 * @return \OCP\ICertificate[]
36
-	 * @since 8.0.0
37
-	 */
38
-	public function listCertificates();
32
+    /**
33
+     * Returns all certificates trusted by the system
34
+     *
35
+     * @return \OCP\ICertificate[]
36
+     * @since 8.0.0
37
+     */
38
+    public function listCertificates();
39 39
 
40
-	/**
41
-	 * @param string $certificate the certificate data
42
-	 * @param string $name the filename for the certificate
43
-	 * @return \OCP\ICertificate
44
-	 * @throws \Exception If the certificate could not get added
45
-	 * @since 8.0.0 - since 8.1.0 throws exception instead of returning false
46
-	 */
47
-	public function addCertificate($certificate, $name);
40
+    /**
41
+     * @param string $certificate the certificate data
42
+     * @param string $name the filename for the certificate
43
+     * @return \OCP\ICertificate
44
+     * @throws \Exception If the certificate could not get added
45
+     * @since 8.0.0 - since 8.1.0 throws exception instead of returning false
46
+     */
47
+    public function addCertificate($certificate, $name);
48 48
 
49
-	/**
50
-	 * @param string $name
51
-	 * @since 8.0.0
52
-	 */
53
-	public function removeCertificate($name);
49
+    /**
50
+     * @param string $name
51
+     * @since 8.0.0
52
+     */
53
+    public function removeCertificate($name);
54 54
 
55
-	/**
56
-	 * Get the path to the certificate bundle
57
-	 *
58
-	 * @return string
59
-	 * @since 8.0.0
60
-	 */
61
-	public function getCertificateBundle();
55
+    /**
56
+     * Get the path to the certificate bundle
57
+     *
58
+     * @return string
59
+     * @since 8.0.0
60
+     */
61
+    public function getCertificateBundle();
62 62
 
63
-	/**
64
-	 * Get the full local path to the certificate bundle
65
-	 *
66
-	 * @return string
67
-	 * @since 9.0.0
68
-	 */
69
-	public function getAbsoluteBundlePath();
63
+    /**
64
+     * Get the full local path to the certificate bundle
65
+     *
66
+     * @return string
67
+     * @since 9.0.0
68
+     */
69
+    public function getAbsoluteBundlePath();
70 70
 }
Please login to merge, or discard this patch.
lib/public/IServerContainer.php 1 patch
Indentation   +588 added lines, -588 removed lines patch added patch discarded remove patch
@@ -60,592 +60,592 @@
 block discarded – undo
60 60
  */
61 61
 interface IServerContainer extends ContainerInterface, 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
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
70
-	 */
71
-	public function getCalendarManager();
72
-
73
-	/**
74
-	 * The calendar resource backend manager will act as a broker between consumers
75
-	 * for calendar resource information an providers which actual deliver the room information.
76
-	 *
77
-	 * @return \OCP\Calendar\Resource\IBackend
78
-	 * @since 14.0.0
79
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
80
-	 */
81
-	public function getCalendarResourceBackendManager();
82
-
83
-	/**
84
-	 * The calendar room backend manager will act as a broker between consumers
85
-	 * for calendar room information an providers which actual deliver the room information.
86
-	 *
87
-	 * @return \OCP\Calendar\Room\IBackend
88
-	 * @since 14.0.0
89
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
90
-	 */
91
-	public function getCalendarRoomBackendManager();
92
-
93
-	/**
94
-	 * The contacts manager will act as a broker between consumers for contacts information and
95
-	 * providers which actual deliver the contact information.
96
-	 *
97
-	 * @return \OCP\Contacts\IManager
98
-	 * @since 6.0.0
99
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
100
-	 */
101
-	public function getContactsManager();
102
-
103
-	/**
104
-	 * The current request object holding all information about the request currently being processed
105
-	 * is returned from this method.
106
-	 * In case the current execution was not initiated by a web request null is returned
107
-	 *
108
-	 * @return \OCP\IRequest
109
-	 * @since 6.0.0
110
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
111
-	 */
112
-	public function getRequest();
113
-
114
-	/**
115
-	 * Returns the preview manager which can create preview images for a given file
116
-	 *
117
-	 * @return \OCP\IPreview
118
-	 * @since 6.0.0
119
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
120
-	 */
121
-	public function getPreviewManager();
122
-
123
-	/**
124
-	 * Returns the tag manager which can get and set tags for different object types
125
-	 *
126
-	 * @see \OCP\ITagManager::load()
127
-	 * @return \OCP\ITagManager
128
-	 * @since 6.0.0
129
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
130
-	 */
131
-	public function getTagManager();
132
-
133
-	/**
134
-	 * Returns the root folder of ownCloud's data directory
135
-	 *
136
-	 * @return \OCP\Files\IRootFolder
137
-	 * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
138
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
139
-	 */
140
-	public function getRootFolder();
141
-
142
-	/**
143
-	 * Returns a view to ownCloud's files folder
144
-	 *
145
-	 * @param string $userId user ID
146
-	 * @return \OCP\Files\Folder
147
-	 * @since 6.0.0 - parameter $userId was added in 8.0.0
148
-	 * @see getUserFolder in \OCP\Files\IRootFolder
149
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
150
-	 */
151
-	public function getUserFolder($userId = null);
152
-
153
-	/**
154
-	 * Returns a user manager
155
-	 *
156
-	 * @return \OCP\IUserManager
157
-	 * @since 8.0.0
158
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
159
-	 */
160
-	public function getUserManager();
161
-
162
-	/**
163
-	 * Returns a group manager
164
-	 *
165
-	 * @return \OCP\IGroupManager
166
-	 * @since 8.0.0
167
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
168
-	 */
169
-	public function getGroupManager();
170
-
171
-	/**
172
-	 * Returns the user session
173
-	 *
174
-	 * @return \OCP\IUserSession
175
-	 * @since 6.0.0
176
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
177
-	 */
178
-	public function getUserSession();
179
-
180
-	/**
181
-	 * Returns the navigation manager
182
-	 *
183
-	 * @return \OCP\INavigationManager
184
-	 * @since 6.0.0
185
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
186
-	 */
187
-	public function getNavigationManager();
188
-
189
-	/**
190
-	 * Returns the config manager
191
-	 *
192
-	 * @return \OCP\IConfig
193
-	 * @since 6.0.0
194
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
195
-	 */
196
-	public function getConfig();
197
-
198
-	/**
199
-	 * Returns a Crypto instance
200
-	 *
201
-	 * @return \OCP\Security\ICrypto
202
-	 * @since 8.0.0
203
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
204
-	 */
205
-	public function getCrypto();
206
-
207
-	/**
208
-	 * Returns a Hasher instance
209
-	 *
210
-	 * @return \OCP\Security\IHasher
211
-	 * @since 8.0.0
212
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
213
-	 */
214
-	public function getHasher();
215
-
216
-	/**
217
-	 * Returns a SecureRandom instance
218
-	 *
219
-	 * @return \OCP\Security\ISecureRandom
220
-	 * @since 8.1.0
221
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
222
-	 */
223
-	public function getSecureRandom();
224
-
225
-	/**
226
-	 * Returns a CredentialsManager instance
227
-	 *
228
-	 * @return \OCP\Security\ICredentialsManager
229
-	 * @since 9.0.0
230
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
231
-	 */
232
-	public function getCredentialsManager();
233
-
234
-	/**
235
-	 * Returns the app config manager
236
-	 *
237
-	 * @return \OCP\IAppConfig
238
-	 * @since 7.0.0
239
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
240
-	 */
241
-	public function getAppConfig();
242
-
243
-	/**
244
-	 * @return \OCP\L10N\IFactory
245
-	 * @since 8.2.0
246
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
247
-	 */
248
-	public function getL10NFactory();
249
-
250
-	/**
251
-	 * get an L10N instance
252
-	 * @param string $app appid
253
-	 * @param string $lang
254
-	 * @return \OCP\IL10N
255
-	 * @since 6.0.0 - parameter $lang was added in 8.0.0
256
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
257
-	 */
258
-	public function getL10N($app, $lang = null);
259
-
260
-	/**
261
-	 * @return \OC\Encryption\Manager
262
-	 * @since 8.1.0
263
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
264
-	 */
265
-	public function getEncryptionManager();
266
-
267
-	/**
268
-	 * @return \OC\Encryption\File
269
-	 * @since 8.1.0
270
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
271
-	 */
272
-	public function getEncryptionFilesHelper();
273
-
274
-	/**
275
-	 * @return \OCP\Encryption\Keys\IStorage
276
-	 * @since 8.1.0
277
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
278
-	 */
279
-	public function getEncryptionKeyStorage();
280
-
281
-	/**
282
-	 * Returns the URL generator
283
-	 *
284
-	 * @return \OCP\IURLGenerator
285
-	 * @since 6.0.0
286
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
287
-	 */
288
-	public function getURLGenerator();
289
-
290
-	/**
291
-	 * Returns an ICache instance
292
-	 *
293
-	 * @return \OCP\ICache
294
-	 * @since 6.0.0
295
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
296
-	 */
297
-	public function getCache();
298
-
299
-	/**
300
-	 * Returns an \OCP\CacheFactory instance
301
-	 *
302
-	 * @return \OCP\ICacheFactory
303
-	 * @since 7.0.0
304
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
305
-	 */
306
-	public function getMemCacheFactory();
307
-
308
-	/**
309
-	 * Returns the current session
310
-	 *
311
-	 * @return \OCP\ISession
312
-	 * @since 6.0.0
313
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
314
-	 */
315
-	public function getSession();
316
-
317
-	/**
318
-	 * Returns the activity manager
319
-	 *
320
-	 * @return \OCP\Activity\IManager
321
-	 * @since 6.0.0
322
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
323
-	 */
324
-	public function getActivityManager();
325
-
326
-	/**
327
-	 * Returns the current session
328
-	 *
329
-	 * @return \OCP\IDBConnection
330
-	 * @since 6.0.0
331
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
332
-	 */
333
-	public function getDatabaseConnection();
334
-
335
-	/**
336
-	 * Returns an avatar manager, used for avatar functionality
337
-	 *
338
-	 * @return \OCP\IAvatarManager
339
-	 * @since 6.0.0
340
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
341
-	 */
342
-	public function getAvatarManager();
343
-
344
-	/**
345
-	 * Returns an job list for controlling background jobs
346
-	 *
347
-	 * @return \OCP\BackgroundJob\IJobList
348
-	 * @since 7.0.0
349
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
350
-	 */
351
-	public function getJobList();
352
-
353
-	/**
354
-	 * Returns a logger instance
355
-	 *
356
-	 * @return \OCP\ILogger
357
-	 * @since 8.0.0
358
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
359
-	 */
360
-	public function getLogger();
361
-
362
-	/**
363
-	 * returns a log factory instance
364
-	 *
365
-	 * @return ILogFactory
366
-	 * @since 14.0.0
367
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
368
-	 */
369
-	public function getLogFactory();
370
-
371
-	/**
372
-	 * Returns a router for generating and matching urls
373
-	 *
374
-	 * @return \OCP\Route\IRouter
375
-	 * @since 7.0.0
376
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
377
-	 */
378
-	public function getRouter();
379
-
380
-	/**
381
-	 * Returns a search instance
382
-	 *
383
-	 * @return \OCP\ISearch
384
-	 * @since 7.0.0
385
-	 * @deprecated 20.0.0
386
-	 */
387
-	public function getSearch();
388
-
389
-	/**
390
-	 * Get the certificate manager
391
-	 *
392
-	 * @return \OCP\ICertificateManager
393
-	 * @since 8.0.0
394
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
395
-	 */
396
-	public function getCertificateManager();
397
-
398
-	/**
399
-	 * Create a new event source
400
-	 *
401
-	 * @return \OCP\IEventSource
402
-	 * @since 8.0.0
403
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
404
-	 */
405
-	public function createEventSource();
406
-
407
-	/**
408
-	 * Returns an instance of the HTTP client service
409
-	 *
410
-	 * @return \OCP\Http\Client\IClientService
411
-	 * @since 8.1.0
412
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
413
-	 */
414
-	public function getHTTPClientService();
415
-
416
-	/**
417
-	 * Get the active event logger
418
-	 *
419
-	 * @return \OCP\Diagnostics\IEventLogger
420
-	 * @since 8.0.0
421
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
422
-	 */
423
-	public function getEventLogger();
424
-
425
-	/**
426
-	 * Get the active query logger
427
-	 *
428
-	 * The returned logger only logs data when debug mode is enabled
429
-	 *
430
-	 * @return \OCP\Diagnostics\IQueryLogger
431
-	 * @since 8.0.0
432
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
433
-	 */
434
-	public function getQueryLogger();
435
-
436
-	/**
437
-	 * Get the manager for temporary files and folders
438
-	 *
439
-	 * @return \OCP\ITempManager
440
-	 * @since 8.0.0
441
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
442
-	 */
443
-	public function getTempManager();
444
-
445
-	/**
446
-	 * Get the app manager
447
-	 *
448
-	 * @return \OCP\App\IAppManager
449
-	 * @since 8.0.0
450
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
451
-	 */
452
-	public function getAppManager();
453
-
454
-	/**
455
-	 * Get the webroot
456
-	 *
457
-	 * @return string
458
-	 * @since 8.0.0
459
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
460
-	 */
461
-	public function getWebRoot();
462
-
463
-	/**
464
-	 * @return \OCP\Files\Config\IMountProviderCollection
465
-	 * @since 8.0.0
466
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
467
-	 */
468
-	public function getMountProviderCollection();
469
-
470
-	/**
471
-	 * Get the IniWrapper
472
-	 *
473
-	 * @return \bantu\IniGetWrapper\IniGetWrapper
474
-	 * @since 8.0.0
475
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
476
-	 */
477
-	public function getIniWrapper();
478
-	/**
479
-	 * @return \OCP\Command\IBus
480
-	 * @since 8.1.0
481
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
482
-	 */
483
-	public function getCommandBus();
484
-
485
-	/**
486
-	 * Creates a new mailer
487
-	 *
488
-	 * @return \OCP\Mail\IMailer
489
-	 * @since 8.1.0
490
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
491
-	 */
492
-	public function getMailer();
493
-
494
-	/**
495
-	 * Get the locking provider
496
-	 *
497
-	 * @return \OCP\Lock\ILockingProvider
498
-	 * @since 8.1.0
499
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
500
-	 */
501
-	public function getLockingProvider();
502
-
503
-	/**
504
-	 * @return \OCP\Files\Mount\IMountManager
505
-	 * @since 8.2.0
506
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
507
-	 */
508
-	public function getMountManager();
509
-
510
-	/**
511
-	 * Get the MimeTypeDetector
512
-	 *
513
-	 * @return \OCP\Files\IMimeTypeDetector
514
-	 * @since 8.2.0
515
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
516
-	 */
517
-	public function getMimeTypeDetector();
518
-
519
-	/**
520
-	 * Get the MimeTypeLoader
521
-	 *
522
-	 * @return \OCP\Files\IMimeTypeLoader
523
-	 * @since 8.2.0
524
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
525
-	 */
526
-	public function getMimeTypeLoader();
527
-
528
-	/**
529
-	 * Get the EventDispatcher
530
-	 *
531
-	 * @return EventDispatcherInterface
532
-	 * @deprecated 20.0.0 use \OCP\EventDispatcher\IEventDispatcher
533
-	 * @since 8.2.0
534
-	 */
535
-	public function getEventDispatcher();
536
-
537
-	/**
538
-	 * Get the Notification Manager
539
-	 *
540
-	 * @return \OCP\Notification\IManager
541
-	 * @since 9.0.0
542
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
543
-	 */
544
-	public function getNotificationManager();
545
-
546
-	/**
547
-	 * @return \OCP\Comments\ICommentsManager
548
-	 * @since 9.0.0
549
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
550
-	 */
551
-	public function getCommentsManager();
552
-
553
-	/**
554
-	 * Returns the system-tag manager
555
-	 *
556
-	 * @return \OCP\SystemTag\ISystemTagManager
557
-	 *
558
-	 * @since 9.0.0
559
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
560
-	 */
561
-	public function getSystemTagManager();
562
-
563
-	/**
564
-	 * Returns the system-tag object mapper
565
-	 *
566
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
567
-	 *
568
-	 * @since 9.0.0
569
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
570
-	 */
571
-	public function getSystemTagObjectMapper();
572
-
573
-	/**
574
-	 * Returns the share manager
575
-	 *
576
-	 * @return \OCP\Share\IManager
577
-	 * @since 9.0.0
578
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
579
-	 */
580
-	public function getShareManager();
581
-
582
-	/**
583
-	 * @return IContentSecurityPolicyManager
584
-	 * @since 9.0.0
585
-	 * @deprecated 17.0.0 Use the AddContentSecurityPolicyEvent
586
-	 */
587
-	public function getContentSecurityPolicyManager();
588
-
589
-	/**
590
-	 * @return \OCP\IDateTimeZone
591
-	 * @since 8.0.0
592
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
593
-	 */
594
-	public function getDateTimeZone();
595
-
596
-	/**
597
-	 * @return \OCP\IDateTimeFormatter
598
-	 * @since 8.0.0
599
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
600
-	 */
601
-	public function getDateTimeFormatter();
602
-
603
-	/**
604
-	 * @return \OCP\Federation\ICloudIdManager
605
-	 * @since 12.0.0
606
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
607
-	 */
608
-	public function getCloudIdManager();
609
-
610
-	/**
611
-	 * @return \OCP\GlobalScale\IConfig
612
-	 * @since 14.0.0
613
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
614
-	 */
615
-	public function getGlobalScaleConfig();
616
-
617
-	/**
618
-	 * @return ICloudFederationFactory
619
-	 * @since 14.0.0
620
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
621
-	 */
622
-	public function getCloudFederationFactory();
623
-
624
-	/**
625
-	 * @return ICloudFederationProviderManager
626
-	 * @since 14.0.0
627
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
628
-	 */
629
-	public function getCloudFederationProviderManager();
630
-
631
-	/**
632
-	 * @return \OCP\Remote\Api\IApiFactory
633
-	 * @since 13.0.0
634
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
635
-	 */
636
-	public function getRemoteApiFactory();
637
-
638
-	/**
639
-	 * @return \OCP\Remote\IInstanceFactory
640
-	 * @since 13.0.0
641
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
642
-	 */
643
-	public function getRemoteInstanceFactory();
644
-
645
-	/**
646
-	 * @return \OCP\Files\Storage\IStorageFactory
647
-	 * @since 15.0.0
648
-	 * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
649
-	 */
650
-	public function getStorageFactory();
63
+    /**
64
+     * The calendar manager will act as a broker between consumers for calendar information and
65
+     * providers which actual deliver the calendar information.
66
+     *
67
+     * @return \OCP\Calendar\IManager
68
+     * @since 13.0.0
69
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
70
+     */
71
+    public function getCalendarManager();
72
+
73
+    /**
74
+     * The calendar resource backend manager will act as a broker between consumers
75
+     * for calendar resource information an providers which actual deliver the room information.
76
+     *
77
+     * @return \OCP\Calendar\Resource\IBackend
78
+     * @since 14.0.0
79
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
80
+     */
81
+    public function getCalendarResourceBackendManager();
82
+
83
+    /**
84
+     * The calendar room backend manager will act as a broker between consumers
85
+     * for calendar room information an providers which actual deliver the room information.
86
+     *
87
+     * @return \OCP\Calendar\Room\IBackend
88
+     * @since 14.0.0
89
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
90
+     */
91
+    public function getCalendarRoomBackendManager();
92
+
93
+    /**
94
+     * The contacts manager will act as a broker between consumers for contacts information and
95
+     * providers which actual deliver the contact information.
96
+     *
97
+     * @return \OCP\Contacts\IManager
98
+     * @since 6.0.0
99
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
100
+     */
101
+    public function getContactsManager();
102
+
103
+    /**
104
+     * The current request object holding all information about the request currently being processed
105
+     * is returned from this method.
106
+     * In case the current execution was not initiated by a web request null is returned
107
+     *
108
+     * @return \OCP\IRequest
109
+     * @since 6.0.0
110
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
111
+     */
112
+    public function getRequest();
113
+
114
+    /**
115
+     * Returns the preview manager which can create preview images for a given file
116
+     *
117
+     * @return \OCP\IPreview
118
+     * @since 6.0.0
119
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
120
+     */
121
+    public function getPreviewManager();
122
+
123
+    /**
124
+     * Returns the tag manager which can get and set tags for different object types
125
+     *
126
+     * @see \OCP\ITagManager::load()
127
+     * @return \OCP\ITagManager
128
+     * @since 6.0.0
129
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
130
+     */
131
+    public function getTagManager();
132
+
133
+    /**
134
+     * Returns the root folder of ownCloud's data directory
135
+     *
136
+     * @return \OCP\Files\IRootFolder
137
+     * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
138
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
139
+     */
140
+    public function getRootFolder();
141
+
142
+    /**
143
+     * Returns a view to ownCloud's files folder
144
+     *
145
+     * @param string $userId user ID
146
+     * @return \OCP\Files\Folder
147
+     * @since 6.0.0 - parameter $userId was added in 8.0.0
148
+     * @see getUserFolder in \OCP\Files\IRootFolder
149
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
150
+     */
151
+    public function getUserFolder($userId = null);
152
+
153
+    /**
154
+     * Returns a user manager
155
+     *
156
+     * @return \OCP\IUserManager
157
+     * @since 8.0.0
158
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
159
+     */
160
+    public function getUserManager();
161
+
162
+    /**
163
+     * Returns a group manager
164
+     *
165
+     * @return \OCP\IGroupManager
166
+     * @since 8.0.0
167
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
168
+     */
169
+    public function getGroupManager();
170
+
171
+    /**
172
+     * Returns the user session
173
+     *
174
+     * @return \OCP\IUserSession
175
+     * @since 6.0.0
176
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
177
+     */
178
+    public function getUserSession();
179
+
180
+    /**
181
+     * Returns the navigation manager
182
+     *
183
+     * @return \OCP\INavigationManager
184
+     * @since 6.0.0
185
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
186
+     */
187
+    public function getNavigationManager();
188
+
189
+    /**
190
+     * Returns the config manager
191
+     *
192
+     * @return \OCP\IConfig
193
+     * @since 6.0.0
194
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
195
+     */
196
+    public function getConfig();
197
+
198
+    /**
199
+     * Returns a Crypto instance
200
+     *
201
+     * @return \OCP\Security\ICrypto
202
+     * @since 8.0.0
203
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
204
+     */
205
+    public function getCrypto();
206
+
207
+    /**
208
+     * Returns a Hasher instance
209
+     *
210
+     * @return \OCP\Security\IHasher
211
+     * @since 8.0.0
212
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
213
+     */
214
+    public function getHasher();
215
+
216
+    /**
217
+     * Returns a SecureRandom instance
218
+     *
219
+     * @return \OCP\Security\ISecureRandom
220
+     * @since 8.1.0
221
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
222
+     */
223
+    public function getSecureRandom();
224
+
225
+    /**
226
+     * Returns a CredentialsManager instance
227
+     *
228
+     * @return \OCP\Security\ICredentialsManager
229
+     * @since 9.0.0
230
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
231
+     */
232
+    public function getCredentialsManager();
233
+
234
+    /**
235
+     * Returns the app config manager
236
+     *
237
+     * @return \OCP\IAppConfig
238
+     * @since 7.0.0
239
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
240
+     */
241
+    public function getAppConfig();
242
+
243
+    /**
244
+     * @return \OCP\L10N\IFactory
245
+     * @since 8.2.0
246
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
247
+     */
248
+    public function getL10NFactory();
249
+
250
+    /**
251
+     * get an L10N instance
252
+     * @param string $app appid
253
+     * @param string $lang
254
+     * @return \OCP\IL10N
255
+     * @since 6.0.0 - parameter $lang was added in 8.0.0
256
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
257
+     */
258
+    public function getL10N($app, $lang = null);
259
+
260
+    /**
261
+     * @return \OC\Encryption\Manager
262
+     * @since 8.1.0
263
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
264
+     */
265
+    public function getEncryptionManager();
266
+
267
+    /**
268
+     * @return \OC\Encryption\File
269
+     * @since 8.1.0
270
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
271
+     */
272
+    public function getEncryptionFilesHelper();
273
+
274
+    /**
275
+     * @return \OCP\Encryption\Keys\IStorage
276
+     * @since 8.1.0
277
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
278
+     */
279
+    public function getEncryptionKeyStorage();
280
+
281
+    /**
282
+     * Returns the URL generator
283
+     *
284
+     * @return \OCP\IURLGenerator
285
+     * @since 6.0.0
286
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
287
+     */
288
+    public function getURLGenerator();
289
+
290
+    /**
291
+     * Returns an ICache instance
292
+     *
293
+     * @return \OCP\ICache
294
+     * @since 6.0.0
295
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
296
+     */
297
+    public function getCache();
298
+
299
+    /**
300
+     * Returns an \OCP\CacheFactory instance
301
+     *
302
+     * @return \OCP\ICacheFactory
303
+     * @since 7.0.0
304
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
305
+     */
306
+    public function getMemCacheFactory();
307
+
308
+    /**
309
+     * Returns the current session
310
+     *
311
+     * @return \OCP\ISession
312
+     * @since 6.0.0
313
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
314
+     */
315
+    public function getSession();
316
+
317
+    /**
318
+     * Returns the activity manager
319
+     *
320
+     * @return \OCP\Activity\IManager
321
+     * @since 6.0.0
322
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
323
+     */
324
+    public function getActivityManager();
325
+
326
+    /**
327
+     * Returns the current session
328
+     *
329
+     * @return \OCP\IDBConnection
330
+     * @since 6.0.0
331
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
332
+     */
333
+    public function getDatabaseConnection();
334
+
335
+    /**
336
+     * Returns an avatar manager, used for avatar functionality
337
+     *
338
+     * @return \OCP\IAvatarManager
339
+     * @since 6.0.0
340
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
341
+     */
342
+    public function getAvatarManager();
343
+
344
+    /**
345
+     * Returns an job list for controlling background jobs
346
+     *
347
+     * @return \OCP\BackgroundJob\IJobList
348
+     * @since 7.0.0
349
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
350
+     */
351
+    public function getJobList();
352
+
353
+    /**
354
+     * Returns a logger instance
355
+     *
356
+     * @return \OCP\ILogger
357
+     * @since 8.0.0
358
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
359
+     */
360
+    public function getLogger();
361
+
362
+    /**
363
+     * returns a log factory instance
364
+     *
365
+     * @return ILogFactory
366
+     * @since 14.0.0
367
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
368
+     */
369
+    public function getLogFactory();
370
+
371
+    /**
372
+     * Returns a router for generating and matching urls
373
+     *
374
+     * @return \OCP\Route\IRouter
375
+     * @since 7.0.0
376
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
377
+     */
378
+    public function getRouter();
379
+
380
+    /**
381
+     * Returns a search instance
382
+     *
383
+     * @return \OCP\ISearch
384
+     * @since 7.0.0
385
+     * @deprecated 20.0.0
386
+     */
387
+    public function getSearch();
388
+
389
+    /**
390
+     * Get the certificate manager
391
+     *
392
+     * @return \OCP\ICertificateManager
393
+     * @since 8.0.0
394
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
395
+     */
396
+    public function getCertificateManager();
397
+
398
+    /**
399
+     * Create a new event source
400
+     *
401
+     * @return \OCP\IEventSource
402
+     * @since 8.0.0
403
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
404
+     */
405
+    public function createEventSource();
406
+
407
+    /**
408
+     * Returns an instance of the HTTP client service
409
+     *
410
+     * @return \OCP\Http\Client\IClientService
411
+     * @since 8.1.0
412
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
413
+     */
414
+    public function getHTTPClientService();
415
+
416
+    /**
417
+     * Get the active event logger
418
+     *
419
+     * @return \OCP\Diagnostics\IEventLogger
420
+     * @since 8.0.0
421
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
422
+     */
423
+    public function getEventLogger();
424
+
425
+    /**
426
+     * Get the active query logger
427
+     *
428
+     * The returned logger only logs data when debug mode is enabled
429
+     *
430
+     * @return \OCP\Diagnostics\IQueryLogger
431
+     * @since 8.0.0
432
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
433
+     */
434
+    public function getQueryLogger();
435
+
436
+    /**
437
+     * Get the manager for temporary files and folders
438
+     *
439
+     * @return \OCP\ITempManager
440
+     * @since 8.0.0
441
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
442
+     */
443
+    public function getTempManager();
444
+
445
+    /**
446
+     * Get the app manager
447
+     *
448
+     * @return \OCP\App\IAppManager
449
+     * @since 8.0.0
450
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
451
+     */
452
+    public function getAppManager();
453
+
454
+    /**
455
+     * Get the webroot
456
+     *
457
+     * @return string
458
+     * @since 8.0.0
459
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
460
+     */
461
+    public function getWebRoot();
462
+
463
+    /**
464
+     * @return \OCP\Files\Config\IMountProviderCollection
465
+     * @since 8.0.0
466
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
467
+     */
468
+    public function getMountProviderCollection();
469
+
470
+    /**
471
+     * Get the IniWrapper
472
+     *
473
+     * @return \bantu\IniGetWrapper\IniGetWrapper
474
+     * @since 8.0.0
475
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
476
+     */
477
+    public function getIniWrapper();
478
+    /**
479
+     * @return \OCP\Command\IBus
480
+     * @since 8.1.0
481
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
482
+     */
483
+    public function getCommandBus();
484
+
485
+    /**
486
+     * Creates a new mailer
487
+     *
488
+     * @return \OCP\Mail\IMailer
489
+     * @since 8.1.0
490
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
491
+     */
492
+    public function getMailer();
493
+
494
+    /**
495
+     * Get the locking provider
496
+     *
497
+     * @return \OCP\Lock\ILockingProvider
498
+     * @since 8.1.0
499
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
500
+     */
501
+    public function getLockingProvider();
502
+
503
+    /**
504
+     * @return \OCP\Files\Mount\IMountManager
505
+     * @since 8.2.0
506
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
507
+     */
508
+    public function getMountManager();
509
+
510
+    /**
511
+     * Get the MimeTypeDetector
512
+     *
513
+     * @return \OCP\Files\IMimeTypeDetector
514
+     * @since 8.2.0
515
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
516
+     */
517
+    public function getMimeTypeDetector();
518
+
519
+    /**
520
+     * Get the MimeTypeLoader
521
+     *
522
+     * @return \OCP\Files\IMimeTypeLoader
523
+     * @since 8.2.0
524
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
525
+     */
526
+    public function getMimeTypeLoader();
527
+
528
+    /**
529
+     * Get the EventDispatcher
530
+     *
531
+     * @return EventDispatcherInterface
532
+     * @deprecated 20.0.0 use \OCP\EventDispatcher\IEventDispatcher
533
+     * @since 8.2.0
534
+     */
535
+    public function getEventDispatcher();
536
+
537
+    /**
538
+     * Get the Notification Manager
539
+     *
540
+     * @return \OCP\Notification\IManager
541
+     * @since 9.0.0
542
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
543
+     */
544
+    public function getNotificationManager();
545
+
546
+    /**
547
+     * @return \OCP\Comments\ICommentsManager
548
+     * @since 9.0.0
549
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
550
+     */
551
+    public function getCommentsManager();
552
+
553
+    /**
554
+     * Returns the system-tag manager
555
+     *
556
+     * @return \OCP\SystemTag\ISystemTagManager
557
+     *
558
+     * @since 9.0.0
559
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
560
+     */
561
+    public function getSystemTagManager();
562
+
563
+    /**
564
+     * Returns the system-tag object mapper
565
+     *
566
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
567
+     *
568
+     * @since 9.0.0
569
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
570
+     */
571
+    public function getSystemTagObjectMapper();
572
+
573
+    /**
574
+     * Returns the share manager
575
+     *
576
+     * @return \OCP\Share\IManager
577
+     * @since 9.0.0
578
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
579
+     */
580
+    public function getShareManager();
581
+
582
+    /**
583
+     * @return IContentSecurityPolicyManager
584
+     * @since 9.0.0
585
+     * @deprecated 17.0.0 Use the AddContentSecurityPolicyEvent
586
+     */
587
+    public function getContentSecurityPolicyManager();
588
+
589
+    /**
590
+     * @return \OCP\IDateTimeZone
591
+     * @since 8.0.0
592
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
593
+     */
594
+    public function getDateTimeZone();
595
+
596
+    /**
597
+     * @return \OCP\IDateTimeFormatter
598
+     * @since 8.0.0
599
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
600
+     */
601
+    public function getDateTimeFormatter();
602
+
603
+    /**
604
+     * @return \OCP\Federation\ICloudIdManager
605
+     * @since 12.0.0
606
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
607
+     */
608
+    public function getCloudIdManager();
609
+
610
+    /**
611
+     * @return \OCP\GlobalScale\IConfig
612
+     * @since 14.0.0
613
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
614
+     */
615
+    public function getGlobalScaleConfig();
616
+
617
+    /**
618
+     * @return ICloudFederationFactory
619
+     * @since 14.0.0
620
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
621
+     */
622
+    public function getCloudFederationFactory();
623
+
624
+    /**
625
+     * @return ICloudFederationProviderManager
626
+     * @since 14.0.0
627
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
628
+     */
629
+    public function getCloudFederationProviderManager();
630
+
631
+    /**
632
+     * @return \OCP\Remote\Api\IApiFactory
633
+     * @since 13.0.0
634
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
635
+     */
636
+    public function getRemoteApiFactory();
637
+
638
+    /**
639
+     * @return \OCP\Remote\IInstanceFactory
640
+     * @since 13.0.0
641
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
642
+     */
643
+    public function getRemoteInstanceFactory();
644
+
645
+    /**
646
+     * @return \OCP\Files\Storage\IStorageFactory
647
+     * @since 15.0.0
648
+     * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
649
+     */
650
+    public function getStorageFactory();
651 651
 }
Please login to merge, or discard this patch.