2 * Copyright (C) 2015-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "Webinterface.h"
11 #include "addons/addoninfo/AddonType.h"
12 #include "utils/StringUtils.h"
13 #include "utils/URIUtils.h"
14 #include "utils/log.h"
16 using namespace ADDON
;
18 CWebinterface::CWebinterface(const AddonInfoPtr
& addonInfo
)
19 : CAddon(addonInfo
, AddonType::WEB_INTERFACE
), m_entryPoint(WEBINTERFACE_DEFAULT_ENTRY_POINT
)
21 // determine the type of the webinterface
22 std::string webinterfaceType
= Type(AddonType::WEB_INTERFACE
)->GetValue("@type").asString();
23 if (StringUtils::EqualsNoCase(webinterfaceType
, "wsgi"))
24 m_type
= WebinterfaceTypeWsgi
;
25 else if (!webinterfaceType
.empty() && !StringUtils::EqualsNoCase(webinterfaceType
, "static") && !StringUtils::EqualsNoCase(webinterfaceType
, "html"))
27 "CWebinterface::{}: Addon \"{}\" has specified an unsupported type \"{}\"", __func__
,
28 ID(), webinterfaceType
);
30 // determine the entry point of the webinterface
31 std::string entry
= Type(AddonType::WEB_INTERFACE
)->GetValue("@entry").asString();
36 std::string
CWebinterface::GetEntryPoint(const std::string
&path
) const
38 if (m_type
== WebinterfaceTypeWsgi
)
41 return URIUtils::AddFileToFolder(path
, m_entryPoint
);
44 std::string
CWebinterface::GetBaseLocation() const
46 if (m_type
== WebinterfaceTypeWsgi
)
47 return "/addons/" + ID();