1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @copyright 2020 Christoph Wurst <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @author 2020 Christoph Wurst <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @license GNU AGPL version 3 or any later version |
11
|
|
|
* |
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
15
|
|
|
* License, or (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, |
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
* GNU Affero General Public License for more details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace OCA\ContactsInteraction; |
27
|
|
|
|
28
|
|
|
use OCA\ContactsInteraction\AppInfo\Application; |
29
|
|
|
use OCA\ContactsInteraction\Db\RecentContactMapper; |
30
|
|
|
use OCA\DAV\CardDAV\Integration\ExternalAddressBook; |
31
|
|
|
use OCA\DAV\CardDAV\Integration\IAddressBookProvider; |
32
|
|
|
use OCP\IL10N; |
33
|
|
|
|
34
|
|
|
class AddressBookProvider implements IAddressBookProvider { |
35
|
|
|
|
36
|
|
|
/** @var RecentContactMapper */ |
37
|
|
|
private $mapper; |
38
|
|
|
|
39
|
|
|
/** @var IL10N */ |
40
|
|
|
private $l10n; |
41
|
|
|
|
42
|
|
|
public function __construct(RecentContactMapper $mapper, IL10N $l10n) { |
43
|
|
|
$this->mapper = $mapper; |
44
|
|
|
$this->l10n = $l10n; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @inheritDoc |
49
|
|
|
*/ |
50
|
|
|
public function getAppId(): string { |
51
|
|
|
return Application::APP_ID; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @inheritDoc |
56
|
|
|
*/ |
57
|
|
|
public function fetchAllForAddressBookHome(string $principalUri): array { |
58
|
|
|
return [ |
59
|
|
|
new AddressBook($this->mapper, $this->l10n, $principalUri) |
60
|
|
|
]; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @inheritDoc |
65
|
|
|
*/ |
66
|
|
|
public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool { |
67
|
|
|
return $uri === AddressBook::URI; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @inheritDoc |
72
|
|
|
*/ |
73
|
|
|
public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook { |
74
|
|
|
if ($uri === AddressBook::URI) { |
75
|
|
|
return new AddressBook($this->mapper, $this->l10n, $principalUri); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return null; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|