diff options
Diffstat (limited to 'xbmc/addons/Webinterface.cpp')
| -rw-r--r-- | xbmc/addons/Webinterface.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/xbmc/addons/Webinterface.cpp b/xbmc/addons/Webinterface.cpp new file mode 100644 index 0000000..5745b1c --- /dev/null +++ b/xbmc/addons/Webinterface.cpp | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015 Team XBMC | ||
| 3 | * http://xbmc.org | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with XBMC; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include "Webinterface.h" | ||
| 22 | #include "addons/AddonManager.h" | ||
| 23 | #include "utils/log.h" | ||
| 24 | #include "utils/StringUtils.h" | ||
| 25 | #include "utils/URIUtils.h" | ||
| 26 | |||
| 27 | using namespace ADDON; | ||
| 28 | |||
| 29 | CWebinterface::CWebinterface(const ADDON::AddonProps &props, WebinterfaceType type /* = WebinterfaceTypeStatic */, const std::string &entryPoint /* = "WEBINTERFACE_DEFAULT_ENTRY_POINT" */) | ||
| 30 | : CAddon(props), | ||
| 31 | m_type(type), | ||
| 32 | m_entryPoint(entryPoint) | ||
| 33 | { } | ||
| 34 | |||
| 35 | CWebinterface::CWebinterface(const cp_extension_t *ext) | ||
| 36 | : CAddon(ext), | ||
| 37 | m_type(WebinterfaceTypeStatic), | ||
| 38 | m_entryPoint(WEBINTERFACE_DEFAULT_ENTRY_POINT) | ||
| 39 | { | ||
| 40 | // determine the type of the webinterface | ||
| 41 | std::string webinterfaceType = CAddonMgr::Get().GetExtValue(ext->configuration, "@type"); | ||
| 42 | if (StringUtils::EqualsNoCase(webinterfaceType.c_str(), "wsgi")) | ||
| 43 | m_type = WebinterfaceTypeWsgi; | ||
| 44 | else if (!webinterfaceType.empty() && !StringUtils::EqualsNoCase(webinterfaceType.c_str(), "static") && !StringUtils::EqualsNoCase(webinterfaceType.c_str(), "html")) | ||
| 45 | CLog::Log(LOGWARNING, "Webinterface addon \"%s\" has specified an unsupported type \"%s\"", ID().c_str(), webinterfaceType.c_str()); | ||
| 46 | |||
| 47 | // determine the entry point of the webinterface | ||
| 48 | std::string entryPoint = CAddonMgr::Get().GetExtValue(ext->configuration, "@entry"); | ||
| 49 | if (!entryPoint.empty()) | ||
| 50 | m_entryPoint = entryPoint; | ||
| 51 | } | ||
| 52 | |||
| 53 | CWebinterface::~CWebinterface() | ||
| 54 | { } | ||
| 55 | |||
| 56 | std::string CWebinterface::GetEntryPoint(const std::string &path) const | ||
| 57 | { | ||
| 58 | if (m_type == WebinterfaceTypeWsgi) | ||
| 59 | return LibPath(); | ||
| 60 | |||
| 61 | return URIUtils::AddFileToFolder(path, m_entryPoint); | ||
| 62 | } | ||
| 63 | |||
| 64 | std::string CWebinterface::GetBaseLocation() const | ||
| 65 | { | ||
| 66 | if (m_type == WebinterfaceTypeWsgi) | ||
| 67 | return "/addons/" + ID(); | ||
| 68 | |||
| 69 | return ""; | ||
| 70 | } | ||
| 71 | |||
| 72 | AddonPtr CWebinterface::Clone() const | ||
| 73 | { | ||
| 74 | return AddonPtr(new CWebinterface(*this)); | ||
| 75 | } \ No newline at end of file | ||
