2 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
21 #include "AddonManager.h"
22 #include "interfaces/generic/ScriptInvocationManager.h"
23 #include "utils/log.h"
31 CService::CService(const cp_extension_t *ext)
32 : CAddon(ext), m_type(UNKNOWN), m_startOption(LOGIN)
36 CStdString start = CAddonMgr::Get().GetExtValue(ext->configuration, "@start");
37 if (start.Equals("startup"))
38 m_startOption = STARTUP;
42 CService::CService(const AddonProps &props)
43 : CAddon(props), m_type(UNKNOWN), m_startOption(LOGIN)
48 AddonPtr CService::Clone() const
50 return AddonPtr(new CService(*this));
53 bool CService::Start()
60 ret = (CScriptInvocationManager::Get().Execute(LibPath(), this->shared_from_this()) != -1);
81 ret = CScriptInvocationManager::Get().Stop(LibPath());
94 void CService::BuildServiceType()
96 CStdString str = LibPath();
99 size_t p = str.find_last_of('.');
100 if (p != string::npos)
101 ext = str.substr(p + 1);
104 CStdString pythonExt = ADDON_PYTHON_EXT;
105 pythonExt.erase(0, 2);
106 if ( ext.Equals(pythonExt) )
112 CLog::Log(LOGERROR, "ADDON: extension '%s' is not currently supported for service addon", ext.c_str());