本文整理汇总了C++中CAddonDatabase::GetAddonId方法的典型用法代码示例。如果您正苦于以下问题:C++ CAddonDatabase::GetAddonId方法的具体用法?C++ CAddonDatabase::GetAddonId怎么用?C++ CAddonDatabase::GetAddonId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAddonDatabase
的用法示例。
在下文中一共展示了CAddonDatabase::GetAddonId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: UpdateTables
void CPVRDatabase::UpdateTables(int iVersion)
{
if (iVersion < 13)
m_pDS->exec("ALTER TABLE channels ADD idEpg integer;");
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");
if (iVersion < 24)
m_pDS->exec("ALTER TABLE channels ADD bIsUserSetName bool");
if (iVersion < 25)
m_pDS->exec("DROP TABLE IF EXISTS channelsettings");
if (iVersion < 26)
{
m_pDS->exec("ALTER TABLE channels ADD iClientSubChannelNumber integer");
m_pDS->exec("UPDATE channels SET iClientSubChannelNumber = 0");
m_pDS->exec("ALTER TABLE map_channelgroups_channels ADD iSubChannelNumber integer");
m_pDS->exec("UPDATE map_channelgroups_channels SET iSubChannelNumber = 0");
}
if (iVersion < 27)
m_pDS->exec("ALTER TABLE channelgroups ADD bIsHidden bool");
if (iVersion < 28)
{
VECADDONS addons;
CAddonDatabase database;
if (database.Open() && CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true))
{
/** find all old client IDs */
std::string strQuery(PrepareSQL("SELECT idClient, sUid FROM clients"));
m_pDS->query(strQuery);
while (!m_pDS->eof() && !addons.empty())
{
/** try to find an add-on that matches the sUid */
for (VECADDONS::iterator it = addons.begin(); it != addons.end(); ++it)
{
if ((*it)->ID() == m_pDS->fv(1).get_asString())
{
/** try to get the current ID from the database */
int iAddonId = database.GetAddonId(*it);
/** register a new id if it didn't exist */
if (iAddonId <= 0)
iAddonId = database.AddAddon(*it, 0);
if (iAddonId > 0)
{
// this fails when an id becomes the id of one that's being replaced next iteration
// but since almost everyone only has 1 add-on enabled...
/** update the iClientId in the channels table */
strQuery = PrepareSQL("UPDATE channels SET iClientId = %u WHERE iClientId = %u", iAddonId, m_pDS->fv(0).get_asInt());
m_pDS->exec(strQuery);
/** no need to check this add-on again */
it = addons.erase(it);
break;
}
}
}
m_pDS->next();
}
}
m_pDS->exec("DROP TABLE clients");
}
if (iVersion < 29)
m_pDS->exec("ALTER TABLE channelgroups ADD iPosition integer");
}