本文整理汇总了C++中addon::VECADDONS类的典型用法代码示例。如果您正苦于以下问题:C++ VECADDONS类的具体用法?C++ VECADDONS怎么用?C++ VECADDONS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VECADDONS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: HandleRequest
int CHTTPWebinterfaceAddonsHandler::HandleRequest()
{
m_responseData = ADDON_HEADER;
ADDON::VECADDONS addons;
if (!ADDON::CAddonMgr::GetInstance().GetAddons(addons, ADDON::ADDON_WEB_INTERFACE) || addons.empty())
{
m_response.type = HTTPError;
m_response.status = MHD_HTTP_INTERNAL_SERVER_ERROR;
return MHD_YES;
}
for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon)
m_responseData += "<li><a href=/addons/" + (*addon)->ID() + "/>" + (*addon)->Name() + "</a></li>\n";
m_responseData += "</ul>\n</body></html>";
m_responseRange.SetData(m_responseData.c_str(), m_responseData.size());
m_response.type = HTTPMemoryDownloadNoFreeCopy;
m_response.status = MHD_HTTP_OK;
m_response.contentType = "text/html";
m_response.totalLength = m_responseData.size();
return MHD_YES;
}
开发者ID:Razzeee,项目名称:xbmc,代码行数:26,代码来源:HTTPWebinterfaceAddonsHandler.cpp
示例2: CreateTables
void CActiveAEDSPDatabase::CreateTables()
{
BeginTransaction();
CLog::Log(LOGINFO, "Audio DSP - %s - creating tables", __FUNCTION__);
CLog::Log(LOGDEBUG, "Audio DSP - %s - creating table 'addons'", __FUNCTION__);
m_pDS->exec(
"CREATE TABLE addons ("
"idAddon integer primary key, "
"sName varchar(64), "
"sUid varchar(32)"
")"
);
CLog::Log(LOGDEBUG, "Audio DSP - %s - creating table 'modes'", __FUNCTION__);
m_pDS->exec(
"CREATE TABLE modes ("
"idMode integer primary key, "
"iType integer, "
"iPosition integer, "
"iStreamTypeFlags integer, "
"iBaseType integer, "
"bIsEnabled bool, "
"sOwnIconPath varchar(255), "
"sOverrideIconPath varchar(255), "
"iModeName integer, "
"iModeSetupName integer, "
"iModeHelp integer, "
"iModeDescription integer, "
"sAddonModeName varchar(64), "
"iAddonId integer, "
"iAddonModeNumber integer, "
"bHasSettings bool"
")"
);
CLog::Log(LOGDEBUG, "Audio DSP - %s - create settings table", __FUNCTION__);
m_pDS->exec(
"CREATE TABLE settings ("
"id integer primary key, "
"strPath varchar(255), "
"strFileName varchar(255), "
"MasterStreamTypeSel integer, "
"MasterStreamType integer, "
"MasterBaseType integer, "
"MasterModeId integer"
")"
);
// disable all Audio DSP add-on when started the first time
ADDON::VECADDONS addons;
if (CAddonMgr::Get().GetAddons(ADDON_ADSPDLL, addons, true))
CLog::Log(LOGERROR, "Audio DSP - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
{
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
CAddonMgr::Get().DisableAddon(it->get()->ID());
}
}
开发者ID:gellis12,项目名称:xbmc,代码行数:59,代码来源:ActiveAEDSPDatabase.cpp
示例3: UpdateTables
void CPVRDatabase::UpdateTables(int iVersion)
{
if (iVersion < 13)
m_pDS->exec("ALTER TABLE channels ADD idEpg integer;");
if (iVersion < 14)
m_pDS->exec("ALTER TABLE channelsettings ADD fCustomVerticalShift float;");
if (iVersion < 15)
{
m_pDS->exec("ALTER TABLE channelsettings ADD bCustomNonLinStretch bool;");
m_pDS->exec("ALTER TABLE channelsettings ADD bPostProcess bool;");
m_pDS->exec("ALTER TABLE channelsettings ADD iScalingMethod integer;");
}
if (iVersion < 16)
{
/* sqlite apparently can't delete columns from an existing table, so just leave the extra column alone */
}
if (iVersion < 17)
{
m_pDS->exec("ALTER TABLE channelsettings ADD iDeinterlaceMode integer");
m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 2 WHERE iInterlaceMethod NOT IN (0,1)"); // anything other than none: method auto => mode force
m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 1 WHERE iInterlaceMethod = 1"); // method auto => mode auto
m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 0, iInterlaceMethod = 1 WHERE iInterlaceMethod = 0"); // method none => mode off, method auto
}
if (iVersion < 19)
{
// bit of a hack, but we need to keep the version/contents of the non-pvr databases the same to allow clean upgrades
ADDON::VECADDONS addons;
if (!CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true))
CLog::Log(LOGERROR, "PVR - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
{
CAddonDatabase database;
database.Open();
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
{
if (!database.IsSystemPVRAddonEnabled(it->get()->ID()))
CAddonMgr::Get().DisableAddon(it->get()->ID());
}
database.Close();
}
}
if (iVersion < 20)
m_pDS->exec("ALTER TABLE channels ADD bIsUserSetIcon bool");
if (iVersion < 21)
m_pDS->exec("ALTER TABLE channelgroups ADD iGroupType integer");
if (iVersion < 22)
m_pDS->exec("ALTER TABLE channels ADD bIsLocked bool");
if (iVersion < 23)
m_pDS->exec("ALTER TABLE channelgroups ADD iLastWatched integer");
}
开发者ID:lorem-ipsum,项目名称:xbmc,代码行数:55,代码来源:PVRDatabase.cpp
示例4: SettingOptionsLanguageNamesFiller
void CLangInfo::SettingOptionsLanguageNamesFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t, void *data)
{
// find languages...
ADDON::VECADDONS addons;
if (!ADDON::CAddonMgr::GetInstance().GetAddons(ADDON::ADDON_RESOURCE_LANGUAGE, addons, true))
return;
for (ADDON::VECADDONS::const_iterator addon = addons.begin(); addon != addons.end(); ++addon)
list.push_back(make_pair((*addon)->Name(), (*addon)->Name()));
sort(list.begin(), list.end(), SortLanguage());
}
开发者ID:roguesupport,项目名称:xbmc,代码行数:12,代码来源:LangInfo.cpp
示例5:
std::set<std::string> CGUIControllerList::GetNewControllerIDs(ADDON::VECADDONS& addonCache) const
{
std::set<std::string> controllerIds;
CAddonMgr::GetInstance().GetAddons(addonCache, ADDON_GAME_CONTROLLER);
std::transform(addonCache.begin(), addonCache.end(), std::inserter(controllerIds, controllerIds.end()),
[](const AddonPtr& addon)
{
return addon->ID();
});
return controllerIds;
}
开发者ID:Almarefa,项目名称:xbmc,代码行数:14,代码来源:GUIControllerList.cpp
示例6: RegisterController
void CGUIControllerList::RegisterController(const std::string& addonId, const ADDON::VECADDONS& addonCache)
{
auto it = std::find_if(addonCache.begin(), addonCache.end(),
[addonId](const AddonPtr& addon)
{
return addon->ID() == addonId;
});
if (it != addonCache.end())
{
ControllerPtr newController = std::dynamic_pointer_cast<CController>(*it);
if (newController && newController->LoadLayout())
m_controllers.push_back(newController);
}
}
开发者ID:Almarefa,项目名称:xbmc,代码行数:15,代码来源:GUIControllerList.cpp
示例7: 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;
}
开发者ID:AdolphHuan,项目名称:xbmc,代码行数:38,代码来源:PVRClients.cpp
示例8: 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;
}
开发者ID:RobertMe,项目名称:xbmc,代码行数:24,代码来源:PVRClients.cpp
示例9: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(ADDON::TYPE type, CStdStringArray &addonIDs, bool showNone /*= false*/, bool multipleSelection /*= true*/)
{
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (type == ADDON_UNKNOWN || !dialog)
return 0;
ADDON::VECADDONS addons;
if (type == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio",addons);
else if (type == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable",addons);
else if (type == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image",addons);
else if (type == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video",addons);
else
CAddonMgr::Get().GetAddons(type, addons);
CFileItemList items;
for (ADDON::IVECADDONS i = addons.begin(); i != addons.end(); ++i)
items.Add(CAddonsDirectory::FileItemFromAddon(*i, ""));
dialog->SetHeading(TranslateType(type, true));
dialog->Reset();
dialog->SetUseDetails(true);
if (multipleSelection)
{
showNone = false;
dialog->EnableButton(true, 186);
}
else
dialog->EnableButton(true, 21452);
if (showNone)
{
CFileItemPtr item(new CFileItem("", false));
item->SetLabel(g_localizeStrings.Get(231));
item->SetLabel2(g_localizeStrings.Get(24040));
item->SetIconImage("DefaultAddonNone.png");
item->SetSpecialSort(SORT_ON_TOP);
items.Add(item);
}
items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
if (addonIDs.size() > 0)
{
for (CStdStringArray::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; it++)
{
CFileItemPtr item = items.Get(*it);
if (item)
item->Select(true);
}
}
dialog->SetItems(&items);
dialog->SetMultiSelection(multipleSelection);
dialog->DoModal();
if (!multipleSelection && dialog->IsButtonPressed())
{ // switch to the addons browser.
vector<CStdString> params;
params.push_back("addons://all/"+TranslateType(type,false)+"/");
params.push_back("return");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
return 2;
}
if (!multipleSelection && dialog->GetSelectedLabel() == -1)
return 0;
addonIDs.clear();
const CFileItemList& list = dialog->GetSelectedItems();
for (int i = 0 ; i < list.Size() ; i++)
addonIDs.push_back(list.Get(i)->GetPath());
return 1;
}
开发者ID:Dolmio,项目名称:xbmc,代码行数:71,代码来源:GUIWindowAddonBrowser.cpp
示例10: UpdateOldVersion
bool CPVRDatabase::UpdateOldVersion(int iVersion)
{
bool bReturn = true;
BeginTransaction();
try
{
if (iVersion < 11)
{
CLog::Log(LOGERROR, "PVR - %s - updating from table versions < 11 not supported. please delete '%s'",
__FUNCTION__, GetBaseDBName());
bReturn = false;
}
else
{
if (iVersion < 12)
m_pDS->exec("DROP VIEW vw_last_watched;");
if (iVersion < 13)
m_pDS->exec("ALTER TABLE channels ADD idEpg integer;");
if (iVersion < 14)
m_pDS->exec("ALTER TABLE channelsettings ADD fCustomVerticalShift float;");
if (iVersion < 15)
{
m_pDS->exec("ALTER TABLE channelsettings ADD bCustomNonLinStretch bool;");
m_pDS->exec("ALTER TABLE channelsettings ADD bPostProcess bool;");
m_pDS->exec("ALTER TABLE channelsettings ADD iScalingMethod integer;");
}
if (iVersion < 16)
{
/* sqlite apparently can't delete columns from an existing table, so just leave the extra column alone */
}
if (iVersion < 17)
{
m_pDS->exec("ALTER TABLE channelsettings ADD iDeinterlaceMode integer");
m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 2 WHERE iInterlaceMethod NOT IN (0,1)"); // anything other than none: method auto => mode force
m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 1 WHERE iInterlaceMethod = 1"); // method auto => mode auto
m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 0, iInterlaceMethod = 1 WHERE iInterlaceMethod = 0"); // method none => mode off, method auto
}
if (iVersion < 18)
{
m_pDS->exec("DROP INDEX idx_channels_iClientId;");
m_pDS->exec("DROP INDEX idx_channels_iLastWatched;");
m_pDS->exec("DROP INDEX idx_channels_bIsRadio;");
m_pDS->exec("DROP INDEX idx_channels_bIsHidden;");
m_pDS->exec("DROP INDEX idx_idChannel_idGroup;");
m_pDS->exec("DROP INDEX idx_idGroup_iChannelNumber;");
m_pDS->exec("CREATE UNIQUE INDEX idx_channels_iClientId_iUniqueId on channels(iClientId, iUniqueId);");
m_pDS->exec("CREATE UNIQUE INDEX idx_idGroup_idChannel on map_channelgroups_channels(idGroup, idChannel);");
}
if (iVersion < 19)
{
// bit of a hack, but we need to keep the version/contents of the non-pvr databases the same to allow clean upgrades
ADDON::VECADDONS addons;
if ((bReturn = CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true, false)) == false)
CLog::Log(LOGERROR, "PVR - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
{
CAddonDatabase database;
database.Open();
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
{
if (!database.IsSystemPVRAddonEnabled(it->get()->ID()))
database.DisableAddon(it->get()->ID());
}
database.Close();
}
}
if (iVersion < 20)
m_pDS->exec("ALTER TABLE channels ADD bIsUserSetIcon bool");
if (iVersion < 21)
m_pDS->exec("ALTER TABLE channelgroups ADD iGroupType integer");
}
}
catch (...)
{
CLog::Log(LOGERROR, "PVR - %s - error attempting to update the database version!", __FUNCTION__);
bReturn = false;
}
if (bReturn)
CommitTransaction();
else
RollbackTransaction();
return bReturn;
}
开发者ID:Omel,项目名称:xbmc,代码行数:91,代码来源:PVRDatabase.cpp
示例11: CreateTables
//.........这里部分代码省略.........
"iUniqueId integer, "
"bIsRadio bool, "
"bIsHidden bool, "
"bIsUserSetIcon bool, "
"bIsLocked bool, "
"sIconPath varchar(255), "
"sChannelName varchar(64), "
"bIsVirtual bool, "
"bEPGEnabled bool, "
"sEPGScraper varchar(32), "
"iLastWatched integer,"
// TODO use mapping table
"iClientId integer, "
"iClientChannelNumber integer, "
"sInputFormat varchar(32), "
"sStreamURL varchar(255), "
"iEncryptionSystem integer, "
"idEpg integer"
")"
);
// TODO use a mapping table so multiple backends per channel can be implemented
// CLog::Log(LOGDEBUG, "PVR - %s - creating table 'map_channels_clients'", __FUNCTION__);
// m_pDS->exec(
// "CREATE TABLE map_channels_clients ("
// "idChannel integer primary key, "
// "idClient integer, "
// "iClientChannelNumber integer,"
// "sInputFormat string,"
// "sStreamURL string,"
// "iEncryptionSystem integer"
// ");"
// );
// m_pDS->exec("CREATE UNIQUE INDEX idx_idChannel_idClient on map_channels_clients(idChannel, idClient);");
CLog::Log(LOGDEBUG, "PVR - %s - creating table 'channelgroups'", __FUNCTION__);
m_pDS->exec(
"CREATE TABLE channelgroups ("
"idGroup integer primary key,"
"bIsRadio bool, "
"iGroupType integer, "
"sName varchar(64), "
"iLastWatched integer"
")"
);
CLog::Log(LOGDEBUG, "PVR - %s - creating table 'map_channelgroups_channels'", __FUNCTION__);
m_pDS->exec(
"CREATE TABLE map_channelgroups_channels ("
"idChannel integer, "
"idGroup integer, "
"iChannelNumber integer"
")"
);
CLog::Log(LOGDEBUG, "PVR - %s - creating table 'channelsettings'", __FUNCTION__);
m_pDS->exec(
"CREATE TABLE channelsettings ("
"idChannel integer primary key, "
"iInterlaceMethod integer, "
"iViewMode integer, "
"fCustomZoomAmount float, "
"fPixelRatio float, "
"iAudioStream integer, "
"iSubtitleStream integer,"
"fSubtitleDelay float, "
"bSubtitles bool, "
"fBrightness float, "
"fContrast float, "
"fGamma float,"
"fVolumeAmplification float, "
"fAudioDelay float, "
"bOutputToAllSpeakers bool, "
"bCrop bool, "
"iCropLeft integer, "
"iCropRight integer, "
"iCropTop integer, "
"iCropBottom integer, "
"fSharpness float, "
"fNoiseReduction float, "
"fCustomVerticalShift float, "
"bCustomNonLinStretch bool, "
"bPostProcess bool, "
"iScalingMethod integer, "
"iDeinterlaceMode integer "
")"
);
// disable all PVR add-on when started the first time
ADDON::VECADDONS addons;
if (!CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true))
CLog::Log(LOGERROR, "PVR - %s - failed to get add-ons from the add-on manager", __FUNCTION__);
else
{
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
CAddonMgr::Get().DisableAddon(it->get()->ID());
}
}
开发者ID:lorem-ipsum,项目名称:xbmc,代码行数:101,代码来源:PVRDatabase.cpp
示例12: 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");
//.........这里部分代码省略.........
开发者ID:marlboroman,项目名称:xbmc,代码行数:101,代码来源:XBPyThread.cpp
示例13: 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());
//.........这里部分代码省略.........
开发者ID:Jmend25,项目名称:boxeebox-xbmc,代码行数:101,代码来源:PythonInvoker.cpp
示例14: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStdStringArray &addonIDs, bool showNone /*= false*/, bool multipleSelection /*= true*/)
{
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog)
return 0;
CFileItemList items;
CStdString heading;
int iTypes = 0;
for (vector<ADDON::TYPE>::const_iterator it = types.begin(); it != types.end(); ++it)
{
if (*it == ADDON_UNKNOWN)
continue;
ADDON::VECADDONS addons;
iTypes++;
if (*it == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio",addons);
else if (*it == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable",addons);
else if (*it == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image",addons);
else if (*it == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video",addons);
else
CAddonMgr::Get().GetAddons(*it, addons);
for (ADDON::IVECADDONS it2 = addons.begin() ; it2 != addons.end() ; ++it2)
{
CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*it2, ""));
if (!items.Contains(item->GetPath()))
items.Add(item);
}
if (!heading.IsEmpty())
heading += ", ";
heading += TranslateType(*it, true);
}
if (iTypes == 0)
return 0;
dialog->SetHeading(heading);
dialog->Reset();
dialog->SetUseDetails(true);
if (multipleSelection)
showNone = false;
if (multipleSelection || iTypes > 1)
dialog->EnableButton(true, 186);
else
dialog->EnableButton(true, 21452);
if (showNone)
{
CFileItemPtr item(new CFileItem("", false));
item->SetLabel(g_localizeStrings.Get(231));
item->SetLabel2(g_localizeStrings.Get(24040));
item->SetIconImage("DefaultAddonNone.png");
item->SetSpecialSort(SortSpecialOnTop);
items.Add(item);
}
items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
if (addonIDs.size() > 0)
{
for (CStdStringArray::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; it++)
{
CFileItemPtr item = items.Get(*it);
if (item)
item->Select(true);
}
}
dialog->SetItems(&items);
dialog->SetMultiSelection(multipleSelection);
dialog->DoModal();
if (!multipleSelection && iTypes == 1 && dialog->IsButtonPressed())
{ // switch to the addons browser.
vector<CStdString> params;
params.push_back("addons://all/"+TranslateType(types[0],false)+"/");
params.push_back("return");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
return 2;
}
if (!dialog->IsConfirmed())
return 0;
addonIDs.clear();
const CFileItemList& list = dialog->GetSelectedItems();
for (int i = 0 ; i < list.Size() ; i++)
addonIDs.push_back(list.Get(i)->GetPath());
return 1;
}
开发者ID:cpaowner,项目名称:xbmc,代码行数:88,代码来源:GUIWindowAddonBrowser.cpp
示例15: 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));
}
开发者ID:Almarefa,项目名称:xbmc,代码行数:99,代码来源:DVDFactoryInputStream.cpp
示例16: SetLanguage
bool CLangInfo::SetLanguage(bool& fallback, const std::string &strLanguage /* = "" */, bool reloadServices /* = true */)
{
fallback = false;
std::string language = strLanguage;
if (language.empty())
{
language = CSettings::GetInstance().GetString(CSettings::SETTING_LOCALE_LANGUAGE);
if (language.empty())
{
CLog::Log(LOGFATAL, "CLangInfo: cannot load empty language.");
return false;
}
}
LanguageResourcePtr languageAddon = GetLanguageAddon(language);
if (languageAddon == NULL)
{
CLog::Log(LOGWARNING, "CLangInfo: unable to load language \"%s\". Trying to determine matching language addon...", language.c_str());
// we may have to fall back to the default language
std::string defaultLanguage = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(CSettings::SETTING_LOCALE_LANGUAGE))->GetDefault();
std::string newLanguage = defaultLanguage;
// try to determine a language addon matching the given language in name
if (!ADDON::CLanguageResource::FindLanguageAddonByName(language, newLanguage))
{
CLog::Log(LOGWARNING, "CLangInfo: unable to find an installed language addon matching \"%s\". Trying to find an installable language...", language.c_str());
bool foundMatchingAddon = false;
CAddonDatabase addondb;
if (addondb.Open())
{
// update the addon repositories to check if there's a matching language addon available for download
CAddonInstaller::GetInstance().UpdateRepos(true, true);
ADDON::VECADDONS languageAddons;
if (addondb.GetAddons(languageAddons, ADDON::ADDON_RESOURCE_LANGUAGE) && !languageAddons.empty())
{
// try to get the proper language addon by its name from all available language addons
if (ADDON::CLanguageResource::FindLanguageAddonByName(language, newLanguage, languageAddons))
{
if (CAddonInstaller::GetInstance().Install(newLanguage, true, "", false, false))
{
CLog::Log(LOGINFO, "CLangInfo: successfully installed language addon \"%s\" matching current language \"%s\"", newLanguage.c_str(), language.c_str());
foundMatchingAddon = true;
}
else
CLog::Log(LOGERROR, "CLangInfo: failed to installed language addon \"%s\" matching current language \"%s\"", newLanguage.c_str(), language.c_str());
}
else
CLog::Log(LOGERROR, "CLangInfo: unable to match old language \"%s\" to any available language addon", language.c_str());
}
else
CLog::Log(LOGERROR, "CLangInfo: no language addons available to match against \"%s\"", language.c_str());
}
else
CLog::Log(LOGERROR, "CLangInfo: unable to open addon database to look for a language addon matching \"%s\"", language.c_str());
// if the new language matches the default language we are loading the
// default language as a fallback
if (!foundMatchingAddon && newLanguage == defaultLanguage)
{
CLog::Log(LOGINFO, "CLangInfo: fall back to the default language \"%s\"", defaultLanguage.c_str());
fallback = true;
}
}
if (!CSettings::GetInstance().SetString(CSettings::SETTING_LOCALE_LANGUAGE, newLanguage))
return false;
CSettings::GetInstance().Save();
return true;
}
CLog::Log(LOGINFO, "CLangInfo: loading %s language information...", language.c_str());
if (!Load(language))
{
CLog::LogF(LOGFATAL, "CLangInfo: failed to load %s language information", language.c_str());
return false;
}
CLog::Log(LOGINFO, "CLangInfo: loading %s language strings...", language.c_str());
if (!g_localizeStrings.Load(GetLanguagePath(), language))
{
CLog::LogF(LOGFATAL, "CLangInfo: failed to load %s language strings", language.c_str());
return false;
}
if (reloadServices)
{
// also tell our weather and skin to reload as these are localized
g_weatherManager.Refresh();
g_PVRManager.LocalizationChanged();
CApplicationMessenger::GetInstance().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "ReloadSkin");
}
return true;
}
开发者ID:roguesupport,项目名称:xbmc,代码行数:100,代码来源:LangInfo.cpp
示例17: GetBool
//.........这里部分代码省略.........
case SYSTEM_DVDREADY:
value = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
return true;
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
|
请发表评论