示例#1
0
bool CPVRDatabase::UpdateLastEpgScanTime(void)
{
  CDateTime now = CDateTime::GetCurrentDateTime();
  CLog::Log(LOGDEBUG, "PVRDB - %s - updating last scan time to '%s'",
      __FUNCTION__, now.GetAsDBDateTime().c_str());
  lastScanTime = now;

  bool bReturn = true;
  CStdString strQuery = FormatSQL("REPLACE INTO LastEPGScan (ScanTime) VALUES ('%s')\n",
      now.GetAsDBDateTime().c_str());

  bReturn = ExecuteQuery(strQuery);

  return bReturn;
}
示例#2
0
int CAddonDatabase::AddRepository(const std::string& id, const VECADDONS& addons, const std::string& checksum, const AddonVersion& version)
{
  try
  {
    if (NULL == m_pDB.get()) return -1;
    if (NULL == m_pDS.get()) return -1;

    std::string sql;
    int idRepo = GetRepoChecksum(id,sql);
    if (idRepo > -1)
      DeleteRepository(idRepo);

    BeginTransaction();

    CDateTime time = CDateTime::GetCurrentDateTime();
    sql = PrepareSQL("insert into repo (id,addonID,checksum,lastcheck,version) values (NULL,'%s','%s','%s','%s')",
                     id.c_str(), checksum.c_str(), time.GetAsDBDateTime().c_str(), version.asString().c_str());
    m_pDS->exec(sql.c_str());
    idRepo = (int)m_pDS->lastinsertid();
    for (unsigned int i=0;i<addons.size();++i)
      AddAddon(addons[i],idRepo);

    CommitTransaction();
    return idRepo;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on repo '%s'", __FUNCTION__, id.c_str());
    RollbackTransaction();
  }
  return -1;
}
示例#3
0
bool CPVRDatabase::EraseOldEpgEntries()
{
  CDateTime yesterday = CDateTime::GetCurrentDateTime() - CDateTimeSpan(1, 0, 0, 0);
  CStdString strWhereClause = FormatSQL("EndTime < '%s'", yesterday.GetAsDBDateTime().c_str());

  return DeleteValues("EpgData", strWhereClause);
}
示例#4
0
bool CPVRDatabase::EraseEpgForChannel(const CPVRChannel &channel, const CDateTime &start /* = NULL */, const CDateTime &end /* = NULL */)
{
  /* invalid channel */
  if (channel.ChannelID() <= 0)
  {
    CLog::Log(LOGERROR, "PVRDB - %s - invalid channel id: %li",
        __FUNCTION__, channel.ChannelID());
    return false;
  }

  CLog::Log(LOGDEBUG, "PVRDB - %s - clearing the EPG for channel '%s'",
      __FUNCTION__, channel.ChannelName().c_str());

  CStdString strWhereClause;
  strWhereClause = FormatSQL("ChannelId = %u", channel.ChannelID());

  if (start != NULL)
    strWhereClause.append(FormatSQL(" AND StartTime < %u", start.GetAsDBDateTime().c_str()).c_str());

  if (end != NULL)
    strWhereClause.append(FormatSQL(" AND EndTime > %u", end.GetAsDBDateTime().c_str()).c_str());

  return DeleteValues("EpgData", strWhereClause);
}
示例#5
0
bool CAddonDatabase::SetLastUpdated(const std::string& addonId, const CDateTime& dateTime)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    m_pDS->exec(PrepareSQL("UPDATE installed SET lastUpdated='%s' WHERE addonID='%s'",
        dateTime.GetAsDBDateTime().c_str(), addonId.c_str()));
    return true;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addonId.c_str());
  }
  return false;
}
示例#6
0
bool CAddonDatabase::SetLastUsed(const std::string& addonId, const CDateTime& dateTime)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    auto start = XbmcThreads::SystemClockMillis();
    m_pDS->exec(PrepareSQL("UPDATE installed SET lastUsed='%s' WHERE addonID='%s'",
        dateTime.GetAsDBDateTime().c_str(), addonId.c_str()));

    CLog::Log(LOGDEBUG, "CAddonDatabase::SetLastUsed[%s] took %i ms", addonId.c_str(), XbmcThreads::SystemClockMillis() - start);
    return true;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on addon '%s'", __FUNCTION__, addonId.c_str());
  }
  return false;
}
示例#7
0
文件: XMLUtils.cpp 项目: B0k0/xbmc
void XMLUtils::SetDateTime(TiXmlNode* pRootNode, const char *strTag, const CDateTime& dateTime)
{
  SetString(pRootNode, strTag, dateTime.IsValid() ? dateTime.GetAsDBDateTime() : "");
}
示例#8
0
int CPVRDatabase::GetEpgForChannel(CPVREpg *epg, const CDateTime &start /* = NULL */, const CDateTime &end /* = NULL */)
{
  int iReturn = -1;
  CPVRChannel *channel = epg->Channel();

  if (!channel)
  {
    CLog::Log(LOGERROR, "PVRDB - %s - EPG doesn't contain a channel tag", __FUNCTION__);
    return false;
  }

  CStdString strWhereClause;
  strWhereClause = FormatSQL("ChannelId = %u", channel->ChannelID());

  if (start != NULL)
    strWhereClause.append(FormatSQL(" AND StartTime < %u", start.GetAsDBDateTime().c_str()).c_str());

  if (end != NULL)
    strWhereClause.append(FormatSQL(" AND EndTime > %u", end.GetAsDBDateTime().c_str()).c_str());

  CStdString strQuery;
  strQuery.Format("SELECT * FROM EpgData WHERE %s ORDER BY StartTime ASC\n", strWhereClause.c_str());

  int iNumRows = ResultQuery(strQuery);

  if (iNumRows > 0)
  {
    try
    {
      while (!m_pDS->eof())
      {
        int iBroadcastUid =          m_pDS->fv("BroadcastUid").get_asInt();

        CDateTime startTime, endTime, firstAired;
        startTime.SetFromDBDateTime (m_pDS->fv("StartTime").get_asString());
        endTime.SetFromDBDateTime   (m_pDS->fv("EndTime").get_asString());
        firstAired.SetFromDBDateTime(m_pDS->fv("FirstAired").get_asString());

        CPVREpgInfoTag newTag(iBroadcastUid);
        newTag.SetBroadcastId       (m_pDS->fv("BroadcastId").get_asInt());
        newTag.SetTitle             (m_pDS->fv("Title").get_asString().c_str());
        newTag.SetPlotOutline       (m_pDS->fv("PlotOutline").get_asString().c_str());
        newTag.SetPlot              (m_pDS->fv("Plot").get_asString().c_str());
        newTag.SetStart             (startTime);
        newTag.SetEnd               (endTime);
        newTag.SetGenre             (m_pDS->fv("GenreType").get_asInt(),
                                     m_pDS->fv("GenreSubType").get_asInt(),
                                     m_pDS->fv("Genre").get_asString().c_str());
        newTag.SetFirstAired        (firstAired);
        newTag.SetParentalRating    (m_pDS->fv("ParentalRating").get_asInt());
        newTag.SetStarRating        (m_pDS->fv("StarRating").get_asInt());
        newTag.SetNotify            (m_pDS->fv("Notify").get_asBool());
        newTag.SetEpisodeNum        (m_pDS->fv("EpisodeId").get_asString().c_str());
        newTag.SetEpisodePart       (m_pDS->fv("EpisodePart").get_asString().c_str());
        newTag.SetEpisodeName       (m_pDS->fv("EpisodeName").get_asString().c_str());

        epg->UpdateEntry(newTag, false);
        m_pDS->next();
        ++iReturn;
      }
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "%s - couldn't load EPG data from the database", __FUNCTION__);
    }
  }
  return iReturn;
}
示例#9
0
bool CPVRClients::OpenStream(const CPVRRecordingPtr &channel)
{
  assert(channel.get());

  bool bReturn(false);
  CloseStream();

  /* try to open the recording stream on the client */
  PVR_CLIENT client;
  if (GetConnectedClient(channel->m_iClientId, client) &&
      client->OpenStream(channel))
  {
    CSingleLock lock(m_critSection);

    CDateTime endTime = channel->RecordingTimeAsLocalTime() +
        CDateTimeSpan(0, 0, channel->GetDuration() / 60, channel->GetDuration() % 60);

    m_bIsRecordingInProgress = (endTime > CDateTime::GetCurrentDateTime());

    if (m_bIsRecordingInProgress)
      CLog::Log(LOGNOTICE, "PVRClients - %s - recording is still in progress, end time = %s", __FUNCTION__, endTime.GetAsDBDateTime().c_str());

    m_playingClientId = channel->m_iClientId;
    m_bIsPlayingRecording = true;
    m_strPlayingClientName = client->GetFriendlyName();
    bReturn = true;
  }

  return bReturn;
}