BHandler::MessageReceived handles also B_GET_SUPPORTED_SUITES as it should, and prints the message to the stream if it doesn't understand it. Restyled the function to follow our guidelines (more or less).

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11411 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2005-02-18 11:34:52 +00:00
parent 997aa9ac18
commit 2f197f3340
+42 -47
View File
@@ -120,6 +120,7 @@
// Standard Includes ----------------------------------------------------------- // Standard Includes -----------------------------------------------------------
#include <algorithm> #include <algorithm>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <map> #include <map>
@@ -162,7 +163,7 @@ static property_info gHandlerPropInfo[] =
// extra data // extra data
0, 0,
// types // types
{ }, { 0 },
// ctypes (compound_type) // ctypes (compound_type)
{ {
// ctypes[0] // ctypes[0]
@@ -191,7 +192,7 @@ static property_info gHandlerPropInfo[] =
} }
}, },
// reserved // reserved
{} { 0 }
}, },
{ {
"Messenger", "Messenger",
@@ -199,8 +200,8 @@ static property_info gHandlerPropInfo[] =
{ B_DIRECT_SPECIFIER }, { B_DIRECT_SPECIFIER },
NULL, 0, NULL, 0,
{ B_MESSENGER_TYPE }, { B_MESSENGER_TYPE },
{}, { 0 },
{} { 0 }
}, },
{ {
"InternalName", "InternalName",
@@ -208,10 +209,10 @@ static property_info gHandlerPropInfo[] =
{ B_DIRECT_SPECIFIER }, { B_DIRECT_SPECIFIER },
NULL, 0, NULL, 0,
{ B_STRING_TYPE }, { B_STRING_TYPE },
{}, { 0 },
{} { 0 }
}, },
{} { 0 }
}; };
bool FilterDeleter(void* filter); bool FilterDeleter(void* filter);
@@ -292,62 +293,56 @@ status_t BHandler::Archive(BMessage* data, bool deep) const
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BHandler::MessageReceived(BMessage* message) void BHandler::MessageReceived(BMessage* message)
{ {
switch (message->what) BMessage reply(B_REPLY);
{
switch (message->what) {
case B_GET_PROPERTY: case B_GET_PROPERTY:
{ {
BMessage Specifier; int32 cur;
BMessage specifier;
int32 form; int32 form;
const char *prop; const char *prop;
int32 cur;
status_t err;
err = message->GetCurrentSpecifier(&cur, &Specifier, &form, &prop); status_t err = message->GetCurrentSpecifier(&cur, &specifier, &form, &prop);
if (!err) if (err == B_OK) {
{ if (strcmp(prop, "Suites") == 0) {
BMessage Reply(B_REPLY); if (GetSupportedSuites(&reply) == B_OK
if (strcmp(prop, "Suites") == 0) && reply.AddInt32("error", B_OK) == B_OK)
{ message->SendReply(&reply);
if (GetSupportedSuites(&Reply) == B_OK &&
Reply.AddInt32("error", B_OK) == B_OK)
{
message->SendReply(&Reply);
}
}
else if (strcmp(prop, "Messenger") == 0)
{
if (Reply.AddMessenger("result", this) == B_OK &&
Reply.AddInt32("error", B_OK) == B_OK)
{ } else if (strcmp(prop, "Messenger") == 0) {
message->SendReply(&Reply); if (reply.AddMessenger("result", this) == B_OK
} && reply.AddInt32("error", B_OK) == B_OK)
} message->SendReply(&reply);
else if (strcmp(prop, "InternalName") == 0)
{
if (Reply.AddString("result", Name()) == B_OK &&
Reply.AddInt32("error", B_OK) == B_OK)
{ } else if (strcmp(prop, "InternalName") == 0) {
message->SendReply(&Reply); if (reply.AddString("result", Name()) == B_OK
} && reply.AddInt32("error", B_OK) == B_OK)
}
else message->SendReply(&reply);
{
} else {
// Should never be here // Should never be here
debugger("We are *not* supposed to be here"); debugger("BHandler::MessageReceived(): We are *not* supposed to be here");
} }
} }
break;
}
case B_GET_SUPPORTED_SUITES:
{
reply.AddInt32("error", GetSupportedSuites(&reply));
message->SendReply(&reply);
break; break;
} }
default: default:
if (fNextHandler) if (fNextHandler)
{
fNextHandler->MessageReceived(message); fNextHandler->MessageReceived(message);
} else {
else printf("BHandler::MessageReceived(): B_MESSAGE_NOT_UNDERSTOOD");
{ message->PrintToStream();
message->SendReply(B_MESSAGE_NOT_UNDERSTOOD); message->SendReply(B_MESSAGE_NOT_UNDERSTOOD);
} }
break; break;