2016-04-18 19:17:08 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-04-18 19:17:08 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-04-18 19:17:08 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\FederatedFileSharing\AppInfo;
|
|
|
|
|
|
|
|
|
2016-08-19 13:01:13 +03:00
|
|
|
use OC\AppFramework\Utility\SimpleContainer;
|
|
|
|
use OCA\FederatedFileSharing\AddressHandler;
|
|
|
|
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
|
2016-04-18 19:17:08 +03:00
|
|
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
2016-08-19 13:01:13 +03:00
|
|
|
use OCA\FederatedFileSharing\Notifications;
|
2019-12-05 16:15:32 +03:00
|
|
|
use OCA\FederatedFileSharing\Notifier;
|
2018-04-30 12:49:24 +03:00
|
|
|
use OCA\FederatedFileSharing\OCM\CloudFederationProviderFiles;
|
2016-04-18 19:17:08 +03:00
|
|
|
use OCP\AppFramework\App;
|
2017-05-24 10:07:58 +03:00
|
|
|
use OCP\GlobalScale\IConfig;
|
2016-04-18 19:17:08 +03:00
|
|
|
|
|
|
|
class Application extends App {
|
|
|
|
|
|
|
|
/** @var FederatedShareProvider */
|
|
|
|
protected $federatedShareProvider;
|
|
|
|
|
2016-05-23 12:48:14 +03:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct('federatedfilesharing');
|
2016-08-19 13:01:13 +03:00
|
|
|
|
|
|
|
$container = $this->getContainer();
|
|
|
|
$server = $container->getServer();
|
|
|
|
|
2018-04-18 17:05:11 +03:00
|
|
|
$cloudFederationManager = $server->getCloudFederationProviderManager();
|
|
|
|
$cloudFederationManager->addCloudFederationProvider('file',
|
|
|
|
'Federated Files Sharing',
|
|
|
|
function() use ($container) {
|
2018-04-30 12:49:24 +03:00
|
|
|
$server = $container->getServer();
|
|
|
|
return new CloudFederationProviderFiles(
|
|
|
|
$server->getAppManager(),
|
|
|
|
$server->query(FederatedShareProvider::class),
|
|
|
|
$server->query(AddressHandler::class),
|
|
|
|
$server->getLogger(),
|
|
|
|
$server->getUserManager(),
|
|
|
|
$server->getCloudIdManager(),
|
|
|
|
$server->getActivityManager(),
|
|
|
|
$server->getNotificationManager(),
|
2018-05-30 18:44:08 +03:00
|
|
|
$server->getURLGenerator(),
|
|
|
|
$server->getCloudFederationFactory(),
|
2018-06-04 17:36:37 +03:00
|
|
|
$server->getCloudFederationProviderManager(),
|
2018-06-13 15:19:59 +03:00
|
|
|
$server->getDatabaseConnection(),
|
|
|
|
$server->getGroupManager()
|
2018-04-30 12:49:24 +03:00
|
|
|
);
|
2018-04-18 17:05:11 +03:00
|
|
|
});
|
|
|
|
|
2016-08-19 13:01:13 +03:00
|
|
|
$container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) {
|
|
|
|
$addressHandler = new AddressHandler(
|
|
|
|
$server->getURLGenerator(),
|
2017-01-27 14:52:17 +03:00
|
|
|
$server->getL10N('federatedfilesharing'),
|
|
|
|
$server->getCloudIdManager()
|
2016-08-19 13:01:13 +03:00
|
|
|
);
|
|
|
|
$notification = new Notifications(
|
|
|
|
$addressHandler,
|
|
|
|
$server->getHTTPClientService(),
|
2017-04-05 23:35:59 +03:00
|
|
|
$server->query(\OCP\OCS\IDiscoveryService::class),
|
2018-05-04 16:25:02 +03:00
|
|
|
\OC::$server->getJobList(),
|
|
|
|
\OC::$server->getCloudFederationProviderManager(),
|
|
|
|
\OC::$server->getCloudFederationFactory()
|
2016-08-19 13:01:13 +03:00
|
|
|
);
|
|
|
|
return new RequestHandlerController(
|
|
|
|
$c->query('AppName'),
|
|
|
|
$server->getRequest(),
|
|
|
|
$this->getFederatedShareProvider(),
|
|
|
|
$server->getDatabaseConnection(),
|
|
|
|
$server->getShareManager(),
|
|
|
|
$notification,
|
|
|
|
$addressHandler,
|
2017-01-27 14:52:17 +03:00
|
|
|
$server->getUserManager(),
|
2018-04-23 11:44:49 +03:00
|
|
|
$server->getCloudIdManager(),
|
2018-04-30 12:49:24 +03:00
|
|
|
$server->getLogger(),
|
|
|
|
$server->getCloudFederationFactory(),
|
|
|
|
$server->getCloudFederationProviderManager()
|
2016-08-19 13:01:13 +03:00
|
|
|
);
|
|
|
|
});
|
2019-12-05 16:15:32 +03:00
|
|
|
|
|
|
|
// register events listeners
|
|
|
|
$eventDispatcher = $server->getEventDispatcher();
|
|
|
|
$manager = $server->getNotificationManager();
|
|
|
|
$federatedShareProvider = $this->getFederatedShareProvider();
|
|
|
|
|
|
|
|
$manager->registerNotifierService(Notifier::class);
|
|
|
|
|
|
|
|
$eventDispatcher->addListener(
|
|
|
|
'OCA\Files::loadAdditionalScripts',
|
|
|
|
function() use ($federatedShareProvider) {
|
|
|
|
if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) {
|
|
|
|
\OCP\Util::addScript('federatedfilesharing', 'external');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-05-23 12:48:14 +03:00
|
|
|
}
|
|
|
|
|
2016-04-18 19:17:08 +03:00
|
|
|
/**
|
|
|
|
* get instance of federated share provider
|
|
|
|
*
|
|
|
|
* @return FederatedShareProvider
|
|
|
|
*/
|
2019-12-05 16:15:32 +03:00
|
|
|
protected function getFederatedShareProvider() {
|
2016-04-18 19:17:08 +03:00
|
|
|
if ($this->federatedShareProvider === null) {
|
|
|
|
$this->initFederatedShareProvider();
|
|
|
|
}
|
|
|
|
return $this->federatedShareProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize federated share provider
|
|
|
|
*/
|
|
|
|
protected function initFederatedShareProvider() {
|
2017-05-24 10:07:58 +03:00
|
|
|
$c = $this->getContainer();
|
2016-04-18 19:17:08 +03:00
|
|
|
$addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
|
|
|
|
\OC::$server->getURLGenerator(),
|
2017-01-27 14:52:17 +03:00
|
|
|
\OC::$server->getL10N('federatedfilesharing'),
|
|
|
|
\OC::$server->getCloudIdManager()
|
2016-04-18 19:17:08 +03:00
|
|
|
);
|
|
|
|
$notifications = new \OCA\FederatedFileSharing\Notifications(
|
|
|
|
$addressHandler,
|
|
|
|
\OC::$server->getHTTPClientService(),
|
2017-04-05 23:35:59 +03:00
|
|
|
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
|
2018-05-04 16:25:02 +03:00
|
|
|
\OC::$server->getJobList(),
|
|
|
|
\OC::$server->getCloudFederationProviderManager(),
|
|
|
|
\OC::$server->getCloudFederationFactory()
|
2016-04-18 19:17:08 +03:00
|
|
|
);
|
|
|
|
$tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
|
|
|
|
\OC::$server->getSecureRandom()
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
|
|
|
|
\OC::$server->getDatabaseConnection(),
|
|
|
|
$addressHandler,
|
|
|
|
$notifications,
|
|
|
|
$tokenHandler,
|
|
|
|
\OC::$server->getL10N('federatedfilesharing'),
|
|
|
|
\OC::$server->getLogger(),
|
|
|
|
\OC::$server->getLazyRootFolder(),
|
2016-05-11 21:48:27 +03:00
|
|
|
\OC::$server->getConfig(),
|
2017-01-27 14:52:17 +03:00
|
|
|
\OC::$server->getUserManager(),
|
2017-05-24 10:07:58 +03:00
|
|
|
\OC::$server->getCloudIdManager(),
|
2018-06-13 15:19:59 +03:00
|
|
|
$c->query(IConfig::class),
|
|
|
|
\OC::$server->getCloudFederationProviderManager()
|
|
|
|
|
2016-04-18 19:17:08 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|