2020-04-26 11:36:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\BigBlueButton\AppInfo;
|
|
|
|
|
2020-09-23 12:33:09 +02:00
|
|
|
use \OCA\BigBlueButton\Activity\MeetingListener;
|
2020-09-07 22:18:23 +02:00
|
|
|
use \OCA\BigBlueButton\Activity\RoomListener;
|
2020-09-18 17:13:46 +02:00
|
|
|
use \OCA\BigBlueButton\Activity\RoomShareListener;
|
2020-09-22 16:02:18 +02:00
|
|
|
use \OCA\BigBlueButton\Event\MeetingEndedEvent;
|
2020-09-23 12:33:09 +02:00
|
|
|
use \OCA\BigBlueButton\Event\MeetingStartedEvent;
|
2020-09-22 16:02:18 +02:00
|
|
|
use \OCA\BigBlueButton\Event\RecordingReadyEvent;
|
2020-09-23 12:33:09 +02:00
|
|
|
use \OCA\BigBlueButton\Event\RoomCreatedEvent;
|
|
|
|
use \OCA\BigBlueButton\Event\RoomDeletedEvent;
|
|
|
|
use \OCA\BigBlueButton\Event\RoomShareCreatedEvent;
|
|
|
|
use \OCA\BigBlueButton\Event\RoomShareDeletedEvent;
|
2020-09-24 11:05:51 +02:00
|
|
|
use \OCA\BigBlueButton\Listener\UserDeletedListener;
|
2020-09-23 12:33:09 +02:00
|
|
|
use \OCA\BigBlueButton\Middleware\HookMiddleware;
|
|
|
|
use \OCA\BigBlueButton\Middleware\JoinMiddleware;
|
|
|
|
use \OCP\AppFramework\App;
|
2021-04-19 13:15:37 +02:00
|
|
|
use \OCP\AppFramework\QueryException;
|
2020-09-23 12:33:09 +02:00
|
|
|
use \OCP\EventDispatcher\IEventDispatcher;
|
|
|
|
use \OCP\IConfig;
|
|
|
|
use \OCP\Settings\IManager as ISettingsManager;
|
2020-09-24 11:05:51 +02:00
|
|
|
use \OCP\User\Events\UserDeletedEvent;
|
2020-06-04 09:52:49 +02:00
|
|
|
|
2020-04-26 11:36:41 +02:00
|
|
|
if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
|
|
|
|
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
|
|
|
|
}
|
2020-06-04 09:52:49 +02:00
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
class Application extends App {
|
2020-09-07 22:18:23 +02:00
|
|
|
public const ID = 'bbb';
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function __construct(array $urlParams = []) {
|
2020-09-07 22:18:23 +02:00
|
|
|
parent::__construct(self::ID, $urlParams);
|
2020-06-04 09:52:49 +02:00
|
|
|
|
|
|
|
$container = $this->getContainer();
|
|
|
|
|
2020-09-24 11:05:51 +02:00
|
|
|
/* @var IEventDispatcher $dispatcher */
|
2020-09-07 22:18:23 +02:00
|
|
|
$dispatcher = $container->query(IEventDispatcher::class);
|
2020-09-24 11:05:51 +02:00
|
|
|
$this->registerServiceListener($dispatcher);
|
2020-09-22 16:02:18 +02:00
|
|
|
|
2020-06-04 09:52:49 +02:00
|
|
|
$container->registerMiddleWare(JoinMiddleware::class);
|
2020-09-22 12:19:48 +02:00
|
|
|
$container->registerMiddleWare(HookMiddleware::class);
|
2020-08-26 10:57:31 +02:00
|
|
|
|
|
|
|
$config = $container->query(IConfig::class);
|
|
|
|
|
2020-09-07 22:18:23 +02:00
|
|
|
if ($config->getAppValue(self::ID, 'app.navigation') === 'true') {
|
2021-07-26 16:13:02 +02:00
|
|
|
$name = $config->getAppValue(self::ID, 'app.navigation.name', 'BBB');
|
2021-02-24 14:36:37 +01:00
|
|
|
|
|
|
|
$this->registerAsNavigationEntry($name);
|
2020-08-26 10:57:31 +02:00
|
|
|
} else {
|
|
|
|
$this->registerAsPersonalSetting();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-24 15:23:26 +01:00
|
|
|
private function registerAsPersonalSetting(): void {
|
2021-04-19 13:15:37 +02:00
|
|
|
try {
|
|
|
|
/** @var ISettingsManager */
|
|
|
|
$settingsManager = $this->getContainer()->query(ISettingsManager::class);
|
|
|
|
} catch (QueryException $exception) {
|
|
|
|
// Workaround for Nextcloud 19
|
|
|
|
$server = $this->getContainer()->getServer();
|
|
|
|
|
|
|
|
if (method_exists($server, 'getSettingsManager')) {
|
|
|
|
$settingsManager = $server->getSettingsManager();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-26 10:57:31 +02:00
|
|
|
|
2020-09-02 10:07:20 +02:00
|
|
|
$settingsManager->registerSetting(ISettingsManager::KEY_PERSONAL_SETTINGS, \OCA\BigBlueButton\Settings\Personal::class);
|
2020-08-26 10:57:31 +02:00
|
|
|
}
|
|
|
|
|
2021-02-24 15:23:26 +01:00
|
|
|
private function registerAsNavigationEntry(string $name): void {
|
2020-08-26 10:57:31 +02:00
|
|
|
$server = $this->getContainer()->getServer();
|
|
|
|
|
2021-02-24 14:36:37 +01:00
|
|
|
$server->getNavigationManager()->add(function () use ($server, $name) {
|
2020-08-26 10:57:31 +02:00
|
|
|
return [
|
2020-09-07 22:18:23 +02:00
|
|
|
'id' => self::ID,
|
2020-08-26 10:57:31 +02:00
|
|
|
'order' => 80,
|
|
|
|
'href' => $server->getURLGenerator()->linkToRoute('bbb.page.index'),
|
|
|
|
'icon' => $server->getURLGenerator()->imagePath('bbb', 'app.svg'),
|
2021-02-24 14:36:37 +01:00
|
|
|
'name' => $name,
|
2020-08-26 10:57:31 +02:00
|
|
|
];
|
|
|
|
});
|
2020-06-04 09:52:49 +02:00
|
|
|
}
|
2020-09-24 11:05:51 +02:00
|
|
|
|
2021-02-24 15:23:26 +01:00
|
|
|
private function registerServiceListener(IEventDispatcher $dispatcher): void {
|
2020-09-24 11:05:51 +02:00
|
|
|
$dispatcher->addServiceListener(RoomCreatedEvent::class, RoomListener::class);
|
|
|
|
$dispatcher->addServiceListener(RoomDeletedEvent::class, RoomListener::class);
|
|
|
|
|
|
|
|
$dispatcher->addServiceListener(RoomShareCreatedEvent::class, RoomShareListener::class);
|
|
|
|
$dispatcher->addServiceListener(RoomShareDeletedEvent::class, RoomShareListener::class);
|
|
|
|
|
|
|
|
$dispatcher->addServiceListener(MeetingStartedEvent::class, MeetingListener::class);
|
|
|
|
$dispatcher->addServiceListener(MeetingEndedEvent::class, MeetingListener::class);
|
|
|
|
$dispatcher->addServiceListener(RecordingReadyEvent::class, MeetingListener::class);
|
|
|
|
|
|
|
|
$dispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
|
|
|
|
}
|
2020-06-04 09:52:49 +02:00
|
|
|
}
|