You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Application.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Robin Appelman <icewind@owncloud.com>
  6. * @author Robin McCorkell <robin@mccorkell.me.uk>
  7. * @author Roeland Jago Douma <rullzer@owncloud.com>
  8. * @author Ross Nicoll <jrn@jrn.me.uk>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @copyright Copyright (c) 2016, ownCloud, Inc.
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCA\Files_External\AppInfo;
  28. use \OCP\AppFramework\App;
  29. use OCP\AppFramework\IAppContainer;
  30. use \OCP\IContainer;
  31. use \OCA\Files_External\Service\BackendService;
  32. use \OCA\Files_External\Lib\Config\IBackendProvider;
  33. use \OCA\Files_External\Lib\Config\IAuthMechanismProvider;
  34. /**
  35. * @package OCA\Files_External\AppInfo
  36. */
  37. class Application extends App implements IBackendProvider, IAuthMechanismProvider {
  38. public function __construct(array $urlParams = array()) {
  39. parent::__construct('files_external', $urlParams);
  40. $container = $this->getContainer();
  41. $container->registerService('OCP\Files\Config\IUserMountCache', function (IAppContainer $c) {
  42. return $c->getServer()->query('UserMountCache');
  43. });
  44. $backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
  45. $backendService->registerBackendProvider($this);
  46. $backendService->registerAuthMechanismProvider($this);
  47. // app developers: do NOT depend on this! it will disappear with oC 9.0!
  48. \OC::$server->getEventDispatcher()->dispatch(
  49. 'OCA\\Files_External::loadAdditionalBackends'
  50. );
  51. }
  52. /**
  53. * Register settings templates
  54. */
  55. public function registerSettings() {
  56. $container = $this->getContainer();
  57. $backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
  58. \OCP\App::registerAdmin('files_external', 'settings');
  59. \OCP\App::registerPersonal('files_external', 'personal');
  60. }
  61. /**
  62. * @{inheritdoc}
  63. */
  64. public function getBackends() {
  65. $container = $this->getContainer();
  66. $backends = [
  67. $container->query('OCA\Files_External\Lib\Backend\Local'),
  68. $container->query('OCA\Files_External\Lib\Backend\FTP'),
  69. $container->query('OCA\Files_External\Lib\Backend\DAV'),
  70. $container->query('OCA\Files_External\Lib\Backend\OwnCloud'),
  71. $container->query('OCA\Files_External\Lib\Backend\SFTP'),
  72. $container->query('OCA\Files_External\Lib\Backend\AmazonS3'),
  73. $container->query('OCA\Files_External\Lib\Backend\Dropbox'),
  74. $container->query('OCA\Files_External\Lib\Backend\Google'),
  75. $container->query('OCA\Files_External\Lib\Backend\Swift'),
  76. $container->query('OCA\Files_External\Lib\Backend\SFTP_Key'),
  77. ];
  78. if (!\OC_Util::runningOnWindows()) {
  79. $backends[] = $container->query('OCA\Files_External\Lib\Backend\SMB');
  80. $backends[] = $container->query('OCA\Files_External\Lib\Backend\SMB_OC');
  81. }
  82. return $backends;
  83. }
  84. /**
  85. * @{inheritdoc}
  86. */
  87. public function getAuthMechanisms() {
  88. $container = $this->getContainer();
  89. return [
  90. // AuthMechanism::SCHEME_NULL mechanism
  91. $container->query('OCA\Files_External\Lib\Auth\NullMechanism'),
  92. // AuthMechanism::SCHEME_BUILTIN mechanism
  93. $container->query('OCA\Files_External\Lib\Auth\Builtin'),
  94. // AuthMechanism::SCHEME_PASSWORD mechanisms
  95. $container->query('OCA\Files_External\Lib\Auth\Password\Password'),
  96. $container->query('OCA\Files_External\Lib\Auth\Password\SessionCredentials'),
  97. // AuthMechanism::SCHEME_OAUTH1 mechanisms
  98. $container->query('OCA\Files_External\Lib\Auth\OAuth1\OAuth1'),
  99. // AuthMechanism::SCHEME_OAUTH2 mechanisms
  100. $container->query('OCA\Files_External\Lib\Auth\OAuth2\OAuth2'),
  101. // AuthMechanism::SCHEME_PUBLICKEY mechanisms
  102. $container->query('OCA\Files_External\Lib\Auth\PublicKey\RSA'),
  103. // AuthMechanism::SCHEME_OPENSTACK mechanisms
  104. $container->query('OCA\Files_External\Lib\Auth\OpenStack\OpenStack'),
  105. $container->query('OCA\Files_External\Lib\Auth\OpenStack\Rackspace'),
  106. // Specialized mechanisms
  107. $container->query('OCA\Files_External\Lib\Auth\AmazonS3\AccessKey'),
  108. ];
  109. }
  110. }