aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/AppInfo/Application.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/AppInfo/Application.php')
-rw-r--r--apps/dav/lib/AppInfo/Application.php146
1 files changed, 56 insertions, 90 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index deb28797952..9807b585080 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -3,37 +3,14 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Tobia De Koninck <tobia@ledfan.be>
- *
- * @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,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\DAV\AppInfo;
-use OCA\DAV\CalDAV\Activity\Backend;
use OCA\DAV\CalDAV\AppCalendar\AppCalendarPlugin;
+use OCA\DAV\CalDAV\CachedSubscriptionProvider;
use OCA\DAV\CalDAV\CalendarManager;
use OCA\DAV\CalDAV\CalendarProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProvider\AudioProvider;
@@ -41,10 +18,8 @@ use OCA\DAV\CalDAV\Reminder\NotificationProvider\EmailProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProviderManager;
use OCA\DAV\CalDAV\Reminder\Notifier;
-
use OCA\DAV\Capabilities;
use OCA\DAV\CardDAV\ContactsManager;
-use OCA\DAV\CardDAV\PhotoCache;
use OCA\DAV\CardDAV\SyncService;
use OCA\DAV\Events\AddressBookCreatedEvent;
use OCA\DAV\Events\AddressBookDeletedEvent;
@@ -53,12 +28,6 @@ use OCA\DAV\Events\AddressBookUpdatedEvent;
use OCA\DAV\Events\CalendarCreatedEvent;
use OCA\DAV\Events\CalendarDeletedEvent;
use OCA\DAV\Events\CalendarMovedToTrashEvent;
-use OCA\DAV\Events\CalendarObjectCreatedEvent;
-use OCA\DAV\Events\CalendarObjectDeletedEvent;
-use OCA\DAV\Events\CalendarObjectMovedEvent;
-use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
-use OCA\DAV\Events\CalendarObjectRestoredEvent;
-use OCA\DAV\Events\CalendarObjectUpdatedEvent;
use OCA\DAV\Events\CalendarPublishedEvent;
use OCA\DAV\Events\CalendarRestoredEvent;
use OCA\DAV\Events\CalendarShareUpdatedEvent;
@@ -69,8 +38,8 @@ use OCA\DAV\Events\CardDeletedEvent;
use OCA\DAV\Events\CardUpdatedEvent;
use OCA\DAV\Events\SubscriptionCreatedEvent;
use OCA\DAV\Events\SubscriptionDeletedEvent;
-use OCA\DAV\HookManager;
use OCA\DAV\Listener\ActivityUpdaterListener;
+use OCA\DAV\Listener\AddMissingIndicesListener;
use OCA\DAV\Listener\AddressbookListener;
use OCA\DAV\Listener\BirthdayListener;
use OCA\DAV\Listener\CalendarContactInteractionListener;
@@ -80,37 +49,56 @@ use OCA\DAV\Listener\CalendarPublicationListener;
use OCA\DAV\Listener\CalendarShareUpdateListener;
use OCA\DAV\Listener\CardListener;
use OCA\DAV\Listener\ClearPhotoCacheListener;
+use OCA\DAV\Listener\DavAdminSettingsListener;
use OCA\DAV\Listener\OutOfOfficeListener;
use OCA\DAV\Listener\SubscriptionListener;
use OCA\DAV\Listener\TrustedServerRemovedListener;
+use OCA\DAV\Listener\UserEventsListener;
use OCA\DAV\Listener\UserPreferenceListener;
use OCA\DAV\Search\ContactsSearchProvider;
use OCA\DAV\Search\EventsSearchProvider;
use OCA\DAV\Search\TasksSearchProvider;
+use OCA\DAV\Settings\Admin\SystemAddressBookSettings;
use OCA\DAV\SetupChecks\NeedsSystemAddressBookSync;
use OCA\DAV\SetupChecks\WebdavEndpoint;
use OCA\DAV\UserMigration\CalendarMigrator;
use OCA\DAV\UserMigration\ContactsMigrator;
use OCP\Accounts\UserUpdatedEvent;
+use OCP\App\IAppManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
+use OCP\Calendar\Events\CalendarObjectCreatedEvent;
+use OCP\Calendar\Events\CalendarObjectDeletedEvent;
+use OCP\Calendar\Events\CalendarObjectMovedEvent;
+use OCP\Calendar\Events\CalendarObjectMovedToTrashEvent;
+use OCP\Calendar\Events\CalendarObjectRestoredEvent;
+use OCP\Calendar\Events\CalendarObjectUpdatedEvent;
use OCP\Calendar\IManager as ICalendarManager;
use OCP\Config\BeforePreferenceDeletedEvent;
use OCP\Config\BeforePreferenceSetEvent;
use OCP\Contacts\IManager as IContactsManager;
-use OCP\EventDispatcher\IEventDispatcher;
+use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\Federation\Events\TrustedServerRemovedEvent;
-use OCP\Files\AppData\IAppDataFactory;
-use OCP\IUser;
+use OCP\IUserSession;
+use OCP\Server;
+use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
+use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
+use OCP\User\Events\BeforeUserDeletedEvent;
+use OCP\User\Events\BeforeUserIdUnassignedEvent;
use OCP\User\Events\OutOfOfficeChangedEvent;
use OCP\User\Events\OutOfOfficeClearedEvent;
use OCP\User\Events\OutOfOfficeScheduledEvent;
+use OCP\User\Events\UserChangedEvent;
+use OCP\User\Events\UserCreatedEvent;
+use OCP\User\Events\UserDeletedEvent;
+use OCP\User\Events\UserFirstTimeLoggedInEvent;
+use OCP\User\Events\UserIdAssignedEvent;
+use OCP\User\Events\UserIdUnassignedEvent;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
use Throwable;
use function is_null;
@@ -123,12 +111,6 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void {
$context->registerServiceAlias('CardDAVSyncService', SyncService::class);
- $context->registerService(PhotoCache::class, function (ContainerInterface $c) {
- return new PhotoCache(
- $c->get(IAppDataFactory::class)->get('dav-photocache'),
- $c->get(LoggerInterface::class)
- );
- });
$context->registerService(AppCalendarPlugin::class, function (ContainerInterface $c) {
return new AppCalendarPlugin(
$c->get(ICalendarManager::class),
@@ -151,6 +133,8 @@ class Application extends App implements IBootstrap {
/**
* Register event listeners
*/
+ $context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class);
+
$context->registerEventListener(CalendarCreatedEvent::class, ActivityUpdaterListener::class);
$context->registerEventListener(CalendarDeletedEvent::class, ActivityUpdaterListener::class);
$context->registerEventListener(CalendarDeletedEvent::class, CalendarObjectReminderUpdaterListener::class);
@@ -204,63 +188,46 @@ class Application extends App implements IBootstrap {
$context->registerEventListener(OutOfOfficeClearedEvent::class, OutOfOfficeListener::class);
$context->registerEventListener(OutOfOfficeScheduledEvent::class, OutOfOfficeListener::class);
+ $context->registerEventListener(UserFirstTimeLoggedInEvent::class, UserEventsListener::class);
+ $context->registerEventListener(UserIdAssignedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(BeforeUserIdUnassignedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(UserIdUnassignedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(BeforeUserDeletedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(UserDeletedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(UserCreatedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(UserChangedEvent::class, UserEventsListener::class);
+ $context->registerEventListener(UserUpdatedEvent::class, UserEventsListener::class);
+
$context->registerNotifierService(Notifier::class);
$context->registerCalendarProvider(CalendarProvider::class);
+ $context->registerCalendarProvider(CachedSubscriptionProvider::class);
$context->registerUserMigrator(CalendarMigrator::class);
$context->registerUserMigrator(ContactsMigrator::class);
$context->registerSetupCheck(NeedsSystemAddressBookSync::class);
$context->registerSetupCheck(WebdavEndpoint::class);
- }
- public function boot(IBootContext $context): void {
- // Load all dav apps
- \OC_App::loadApps(['dav']);
+ // register admin settings form and listener(s)
+ $context->registerDeclarativeSettings(SystemAddressBookSettings::class);
+ $context->registerEventListener(DeclarativeSettingsGetValueEvent::class, DavAdminSettingsListener::class);
+ $context->registerEventListener(DeclarativeSettingsSetValueEvent::class, DavAdminSettingsListener::class);
- $context->injectFn([$this, 'registerHooks']);
- $context->injectFn([$this, 'registerContactsManager']);
- $context->injectFn([$this, 'registerCalendarManager']);
- $context->injectFn([$this, 'registerCalendarReminders']);
}
- public function registerHooks(HookManager $hm,
- IEventDispatcher $dispatcher,
- IAppContainer $container) {
- $hm->setup();
-
- // first time login event setup
- $dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
- if ($event instanceof GenericEvent) {
- $hm->firstLogin($event->getSubject());
- }
- });
-
- $dispatcher->addListener(UserUpdatedEvent::class, function (UserUpdatedEvent $event) use ($container) {
- /** @var SyncService $syncService */
- $syncService = \OCP\Server::get(SyncService::class);
- $syncService->updateUser($event->getUser());
- });
-
-
- $dispatcher->addListener(CalendarShareUpdatedEvent::class, function (CalendarShareUpdatedEvent $event) use ($container) {
- /** @var Backend $backend */
- $backend = $container->query(Backend::class);
- $backend->onCalendarUpdateShares(
- $event->getCalendarData(),
- $event->getOldShares(),
- $event->getAdded(),
- $event->getRemoved()
- );
+ public function boot(IBootContext $context): void {
+ // Load all dav apps
+ $context->getServerContainer()->get(IAppManager::class)->loadApps(['dav']);
- // Here we should recalculate if reminders should be sent to new or old sharees
- });
+ $context->injectFn($this->registerContactsManager(...));
+ $context->injectFn($this->registerCalendarManager(...));
+ $context->injectFn($this->registerCalendarReminders(...));
}
public function registerContactsManager(IContactsManager $cm, IAppContainer $container): void {
$cm->register(function () use ($container, $cm): void {
- $user = \OC::$server->getUserSession()->getUser();
+ $user = Server::get(IUserSession::class)->getUser();
if (!is_null($user)) {
$this->setupContactsProvider($cm, $container, $user->getUID());
} else {
@@ -278,18 +245,17 @@ class Application extends App implements IBootstrap {
$cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
}
- private function setupSystemContactsProvider(IContactsManager $contactsManager,
- IAppContainer $container): void {
+ private function setupSystemContactsProvider(IContactsManager $contactsManager, IAppContainer $container): void {
/** @var ContactsManager $cm */
$cm = $container->query(ContactsManager::class);
$urlGenerator = $container->getServer()->getURLGenerator();
- $cm->setupSystemContactsProvider($contactsManager, $urlGenerator);
+ $cm->setupSystemContactsProvider($contactsManager, null, $urlGenerator);
}
public function registerCalendarManager(ICalendarManager $calendarManager,
IAppContainer $container): void {
- $calendarManager->register(function () use ($container, $calendarManager) {
- $user = \OC::$server->getUserSession()->getUser();
+ $calendarManager->register(function () use ($container, $calendarManager): void {
+ $user = Server::get(IUserSession::class)->getUser();
if ($user !== null) {
$this->setupCalendarProvider($calendarManager, $container, $user->getUID());
}