Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PVR] Support for Kodi Eventlog #8374

Merged
merged 2 commits into from Dec 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion xbmc/pvr/addons/PVRClients.cpp
Expand Up @@ -252,7 +252,7 @@ bool CPVRClients::HasConnectedClients(void) const
return false;
}

bool CPVRClients::GetClientName(int iClientId, std::string &strName) const
bool CPVRClients::GetClientFriendlyName(int iClientId, std::string &strName) const
{
bool bReturn(false);
PVR_CLIENT client;
Expand All @@ -262,6 +262,26 @@ bool CPVRClients::GetClientName(int iClientId, std::string &strName) const
return bReturn;
}

bool CPVRClients::GetClientAddonName(int iClientId, std::string &strName) const
{
bool bReturn(false);
PVR_CLIENT client;
if ((bReturn = GetConnectedClient(iClientId, client)) == true)
strName = client->Name();

return bReturn;
}

bool CPVRClients::GetClientAddonIcon(int iClientId, std::string &strIcon) const
{
bool bReturn(false);
PVR_CLIENT client;
if ((bReturn = GetConnectedClient(iClientId, client)) == true)
strIcon = client->Icon();

return bReturn;
}

std::vector<SBackend> CPVRClients::GetBackendProperties() const
{
std::vector<SBackend> backendProperties;
Expand Down
18 changes: 17 additions & 1 deletion xbmc/pvr/addons/PVRClients.h
Expand Up @@ -160,7 +160,23 @@ namespace PVR
* @param strName The friendly name of the client or an empty string when it wasn't found.
* @return True if the client was found, false otherwise.
*/
bool GetClientName(int iClientId, std::string &strName) const;
bool GetClientFriendlyName(int iClientId, std::string &strName) const;

/*!
* @brief Get the addon name for the client with the given id.
* @param iClientId The id of the client.
* @param strName The addon name of the client or an empty string when it wasn't found.
* @return True if the client was found, false otherwise.
*/
bool GetClientAddonName(int iClientId, std::string &strName) const;

/*!
* @brief Get the addon icon for the client with the given id.
* @param iClientId The id of the client.
* @param strIcon The path to the addon icon of the client or an empty string when it wasn't found.
* @return True if the client was found, false otherwise.
*/
bool GetClientAddonIcon(int iClientId, std::string &strIcon) const;

/*!
* @brief Returns properties about all connected clients
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
Expand Up @@ -685,7 +685,7 @@ void CGUIDialogPVRChannelManager::Update()
channelFile->SetProperty("Number", StringUtils::Format("%i", channel->ChannelNumber()));

std::string clientName;
g_PVRClients->GetClientName(channel->ClientID(), clientName);
g_PVRClients->GetClientFriendlyName(channel->ClientID(), clientName);
channelFile->SetProperty("ClientName", clientName);
channelFile->SetProperty("SupportsSettings", g_PVRClients->SupportsChannelSettings(channel->ClientID()));

Expand Down
12 changes: 0 additions & 12 deletions xbmc/pvr/timers/PVRTimerInfoTag.cpp
Expand Up @@ -857,18 +857,6 @@ std::string CPVRTimerInfoTag::GetDeletedNotificationText() const
return StringUtils::Format("%s: '%s'", g_localizeStrings.Get(stringID).c_str(), m_strTitle.c_str());
}

void CPVRTimerInfoTag::QueueNotification(void) const
{
if (CSettings::GetInstance().GetBool(CSettings::SETTING_PVRRECORD_TIMERNOTIFICATIONS))
{
std::string strMessage;
GetNotificationText(strMessage);

if (!strMessage.empty())
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(19166), strMessage);
}
}

CEpgInfoTagPtr CPVRTimerInfoTag::GetEpgInfoTag(void) const
{
return m_epgTag;
Expand Down
5 changes: 0 additions & 5 deletions xbmc/pvr/timers/PVRTimerInfoTag.h
Expand Up @@ -180,11 +180,6 @@ namespace PVR
unsigned int MarginEnd(void) const { return m_iMarginEnd; }
void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; }

/*!
* @brief Show a notification for this timer in the UI
*/
void QueueNotification(void) const;

/*!
* @brief Get the text for the notification.
* @param strText The notification.
Expand Down
30 changes: 18 additions & 12 deletions xbmc/pvr/timers/PVRTimers.cpp
Expand Up @@ -27,6 +27,8 @@
#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogOK.h"
#include "epg/EpgContainer.h"
#include "events/EventLog.h"
#include "events/NotificationEvent.h"
#include "FileItem.h"
#include "pvr/addons/PVRClients.h"
#include "pvr/channels/PVRChannelGroupsContainer.h"
Expand Down Expand Up @@ -104,7 +106,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers)
{
bool bChanged(false);
bool bAddedOrDeleted(false);
std::vector<std::string> timerNotifications;
std::vector< std::pair< int, std::string> > timerNotifications;

CSingleLock lock(m_critSection);

Expand All @@ -128,7 +130,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers)
{
std::string strMessage;
existingTimer->GetNotificationText(strMessage);
timerNotifications.push_back(strMessage);
timerNotifications.push_back(std::make_pair((*timerIt)->m_iClientId, strMessage));
}

CLog::Log(LOGDEBUG,"PVRTimers - %s - updated timer %d on client %d",
Expand Down Expand Up @@ -164,7 +166,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers)
{
std::string strMessage;
newTimer->GetNotificationText(strMessage);
timerNotifications.push_back(strMessage);
timerNotifications.push_back(std::make_pair(newTimer->m_iClientId, strMessage));
}

CLog::Log(LOGDEBUG,"PVRTimers - %s - added timer %d on client %d",
Expand All @@ -189,7 +191,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers)
__FUNCTION__, timer->m_iClientIndex, timer->m_iClientId);

if (g_PVRManager.IsStarted())
timerNotifications.push_back(timer->GetDeletedNotificationText());
timerNotifications.push_back(std::make_pair(timer->m_iClientId, timer->GetDeletedNotificationText()));

/** clear the EPG tag explicitly here, because it no longer happens automatically with shared pointers */
timer->ClearEpgTag();
Expand Down Expand Up @@ -254,15 +256,19 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers)

NotifyObservers(bAddedOrDeleted ? ObservableMessageTimersReset : ObservableMessageTimers);

if (CSettings::GetInstance().GetBool(CSettings::SETTING_PVRRECORD_TIMERNOTIFICATIONS))
/* queue notifications / fill eventlog*/
for (const auto &entry : timerNotifications)
{
/* queue notifications */
for (unsigned int iNotificationPtr = 0; iNotificationPtr < timerNotifications.size(); iNotificationPtr++)
{
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info,
g_localizeStrings.Get(19166),
timerNotifications.at(iNotificationPtr));
}
if (CSettings::GetInstance().GetBool(CSettings::SETTING_PVRRECORD_TIMERNOTIFICATIONS))
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(19166), entry.second);

std::string strName;
g_PVRClients->GetClientAddonName(entry.first, strName);

std::string strIcon;
g_PVRClients->GetClientAddonIcon(entry.first, strIcon);

CEventLog::GetInstance().Add(EventPtr(new CNotificationEvent(strName, entry.second, strIcon, EventLevelInformation)));
}
}

Expand Down