本文整理汇总了C++中AddonPtr::Name方法的典型用法代码示例。如果您正苦于以下问题:C++ AddonPtr::Name方法的具体用法?C++ AddonPtr::Name怎么用?C++ AddonPtr::Name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AddonPtr
的用法示例。
在下文中一共展示了AddonPtr::Name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegisterClient
int CPVRClients::RegisterClient(AddonPtr client)
{
int iClientId(-1);
if (!client->Enabled())
return -1;
CLog::Log(LOGDEBUG, "%s - registering add-on '%s'", __FUNCTION__, client->Name().c_str());
CPVRDatabase *database = GetPVRDatabase();
if (!database)
return -1;
// check whether we already know this client
iClientId = database->GetClientId(client->ID());
// try to register the new client in the db
if (iClientId < 0 && (iClientId = database->Persist(client)) < 0)
{
CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", __FUNCTION__, client->Name().c_str());
return -1;
}
PVR_CLIENT addon;
// load and initialise the client libraries
{
CSingleLock lock(m_critSection);
PVR_CLIENTMAP_ITR existingClient = m_clientMap.find(iClientId);
if (existingClient != m_clientMap.end())
{
// return existing client
addon = existingClient->second;
}
else
{
// create a new client instance
addon = boost::dynamic_pointer_cast<CPVRClient>(client);
m_clientMap.insert(std::make_pair(iClientId, addon));
}
}
if (iClientId < 0)
CLog::Log(LOGERROR, "PVR - %s - can't register add-on '%s'", __FUNCTION__, client->Name().c_str());
return iClientId;
}
示例2: RegisterAudioDSPAddon
int CActiveAEDSP::RegisterAudioDSPAddon(AddonPtr addon, bool* newRegistration/*=NULL*/)
{
int iAddonId(-1);
if (newRegistration)
*newRegistration = false;
if (!addon->Enabled())
return -1;
CLog::Log(LOGDEBUG, "ActiveAE DSP - %s - registering add-on '%s'", __FUNCTION__, addon->Name().c_str());
if (!m_databaseDSP.IsOpen())
{
CLog::Log(LOGERROR, "ActiveAE DSP - %s - failed to get the database", __FUNCTION__);
return -1;
}
/* check whether we already know this dsp addon */
iAddonId = m_databaseDSP.GetAudioDSPAddonId(addon->ID());
/* try to register the new dsp addon in the db */
if (iAddonId < 0)
{
if ((iAddonId = m_databaseDSP.Persist(addon)) < 0)
{
CLog::Log(LOGERROR, "ActiveAE DSP - %s - can't add dsp addon '%s' to the database", __FUNCTION__, addon->Name().c_str());
return -1;
}
else if (newRegistration)
*newRegistration = true;
}
AE_DSP_ADDON dspAddon;
/* load and initialise the dsp addon libraries */
{
CSingleLock lock(m_critSection);
AE_DSP_ADDONMAP_CITR existingAddon = m_addonMap.find(iAddonId);
if (existingAddon != m_addonMap.end())
{
/* return existing addon */
dspAddon = existingAddon->second;
}
else
{
/* create a new addon instance */
dspAddon = std::dynamic_pointer_cast<CActiveAEDSPAddon> (addon);
m_addonMap.insert(std::make_pair(iAddonId, dspAddon));
}
}
if (iAddonId < 0)
CLog::Log(LOGERROR, "ActiveAE DSP - %s - can't register dsp add-on '%s'", __FUNCTION__, addon->Name().c_str());
return iAddonId;
}
示例3: Persist
int CPVRDatabase::Persist(const AddonPtr client)
{
int iReturn(-1);
/* invalid client uid or name */
if (client->Name().empty() || client->ID().empty())
{
CLog::Log(LOGERROR, "PVR - %s - invalid client uid or name", __FUNCTION__);
return iReturn;
}
CStdString strQuery = PrepareSQL("REPLACE INTO clients (sName, sUid) VALUES ('%s', '%s');",
client->Name().c_str(), client->ID().c_str());
if (ExecuteQuery(strQuery))
iReturn = (int) m_pDS->lastinsertid();
return iReturn;
}
示例4: Persist
int CActiveAEDSPDatabase::Persist(const AddonPtr addon)
{
int iReturn(-1);
/* invalid addon uid or name */
if (addon->Name().empty() || addon->ID().empty())
{
CLog::Log(LOGERROR, "Audio DSP - %s - invalid add-on uid or name", __FUNCTION__);
return iReturn;
}
string strQuery = PrepareSQL("REPLACE INTO addons (sName, sUid) VALUES ('%s', '%s');",
addon->Name().c_str(), addon->ID().c_str());
if (ExecuteQuery(strQuery))
iReturn = (int) m_pDS->lastinsertid();
return iReturn;
}
示例5: RegisterClient
int CPVRClients::RegisterClient(AddonPtr client)
{
int iClientId(-1);
CAddonDatabase database;
PVR_CLIENT addon;
if (CAddonMgr::GetInstance().IsAddonDisabled(client->ID()) || !database.Open())
return -1;
CLog::Log(LOGDEBUG, "%s - registering add-on '%s'", __FUNCTION__, client->Name().c_str());
// check whether we already know this client
iClientId = database.GetAddonId(client); //database->GetClientId(client->ID());
// try to register the new client in the db
if (iClientId <= 0)
iClientId = database.AddAddon(client, 0);
if (iClientId > 0)
// load and initialise the client libraries
{
CSingleLock lock(m_critSection);
PVR_CLIENTMAP_CITR existingClient = m_clientMap.find(iClientId);
if (existingClient != m_clientMap.end())
{
// return existing client
addon = existingClient->second;
}
else
{
// create a new client instance
addon = std::dynamic_pointer_cast<CPVRClient>(client);
m_clientMap.insert(std::make_pair(iClientId, addon));
m_addonNameIds.insert(make_pair(addon->ID(), iClientId));
}
}
if (iClientId <= 0)
CLog::Log(LOGERROR, "PVR - %s - can't register add-on '%s'", __FUNCTION__, client->Name().c_str());
return iClientId;
}
示例6: RunScriptWithParams
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<CStdString> argv;
argv.push_back(basePath);
argv.push_back(strHandle);
argv.push_back(options);
// run the script
#ifdef HAS_PYTHON
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 (g_pythonParser.evalFile(addon->LibPath(), argv,addon) >= 0)
return true;
else
#endif
CLog::Log(LOGERROR, "Unable to run plugin %s", addon->Name().c_str());
return false;
}
示例7: AddAddon
int CAddonDatabase::AddAddon(const AddonPtr& addon,
int idRepo)
{
try
{
if (NULL == m_pDB.get()) return -1;
if (NULL == m_pDS.get()) return -1;
CStdString sql = PrepareSQL("insert into addon (id, type, name, summary,"
"description, stars, path, icon, changelog, "
"fanart, addonID, version, author, disclaimer)"
" values(NULL, '%s', '%s', '%s', '%s', %i,"
"'%s', '%s', '%s', '%s', '%s','%s','%s','%s')",
TranslateType(addon->Type(),false).c_str(),
addon->Name().c_str(), addon->Summary().c_str(),
addon->Description().c_str(),addon->Stars(),
addon->Path().c_str(), addon->Props().icon.c_str(),
addon->ChangeLog().c_str(),addon->FanArt().c_str(),
addon->ID().c_str(), addon->Version().str.c_str(),
addon->Author().c_str(),addon->Disclaimer().c_str());
m_pDS->exec(sql.c_str());
int idAddon = (int)m_pDS->lastinsertid();
sql = PrepareSQL("insert into addonlinkrepo (idRepo, idAddon) values (%i,%i)",idRepo,idAddon);
m_pDS->exec(sql.c_str());
const InfoMap &info = addon->ExtraInfo();
for (InfoMap::const_iterator i = info.begin(); i != info.end(); ++i)
{
sql = PrepareSQL("insert into addonextra(id, key, value) values (%i, '%s', '%s')", idAddon, i->first.c_str(), i->second.c_str());
m_pDS->exec(sql.c_str());
}
return idAddon;
}
catch (...)
{
CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addon->Name().c_str());
}
return -1;
}
示例8: 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 == -1)
{
CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database",
__FUNCTION__, client->Name().c_str());
}
return iClientDbId;
}
示例9: FindLegacyLanguage
bool CLanguageResource::FindLegacyLanguage(const std::string &locale, std::string &legacyLanguage)
{
if (locale.empty())
return false;
std::string addonId = GetAddonId(locale);
AddonPtr addon;
if (!CServiceBroker::GetAddonMgr().GetAddon(addonId, addon, ADDON_RESOURCE_LANGUAGE, true))
return false;
legacyLanguage = addon->Name();
return true;
}
示例10: 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;
}
示例11: Persist
int CPVRDatabase::Persist(const AddonPtr client)
{
int iReturn(-1);
/* invalid client uid or name */
if (client->Name().IsEmpty() || client->ID().IsEmpty())
{
CLog::Log(LOGERROR, "PVR - %s - invalid client uid or name", __FUNCTION__);
return iReturn;
}
/* only add this client if it's not already in the database */
iReturn = GetClientId(client->ID());
if (iReturn <= 0)
{
CStdString strQuery = FormatSQL("INSERT INTO clients (sName, sUid) VALUES ('%s', '%s');",
client->Name().c_str(), client->ID().c_str());
if (ExecuteQuery(strQuery))
iReturn = (int) m_pDS->lastinsertid();
}
return iReturn;
}
示例12: RunScriptWithParams
bool CPluginDirectory::RunScriptWithParams(const std::string& strPath)
{
CURL url(strPath);
if (url.GetHostName().empty()) // 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
std::string options = url.GetOptions();
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)
std::string basePath(url.Get());
// setup our parameters to send the script
std::string strHandle = StringUtils::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;
}
示例13: GetAddonNames
std::string CGUIDialogAddonSettings::GetAddonNames(const std::string& addonIDslist) const
{
std::string retVal;
vector<string> addons = StringUtils::Split(addonIDslist, ',');
for (vector<string>::const_iterator it = addons.begin(); it != addons.end() ; ++it)
{
if (!retVal.empty())
retVal += ", ";
AddonPtr addon;
if (CAddonMgr::Get().GetAddon(*it ,addon))
retVal += addon->Name();
else
retVal += *it;
}
return retVal;
}
示例14: SetPropertiesFromAddon
void CAddonDatabase::SetPropertiesFromAddon(const AddonPtr& addon,
CFileItemPtr& pItem)
{
pItem->SetProperty("Addon.ID", addon->ID());
pItem->SetProperty("Addon.Type", TranslateType(addon->Type(),true));
pItem->SetProperty("Addon.intType", TranslateType(addon->Type()));
pItem->SetProperty("Addon.Name", addon->Name());
pItem->SetProperty("Addon.Version", addon->Version().c_str());
pItem->SetProperty("Addon.Summary", addon->Summary());
pItem->SetProperty("Addon.Description", addon->Description());
pItem->SetProperty("Addon.Creator", addon->Author());
pItem->SetProperty("Addon.Disclaimer", addon->Disclaimer());
pItem->SetProperty("Addon.Rating", addon->Stars());
CStdString starrating;
starrating.Format("rating%d.png", addon->Stars());
pItem->SetProperty("Addon.StarRating",starrating);
pItem->SetProperty("Addon.Path", addon->Path());
pItem->SetProperty("Addon.Broken", addon->Props().broken);
}
示例15: Serialize
static CVariant Serialize(const AddonPtr& addon)
{
CVariant variant;
variant["addonid"] = addon->ID();
variant["type"] = CAddonInfo::TranslateType(addon->Type(), false);
variant["name"] = addon->Name();
variant["version"] = addon->Version().asString();
variant["summary"] = addon->Summary();
variant["description"] = addon->Description();
variant["path"] = addon->Path();
variant["author"] = addon->Author();
variant["thumbnail"] = addon->Icon();
variant["disclaimer"] = addon->Disclaimer();
variant["fanart"] = addon->FanArt();
variant["dependencies"] = CVariant(CVariant::VariantTypeArray);
for (const auto& dep : addon->GetDependencies())
{
CVariant info(CVariant::VariantTypeObject);
info["addonid"] = dep.id;
info["version"] = dep.requiredVersion.asString();
info["optional"] = dep.optional;
variant["dependencies"].push_back(std::move(info));
}
if (addon->Broken().empty())
variant["broken"] = false;
else
variant["broken"] = addon->Broken();
variant["extrainfo"] = CVariant(CVariant::VariantTypeArray);
for (const auto& kv : addon->ExtraInfo())
{
CVariant info(CVariant::VariantTypeObject);
info["key"] = kv.first;
info["value"] = kv.second;
variant["extrainfo"].push_back(std::move(info));
}
variant["rating"] = -1;
return variant;
}