bool CPVRDatabase::Persist(CPVRChannel &channel, bool bQueueWrite /* = false */) { bool bReturn(false); /* invalid channel */ if (channel.UniqueID() <= 0) { CLog::Log(LOGERROR, "PVR - %s - invalid channel uid: %d", __FUNCTION__, channel.UniqueID()); return bReturn; } CStdString strQuery; if (channel.ChannelID() <= 0) { /* new channel */ strQuery = PrepareSQL("INSERT INTO channels (" "iUniqueId, bIsRadio, bIsHidden, bIsUserSetIcon, bIsLocked, " "sIconPath, sChannelName, bIsVirtual, bEPGEnabled, sEPGScraper, iLastWatched, iClientId, " "iClientChannelNumber, sInputFormat, sStreamURL, iEncryptionSystem, idEpg) " "VALUES (%i, %i, %i, %i, %i, '%s', '%s', %i, %i, '%s', %u, %i, %i, '%s', '%s', %i, %i)", channel.UniqueID(), (channel.IsRadio() ? 1 :0), (channel.IsHidden() ? 1 : 0), (channel.IsUserSetIcon() ? 1 : 0), (channel.IsLocked() ? 1 : 0), channel.IconPath().c_str(), channel.ChannelName().c_str(), (channel.IsVirtual() ? 1 : 0), (channel.EPGEnabled() ? 1 : 0), channel.EPGScraper().c_str(), channel.LastWatched(), channel.ClientID(), channel.ClientChannelNumber(), channel.InputFormat().c_str(), channel.StreamURL().c_str(), channel.EncryptionSystem(), channel.EpgID()); } else { /* update channel */ strQuery = PrepareSQL("REPLACE INTO channels (" "iUniqueId, bIsRadio, bIsHidden, bIsUserSetIcon, bIsLocked, " "sIconPath, sChannelName, bIsVirtual, bEPGEnabled, sEPGScraper, iLastWatched, iClientId, " "iClientChannelNumber, sInputFormat, sStreamURL, iEncryptionSystem, idChannel, idEpg) " "VALUES (%i, %i, %i, %i, %i, '%s', '%s', %i, %i, '%s', %u, %i, %i, '%s', '%s', %i, %i, %i)", channel.UniqueID(), (channel.IsRadio() ? 1 :0), (channel.IsHidden() ? 1 : 0), (channel.IsUserSetIcon() ? 1 : 0), (channel.IsLocked() ? 1 : 0), channel.IconPath().c_str(), channel.ChannelName().c_str(), (channel.IsVirtual() ? 1 : 0), (channel.EPGEnabled() ? 1 : 0), channel.EPGScraper().c_str(), channel.LastWatched(), channel.ClientID(), channel.ClientChannelNumber(), channel.InputFormat().c_str(), channel.StreamURL().c_str(), channel.EncryptionSystem(), channel.ChannelID(), channel.EpgID()); } if (bQueueWrite) { QueueInsertQuery(strQuery); bReturn = true; } else if (ExecuteQuery(strQuery)) { CSingleLock lock(channel.m_critSection); if (channel.m_iChannelId <= 0) channel.m_iChannelId = (int)m_pDS->lastinsertid(); bReturn = true; } return bReturn; }
int CPVRDatabase::Persist(const CPVRChannel &channel, bool bQueueWrite /* = false */) { int iReturn = -1; /* invalid channel */ if (channel.UniqueID() <= 0) { CLog::Log(LOGERROR, "PVRDB - %s - invalid channel uid: %d", __FUNCTION__, channel.UniqueID()); return iReturn; } CStdString strQuery; if (channel.ChannelID() <= 0) { /* new channel */ strQuery = FormatSQL("INSERT INTO channels (" "iUniqueId, bIsRadio, bIsHidden, " "sIconPath, sChannelName, bIsVirtual, bEPGEnabled, sEPGScraper, iLastWatched, iClientId, " "iClientChannelNumber, sInputFormat, sStreamURL, iEncryptionSystem, idEpg) " "VALUES (%i, %i, %i, '%s', '%s', %i, %i, '%s', %u, %i, %i, '%s', '%s', %i, %i);", channel.UniqueID(), (channel.IsRadio() ? 1 :0), (channel.IsHidden() ? 1 : 0), channel.IconPath().c_str(), channel.ChannelName().c_str(), (channel.IsVirtual() ? 1 : 0), (channel.EPGEnabled() ? 1 : 0), channel.EPGScraper().c_str(), channel.LastWatched(), channel.ClientID(), channel.ClientChannelNumber(), channel.InputFormat().c_str(), channel.StreamURL().c_str(), channel.EncryptionSystem(), channel.EpgID()); } else { /* update channel */ strQuery = FormatSQL("REPLACE INTO channels (" "iUniqueId, bIsRadio, bIsHidden, " "sIconPath, sChannelName, bIsVirtual, bEPGEnabled, sEPGScraper, iLastWatched, iClientId, " "iClientChannelNumber, sInputFormat, sStreamURL, iEncryptionSystem, idChannel, idEpg) " "VALUES (%i, %i, %i, '%s', '%s', %i, %i, '%s', %u, %i, %i, '%s', '%s', %i, %i, %i);", channel.UniqueID(), (channel.IsRadio() ? 1 :0), (channel.IsHidden() ? 1 : 0), channel.IconPath().c_str(), channel.ChannelName().c_str(), (channel.IsVirtual() ? 1 : 0), (channel.EPGEnabled() ? 1 : 0), channel.EPGScraper().c_str(), channel.LastWatched(), channel.ClientID(), channel.ClientChannelNumber(), channel.InputFormat().c_str(), channel.StreamURL().c_str(), channel.EncryptionSystem(), channel.ChannelID(), channel.EpgID()); } if (bQueueWrite) { QueueInsertQuery(strQuery); iReturn = 0; } else if (ExecuteQuery(strQuery)) { iReturn = (channel.ChannelID() <= 0) ? (int) m_pDS->lastinsertid() : channel.ChannelID(); } return iReturn; }
long CPVRDatabase::UpdateChannel(const CPVRChannel &channel, bool bQueueWrite /* = false */) { long iReturn = -1; /* invalid channel */ if (channel.UniqueID() <= 0) { CLog::Log(LOGERROR, "PVRDB - %s - invalid channel uid: %d", __FUNCTION__, channel.UniqueID()); return iReturn; } CStdString strQuery; if (channel.ChannelID() <= 0) { /* new channel */ strQuery = FormatSQL("INSERT INTO Channels (" "UniqueId, ChannelNumber, GroupId, IsRadio, IsHidden, " "IconPath, ChannelName, IsVirtual, EPGEnabled, EPGScraper, ClientId, " "ClientChannelNumber, InputFormat, StreamURL, EncryptionSystem) " "VALUES (%i, %i, %i, %i, %i, '%s', '%s', %i, %i, '%s', %i, %i, '%s', '%s', %i)\n", channel.UniqueID(), channel.ChannelNumber(), channel.GroupID(), (channel.IsRadio() ? 1 :0), (channel.IsHidden() ? 1 : 0), channel.IconPath().c_str(), channel.ChannelName().c_str(), (channel.IsVirtual() ? 1 : 0), (channel.EPGEnabled() ? 1 : 0), channel.EPGScraper().c_str(), channel.ClientID(), channel.ClientChannelNumber(), channel.InputFormat().c_str(), channel.StreamURL().c_str(), channel.EncryptionSystem()); } else { /* update channel */ strQuery = FormatSQL("REPLACE INTO Channels (" "UniqueId, ChannelNumber, GroupId, IsRadio, IsHidden, " "IconPath, ChannelName, IsVirtual, EPGEnabled, EPGScraper, ClientId, " "ClientChannelNumber, InputFormat, StreamURL, EncryptionSystem, ChannelId) " "VALUES (%i, %i, %i, %i, %i, '%s', '%s', %i, %i, '%s', %i, %i, '%s', '%s', %i, %i)\n", channel.UniqueID(), channel.ChannelNumber(), channel.GroupID(), (channel.IsRadio() ? 1 :0), (channel.IsHidden() ? 1 : 0), channel.IconPath().c_str(), channel.ChannelName().c_str(), (channel.IsVirtual() ? 1 : 0), (channel.EPGEnabled() ? 1 : 0), channel.EPGScraper().c_str(), channel.ClientID(), channel.ClientChannelNumber(), channel.InputFormat().c_str(), channel.StreamURL().c_str(), channel.EncryptionSystem(), channel.ChannelID()); } if (bQueueWrite) { QueueInsertQuery(strQuery); iReturn = 0; } else if (ExecuteQuery(strQuery)) { iReturn = (channel.ChannelID() <= 0) ? (long) m_pDS->lastinsertid() : channel.ChannelID(); } return iReturn; }
bool CPVRChannel::UpdateFromClient(const CPVRChannel &channel) { bool bChanged = false; bChanged = SetClientID(channel.ClientID()) || bChanged; bChanged = SetClientChannelNumber(channel.ClientChannelNumber()) || bChanged; bChanged = SetClientChannelName(channel.ClientChannelName()) || bChanged; bChanged = SetInputFormat(channel.InputFormat()) || bChanged; bChanged = SetStreamURL(channel.StreamURL()) || bChanged; bChanged = SetEncryptionSystem(channel.EncryptionSystem()) || bChanged; bChanged = SetRecording(channel.IsRecording()) || bChanged; if (m_strChannelName.IsEmpty()) { m_strChannelName = channel.ClientChannelName(); bChanged = true; } if (m_strIconPath.IsEmpty()) { m_strIconPath = channel.IconPath(); bChanged = true; } return bChanged; }
CPVRChannel *CPVRChannels::GetByClient(int iClientChannelNumber, int iClientID) { for (unsigned int ptr = 0; ptr < size(); ptr++) { CPVRChannel *channel = at(ptr); if (channel->ClientChannelNumber() == iClientChannelNumber && channel->ClientID() == iClientID) return channel; } return NULL; }
/*! * @brief Copy over channel info from xbmcChannel to addonClient. * @param xbmcChannel The channel on XBMC's side. * @param addonChannel The channel on the addon's side. */ inline void PVRWriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel) { addonChannel.iUniqueId = xbmcChannel.UniqueID(); addonChannel.iChannelNumber = xbmcChannel.ClientChannelNumber(); addonChannel.strChannelName = xbmcChannel.ClientChannelName().c_str(); addonChannel.strIconPath = xbmcChannel.IconPath().c_str(); addonChannel.iEncryptionSystem = xbmcChannel.EncryptionSystem(); addonChannel.bIsRadio = xbmcChannel.IsRadio(); addonChannel.bIsHidden = xbmcChannel.IsHidden(); addonChannel.strInputFormat = xbmcChannel.InputFormat().c_str(); addonChannel.strStreamURL = xbmcChannel.StreamURL().c_str(); }
/*! * @brief Copy over channel info from xbmcChannel to addonClient. * @param xbmcChannel The channel on XBMC's side. * @param addonChannel The channel on the addon's side. */ void CPVRClient::WriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel) { memset(&addonChannel, 0, sizeof(addonChannel)); addonChannel.iUniqueId = xbmcChannel.UniqueID(); addonChannel.iChannelNumber = xbmcChannel.ClientChannelNumber(); strncpy(addonChannel.strChannelName, xbmcChannel.ClientChannelName().c_str(), sizeof(addonChannel.strChannelName) - 1); strncpy(addonChannel.strIconPath, xbmcChannel.IconPath().c_str(), sizeof(addonChannel.strIconPath) - 1); addonChannel.iEncryptionSystem = xbmcChannel.EncryptionSystem(); addonChannel.bIsRadio = xbmcChannel.IsRadio(); addonChannel.bIsHidden = xbmcChannel.IsHidden(); strncpy(addonChannel.strInputFormat, xbmcChannel.InputFormat().c_str(), sizeof(addonChannel.strInputFormat) - 1); strncpy(addonChannel.strStreamURL, xbmcChannel.StreamURL().c_str(), sizeof(addonChannel.strStreamURL) - 1); }
bool CPVRChannel::UpdateFromClient(const CPVRChannel &channel) { SetClientID(channel.ClientID()); SetClientChannelNumber(channel.ClientChannelNumber()); SetInputFormat(channel.InputFormat()); SetStreamURL(channel.StreamURL()); SetEncryptionSystem(channel.EncryptionSystem()); SetClientChannelName(channel.ClientChannelName()); CSingleLock lock(m_critSection); if (m_strChannelName.IsEmpty()) SetChannelName(channel.ClientChannelName()); if (m_strIconPath.IsEmpty()||(!m_strIconPath.Equals(channel.IconPath()) && !IsUserSetIcon())) SetIconPath(channel.IconPath()); return m_bChanged; }
bool CPVRChannel::UpdateFromClient(const CPVRChannel &channel) { SetClientID(channel.ClientID()); SetClientChannelNumber(channel.ClientChannelNumber()); SetInputFormat(channel.InputFormat()); SetStreamURL(channel.StreamURL()); SetEncryptionSystem(channel.EncryptionSystem()); SetClientChannelName(channel.ClientChannelName()); CSingleLock lock(m_critSection); // only update the channel name and icon if the user hasn't changed them manually if (m_strChannelName.empty() || !IsUserSetName()) SetChannelName(channel.ClientChannelName()); if (m_strIconPath.empty() || !IsUserSetIcon()) SetIconPath(channel.IconPath()); return m_bChanged; }
CPVRTimerInfoTag *CPVRTimerInfoTag::InstantTimer() { /* create a new timer */ CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag(); if (!newTag) { CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__); return NULL; } CFileItem *curPlayingChannel = g_PVRManager.GetCurrentPlayingItem(); CPVRChannel *channel = (curPlayingChannel) ? curPlayingChannel->GetPVRChannelInfoTag(): NULL; if (!channel) { CLog::Log(LOGDEBUG, "%s - couldn't find current playing channel", __FUNCTION__); channel = PVRChannelsTV.GetByChannelNumber(1); if (!channel) { CLog::Log(LOGERROR, "%s - cannot find any channels", __FUNCTION__); } } int iDuration = g_guiSettings.GetInt("pvrrecord.instantrecordtime"); if (!iDuration) iDuration = 180; /* default to 180 minutes */ int iPriority = g_guiSettings.GetInt("pvrrecord.defaultpriority"); if (!iPriority) iPriority = 50; /* default to 50 */ int iLifetime = g_guiSettings.GetInt("pvrrecord.defaultlifetime"); if (!iLifetime) iLifetime = 30; /* default to 30 days */ /* set the timer data */ newTag->m_iClientIndex = -1; newTag->m_bIsActive = true; newTag->m_strTitle = g_localizeStrings.Get(19056); newTag->m_iChannelNumber = channel->ChannelNumber(); newTag->m_iClientNumber = channel->ClientChannelNumber(); newTag->m_iClientID = channel->ClientID(); newTag->m_bIsRadio = channel->IsRadio(); newTag->m_StartTime = CDateTime::GetCurrentDateTime(); newTag->SetDuration(iDuration); newTag->m_iPriority = iPriority; newTag->m_iLifetime = iLifetime; /* generate summary string */ newTag->m_strSummary.Format("%s %s %s %s %s", newTag->m_StartTime.GetAsLocalizedDate(), g_localizeStrings.Get(19159), newTag->m_StartTime.GetAsLocalizedTime("", false), g_localizeStrings.Get(19160), newTag->m_StopTime.GetAsLocalizedTime("", false)); /* unused only for reference */ newTag->m_strFileNameAndPath = "pvr://timers/new"; return newTag; }