aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2017-02-11 22:31:32 +0100
committerKai Sommerfeld <kai.sommerfeld@gmx.com>2017-02-16 22:19:23 +0100
commitfc99e0bb42a7cc7274bad22eb278cb2ca5f7d555 (patch)
tree7de174d5e39ae1fbe0a0fd302845f85504003019
parenta23d810bc9bf3211678087d547d93eebd1b32449 (diff)
[PVR] CPVRClients is gui code free, finally.
-rw-r--r--addons/resource.language.en_gb/resources/strings.po4
-rw-r--r--xbmc/pvr/PVRJobs.cpp16
-rw-r--r--xbmc/pvr/PVRJobs.h17
-rw-r--r--xbmc/pvr/addons/PVRClients.cpp47
-rw-r--r--xbmc/pvr/addons/PVRClients.h12
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp21
6 files changed, 65 insertions, 52 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index 9c962eee84..86df4b26c2 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -9115,7 +9115,7 @@ msgstr ""
#. generic 'information' label used in different places, like labels for message box headers
#: xbmc/event/windows/GUIWindowEventLog.cpp
-#: xbmc/pvr/addons/PVRClients.cpp
+#: xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
#: xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp
#: xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp
#: xbmc/pvr/recordings/PVRRecording.cpp
@@ -9156,7 +9156,7 @@ msgid "Show signal quality"
msgstr ""
#. message box text stating that a PVR backend does not support a certain functionality.
-#: xbmc/pvr/addons/PVRClients.cpp
+#: xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
msgctxt "#19038"
msgid "Not supported by the PVR backend."
msgstr ""
diff --git a/xbmc/pvr/PVRJobs.cpp b/xbmc/pvr/PVRJobs.cpp
index 52281b2d77..705d07360f 100644
--- a/xbmc/pvr/PVRJobs.cpp
+++ b/xbmc/pvr/PVRJobs.cpp
@@ -20,6 +20,10 @@
#include "PVRJobs.h"
+#include "dialogs/GUIDialogKaiToast.h"
+#include "events/EventLog.h"
+#include "events/NotificationEvent.h"
+
#include "pvr/PVRGUIActions.h"
namespace PVR
@@ -35,4 +39,16 @@ bool CPVRContinueLastChannelJob::DoWork()
return CPVRGUIActions::GetInstance().ContinueLastPlayedChannel();
}
+bool CPVREventlogJob::DoWork()
+{
+ if (m_bNotifyUser)
+ CGUIDialogKaiToast::QueueNotification(
+ m_bError ? CGUIDialogKaiToast::Error : CGUIDialogKaiToast::Info, m_label.c_str(), m_msg, 5000, true);
+
+ // Write event log entry.
+ CEventLog::GetInstance().Add(
+ EventPtr(new CNotificationEvent(m_label, m_msg, m_icon, m_bError ? EventLevel::Error : EventLevel::Information)));
+ return true;
+}
+
} // namespace PVR
diff --git a/xbmc/pvr/PVRJobs.h b/xbmc/pvr/PVRJobs.h
index 6d7ec7d2a4..a904a7d4bf 100644
--- a/xbmc/pvr/PVRJobs.h
+++ b/xbmc/pvr/PVRJobs.h
@@ -49,4 +49,21 @@ namespace PVR
bool DoWork() override;
};
+ class CPVREventlogJob : public CJob
+ {
+ public:
+ CPVREventlogJob(bool bNotifyUser, bool bError, const std::string &label, const std::string &msg, const std::string &icon)
+ : m_bNotifyUser(bNotifyUser), m_bError(bError), m_label(label), m_msg(msg), m_icon(icon) {}
+ virtual ~CPVREventlogJob() {}
+ const char *GetType() const override { return "pvr-eventlog-job"; }
+
+ bool DoWork() override;
+ private:
+ bool m_bNotifyUser;
+ bool m_bError;
+ std::string m_label;
+ std::string m_msg;
+ std::string m_icon;
+ };
+
} // namespace PVR
diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp
index 16177cc1be..1bd94dc84f 100644
--- a/xbmc/pvr/addons/PVRClients.cpp
+++ b/xbmc/pvr/addons/PVRClients.cpp
@@ -27,18 +27,14 @@
#include "Application.h"
#include "ServiceBroker.h"
#include "cores/IPlayer.h"
-#include "dialogs/GUIDialogOK.h"
-#include "dialogs/GUIDialogKaiToast.h"
-#include "events/EventLog.h"
-#include "events/NotificationEvent.h"
#include "messaging/ApplicationMessenger.h"
#include "pvr/channels/PVRChannelGroupInternal.h"
#include "pvr/channels/PVRChannelGroups.h"
+#include "pvr/PVRJobs.h"
#include "pvr/PVRManager.h"
#include "pvr/recordings/PVRRecordings.h"
#include "pvr/timers/PVRTimers.h"
#include "utils/log.h"
-#include "utils/Variant.h"
using namespace ADDON;
using namespace PVR;
@@ -888,8 +884,7 @@ std::vector<PVR_CLIENT> CPVRClients::GetClientsSupportingChannelSettings(bool bR
return possibleSettingsClients;
}
-
-bool CPVRClients::OpenDialogChannelAdd(const CPVRChannelPtr &channel)
+PVR_ERROR CPVRClients::OpenDialogChannelAdd(const CPVRChannelPtr &channel)
{
PVR_ERROR error = PVR_ERROR_UNKNOWN;
@@ -899,16 +894,10 @@ bool CPVRClients::OpenDialogChannelAdd(const CPVRChannelPtr &channel)
else
CLog::Log(LOGERROR, "PVR - %s - cannot find client %d",__FUNCTION__, channel->ClientID());
- if (error == PVR_ERROR_NOT_IMPLEMENTED)
- {
- CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038});
- return true;
- }
-
- return error == PVR_ERROR_NO_ERROR;
+ return error;
}
-bool CPVRClients::OpenDialogChannelSettings(const CPVRChannelPtr &channel)
+PVR_ERROR CPVRClients::OpenDialogChannelSettings(const CPVRChannelPtr &channel)
{
PVR_ERROR error = PVR_ERROR_UNKNOWN;
@@ -918,16 +907,10 @@ bool CPVRClients::OpenDialogChannelSettings(const CPVRChannelPtr &channel)
else
CLog::Log(LOGERROR, "PVR - %s - cannot find client %d",__FUNCTION__, channel->ClientID());
- if (error == PVR_ERROR_NOT_IMPLEMENTED)
- {
- CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038});
- return true;
- }
-
- return error == PVR_ERROR_NO_ERROR;
+ return error;
}
-bool CPVRClients::DeleteChannel(const CPVRChannelPtr &channel)
+PVR_ERROR CPVRClients::DeleteChannel(const CPVRChannelPtr &channel)
{
PVR_ERROR error = PVR_ERROR_UNKNOWN;
@@ -937,13 +920,7 @@ bool CPVRClients::DeleteChannel(const CPVRChannelPtr &channel)
else
CLog::Log(LOGERROR, "PVR - %s - cannot find client %d",__FUNCTION__, channel->ClientID());
- if (error == PVR_ERROR_NOT_IMPLEMENTED)
- {
- CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038});
- return true;
- }
-
- return error == PVR_ERROR_NO_ERROR;
+ return error;
}
bool CPVRClients::RenameChannel(const CPVRChannelPtr &channel)
@@ -1013,8 +990,8 @@ void CPVRClients::UpdateAddons(void)
CLog::Log(LOGERROR, "%s - failed to create add-on %s, status = %d", __FUNCTION__, addon->Name().c_str(), status);
if (status == ADDON_STATUS_PERMANENT_FAILURE)
{
- CGUIDialogOK::ShowAndGetInput(CVariant{24070}, CVariant{16029});
CAddonMgr::GetInstance().DisableAddon(addon->ID());
+ CJobManager::GetInstance().AddJob(new CPVREventlogJob(true, true, addon->Name(), g_localizeStrings.Get(24070), addon->Icon()), nullptr);
}
}
}
@@ -1412,13 +1389,7 @@ void CPVRClients::ConnectionStateChange(CPVRClient *client, std::string &strConn
strMsg = g_localizeStrings.Get(iMsg);
// Notify user.
- if (bNotify)
- CGUIDialogKaiToast::QueueNotification(bError ? CGUIDialogKaiToast::Error : CGUIDialogKaiToast::Info, client->Name().c_str(),
- strMsg, 5000, true);
-
- // Write event log entry.
- CEventLog::GetInstance().Add(EventPtr(new CNotificationEvent(client->Name(), strMsg, client->Icon(),
- bError ? EventLevel::Error : EventLevel::Information)));
+ CJobManager::GetInstance().AddJob(new CPVREventlogJob(bNotify, bError, client->Name(), strMsg, client->Icon()), nullptr);
if (newState == PVR_CONNECTION_STATE_CONNECTED)
{
diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h
index af2db35c43..39283fe74c 100644
--- a/xbmc/pvr/addons/PVRClients.h
+++ b/xbmc/pvr/addons/PVRClients.h
@@ -608,23 +608,23 @@ namespace PVR
/*!
* @brief Open addon settings dialog to add a channel
* @param channel The channel to edit.
- * @return True if the edit was successful, false otherwise.
+ * @return PVR_ERROR_NO_ERROR if the dialog was opened successfully, the respective error code otherwise.
*/
- bool OpenDialogChannelAdd(const CPVRChannelPtr &channel);
+ PVR_ERROR OpenDialogChannelAdd(const CPVRChannelPtr &channel);
/*!
* @brief Open addon settings dialog to related channel
* @param channel The channel to edit.
- * @return True if the edit was successful, false otherwise.
+ * @return PVR_ERROR_NO_ERROR if the dialog was opened successfully, the respective error code otherwise.
*/
- bool OpenDialogChannelSettings(const CPVRChannelPtr &channel);
+ PVR_ERROR OpenDialogChannelSettings(const CPVRChannelPtr &channel);
/*!
* @brief Inform addon to delete channel
* @param channel The channel to delete.
- * @return True if it was successful, false otherwise.
+ * @return PVR_ERROR_NO_ERROR if the channel was deleted successfully, the respective error code otherwise.
*/
- bool DeleteChannel(const CPVRChannelPtr &channel);
+ PVR_ERROR DeleteChannel(const CPVRChannelPtr &channel);
/*!
* @brief Request the client to rename given channel
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
index ff0066926a..d3277a76c1 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
@@ -470,10 +470,13 @@ bool CGUIDialogPVRChannelManager::OnClickButtonNewChannel()
channel->SetEPGEnabled(g_PVRClients->SupportsEPG(iClientID));
channel->SetClientID(iClientID);
- if (g_PVRClients->OpenDialogChannelAdd(channel))
+ PVR_ERROR ret = g_PVRClients->OpenDialogChannelAdd(channel);
+ if (ret == PVR_ERROR_NO_ERROR)
Update();
+ else if (ret == PVR_ERROR_NOT_IMPLEMENTED)
+ CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038}); // "Information", "Not supported by the PVR backend."
else
- CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // Add-on error;Check the log file for details.
+ CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // "Add-on error", "Check the log for more information about this message."
}
return true;
}
@@ -599,8 +602,11 @@ bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON
}
else if (button == CONTEXT_BUTTON_SETTINGS)
{
- if (!g_PVRClients->OpenDialogChannelSettings(pItem->GetPVRChannelInfoTag()))
- CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // Add-on error;Check the log file for details.
+ PVR_ERROR ret = g_PVRClients->OpenDialogChannelSettings(pItem->GetPVRChannelInfoTag());
+ if (ret == PVR_ERROR_NOT_IMPLEMENTED)
+ CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038}); // "Information", "Not supported by the PVR backend."
+ else if (ret != PVR_ERROR_NO_ERROR)
+ CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // "Add-on error", "Check the log for more information about this message."
}
else if (button == CONTEXT_BUTTON_DELETE)
{
@@ -615,15 +621,18 @@ bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON
if (pDialog->IsConfirmed())
{
CPVRChannelPtr channel = pItem->GetPVRChannelInfoTag();
- if (g_PVRClients->DeleteChannel(channel))
+ PVR_ERROR ret = g_PVRClients->DeleteChannel(channel);
+ if (ret == PVR_ERROR_NO_ERROR)
{
g_PVRChannelGroups->GetGroupAll(channel->IsRadio())->RemoveFromGroup(channel);
m_channelItems->Remove(m_iSelected);
m_viewControl.SetItems(*m_channelItems);
Renumber();
}
+ else if (ret == PVR_ERROR_NOT_IMPLEMENTED)
+ CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038}); // "Information", "Not supported by the PVR backend."
else
- CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // Add-on error;Check the log file for details.
+ CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // "Add-on error", "Check the log for more information about this message."
}
}
else if (button == CONTEXT_BUTTON_EDIT_SOURCE)