From dab17829fb6b69bf3c96888c0c9675747384c535 Mon Sep 17 00:00:00 2001 From: enen92 <92enen@gmail.com> Date: Mon, 14 Oct 2024 15:07:32 +0100 Subject: [Zeroconf] Use announcements instead of direct GUI messages --- xbmc/network/ZeroconfBrowser.h | 3 +-- xbmc/network/mdns/ZeroconfBrowserMDNS.cpp | 14 ++++++-------- xbmc/platform/android/network/ZeroconfBrowserAndroid.cpp | 13 +++++-------- xbmc/platform/darwin/network/ZeroconfBrowserDarwin.cpp | 13 +++++-------- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/xbmc/network/ZeroconfBrowser.h b/xbmc/network/ZeroconfBrowser.h index 76a4439a11..7f104eabc5 100644 --- a/xbmc/network/ZeroconfBrowser.h +++ b/xbmc/network/ZeroconfBrowser.h @@ -89,8 +89,7 @@ public: void Stop(); ///returns the list of found services - /// if this is updated, the following message with "zeroconf://" as path is sent: - /// CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH); + /// if this is updated, a source update announcement with "zeroconf://" as path is sent: std::vector GetFoundServices(); ///@} diff --git a/xbmc/network/mdns/ZeroconfBrowserMDNS.cpp b/xbmc/network/mdns/ZeroconfBrowserMDNS.cpp index c4a1c1ecab..9546dcc6b5 100644 --- a/xbmc/network/mdns/ZeroconfBrowserMDNS.cpp +++ b/xbmc/network/mdns/ZeroconfBrowserMDNS.cpp @@ -8,11 +8,8 @@ #include "ZeroconfBrowserMDNS.h" -#include "GUIUserMessages.h" #include "ServiceBroker.h" -#include "guilib/GUIComponent.h" -#include "guilib/GUIMessage.h" -#include "guilib/GUIWindowManager.h" +#include "interfaces/AnnouncementManager.h" #include "network/DNSNameCache.h" #include "utils/log.h" @@ -88,10 +85,11 @@ void DNSSD_API CZeroconfBrowserMDNS::BrowserCallback(DNSServiceRef browser, } if(! (flags & kDNSServiceFlagsMoreComing) ) { - CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH); - message.SetStringParam("zeroconf://"); - CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(message); - CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback sent gui update for path zeroconf://"); + CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Sources, "OnUpdated", + CVariant{"zeroconf://"}); + CLog::Log( + LOGDEBUG, + "ZeroconfBrowserMDNS::BrowserCallback sent source update announce for path zeroconf://"); } } else diff --git a/xbmc/platform/android/network/ZeroconfBrowserAndroid.cpp b/xbmc/platform/android/network/ZeroconfBrowserAndroid.cpp index dd6db2576b..d31564f5ea 100644 --- a/xbmc/platform/android/network/ZeroconfBrowserAndroid.cpp +++ b/xbmc/platform/android/network/ZeroconfBrowserAndroid.cpp @@ -8,11 +8,8 @@ #include "ZeroconfBrowserAndroid.h" -#include "GUIUserMessages.h" #include "ServiceBroker.h" -#include "guilib/GUIComponent.h" -#include "guilib/GUIMessage.h" -#include "guilib/GUIWindowManager.h" +#include "interfaces/AnnouncementManager.h" #include "network/DNSNameCache.h" #include "utils/log.h" @@ -241,10 +238,10 @@ void CZeroconfBrowserAndroidDiscover::onServiceFound(const jni::CJNINsdServiceIn s.GetName(), s.GetType(), s.GetDomain()); m_browser->addDiscoveredService(this, s); - CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH); - message.SetStringParam("zeroconf://"); - CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(message); - CLog::Log(LOGDEBUG, "CZeroconfBrowserAndroidDiscover::onServiceFound sent gui update for path zeroconf://"); + CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Sources, "OnUpdated", + CVariant{"zeroconf://"}); + CLog::Log(LOGDEBUG, "CZeroconfBrowserAndroidDiscover::onServiceFound sent source update announce " + "for path zeroconf://"); } void CZeroconfBrowserAndroidDiscover::onServiceLost(const jni::CJNINsdServiceInfo& serviceInfo) diff --git a/xbmc/platform/darwin/network/ZeroconfBrowserDarwin.cpp b/xbmc/platform/darwin/network/ZeroconfBrowserDarwin.cpp index 50515d0879..e2078a3520 100644 --- a/xbmc/platform/darwin/network/ZeroconfBrowserDarwin.cpp +++ b/xbmc/platform/darwin/network/ZeroconfBrowserDarwin.cpp @@ -8,11 +8,8 @@ #include "ZeroconfBrowserDarwin.h" -#include "GUIUserMessages.h" #include "ServiceBroker.h" -#include "guilib/GUIComponent.h" -#include "guilib/GUIMessage.h" -#include "guilib/GUIWindowManager.h" +#include "interfaces/AnnouncementManager.h" #include "utils/log.h" #include "platform/darwin/DarwinUtils.h" @@ -168,10 +165,10 @@ void CZeroconfBrowserDarwin::BrowserCallback(CFNetServiceBrowserRef browser, CFO } if (! (flags & kCFNetServiceFlagMoreComing) ) { - CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH); - message.SetStringParam("zeroconf://"); - CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(message); - CLog::Log(LOGDEBUG, "CZeroconfBrowserDarwin::BrowserCallback sent gui update for path zeroconf://"); + CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Sources, "OnUpdated", + CVariant{"zeroconf://"}); + CLog::Log(LOGDEBUG, "CZeroconfBrowserDarwin::BrowserCallback sent sources update " + "announcement for path zeroconf://"); } } else { -- cgit v1.2.3