|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Nextcloud - passman |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (c) 2016, Sander Brand ([email protected]) |
|
6
|
|
|
* @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected]) |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OCA\Passman\AppInfo; |
|
25
|
|
|
|
|
26
|
|
|
use OC\Files\View; |
|
27
|
|
|
|
|
28
|
|
|
use OCA\Passman\Controller\CredentialController; |
|
29
|
|
|
use OCA\Passman\Controller\PageController; |
|
30
|
|
|
use OCA\Passman\Controller\ShareController; |
|
31
|
|
|
use OCA\Passman\Controller\VaultController; |
|
32
|
|
|
use OCA\Passman\Middleware\ShareMiddleware; |
|
33
|
|
|
use OCA\Passman\Service\ActivityService; |
|
34
|
|
|
use OCA\Passman\Service\CronService; |
|
35
|
|
|
use OCA\Passman\Service\CredentialService; |
|
36
|
|
|
use OCA\Passman\Service\ShareService; |
|
37
|
|
|
use OCA\Passman\Service\FileService; |
|
38
|
|
|
use OCA\Passman\Service\VaultService; |
|
39
|
|
|
use OCA\Passman\Utility\Utils; |
|
40
|
|
|
use OCA\Passman\Service\NotificationService; |
|
41
|
|
|
Use OCA\Passman\Service\SettingsService; |
|
42
|
|
|
use OCP\IConfig; |
|
43
|
|
|
use OCP\IDBConnection; |
|
44
|
|
|
|
|
45
|
|
|
use OCP\AppFramework\App; |
|
46
|
|
|
use OCP\IL10N; |
|
47
|
|
|
use OCP\Util; |
|
48
|
|
|
|
|
49
|
|
|
class Application extends App { |
|
50
|
|
|
public function __construct() { |
|
51
|
|
|
parent::__construct('passman'); |
|
52
|
|
|
$container = $this->getContainer(); |
|
53
|
|
|
// Allow automatic DI for the View, until we migrated to Nodes API |
|
54
|
|
|
$container->registerService(View::class, function () { |
|
55
|
|
|
return new View(''); |
|
56
|
|
|
}, false); |
|
57
|
|
|
$container->registerService('isCLI', function () { |
|
58
|
|
|
return \OC::$CLI; |
|
59
|
|
|
}); |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Middleware |
|
63
|
|
|
*/ |
|
64
|
|
|
$container->registerService('ShareMiddleware', function ($c) { |
|
65
|
|
|
return new ShareMiddleware($c->query('SettingsService')); |
|
66
|
|
|
}); |
|
67
|
|
|
$container->registerMiddleware('ShareMiddleware'); |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Controllers |
|
71
|
|
|
*/ |
|
72
|
|
|
$container->registerService('ShareController', function ($c) { |
|
73
|
|
|
$container = $this->getContainer(); |
|
74
|
|
|
$server = $container->getServer(); |
|
75
|
|
|
return new ShareController( |
|
76
|
|
|
$c->query('AppName'), |
|
77
|
|
|
$c->query('Request'), |
|
78
|
|
|
$server->getUserSession()->getUser(), |
|
79
|
|
|
$server->getGroupManager(), |
|
80
|
|
|
$server->getUserManager(), |
|
81
|
|
|
$c->query('ActivityService'), |
|
82
|
|
|
$c->query('VaultService'), |
|
83
|
|
|
$c->query('ShareService'), |
|
84
|
|
|
$c->query('CredentialService'), |
|
85
|
|
|
$c->query('NotificationService'), |
|
86
|
|
|
$c->query('FileService'), |
|
87
|
|
|
$c->query('SettingsService') |
|
88
|
|
|
); |
|
89
|
|
|
}); |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/** Cron **/ |
|
93
|
|
|
$container->registerService('CronService', function ($c) { |
|
94
|
|
|
return new CronService( |
|
95
|
|
|
$c->query('CredentialService'), |
|
96
|
|
|
$c->query('Logger'), |
|
97
|
|
|
$c->query('Utils'), |
|
98
|
|
|
$c->query('NotificationService'), |
|
99
|
|
|
$c->query('ActivityService'), |
|
100
|
|
|
$c->query('IDBConnection') |
|
101
|
|
|
); |
|
102
|
|
|
}); |
|
103
|
|
|
|
|
104
|
|
|
$container->registerService('Db', function () { |
|
105
|
|
|
return new Db(); |
|
106
|
|
|
}); |
|
107
|
|
|
|
|
108
|
|
|
$container->registerService('Logger', function ($c) { |
|
109
|
|
|
return $c->query('ServerContainer')->getLogger(); |
|
110
|
|
|
}); |
|
111
|
|
|
|
|
112
|
|
|
// Aliases for the controllers so we can use the automatic DI |
|
113
|
|
|
$container->registerAlias('CredentialController', CredentialController::class); |
|
114
|
|
|
$container->registerAlias('PageController', PageController::class); |
|
115
|
|
|
$container->registerAlias('VaultController', VaultController::class); |
|
116
|
|
|
$container->registerAlias('VaultController', VaultController::class); |
|
117
|
|
|
$container->registerAlias('CredentialService', CredentialService::class); |
|
118
|
|
|
$container->registerAlias('NotificationService', NotificationService::class); |
|
119
|
|
|
$container->registerAlias('ActivityService', ActivityService::class); |
|
120
|
|
|
$container->registerAlias('VaultService', VaultService::class); |
|
121
|
|
|
$container->registerAlias('FileService', FileService::class); |
|
122
|
|
|
$container->registerAlias('ShareService', ShareService::class); |
|
123
|
|
|
$container->registerAlias('Utils', Utils::class); |
|
124
|
|
|
$container->registerAlias('IDBConnection', IDBConnection::class); |
|
125
|
|
|
$container->registerAlias('IConfig', IConfig::class); |
|
126
|
|
|
$container->registerAlias('SettingsService', SettingsService::class); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Register the navigation entry |
|
131
|
|
|
*/ |
|
132
|
|
|
public function registerNavigationEntry() { |
|
133
|
|
|
$c = $this->getContainer(); |
|
134
|
|
|
/** @var \OCP\IServerContainer $server */ |
|
135
|
|
|
$server = $c->getServer(); |
|
136
|
|
|
$navigationEntry = function () use ($c, $server) { |
|
137
|
|
|
return [ |
|
138
|
|
|
'id' => $c->getAppName(), |
|
139
|
|
|
'order' => 10, |
|
140
|
|
|
'name' => $c->query(IL10N::class)->t('Passwords'), |
|
141
|
|
|
'href' => $server->getURLGenerator()->linkToRoute('passman.page.index'), |
|
142
|
|
|
'icon' => $server->getURLGenerator()->imagePath($c->getAppName(), 'app.svg'), |
|
143
|
|
|
]; |
|
144
|
|
|
}; |
|
145
|
|
|
$server->getNavigationManager()->add($navigationEntry); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Register personal settings for notifications and emails |
|
150
|
|
|
*/ |
|
151
|
|
|
public function registerPersonalPage() { |
|
152
|
|
|
\OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal'); |
|
153
|
|
|
} |
|
154
|
|
|
} |