|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Music app |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Morris Jobke <[email protected]> |
|
10
|
|
|
* @author Pauli Järvinen <[email protected]> |
|
11
|
|
|
* @copyright Morris Jobke 2014 |
|
12
|
|
|
* @copyright Pauli Järvinen 2017 - 2024 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace OCA\Music\AppInfo; |
|
16
|
|
|
|
|
17
|
|
|
use OCP\AppFramework\App; |
|
18
|
|
|
use OCP\AppFramework\IAppContainer; |
|
19
|
|
|
|
|
20
|
|
|
use OCA\Music\AppFramework\Core\Logger; |
|
21
|
|
|
|
|
22
|
|
|
use OCA\Music\BusinessLayer\AlbumBusinessLayer; |
|
23
|
|
|
use OCA\Music\BusinessLayer\ArtistBusinessLayer; |
|
24
|
|
|
use OCA\Music\BusinessLayer\BookmarkBusinessLayer; |
|
25
|
|
|
use OCA\Music\BusinessLayer\GenreBusinessLayer; |
|
26
|
|
|
use OCA\Music\BusinessLayer\Library; |
|
27
|
|
|
use OCA\Music\BusinessLayer\PlaylistBusinessLayer; |
|
28
|
|
|
use OCA\Music\BusinessLayer\PodcastChannelBusinessLayer; |
|
29
|
|
|
use OCA\Music\BusinessLayer\PodcastEpisodeBusinessLayer; |
|
30
|
|
|
use OCA\Music\BusinessLayer\RadioStationBusinessLayer; |
|
31
|
|
|
use OCA\Music\BusinessLayer\TrackBusinessLayer; |
|
32
|
|
|
|
|
33
|
|
|
use OCA\Music\Controller\AdvSearchController; |
|
34
|
|
|
use OCA\Music\Controller\AmpacheController; |
|
35
|
|
|
use OCA\Music\Controller\AmpacheImageController; |
|
36
|
|
|
use OCA\Music\Controller\ApiController; |
|
37
|
|
|
use OCA\Music\Controller\FavoritesController; |
|
38
|
|
|
use OCA\Music\Controller\LogController; |
|
39
|
|
|
use OCA\Music\Controller\PageController; |
|
40
|
|
|
use OCA\Music\Controller\PlaylistApiController; |
|
41
|
|
|
use OCA\Music\Controller\PodcastApiController; |
|
42
|
|
|
use OCA\Music\Controller\RadioApiController; |
|
43
|
|
|
use OCA\Music\Controller\SettingController; |
|
44
|
|
|
use OCA\Music\Controller\ShareController; |
|
45
|
|
|
use OCA\Music\Controller\ShivaApiController; |
|
46
|
|
|
use OCA\Music\Controller\SubsonicController; |
|
47
|
|
|
|
|
48
|
|
|
use OCA\Music\Db\AlbumMapper; |
|
49
|
|
|
use OCA\Music\Db\AmpacheSessionMapper; |
|
50
|
|
|
use OCA\Music\Db\AmpacheUserMapper; |
|
51
|
|
|
use OCA\Music\Db\ArtistMapper; |
|
52
|
|
|
use OCA\Music\Db\BookmarkMapper; |
|
53
|
|
|
use OCA\Music\Db\Cache; |
|
54
|
|
|
use OCA\Music\Db\GenreMapper; |
|
55
|
|
|
use OCA\Music\Db\Maintenance; |
|
56
|
|
|
use OCA\Music\Db\PlaylistMapper; |
|
57
|
|
|
use OCA\Music\Db\PodcastChannelMapper; |
|
58
|
|
|
use OCA\Music\Db\PodcastEpisodeMapper; |
|
59
|
|
|
use OCA\Music\Db\RadioStationMapper; |
|
60
|
|
|
use OCA\Music\Db\TrackMapper; |
|
61
|
|
|
|
|
62
|
|
|
use OCA\Music\Hooks\FileHooks; |
|
63
|
|
|
use OCA\Music\Hooks\ShareHooks; |
|
64
|
|
|
use OCA\Music\Hooks\UserHooks; |
|
65
|
|
|
|
|
66
|
|
|
use OCA\Music\Middleware\AmpacheMiddleware; |
|
67
|
|
|
use OCA\Music\Middleware\SubsonicMiddleware; |
|
68
|
|
|
|
|
69
|
|
|
use OCA\Music\Utility\AmpacheImageService; |
|
70
|
|
|
use OCA\Music\Utility\CollectionHelper; |
|
71
|
|
|
use OCA\Music\Utility\CoverHelper; |
|
72
|
|
|
use OCA\Music\Utility\DetailsHelper; |
|
73
|
|
|
use OCA\Music\Utility\ExtractorGetID3; |
|
74
|
|
|
use OCA\Music\Utility\LastfmService; |
|
75
|
|
|
use OCA\Music\Utility\PlaylistFileService; |
|
76
|
|
|
use OCA\Music\Utility\PodcastService; |
|
77
|
|
|
use OCA\Music\Utility\RadioService; |
|
78
|
|
|
use OCA\Music\Utility\Random; |
|
79
|
|
|
use OCA\Music\Utility\Scanner; |
|
80
|
|
|
use OCA\Music\Utility\LibrarySettings; |
|
81
|
|
|
|
|
82
|
|
|
// The IBootstrap interface is not available on ownCloud. Create a thin base class to hide this difference |
|
83
|
|
|
// from the actual Application class. |
|
84
|
|
|
function useOwncloudBootstrapping() { |
|
85
|
|
|
return (\OCA\Music\Utility\AppInfo::getVendor() == 'owncloud'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
if (useOwncloudBootstrapping()) { |
|
89
|
|
|
class ApplicationBase extends App {} |
|
90
|
|
|
} else { |
|
91
|
|
|
abstract class ApplicationBase extends App implements \OCP\AppFramework\Bootstrap\IBootstrap {} |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
class Application extends ApplicationBase { |
|
95
|
|
|
public function __construct(array $urlParams=[]) { |
|
96
|
|
|
parent::__construct('music', $urlParams); |
|
97
|
|
|
|
|
98
|
|
|
\mb_internal_encoding('UTF-8'); |
|
99
|
|
|
|
|
100
|
|
|
// NC26+ no longer ships OCP\AppFramework\Db\Mapper. Create a class alias which refers to this OCP class if available |
|
101
|
|
|
// or to our own ponyfill if not (created by copying the said class from NC25). |
|
102
|
|
|
if (!\class_exists('\OCA\Music\AppFramework\Db\CompatibleMapper')) { |
|
103
|
|
|
if (\class_exists('\OCP\AppFramework\Db\Mapper')) { |
|
104
|
|
|
\class_alias(\OCP\AppFramework\Db\Mapper::class, '\OCA\Music\AppFramework\Db\CompatibleMapper'); |
|
105
|
|
|
} else { |
|
106
|
|
|
\class_alias(\OCA\Music\AppFramework\Db\OldNextcloudMapper::class, '\OCA\Music\AppFramework\Db\CompatibleMapper'); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
// Create a class alias which refers to the TimedJob either from OC or OCP namespace. The OC version is available |
|
111
|
|
|
// on ownCloud and on Nextcloud versions <29. The OCP version is available on NC15+. |
|
112
|
|
|
if (!\class_exists('\OCA\Music\BackgroundJob\TimedJob')) { |
|
113
|
|
|
if (\class_exists('\OCP\BackgroundJob\TimedJob')) { |
|
114
|
|
|
\class_alias(\OCP\BackgroundJob\TimedJob::class, '\OCA\Music\BackgroundJob\TimedJob'); |
|
115
|
|
|
} else { |
|
116
|
|
|
\class_alias(\OC\BackgroundJob\TimedJob::class, '\OCA\Music\BackgroundJob\TimedJob'); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
// On ownCloud, the registrations must happen already within the constructor |
|
121
|
|
|
if (useOwncloudBootstrapping()) { |
|
122
|
|
|
$this->register($this->getContainer()); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
// On ownCloud, the $context is actually an IAppContainer |
|
127
|
|
|
public function register(/*\OCP\AppFramework\Bootstrap\IRegistrationContext*/ $context): void { |
|
128
|
|
|
/** |
|
129
|
|
|
* Controllers |
|
130
|
|
|
*/ |
|
131
|
|
|
|
|
132
|
|
|
$context->registerService('AdvSearchController', function (IAppContainer $c) { |
|
133
|
|
|
return new AdvSearchController( |
|
134
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
135
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
136
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
137
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
138
|
|
|
$c->query('BookmarkBusinessLayer'), |
|
|
|
|
|
|
139
|
|
|
$c->query('GenreBusinessLayer'), |
|
|
|
|
|
|
140
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
141
|
|
|
$c->query('PodcastChannelBusinessLayer'), |
|
|
|
|
|
|
142
|
|
|
$c->query('PodcastEpisodeBusinessLayer'), |
|
|
|
|
|
|
143
|
|
|
$c->query('RadioStationBusinessLayer'), |
|
|
|
|
|
|
144
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
145
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
146
|
|
|
$c->query('Random'), |
|
|
|
|
|
|
147
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
148
|
|
|
); |
|
149
|
|
|
}); |
|
150
|
|
|
|
|
151
|
|
|
$context->registerService('AmpacheController', function (IAppContainer $c) { |
|
152
|
|
|
return new AmpacheController( |
|
153
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
154
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
155
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
156
|
|
|
$c->query('L10N'), |
|
|
|
|
|
|
157
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
158
|
|
|
$c->query('UserManager'), |
|
|
|
|
|
|
159
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
160
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
161
|
|
|
$c->query('BookmarkBusinessLayer'), |
|
|
|
|
|
|
162
|
|
|
$c->query('GenreBusinessLayer'), |
|
|
|
|
|
|
163
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
164
|
|
|
$c->query('PodcastChannelBusinessLayer'), |
|
|
|
|
|
|
165
|
|
|
$c->query('PodcastEpisodeBusinessLayer'), |
|
|
|
|
|
|
166
|
|
|
$c->query('RadioStationBusinessLayer'), |
|
|
|
|
|
|
167
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
168
|
|
|
$c->query('Library'), |
|
|
|
|
|
|
169
|
|
|
$c->query('PodcastService'), |
|
|
|
|
|
|
170
|
|
|
$c->query('AmpacheImageService'), |
|
|
|
|
|
|
171
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
172
|
|
|
$c->query('LastfmService'), |
|
|
|
|
|
|
173
|
|
|
$c->query('LibrarySettings'), |
|
|
|
|
|
|
174
|
|
|
$c->query('Random'), |
|
|
|
|
|
|
175
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
176
|
|
|
); |
|
177
|
|
|
}); |
|
178
|
|
|
|
|
179
|
|
|
$context->registerService('AmpacheImageController', function (IAppContainer $c) { |
|
180
|
|
|
return new AmpacheImageController( |
|
181
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
182
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
183
|
|
|
$c->query('AmpacheImageService'), |
|
|
|
|
|
|
184
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
185
|
|
|
$c->query('LibrarySettings'), |
|
|
|
|
|
|
186
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
187
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
188
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
189
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
190
|
|
|
); |
|
191
|
|
|
}); |
|
192
|
|
|
|
|
193
|
|
|
$context->registerService('ApiController', function (IAppContainer $c) { |
|
194
|
|
|
return new ApiController( |
|
195
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
196
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
197
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
198
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
199
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
200
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
201
|
|
|
$c->query('GenreBusinessLayer'), |
|
|
|
|
|
|
202
|
|
|
$c->query('Scanner'), |
|
|
|
|
|
|
203
|
|
|
$c->query('CollectionHelper'), |
|
|
|
|
|
|
204
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
205
|
|
|
$c->query('DetailsHelper'), |
|
|
|
|
|
|
206
|
|
|
$c->query('LastfmService'), |
|
|
|
|
|
|
207
|
|
|
$c->query('Maintenance'), |
|
|
|
|
|
|
208
|
|
|
$c->query('LibrarySettings'), |
|
|
|
|
|
|
209
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
210
|
|
|
$c->query('UserFolder'), |
|
|
|
|
|
|
211
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
212
|
|
|
); |
|
213
|
|
|
}); |
|
214
|
|
|
|
|
215
|
|
|
$context->registerService('FavoritesController', function (IAppContainer $c) { |
|
216
|
|
|
return new FavoritesController( |
|
217
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
218
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
219
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
220
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
221
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
222
|
|
|
$c->query('PodcastChannelBusinessLayer'), |
|
|
|
|
|
|
223
|
|
|
$c->query('PodcastEpisodeBusinessLayer'), |
|
|
|
|
|
|
224
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
225
|
|
|
$c->query('UserId') |
|
|
|
|
|
|
226
|
|
|
); |
|
227
|
|
|
}); |
|
228
|
|
|
|
|
229
|
|
|
$context->registerService('PageController', function (IAppContainer $c) { |
|
230
|
|
|
return new PageController( |
|
231
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
232
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
233
|
|
|
$c->query('L10N') |
|
|
|
|
|
|
234
|
|
|
); |
|
235
|
|
|
}); |
|
236
|
|
|
|
|
237
|
|
|
$context->registerService('PlaylistApiController', function (IAppContainer $c) { |
|
238
|
|
|
return new PlaylistApiController( |
|
239
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
240
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
241
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
242
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
243
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
244
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
245
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
246
|
|
|
$c->query('GenreBusinessLayer'), |
|
|
|
|
|
|
247
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
248
|
|
|
$c->query('PlaylistFileService'), |
|
|
|
|
|
|
249
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
250
|
|
|
$c->query('UserFolder'), |
|
|
|
|
|
|
251
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
252
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
253
|
|
|
); |
|
254
|
|
|
}); |
|
255
|
|
|
|
|
256
|
|
|
$context->registerService('PodcastApiController', function (IAppContainer $c) { |
|
257
|
|
|
return new PodcastApiController( |
|
258
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
259
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
260
|
|
|
$c->query('PodcastService'), |
|
|
|
|
|
|
261
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
262
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
263
|
|
|
); |
|
264
|
|
|
}); |
|
265
|
|
|
|
|
266
|
|
|
$context->registerService('LogController', function (IAppContainer $c) { |
|
267
|
|
|
return new LogController( |
|
268
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
269
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
270
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
271
|
|
|
); |
|
272
|
|
|
}); |
|
273
|
|
|
|
|
274
|
|
|
$context->registerService('RadioApiController', function (IAppContainer $c) { |
|
275
|
|
|
return new RadioApiController( |
|
276
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
277
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
278
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
279
|
|
|
$c->query('RadioStationBusinessLayer'), |
|
|
|
|
|
|
280
|
|
|
$c->query('RadioService'), |
|
|
|
|
|
|
281
|
|
|
$c->query('PlaylistFileService'), |
|
|
|
|
|
|
282
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
283
|
|
|
$c->query('UserFolder'), |
|
|
|
|
|
|
284
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
285
|
|
|
); |
|
286
|
|
|
}); |
|
287
|
|
|
|
|
288
|
|
|
$context->registerService('SettingController', function (IAppContainer $c) { |
|
289
|
|
|
return new SettingController( |
|
290
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
291
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
292
|
|
|
$c->query('AmpacheSessionMapper'), |
|
|
|
|
|
|
293
|
|
|
$c->query('AmpacheUserMapper'), |
|
|
|
|
|
|
294
|
|
|
$c->query('Scanner'), |
|
|
|
|
|
|
295
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
296
|
|
|
$c->query('LibrarySettings'), |
|
|
|
|
|
|
297
|
|
|
$c->query('SecureRandom'), |
|
|
|
|
|
|
298
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
299
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
300
|
|
|
); |
|
301
|
|
|
}); |
|
302
|
|
|
|
|
303
|
|
|
$context->registerService('ShareController', function (IAppContainer $c) { |
|
304
|
|
|
return new ShareController( |
|
305
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
306
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
307
|
|
|
$c->query('Scanner'), |
|
|
|
|
|
|
308
|
|
|
$c->query('PlaylistFileService'), |
|
|
|
|
|
|
309
|
|
|
$c->query('Logger'), |
|
|
|
|
|
|
310
|
|
|
$c->query('ShareManager') |
|
|
|
|
|
|
311
|
|
|
); |
|
312
|
|
|
}); |
|
313
|
|
|
|
|
314
|
|
|
$context->registerService('ShivaApiController', function (IAppContainer $c) { |
|
315
|
|
|
return new ShivaApiController( |
|
316
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
317
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
318
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
319
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
320
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
321
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
322
|
|
|
$c->query('UserId'), |
|
|
|
|
|
|
323
|
|
|
$c->query('L10N'), |
|
|
|
|
|
|
324
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
325
|
|
|
); |
|
326
|
|
|
}); |
|
327
|
|
|
|
|
328
|
|
|
$context->registerService('SubsonicController', function (IAppContainer $c) { |
|
329
|
|
|
return new SubsonicController( |
|
330
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
331
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
332
|
|
|
$c->query('L10N'), |
|
|
|
|
|
|
333
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
334
|
|
|
$c->query('UserManager'), |
|
|
|
|
|
|
335
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
336
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
337
|
|
|
$c->query('BookmarkBusinessLayer'), |
|
|
|
|
|
|
338
|
|
|
$c->query('GenreBusinessLayer'), |
|
|
|
|
|
|
339
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
340
|
|
|
$c->query('PodcastChannelBusinessLayer'), |
|
|
|
|
|
|
341
|
|
|
$c->query('PodcastEpisodeBusinessLayer'), |
|
|
|
|
|
|
342
|
|
|
$c->query('RadioStationBusinessLayer'), |
|
|
|
|
|
|
343
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
344
|
|
|
$c->query('LibrarySettings'), |
|
|
|
|
|
|
345
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
346
|
|
|
$c->query('DetailsHelper'), |
|
|
|
|
|
|
347
|
|
|
$c->query('LastfmService'), |
|
|
|
|
|
|
348
|
|
|
$c->query('PodcastService'), |
|
|
|
|
|
|
349
|
|
|
$c->query('Random'), |
|
|
|
|
|
|
350
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
351
|
|
|
); |
|
352
|
|
|
}); |
|
353
|
|
|
|
|
354
|
|
|
/** |
|
355
|
|
|
* Business Layer |
|
356
|
|
|
*/ |
|
357
|
|
|
|
|
358
|
|
|
$context->registerService('TrackBusinessLayer', function (IAppContainer $c) { |
|
359
|
|
|
return new TrackBusinessLayer( |
|
360
|
|
|
$c->query('TrackMapper'), |
|
|
|
|
|
|
361
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
362
|
|
|
); |
|
363
|
|
|
}); |
|
364
|
|
|
|
|
365
|
|
|
$context->registerService('ArtistBusinessLayer', function (IAppContainer $c) { |
|
366
|
|
|
return new ArtistBusinessLayer( |
|
367
|
|
|
$c->query('ArtistMapper'), |
|
|
|
|
|
|
368
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
369
|
|
|
); |
|
370
|
|
|
}); |
|
371
|
|
|
|
|
372
|
|
|
$context->registerService('GenreBusinessLayer', function (IAppContainer $c) { |
|
373
|
|
|
return new GenreBusinessLayer( |
|
374
|
|
|
$c->query('GenreMapper'), |
|
|
|
|
|
|
375
|
|
|
$c->query('TrackMapper'), |
|
|
|
|
|
|
376
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
377
|
|
|
); |
|
378
|
|
|
}); |
|
379
|
|
|
|
|
380
|
|
|
$context->registerService('AlbumBusinessLayer', function (IAppContainer $c) { |
|
381
|
|
|
return new AlbumBusinessLayer( |
|
382
|
|
|
$c->query('AlbumMapper'), |
|
|
|
|
|
|
383
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
384
|
|
|
); |
|
385
|
|
|
}); |
|
386
|
|
|
|
|
387
|
|
|
$context->registerService('PlaylistBusinessLayer', function (IAppContainer $c) { |
|
388
|
|
|
return new PlaylistBusinessLayer( |
|
389
|
|
|
$c->query('PlaylistMapper'), |
|
|
|
|
|
|
390
|
|
|
$c->query('TrackMapper'), |
|
|
|
|
|
|
391
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
392
|
|
|
); |
|
393
|
|
|
}); |
|
394
|
|
|
|
|
395
|
|
|
$context->registerService('PodcastChannelBusinessLayer', function (IAppContainer $c) { |
|
396
|
|
|
return new PodcastChannelBusinessLayer( |
|
397
|
|
|
$c->query('PodcastChannelMapper'), |
|
|
|
|
|
|
398
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
399
|
|
|
); |
|
400
|
|
|
}); |
|
401
|
|
|
|
|
402
|
|
|
$context->registerService('PodcastEpisodeBusinessLayer', function (IAppContainer $c) { |
|
403
|
|
|
return new PodcastEpisodeBusinessLayer( |
|
404
|
|
|
$c->query('PodcastEpisodeMapper'), |
|
|
|
|
|
|
405
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
406
|
|
|
); |
|
407
|
|
|
}); |
|
408
|
|
|
|
|
409
|
|
|
$context->registerService('BookmarkBusinessLayer', function (IAppContainer $c) { |
|
410
|
|
|
return new BookmarkBusinessLayer( |
|
411
|
|
|
$c->query('BookmarkMapper'), |
|
|
|
|
|
|
412
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
413
|
|
|
); |
|
414
|
|
|
}); |
|
415
|
|
|
|
|
416
|
|
|
$context->registerService('RadioStationBusinessLayer', function ($c) { |
|
417
|
|
|
return new RadioStationBusinessLayer( |
|
418
|
|
|
$c->query('RadioStationMapper'), |
|
419
|
|
|
$c->query('Logger') |
|
420
|
|
|
); |
|
421
|
|
|
}); |
|
422
|
|
|
|
|
423
|
|
|
$context->registerService('Library', function (IAppContainer $c) { |
|
424
|
|
|
return new Library( |
|
425
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
426
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
427
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
428
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
429
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
430
|
|
|
$c->query('L10N'), |
|
|
|
|
|
|
431
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
432
|
|
|
); |
|
433
|
|
|
}); |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* Mappers |
|
437
|
|
|
*/ |
|
438
|
|
|
|
|
439
|
|
|
$context->registerService('AlbumMapper', function (IAppContainer $c) { |
|
440
|
|
|
return new AlbumMapper( |
|
441
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
442
|
|
|
$c->query('Config') |
|
|
|
|
|
|
443
|
|
|
); |
|
444
|
|
|
}); |
|
445
|
|
|
|
|
446
|
|
|
$context->registerService('AmpacheSessionMapper', function (IAppContainer $c) { |
|
447
|
|
|
return new AmpacheSessionMapper( |
|
448
|
|
|
$c->query('Db') |
|
|
|
|
|
|
449
|
|
|
); |
|
450
|
|
|
}); |
|
451
|
|
|
|
|
452
|
|
|
$context->registerService('AmpacheUserMapper', function (IAppContainer $c) { |
|
453
|
|
|
return new AmpacheUserMapper( |
|
454
|
|
|
$c->query('Db') |
|
|
|
|
|
|
455
|
|
|
); |
|
456
|
|
|
}); |
|
457
|
|
|
|
|
458
|
|
|
$context->registerService('ArtistMapper', function (IAppContainer $c) { |
|
459
|
|
|
return new ArtistMapper( |
|
460
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
461
|
|
|
$c->query('Config') |
|
|
|
|
|
|
462
|
|
|
); |
|
463
|
|
|
}); |
|
464
|
|
|
|
|
465
|
|
|
$context->registerService('DbCache', function (IAppContainer $c) { |
|
466
|
|
|
return new Cache( |
|
467
|
|
|
$c->query('Db') |
|
|
|
|
|
|
468
|
|
|
); |
|
469
|
|
|
}); |
|
470
|
|
|
|
|
471
|
|
|
$context->registerService('GenreMapper', function (IAppContainer $c) { |
|
472
|
|
|
return new GenreMapper( |
|
473
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
474
|
|
|
$c->query('Config') |
|
|
|
|
|
|
475
|
|
|
); |
|
476
|
|
|
}); |
|
477
|
|
|
|
|
478
|
|
|
$context->registerService('PlaylistMapper', function (IAppContainer $c) { |
|
479
|
|
|
return new PlaylistMapper( |
|
480
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
481
|
|
|
$c->query('Config') |
|
|
|
|
|
|
482
|
|
|
); |
|
483
|
|
|
}); |
|
484
|
|
|
|
|
485
|
|
|
$context->registerService('PodcastChannelMapper', function (IAppContainer $c) { |
|
486
|
|
|
return new PodcastChannelMapper( |
|
487
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
488
|
|
|
$c->query('Config') |
|
|
|
|
|
|
489
|
|
|
); |
|
490
|
|
|
}); |
|
491
|
|
|
|
|
492
|
|
|
$context->registerService('PodcastEpisodeMapper', function (IAppContainer $c) { |
|
493
|
|
|
return new PodcastEpisodeMapper( |
|
494
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
495
|
|
|
$c->query('Config') |
|
|
|
|
|
|
496
|
|
|
); |
|
497
|
|
|
}); |
|
498
|
|
|
|
|
499
|
|
|
$context->registerService('TrackMapper', function (IAppContainer $c) { |
|
500
|
|
|
return new TrackMapper( |
|
501
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
502
|
|
|
$c->query('Config') |
|
|
|
|
|
|
503
|
|
|
); |
|
504
|
|
|
}); |
|
505
|
|
|
|
|
506
|
|
|
$context->registerService('BookmarkMapper', function (IAppContainer $c) { |
|
507
|
|
|
return new BookmarkMapper( |
|
508
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
509
|
|
|
$c->query('Config') |
|
|
|
|
|
|
510
|
|
|
); |
|
511
|
|
|
}); |
|
512
|
|
|
|
|
513
|
|
|
$context->registerService('RadioStationMapper', function (IAppContainer $c) { |
|
514
|
|
|
return new RadioStationMapper( |
|
515
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
516
|
|
|
$c->query('Config') |
|
|
|
|
|
|
517
|
|
|
); |
|
518
|
|
|
}); |
|
519
|
|
|
|
|
520
|
|
|
/** |
|
521
|
|
|
* Core |
|
522
|
|
|
*/ |
|
523
|
|
|
|
|
524
|
|
|
$context->registerService('Config', function (IAppContainer $c) { |
|
525
|
|
|
return $c->getServer()->getConfig(); |
|
|
|
|
|
|
526
|
|
|
}); |
|
527
|
|
|
|
|
528
|
|
|
$context->registerService('Db', function (IAppContainer $c) { |
|
529
|
|
|
return $c->getServer()->getDatabaseConnection(); |
|
|
|
|
|
|
530
|
|
|
}); |
|
531
|
|
|
|
|
532
|
|
|
$context->registerService('FileCache', function (IAppContainer $c) { |
|
533
|
|
|
return $c->getServer()->getCache(); |
|
|
|
|
|
|
534
|
|
|
}); |
|
535
|
|
|
|
|
536
|
|
|
$context->registerService('L10N', function (IAppContainer $c) { |
|
537
|
|
|
return $c->getServer()->getL10N($c->query('AppName')); |
|
|
|
|
|
|
538
|
|
|
}); |
|
539
|
|
|
|
|
540
|
|
|
$context->registerService('L10NFactory', function (IAppContainer $c) { |
|
541
|
|
|
return $c->getServer()->getL10NFactory(); |
|
|
|
|
|
|
542
|
|
|
}); |
|
543
|
|
|
|
|
544
|
|
|
$context->registerService('Logger', function (IAppContainer $c) { |
|
545
|
|
|
return new Logger( |
|
546
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
547
|
|
|
$c->getServer()->getLogger() |
|
|
|
|
|
|
548
|
|
|
); |
|
549
|
|
|
}); |
|
550
|
|
|
|
|
551
|
|
|
$context->registerService('MimeTypeLoader', function (IappContainer $c) { |
|
552
|
|
|
return $c->getServer()->getMimeTypeLoader(); |
|
|
|
|
|
|
553
|
|
|
}); |
|
554
|
|
|
|
|
555
|
|
|
$context->registerService('URLGenerator', function (IAppContainer $c) { |
|
556
|
|
|
return $c->getServer()->getURLGenerator(); |
|
|
|
|
|
|
557
|
|
|
}); |
|
558
|
|
|
|
|
559
|
|
|
$context->registerService('UserFolder', function (IAppContainer $c) { |
|
560
|
|
|
return $c->getServer()->getUserFolder(); |
|
|
|
|
|
|
561
|
|
|
}); |
|
562
|
|
|
|
|
563
|
|
|
$context->registerService('RootFolder', function (IAppContainer $c) { |
|
564
|
|
|
return $c->getServer()->getRootFolder(); |
|
|
|
|
|
|
565
|
|
|
}); |
|
566
|
|
|
|
|
567
|
|
|
$context->registerService('UserId', function (IAppContainer $c) { |
|
568
|
|
|
$user = $c->getServer()->getUserSession()->getUser(); |
|
|
|
|
|
|
569
|
|
|
return $user ? $user->getUID() : null; |
|
570
|
|
|
}); |
|
571
|
|
|
|
|
572
|
|
|
$context->registerService('SecureRandom', function (IAppContainer $c) { |
|
573
|
|
|
return $c->getServer()->getSecureRandom(); |
|
|
|
|
|
|
574
|
|
|
}); |
|
575
|
|
|
|
|
576
|
|
|
$context->registerService('UserManager', function (IAppContainer $c) { |
|
577
|
|
|
return $c->getServer()->getUserManager(); |
|
|
|
|
|
|
578
|
|
|
}); |
|
579
|
|
|
|
|
580
|
|
|
$context->registerService('GroupManager', function (IAppContainer $c) { |
|
581
|
|
|
return $c->getServer()->getGroupManager(); |
|
|
|
|
|
|
582
|
|
|
}); |
|
583
|
|
|
|
|
584
|
|
|
$context->registerService('ShareManager', function (IAppContainer $c) { |
|
585
|
|
|
return $c->getServer()->getShareManager(); |
|
|
|
|
|
|
586
|
|
|
}); |
|
587
|
|
|
|
|
588
|
|
|
/** |
|
589
|
|
|
* Utility |
|
590
|
|
|
*/ |
|
591
|
|
|
|
|
592
|
|
|
$context->registerService('AmpacheImageService', function (IAppContainer $c) { |
|
593
|
|
|
return new AmpacheImageService( |
|
594
|
|
|
$c->query('AmpacheUserMapper'), |
|
|
|
|
|
|
595
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
596
|
|
|
); |
|
597
|
|
|
}); |
|
598
|
|
|
|
|
599
|
|
|
$context->registerService('CollectionHelper', function (IAppContainer $c) { |
|
600
|
|
|
return new CollectionHelper( |
|
601
|
|
|
$c->query('Library'), |
|
|
|
|
|
|
602
|
|
|
$c->query('FileCache'), |
|
|
|
|
|
|
603
|
|
|
$c->query('DbCache'), |
|
|
|
|
|
|
604
|
|
|
$c->query('Logger'), |
|
|
|
|
|
|
605
|
|
|
$c->query('UserId') |
|
|
|
|
|
|
606
|
|
|
); |
|
607
|
|
|
}); |
|
608
|
|
|
|
|
609
|
|
|
$context->registerService('CoverHelper', function (IAppContainer $c) { |
|
610
|
|
|
return new CoverHelper( |
|
611
|
|
|
$c->query('ExtractorGetID3'), |
|
|
|
|
|
|
612
|
|
|
$c->query('DbCache'), |
|
|
|
|
|
|
613
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
614
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
615
|
|
|
$c->query('L10N'), |
|
|
|
|
|
|
616
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
617
|
|
|
); |
|
618
|
|
|
}); |
|
619
|
|
|
|
|
620
|
|
|
$context->registerService('DetailsHelper', function (IAppContainer $c) { |
|
621
|
|
|
return new DetailsHelper( |
|
622
|
|
|
$c->query('ExtractorGetID3'), |
|
|
|
|
|
|
623
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
624
|
|
|
); |
|
625
|
|
|
}); |
|
626
|
|
|
|
|
627
|
|
|
$context->registerService('ExtractorGetID3', function (IAppContainer $c) { |
|
628
|
|
|
return new ExtractorGetID3( |
|
629
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
630
|
|
|
); |
|
631
|
|
|
}); |
|
632
|
|
|
|
|
633
|
|
|
$context->registerService('LastfmService', function (IAppContainer $c) { |
|
634
|
|
|
return new LastfmService( |
|
635
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
636
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
637
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
638
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
639
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
640
|
|
|
); |
|
641
|
|
|
}); |
|
642
|
|
|
|
|
643
|
|
|
$context->registerService('Maintenance', function (IAppContainer $c) { |
|
644
|
|
|
return new Maintenance( |
|
645
|
|
|
$c->query('Db'), |
|
|
|
|
|
|
646
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
647
|
|
|
); |
|
648
|
|
|
}); |
|
649
|
|
|
|
|
650
|
|
|
$context->registerService('PlaylistFileService', function (IAppContainer $c) { |
|
651
|
|
|
return new PlaylistFileService( |
|
652
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
653
|
|
|
$c->query('RadioStationBusinessLayer'), |
|
|
|
|
|
|
654
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
655
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
656
|
|
|
); |
|
657
|
|
|
}); |
|
658
|
|
|
|
|
659
|
|
|
$context->registerService('PodcastService', function (IAppContainer $c) { |
|
660
|
|
|
return new PodcastService( |
|
661
|
|
|
$c->query('PodcastChannelBusinessLayer'), |
|
|
|
|
|
|
662
|
|
|
$c->query('PodcastEpisodeBusinessLayer'), |
|
|
|
|
|
|
663
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
664
|
|
|
); |
|
665
|
|
|
}); |
|
666
|
|
|
|
|
667
|
|
|
$context->registerService('RadioService', function (IAppContainer $c) { |
|
668
|
|
|
return new RadioService( |
|
669
|
|
|
$c->query('URLGenerator'), |
|
|
|
|
|
|
670
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
671
|
|
|
); |
|
672
|
|
|
}); |
|
673
|
|
|
|
|
674
|
|
|
$context->registerService('Random', function (IAppContainer $c) { |
|
675
|
|
|
return new Random( |
|
676
|
|
|
$c->query('DbCache'), |
|
|
|
|
|
|
677
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
678
|
|
|
); |
|
679
|
|
|
}); |
|
680
|
|
|
|
|
681
|
|
|
$context->registerService('Scanner', function (IAppContainer $c) { |
|
682
|
|
|
return new Scanner( |
|
683
|
|
|
$c->query('ExtractorGetID3'), |
|
|
|
|
|
|
684
|
|
|
$c->query('ArtistBusinessLayer'), |
|
|
|
|
|
|
685
|
|
|
$c->query('AlbumBusinessLayer'), |
|
|
|
|
|
|
686
|
|
|
$c->query('TrackBusinessLayer'), |
|
|
|
|
|
|
687
|
|
|
$c->query('PlaylistBusinessLayer'), |
|
|
|
|
|
|
688
|
|
|
$c->query('GenreBusinessLayer'), |
|
|
|
|
|
|
689
|
|
|
$c->query('DbCache'), |
|
|
|
|
|
|
690
|
|
|
$c->query('CoverHelper'), |
|
|
|
|
|
|
691
|
|
|
$c->query('Logger'), |
|
|
|
|
|
|
692
|
|
|
$c->query('Maintenance'), |
|
|
|
|
|
|
693
|
|
|
$c->query('LibrarySettings'), |
|
|
|
|
|
|
694
|
|
|
$c->query('RootFolder'), |
|
|
|
|
|
|
695
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
696
|
|
|
$c->query('L10NFactory') |
|
|
|
|
|
|
697
|
|
|
); |
|
698
|
|
|
}); |
|
699
|
|
|
|
|
700
|
|
|
$context->registerService('LibrarySettings', function (IAppContainer $c) { |
|
701
|
|
|
return new LibrarySettings( |
|
702
|
|
|
$c->query('AppName'), |
|
|
|
|
|
|
703
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
704
|
|
|
$c->query('RootFolder'), |
|
|
|
|
|
|
705
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
706
|
|
|
); |
|
707
|
|
|
}); |
|
708
|
|
|
|
|
709
|
|
|
/** |
|
710
|
|
|
* Middleware |
|
711
|
|
|
*/ |
|
712
|
|
|
|
|
713
|
|
|
$context->registerService('AmpacheMiddleware', function (IAppContainer $c) { |
|
714
|
|
|
return new AmpacheMiddleware( |
|
715
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
716
|
|
|
$c->query('Config'), |
|
|
|
|
|
|
717
|
|
|
$c->query('AmpacheSessionMapper'), |
|
|
|
|
|
|
718
|
|
|
$c->query('AmpacheUserMapper'), |
|
|
|
|
|
|
719
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
720
|
|
|
); |
|
721
|
|
|
}); |
|
722
|
|
|
$context->registerMiddleWare('AmpacheMiddleware'); |
|
723
|
|
|
|
|
724
|
|
|
$context->registerService('SubsonicMiddleware', function (IAppContainer $c) { |
|
725
|
|
|
return new SubsonicMiddleware( |
|
726
|
|
|
$c->query('Request'), |
|
|
|
|
|
|
727
|
|
|
$c->query('AmpacheUserMapper'), /* not a mistake, the mapper is shared between the APIs */ |
|
|
|
|
|
|
728
|
|
|
$c->query('Logger') |
|
|
|
|
|
|
729
|
|
|
); |
|
730
|
|
|
}); |
|
731
|
|
|
$context->registerMiddleWare('SubsonicMiddleware'); |
|
732
|
|
|
|
|
733
|
|
|
/** |
|
734
|
|
|
* Hooks |
|
735
|
|
|
*/ |
|
736
|
|
|
$context->registerService('FileHooks', function (IAppContainer $c) { |
|
737
|
|
|
return new FileHooks( |
|
738
|
|
|
$c->getServer()->getRootFolder() |
|
|
|
|
|
|
739
|
|
|
); |
|
740
|
|
|
}); |
|
741
|
|
|
|
|
742
|
|
|
$context->registerService('ShareHooks', function (/** @scrutinizer ignore-unused */ IAppContainer $c) { |
|
743
|
|
|
return new ShareHooks(); |
|
744
|
|
|
}); |
|
745
|
|
|
|
|
746
|
|
|
$context->registerService('UserHooks', function (IAppContainer $c) { |
|
747
|
|
|
return new UserHooks( |
|
748
|
|
|
$c->query('ServerContainer')->getUserManager(), |
|
|
|
|
|
|
749
|
|
|
$c->query('Maintenance') |
|
|
|
|
|
|
750
|
|
|
); |
|
751
|
|
|
}); |
|
752
|
|
|
} |
|
753
|
|
|
|
|
754
|
|
|
/** |
|
755
|
|
|
* This gets called on Nextcloud but not on ownCloud |
|
756
|
|
|
*/ |
|
757
|
|
|
public function boot(/*\OCP\AppFramework\Bootstrap\IBootContext*/ $context) : void { |
|
758
|
|
|
$this->init(); |
|
759
|
|
|
$this->registerEmbeddedPlayer(); |
|
760
|
|
|
} |
|
761
|
|
|
|
|
762
|
|
|
public function init() : void { |
|
763
|
|
|
$this->registerHooks(); |
|
764
|
|
|
|
|
765
|
|
|
// Adjust the CSP if loading the Music app proper |
|
766
|
|
|
$url = $this->getRequestUrl(); |
|
767
|
|
|
if (\preg_match('%/apps/music/?$%', $url)) { |
|
768
|
|
|
$this->adjustCsp(); |
|
769
|
|
|
} |
|
770
|
|
|
} |
|
771
|
|
|
|
|
772
|
|
|
/** |
|
773
|
|
|
* Load embedded music player for Files and Sharing apps |
|
774
|
|
|
*/ |
|
775
|
|
|
public function loadEmbeddedMusicPlayer() { |
|
776
|
|
|
\OCA\Music\Utility\HtmlUtil::addWebpackScript('files_music_player'); |
|
777
|
|
|
\OCA\Music\Utility\HtmlUtil::addWebpackStyle('files_music_player'); |
|
778
|
|
|
$this->adjustCsp(); |
|
779
|
|
|
} |
|
780
|
|
|
|
|
781
|
|
|
private function getRequestUrl() : string { |
|
782
|
|
|
$request = $this->getContainer()->getServer()->getRequest(); |
|
|
|
|
|
|
783
|
|
|
$url = $request->server['REQUEST_URI'] ?? ''; |
|
784
|
|
|
$url = \explode('?', $url)[0]; // get rid of any query args |
|
785
|
|
|
$url = \explode('#', $url)[0]; // get rid of any hash part |
|
786
|
|
|
return $url; |
|
787
|
|
|
} |
|
788
|
|
|
|
|
789
|
|
|
private function registerHooks() { |
|
790
|
|
|
$container = $this->getContainer(); |
|
791
|
|
|
$container->query('FileHooks')->register(); |
|
|
|
|
|
|
792
|
|
|
$container->query('ShareHooks')->register(); |
|
|
|
|
|
|
793
|
|
|
$container->query('UserHooks')->register(); |
|
|
|
|
|
|
794
|
|
|
} |
|
795
|
|
|
|
|
796
|
|
|
private function registerEmbeddedPlayer() { |
|
797
|
|
|
$loadEmbeddedMusicPlayer = function() { |
|
798
|
|
|
$this->loadEmbeddedMusicPlayer(); |
|
799
|
|
|
}; |
|
800
|
|
|
|
|
801
|
|
|
$dispatcher = $this->getContainer()->query(\OCP\EventDispatcher\IEventDispatcher::class); |
|
|
|
|
|
|
802
|
|
|
$dispatcher->addListener(\OCA\Files\Event\LoadAdditionalScriptsEvent::class, $loadEmbeddedMusicPlayer); |
|
803
|
|
|
$dispatcher->addListener(\OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent::class, $loadEmbeddedMusicPlayer); |
|
804
|
|
|
} |
|
805
|
|
|
|
|
806
|
|
|
/** |
|
807
|
|
|
* Set content security policy to allow streaming media from the configured external sources |
|
808
|
|
|
*/ |
|
809
|
|
|
private function adjustCsp() { |
|
810
|
|
|
$container = $this->getContainer(); |
|
811
|
|
|
|
|
812
|
|
|
/** @var \OCP\IConfig $config */ |
|
813
|
|
|
$config = $container->query('Config'); |
|
|
|
|
|
|
814
|
|
|
$radioSources = $config->getSystemValue('music.allowed_radio_src', ['http://*:*', 'https://*:*']); |
|
815
|
|
|
$enableHls = $config->getSystemValue('music.enable_radio_hls', true); |
|
816
|
|
|
|
|
817
|
|
|
if (\is_string($radioSources)) { |
|
818
|
|
|
$radioSources = [$radioSources]; |
|
819
|
|
|
} |
|
820
|
|
|
|
|
821
|
|
|
$policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(); |
|
822
|
|
|
|
|
823
|
|
|
foreach ($radioSources as $source) { |
|
824
|
|
|
$policy->addAllowedMediaDomain($source); |
|
825
|
|
|
$policy->addAllowedImageDomain($source); // for podcast images |
|
826
|
|
|
} |
|
827
|
|
|
|
|
828
|
|
|
// Also the media sources 'data:' and 'blob:' are needed for HLS streaming |
|
829
|
|
|
if ($enableHls) { |
|
830
|
|
|
$policy->addAllowedMediaDomain('data:'); |
|
831
|
|
|
$policy->addAllowedMediaDomain('blob:'); |
|
832
|
|
|
} |
|
833
|
|
|
|
|
834
|
|
|
$container->getServer()->getContentSecurityPolicyManager()->addDefaultPolicy($policy); |
|
|
|
|
|
|
835
|
|
|
} |
|
836
|
|
|
|
|
837
|
|
|
} |
|
838
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.