1<?php
2
3declare(strict_types=0);
4
5/*
6 * vim:set softtabstop=4 shiftwidth=4 expandtab:
7 *
8 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later)
9 * Copyright 2001 - 2020 Ampache.org
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 published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (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 <https://www.gnu.org/licenses/>.
23 *
24 */
25
26namespace Ampache\Application\Api\Upnp;
27
28use Ampache\Application\ApplicationInterface;
29use Ampache\Config\AmpConfig;
30use Ampache\Module\Api\Upnp_Api;
31
32final class CmControlReplyApplication implements ApplicationInterface
33{
34    public function run(): void
35    {
36        if (!AmpConfig::get('upnp_backend')) {
37            echo T_("Disabled");
38
39            return;
40        }
41
42        set_time_limit(600);
43
44        header("Content-Type: text/html; charset=UTF-8");
45
46        // Parse the request from UPnP player
47        $requestRaw = file_get_contents('php://input');
48        if ($requestRaw != '') {
49            $upnpRequest = Upnp_Api::parseUPnPRequest($requestRaw);
50            debug_event('cm-control-reply', 'Request: ' . $requestRaw, 5);
51        } else {
52            echo T_('Received an empty UPnP request');
53            debug_event('cm-control-reply', 'No request', 5);
54
55            return;
56        }
57
58        switch ($upnpRequest['action']) {
59            case 'getprotocolinfo':
60                $responseType = 'u:GetProtocolInfoResponse';
61                //$items = \Ampache\Module\Api\Upnp_Api::cm_getProtocolInfo();
62                break;
63        }
64    }
65}
66