Added a RosterBroadcastHandler class for Broadcast() tests. Some minor extensions.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1537 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -251,6 +251,10 @@ LaunchContext::HandleMessage(BMessage *message)
|
|||||||
case MSG_MESSAGE_RECEIVED:
|
case MSG_MESSAGE_RECEIVED:
|
||||||
case MSG_QUIT_REQUESTED:
|
case MSG_QUIT_REQUESTED:
|
||||||
case MSG_READY_TO_RUN:
|
case MSG_READY_TO_RUN:
|
||||||
|
case MSG_1:
|
||||||
|
case MSG_2:
|
||||||
|
case MSG_3:
|
||||||
|
case MSG_REPLY:
|
||||||
{
|
{
|
||||||
BMessenger messenger = message->ReturnAddress();
|
BMessenger messenger = message->ReturnAddress();
|
||||||
// add the message to the respective team's message list
|
// add the message to the respective team's message list
|
||||||
@@ -258,9 +262,12 @@ LaunchContext::HandleMessage(BMessage *message)
|
|||||||
// remote team. The R5 registrar seems to send a B_REPLY message
|
// remote team. The R5 registrar seems to send a B_REPLY message
|
||||||
// sometimes.
|
// sometimes.
|
||||||
team_id sender = -1;
|
team_id sender = -1;
|
||||||
|
bool dontIgnore = false;
|
||||||
if (message->FindInt32("sender", &sender) != B_OK
|
if (message->FindInt32("sender", &sender) != B_OK
|
||||||
|| sender == be_app->Team()
|
|| sender == be_app->Team()
|
||||||
|| sender == messenger.Team()) {
|
|| sender == messenger.Team()
|
||||||
|
|| (message->FindBool("don't ignore", &dontIgnore) == B_OK)
|
||||||
|
&& dontIgnore) {
|
||||||
AppInfo *info = CreateAppInfo(messenger);
|
AppInfo *info = CreateAppInfo(messenger);
|
||||||
info->AddMessage(*message);
|
info->AddMessage(*message);
|
||||||
if (fTerminating)
|
if (fTerminating)
|
||||||
@@ -335,6 +342,11 @@ LaunchContext::CheckNextMessage(LaunchCaller &caller, team_id team,
|
|||||||
int32 &cookie, uint32 what)
|
int32 &cookie, uint32 what)
|
||||||
{
|
{
|
||||||
BMessage *message = NextMessageFrom(team, cookie);
|
BMessage *message = NextMessageFrom(team, cookie);
|
||||||
|
if (!message)
|
||||||
|
printf("LaunchContext::CheckNextMessage(): no more messages\n");
|
||||||
|
else if (message->what != what)
|
||||||
|
printf("LaunchContext::CheckNextMessage(): %.4s vs %.4s\n",
|
||||||
|
(char*)&message->what, (char*)&what);
|
||||||
return (message && message->what == what);
|
return (message && message->what == what);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,11 +727,17 @@ LaunchContext::NotifySleepers(uint32 messageCode)
|
|||||||
// constructor
|
// constructor
|
||||||
RosterLaunchApp::RosterLaunchApp(const char *signature)
|
RosterLaunchApp::RosterLaunchApp(const char *signature)
|
||||||
: BApplication(signature),
|
: BApplication(signature),
|
||||||
fMessageQueue(),
|
fLaunchContext(NULL),
|
||||||
fLaunchContext(NULL)
|
fHandler(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
RosterLaunchApp::~RosterLaunchApp()
|
||||||
|
{
|
||||||
|
SetHandler(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// MessageReceived
|
// MessageReceived
|
||||||
void
|
void
|
||||||
RosterLaunchApp::MessageReceived(BMessage *message)
|
RosterLaunchApp::MessageReceived(BMessage *message)
|
||||||
@@ -728,13 +746,6 @@ RosterLaunchApp::MessageReceived(BMessage *message)
|
|||||||
fLaunchContext->HandleMessage(message);
|
fLaunchContext->HandleMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageQueue
|
|
||||||
BMessageQueue&
|
|
||||||
RosterLaunchApp::MessageQueue()
|
|
||||||
{
|
|
||||||
return fMessageQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLaunchContext
|
// SetLaunchContext
|
||||||
void
|
void
|
||||||
RosterLaunchApp::SetLaunchContext(LaunchContext *context)
|
RosterLaunchApp::SetLaunchContext(LaunchContext *context)
|
||||||
@@ -749,3 +760,41 @@ RosterLaunchApp::GetLaunchContext() const
|
|||||||
return fLaunchContext;
|
return fLaunchContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetHandler
|
||||||
|
void
|
||||||
|
RosterLaunchApp::SetHandler(BHandler *handler)
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
if (fHandler) {
|
||||||
|
RemoveHandler(fHandler);
|
||||||
|
delete fHandler;
|
||||||
|
fHandler = NULL;
|
||||||
|
}
|
||||||
|
if (handler) {
|
||||||
|
fHandler = handler;
|
||||||
|
AddHandler(handler);
|
||||||
|
}
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// RosterBroadcastHandler
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
RosterBroadcastHandler::RosterBroadcastHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// MessageReceived
|
||||||
|
void
|
||||||
|
RosterBroadcastHandler::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
RosterLaunchApp *app = dynamic_cast<RosterLaunchApp*>(be_app);
|
||||||
|
if (LaunchContext *launchContext = app->GetLaunchContext()) {
|
||||||
|
message->AddInt32("original what", (int32)message->what);
|
||||||
|
message->what = MSG_REPLY;
|
||||||
|
launchContext->HandleMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,6 @@
|
|||||||
#include <MessageQueue.h>
|
#include <MessageQueue.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
enum {
|
|
||||||
MSG_1 = 'msg1',
|
|
||||||
MSG_2 = 'msg2',
|
|
||||||
MSG_3 = 'msg3',
|
|
||||||
};
|
|
||||||
|
|
||||||
// LaunchCaller
|
// LaunchCaller
|
||||||
class LaunchCaller {
|
class LaunchCaller {
|
||||||
public:
|
public:
|
||||||
@@ -138,17 +132,27 @@ private:
|
|||||||
class RosterLaunchApp : public BApplication {
|
class RosterLaunchApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
RosterLaunchApp(const char *signature);
|
RosterLaunchApp(const char *signature);
|
||||||
|
~RosterLaunchApp();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
BMessageQueue &MessageQueue();
|
|
||||||
|
|
||||||
void SetLaunchContext(LaunchContext *context);
|
void SetLaunchContext(LaunchContext *context);
|
||||||
LaunchContext *GetLaunchContext() const;
|
LaunchContext *GetLaunchContext() const;
|
||||||
|
|
||||||
|
BHandler *Handler() { return fHandler; }
|
||||||
|
void SetHandler(BHandler *handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMessageQueue fMessageQueue;
|
|
||||||
LaunchContext *fLaunchContext;
|
LaunchContext *fLaunchContext;
|
||||||
|
BHandler *fHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// RosterBroadcastHandler
|
||||||
|
class RosterBroadcastHandler : public BHandler {
|
||||||
|
public:
|
||||||
|
RosterBroadcastHandler();
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCH_TESTER_HELPER_H
|
#endif // LAUNCH_TESTER_HELPER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user