本文整理汇总了C++中AddonPtr类的典型用法代码示例。如果您正苦于以下问题:C++ AddonPtr类的具体用法?C++ AddonPtr怎么用?C++ AddonPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AddonPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddClientToDb
int CPVRClients::AddClientToDb(const AddonPtr client)
{
/* add this client to the database if it's not in there yet */
CPVRDatabase *database = GetPVRDatabase();
int iClientDbId = database ? database->Persist(client) : -1;
if (iClientDbId <= 0)
{
CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database",
__FUNCTION__, client->Name().c_str());
}
return iClientDbId;
}
示例2: addonFolder
bool CAddonInstallJob::Install(const CStdString &installFrom)
{
CStdString addonFolder(installFrom);
URIUtils::RemoveSlashAtEnd(addonFolder);
addonFolder = URIUtils::AddFileToFolder("special://home/addons/",
URIUtils::GetFileName(addonFolder));
CFileItemList install;
install.Add(CFileItemPtr(new CFileItem(installFrom, true)));
install[0]->Select(true);
CFileOperationJob job(CFileOperationJob::ActionReplace, install, "special://home/addons/");
AddonPtr addon;
if (!job.DoWork() || !CAddonMgr::Get().LoadAddonDescription(addonFolder, addon))
{ // failed extraction or failed to load addon description
CStdString addonID = URIUtils::GetFileName(addonFolder);
ReportInstallError(addonID, addonID);
CLog::Log(LOGERROR,"Could not read addon description of %s", addonID.c_str());
DeleteAddon(addonFolder);
return false;
}
// resolve dependencies
CAddonMgr::Get().FindAddons(); // needed as GetDeps() grabs directly from c-pluff via the addon manager
ADDONDEPS deps = addon->GetDeps();
CStdString referer;
referer.Format("Referer=%s-%s.zip",addon->ID().c_str(),addon->Version().c_str());
for (ADDONDEPS::iterator it = deps.begin(); it != deps.end(); ++it)
{
if (it->first.Equals("xbmc.metadata"))
continue;
const CStdString &addonID = it->first;
const AddonVersion &version = it->second.first;
bool optional = it->second.second;
AddonPtr dependency;
bool haveAddon = CAddonMgr::Get().GetAddon(addonID, dependency);
if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
{ // we have it but our version isn't good enough, or we don't have it and we need it
bool force=(dependency != NULL);
// dependency is already queued up for install - ::Install will fail
// instead we wait until the Job has finished. note that we
// recall install on purpose in case prior installation failed
if (CAddonInstaller::Get().HasJob(addonID))
{
while (CAddonInstaller::Get().HasJob(addonID))
Sleep(50);
force = false;
}
// don't have the addon or the addon isn't new enough - grab it (no new job for these)
if (!CAddonInstaller::Get().Install(addonID, force, referer, false))
{
DeleteAddon(addonFolder);
return false;
}
}
}
return true;
}
示例3: url
bool CPluginDirectory::RunScriptWithParams(const CStdString& strPath)
{
CURL url(strPath);
if (url.GetHostName().IsEmpty()) // called with no script - should never happen
return false;
AddonPtr addon;
if (!CAddonMgr::Get().GetAddon(url.GetHostName(), addon, ADDON_PLUGIN) && !CAddonInstaller::Get().PromptForInstall(url.GetHostName(), addon))
{
CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
return false;
}
// options
CStdString options = url.GetOptions();
URIUtils::RemoveSlashAtEnd(options); // This MAY kill some scripts (eg though with a URL ending with a slash), but
// is needed for all others, as XBMC adds slashes to "folders"
url.SetOptions(""); // do this because we can then use the url to generate the basepath
// which is passed to the plugin (and represents the share)
CStdString basePath(url.Get());
// setup our parameters to send the script
CStdString strHandle;
strHandle.Format("%i", -1);
vector<string> argv;
argv.push_back(basePath);
argv.push_back(strHandle);
argv.push_back(options);
// run the script
CLog::Log(LOGDEBUG, "%s - calling plugin %s('%s','%s','%s')", __FUNCTION__, addon->Name().c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str());
if (CScriptInvocationManager::Get().Execute(addon->LibPath(), addon, argv) >= 0)
return true;
else
CLog::Log(LOGERROR, "Unable to run plugin %s", addon->Name().c_str());
return false;
}
示例4: GetContextButtons
void CGUIWindowAddonBrowser::GetContextButtons(int itemNumber,
CContextButtons& buttons)
{
CFileItemPtr pItem = m_vecItems->Get(itemNumber);
if (pItem->GetPath().Equals("addons://enabled/"))
buttons.Add(CONTEXT_BUTTON_SCAN,24034);
AddonPtr addon;
if (!CAddonMgr::Get().GetAddon(pItem->GetProperty("Addon.ID").asString(), addon, ADDON_UNKNOWN, false)) // allow disabled addons
return;
if (addon->Type() == ADDON_REPOSITORY && pItem->m_bIsFolder)
{
buttons.Add(CONTEXT_BUTTON_SCAN,24034);
buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY,24035);
}
buttons.Add(CONTEXT_BUTTON_INFO,24003);
if (addon->HasSettings())
buttons.Add(CONTEXT_BUTTON_SETTINGS,24020);
}
示例5: DoInstall
bool CAddonInstaller::DoInstall(const AddonPtr &addon, const RepositoryPtr& repo,
const std::string &hash /* = "" */, bool background /* = true */, bool modal /* = false */,
bool autoUpdate /* = false*/)
{
// check whether we already have the addon installing
CSingleLock lock(m_critSection);
if (m_downloadJobs.find(addon->ID()) != m_downloadJobs.end())
return false;
CAddonInstallJob* installJob = new CAddonInstallJob(addon, repo, hash, autoUpdate);
if (background)
{
// Workaround: because CAddonInstallJob is blocking waiting for other jobs, it needs to be run
// with priority dedicated.
unsigned int jobID = CJobManager::GetInstance().AddJob(installJob, this, CJob::PRIORITY_DEDICATED);
m_downloadJobs.insert(make_pair(addon->ID(), CDownloadJob(jobID)));
m_idle.Reset();
return true;
}
m_downloadJobs.insert(make_pair(addon->ID(), CDownloadJob(0)));
m_idle.Reset();
lock.Leave();
bool result = false;
if (modal)
result = installJob->DoModal();
else
result = installJob->DoWork();
delete installJob;
lock.Enter();
JobMap::iterator i = m_downloadJobs.find(addon->ID());
m_downloadJobs.erase(i);
if (m_downloadJobs.empty())
m_idle.Set();
return result;
}
示例6: lock
AddonPtr CBinaryAddonCache::GetAddonInstance(const std::string& strId, TYPE type)
{
AddonPtr addon;
CSingleLock lock(m_critSection);
auto it = m_addons.find(type);
if (it != m_addons.end())
{
VECADDONS& addons = it->second;
auto itAddon = std::find_if(addons.begin(), addons.end(),
[&strId](const AddonPtr& addon)
{
return addon->ID() == strId;
});
if (itAddon != addons.end())
addon = *itAddon;
}
return addon;
}
示例7: pathToUrl
bool CAddonInstaller::InstallFromZip(const std::string &path)
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return false;
// grab the descriptive XML document from the zip, and read it in
CFileItemList items;
// BUG: some zip files return a single item (root folder) that we think is stored, so we don't use the zip:// protocol
CURL pathToUrl(path);
CURL zipDir = URIUtils::CreateArchivePath("zip", pathToUrl, "");
if (!CDirectory::GetDirectory(zipDir, items) || items.Size() != 1 || !items[0]->m_bIsFolder)
{
CEventLog::GetInstance().AddWithNotification(
EventPtr(new CNotificationEvent(EventLevelError, 24045,
StringUtils::Format(g_localizeStrings.Get(24143).c_str(), path.c_str()))), false);
return false;
}
// TODO: possibly add support for github generated zips here?
std::string archive = URIUtils::AddFileToFolder(items[0]->GetPath(), "addon.xml");
CXBMCTinyXML xml;
AddonPtr addon;
if (xml.LoadFile(archive) && CAddonMgr::GetInstance().LoadAddonDescriptionFromMemory(xml.RootElement(), addon))
{
// set the correct path
addon->Props().path = items[0]->GetPath();
addon->Props().icon = URIUtils::AddFileToFolder(items[0]->GetPath(), "icon.png");
// install the addon
return DoInstall(addon);
}
CEventLog::GetInstance().AddWithNotification(
EventPtr(new CNotificationEvent(EventLevelError, 24045,
StringUtils::Format(g_localizeStrings.Get(24143).c_str(), path.c_str()))), false);
return false;
}
示例8: GetAddon
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/, bool install /*= false*/)
{
CSingleLock lock(m_critSection);
cp_status_t status;
cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
if (status == CP_OK && cpaddon)
{
addon = GetAddonFromDescriptor(cpaddon);
m_cpluff->release_info(m_cp_context, cpaddon);
if (addon.get() && enabledOnly && m_database.IsAddonDisabled(addon->ID()))
return false;
return NULL != addon.get();
}
else
{
if (install)
{
if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),
str.c_str(), g_localizeStrings.Get(24101)))
return false;
if (CAddonInstaller::Get().Install(str.c_str(), true, "", false))
{
cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
addon = GetAddonFromDescriptor(cpaddon);
m_cpluff->release_info(m_cp_context, cpaddon);
if (status == CP_OK && cpaddon)
return NULL != addon.get();
}
}
}
if (cpaddon)
m_cpluff->release_info(m_cp_context, cpaddon);
return false;
}
示例9: bReturn
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;
}
示例10: GetAudioDSPAddonId
int CActiveAEDSP::GetAudioDSPAddonId(const AddonPtr &addon) const
{
CSingleLock lock(m_critUpdateSection);
for (auto &entry : m_addonMap)
{
if (entry.second->ID() == addon->ID())
{
return entry.first;
}
}
return -1;
}
示例11: lock
bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool enabled /*= true*/)
{
CSingleLock lock(m_critSection);
for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i)
{
VECADDONS temp;
if (CAddonMgr::Get().GetAddons((TYPE)i, temp, enabled))
{
AddonPtr repoAddon;
for (unsigned int j = 0; j < temp.size(); j++)
{
if (!m_database.GetAddon(temp[j]->ID(), repoAddon))
continue;
if (temp[j]->Version() < repoAddon->Version() &&
!m_database.IsAddonBlacklisted(temp[j]->ID(),
repoAddon->Version().c_str()))
addons.push_back(repoAddon);
}
}
}
return !addons.empty();
}
示例12: GetClientId
int CPVRClients::GetClientId(const AddonPtr &client) const
{
CSingleLock lock(m_critSection);
for (auto &entry : m_clientMap)
{
if (entry.second->ID() == client->ID())
{
return entry.first;
}
}
return -1;
}
示例13: GetRepoForAddon
AddonPtr CAddonInstallJob::GetRepoForAddon(const AddonPtr& addon)
{
AddonPtr repoPtr;
CAddonDatabase database;
if (!database.Open())
return repoPtr;
std::string repo;
if (!database.GetRepoForAddon(addon->ID(), repo))
return repoPtr;
if (!CAddonMgr::GetInstance().GetAddon(repo, repoPtr))
return repoPtr;
if (std::dynamic_pointer_cast<CRepository>(repoPtr) == NULL)
{
repoPtr.reset();
return repoPtr;
}
return repoPtr;
}
示例14: InitialiseClient
bool CPVRClients::InitialiseClient(AddonPtr client)
{
bool bReturn(false);
if (!client->Enabled())
return bReturn;
CLog::Log(LOGDEBUG, "%s - initialising add-on '%s'", __FUNCTION__, client->Name().c_str());
/* register this client in the db */
int iClientId = AddClientToDb(client);
if (iClientId == -1)
return bReturn;
/* load and initialise the client libraries */
boost::shared_ptr<CPVRClient> addon;
{
CSingleLock lock(m_critSection);
CLIENTMAPITR existingClient = m_clientMap.find(iClientId);
if (existingClient != m_clientMap.end())
{
addon = existingClient->second;
}
else
{
addon = boost::dynamic_pointer_cast<CPVRClient>(client);
m_clientMap.insert(std::make_pair(iClientId, addon));
}
}
if (addon)
bReturn = addon->Create(iClientId);
if (!bReturn)
CLog::Log(LOGERROR, "PVR - %s - can't initialise add-on '%s'", __FUNCTION__, client->Name().c_str());
return bReturn;
}
示例15: CheckDependencies
bool CAddonInstaller::CheckDependencies(const AddonPtr &addon,
std::vector<std::string>& preDeps, CAddonDatabase &database,
std::pair<std::string, std::string> &failedDep)
{
if (addon == NULL)
return true; // a NULL addon has no dependencies
if (!database.Open())
return false;
ADDONDEPS deps = addon->GetDeps();
for (ADDONDEPS::const_iterator i = deps.begin(); i != deps.end(); ++i)
{
const std::string &addonID = i->first;
const AddonVersion &version = i->second.first;
bool optional = i->second.second;
AddonPtr dep;
bool haveAddon = CAddonMgr::GetInstance().GetAddon(addonID, dep);
if ((haveAddon && !dep->MeetsVersion(version)) || (!haveAddon && !optional))
{
// we have it but our version isn't good enough, or we don't have it and we need it
if (!database.GetAddon(addonID, dep) || !dep->MeetsVersion(version))
{
// we don't have it in a repo, or we have it but the version isn't good enough, so dep isn't satisfied.
CLog::Log(LOGDEBUG, "CAddonInstallJob[%s]: requires %s version %s which is not available", addon->ID().c_str(), addonID.c_str(), version.asString().c_str());
database.Close();
// fill in the details of the failed dependency
failedDep.first = addon->ID();
failedDep.second = version.asString();
return false;
}
}
// at this point we have our dep, or the dep is optional (and we don't have it) so check that it's OK as well
// TODO: should we assume that installed deps are OK?
if (dep && std::find(preDeps.begin(), preDeps.end(), dep->ID()) == preDeps.end())
{
if (!CheckDependencies(dep, preDeps, database, failedDep))
{
database.Close();
preDeps.push_back(dep->ID());
return false;
}
}
}
database.Close();
return true;
}