diff options
author | Pär Björklund <per.bjorklund@gmail.com> | 2015-05-06 16:37:23 +0200 |
---|---|---|
committer | Pär Björklund <per.bjorklund@gmail.com> | 2015-07-15 18:43:55 +0200 |
commit | 9e9396b073ba973b2847896a11244a9f37ecbaff (patch) | |
tree | 6feb26cb18dc1df4c8bc089f93d17f825c62df47 | |
parent | 753e2e819b8a3ed2ee4f9f71f77d03d13fa3a9f6 (diff) |
Clean up ApplicationMessenger
ApplicationMessenger had become a place to stick all kinds of convenience
methods and depending on just about everything. This PR cleans this up
and returns it back to a messaging class.
Removed the bool parameters and used naming from Win32 API with
SendMsg for blocking and PostMsg for non-blocking messaging.
110 files changed, 1965 insertions, 2081 deletions
diff --git a/Kodi.xcodeproj/project.pbxproj b/Kodi.xcodeproj/project.pbxproj index 58dec6a8c7..69e177a906 100644 --- a/Kodi.xcodeproj/project.pbxproj +++ b/Kodi.xcodeproj/project.pbxproj @@ -857,6 +857,9 @@ DF40BC31178B4C07009DB567 /* ScriptInvocationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF40BC27178B4C07009DB567 /* ScriptInvocationManager.cpp */; }; DF448457140048A60069344B /* AirTunesServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF448455140048A60069344B /* AirTunesServer.cpp */; }; DF44845E140048C80069344B /* PipesManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF44845B140048C80069344B /* PipesManager.cpp */; }; + DF4A3BB21B4B0FC100F9CDC0 /* ApplicationMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4A3BAD1B4B0FC100F9CDC0 /* ApplicationMessenger.cpp */; }; + DF4A3BB31B4B0FC100F9CDC0 /* ApplicationMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4A3BAD1B4B0FC100F9CDC0 /* ApplicationMessenger.cpp */; }; + DF4A3BB41B4B0FC100F9CDC0 /* ApplicationMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4A3BAD1B4B0FC100F9CDC0 /* ApplicationMessenger.cpp */; }; DF4BF0151A4EF30F0053AC56 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */; }; DF4BF0161A4EF30F0053AC56 /* cc_decoder708.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */; }; DF4BF0171A4EF31E0053AC56 /* cc_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */; }; @@ -1771,7 +1774,6 @@ DFF0F42717528350002DA3A4 /* GUIWindowSystemInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E18390D25F9FA00618676 /* GUIWindowSystemInfo.cpp */; }; DFF0F42817528350002DA3A4 /* GUIWindowWeather.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E18490D25F9FA00618676 /* GUIWindowWeather.cpp */; }; DFF0F43117528350002DA3A4 /* Application.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14640D25F9F900618676 /* Application.cpp */; }; - DFF0F43217528350002DA3A4 /* ApplicationMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14660D25F9F900618676 /* ApplicationMessenger.cpp */; }; DFF0F43317528350002DA3A4 /* AppParamParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352C616E5436900D21BAD /* AppParamParser.cpp */; }; DFF0F43417528350002DA3A4 /* Autorun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E146E0D25F9F900618676 /* Autorun.cpp */; }; DFF0F43517528350002DA3A4 /* AutoSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14700D25F9F900618676 /* AutoSwitch.cpp */; }; @@ -1875,7 +1877,6 @@ E36C29EC0DA72486001F0C9D /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; }; E38A06CE0D95AA5500FF8227 /* GUIDialogKaiToast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38A06CC0D95AA5500FF8227 /* GUIDialogKaiToast.cpp */; }; E38E1F370D25F9FD00618676 /* Application.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14640D25F9F900618676 /* Application.cpp */; }; - E38E1F380D25F9FD00618676 /* ApplicationMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14660D25F9F900618676 /* ApplicationMessenger.cpp */; }; E38E1F3C0D25F9FD00618676 /* Autorun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E146E0D25F9F900618676 /* Autorun.cpp */; }; E38E1F3D0D25F9FD00618676 /* AutoSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14700D25F9F900618676 /* AutoSwitch.cpp */; }; E38E1F3E0D25F9FD00618676 /* BackgroundInfoLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14720D25F9F900618676 /* BackgroundInfoLoader.cpp */; }; @@ -2947,7 +2948,6 @@ E49914AB174E607200741B6D /* GUIWindowSystemInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E18390D25F9FA00618676 /* GUIWindowSystemInfo.cpp */; }; E49914AC174E607200741B6D /* GUIWindowWeather.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E18490D25F9FA00618676 /* GUIWindowWeather.cpp */; }; E499152C174E640800741B6D /* Application.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14640D25F9F900618676 /* Application.cpp */; }; - E499152D174E642900741B6D /* ApplicationMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14660D25F9F900618676 /* ApplicationMessenger.cpp */; }; E499152E174E642900741B6D /* AppParamParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56352C616E5436900D21BAD /* AppParamParser.cpp */; }; E499152F174E642900741B6D /* Autorun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E146E0D25F9F900618676 /* Autorun.cpp */; }; E4991530174E642900741B6D /* AutoSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E14700D25F9F900618676 /* AutoSwitch.cpp */; }; @@ -4445,6 +4445,10 @@ DF448456140048A60069344B /* AirTunesServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AirTunesServer.h; sourceTree = "<group>"; }; DF44845B140048C80069344B /* PipesManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PipesManager.cpp; sourceTree = "<group>"; }; DF44845C140048C80069344B /* PipesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PipesManager.h; sourceTree = "<group>"; }; + DF4A3BAD1B4B0FC100F9CDC0 /* ApplicationMessenger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationMessenger.cpp; sourceTree = "<group>"; }; + DF4A3BAE1B4B0FC100F9CDC0 /* ApplicationMessenger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationMessenger.h; sourceTree = "<group>"; }; + DF4A3BAF1B4B0FC100F9CDC0 /* IMessageTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMessageTarget.h; sourceTree = "<group>"; }; + DF4A3BB11B4B0FC100F9CDC0 /* ThreadMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadMessage.h; sourceTree = "<group>"; }; DF4BF0111A4EF30F0053AC56 /* cc_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cc_decoder.c; sourceTree = "<group>"; }; DF4BF0121A4EF30F0053AC56 /* cc_decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc_decoder.h; sourceTree = "<group>"; }; DF4BF0131A4EF30F0053AC56 /* cc_decoder708.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cc_decoder708.cpp; sourceTree = "<group>"; }; @@ -4712,8 +4716,6 @@ E38A06CD0D95AA5500FF8227 /* GUIDialogKaiToast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogKaiToast.h; sourceTree = "<group>"; }; E38E14640D25F9F900618676 /* Application.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Application.cpp; sourceTree = "<group>"; }; E38E14650D25F9F900618676 /* Application.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Application.h; sourceTree = "<group>"; }; - E38E14660D25F9F900618676 /* ApplicationMessenger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationMessenger.cpp; sourceTree = "<group>"; }; - E38E14670D25F9F900618676 /* ApplicationMessenger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationMessenger.h; sourceTree = "<group>"; }; E38E146E0D25F9F900618676 /* Autorun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Autorun.cpp; sourceTree = "<group>"; }; E38E146F0D25F9F900618676 /* Autorun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autorun.h; sourceTree = "<group>"; }; E38E14700D25F9F900618676 /* AutoSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoSwitch.cpp; sourceTree = "<group>"; }; @@ -7787,6 +7789,17 @@ path = generic; sourceTree = "<group>"; }; + DF4A3BAC1B4B0FC100F9CDC0 /* messaging */ = { + isa = PBXGroup; + children = ( + DF4A3BAD1B4B0FC100F9CDC0 /* ApplicationMessenger.cpp */, + DF4A3BAE1B4B0FC100F9CDC0 /* ApplicationMessenger.h */, + DF4A3BAF1B4B0FC100F9CDC0 /* IMessageTarget.h */, + DF4A3BB11B4B0FC100F9CDC0 /* ThreadMessage.h */, + ); + path = messaging; + sourceTree = "<group>"; + }; DF4BF0101A4EF30F0053AC56 /* contrib */ = { isa = PBXGroup; children = ( @@ -8152,6 +8165,7 @@ 7C430161175C41FE009B82E5 /* listproviders */, 552A226615F7E11B0015C0D0 /* main */, 7CF0504F191195DA00222135 /* media */, + DF4A3BAC1B4B0FC100F9CDC0 /* messaging */, 18B7C853129423A7009E7A26 /* music */, 431376F212D6449100680C15 /* network */, E37D5CB40D3023BB0081D327 /* osx */, @@ -8174,8 +8188,6 @@ 43D82FF512D64C8600B38489 /* windows */, E38E14640D25F9F900618676 /* Application.cpp */, E38E14650D25F9F900618676 /* Application.h */, - E38E14660D25F9F900618676 /* ApplicationMessenger.cpp */, - E38E14670D25F9F900618676 /* ApplicationMessenger.h */, F59EED7C17AD5174005BB7C6 /* ApplicationPlayer.cpp */, F59EED7D17AD5174005BB7C6 /* ApplicationPlayer.h */, F56352C616E5436900D21BAD /* AppParamParser.cpp */, @@ -10077,7 +10089,6 @@ files = ( E38E1F370D25F9FD00618676 /* Application.cpp in Sources */, 399442771A8DD920006C39E9 /* VideoLibraryProgressJob.cpp in Sources */, - E38E1F380D25F9FD00618676 /* ApplicationMessenger.cpp in Sources */, E38E1F3C0D25F9FD00618676 /* Autorun.cpp in Sources */, E38E1F3D0D25F9FD00618676 /* AutoSwitch.cpp in Sources */, E38E1F3E0D25F9FD00618676 /* BackgroundInfoLoader.cpp in Sources */, @@ -11101,6 +11112,7 @@ 7CCDAC9219275CA70074CF51 /* NptBsdSockets.cpp in Sources */, 7CCDACA719275D1F0074CF51 /* NptStdcDebug.cpp in Sources */, 7CCDACB019275D1F0074CF51 /* NptStdcEnvironment.cpp in Sources */, + DF4A3BB21B4B0FC100F9CDC0 /* ApplicationMessenger.cpp in Sources */, 7CCDACC119275D790074CF51 /* NptAppleAutoreleasePool.mm in Sources */, 7CCDACCA19275D790074CF51 /* NptAppleLogConfig.mm in Sources */, 7CAA469019427AED00008885 /* PosixDirectory.cpp in Sources */, @@ -11898,7 +11910,6 @@ DFF0F42717528350002DA3A4 /* GUIWindowSystemInfo.cpp in Sources */, DFF0F42817528350002DA3A4 /* GUIWindowWeather.cpp in Sources */, DFF0F43117528350002DA3A4 /* Application.cpp in Sources */, - DFF0F43217528350002DA3A4 /* ApplicationMessenger.cpp in Sources */, DFF0F43317528350002DA3A4 /* AppParamParser.cpp in Sources */, DFF0F43417528350002DA3A4 /* Autorun.cpp in Sources */, DFF0F43517528350002DA3A4 /* AutoSwitch.cpp in Sources */, @@ -12028,6 +12039,7 @@ F5CC22E51814FF3B006B5E91 /* ActiveAE.cpp in Sources */, F5CC22E61814FF3B006B5E91 /* ActiveAEBuffer.cpp in Sources */, F5CC22E81814FF3B006B5E91 /* ActiveAESink.cpp in Sources */, + DF4A3BB41B4B0FC100F9CDC0 /* ApplicationMessenger.cpp in Sources */, F5CC22E91814FF3B006B5E91 /* ActiveAESound.cpp in Sources */, F5CC22EA1814FF3B006B5E91 /* ActiveAEStream.cpp in Sources */, F5CC22FE18150065006B5E91 /* ActorProtocol.cpp in Sources */, @@ -12308,6 +12320,7 @@ E49911F9174E5D4500741B6D /* DVDMessage.cpp in Sources */, E49911FA174E5D4500741B6D /* DVDMessageQueue.cpp in Sources */, E49911FC174E5D4500741B6D /* DVDOverlayContainer.cpp in Sources */, + DF4A3BB31B4B0FC100F9CDC0 /* ApplicationMessenger.cpp in Sources */, E49911FD174E5D4500741B6D /* DVDOverlayRenderer.cpp in Sources */, E49911FF174E5D4500741B6D /* DVDPlayer.cpp in Sources */, E4991200174E5D4500741B6D /* DVDPlayerAudio.cpp in Sources */, @@ -12942,7 +12955,6 @@ E49914AB174E607200741B6D /* GUIWindowSystemInfo.cpp in Sources */, E49914AC174E607200741B6D /* GUIWindowWeather.cpp in Sources */, E499152C174E640800741B6D /* Application.cpp in Sources */, - E499152D174E642900741B6D /* ApplicationMessenger.cpp in Sources */, E499152E174E642900741B6D /* AppParamParser.cpp in Sources */, E499152F174E642900741B6D /* Autorun.cpp in Sources */, E4991530174E642900741B6D /* AutoSwitch.cpp in Sources */, diff --git a/Makefile.in b/Makefile.in index eba70f9c98..c420df6b63 100644 --- a/Makefile.in +++ b/Makefile.in @@ -58,6 +58,7 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \ xbmc/listproviders/listproviders.a \ xbmc/main/main.a \ xbmc/media/media.a \ + xbmc/messaging/messaging.a \ xbmc/music/dialogs/musicdialogs.a \ xbmc/music/infoscanner/musicscanner.a \ xbmc/music/karaoke/karaoke.a \ diff --git a/configure.ac b/configure.ac index fffafae203..d321f7dc74 100644 --- a/configure.ac +++ b/configure.ac @@ -2470,6 +2470,7 @@ OUTPUT_FILES="Makefile \ xbmc/cores/paplayer/Makefile \ xbmc/cores/omxplayer/Makefile \ xbmc/cores/playercorefactory/Makefile \ + xbmc/messaging/Makefile \ xbmc/music/karaoke/Makefile \ xbmc/osx/Makefile \ xbmc/guilib/Makefile \ diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index 4c61fd4c97..69aafb5c8c 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -204,7 +204,6 @@ <ClCompile Include="..\..\xbmc\addons\UISoundsResource.cpp" /> <ClCompile Include="..\..\xbmc\addons\Webinterface.cpp" /> <ClCompile Include="..\..\xbmc\Application.cpp" /> - <ClCompile Include="..\..\xbmc\ApplicationMessenger.cpp" /> <ClCompile Include="..\..\xbmc\ApplicationPlayer.cpp" /> <ClCompile Include="..\..\xbmc\AppParamParser.cpp" /> <ClCompile Include="..\..\xbmc\Autorun.cpp" /> @@ -604,6 +603,7 @@ </ClCompile> <ClCompile Include="..\..\xbmc\MediaSource.cpp" /> <ClCompile Include="..\..\xbmc\media\MediaType.cpp" /> + <ClCompile Include="..\..\xbmc\messaging\ApplicationMessenger.cpp" /> <ClCompile Include="..\..\xbmc\music\Album.cpp" /> <ClCompile Include="..\..\xbmc\music\Artist.cpp" /> <ClCompile Include="..\..\xbmc\music\CueInfoLoader.cpp" /> @@ -994,6 +994,9 @@ <ClInclude Include="..\..\xbmc\interfaces\python\pythreadstate.h" /> <ClInclude Include="..\..\xbmc\main\win32\MessagePrinter.h" /> <ClInclude Include="..\..\xbmc\media\MediaType.h" /> + <ClInclude Include="..\..\xbmc\messaging\ApplicationMessenger.h" /> + <ClInclude Include="..\..\xbmc\messaging\IMessageTarget.h" /> + <ClInclude Include="..\..\xbmc\messaging\ThreadMessage.h" /> <ClInclude Include="..\..\xbmc\music\CueInfoLoader.h" /> <ClInclude Include="..\..\xbmc\music\EmbeddedArt.h" /> <ClInclude Include="..\..\xbmc\music\karaoke\karaokevideobackground.h" /> @@ -1700,7 +1703,6 @@ <ClInclude Include="..\..\xbmc\addons\Service.h" /> <ClInclude Include="..\..\xbmc\addons\Skin.h" /> <ClInclude Include="..\..\xbmc\Application.h" /> - <ClInclude Include="..\..\xbmc\ApplicationMessenger.h" /> <ClInclude Include="..\..\xbmc\Autorun.h" /> <ClInclude Include="..\..\xbmc\AutoSwitch.h" /> <ClInclude Include="..\..\xbmc\BackgroundInfoLoader.h" /> diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index eb3d565e97..4a7dce5fba 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -352,6 +352,9 @@ <Filter Include="main\win32"> <UniqueIdentifier>{b2cf6073-0796-485b-a2f8-0b54851262b3}</UniqueIdentifier> </Filter> + <Filter Include="messaging"> + <UniqueIdentifier>{378b3a72-20d2-4482-8dbb-91f041290ceb}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClCompile Include="..\..\xbmc\win32\pch.cpp"> @@ -2217,7 +2220,6 @@ <ClCompile Include="..\..\xbmc\utils\Screenshot.cpp"> <Filter>utils</Filter> </ClCompile> - <ClCompile Include="..\..\xbmc\ApplicationMessenger.cpp" /> <ClCompile Include="..\..\xbmc\Autorun.cpp" /> <ClCompile Include="..\..\xbmc\AutoSwitch.cpp" /> <ClCompile Include="..\..\xbmc\DynamicDll.cpp" /> @@ -3111,6 +3113,9 @@ <ClCompile Include="..\..\xbmc\main\win32\MessagePrinter.cpp"> <Filter>main\win32</Filter> </ClCompile> + <ClCompile Include="..\..\xbmc\messaging\ApplicationMessenger.cpp"> + <Filter>messaging</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\xbmc\win32\pch.h"> @@ -5201,7 +5206,6 @@ <ClInclude Include="..\..\xbmc\video\VideoDatabase.h"> <Filter>video</Filter> </ClInclude> - <ClInclude Include="..\..\xbmc\ApplicationMessenger.h" /> <ClInclude Include="..\..\xbmc\Autorun.h" /> <ClInclude Include="..\..\xbmc\AutoSwitch.h" /> <ClInclude Include="..\..\xbmc\DynamicDll.h" /> @@ -5947,7 +5951,7 @@ <ClInclude Include="..\..\xbmc\addons\LanguageResource.h"> <Filter>addons</Filter> </ClInclude> - <ClInclude Include="..\..\xbmc\addons\UISoundsResource.h"> + <ClInclude Include="..\..\xbmc\addons\UISoundsResource.h"> <Filter>addons</Filter> </ClInclude> <ClInclude Include="..\..\xbmc\filesystem\ResourceFile.h"> @@ -6007,6 +6011,15 @@ <ClInclude Include="..\..\xbmc\main\win32\MessagePrinter.h"> <Filter>main\win32</Filter> </ClInclude> + <ClInclude Include="..\..\xbmc\messaging\ApplicationMessenger.h"> + <Filter>messaging</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\messaging\ThreadMessage.h"> + <Filter>messaging</Filter> + </ClInclude> + <ClInclude Include="..\..\xbmc\messaging\IMessageTarget.h"> + <Filter>messaging</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc"> diff --git a/xbmc/AppParamParser.cpp b/xbmc/AppParamParser.cpp index 967e1da2f7..24ad3048d2 100644 --- a/xbmc/AppParamParser.cpp +++ b/xbmc/AppParamParser.cpp @@ -21,7 +21,7 @@ #include "AppParamParser.h" #include "PlayListPlayer.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "settings/AdvancedSettings.h" #include "utils/log.h" #include "utils/SystemInfo.h" @@ -35,6 +35,8 @@ #endif #include <stdlib.h> +using namespace KODI::MESSAGING; + CAppParamParser::CAppParamParser() { m_testmode = false; @@ -155,6 +157,5 @@ void CAppParamParser::PlayPlaylist() g_playlistPlayer.SetCurrentPlaylist(0); } - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PLAY, -1}; - CApplicationMessenger::Get().SendMessage(tMsg, false); + CApplicationMessenger::Get().PostMsg(TMSG_PLAYLISTPLAYER_PLAY, -1); } diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 703d7fc800..f0a54daf64 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -55,7 +55,8 @@ #include "guilib/GUIAudioManager.h" #include "GUIPassword.h" #include "input/InertialScrollingHandler.h" -#include "ApplicationMessenger.h" +#include "messaging/ThreadMessage.h" +#include "messaging/ApplicationMessenger.h" #include "SectionLoader.h" #include "cores/DllLoader/DllLoaderContainer.h" #include "GUIUserMessages.h" @@ -221,6 +222,8 @@ #include "cores/FFmpeg.h" #include "utils/CharsetConverter.h" +#include "pictures/GUIWindowSlideShow.h" +#include "windows/GUIWindowLoginScreen.h" using namespace ADDON; using namespace XFILE; @@ -240,6 +243,7 @@ using namespace ANNOUNCEMENT; using namespace PVR; using namespace EPG; using namespace PERIPHERALS; +using namespace KODI::MESSAGING; using namespace XbmcThreads; @@ -339,7 +343,7 @@ bool CApplication::OnEvent(XBMC_Event& newEvent) { case XBMC_QUIT: if (!g_application.m_bStop) - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); break; case XBMC_VIDEORESIZE: if (!g_application.m_bInitializing && @@ -368,7 +372,7 @@ bool CApplication::OnEvent(XBMC_Event& newEvent) } break; case XBMC_USEREVENT: - CApplicationMessenger::Get().UserEvent(newEvent.user.code); + CApplicationMessenger::Get().PostMsg(static_cast<uint32_t>(newEvent.user.code)); break; case XBMC_APPCOMMAND: return g_application.OnAppCommand(newEvent.appcommand.action); @@ -1126,6 +1130,10 @@ bool CApplication::Initialize() CDirectory::Create("special://xbmc/sounds"); } + CApplicationMessenger::Get().RegisterReceveiver(this); + CApplicationMessenger::Get().RegisterReceveiver(&g_playlistPlayer); + CApplicationMessenger::Get().RegisterReceveiver(&g_infoManager); + // load the language and its translated strings if (!LoadLanguage(false)) return false; @@ -1386,11 +1394,11 @@ void CApplication::OnSettingChanged(const CSetting *setting) } } - std::string builtin("ReloadSkin"); - if (settingId == "lookandfeel.skin" && !m_skinReverting) - builtin += "(confirm)"; - CApplicationMessenger::Get().ExecBuiltIn(builtin); - } + std::string builtin("ReloadSkin"); + if (settingId == "lookandfeel.skin" && !m_skinReverting) + builtin += "(confirm)"; + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, builtin); + } else if (settingId == "lookandfeel.skintheme") { // also set the default color theme @@ -1406,7 +1414,7 @@ void CApplication::OnSettingChanged(const CSetting *setting) if (!StringUtils::EqualsNoCase(colorTheme, CSettings::Get().GetString("lookandfeel.skincolors"))) CSettings::Get().SetString("lookandfeel.skincolors", colorTheme); else - CApplicationMessenger::Get().ExecBuiltIn("ReloadSkin"); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "ReloadSkin"); } else if (settingId == "lookandfeel.skinzoom") { @@ -1426,7 +1434,7 @@ void CApplication::OnSettingChanged(const CSetting *setting) // if this is changed, audio stream has to be reopened else if (settingId == "audiooutput.passthrough") { - CApplicationMessenger::Get().MediaRestart(false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_RESTART); } } else if (StringUtils::EqualsNoCase(settingId, "musicplayer.replaygaintype")) @@ -2255,7 +2263,9 @@ bool CApplication::OnAction(const CAction &action) // Player ignored action; popup the OSD if ((action.GetID() == ACTION_MOUSE_MOVE && (action.GetAmount(2) || action.GetAmount(3))) // filter "false" mouse move from touch || action.GetID() == ACTION_MOUSE_LEFT_CLICK) - CApplicationMessenger::Get().SendAction(CAction(ACTION_TRIGGER_OSD), WINDOW_INVALID, false); + { + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_TRIGGER_OSD))); + } } // stop : stops playing current audio song @@ -2473,6 +2483,293 @@ bool CApplication::OnAction(const CAction &action) return false; } +int CApplication::GetMessageMask() +{ + return TMSG_MASK_APPLICATION; +} + +void CApplication::OnApplicationMessage(ThreadMessage* pMsg) +{ + switch (pMsg->dwMessage) + { + case TMSG_POWERDOWN: + Stop(EXITCODE_POWERDOWN); + g_powerManager.Powerdown(); + break; + + case TMSG_QUIT: + Stop(EXITCODE_QUIT); + break; + + case TMSG_SHUTDOWN: + { + switch (CSettings::Get().GetInt("powermanagement.shutdownstate")) + { + case POWERSTATE_SHUTDOWN: + CApplicationMessenger::Get().PostMsg(TMSG_SHUTDOWN); + break; + + case POWERSTATE_SUSPEND: + CApplicationMessenger::Get().PostMsg(TMSG_SUSPEND); + break; + + case POWERSTATE_HIBERNATE: + CApplicationMessenger::Get().PostMsg(TMSG_HIBERNATE); + break; + + case POWERSTATE_QUIT: + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); + break; + + case POWERSTATE_MINIMIZE: + CApplicationMessenger::Get().PostMsg(TMSG_MINIMIZE); + break; + + case TMSG_RENDERER_FLUSH: + g_renderManager.Flush(); + break; + } + } + break; + + case TMSG_HIBERNATE: + g_PVRManager.SetWakeupCommand(); + g_powerManager.Hibernate(); + break; + + case TMSG_SUSPEND: + g_PVRManager.SetWakeupCommand(); + g_powerManager.Suspend(); + break; + + case TMSG_RESTART: + case TMSG_RESET: + Stop(EXITCODE_REBOOT); + g_powerManager.Reboot(); + break; + + case TMSG_RESTARTAPP: +#if defined(TARGET_WINDOWS) || defined(TARGET_LINUX) + Stop(EXITCODE_RESTARTAPP); +#endif + break; + + case TMSG_INHIBITIDLESHUTDOWN: + InhibitIdleShutdown(pMsg->param1 != 0); + break; + + case TMSG_ACTIVATESCREENSAVER: + ActivateScreenSaver(); + break; + + case TMSG_VOLUME_SHOW: + { + CAction action(pMsg->param1); + ShowVolumeBar(&action); + } + break; + + case TMSG_SPLASH_MESSAGE: + if (GetSplash()) + GetSplash()->Show(pMsg->strParam); + break; + + case TMSG_DISPLAY_SETUP: + *static_cast<bool*>(pMsg->lpVoid) = InitWindow(); + SetRenderGUI(true); + break; + + case TMSG_DISPLAY_DESTROY: + *static_cast<bool*>(pMsg->lpVoid) = DestroyWindow(); + SetRenderGUI(false); + break; + + case TMSG_SETPVRMANAGERSTATE: + if (pMsg->param1 != 0) + StartPVRManager(); + else + StopPVRManager(); + break; + + case TMSG_START_ANDROID_ACTIVITY: + { +#if defined(TARGET_ANDROID) + if (pMsg->params.size()) + { + CXBMCApp::StartActivity(pMsg->params[0], + pMsg->params.size() > 1 ? pMsg->params[1] : "", + pMsg->params.size() > 2 ? pMsg->params[2] : "", + pMsg->params.size() > 3 ? pMsg->params[3] : ""); + } +#endif + } + break; + + case TMSG_NETWORKMESSAGE: + getNetwork().NetworkMessage((CNetwork::EMESSAGE)pMsg->param1, pMsg->param2); + break; + + case TMSG_SETLANGUAGE: + SetLanguage(pMsg->strParam); + break; + + + case TMSG_SWITCHTOFULLSCREEN: + if (g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO) + SwitchToFullScreen(true); + break; + + case TMSG_VIDEORESIZE: + { + XBMC_Event newEvent; + memset(&newEvent, 0, sizeof(newEvent)); + newEvent.type = XBMC_VIDEORESIZE; + newEvent.resize.w = pMsg->param1; + newEvent.resize.h = pMsg->param2; + OnEvent(newEvent); + g_windowManager.MarkDirty(); + } + break; + + case TMSG_SETVIDEORESOLUTION: + g_graphicsContext.SetVideoResolution(static_cast<RESOLUTION>(pMsg->param1), pMsg->param2 == 1); + break; + + case TMSG_TOGGLEFULLSCREEN: + g_graphicsContext.Lock(); + g_graphicsContext.ToggleFullScreenRoot(); + g_graphicsContext.Unlock(); + break; + + case TMSG_MINIMIZE: + Minimize(); + break; + + case TMSG_EXECUTE_OS: + /* Suspend AE temporarily so exclusive or hog-mode sinks */ + /* don't block external player's access to audio device */ + if (!CAEFactory::Suspend()) + { + CLog::Log(LOGNOTICE, "%s: Failed to suspend AudioEngine before launching external program", __FUNCTION__); + } +#if defined( TARGET_POSIX) && !defined(TARGET_DARWIN) + CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->param1 == 1)); +#elif defined(TARGET_WINDOWS) + CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->param1 == 1)); +#endif + /* Resume AE processing of XBMC native audio */ + if (!CAEFactory::Resume()) + { + CLog::Log(LOGFATAL, "%s: Failed to restart AudioEngine after return from external player", __FUNCTION__); + } + break; + + case TMSG_EXECUTE_SCRIPT: + CScriptInvocationManager::Get().ExecuteAsync(pMsg->strParam); + break; + + case TMSG_EXECUTE_BUILT_IN: + CBuiltins::Execute(pMsg->strParam.c_str()); + break; + + case TMSG_PICTURE_SHOW: + { + CGUIWindowSlideShow *pSlideShow = static_cast<CGUIWindowSlideShow *>(g_windowManager.GetWindow(WINDOW_SLIDESHOW)); + if (!pSlideShow) return; + + // stop playing file + if (g_application.m_pPlayer->IsPlayingVideo()) g_application.StopPlaying(); + + if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) + g_windowManager.PreviousWindow(); + + g_application.ResetScreenSaver(); + g_application.WakeUpScreenSaverAndDPMS(); + + g_graphicsContext.Lock(); + + if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) + g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); + if (URIUtils::IsZIP(pMsg->strParam) || URIUtils::IsRAR(pMsg->strParam)) // actually a cbz/cbr + { + CFileItemList items; + CURL pathToUrl; + if (URIUtils::IsZIP(pMsg->strParam)) + pathToUrl = URIUtils::CreateArchivePath("zip", CURL(pMsg->strParam), ""); + else + pathToUrl = URIUtils::CreateArchivePath("rar", CURL(pMsg->strParam), ""); + + CUtil::GetRecursiveListing(pathToUrl.Get(), items, g_advancedSettings.m_pictureExtensions, XFILE::DIR_FLAG_NO_FILE_DIRS); + if (items.Size() > 0) + { + pSlideShow->Reset(); + for (int i = 0; i<items.Size(); ++i) + { + pSlideShow->Add(items[i].get()); + } + pSlideShow->Select(items[0]->GetPath()); + } + } + else + { + CFileItem item(pMsg->strParam, false); + pSlideShow->Reset(); + pSlideShow->Add(&item); + pSlideShow->Select(pMsg->strParam); + } + g_graphicsContext.Unlock(); + } + break; + + case TMSG_PICTURE_SLIDESHOW: + { + CGUIWindowSlideShow *pSlideShow = static_cast<CGUIWindowSlideShow *>(g_windowManager.GetWindow(WINDOW_SLIDESHOW)); + if (!pSlideShow) return; + + if (g_application.m_pPlayer->IsPlayingVideo()) + g_application.StopPlaying(); + + g_graphicsContext.Lock(); + pSlideShow->Reset(); + + CFileItemList items; + std::string strPath = pMsg->strParam; + std::string extensions = g_advancedSettings.m_pictureExtensions; + if (pMsg->param1) + extensions += "|.tbn"; + CUtil::GetRecursiveListing(strPath, items, extensions); + + if (items.Size() > 0) + { + for (int i = 0; i<items.Size(); ++i) + pSlideShow->Add(items[i].get()); + pSlideShow->StartSlideShow(); //Start the slideshow! + } + + if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) + { + if (items.Size() == 0) + { + CSettings::Get().SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); + g_application.ActivateScreenSaver(); + } + else + g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); + } + + g_graphicsContext.Unlock(); + } + break; + + case TMSG_LOADPROFILE: + { + CGUIWindowLoginScreen::LoadProfile(pMsg->param1); + break; + } + + } +} + void CApplication::FrameMove(bool processEvents, bool processGUI) { MEASURE_FUNCTION; @@ -3745,7 +4042,7 @@ bool CApplication::WakeUpScreenSaver(bool bPowerOffKeyPressed /* = false */) if (g_windowManager.GetActiveWindow() == WINDOW_SCREENSAVER) g_windowManager.PreviousWindow(); // show the previous window if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) - CApplicationMessenger::Get().SendAction(CAction(ACTION_STOP), WINDOW_SLIDESHOW); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_STOP))); } return true; } @@ -3874,7 +4171,7 @@ void CApplication::CheckShutdown() m_shutdownTimer.Stop(); // Sleep the box - CApplicationMessenger::Get().Shutdown(); + CApplicationMessenger::Get().PostMsg(TMSG_SHUTDOWN); } } @@ -4115,7 +4412,7 @@ bool CApplication::OnMessage(CGUIMessage& message) } if (IsEnableTestMode()) - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); return true; } break; @@ -4636,11 +4933,11 @@ void CApplication::SeekTime( double dTime ) else { // seeking to a new file m_currentStackPosition = i; - CFileItem item(*(*m_currentStack)[i]); - item.m_lStartOffset = (long)((dTime - startOfNewFile) * 75.0); + CFileItem *item = new CFileItem(*(*m_currentStack)[i]); + item->m_lStartOffset = static_cast<long>((dTime - startOfNewFile) * 75.0); // don't just call "PlayFile" here, as we are quite likely called from the // player thread, so we won't be able to delete ourselves. - CApplicationMessenger::Get().PlayFile(item, true); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 1, 0, static_cast<void*>(item)); } return; } diff --git a/xbmc/Application.h b/xbmc/Application.h index 5311bd8528..f3fb59ac1b 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -25,6 +25,7 @@ #include "guilib/IMsgTargetCallback.h" #include "utils/GlobalsHandling.h" +#include "messaging/IMessageTarget.h" #include <map> #include <memory> @@ -34,6 +35,8 @@ class CAction; class CFileItem; class CFileItemList; class CKey; + + namespace ADDON { class CSkinInfo; @@ -114,7 +117,8 @@ protected: }; class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMsgTargetCallback, - public ISettingCallback, public ISettingsHandler, public ISubSettings + public ISettingCallback, public ISettingsHandler, public ISubSettings, + public KODI::MESSAGING::IMessageTarget { friend class CApplicationPlayer; public: @@ -174,6 +178,10 @@ public: virtual void OnPlayBackSeek(int iTime, int seekOffset); virtual void OnPlayBackSeekChapter(int iChapter); virtual void OnPlayBackSpeedChanged(int iSpeed); + + virtual int GetMessageMask() override; + virtual void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; + bool PlayMedia(const CFileItem& item, int iPlaylist = PLAYLIST_MUSIC); bool PlayMediaSync(const CFileItem& item, int iPlaylist = PLAYLIST_MUSIC); bool ProcessAndStartPlaylist(const std::string& strPlayList, PLAYLIST::CPlayList& playlist, int iPlaylist, int track=0); diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp deleted file mode 100644 index e5cc37e0eb..0000000000 --- a/xbmc/ApplicationMessenger.cpp +++ /dev/null @@ -1,1412 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "system.h" -#include "ApplicationMessenger.h" -#include "Application.h" - -#include "PlayListPlayer.h" -#include "Util.h" -#include "pictures/GUIWindowSlideShow.h" -#include "interfaces/Builtins.h" -#include "interfaces/generic/ScriptInvocationManager.h" -#include "network/Network.h" -#include "utils/log.h" -#include "utils/URIUtils.h" -#include "utils/Variant.h" -#include "guilib/GUIWindowManager.h" -#include "settings/AdvancedSettings.h" -#include "settings/Settings.h" -#include "FileItem.h" -#include "guilib/GUIDialog.h" -#include "input/Key.h" -#include "guilib/GUIKeyboardFactory.h" -#include "guilib/Resolution.h" -#include "GUIInfoManager.h" -#include "utils/Splash.h" -#include "cores/VideoRenderers/RenderManager.h" -#include "cores/AudioEngine/AEFactory.h" -#include "music/tags/MusicInfoTag.h" - -#include "peripherals/Peripherals.h" -#include "powermanagement/PowerManager.h" - -#ifdef TARGET_WINDOWS -#include "WIN32Util.h" -#define CHalManager CWIN32Util -#elif defined(TARGET_DARWIN) -#include "osx/CocoaInterface.h" -#endif -#include "addons/AddonCallbacksGUI.h" -#include "guilib/LocalizeStrings.h" -#include "threads/SingleLock.h" -#include "URL.h" - -#include "playlists/PlayList.h" - -#include "pvr/PVRManager.h" -#include "windows/GUIWindowLoginScreen.h" - -#include "utils/GlobalsHandling.h" -#if defined(TARGET_ANDROID) - #include "xbmc/android/activity/XBMCApp.h" -#endif - -using namespace PVR; -using namespace MUSIC_INFO; -using namespace PERIPHERALS; - -CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay) : CThread("DelayedMessage") -{ - m_msg.dwMessage = msg.dwMessage; - m_msg.param1 = msg.param1; - m_msg.param2 = msg.param2; - m_msg.waitEvent = msg.waitEvent; - m_msg.lpVoid = msg.lpVoid; - m_msg.strParam = msg.strParam; - m_msg.params = msg.params; - - m_delay = delay; -} - -void CDelayedMessage::Process() -{ - Sleep(m_delay); - - if (!m_bStop) - CApplicationMessenger::Get().SendMessage(m_msg, false); -} - - -CApplicationMessenger& CApplicationMessenger::Get() -{ - return s_messenger; -} - -CApplicationMessenger::CApplicationMessenger() -{ -} - -CApplicationMessenger::~CApplicationMessenger() -{ - Cleanup(); -} - -void CApplicationMessenger::Cleanup() -{ - CSingleLock lock (m_critSection); - - while (!m_vecMessages.empty()) - { - ThreadMessage* pMsg = m_vecMessages.front(); - - if (pMsg->waitEvent) - pMsg->waitEvent->Set(); - - delete pMsg; - m_vecMessages.pop(); - } - - while (!m_vecWindowMessages.empty()) - { - ThreadMessage* pMsg = m_vecWindowMessages.front(); - - if (pMsg->waitEvent) - pMsg->waitEvent->Set(); - - delete pMsg; - m_vecWindowMessages.pop(); - } -} - -void CApplicationMessenger::SendMessage(ThreadMessage& message, bool wait) -{ - message.waitEvent.reset(); - std::shared_ptr<CEvent> waitEvent; - if (wait) - { // check that we're not being called from our application thread, else we'll be waiting - // forever! - if (!g_application.IsCurrentThread()) - { - message.waitEvent.reset(new CEvent(true)); - waitEvent = message.waitEvent; - } - else - { - //OutputDebugString("Attempting to wait on a SendMessage() from our application thread will cause lockup!\n"); - //OutputDebugString("Sending immediately\n"); - ProcessMessage(&message); - return; - } - } - - CSingleLock lock (m_critSection); - - if (g_application.m_bStop) - { - if (message.waitEvent) - message.waitEvent.reset(); - return; - } - - ThreadMessage* msg = new ThreadMessage(); - msg->dwMessage = message.dwMessage; - msg->param1 = message.param1; - msg->param2 = message.param2; - msg->waitEvent = message.waitEvent; - msg->lpVoid = message.lpVoid; - msg->strParam = message.strParam; - msg->params = message.params; - - if (msg->dwMessage == TMSG_GUI_DIALOG_OPEN) - m_vecWindowMessages.push(msg); - else - m_vecMessages.push(msg); - lock.Leave(); // this releases the lock on the vec of messages and - // allows the ProcessMessage to execute and therefore - // delete the message itself. Therefore any accesss - // of the message itself after this point consittutes - // a race condition (yarc - "yet another race condition") - // - if (waitEvent) // ... it just so happens we have a spare reference to the - // waitEvent ... just for such contingencies :) - { - // ensure the thread doesn't hold the graphics lock - CSingleExit exit(g_graphicsContext); - waitEvent->Wait(); - } -} - -void CApplicationMessenger::ProcessMessages() -{ - // process threadmessages - CSingleLock lock (m_critSection); - while (!m_vecMessages.empty()) - { - ThreadMessage* pMsg = m_vecMessages.front(); - //first remove the message from the queue, else the message could be processed more then once - m_vecMessages.pop(); - - //Leave here as the message might make another - //thread call processmessages or sendmessage - - std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent; - lock.Leave(); // <- see the large comment in SendMessage ^ - - ProcessMessage(pMsg); - if (waitEvent) - waitEvent->Set(); - delete pMsg; - - lock.Enter(); - } -} - -void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) -{ - switch (pMsg->dwMessage) - { - case TMSG_SHUTDOWN: - { - switch (CSettings::Get().GetInt("powermanagement.shutdownstate")) - { - case POWERSTATE_SHUTDOWN: - Powerdown(); - break; - - case POWERSTATE_SUSPEND: - Suspend(); - break; - - case POWERSTATE_HIBERNATE: - Hibernate(); - break; - - case POWERSTATE_QUIT: - Quit(); - break; - - case POWERSTATE_MINIMIZE: - Minimize(); - break; - - case TMSG_RENDERER_FLUSH: - g_renderManager.Flush(); - break; - } - } - break; - - case TMSG_POWERDOWN: - { - g_application.Stop(EXITCODE_POWERDOWN); - g_powerManager.Powerdown(); - } - break; - - case TMSG_QUIT: - { - g_application.Stop(EXITCODE_QUIT); - } - break; - - case TMSG_HIBERNATE: - { - g_PVRManager.SetWakeupCommand(); - g_powerManager.Hibernate(); - } - break; - - case TMSG_SUSPEND: - { - g_PVRManager.SetWakeupCommand(); - g_powerManager.Suspend(); - } - break; - - case TMSG_RESTART: - case TMSG_RESET: - { - g_application.Stop(EXITCODE_REBOOT); - g_powerManager.Reboot(); - } - break; - - case TMSG_RESTARTAPP: - { -#if defined(TARGET_WINDOWS) || defined(TARGET_LINUX) - g_application.Stop(EXITCODE_RESTARTAPP); -#endif - } - break; - - case TMSG_INHIBITIDLESHUTDOWN: - { - g_application.InhibitIdleShutdown(pMsg->param1 != 0); - } - break; - - case TMSG_ACTIVATESCREENSAVER: - { - g_application.ActivateScreenSaver(); - } - break; - - case TMSG_MEDIA_PLAY: - { - // first check if we were called from the PlayFile() function - if (pMsg->lpVoid && pMsg->param2 == 0) - { - CFileItem *item = (CFileItem *)pMsg->lpVoid; - g_application.PlayFile(*item, pMsg->param1 != 0); - delete item; - return; - } - // restore to previous window if needed - if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW || - g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || - g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) - g_windowManager.PreviousWindow(); - - g_application.ResetScreenSaver(); - g_application.WakeUpScreenSaverAndDPMS(); - - //g_application.StopPlaying(); - // play file - if(pMsg->lpVoid) - { - CFileItemList *list = (CFileItemList *)pMsg->lpVoid; - - if (list->Size() > 0) - { - int playlist = PLAYLIST_MUSIC; - for (int i = 0; i < list->Size(); i++) - { - if ((*list)[i]->IsVideo()) - { - playlist = PLAYLIST_VIDEO; - break; - } - } - - g_playlistPlayer.ClearPlaylist(playlist); - g_playlistPlayer.SetCurrentPlaylist(playlist); - //For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate - //It will fall through to PlayFile - if (list->Size() == 1 && !(*list)[0]->IsPlayList()) - g_application.PlayMedia(*((*list)[0]), playlist); - else - { - // Handle "shuffled" option if present - if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) - g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); - // Handle "repeat" option if present - if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) - g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); - - g_playlistPlayer.Add(playlist, (*list)); - g_playlistPlayer.Play(pMsg->param1); - } - } - - delete list; - } - else if (pMsg->param1 == PLAYLIST_MUSIC || pMsg->param1 == PLAYLIST_VIDEO) - { - if (g_playlistPlayer.GetCurrentPlaylist() != pMsg->param1) - g_playlistPlayer.SetCurrentPlaylist(pMsg->param1); - - PlayListPlayerPlay(pMsg->param2); - } - } - break; - - case TMSG_MEDIA_RESTART: - g_application.Restart(true); - break; - - case TMSG_PICTURE_SHOW: - { - CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); - if (!pSlideShow) return ; - - // stop playing file - if (g_application.m_pPlayer->IsPlayingVideo()) g_application.StopPlaying(); - - if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) - g_windowManager.PreviousWindow(); - - g_application.ResetScreenSaver(); - g_application.WakeUpScreenSaverAndDPMS(); - - g_graphicsContext.Lock(); - - if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) - g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); - if (URIUtils::IsZIP(pMsg->strParam) || URIUtils::IsRAR(pMsg->strParam)) // actually a cbz/cbr - { - CFileItemList items; - CURL pathToUrl; - if (URIUtils::IsZIP(pMsg->strParam)) - pathToUrl = URIUtils::CreateArchivePath("zip", CURL(pMsg->strParam), ""); - else - pathToUrl = URIUtils::CreateArchivePath("rar", CURL(pMsg->strParam), ""); - - CUtil::GetRecursiveListing(pathToUrl.Get(), items, g_advancedSettings.m_pictureExtensions, XFILE::DIR_FLAG_NO_FILE_DIRS); - if (items.Size() > 0) - { - pSlideShow->Reset(); - for (int i=0;i<items.Size();++i) - { - pSlideShow->Add(items[i].get()); - } - pSlideShow->Select(items[0]->GetPath()); - } - } - else - { - CFileItem item(pMsg->strParam, false); - pSlideShow->Reset(); - pSlideShow->Add(&item); - pSlideShow->Select(pMsg->strParam); - } - g_graphicsContext.Unlock(); - } - break; - - case TMSG_PICTURE_SLIDESHOW: - { - CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); - if (!pSlideShow) return ; - - if (g_application.m_pPlayer->IsPlayingVideo()) - g_application.StopPlaying(); - - g_graphicsContext.Lock(); - pSlideShow->Reset(); - - CFileItemList items; - std::string strPath = pMsg->strParam; - std::string extensions = g_advancedSettings.m_pictureExtensions; - if (pMsg->param1) - extensions += "|.tbn"; - CUtil::GetRecursiveListing(strPath, items, extensions); - - if (items.Size() > 0) - { - for (int i=0;i<items.Size();++i) - pSlideShow->Add(items[i].get()); - pSlideShow->StartSlideShow(); //Start the slideshow! - } - - if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) - { - if(items.Size() == 0) - { - CSettings::Get().SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); - g_application.ActivateScreenSaver(); - } - else - g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); - } - - g_graphicsContext.Unlock(); - } - break; - - case TMSG_SETLANGUAGE: - g_application.SetLanguage(pMsg->strParam); - break; - case TMSG_MEDIA_STOP: - { - // restore to previous window if needed - bool stopSlideshow = true; - bool stopVideo = true; - bool stopMusic = true; - if (pMsg->param1 >= PLAYLIST_MUSIC && pMsg->param1 <= PLAYLIST_PICTURE) - { - stopSlideshow = (pMsg->param1 == PLAYLIST_PICTURE); - stopVideo = (pMsg->param1 == PLAYLIST_VIDEO); - stopMusic = (pMsg->param1 == PLAYLIST_MUSIC); - } - - if ((stopSlideshow && g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) || - (stopVideo && g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) || - (stopMusic && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)) - g_windowManager.PreviousWindow(); - - g_application.ResetScreenSaver(); - g_application.WakeUpScreenSaverAndDPMS(); - - // stop playing file - if (g_application.m_pPlayer->IsPlaying()) g_application.StopPlaying(); - } - break; - - case TMSG_MEDIA_PAUSE: - if (g_application.m_pPlayer->HasPlayer()) - { - g_application.ResetScreenSaver(); - g_application.WakeUpScreenSaverAndDPMS(); - g_application.m_pPlayer->Pause(); - } - break; - - case TMSG_MEDIA_UNPAUSE: - if (g_application.m_pPlayer->IsPausedPlayback()) - { - g_application.ResetScreenSaver(); - g_application.WakeUpScreenSaverAndDPMS(); - g_application.m_pPlayer->Pause(); - } - break; - - case TMSG_MEDIA_PAUSE_IF_PLAYING: - if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) - { - g_application.ResetScreenSaver(); - g_application.WakeUpScreenSaverAndDPMS(); - g_application.m_pPlayer->Pause(); - } - break; - - case TMSG_SWITCHTOFULLSCREEN: - if(g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO) - g_application.SwitchToFullScreen(true); - break; - - case TMSG_SETVIDEORESOLUTION: - { - RESOLUTION res = (RESOLUTION)pMsg->param1; - bool forceUpdate = pMsg->param2 == 1 ? true : false; - g_graphicsContext.SetVideoResolution(res, forceUpdate); - } - break; - - case TMSG_VIDEORESIZE: - { - XBMC_Event newEvent; - memset(&newEvent, 0, sizeof(newEvent)); - newEvent.type = XBMC_VIDEORESIZE; - newEvent.resize.w = pMsg->param1; - newEvent.resize.h = pMsg->param2; - g_application.OnEvent(newEvent); - g_windowManager.MarkDirty(); - } - break; - - case TMSG_TOGGLEFULLSCREEN: - g_graphicsContext.Lock(); - g_graphicsContext.ToggleFullScreenRoot(); - g_graphicsContext.Unlock(); - break; - - case TMSG_MINIMIZE: - g_application.Minimize(); - break; - - case TMSG_EXECUTE_OS: - /* Suspend AE temporarily so exclusive or hog-mode sinks */ - /* don't block external player's access to audio device */ - if (!CAEFactory::Suspend()) - { - CLog::Log(LOGNOTICE, "%s: Failed to suspend AudioEngine before launching external program",__FUNCTION__); - } -#if defined( TARGET_POSIX) && !defined(TARGET_DARWIN) - CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->param1 == 1)); -#elif defined(TARGET_WINDOWS) - CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->param1 == 1)); -#endif - /* Resume AE processing of XBMC native audio */ - if (!CAEFactory::Resume()) - { - CLog::Log(LOGFATAL, "%s: Failed to restart AudioEngine after return from external player",__FUNCTION__); - } - break; - - case TMSG_EXECUTE_SCRIPT: - CScriptInvocationManager::Get().ExecuteAsync(pMsg->strParam); - break; - - case TMSG_EXECUTE_BUILT_IN: - CBuiltins::Execute(pMsg->strParam.c_str()); - break; - - case TMSG_PLAYLISTPLAYER_PLAY: - if (pMsg->param1 != -1) - g_playlistPlayer.Play(pMsg->param1); - else - g_playlistPlayer.Play(); - break; - - case TMSG_PLAYLISTPLAYER_PLAY_SONG_ID: - if (pMsg->param1 != -1) - { - bool *result = (bool*)pMsg->lpVoid; - *result = g_playlistPlayer.PlaySongId(pMsg->param1); - } - else - g_playlistPlayer.Play(); - break; - - case TMSG_PLAYLISTPLAYER_NEXT: - g_playlistPlayer.PlayNext(); - break; - - case TMSG_PLAYLISTPLAYER_PREV: - g_playlistPlayer.PlayPrevious(); - break; - - case TMSG_PLAYLISTPLAYER_ADD: - if(pMsg->lpVoid) - { - CFileItemList *list = (CFileItemList *)pMsg->lpVoid; - - g_playlistPlayer.Add(pMsg->param1, (*list)); - delete list; - } - break; - - case TMSG_PLAYLISTPLAYER_INSERT: - if (pMsg->lpVoid) - { - CFileItemList *list = (CFileItemList *)pMsg->lpVoid; - g_playlistPlayer.Insert(pMsg->param1, (*list), pMsg->param2); - delete list; - } - break; - - case TMSG_PLAYLISTPLAYER_REMOVE: - if (pMsg->param1 != -1) - g_playlistPlayer.Remove(pMsg->param1,pMsg->param2); - break; - - case TMSG_PLAYLISTPLAYER_CLEAR: - g_playlistPlayer.ClearPlaylist(pMsg->param1); - break; - - case TMSG_PLAYLISTPLAYER_SHUFFLE: - g_playlistPlayer.SetShuffle(pMsg->param1, pMsg->param2 > 0); - break; - - case TMSG_PLAYLISTPLAYER_REPEAT: - g_playlistPlayer.SetRepeat(pMsg->param1, (PLAYLIST::REPEAT_STATE)pMsg->param2); - break; - - case TMSG_PLAYLISTPLAYER_GET_ITEMS: - if (pMsg->lpVoid) - { - PLAYLIST::CPlayList playlist = g_playlistPlayer.GetPlaylist(pMsg->param1); - CFileItemList *list = (CFileItemList *)pMsg->lpVoid; - - for (int i = 0; i < playlist.size(); i++) - list->Add(CFileItemPtr(new CFileItem(*playlist[i]))); - } - break; - - case TMSG_PLAYLISTPLAYER_SWAP: - if (pMsg->lpVoid) - { - std::vector<int> *indexes = (std::vector<int> *)pMsg->lpVoid; - if (indexes->size() == 2) - g_playlistPlayer.Swap(pMsg->param1, indexes->at(0), indexes->at(1)); - delete indexes; - } - break; - - // Window messages below here... - case TMSG_NETWORKMESSAGE: - { - g_application.getNetwork().NetworkMessage((CNetwork::EMESSAGE)pMsg->param1, pMsg->param2); - } - break; - - case TMSG_GUI_DIALOG_OPEN: - { - CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; - if (pDialog) - pDialog->Open(); - } - break; - - case TMSG_GUI_WINDOW_CLOSE: - { - CGUIWindow *window = (CGUIWindow *)pMsg->lpVoid; - if (window) - window->Close(pMsg->param2 & 0x1 ? true : false, pMsg->param1, pMsg->param2 & 0x2 ? true : false); - } - break; - - case TMSG_GUI_ACTIVATE_WINDOW: - { - g_windowManager.ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 & 0x1 ? true : false, pMsg->param2 & 0x2 ? true : false); - } - break; - - case TMSG_GUI_ADDON_DIALOG: - { - if (pMsg->lpVoid) - { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs - ((ADDON::CGUIAddonWindowDialog *) pMsg->lpVoid)->Show_Internal(pMsg->param2 > 0); - } - } - break; - -#ifdef HAS_PYTHON - case TMSG_GUI_PYTHON_DIALOG: - { - // This hack is not much better but at least I don't need to make ApplicationMessenger - // know about Addon (Python) specific classes. - CAction caction(pMsg->param1); - ((CGUIWindow*)pMsg->lpVoid)->OnAction(caction); - } - break; -#endif - - case TMSG_GUI_ACTION: - { - if (pMsg->lpVoid) - { - CAction *action = (CAction *)pMsg->lpVoid; - if (pMsg->param1 == WINDOW_INVALID) - g_application.OnAction(*action); - else - { - CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->param1); - if (pWindow) - pWindow->OnAction(*action); - else - CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->param1); - } - delete action; - } - } - break; - - case TMSG_GUI_MESSAGE: - { - if (pMsg->lpVoid) - { - CGUIMessage *message = (CGUIMessage *)pMsg->lpVoid; - g_windowManager.SendMessage(*message, pMsg->param1); - delete message; - } - } - break; - - case TMSG_GUI_INFOLABEL: - { - if (pMsg->lpVoid) - { - std::vector<std::string> *infoLabels = (std::vector<std::string> *)pMsg->lpVoid; - for (unsigned int i = 0; i < pMsg->params.size(); i++) - infoLabels->push_back(g_infoManager.GetLabel(g_infoManager.TranslateString(pMsg->params[i]))); - } - } - break; - case TMSG_GUI_INFOBOOL: - { - if (pMsg->lpVoid) - { - std::vector<bool> *infoLabels = (std::vector<bool> *)pMsg->lpVoid; - for (unsigned int i = 0; i < pMsg->params.size(); i++) - infoLabels->push_back(g_infoManager.EvaluateBool(pMsg->params[i])); - } - } - break; - - case TMSG_CALLBACK: - { - ThreadMessageCallback *callback = (ThreadMessageCallback*)pMsg->lpVoid; - callback->callback(callback->userptr); - } - break; - - case TMSG_VOLUME_SHOW: - { - CAction action(pMsg->param1); - g_application.ShowVolumeBar(&action); - } - break; - - case TMSG_SPLASH_MESSAGE: - { - if (g_application.GetSplash()) - g_application.GetSplash()->Show(pMsg->strParam); - } - break; - - case TMSG_DISPLAY_SETUP: - { - *((bool*)pMsg->lpVoid) = g_application.InitWindow(); - g_application.SetRenderGUI(true); - } - break; - - case TMSG_DISPLAY_DESTROY: - { - *((bool*)pMsg->lpVoid) = g_application.DestroyWindow(); - g_application.SetRenderGUI(false); - } - break; - - case TMSG_UPDATE_CURRENT_ITEM: - { - CFileItem* item = (CFileItem*)pMsg->lpVoid; - if (!item) - return; - if (pMsg->param1 == 1 && item->HasMusicInfoTag()) // only grab music tag - g_infoManager.SetCurrentSongTag(*item->GetMusicInfoTag()); - else if (pMsg->param1 == 2 && item->HasVideoInfoTag()) // only grab video tag - g_infoManager.SetCurrentVideoTag(*item->GetVideoInfoTag()); - else - g_infoManager.SetCurrentItem(*item); - delete item; - break; - } - - case TMSG_LOADPROFILE: - { - CGUIWindowLoginScreen::LoadProfile(pMsg->param1); - break; - } - case TMSG_CECTOGGLESTATE: - { - *((bool*)pMsg->lpVoid) = g_peripherals.ToggleDeviceState(STATE_SWITCH_TOGGLE); - break; - } - case TMSG_CECACTIVATESOURCE: - { - g_peripherals.ToggleDeviceState(STATE_ACTIVATE_SOURCE); - break; - } - case TMSG_CECSTANDBY: - { - g_peripherals.ToggleDeviceState(STATE_STANDBY); - break; - } - case TMSG_START_ANDROID_ACTIVITY: - { -#if defined(TARGET_ANDROID) - if (pMsg->params.size()) - { - CXBMCApp::StartActivity(pMsg->params[0], - pMsg->params.size() > 1 ? pMsg->params[1] : "", - pMsg->params.size() > 2 ? pMsg->params[2] : "", - pMsg->params.size() > 3 ? pMsg->params[3] : ""); - } -#endif - break; - } - case TMSG_SETPVRMANAGERSTATE: - { - if (pMsg->param1 != 0) - g_application.StartPVRManager(); - else - g_application.StopPVRManager(); - } - } -} - -void CApplicationMessenger::ProcessWindowMessages() -{ - CSingleLock lock (m_critSection); - //message type is window, process window messages - while (!m_vecWindowMessages.empty()) - { - ThreadMessage* pMsg = m_vecWindowMessages.front(); - //first remove the message from the queue, else the message could be processed more then once - m_vecWindowMessages.pop(); - - // leave here in case we make more thread messages from this one - - std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent; - lock.Leave(); // <- see the large comment in SendMessage ^ - - ProcessMessage(pMsg); - if (waitEvent) - waitEvent->Set(); - delete pMsg; - - lock.Enter(); - } -} - -int CApplicationMessenger::SetResponse(std::string response) -{ - CSingleLock lock (m_critBuffer); - bufferResponse=response; - lock.Leave(); - return 0; -} - -std::string CApplicationMessenger::GetResponse() -{ - std::string tmp; - CSingleLock lock (m_critBuffer); - tmp=bufferResponse; - lock.Leave(); - return tmp; -} - -void CApplicationMessenger::ExecBuiltIn(const std::string &command, bool wait) -{ - ThreadMessage tMsg = {TMSG_EXECUTE_BUILT_IN}; - tMsg.strParam = command; - SendMessage(tMsg, wait); -} - -void CApplicationMessenger::MediaPlay(std::string filename) -{ - CFileItem item(filename, false); - MediaPlay(item); -} - -void CApplicationMessenger::MediaPlay(const CFileItem &item, bool wait) -{ - CFileItemList list; - list.Add(CFileItemPtr(new CFileItem(item))); - - MediaPlay(list, 0, wait); -} - -void CApplicationMessenger::MediaPlay(const CFileItemList &list, int song, bool wait) -{ - ThreadMessage tMsg = {TMSG_MEDIA_PLAY}; - CFileItemList* listcopy = new CFileItemList(); - listcopy->Copy(list); - tMsg.lpVoid = (void*)listcopy; - tMsg.param1 = song; - tMsg.param2 = 1; - SendMessage(tMsg, wait); -} - -void CApplicationMessenger::MediaPlay(int playlistid, int song /* = -1 */) -{ - ThreadMessage tMsg = {TMSG_MEDIA_PLAY}; - tMsg.lpVoid = NULL; - tMsg.param1 = playlistid; - tMsg.param2 = song; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayFile(const CFileItem &item, bool bRestart /*= false*/) -{ - ThreadMessage tMsg = {TMSG_MEDIA_PLAY}; - CFileItem *pItem = new CFileItem(item); - tMsg.lpVoid = (void *)pItem; - tMsg.param1 = bRestart ? 1 : 0; - tMsg.param2 = 0; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::MediaStop(bool bWait /* = true */, int playlistid /* = -1 */) -{ - ThreadMessage tMsg = {TMSG_MEDIA_STOP}; - tMsg.param1 = playlistid; - SendMessage(tMsg, bWait); -} - -void CApplicationMessenger::MediaPause() -{ - ThreadMessage tMsg = {TMSG_MEDIA_PAUSE}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::MediaUnPause() -{ - ThreadMessage tMsg = {TMSG_MEDIA_UNPAUSE}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::MediaPauseIfPlaying() -{ - ThreadMessage tMsg = {TMSG_MEDIA_PAUSE_IF_PLAYING}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::MediaRestart(bool bWait) -{ - ThreadMessage tMsg = {TMSG_MEDIA_RESTART}; - SendMessage(tMsg, bWait); -} - -void CApplicationMessenger::PlayListPlayerPlay() -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PLAY, -1}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerPlay(int iSong) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PLAY, iSong}; - SendMessage(tMsg, true); -} - -bool CApplicationMessenger::PlayListPlayerPlaySongId(int songId) -{ - bool returnState; - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PLAY_SONG_ID, songId}; - tMsg.lpVoid = (void *)&returnState; - SendMessage(tMsg, true); - return returnState; -} - -void CApplicationMessenger::PlayListPlayerNext() -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_NEXT}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerPrevious() -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PREV}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerAdd(int playlist, const CFileItem &item) -{ - CFileItemList list; - list.Add(CFileItemPtr(new CFileItem(item))); - - PlayListPlayerAdd(playlist, list); -} - -void CApplicationMessenger::PlayListPlayerAdd(int playlist, const CFileItemList &list) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_ADD}; - CFileItemList* listcopy = new CFileItemList(); - listcopy->Copy(list); - tMsg.lpVoid = (void*)listcopy; - tMsg.param1 = playlist; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerInsert(int playlist, const CFileItem &item, int index) -{ - CFileItemList list; - list.Add(CFileItemPtr(new CFileItem(item))); - PlayListPlayerInsert(playlist, list, index); -} - -void CApplicationMessenger::PlayListPlayerInsert(int playlist, const CFileItemList &list, int index) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_INSERT}; - CFileItemList* listcopy = new CFileItemList(); - listcopy->Copy(list); - tMsg.lpVoid = (void *)listcopy; - tMsg.param1 = playlist; - tMsg.param2 = index; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerRemove(int playlist, int position) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_REMOVE, playlist, position}; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerClear(int playlist) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_CLEAR}; - tMsg.param1 = playlist; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerShuffle(int playlist, bool shuffle) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_SHUFFLE}; - tMsg.param1 = playlist; - tMsg.param2 = shuffle ? 1 : 0; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerGetItems(int playlist, CFileItemList &list) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_GET_ITEMS}; - tMsg.param1 = playlist; - tMsg.lpVoid = (void *)&list; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerSwap(int playlist, int indexItem1, int indexItem2) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_SWAP}; - tMsg.param1 = playlist; - std::vector<int> *indexes = new std::vector<int>(); - indexes->push_back(indexItem1); - indexes->push_back(indexItem2); - tMsg.lpVoid = (void *)indexes; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PlayListPlayerRepeat(int playlist, int repeatState) -{ - ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_REPEAT}; - tMsg.param1 = playlist; - tMsg.param2 = repeatState; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::PictureShow(std::string filename) -{ - ThreadMessage tMsg = {TMSG_PICTURE_SHOW}; - tMsg.strParam = filename; - SendMessage(tMsg); -} - -void CApplicationMessenger::PictureSlideShow(std::string pathname, bool addTBN /* = false */) -{ - unsigned int dwMessage = TMSG_PICTURE_SLIDESHOW; - ThreadMessage tMsg = {dwMessage}; - tMsg.strParam = pathname; - tMsg.param1 = addTBN ? 1 : 0; - SendMessage(tMsg); -} - -void CApplicationMessenger::SetGUILanguage(const std::string &strLanguage) -{ - ThreadMessage tMsg = {TMSG_SETLANGUAGE}; - tMsg.strParam = strLanguage; - SendMessage(tMsg); -} - -void CApplicationMessenger::Shutdown() -{ - ThreadMessage tMsg = {TMSG_SHUTDOWN}; - SendMessage(tMsg); -} - -void CApplicationMessenger::Powerdown() -{ - ThreadMessage tMsg = {TMSG_POWERDOWN}; - SendMessage(tMsg); -} - -void CApplicationMessenger::Quit() -{ - ThreadMessage tMsg = {TMSG_QUIT}; - SendMessage(tMsg); -} - -void CApplicationMessenger::Hibernate() -{ - ThreadMessage tMsg = {TMSG_HIBERNATE}; - SendMessage(tMsg); -} - -void CApplicationMessenger::Suspend() -{ - ThreadMessage tMsg = {TMSG_SUSPEND}; - SendMessage(tMsg); -} - -void CApplicationMessenger::Restart() -{ - ThreadMessage tMsg = {TMSG_RESTART}; - SendMessage(tMsg); -} - -void CApplicationMessenger::Reset() -{ - ThreadMessage tMsg = {TMSG_RESET}; - SendMessage(tMsg); -} - -void CApplicationMessenger::RestartApp() -{ - ThreadMessage tMsg = {TMSG_RESTARTAPP}; - SendMessage(tMsg); -} - -void CApplicationMessenger::InhibitIdleShutdown(bool inhibit) -{ - ThreadMessage tMsg = {TMSG_INHIBITIDLESHUTDOWN, inhibit}; - SendMessage(tMsg); -} - -void CApplicationMessenger::ActivateScreensaver() -{ - ThreadMessage tMsg = {TMSG_ACTIVATESCREENSAVER}; - SendMessage(tMsg); -} - -void CApplicationMessenger::NetworkMessage(int dwMessage, int dwParam) -{ - ThreadMessage tMsg = {TMSG_NETWORKMESSAGE, dwMessage, dwParam}; - SendMessage(tMsg); -} - -void CApplicationMessenger::SwitchToFullscreen() -{ - /* FIXME: ideally this call should return upon a successfull switch but currently - is causing deadlocks between the dvdplayer destructor and the rendermanager - */ - ThreadMessage tMsg = {TMSG_SWITCHTOFULLSCREEN}; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::Minimize(bool wait) -{ - ThreadMessage tMsg = {TMSG_MINIMIZE}; - SendMessage(tMsg, wait); -} - -void CApplicationMessenger::ExecOS(const std::string &command, bool waitExit) -{ - ThreadMessage tMsg = {TMSG_EXECUTE_OS}; - tMsg.strParam = command; - tMsg.param1 = waitExit ? 1 : 0; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::UserEvent(int code) -{ - ThreadMessage tMsg = {(unsigned int)code}; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::Open(CGUIDialog *pDialog) -{ - ThreadMessage tMsg = {TMSG_GUI_DIALOG_OPEN}; - tMsg.lpVoid = pDialog; - SendMessage(tMsg, true); -} - - -void CApplicationMessenger::Close(CGUIWindow *window, bool forceClose, bool waitResult /*= true*/, int nextWindowID /*= 0*/, bool enableSound /*= true*/) -{ - ThreadMessage tMsg = {TMSG_GUI_WINDOW_CLOSE, nextWindowID}; - tMsg.param2 = (forceClose ? 0x01 : 0) | (enableSound ? 0x02 : 0); - tMsg.lpVoid = window; - SendMessage(tMsg, waitResult); -} - -void CApplicationMessenger::ActivateWindow(int windowID, const std::vector<std::string> ¶ms, bool swappingWindows, bool force /* = false */) -{ - ThreadMessage tMsg = {TMSG_GUI_ACTIVATE_WINDOW, windowID}; - tMsg.param2 = (swappingWindows ? 0x01 : 0) | (force ? 0x02 : 0); - tMsg.params = params; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::SendAction(const CAction &action, int windowID, bool waitResult) -{ - ThreadMessage tMsg = {TMSG_GUI_ACTION}; - tMsg.param1 = windowID; - tMsg.lpVoid = new CAction(action); - SendMessage(tMsg, waitResult); -} - -void CApplicationMessenger::SendGUIMessage(const CGUIMessage &message, int windowID, bool waitResult) -{ - ThreadMessage tMsg = {TMSG_GUI_MESSAGE}; - tMsg.param1 = windowID == WINDOW_INVALID ? 0 : windowID; - tMsg.lpVoid = new CGUIMessage(message); - SendMessage(tMsg, waitResult); -} - -void CApplicationMessenger::SendText(const std::string &aTextString, bool closeKeyboard /* = false */) -{ - if (CGUIKeyboardFactory::SendTextToActiveKeyboard(aTextString, closeKeyboard)) - return; - - CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow()); - if (!window) - return; - - CGUIMessage msg(GUI_MSG_SET_TEXT, 0, window->GetFocusedControlID()); - msg.SetLabel(aTextString); - msg.SetParam1(closeKeyboard ? 1 : 0); - SendGUIMessage(msg, window->GetID()); -} - -std::vector<std::string> CApplicationMessenger::GetInfoLabels(const std::vector<std::string> &properties) -{ - std::vector<std::string> infoLabels; - - ThreadMessage tMsg = {TMSG_GUI_INFOLABEL}; - tMsg.params = properties; - tMsg.lpVoid = (void*)&infoLabels; - SendMessage(tMsg, true); - return infoLabels; -} - -std::vector<bool> CApplicationMessenger::GetInfoBooleans(const std::vector<std::string> &properties) -{ - std::vector<bool> infoLabels; - - ThreadMessage tMsg = {TMSG_GUI_INFOBOOL}; - tMsg.params = properties; - tMsg.lpVoid = (void*)&infoLabels; - SendMessage(tMsg, true); - return infoLabels; -} - -void CApplicationMessenger::ShowVolumeBar(bool up) -{ - ThreadMessage tMsg = {TMSG_VOLUME_SHOW}; - tMsg.param1 = up ? ACTION_VOLUME_UP : ACTION_VOLUME_DOWN; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::SetSplashMessage(const std::string& message) -{ - ThreadMessage tMsg = {TMSG_SPLASH_MESSAGE}; - tMsg.strParam = message; - SendMessage(tMsg, true); -} - -void CApplicationMessenger::SetSplashMessage(int stringID) -{ - SetSplashMessage(g_localizeStrings.Get(stringID)); -} - -bool CApplicationMessenger::SetupDisplay() -{ - bool result; - - ThreadMessage tMsg = {TMSG_DISPLAY_SETUP}; - tMsg.lpVoid = (void*)&result; - SendMessage(tMsg, true); - - return result; -} - -bool CApplicationMessenger::DestroyDisplay() -{ - bool result; - - ThreadMessage tMsg = {TMSG_DISPLAY_DESTROY}; - tMsg.lpVoid = (void*)&result; - SendMessage(tMsg, true); - - return result; -} - -void CApplicationMessenger::SetCurrentSongTag(const CMusicInfoTag& tag) -{ - CFileItem* item = new CFileItem(tag); - ThreadMessage tMsg = {TMSG_UPDATE_CURRENT_ITEM}; - tMsg.param1 = 1; - tMsg.lpVoid = (void*)item; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::SetCurrentVideoTag(const CVideoInfoTag& tag) -{ - CFileItem* item = new CFileItem(tag); - ThreadMessage tMsg = {TMSG_UPDATE_CURRENT_ITEM}; - tMsg.param1 = 2; - tMsg.lpVoid = (void*)item; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::SetCurrentItem(const CFileItem& item) -{ - CFileItem* item2 = new CFileItem(item); - ThreadMessage tMsg = {TMSG_UPDATE_CURRENT_ITEM}; - tMsg.lpVoid = (void*)item2; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::LoadProfile(unsigned int idx) -{ - ThreadMessage tMsg = {TMSG_LOADPROFILE}; - tMsg.param1 = idx; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::StartAndroidActivity(const std::vector<std::string> ¶ms) -{ - ThreadMessage tMsg = {TMSG_START_ANDROID_ACTIVITY}; - tMsg.params = params; - SendMessage(tMsg, false); -} - -bool CApplicationMessenger::CECToggleState() -{ - bool result; - - ThreadMessage tMsg = {TMSG_CECTOGGLESTATE}; - tMsg.lpVoid = (void*)&result; - SendMessage(tMsg, true); - - return result; -} - -void CApplicationMessenger::CECActivateSource() -{ - ThreadMessage tMsg = {TMSG_CECACTIVATESOURCE}; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::CECStandby() -{ - ThreadMessage tMsg = {TMSG_CECSTANDBY}; - SendMessage(tMsg, false); -} - -void CApplicationMessenger::SetPVRManagerState(bool onOff) -{ - ThreadMessage tMsg = {TMSG_SETPVRMANAGERSTATE}; - tMsg.param1 = onOff ? 1 : 0; - SendMessage(tMsg, false); -} diff --git a/xbmc/ApplicationMessenger.h b/xbmc/ApplicationMessenger.h deleted file mode 100644 index be958e2ef3..0000000000 --- a/xbmc/ApplicationMessenger.h +++ /dev/null @@ -1,282 +0,0 @@ -#pragma once - -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "guilib/WindowIDs.h" -#include "threads/Thread.h" -#include <memory> - -#include <queue> -#include "utils/GlobalsHandling.h" - -class CFileItem; -class CFileItemList; -class CGUIDialog; -class CGUIWindow; -class CGUIMessage; -class CVideoInfoTag; -class CAction; - -namespace MUSIC_INFO -{ - class CMusicInfoTag; -} - -// defines here -#define TMSG_EXECUTE_SCRIPT 102 -#define TMSG_EXECUTE_BUILT_IN 103 -#define TMSG_EXECUTE_OS 104 - -#define TMSG_MEDIA_PLAY 200 -#define TMSG_MEDIA_STOP 201 -// the PAUSE is indeed a PLAYPAUSE -#define TMSG_MEDIA_PAUSE 202 -#define TMSG_MEDIA_RESTART 203 -#define TMSG_MEDIA_UNPAUSE 204 -#define TMSG_MEDIA_PAUSE_IF_PLAYING 205 - -#define TMSG_PLAYLISTPLAYER_PLAY 210 -#define TMSG_PLAYLISTPLAYER_NEXT 211 -#define TMSG_PLAYLISTPLAYER_PREV 212 -#define TMSG_PLAYLISTPLAYER_ADD 213 -#define TMSG_PLAYLISTPLAYER_CLEAR 214 -#define TMSG_PLAYLISTPLAYER_SHUFFLE 215 -#define TMSG_PLAYLISTPLAYER_GET_ITEMS 216 -#define TMSG_PLAYLISTPLAYER_PLAY_SONG_ID 217 -#define TMSG_PLAYLISTPLAYER_INSERT 218 -#define TMSG_PLAYLISTPLAYER_REMOVE 219 -#define TMSG_PLAYLISTPLAYER_SWAP 223 -#define TMSG_PLAYLISTPLAYER_REPEAT 224 -#define TMSG_UPDATE_CURRENT_ITEM 225 - -#define TMSG_PICTURE_SHOW 220 -#define TMSG_PICTURE_SLIDESHOW 221 - -#define TMSG_SHUTDOWN 300 -#define TMSG_POWERDOWN 301 -#define TMSG_QUIT 302 -#define TMSG_HIBERNATE 303 -#define TMSG_SUSPEND 304 -#define TMSG_RESTART 305 -#define TMSG_RESET 306 -#define TMSG_RESTARTAPP 307 -#define TMSG_SWITCHTOFULLSCREEN 308 -#define TMSG_MINIMIZE 309 -#define TMSG_TOGGLEFULLSCREEN 310 -#define TMSG_SETLANGUAGE 311 -#define TMSG_RENDERER_FLUSH 312 -#define TMSG_INHIBITIDLESHUTDOWN 313 -#define TMSG_LOADPROFILE 314 -#define TMSG_ACTIVATESCREENSAVER 315 -#define TMSG_CECTOGGLESTATE 316 -#define TMSG_CECACTIVATESOURCE 317 -#define TMSG_CECSTANDBY 318 -#define TMSG_SETVIDEORESOLUTION 319 -#define TMSG_SETPVRMANAGERSTATE 320 -#define TMSG_VIDEORESIZE 321 - -#define TMSG_NETWORKMESSAGE 500 - -#define TMSG_GUI_DIALOG_OPEN 600 -#define TMSG_GUI_ACTIVATE_WINDOW 604 -#define TMSG_GUI_PYTHON_DIALOG 605 -#define TMSG_GUI_WINDOW_CLOSE 606 -#define TMSG_GUI_ACTION 607 -#define TMSG_GUI_INFOLABEL 608 -#define TMSG_GUI_INFOBOOL 609 -#define TMSG_GUI_ADDON_DIALOG 610 -#define TMSG_GUI_MESSAGE 611 -#define TMSG_START_ANDROID_ACTIVITY 612 - -#define TMSG_CALLBACK 800 - -#define TMSG_VOLUME_SHOW 900 -#define TMSG_SPLASH_MESSAGE 901 - -#define TMSG_DISPLAY_SETUP 1000 -#define TMSG_DISPLAY_DESTROY 1001 - -typedef struct -{ - unsigned int dwMessage; - int param1; - int param2; - std::string strParam; - std::vector<std::string> params; - std::shared_ptr<CEvent> waitEvent; - void* lpVoid; -} -ThreadMessage; - -class CDelayedMessage : public CThread -{ - public: - CDelayedMessage(ThreadMessage& msg, unsigned int delay); - virtual void Process(); - - private: - unsigned int m_delay; - ThreadMessage m_msg; -}; - -struct ThreadMessageCallback -{ - void (*callback)(void *userptr); - void *userptr; -}; - -class CApplicationMessenger; -namespace xbmcutil -{ - template<class T> class GlobalsSingleton; -} - -class CApplicationMessenger -{ -public: - /*! - \brief The only way through which the global instance of the CApplicationMessenger should be accessed. - \return the global instance. - */ - static CApplicationMessenger& Get(); - - void Cleanup(); - // if a message has to be send to the gui, use MSG_TYPE_WINDOW instead - void SendMessage(ThreadMessage& msg, bool wait = false); - void ProcessMessages(); // only call from main thread. - void ProcessWindowMessages(); - - - void MediaPlay(std::string filename); - void MediaPlay(const CFileItem &item, bool wait = true); - void MediaPlay(const CFileItemList &item, int song = 0, bool wait = true); - void MediaPlay(int playlistid, int song = -1); - void MediaStop(bool bWait = true, int playlistid = -1); - void MediaPause(); - void MediaUnPause(); - void MediaPauseIfPlaying(); - void MediaRestart(bool bWait); - - void PlayListPlayerPlay(); - void PlayListPlayerPlay(int iSong); - bool PlayListPlayerPlaySongId(int songId); - void PlayListPlayerNext(); - void PlayListPlayerPrevious(); - void PlayListPlayerAdd(int playlist, const CFileItem &item); - void PlayListPlayerAdd(int playlist, const CFileItemList &list); - void PlayListPlayerClear(int playlist); - void PlayListPlayerShuffle(int playlist, bool shuffle); - void PlayListPlayerGetItems(int playlist, CFileItemList &list); - void PlayListPlayerInsert(int playlist, const CFileItem &item, int position); - void PlayListPlayerInsert(int playlist, const CFileItemList &list, int position); - void PlayListPlayerRemove(int playlist, int position); - void PlayListPlayerSwap(int playlist, int indexItem1, int indexItem2); - void PlayListPlayerRepeat(int playlist, int repeatState); - - void PlayFile(const CFileItem &item, bool bRestart = false); // thread safe version of g_application.PlayFile() - void PictureShow(std::string filename); - void PictureSlideShow(std::string pathname, bool addTBN = false); - void SetGUILanguage(const std::string &strLanguage); - void Shutdown(); - void Powerdown(); - void Quit(); - void Hibernate(); - void Suspend(); - void Restart(); - void RestartApp(); - void Reset(); - void InhibitIdleShutdown(bool inhibit); - void ActivateScreensaver(); - void SwitchToFullscreen(); // - void Minimize(bool wait = false); - void ExecOS(const std::string &command, bool waitExit = false); - void UserEvent(int code); - //! \brief Set the tag for the currently playing song - void SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag& tag); - //! \brief Set the tag for the currently playing video - void SetCurrentVideoTag(const CVideoInfoTag& tag); - //! \brief Set the currently currently item - void SetCurrentItem(const CFileItem& item); - - void LoadProfile(unsigned int idx); - bool CECToggleState(); - void CECActivateSource(); - void CECStandby(); - - std::string GetResponse(); - int SetResponse(std::string response); - void ExecBuiltIn(const std::string &command, bool wait = false); - - void NetworkMessage(int dwMessage, int dwParam = 0); - - void Open(CGUIDialog *pDialog); - void Close(CGUIWindow *window, bool forceClose, bool waitResult = true, int nextWindowID = 0, bool enableSound = true); - void ActivateWindow(int windowID, const std::vector<std::string> ¶ms, bool swappingWindows, bool force = false); - void SendAction(const CAction &action, int windowID = WINDOW_INVALID, bool waitResult=true); - - //! \brief Send text to currently focused window / keyboard. - void SendText(const std::string &aTextString, bool closeKeyboard = false); - - /*! \brief Send a GUIMessage, optionally waiting before it's processed to return. - Should be used to send messages to the GUI from other threads. - \param msg the GUIMessage to send. - \param windowID optional window to send the message to (defaults to no specified window). - \param waitResult whether to wait for the result (defaults to false). - */ - void SendGUIMessage(const CGUIMessage &msg, int windowID = WINDOW_INVALID, bool waitResult=false); - - std::vector<std::string> GetInfoLabels(const std::vector<std::string> &properties); - std::vector<bool> GetInfoBooleans(const std::vector<std::string> &properties); - - void ShowVolumeBar(bool up); - - void SetSplashMessage(const std::string& message); - void SetSplashMessage(int stringID); - - /*! \brief Used to enable/disable PVR system without waiting. - \param onOff if true it becomes switched on otherwise off - */ - void SetPVRManagerState(bool onOff); - - bool SetupDisplay(); - bool DestroyDisplay(); - void StartAndroidActivity(const std::vector<std::string> ¶ms); - - virtual ~CApplicationMessenger(); -private: - // private construction, and no assignements; use the provided singleton methods - friend class xbmcutil::GlobalsSingleton<CApplicationMessenger>; - CApplicationMessenger(); - CApplicationMessenger(const CApplicationMessenger&); - CApplicationMessenger const& operator=(CApplicationMessenger const&); - void ProcessMessage(ThreadMessage *pMsg); - - std::queue<ThreadMessage*> m_vecMessages; - std::queue<ThreadMessage*> m_vecWindowMessages; - CCriticalSection m_critSection; - CCriticalSection m_critBuffer; - std::string bufferResponse; -}; - -XBMC_GLOBAL_REF(CApplicationMessenger,s_messenger); -#define s_messenger XBMC_GLOBAL_USE(CApplicationMessenger) - - diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 9087d71254..f288e441e4 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -65,6 +65,7 @@ #include <memory> #include "cores/DataCacheCore.h" #include "guiinfo/GUIInfoLabels.h" +#include "messaging/ApplicationMessenger.h" // stuff for current song #include "music/MusicInfoLoader.h" @@ -5857,3 +5858,54 @@ CEpgInfoTagPtr CGUIInfoManager::GetEpgInfoTag() const } return currentTag; } + +int CGUIInfoManager::GetMessageMask() +{ + return TMSG_MASK_GUIINFOMANAGER; +} + +void CGUIInfoManager::OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) +{ + switch (pMsg->dwMessage) + { + case TMSG_GUI_INFOLABEL: + { + if (pMsg->lpVoid) + { + auto infoLabels = static_cast<std::vector<std::string>*>(pMsg->lpVoid); + for (auto& param : pMsg->params) + infoLabels->push_back(GetLabel(TranslateString(param))); + } + } + break; + + case TMSG_GUI_INFOBOOL: + { + if (pMsg->lpVoid) + { + auto infoLabels = static_cast<std::vector<bool>*>(pMsg->lpVoid); + for (auto& param : pMsg->params) + infoLabels->push_back(EvaluateBool(param)); + } + } + break; + + case TMSG_UPDATE_CURRENT_ITEM: + { + auto item = static_cast<CFileItem*>(pMsg->lpVoid); + if (!item) + return; + if (pMsg->param1 == 1 && item->HasMusicInfoTag()) // only grab music tag + SetCurrentSongTag(*item->GetMusicInfoTag()); + else if (pMsg->param1 == 2 && item->HasVideoInfoTag()) // only grab video tag + SetCurrentVideoTag(*item->GetVideoInfoTag()); + else + SetCurrentItem(*item); + delete item; + } + break; + + default: + break; + } +} diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 8a60a526c0..8a412d813d 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -28,6 +28,7 @@ #include "threads/CriticalSection.h" #include "guilib/IMsgTargetCallback.h" +#include "messaging/IMessageTarget.h" #include "inttypes.h" #include "XBDateTime.h" #include "utils/Observer.h" @@ -93,7 +94,8 @@ private: \ingroup strings \brief */ -class CGUIInfoManager : public IMsgTargetCallback, public Observable +class CGUIInfoManager : public IMsgTargetCallback, public Observable, + public KODI::MESSAGING::IMessageTarget { public: CGUIInfoManager(void); @@ -102,6 +104,9 @@ public: void Clear(); virtual bool OnMessage(CGUIMessage &message); + virtual int GetMessageMask() override; + virtual void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; + /*! \brief Register a boolean condition/expression This routine allows controls or other clients of the info manager to register to receive updates of particular expressions, in a particular context (currently windows). diff --git a/xbmc/GUIPassword.cpp b/xbmc/GUIPassword.cpp index 4510ed6411..6119f35297 100644 --- a/xbmc/GUIPassword.cpp +++ b/xbmc/GUIPassword.cpp @@ -20,7 +20,7 @@ #include "GUIPassword.h" #include "GUIUserMessages.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "dialogs/GUIDialogGamepad.h" #include "guilib/GUIKeyboardFactory.h" #include "dialogs/GUIDialogNumeric.h" @@ -40,6 +40,8 @@ #include <utility> +using namespace KODI::MESSAGING; + CGUIPassword::CGUIPassword(void) { iMasterLockRetriesLeft = -1; @@ -160,7 +162,7 @@ bool CGUIPassword::CheckStartUpLock() } else { - CApplicationMessenger::Get().Shutdown(); // Turn off the box + CApplicationMessenger::Get().PostMsg(TMSG_SHUTDOWN); // Turn off the box return false; } } diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index 9a2754aee2..dcdf8c2f9b 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -20,7 +20,9 @@ #include "LangInfo.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" +#include "FileItem.h" +#include "Util.h" #include "addons/AddonInstaller.h" #include "addons/AddonManager.h" #include "addons/LanguageResource.h" @@ -43,6 +45,7 @@ #include <utility> using namespace PVR; +using namespace KODI::MESSAGING; static std::string shortDateFormats[] = { // short date formats using "/" @@ -707,7 +710,7 @@ bool CLangInfo::SetLanguage(bool& fallback, const std::string &strLanguage /* = // also tell our weather and skin to reload as these are localized g_weatherManager.Refresh(); g_PVRManager.LocalizationChanged(); - CApplicationMessenger::Get().ExecBuiltIn("ReloadSkin", false); + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "ReloadSkin"); } return true; diff --git a/xbmc/Makefile.in b/xbmc/Makefile.in index daed651dd3..9a77779c1c 100644 --- a/xbmc/Makefile.in +++ b/xbmc/Makefile.in @@ -1,5 +1,4 @@ SRCS=Application.cpp \ - ApplicationMessenger.cpp \ ApplicationPlayer.cpp \ AppParamParser.cpp \ Autorun.cpp \ diff --git a/xbmc/PlayListPlayer.cpp b/xbmc/PlayListPlayer.cpp index 0c52964cee..853d6dd3cd 100644 --- a/xbmc/PlayListPlayer.cpp +++ b/xbmc/PlayListPlayer.cpp @@ -36,6 +36,7 @@ #include "interfaces/AnnouncementManager.h" #include "input/Key.h" #include "URL.h" +#include "messaging/ApplicationMessenger.h" using namespace PLAYLIST; @@ -718,3 +719,226 @@ void CPlayListPlayer::AnnouncePropertyChanged(int iPlaylist, const std::string & data["property"][strProperty] = value; ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::Player, "xbmc", "OnPropertyChanged", data); } + +int PLAYLIST::CPlayListPlayer::GetMessageMask() +{ + return TMSG_MASK_PLAYLISTPLAYER; +} + +void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) +{ + switch (pMsg->dwMessage) + { + case TMSG_PLAYLISTPLAYER_PLAY: + if (pMsg->param1 != -1) + Play(pMsg->param1); + else + Play(); + break; + + case TMSG_PLAYLISTPLAYER_PLAY_SONG_ID: + if (pMsg->param1 != -1) + { + bool *result = (bool*)pMsg->lpVoid; + *result = PlaySongId(pMsg->param1); + } + else + Play(); + break; + + case TMSG_PLAYLISTPLAYER_NEXT: + PlayNext(); + break; + + case TMSG_PLAYLISTPLAYER_PREV: + PlayPrevious(); + break; + + case TMSG_PLAYLISTPLAYER_ADD: + if (pMsg->lpVoid) + { + CFileItemList *list = (CFileItemList *)pMsg->lpVoid; + + Add(pMsg->param1, (*list)); + delete list; + } + break; + + case TMSG_PLAYLISTPLAYER_INSERT: + if (pMsg->lpVoid) + { + CFileItemList *list = (CFileItemList *)pMsg->lpVoid; + Insert(pMsg->param1, (*list), pMsg->param2); + delete list; + } + break; + + case TMSG_PLAYLISTPLAYER_REMOVE: + if (pMsg->param1 != -1) + Remove(pMsg->param1, pMsg->param2); + break; + + case TMSG_PLAYLISTPLAYER_CLEAR: + ClearPlaylist(pMsg->param1); + break; + + case TMSG_PLAYLISTPLAYER_SHUFFLE: + SetShuffle(pMsg->param1, pMsg->param2 > 0); + break; + + case TMSG_PLAYLISTPLAYER_REPEAT: + SetRepeat(pMsg->param1, (PLAYLIST::REPEAT_STATE)pMsg->param2); + break; + + case TMSG_PLAYLISTPLAYER_GET_ITEMS: + if (pMsg->lpVoid) + { + PLAYLIST::CPlayList playlist = GetPlaylist(pMsg->param1); + CFileItemList *list = static_cast<CFileItemList*>(pMsg->lpVoid); + + for (int i = 0; i < playlist.size(); i++) + list->Add(std::make_shared<CFileItem>(*playlist[i])); + } + break; + + case TMSG_PLAYLISTPLAYER_SWAP: + if (pMsg->lpVoid) + { + auto indexes = static_cast<std::vector<int>*>(pMsg->lpVoid); + if (indexes->size() == 2) + Swap(pMsg->param1, indexes->at(0), indexes->at(1)); + delete indexes; + } + break; + + case TMSG_MEDIA_PLAY: + { + // first check if we were called from the PlayFile() function + if (pMsg->lpVoid && pMsg->param2 == 0) + { + CFileItem *item = (CFileItem *)pMsg->lpVoid; + g_application.PlayFile(*item, pMsg->param1 != 0); + delete item; + return; + } + // restore to previous window if needed + if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW || + g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || + g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) + g_windowManager.PreviousWindow(); + + g_application.ResetScreenSaver(); + g_application.WakeUpScreenSaverAndDPMS(); + + //g_application.StopPlaying(); + // play file + if (pMsg->lpVoid) + { + CFileItemList *list = (CFileItemList *)pMsg->lpVoid; + + if (list->Size() > 0) + { + int playlist = PLAYLIST_MUSIC; + for (int i = 0; i < list->Size(); i++) + { + if ((*list)[i]->IsVideo()) + { + playlist = PLAYLIST_VIDEO; + break; + } + } + + ClearPlaylist(playlist); + SetCurrentPlaylist(playlist); + //For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate + //It will fall through to PlayFile + if (list->Size() == 1 && !(*list)[0]->IsPlayList()) + g_application.PlayMedia(*((*list)[0]), playlist); + else + { + // Handle "shuffled" option if present + if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) + SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); + // Handle "repeat" option if present + if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) + SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); + + Add(playlist, (*list)); + Play(pMsg->param1); + } + } + + delete list; + } + else if (pMsg->param1 == PLAYLIST_MUSIC || pMsg->param1 == PLAYLIST_VIDEO) + { + if (GetCurrentPlaylist() != pMsg->param1) + SetCurrentPlaylist(pMsg->param1); + + //PlayListPlayerPlay(pMsg->param2); + } + } + break; + + case TMSG_MEDIA_RESTART: + g_application.Restart(true); + break; + + case TMSG_MEDIA_STOP: + { + // restore to previous window if needed + bool stopSlideshow = true; + bool stopVideo = true; + bool stopMusic = true; + if (pMsg->param1 >= PLAYLIST_MUSIC && pMsg->param1 <= PLAYLIST_PICTURE) + { + stopSlideshow = (pMsg->param1 == PLAYLIST_PICTURE); + stopVideo = (pMsg->param1 == PLAYLIST_VIDEO); + stopMusic = (pMsg->param1 == PLAYLIST_MUSIC); + } + + if ((stopSlideshow && g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) || + (stopVideo && g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) || + (stopMusic && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)) + g_windowManager.PreviousWindow(); + + g_application.ResetScreenSaver(); + g_application.WakeUpScreenSaverAndDPMS(); + + // stop playing file + if (g_application.m_pPlayer->IsPlaying()) g_application.StopPlaying(); + } + break; + + case TMSG_MEDIA_PAUSE: + if (g_application.m_pPlayer->HasPlayer()) + { + g_application.ResetScreenSaver(); + g_application.WakeUpScreenSaverAndDPMS(); + g_application.m_pPlayer->Pause(); + } + break; + + case TMSG_MEDIA_UNPAUSE: + if (g_application.m_pPlayer->IsPausedPlayback()) + { + g_application.ResetScreenSaver(); + g_application.WakeUpScreenSaverAndDPMS(); + g_application.m_pPlayer->Pause(); + } + break; + + case TMSG_MEDIA_PAUSE_IF_PLAYING: + if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) + { + g_application.ResetScreenSaver(); + g_application.WakeUpScreenSaverAndDPMS(); + g_application.m_pPlayer->Pause(); + } + break; + default: + break; + } +} + + diff --git a/xbmc/PlayListPlayer.h b/xbmc/PlayListPlayer.h index 2167a7a01b..478e064fa0 100644 --- a/xbmc/PlayListPlayer.h +++ b/xbmc/PlayListPlayer.h @@ -20,6 +20,7 @@ */ #include "guilib/IMsgTargetCallback.h" +#include "messaging/IMessageTarget.h" #include <memory> #define PLAYLIST_NONE -1 @@ -43,7 +44,8 @@ enum REPEAT_STATE { REPEAT_NONE = 0, REPEAT_ONE, REPEAT_ALL }; class CPlayList; -class CPlayListPlayer : public IMsgTargetCallback +class CPlayListPlayer : public IMsgTargetCallback, + public KODI::MESSAGING::IMessageTarget { public: @@ -51,6 +53,9 @@ public: virtual ~CPlayListPlayer(void); virtual bool OnMessage(CGUIMessage &message); + virtual int GetMessageMask() override; + virtual void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; + /*! \brief Play the next (or another) entry in the current playlist \param offset The offset from the current entry (defaults to 1, i.e. the next entry). \param autoPlay Whether we should start playing if not already (defaults to false). diff --git a/xbmc/addons/AddonCallbacksGUI.cpp b/xbmc/addons/AddonCallbacksGUI.cpp index 66ddedb74d..aac4a5ed84 100644 --- a/xbmc/addons/AddonCallbacksGUI.cpp +++ b/xbmc/addons/AddonCallbacksGUI.cpp @@ -19,7 +19,7 @@ */ #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Addon.h" #include "AddonCallbacksGUI.h" #include "utils/log.h" @@ -51,6 +51,7 @@ #define CONTROL_LABELFILES 12 using namespace std; +using namespace KODI::MESSAGING; namespace ADDON { @@ -2185,9 +2186,7 @@ bool CGUIAddonWindowDialog::OnMessage(CGUIMessage &message) void CGUIAddonWindowDialog::Show(bool show /* = true */) { unsigned int iCount = g_graphicsContext.exit(); - ThreadMessage tMsg = {TMSG_GUI_ADDON_DIALOG, 1, show ? 1 : 0}; - tMsg.lpVoid = this; - CApplicationMessenger::Get().SendMessage(tMsg, true); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ADDON_DIALOG, 1, show ? 1 : 0, static_cast<void*>(this)); g_graphicsContext.restore(iCount); } diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp index 7125e1da3b..06b971146d 100644 --- a/xbmc/addons/AddonInstaller.cpp +++ b/xbmc/addons/AddonInstaller.cpp @@ -28,7 +28,7 @@ #include "filesystem/Directory.h" #include "settings/AdvancedSettings.h" #include "settings/Settings.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "filesystem/FavouritesDirectory.h" #include "utils/JobManager.h" #include "dialogs/GUIDialogYesNo.h" @@ -47,7 +47,7 @@ using namespace std; using namespace XFILE; using namespace ADDON; - +using namespace KODI::MESSAGING; struct find_map : public binary_function<CAddonInstaller::JobMap::value_type, unsigned int, bool> { diff --git a/xbmc/addons/AddonStatusHandler.cpp b/xbmc/addons/AddonStatusHandler.cpp index dbd7a999ee..bcbe199eac 100644 --- a/xbmc/addons/AddonStatusHandler.cpp +++ b/xbmc/addons/AddonStatusHandler.cpp @@ -20,7 +20,7 @@ #include "AddonStatusHandler.h" #include "AddonManager.h" #include "threads/SingleLock.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIWindowManager.h" #include "GUIDialogAddonSettings.h" #include "dialogs/GUIDialogYesNo.h" @@ -31,6 +31,8 @@ #include "utils/StringUtils.h" #include "utils/Variant.h" +using namespace KODI::MESSAGING; + namespace ADDON { diff --git a/xbmc/addons/GUIDialogAddonSettings.cpp b/xbmc/addons/GUIDialogAddonSettings.cpp index f7cc91b092..78e6bff113 100644 --- a/xbmc/addons/GUIDialogAddonSettings.cpp +++ b/xbmc/addons/GUIDialogAddonSettings.cpp @@ -37,7 +37,7 @@ #include "input/Key.h" #include "filesystem/Directory.h" #include "guilib/GUIWindowManager.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIKeyboardFactory.h" #include "FileItem.h" #include "settings/AdvancedSettings.h" @@ -53,6 +53,7 @@ using namespace std; using namespace ADDON; +using namespace KODI::MESSAGING; using XFILE::CDirectory; #define CONTROL_SETTINGS_AREA 2 @@ -251,7 +252,7 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl) StringUtils::Replace(action, "$ID", m_addon->ID()); if (option) bCloseDialog = (strcmpi(option, "close") == 0); - CApplicationMessenger::Get().ExecBuiltIn(action); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, action); } break; } diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index f51838c437..05357261e9 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -20,7 +20,6 @@ #include "Skin.h" #include "AddonManager.h" -#include "ApplicationMessenger.h" #include "Util.h" #include "dialogs/GUIDialogKaiToast.h" #include "dialogs/GUIDialogYesNo.h" @@ -37,6 +36,7 @@ #include "utils/URIUtils.h" #include "utils/XMLUtils.h" #include "utils/Variant.h" +#include "messaging/ApplicationMessenger.h" #define XML_SETTINGS "settings" #define XML_SETTING "setting" @@ -46,6 +46,7 @@ using namespace std; using namespace XFILE; +using namespace KODI::MESSAGING; std::shared_ptr<ADDON::CSkinInfo> g_SkinInfo; @@ -367,7 +368,7 @@ const INFO::CSkinVariableString* CSkinInfo::CreateSkinVariable(const std::string void CSkinInfo::OnPreInstall() { if (IsInUse()) - CApplicationMessenger::Get().ExecBuiltIn("UnloadSkin", true); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "UnloadSkin"); } void CSkinInfo::OnPostInstall(bool update, bool modal) @@ -381,7 +382,7 @@ void CSkinInfo::OnPostInstall(bool update, bool modal) toast->Close(true); } if (CSettings::Get().GetString("lookandfeel.skin") == ID()) - CApplicationMessenger::Get().ExecBuiltIn("ReloadSkin", true); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "ReloadSkin"); else CSettings::Get().SetString("lookandfeel.skin", ID()); } diff --git a/xbmc/android/activity/XBMCApp.cpp b/xbmc/android/activity/XBMCApp.cpp index 1ece8379d9..d0ca5f40b5 100644 --- a/xbmc/android/activity/XBMCApp.cpp +++ b/xbmc/android/activity/XBMCApp.cpp @@ -43,7 +43,7 @@ #include "windowing/WinEvents.h" #include "guilib/GUIWindowManager.h" #include "utils/log.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "utils/StringUtils.h" #include "utils/Variant.h" #include "AppParamParser.h" @@ -83,6 +83,7 @@ #define GIGABYTES 1073741824 using namespace std; +using namespace KODI::MESSAGING; template<class T, void(T::*fn)()> void* thread_run(void* obj) @@ -401,24 +402,28 @@ void CXBMCApp::XBMC_Pause(bool pause) android_printf("XBMC_Pause(%s)", pause ? "true" : "false"); // Only send the PAUSE action if we are pausing XBMC and video is currently playing if (pause && g_application.m_pPlayer->IsPlayingVideo() && !g_application.m_pPlayer->IsPaused()) - CApplicationMessenger::Get().SendAction(CAction(ACTION_PAUSE), WINDOW_INVALID, true); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_PAUSE))); } void CXBMCApp::XBMC_Stop() { - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); } bool CXBMCApp::XBMC_SetupDisplay() { android_printf("XBMC_SetupDisplay()"); - return CApplicationMessenger::Get().SetupDisplay(); + bool result; + CApplicationMessenger::Get().SendMsg(TMSG_DISPLAY_SETUP, -1, -1, static_cast<void*>(&result)); + return result; } bool CXBMCApp::XBMC_DestroyDisplay() { android_printf("XBMC_DestroyDisplay()"); - return CApplicationMessenger::Get().DestroyDisplay(); + bool result; + CApplicationMessenger::Get().SendMsg(TMSG_DISPLAY_DESTROY, -1, -1, static_cast<void*>(&result)); + return result; } int CXBMCApp::SetBuffersGeometry(int width, int height, int format) @@ -743,21 +748,23 @@ void CXBMCApp::onNewIntent(CJNIIntent intent) std::string action = intent.getAction(); if (action == "android.intent.action.VIEW") { - std::string playFile = GetFilenameFromIntent(intent); - CApplicationMessenger::Get().MediaPlay(playFile); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PLAY, 1, 0, static_cast<void*>( + new CFileItem(GetFilenameFromIntent(intent)))); } } void CXBMCApp::onVolumeChanged(int volume) { - CApplicationMessenger::Get().SendAction(CAction(ACTION_VOLUME_SET, (float)volume), WINDOW_INVALID, false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>( + new CAction(ACTION_VOLUME_SET, static_cast<float>(volume)))); } void CXBMCApp::onAudioFocusChange(int focusChange) { CXBMCApp::android_printf("Audio Focus changed: %d", focusChange); if (focusChange == CJNIAudioManager::AUDIOFOCUS_LOSS && g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) - CApplicationMessenger::Get().SendAction(CAction(ACTION_PAUSE), WINDOW_INVALID, true); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>( + new CAction(ACTION_PAUSE))); } void CXBMCApp::SetupEnv() diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 7f439495b5..3e9a870f41 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -32,7 +32,7 @@ #include "utils/StringUtils.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" #include "settings/Settings.h" @@ -62,8 +62,11 @@ #include "../dvdplayer/DVDCodecs/Video/VAAPI.h" #endif +using namespace KODI::MESSAGING; + #define MAXPRESENTDELAY 0.500 + /* at any point we want an exclusive lock on rendermanager */ /* we must make sure we don't have a graphiccontext lock */ /* these two functions allow us to step out from that lock */ @@ -267,7 +270,7 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi if( flags & CONF_FLAGS_FULLSCREEN ) { lock.Leave(); - CApplicationMessenger::Get().SwitchToFullscreen(); + CApplicationMessenger::Get().PostMsg(TMSG_SWITCHTOFULLSCREEN); lock.Enter(); } lock2.Enter(); @@ -499,9 +502,8 @@ bool CXBMCRenderManager::Flush() } else { - ThreadMessage msg = {TMSG_RENDERER_FLUSH}; m_flushEvent.Reset(); - CApplicationMessenger::Get().SendMessage(msg, false); + CApplicationMessenger::Get().PostMsg(TMSG_RENDERER_FLUSH); if (!m_flushEvent.WaitMSec(1000)) { CLog::Log(LOGERROR, "%s - timed out waiting for renderer to flush", __FUNCTION__); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index e81e9ae07e..496ec2a77d 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -29,7 +29,7 @@ #include "DVDVideoCodecAndroidMediaCodec.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "DVDClock.h" #include "threads/Atomics.h" #include "utils/BitstreamConverter.h" @@ -52,6 +52,8 @@ #include <cassert> +using namespace KODI::MESSAGING; + static bool CanSurfaceRenderBlackList(const std::string &name) { // All devices 'should' be capiable of surface rendering @@ -1258,12 +1260,8 @@ void CDVDVideoCodecAndroidMediaCodec::InitSurfaceTexture(void) callbackData.callback = &CallbackInitSurfaceTexture; callbackData.userptr = (void*)this; - ThreadMessage msg; - msg.dwMessage = TMSG_CALLBACK; - msg.lpVoid = (void*)&callbackData; - // wait for it. - CApplicationMessenger::Get().SendMessage(msg, true); + CApplicationMessenger::Get().SendMsg(TMSG_CALLBACK, -1, -1, static_cast<void*>(&callbackData)); } return; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp index 5c329db0ed..9bf9793da2 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp @@ -33,13 +33,15 @@ #include "DVDVideoCodecStageFright.h" #include "utils/log.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" #include "DllLibStageFrightCodec.h" #define CLASSNAME "CDVDVideoCodecStageFright" + +using namespace KODI::MESSAGING; //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h index fcc497bc10..35cb16aa6c 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h @@ -28,16 +28,23 @@ #include "DVDVideoCodec.h" class CApplication; -class CApplicationMessenger; class CWinSystemEGL; class CAdvancedSettings; +namespace KODI +{ + namespace MESSAGING + { + class CApplicationMessenger; + } +} + class DllLibStageFrightCodecInterface { public: virtual ~DllLibStageFrightCodecInterface() {} - virtual void* create_stf(CApplication* application, CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings)=0; + virtual void* create_stf(CApplication* application, KODI::MESSAGING::CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings)=0; virtual void destroy_stf(void*)=0; virtual bool stf_Open(void*, CDVDStreamInfo &hints) = 0; @@ -56,7 +63,7 @@ public: class DllLibStageFrightCodec : public DllDynamic, DllLibStageFrightCodecInterface { DECLARE_DLL_WRAPPER(DllLibStageFrightCodec, DLL_PATH_LIBSTAGEFRIGHTICS) - DEFINE_METHOD4(void*, create_stf, (CApplication* p1, CApplicationMessenger* p2, CWinSystemEGL* p3, CAdvancedSettings* p4)) + DEFINE_METHOD4(void*, create_stf, (CApplication* p1, KODI::MESSAGING::CApplicationMessenger* p2, CWinSystemEGL* p3, CAdvancedSettings* p4)) DEFINE_METHOD1(void, destroy_stf, (void* p1)) DEFINE_METHOD2(bool, stf_Open, (void* p1, CDVDStreamInfo &p2)) DEFINE_METHOD1(void, stf_Dispose, (void* p1)) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp index 95584aa96e..ae5f2cb84d 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/MMALCodec.cpp @@ -35,7 +35,7 @@ #include "utils/TimeUtils.h" #include "settings/Settings.h" #include "settings/MediaSettings.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Application.h" #include "threads/Atomics.h" #include "guilib/GUIWindowManager.h" @@ -46,6 +46,8 @@ #include "linux/RBP.h" +using namespace KODI::MESSAGING; + #define CLASSNAME "CMMALVideoBuffer" CMMALVideoBuffer::CMMALVideoBuffer(CMMALVideo *omv) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMax.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMax.cpp index d026ac4c36..ade2990738 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMax.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMax.cpp @@ -33,7 +33,7 @@ #include "DVDVideoCodec.h" #include "utils/log.h" #include "utils/TimeUtils.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Application.h" #include <OMX_Core.h> @@ -41,6 +41,8 @@ #include <OMX_Index.h> #include <OMX_Image.h> +using namespace KODI::MESSAGING; + #define CLASSNAME "COpenMax" //////////////////////////////////////////////////////////////////////////////////////////// diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp index bd09077630..ce952209af 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp @@ -33,7 +33,7 @@ #include "utils/log.h" #include "utils/TimeUtils.h" #include "guilib/GUIWindowManager.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Application.h" #include <OMX_Core.h> @@ -41,6 +41,8 @@ #include <OMX_Index.h> #include <OMX_Image.h> +using namespace KODI::MESSAGING; + #if 1 //#define OMX_DEBUG_EMPTYBUFFERDONE #define OMX_DEBUG_VERBOSE @@ -749,11 +751,10 @@ OMX_ERRORTYPE COpenMaxVideo::AllocOMXOutputBuffers(void) callbackData.callback = &CallbackAllocOMXEGLTextures; callbackData.userptr = (void *)this; - ThreadMessage tMsg; tMsg.dwMessage = TMSG_CALLBACK; tMsg.lpVoid = (void*)&callbackData; - CApplicationMessenger::Get().SendMessage(tMsg, true); + CApplicationMessenger::Get().SendMsg(TMSG_CALLBACK, -1, -1 static_cast<void*>(&callbackData)); omx_err = OMX_ErrorNone; } @@ -1225,12 +1226,8 @@ void OpenMaxVideoBuffer::ReleaseTexture() deleteInfo->callback.callback = &OpenMaxDeleteTextures; deleteInfo->callback.userptr = (void *)deleteInfo; - ThreadMessage tMsg; - tMsg.dwMessage = TMSG_CALLBACK; - tMsg.lpVoid = (void*)&deleteInfo->callback; - // HACK, this should be synchronous, but it's not possible since Stop blocks the GUI thread. - CApplicationMessenger::Get().SendMessage(tMsg, false); + CApplicationMessenger::Get().PostMsg(TMSG_CALLBACK, -1, -1 static_cast<void*>(deleteInfo)); } } diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp index 6366bfc095..d10a3786ab 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp @@ -24,7 +24,7 @@ #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" -void* create_stf(CApplication* application, CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings) +void* create_stf(CApplication* application, KODI::MESSAGING::CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings) { return (void*)new CStageFrightVideo(application, applicationMessenger, windowing, advsettings); } @@ -83,4 +83,3 @@ void stf_ReleaseBuffer(void* stf, EGLImageKHR eglimg) { ((CStageFrightVideo*)stf)->ReleaseBuffer(eglimg); } - diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h index ffd9700067..9b0def2244 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h @@ -24,13 +24,20 @@ class CStageFrightVideo; class CApplication; -class CApplicationMessenger; class CWinSystemEGL; class CAdvancedSettings; +namespace KODI +{ + namespace MESSAGING + { + class CApplicationMessenger; + } +} + extern "C" { - void* create_stf(CApplication* application, CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings); + void* create_stf(CApplication* application, KODI::MESSAGING::CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings); void destroy_stf(void*); bool stf_Open(void*, CDVDStreamInfo &hints); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp index d5ca74f3e2..4d144bebf2 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp @@ -33,7 +33,7 @@ #include "threads/Thread.h" #include "threads/Event.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "settings/AdvancedSettings.h" #include "android/jni/Build.h" @@ -55,6 +55,7 @@ #define EGL_IMAGE_PRESERVED_KHR 0x30D2 using namespace android; +using namespace KODI::MESSAGING; static int64_t pts_dtoi(double pts) { diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h index f36db6794d..44f070e6c4 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h @@ -24,8 +24,15 @@ #include "cores/dvdplayer/DVDStreamInfo.h" #include "DVDVideoCodec.h" +namespace KODI +{ + namespace MESSAGING + { + class CApplicationMessenger; + } +} + class CApplication; -class CApplicationMessenger; class CWinSystemEGL; class CAdvancedSettings; class CStageFrightVideoPrivate; @@ -35,7 +42,7 @@ namespace android { class MediaBuffer; } class CStageFrightVideo { public: - CStageFrightVideo(CApplication* application, CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings); + CStageFrightVideo(CApplication* application, KODI::MESSAGING::CApplicationMessenger* applicationMessenger, CWinSystemEGL* windowing, CAdvancedSettings* advsettings); virtual ~CStageFrightVideo(); bool Open(CDVDStreamInfo &hints); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp index ee0f7ac7f2..f0a03a8cec 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp @@ -29,7 +29,7 @@ #include <GLES2/gl2ext.h> #include "windowing/egl/EGLWrapper.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "windowing/WindowingFactory.h" #include "settings/AdvancedSettings.h" #include "utils/log.h" @@ -40,6 +40,8 @@ #define CLASSNAME "CStageFrightVideoPrivate" +using namespace KODI::MESSAGING; + GLint glerror; #define CheckEglError(x) while((glerror = eglGetError()) != EGL_SUCCESS) CLog::Log(LOGERROR, "EGL error in %s: %x",x, glerror); #define CheckGlError(x) while((glerror = glGetError()) != GL_NO_ERROR) CLog::Log(LOGERROR, "GL error in %s: %x",x, glerror); diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h index 02a6dc42d9..e3a5030cba 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h @@ -65,7 +65,14 @@ class CJNISurfaceTexture; class CWinSystemEGL; class CAdvancedSettings; class CApplication; -class CApplicationMessenger; + +namespace KODI +{ + namespace MESSAGING + { + class CApplicationMessenger; + } +} struct stSlot { @@ -122,7 +129,7 @@ public: GLint mTexMatrixHandle; CApplication* m_g_application; - CApplicationMessenger* m_g_applicationMessenger; + KODI::MESSAGING::CApplicationMessenger* m_g_applicationMessenger; CWinSystemEGL* m_g_Windowing; CAdvancedSettings* m_g_advancedSettings; diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index 8eb4efc36b..4761c58863 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -44,7 +44,7 @@ #include "guilib/GUIWindowManager.h" #include "guilib/StereoscopicsManager.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "DVDDemuxers/DVDDemuxCC.h" #ifdef HAS_VIDEO_PLAYBACK @@ -83,6 +83,7 @@ using namespace std; using namespace PVR; +using namespace KODI::MESSAGING; void CSelectionStreams::Clear(StreamType type, StreamSource source) { @@ -2573,7 +2574,7 @@ void CDVDPlayer::HandleMessages() }else { CLog::Log(LOGWARNING, "%s - failed to switch channel. playback stopped", __FUNCTION__); - CApplicationMessenger::Get().MediaStop(false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_STOP); } } else if (pMsg->IsType(CDVDMsg::PLAYER_CHANNEL_SELECT) && m_messenger.GetPacketCount(CDVDMsg::PLAYER_CHANNEL_SELECT) == 0) @@ -2587,7 +2588,7 @@ void CDVDPlayer::HandleMessages() }else { CLog::Log(LOGWARNING, "%s - failed to switch channel. playback stopped", __FUNCTION__); - CApplicationMessenger::Get().MediaStop(false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_STOP); } } else if (pMsg->IsType(CDVDMsg::PLAYER_CHANNEL_NEXT) || pMsg->IsType(CDVDMsg::PLAYER_CHANNEL_PREV)) @@ -2633,7 +2634,7 @@ void CDVDPlayer::HandleMessages() else { CLog::Log(LOGWARNING, "%s - failed to switch channel. playback stopped", __FUNCTION__); - CApplicationMessenger::Get().MediaStop(false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_STOP); } } } @@ -4047,7 +4048,7 @@ bool CDVDPlayer::OnAction(const CAction &action) return true; else { - CApplicationMessenger::Get().SendAction(CAction(ACTION_TRIGGER_OSD), WINDOW_INVALID, false); // Trigger the osd + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_TRIGGER_OSD))); return false; } } @@ -4561,7 +4562,7 @@ void CDVDPlayer::UpdateApplication(double timeout) if(pStream->UpdateItem(item)) { g_application.CurrentFileItem() = item; - CApplicationMessenger::Get().SetCurrentItem(item); + CApplicationMessenger::Get().PostMsg(TMSG_UPDATE_CURRENT_ITEM, 0, -1, static_cast<void*>(new CFileItem(item))); } } m_UpdateApplication = CDVDClock::GetAbsoluteClock(); diff --git a/xbmc/dialogs/GUIDialogCache.cpp b/xbmc/dialogs/GUIDialogCache.cpp index db57a24c00..aaf0073921 100644 --- a/xbmc/dialogs/GUIDialogCache.cpp +++ b/xbmc/dialogs/GUIDialogCache.cpp @@ -20,7 +20,7 @@ #include "threads/SystemClock.h" #include "GUIDialogCache.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogProgress.h" #include "guilib/LocalizeStrings.h" @@ -29,6 +29,8 @@ #include "utils/Variant.h" +using namespace KODI::MESSAGING; + CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const std::string& strHeader, const std::string& strMsg) : CThread("GUIDialogCache"), m_strHeader(strHeader), m_strLinePrev(strMsg) @@ -59,7 +61,7 @@ void CGUIDialogCache::Close(bool bForceClose) // we cannot wait for the app thread to process the close message // as this might happen during player startup which leads to a deadlock if (m_pDlg && m_pDlg->IsDialogRunning()) - CApplicationMessenger::Get().Close(m_pDlg,bForceClose,false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_WINDOW_CLOSE, -1, bForceClose ? 1 : 0, static_cast<void*>(m_pDlg)); //Set stop, this will kill this object, when thread stops CThread::m_bStop = true; diff --git a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp index 7007480fab..5330b04cdc 100644 --- a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp +++ b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp @@ -32,9 +32,12 @@ #include "settings/Settings.h" #include "utils/RegExp.h" #include "utils/Variant.h" -#include "ApplicationMessenger.h" +#include "utils/StringUtils.h" +#include "messaging/ApplicationMessenger.h" #include "windowing/WindowingFactory.h" +using namespace KODI::MESSAGING; + #define BUTTON_ID_OFFSET 100 #define BUTTONS_PER_ROW 20 #define BUTTONS_MAX_ROWS 4 diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index 7c0e45bc8f..fb1feee30b 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -34,13 +34,14 @@ #include "video/VideoInfoTag.h" #include "utils/log.h" #include "utils/StringUtils.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Application.h" #include "URL.h" using namespace XFILE; using namespace std; using namespace ADDON; +using namespace KODI::MESSAGING; map<int, CPluginDirectory *> CPluginDirectory::globalHandles; int CPluginDirectory::handleCounter = 0; @@ -537,7 +538,7 @@ bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scr } if (progressBar) - CApplicationMessenger::Get().Close(progressBar, false, false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_WINDOW_CLOSE, -1, 0, static_cast<void*>(progressBar)); return !cancelled && m_success; } diff --git a/xbmc/filesystem/ShoutcastFile.cpp b/xbmc/filesystem/ShoutcastFile.cpp index d649d75663..b70ff2f17f 100644 --- a/xbmc/filesystem/ShoutcastFile.cpp +++ b/xbmc/filesystem/ShoutcastFile.cpp @@ -30,12 +30,14 @@ #include "utils/RegExp.h" #include "utils/HTMLUtil.h" #include "utils/CharsetConverter.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "FileCache.h" +#include "FileItem.h" #include <climits> using namespace XFILE; using namespace MUSIC_INFO; +using namespace KODI::MESSAGING; CShoutcastFile::CShoutcastFile() : IFile(), CThread("ShoutcastFile") @@ -202,7 +204,7 @@ void CShoutcastFile::Process() { while (!m_bStop && m_cacheReader->GetPosition() < m_tagPos) Sleep(20); - CApplicationMessenger::Get().SetCurrentSongTag(m_tag); + CApplicationMessenger::Get().PostMsg(TMSG_UPDATE_CURRENT_ITEM, 1,-1, static_cast<void*>(new CFileItem(m_tag))); m_tagPos = 0; } } diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp index 67b9d61c33..15947d182c 100644 --- a/xbmc/guilib/GUIDialog.cpp +++ b/xbmc/guilib/GUIDialog.cpp @@ -24,9 +24,11 @@ #include "threads/SingleLock.h" #include "utils/TimeUtils.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "input/Key.h" +using namespace KODI::MESSAGING; + CGUIDialog::CGUIDialog(int id, const std::string &xmlFile, DialogModalityType modalityType /* = DialogModalityType::MODAL */) : CGUIWindow(id, xmlFile) { @@ -188,15 +190,15 @@ void CGUIDialog::Open_Internal(bool bProcessRenderLoop) // process render loop if (bProcessRenderLoop) { - if (!m_windowLoaded) - Close(true); + if (!m_windowLoaded) + Close(true); - lock.Leave(); + lock.Leave(); - while (m_active && !g_application.m_bStop) - { - g_windowManager.ProcessRenderLoop(); - } + while (m_active && !g_application.m_bStop) + { + g_windowManager.ProcessRenderLoop(); + } } } @@ -206,7 +208,7 @@ void CGUIDialog::Open() { // make sure graphics lock is not held CSingleExit leaveIt(g_graphicsContext); - CApplicationMessenger::Get().Open(this); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_DIALOG_OPEN, -1, -1, static_cast<void*>(this)); } else Open_Internal(); diff --git a/xbmc/guilib/GUIKeyboardFactory.cpp b/xbmc/guilib/GUIKeyboardFactory.cpp index 0199896b61..a4ea151832 100644 --- a/xbmc/guilib/GUIKeyboardFactory.cpp +++ b/xbmc/guilib/GUIKeyboardFactory.cpp @@ -19,7 +19,7 @@ */ #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "LocalizeStrings.h" #include "GUIKeyboardFactory.h" #include "dialogs/GUIDialogOK.h" @@ -36,6 +36,8 @@ #include "windowing/WindowingFactory.h" #endif +using namespace KODI::MESSAGING; + CGUIKeyboard *CGUIKeyboardFactory::g_activedKeyboard = NULL; FILTERING CGUIKeyboardFactory::m_filtering = FILTERING_NONE; diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp index a700ebe83b..448ddfee63 100644 --- a/xbmc/guilib/GUIWindow.cpp +++ b/xbmc/guilib/GUIWindow.cpp @@ -35,7 +35,7 @@ #include "utils/XMLUtils.h" #include "GUIAudioManager.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "utils/Variant.h" #include "utils/StringUtils.h" @@ -44,6 +44,7 @@ #endif using namespace std; +using namespace KODI::MESSAGING; bool CGUIWindow::icompare::operator()(const std::string &s1, const std::string &s2) const { @@ -401,7 +402,11 @@ void CGUIWindow::Close(bool forceClose /*= false*/, int nextWindowID /*= 0*/, bo { // make sure graphics lock is not held CSingleExit leaveIt(g_graphicsContext); - CApplicationMessenger::Get().Close(this, forceClose, bWait, nextWindowID, enableSound); + int param2 = (forceClose ? 0x01 : 0) | (enableSound ? 0x02 : 0); + if (bWait) + CApplicationMessenger::Get().SendMsg(TMSG_GUI_WINDOW_CLOSE, nextWindowID, param2, static_cast<void*>(this)); + else + CApplicationMessenger::Get().PostMsg(TMSG_GUI_WINDOW_CLOSE, nextWindowID, param2, static_cast<void*>(this)); } else Close_Internal(forceClose, nextWindowID, enableSound); diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 6500bf541c..ae85337270 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -22,7 +22,7 @@ #include "GUIAudioManager.h" #include "GUIDialog.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIPassword.h" #include "GUIInfoManager.h" #include "threads/SingleLock.h" @@ -144,10 +144,12 @@ #include "peripherals/dialogs/GUIDialogPeripheralManager.h" #include "peripherals/dialogs/GUIDialogPeripheralSettings.h" +#include "addons/AddonCallbacksGUI.h" using namespace std; using namespace PVR; using namespace PERIPHERALS; +using namespace KODI::MESSAGING; CGUIWindowManager::CGUIWindowManager(void) { @@ -167,6 +169,8 @@ void CGUIWindowManager::Initialize() m_initialized = true; LoadNotOnDemandWindows(); + + CApplicationMessenger::Get().RegisterReceveiver(this); } void CGUIWindowManager::CreateWindows() @@ -717,7 +721,7 @@ void CGUIWindowManager::ActivateWindow(int iWindowID, const vector<string>& para { // make sure graphics lock is not held CSingleExit leaveIt(g_graphicsContext); - CApplicationMessenger::Get().ActivateWindow(iWindowID, params, swappingWindows, force); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTIVATE_WINDOW, iWindowID, swappingWindows ? 1 : 0, nullptr, "", params); } else { @@ -834,6 +838,90 @@ void CGUIWindowManager::CloseInternalModalDialogs(bool forceClose) const } } +void CGUIWindowManager::OnApplicationMessage(ThreadMessage* pMsg) +{ + switch (pMsg->dwMessage) + { + case TMSG_GUI_DIALOG_OPEN: + { + CGUIDialog* pDialog = static_cast<CGUIDialog*>(GetWindow(pMsg->param1)); + if (!pDialog) + pDialog->Open(); + } + break; + + case TMSG_GUI_WINDOW_CLOSE: + { + CGUIWindow *window = static_cast<CGUIWindow *>(pMsg->lpVoid); + if (window) + window->Close(pMsg->param1 & 0x1 ? true : false, pMsg->param1, pMsg->param1 & 0x2 ? true : false); + } + break; + + case TMSG_GUI_ACTIVATE_WINDOW: + { + ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 > 0); + } + break; + + case TMSG_GUI_ADDON_DIALOG: + { + if (pMsg->lpVoid) + { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs + static_cast<ADDON::CGUIAddonWindowDialog *>(pMsg->lpVoid)->Show_Internal(pMsg->param2 > 0); + } + } + break; + +#ifdef HAS_PYTHON + case TMSG_GUI_PYTHON_DIALOG: + { + // This hack is not much better but at least I don't need to make ApplicationMessenger + // know about Addon (Python) specific classes. + CAction caction(pMsg->param1); + static_cast<CGUIWindow*>(pMsg->lpVoid)->OnAction(caction); + } + break; +#endif + + case TMSG_GUI_ACTION: + { + if (pMsg->lpVoid) + { + CAction *action = static_cast<CAction *>(pMsg->lpVoid); + if (pMsg->param1 == WINDOW_INVALID) + g_application.OnAction(*action); + else + { + CGUIWindow *pWindow = GetWindow(pMsg->param1); + if (pWindow) + pWindow->OnAction(*action); + else + CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->param1); + } + delete action; + } + } + break; + + case TMSG_GUI_MESSAGE: + { + if (pMsg->lpVoid) + { + CGUIMessage *message = static_cast<CGUIMessage *>(pMsg->lpVoid); + SendMessage(*message, pMsg->param1); + delete message; + } + } + break; + } +} + +int CGUIWindowManager::GetMessageMask() +{ + return TMSG_MASK_WINDOWMANAGER; +} + bool CGUIWindowManager::OnAction(const CAction &action) const { CSingleLock lock(g_graphicsContext); diff --git a/xbmc/guilib/GUIWindowManager.h b/xbmc/guilib/GUIWindowManager.h index c08c7d5666..1efe316030 100644 --- a/xbmc/guilib/GUIWindowManager.h +++ b/xbmc/guilib/GUIWindowManager.h @@ -34,18 +34,27 @@ #include "DirtyRegionTracker.h" #include "utils/GlobalsHandling.h" #include "guilib/WindowIDs.h" +#include "messaging/IMessageTarget.h" #include <list> class CGUIDialog; enum class DialogModalityType; +namespace KODI +{ + namespace MESSAGING + { + class CApplicationMessenger; + } +} + #define WINDOW_ID_MASK 0xffff /*! \ingroup winman \brief */ -class CGUIWindowManager +class CGUIWindowManager : public KODI::MESSAGING::IMessageTarget { public: CGUIWindowManager(void); @@ -68,6 +77,9 @@ public: void CloseDialogs(bool forceClose = false) const; void CloseInternalModalDialogs(bool forceClose = false) const; + virtual void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; + virtual int GetMessageMask() override; + // OnAction() runs through our active dialogs and windows and sends the message // off to the callbacks (application, python, playlist player) and to the // currently focused window(s). Returns true only if the message is handled. @@ -182,8 +194,8 @@ private: void CloseWindowSync(CGUIWindow *window, int nextWindowID = 0); CGUIWindow *GetTopMostDialog() const; - friend class CApplicationMessenger; - + friend class KODI::MESSAGING::CApplicationMessenger; + /*! \brief Activate the given window. * * \param windowID The window ID to activate. diff --git a/xbmc/guilib/GraphicContext.cpp b/xbmc/guilib/GraphicContext.cpp index bd7dff932e..2d680bc7a4 100644 --- a/xbmc/guilib/GraphicContext.cpp +++ b/xbmc/guilib/GraphicContext.cpp @@ -21,7 +21,7 @@ #include "system.h" #include "GraphicContext.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "settings/AdvancedSettings.h" #include "settings/DisplaySettings.h" #include "settings/lib/Setting.h" @@ -34,6 +34,7 @@ #include "video/VideoReferenceClock.h" using namespace std; +using namespace KODI::MESSAGING; extern bool g_fullScreen; @@ -380,10 +381,7 @@ void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate) } else { - ThreadMessage msg = {TMSG_SETVIDEORESOLUTION}; - msg.param1 = res; - msg.param2 = forceUpdate ? 1 : 0; - CApplicationMessenger::Get().SendMessage(msg, true); + CApplicationMessenger::Get().SendMsg(TMSG_SETVIDEORESOLUTION, res, forceUpdate ? 1 : 0); } } @@ -412,7 +410,7 @@ void CGraphicContext::SetVideoResolutionInternal(RESOLUTION res, bool forceUpdat if (delay > 0 && CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF && g_application.m_pPlayer->IsPlayingVideo() && !g_application.m_pPlayer->IsPausedPlayback()) { g_application.m_pPlayer->Pause(); - ThreadMessage msg = {TMSG_MEDIA_UNPAUSE}; + KODI::MESSAGING::ThreadMessage msg{TMSG_MEDIA_UNPAUSE}; CDelayedMessage* pauseMessage = new CDelayedMessage(msg, delay * 100); pauseMessage->Create(true); } diff --git a/xbmc/guilib/StereoscopicsManager.cpp b/xbmc/guilib/StereoscopicsManager.cpp index 8765492298..676c04d29f 100644 --- a/xbmc/guilib/StereoscopicsManager.cpp +++ b/xbmc/guilib/StereoscopicsManager.cpp @@ -27,7 +27,7 @@ #include "StereoscopicsManager.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "dialogs/GUIDialogKaiToast.h" #include "dialogs/GUIDialogSelect.h" #include "GUIInfoManager.h" @@ -46,6 +46,7 @@ #include "windowing/WindowingFactory.h" #include "guiinfo/GUIInfoLabels.h" +using namespace KODI::MESSAGING; struct StereoModeMap { @@ -549,7 +550,7 @@ void CStereoscopicsManager::OnPlaybackStarted(void) { case STEREOSCOPIC_PLAYBACK_MODE_ASK: // Ask { - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); @@ -586,7 +587,7 @@ void CStereoscopicsManager::OnPlaybackStarted(void) SetStereoModeByUser( mode ); } - CApplicationMessenger::Get().MediaUnPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_UNPAUSE); } break; case STEREOSCOPIC_PLAYBACK_MODE_PREFERRED: // Stereoscopic diff --git a/xbmc/input/InputManager.cpp b/xbmc/input/InputManager.cpp index 2ae10aaf2a..3edc2f7772 100644 --- a/xbmc/input/InputManager.cpp +++ b/xbmc/input/InputManager.cpp @@ -23,7 +23,7 @@ #include "Application.h" #include "InputManager.h" #include "input/Key.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/Geometry.h" #include "guilib/GUIAudioManager.h" #include "guilib/GUIControl.h" @@ -73,6 +73,7 @@ using EVENTSERVER::CEventServer; #endif +using namespace KODI::MESSAGING; using PERIPHERALS::CPeripherals; CInputManager& CInputManager::Get() @@ -490,13 +491,16 @@ bool CInputManager::OnEvent(XBMC_Event& newEvent) if ((actionId >= ACTION_TOUCH_TAP && actionId <= ACTION_GESTURE_END) || (actionId >= ACTION_MOUSE_START && actionId <= ACTION_MOUSE_END)) - CApplicationMessenger::Get().SendAction(CAction(actionId, 0, newEvent.touch.x, newEvent.touch.y, newEvent.touch.x2, newEvent.touch.y2), WINDOW_INVALID, false); + { + auto action = new CAction(actionId, 0, newEvent.touch.x, newEvent.touch.y, newEvent.touch.x2, newEvent.touch.y2); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(action)); + } else { if (actionId == ACTION_BUILT_IN_FUNCTION && !actionString.empty()) - CApplicationMessenger::Get().SendAction(CAction(actionId, actionString), WINDOW_INVALID, false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionId, actionString))); else - CApplicationMessenger::Get().SendAction(CAction(actionId), WINDOW_INVALID, false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionId))); } // Post an unfocus message for touch device after the action. @@ -541,12 +545,14 @@ bool CInputManager::OnKey(const CKey& key) if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState")) { CLog::LogF(LOGDEBUG, "action %s [%d], toggling state of playing device", action.GetName().c_str(), action.GetID()); - if (!CApplicationMessenger::Get().CECToggleState()) + bool result; + CApplicationMessenger::Get().SendMsg(TMSG_CECTOGGLESTATE, 0, 0, static_cast<void*>(&result)); + if (!result) return true; } else { - CApplicationMessenger::Get().CECStandby(); + CApplicationMessenger::Get().PostMsg(TMSG_CECSTANDBY); return true; } } diff --git a/xbmc/input/touch/generic/GenericTouchActionHandler.cpp b/xbmc/input/touch/generic/GenericTouchActionHandler.cpp index fc8599c9da..96a5070135 100644 --- a/xbmc/input/touch/generic/GenericTouchActionHandler.cpp +++ b/xbmc/input/touch/generic/GenericTouchActionHandler.cpp @@ -19,11 +19,13 @@ */ #include "GenericTouchActionHandler.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIWindowManager.h" #include "input/Key.h" #include "windowing/WinEvents.h" +using namespace KODI::MESSAGING; + CGenericTouchActionHandler &CGenericTouchActionHandler::Get() { static CGenericTouchActionHandler sTouchAction; diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp index 3131832189..d918740bff 100644 --- a/xbmc/interfaces/Builtins.cpp +++ b/xbmc/interfaces/Builtins.cpp @@ -24,7 +24,7 @@ #include "utils/Screenshot.h" #include "utils/SeekHandler.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Autorun.h" #include "Builtins.h" #include "input/ButtonTranslator.h" @@ -110,6 +110,7 @@ using namespace std; using namespace XFILE; using namespace ADDON; +using namespace KODI::MESSAGING; #ifdef HAS_DVD_DRIVE using namespace MEDIA_DETECT; @@ -322,44 +323,44 @@ int CBuiltins::Execute(const std::string& execString) if (execute == "reboot" || execute == "restart" || execute == "reset") //Will reboot the system { - CApplicationMessenger::Get().Restart(); + CApplicationMessenger::Get().PostMsg(TMSG_RESTART); } else if (execute == "shutdown") { - CApplicationMessenger::Get().Shutdown(); + CApplicationMessenger::Get().PostMsg(TMSG_SHUTDOWN); } else if (execute == "powerdown") { - CApplicationMessenger::Get().Powerdown(); + CApplicationMessenger::Get().PostMsg(TMSG_POWERDOWN); } else if (execute == "restartapp") { - CApplicationMessenger::Get().RestartApp(); + CApplicationMessenger::Get().PostMsg(TMSG_RESTARTAPP); } else if (execute == "hibernate") { - CApplicationMessenger::Get().Hibernate(); + CApplicationMessenger::Get().PostMsg(TMSG_HIBERNATE); } else if (execute == "suspend") { - CApplicationMessenger::Get().Suspend(); + CApplicationMessenger::Get().PostMsg(TMSG_SUSPEND); } else if (execute == "quit") { - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); } else if (execute == "inhibitidleshutdown") { bool inhibit = (params.size() == 1 && StringUtils::EqualsNoCase(params[0], "true")); - CApplicationMessenger::Get().InhibitIdleShutdown(inhibit); + CApplicationMessenger::Get().PostMsg(TMSG_INHIBITIDLESHUTDOWN, inhibit); } else if (execute == "activatescreensaver") { - CApplicationMessenger::Get().ActivateScreensaver(); + CApplicationMessenger::Get().PostMsg(TMSG_ACTIVATESCREENSAVER); } else if (execute == "minimize") { - CApplicationMessenger::Get().Minimize(); + CApplicationMessenger::Get().PostMsg(TMSG_MINIMIZE); } else if (execute == "loadprofile") { @@ -370,7 +371,7 @@ int CBuiltins::Execute(const std::string& execString) && (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || g_passwordManager.IsProfileLockUnlocked(index,bCanceled,prompt))) { - CApplicationMessenger::Get().LoadProfile(index); + CApplicationMessenger::Get().PostMsg(TMSG_LOADPROFILE, index); } } else if (execute == "mastermode") @@ -396,7 +397,7 @@ int CBuiltins::Execute(const std::string& execString) { if (params.size()) { - CApplicationMessenger::Get().SetGUILanguage(params[0]); + CApplicationMessenger::Get().PostMsg(TMSG_SETLANGUAGE, -1, -1, nullptr, params[0]); } } else if (execute == "takescreenshot") @@ -569,13 +570,13 @@ int CBuiltins::Execute(const std::string& execString) } else if (execute == "system.exec") { - CApplicationMessenger::Get().Minimize(); - CApplicationMessenger::Get().ExecOS(parameter, false); + CApplicationMessenger::Get().PostMsg(TMSG_MINIMIZE); + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_OS, 0, -1, nullptr, parameter); } else if (execute == "system.execwait") { - CApplicationMessenger::Get().Minimize(); - CApplicationMessenger::Get().ExecOS(parameter, true); + CApplicationMessenger::Get().PostMsg(TMSG_MINIMIZE); + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_OS, 1, -1, nullptr, parameter); } else if (execute == "resolution") { @@ -1121,7 +1122,7 @@ int CBuiltins::Execute(const std::string& execString) { if(params.size() > 1 && StringUtils::EqualsNoCase(params[1], "showVolumeBar")) { - CApplicationMessenger::Get().ShowVolumeBar(oldVolume < volume); + CApplicationMessenger::Get().PostMsg(TMSG_VOLUME_SHOW, oldVolume < volume ? ACTION_VOLUME_UP : ACTION_VOLUME_DOWN); } } } @@ -1742,7 +1743,7 @@ int CBuiltins::Execute(const std::string& execString) if (CButtonTranslator::TranslateActionString(params[0].c_str(), actionID)) { int windowID = params.size() == 2 ? CButtonTranslator::TranslateWindow(params[1]) : WINDOW_INVALID; - CApplicationMessenger::Get().SendAction(CAction(actionID), windowID); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, windowID, -1, static_cast<void*>(new CAction(actionID))); } } else if (execute == "setproperty" && params.size() >= 2) @@ -1808,15 +1809,16 @@ int CBuiltins::Execute(const std::string& execString) } else if (execute == "cectogglestate") { - CApplicationMessenger::Get().CECToggleState(); + bool result; + CApplicationMessenger::Get().SendMsg(TMSG_CECTOGGLESTATE, 0, 0, static_cast<void*>(&result)); } else if (execute == "cecactivatesource") { - CApplicationMessenger::Get().CECActivateSource(); + CApplicationMessenger::Get().PostMsg(TMSG_CECACTIVATESOURCE); } else if (execute == "cecstandby") { - CApplicationMessenger::Get().CECStandby(); + CApplicationMessenger::Get().PostMsg(TMSG_CECSTANDBY); } else if (execute == "weather.locationset" && !params.empty()) { @@ -1860,13 +1862,13 @@ int CBuiltins::Execute(const std::string& execString) } else if (execute == "startandroidactivity" && !params.empty()) { - CApplicationMessenger::Get().StartAndroidActivity(params); + CApplicationMessenger::Get().PostMsg(TMSG_START_ANDROID_ACTIVITY, -1, -1, static_cast<void*>(¶ms)); } else if (execute == "setstereomode" && !parameter.empty()) { CAction action = CStereoscopicsManager::Get().ConvertActionCommandToAction(execute, parameter); if (action.GetID() != ACTION_NONE) - CApplicationMessenger::Get().SendAction(action); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(action))); else { CLog::Log(LOGERROR,"Builtin 'SetStereoMode' called with unknown parameter: %s", parameter.c_str()); diff --git a/xbmc/interfaces/json-rpc/AddonsOperations.cpp b/xbmc/interfaces/json-rpc/AddonsOperations.cpp index 7b4734ac93..631506b02f 100644 --- a/xbmc/interfaces/json-rpc/AddonsOperations.cpp +++ b/xbmc/interfaces/json-rpc/AddonsOperations.cpp @@ -23,7 +23,7 @@ #include "addons/AddonManager.h" #include "addons/AddonDatabase.h" #include "addons/PluginSource.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "TextureCache.h" #include "filesystem/File.h" #include "utils/StringUtils.h" @@ -33,6 +33,7 @@ using namespace std; using namespace JSONRPC; using namespace ADDON; using namespace XFILE; +using namespace KODI::MESSAGING; JSONRPC_STATUS CAddonsOperations::GetAddons(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -196,7 +197,11 @@ JSONRPC_STATUS CAddonsOperations::ExecuteAddon(const std::string &method, ITrans cmd = StringUtils::Format("RunAddon(%s)", id.c_str()); else cmd = StringUtils::Format("RunAddon(%s, %s)", id.c_str(), argv.c_str()); - CApplicationMessenger::Get().ExecBuiltIn(cmd, parameterObject["wait"].asBoolean()); + + if (params["wait"].asBoolean()) + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); + else + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } diff --git a/xbmc/interfaces/json-rpc/ApplicationOperations.cpp b/xbmc/interfaces/json-rpc/ApplicationOperations.cpp index 5f0bfe0e83..ad31f656e3 100644 --- a/xbmc/interfaces/json-rpc/ApplicationOperations.cpp +++ b/xbmc/interfaces/json-rpc/ApplicationOperations.cpp @@ -21,7 +21,11 @@ #include "ApplicationOperations.h" #include "InputOperations.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" +#include "FileItem.h" +#include "Util.h" +#include "utils/log.h" +#include "GUIInfoManager.h" #include "system.h" #include "CompileInfo.h" #include "utils/StringUtils.h" @@ -29,6 +33,7 @@ #include <string.h> using namespace JSONRPC; +using namespace KODI::MESSAGING; JSONRPC_STATUS CApplicationOperations::GetProperties(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -84,7 +89,7 @@ JSONRPC_STATUS CApplicationOperations::SetVolume(const std::string &method, ITra else return InvalidParams; - CApplicationMessenger::Get().ShowVolumeBar(up); + CApplicationMessenger::Get().PostMsg(TMSG_VOLUME_SHOW, up ? ACTION_VOLUME_UP : ACTION_VOLUME_DOWN); return GetPropertyValue("volume", result); } @@ -93,7 +98,7 @@ JSONRPC_STATUS CApplicationOperations::SetMute(const std::string &method, ITrans { if ((parameterObject["mute"].isString() && parameterObject["mute"].asString().compare("toggle") == 0) || (parameterObject["mute"].isBoolean() && parameterObject["mute"].asBoolean() != g_application.IsMuted())) - CApplicationMessenger::Get().SendAction(CAction(ACTION_MUTE)); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_MUTE))); else if (!parameterObject["mute"].isBoolean() && !parameterObject["mute"].isString()) return InvalidParams; @@ -102,7 +107,7 @@ JSONRPC_STATUS CApplicationOperations::SetMute(const std::string &method, ITrans JSONRPC_STATUS CApplicationOperations::Quit(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); return ACK; } diff --git a/xbmc/interfaces/json-rpc/AudioLibrary.cpp b/xbmc/interfaces/json-rpc/AudioLibrary.cpp index dda8a084d5..f63009dfee 100644 --- a/xbmc/interfaces/json-rpc/AudioLibrary.cpp +++ b/xbmc/interfaces/json-rpc/AudioLibrary.cpp @@ -30,13 +30,15 @@ #include "music/Artist.h" #include "music/Album.h" #include "music/Song.h" -#include "ApplicationMessenger.h" +#include "music/Artist.h" +#include "messaging/ApplicationMessenger.h" #include "filesystem/Directory.h" #include "settings/Settings.h" using namespace MUSIC_INFO; using namespace JSONRPC; using namespace XFILE; +using namespace KODI::MESSAGING; JSONRPC_STATUS CAudioLibrary::GetArtists(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -533,7 +535,7 @@ JSONRPC_STATUS CAudioLibrary::Scan(const std::string &method, ITransportLayer *t std::string directory = parameterObject["directory"].asString(); std::string cmd = StringUtils::Format("updatelibrary(music, %s, %s)", StringUtils::Paramify(directory).c_str(), parameterObject["showdialogs"].asBoolean() ? "true" : "false"); - CApplicationMessenger::Get().ExecBuiltIn(cmd); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } @@ -547,14 +549,14 @@ JSONRPC_STATUS CAudioLibrary::Export(const std::string &method, ITransportLayer parameterObject["options"]["images"].asBoolean() ? "true" : "false", parameterObject["options"]["overwrite"].asBoolean() ? "true" : "false"); - CApplicationMessenger::Get().ExecBuiltIn(cmd); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } JSONRPC_STATUS CAudioLibrary::Clean(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { std::string cmd = StringUtils::Format("cleanlibrary(music, %s)", parameterObject["showdialogs"].asBoolean() ? "true" : "false"); - CApplicationMessenger::Get().ExecBuiltIn(cmd); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } diff --git a/xbmc/interfaces/json-rpc/GUIOperations.cpp b/xbmc/interfaces/json-rpc/GUIOperations.cpp index ced9160fc6..69fd97c385 100644 --- a/xbmc/interfaces/json-rpc/GUIOperations.cpp +++ b/xbmc/interfaces/json-rpc/GUIOperations.cpp @@ -20,7 +20,7 @@ #include "GUIOperations.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIInfoManager.h" #include "guilib/GUIWindowManager.h" #include "input/Key.h" @@ -35,6 +35,7 @@ using namespace std; using namespace JSONRPC; using namespace ADDON; +using namespace KODI::MESSAGING; JSONRPC_STATUS CGUIOperations::GetProperties(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -95,7 +96,9 @@ JSONRPC_STATUS CGUIOperations::SetFullscreen(const std::string &method, ITranspo parameterObject["fullscreen"].asString().compare("toggle") == 0) || (parameterObject["fullscreen"].isBoolean() && parameterObject["fullscreen"].asBoolean() != g_application.IsFullScreen())) - CApplicationMessenger::Get().SendAction(CAction(ACTION_SHOW_GUI)); + { + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_SHOW_GUI))); + } else if (!parameterObject["fullscreen"].isBoolean() && !parameterObject["fullscreen"].isString()) return InvalidParams; @@ -107,7 +110,7 @@ JSONRPC_STATUS CGUIOperations::SetStereoscopicMode(const std::string &method, IT CAction action = CStereoscopicsManager::Get().ConvertActionCommandToAction("SetStereoMode", parameterObject["mode"].asString()); if (action.GetID() != ACTION_NONE) { - CApplicationMessenger::Get().SendAction(action); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(action))); return ACK; } diff --git a/xbmc/interfaces/json-rpc/InputOperations.cpp b/xbmc/interfaces/json-rpc/InputOperations.cpp index 7d2ff2c791..ef9b20664d 100644 --- a/xbmc/interfaces/json-rpc/InputOperations.cpp +++ b/xbmc/interfaces/json-rpc/InputOperations.cpp @@ -20,13 +20,19 @@ #include "InputOperations.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIAudioManager.h" #include "guilib/GUIWindow.h" +#include "guilib/GUIWindowManager.h" +#include "guilib/GUIKeyboardFactory.h" #include "input/ButtonTranslator.h" #include "utils/Variant.h" +#include "input/XBMC_keyboard.h" +#include "input/XBMC_vkeys.h" +#include "threads/SingleLock.h" using namespace JSONRPC; +using namespace KODI::MESSAGING; //TODO the breakage of the screensaver should be refactored //to one central super duper place for getting rid of @@ -46,7 +52,10 @@ JSONRPC_STATUS CInputOperations::SendAction(int actionID, bool wakeScreensaver / { g_application.ResetSystemIdleTimer(); g_audioManager.PlayActionSound(actionID); - CApplicationMessenger::Get().SendAction(CAction(actionID), WINDOW_INVALID, waitResult); + if (waitResult) + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionID))); + else + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionID))); } return ACK; } @@ -54,14 +63,25 @@ JSONRPC_STATUS CInputOperations::SendAction(int actionID, bool wakeScreensaver / JSONRPC_STATUS CInputOperations::activateWindow(int windowID) { if(!handleScreenSaver()) - CApplicationMessenger::Get().ActivateWindow(windowID, std::vector<std::string>(), false); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTIVATE_WINDOW, windowID, 0); return ACK; } JSONRPC_STATUS CInputOperations::SendText(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { - CApplicationMessenger::Get().SendText(parameterObject["text"].asString(), parameterObject["done"].asBoolean()); + if (CGUIKeyboardFactory::SendTextToActiveKeyboard(parameterObject["text"].asString(), parameterObject["done"].asBoolean())) + return ACK; + + CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow()); + if (!window) + return ACK; + + CGUIMessage msg(GUI_MSG_SET_TEXT, 0, window->GetFocusedControlID()); + msg.SetLabel(parameterObject["text"].asString()); + msg.SetParam1(parameterObject["done"].asBoolean() ? 1 : 0); + CApplicationMessenger::Get().SendGUIMessage(msg, window->GetID()); + return ACK; } diff --git a/xbmc/interfaces/json-rpc/PVROperations.cpp b/xbmc/interfaces/json-rpc/PVROperations.cpp index 36b5a1e8fc..b794c6d240 100644 --- a/xbmc/interfaces/json-rpc/PVROperations.cpp +++ b/xbmc/interfaces/json-rpc/PVROperations.cpp @@ -19,6 +19,7 @@ */ #include "PVROperations.h" +#include "messaging/ApplicationMessenger.h" #include "pvr/PVRManager.h" #include "pvr/channels/PVRChannelGroupsContainer.h" @@ -33,6 +34,7 @@ using namespace std; using namespace JSONRPC; using namespace PVR; using namespace EPG; +using namespace KODI::MESSAGING; JSONRPC_STATUS CPVROperations::GetProperties(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.cpp b/xbmc/interfaces/json-rpc/PlayerOperations.cpp index 38882f25b2..6b9a40b70e 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlayerOperations.cpp @@ -27,7 +27,7 @@ #include "pictures/GUIWindowSlideShow.h" #include "interfaces/Builtins.h" #include "PartyModeManager.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "FileItem.h" #include "VideoLibrary.h" #include "video/VideoDatabase.h" @@ -48,6 +48,7 @@ using namespace JSONRPC; using namespace PLAYLIST; using namespace PVR; +using namespace KODI::MESSAGING; JSONRPC_STATUS CPlayerOperations::GetActivePlayers(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -295,12 +296,12 @@ JSONRPC_STATUS CPlayerOperations::PlayPause(const std::string &method, ITranspor if (parameterObject["play"].asBoolean()) { if (g_application.m_pPlayer->IsPausedPlayback()) - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); else if (g_application.m_pPlayer->GetPlaySpeed() != 1) g_application.m_pPlayer->SetPlaySpeed(1, g_application.IsMutedInternal()); } else if (!g_application.m_pPlayer->IsPausedPlayback()) - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); } result["speed"] = g_application.m_pPlayer->IsPausedPlayback() ? 0 : g_application.m_pPlayer->GetPlaySpeed(); return OK; @@ -330,7 +331,7 @@ JSONRPC_STATUS CPlayerOperations::Stop(const std::string &method, ITransportLaye { case Video: case Audio: - CApplicationMessenger::Get().MediaStop(true, (int)parameterObject["playerid"].asInteger()); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP, static_cast<int>(parameterObject["playerid"].asInteger())); return ACK; case Picture: @@ -454,9 +455,9 @@ JSONRPC_STATUS CPlayerOperations::Move(const std::string &method, ITransportLaye case Video: case Audio: if (direction == "left" || direction == "up") - CApplicationMessenger::Get().SendAction(CAction(ACTION_PREV_ITEM)); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_PREV_ITEM))); else if (direction == "right" || direction == "down") - CApplicationMessenger::Get().SendAction(CAction(ACTION_NEXT_ITEM)); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_NEXT_ITEM))); else return InvalidParams; @@ -546,7 +547,7 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye { case PLAYLIST_MUSIC: case PLAYLIST_VIDEO: - CApplicationMessenger::Get().MediaPlay(playlistid, playlistStartPosition); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PLAY, playlistid, playlistStartPosition); OnPlaylistChanged(); break; @@ -582,7 +583,7 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye { if (g_partyModeManager.IsEnabled()) g_partyModeManager.Disable(); - CApplicationMessenger::Get().ExecBuiltIn("playercontrol(partymode(" + parameterObject["item"]["partymode"].asString() + "))"); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "playercontrol(partymode(" + parameterObject["item"]["partymode"].asString() + "))"); return ACK; } else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("channelid")) @@ -602,7 +603,11 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye (g_PVRManager.IsPlayingTV() && !channel->IsRadio())) g_application.m_pPlayer->SwitchChannel(channel); else - CApplicationMessenger::Get().MediaPlay(CFileItem(channel)); + { + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(channel)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); + } return ACK; } @@ -619,7 +624,10 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye if (fileItem == NULL) return InvalidParams; - CApplicationMessenger::Get().MediaPlay(*fileItem); + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(*fileItem)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); + return ACK; } else @@ -694,7 +702,9 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye list[0]->m_lStartOffset = (int)(ParseTimeInSeconds(optionResume) * 75.0); } - CApplicationMessenger::Get().MediaPlay(list); + auto l = new CFileItemList(); //don't delete + l->Copy(list); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); } return ACK; @@ -724,14 +734,15 @@ JSONRPC_STATUS CPlayerOperations::GoTo(const std::string &method, ITransportLaye else return InvalidParams; - CApplicationMessenger::Get().SendAction(CAction(actionID)); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionID))); } else if (to.isInteger()) { if (IsPVRChannel()) - CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float)to.asInteger())); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>( + new CAction(ACTION_CHANNEL_SWITCH, static_cast<float>(to.asInteger())))); else - CApplicationMessenger::Get().PlayListPlayerPlay((int)to.asInteger()); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, static_cast<int>(to.asInteger())); } else return InvalidParams; @@ -782,7 +793,7 @@ JSONRPC_STATUS CPlayerOperations::SetShuffle(const std::string &method, ITranspo if ((shuffle.isBoolean() && !shuffle.asBoolean()) || (shuffle.isString() && shuffle.asString() == "toggle")) { - CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, false); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 0); OnPlaylistChanged(); } } @@ -791,7 +802,7 @@ JSONRPC_STATUS CPlayerOperations::SetShuffle(const std::string &method, ITranspo if ((shuffle.isBoolean() && shuffle.asBoolean()) || (shuffle.isString() && shuffle.asString() == "toggle")) { - CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, true); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 1); OnPlaylistChanged(); } } @@ -847,7 +858,7 @@ JSONRPC_STATUS CPlayerOperations::SetRepeat(const std::string &method, ITranspor else repeat = (REPEAT_STATE)ParseRepeatState(parameterObject["repeat"]); - CApplicationMessenger::Get().PlayListPlayerRepeat(playlistid, repeat); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_REPEAT, playlistid, repeat); OnPlaylistChanged(); break; } @@ -901,7 +912,7 @@ JSONRPC_STATUS CPlayerOperations::SetPartymode(const std::string &method, ITrans } if (change) - CApplicationMessenger::Get().ExecBuiltIn("playercontrol(partymode(" + strContext + "))"); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "playercontrol(partymode(" + strContext + "))"); break; } @@ -1111,7 +1122,7 @@ JSONRPC_STATUS CPlayerOperations::StartSlideshow(const std::string& path, bool r void CPlayerOperations::SendSlideshowAction(int actionID) { - CApplicationMessenger::Get().SendAction(CAction(actionID), WINDOW_SLIDESHOW); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(actionID))); } void CPlayerOperations::OnPlaylistChanged() diff --git a/xbmc/interfaces/json-rpc/PlaylistOperations.cpp b/xbmc/interfaces/json-rpc/PlaylistOperations.cpp index 4e2607ef0a..e23d2973c2 100644 --- a/xbmc/interfaces/json-rpc/PlaylistOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlaylistOperations.cpp @@ -23,7 +23,7 @@ #include "guilib/GUIWindowManager.h" #include "input/Key.h" #include "GUIUserMessages.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "pictures/GUIWindowSlideShow.h" #include "pictures/PictureInfoTag.h" #include "utils/Variant.h" @@ -31,6 +31,7 @@ using namespace JSONRPC; using namespace PLAYLIST; using namespace std; +using namespace KODI::MESSAGING; JSONRPC_STATUS CPlaylistOperations::GetPlaylists(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -79,7 +80,7 @@ JSONRPC_STATUS CPlaylistOperations::GetItems(const std::string &method, ITranspo { case PLAYLIST_VIDEO: case PLAYLIST_MUSIC: - CApplicationMessenger::Get().PlayListPlayerGetItems(playlist, list); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_GET_ITEMS, playlist, -1, static_cast<void*>(&list)); break; case PLAYLIST_PICTURE: @@ -128,9 +129,12 @@ JSONRPC_STATUS CPlaylistOperations::Add(const std::string &method, ITransportLay { case PLAYLIST_VIDEO: case PLAYLIST_MUSIC: - CApplicationMessenger::Get().PlayListPlayerAdd(playlist, list); + { + auto tmpList = new CFileItemList(); + tmpList->Copy(list); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_ADD, playlist, -1, static_cast<void*>(tmpList)); break; - + } case PLAYLIST_PICTURE: for (int index = 0; index < list.Size(); index++) { @@ -161,7 +165,10 @@ JSONRPC_STATUS CPlaylistOperations::Insert(const std::string &method, ITransport if (!HandleItemsParameter(playlist, parameterObject["item"], list)) return InvalidParams; - CApplicationMessenger::Get().PlayListPlayerInsert(GetPlaylist(parameterObject["playlistid"]), list, (int)parameterObject["position"].asInteger()); + auto tmpList = new CFileItemList(); + tmpList->Copy(list); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_INSERT, GetPlaylist(parameterObject["playlistid"]), + static_cast<int>(parameterObject["position"].asInteger()), static_cast<void*>(tmpList)); NotifyAll(); return ACK; @@ -177,7 +184,7 @@ JSONRPC_STATUS CPlaylistOperations::Remove(const std::string &method, ITransport if (g_playlistPlayer.GetCurrentPlaylist() == playlist && g_playlistPlayer.GetCurrentSong() == position) return InvalidParams; - CApplicationMessenger::Get().PlayListPlayerRemove(playlist, position); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_REMOVE, playlist, position); NotifyAll(); return ACK; @@ -191,16 +198,16 @@ JSONRPC_STATUS CPlaylistOperations::Clear(const std::string &method, ITransportL { case PLAYLIST_MUSIC: case PLAYLIST_VIDEO: - CApplicationMessenger::Get().PlayListPlayerClear(playlist); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_CLEAR, playlist); break; case PLAYLIST_PICTURE: - slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW); - if (!slideshow) - return FailedToExecute; - CApplicationMessenger::Get().SendAction(CAction(ACTION_STOP), WINDOW_SLIDESHOW); - slideshow->Reset(); - break; + slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW); + if (!slideshow) + return FailedToExecute; + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_STOP))); + slideshow->Reset(); + break; } NotifyAll(); @@ -213,7 +220,10 @@ JSONRPC_STATUS CPlaylistOperations::Swap(const std::string &method, ITransportLa if (playlist == PLAYLIST_PICTURE) return FailedToExecute; - CApplicationMessenger::Get().PlayListPlayerSwap(playlist, (int)parameterObject["position1"].asInteger(), (int)parameterObject["position2"].asInteger()); + auto tmpVec = new std::vector<int>(); + tmpVec->push_back(static_cast<int>(parameterObject["position1"].asInteger())); + tmpVec->push_back(static_cast<int>(parameterObject["position2"].asInteger())); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_SWAP, playlist, -1, static_cast<void*>(tmpVec)); NotifyAll(); return ACK; @@ -265,7 +275,7 @@ JSONRPC_STATUS CPlaylistOperations::GetPropertyValue(int playlist, const std::st { case PLAYLIST_MUSIC: case PLAYLIST_VIDEO: - CApplicationMessenger::Get().PlayListPlayerGetItems(playlist, list); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_GET_ITEMS, playlist, -1, static_cast<void*>(&list)); result = list.Size(); break; diff --git a/xbmc/interfaces/json-rpc/ProfilesOperations.cpp b/xbmc/interfaces/json-rpc/ProfilesOperations.cpp index c514ac665b..39cec62d05 100644 --- a/xbmc/interfaces/json-rpc/ProfilesOperations.cpp +++ b/xbmc/interfaces/json-rpc/ProfilesOperations.cpp @@ -19,12 +19,14 @@ */ #include "ProfilesOperations.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" +#include "guilib/LocalizeStrings.h" #include "profiles/ProfilesManager.h" #include "utils/md5.h" #include "utils/Variant.h" using namespace JSONRPC; +using namespace KODI::MESSAGING; JSONRPC_STATUS CProfilesOperations::GetProfiles(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -128,7 +130,7 @@ JSONRPC_STATUS CProfilesOperations::LoadProfile(const std::string &method, ITran if (bLoadProfile) { - CApplicationMessenger::Get().LoadProfile(index); + CApplicationMessenger::Get().PostMsg(TMSG_LOADPROFILE, index); return ACK; } return InvalidParams; diff --git a/xbmc/interfaces/json-rpc/SystemOperations.cpp b/xbmc/interfaces/json-rpc/SystemOperations.cpp index d6016d1405..acf9448913 100644 --- a/xbmc/interfaces/json-rpc/SystemOperations.cpp +++ b/xbmc/interfaces/json-rpc/SystemOperations.cpp @@ -19,12 +19,13 @@ */ #include "SystemOperations.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "interfaces/Builtins.h" #include "utils/Variant.h" #include "powermanagement/PowerManager.h" using namespace JSONRPC; +using namespace KODI::MESSAGING; JSONRPC_STATUS CSystemOperations::GetProperties(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -54,7 +55,7 @@ JSONRPC_STATUS CSystemOperations::Shutdown(const std::string &method, ITransport { if (g_powerManager.CanPowerdown()) { - CApplicationMessenger::Get().Powerdown(); + CApplicationMessenger::Get().PostMsg(TMSG_POWERDOWN); return ACK; } else @@ -65,7 +66,7 @@ JSONRPC_STATUS CSystemOperations::Suspend(const std::string &method, ITransportL { if (g_powerManager.CanSuspend()) { - CApplicationMessenger::Get().Suspend(); + CApplicationMessenger::Get().PostMsg(TMSG_SUSPEND); return ACK; } else @@ -76,7 +77,7 @@ JSONRPC_STATUS CSystemOperations::Hibernate(const std::string &method, ITranspor { if (g_powerManager.CanHibernate()) { - CApplicationMessenger::Get().Hibernate(); + CApplicationMessenger::Get().PostMsg(TMSG_HIBERNATE); return ACK; } else @@ -87,7 +88,7 @@ JSONRPC_STATUS CSystemOperations::Reboot(const std::string &method, ITransportLa { if (g_powerManager.CanReboot()) { - CApplicationMessenger::Get().Restart(); + CApplicationMessenger::Get().PostMsg(TMSG_RESTART); return ACK; } else diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.cpp b/xbmc/interfaces/json-rpc/VideoLibrary.cpp index 0dd3127e6d..c5386bb83f 100644 --- a/xbmc/interfaces/json-rpc/VideoLibrary.cpp +++ b/xbmc/interfaces/json-rpc/VideoLibrary.cpp @@ -19,7 +19,7 @@ */ #include "VideoLibrary.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "TextureDatabase.h" #include "Util.h" #include "utils/SortUtils.h" @@ -29,6 +29,7 @@ #include "video/VideoDatabase.h" using namespace JSONRPC; +using namespace KODI::MESSAGING; JSONRPC_STATUS CVideoLibrary::GetMovies(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -752,7 +753,7 @@ JSONRPC_STATUS CVideoLibrary::Scan(const std::string &method, ITransportLayer *t std::string directory = parameterObject["directory"].asString(); std::string cmd = StringUtils::Format("updatelibrary(video, %s, %s)", StringUtils::Paramify(directory).c_str(), parameterObject["showdialogs"].asBoolean() ? "true" : "false"); - CApplicationMessenger::Get().ExecBuiltIn(cmd); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } @@ -767,14 +768,14 @@ JSONRPC_STATUS CVideoLibrary::Export(const std::string &method, ITransportLayer parameterObject["options"]["overwrite"].asBoolean() ? "true" : "false", parameterObject["options"]["actorthumbs"].asBoolean() ? "true" : "false"); - CApplicationMessenger::Get().ExecBuiltIn(cmd); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } JSONRPC_STATUS CVideoLibrary::Clean(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { std::string cmd = StringUtils::Format("cleanlibrary(video, %s)", parameterObject["showdialogs"].asBoolean() ? "true" : "false"); - CApplicationMessenger::Get().ExecBuiltIn(cmd); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd); return ACK; } diff --git a/xbmc/interfaces/json-rpc/XBMCOperations.cpp b/xbmc/interfaces/json-rpc/XBMCOperations.cpp index 55261967fb..97bae3e238 100644 --- a/xbmc/interfaces/json-rpc/XBMCOperations.cpp +++ b/xbmc/interfaces/json-rpc/XBMCOperations.cpp @@ -19,11 +19,12 @@ */ #include "XBMCOperations.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "utils/Variant.h" #include "powermanagement/PowerManager.h" using namespace JSONRPC; +using namespace KODI::MESSAGING; JSONRPC_STATUS CXBMCOperations::GetInfoLabels(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { @@ -39,7 +40,9 @@ JSONRPC_STATUS CXBMCOperations::GetInfoLabels(const std::string &method, ITransp if (info.size() > 0) { - std::vector<std::string> infoLabels = CApplicationMessenger::Get().GetInfoLabels(info); + std::vector<std::string> infoLabels; + CApplicationMessenger::Get().SendMsg(TMSG_GUI_INFOLABEL, -1, -1, static_cast<void*>(&infoLabels), "", info); + for (unsigned int i = 0; i < info.size(); i++) { if (i >= infoLabels.size()) @@ -80,7 +83,8 @@ JSONRPC_STATUS CXBMCOperations::GetInfoBooleans(const std::string &method, ITran if (info.size() > 0) { - std::vector<bool> infoLabels = CApplicationMessenger::Get().GetInfoBooleans(info); + std::vector<bool> infoLabels; + CApplicationMessenger::Get().SendMsg(TMSG_GUI_INFOBOOL, -1, -1, static_cast<void*>(&infoLabels), "", info); for (unsigned int i = 0; i < info.size(); i++) { if (i >= infoLabels.size()) diff --git a/xbmc/interfaces/legacy/Dialog.cpp b/xbmc/interfaces/legacy/Dialog.cpp index ca53e34767..275239bc9e 100644 --- a/xbmc/interfaces/legacy/Dialog.cpp +++ b/xbmc/interfaces/legacy/Dialog.cpp @@ -33,9 +33,11 @@ #include "utils/StringUtils.h" #include "utils/Variant.h" #include "WindowException.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Dialog.h" +using namespace KODI::MESSAGING; + #define ACTIVE_WINDOW g_windowManager.GetActiveWindow() namespace XBMCAddon diff --git a/xbmc/interfaces/legacy/Keyboard.cpp b/xbmc/interfaces/legacy/Keyboard.cpp index a197171ac0..0bde8ee66f 100644 --- a/xbmc/interfaces/legacy/Keyboard.cpp +++ b/xbmc/interfaces/legacy/Keyboard.cpp @@ -23,6 +23,9 @@ #include "guilib/GUIKeyboardFactory.h" #include "utils/Variant.h" +#include "messaging/ApplicationMessenger.h" + +using namespace KODI::MESSAGING; namespace XBMCAddon { diff --git a/xbmc/interfaces/legacy/ModuleXbmc.cpp b/xbmc/interfaces/legacy/ModuleXbmc.cpp index 1ddfd64d94..03a5b14acf 100644 --- a/xbmc/interfaces/legacy/ModuleXbmc.cpp +++ b/xbmc/interfaces/legacy/ModuleXbmc.cpp @@ -28,7 +28,8 @@ #include "ModuleXbmc.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" +#include "utils/URIUtils.h" #include "aojsonrpc.h" #ifndef TARGET_WINDOWS #include "XTimeUtils.h" @@ -60,6 +61,8 @@ #include <vector> #include "utils/log.h" +using namespace KODI::MESSAGING; + namespace XBMCAddon { @@ -79,15 +82,13 @@ namespace XBMCAddon void shutdown() { XBMC_TRACE; - ThreadMessage tMsg = {TMSG_SHUTDOWN}; - CApplicationMessenger::Get().SendMessage(tMsg); + CApplicationMessenger::Get().PostMsg(TMSG_SHUTDOWN); } void restart() { XBMC_TRACE; - ThreadMessage tMsg = {TMSG_RESTART}; - CApplicationMessenger::Get().SendMessage(tMsg); + CApplicationMessenger::Get().PostMsg(TMSG_RESTART); } void executescript(const char* script) @@ -96,9 +97,7 @@ namespace XBMCAddon if (! script) return; - ThreadMessage tMsg = {TMSG_EXECUTE_SCRIPT}; - tMsg.strParam = script; - CApplicationMessenger::Get().SendMessage(tMsg); + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_SCRIPT, -1, -1, nullptr, script); } void executebuiltin(const char* function, bool wait /* = false*/) @@ -106,7 +105,10 @@ namespace XBMCAddon XBMC_TRACE; if (! function) return; - CApplicationMessenger::Get().ExecBuiltIn(function,wait); + if (wait) + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, function); + else + CApplicationMessenger::Get().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, function); } String executeJSONRPC(const char* jsonrpccommand) diff --git a/xbmc/interfaces/legacy/Player.cpp b/xbmc/interfaces/legacy/Player.cpp index 0385ba1097..b53b7d829b 100644 --- a/xbmc/interfaces/legacy/Player.cpp +++ b/xbmc/interfaces/legacy/Player.cpp @@ -24,12 +24,14 @@ #include "PlayListPlayer.h" #include "settings/MediaSettings.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIInfoManager.h" #include "AddonUtils.h" #include "utils/log.h" #include "cores/IPlayer.h" +using namespace KODI::MESSAGING; + namespace XBMCAddon { namespace xbmc @@ -98,12 +100,13 @@ namespace XBMCAddon { // set m_strPath to the passed url listitem->item->SetPath(item.c_str()); - CApplicationMessenger::Get().PlayFile((const CFileItem)(*(listitem->item)), false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(*listitem->item))); } else { - CFileItem nextitem(item, false); - CApplicationMessenger::Get().MediaPlay(nextitem.GetPath()); + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(item, false)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); } } else @@ -123,7 +126,7 @@ namespace XBMCAddon // play current file in playlist if (g_playlistPlayer.GetCurrentPlaylist() != iPlayList) g_playlistPlayer.SetCurrentPlaylist(iPlayList); - CApplicationMessenger::Get().PlayListPlayerPlay(g_playlistPlayer.GetCurrentSong()); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, g_playlistPlayer.GetCurrentSong()); } void Player::playPlaylist(const PlayList* playlist, bool windowed, int startpos) @@ -143,7 +146,7 @@ namespace XBMCAddon g_playlistPlayer.SetCurrentPlaylist(iPlayList); if (startpos > -1) g_playlistPlayer.SetCurrentSong(startpos); - CApplicationMessenger::Get().PlayListPlayerPlay(startpos); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, startpos); } else playCurrent(windowed); @@ -152,13 +155,13 @@ namespace XBMCAddon void Player::stop() { XBMC_TRACE; - CApplicationMessenger::Get().MediaStop(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); } void Player::pause() { XBMC_TRACE; - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); } void Player::playnext() @@ -168,7 +171,7 @@ namespace XBMCAddon // force a playercore before playing g_application.m_eForcedNextPlayer = playerCore; - CApplicationMessenger::Get().PlayListPlayerNext(); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_NEXT); } void Player::playprevious() @@ -178,7 +181,7 @@ namespace XBMCAddon // force a playercore before playing g_application.m_eForcedNextPlayer = playerCore; - CApplicationMessenger::Get().PlayListPlayerPrevious(); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_PREV); } void Player::playselected(int selected) @@ -194,7 +197,7 @@ namespace XBMCAddon } g_playlistPlayer.SetCurrentSong(selected); - CApplicationMessenger::Get().PlayListPlayerPlay(selected); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, selected); //g_playlistPlayer.Play(selected); //CLog::Log(LOGNOTICE, "Current Song After Play: %i", g_playlistPlayer.GetCurrentSong()); } diff --git a/xbmc/interfaces/legacy/Window.cpp b/xbmc/interfaces/legacy/Window.cpp index f2d89da575..796463c48c 100644 --- a/xbmc/interfaces/legacy/Window.cpp +++ b/xbmc/interfaces/legacy/Window.cpp @@ -26,10 +26,12 @@ #include "guilib/GUIRadioButtonControl.h" #include "guilib/GUIWindowManager.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "utils/Variant.h" #include "WindowException.h" +using namespace KODI::MESSAGING; + #define ACTIVE_WINDOW g_windowManager.GetActiveWindow() @@ -517,8 +519,7 @@ namespace XBMCAddon DelayedCallGuard dcguard(languageHook); popActiveWindowId(); - std::vector<std::string> params; - CApplicationMessenger::Get().ActivateWindow(iWindowId, params, false); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTIVATE_WINDOW, iWindowId, 0); } void Window::setFocus(Control* pControl) @@ -684,10 +685,9 @@ namespace XBMCAddon if (!existingWindow) PulseActionEvent(); - std::vector<std::string> params; { DelayedCallGuard dcguard(languageHook); - CApplicationMessenger::Get().ActivateWindow(iOldWindowId, params, false); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTIVATE_WINDOW, iOldWindowId, 0); } iOldWindowId = 0; diff --git a/xbmc/interfaces/legacy/WindowDialogMixin.cpp b/xbmc/interfaces/legacy/WindowDialogMixin.cpp index 5b7d7c98b7..42c71000de 100644 --- a/xbmc/interfaces/legacy/WindowDialogMixin.cpp +++ b/xbmc/interfaces/legacy/WindowDialogMixin.cpp @@ -21,9 +21,11 @@ #include "WindowDialogMixin.h" #include "WindowInterceptor.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIWindowManager.h" +using namespace KODI::MESSAGING; + namespace XBMCAddon { namespace xbmcgui @@ -31,9 +33,7 @@ namespace XBMCAddon void WindowDialogMixin::show() { XBMC_TRACE; - ThreadMessage tMsg = {TMSG_GUI_PYTHON_DIALOG, HACK_CUSTOM_ACTION_OPENING, 0}; - tMsg.lpVoid = w->window->get(); - CApplicationMessenger::Get().SendMessage(tMsg, true); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_PYTHON_DIALOG, HACK_CUSTOM_ACTION_OPENING, 0, static_cast<void*>(w->window->get())); } void WindowDialogMixin::close() @@ -42,9 +42,7 @@ namespace XBMCAddon w->bModal = false; w->PulseActionEvent(); - ThreadMessage tMsg = {TMSG_GUI_PYTHON_DIALOG, HACK_CUSTOM_ACTION_CLOSING, 0}; - tMsg.lpVoid = w->window->get(); - CApplicationMessenger::Get().SendMessage(tMsg, true); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_PYTHON_DIALOG, HACK_CUSTOM_ACTION_CLOSING, 0, static_cast<void*>(w->window->get())); w->iOldWindowId = 0; } diff --git a/xbmc/interfaces/python/PythonInvoker.cpp b/xbmc/interfaces/python/PythonInvoker.cpp index a2dcf8313c..296661f76e 100644 --- a/xbmc/interfaces/python/PythonInvoker.cpp +++ b/xbmc/interfaces/python/PythonInvoker.cpp @@ -29,7 +29,7 @@ #include "system.h" #include "PythonInvoker.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "addons/AddonManager.h" #include "dialogs/GUIDialogKaiToast.h" #include "filesystem/File.h" @@ -67,6 +67,7 @@ extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode); using namespace std; using namespace XFILE; +using namespace KODI::MESSAGING; extern "C" { diff --git a/xbmc/listproviders/DirectoryProvider.cpp b/xbmc/listproviders/DirectoryProvider.cpp index 5adeebb2af..f4c0967309 100644 --- a/xbmc/listproviders/DirectoryProvider.cpp +++ b/xbmc/listproviders/DirectoryProvider.cpp @@ -27,6 +27,7 @@ #include "utils/URIUtils.h" #include "utils/Variant.h" #include "threads/SingleLock.h" +#include "messaging/ApplicationMessenger.h" #include "FileItem.h" #include "video/VideoThumbLoader.h" #include "music/MusicThumbLoader.h" @@ -38,6 +39,7 @@ using namespace std; using namespace XFILE; using namespace ANNOUNCEMENT; +using namespace KODI::MESSAGING; class CDirectoryJob : public CJob { diff --git a/xbmc/main/osx/SDLMain.mm b/xbmc/main/osx/SDLMain.mm index 8f47794eac..07ca86af28 100644 --- a/xbmc/main/osx/SDLMain.mm +++ b/xbmc/main/osx/SDLMain.mm @@ -20,7 +20,7 @@ // and obj-c's typedef unsigned char BOOL #define BOOL XBMC_BOOL #import "PlatformDefs.h" -#import "ApplicationMessenger.h" +#import "messaging/ApplicationMessenger.h" #import "storage/osx/DarwinStorageProvider.h" #undef BOOL diff --git a/xbmc/messaging/ApplicationMessenger.cpp b/xbmc/messaging/ApplicationMessenger.cpp new file mode 100644 index 0000000000..f095c88da3 --- /dev/null +++ b/xbmc/messaging/ApplicationMessenger.cpp @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "ApplicationMessenger.h" +#include "Application.h" + +#include "threads/SingleLock.h" +#include "guilib/GraphicContext.h" + + +namespace KODI +{ +namespace MESSAGING +{ + +CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay) : CThread("DelayedMessage") +{ + m_msg = msg; + + m_delay = delay; +} + +void CDelayedMessage::Process() +{ + Sleep(m_delay); + + if (!m_bStop) + CApplicationMessenger::Get().PostMsg(m_msg.dwMessage, m_msg.param1, m_msg.param1, m_msg.lpVoid, m_msg.strParam, m_msg.params); +} + + +CApplicationMessenger& CApplicationMessenger::Get() +{ + static CApplicationMessenger appMessenger; + return appMessenger; +} + +CApplicationMessenger::CApplicationMessenger() +{ +} + +CApplicationMessenger::~CApplicationMessenger() +{ + Cleanup(); +} + +void CApplicationMessenger::Cleanup() +{ + CSingleLock lock (m_critSection); + + while (!m_vecMessages.empty()) + { + ThreadMessage* pMsg = m_vecMessages.front(); + + if (pMsg->waitEvent) + pMsg->waitEvent->Set(); + + delete pMsg; + m_vecMessages.pop(); + } + + while (!m_vecWindowMessages.empty()) + { + ThreadMessage* pMsg = m_vecWindowMessages.front(); + + if (pMsg->waitEvent) + pMsg->waitEvent->Set(); + + delete pMsg; + m_vecWindowMessages.pop(); + } +} + +void CApplicationMessenger::SendMsg(ThreadMessage&& message, bool wait) +{ + std::shared_ptr<CEvent> waitEvent; + if (wait) + { // check that we're not being called from our application thread, else we'll be waiting + // forever! + if (!g_application.IsCurrentThread()) + { + message.waitEvent.reset(new CEvent(true)); + waitEvent = message.waitEvent; + } + else + { + //OutputDebugString("Attempting to wait on a SendMessage() from our application thread will cause lockup!\n"); + //OutputDebugString("Sending immediately\n"); + ProcessMessage(&message); + return; + } + } + + + if (g_application.m_bStop) + return; + + ThreadMessage* msg = new ThreadMessage(std::move(message)); + + CSingleLock lock (m_critSection); + + if (msg->dwMessage == TMSG_GUI_DIALOG_OPEN) + m_vecWindowMessages.push(msg); + else + m_vecMessages.push(msg); + lock.Leave(); // this releases the lock on the vec of messages and + // allows the ProcessMessage to execute and therefore + // delete the message itself. Therefore any accesss + // of the message itself after this point consittutes + // a race condition (yarc - "yet another race condition") + // + if (waitEvent) // ... it just so happens we have a spare reference to the + // waitEvent ... just for such contingencies :) + { + // ensure the thread doesn't hold the graphics lock + CSingleExit exit(g_graphicsContext); + waitEvent->Wait(); + } +} + +void CApplicationMessenger::SendMsg(uint32_t messageId) +{ + SendMsg(ThreadMessage{ messageId }, true); +} + +void CApplicationMessenger::SendMsg(uint32_t messageId, int param1, int param2, void* payload) +{ + SendMsg(ThreadMessage{ messageId, param1, param2, payload }, true); +} + +void CApplicationMessenger::SendMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam) +{ + SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, std::vector<std::string>{} }, true); +} + +void CApplicationMessenger::SendMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam, std::vector<std::string> params) +{ + SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, params }, true); +} + +void CApplicationMessenger::PostMsg(uint32_t messageId) +{ + SendMsg(ThreadMessage{ messageId }, false); +} + +void CApplicationMessenger::PostMsg(uint32_t messageId, int param1, int param2, void* payload) +{ + SendMsg(ThreadMessage{ messageId, param1, param2, payload }, false); +} + +void CApplicationMessenger::PostMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam) +{ + SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, std::vector<std::string>{} }, false); +} + +void CApplicationMessenger::PostMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam, std::vector<std::string> params) +{ + SendMsg(ThreadMessage{ messageId, param1, param2, payload, strParam, params }, false); +} + +void CApplicationMessenger::ProcessMessages() +{ + // process threadmessages + CSingleLock lock (m_critSection); + while (!m_vecMessages.empty()) + { + ThreadMessage* pMsg = m_vecMessages.front(); + //first remove the message from the queue, else the message could be processed more then once + m_vecMessages.pop(); + + //Leave here as the message might make another + //thread call processmessages or sendmessage + + std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent; + lock.Leave(); // <- see the large comment in SendMessage ^ + + ProcessMessage(pMsg); + if (waitEvent) + waitEvent->Set(); + delete pMsg; + + lock.Enter(); + } +} + +void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) +{ + //special case for this that we handle ourselves + if (pMsg->dwMessage == TMSG_CALLBACK) + { + ThreadMessageCallback *callback = static_cast<ThreadMessageCallback*>(pMsg->lpVoid); + callback->callback(callback->userptr); + return; + } + + CSingleLock lock(m_critSection); + int mask = pMsg->dwMessage & TMSG_MASK_MESSAGE; + + auto target = m_mapTargets.at(mask); + if (target != nullptr) + { + CSingleExit exit(m_critSection); + target->OnApplicationMessage(pMsg); + } +} + +void CApplicationMessenger::ProcessWindowMessages() +{ + CSingleLock lock (m_critSection); + //message type is window, process window messages + while (!m_vecWindowMessages.empty()) + { + ThreadMessage* pMsg = m_vecWindowMessages.front(); + //first remove the message from the queue, else the message could be processed more then once + m_vecWindowMessages.pop(); + + // leave here in case we make more thread messages from this one + + std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent; + lock.Leave(); // <- see the large comment in SendMessage ^ + + ProcessMessage(pMsg); + if (waitEvent) + waitEvent->Set(); + delete pMsg; + + lock.Enter(); + } +} + +void CApplicationMessenger::SendGUIMessage(const CGUIMessage &message, int windowID, bool waitResult) +{ + ThreadMessage tMsg(TMSG_GUI_MESSAGE); + tMsg.param1 = windowID == WINDOW_INVALID ? 0 : windowID; + tMsg.lpVoid = new CGUIMessage(message); + SendMsg(std::move(tMsg), waitResult); +} + +void CApplicationMessenger::RegisterReceveiver(IMessageTarget* target) +{ + CSingleLock lock(m_critSection); + m_mapTargets.insert(std::make_pair(target->GetMessageMask(), target)); +} + +} +} diff --git a/xbmc/messaging/ApplicationMessenger.h b/xbmc/messaging/ApplicationMessenger.h new file mode 100644 index 0000000000..00bde9872e --- /dev/null +++ b/xbmc/messaging/ApplicationMessenger.h @@ -0,0 +1,197 @@ +#pragma once + +/* + * Copyright (C) 2005-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "guilib/WindowIDs.h" +#include "threads/Thread.h" +#include "messaging/ThreadMessage.h" + +#include <map> +#include <memory> +#include <queue> +#include <string> +#include <vector> + +#define TMSG_MASK_MESSAGE 0xFFFF0000 // only keep the high bits to route messages +#define TMSG_MASK_APPLICATION (1<<30) //Don't use bit 31 as it'll fail to build, using unsigned variable to hold the message. +#define TMSG_MASK_PLAYLISTPLAYER (1<<29) +#define TMSG_MASK_GUIINFOMANAGER (1<<28) +#define TMSG_MASK_WINDOWMANAGER (1<<27) +#define TMSG_MASK_PERIPHERALS (1<<26) + +// defines here +#define TMSG_PLAYLISTPLAYER_PLAY TMSG_MASK_PLAYLISTPLAYER + 0 +#define TMSG_PLAYLISTPLAYER_NEXT TMSG_MASK_PLAYLISTPLAYER + 1 +#define TMSG_PLAYLISTPLAYER_PREV TMSG_MASK_PLAYLISTPLAYER + 2 +#define TMSG_PLAYLISTPLAYER_ADD TMSG_MASK_PLAYLISTPLAYER + 3 +#define TMSG_PLAYLISTPLAYER_CLEAR TMSG_MASK_PLAYLISTPLAYER + 4 +#define TMSG_PLAYLISTPLAYER_SHUFFLE TMSG_MASK_PLAYLISTPLAYER + 5 +#define TMSG_PLAYLISTPLAYER_GET_ITEMS TMSG_MASK_PLAYLISTPLAYER + 6 +#define TMSG_PLAYLISTPLAYER_PLAY_SONG_ID TMSG_MASK_PLAYLISTPLAYER + 7 +#define TMSG_PLAYLISTPLAYER_INSERT TMSG_MASK_PLAYLISTPLAYER + 8 +#define TMSG_PLAYLISTPLAYER_REMOVE TMSG_MASK_PLAYLISTPLAYER + 9 +#define TMSG_PLAYLISTPLAYER_SWAP TMSG_MASK_PLAYLISTPLAYER + 10 +#define TMSG_PLAYLISTPLAYER_REPEAT TMSG_MASK_PLAYLISTPLAYER + 11 +#define TMSG_MEDIA_PLAY TMSG_MASK_PLAYLISTPLAYER + 12 +#define TMSG_MEDIA_STOP TMSG_MASK_PLAYLISTPLAYER + 13 +// the PAUSE is indeed a PLAYPAUSE +#define TMSG_MEDIA_PAUSE TMSG_MASK_PLAYLISTPLAYER + 14 +#define TMSG_MEDIA_RESTART TMSG_MASK_PLAYLISTPLAYER + 15 +#define TMSG_MEDIA_UNPAUSE TMSG_MASK_PLAYLISTPLAYER + 16 +#define TMSG_MEDIA_PAUSE_IF_PLAYING TMSG_MASK_PLAYLISTPLAYER + 17 + + + +#define TMSG_SHUTDOWN TMSG_MASK_APPLICATION + 0 +#define TMSG_POWERDOWN TMSG_MASK_APPLICATION + 1 +#define TMSG_QUIT TMSG_MASK_APPLICATION + 2 +#define TMSG_HIBERNATE TMSG_MASK_APPLICATION + 3 +#define TMSG_SUSPEND TMSG_MASK_APPLICATION + 4 +#define TMSG_RESTART TMSG_MASK_APPLICATION + 5 +#define TMSG_RESET TMSG_MASK_APPLICATION + 6 +#define TMSG_RESTARTAPP TMSG_MASK_APPLICATION + 7 +#define TMSG_ACTIVATESCREENSAVER TMSG_MASK_APPLICATION + 8 +#define TMSG_NETWORKMESSAGE TMSG_MASK_APPLICATION + 9 +#define TMSG_SETPVRMANAGERSTATE TMSG_MASK_APPLICATION + 10 +#define TMSG_VOLUME_SHOW TMSG_MASK_APPLICATION + 11 +#define TMSG_SPLASH_MESSAGE TMSG_MASK_APPLICATION + 12 +#define TMSG_DISPLAY_SETUP TMSG_MASK_APPLICATION + 13 +#define TMSG_DISPLAY_DESTROY TMSG_MASK_APPLICATION + 14 +#define TMSG_SETVIDEORESOLUTION TMSG_MASK_APPLICATION + 15 +#define TMSG_SWITCHTOFULLSCREEN TMSG_MASK_APPLICATION + 16 +#define TMSG_MINIMIZE TMSG_MASK_APPLICATION + 17 +#define TMSG_TOGGLEFULLSCREEN TMSG_MASK_APPLICATION + 18 +#define TMSG_SETLANGUAGE TMSG_MASK_APPLICATION + 19 +#define TMSG_RENDERER_FLUSH TMSG_MASK_APPLICATION + 20 +#define TMSG_INHIBITIDLESHUTDOWN TMSG_MASK_APPLICATION + 21 +#define TMSG_START_ANDROID_ACTIVITY TMSG_MASK_APPLICATION + 22 +#define TMSG_EXECUTE_SCRIPT TMSG_MASK_APPLICATION + 23 +#define TMSG_EXECUTE_BUILT_IN TMSG_MASK_APPLICATION + 24 +#define TMSG_EXECUTE_OS TMSG_MASK_APPLICATION + 25 +#define TMSG_PICTURE_SHOW TMSG_MASK_APPLICATION + 26 +#define TMSG_PICTURE_SLIDESHOW TMSG_MASK_APPLICATION + 27 +#define TMSG_LOADPROFILE TMSG_MASK_APPLICATION + 28 +#define TMSG_VIDEORESIZE TMSG_MASK_APPLICATION + 29 + +#define TMSG_GUI_INFOLABEL TMSG_MASK_GUIINFOMANAGER + 0 +#define TMSG_GUI_INFOBOOL TMSG_MASK_GUIINFOMANAGER + 1 +#define TMSG_UPDATE_CURRENT_ITEM TMSG_MASK_GUIINFOMANAGER + 2 + + +#define TMSG_CECTOGGLESTATE TMSG_MASK_PERIPHERALS + 1 +#define TMSG_CECACTIVATESOURCE TMSG_MASK_PERIPHERALS + 2 +#define TMSG_CECSTANDBY TMSG_MASK_PERIPHERALS + 3 + + + + +#define TMSG_GUI_DIALOG_OPEN TMSG_MASK_WINDOWMANAGER + 1 +#define TMSG_GUI_ACTIVATE_WINDOW TMSG_MASK_WINDOWMANAGER + 2 +#define TMSG_GUI_PYTHON_DIALOG TMSG_MASK_WINDOWMANAGER + 3 +#define TMSG_GUI_WINDOW_CLOSE TMSG_MASK_WINDOWMANAGER + 4 +#define TMSG_GUI_ACTION TMSG_MASK_WINDOWMANAGER + 5 +#define TMSG_GUI_ADDON_DIALOG TMSG_MASK_WINDOWMANAGER + 6 +#define TMSG_GUI_MESSAGE TMSG_MASK_WINDOWMANAGER + 7 + + +#define TMSG_CALLBACK 800 + + + +class CGUIMessage; + +namespace KODI +{ +namespace MESSAGING +{ + +class CDelayedMessage : public CThread +{ + public: + CDelayedMessage(ThreadMessage& msg, unsigned int delay); + virtual void Process() override; + + private: + unsigned int m_delay; + ThreadMessage m_msg; +}; + +struct ThreadMessageCallback +{ + void (*callback)(void *userptr); + void *userptr; +}; + +class IMessageTarget; + +class CApplicationMessenger +{ +public: + /*! + \brief The only way through which the global instance of the CApplicationMessenger should be accessed. + \return the global instance. + */ + static CApplicationMessenger& Get(); + + void Cleanup(); + // if a message has to be send to the gui, use MSG_TYPE_WINDOW instead + void SendMsg(uint32_t messageId); + void SendMsg(uint32_t messageId, int param1, int param2 = -1, void* payload = nullptr); + void SendMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam); + void SendMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam, std::vector<std::string> params); + + void PostMsg(uint32_t messageId); + void PostMsg(uint32_t messageId, int param1, int param2 = -1, void* payload = nullptr); + void PostMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam); + void PostMsg(uint32_t messageId, int param1, int param2, void* payload, std::string strParam, std::vector<std::string> params); + + void ProcessMessages(); // only call from main thread. + void ProcessWindowMessages(); + + /*! \brief Send a GUIMessage, optionally waiting before it's processed to return. + Should be used to send messages to the GUI from other threads. + \param msg the GUIMessage to send. + \param windowID optional window to send the message to (defaults to no specified window). + \param waitResult whether to wait for the result (defaults to false). + */ + void SendGUIMessage(const CGUIMessage &msg, int windowID = WINDOW_INVALID, bool waitResult=false); + + void RegisterReceveiver(IMessageTarget* target); + +private: + // private construction, and no assignements; use the provided singleton methods + CApplicationMessenger(); + CApplicationMessenger(const CApplicationMessenger&) = delete; + CApplicationMessenger const& operator=(CApplicationMessenger const&) = delete; + ~CApplicationMessenger(); + + void SendMsg(ThreadMessage&& msg, bool wait); + void ProcessMessage(ThreadMessage *pMsg); + + std::queue<ThreadMessage*> m_vecMessages; + std::queue<ThreadMessage*> m_vecWindowMessages; + std::map<int, IMessageTarget*> m_mapTargets; + CCriticalSection m_critSection; +}; +} +} + + diff --git a/xbmc/messaging/IMessageTarget.h b/xbmc/messaging/IMessageTarget.h new file mode 100644 index 0000000000..b59f150b54 --- /dev/null +++ b/xbmc/messaging/IMessageTarget.h @@ -0,0 +1,36 @@ +#pragma once +/* +* Copyright (C) 2005-2015 Team XBMC +* http://xbmc.org +* +* This Program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* This Program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XBMC; see the file COPYING. If not, see +* <http://www.gnu.org/licenses/>. +* +*/ + +namespace KODI +{ +namespace MESSAGING +{ +class ThreadMessage; + +class IMessageTarget +{ +public: + virtual ~IMessageTarget() { } + virtual int GetMessageMask() = 0; + virtual void OnApplicationMessage(ThreadMessage* msg) = 0; +}; +} +}
\ No newline at end of file diff --git a/xbmc/messaging/Makefile.in b/xbmc/messaging/Makefile.in new file mode 100644 index 0000000000..0d369c4796 --- /dev/null +++ b/xbmc/messaging/Makefile.in @@ -0,0 +1,7 @@ +SRCS = ApplicationMessenger.cpp + +LIB = messaging.a + +include @abs_top_srcdir@/Makefile.include +-include $(patsubst %.cpp,%.P,$(patsubst %c,%.P,$(patsubst %.S,,$(SRCS)))) + diff --git a/xbmc/messaging/ThreadMessage.h b/xbmc/messaging/ThreadMessage.h new file mode 100644 index 0000000000..24155b53b6 --- /dev/null +++ b/xbmc/messaging/ThreadMessage.h @@ -0,0 +1,129 @@ +#pragma once +/* +* Copyright (C) 2005-2015 Team XBMC +* http://xbmc.org +* +* This Program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* This Program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XBMC; see the file COPYING. If not, see +* <http://www.gnu.org/licenses/>. +* +*/ + +#include <memory> +#include <string> +#include <vector> + +class CEvent; + +namespace KODI +{ +namespace MESSAGING +{ + +class CApplicationMessenger; + +class ThreadMessage +{ + friend CApplicationMessenger; +public: + ThreadMessage() + : ThreadMessage{ 0, -1, -1, nullptr } + { + } + + explicit ThreadMessage(uint32_t messageId) + : ThreadMessage{ messageId, -1, -1, nullptr } + { + } + + ThreadMessage(uint32_t messageId, int p1, int p2, void* payload) + : dwMessage{ messageId } + , param1{ p1 } + , param2{ p2 } + , lpVoid{ payload } + { + } + + ThreadMessage(uint32_t messageId, int p1, int p2, void* payload, std::string param, std::vector<std::string> vecParams) + : dwMessage{ messageId } + , param1{ p1 } + , param2{ p2 } + , lpVoid{ payload } + + { + strParam = param; + params = vecParams; + } + + ThreadMessage(const ThreadMessage& other) + : dwMessage(other.dwMessage), + param1(other.param1), + param2(other.param2), + lpVoid(other.lpVoid), + strParam(other.strParam), + params(other.params), + waitEvent(other.waitEvent) + { + } + + ThreadMessage(ThreadMessage&& other) + : dwMessage(other.dwMessage), + param1(other.param1), + param2(other.param2), + lpVoid(other.lpVoid), + strParam(std::move(other.strParam)), + params(std::move(other.params)), + waitEvent(std::move(other.waitEvent)) + { + } + + ThreadMessage& operator=(const ThreadMessage& other) + { + if (this == &other) + return *this; + dwMessage = other.dwMessage; + param1 = other.param1; + param2 = other.param2; + lpVoid = other.lpVoid; + strParam = other.strParam; + params = other.params; + waitEvent = other.waitEvent; + return *this; + } + + ThreadMessage& operator=(ThreadMessage&& other) + { + if (this == &other) + return *this; + dwMessage = other.dwMessage; + param1 = other.param1; + param2 = other.param2; + lpVoid = other.lpVoid; + strParam = std::move(other.strParam); + params = std::move(other.params); + waitEvent = std::move(other.waitEvent); + return *this; + } + + uint32_t dwMessage; + int param1; + int param2; + void* lpVoid; + std::string strParam; + std::vector<std::string> params; + +protected: + std::shared_ptr<CEvent> waitEvent; +}; +} +} diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index c0abd7c935..3c27a87736 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -44,7 +44,7 @@ #include "GUIUserMessages.h" #include "FileItem.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "settings/Settings.h" #include "settings/AdvancedSettings.h" #include "guilib/LocalizeStrings.h" @@ -60,6 +60,7 @@ using namespace std; using namespace XFILE; using namespace PLAYLIST; using namespace MUSICDATABASEDIRECTORY; +using namespace KODI::MESSAGING; #define CONTROL_BTNVIEWASICONS 2 #define CONTROL_BTNSORTBY 3 @@ -667,7 +668,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) database.Open(); CVideoInfoTag details; database.GetMusicVideoInfo("",details,database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle())); - CApplicationMessenger::Get().PlayFile(CFileItem(details)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(details))); return true; } diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp index 0afc29feb8..cab21a324a 100644 --- a/xbmc/network/AirPlayServer.cpp +++ b/xbmc/network/AirPlayServer.cpp @@ -36,7 +36,7 @@ #include "filesystem/Directory.h" #include "FileItem.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "utils/md5.h" #include "utils/Variant.h" #include "settings/Settings.h" @@ -49,6 +49,7 @@ #endif // HAS_ZEROCONF using namespace ANNOUNCEMENT; +using namespace KODI::MESSAGING; using namespace std; #ifdef TARGET_WINDOWS @@ -821,14 +822,14 @@ int CAirPlayServer::CTCPClient::ProcessRequest( std::string& responseHeader, { if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) { - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); } } else { if (g_application.m_pPlayer->IsPausedPlayback()) { - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); } } } @@ -856,7 +857,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( std::string& responseHeader, { backupVolume(); g_application.SetVolume(volume); - CApplicationMessenger::Get().ShowVolumeBar(oldVolume < volume); + CApplicationMessenger::Get().PostMsg(TMSG_VOLUME_SHOW, oldVolume < volume ? ACTION_VOLUME_UP : ACTION_VOLUME_DOWN); } } } @@ -981,12 +982,15 @@ int CAirPlayServer::CTCPClient::ProcessRequest( std::string& responseHeader, // froce to internal dvdplayer cause it is the only // one who will work well with airplay g_application.m_eForcedNextPlayer = EPC_DVDPLAYER; - CApplicationMessenger::Get().MediaPlay(fileToPlay); + + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(fileToPlay)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); // allow starting the player paused in ios8 mode (needed by camera roll app) if (CSettings::Get().GetBool("services.airplayios8compat") && !startPlayback) { - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); g_application.m_pPlayer->SeekPercentage(position * 100.0f); } } @@ -1039,12 +1043,12 @@ int CAirPlayServer::CTCPClient::ProcessRequest( std::string& responseHeader, { if (IsPlaying()) //only stop player if we started him { - CApplicationMessenger::Get().MediaStop(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); CAirPlayServer::m_isPlaying--; } else //if we are not playing and get the stop request - we just wanna stop picture streaming { - CApplicationMessenger::Get().SendAction(ACTION_PREVIOUS_MENU); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PREVIOUS_MENU))); } } ClearPhotoAssetCache(); @@ -1115,7 +1119,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( std::string& responseHeader, CLog::Log(LOGWARNING, "AIRPLAY: Asset %s not found in our cache.", photoCacheId.c_str()); } else - CApplicationMessenger::Get().PictureShow(tmpFileName); + CApplicationMessenger::Get().PostMsg(TMSG_PICTURE_SHOW, -1, -1, nullptr, tmpFileName); } else { diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp index 77a0912cbd..93062dff02 100644 --- a/xbmc/network/AirTunesServer.cpp +++ b/xbmc/network/AirTunesServer.cpp @@ -36,7 +36,7 @@ #include "utils/log.h" #include "network/Zeroconf.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "filesystem/PipeFile.h" #include "Application.h" #include "cores/dvdplayer/DVDDemuxers/DVDDemuxBXA.h" @@ -65,6 +65,7 @@ using namespace XFILE; using namespace ANNOUNCEMENT; +using namespace KODI::MESSAGING; DllLibShairplay *CAirTunesServer::m_pLibShairplay = NULL; CAirTunesServer *CAirTunesServer::ServerInstance = NULL; @@ -129,7 +130,7 @@ void CAirTunesServer::RefreshMetadata() if (m_metadata[2].length()) tag.SetArtist(m_metadata[2]);//artist - CApplicationMessenger::Get().SetCurrentSongTag(tag); + CApplicationMessenger::Get().PostMsg(TMSG_UPDATE_CURRENT_ITEM, 1, -1, static_cast<void*>(new CFileItem(tag))); } void CAirTunesServer::RefreshCoverArt(const char *outputFilename/* = NULL*/) @@ -373,16 +374,15 @@ void* CAirTunesServer::AudioOutputFunctions::audio_init(void *cls, int bits, int if (pipe->Write(&header, sizeof(header)) == 0) return 0; - ThreadMessage tMsg = { TMSG_MEDIA_STOP }; - CApplicationMessenger::Get().SendMessage(tMsg, true); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); - CFileItem item; - item.SetPath(pipe->GetName()); - item.SetMimeType("audio/x-xbmc-pcm"); + CFileItem *item = new CFileItem();; + item->SetPath(pipe->GetName()); + item->SetMimeType("audio/x-xbmc-pcm"); m_streamStarted = true; m_sampleRate = samplerate; - CApplicationMessenger::Get().PlayFile(item); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(item)); // Not all airplay streams will provide metadata (e.g. if using mirroring, // no metadata will be sent). If there *is* metadata, it will be received @@ -495,8 +495,7 @@ void CAirTunesServer::AudioOutputFunctions::audio_destroy(void *cls, void *sess if (!CAirPlayServer::IsPlaying()) #endif { - ThreadMessage tMsg = { TMSG_MEDIA_STOP }; - CApplicationMessenger::Get().SendMessage(tMsg, true); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); CLog::Log(LOGDEBUG, "AIRTUNES: AirPlay not running - stopping player"); } diff --git a/xbmc/network/Network.cpp b/xbmc/network/Network.cpp index ed4c5d741c..82da35b93e 100644 --- a/xbmc/network/Network.cpp +++ b/xbmc/network/Network.cpp @@ -23,7 +23,7 @@ #include <arpa/inet.h> #include "Network.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "network/NetworkServices.h" #include "utils/log.h" #ifdef TARGET_WINDOWS @@ -33,6 +33,8 @@ #endif #include "utils/StringUtils.h" +using namespace KODI::MESSAGING; + /* slightly modified in_ether taken from the etherboot project (http://sourceforge.net/projects/etherboot) */ bool in_ether (const char *bufp, unsigned char *addr) { @@ -132,12 +134,12 @@ int NetworkAccessPoint::FreqToChannel(float frequency) CNetwork::CNetwork() { - CApplicationMessenger::Get().NetworkMessage(SERVICES_UP, 0); + CApplicationMessenger::Get().PostMsg(TMSG_NETWORKMESSAGE, SERVICES_UP, 0); } CNetwork::~CNetwork() { - CApplicationMessenger::Get().NetworkMessage(SERVICES_DOWN, 0); + CApplicationMessenger::Get().PostMsg(TMSG_NETWORKMESSAGE, SERVICES_DOWN, 0); } int CNetwork::ParseHex(char *str, unsigned char *addr) diff --git a/xbmc/network/NetworkServices.cpp b/xbmc/network/NetworkServices.cpp index cf959691b0..5b3bc27a60 100644 --- a/xbmc/network/NetworkServices.cpp +++ b/xbmc/network/NetworkServices.cpp @@ -20,7 +20,7 @@ #include "NetworkServices.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #ifdef TARGET_LINUX #include "Util.h" #endif @@ -84,6 +84,7 @@ #include "utils/SystemInfo.h" #include "utils/Variant.h" +using namespace KODI::MESSAGING; using namespace std; #ifdef HAS_JSONRPC using namespace JSONRPC; @@ -416,7 +417,7 @@ void CNetworkServices::OnSettingChanged(const CSetting *setting) if (CGUIDialogYesNo::ShowAndGetInput(CVariant{14038}, CVariant{14039})) { CSettings::Get().Save(); - CApplicationMessenger::Get().RestartApp(); + CApplicationMessenger::Get().PostMsg(TMSG_RESTARTAPP); } } } diff --git a/xbmc/network/upnp/UPnP.cpp b/xbmc/network/upnp/UPnP.cpp index ec5a17d055..201910c664 100644 --- a/xbmc/network/upnp/UPnP.cpp +++ b/xbmc/network/upnp/UPnP.cpp @@ -33,7 +33,7 @@ #include "UPnPSettings.h" #include "utils/URIUtils.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "network/Network.h" #include "utils/log.h" #include "URL.h" @@ -51,6 +51,7 @@ using namespace std; using namespace UPNP; +using namespace KODI::MESSAGING; NPT_SET_LOCAL_LOGGER("xbmc.upnp") diff --git a/xbmc/network/upnp/UPnPPlayer.cpp b/xbmc/network/upnp/UPnPPlayer.cpp index 9c7dadb024..796c8842dc 100644 --- a/xbmc/network/upnp/UPnPPlayer.cpp +++ b/xbmc/network/upnp/UPnPPlayer.cpp @@ -34,13 +34,14 @@ #include "ThumbLoader.h" #include "video/VideoThumbLoader.h" #include "music/MusicThumbLoader.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Application.h" #include "dialogs/GUIDialogBusy.h" #include "guilib/GUIWindowManager.h" #include "input/Key.h" #include "dialogs/GUIDialogYesNo.h" +using namespace KODI::MESSAGING; NPT_SET_LOCAL_LOGGER("xbmc.upnp.player") @@ -528,7 +529,7 @@ void CUPnPPlayer::DoAudioWork() m_current_meta = (const char*)meta; CFileItemPtr item = GetFileItem(uri, meta); g_application.CurrentFileItem() = *item; - CApplicationMessenger::Get().SetCurrentItem(*item.get()); + CApplicationMessenger::Get().PostMsg(TMSG_UPDATE_CURRENT_ITEM, 0, -1, static_cast<void*>(new CFileItem(*item))); } NPT_CHECK_LABEL(m_delegate->m_transport->GetStateVariableValue("TransportState", data), failed); diff --git a/xbmc/network/upnp/UPnPRenderer.cpp b/xbmc/network/upnp/UPnPRenderer.cpp index 0d1ce1ae2f..a63c29ea01 100644 --- a/xbmc/network/upnp/UPnPRenderer.cpp +++ b/xbmc/network/upnp/UPnPRenderer.cpp @@ -24,7 +24,7 @@ #include "UPnP.h" #include "UPnPInternal.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "FileItem.h" #include "filesystem/SpecialProtocol.h" #include "GUIInfoManager.h" @@ -47,6 +47,7 @@ NPT_SET_LOCAL_LOGGER("xbmc.upnp.renderer") using namespace ANNOUNCEMENT; +using namespace KODI::MESSAGING; namespace UPNP { @@ -447,10 +448,9 @@ NPT_Result CUPnPRenderer::OnNext(PLT_ActionReference& action) { if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { - CAction action(ACTION_NEXT_PICTURE); - CApplicationMessenger::Get().SendAction(action, WINDOW_SLIDESHOW); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_NEXT_PICTURE))); } else { - CApplicationMessenger::Get().PlayListPlayerNext(); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_NEXT); } return NPT_SUCCESS; } @@ -462,10 +462,9 @@ NPT_Result CUPnPRenderer::OnPause(PLT_ActionReference& action) { if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { - CAction action(ACTION_PAUSE); - CApplicationMessenger::Get().SendAction(action, WINDOW_SLIDESHOW); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_NEXT_PICTURE))); } else if (!g_application.m_pPlayer->IsPausedPlayback()) - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); return NPT_SUCCESS; } @@ -478,7 +477,7 @@ CUPnPRenderer::OnPlay(PLT_ActionReference& action) if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { return NPT_SUCCESS; } else if (g_application.m_pPlayer->IsPausedPlayback()) { - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); } else if (!g_application.m_pPlayer->IsPlaying()) { NPT_String uri, meta; PLT_Service* service; @@ -500,10 +499,9 @@ NPT_Result CUPnPRenderer::OnPrevious(PLT_ActionReference& action) { if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { - CAction action(ACTION_PREV_PICTURE); - CApplicationMessenger::Get().SendAction(action, WINDOW_SLIDESHOW); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_PREV_PICTURE))); } else { - CApplicationMessenger::Get().PlayListPlayerPrevious(); + CApplicationMessenger::Get().SendMsg(TMSG_PLAYLISTPLAYER_PREV); } return NPT_SUCCESS; } @@ -515,10 +513,9 @@ NPT_Result CUPnPRenderer::OnStop(PLT_ActionReference& action) { if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { - CAction action(ACTION_STOP); - CApplicationMessenger::Get().SendAction(action, WINDOW_SLIDESHOW); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_NEXT_PICTURE))); } else { - CApplicationMessenger::Get().MediaStop(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); } return NPT_SUCCESS; } @@ -624,9 +621,11 @@ CUPnPRenderer::PlayMedia(const NPT_String& uri, const NPT_String& meta, PLT_Acti } if (item->IsPicture()) { - CApplicationMessenger::Get().PictureShow(item->GetPath()); + CApplicationMessenger::Get().PostMsg(TMSG_PICTURE_SHOW, -1, -1, nullptr, item->GetPath()); } else { - CApplicationMessenger::Get().MediaPlay(*item, false); + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(*item)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); } // just return success because the play actions are asynchronous diff --git a/xbmc/osx/IOSEAGLView.mm b/xbmc/osx/IOSEAGLView.mm index 51a7e31109..7135bff08f 100644 --- a/xbmc/osx/IOSEAGLView.mm +++ b/xbmc/osx/IOSEAGLView.mm @@ -29,7 +29,7 @@ #include "AdvancedSettings.h" #include "FileItem.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "WindowingFactory.h" #include "VideoReferenceClock.h" #include "utils/log.h" @@ -54,6 +54,8 @@ #import "DarwinUtils.h" #import "XBMCDebugHelpers.h" +using namespace KODI::MESSAGING; + //-------------------------------------------------------------- @interface IOSEAGLView (PrivateMethods) - (void) setContext:(EAGLContext *)newContext; @@ -359,8 +361,7 @@ xbmcAlive = FALSE; if (!g_application.m_bStop) { - ThreadMessage tMsg = {TMSG_QUIT}; - CApplicationMessenger::Get().SendMessage(tMsg); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); } // wait for animation thread to die if ([animationThread isFinished] == NO) diff --git a/xbmc/osx/OSXTextInputResponder.mm b/xbmc/osx/OSXTextInputResponder.mm index d0884dbb6c..1b41946956 100644 --- a/xbmc/osx/OSXTextInputResponder.mm +++ b/xbmc/osx/OSXTextInputResponder.mm @@ -27,10 +27,12 @@ #include "guilib/GUIWindowManager.h" #include "GUIUserMessages.h" #include "utils/log.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "input/Key.h" #undef BOOL +using namespace KODI::MESSAGING; + void SendKeyboardText(const char *text) { // CLog::Log(LOGDEBUG, "SendKeyboardText(%s)", text); @@ -39,12 +41,9 @@ void SendKeyboardText(const char *text) if ((unsigned char)*text < ' ' || *text == 127) return; - ThreadMessage tMsg = {TMSG_GUI_ACTION}; - tMsg.param1 = WINDOW_INVALID; CAction *action = new CAction(ACTION_INPUT_TEXT); action->SetText(text); - tMsg.lpVoid = action; - CApplicationMessenger::Get().SendMessage(tMsg, false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(action)); } void SendEditingText(const char *text, unsigned int location, unsigned int length) diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm index 063111bad3..f3ac65718b 100644 --- a/xbmc/osx/ios/XBMCController.mm +++ b/xbmc/osx/ios/XBMCController.mm @@ -31,7 +31,7 @@ #include "MusicInfoTag.h" #include "SpecialProtocol.h" #include "PlayList.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Application.h" #include "interfaces/AnnouncementManager.h" #include "input/touch/generic/GenericTouchActionHandler.h" @@ -50,6 +50,8 @@ #include <math.h> #include "osx/DarwinUtils.h" +using namespace KODI::MESSAGING; + #ifndef M_PI #define M_PI 3.1415926535897932384626433832795028842 #endif @@ -1021,36 +1023,36 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; switch (receivedEvent.subtype) { case UIEventSubtypeRemoteControlTogglePlayPause: - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_PLAYPAUSE); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_PLAYPAUSE))); break; case UIEventSubtypeRemoteControlPlay: - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_PLAY); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_PLAY))); break; case UIEventSubtypeRemoteControlPause: // ACTION_PAUSE sometimes cause unpause, use MediaPauseIfPlaying to make sure pause only - CApplicationMessenger::Get().MediaPauseIfPlaying(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE_IF_PLAYING); break; case UIEventSubtypeRemoteControlNextTrack: - CApplicationMessenger::Get().SendAction(ACTION_NEXT_ITEM); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_NEXT_ITEM))); break; case UIEventSubtypeRemoteControlPreviousTrack: - CApplicationMessenger::Get().SendAction(ACTION_PREV_ITEM); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PREV_ITEM))); break; case UIEventSubtypeRemoteControlBeginSeekingForward: // use 4X speed forward. - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_FORWARD); - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_FORWARD); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_FORWARD))); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_FORWARD))); break; case UIEventSubtypeRemoteControlBeginSeekingBackward: // use 4X speed rewind. - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_REWIND); - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_REWIND); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_REWIND))); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_REWIND))); break; case UIEventSubtypeRemoteControlEndSeekingForward: case UIEventSubtypeRemoteControlEndSeekingBackward: // restore to normal playback speed. if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) - CApplicationMessenger::Get().SendAction(ACTION_PLAYER_PLAY); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, -1, -1, static_cast<void*>(new CAction(ACTION_PLAYER_PLAY))); break; default: LOG(@"unhandled subtype: %d", receivedEvent.subtype); @@ -1066,7 +1068,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) { m_isPlayingBeforeInactive = YES; - CApplicationMessenger::Get().MediaPauseIfPlaying(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE_IF_PLAYING); } g_Windowing.OnAppFocusChange(false); } @@ -1078,7 +1080,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; // when we come back, restore playing if we were. if (m_isPlayingBeforeInactive) { - CApplicationMessenger::Get().MediaUnPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_UNPAUSE); m_isPlayingBeforeInactive = NO; } } @@ -1090,7 +1092,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; if (g_application.m_pPlayer->IsPlayingVideo() && !g_application.m_pPlayer->IsPaused()) { m_isPlayingBeforeInactive = YES; - CApplicationMessenger::Get().MediaPauseIfPlaying(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE_IF_PLAYING); } // check whether we need disable network auto suspend. [self rescheduleNetworkAutoSuspend]; diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp index 95eb0cef85..f6c06e98bf 100644 --- a/xbmc/peripherals/Peripherals.cpp +++ b/xbmc/peripherals/Peripherals.cpp @@ -48,6 +48,8 @@ #include "Util.h" #include "input/Key.h" #include "settings/lib/Setting.h" +#include "messaging/ThreadMessage.h" +#include "messaging/ApplicationMessenger.h" using namespace PERIPHERALS; using namespace XFILE; @@ -100,6 +102,7 @@ void CPeripherals::Initialise(void) } m_bInitialised = true; + KODI::MESSAGING::CApplicationMessenger::Get().RegisterReceveiver(this); } } @@ -724,3 +727,26 @@ void CPeripherals::OnSettingAction(const CSetting *setting) dialog->Open(); } } + +void CPeripherals::OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) +{ + switch (pMsg->dwMessage) + { + case TMSG_CECTOGGLESTATE: + *static_cast<bool*>(pMsg->lpVoid) = ToggleDeviceState(STATE_SWITCH_TOGGLE); + break; + + case TMSG_CECACTIVATESOURCE: + ToggleDeviceState(STATE_ACTIVATE_SOURCE); + break; + + case TMSG_CECSTANDBY: + ToggleDeviceState(STATE_STANDBY); + break; + } +} + +int CPeripherals::GetMessageMask() +{ + return TMSG_MASK_PERIPHERALS; +} diff --git a/xbmc/peripherals/Peripherals.h b/xbmc/peripherals/Peripherals.h index 8f2a08c65e..17bd726f7a 100644 --- a/xbmc/peripherals/Peripherals.h +++ b/xbmc/peripherals/Peripherals.h @@ -26,6 +26,7 @@ #include "threads/CriticalSection.h" #include "threads/Thread.h" #include "utils/Observer.h" +#include "messaging/IMessageTarget.h" class CFileItemList; class CSetting; @@ -39,7 +40,8 @@ namespace PERIPHERALS #define g_peripherals CPeripherals::Get() class CPeripherals : public ISettingCallback, - public Observable + public Observable, + public KODI::MESSAGING::IMessageTarget { public: static CPeripherals &Get(void); @@ -210,6 +212,9 @@ namespace PERIPHERALS virtual void OnSettingChanged(const CSetting *setting); virtual void OnSettingAction(const CSetting *setting); + virtual void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; + virtual int GetMessageMask() override; + private: CPeripherals(void); bool LoadMappings(void); diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp index ea702e522d..a10264a64a 100644 --- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp +++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp @@ -23,7 +23,7 @@ #include "PeripheralCecAdapter.h" #include "input/XBIRRemote.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "DynamicDll.h" #include "threads/SingleLock.h" #include "dialogs/GUIDialogKaiToast.h" @@ -37,6 +37,7 @@ #include <libcec/cec.h> +using namespace KODI::MESSAGING; using namespace PERIPHERALS; using namespace ANNOUNCEMENT; using namespace CEC; @@ -601,7 +602,7 @@ void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage) if (!strGuiLanguage.empty()) { strGuiLanguage = "resource.language." + strGuiLanguage; - CApplicationMessenger::Get().SetGUILanguage(strGuiLanguage); + CApplicationMessenger::Get().PostMsg(TMSG_SETLANGUAGE, -1, -1, nullptr, strGuiLanguage); CLog::Log(LOGDEBUG, "%s - language set to '%s'", __FUNCTION__, strGuiLanguage.c_str()); } else @@ -1171,7 +1172,7 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log pSlideShow->OnAction(CAction(ACTION_PAUSE)); else // pause/resume player - CApplicationMessenger::Get().MediaPause(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_PAUSE); } } } diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index 3a4c04f526..29450be4b4 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -22,7 +22,7 @@ #include "system.h" #include "GUIWindowSlideShow.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "utils/URIUtils.h" #include "URL.h" #include "guilib/TextureManager.h" @@ -47,6 +47,7 @@ #include "pictures/PictureThumbLoader.h" using namespace XFILE; +using namespace KODI::MESSAGING; #define MAX_ZOOM_FACTOR 10 #define MAX_PICTURE_SIZE 2048*2048 diff --git a/xbmc/pvr/PVRActionListener.cpp b/xbmc/pvr/PVRActionListener.cpp index 2700c44f8b..4b41e424b9 100644 --- a/xbmc/pvr/PVRActionListener.cpp +++ b/xbmc/pvr/PVRActionListener.cpp @@ -21,7 +21,7 @@ #include "PVRActionListener.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "input/Key.h" #include "guilib/LocalizeStrings.h" #include "dialogs/GUIDialogNumeric.h" @@ -34,6 +34,7 @@ #include "pvr/channels/PVRChannelGroupsContainer.h" using namespace PVR; +using namespace KODI::MESSAGING; CPVRActionListener::CPVRActionListener() { @@ -103,7 +104,8 @@ bool CPVRActionListener::OnAction(const CAction &action) if (fileItem && fileItem->HasPVRChannelInfoTag()) { CLog::Log(LOGDEBUG, "%s - switch to channel number %d", __FUNCTION__, fileItem->GetPVRChannelInfoTag()->ChannelNumber()); - CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float) fileItem->GetPVRChannelInfoTag()->ChannelNumber()), WINDOW_INVALID, false); + CApplicationMessenger::Get().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1,static_cast<void*>( + new CAction(ACTION_CHANNEL_SWITCH, static_cast<float>(fileItem->GetPVRChannelInfoTag()->ChannelNumber())))); } } } @@ -121,7 +123,8 @@ bool CPVRActionListener::OnAction(const CAction &action) if (!channel || !channel->HasPVRChannelInfoTag()) return false; - CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber), WINDOW_INVALID, false); + CApplicationMessenger::Get().PostMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>( + new CAction(ACTION_CHANNEL_SWITCH, static_cast<float>(iChannelNumber)))); } } } @@ -131,6 +134,5 @@ bool CPVRActionListener::OnAction(const CAction &action) } break; } - return false; } diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 4b242dce03..7c27040738 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -19,7 +19,7 @@ */ #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIInfoManager.h" #include "Util.h" #include "dialogs/GUIDialogOK.h" @@ -66,6 +66,7 @@ using namespace MUSIC_INFO; using namespace PVR; using namespace EPG; using namespace ANNOUNCEMENT; +using namespace KODI::MESSAGING; int CPVRManager::m_pvrWindowIds[10] = { WINDOW_TV_CHANNELS, @@ -153,7 +154,7 @@ void CPVRManager::OnSettingChanged(const CSetting *setting) const std::string &settingId = setting->GetId(); if (settingId == "pvrmanager.enabled") { - CApplicationMessenger::Get().SetPVRManagerState(((CSettingBool*)setting)->GetValue()); + CApplicationMessenger::Get().PostMsg(TMSG_SETPVRMANAGERSTATE, ((CSettingBool*)setting)->GetValue() ? 1 : 0); } else if (settingId == "pvrparental.enabled") { @@ -454,7 +455,7 @@ void CPVRManager::Stop(void) if (IsPlaying()) { CLog::Log(LOGNOTICE,"PVRManager - %s - stopping PVR playback", __FUNCTION__); - CApplicationMessenger::Get().MediaStop(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); } /* stop all update threads */ @@ -563,7 +564,7 @@ void CPVRManager::Process(void) if (IsStarted()) { CLog::Log(LOGNOTICE, "PVRManager - %s - no add-ons enabled anymore. restarting the pvrmanager", __FUNCTION__); - CApplicationMessenger::Get().SetPVRManagerState(true); + CApplicationMessenger::Get().PostMsg(TMSG_SETPVRMANAGERSTATE, 1); } else { @@ -778,7 +779,7 @@ void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */) if (m_addons && m_addons->IsPlaying()) { CLog::Log(LOGNOTICE,"PVRManager - %s - stopping playback", __FUNCTION__); - CApplicationMessenger::Get().MediaStop(); + CApplicationMessenger::Get().SendMsg(TMSG_MEDIA_STOP); } pDlgProgress->SetPercentage(10); @@ -1115,7 +1116,9 @@ bool CPVRManager::PlayMedia(const CFileItem& item) if (!g_application.IsCurrentThread()) { - CApplicationMessenger::Get().MediaPlay(pvrItem); + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(pvrItem)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); return true; } @@ -1198,7 +1201,11 @@ bool CPVRManager::UpdateItem(CFileItem& item) bool CPVRManager::StartPlayback(const CPVRChannelPtr &channel, bool bMinimised /* = false */) { CMediaSettings::Get().SetVideoStartWindowed(bMinimised); - CApplicationMessenger::Get().MediaPlay(CFileItem(channel)); + + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(channel)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); + CLog::Log(LOGNOTICE, "PVRManager - %s - started playback on channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); return true; diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index e8ef200271..42430a2138 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -21,7 +21,7 @@ #include "PVRClients.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIUserMessages.h" #include "dialogs/GUIDialogExtendedProgressBar.h" #include "dialogs/GUIDialogOK.h" @@ -40,6 +40,7 @@ using namespace ADDON; using namespace PVR; using namespace EPG; +using namespace KODI::MESSAGING; /** number of iterations when scanning for add-ons. don't use a timer because the user may block in the dialog */ #define PVR_CLIENT_AVAHI_SCAN_ITERATIONS (20) @@ -377,8 +378,7 @@ bool CPVRClients::SwitchChannel(const CPVRChannelPtr &channel) } else { - CFileItem m_currentFile(channel); - CApplicationMessenger::Get().PlayFile(m_currentFile, false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(channel))); bSwitchSuccessful = true; } } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp index 0e7d30e530..b068495163 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp @@ -20,7 +20,7 @@ #include "GUIDialogPVRChannelsOSD.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "FileItem.h" #include "guilib/GUIWindowManager.h" #include "input/Key.h" @@ -38,6 +38,7 @@ using namespace PVR; using namespace EPG; +using namespace KODI::MESSAGING; #define CONTROL_LIST 11 @@ -261,7 +262,7 @@ void CGUIDialogPVRChannelsOSD::GotoChannel(int item) } } else - CApplicationMessenger::Get().PlayFile(*pItem); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(*pItem))); m_group = GetPlayingGroup(); diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp index 0e14ea5e0d..c995cd324f 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp @@ -21,7 +21,7 @@ #include "GUIWindowPVRBase.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "dialogs/GUIDialogNumeric.h" #include "dialogs/GUIDialogKaiToast.h" #include "dialogs/GUIDialogOK.h" @@ -51,6 +51,7 @@ using namespace PVR; using namespace EPG; +using namespace KODI::MESSAGING; std::map<bool, std::string> CGUIWindowPVRBase::m_selectedItemPaths; @@ -330,7 +331,7 @@ bool CGUIWindowPVRBase::PlayFile(CFileItem *item, bool bPlayMinimized /* = false if (!bSwitchSuccessful) { - CApplicationMessenger::Get().PlayFile(*item, false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(*item))); return true; } } @@ -460,7 +461,7 @@ bool CGUIWindowPVRBase::PlayRecording(CFileItem *item, bool bPlayMinimized /* = { if (bCheckResume) CheckResumeRecording(item); - CApplicationMessenger::Get().PlayFile(*item, false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(*item))); return true; } @@ -512,7 +513,7 @@ bool CGUIWindowPVRBase::PlayRecording(CFileItem *item, bool bPlayMinimized /* = if (bCheckResume) CheckResumeRecording(item); - CApplicationMessenger::Get().PlayFile(*item, false); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(*item))); return true; } diff --git a/xbmc/utils/AlarmClock.cpp b/xbmc/utils/AlarmClock.cpp index 24ca8fb5cb..19e7253967 100644 --- a/xbmc/utils/AlarmClock.cpp +++ b/xbmc/utils/AlarmClock.cpp @@ -19,13 +19,14 @@ */ #include "AlarmClock.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/LocalizeStrings.h" #include "threads/SingleLock.h" #include "log.h" #include "dialogs/GUIDialogKaiToast.h" #include "utils/StringUtils.h" +using namespace KODI::MESSAGING; using namespace std; CAlarmClock::CAlarmClock() : CThread("AlarmClock"), m_bIsRunning(false) @@ -119,7 +120,7 @@ void CAlarmClock::Stop(const std::string& strName, bool bSilent /* false */) } else { - CApplicationMessenger::Get().ExecBuiltIn(iter->second.m_strCommand); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, iter->second.m_strCommand); if (iter->second.m_loop) { iter->second.watch.Reset(); diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 6081f16546..85c671e33b 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -22,7 +22,7 @@ #include "config.h" #endif -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "threads/SystemClock.h" #include "VideoDatabase.h" #include "video/windows/GUIWindowVideoBase.h" @@ -78,6 +78,7 @@ using namespace dbiplus; using namespace XFILE; using namespace VIDEO; using namespace ADDON; +using namespace KODI::MESSAGING; //******************************************************************************************************************************** CVideoDatabase::CVideoDatabase(void) diff --git a/xbmc/video/VideoInfoDownloader.cpp b/xbmc/video/VideoInfoDownloader.cpp index b7e9843524..c8aee9f76e 100644 --- a/xbmc/video/VideoInfoDownloader.cpp +++ b/xbmc/video/VideoInfoDownloader.cpp @@ -21,12 +21,13 @@ #include "VideoInfoDownloader.h" #include "dialogs/GUIDialogProgress.h" #include "dialogs/GUIDialogOK.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "guilib/GUIWindowManager.h" #include "utils/log.h" #include "utils/Variant.h" using namespace VIDEO; +using namespace KODI::MESSAGING; #ifndef __GNUC__ #pragma warning (disable:4018) diff --git a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp index cb2c234dbd..3cda4dfa74 100644 --- a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp @@ -49,11 +49,13 @@ #include "video/VideoThumbLoader.h" #include "filesystem/File.h" #include "TextureCache.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "settings/Settings.h" #include <string> #include <vector> +using namespace KODI::MESSAGING; + #define BOOKMARK_THUMB_WIDTH g_advancedSettings.GetThumbSize() #define CONTROL_ADD_BOOKMARK 2 diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 83c1803e3c..e56edd0f16 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -29,7 +29,7 @@ #include "video/windows/GUIWindowVideoNav.h" #include "dialogs/GUIDialogFileBrowser.h" #include "video/VideoInfoScanner.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "video/VideoInfoTag.h" #include "guilib/GUIKeyboardFactory.h" #include "guilib/GUIWindowManager.h" @@ -61,6 +61,7 @@ using namespace XFILE::VIDEODATABASEDIRECTORY; using namespace XFILE; +using namespace KODI::MESSAGING; #define CONTROL_IMAGE 3 #define CONTROL_TEXTAREA 4 @@ -880,9 +881,13 @@ void CGUIDialogVideoInfo::PlayTrailer() Close(true); if (item.IsPlayList()) - CApplicationMessenger::Get().MediaPlay(item); + { + CFileItemList *l = new CFileItemList; //don't delete, + l->Add(std::make_shared<CFileItem>(item)); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); + } else - CApplicationMessenger::Get().PlayFile(item); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(item))); } void CGUIDialogVideoInfo::SetLabel(int iControl, const std::string &strLabel) diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index a92ec59286..f88c9d745a 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -22,7 +22,7 @@ #include "system.h" #include "GUIWindowFullScreen.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #ifdef HAS_VIDEO_PLAYBACK #include "cores/VideoRenderers/RenderManager.h" #endif @@ -54,6 +54,8 @@ #include "linux/LinuxResourceCounter.h" #endif +using namespace KODI::MESSAGING; + #define BLUE_BAR 0 #define LABEL_ROW1 10 #define LABEL_ROW2 11 diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 9fa2c3ce6d..679cbbb9f2 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -34,7 +34,7 @@ #include "filesystem/Directory.h" #include "FileItem.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "profiles/ProfilesManager.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" @@ -56,6 +56,7 @@ using namespace XFILE; using namespace VIDEODATABASEDIRECTORY; +using namespace KODI::MESSAGING; #define CONTROL_BTNVIEWASICONS 2 #define CONTROL_BTNSORTBY 3 @@ -1056,7 +1057,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strTitle), song)) { - CApplicationMessenger::Get().PlayFile(song); + CApplicationMessenger::Get().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(song))); } return true; } diff --git a/xbmc/windowing/WinEventsSDL.cpp b/xbmc/windowing/WinEventsSDL.cpp index 29f1351b1d..a665856009 100644 --- a/xbmc/windowing/WinEventsSDL.cpp +++ b/xbmc/windowing/WinEventsSDL.cpp @@ -24,7 +24,7 @@ #include "WinEvents.h" #include "WinEventsSDL.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIUserMessages.h" #include "settings/DisplaySettings.h" #include "guilib/GUIWindowManager.h" @@ -46,6 +46,8 @@ #include "utils/log.h" #endif +using namespace KODI::MESSAGING; + #if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) // The following chunk of code is Linux specific. For keys that have // with keysym.sym set to zero it checks the scan code, and sets the sym @@ -227,7 +229,7 @@ bool CWinEventsSDL::MessagePump() { case SDL_QUIT: if (!g_application.m_bStop) - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); break; #ifdef HAS_SDL_JOYSTICK @@ -439,7 +441,7 @@ bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event) { case SDLK_q: // CMD-q to quit if (!g_application.m_bStop) - CApplicationMessenger::Get().Quit(); + CApplicationMessenger::Get().PostMsg(TMSG_QUIT); return true; case SDLK_f: // CMD-f to toggle fullscreen @@ -455,7 +457,7 @@ bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event) return true; case SDLK_m: // CMD-m to minimize - CApplicationMessenger::Get().Minimize(); + CApplicationMessenger::Get().PostMsg(TMSG_MINIMIZE); return true; default: diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp index 38a52df6db..1aacf5a334 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp @@ -26,7 +26,7 @@ #include "WinEvents.h" #include "WinEventsX11.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include <X11/Xlib.h> #include <X11/extensions/Xrandr.h> #include "X11/WinSystemX11GL.h" @@ -43,6 +43,8 @@ #include "input/SDLJoystick.h" #endif +using namespace KODI::MESSAGING; + CWinEventsX11Imp* CWinEventsX11Imp::WinEvents = 0; static uint32_t SymMappingsX11[][2] = @@ -406,7 +408,7 @@ bool CWinEventsX11Imp::MessagePump() case ClientMessage: { if ((unsigned int)xevent.xclient.data.l[0] == WinEvents->m_wmDeleteMessage) - if (!g_application.m_bStop) CApplicationMessenger::Get().Quit(); + if (!g_application.m_bStop) CApplicationMessenger::Get().PostMsg(TMSG_QUIT); break; } diff --git a/xbmc/windowing/osx/WinSystemOSX.mm b/xbmc/windowing/osx/WinSystemOSX.mm index 391854f2e7..714cdeb1e1 100644 --- a/xbmc/windowing/osx/WinSystemOSX.mm +++ b/xbmc/windowing/osx/WinSystemOSX.mm @@ -26,7 +26,7 @@ #include "WinSystemOSX.h" #include "WinEventsOSX.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "CompileInfo.h" #include "guilib/DispResource.h" #include "guilib/GUIWindowManager.h" @@ -55,6 +55,8 @@ // turn off deprecated warning spew. #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +using namespace KODI::MESSAGING; + //------------------------------------------------------------------------------------------ // special object-c class for handling the inhibit display NSTimer callback. @interface windowInhibitScreenSaverClass : NSObject @@ -1616,10 +1618,7 @@ void CWinSystemOSX::HandlePossibleRefreshrateChange() oldRefreshRate = m_refreshRate; // send a message so that videoresolution (and refreshrate) // is changed - ThreadMessage msg = {TMSG_VIDEORESIZE}; - msg.param1 = m_SDLSurface->w; - msg.param2 = m_SDLSurface->h; - CApplicationMessenger::Get().SendMessage(msg, false); + CApplicationMessenger::Get().PostMsg(TMSG_VIDEORESIZE, m_SDLSurface->w, m_SDLSurface->h); } } diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index cdf128ea25..45feb7efef 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -20,7 +20,7 @@ #include "GUIMediaWindow.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "ContextMenuManager.h" #include "FileItemListModification.h" #include "GUIPassword.h" @@ -84,6 +84,7 @@ #define PROPERTY_SORT_ASCENDING "sort.ascending" using namespace ADDON; +using namespace KODI::MESSAGING; CGUIMediaWindow::CGUIMediaWindow(int id, const char *xmlFile) : CGUIWindow(id, xmlFile) @@ -1609,7 +1610,7 @@ bool CGUIMediaWindow::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_USER10: { std::string action = StringUtils::Format("contextmenuaction(%i)", button - CONTEXT_BUTTON_USER1); - CApplicationMessenger::Get().ExecBuiltIn(m_vecItems->Get(itemNumber)->GetProperty(action).asString()); + CApplicationMessenger::Get().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, m_vecItems->Get(itemNumber)->GetProperty(action).asString()); return true; } default: diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index 6c63957fd0..580cab01c3 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -21,7 +21,7 @@ #include "system.h" #include "GUIWindowFileManager.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "Util.h" #include "filesystem/Directory.h" #include "filesystem/ZipManager.h" @@ -60,6 +60,7 @@ using namespace XFILE; using namespace PLAYLIST; +using namespace KODI::MESSAGING; #define ACTION_COPY 1 #define ACTION_MOVE 2 diff --git a/xbmc/windows/GUIWindowLoginScreen.cpp b/xbmc/windows/GUIWindowLoginScreen.cpp index 66655f48cb..f9e1feca73 100644 --- a/xbmc/windows/GUIWindowLoginScreen.cpp +++ b/xbmc/windows/GUIWindowLoginScreen.cpp @@ -20,7 +20,7 @@ #include "system.h" #include "Application.h" -#include "ApplicationMessenger.h" +#include "messaging/ApplicationMessenger.h" #include "GUIWindowLoginScreen.h" #include "profiles/Profile.h" #include "profiles/ProfilesManager.h" @@ -50,6 +50,8 @@ #include "pvr/PVRManager.h" #include "ContextMenuManager.h" +using namespace KODI::MESSAGING; + #define CONTROL_BIG_LIST 52 #define CONTROL_LABEL_HEADER 2 #define CONTROL_LABEL_SELECTED_PROFILE 3 @@ -240,7 +242,7 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem) if (g_passwordManager.CheckLock(CProfilesManager::Get().GetMasterProfile().getLockMode(),CProfilesManager::Get().GetMasterProfile().getLockCode(),20075)) g_passwordManager.iMasterLockRetriesLeft = CSettings::Get().GetInt("masterlock.maxretries"); else // be inconvenient - CApplicationMessenger::Get().Shutdown(); + CApplicationMessenger::Get().PostMsg(TMSG_SHUTDOWN); return true; } |