bool CPVRDatabase::DeleteClientChannels(const CPVRClient &client) { /* invalid client Id */ if (client.GetID() <= 0) { CLog::Log(LOGERROR, "PVR - %s - invalid client id: %i", __FUNCTION__, client.GetID()); return false; } CLog::Log(LOGDEBUG, "PVR - %s - deleting all channels from client '%i' from the database", __FUNCTION__, client.GetID()); CStdString strWhereClause = FormatSQL("iClientId = %u", client.GetID()); return DeleteValues("channels", strWhereClause); }
bool CPVRDatabase::Delete(const CPVRClient &client) { if (client.GetID() == PVR_INVALID_CLIENT_ID) return false; CLog::LogFC(LOGDEBUG, LOGPVR, "Deleting client '%s' from the database", client.ID().c_str()); CSingleLock lock(m_critSection); Filter filter; filter.AppendWhere(PrepareSQL("idClient = '%i'", client.GetID())); return DeleteValues("clients", filter); }
bool CPVRDatabase::Persist(const CPVRClient &client) { if (client.GetID() == PVR_INVALID_CLIENT_ID) return false; CLog::LogFC(LOGDEBUG, LOGPVR, "Persisting client '%s' to database", client.ID().c_str()); CSingleLock lock(m_critSection); const std::string strQuery = PrepareSQL("REPLACE INTO clients (idClient, iPriority) VALUES (%i, %i);", client.GetID(), client.GetPriority()); return ExecuteQuery(strQuery); }
bool CPVRDatabase::DeleteClientChannels(const CPVRClient &client) { /* invalid client Id */ if (client.GetID() <= 0) { CLog::Log(LOGERROR, "PVR - %s - invalid client id: %i", __FUNCTION__, client.GetID()); return false; } CLog::Log(LOGDEBUG, "PVR - %s - deleting all channels from client '%i' from the database", __FUNCTION__, client.GetID()); Filter filter; filter.AppendWhere(PrepareSQL("iClientId = %u", client.GetID())); return DeleteValues("channels", filter); }
void CAddonCallbacksPVR::PVRTransferTimerEntry(void *addonData, const ADDON_HANDLE handle, const PVR_TIMER *timer) { if (!handle) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRClient *client = GetPVRClient(addonData); CPVRTimers *xbmcTimers = static_cast<CPVRTimers *>(handle->dataAddress); if (!timer || !client || !xbmcTimers) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRChannelPtr channel = g_PVRChannelGroups->GetByUniqueID(timer->iClientChannelUid, client->GetID()); if (!channel) { CLog::Log(LOGERROR, "PVR - %s - cannot find channel %d on client %d", __FUNCTION__, timer->iClientChannelUid, client->GetID()); return; } /* transfer this entry to the timers container */ CPVRTimerInfoTag transferTimer(*timer, channel, client->GetID()); xbmcTimers->UpdateFromClient(transferTimer); }
int CPVRDatabase::GetPriority(const CPVRClient &client) { if (client.GetID() == PVR_INVALID_CLIENT_ID) return 0; CLog::LogFC(LOGDEBUG, LOGPVR, "Getting priority for client '%s' from the database", client.ID().c_str()); CSingleLock lock(m_critSection); const std::string strWhereClause = PrepareSQL("idClient = '%i'", client.GetID()); const std::string strValue = GetSingleValue("clients", "iPriority", strWhereClause); if (strValue.empty()) return 0; return atoi(strValue.c_str()); }
void CAddonCallbacksPVR::PVREpgEventStateChange(void* addonData, EPG_TAG* tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState) { CPVRClient *client = GetPVRClient(addonData); if (!client || !tag) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CLog::Log(LOGDEBUG, "PVR - %s - state for epg event '%d' on channel '%d' on client '%s' changed to '%d'.", __FUNCTION__, tag->iUniqueBroadcastId, iUniqueChannelId, client->Name().c_str(), newState); static CCriticalSection queueMutex; static std::vector<EpgEventStateChange> queuedChanges; // during Kodi startup, addons may push updates very early, even before EPGs are ready to use. if (g_PVRManager.EpgsCreated()) { { // deliver queued changes, if any. discard event if delivery fails. CSingleLock lock(queueMutex); if (!queuedChanges.empty()) CLog::Log(LOGNOTICE, "PVR - %s - processing %ld queued epg event changes.", __FUNCTION__, queuedChanges.size()); while (!queuedChanges.empty()) { auto it = queuedChanges.begin(); UpdateEpgEvent(*it, true); queuedChanges.erase(it); } } // deliver current change. UpdateEpgEvent(EpgEventStateChange(client->GetID(), iUniqueChannelId, tag, newState), false); } else { // queue for later delivery. CSingleLock lock(queueMutex); queuedChanges.push_back(EpgEventStateChange(client->GetID(), iUniqueChannelId, tag, newState)); } }
void CAddonCallbacksPVR::PVRTriggerEpgUpdate(void *addonData, unsigned int iChannelUid) { // get the client CPVRClient *client = GetPVRClient(addonData); if (!client) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } g_EpgContainer.UpdateRequest(client->GetID(), iChannelUid); }
void CAddonCallbacksPVR::PVRTransferRecordingEntry(void *addonData, const PVR_HANDLE handle, const PVR_RECORDING *recording) { CPVRClient *client = GetPVRClient(addonData); CPVRRecordings *xbmcRecordings = static_cast<CPVRRecordings *>(handle->dataAddress); if (!handle || !recording || !client || !xbmcRecordings) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } /* transfer this entry to the recordings container */ xbmcRecordings->UpdateFromClient(CPVRRecording(*recording, client->GetID())); }
void CAddonCallbacksPVR::PVRTransferChannelEntry(void *addonData, const PVR_HANDLE handle, const PVR_CHANNEL *channel) { CPVRClient *client = GetPVRClient(addonData); CPVRChannelGroupInternal *xbmcChannels = static_cast<CPVRChannelGroupInternal *>(handle->dataAddress); if (!handle || !channel || !client || !xbmcChannels) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } /* transfer this entry to the internal channels group */ xbmcChannels->UpdateFromClient(CPVRChannel(*channel, client->GetID())); }
void CAddonCallbacksPVR::PVRConnectionStateChange(void* addonData, const char* strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage) { CPVRClient *client = GetPVRClient(addonData); if (!client || !strConnectionString) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } const PVR_CONNECTION_STATE prevState(client->GetConnectionState()); if (prevState == newState) return; CLog::Log(LOGDEBUG, "PVR - %s - state for connection '%s' on client '%s' changed from '%d' to '%d'", __FUNCTION__, strConnectionString, client->Name().c_str(), prevState, newState); client->SetConnectionState(newState); std::string msg; if (strMessage != nullptr) msg = strMessage; g_PVRManager.ConnectionStateChange(client->GetID(), std::string(strConnectionString), newState, msg); }
void CAddonCallbacksPVR::PVRTransferTimerEntry(void *addonData, const ADDON_HANDLE handle, const PVR_TIMER *timer) { if (!handle) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRClient *client = GetPVRClient(addonData); CPVRTimers *xbmcTimers = static_cast<CPVRTimers *>(handle->dataAddress); if (!timer || !client || !xbmcTimers) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } /* Note: channel can be NULL here, for instance for epg-based timer rules ("record on any channel" condition). */ CPVRChannelPtr channel = g_PVRChannelGroups->GetByUniqueID(timer->iClientChannelUid, client->GetID()); /* transfer this entry to the timers container */ CPVRTimerInfoTagPtr transferTimer(new CPVRTimerInfoTag(*timer, channel, client->GetID())); xbmcTimers->UpdateFromClient(transferTimer); }
void CAddonCallbacksPVR::PVRTriggerEpgUpdate(void *addonData, unsigned int iChannelUid) { // get the client CPVRClient *client = GetPVRClient(addonData); if (!client) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } // get the channel CPVRChannelPtr channel = g_PVRChannelGroups->GetByUniqueID(iChannelUid, client->GetID()); CEpg* epg(NULL); // get the EPG for the channel if (!channel || (epg = channel->GetEPG()) == NULL) { CLog::Log(LOGERROR, "PVR - %s - invalid channel or channel doesn't have an EPG", __FUNCTION__); return; } // force an update epg->ForceUpdate(); }
void CAddonCallbacksPVR::PVRTransferChannelGroupMember(void *addonData, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member) { if (!handle) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRClient *client = GetPVRClient(addonData); CPVRChannelGroup *group = static_cast<CPVRChannelGroup *>(handle->dataAddress); if (!member || !client || !group) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRChannelPtr channel = g_PVRChannelGroups->GetByUniqueID(member->iChannelUniqueId, client->GetID()); if (!channel) { CLog::Log(LOGERROR, "PVR - %s - cannot find group '%s' or channel '%d'", __FUNCTION__, member->strGroupName, member->iChannelUniqueId); } else if (group->IsRadio() == channel->IsRadio()) { /* transfer this entry to the group */ group->AddToGroup(channel, member->iChannelNumber); } }