示例#1
0
文件: PVRGUIInfo.cpp 项目: A600/xbmc
void CPVRGUIInfo::UpdateBackendCache(void)
{
  CStdString strBackendName;
  CStdString strBackendVersion;
  CStdString strBackendHost;
  CStdString strBackendDiskspace;
  CStdString strBackendTimers;
  CStdString strBackendRecordings;
  CStdString strBackendChannels;
  int        iActiveClients(0);

  if (!AddonInfoToggle())
    return;

  CPVRClients *clients = g_PVRClients;
  PVR_CLIENTMAP activeClients;
  iActiveClients = clients->GetConnectedClients(activeClients);
  if (iActiveClients > 0)
  {
    PVR_CLIENTMAP_CITR activeClient = activeClients.begin();
    /* safe to read unlocked */
    for (unsigned int i = 0; i < m_iAddonInfoToggleCurrent; i++)
      activeClient++;

    long long kBTotal = 0;
    long long kBUsed  = 0;

    if (activeClient->second->GetDriveSpace(&kBTotal, &kBUsed) == PVR_ERROR_NO_ERROR)
    {
      kBTotal /= 1024; // Convert to MBytes
      kBUsed /= 1024;  // Convert to MBytes
      strBackendDiskspace.Format("%s %.1f GByte - %s: %.1f GByte",
          g_localizeStrings.Get(20161), (float) kBTotal / 1024, g_localizeStrings.Get(20162), (float) kBUsed / 1024);
    }
    else
    {
      strBackendDiskspace = g_localizeStrings.Get(19055);
    }

    int NumChannels = activeClient->second->GetChannelsAmount();
    if (NumChannels >= 0)
      strBackendChannels.Format("%i", NumChannels);
    else
      strBackendChannels = g_localizeStrings.Get(161);

    int NumTimers = activeClient->second->GetTimersAmount();
    if (NumTimers >= 0)
      strBackendTimers.Format("%i", NumTimers);
    else
      strBackendTimers = g_localizeStrings.Get(161);

    int NumRecordings = activeClient->second->GetRecordingsAmount();
    if (NumRecordings >= 0)
      strBackendRecordings.Format("%i", NumRecordings);
    else
      strBackendRecordings = g_localizeStrings.Get(161);

    strBackendName    = activeClient->second->GetBackendName();
    strBackendVersion = activeClient->second->GetBackendVersion();
    strBackendHost    = activeClient->second->GetConnectionString();
  }

  CSingleLock lock(m_critSection);
  m_strBackendName         = strBackendName;
  m_strBackendVersion      = strBackendVersion;
  m_strBackendHost         = strBackendHost;
  m_strBackendDiskspace    = strBackendDiskspace;
  m_strBackendTimers       = strBackendTimers;
  m_strBackendRecordings   = strBackendRecordings;
  m_strBackendChannels     = strBackendChannels;
  m_iActiveClients         = iActiveClients;
}
示例#2
0
void CPVRGUIInfo::UpdateBackendCache(void)
{
  std::string strBackendName;
  std::string strBackendVersion;
  std::string strBackendHost;
  std::string strBackendDiskspace;
  std::string strBackendTimers;
  std::string strBackendRecordings;
  std::string strBackendChannels;
  long long   iBackendkBUsed(0);
  long long   iBackendkBTotal(0);
  int         iActiveClients(0);

  CPVRClients *clients = g_PVRClients;
  PVR_CLIENTMAP activeClients;
  iActiveClients = clients->GetConnectedClients(activeClients);

  if (iActiveClients > 1 && !AddonInfoToggle())
    return;

  if (iActiveClients > 0)
  {
    PVR_CLIENTMAP_CITR activeClient = activeClients.begin();
    /* safe to read unlocked */
    for (unsigned int i = 0; i < m_iAddonInfoToggleCurrent; i++)
      activeClient++;

    if (activeClient->second->GetDriveSpace(&iBackendkBTotal, &iBackendkBUsed) == PVR_ERROR_NO_ERROR)
    {
      iBackendkBUsed *= 1024;  // Convert to Bytes
      iBackendkBTotal *= 1024; // Convert to Bytes
    }
    else
    {
      iBackendkBUsed = 0;
      iBackendkBTotal = 0;
    }

    int NumChannels = activeClient->second->GetChannelsAmount();
    if (NumChannels >= 0)
      strBackendChannels = StringUtils::Format("%i", NumChannels);
    else
      strBackendChannels = g_localizeStrings.Get(161);

    int NumTimers = activeClient->second->GetTimersAmount();
    if (NumTimers >= 0)
      strBackendTimers = StringUtils::Format("%i", NumTimers);
    else
      strBackendTimers = g_localizeStrings.Get(161);

    int NumRecordings = activeClient->second->GetRecordingsAmount();
    if (NumRecordings >= 0)
      strBackendRecordings = StringUtils::Format("%i", NumRecordings);
    else
      strBackendRecordings = g_localizeStrings.Get(161);

    strBackendName    = activeClient->second->GetBackendName();
    strBackendVersion = activeClient->second->GetBackendVersion();
    strBackendHost    = activeClient->second->GetConnectionString();
  }

  CSingleLock lock(m_critSection);
  m_strBackendName         = strBackendName;
  m_strBackendVersion      = strBackendVersion;
  m_strBackendHost         = strBackendHost;
  m_strBackendTimers       = strBackendTimers;
  m_strBackendRecordings   = strBackendRecordings;
  m_strBackendChannels     = strBackendChannels;
  m_iActiveClients         = iActiveClients;
  m_iBackendUsedDiskspace  = iBackendkBUsed;
  m_iBackendTotalDiskspace = iBackendkBTotal;
}