$userManager = \OC::$server->getUserManager();
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->getLogger();
-$dispatcher = \OC::$server->getEventDispatcher();
-$calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, \OC::$server->getGroupManager(), $random, $logger, $dispatcher, true);
+$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
+$legacyDispatcher = \OC::$server->getEventDispatcher();
+
+$calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, \OC::$server->getGroupManager(), $random, $logger, $dispatcher, $legacyDispatcher, true);
$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
$sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes';
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
-$cardDavBackend = new CardDavBackend($db, $principalBackend, \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getEventDispatcher());
+$cardDavBackend = new CardDavBackend($db, $principalBackend, \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->getEventDispatcher());
$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
'OCA\\DAV\\Direct\\DirectHome' => $baseDir . '/../lib/Direct/DirectHome.php',
'OCA\\DAV\\Direct\\Server' => $baseDir . '/../lib/Direct/Server.php',
'OCA\\DAV\\Direct\\ServerFactory' => $baseDir . '/../lib/Direct/ServerFactory.php',
+ 'OCA\\DAV\\Events\\AddressBookCreatedEvent' => $baseDir . '/../lib/Events/AddressBookCreatedEvent.php',
+ 'OCA\\DAV\\Events\\AddressBookDeletedEvent' => $baseDir . '/../lib/Events/AddressBookDeletedEvent.php',
+ 'OCA\\DAV\\Events\\AddressBookShareUpdatedEvent' => $baseDir . '/../lib/Events/AddressBookShareUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\AddressBookUpdatedEvent' => $baseDir . '/../lib/Events/AddressBookUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CachedCalendarObjectCreatedEvent' => $baseDir . '/../lib/Events/CachedCalendarObjectCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CachedCalendarObjectDeletedEvent' => $baseDir . '/../lib/Events/CachedCalendarObjectDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CachedCalendarObjectUpdatedEvent' => $baseDir . '/../lib/Events/CachedCalendarObjectUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarCreatedEvent' => $baseDir . '/../lib/Events/CalendarCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarDeletedEvent' => $baseDir . '/../lib/Events/CalendarDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarObjectCreatedEvent' => $baseDir . '/../lib/Events/CalendarObjectCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarObjectDeletedEvent' => $baseDir . '/../lib/Events/CalendarObjectDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarObjectUpdatedEvent' => $baseDir . '/../lib/Events/CalendarObjectUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarPublishedEvent' => $baseDir . '/../lib/Events/CalendarPublishedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarShareUpdatedEvent' => $baseDir . '/../lib/Events/CalendarShareUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarUnpublishedEvent' => $baseDir . '/../lib/Events/CalendarUnpublishedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarUpdatedEvent' => $baseDir . '/../lib/Events/CalendarUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CardCreatedEvent' => $baseDir . '/../lib/Events/CardCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CardDeletedEvent' => $baseDir . '/../lib/Events/CardDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CardUpdatedEvent' => $baseDir . '/../lib/Events/CardUpdatedEvent.php',
'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => $baseDir . '/../lib/Events/SabrePluginAuthInitEvent.php',
+ 'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => $baseDir . '/../lib/Events/SubscriptionCreatedEvent.php',
+ 'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => $baseDir . '/../lib/Events/SubscriptionDeletedEvent.php',
+ 'OCA\\DAV\\Events\\SubscriptionUpdatedEvent' => $baseDir . '/../lib/Events/SubscriptionUpdatedEvent.php',
'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => $baseDir . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir . '/../lib/Files/BrowserErrorPagePlugin.php',
'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir . '/../lib/Files/FileSearchBackend.php',
'OCA\\DAV\\Direct\\DirectHome' => __DIR__ . '/..' . '/../lib/Direct/DirectHome.php',
'OCA\\DAV\\Direct\\Server' => __DIR__ . '/..' . '/../lib/Direct/Server.php',
'OCA\\DAV\\Direct\\ServerFactory' => __DIR__ . '/..' . '/../lib/Direct/ServerFactory.php',
+ 'OCA\\DAV\\Events\\AddressBookCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookCreatedEvent.php',
+ 'OCA\\DAV\\Events\\AddressBookDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookDeletedEvent.php',
+ 'OCA\\DAV\\Events\\AddressBookShareUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookShareUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\AddressBookUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/AddressBookUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CachedCalendarObjectCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CachedCalendarObjectCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CachedCalendarObjectDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CachedCalendarObjectDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CachedCalendarObjectUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CachedCalendarObjectUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarObjectCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarObjectCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarObjectDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarObjectDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarObjectUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarObjectUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarPublishedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarPublishedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarShareUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarShareUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarUnpublishedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarUnpublishedEvent.php',
+ 'OCA\\DAV\\Events\\CalendarUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CalendarUpdatedEvent.php',
+ 'OCA\\DAV\\Events\\CardCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CardCreatedEvent.php',
+ 'OCA\\DAV\\Events\\CardDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CardDeletedEvent.php',
+ 'OCA\\DAV\\Events\\CardUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CardUpdatedEvent.php',
'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => __DIR__ . '/..' . '/../lib/Events/SabrePluginAuthInitEvent.php',
+ 'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionCreatedEvent.php',
+ 'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionDeletedEvent.php',
+ 'OCA\\DAV\\Events\\SubscriptionUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionUpdatedEvent.php',
'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => __DIR__ . '/..' . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__ . '/..' . '/../lib/Files/BrowserErrorPagePlugin.php',
'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__ . '/..' . '/../lib/Files/FileSearchBackend.php',
use OCA\DAV\Connector\Sabre\Principal;
use OCA\DAV\DAV\Sharing\Backend;
use OCA\DAV\DAV\Sharing\IShareable;
+use OCA\DAV\Events\CachedCalendarObjectCreatedEvent;
+use OCA\DAV\Events\CachedCalendarObjectDeletedEvent;
+use OCA\DAV\Events\CachedCalendarObjectUpdatedEvent;
+use OCA\DAV\Events\CalendarCreatedEvent;
+use OCA\DAV\Events\CalendarDeletedEvent;
+use OCA\DAV\Events\CalendarObjectCreatedEvent;
+use OCA\DAV\Events\CalendarObjectDeletedEvent;
+use OCA\DAV\Events\CalendarObjectUpdatedEvent;
+use OCA\DAV\Events\CalendarPublishedEvent;
+use OCA\DAV\Events\CalendarShareUpdatedEvent;
+use OCA\DAV\Events\CalendarUnpublishedEvent;
+use OCA\DAV\Events\CalendarUpdatedEvent;
+use OCA\DAV\Events\SubscriptionCreatedEvent;
+use OCA\DAV\Events\SubscriptionDeletedEvent;
+use OCA\DAV\Events\SubscriptionUpdatedEvent;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\ILogger;
/** @var ILogger */
private $logger;
- /** @var EventDispatcherInterface */
+ /** @var IEventDispatcher */
private $dispatcher;
+ /** @var EventDispatcherInterface */
+ private $legacyDispatcher;
+
/** @var bool */
private $legacyEndpoint;
* @param IGroupManager $groupManager
* @param ISecureRandom $random
* @param ILogger $logger
- * @param EventDispatcherInterface $dispatcher
+ * @param IEventDispatcher $dispatcher
+ * @param EventDispatcherInterface $legacyDispatcher
* @param bool $legacyEndpoint
*/
public function __construct(IDBConnection $db,
IGroupManager $groupManager,
ISecureRandom $random,
ILogger $logger,
- EventDispatcherInterface $dispatcher,
+ IEventDispatcher $dispatcher,
+ EventDispatcherInterface $legacyDispatcher,
bool $legacyEndpoint = false) {
$this->db = $db;
$this->principalBackend = $principalBackend;
$this->random = $random;
$this->logger = $logger;
$this->dispatcher = $dispatcher;
+ $this->legacyDispatcher = $legacyDispatcher;
$this->legacyEndpoint = $legacyEndpoint;
}
$query->execute();
$calendarId = $query->getLastInsertId();
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent(
+ $calendarData = $this->getCalendarById($calendarId);
+ $this->dispatcher->dispatchTyped(new CalendarCreatedEvent((int)$calendarId, $calendarData));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::createCalendar',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
+ 'calendarData' => $calendarData,
]));
return $calendarId;
$this->addChange($calendarId, "", 2);
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent(
+ $calendarData = $this->getCalendarById($calendarId);
+ $shares = $this->getShares($calendarId);
+ $this->dispatcher->dispatchTyped(new CalendarUpdatedEvent((int)$calendarId, $calendarData, $shares, $mutations));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::updateCalendar',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
+ 'calendarData' => $calendarData,
+ 'shares' => $shares,
'propertyMutations' => $mutations,
]));
* @return void
*/
public function deleteCalendar($calendarId) {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', new GenericEvent(
+ $calendarData = $this->getCalendarById($calendarId);
+ $shares = $this->getShares($calendarId);
+
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
+ 'calendarData' => $calendarData,
+ 'shares' => $shares,
]));
$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `calendartype` = ?');
->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)))
->execute();
+
+ if ($calendarData) {
+ $this->dispatcher->dispatchTyped(new CalendarDeletedEvent((int)$calendarId, $calendarData, $shares));
+ }
}
/**
->execute();
$this->updateProperties($calendarId, $objectUri, $calendarData, $calendarType);
+ $this->addChange($calendarId, $objectUri, 1, $calendarType);
+ $objectRow = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent(
+ $calendarRow = $this->getCalendarById($calendarId);
+ $shares = $this->getShares($calendarId);
+
+ $this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
- 'objectData' => $this->getCalendarObject($calendarId, $objectUri),
+ 'calendarData' => $calendarRow,
+ 'shares' => $shares,
+ 'objectData' => $objectRow,
]
));
} else {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject', new GenericEvent(
+ $subscriptionRow = $this->getSubscriptionById($calendarId);
+
+ $this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject',
[
'subscriptionId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
- 'objectData' => $this->getCalendarObject($calendarId, $objectUri),
+ 'calendarData' => $subscriptionRow,
+ 'shares' => [],
+ 'objectData' => $objectRow,
]
));
}
- $this->addChange($calendarId, $objectUri, 1, $calendarType);
return '"' . $extraData['etag'] . '"';
}
->execute();
$this->updateProperties($calendarId, $objectUri, $calendarData, $calendarType);
+ $this->addChange($calendarId, $objectUri, 2, $calendarType);
- $data = $this->getCalendarObject($calendarId, $objectUri);
- if (is_array($data)) {
+ $objectRow = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
+ if (is_array($objectRow)) {
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent(
+ $calendarRow = $this->getCalendarById($calendarId);
+ $shares = $this->getShares($calendarId);
+
+ $this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
- 'objectData' => $data,
+ 'calendarData' => $calendarRow,
+ 'shares' => $shares,
+ 'objectData' => $objectRow,
]
));
} else {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject', new GenericEvent(
+ $subscriptionRow = $this->getSubscriptionById($calendarId);
+
+ $this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject',
[
'subscriptionId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
- 'objectData' => $data,
+ 'calendarData' => $subscriptionRow,
+ 'shares' => [],
+ 'objectData' => $objectRow,
]
));
}
}
- $this->addChange($calendarId, $objectUri, 2, $calendarType);
return '"' . $extraData['etag'] . '"';
}
$data = $this->getCalendarObject($calendarId, $objectUri, $calendarType);
if (is_array($data)) {
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent(
+ $calendarRow = $this->getCalendarById($calendarId);
+ $shares = $this->getShares($calendarId);
+
+ $this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int)$calendarId, $calendarRow, $shares, $data));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
+ 'calendarData' => $calendarRow,
+ 'shares' => $shares,
'objectData' => $data,
]
));
} else {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject', new GenericEvent(
+ $subscriptionRow = $this->getSubscriptionById($calendarId);
+
+ $this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent((int)$calendarId, $subscriptionRow, [], $data));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject',
[
'subscriptionId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
+ 'calendarData' => $subscriptionRow,
+ 'shares' => [],
'objectData' => $data,
]
));
$subscriptionId = $this->db->lastInsertId('*PREFIX*calendarsubscriptions');
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createSubscription', new GenericEvent(
+ $subscriptionRow = $this->getSubscriptionById($subscriptionId);
+ $this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent((int)$subscriptionId, $subscriptionRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createSubscription', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::createSubscription',
[
'subscriptionId' => $subscriptionId,
- 'subscriptionData' => $this->getSubscriptionById($subscriptionId),
+ 'subscriptionData' => $subscriptionRow,
]));
return $subscriptionId;
$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
->execute();
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateSubscription', new GenericEvent(
+ $subscriptionRow = $this->getSubscriptionById($subscriptionId);
+ $this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateSubscription', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::updateSubscription',
[
'subscriptionId' => $subscriptionId,
- 'subscriptionData' => $this->getSubscriptionById($subscriptionId),
+ 'subscriptionData' => $subscriptionRow,
'propertyMutations' => $mutations,
]));
* @return void
*/
public function deleteSubscription($subscriptionId) {
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription', new GenericEvent(
+ $subscriptionRow = $this->getSubscriptionById($subscriptionId);
+
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription',
[
'subscriptionId' => $subscriptionId,
->where($query->expr()->eq('calendarid', $query->createNamedParameter($subscriptionId)))
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
->execute();
+
+ if ($subscriptionRow) {
+ $this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent((int)$subscriptionId, $subscriptionRow, []));
+ }
}
/**
*/
public function updateShares($shareable, $add, $remove) {
$calendarId = $shareable->getResourceId();
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateShares', new GenericEvent(
+ $calendarRow = $this->getCalendarById($calendarId);
+ $oldShares = $this->getShares($calendarId);
+
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateShares', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::updateShares',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
- 'shares' => $this->getShares($calendarId),
+ 'calendarData' => $calendarRow,
+ 'shares' => $oldShares,
'add' => $add,
'remove' => $remove,
]));
$this->calendarSharingBackend->updateShares($shareable, $add, $remove);
+
+ $this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent((int)$calendarId, $calendarRow, $oldShares, $add, $remove));
}
/**
*/
public function setPublishStatus($value, $calendar) {
$calendarId = $calendar->getResourceId();
- $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
+ $calendarData = $this->getCalendarById($calendarId);
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
'\OCA\DAV\CalDAV\CalDavBackend::updateShares',
[
'calendarId' => $calendarId,
- 'calendarData' => $this->getCalendarById($calendarId),
+ 'calendarData' => $calendarData,
'public' => $value,
]));
'publicuri' => $query->createNamedParameter($publicUri)
]);
$query->execute();
+
+ $this->dispatcher->dispatchTyped(new CalendarPublishedEvent((int)$calendarId, $calendarData, $publicUri));
return $publicUri;
}
$query->delete('dav_shares')
->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)));
$query->execute();
+
+ $this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent((int)$calendarId, $calendarData));
return null;
}
use OCA\DAV\Connector\Sabre\Principal;
use OCA\DAV\DAV\Sharing\Backend;
use OCA\DAV\DAV\Sharing\IShareable;
+use OCA\DAV\Events\AddressBookCreatedEvent;
+use OCA\DAV\Events\AddressBookDeletedEvent;
+use OCA\DAV\Events\AddressBookShareUpdatedEvent;
+use OCA\DAV\Events\AddressBookUpdatedEvent;
+use OCA\DAV\Events\CardCreatedEvent;
+use OCA\DAV\Events\CardDeletedEvent;
+use OCA\DAV\Events\CardUpdatedEvent;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUser;
/** @var IUserManager */
private $userManager;
- /** @var EventDispatcherInterface */
+ /** @var IEventDispatcher */
private $dispatcher;
+ /** @var EventDispatcherInterface */
+ private $legacyDispatcher;
+
private $etagCache = [];
/**
* @param Principal $principalBackend
* @param IUserManager $userManager
* @param IGroupManager $groupManager
- * @param EventDispatcherInterface $dispatcher
+ * @param IEventDispatcher $dispatcher
+ * @param EventDispatcherInterface $legacyDispatcher
*/
public function __construct(IDBConnection $db,
Principal $principalBackend,
IUserManager $userManager,
IGroupManager $groupManager,
- EventDispatcherInterface $dispatcher) {
+ IEventDispatcher $dispatcher,
+ EventDispatcherInterface $legacyDispatcher) {
$this->db = $db;
$this->principalBackend = $principalBackend;
$this->userManager = $userManager;
$this->dispatcher = $dispatcher;
+ $this->legacyDispatcher = $legacyDispatcher;
$this->sharingBackend = new Backend($this->db, $this->userManager, $groupManager, $principalBackend, 'addressbook');
}
$this->addChange($addressBookId, "", 2);
+ $addressBookRow = $this->getAddressBookById($addressBookId);
+ $shares = $this->getShares($addressBookId);
+ $this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
+
return true;
});
}
->setParameters($values)
->execute();
- return $query->getLastInsertId();
+ $addressBookId = $query->getLastInsertId();
+ $addressBookRow = $this->getAddressBookById($addressBookId);
+ $this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow));
+
+ return $addressBookId;
}
/**
* @return void
*/
public function deleteAddressBook($addressBookId) {
+ $addressBookData = $this->getAddressBookById($addressBookId);
+ $shares = $this->getShares($addressBookId);
+
$query = $this->db->getQueryBuilder();
$query->delete($this->dbCardsTable)
->where($query->expr()->eq('addressbookid', $query->createParameter('addressbookid')))
$query->delete($this->dbCardsPropertiesTable)
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
->execute();
+
+ if ($addressBookData) {
+ $this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares));
+ }
}
/**
$this->addChange($addressBookId, $cardUri, 1);
$this->updateProperties($addressBookId, $cardUri, $cardData);
- $this->dispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
+ $addressBookData = $this->getAddressBookById($addressBookId);
+ $shares = $this->getShares($addressBookId);
+ $objectRow = $this->getCard($addressBookId, $cardUri);
+ $this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
new GenericEvent(null, [
'addressBookId' => $addressBookId,
'cardUri' => $cardUri,
$this->addChange($addressBookId, $cardUri, 2);
$this->updateProperties($addressBookId, $cardUri, $cardData);
- $this->dispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
+ $addressBookData = $this->getAddressBookById($addressBookId);
+ $shares = $this->getShares($addressBookId);
+ $objectRow = $this->getCard($addressBookId, $cardUri);
+ $this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
new GenericEvent(null, [
'addressBookId' => $addressBookId,
'cardUri' => $cardUri,
* @return bool
*/
public function deleteCard($addressBookId, $cardUri) {
+ $addressBookData = $this->getAddressBookById($addressBookId);
+ $shares = $this->getShares($addressBookId);
+ $objectRow = $this->getCard($addressBookId, $cardUri);
+
try {
$cardId = $this->getCardId($addressBookId, $cardUri);
} catch (\InvalidArgumentException $e) {
$this->addChange($addressBookId, $cardUri, 3);
- $this->dispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
- new GenericEvent(null, [
- 'addressBookId' => $addressBookId,
- 'cardUri' => $cardUri]));
-
if ($ret === 1) {
if ($cardId !== null) {
+ $this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
+ $this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
+ new GenericEvent(null, [
+ 'addressBookId' => $addressBookId,
+ 'cardUri' => $cardUri]));
+
$this->purgeProperties($addressBookId, $cardId);
}
return true;
* @param string[] $remove
*/
public function updateShares(IShareable $shareable, $add, $remove) {
+ $addressBookId = $shareable->getResourceId();
+ $addressBookData = $this->getAddressBookById($addressBookId);
+ $oldShares = $this->getShares($addressBookId);
+
$this->sharingBackend->updateShares($shareable, $add, $remove);
+
+ $this->dispatcher->dispatchTyped(new AddressBookShareUpdatedEvent($addressBookId, $addressBookData, $oldShares, $add, $remove));
}
/**
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Connector\Sabre\Principal;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
);
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->getLogger();
- $dispatcher = \OC::$server->getEventDispatcher();
+ $dispatcher = \OC::$server->get(IEventDispatcher::class);
+ $legacyDispatcher = \OC::$server->getEventDispatcher();
$name = $input->getArgument('name');
- $caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher);
+ $caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
$caldav->createCalendar("principals/users/$user", $name, []);
return 0;
}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class AddressBookCreatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class AddressBookCreatedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /**
+ * AddressBookCreatedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId(): int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class AddressBookDeletedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class AddressBookDeletedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /** @var array */
+ private $shares;
+
+ /**
+ * AddressBookDeletedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @param array $shares
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData,
+ array $shares) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ $this->shares = $shares;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId():int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class AddressBookShareUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class AddressBookShareUpdatedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /** @var array */
+ private $oldShares;
+
+ /** @var array */
+ private $added;
+
+ /** @var array */
+ private $removed;
+
+ /**
+ * AddressBookShareUpdatedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @param array $oldShares
+ * @param array $added
+ * @param array $removed
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData,
+ array $oldShares,
+ array $added,
+ array $removed) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ $this->oldShares = $oldShares;
+ $this->added = $added;
+ $this->removed = $removed;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId(): int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getOldShares(): array {
+ return $this->oldShares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAdded(): array {
+ return $this->added;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getRemoved(): array {
+ return $this->removed;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class AddressBookUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class AddressBookUpdatedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $mutations;
+
+ /**
+ * AddressBookUpdatedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @param array $shares
+ * @param array $mutations
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData,
+ array $shares,
+ array $mutations) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ $this->shares = $shares;
+ $this->mutations = $mutations;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId(): int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getMutations(): array {
+ return $this->mutations;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CachedCalendarObjectCreatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CachedCalendarObjectCreatedEvent extends Event {
+
+ /** @var int */
+ private $subscriptionId;
+
+ /** @var array */
+ private $subscriptionData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $objectData;
+
+ /**
+ * CachedCalendarObjectCreatedEvent constructor.
+ *
+ * @param int $subscriptionId
+ * @param array $subscriptionData
+ * @param array $shares
+ * @param array $objectData
+ * @since 20.0.0
+ */
+ public function __construct(int $subscriptionId,
+ array $subscriptionData,
+ array $shares,
+ array $objectData) {
+ parent::__construct();
+ $this->subscriptionId = $subscriptionId;
+ $this->subscriptionData = $subscriptionData;
+ $this->shares = $shares;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getSubscriptionId(): int {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getSubscriptionData(): array {
+ return $this->subscriptionData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getObjectData(): array {
+ return $this->objectData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CachedCalendarObjectDeletedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CachedCalendarObjectDeletedEvent extends Event {
+
+ /** @var int */
+ private $subscriptionId;
+
+ /** @var array */
+ private $subscriptionData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $objectData;
+
+ /**
+ * CachedCalendarObjectDeletedEvent constructor.
+ *
+ * @param int $subscriptionId
+ * @param array $subscriptionData
+ * @param array $shares
+ * @param array $objectData
+ * @since 20.0.0
+ */
+ public function __construct(int $subscriptionId,
+ array $subscriptionData,
+ array $shares,
+ array $objectData) {
+ parent::__construct();
+ $this->subscriptionId = $subscriptionId;
+ $this->subscriptionData = $subscriptionData;
+ $this->shares = $shares;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getSubscriptionId(): int {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getSubscriptionData(): array {
+ return $this->subscriptionData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getObjectData(): array {
+ return $this->objectData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CachedCalendarObjectUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CachedCalendarObjectUpdatedEvent extends Event {
+
+ /** @var int */
+ private $subscriptionId;
+
+ /** @var array */
+ private $subscriptionData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $objectData;
+
+ /**
+ * CachedCalendarObjectUpdatedEvent constructor.
+ *
+ * @param int $subscriptionId
+ * @param array $subscriptionData
+ * @param array $shares
+ * @param array $objectData
+ * @since 20.0.0
+ */
+ public function __construct(int $subscriptionId,
+ array $subscriptionData,
+ array $shares,
+ array $objectData) {
+ parent::__construct();
+ $this->subscriptionId = $subscriptionId;
+ $this->subscriptionData = $subscriptionData;
+ $this->shares = $shares;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getSubscriptionId(): int {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getSubscriptionData(): array {
+ return $this->subscriptionData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getObjectData(): array {
+ return $this->objectData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarCreatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarCreatedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /**
+ * CalendarCreatedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarDeletedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarDeletedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var array */
+ private $shares;
+
+ /**
+ * CalendarDeletedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param array $shares
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ array $shares) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->shares = $shares;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarObjectCreatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarObjectCreatedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $objectData;
+
+ /**
+ * CalendarObjectCreatedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param array $shares
+ * @param array $objectData
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ array $shares,
+ array $objectData) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->shares = $shares;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getObjectData(): array {
+ return $this->objectData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarObjectDeletedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarObjectDeletedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $objectData;
+
+ /**
+ * CalendarObjectDeletedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param array $shares
+ * @param array $objectData
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ array $shares,
+ array $objectData) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->shares = $shares;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getObjectData(): array {
+ return $this->objectData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarObjectUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarObjectUpdatedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $objectData;
+
+ /**
+ * CalendarObjectUpdatedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param array $shares
+ * @param array $objectData
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ array $shares,
+ array $objectData) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->shares = $shares;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getObjectData(): array {
+ return $this->objectData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarPublishedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarPublishedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var string */
+ private $publicUri;
+
+ /**
+ * CalendarPublishedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param string $publicUri
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ string $publicUri) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->publicUri = $publicUri;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return string
+ * @since 20.0.0
+ */
+ public function getPublicUri(): string {
+ return $this->publicUri;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarShareUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarShareUpdatedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var array */
+ private $oldShares;
+
+ /** @var array */
+ private $added;
+
+ /** @var array */
+ private $removed;
+
+ /**
+ * CalendarShareUpdatedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param array $oldShares
+ * @param array $added
+ * @param array $removed
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ array $oldShares,
+ array $added,
+ array $removed) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->oldShares = $oldShares;
+ $this->added = $added;
+ $this->removed = $removed;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getOldShares(): array {
+ return $this->oldShares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAdded(): array {
+ return $this->added;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getRemoved(): array {
+ return $this->removed;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarPublishedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarUnpublishedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /**
+ * CalendarUnpublishedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CalendarUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CalendarUpdatedEvent extends Event {
+
+ /** @var int */
+ private $calendarId;
+
+ /** @var array */
+ private $calendarData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $mutations;
+
+ /**
+ * CalendarUpdatedEvent constructor.
+ *
+ * @param int $calendarId
+ * @param array $calendarData
+ * @param array $shares
+ * @param array $mutations
+ * @since 20.0.0
+ */
+ public function __construct(int $calendarId,
+ array $calendarData,
+ array $shares,
+ array $mutations) {
+ parent::__construct();
+ $this->calendarId = $calendarId;
+ $this->calendarData = $calendarData;
+ $this->shares = $shares;
+ $this->mutations = $mutations;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getCalendarId(): int {
+ return $this->calendarId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCalendarData(): array {
+ return $this->calendarData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getMutations(): array {
+ return $this->mutations;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CardCreatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CardCreatedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $cardData;
+
+ /**
+ * CardCreatedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @param array $shares
+ * @param array $cardData
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData,
+ array $shares,
+ array $cardData) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ $this->shares = $shares;
+ $this->cardData = $cardData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId(): int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCardData(): array {
+ return $this->cardData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CardDeletedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CardDeletedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $cardData;
+
+ /**
+ * CardDeletedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @param array $shares
+ * @param array $cardData
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData,
+ array $shares,
+ array $cardData) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ $this->shares = $shares;
+ $this->cardData = $cardData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId(): int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCardData(): array {
+ return $this->cardData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class CardUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class CardUpdatedEvent extends Event {
+
+ /** @var int */
+ private $addressBookId;
+
+ /** @var array */
+ private $addressBookData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $cardData;
+
+ /**
+ * CardUpdatedEvent constructor.
+ *
+ * @param int $addressBookId
+ * @param array $addressBookData
+ * @param array $shares
+ * @param array $cardData
+ * @since 20.0.0
+ */
+ public function __construct(int $addressBookId,
+ array $addressBookData,
+ array $shares,
+ array $cardData) {
+ parent::__construct();
+ $this->addressBookId = $addressBookId;
+ $this->addressBookData = $addressBookData;
+ $this->shares = $shares;
+ $this->cardData = $cardData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getAddressBookId(): int {
+ return $this->addressBookId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getAddressBookData(): array {
+ return $this->addressBookData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getCardData(): array {
+ return $this->cardData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class SubscriptionCreatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class SubscriptionCreatedEvent extends Event {
+
+ /** @var int */
+ private $subscriptionId;
+
+ /** @var array */
+ private $subscriptionData;
+
+ /**
+ * SubscriptionCreatedEvent constructor.
+ *
+ * @param int $subscriptionId
+ * @param array $subscriptionData
+ * @since 20.0.0
+ */
+ public function __construct(int $subscriptionId,
+ array $subscriptionData) {
+ parent::__construct();
+ $this->subscriptionId = $subscriptionId;
+ $this->subscriptionData = $subscriptionData;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getSubscriptionId(): int {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getSubscriptionData(): array {
+ return $this->subscriptionData;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class SubscriptionDeletedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class SubscriptionDeletedEvent extends Event {
+
+ /** @var int */
+ private $subscriptionId;
+
+ /** @var array */
+ private $subscriptionData;
+
+ /** @var array */
+ private $shares;
+
+ /**
+ * SubscriptionDeletedEvent constructor.
+ *
+ * @param int $subscriptionId
+ * @param array $subscriptionData
+ * @param array $shares
+ * @since 20.0.0
+ */
+ public function __construct(int $subscriptionId,
+ array $subscriptionData,
+ array $shares) {
+ parent::__construct();
+ $this->subscriptionId = $subscriptionId;
+ $this->subscriptionData = $subscriptionData;
+ $this->shares = $shares;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getSubscriptionId(): int {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getSubscriptionData(): array {
+ return $this->subscriptionData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+}
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020, Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @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/>
+ *
+ */
+namespace OCA\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Class SubscriptionUpdatedEvent
+ *
+ * @package OCA\DAV\Events
+ * @since 20.0.0
+ */
+class SubscriptionUpdatedEvent extends Event {
+
+ /** @var int */
+ private $subscriptionId;
+
+ /** @var array */
+ private $subscriptionData;
+
+ /** @var array */
+ private $shares;
+
+ /** @var array */
+ private $mutations;
+
+ /**
+ * SubscriptionUpdatedEvent constructor.
+ *
+ * @param int $subscriptionId
+ * @param array $subscriptionData
+ * @param array $shares
+ * @param array $mutations
+ * @since 20.0.0
+ */
+ public function __construct(int $subscriptionId,
+ array $subscriptionData,
+ array $shares,
+ array $mutations) {
+ parent::__construct();
+ $this->subscriptionId = $subscriptionId;
+ $this->subscriptionData = $subscriptionData;
+ $this->shares = $shares;
+ $this->mutations = $mutations;
+ }
+
+ /**
+ * @return int
+ * @since 20.0.0
+ */
+ public function getSubscriptionId(): int {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getSubscriptionData(): array {
+ return $this->subscriptionData;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getShares(): array {
+ return $this->shares;
+ }
+
+ /**
+ * @return array
+ * @since 20.0.0
+ */
+ public function getMutations(): array {
+ return $this->mutations;
+ }
+}
use OCA\DAV\Upload\CleanupService;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\EventDispatcher\IEventDispatcher;
use Sabre\DAV\SimpleCollection;
class RootCollection extends SimpleCollection {
$groupManager = \OC::$server->getGroupManager();
$shareManager = \OC::$server->getShareManager();
$db = \OC::$server->getDatabaseConnection();
- $dispatcher = \OC::$server->getEventDispatcher();
+ $dispatcher = \OC::$server->get(IEventDispatcher::class);
+ $legacyDispatcher = \OC::$server->getEventDispatcher();
$proxyMapper = \OC::$server->query(ProxyMapper::class);
$userPrincipalBackend = new Principal(
$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
$filesCollection->disableListing = $disableListing;
- $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
+ $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
$userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
$userCalendarRoot->disableListing = $disableListing;
- $resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
+ $resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
$resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources');
$resourceCalendarRoot->disableListing = $disableListing;
- $roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher);
+ $roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher, $legacyDispatcher);
$roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms');
$roomCalendarRoot->disableListing = $disableListing;
);
$pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
- $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher);
+ $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher, $legacyDispatcher);
$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, $pluginManager, 'principals/users');
$usersAddressBookRoot->disableListing = $disableListing;
- $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher);
+ $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher, $legacyDispatcher);
$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, $pluginManager, 'principals/system');
$systemAddressBookRoot->disableListing = $disableListing;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\App\IAppManager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\ILogger;
protected $groupManager;
/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $dispatcher;
+ /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
+ protected $legacyDispatcher;
/** @var ISecureRandom */
private $random;
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
- $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->principal = $this->getMockBuilder(Principal::class)
->setConstructorArgs([
$this->userManager,
$db = \OC::$server->getDatabaseConnection();
$this->random = \OC::$server->getSecureRandom();
$this->logger = $this->createMock(ILogger::class);
- $this->backend = new CalDavBackend($db, $this->principal, $this->userManager, $this->groupManager, $this->random, $this->logger, $this->dispatcher);
+ $this->backend = new CalDavBackend($db, $this->principal, $this->userManager, $this->groupManager, $this->random, $this->logger, $this->dispatcher, $this->legacyDispatcher);
$this->cleanUpBackend();
}
private function cleanupForPrincipal($principal): void {
$calendars = $this->backend->getCalendarsForUser($principal);
foreach ($calendars as $calendar) {
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar');
}
protected function createTestCalendar() {
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendar');
EOD;
$uri0 = $this->getUniqueID('event');
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
'{DAV:}displayname' => 'Unit test',
'{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar used for unit testing'
]);
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar');
$this->backend->updateCalendar($calendarId, $patch);
$this->assertEquals('User\'s displayname', $calendars[0]['{http://nextcloud.com/ns}owner-displayname']);
// delete the address book
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar');
$this->backend->deleteCalendar($calendars[0]['id']);
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertCount(1, $calendars);
$calendar = new Calendar($this->backend, $calendars[0], $l10n, $config);
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::updateShares');
$this->backend->updateShares($calendar, $add, []);
END:VCALENDAR
EOD;
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
$this->backend->createCalendarObject($calendarId, $uri, $calData);
$this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl);
// delete the address book
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar');
$this->backend->deleteCalendar($calendars[0]['id']);
END:VCALENDAR
EOD;
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
$this->backend->createCalendarObject($calendarId, $uri, $calData);
END:VEVENT
END:VCALENDAR
EOD;
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject');
$this->backend->updateCalendarObject($calendarId, $uri, $calData);
$this->assertEquals($calData, $calendarObject['calendardata']);
// delete the card
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
$this->backend->deleteCalendarObject($calendarId, $uri);
EOD;
$uri0 = static::getUniqueID('card');
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
$this->backend->createCalendarObject($calendarId, $uri0, $calData[0]);
$uri1 = static::getUniqueID('card');
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
$this->backend->createCalendarObject($calendarId, $uri1, $calData[1]);
$uri2 = static::getUniqueID('card');
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject');
$this->backend->createCalendarObject($calendarId, $uri2, $calData[2]);
$this->assertEquals($calData[2], $calendarObjects[1]['calendardata']);
// delete the card
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
$this->backend->deleteCalendarObject($calendarId, $uri0);
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
$this->backend->deleteCalendarObject($calendarId, $uri1);
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject');
$this->backend->deleteCalendarObject($calendarId, $uri2);
}
public function testPublications() {
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendar');
use OCA\DAV\CalDAV\PublicCalendar;
use OCA\DAV\CalDAV\PublicCalendarRoot;
use OCA\DAV\Connector\Sabre\Principal;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
$this->groupManager = $this->createMock(IGroupManager::class);
$this->random = \OC::$server->getSecureRandom();
$this->logger = $this->createMock(ILogger::class);
- $dispatcher = $this->createMock(EventDispatcherInterface::class);
+ $dispatcher = $this->createMock(IEventDispatcher::class);
+ $legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->principal->expects($this->any())->method('getGroupMembership')
->withAnyParameters()
$this->groupManager,
$this->random,
$this->logger,
- $dispatcher
+ $dispatcher,
+ $legacyDispatcher
);
$this->l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()->getMock();
use OCA\DAV\Connector\Sabre\Principal;
use OCP\App\IAppManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
private $groupManager;
/** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
+ private $legacyDispatcher;
+
+ /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $dispatcher;
/** @var IDBConnection */
$this->principal->method('getGroupMembership')
->withAnyParameters()
->willReturn([self::UNIT_TEST_GROUP]);
- $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->db = \OC::$server->getDatabaseConnection();
- $this->backend = new CardDavBackend($this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher);
+ $this->backend = new CardDavBackend($this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher);
// start every test with a empty cards_properties and cards table
$query = $this->db->getQueryBuilder();
$query->delete('cards_properties')->execute();
/** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backend */
$backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['updateProperties', 'purgeProperties'])->getMock();
// create a new address book
$backend->expects($this->at(1))->method('updateProperties')->with($bookId, $uri, $this->vcardTest1);
// Expect event
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CardDAV\CardDavBackend::createCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) {
return $e->getArgument('addressBookId') === $bookId &&
$this->assertEquals($this->vcardTest0, $card['carddata']);
// Expect event
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) {
return $e->getArgument('addressBookId') === $bookId &&
$this->assertEquals($this->vcardTest1, $card['carddata']);
// Expect event
- $this->dispatcher->expects($this->at(0))
+ $this->legacyDispatcher->expects($this->at(0))
->method('dispatch')
->with('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) {
return $e->getArgument('addressBookId') === $bookId &&
public function testMultiCard() {
$this->backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['updateProperties'])->getMock();
// create a new address book
public function testMultipleUIDOnDifferentAddressbooks() {
$this->backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['updateProperties'])->getMock();
// create 2 new address books
public function testMultipleUIDDenied() {
$this->backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['updateProperties'])->getMock();
// create a new address book
public function testNoValidUID() {
$this->backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['updateProperties'])->getMock();
// create a new address book
public function testDeleteWithoutCard() {
$this->backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods([
'getCardId',
'addChange',
public function testSyncSupport() {
$this->backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['updateProperties'])->getMock();
// create a new address book
$cardId = 2;
$backend = $this->getMockBuilder(CardDavBackend::class)
- ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
+ ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher])
->setMethods(['getCardId'])->getMock();
$backend->expects($this->any())->method('getCardId')->willReturn($cardId);