本文整理汇总了C++中AddonPtr::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ AddonPtr::Type方法的具体用法?C++ AddonPtr::Type怎么用?C++ AddonPtr::Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AddonPtr
的用法示例。
在下文中一共展示了AddonPtr::Type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateListing
void CAddonsDirectory::GenerateListing(CURL &path, VECADDONS& addons, CFileItemList &items, bool reposAsFolders)
{
CStdString xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc/addons");
items.ClearItems();
for (unsigned i=0; i < addons.size(); i++)
{
AddonPtr addon = addons[i];
CFileItemPtr pItem;
if (reposAsFolders && addon->Type() == ADDON_REPOSITORY)
pItem = FileItemFromAddon(addon, "addons://", true);
else
pItem = FileItemFromAddon(addon, path.Get(), false);
AddonPtr addon2;
if (CAddonMgr::Get().GetAddon(addon->ID(),addon2))
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(305));
else if ((addon->Type() == ADDON_PVRDLL) && (CStdString(pItem->GetProperty("Addon.Path").asString()).Left(xbmcPath.size()).Equals(xbmcPath)))
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24023));
if (!addon->Props().broken.IsEmpty())
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24098));
if (addon2 && addon2->Version() < addon->Version())
{
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24068));
pItem->SetProperty("Addon.UpdateAvail", true);
}
CAddonDatabase::SetPropertiesFromAddon(addon,pItem);
items.Add(pItem);
}
}
示例2: SearchTitle
bool CAddonDatabase::SearchTitle(const CStdString& search, VECADDONS& addons)
{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
CStdString strSQL;
strSQL=PrepareSQL("select idAddon from addon where name like '%s%%'", search.c_str());
if (!m_pDS->query(strSQL.c_str())) return false;
if (m_pDS->num_rows() == 0) return false;
while (!m_pDS->eof())
{
AddonPtr addon;
GetAddon(m_pDS->fv(0).get_asInt(),addon);
if (addon->Type() >= ADDON_UNKNOWN+1 && addon->Type() < ADDON_SCRAPER_LIBRARY)
addons.push_back(addon);
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
}
return false;
}
示例3: Search
bool CAddonDatabase::Search(const std::string& search, VECADDONS& addons)
{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
std::string strSQL;
strSQL=PrepareSQL("SELECT addonID FROM addon WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", search.c_str(), search.c_str(), search.c_str());
CLog::Log(LOGDEBUG, "%s query: %s", __FUNCTION__, strSQL.c_str());
if (!m_pDS->query(strSQL.c_str())) return false;
if (m_pDS->num_rows() == 0) return false;
while (!m_pDS->eof())
{
AddonPtr addon;
GetAddon(m_pDS->fv(0).get_asString(),addon);
if (addon->Type() >= ADDON_UNKNOWN+1 && addon->Type() < ADDON_SCRAPER_LIBRARY)
addons.push_back(addon);
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
}
return false;
}
示例4: FileItemFromAddon
CFileItemPtr CAddonsDirectory::FileItemFromAddon(AddonPtr &addon, const CStdString &basePath, bool folder)
{
if (!addon)
return CFileItemPtr();
// TODO: This can probably be done more efficiently
CURL url(basePath);
url.SetFileName(addon->ID());
CStdString path(url.Get());
if (folder)
URIUtils::AddSlashAtEnd(path);
CFileItemPtr item(new CFileItem(path, folder));
CStdString strLabel(addon->Name());
if (url.GetHostName().Equals("search"))
strLabel.Format("%s - %s", TranslateType(addon->Type(), true), addon->Name());
item->SetLabel(strLabel);
if (!(basePath.Equals("addons://") && addon->Type() == ADDON_REPOSITORY))
item->SetLabel2(addon->Version().c_str());
item->SetArt("thumb", addon->Icon());
item->SetLabelPreformated(true);
item->SetIconImage("DefaultAddon.png");
if (!addon->FanArt().IsEmpty() &&
(URIUtils::IsInternetStream(addon->FanArt()) ||
CFile::Exists(addon->FanArt())))
{
item->SetArt("fanart", addon->FanArt());
}
CAddonDatabase::SetPropertiesFromAddon(addon, item);
return item;
}
示例5: 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().asString());
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());
std::string starrating = StringUtils::Format("rating%d.png", addon->Stars());
pItem->SetProperty("Addon.StarRating",starrating);
pItem->SetProperty("Addon.Path", addon->Path());
if (addon->Props().broken == "DEPSNOTMET")
pItem->SetProperty("Addon.Broken", g_localizeStrings.Get(24044));
else
pItem->SetProperty("Addon.Broken", addon->Props().broken);
std::map<std::string,std::string>::iterator it =
addon->Props().extrainfo.find("language");
if (it != addon->Props().extrainfo.end())
pItem->SetProperty("Addon.Language", it->second);
}
示例6: AddAddon
int CAddonDatabase::AddAddon(const AddonPtr& addon,
int idRepo)
{
try
{
if (NULL == m_pDB.get()) return -1;
if (NULL == m_pDS.get()) return -1;
bool bDisablePVRAddon = addon->Type() == ADDON_PVRDLL && !HasAddon(addon->ID());
CStdString sql = PrepareSQL("insert into addon (id, type, name, summary,"
"description, stars, path, icon, changelog, "
"fanart, addonID, version, author, disclaimer, minversion)"
" values(NULL, '%s', '%s', '%s', '%s', %i,"
"'%s', '%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().c_str(),
addon->Author().c_str(),addon->Disclaimer().c_str(),
addon->MinVersion().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());
}
const ADDONDEPS &deps = addon->GetDeps();
for (ADDONDEPS::const_iterator i = deps.begin(); i != deps.end(); ++i)
{
sql = PrepareSQL("insert into dependencies(id, addon, version, optional) values (%i, '%s', '%s', %i)", idAddon, i->first.c_str(), i->second.first.c_str(), i->second.second ? 1 : 0);
m_pDS->exec(sql.c_str());
}
// these need to be configured
if (bDisablePVRAddon)
DisableAddon(addon->ID(), true);
return idAddon;
}
catch (...)
{
CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addon->Name().c_str());
}
return -1;
}
示例7: GetAddonDetails
JSONRPC_STATUS CAddonsOperations::GetAddonDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
std::string id = parameterObject["addonid"].asString();
AddonPtr addon;
if (!CServiceBroker::GetAddonMgr().GetAddon(id, addon, ADDON::ADDON_UNKNOWN, false) || addon.get() == NULL ||
addon->Type() <= ADDON_UNKNOWN || addon->Type() >= ADDON_MAX)
return InvalidParams;
CAddonDatabase addondb;
FillDetails(addon, parameterObject["properties"], result["addon"], addondb);
return OK;
}
示例8: GetAddon
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/)
{
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, type==ADDON_UNKNOWN?"":TranslateType(type));
m_cpluff->release_info(m_cp_context, cpaddon);
if (addon && addon.get())
{
if (enabledOnly && m_database.IsAddonDisabled(addon->ID()))
return false;
if (addon->Type() == ADDON_PVRDLL && g_PVRManager.IsStarted())
{
AddonPtr pvrAddon;
if (g_PVRClients->GetClient(addon->ID(), pvrAddon))
addon = pvrAddon;
}
}
return NULL != addon.get();
}
if (cpaddon)
m_cpluff->release_info(m_cp_context, cpaddon);
return false;
}
示例9: CanAddonBeDisabled
bool CAddonMgr::CanAddonBeDisabled(const std::string& ID)
{
if (ID.empty())
return false;
CSingleLock lock(m_critSection);
// can't disable an already disabled addon
if (IsAddonDisabled(ID))
return false;
AddonPtr localAddon;
// can't disable an addon that isn't installed
if (!IsAddonInstalled(ID, localAddon))
return false;
// can't disable an addon that is in use
if (localAddon->IsInUse())
return false;
// installed PVR addons can always be disabled
if (localAddon->Type() == ADDON_PVRDLL)
return true;
std::string systemAddonsPath = CSpecialProtocol::TranslatePath("special://xbmc/addons");
// can't disable system addons
if (StringUtils::StartsWith(localAddon->Path(), systemAddonsPath))
return false;
return true;
}
示例10: GenerateListing
void CAddonsDirectory::GenerateListing(CURL &path, VECADDONS& addons, CFileItemList &items, bool reposAsFolders)
{
items.ClearItems();
for (unsigned i=0; i < addons.size(); i++)
{
AddonPtr addon = addons[i];
CFileItemPtr pItem;
if (reposAsFolders && addon->Type() == ADDON_REPOSITORY)
pItem = FileItemFromAddon(addon, "addons://", true);
else
pItem = FileItemFromAddon(addon, path.Get(), false);
AddonPtr addon2;
if (CAddonMgr::Get().GetAddon(addon->ID(),addon2))
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(305));
else if (CAddonMgr::Get().IsAddonDisabled(addon->ID()))
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24023));
if (addon->Props().broken == "DEPSNOTMET")
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24049));
else if (!addon->Props().broken.empty())
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24098));
if (addon2 && addon2->Version() < addon->Version())
{
pItem->SetProperty("Addon.Status",g_localizeStrings.Get(24068));
pItem->SetProperty("Addon.UpdateAvail", true);
}
CAddonDatabase::SetPropertiesFromAddon(addon,pItem);
items.Add(pItem);
}
}
示例11: GetAddon
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/)
{
CSingleLock lock(m_critSection);
CStdString xbmcPath = _P("special://xbmc/addons");
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 && addon.get() && enabledOnly)
{
if (addon->Type() == ADDON_PVRDLL && addon->Path().Left(xbmcPath.size()).Equals(xbmcPath))
{
if (!m_database.IsSystemPVRAddonEnabled(addon->ID()))
return false;
}
else if (m_database.IsAddonDisabled(addon->ID()))
return false;
}
return NULL != addon.get();
}
if (cpaddon)
m_cpluff->release_info(m_cp_context, cpaddon);
return false;
}
示例12: ExecuteAddon
JSONRPC_STATUS CAddonsOperations::ExecuteAddon(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
std::string id = parameterObject["addonid"].asString();
AddonPtr addon;
if (!CServiceBroker::GetAddonMgr().GetAddon(id, addon) || addon.get() == NULL ||
addon->Type() < ADDON_VIZ || addon->Type() >= ADDON_MAX)
return InvalidParams;
std::string argv;
CVariant params = parameterObject["params"];
if (params.isObject())
{
for (CVariant::const_iterator_map it = params.begin_map(); it != params.end_map(); it++)
{
if (it != params.begin_map())
argv += ",";
argv += it->first + "=" + it->second.asString();
}
}
else if (params.isArray())
{
for (CVariant::const_iterator_array it = params.begin_array(); it != params.end_array(); it++)
{
if (it != params.begin_array())
argv += ",";
argv += StringUtils::Paramify(it->asString());
}
}
else if (params.isString())
{
if (!params.empty())
argv = StringUtils::Paramify(params.asString());
}
std::string cmd;
if (params.empty())
cmd = StringUtils::Format("RunAddon(%s)", id.c_str());
else
cmd = StringUtils::Format("RunAddon(%s, %s)", id.c_str(), argv.c_str());
if (params["wait"].asBoolean())
CApplicationMessenger::GetInstance().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd);
else
CApplicationMessenger::GetInstance().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd);
return ACK;
}
示例13: 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);
}
示例14: SetAddonEnabled
JSONRPC_STATUS CAddonsOperations::SetAddonEnabled(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
std::string id = parameterObject["addonid"].asString();
AddonPtr addon;
if (!CServiceBroker::GetAddonMgr().GetAddon(id, addon, ADDON::ADDON_UNKNOWN, false) || addon == nullptr ||
addon->Type() <= ADDON_UNKNOWN || addon->Type() >= ADDON_MAX)
return InvalidParams;
bool disabled = false;
if (parameterObject["enabled"].isBoolean())
disabled = !parameterObject["enabled"].asBoolean();
// we need to toggle the current disabled state of the addon
else if (parameterObject["enabled"].isString())
disabled = !CServiceBroker::GetAddonMgr().IsAddonDisabled(id);
else
return InvalidParams;
bool success = disabled ? CServiceBroker::GetAddonMgr().DisableAddon(id) : CServiceBroker::GetAddonMgr().EnableAddon(id);
return success ? ACK : InvalidParams;
}
示例15: 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);
std::map<CStdString,CStdString>::iterator it =
addon->Props().extrainfo.find("language");
if (it != addon->Props().extrainfo.end())
pItem->SetProperty("Addon.Language", it->second);
}