本文整理汇总了C++中addon::VECADDONS::size方法的典型用法代码示例。如果您正苦于以下问题:C++ VECADDONS::size方法的具体用法?C++ VECADDONS::size怎么用?C++ VECADDONS::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类addon::VECADDONS
的用法示例。
在下文中一共展示了VECADDONS::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAddons
bool CPVRClients::UpdateAddons(void)
{
ADDON::VECADDONS addons;
bool bReturn(CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true));
if (bReturn)
{
CSingleLock lock(m_critSection);
m_addons = addons;
}
// handle "new" addons which aren't yet in the db - these have to be added first
for (unsigned iClientPtr = 0; iClientPtr < m_addons.size(); iClientPtr++)
{
const AddonPtr clientAddon = m_addons.at(iClientPtr);
if (!m_addonDb.HasAddon(clientAddon->ID()))
{
m_addonDb.AddAddon(clientAddon, -1);
}
}
if ((!bReturn || addons.size() == 0) && !m_bNoAddonWarningDisplayed &&
!CAddonMgr::Get().HasAddons(ADDON_PVRDLL, false) &&
(g_PVRManager.GetState() == ManagerStateStarted || g_PVRManager.GetState() == ManagerStateStarting))
{
// No PVR add-ons could be found
// You need a tuner, backend software, and an add-on for the backend to be able to use PVR.
// Please visit xbmc.org/pvr to learn more.
m_bNoAddonWarningDisplayed = true;
g_guiSettings.SetBool("pvrmanager.enabled", false);
CGUIDialogOK::ShowAndGetInput(19271, 19272, 19273, 19274);
CGUIMessage msg(GUI_MSG_UPDATE, WINDOW_SETTINGS_MYPVR, 0);
g_windowManager.SendThreadMessage(msg, WINDOW_SETTINGS_MYPVR);
}
return bReturn;
}
示例2: UpdateAddons
bool CPVRClients::UpdateAddons(void)
{
ADDON::VECADDONS addons;
bool bReturn(CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true));
if (bReturn)
{
CSingleLock lock(m_critSection);
m_addons = addons;
}
if ((!bReturn || addons.size() == 0) && !m_bNoAddonWarningDisplayed &&
!CAddonMgr::Get().HasAddons(ADDON_PVRDLL, false) &&
(g_PVRManager.GetState() == ManagerStateStarted || g_PVRManager.GetState() == ManagerStateStarting))
{
// No PVR add-ons could be found
// You need a tuner, backend software, and an add-on for the backend to be able to use PVR.
// Please visit xbmc.org/pvr to learn more.
m_bNoAddonWarningDisplayed = true;
CGUIDialogOK::ShowAndGetInput(19271, 19272, 19273, 19274);
}
return bReturn;
}
示例3: UpdateAndInitialiseClients
bool CPVRClients::UpdateAndInitialiseClients(bool bInitialiseAllClients /* = false */)
{
bool bReturn(true);
ADDON::VECADDONS map;
ADDON::VECADDONS disableAddons;
{
CSingleLock lock(m_critSection);
map = m_addons;
}
if (map.size() == 0)
return false;
for (unsigned iClientPtr = 0; iClientPtr < map.size(); iClientPtr++)
{
const AddonPtr clientAddon = map.at(iClientPtr);
bool bEnabled = clientAddon->Enabled() &&
!m_addonDb.IsAddonDisabled(clientAddon->ID());
if (!bEnabled && IsKnownClient(clientAddon))
{
CSingleLock lock(m_critSection);
/* stop the client and remove it from the db */
StopClient(clientAddon, false);
ADDON::VECADDONS::iterator addonPtr = std::find(m_addons.begin(), m_addons.end(), clientAddon);
if (addonPtr != m_addons.end())
m_addons.erase(addonPtr);
}
else if (bEnabled && (bInitialiseAllClients || !IsKnownClient(clientAddon) || !IsConnectedClient(clientAddon)))
{
bool bDisabled(false);
// register the add-on in the pvr db, and create the CPVRClient instance
int iClientId = RegisterClient(clientAddon);
if (iClientId < 0)
{
// failed to register or create the add-on, disable it
CLog::Log(LOGWARNING, "%s - failed to register add-on %s, disabling it", __FUNCTION__, clientAddon->Name().c_str());
disableAddons.push_back(clientAddon);
bDisabled = true;
}
else
{
ADDON_STATUS status(ADDON_STATUS_UNKNOWN);
PVR_CLIENT addon;
{
CSingleLock lock(m_critSection);
if (!GetClient(iClientId, addon))
{
CLog::Log(LOGWARNING, "%s - failed to find add-on %s, disabling it", __FUNCTION__, clientAddon->Name().c_str());
disableAddons.push_back(clientAddon);
bDisabled = true;
}
}
// throttle connection attempts, no more than 1 attempt per 5 seconds
if (!bDisabled && addon->Enabled())
{
time_t now;
CDateTime::GetCurrentDateTime().GetAsTime(now);
std::map<int, time_t>::iterator it = m_connectionAttempts.find(iClientId);
if (it != m_connectionAttempts.end() && now < it->second)
continue;
m_connectionAttempts[iClientId] = now + 5;
}
// re-check the enabled status. newly installed clients get disabled when they're added to the db
if (!bDisabled && addon->Enabled() && (status = addon->Create(iClientId)) != ADDON_STATUS_OK)
{
CLog::Log(LOGWARNING, "%s - failed to create add-on %s, status = %d", __FUNCTION__, clientAddon->Name().c_str(), status);
if (!addon.get() || !addon->DllLoaded() || status == ADDON_STATUS_PERMANENT_FAILURE)
{
// failed to load the dll of this add-on, disable it
CLog::Log(LOGWARNING, "%s - failed to load the dll for add-on %s, disabling it", __FUNCTION__, clientAddon->Name().c_str());
disableAddons.push_back(clientAddon);
bDisabled = true;
}
}
}
if (bDisabled && (g_PVRManager.GetState() == ManagerStateStarted || g_PVRManager.GetState() == ManagerStateStarting))
CGUIDialogOK::ShowAndGetInput(24070, 24071, 16029, 0);
}
}
// disable add-ons that failed to initialise
if (disableAddons.size() > 0)
{
CSingleLock lock(m_critSection);
for (ADDON::VECADDONS::iterator it = disableAddons.begin(); it != disableAddons.end(); it++)
{
// disable in the add-on db
m_addonDb.DisableAddon((*it)->ID(), true);
// remove from the pvr add-on list
ADDON::VECADDONS::iterator addonPtr = std::find(m_addons.begin(), m_addons.end(), *it);
if (addonPtr != m_addons.end())
m_addons.erase(addonPtr);
}
//.........这里部分代码省略.........
示例4: execute
bool CPythonInvoker::execute(const std::string &script, const std::vector<std::string> &arguments)
{
// copy the code/script into a local string buffer
m_sourceFile = script;
// copy the arguments into a local buffer
m_argc = arguments.size();
m_argv = new char*[m_argc];
for (unsigned int i = 0; i < m_argc; i++)
{
m_argv[i] = new char[arguments.at(i).length() + 1];
strcpy(m_argv[i], arguments.at(i).c_str());
}
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): start processing", GetId(), m_sourceFile.c_str());
int m_Py_file_input = Py_file_input;
// get the global lock
PyEval_AcquireLock();
PyThreadState* state = Py_NewInterpreter();
if (state == NULL)
{
PyEval_ReleaseLock();
CLog::Log(LOGERROR, "CPythonInvoker(%d, %s): FAILED to get thread state!", GetId(), m_sourceFile.c_str());
return false;
}
// swap in my thread state
PyThreadState_Swap(state);
XBMCAddon::AddonClass::Ref<XBMCAddon::Python::PythonLanguageHook> languageHook(new XBMCAddon::Python::PythonLanguageHook(state->interp));
languageHook->RegisterMe();
onInitialization();
setState(InvokerStateInitialized);
std::string realFilename(CSpecialProtocol::TranslatePath(m_sourceFile));
if (realFilename == m_sourceFile)
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): the source file to load is \"%s\"", GetId(), m_sourceFile.c_str(), m_sourceFile.c_str());
else
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): the source file to load is \"%s\" (\"%s\")", GetId(), m_sourceFile.c_str(), m_sourceFile.c_str(), realFilename.c_str());
// get path from script file name and add python path's
// this is used for python so it will search modules from script path first
std::string scriptDir = URIUtils::GetDirectory(realFilename);
URIUtils::RemoveSlashAtEnd(scriptDir);
addPath(scriptDir);
// add all addon module dependecies to path
if (m_addon)
{
std::set<std::string> paths;
getAddonModuleDeps(m_addon, paths);
for (std::set<std::string>::const_iterator it = paths.begin(); it != paths.end(); ++it)
addPath(*it);
}
else
{ // for backwards compatibility.
// we don't have any addon so just add all addon modules installed
CLog::Log(LOGWARNING, "CPythonInvoker(%d): Script invoked without an addon. Adding all addon "
"modules installed to python path as fallback. This behaviour will be removed in future "
"version.", GetId());
ADDON::VECADDONS addons;
ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_SCRIPT_MODULE, addons);
for (unsigned int i = 0; i < addons.size(); ++i)
addPath(CSpecialProtocol::TranslatePath(addons[i]->LibPath()));
}
// we want to use sys.path so it includes site-packages
// if this fails, default to using Py_GetPath
PyObject *sysMod(PyImport_ImportModule((char*)"sys")); // must call Py_DECREF when finished
PyObject *sysModDict(PyModule_GetDict(sysMod)); // borrowed ref, no need to delete
PyObject *pathObj(PyDict_GetItemString(sysModDict, "path")); // borrowed ref, no need to delete
if (pathObj != NULL && PyList_Check(pathObj))
{
for (int i = 0; i < PyList_Size(pathObj); i++)
{
PyObject *e = PyList_GetItem(pathObj, i); // borrowed ref, no need to delete
if (e != NULL && PyString_Check(e))
addNativePath(PyString_AsString(e)); // returns internal data, don't delete or modify
}
}
else
addNativePath(Py_GetPath());
Py_DECREF(sysMod); // release ref to sysMod
// set current directory and python's path.
if (m_argv != NULL)
PySys_SetArgv(m_argc, m_argv);
#ifdef TARGET_WINDOWS
std::string pyPathUtf8;
g_charsetConverter.systemToUtf8(m_pythonPath, pyPathUtf8, false);
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): setting the Python path to %s", GetId(), m_sourceFile.c_str(), pyPathUtf8.c_str());
#else // ! TARGET_WINDOWS
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): setting the Python path to %s", GetId(), m_sourceFile.c_str(), m_pythonPath.c_str());
#endif // ! TARGET_WINDOWS
PySys_SetPath((char *)m_pythonPath.c_str());
//.........这里部分代码省略.........
示例5: CreateInputStream
CDVDInputStream* CDVDFactoryInputStream::CreateInputStream(IVideoPlayer* pPlayer, const CFileItem &fileitem, bool scanforextaudio)
{
std::string file = fileitem.GetPath();
if (scanforextaudio)
{
// find any available external audio tracks
std::vector<std::string> filenames;
filenames.push_back(file);
CUtil::ScanForExternalAudio(file, filenames);
CUtil::ScanForExternalDemuxSub(file, filenames);
if (filenames.size() >= 2)
{
return CreateInputStream(pPlayer, fileitem, filenames);
}
}
ADDON::VECADDONS addons;
ADDON::CBinaryAddonCache &addonCache = CServiceBroker::GetBinaryAddonCache();
addonCache.GetAddons(addons, ADDON::ADDON_INPUTSTREAM);
for (size_t i=0; i<addons.size(); ++i)
{
std::shared_ptr<ADDON::CInputStream> input(std::static_pointer_cast<ADDON::CInputStream>(addons[i]));
if (input->Supports(fileitem))
{
std::shared_ptr<ADDON::CInputStream> addon = input;
if (!input->UseParent())
addon = std::shared_ptr<ADDON::CInputStream>(new ADDON::CInputStream(*input));
ADDON_STATUS status = addon->Create();
if (status == ADDON_STATUS_OK)
{
unsigned int videoWidth, videoHeight;
pPlayer->GetVideoResolution(videoWidth, videoHeight);
addon->SetVideoResolution(videoWidth, videoHeight);
return new CInputStreamAddon(fileitem, addon);
}
}
}
if (fileitem.IsDiscImage())
{
#ifdef HAVE_LIBBLURAY
CURL url("udf://");
url.SetHostName(file);
url.SetFileName("BDMV/index.bdmv");
if(XFILE::CFile::Exists(url.Get()))
return new CDVDInputStreamBluray(pPlayer, fileitem);
#endif
return new CDVDInputStreamNavigator(pPlayer, fileitem);
}
#ifdef HAS_DVD_DRIVE
if(file.compare(g_mediaManager.TranslateDevicePath("")) == 0)
{
#ifdef HAVE_LIBBLURAY
if(XFILE::CFile::Exists(URIUtils::AddFileToFolder(file, "BDMV/index.bdmv")))
return new CDVDInputStreamBluray(pPlayer, fileitem);
#endif
return new CDVDInputStreamNavigator(pPlayer, fileitem);
}
#endif
if (fileitem.IsDVDFile(false, true))
return (new CDVDInputStreamNavigator(pPlayer, fileitem));
else if(file.substr(0, 6) == "pvr://")
return new CDVDInputStreamPVRManager(pPlayer, fileitem);
#ifdef HAVE_LIBBLURAY
else if (fileitem.IsType(".bdmv") || fileitem.IsType(".mpls") || file.substr(0, 7) == "bluray:")
return new CDVDInputStreamBluray(pPlayer, fileitem);
#endif
else if(file.substr(0, 6) == "rtp://"
|| file.substr(0, 7) == "rtsp://"
|| file.substr(0, 6) == "sdp://"
|| file.substr(0, 6) == "udp://"
|| file.substr(0, 6) == "tcp://"
|| file.substr(0, 6) == "mms://"
|| file.substr(0, 7) == "mmst://"
|| file.substr(0, 7) == "mmsh://")
return new CDVDInputStreamFFmpeg(fileitem);
#ifdef ENABLE_DVDINPUTSTREAM_STACK
else if(file.substr(0, 8) == "stack://")
return new CDVDInputStreamStack(fileitem);
#endif
else if (fileitem.IsInternetStream())
{
if (fileitem.IsType(".m3u8"))
return new CDVDInputStreamFFmpeg(fileitem);
if (fileitem.GetMimeType() == "application/vnd.apple.mpegurl")
return new CDVDInputStreamFFmpeg(fileitem);
}
// our file interface handles all these types of streams
return (new CDVDInputStreamFile(fileitem));
}
示例6: GetBool
//.........这里部分代码省略.........
case SYSTEM_TRAYOPEN:
value = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
return true;
#endif
case SYSTEM_CAN_POWERDOWN:
value = CServiceBroker::GetPowerManager().CanPowerdown();
return true;
case SYSTEM_CAN_SUSPEND:
value = CServiceBroker::GetPowerManager().CanSuspend();
return true;
case SYSTEM_CAN_HIBERNATE:
value = CServiceBroker::GetPowerManager().CanHibernate();
return true;
case SYSTEM_CAN_REBOOT:
value = CServiceBroker::GetPowerManager().CanReboot();
return true;
case SYSTEM_SCREENSAVER_ACTIVE:
value = g_application.IsInScreenSaver();
return true;
case SYSTEM_DPMS_ACTIVE:
value = g_application.IsDPMSActive();
return true;
case SYSTEM_HASLOCKS:
value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
return true;
case SYSTEM_HAS_PVR:
value = true;
return true;
case SYSTEM_HAS_PVR_ADDON:
{
ADDON::VECADDONS pvrAddons;
ADDON::CBinaryAddonCache &addonCache = CServiceBroker::GetBinaryAddonCache();
addonCache.GetAddons(pvrAddons, ADDON::ADDON_PVRDLL);
value = (pvrAddons.size() > 0);
return true;
}
case SYSTEM_HAS_CMS:
#if defined(HAS_GL) || defined(HAS_DX)
value = true;
#else
value = false;
#endif
return true;
case SYSTEM_ISMASTER:
value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
return true;
case SYSTEM_ISFULLSCREEN:
value = CServiceBroker::GetWinSystem()->IsFullScreen();
return true;
case SYSTEM_ISSTANDALONE:
value = g_application.IsStandAlone();
return true;
case SYSTEM_ISINHIBIT:
value = g_application.IsIdleShutdownInhibited();
return true;
case SYSTEM_HAS_SHUTDOWN:
value = (CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNTIME) > 0);
return true;
case SYSTEM_LOGGEDON:
value = !(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_LOGIN_SCREEN);
return true;
case SYSTEM_SHOW_EXIT_BUTTON:
value = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_showExitButton;
return true;
case SYSTEM_HAS_LOGINSCREEN:
value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->UsingLoginScreen();
示例7: Process
void XBPyThread::Process()
{
CLog::Log(LOGDEBUG,"Python thread: start processing");
int m_Py_file_input = Py_file_input;
// get the global lock
PyEval_AcquireLock();
PyThreadState* state = Py_NewInterpreter();
if (!state)
{
PyEval_ReleaseLock();
CLog::Log(LOGERROR,"Python thread: FAILED to get thread state!");
return;
}
// swap in my thread state
PyThreadState_Swap(state);
XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> languageHook(new XBMCAddon::Python::LanguageHook(state->interp));
languageHook->RegisterMe();
m_pExecuter->InitializeInterpreter(addon);
CLog::Log(LOGDEBUG, "%s - The source file to load is %s", __FUNCTION__, m_source);
// get path from script file name and add python path's
// this is used for python so it will search modules from script path first
CStdString scriptDir;
URIUtils::GetDirectory(CSpecialProtocol::TranslatePath(m_source), scriptDir);
URIUtils::RemoveSlashAtEnd(scriptDir);
CStdString path = scriptDir;
// add on any addon modules the user has installed
ADDON::VECADDONS addons;
ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_SCRIPT_MODULE, addons);
for (unsigned int i = 0; i < addons.size(); ++i)
#ifdef TARGET_WINDOWS
{
CStdString strTmp(CSpecialProtocol::TranslatePath(addons[i]->LibPath()));
g_charsetConverter.utf8ToSystem(strTmp);
path += PY_PATH_SEP + strTmp;
}
#else
path += PY_PATH_SEP + CSpecialProtocol::TranslatePath(addons[i]->LibPath());
#endif
// and add on whatever our default path is
path += PY_PATH_SEP;
// we want to use sys.path so it includes site-packages
// if this fails, default to using Py_GetPath
PyObject *sysMod(PyImport_ImportModule((char*)"sys")); // must call Py_DECREF when finished
PyObject *sysModDict(PyModule_GetDict(sysMod)); // borrowed ref, no need to delete
PyObject *pathObj(PyDict_GetItemString(sysModDict, "path")); // borrowed ref, no need to delete
if( pathObj && PyList_Check(pathObj) )
{
for( int i = 0; i < PyList_Size(pathObj); i++ )
{
PyObject *e = PyList_GetItem(pathObj, i); // borrowed ref, no need to delete
if( e && PyString_Check(e) )
{
path += PyString_AsString(e); // returns internal data, don't delete or modify
path += PY_PATH_SEP;
}
}
}
else
{
path += Py_GetPath();
}
Py_DECREF(sysMod); // release ref to sysMod
// set current directory and python's path.
if (m_argv != NULL)
PySys_SetArgv(m_argc, m_argv);
CLog::Log(LOGDEBUG, "%s - Setting the Python path to %s", __FUNCTION__, path.c_str());
PySys_SetPath((char *)path.c_str());
CLog::Log(LOGDEBUG, "%s - Entering source directory %s", __FUNCTION__, scriptDir.c_str());
PyObject* module = PyImport_AddModule((char*)"__main__");
PyObject* moduleDict = PyModule_GetDict(module);
// when we are done initing we store thread state so we can be aborted
PyThreadState_Swap(NULL);
PyEval_ReleaseLock();
// we need to check if we was asked to abort before we had inited
bool stopping = false;
{ CSingleLock lock(m_pExecuter->m_critSection);
m_threadState = state;
stopping = m_stopping;
}
PyEval_AcquireLock();
PyThreadState_Swap(state);
//.........这里部分代码省略.........
示例8: UpdateAndInitialiseClients
bool CPVRClients::UpdateAndInitialiseClients(bool bInitialiseAllClients /* = false */)
{
bool bReturn(true);
ADDON::VECADDONS map;
ADDON::VECADDONS disableAddons;
{
CSingleLock lock(m_critSection);
map = m_addons;
}
if (map.size() == 0)
return false;
for (unsigned iClientPtr = 0; iClientPtr < map.size(); iClientPtr++)
{
const AddonPtr clientAddon = map.at(iClientPtr);
bool bEnabled = clientAddon->Enabled() &&
!m_addonDb.IsAddonDisabled(clientAddon->ID());
if (!bEnabled && IsKnownClient(clientAddon))
{
CSingleLock lock(m_critSection);
/* stop the client and remove it from the db */
StopClient(clientAddon, false);
ADDON::VECADDONS::iterator addonPtr = std::find(m_addons.begin(), m_addons.end(), clientAddon);
if (addonPtr != m_addons.end())
m_addons.erase(addonPtr);
}
else if (bEnabled && (bInitialiseAllClients || !IsKnownClient(clientAddon) || !IsConnectedClient(clientAddon)))
{
bool bDisabled(false);
// register the add-on in the pvr db, and create the CPVRClient instance
int iClientId = RegisterClient(clientAddon);
if (iClientId < 0)
{
// failed to register or create the add-on, disable it
CLog::Log(LOGWARNING, "%s - failed to register add-on %s, disabling it", __FUNCTION__, clientAddon->Name().c_str());
disableAddons.push_back(clientAddon);
bDisabled = true;
}
else
{
PVR_CLIENT addon;
if (!GetClient(iClientId, addon))
{
CLog::Log(LOGWARNING, "%s - failed to find add-on %s, disabling it", __FUNCTION__, clientAddon->Name().c_str());
disableAddons.push_back(clientAddon);
bDisabled = true;
}
// re-check the enabled status. newly installed clients get disabled when they're added to the db
else if (addon->Enabled() && !addon->Create(iClientId))
{
CLog::Log(LOGWARNING, "%s - failed to create add-on %s", __FUNCTION__, clientAddon->Name().c_str());
if (!addon.get() || !addon->DllLoaded())
{
// failed to load the dll of this add-on, disable it
CLog::Log(LOGWARNING, "%s - failed to load the dll for add-on %s, disabling it", __FUNCTION__, clientAddon->Name().c_str());
disableAddons.push_back(clientAddon);
bDisabled = true;
}
}
}
if (bDisabled && (g_PVRManager.GetState() == ManagerStateStarted || g_PVRManager.GetState() == ManagerStateStarting))
CGUIDialogOK::ShowAndGetInput(24070, 24071, 16029, 0);
}
}
// disable add-ons that failed to initialise
if (disableAddons.size() > 0)
{
CSingleLock lock(m_critSection);
for (ADDON::VECADDONS::iterator it = disableAddons.begin(); it != disableAddons.end(); it++)
{
// disable in the add-on db
m_addonDb.DisableAddon((*it)->ID(), true);
// remove from the pvr add-on list
ADDON::VECADDONS::iterator addonPtr = std::find(m_addons.begin(), m_addons.end(), *it);
if (addonPtr != m_addons.end())
m_addons.erase(addonPtr);
}
}
return bReturn;
}
示例9: execute
bool CPythonInvoker::execute(const std::string &script, const std::vector<std::string> &arguments)
{
// copy the code/script into a local string buffer
#ifdef TARGET_WINDOWS
CStdString strsrc = script;
g_charsetConverter.utf8ToSystem(strsrc);
m_source = new char[strsrc.length() + 1];
strcpy(m_source, strsrc);
#else
m_source = new char[script.length() + 1];
strcpy(m_source, script.c_str());
#endif
// copy the arguments into a local buffer
m_argc = arguments.size();
m_argv = new char*[m_argc];
for (unsigned int i = 0; i < m_argc; i++)
{
m_argv[i] = new char[arguments.at(i).length() + 1];
strcpy(m_argv[i], arguments.at(i).c_str());
}
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): start processing", GetId(), m_source);
int m_Py_file_input = Py_file_input;
// get the global lock
PyEval_AcquireLock();
PyThreadState* state = Py_NewInterpreter();
if (state == NULL)
{
PyEval_ReleaseLock();
CLog::Log(LOGERROR, "CPythonInvoker(%d, %s): FAILED to get thread state!", GetId(), m_source);
return false;
}
// swap in my thread state
PyThreadState_Swap(state);
XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> languageHook(new XBMCAddon::Python::LanguageHook(state->interp));
languageHook->RegisterMe();
g_pythonParser.InitializeInterpreter(m_addon);
setState(InvokerStateInitialized);
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): the source file to load is %s", GetId(), m_source, m_source);
// get path from script file name and add python path's
// this is used for python so it will search modules from script path first
CStdString scriptDir;
URIUtils::GetDirectory(CSpecialProtocol::TranslatePath(m_source), scriptDir);
URIUtils::RemoveSlashAtEnd(scriptDir);
addPath(scriptDir);
// add on any addon modules the user has installed
ADDON::VECADDONS addons;
ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_SCRIPT_MODULE, addons);
for (unsigned int i = 0; i < addons.size(); ++i)
addPath(CSpecialProtocol::TranslatePath(addons[i]->LibPath()));
// we want to use sys.path so it includes site-packages
// if this fails, default to using Py_GetPath
PyObject *sysMod(PyImport_ImportModule((char*)"sys")); // must call Py_DECREF when finished
PyObject *sysModDict(PyModule_GetDict(sysMod)); // borrowed ref, no need to delete
PyObject *pathObj(PyDict_GetItemString(sysModDict, "path")); // borrowed ref, no need to delete
if (pathObj != NULL && PyList_Check(pathObj))
{
for (int i = 0; i < PyList_Size(pathObj); i++)
{
PyObject *e = PyList_GetItem(pathObj, i); // borrowed ref, no need to delete
if (e != NULL && PyString_Check(e))
addPath(PyString_AsString(e)); // returns internal data, don't delete or modify
}
}
else
addPath(Py_GetPath());
Py_DECREF(sysMod); // release ref to sysMod
// set current directory and python's path.
if (m_argv != NULL)
PySys_SetArgv(m_argc, m_argv);
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): setting the Python path to %s", GetId(), m_source, m_pythonPath.c_str());
PySys_SetPath((char *)m_pythonPath.c_str());
CLog::Log(LOGDEBUG, "CPythonInvoker(%d, %s): entering source directory %s", GetId(), m_source, scriptDir.c_str());
PyObject* module = PyImport_AddModule((char*)"__main__");
PyObject* moduleDict = PyModule_GetDict(module);
// when we are done initing we store thread state so we can be aborted
PyThreadState_Swap(NULL);
PyEval_ReleaseLock();
// we need to check if we was asked to abort before we had inited
bool stopping = false;
{ CSingleLock lock(m_critical);
m_threadState = state;
stopping = m_stop;
}
//.........这里部分代码省略.........
示例10: Process
void XBPyThread::Process()
{
CLog::Log(LOGDEBUG,"Python thread: start processing");
int m_Py_file_input = Py_file_input;
// get the global lock
PyEval_AcquireLock();
PyThreadState* state = Py_NewInterpreter();
if (!state)
{
PyEval_ReleaseLock();
CLog::Log(LOGERROR,"Python thread: FAILED to get thread state!");
return;
}
// swap in my thread state
PyThreadState_Swap(state);
m_pExecuter->InitializeInterpreter();
CLog::Log(LOGDEBUG, "%s - The source file to load is %s", __FUNCTION__, m_source);
// get path from script file name and add python path's
// this is used for python so it will search modules from script path first
CStdString scriptDir;
URIUtils::GetDirectory(_P(m_source), scriptDir);
URIUtils::RemoveSlashAtEnd(scriptDir);
CStdString path = scriptDir;
// add on any addon modules the user has installed
ADDON::VECADDONS addons;
ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_SCRIPT_MODULE, addons);
for (unsigned int i = 0; i < addons.size(); ++i)
path += PY_PATH_SEP + _P(addons[i]->LibPath());
// and add on whatever our default path is
path += PY_PATH_SEP;
{
// we want to use sys.path so it includes site-packages
// if this fails, default to using Py_GetPath
PyObject *sysMod(PyImport_ImportModule((char*)"sys")); // must call Py_DECREF when finished
PyObject *sysModDict(PyModule_GetDict(sysMod)); // borrowed ref, no need to delete
PyObject *pathObj(PyDict_GetItemString(sysModDict, "path")); // borrowed ref, no need to delete
if( pathObj && PyList_Check(pathObj) )
{
for( int i = 0; i < PyList_Size(pathObj); i++ )
{
PyObject *e = PyList_GetItem(pathObj, i); // borrowed ref, no need to delete
if( e && PyString_Check(e) )
{
path += PyString_AsString(e); // returns internal data, don't delete or modify
path += PY_PATH_SEP;
}
}
}
else
{
path += Py_GetPath();
}
Py_DECREF(sysMod); // release ref to sysMod
}
// set current directory and python's path.
if (m_argv != NULL)
PySys_SetArgv(m_argc, m_argv);
CLog::Log(LOGDEBUG, "%s - Setting the Python path to %s", __FUNCTION__, path.c_str());
PySys_SetPath((char *)path.c_str());
CLog::Log(LOGDEBUG, "%s - Entering source directory %s", __FUNCTION__, scriptDir.c_str());
PyObject* module = PyImport_AddModule((char*)"__main__");
PyObject* moduleDict = PyModule_GetDict(module);
// when we are done initing we store thread state so we can be aborted
PyThreadState_Swap(NULL);
PyEval_ReleaseLock();
// we need to check if we was asked to abort before we had inited
bool stopping = false;
{ CSingleLock lock(m_pExecuter->m_critSection);
m_threadState = state;
stopping = m_stopping;
}
PyEval_AcquireLock();
PyThreadState_Swap(state);
if (!stopping)
{
if (m_type == 'F')
{
// run script from file
// We need to have python open the file because on Windows the DLL that python
// is linked against may not be the DLL that xbmc is linked against so
// passing a FILE* to python from an fopen has the potential to crash.
PyObject* file = PyFile_FromString((char *) _P(m_source).c_str(), (char*)"r");
//.........这里部分代码省略.........
示例11: CreateInputStream
CDVDInputStream* CDVDFactoryInputStream::CreateInputStream(IVideoPlayer* pPlayer, CFileItem fileitem)
{
std::string file = fileitem.GetPath();
ADDON::VECADDONS addons;
ADDON::CAddonMgr::GetInstance().GetAddons(addons, ADDON::ADDON_INPUTSTREAM);
for (size_t i=0; i<addons.size(); ++i)
{
std::shared_ptr<ADDON::CInputStream> input(std::static_pointer_cast<ADDON::CInputStream>(addons[i]));
ADDON::CInputStream* clone = new ADDON::CInputStream(*input);
ADDON_STATUS status = clone->Supports(fileitem) ? clone->Create() : ADDON_STATUS_PERMANENT_FAILURE;
if (status == ADDON_STATUS_OK)
{
if (clone->Supports(fileitem))
{
return new CInputStreamAddon(fileitem, clone);
}
}
delete clone;
}
if (fileitem.IsDiscImage())
{
#ifdef HAVE_LIBBLURAY
CURL url("udf://");
url.SetHostName(file);
url.SetFileName("BDMV/index.bdmv");
if(XFILE::CFile::Exists(url.Get()))
return new CDVDInputStreamBluray(pPlayer, fileitem);
#endif
return new CDVDInputStreamNavigator(pPlayer, fileitem);
}
#ifdef HAS_DVD_DRIVE
if(file.compare(g_mediaManager.TranslateDevicePath("")) == 0)
{
#ifdef HAVE_LIBBLURAY
if(XFILE::CFile::Exists(URIUtils::AddFileToFolder(file, "BDMV/index.bdmv")))
return new CDVDInputStreamBluray(pPlayer, fileitem);
#endif
return new CDVDInputStreamNavigator(pPlayer, fileitem);
}
#endif
if (fileitem.IsDVDFile(false, true))
return (new CDVDInputStreamNavigator(pPlayer, fileitem));
else if(file.substr(0, 6) == "pvr://")
return new CDVDInputStreamPVRManager(pPlayer, fileitem);
#ifdef HAVE_LIBBLURAY
else if (fileitem.IsType(".bdmv") || fileitem.IsType(".mpls") || file.substr(0, 7) == "bluray:")
return new CDVDInputStreamBluray(pPlayer, fileitem);
#endif
else if(file.substr(0, 6) == "rtp://"
|| file.substr(0, 7) == "rtsp://"
|| file.substr(0, 6) == "sdp://"
|| file.substr(0, 6) == "udp://"
|| file.substr(0, 6) == "tcp://"
|| file.substr(0, 6) == "mms://"
|| file.substr(0, 7) == "mmst://"
|| file.substr(0, 7) == "mmsh://")
return new CDVDInputStreamFFmpeg(fileitem);
#ifdef ENABLE_DVDINPUTSTREAM_STACK
else if(file.substr(0, 8) == "stack://")
return new CDVDInputStreamStack(fileitem);
#endif
#ifdef HAS_LIBRTMP
else if(file.substr(0, 7) == "rtmp://"
|| file.substr(0, 8) == "rtmpt://"
|| file.substr(0, 8) == "rtmpe://"
|| file.substr(0, 9) == "rtmpte://"
|| file.substr(0, 8) == "rtmps://")
return new CDVDInputStreamRTMP(fileitem);
#endif
else if (fileitem.IsInternetStream())
{
if (fileitem.IsType(".m3u8"))
return new CDVDInputStreamFFmpeg(fileitem);
if (fileitem.ContentLookup())
{
// request header
fileitem.SetMimeType("");
fileitem.FillInMimeType();
}
if (fileitem.GetMimeType() == "application/vnd.apple.mpegurl")
return new CDVDInputStreamFFmpeg(fileitem);
}
// our file interface handles all these types of streams
return (new CDVDInputStreamFile(fileitem));
}