Skip to content

Commit

Permalink
ability to send guimessages via the application messenger
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Marshall committed Mar 17, 2012
1 parent 6e91544 commit 48749de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions xbmc/ApplicationMessenger.cpp
Expand Up @@ -707,6 +707,17 @@ case TMSG_POWERDOWN:
}
break;

case TMSG_GUI_MESSAGE:
{
if (pMsg->lpVoid)
{
CGUIMessage *message = (CGUIMessage *)pMsg->lpVoid;
g_windowManager.SendMessage(*message, pMsg->dwParam1);
delete message;
}
}
break;

case TMSG_GUI_INFOLABEL:
{
if (pMsg->lpVoid)
Expand Down Expand Up @@ -1139,6 +1150,14 @@ void CApplicationMessenger::SendAction(const CAction &action, int windowID, bool
SendMessage(tMsg, waitResult);
}

void CApplicationMessenger::SendGUIMessage(const CGUIMessage &message, int windowID, bool waitResult)
{
ThreadMessage tMsg = {TMSG_GUI_MESSAGE};
tMsg.dwParam1 = windowID == WINDOW_INVALID ? 0 : windowID;
tMsg.lpVoid = new CGUIMessage(message);
SendMessage(tMsg, waitResult);
}

vector<CStdString> CApplicationMessenger::GetInfoLabels(const vector<CStdString> &properties)
{
vector<CStdString> infoLabels;
Expand Down
11 changes: 11 additions & 0 deletions xbmc/ApplicationMessenger.h
Expand Up @@ -34,6 +34,7 @@ class CFileItem;
class CFileItemList;
class CGUIDialog;
class CGUIWindow;
class CGUIMessage;

// defines here
#define TMSG_DIALOG_DOMODAL 100
Expand Down Expand Up @@ -90,6 +91,7 @@ class CGUIWindow;
#define TMSG_GUI_ACTION 607
#define TMSG_GUI_INFOLABEL 608
#define TMSG_GUI_INFOBOOL 609
#define TMSG_GUI_MESSAGE 610

#define TMSG_CALLBACK 800

Expand Down Expand Up @@ -191,6 +193,15 @@ class CApplicationMessenger
void Close(CGUIWindow *window, bool forceClose, bool waitResult = true, int nextWindowID = 0, bool enableSound = true);
void ActivateWindow(int windowID, const std::vector<CStdString> &params, bool swappingWindows);
void SendAction(const CAction &action, int windowID = WINDOW_INVALID, bool waitResult=true);

/*! \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<CStdString> GetInfoLabels(const std::vector<CStdString> &properties);
std::vector<bool> GetInfoBooleans(const std::vector<CStdString> &properties);

Expand Down

0 comments on commit 48749de

Please sign in to comment.