@@ -25,28 +25,28 @@ |
||
| 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 $identifier |
|
| 34 | - * @param string $message |
|
| 35 | - * |
|
| 36 | - * @since 14.0.0 |
|
| 37 | - */ |
|
| 38 | - public function setMessage($identifier, $message) { |
|
| 39 | - $this->message[$identifier] = $message; |
|
| 40 | - } |
|
| 30 | + /** |
|
| 31 | + * add a message to the notification |
|
| 32 | + * |
|
| 33 | + * @param string $identifier |
|
| 34 | + * @param string $message |
|
| 35 | + * |
|
| 36 | + * @since 14.0.0 |
|
| 37 | + */ |
|
| 38 | + public function setMessage($identifier, $message) { |
|
| 39 | + $this->message[$identifier] = $message; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * get JSON encoded Message, ready to send out |
|
| 44 | - * |
|
| 45 | - * @return string |
|
| 46 | - * |
|
| 47 | - * @since 14.0.0 |
|
| 48 | - */ |
|
| 49 | - public function getMessage() { |
|
| 50 | - return json_encode($this->message); |
|
| 51 | - } |
|
| 42 | + /** |
|
| 43 | + * get JSON encoded Message, ready to send out |
|
| 44 | + * |
|
| 45 | + * @return string |
|
| 46 | + * |
|
| 47 | + * @since 14.0.0 |
|
| 48 | + */ |
|
| 49 | + public function getMessage() { |
|
| 50 | + return json_encode($this->message); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -36,47 +36,47 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $application = new Application(); |
| 38 | 38 | $application->registerRoutes($this, [ |
| 39 | - 'routes' => [ |
|
| 40 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
| 41 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
| 42 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
| 43 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
| 44 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
| 45 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
| 46 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
| 47 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
| 48 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
| 49 | - ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
| 50 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
| 51 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
| 52 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
| 53 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
| 54 | - ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
| 55 | - ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
| 56 | - ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
| 57 | - ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
| 58 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
| 59 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
| 60 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
| 61 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
| 62 | - ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
| 63 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
| 64 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 65 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 66 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
| 67 | - ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
| 68 | - ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
| 69 | - ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
| 70 | - ], |
|
| 71 | - 'ocs' => [ |
|
| 72 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
| 73 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
| 74 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
| 75 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
| 76 | - ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
| 77 | - ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
| 78 | - ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
| 79 | - ], |
|
| 39 | + 'routes' => [ |
|
| 40 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
| 41 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
| 42 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
| 43 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
| 44 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
| 45 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
| 46 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
| 47 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
| 48 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
| 49 | + ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
| 50 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
| 51 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
| 52 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
| 53 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
| 54 | + ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
| 55 | + ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
| 56 | + ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
| 57 | + ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
| 58 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
| 59 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
| 60 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
| 61 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
| 62 | + ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
| 63 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
| 64 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 65 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
| 66 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
| 67 | + ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
| 68 | + ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
| 69 | + ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
| 70 | + ], |
|
| 71 | + 'ocs' => [ |
|
| 72 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
| 73 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
| 74 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
| 75 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
| 76 | + ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
| 77 | + ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
| 78 | + ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
| 79 | + ], |
|
| 80 | 80 | ]); |
| 81 | 81 | |
| 82 | 82 | // Post installation check |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | // Core ajax actions |
| 86 | 86 | // Routing |
| 87 | 87 | $this->create('core_ajax_update', '/core/ajax/update.php') |
| 88 | - ->actionInclude('core/ajax/update.php'); |
|
| 88 | + ->actionInclude('core/ajax/update.php'); |
|
| 89 | 89 | |
| 90 | 90 | // File routes |
| 91 | 91 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
| 92 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
| 93 | - $app->dispatch('ViewController', 'index'); |
|
| 92 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
| 93 | + $app->dispatch('ViewController', 'index'); |
|
| 94 | 94 | }); |
| 95 | 95 | |
| 96 | 96 | // Call routes |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @suppress PhanUndeclaredClassMethod |
| 100 | 100 | */ |
| 101 | 101 | $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { |
| 102 | - if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
| 103 | - $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
| 104 | - $app->dispatch('PageController', 'index'); |
|
| 105 | - } else { |
|
| 106 | - throw new \OC\HintException('App spreed is not enabled'); |
|
| 107 | - } |
|
| 102 | + if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
| 103 | + $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
| 104 | + $app->dispatch('PageController', 'index'); |
|
| 105 | + } else { |
|
| 106 | + throw new \OC\HintException('App spreed is not enabled'); |
|
| 107 | + } |
|
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | 110 | // OCM routes |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * @suppress PhanUndeclaredClassMethod |
| 114 | 114 | */ |
| 115 | 115 | $this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) { |
| 116 | - if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 117 | - $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 118 | - $app->dispatch('RequestHandlerController', 'addShare'); |
|
| 119 | - } else { |
|
| 120 | - throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 121 | - } |
|
| 116 | + if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 117 | + $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 118 | + $app->dispatch('RequestHandlerController', 'addShare'); |
|
| 119 | + } else { |
|
| 120 | + throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 121 | + } |
|
| 122 | 122 | }); |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,53 +126,53 @@ discard block |
||
| 126 | 126 | * @suppress PhanUndeclaredClassMethod |
| 127 | 127 | */ |
| 128 | 128 | $this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) { |
| 129 | - if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 130 | - $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 131 | - $app->dispatch('RequestHandlerController', 'receiveNotification'); |
|
| 132 | - } else { |
|
| 133 | - throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 134 | - } |
|
| 129 | + if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) { |
|
| 130 | + $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams); |
|
| 131 | + $app->dispatch('RequestHandlerController', 'receiveNotification'); |
|
| 132 | + } else { |
|
| 133 | + throw new \OC\HintException('Cloud Federation API not enabled'); |
|
| 134 | + } |
|
| 135 | 135 | }); |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // Sharing routes |
| 139 | 139 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
| 140 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 141 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 142 | - $app->dispatch('ShareController', 'showShare'); |
|
| 143 | - } else { |
|
| 144 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 145 | - } |
|
| 140 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 141 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 142 | + $app->dispatch('ShareController', 'showShare'); |
|
| 143 | + } else { |
|
| 144 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 145 | + } |
|
| 146 | 146 | }); |
| 147 | 147 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) { |
| 148 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 149 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 150 | - $app->dispatch('ShareController', 'authenticate'); |
|
| 151 | - } else { |
|
| 152 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 153 | - } |
|
| 148 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 149 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 150 | + $app->dispatch('ShareController', 'authenticate'); |
|
| 151 | + } else { |
|
| 152 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 153 | + } |
|
| 154 | 154 | }); |
| 155 | 155 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) { |
| 156 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 157 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 158 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
| 159 | - } else { |
|
| 160 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 161 | - } |
|
| 156 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 157 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 158 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
| 159 | + } else { |
|
| 160 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 161 | + } |
|
| 162 | 162 | }); |
| 163 | 163 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
| 164 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 165 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 166 | - $app->dispatch('ShareController', 'downloadShare'); |
|
| 167 | - } else { |
|
| 168 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 169 | - } |
|
| 164 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 165 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 166 | + $app->dispatch('ShareController', 'downloadShare'); |
|
| 167 | + } else { |
|
| 168 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 169 | + } |
|
| 170 | 170 | }); |
| 171 | 171 | $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) { |
| 172 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 173 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 174 | - $app->dispatch('PublicPreviewController', 'directLink'); |
|
| 175 | - } else { |
|
| 176 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
| 177 | - } |
|
| 172 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
| 173 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
| 174 | + $app->dispatch('PublicPreviewController', 'directLink'); |
|
| 175 | + } else { |
|
| 176 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
| 177 | + } |
|
| 178 | 178 | }); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param string $remote url |
| 157 | 157 | * @param int $id share id |
| 158 | 158 | * @param string $token |
| 159 | - * @return bool |
|
| 159 | + * @return boolean|null |
|
| 160 | 160 | */ |
| 161 | 161 | public function sendRemoteUnShare($remote, $id, $token) { |
| 162 | 162 | $this->sendUpdateToRemote($remote, $id, $token, 'unshare'); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param string $remote url |
| 169 | 169 | * @param int $id share id |
| 170 | 170 | * @param string $token |
| 171 | - * @return bool |
|
| 171 | + * @return boolean|null |
|
| 172 | 172 | */ |
| 173 | 173 | public function sendRevokeShare($remote, $id, $token) { |
| 174 | 174 | $this->sendUpdateToRemote($remote, $id, $token, 'revoke'); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param int $remoteId |
| 182 | 182 | * @param string $token |
| 183 | 183 | * @param int $permissions |
| 184 | - * @return bool |
|
| 184 | + * @return boolean|null |
|
| 185 | 185 | */ |
| 186 | 186 | public function sendPermissionChange($remote, $remoteId, $token, $permissions) { |
| 187 | 187 | $this->sendUpdateToRemote($remote, $remoteId, $token, 'permissions', ['permissions' => $permissions]); |
@@ -342,6 +342,10 @@ discard block |
||
| 342 | 342 | return ''; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | + /** |
|
| 346 | + * @param string $remoteDomain |
|
| 347 | + * @param string $urlSuffix |
|
| 348 | + */ |
|
| 345 | 349 | protected function sendNotificationToOCMEndPoint($remoteDomain, $urlSuffix, $fields) { |
| 346 | 350 | $client = $this->httpClientService->newClient(); |
| 347 | 351 | switch ($urlSuffix) { |
@@ -31,324 +31,324 @@ |
||
| 31 | 31 | use OCP\OCS\IDiscoveryService; |
| 32 | 32 | |
| 33 | 33 | class Notifications { |
| 34 | - const RESPONSE_FORMAT = 'json'; // default response format for ocs calls |
|
| 35 | - |
|
| 36 | - /** @var AddressHandler */ |
|
| 37 | - private $addressHandler; |
|
| 38 | - |
|
| 39 | - /** @var IClientService */ |
|
| 40 | - private $httpClientService; |
|
| 41 | - |
|
| 42 | - /** @var IDiscoveryService */ |
|
| 43 | - private $discoveryService; |
|
| 44 | - |
|
| 45 | - /** @var IJobList */ |
|
| 46 | - private $jobList; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @param AddressHandler $addressHandler |
|
| 50 | - * @param IClientService $httpClientService |
|
| 51 | - * @param IDiscoveryService $discoveryService |
|
| 52 | - * @param IJobList $jobList |
|
| 53 | - */ |
|
| 54 | - public function __construct( |
|
| 55 | - AddressHandler $addressHandler, |
|
| 56 | - IClientService $httpClientService, |
|
| 57 | - IDiscoveryService $discoveryService, |
|
| 58 | - IJobList $jobList |
|
| 59 | - ) { |
|
| 60 | - $this->addressHandler = $addressHandler; |
|
| 61 | - $this->httpClientService = $httpClientService; |
|
| 62 | - $this->discoveryService = $discoveryService; |
|
| 63 | - $this->jobList = $jobList; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * send server-to-server share to remote server |
|
| 68 | - * |
|
| 69 | - * @param string $token |
|
| 70 | - * @param string $shareWith |
|
| 71 | - * @param string $name |
|
| 72 | - * @param int $remote_id |
|
| 73 | - * @param string $owner |
|
| 74 | - * @param string $ownerFederatedId |
|
| 75 | - * @param string $sharedBy |
|
| 76 | - * @param string $sharedByFederatedId |
|
| 77 | - * @return bool |
|
| 78 | - * @throws \OC\HintException |
|
| 79 | - * @throws \OC\ServerNotAvailableException |
|
| 80 | - */ |
|
| 81 | - public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId) { |
|
| 82 | - |
|
| 83 | - list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); |
|
| 84 | - |
|
| 85 | - if ($user && $remote) { |
|
| 86 | - $local = $this->addressHandler->generateRemoteURL(); |
|
| 87 | - |
|
| 88 | - $fields = array( |
|
| 89 | - 'shareWith' => $user, |
|
| 90 | - 'token' => $token, |
|
| 91 | - 'name' => $name, |
|
| 92 | - 'remoteId' => $remote_id, |
|
| 93 | - 'owner' => $owner, |
|
| 94 | - 'ownerFederatedId' => $ownerFederatedId, |
|
| 95 | - 'sharedBy' => $sharedBy, |
|
| 96 | - 'sharedByFederatedId' => $sharedByFederatedId, |
|
| 97 | - 'remote' => $local, |
|
| 98 | - ); |
|
| 99 | - |
|
| 100 | - $result = $this->tryHttpPostToShareEndpoint($remote, '', $fields); |
|
| 101 | - $status = json_decode($result['result'], true); |
|
| 102 | - |
|
| 103 | - if ($result['success'] && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200)) { |
|
| 104 | - \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]); |
|
| 105 | - return true; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return false; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * ask owner to re-share the file with the given user |
|
| 115 | - * |
|
| 116 | - * @param string $token |
|
| 117 | - * @param int $id remote Id |
|
| 118 | - * @param int $shareId internal share Id |
|
| 119 | - * @param string $remote remote address of the owner |
|
| 120 | - * @param string $shareWith |
|
| 121 | - * @param int $permission |
|
| 122 | - * @return bool |
|
| 123 | - * @throws \OC\HintException |
|
| 124 | - * @throws \OC\ServerNotAvailableException |
|
| 125 | - */ |
|
| 126 | - public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission) { |
|
| 127 | - |
|
| 128 | - $fields = array( |
|
| 129 | - 'shareWith' => $shareWith, |
|
| 130 | - 'token' => $token, |
|
| 131 | - 'permission' => $permission, |
|
| 132 | - 'remoteId' => $shareId |
|
| 133 | - ); |
|
| 134 | - |
|
| 135 | - $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields); |
|
| 136 | - $status = json_decode($result['result'], true); |
|
| 137 | - |
|
| 138 | - $httpRequestSuccessful = $result['success']; |
|
| 139 | - $ocsCallSuccessful = $status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200; |
|
| 140 | - $validToken = isset($status['ocs']['data']['token']) && is_string($status['ocs']['data']['token']); |
|
| 141 | - $validRemoteId = isset($status['ocs']['data']['remoteId']); |
|
| 142 | - |
|
| 143 | - if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) { |
|
| 144 | - return [ |
|
| 145 | - $status['ocs']['data']['token'], |
|
| 146 | - (int)$status['ocs']['data']['remoteId'] |
|
| 147 | - ]; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - return false; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * send server-to-server unshare to remote server |
|
| 155 | - * |
|
| 156 | - * @param string $remote url |
|
| 157 | - * @param int $id share id |
|
| 158 | - * @param string $token |
|
| 159 | - * @return bool |
|
| 160 | - */ |
|
| 161 | - public function sendRemoteUnShare($remote, $id, $token) { |
|
| 162 | - $this->sendUpdateToRemote($remote, $id, $token, 'unshare'); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * send server-to-server unshare to remote server |
|
| 167 | - * |
|
| 168 | - * @param string $remote url |
|
| 169 | - * @param int $id share id |
|
| 170 | - * @param string $token |
|
| 171 | - * @return bool |
|
| 172 | - */ |
|
| 173 | - public function sendRevokeShare($remote, $id, $token) { |
|
| 174 | - $this->sendUpdateToRemote($remote, $id, $token, 'revoke'); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * send notification to remote server if the permissions was changed |
|
| 179 | - * |
|
| 180 | - * @param string $remote |
|
| 181 | - * @param int $remoteId |
|
| 182 | - * @param string $token |
|
| 183 | - * @param int $permissions |
|
| 184 | - * @return bool |
|
| 185 | - */ |
|
| 186 | - public function sendPermissionChange($remote, $remoteId, $token, $permissions) { |
|
| 187 | - $this->sendUpdateToRemote($remote, $remoteId, $token, 'permissions', ['permissions' => $permissions]); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * forward accept reShare to remote server |
|
| 192 | - * |
|
| 193 | - * @param string $remote |
|
| 194 | - * @param int $remoteId |
|
| 195 | - * @param string $token |
|
| 196 | - */ |
|
| 197 | - public function sendAcceptShare($remote, $remoteId, $token) { |
|
| 198 | - $this->sendUpdateToRemote($remote, $remoteId, $token, 'accept'); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * forward decline reShare to remote server |
|
| 203 | - * |
|
| 204 | - * @param string $remote |
|
| 205 | - * @param int $remoteId |
|
| 206 | - * @param string $token |
|
| 207 | - */ |
|
| 208 | - public function sendDeclineShare($remote, $remoteId, $token) { |
|
| 209 | - $this->sendUpdateToRemote($remote, $remoteId, $token, 'decline'); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * inform remote server whether server-to-server share was accepted/declined |
|
| 214 | - * |
|
| 215 | - * @param string $remote |
|
| 216 | - * @param string $token |
|
| 217 | - * @param int $remoteId Share id on the remote host |
|
| 218 | - * @param string $action possible actions: accept, decline, unshare, revoke, permissions |
|
| 219 | - * @param array $data |
|
| 220 | - * @param int $try |
|
| 221 | - * @return boolean |
|
| 222 | - */ |
|
| 223 | - public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = [], $try = 0) { |
|
| 224 | - |
|
| 225 | - $fields = array('token' => $token); |
|
| 226 | - foreach ($data as $key => $value) { |
|
| 227 | - $fields[$key] = $value; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields); |
|
| 231 | - $status = json_decode($result['result'], true); |
|
| 232 | - |
|
| 233 | - if ($result['success'] && |
|
| 234 | - ($status['ocs']['meta']['statuscode'] === 100 || |
|
| 235 | - $status['ocs']['meta']['statuscode'] === 200 |
|
| 236 | - ) |
|
| 237 | - ) { |
|
| 238 | - return true; |
|
| 239 | - } elseif ($try === 0) { |
|
| 240 | - // only add new job on first try |
|
| 241 | - $this->jobList->add('OCA\FederatedFileSharing\BackgroundJob\RetryJob', |
|
| 242 | - [ |
|
| 243 | - 'remote' => $remote, |
|
| 244 | - 'remoteId' => $remoteId, |
|
| 245 | - 'token' => $token, |
|
| 246 | - 'action' => $action, |
|
| 247 | - 'data' => json_encode($data), |
|
| 248 | - 'try' => $try, |
|
| 249 | - 'lastRun' => $this->getTimestamp() |
|
| 250 | - ] |
|
| 251 | - ); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - return false; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * return current timestamp |
|
| 260 | - * |
|
| 261 | - * @return int |
|
| 262 | - */ |
|
| 263 | - protected function getTimestamp() { |
|
| 264 | - return time(); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * try http post with the given protocol, if no protocol is given we pick |
|
| 269 | - * the secure one (https) |
|
| 270 | - * |
|
| 271 | - * @param string $remoteDomain |
|
| 272 | - * @param string $urlSuffix |
|
| 273 | - * @param array $fields post parameters |
|
| 274 | - * @return array |
|
| 275 | - * @throws \Exception |
|
| 276 | - */ |
|
| 277 | - protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields) { |
|
| 278 | - |
|
| 279 | - if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) { |
|
| 280 | - $remoteDomain = 'https://' . $remoteDomain; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - $result = [ |
|
| 284 | - 'success' => false, |
|
| 285 | - 'result' => '', |
|
| 286 | - ]; |
|
| 287 | - |
|
| 288 | - // if possible we use the new OCM API |
|
| 289 | - $ocmEndPoint = $this->getOCMEndPoint($remoteDomain); |
|
| 290 | - if ($ocmEndPoint) { |
|
| 291 | - $ocmResult = $this->sendNotificationToOCMEndPoint($remoteDomain, $urlSuffix, $fields); |
|
| 292 | - $result['result'] = $ocmResult['body']; |
|
| 293 | - $result['success'] = true; |
|
| 294 | - return $result; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // Fall back to old API |
|
| 298 | - $client = $this->httpClientService->newClient(); |
|
| 299 | - $federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING'); |
|
| 300 | - $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
|
| 301 | - try { |
|
| 302 | - $response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [ |
|
| 303 | - 'body' => $fields, |
|
| 304 | - 'timeout' => 10, |
|
| 305 | - 'connect_timeout' => 10, |
|
| 306 | - ]); |
|
| 307 | - $result['result'] = $response->getBody(); |
|
| 308 | - $result['success'] = true; |
|
| 309 | - } catch (\Exception $e) { |
|
| 310 | - // if flat re-sharing is not supported by the remote server |
|
| 311 | - // we re-throw the exception and fall back to the old behaviour. |
|
| 312 | - // (flat re-shares has been introduced in Nextcloud 9.1) |
|
| 313 | - if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { |
|
| 314 | - throw $e; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - return $result; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * check if server supports the new OCM api and ask for the correct end-point |
|
| 323 | - * |
|
| 324 | - * @param string $url |
|
| 325 | - * @return string |
|
| 326 | - */ |
|
| 327 | - protected function getOCMEndPoint($url) { |
|
| 328 | - $client = $this->httpClientService->newClient(); |
|
| 329 | - try { |
|
| 330 | - $response = $client->get($url, ['timeout' => 10, 'connect_timeout' => 10]); |
|
| 331 | - } catch (\Exception $e) { |
|
| 332 | - return ''; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - $result = $response->getBody(); |
|
| 336 | - $result = json_decode($result, true); |
|
| 337 | - |
|
| 338 | - if (isset($result['end-point'])) { |
|
| 339 | - return $result['end-point']; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - return ''; |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - protected function sendNotificationToOCMEndPoint($remoteDomain, $urlSuffix, $fields) { |
|
| 346 | - $client = $this->httpClientService->newClient(); |
|
| 347 | - switch ($urlSuffix) { |
|
| 348 | - case '': |
|
| 349 | - null; |
|
| 350 | - break; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - } |
|
| 34 | + const RESPONSE_FORMAT = 'json'; // default response format for ocs calls |
|
| 35 | + |
|
| 36 | + /** @var AddressHandler */ |
|
| 37 | + private $addressHandler; |
|
| 38 | + |
|
| 39 | + /** @var IClientService */ |
|
| 40 | + private $httpClientService; |
|
| 41 | + |
|
| 42 | + /** @var IDiscoveryService */ |
|
| 43 | + private $discoveryService; |
|
| 44 | + |
|
| 45 | + /** @var IJobList */ |
|
| 46 | + private $jobList; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @param AddressHandler $addressHandler |
|
| 50 | + * @param IClientService $httpClientService |
|
| 51 | + * @param IDiscoveryService $discoveryService |
|
| 52 | + * @param IJobList $jobList |
|
| 53 | + */ |
|
| 54 | + public function __construct( |
|
| 55 | + AddressHandler $addressHandler, |
|
| 56 | + IClientService $httpClientService, |
|
| 57 | + IDiscoveryService $discoveryService, |
|
| 58 | + IJobList $jobList |
|
| 59 | + ) { |
|
| 60 | + $this->addressHandler = $addressHandler; |
|
| 61 | + $this->httpClientService = $httpClientService; |
|
| 62 | + $this->discoveryService = $discoveryService; |
|
| 63 | + $this->jobList = $jobList; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * send server-to-server share to remote server |
|
| 68 | + * |
|
| 69 | + * @param string $token |
|
| 70 | + * @param string $shareWith |
|
| 71 | + * @param string $name |
|
| 72 | + * @param int $remote_id |
|
| 73 | + * @param string $owner |
|
| 74 | + * @param string $ownerFederatedId |
|
| 75 | + * @param string $sharedBy |
|
| 76 | + * @param string $sharedByFederatedId |
|
| 77 | + * @return bool |
|
| 78 | + * @throws \OC\HintException |
|
| 79 | + * @throws \OC\ServerNotAvailableException |
|
| 80 | + */ |
|
| 81 | + public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId) { |
|
| 82 | + |
|
| 83 | + list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); |
|
| 84 | + |
|
| 85 | + if ($user && $remote) { |
|
| 86 | + $local = $this->addressHandler->generateRemoteURL(); |
|
| 87 | + |
|
| 88 | + $fields = array( |
|
| 89 | + 'shareWith' => $user, |
|
| 90 | + 'token' => $token, |
|
| 91 | + 'name' => $name, |
|
| 92 | + 'remoteId' => $remote_id, |
|
| 93 | + 'owner' => $owner, |
|
| 94 | + 'ownerFederatedId' => $ownerFederatedId, |
|
| 95 | + 'sharedBy' => $sharedBy, |
|
| 96 | + 'sharedByFederatedId' => $sharedByFederatedId, |
|
| 97 | + 'remote' => $local, |
|
| 98 | + ); |
|
| 99 | + |
|
| 100 | + $result = $this->tryHttpPostToShareEndpoint($remote, '', $fields); |
|
| 101 | + $status = json_decode($result['result'], true); |
|
| 102 | + |
|
| 103 | + if ($result['success'] && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200)) { |
|
| 104 | + \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]); |
|
| 105 | + return true; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * ask owner to re-share the file with the given user |
|
| 115 | + * |
|
| 116 | + * @param string $token |
|
| 117 | + * @param int $id remote Id |
|
| 118 | + * @param int $shareId internal share Id |
|
| 119 | + * @param string $remote remote address of the owner |
|
| 120 | + * @param string $shareWith |
|
| 121 | + * @param int $permission |
|
| 122 | + * @return bool |
|
| 123 | + * @throws \OC\HintException |
|
| 124 | + * @throws \OC\ServerNotAvailableException |
|
| 125 | + */ |
|
| 126 | + public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission) { |
|
| 127 | + |
|
| 128 | + $fields = array( |
|
| 129 | + 'shareWith' => $shareWith, |
|
| 130 | + 'token' => $token, |
|
| 131 | + 'permission' => $permission, |
|
| 132 | + 'remoteId' => $shareId |
|
| 133 | + ); |
|
| 134 | + |
|
| 135 | + $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields); |
|
| 136 | + $status = json_decode($result['result'], true); |
|
| 137 | + |
|
| 138 | + $httpRequestSuccessful = $result['success']; |
|
| 139 | + $ocsCallSuccessful = $status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200; |
|
| 140 | + $validToken = isset($status['ocs']['data']['token']) && is_string($status['ocs']['data']['token']); |
|
| 141 | + $validRemoteId = isset($status['ocs']['data']['remoteId']); |
|
| 142 | + |
|
| 143 | + if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) { |
|
| 144 | + return [ |
|
| 145 | + $status['ocs']['data']['token'], |
|
| 146 | + (int)$status['ocs']['data']['remoteId'] |
|
| 147 | + ]; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + return false; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * send server-to-server unshare to remote server |
|
| 155 | + * |
|
| 156 | + * @param string $remote url |
|
| 157 | + * @param int $id share id |
|
| 158 | + * @param string $token |
|
| 159 | + * @return bool |
|
| 160 | + */ |
|
| 161 | + public function sendRemoteUnShare($remote, $id, $token) { |
|
| 162 | + $this->sendUpdateToRemote($remote, $id, $token, 'unshare'); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * send server-to-server unshare to remote server |
|
| 167 | + * |
|
| 168 | + * @param string $remote url |
|
| 169 | + * @param int $id share id |
|
| 170 | + * @param string $token |
|
| 171 | + * @return bool |
|
| 172 | + */ |
|
| 173 | + public function sendRevokeShare($remote, $id, $token) { |
|
| 174 | + $this->sendUpdateToRemote($remote, $id, $token, 'revoke'); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * send notification to remote server if the permissions was changed |
|
| 179 | + * |
|
| 180 | + * @param string $remote |
|
| 181 | + * @param int $remoteId |
|
| 182 | + * @param string $token |
|
| 183 | + * @param int $permissions |
|
| 184 | + * @return bool |
|
| 185 | + */ |
|
| 186 | + public function sendPermissionChange($remote, $remoteId, $token, $permissions) { |
|
| 187 | + $this->sendUpdateToRemote($remote, $remoteId, $token, 'permissions', ['permissions' => $permissions]); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * forward accept reShare to remote server |
|
| 192 | + * |
|
| 193 | + * @param string $remote |
|
| 194 | + * @param int $remoteId |
|
| 195 | + * @param string $token |
|
| 196 | + */ |
|
| 197 | + public function sendAcceptShare($remote, $remoteId, $token) { |
|
| 198 | + $this->sendUpdateToRemote($remote, $remoteId, $token, 'accept'); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * forward decline reShare to remote server |
|
| 203 | + * |
|
| 204 | + * @param string $remote |
|
| 205 | + * @param int $remoteId |
|
| 206 | + * @param string $token |
|
| 207 | + */ |
|
| 208 | + public function sendDeclineShare($remote, $remoteId, $token) { |
|
| 209 | + $this->sendUpdateToRemote($remote, $remoteId, $token, 'decline'); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * inform remote server whether server-to-server share was accepted/declined |
|
| 214 | + * |
|
| 215 | + * @param string $remote |
|
| 216 | + * @param string $token |
|
| 217 | + * @param int $remoteId Share id on the remote host |
|
| 218 | + * @param string $action possible actions: accept, decline, unshare, revoke, permissions |
|
| 219 | + * @param array $data |
|
| 220 | + * @param int $try |
|
| 221 | + * @return boolean |
|
| 222 | + */ |
|
| 223 | + public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = [], $try = 0) { |
|
| 224 | + |
|
| 225 | + $fields = array('token' => $token); |
|
| 226 | + foreach ($data as $key => $value) { |
|
| 227 | + $fields[$key] = $value; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields); |
|
| 231 | + $status = json_decode($result['result'], true); |
|
| 232 | + |
|
| 233 | + if ($result['success'] && |
|
| 234 | + ($status['ocs']['meta']['statuscode'] === 100 || |
|
| 235 | + $status['ocs']['meta']['statuscode'] === 200 |
|
| 236 | + ) |
|
| 237 | + ) { |
|
| 238 | + return true; |
|
| 239 | + } elseif ($try === 0) { |
|
| 240 | + // only add new job on first try |
|
| 241 | + $this->jobList->add('OCA\FederatedFileSharing\BackgroundJob\RetryJob', |
|
| 242 | + [ |
|
| 243 | + 'remote' => $remote, |
|
| 244 | + 'remoteId' => $remoteId, |
|
| 245 | + 'token' => $token, |
|
| 246 | + 'action' => $action, |
|
| 247 | + 'data' => json_encode($data), |
|
| 248 | + 'try' => $try, |
|
| 249 | + 'lastRun' => $this->getTimestamp() |
|
| 250 | + ] |
|
| 251 | + ); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + return false; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * return current timestamp |
|
| 260 | + * |
|
| 261 | + * @return int |
|
| 262 | + */ |
|
| 263 | + protected function getTimestamp() { |
|
| 264 | + return time(); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * try http post with the given protocol, if no protocol is given we pick |
|
| 269 | + * the secure one (https) |
|
| 270 | + * |
|
| 271 | + * @param string $remoteDomain |
|
| 272 | + * @param string $urlSuffix |
|
| 273 | + * @param array $fields post parameters |
|
| 274 | + * @return array |
|
| 275 | + * @throws \Exception |
|
| 276 | + */ |
|
| 277 | + protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields) { |
|
| 278 | + |
|
| 279 | + if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) { |
|
| 280 | + $remoteDomain = 'https://' . $remoteDomain; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + $result = [ |
|
| 284 | + 'success' => false, |
|
| 285 | + 'result' => '', |
|
| 286 | + ]; |
|
| 287 | + |
|
| 288 | + // if possible we use the new OCM API |
|
| 289 | + $ocmEndPoint = $this->getOCMEndPoint($remoteDomain); |
|
| 290 | + if ($ocmEndPoint) { |
|
| 291 | + $ocmResult = $this->sendNotificationToOCMEndPoint($remoteDomain, $urlSuffix, $fields); |
|
| 292 | + $result['result'] = $ocmResult['body']; |
|
| 293 | + $result['success'] = true; |
|
| 294 | + return $result; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // Fall back to old API |
|
| 298 | + $client = $this->httpClientService->newClient(); |
|
| 299 | + $federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING'); |
|
| 300 | + $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
|
| 301 | + try { |
|
| 302 | + $response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [ |
|
| 303 | + 'body' => $fields, |
|
| 304 | + 'timeout' => 10, |
|
| 305 | + 'connect_timeout' => 10, |
|
| 306 | + ]); |
|
| 307 | + $result['result'] = $response->getBody(); |
|
| 308 | + $result['success'] = true; |
|
| 309 | + } catch (\Exception $e) { |
|
| 310 | + // if flat re-sharing is not supported by the remote server |
|
| 311 | + // we re-throw the exception and fall back to the old behaviour. |
|
| 312 | + // (flat re-shares has been introduced in Nextcloud 9.1) |
|
| 313 | + if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { |
|
| 314 | + throw $e; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + return $result; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * check if server supports the new OCM api and ask for the correct end-point |
|
| 323 | + * |
|
| 324 | + * @param string $url |
|
| 325 | + * @return string |
|
| 326 | + */ |
|
| 327 | + protected function getOCMEndPoint($url) { |
|
| 328 | + $client = $this->httpClientService->newClient(); |
|
| 329 | + try { |
|
| 330 | + $response = $client->get($url, ['timeout' => 10, 'connect_timeout' => 10]); |
|
| 331 | + } catch (\Exception $e) { |
|
| 332 | + return ''; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + $result = $response->getBody(); |
|
| 336 | + $result = json_decode($result, true); |
|
| 337 | + |
|
| 338 | + if (isset($result['end-point'])) { |
|
| 339 | + return $result['end-point']; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + return ''; |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + protected function sendNotificationToOCMEndPoint($remoteDomain, $urlSuffix, $fields) { |
|
| 346 | + $client = $this->httpClientService->newClient(); |
|
| 347 | + switch ($urlSuffix) { |
|
| 348 | + case '': |
|
| 349 | + null; |
|
| 350 | + break; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + } |
|
| 354 | 354 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'remoteId' => $shareId |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields); |
|
| 135 | + $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$id.'/reshare', $fields); |
|
| 136 | 136 | $status = json_decode($result['result'], true); |
| 137 | 137 | |
| 138 | 138 | $httpRequestSuccessful = $result['success']; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) { |
| 144 | 144 | return [ |
| 145 | 145 | $status['ocs']['data']['token'], |
| 146 | - (int)$status['ocs']['data']['remoteId'] |
|
| 146 | + (int) $status['ocs']['data']['remoteId'] |
|
| 147 | 147 | ]; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $fields[$key] = $value; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields); |
|
| 230 | + $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$remoteId.'/'.$action, $fields); |
|
| 231 | 231 | $status = json_decode($result['result'], true); |
| 232 | 232 | |
| 233 | 233 | if ($result['success'] && |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields) { |
| 278 | 278 | |
| 279 | 279 | if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) { |
| 280 | - $remoteDomain = 'https://' . $remoteDomain; |
|
| 280 | + $remoteDomain = 'https://'.$remoteDomain; |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $result = [ |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING'); |
| 300 | 300 | $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
| 301 | 301 | try { |
| 302 | - $response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [ |
|
| 302 | + $response = $client->post($remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, [ |
|
| 303 | 303 | 'body' => $fields, |
| 304 | 304 | 'timeout' => 10, |
| 305 | 305 | 'connect_timeout' => 10, |
@@ -23,7 +23,6 @@ |
||
| 23 | 23 | namespace OC\Federation; |
| 24 | 24 | |
| 25 | 25 | use OCP\App\IAppManager; |
| 26 | -use OCP\Federation\Exceptions\ProviderAlreadyExistsException; |
|
| 27 | 26 | use OCP\Federation\Exceptions\ProviderDoesNotExistsException; |
| 28 | 27 | use OCP\Federation\ICloudFederationNotification; |
| 29 | 28 | use OCP\Federation\ICloudFederationProvider; |
@@ -39,84 +39,84 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class CloudFederationProviderManager implements ICloudFederationProviderManager { |
| 41 | 41 | |
| 42 | - /** @var array list of available cloud federation providers */ |
|
| 43 | - private $cloudFederationProvider; |
|
| 44 | - |
|
| 45 | - /** @var IAppManager */ |
|
| 46 | - private $appManager; |
|
| 47 | - |
|
| 48 | - public function __construct(IAppManager $appManager) { |
|
| 49 | - $this->cloudFederationProvider= []; |
|
| 50 | - $this->appManager = $appManager; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Registers an callback function which must return an cloud federation provider |
|
| 56 | - * |
|
| 57 | - * @param string $shareType which share type does the provider handles |
|
| 58 | - * @param string $displayName user facing name of the federated share provider |
|
| 59 | - * @param callable $callback |
|
| 60 | - */ |
|
| 61 | - public function addCloudFederationProvider($shareType, $displayName, callable $callback) { |
|
| 62 | - \OC::$server->getRemoteApiFactory(); |
|
| 63 | - |
|
| 64 | - $this->cloudFederationProvider[$shareType] = [ |
|
| 65 | - 'shareType' => $shareType, |
|
| 66 | - 'displayName' => $displayName, |
|
| 67 | - 'callback' => $callback, |
|
| 68 | - ]; |
|
| 69 | - |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * remove cloud federation provider |
|
| 74 | - * |
|
| 75 | - * @param string $providerId |
|
| 76 | - */ |
|
| 77 | - public function removeCloudFederationProvider($providerId) { |
|
| 78 | - unset($this->cloudFederationProvider[$providerId]); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * get a list of all cloudFederationProviders |
|
| 83 | - * |
|
| 84 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
| 85 | - */ |
|
| 86 | - public function getAllCloudFederationProviders() { |
|
| 87 | - return $this->cloudFederationProvider; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * get a specific cloud federation provider |
|
| 92 | - * |
|
| 93 | - * @param string $shareType |
|
| 94 | - * @return ICloudFederationProvider |
|
| 95 | - * @throws ProviderDoesNotExistsException |
|
| 96 | - */ |
|
| 97 | - public function getCloudFederationProvider($shareType) { |
|
| 98 | - if (isset($this->cloudFederationProvider[$shareType])) { |
|
| 99 | - return call_user_func($this->cloudFederationProvider[$shareType]['callback']); |
|
| 100 | - } else { |
|
| 101 | - throw new ProviderDoesNotExistsException($shareType); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - public function sendShare(ICloudFederationShare $share) { |
|
| 106 | - // TODO: Implement sendShare() method. |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - public function sendNotification(ICloudFederationNotification $notification) { |
|
| 110 | - // TODO: Implement sendNotification() method. |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * check if the new cloud federation API is ready to be used |
|
| 115 | - * |
|
| 116 | - * @return bool |
|
| 117 | - */ |
|
| 118 | - public function isReady() { |
|
| 119 | - return $this->appManager->isEnabledForUser('cloud_federation_api', false); |
|
| 120 | - } |
|
| 42 | + /** @var array list of available cloud federation providers */ |
|
| 43 | + private $cloudFederationProvider; |
|
| 44 | + |
|
| 45 | + /** @var IAppManager */ |
|
| 46 | + private $appManager; |
|
| 47 | + |
|
| 48 | + public function __construct(IAppManager $appManager) { |
|
| 49 | + $this->cloudFederationProvider= []; |
|
| 50 | + $this->appManager = $appManager; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Registers an callback function which must return an cloud federation provider |
|
| 56 | + * |
|
| 57 | + * @param string $shareType which share type does the provider handles |
|
| 58 | + * @param string $displayName user facing name of the federated share provider |
|
| 59 | + * @param callable $callback |
|
| 60 | + */ |
|
| 61 | + public function addCloudFederationProvider($shareType, $displayName, callable $callback) { |
|
| 62 | + \OC::$server->getRemoteApiFactory(); |
|
| 63 | + |
|
| 64 | + $this->cloudFederationProvider[$shareType] = [ |
|
| 65 | + 'shareType' => $shareType, |
|
| 66 | + 'displayName' => $displayName, |
|
| 67 | + 'callback' => $callback, |
|
| 68 | + ]; |
|
| 69 | + |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * remove cloud federation provider |
|
| 74 | + * |
|
| 75 | + * @param string $providerId |
|
| 76 | + */ |
|
| 77 | + public function removeCloudFederationProvider($providerId) { |
|
| 78 | + unset($this->cloudFederationProvider[$providerId]); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * get a list of all cloudFederationProviders |
|
| 83 | + * |
|
| 84 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
| 85 | + */ |
|
| 86 | + public function getAllCloudFederationProviders() { |
|
| 87 | + return $this->cloudFederationProvider; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * get a specific cloud federation provider |
|
| 92 | + * |
|
| 93 | + * @param string $shareType |
|
| 94 | + * @return ICloudFederationProvider |
|
| 95 | + * @throws ProviderDoesNotExistsException |
|
| 96 | + */ |
|
| 97 | + public function getCloudFederationProvider($shareType) { |
|
| 98 | + if (isset($this->cloudFederationProvider[$shareType])) { |
|
| 99 | + return call_user_func($this->cloudFederationProvider[$shareType]['callback']); |
|
| 100 | + } else { |
|
| 101 | + throw new ProviderDoesNotExistsException($shareType); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + public function sendShare(ICloudFederationShare $share) { |
|
| 106 | + // TODO: Implement sendShare() method. |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + public function sendNotification(ICloudFederationNotification $notification) { |
|
| 110 | + // TODO: Implement sendNotification() method. |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * check if the new cloud federation API is ready to be used |
|
| 115 | + * |
|
| 116 | + * @return bool |
|
| 117 | + */ |
|
| 118 | + public function isReady() { |
|
| 119 | + return $this->appManager->isEnabledForUser('cloud_federation_api', false); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | private $appManager; |
| 47 | 47 | |
| 48 | 48 | public function __construct(IAppManager $appManager) { |
| 49 | - $this->cloudFederationProvider= []; |
|
| 49 | + $this->cloudFederationProvider = []; |
|
| 50 | 50 | $this->appManager = $appManager; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -32,75 +32,75 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | interface ICloudFederationProviderManager { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Registers an callback function which must return an cloud federation provider |
|
| 37 | - * |
|
| 38 | - * @param string $shareType which share type does the provider handles |
|
| 39 | - * @param string $displayName user facing name of the federated share provider |
|
| 40 | - * @param callable $callback |
|
| 41 | - * @throws Exceptions\ProviderAlreadyExistsException |
|
| 42 | - * |
|
| 43 | - * @since 14.0.0 |
|
| 44 | - */ |
|
| 45 | - public function addCloudFederationProvider($shareType, $displayName, callable $callback); |
|
| 35 | + /** |
|
| 36 | + * Registers an callback function which must return an cloud federation provider |
|
| 37 | + * |
|
| 38 | + * @param string $shareType which share type does the provider handles |
|
| 39 | + * @param string $displayName user facing name of the federated share provider |
|
| 40 | + * @param callable $callback |
|
| 41 | + * @throws Exceptions\ProviderAlreadyExistsException |
|
| 42 | + * |
|
| 43 | + * @since 14.0.0 |
|
| 44 | + */ |
|
| 45 | + public function addCloudFederationProvider($shareType, $displayName, callable $callback); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * remove cloud federation provider |
|
| 49 | - * |
|
| 50 | - * @param string $shareType |
|
| 51 | - * |
|
| 52 | - * @since 14.0.0 |
|
| 53 | - */ |
|
| 54 | - public function removeCloudFederationProvider($shareType); |
|
| 47 | + /** |
|
| 48 | + * remove cloud federation provider |
|
| 49 | + * |
|
| 50 | + * @param string $shareType |
|
| 51 | + * |
|
| 52 | + * @since 14.0.0 |
|
| 53 | + */ |
|
| 54 | + public function removeCloudFederationProvider($shareType); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * get a list of all cloudFederationProviders |
|
| 58 | - * |
|
| 59 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
| 60 | - * |
|
| 61 | - * @since 14.0.0 |
|
| 62 | - */ |
|
| 63 | - public function getAllCloudFederationProviders(); |
|
| 56 | + /** |
|
| 57 | + * get a list of all cloudFederationProviders |
|
| 58 | + * |
|
| 59 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
| 60 | + * |
|
| 61 | + * @since 14.0.0 |
|
| 62 | + */ |
|
| 63 | + public function getAllCloudFederationProviders(); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * get a specific cloud federation provider |
|
| 67 | - * |
|
| 68 | - * @param string $shareType |
|
| 69 | - * @return ICloudFederationProvider |
|
| 70 | - * @throws Exceptions\ProviderDoesNotExistsException; |
|
| 71 | - * |
|
| 72 | - * @since 14.0.0 |
|
| 73 | - */ |
|
| 74 | - public function getCloudFederationProvider($shareType); |
|
| 65 | + /** |
|
| 66 | + * get a specific cloud federation provider |
|
| 67 | + * |
|
| 68 | + * @param string $shareType |
|
| 69 | + * @return ICloudFederationProvider |
|
| 70 | + * @throws Exceptions\ProviderDoesNotExistsException; |
|
| 71 | + * |
|
| 72 | + * @since 14.0.0 |
|
| 73 | + */ |
|
| 74 | + public function getCloudFederationProvider($shareType); |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * send federated share |
|
| 78 | - * |
|
| 79 | - * @param ICloudFederationShare $share |
|
| 80 | - * @return mixed |
|
| 81 | - * |
|
| 82 | - * @since 14.0.0 |
|
| 83 | - */ |
|
| 84 | - public function sendShare(ICloudFederationShare $share); |
|
| 76 | + /** |
|
| 77 | + * send federated share |
|
| 78 | + * |
|
| 79 | + * @param ICloudFederationShare $share |
|
| 80 | + * @return mixed |
|
| 81 | + * |
|
| 82 | + * @since 14.0.0 |
|
| 83 | + */ |
|
| 84 | + public function sendShare(ICloudFederationShare $share); |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * send notification about existing share |
|
| 88 | - * |
|
| 89 | - * @param ICloudFederationNotification $notification |
|
| 90 | - * @return mixed |
|
| 91 | - * |
|
| 92 | - * @since 14.0.0 |
|
| 93 | - */ |
|
| 94 | - public function sendNotification(ICloudFederationNotification $notification); |
|
| 86 | + /** |
|
| 87 | + * send notification about existing share |
|
| 88 | + * |
|
| 89 | + * @param ICloudFederationNotification $notification |
|
| 90 | + * @return mixed |
|
| 91 | + * |
|
| 92 | + * @since 14.0.0 |
|
| 93 | + */ |
|
| 94 | + public function sendNotification(ICloudFederationNotification $notification); |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * check if the new cloud federation API is ready to be used |
|
| 98 | - * |
|
| 99 | - * @return bool |
|
| 100 | - * |
|
| 101 | - * @since 14.0.0 |
|
| 102 | - */ |
|
| 103 | - public function isReady(); |
|
| 96 | + /** |
|
| 97 | + * check if the new cloud federation API is ready to be used |
|
| 98 | + * |
|
| 99 | + * @return bool |
|
| 100 | + * |
|
| 101 | + * @since 14.0.0 |
|
| 102 | + */ |
|
| 103 | + public function isReady(); |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | } |
@@ -60,509 +60,509 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | interface IServerContainer extends IContainer { |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
| 65 | - * providers which actual deliver the calendar information. |
|
| 66 | - * |
|
| 67 | - * @return \OCP\Calendar\IManager |
|
| 68 | - * @since 13.0.0 |
|
| 69 | - */ |
|
| 70 | - public function getCalendarManager(); |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
| 74 | - * providers which actual deliver the contact information. |
|
| 75 | - * |
|
| 76 | - * @return \OCP\Contacts\IManager |
|
| 77 | - * @since 6.0.0 |
|
| 78 | - */ |
|
| 79 | - public function getContactsManager(); |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * The current request object holding all information about the request currently being processed |
|
| 83 | - * is returned from this method. |
|
| 84 | - * In case the current execution was not initiated by a web request null is returned |
|
| 85 | - * |
|
| 86 | - * @return \OCP\IRequest |
|
| 87 | - * @since 6.0.0 |
|
| 88 | - */ |
|
| 89 | - public function getRequest(); |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Returns the preview manager which can create preview images for a given file |
|
| 93 | - * |
|
| 94 | - * @return \OCP\IPreview |
|
| 95 | - * @since 6.0.0 |
|
| 96 | - */ |
|
| 97 | - public function getPreviewManager(); |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Returns the tag manager which can get and set tags for different object types |
|
| 101 | - * |
|
| 102 | - * @see \OCP\ITagManager::load() |
|
| 103 | - * @return \OCP\ITagManager |
|
| 104 | - * @since 6.0.0 |
|
| 105 | - */ |
|
| 106 | - public function getTagManager(); |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Returns the root folder of ownCloud's data directory |
|
| 110 | - * |
|
| 111 | - * @return \OCP\Files\IRootFolder |
|
| 112 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
| 113 | - */ |
|
| 114 | - public function getRootFolder(); |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Returns a view to ownCloud's files folder |
|
| 118 | - * |
|
| 119 | - * @param string $userId user ID |
|
| 120 | - * @return \OCP\Files\Folder |
|
| 121 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
| 122 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
| 123 | - */ |
|
| 124 | - public function getUserFolder($userId = null); |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Returns an app-specific view in ownClouds data directory |
|
| 128 | - * |
|
| 129 | - * @return \OCP\Files\Folder |
|
| 130 | - * @since 6.0.0 |
|
| 131 | - * @deprecated 9.2.0 use IAppData |
|
| 132 | - */ |
|
| 133 | - public function getAppFolder(); |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Returns a user manager |
|
| 137 | - * |
|
| 138 | - * @return \OCP\IUserManager |
|
| 139 | - * @since 8.0.0 |
|
| 140 | - */ |
|
| 141 | - public function getUserManager(); |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Returns a group manager |
|
| 145 | - * |
|
| 146 | - * @return \OCP\IGroupManager |
|
| 147 | - * @since 8.0.0 |
|
| 148 | - */ |
|
| 149 | - public function getGroupManager(); |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Returns the user session |
|
| 153 | - * |
|
| 154 | - * @return \OCP\IUserSession |
|
| 155 | - * @since 6.0.0 |
|
| 156 | - */ |
|
| 157 | - public function getUserSession(); |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Returns the navigation manager |
|
| 161 | - * |
|
| 162 | - * @return \OCP\INavigationManager |
|
| 163 | - * @since 6.0.0 |
|
| 164 | - */ |
|
| 165 | - public function getNavigationManager(); |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Returns the config manager |
|
| 169 | - * |
|
| 170 | - * @return \OCP\IConfig |
|
| 171 | - * @since 6.0.0 |
|
| 172 | - */ |
|
| 173 | - public function getConfig(); |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Returns a Crypto instance |
|
| 177 | - * |
|
| 178 | - * @return \OCP\Security\ICrypto |
|
| 179 | - * @since 8.0.0 |
|
| 180 | - */ |
|
| 181 | - public function getCrypto(); |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Returns a Hasher instance |
|
| 185 | - * |
|
| 186 | - * @return \OCP\Security\IHasher |
|
| 187 | - * @since 8.0.0 |
|
| 188 | - */ |
|
| 189 | - public function getHasher(); |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Returns a SecureRandom instance |
|
| 193 | - * |
|
| 194 | - * @return \OCP\Security\ISecureRandom |
|
| 195 | - * @since 8.1.0 |
|
| 196 | - */ |
|
| 197 | - public function getSecureRandom(); |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Returns a CredentialsManager instance |
|
| 201 | - * |
|
| 202 | - * @return \OCP\Security\ICredentialsManager |
|
| 203 | - * @since 9.0.0 |
|
| 204 | - */ |
|
| 205 | - public function getCredentialsManager(); |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Returns the app config manager |
|
| 209 | - * |
|
| 210 | - * @return \OCP\IAppConfig |
|
| 211 | - * @since 7.0.0 |
|
| 212 | - */ |
|
| 213 | - public function getAppConfig(); |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @return \OCP\L10N\IFactory |
|
| 217 | - * @since 8.2.0 |
|
| 218 | - */ |
|
| 219 | - public function getL10NFactory(); |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * get an L10N instance |
|
| 223 | - * @param string $app appid |
|
| 224 | - * @param string $lang |
|
| 225 | - * @return \OCP\IL10N |
|
| 226 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
| 227 | - */ |
|
| 228 | - public function getL10N($app, $lang = null); |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @return \OC\Encryption\Manager |
|
| 232 | - * @since 8.1.0 |
|
| 233 | - */ |
|
| 234 | - public function getEncryptionManager(); |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * @return \OC\Encryption\File |
|
| 238 | - * @since 8.1.0 |
|
| 239 | - */ |
|
| 240 | - public function getEncryptionFilesHelper(); |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 244 | - * @since 8.1.0 |
|
| 245 | - */ |
|
| 246 | - public function getEncryptionKeyStorage(); |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * Returns the URL generator |
|
| 250 | - * |
|
| 251 | - * @return \OCP\IURLGenerator |
|
| 252 | - * @since 6.0.0 |
|
| 253 | - */ |
|
| 254 | - public function getURLGenerator(); |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * Returns an ICache instance |
|
| 258 | - * |
|
| 259 | - * @return \OCP\ICache |
|
| 260 | - * @since 6.0.0 |
|
| 261 | - */ |
|
| 262 | - public function getCache(); |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Returns an \OCP\CacheFactory instance |
|
| 266 | - * |
|
| 267 | - * @return \OCP\ICacheFactory |
|
| 268 | - * @since 7.0.0 |
|
| 269 | - */ |
|
| 270 | - public function getMemCacheFactory(); |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * Returns the current session |
|
| 274 | - * |
|
| 275 | - * @return \OCP\ISession |
|
| 276 | - * @since 6.0.0 |
|
| 277 | - */ |
|
| 278 | - public function getSession(); |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * Returns the activity manager |
|
| 282 | - * |
|
| 283 | - * @return \OCP\Activity\IManager |
|
| 284 | - * @since 6.0.0 |
|
| 285 | - */ |
|
| 286 | - public function getActivityManager(); |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Returns the current session |
|
| 290 | - * |
|
| 291 | - * @return \OCP\IDBConnection |
|
| 292 | - * @since 6.0.0 |
|
| 293 | - */ |
|
| 294 | - public function getDatabaseConnection(); |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Returns an avatar manager, used for avatar functionality |
|
| 298 | - * |
|
| 299 | - * @return \OCP\IAvatarManager |
|
| 300 | - * @since 6.0.0 |
|
| 301 | - */ |
|
| 302 | - public function getAvatarManager(); |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Returns an job list for controlling background jobs |
|
| 306 | - * |
|
| 307 | - * @return \OCP\BackgroundJob\IJobList |
|
| 308 | - * @since 7.0.0 |
|
| 309 | - */ |
|
| 310 | - public function getJobList(); |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Returns a logger instance |
|
| 314 | - * |
|
| 315 | - * @return \OCP\ILogger |
|
| 316 | - * @since 8.0.0 |
|
| 317 | - */ |
|
| 318 | - public function getLogger(); |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * returns a log factory instance |
|
| 322 | - * |
|
| 323 | - * @return ILogFactory |
|
| 324 | - * @since 14.0.0 |
|
| 325 | - */ |
|
| 326 | - public function getLogFactory(); |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Returns a router for generating and matching urls |
|
| 330 | - * |
|
| 331 | - * @return \OCP\Route\IRouter |
|
| 332 | - * @since 7.0.0 |
|
| 333 | - */ |
|
| 334 | - public function getRouter(); |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * Returns a search instance |
|
| 338 | - * |
|
| 339 | - * @return \OCP\ISearch |
|
| 340 | - * @since 7.0.0 |
|
| 341 | - */ |
|
| 342 | - public function getSearch(); |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Get the certificate manager for the user |
|
| 346 | - * |
|
| 347 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 348 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
| 349 | - * @since 8.0.0 |
|
| 350 | - */ |
|
| 351 | - public function getCertificateManager($userId = null); |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Create a new event source |
|
| 355 | - * |
|
| 356 | - * @return \OCP\IEventSource |
|
| 357 | - * @since 8.0.0 |
|
| 358 | - */ |
|
| 359 | - public function createEventSource(); |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * Returns an instance of the HTTP client service |
|
| 363 | - * |
|
| 364 | - * @return \OCP\Http\Client\IClientService |
|
| 365 | - * @since 8.1.0 |
|
| 366 | - */ |
|
| 367 | - public function getHTTPClientService(); |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Get the active event logger |
|
| 371 | - * |
|
| 372 | - * @return \OCP\Diagnostics\IEventLogger |
|
| 373 | - * @since 8.0.0 |
|
| 374 | - */ |
|
| 375 | - public function getEventLogger(); |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * Get the active query logger |
|
| 379 | - * |
|
| 380 | - * The returned logger only logs data when debug mode is enabled |
|
| 381 | - * |
|
| 382 | - * @return \OCP\Diagnostics\IQueryLogger |
|
| 383 | - * @since 8.0.0 |
|
| 384 | - */ |
|
| 385 | - public function getQueryLogger(); |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * Get the manager for temporary files and folders |
|
| 389 | - * |
|
| 390 | - * @return \OCP\ITempManager |
|
| 391 | - * @since 8.0.0 |
|
| 392 | - */ |
|
| 393 | - public function getTempManager(); |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Get the app manager |
|
| 397 | - * |
|
| 398 | - * @return \OCP\App\IAppManager |
|
| 399 | - * @since 8.0.0 |
|
| 400 | - */ |
|
| 401 | - public function getAppManager(); |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * Get the webroot |
|
| 405 | - * |
|
| 406 | - * @return string |
|
| 407 | - * @since 8.0.0 |
|
| 408 | - */ |
|
| 409 | - public function getWebRoot(); |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
| 413 | - * @since 8.0.0 |
|
| 414 | - */ |
|
| 415 | - public function getMountProviderCollection(); |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * Get the IniWrapper |
|
| 419 | - * |
|
| 420 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
| 421 | - * @since 8.0.0 |
|
| 422 | - */ |
|
| 423 | - public function getIniWrapper(); |
|
| 424 | - /** |
|
| 425 | - * @return \OCP\Command\IBus |
|
| 426 | - * @since 8.1.0 |
|
| 427 | - */ |
|
| 428 | - public function getCommandBus(); |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * Creates a new mailer |
|
| 432 | - * |
|
| 433 | - * @return \OCP\Mail\IMailer |
|
| 434 | - * @since 8.1.0 |
|
| 435 | - */ |
|
| 436 | - public function getMailer(); |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * Get the locking provider |
|
| 440 | - * |
|
| 441 | - * @return \OCP\Lock\ILockingProvider |
|
| 442 | - * @since 8.1.0 |
|
| 443 | - */ |
|
| 444 | - public function getLockingProvider(); |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * @return \OCP\Files\Mount\IMountManager |
|
| 448 | - * @since 8.2.0 |
|
| 449 | - */ |
|
| 450 | - public function getMountManager(); |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * Get the MimeTypeDetector |
|
| 454 | - * |
|
| 455 | - * @return \OCP\Files\IMimeTypeDetector |
|
| 456 | - * @since 8.2.0 |
|
| 457 | - */ |
|
| 458 | - public function getMimeTypeDetector(); |
|
| 459 | - |
|
| 460 | - /** |
|
| 461 | - * Get the MimeTypeLoader |
|
| 462 | - * |
|
| 463 | - * @return \OCP\Files\IMimeTypeLoader |
|
| 464 | - * @since 8.2.0 |
|
| 465 | - */ |
|
| 466 | - public function getMimeTypeLoader(); |
|
| 467 | - |
|
| 468 | - /** |
|
| 469 | - * Get the EventDispatcher |
|
| 470 | - * |
|
| 471 | - * @return EventDispatcherInterface |
|
| 472 | - * @since 8.2.0 |
|
| 473 | - */ |
|
| 474 | - public function getEventDispatcher(); |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * Get the Notification Manager |
|
| 478 | - * |
|
| 479 | - * @return \OCP\Notification\IManager |
|
| 480 | - * @since 9.0.0 |
|
| 481 | - */ |
|
| 482 | - public function getNotificationManager(); |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * @return \OCP\Comments\ICommentsManager |
|
| 486 | - * @since 9.0.0 |
|
| 487 | - */ |
|
| 488 | - public function getCommentsManager(); |
|
| 489 | - |
|
| 490 | - /** |
|
| 491 | - * Returns the system-tag manager |
|
| 492 | - * |
|
| 493 | - * @return \OCP\SystemTag\ISystemTagManager |
|
| 494 | - * |
|
| 495 | - * @since 9.0.0 |
|
| 496 | - */ |
|
| 497 | - public function getSystemTagManager(); |
|
| 498 | - |
|
| 499 | - /** |
|
| 500 | - * Returns the system-tag object mapper |
|
| 501 | - * |
|
| 502 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 503 | - * |
|
| 504 | - * @since 9.0.0 |
|
| 505 | - */ |
|
| 506 | - public function getSystemTagObjectMapper(); |
|
| 507 | - |
|
| 508 | - /** |
|
| 509 | - * Returns the share manager |
|
| 510 | - * |
|
| 511 | - * @return \OCP\Share\IManager |
|
| 512 | - * @since 9.0.0 |
|
| 513 | - */ |
|
| 514 | - public function getShareManager(); |
|
| 515 | - |
|
| 516 | - /** |
|
| 517 | - * @return IContentSecurityPolicyManager |
|
| 518 | - * @since 9.0.0 |
|
| 519 | - */ |
|
| 520 | - public function getContentSecurityPolicyManager(); |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * @return \OCP\IDateTimeZone |
|
| 524 | - * @since 8.0.0 |
|
| 525 | - */ |
|
| 526 | - public function getDateTimeZone(); |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * @return \OCP\IDateTimeFormatter |
|
| 530 | - * @since 8.0.0 |
|
| 531 | - */ |
|
| 532 | - public function getDateTimeFormatter(); |
|
| 533 | - |
|
| 534 | - /** |
|
| 535 | - * @return \OCP\Federation\ICloudIdManager |
|
| 536 | - * @since 12.0.0 |
|
| 537 | - */ |
|
| 538 | - public function getCloudIdManager(); |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * @return \OCP\GlobalScale\IConfig |
|
| 542 | - */ |
|
| 543 | - public function getGlobalScaleConfig(); |
|
| 544 | - |
|
| 545 | - /** |
|
| 546 | - * @return ICloudFederationFactory |
|
| 547 | - * @since 14.0.0 |
|
| 548 | - */ |
|
| 549 | - public function getCloudFederationFactory(); |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * @return ICloudFederationProviderManager |
|
| 553 | - * @since 14.0.0 |
|
| 554 | - */ |
|
| 555 | - public function getCloudFederationProviderManager(); |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * @return \OCP\Remote\Api\IApiFactory |
|
| 559 | - * @since 13.0.0 |
|
| 560 | - */ |
|
| 561 | - public function getRemoteApiFactory(); |
|
| 562 | - |
|
| 563 | - /** |
|
| 564 | - * @return \OCP\Remote\IInstanceFactory |
|
| 565 | - * @since 13.0.0 |
|
| 566 | - */ |
|
| 567 | - public function getRemoteInstanceFactory(); |
|
| 63 | + /** |
|
| 64 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
| 65 | + * providers which actual deliver the calendar information. |
|
| 66 | + * |
|
| 67 | + * @return \OCP\Calendar\IManager |
|
| 68 | + * @since 13.0.0 |
|
| 69 | + */ |
|
| 70 | + public function getCalendarManager(); |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
| 74 | + * providers which actual deliver the contact information. |
|
| 75 | + * |
|
| 76 | + * @return \OCP\Contacts\IManager |
|
| 77 | + * @since 6.0.0 |
|
| 78 | + */ |
|
| 79 | + public function getContactsManager(); |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * The current request object holding all information about the request currently being processed |
|
| 83 | + * is returned from this method. |
|
| 84 | + * In case the current execution was not initiated by a web request null is returned |
|
| 85 | + * |
|
| 86 | + * @return \OCP\IRequest |
|
| 87 | + * @since 6.0.0 |
|
| 88 | + */ |
|
| 89 | + public function getRequest(); |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Returns the preview manager which can create preview images for a given file |
|
| 93 | + * |
|
| 94 | + * @return \OCP\IPreview |
|
| 95 | + * @since 6.0.0 |
|
| 96 | + */ |
|
| 97 | + public function getPreviewManager(); |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Returns the tag manager which can get and set tags for different object types |
|
| 101 | + * |
|
| 102 | + * @see \OCP\ITagManager::load() |
|
| 103 | + * @return \OCP\ITagManager |
|
| 104 | + * @since 6.0.0 |
|
| 105 | + */ |
|
| 106 | + public function getTagManager(); |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Returns the root folder of ownCloud's data directory |
|
| 110 | + * |
|
| 111 | + * @return \OCP\Files\IRootFolder |
|
| 112 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
| 113 | + */ |
|
| 114 | + public function getRootFolder(); |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Returns a view to ownCloud's files folder |
|
| 118 | + * |
|
| 119 | + * @param string $userId user ID |
|
| 120 | + * @return \OCP\Files\Folder |
|
| 121 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
| 122 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
| 123 | + */ |
|
| 124 | + public function getUserFolder($userId = null); |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Returns an app-specific view in ownClouds data directory |
|
| 128 | + * |
|
| 129 | + * @return \OCP\Files\Folder |
|
| 130 | + * @since 6.0.0 |
|
| 131 | + * @deprecated 9.2.0 use IAppData |
|
| 132 | + */ |
|
| 133 | + public function getAppFolder(); |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Returns a user manager |
|
| 137 | + * |
|
| 138 | + * @return \OCP\IUserManager |
|
| 139 | + * @since 8.0.0 |
|
| 140 | + */ |
|
| 141 | + public function getUserManager(); |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Returns a group manager |
|
| 145 | + * |
|
| 146 | + * @return \OCP\IGroupManager |
|
| 147 | + * @since 8.0.0 |
|
| 148 | + */ |
|
| 149 | + public function getGroupManager(); |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Returns the user session |
|
| 153 | + * |
|
| 154 | + * @return \OCP\IUserSession |
|
| 155 | + * @since 6.0.0 |
|
| 156 | + */ |
|
| 157 | + public function getUserSession(); |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Returns the navigation manager |
|
| 161 | + * |
|
| 162 | + * @return \OCP\INavigationManager |
|
| 163 | + * @since 6.0.0 |
|
| 164 | + */ |
|
| 165 | + public function getNavigationManager(); |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Returns the config manager |
|
| 169 | + * |
|
| 170 | + * @return \OCP\IConfig |
|
| 171 | + * @since 6.0.0 |
|
| 172 | + */ |
|
| 173 | + public function getConfig(); |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Returns a Crypto instance |
|
| 177 | + * |
|
| 178 | + * @return \OCP\Security\ICrypto |
|
| 179 | + * @since 8.0.0 |
|
| 180 | + */ |
|
| 181 | + public function getCrypto(); |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Returns a Hasher instance |
|
| 185 | + * |
|
| 186 | + * @return \OCP\Security\IHasher |
|
| 187 | + * @since 8.0.0 |
|
| 188 | + */ |
|
| 189 | + public function getHasher(); |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Returns a SecureRandom instance |
|
| 193 | + * |
|
| 194 | + * @return \OCP\Security\ISecureRandom |
|
| 195 | + * @since 8.1.0 |
|
| 196 | + */ |
|
| 197 | + public function getSecureRandom(); |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Returns a CredentialsManager instance |
|
| 201 | + * |
|
| 202 | + * @return \OCP\Security\ICredentialsManager |
|
| 203 | + * @since 9.0.0 |
|
| 204 | + */ |
|
| 205 | + public function getCredentialsManager(); |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Returns the app config manager |
|
| 209 | + * |
|
| 210 | + * @return \OCP\IAppConfig |
|
| 211 | + * @since 7.0.0 |
|
| 212 | + */ |
|
| 213 | + public function getAppConfig(); |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @return \OCP\L10N\IFactory |
|
| 217 | + * @since 8.2.0 |
|
| 218 | + */ |
|
| 219 | + public function getL10NFactory(); |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * get an L10N instance |
|
| 223 | + * @param string $app appid |
|
| 224 | + * @param string $lang |
|
| 225 | + * @return \OCP\IL10N |
|
| 226 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
| 227 | + */ |
|
| 228 | + public function getL10N($app, $lang = null); |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @return \OC\Encryption\Manager |
|
| 232 | + * @since 8.1.0 |
|
| 233 | + */ |
|
| 234 | + public function getEncryptionManager(); |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * @return \OC\Encryption\File |
|
| 238 | + * @since 8.1.0 |
|
| 239 | + */ |
|
| 240 | + public function getEncryptionFilesHelper(); |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 244 | + * @since 8.1.0 |
|
| 245 | + */ |
|
| 246 | + public function getEncryptionKeyStorage(); |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * Returns the URL generator |
|
| 250 | + * |
|
| 251 | + * @return \OCP\IURLGenerator |
|
| 252 | + * @since 6.0.0 |
|
| 253 | + */ |
|
| 254 | + public function getURLGenerator(); |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * Returns an ICache instance |
|
| 258 | + * |
|
| 259 | + * @return \OCP\ICache |
|
| 260 | + * @since 6.0.0 |
|
| 261 | + */ |
|
| 262 | + public function getCache(); |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Returns an \OCP\CacheFactory instance |
|
| 266 | + * |
|
| 267 | + * @return \OCP\ICacheFactory |
|
| 268 | + * @since 7.0.0 |
|
| 269 | + */ |
|
| 270 | + public function getMemCacheFactory(); |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * Returns the current session |
|
| 274 | + * |
|
| 275 | + * @return \OCP\ISession |
|
| 276 | + * @since 6.0.0 |
|
| 277 | + */ |
|
| 278 | + public function getSession(); |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Returns the activity manager |
|
| 282 | + * |
|
| 283 | + * @return \OCP\Activity\IManager |
|
| 284 | + * @since 6.0.0 |
|
| 285 | + */ |
|
| 286 | + public function getActivityManager(); |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Returns the current session |
|
| 290 | + * |
|
| 291 | + * @return \OCP\IDBConnection |
|
| 292 | + * @since 6.0.0 |
|
| 293 | + */ |
|
| 294 | + public function getDatabaseConnection(); |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Returns an avatar manager, used for avatar functionality |
|
| 298 | + * |
|
| 299 | + * @return \OCP\IAvatarManager |
|
| 300 | + * @since 6.0.0 |
|
| 301 | + */ |
|
| 302 | + public function getAvatarManager(); |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Returns an job list for controlling background jobs |
|
| 306 | + * |
|
| 307 | + * @return \OCP\BackgroundJob\IJobList |
|
| 308 | + * @since 7.0.0 |
|
| 309 | + */ |
|
| 310 | + public function getJobList(); |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Returns a logger instance |
|
| 314 | + * |
|
| 315 | + * @return \OCP\ILogger |
|
| 316 | + * @since 8.0.0 |
|
| 317 | + */ |
|
| 318 | + public function getLogger(); |
|
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * returns a log factory instance |
|
| 322 | + * |
|
| 323 | + * @return ILogFactory |
|
| 324 | + * @since 14.0.0 |
|
| 325 | + */ |
|
| 326 | + public function getLogFactory(); |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Returns a router for generating and matching urls |
|
| 330 | + * |
|
| 331 | + * @return \OCP\Route\IRouter |
|
| 332 | + * @since 7.0.0 |
|
| 333 | + */ |
|
| 334 | + public function getRouter(); |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * Returns a search instance |
|
| 338 | + * |
|
| 339 | + * @return \OCP\ISearch |
|
| 340 | + * @since 7.0.0 |
|
| 341 | + */ |
|
| 342 | + public function getSearch(); |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Get the certificate manager for the user |
|
| 346 | + * |
|
| 347 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 348 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
| 349 | + * @since 8.0.0 |
|
| 350 | + */ |
|
| 351 | + public function getCertificateManager($userId = null); |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Create a new event source |
|
| 355 | + * |
|
| 356 | + * @return \OCP\IEventSource |
|
| 357 | + * @since 8.0.0 |
|
| 358 | + */ |
|
| 359 | + public function createEventSource(); |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * Returns an instance of the HTTP client service |
|
| 363 | + * |
|
| 364 | + * @return \OCP\Http\Client\IClientService |
|
| 365 | + * @since 8.1.0 |
|
| 366 | + */ |
|
| 367 | + public function getHTTPClientService(); |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Get the active event logger |
|
| 371 | + * |
|
| 372 | + * @return \OCP\Diagnostics\IEventLogger |
|
| 373 | + * @since 8.0.0 |
|
| 374 | + */ |
|
| 375 | + public function getEventLogger(); |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * Get the active query logger |
|
| 379 | + * |
|
| 380 | + * The returned logger only logs data when debug mode is enabled |
|
| 381 | + * |
|
| 382 | + * @return \OCP\Diagnostics\IQueryLogger |
|
| 383 | + * @since 8.0.0 |
|
| 384 | + */ |
|
| 385 | + public function getQueryLogger(); |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * Get the manager for temporary files and folders |
|
| 389 | + * |
|
| 390 | + * @return \OCP\ITempManager |
|
| 391 | + * @since 8.0.0 |
|
| 392 | + */ |
|
| 393 | + public function getTempManager(); |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Get the app manager |
|
| 397 | + * |
|
| 398 | + * @return \OCP\App\IAppManager |
|
| 399 | + * @since 8.0.0 |
|
| 400 | + */ |
|
| 401 | + public function getAppManager(); |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * Get the webroot |
|
| 405 | + * |
|
| 406 | + * @return string |
|
| 407 | + * @since 8.0.0 |
|
| 408 | + */ |
|
| 409 | + public function getWebRoot(); |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
| 413 | + * @since 8.0.0 |
|
| 414 | + */ |
|
| 415 | + public function getMountProviderCollection(); |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * Get the IniWrapper |
|
| 419 | + * |
|
| 420 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
| 421 | + * @since 8.0.0 |
|
| 422 | + */ |
|
| 423 | + public function getIniWrapper(); |
|
| 424 | + /** |
|
| 425 | + * @return \OCP\Command\IBus |
|
| 426 | + * @since 8.1.0 |
|
| 427 | + */ |
|
| 428 | + public function getCommandBus(); |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * Creates a new mailer |
|
| 432 | + * |
|
| 433 | + * @return \OCP\Mail\IMailer |
|
| 434 | + * @since 8.1.0 |
|
| 435 | + */ |
|
| 436 | + public function getMailer(); |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * Get the locking provider |
|
| 440 | + * |
|
| 441 | + * @return \OCP\Lock\ILockingProvider |
|
| 442 | + * @since 8.1.0 |
|
| 443 | + */ |
|
| 444 | + public function getLockingProvider(); |
|
| 445 | + |
|
| 446 | + /** |
|
| 447 | + * @return \OCP\Files\Mount\IMountManager |
|
| 448 | + * @since 8.2.0 |
|
| 449 | + */ |
|
| 450 | + public function getMountManager(); |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * Get the MimeTypeDetector |
|
| 454 | + * |
|
| 455 | + * @return \OCP\Files\IMimeTypeDetector |
|
| 456 | + * @since 8.2.0 |
|
| 457 | + */ |
|
| 458 | + public function getMimeTypeDetector(); |
|
| 459 | + |
|
| 460 | + /** |
|
| 461 | + * Get the MimeTypeLoader |
|
| 462 | + * |
|
| 463 | + * @return \OCP\Files\IMimeTypeLoader |
|
| 464 | + * @since 8.2.0 |
|
| 465 | + */ |
|
| 466 | + public function getMimeTypeLoader(); |
|
| 467 | + |
|
| 468 | + /** |
|
| 469 | + * Get the EventDispatcher |
|
| 470 | + * |
|
| 471 | + * @return EventDispatcherInterface |
|
| 472 | + * @since 8.2.0 |
|
| 473 | + */ |
|
| 474 | + public function getEventDispatcher(); |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * Get the Notification Manager |
|
| 478 | + * |
|
| 479 | + * @return \OCP\Notification\IManager |
|
| 480 | + * @since 9.0.0 |
|
| 481 | + */ |
|
| 482 | + public function getNotificationManager(); |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * @return \OCP\Comments\ICommentsManager |
|
| 486 | + * @since 9.0.0 |
|
| 487 | + */ |
|
| 488 | + public function getCommentsManager(); |
|
| 489 | + |
|
| 490 | + /** |
|
| 491 | + * Returns the system-tag manager |
|
| 492 | + * |
|
| 493 | + * @return \OCP\SystemTag\ISystemTagManager |
|
| 494 | + * |
|
| 495 | + * @since 9.0.0 |
|
| 496 | + */ |
|
| 497 | + public function getSystemTagManager(); |
|
| 498 | + |
|
| 499 | + /** |
|
| 500 | + * Returns the system-tag object mapper |
|
| 501 | + * |
|
| 502 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 503 | + * |
|
| 504 | + * @since 9.0.0 |
|
| 505 | + */ |
|
| 506 | + public function getSystemTagObjectMapper(); |
|
| 507 | + |
|
| 508 | + /** |
|
| 509 | + * Returns the share manager |
|
| 510 | + * |
|
| 511 | + * @return \OCP\Share\IManager |
|
| 512 | + * @since 9.0.0 |
|
| 513 | + */ |
|
| 514 | + public function getShareManager(); |
|
| 515 | + |
|
| 516 | + /** |
|
| 517 | + * @return IContentSecurityPolicyManager |
|
| 518 | + * @since 9.0.0 |
|
| 519 | + */ |
|
| 520 | + public function getContentSecurityPolicyManager(); |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * @return \OCP\IDateTimeZone |
|
| 524 | + * @since 8.0.0 |
|
| 525 | + */ |
|
| 526 | + public function getDateTimeZone(); |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * @return \OCP\IDateTimeFormatter |
|
| 530 | + * @since 8.0.0 |
|
| 531 | + */ |
|
| 532 | + public function getDateTimeFormatter(); |
|
| 533 | + |
|
| 534 | + /** |
|
| 535 | + * @return \OCP\Federation\ICloudIdManager |
|
| 536 | + * @since 12.0.0 |
|
| 537 | + */ |
|
| 538 | + public function getCloudIdManager(); |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * @return \OCP\GlobalScale\IConfig |
|
| 542 | + */ |
|
| 543 | + public function getGlobalScaleConfig(); |
|
| 544 | + |
|
| 545 | + /** |
|
| 546 | + * @return ICloudFederationFactory |
|
| 547 | + * @since 14.0.0 |
|
| 548 | + */ |
|
| 549 | + public function getCloudFederationFactory(); |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * @return ICloudFederationProviderManager |
|
| 553 | + * @since 14.0.0 |
|
| 554 | + */ |
|
| 555 | + public function getCloudFederationProviderManager(); |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * @return \OCP\Remote\Api\IApiFactory |
|
| 559 | + * @since 13.0.0 |
|
| 560 | + */ |
|
| 561 | + public function getRemoteApiFactory(); |
|
| 562 | + |
|
| 563 | + /** |
|
| 564 | + * @return \OCP\Remote\IInstanceFactory |
|
| 565 | + * @since 13.0.0 |
|
| 566 | + */ |
|
| 567 | + public function getRemoteInstanceFactory(); |
|
| 568 | 568 | } |
@@ -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()); |
|
| 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()); |
|
| 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 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | // To find out if we are running from CLI or not |
| 173 | 173 | $this->registerParameter('isCLI', \OC::$CLI); |
| 174 | 174 | |
| 175 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 175 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
| 176 | 176 | return $c; |
| 177 | 177 | }); |
| 178 | 178 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
| 186 | 186 | |
| 187 | 187 | |
| 188 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 188 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
| 189 | 189 | return new PreviewManager( |
| 190 | 190 | $c->getConfig(), |
| 191 | 191 | $c->getRootFolder(), |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | }); |
| 197 | 197 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
| 198 | 198 | |
| 199 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 199 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
| 200 | 200 | return new \OC\Preview\Watcher( |
| 201 | 201 | $c->getAppDataDir('preview') |
| 202 | 202 | ); |
| 203 | 203 | }); |
| 204 | 204 | |
| 205 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
| 205 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
| 206 | 206 | $view = new View(); |
| 207 | 207 | $util = new Encryption\Util( |
| 208 | 208 | $view, |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | ); |
| 221 | 221 | }); |
| 222 | 222 | |
| 223 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 223 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
| 224 | 224 | $util = new Encryption\Util( |
| 225 | 225 | new View(), |
| 226 | 226 | $c->getUserManager(), |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | ); |
| 235 | 235 | }); |
| 236 | 236 | |
| 237 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 237 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
| 238 | 238 | $view = new View(); |
| 239 | 239 | $util = new Encryption\Util( |
| 240 | 240 | $view, |
@@ -245,30 +245,30 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | return new Encryption\Keys\Storage($view, $util); |
| 247 | 247 | }); |
| 248 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 248 | + $this->registerService('TagMapper', function(Server $c) { |
|
| 249 | 249 | return new TagMapper($c->getDatabaseConnection()); |
| 250 | 250 | }); |
| 251 | 251 | |
| 252 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 252 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
| 253 | 253 | $tagMapper = $c->query('TagMapper'); |
| 254 | 254 | return new TagManager($tagMapper, $c->getUserSession()); |
| 255 | 255 | }); |
| 256 | 256 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
| 257 | 257 | |
| 258 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 258 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
| 259 | 259 | $config = $c->getConfig(); |
| 260 | 260 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
| 261 | 261 | return new $factoryClass($this); |
| 262 | 262 | }); |
| 263 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 263 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
| 264 | 264 | return $c->query('SystemTagManagerFactory')->getManager(); |
| 265 | 265 | }); |
| 266 | 266 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
| 267 | 267 | |
| 268 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 268 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
| 269 | 269 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
| 270 | 270 | }); |
| 271 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 271 | + $this->registerService('RootFolder', function(Server $c) { |
|
| 272 | 272 | $manager = \OC\Files\Filesystem::getMountManager(null); |
| 273 | 273 | $view = new View(); |
| 274 | 274 | $root = new Root( |
@@ -289,38 +289,38 @@ discard block |
||
| 289 | 289 | }); |
| 290 | 290 | $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
| 291 | 291 | |
| 292 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
| 293 | - return new LazyRoot(function () use ($c) { |
|
| 292 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
| 293 | + return new LazyRoot(function() use ($c) { |
|
| 294 | 294 | return $c->query('RootFolder'); |
| 295 | 295 | }); |
| 296 | 296 | }); |
| 297 | 297 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
| 298 | 298 | |
| 299 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
| 299 | + $this->registerService(\OC\User\Manager::class, function(Server $c) { |
|
| 300 | 300 | $config = $c->getConfig(); |
| 301 | 301 | return new \OC\User\Manager($config); |
| 302 | 302 | }); |
| 303 | 303 | $this->registerAlias('UserManager', \OC\User\Manager::class); |
| 304 | 304 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
| 305 | 305 | |
| 306 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 306 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
| 307 | 307 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
| 308 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 308 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
| 309 | 309 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
| 310 | 310 | }); |
| 311 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 311 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
| 312 | 312 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
| 313 | 313 | }); |
| 314 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 314 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
| 315 | 315 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
| 316 | 316 | }); |
| 317 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 317 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
| 318 | 318 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
| 319 | 319 | }); |
| 320 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 320 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 321 | 321 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
| 322 | 322 | }); |
| 323 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 323 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 324 | 324 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
| 325 | 325 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
| 326 | 326 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | }); |
| 330 | 330 | $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
| 331 | 331 | |
| 332 | - $this->registerService(Store::class, function (Server $c) { |
|
| 332 | + $this->registerService(Store::class, function(Server $c) { |
|
| 333 | 333 | $session = $c->getSession(); |
| 334 | 334 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
| 335 | 335 | $tokenProvider = $c->query(IProvider::class); |
@@ -340,11 +340,11 @@ discard block |
||
| 340 | 340 | return new Store($session, $logger, $tokenProvider); |
| 341 | 341 | }); |
| 342 | 342 | $this->registerAlias(IStore::class, Store::class); |
| 343 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 343 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) { |
|
| 344 | 344 | $dbConnection = $c->getDatabaseConnection(); |
| 345 | 345 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
| 346 | 346 | }); |
| 347 | - $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
| 347 | + $this->registerService(Authentication\Token\DefaultTokenProvider::class, function(Server $c) { |
|
| 348 | 348 | $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
| 349 | 349 | $crypto = $c->getCrypto(); |
| 350 | 350 | $config = $c->getConfig(); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | }); |
| 355 | 355 | $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
| 356 | 356 | |
| 357 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 357 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
| 358 | 358 | $manager = $c->getUserManager(); |
| 359 | 359 | $session = new \OC\Session\Memory(''); |
| 360 | 360 | $timeFactory = new TimeFactory(); |
@@ -378,45 +378,45 @@ discard block |
||
| 378 | 378 | $c->getLockdownManager(), |
| 379 | 379 | $c->getLogger() |
| 380 | 380 | ); |
| 381 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 381 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
| 382 | 382 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
| 383 | 383 | }); |
| 384 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 384 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
| 385 | 385 | /** @var $user \OC\User\User */ |
| 386 | 386 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
| 387 | 387 | }); |
| 388 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
| 388 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($dispatcher) { |
|
| 389 | 389 | /** @var $user \OC\User\User */ |
| 390 | 390 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
| 391 | 391 | $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
| 392 | 392 | }); |
| 393 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 393 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
| 394 | 394 | /** @var $user \OC\User\User */ |
| 395 | 395 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
| 396 | 396 | }); |
| 397 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 397 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
| 398 | 398 | /** @var $user \OC\User\User */ |
| 399 | 399 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
| 400 | 400 | }); |
| 401 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 401 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
| 402 | 402 | /** @var $user \OC\User\User */ |
| 403 | 403 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
| 404 | 404 | }); |
| 405 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 405 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
| 406 | 406 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
| 407 | 407 | }); |
| 408 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 408 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
| 409 | 409 | /** @var $user \OC\User\User */ |
| 410 | 410 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
| 411 | 411 | }); |
| 412 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 412 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
| 413 | 413 | /** @var $user \OC\User\User */ |
| 414 | 414 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
| 415 | 415 | }); |
| 416 | - $userSession->listen('\OC\User', 'logout', function () { |
|
| 416 | + $userSession->listen('\OC\User', 'logout', function() { |
|
| 417 | 417 | \OC_Hook::emit('OC_User', 'logout', array()); |
| 418 | 418 | }); |
| 419 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 419 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 420 | 420 | /** @var $user \OC\User\User */ |
| 421 | 421 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
| 422 | 422 | $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | }); |
| 426 | 426 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
| 427 | 427 | |
| 428 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 428 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
| 429 | 429 | return new \OC\Authentication\TwoFactorAuth\Manager( |
| 430 | 430 | $c->getAppManager(), |
| 431 | 431 | $c->getSession(), |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
| 442 | 442 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
| 443 | 443 | |
| 444 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 444 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
| 445 | 445 | return new \OC\AllConfig( |
| 446 | 446 | $c->getSystemConfig() |
| 447 | 447 | ); |
@@ -449,17 +449,17 @@ discard block |
||
| 449 | 449 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
| 450 | 450 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
| 451 | 451 | |
| 452 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 452 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
| 453 | 453 | return new \OC\SystemConfig($config); |
| 454 | 454 | }); |
| 455 | 455 | |
| 456 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 456 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
| 457 | 457 | return new \OC\AppConfig($c->getDatabaseConnection()); |
| 458 | 458 | }); |
| 459 | 459 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
| 460 | 460 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
| 461 | 461 | |
| 462 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 462 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
| 463 | 463 | return new \OC\L10N\Factory( |
| 464 | 464 | $c->getConfig(), |
| 465 | 465 | $c->getRequest(), |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | }); |
| 470 | 470 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
| 471 | 471 | |
| 472 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 472 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
| 473 | 473 | $config = $c->getConfig(); |
| 474 | 474 | $cacheFactory = $c->getMemCacheFactory(); |
| 475 | 475 | $request = $c->getRequest(); |
@@ -484,12 +484,12 @@ discard block |
||
| 484 | 484 | $this->registerAlias('AppFetcher', AppFetcher::class); |
| 485 | 485 | $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
| 486 | 486 | |
| 487 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 487 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
| 488 | 488 | return new Cache\File(); |
| 489 | 489 | }); |
| 490 | 490 | $this->registerAlias('UserCache', \OCP\ICache::class); |
| 491 | 491 | |
| 492 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 492 | + $this->registerService(Factory::class, function(Server $c) { |
|
| 493 | 493 | |
| 494 | 494 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
| 495 | 495 | ArrayCache::class, |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | $version = implode(',', $v); |
| 507 | 507 | $instanceId = \OC_Util::getInstanceId(); |
| 508 | 508 | $path = \OC::$SERVERROOT; |
| 509 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 509 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
| 510 | 510 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
| 511 | 511 | $config->getSystemValue('memcache.local', null), |
| 512 | 512 | $config->getSystemValue('memcache.distributed', null), |
@@ -519,12 +519,12 @@ discard block |
||
| 519 | 519 | $this->registerAlias('MemCacheFactory', Factory::class); |
| 520 | 520 | $this->registerAlias(ICacheFactory::class, Factory::class); |
| 521 | 521 | |
| 522 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 522 | + $this->registerService('RedisFactory', function(Server $c) { |
|
| 523 | 523 | $systemConfig = $c->getSystemConfig(); |
| 524 | 524 | return new RedisFactory($systemConfig); |
| 525 | 525 | }); |
| 526 | 526 | |
| 527 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 527 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
| 528 | 528 | return new \OC\Activity\Manager( |
| 529 | 529 | $c->getRequest(), |
| 530 | 530 | $c->getUserSession(), |
@@ -534,14 +534,14 @@ discard block |
||
| 534 | 534 | }); |
| 535 | 535 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
| 536 | 536 | |
| 537 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 537 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
| 538 | 538 | return new \OC\Activity\EventMerger( |
| 539 | 539 | $c->getL10N('lib') |
| 540 | 540 | ); |
| 541 | 541 | }); |
| 542 | 542 | $this->registerAlias(IValidator::class, Validator::class); |
| 543 | 543 | |
| 544 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 544 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
| 545 | 545 | return new AvatarManager( |
| 546 | 546 | $c->query(\OC\User\Manager::class), |
| 547 | 547 | $c->getAppDataDir('avatar'), |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
| 556 | 556 | |
| 557 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 557 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
| 558 | 558 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
| 559 | 559 | $factory = new LogFactory($c, $this->getSystemConfig()); |
| 560 | 560 | $logger = $factory->get($logType); |
@@ -564,11 +564,11 @@ discard block |
||
| 564 | 564 | }); |
| 565 | 565 | $this->registerAlias('Logger', \OCP\ILogger::class); |
| 566 | 566 | |
| 567 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
| 567 | + $this->registerService(ILogFactory::class, function(Server $c) { |
|
| 568 | 568 | return new LogFactory($c, $this->getSystemConfig()); |
| 569 | 569 | }); |
| 570 | 570 | |
| 571 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 571 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
| 572 | 572 | $config = $c->getConfig(); |
| 573 | 573 | return new \OC\BackgroundJob\JobList( |
| 574 | 574 | $c->getDatabaseConnection(), |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | }); |
| 579 | 579 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
| 580 | 580 | |
| 581 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 581 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
| 582 | 582 | $cacheFactory = $c->getMemCacheFactory(); |
| 583 | 583 | $logger = $c->getLogger(); |
| 584 | 584 | if ($cacheFactory->isLocalCacheAvailable()) { |
@@ -590,12 +590,12 @@ discard block |
||
| 590 | 590 | }); |
| 591 | 591 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
| 592 | 592 | |
| 593 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 593 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
| 594 | 594 | return new Search(); |
| 595 | 595 | }); |
| 596 | 596 | $this->registerAlias('Search', \OCP\ISearch::class); |
| 597 | 597 | |
| 598 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
| 598 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function(Server $c) { |
|
| 599 | 599 | return new \OC\Security\RateLimiting\Limiter( |
| 600 | 600 | $this->getUserSession(), |
| 601 | 601 | $this->getRequest(), |
@@ -603,34 +603,34 @@ discard block |
||
| 603 | 603 | $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
| 604 | 604 | ); |
| 605 | 605 | }); |
| 606 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 606 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
| 607 | 607 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
| 608 | 608 | $this->getMemCacheFactory(), |
| 609 | 609 | new \OC\AppFramework\Utility\TimeFactory() |
| 610 | 610 | ); |
| 611 | 611 | }); |
| 612 | 612 | |
| 613 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 613 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
| 614 | 614 | return new SecureRandom(); |
| 615 | 615 | }); |
| 616 | 616 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
| 617 | 617 | |
| 618 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 618 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
| 619 | 619 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
| 620 | 620 | }); |
| 621 | 621 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
| 622 | 622 | |
| 623 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 623 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
| 624 | 624 | return new Hasher($c->getConfig()); |
| 625 | 625 | }); |
| 626 | 626 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
| 627 | 627 | |
| 628 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 628 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
| 629 | 629 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
| 630 | 630 | }); |
| 631 | 631 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
| 632 | 632 | |
| 633 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 633 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
| 634 | 634 | $systemConfig = $c->getSystemConfig(); |
| 635 | 635 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
| 636 | 636 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
| 646 | 646 | |
| 647 | 647 | |
| 648 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 648 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
| 649 | 649 | $user = \OC_User::getUser(); |
| 650 | 650 | $uid = $user ? $user : null; |
| 651 | 651 | return new ClientService( |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | ); |
| 661 | 661 | }); |
| 662 | 662 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
| 663 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 663 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
| 664 | 664 | $eventLogger = new EventLogger(); |
| 665 | 665 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 666 | 666 | // In debug mode, module is being activated by default |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | }); |
| 671 | 671 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
| 672 | 672 | |
| 673 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 673 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
| 674 | 674 | $queryLogger = new QueryLogger(); |
| 675 | 675 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 676 | 676 | // In debug mode, module is being activated by default |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | }); |
| 681 | 681 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
| 682 | 682 | |
| 683 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 683 | + $this->registerService(TempManager::class, function(Server $c) { |
|
| 684 | 684 | return new TempManager( |
| 685 | 685 | $c->getLogger(), |
| 686 | 686 | $c->getConfig() |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | $this->registerAlias('TempManager', TempManager::class); |
| 690 | 690 | $this->registerAlias(ITempManager::class, TempManager::class); |
| 691 | 691 | |
| 692 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 692 | + $this->registerService(AppManager::class, function(Server $c) { |
|
| 693 | 693 | return new \OC\App\AppManager( |
| 694 | 694 | $c->getUserSession(), |
| 695 | 695 | $c->query(\OC\AppConfig::class), |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | $this->registerAlias('AppManager', AppManager::class); |
| 702 | 702 | $this->registerAlias(IAppManager::class, AppManager::class); |
| 703 | 703 | |
| 704 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 704 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
| 705 | 705 | return new DateTimeZone( |
| 706 | 706 | $c->getConfig(), |
| 707 | 707 | $c->getSession() |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | }); |
| 710 | 710 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
| 711 | 711 | |
| 712 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 712 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
| 713 | 713 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
| 714 | 714 | |
| 715 | 715 | return new DateTimeFormatter( |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | }); |
| 720 | 720 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
| 721 | 721 | |
| 722 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 722 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
| 723 | 723 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
| 724 | 724 | $listener = new UserMountCacheListener($mountCache); |
| 725 | 725 | $listener->listen($c->getUserManager()); |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | }); |
| 728 | 728 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
| 729 | 729 | |
| 730 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 730 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
| 731 | 731 | $loader = \OC\Files\Filesystem::getLoader(); |
| 732 | 732 | $mountCache = $c->query('UserMountCache'); |
| 733 | 733 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -743,10 +743,10 @@ discard block |
||
| 743 | 743 | }); |
| 744 | 744 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
| 745 | 745 | |
| 746 | - $this->registerService('IniWrapper', function ($c) { |
|
| 746 | + $this->registerService('IniWrapper', function($c) { |
|
| 747 | 747 | return new IniGetWrapper(); |
| 748 | 748 | }); |
| 749 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 749 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
| 750 | 750 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
| 751 | 751 | if ($busClass) { |
| 752 | 752 | list($app, $class) = explode('::', $busClass, 2); |
@@ -761,10 +761,10 @@ discard block |
||
| 761 | 761 | return new CronBus($jobList); |
| 762 | 762 | } |
| 763 | 763 | }); |
| 764 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 764 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
| 765 | 765 | return new TrustedDomainHelper($this->getConfig()); |
| 766 | 766 | }); |
| 767 | - $this->registerService('Throttler', function (Server $c) { |
|
| 767 | + $this->registerService('Throttler', function(Server $c) { |
|
| 768 | 768 | return new Throttler( |
| 769 | 769 | $c->getDatabaseConnection(), |
| 770 | 770 | new TimeFactory(), |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | $c->getConfig() |
| 773 | 773 | ); |
| 774 | 774 | }); |
| 775 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 775 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
| 776 | 776 | // IConfig and IAppManager requires a working database. This code |
| 777 | 777 | // might however be called when ownCloud is not yet setup. |
| 778 | 778 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | $c->getTempManager() |
| 794 | 794 | ); |
| 795 | 795 | }); |
| 796 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 796 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
| 797 | 797 | if (isset($this['urlParams'])) { |
| 798 | 798 | $urlParams = $this['urlParams']; |
| 799 | 799 | } else { |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | }); |
| 830 | 830 | $this->registerAlias('Request', \OCP\IRequest::class); |
| 831 | 831 | |
| 832 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 832 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
| 833 | 833 | return new Mailer( |
| 834 | 834 | $c->getConfig(), |
| 835 | 835 | $c->getLogger(), |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | }); |
| 841 | 841 | $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
| 842 | 842 | |
| 843 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 843 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
| 844 | 844 | $config = $c->getConfig(); |
| 845 | 845 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
| 846 | 846 | if (is_null($factoryClass)) { |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | $factory = new $factoryClass($this); |
| 851 | 851 | return $factory->getLDAPProvider(); |
| 852 | 852 | }); |
| 853 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 853 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
| 854 | 854 | $ini = $c->getIniWrapper(); |
| 855 | 855 | $config = $c->getConfig(); |
| 856 | 856 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -873,49 +873,49 @@ discard block |
||
| 873 | 873 | }); |
| 874 | 874 | $this->registerAlias('LockingProvider', ILockingProvider::class); |
| 875 | 875 | |
| 876 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 876 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
| 877 | 877 | return new \OC\Files\Mount\Manager(); |
| 878 | 878 | }); |
| 879 | 879 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
| 880 | 880 | |
| 881 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 881 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
| 882 | 882 | return new \OC\Files\Type\Detection( |
| 883 | 883 | $c->getURLGenerator(), |
| 884 | 884 | \OC::$configDir, |
| 885 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 885 | + \OC::$SERVERROOT.'/resources/config/' |
|
| 886 | 886 | ); |
| 887 | 887 | }); |
| 888 | 888 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
| 889 | 889 | |
| 890 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 890 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
| 891 | 891 | return new \OC\Files\Type\Loader( |
| 892 | 892 | $c->getDatabaseConnection() |
| 893 | 893 | ); |
| 894 | 894 | }); |
| 895 | 895 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
| 896 | - $this->registerService(BundleFetcher::class, function () { |
|
| 896 | + $this->registerService(BundleFetcher::class, function() { |
|
| 897 | 897 | return new BundleFetcher($this->getL10N('lib')); |
| 898 | 898 | }); |
| 899 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 899 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
| 900 | 900 | return new Manager( |
| 901 | 901 | $c->query(IValidator::class) |
| 902 | 902 | ); |
| 903 | 903 | }); |
| 904 | 904 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
| 905 | 905 | |
| 906 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 906 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
| 907 | 907 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
| 908 | - $manager->registerCapability(function () use ($c) { |
|
| 908 | + $manager->registerCapability(function() use ($c) { |
|
| 909 | 909 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
| 910 | 910 | }); |
| 911 | - $manager->registerCapability(function () use ($c) { |
|
| 911 | + $manager->registerCapability(function() use ($c) { |
|
| 912 | 912 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
| 913 | 913 | }); |
| 914 | 914 | return $manager; |
| 915 | 915 | }); |
| 916 | 916 | $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
| 917 | 917 | |
| 918 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
| 918 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
| 919 | 919 | $config = $c->getConfig(); |
| 920 | 920 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
| 921 | 921 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
| 926 | 926 | $manager = $c->getUserManager(); |
| 927 | 927 | $user = $manager->get($id); |
| 928 | - if(is_null($user)) { |
|
| 928 | + if (is_null($user)) { |
|
| 929 | 929 | $l = $c->getL10N('core'); |
| 930 | 930 | $displayName = $l->t('Unknown user'); |
| 931 | 931 | } else { |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | }); |
| 939 | 939 | $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
| 940 | 940 | |
| 941 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 941 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
| 942 | 942 | /* |
| 943 | 943 | * Dark magic for autoloader. |
| 944 | 944 | * If we do a class_exists it will try to load the class which will |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | } |
| 966 | 966 | return new \OC_Defaults(); |
| 967 | 967 | }); |
| 968 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 968 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
| 969 | 969 | /** @var Factory $cacheFactory */ |
| 970 | 970 | $cacheFactory = $c->query(Factory::class); |
| 971 | 971 | return new SCSSCacher( |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | $this->getMemCacheFactory() |
| 979 | 979 | ); |
| 980 | 980 | }); |
| 981 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 981 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
| 982 | 982 | /** @var Factory $cacheFactory */ |
| 983 | 983 | $cacheFactory = $c->query(Factory::class); |
| 984 | 984 | return new JSCombiner( |
@@ -989,13 +989,13 @@ discard block |
||
| 989 | 989 | $c->getLogger() |
| 990 | 990 | ); |
| 991 | 991 | }); |
| 992 | - $this->registerService(EventDispatcher::class, function () { |
|
| 992 | + $this->registerService(EventDispatcher::class, function() { |
|
| 993 | 993 | return new EventDispatcher(); |
| 994 | 994 | }); |
| 995 | 995 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
| 996 | 996 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
| 997 | 997 | |
| 998 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 998 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
| 999 | 999 | // FIXME: Instantiiated here due to cyclic dependency |
| 1000 | 1000 | $request = new Request( |
| 1001 | 1001 | [ |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $request |
| 1021 | 1021 | ); |
| 1022 | 1022 | }); |
| 1023 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 1023 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
| 1024 | 1024 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
| 1025 | 1025 | |
| 1026 | 1026 | return new CsrfTokenManager( |
@@ -1028,22 +1028,22 @@ discard block |
||
| 1028 | 1028 | $c->query(SessionStorage::class) |
| 1029 | 1029 | ); |
| 1030 | 1030 | }); |
| 1031 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1031 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
| 1032 | 1032 | return new SessionStorage($c->getSession()); |
| 1033 | 1033 | }); |
| 1034 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 1034 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
| 1035 | 1035 | return new ContentSecurityPolicyManager(); |
| 1036 | 1036 | }); |
| 1037 | 1037 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
| 1038 | 1038 | |
| 1039 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1039 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
| 1040 | 1040 | return new ContentSecurityPolicyNonceManager( |
| 1041 | 1041 | $c->getCsrfTokenManager(), |
| 1042 | 1042 | $c->getRequest() |
| 1043 | 1043 | ); |
| 1044 | 1044 | }); |
| 1045 | 1045 | |
| 1046 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1046 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
| 1047 | 1047 | $config = $c->getConfig(); |
| 1048 | 1048 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
| 1049 | 1049 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | |
| 1087 | 1087 | $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
| 1088 | 1088 | |
| 1089 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1089 | + $this->registerService('SettingsManager', function(Server $c) { |
|
| 1090 | 1090 | $manager = new \OC\Settings\Manager( |
| 1091 | 1091 | $c->getLogger(), |
| 1092 | 1092 | $c->getDatabaseConnection(), |
@@ -1104,36 +1104,36 @@ discard block |
||
| 1104 | 1104 | ); |
| 1105 | 1105 | return $manager; |
| 1106 | 1106 | }); |
| 1107 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1107 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
| 1108 | 1108 | return new \OC\Files\AppData\Factory( |
| 1109 | 1109 | $c->getRootFolder(), |
| 1110 | 1110 | $c->getSystemConfig() |
| 1111 | 1111 | ); |
| 1112 | 1112 | }); |
| 1113 | 1113 | |
| 1114 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1115 | - return new LockdownManager(function () use ($c) { |
|
| 1114 | + $this->registerService('LockdownManager', function(Server $c) { |
|
| 1115 | + return new LockdownManager(function() use ($c) { |
|
| 1116 | 1116 | return $c->getSession(); |
| 1117 | 1117 | }); |
| 1118 | 1118 | }); |
| 1119 | 1119 | |
| 1120 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1120 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
| 1121 | 1121 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
| 1122 | 1122 | }); |
| 1123 | 1123 | |
| 1124 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1124 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
| 1125 | 1125 | return new CloudIdManager(); |
| 1126 | 1126 | }); |
| 1127 | 1127 | |
| 1128 | - $this->registerService(IConfig::class, function (Server $c) { |
|
| 1128 | + $this->registerService(IConfig::class, function(Server $c) { |
|
| 1129 | 1129 | return new GlobalScale\Config($c->getConfig()); |
| 1130 | 1130 | }); |
| 1131 | 1131 | |
| 1132 | - $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { |
|
| 1132 | + $this->registerService(ICloudFederationProviderManager::class, function(Server $c) { |
|
| 1133 | 1133 | return new CloudFederationProviderManager($c->getAppManager()); |
| 1134 | 1134 | }); |
| 1135 | 1135 | |
| 1136 | - $this->registerService(ICloudFederationFactory::class, function (Server $c) { |
|
| 1136 | + $this->registerService(ICloudFederationFactory::class, function(Server $c) { |
|
| 1137 | 1137 | return new CloudFederationFactory(); |
| 1138 | 1138 | }); |
| 1139 | 1139 | |
@@ -1143,18 +1143,18 @@ discard block |
||
| 1143 | 1143 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
| 1144 | 1144 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
| 1145 | 1145 | |
| 1146 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1146 | + $this->registerService(Defaults::class, function(Server $c) { |
|
| 1147 | 1147 | return new Defaults( |
| 1148 | 1148 | $c->getThemingDefaults() |
| 1149 | 1149 | ); |
| 1150 | 1150 | }); |
| 1151 | 1151 | $this->registerAlias('Defaults', \OCP\Defaults::class); |
| 1152 | 1152 | |
| 1153 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1153 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
| 1154 | 1154 | return $c->query(\OCP\IUserSession::class)->getSession(); |
| 1155 | 1155 | }); |
| 1156 | 1156 | |
| 1157 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1157 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
| 1158 | 1158 | return new ShareHelper( |
| 1159 | 1159 | $c->query(\OCP\Share\IManager::class) |
| 1160 | 1160 | ); |
@@ -1216,11 +1216,11 @@ discard block |
||
| 1216 | 1216 | // no avatar to remove |
| 1217 | 1217 | } catch (\Exception $e) { |
| 1218 | 1218 | // Ignore exceptions |
| 1219 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1219 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
| 1220 | 1220 | } |
| 1221 | 1221 | }); |
| 1222 | 1222 | |
| 1223 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1223 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
| 1224 | 1224 | $manager = $this->getAvatarManager(); |
| 1225 | 1225 | /** @var IUser $user */ |
| 1226 | 1226 | $user = $e->getSubject(); |
@@ -1371,7 +1371,7 @@ discard block |
||
| 1371 | 1371 | * @deprecated since 9.2.0 use IAppData |
| 1372 | 1372 | */ |
| 1373 | 1373 | public function getAppFolder() { |
| 1374 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1374 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
| 1375 | 1375 | $root = $this->getRootFolder(); |
| 1376 | 1376 | if (!$root->nodeExists($dir)) { |
| 1377 | 1377 | $folder = $root->newFolder($dir); |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | /** |
| 1947 | 1947 | * @return \OCP\Collaboration\AutoComplete\IManager |
| 1948 | 1948 | */ |
| 1949 | - public function getAutoCompleteManager(){ |
|
| 1949 | + public function getAutoCompleteManager() { |
|
| 1950 | 1950 | return $this->query(IManager::class); |
| 1951 | 1951 | } |
| 1952 | 1952 | |