Example #1
0
int CPVRDatabase::GetChannels(CPVRChannels &results, bool bIsRadio)
{
  int iReturn = -1;

  CStdString strQuery = FormatSQL("SELECT * FROM Channels WHERE IsRadio = %u ORDER BY ChannelNumber\n", bIsRadio);
  int iNumRows = ResultQuery(strQuery);

  if (iNumRows > 0)
  {
    try
    {
      while (!m_pDS->eof())
      {
        CPVRChannel *channel = new CPVRChannel();

        channel->m_iChannelId              = m_pDS->fv("ChannelId").get_asInt();
        channel->m_iUniqueId               = m_pDS->fv("UniqueId").get_asInt();
        channel->m_iChannelNumber          = m_pDS->fv("ChannelNumber").get_asInt();
        channel->m_iChannelGroupId         = m_pDS->fv("GroupId").get_asInt();
        channel->m_bIsRadio                = m_pDS->fv("IsRadio").get_asBool();
        channel->m_bIsHidden               = m_pDS->fv("IsHidden").get_asBool();
        channel->m_strIconPath             = m_pDS->fv("IconPath").get_asString();
        channel->m_strChannelName          = m_pDS->fv("ChannelName").get_asString();
        channel->m_bIsVirtual              = m_pDS->fv("IsVirtual").get_asBool();
        channel->m_bEPGEnabled             = m_pDS->fv("EPGEnabled").get_asBool();
        channel->m_strEPGScraper           = m_pDS->fv("EPGScraper").get_asString();
        channel->m_iClientId               = m_pDS->fv("ClientId").get_asInt();
        channel->m_iClientChannelNumber    = m_pDS->fv("ClientChannelNumber").get_asInt();
        channel->m_strInputFormat          = m_pDS->fv("InputFormat").get_asString();
        channel->m_strStreamURL            = m_pDS->fv("StreamURL").get_asString();
        channel->m_iClientEncryptionSystem = m_pDS->fv("EncryptionSystem").get_asInt();

        channel->UpdatePath();

        CLog::Log(LOGDEBUG, "PVRDB - %s - channel '%s' loaded from the database",
            __FUNCTION__, channel->m_strChannelName.c_str());
        results.push_back(channel);
        m_pDS->next();
        ++iReturn;
      }
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "PVRDB - %s - couldn't load channels from the database", __FUNCTION__);
    }
  }

  m_pDS->close();
  return iReturn;
}