2016-01-11 16:34:17 +03:00
|
|
|
<?php
|
2016-01-12 17:02:16 +03:00
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Georg Ehrke <georg@owncloud.com>
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @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/>
|
|
|
|
*
|
|
|
|
*/
|
2016-05-12 10:42:40 +03:00
|
|
|
namespace OCA\DAV\AppInfo;
|
2016-01-11 16:34:17 +03:00
|
|
|
|
2016-10-13 12:04:22 +03:00
|
|
|
use OCA\DAV\CalDAV\Activity\Extension;
|
2016-02-03 17:43:45 +03:00
|
|
|
use OCA\DAV\CalDAV\BirthdayService;
|
2016-10-21 12:45:17 +03:00
|
|
|
use OCA\DAV\Capabilities;
|
2016-01-11 16:34:17 +03:00
|
|
|
use OCA\DAV\CardDAV\ContactsManager;
|
2016-01-13 22:56:25 +03:00
|
|
|
use OCA\DAV\CardDAV\SyncService;
|
|
|
|
use OCA\DAV\HookManager;
|
2016-01-11 16:34:17 +03:00
|
|
|
use \OCP\AppFramework\App;
|
|
|
|
use OCP\Contacts\IManager;
|
2016-02-03 17:43:45 +03:00
|
|
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
2016-01-11 16:34:17 +03:00
|
|
|
|
|
|
|
class Application extends App {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Application constructor.
|
|
|
|
*/
|
2016-09-20 02:15:24 +03:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct('dav');
|
2016-10-21 12:45:17 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register capabilities
|
|
|
|
*/
|
|
|
|
$this->getContainer()->registerCapability(Capabilities::class);
|
2016-01-11 16:34:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IManager $contactsManager
|
|
|
|
* @param string $userID
|
|
|
|
*/
|
|
|
|
public function setupContactsProvider(IManager $contactsManager, $userID) {
|
|
|
|
/** @var ContactsManager $cm */
|
2016-09-20 02:15:24 +03:00
|
|
|
$cm = $this->getContainer()->query(ContactsManager::class);
|
2016-06-21 16:25:44 +03:00
|
|
|
$urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
|
|
|
|
$cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
|
2016-01-11 16:34:17 +03:00
|
|
|
}
|
|
|
|
|
2016-01-13 22:56:25 +03:00
|
|
|
public function registerHooks() {
|
|
|
|
/** @var HookManager $hm */
|
2016-09-20 02:15:24 +03:00
|
|
|
$hm = $this->getContainer()->query(HookManager::class);
|
2016-01-13 22:56:25 +03:00
|
|
|
$hm->setup();
|
2016-02-03 17:43:45 +03:00
|
|
|
|
|
|
|
$listener = function($event) {
|
|
|
|
if ($event instanceof GenericEvent) {
|
2016-03-23 14:28:54 +03:00
|
|
|
/** @var BirthdayService $b */
|
2016-09-20 02:15:24 +03:00
|
|
|
$b = $this->getContainer()->query(BirthdayService::class);
|
2016-02-03 17:43:45 +03:00
|
|
|
$b->onCardChanged(
|
|
|
|
$event->getArgument('addressBookId'),
|
|
|
|
$event->getArgument('cardUri'),
|
|
|
|
$event->getArgument('cardData')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
|
|
|
|
$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $listener);
|
|
|
|
$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $listener);
|
|
|
|
$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function($event) {
|
|
|
|
if ($event instanceof GenericEvent) {
|
2016-03-23 14:28:54 +03:00
|
|
|
/** @var BirthdayService $b */
|
2016-09-20 02:15:24 +03:00
|
|
|
$b = $this->getContainer()->query(BirthdayService::class);
|
2016-02-03 17:43:45 +03:00
|
|
|
$b->onCardDeleted(
|
|
|
|
$event->getArgument('addressBookId'),
|
|
|
|
$event->getArgument('cardUri')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2016-09-26 14:50:39 +03:00
|
|
|
|
|
|
|
$aM = $this->getContainer()->getServer()->getActivityManager();
|
|
|
|
$aM->registerExtension(function() {
|
2016-10-13 12:04:22 +03:00
|
|
|
return $this->getContainer()->query(Extension::class);
|
2016-09-26 14:50:39 +03:00
|
|
|
});
|
2016-01-13 22:56:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSyncService() {
|
2016-09-20 02:15:24 +03:00
|
|
|
return $this->getContainer()->query(SyncService::class);
|
2016-01-13 22:56:25 +03:00
|
|
|
}
|
|
|
|
|
2016-01-11 16:34:17 +03:00
|
|
|
}
|