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