Application.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\FederatedFileSharing\AppInfo;
  23. use OC\AppFramework\Utility\SimpleContainer;
  24. use OCA\FederatedFileSharing\AddressHandler;
  25. use OCA\FederatedFileSharing\Controller\RequestHandlerController;
  26. use OCA\FederatedFileSharing\FederatedShareProvider;
  27. use OCA\FederatedFileSharing\Notifications;
  28. use OCP\AppFramework\App;
  29. class Application extends App {
  30. /** @var FederatedShareProvider */
  31. protected $federatedShareProvider;
  32. public function __construct() {
  33. parent::__construct('federatedfilesharing');
  34. $container = $this->getContainer();
  35. $server = $container->getServer();
  36. $container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) {
  37. $addressHandler = new AddressHandler(
  38. $server->getURLGenerator(),
  39. $server->getL10N('federatedfilesharing'),
  40. $server->getCloudIdManager()
  41. );
  42. $notification = new Notifications(
  43. $addressHandler,
  44. $server->getHTTPClientService(),
  45. new \OCA\FederatedFileSharing\DiscoveryManager(
  46. $server->getMemCacheFactory(),
  47. $server->getHTTPClientService()
  48. ),
  49. \OC::$server->getJobList()
  50. );
  51. return new RequestHandlerController(
  52. $c->query('AppName'),
  53. $server->getRequest(),
  54. $this->getFederatedShareProvider(),
  55. $server->getDatabaseConnection(),
  56. $server->getShareManager(),
  57. $notification,
  58. $addressHandler,
  59. $server->getUserManager(),
  60. $server->getCloudIdManager()
  61. );
  62. });
  63. }
  64. /**
  65. * register personal and admin settings page
  66. */
  67. public function registerSettings() {
  68. \OCP\App::registerPersonal('federatedfilesharing', 'settings-personal');
  69. }
  70. /**
  71. * get instance of federated share provider
  72. *
  73. * @return FederatedShareProvider
  74. */
  75. public function getFederatedShareProvider() {
  76. if ($this->federatedShareProvider === null) {
  77. $this->initFederatedShareProvider();
  78. }
  79. return $this->federatedShareProvider;
  80. }
  81. /**
  82. * initialize federated share provider
  83. */
  84. protected function initFederatedShareProvider() {
  85. $addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
  86. \OC::$server->getURLGenerator(),
  87. \OC::$server->getL10N('federatedfilesharing'),
  88. \OC::$server->getCloudIdManager()
  89. );
  90. $discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
  91. \OC::$server->getMemCacheFactory(),
  92. \OC::$server->getHTTPClientService()
  93. );
  94. $notifications = new \OCA\FederatedFileSharing\Notifications(
  95. $addressHandler,
  96. \OC::$server->getHTTPClientService(),
  97. $discoveryManager,
  98. \OC::$server->getJobList()
  99. );
  100. $tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
  101. \OC::$server->getSecureRandom()
  102. );
  103. $this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
  104. \OC::$server->getDatabaseConnection(),
  105. $addressHandler,
  106. $notifications,
  107. $tokenHandler,
  108. \OC::$server->getL10N('federatedfilesharing'),
  109. \OC::$server->getLogger(),
  110. \OC::$server->getLazyRootFolder(),
  111. \OC::$server->getConfig(),
  112. \OC::$server->getUserManager(),
  113. \OC::$server->getCloudIdManager()
  114. );
  115. }
  116. }