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