11 #include "guilib/WindowIDs.h" 12 #include "messaging/ThreadMessage.h" 13 #include "threads/Thread.h" 22 #define TMSG_MASK_MESSAGE 0xFFFF0000 // only keep the high bits to route messages 23 #define TMSG_MASK_APPLICATION (1<<30) //Don't use bit 31 as it'll fail to build, using unsigned variable to hold the message. 24 #define TMSG_MASK_PLAYLISTPLAYER (1<<29) 25 #define TMSG_MASK_GUIINFOMANAGER (1<<28) 26 #define TMSG_MASK_WINDOWMANAGER (1<<27) 27 #define TMSG_MASK_PERIPHERALS (1<<26) 30 #define TMSG_PLAYLISTPLAYER_PLAY TMSG_MASK_PLAYLISTPLAYER + 0 31 #define TMSG_PLAYLISTPLAYER_NEXT TMSG_MASK_PLAYLISTPLAYER + 1 32 #define TMSG_PLAYLISTPLAYER_PREV TMSG_MASK_PLAYLISTPLAYER + 2 33 #define TMSG_PLAYLISTPLAYER_ADD TMSG_MASK_PLAYLISTPLAYER + 3 34 #define TMSG_PLAYLISTPLAYER_CLEAR TMSG_MASK_PLAYLISTPLAYER + 4 35 #define TMSG_PLAYLISTPLAYER_SHUFFLE TMSG_MASK_PLAYLISTPLAYER + 5 36 #define TMSG_PLAYLISTPLAYER_GET_ITEMS TMSG_MASK_PLAYLISTPLAYER + 6 37 #define TMSG_PLAYLISTPLAYER_PLAY_SONG_ID TMSG_MASK_PLAYLISTPLAYER + 7 38 #define TMSG_PLAYLISTPLAYER_INSERT TMSG_MASK_PLAYLISTPLAYER + 8 39 #define TMSG_PLAYLISTPLAYER_REMOVE TMSG_MASK_PLAYLISTPLAYER + 9 40 #define TMSG_PLAYLISTPLAYER_SWAP TMSG_MASK_PLAYLISTPLAYER + 10 41 #define TMSG_PLAYLISTPLAYER_REPEAT TMSG_MASK_PLAYLISTPLAYER + 11 42 #define TMSG_MEDIA_PLAY TMSG_MASK_PLAYLISTPLAYER + 12 43 #define TMSG_MEDIA_STOP TMSG_MASK_PLAYLISTPLAYER + 13 45 #define TMSG_MEDIA_PAUSE TMSG_MASK_PLAYLISTPLAYER + 14 46 #define TMSG_MEDIA_RESTART TMSG_MASK_PLAYLISTPLAYER + 15 47 #define TMSG_MEDIA_UNPAUSE TMSG_MASK_PLAYLISTPLAYER + 16 48 #define TMSG_MEDIA_PAUSE_IF_PLAYING TMSG_MASK_PLAYLISTPLAYER + 17 49 #define TMSG_MEDIA_SEEK_TIME TMSG_MASK_PLAYLISTPLAYER + 18 51 #define TMSG_SHUTDOWN TMSG_MASK_APPLICATION + 0 52 #define TMSG_POWERDOWN TMSG_MASK_APPLICATION + 1 53 #define TMSG_QUIT TMSG_MASK_APPLICATION + 2 54 #define TMSG_HIBERNATE TMSG_MASK_APPLICATION + 3 55 #define TMSG_SUSPEND TMSG_MASK_APPLICATION + 4 56 #define TMSG_RESTART TMSG_MASK_APPLICATION + 5 57 #define TMSG_RESET TMSG_MASK_APPLICATION + 6 58 #define TMSG_RESTARTAPP TMSG_MASK_APPLICATION + 7 59 #define TMSG_ACTIVATESCREENSAVER TMSG_MASK_APPLICATION + 8 60 #define TMSG_NETWORKMESSAGE TMSG_MASK_APPLICATION + 9 61 #define TMSG_RESETSCREENSAVER TMSG_MASK_APPLICATION + 10 62 #define TMSG_VOLUME_SHOW TMSG_MASK_APPLICATION + 11 63 #define TMSG_DISPLAY_SETUP TMSG_MASK_APPLICATION + 12 64 #define TMSG_DISPLAY_DESTROY TMSG_MASK_APPLICATION + 13 65 #define TMSG_SETVIDEORESOLUTION TMSG_MASK_APPLICATION + 14 66 #define TMSG_SWITCHTOFULLSCREEN TMSG_MASK_APPLICATION + 15 67 #define TMSG_MINIMIZE TMSG_MASK_APPLICATION + 16 68 #define TMSG_TOGGLEFULLSCREEN TMSG_MASK_APPLICATION + 17 69 #define TMSG_SETLANGUAGE TMSG_MASK_APPLICATION + 18 70 #define TMSG_RENDERER_FLUSH TMSG_MASK_APPLICATION + 19 71 #define TMSG_INHIBITIDLESHUTDOWN TMSG_MASK_APPLICATION + 20 72 #define TMSG_START_ANDROID_ACTIVITY TMSG_MASK_APPLICATION + 21 73 #define TMSG_EXECUTE_SCRIPT TMSG_MASK_APPLICATION + 22 74 #define TMSG_EXECUTE_BUILT_IN TMSG_MASK_APPLICATION + 23 75 #define TMSG_EXECUTE_OS TMSG_MASK_APPLICATION + 24 76 #define TMSG_PICTURE_SHOW TMSG_MASK_APPLICATION + 25 77 #define TMSG_PICTURE_SLIDESHOW TMSG_MASK_APPLICATION + 26 78 #define TMSG_LOADPROFILE TMSG_MASK_APPLICATION + 27 79 #define TMSG_VIDEORESIZE TMSG_MASK_APPLICATION + 28 80 #define TMSG_INHIBITSCREENSAVER TMSG_MASK_APPLICATION + 29 82 #define TMSG_SYSTEM_POWERDOWN TMSG_MASK_APPLICATION + 30 83 #define TMSG_RENDERER_PREINIT TMSG_MASK_APPLICATION + 31 84 #define TMSG_RENDERER_UNINIT TMSG_MASK_APPLICATION + 32 85 #define TMSG_EVENT TMSG_MASK_APPLICATION + 33 86 #define TMSG_MOVETOSCREEN TMSG_MASK_APPLICATION + 34 89 #define TMSG_UPDATE_PLAYER_ITEM TMSG_MASK_APPLICATION + 35 91 #define TMSG_GUI_INFOLABEL TMSG_MASK_GUIINFOMANAGER + 0 92 #define TMSG_GUI_INFOBOOL TMSG_MASK_GUIINFOMANAGER + 1 93 #define TMSG_UPDATE_CURRENT_ITEM TMSG_MASK_GUIINFOMANAGER + 2 95 #define TMSG_CECTOGGLESTATE TMSG_MASK_PERIPHERALS + 1 96 #define TMSG_CECACTIVATESOURCE TMSG_MASK_PERIPHERALS + 2 97 #define TMSG_CECSTANDBY TMSG_MASK_PERIPHERALS + 3 99 #define TMSG_GUI_DIALOG_OPEN TMSG_MASK_WINDOWMANAGER + 1 100 #define TMSG_GUI_ACTIVATE_WINDOW TMSG_MASK_WINDOWMANAGER + 2 101 #define TMSG_GUI_PYTHON_DIALOG TMSG_MASK_WINDOWMANAGER + 3 102 #define TMSG_GUI_WINDOW_CLOSE TMSG_MASK_WINDOWMANAGER + 4 103 #define TMSG_GUI_ACTION TMSG_MASK_WINDOWMANAGER + 5 104 #define TMSG_GUI_ADDON_DIALOG TMSG_MASK_WINDOWMANAGER + 6 105 #define TMSG_GUI_MESSAGE TMSG_MASK_WINDOWMANAGER + 7 127 #define TMSG_GUI_DIALOG_YESNO TMSG_MASK_WINDOWMANAGER + 8 128 #define TMSG_GUI_DIALOG_OK TMSG_MASK_WINDOWMANAGER + 9 137 #define TMSG_GUI_PREVIOUS_WINDOW TMSG_MASK_WINDOWMANAGER + 10 140 #define TMSG_CALLBACK 800 149 class IMessageTarget;
153 void (*callback)(
void *userptr);
250 int SendMsg(uint32_t messageId);
268 int SendMsg(uint32_t messageId,
int param1,
int param2 = -1,
void* payload =
nullptr);
287 int SendMsg(uint32_t messageId,
int param1,
int param2,
void* payload, std::string strParam);
307 int SendMsg(uint32_t messageId,
int param1,
int param2,
void* payload, std::string strParam, std::vector<std::string> params);
317 void PostMsg(uint32_t messageId);
328 void PostMsg(uint32_t messageId, int64_t param3);
342 void PostMsg(uint32_t messageId,
int param1,
int param2 = -1,
void* payload =
nullptr);
357 void PostMsg(uint32_t messageId,
int param1,
int param2,
void* payload, std::string strParam);
372 void PostMsg(uint32_t messageId,
int param1,
int param2,
void* payload, std::string strParam, std::vector<std::string> params);
377 void ProcessMessages();
384 void ProcessWindowMessages();
393 void SendGUIMessage(
const CGUIMessage &msg,
int windowID = WINDOW_INVALID,
bool waitResult=
false);
418 void Stop() { m_bStop =
true; }
421 bool IsProcessThread()
const;
430 std::queue<ThreadMessage*> m_vecMessages;
431 std::queue<ThreadMessage*> m_vecWindowMessages;
432 std::map<int, IMessageTarget*> m_mapTargets;
433 CCriticalSection m_critSection;
434 std::thread::id m_guiThreadId;
435 std::thread::id m_processThreadId;
436 bool m_bStop{
false };
A class wishing to receive messages should implement this and call.
Definition: IMessageTarget.h:23
void SetProcessThread(const std::thread::id thread)
Set the processing thread id to avoid messenger being dependent on CApplication to determine if marsh...
Definition: ApplicationMessenger.h:413
Definition: ThreadMessage.h:25
Definition: TestHelpers.h:60
void SetGUIThread(const std::thread::id thread)
Set the UI thread id to avoid messenger being dependent on CApplication to determine if marshaling is...
Definition: ApplicationMessenger.h:406
Definition: AudioDecoder.h:18
Definition: GUIMessage.h:365
Definition: ApplicationMessenger.h:151
This implements a simple message dispatcher/router for Kodi.
Definition: ApplicationMessenger.h:230