1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016, Roeland Jago Douma <[email protected]> |
4
|
|
|
* @copyright Copyright (c) 2017, Matias De lellis <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @author Roeland Jago Douma <[email protected]> |
7
|
|
|
* @author Matias De lellis <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @license GNU AGPL version 3 or any later version |
10
|
|
|
* |
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
14
|
|
|
* License, or (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
namespace OCA\FaceRecognition\AppInfo; |
26
|
|
|
|
27
|
|
|
use OCA\FaceRecognition\Watcher; |
28
|
|
|
use OCP\AppFramework\App; |
29
|
|
|
use OCP\AppFramework\IAppContainer; |
30
|
|
|
use OCP\Files\IRootFolder; |
31
|
|
|
use OCP\Files\Node; |
32
|
|
|
|
33
|
|
|
class Application extends App { |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Application constructor. |
37
|
|
|
* |
38
|
|
|
* @param array $urlParams |
39
|
|
|
*/ |
40
|
|
|
public function __construct(array $urlParams = []) { |
41
|
|
|
parent::__construct('facerecognition', $urlParams); |
42
|
|
|
|
43
|
|
|
$this->connectWatcher(); |
44
|
|
|
$this->connectSearch(); |
45
|
|
|
} |
46
|
|
|
|
47
|
4 |
|
private function connectWatcher() { |
48
|
|
|
/** @var IRootFolder $root */ |
49
|
|
|
$root = $this->getContainer()->query(IRootFolder::class); |
50
|
4 |
|
$root->listen('\OC\Files', 'postWrite', function (Node $node) { |
51
|
|
|
/** @var Watcher $watcher */ |
52
|
4 |
|
$watcher = \OC::$server->query(Watcher::class); |
53
|
4 |
|
$watcher->postWrite($node); |
54
|
4 |
|
}); |
55
|
|
|
// We want to react on postDelete and not preDelete as in preDelete we don't know if |
56
|
|
|
// file actually got deleted (locked, other errors...) |
57
|
|
|
$root->listen('\OC\Files', 'postDelete', function (Node $node) { |
58
|
|
|
/** @var Watcher $watcher */ |
59
|
|
|
$watcher = \OC::$server->query(Watcher::class); |
60
|
|
|
$watcher->postDelete($node); |
61
|
|
|
}); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
private function connectSearch() { |
65
|
|
|
$this->getContainer()->getServer()->getSearch()->registerProvider( |
66
|
|
|
'OCA\FaceRecognition\Search\Provider', array('app'=>'facerecognition', 'apps' => array('files'))); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|