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), $c->get(LoggerInterface::class) ); }); /* * Register capabilities */ $context->registerCapability(Capabilities::class); /* * Register Search Providers */ $context->registerSearchProvider(ContactsSearchProvider::class); $context->registerSearchProvider(EventsSearchProvider::class); $context->registerSearchProvider(TasksSearchProvider::class); /** * 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); $context->registerEventListener(CalendarDeletedEvent::class, CalendarDeletionDefaultUpdaterListener::class); $context->registerEventListener(CalendarMovedToTrashEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarMovedToTrashEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarUpdatedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarRestoredEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarRestoredEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectCreatedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarContactInteractionListener::class); $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarContactInteractionListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectDeletedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectDeletedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectMovedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectMovedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectMovedToTrashEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectMovedToTrashEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectRestoredEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectRestoredEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarShareUpdatedEvent::class, CalendarContactInteractionListener::class); $context->registerEventListener(CalendarPublishedEvent::class, CalendarPublicationListener::class); $context->registerEventListener(CalendarUnpublishedEvent::class, CalendarPublicationListener::class); $context->registerEventListener(CalendarShareUpdatedEvent::class, CalendarShareUpdateListener::class); $context->registerEventListener(SubscriptionCreatedEvent::class, SubscriptionListener::class); $context->registerEventListener(SubscriptionDeletedEvent::class, SubscriptionListener::class); $context->registerEventListener(AddressBookCreatedEvent::class, AddressbookListener::class); $context->registerEventListener(AddressBookDeletedEvent::class, AddressbookListener::class); $context->registerEventListener(AddressBookUpdatedEvent::class, AddressbookListener::class); $context->registerEventListener(AddressBookShareUpdatedEvent::class, AddressbookListener::class); $context->registerEventListener(CardCreatedEvent::class, CardListener::class); $context->registerEventListener(CardDeletedEvent::class, CardListener::class); $context->registerEventListener(CardUpdatedEvent::class, CardListener::class); $context->registerEventListener(CardCreatedEvent::class, BirthdayListener::class); $context->registerEventListener(CardDeletedEvent::class, BirthdayListener::class); $context->registerEventListener(CardUpdatedEvent::class, BirthdayListener::class); $context->registerEventListener(CardDeletedEvent::class, ClearPhotoCacheListener::class); $context->registerEventListener(CardUpdatedEvent::class, ClearPhotoCacheListener::class); $context->registerEventListener(TrustedServerRemovedEvent::class, TrustedServerRemovedListener::class); $context->registerEventListener(BeforePreferenceDeletedEvent::class, UserPreferenceListener::class); $context->registerEventListener(BeforePreferenceSetEvent::class, UserPreferenceListener::class); $context->registerEventListener(OutOfOfficeChangedEvent::class, OutOfOfficeListener::class); $context->registerEventListener(OutOfOfficeClearedEvent::class, OutOfOfficeListener::class); $context->registerEventListener(OutOfOfficeScheduledEvent::class, OutOfOfficeListener::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']); $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): void { if ($event instanceof GenericEvent) { $hm->firstLogin($event->getSubject()); } }); $dispatcher->addListener(UserUpdatedEvent::class, function (UserUpdatedEvent $event) use ($container): void { /** @var SyncService $syncService */ $syncService = Server::get(SyncService::class); $syncService->updateUser($event->getUser()); }); $dispatcher->addListener(CalendarShareUpdatedEvent::class, function (CalendarShareUpdatedEvent $event) use ($container): void { /** @var Backend $backend */ $backend = $container->query(Backend::class); $backend->onCalendarUpdateShares( $event->getCalendarData(), $event->getOldShares(), $event->getAdded(), $event->getRemoved() ); // Here we should recalculate if reminders should be sent to new or old sharees }); } public function registerContactsManager(IContactsManager $cm, IAppContainer $container): void { $cm->register(function () use ($container, $cm): void { $user = \OC::$server->getUserSession()->getUser(); if (!is_null($user)) { $this->setupContactsProvider($cm, $container, $user->getUID()); } else { $this->setupSystemContactsProvider($cm, $container); } }); } private function setupContactsProvider(IContactsManager $contactsManager, IAppContainer $container, string $userID): void { /** @var ContactsManager $cm */ $cm = $container->query(ContactsManager::class); $urlGenerator = $container->getServer()->getURLGenerator(); $cm->setupContactsProvider($contactsManager, $userID, $urlGenerator); } private function setupSystemContactsProvider(IContactsManager $contactsManager, IAppContainer $container): void { /** @var ContactsManager $cm */ $cm = $container->query(ContactsManager::class); $urlGenerator = $container->getServer()->getURLGenerator(); $cm->setupSystemContactsProvider($contactsManager, $urlGenerator); } public function registerCalendarManager(ICalendarManager $calendarManager, IAppContainer $container): void { $calendarManager->register(function () use ($container, $calendarManager): void { $user = \OC::$server->getUserSession()->getUser(); if ($user !== null) { $this->setupCalendarProvider($calendarManager, $container, $user->getUID()); } }); } private function setupCalendarProvider(ICalendarManager $calendarManager, IAppContainer $container, $userId) { $cm = $container->query(CalendarManager::class); $cm->setupCalendarProvider($calendarManager, $userId); } public function registerCalendarReminders(NotificationProviderManager $manager, LoggerInterface $logger): void { try { $manager->registerProvider(AudioProvider::class); $manager->registerProvider(EmailProvider::class); $manager->registerProvider(PushProvider::class); } catch (Throwable $ex) { $logger->error($ex->getMessage(), ['exception' => $ex]); } } }