Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activities for calendars, events and todos #1733

Merged
merged 13 commits into from
Nov 3, 2016
4 changes: 2 additions & 2 deletions apps/dav/appinfo/v1/caldav.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
$config = \OC::$server->getConfig();
$userManager = \OC::$server->getUserManager();
$random = \OC::$server->getSecureRandom();
$calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, $config, $random);
$dispatcher = \OC::$server->getEventDispatcher();
$calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, $random, $dispatcher);

$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);

Expand Down
63 changes: 63 additions & 0 deletions apps/dav/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
namespace OCA\DAV\AppInfo;

use OCA\DAV\CalDAV\Activity\Backend;
use OCA\DAV\CalDAV\Activity\Extension;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\Capabilities;
use OCA\DAV\CardDAV\ContactsManager;
Expand Down Expand Up @@ -88,6 +90,67 @@ public function registerHooks() {
);
}
});

$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);
$backend->onCalendarAdd(
$event->getArgument('calendarData')
);
});
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', function(GenericEvent $event) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);
$backend->onCalendarUpdate(
$event->getArgument('calendarData'),
$event->getArgument('shares'),
$event->getArgument('propertyMutations')
);
});
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function(GenericEvent $event) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);
$backend->onCalendarDelete(
$event->getArgument('calendarData'),
$event->getArgument('shares')
);
});
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);
$backend->onCalendarUpdateShares(
$event->getArgument('calendarData'),
$event->getArgument('shares'),
$event->getArgument('add'),
$event->getArgument('remove')
);
});

$listener = function(GenericEvent $event, $eventName) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);

$subject = Extension::SUBJECT_OBJECT_ADD;
if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') {
$subject = Extension::SUBJECT_OBJECT_UPDATE;
} else if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') {
$subject = Extension::SUBJECT_OBJECT_DELETE;
}
$backend->onTouchCalendarObject(
$subject,
$event->getArgument('calendarData'),
$event->getArgument('shares'),
$event->getArgument('objectData')
);
};
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener);

$aM = $this->getContainer()->getServer()->getActivityManager();
$aM->registerExtension(function() {
return $this->getContainer()->query(Extension::class);
});
}

public function getSyncService() {
Expand Down
Loading