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; }
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; }
void CPVRGUIInfo::UpdateBackendCache(void) { CSingleLock lock(m_critSection); if (!AddonInfoToggle()) return; m_strBackendName = ""; m_strBackendVersion = ""; m_strBackendHost = ""; m_strBackendDiskspace = ""; m_strBackendTimers = ""; m_strBackendRecordings = ""; m_strBackendChannels = ""; CPVRClients *clients = g_PVRClients; std::map<long, CStdString> activeClients; clients->GetClients(&activeClients); m_iActiveClients = activeClients.size(); if (m_iActiveClients > 0) { std::map<long, CStdString>::iterator activeClient = activeClients.begin(); for (unsigned int i = 0; i < m_iAddonInfoToggleCurrent; i++) activeClient++; long long kBTotal = 0; long long kBUsed = 0; CLIENTMAPITR current = clients->m_clientMap.find(activeClient->first); if (current == clients->m_clientMap.end() || !current->second->ReadyToUse()) return; if (current->second->GetDriveSpace(&kBTotal, &kBUsed) == PVR_ERROR_NO_ERROR) { kBTotal /= 1024; // Convert to MBytes kBUsed /= 1024; // Convert to MBytes m_strBackendDiskspace.Format("%s %.1f GByte - %s: %.1f GByte", g_localizeStrings.Get(20161), (float) kBTotal / 1024, g_localizeStrings.Get(20162), (float) kBUsed / 1024); } else { m_strBackendDiskspace = g_localizeStrings.Get(19055); } int NumChannels = current->second->GetChannelsAmount(); if (NumChannels >= 0) m_strBackendChannels.Format("%i", NumChannels); else m_strBackendChannels = g_localizeStrings.Get(161); int NumTimers = current->second->GetTimersAmount(); if (NumTimers >= 0) m_strBackendTimers.Format("%i", NumTimers); else m_strBackendTimers = g_localizeStrings.Get(161); int NumRecordings = current->second->GetRecordingsAmount(); if (NumRecordings >= 0) m_strBackendRecordings.Format("%i", NumRecordings); else m_strBackendRecordings = g_localizeStrings.Get(161); m_strBackendName = current->second->GetBackendName(); m_strBackendVersion = current->second->GetBackendVersion(); m_strBackendHost = current->second->GetConnectionString(); } }