Cleanup of the ServerApp parts I looked at. Removed reduntant comments
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12594 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+95
-135
@@ -1,5 +1,5 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2001-2002, Haiku, Inc.
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -88,58 +88,58 @@
|
|||||||
ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
||||||
team_id clientTeamID, int32 handlerID, char *signature)
|
team_id clientTeamID, int32 handlerID, char *signature)
|
||||||
:
|
:
|
||||||
|
fClientAppPort(sendport),
|
||||||
|
fMessagePort(rcvport),
|
||||||
|
fClientLooperPort(clientLooperPort),
|
||||||
|
fSignature(signature),
|
||||||
|
fMonitorThreadID(-1),
|
||||||
|
fClientTeamID(clientTeamID),
|
||||||
|
fMsgReader(NULL),
|
||||||
|
fMsgSender(NULL),
|
||||||
|
fSWindowList(NULL),
|
||||||
|
fBitmapList(NULL),
|
||||||
|
fPictureList(NULL),
|
||||||
|
fAppCursor(NULL),
|
||||||
|
fLockSem(-1),
|
||||||
|
fCursorHidden(false),
|
||||||
|
fIsActive(false),
|
||||||
|
//fHandlerToken(handlerID),
|
||||||
|
fSharedMem(NULL),
|
||||||
fQuitting(false)
|
fQuitting(false)
|
||||||
{
|
{
|
||||||
// it will be of *very* musch use in correct window order
|
if (fSignature == "")
|
||||||
fClientTeamID = clientTeamID;
|
fSignature = "application/x-vnd.NULL-application-signature";
|
||||||
|
|
||||||
// what to send a message to the client? Write a BMessage to this port.
|
|
||||||
fClientLooperPort = clientLooperPort;
|
|
||||||
|
|
||||||
// need to copy the fSignature because the message buffer
|
|
||||||
// owns the copy which we are passed as a parameter.
|
|
||||||
fSignature=(signature)?signature:"application/x-vnd.NULL-application-signature";
|
|
||||||
|
|
||||||
// token ID of the BApplication's BHandler object. Used for BMessage target specification
|
|
||||||
fHandlerToken=handlerID;
|
|
||||||
|
|
||||||
// fClientAppPort is the our BApplication's event port
|
|
||||||
fClientAppPort=sendport;
|
|
||||||
|
|
||||||
// fMessagePort is the port we receive messages from our BApplication
|
|
||||||
fMessagePort=rcvport;
|
|
||||||
|
|
||||||
fMsgReader = new LinkMsgReader(fMessagePort);
|
fMsgReader = new LinkMsgReader(fMessagePort);
|
||||||
fMsgSender = new LinkMsgSender(fClientAppPort);
|
fMsgSender = new LinkMsgSender(fClientAppPort);
|
||||||
|
|
||||||
fSWindowList=new BList(0);
|
fSWindowList = new BList();
|
||||||
fBitmapList=new BList(0);
|
fBitmapList = new BList();
|
||||||
fPictureList=new BList(0);
|
fPictureList = new BList();
|
||||||
fIsActive=false;
|
|
||||||
|
|
||||||
fSharedMem=new AreaPool;
|
fSharedMem = new AreaPool;
|
||||||
|
|
||||||
// although this isn't pretty, ATM we have only one RootLayer.
|
// although this isn't pretty, ATM we have only one RootLayer.
|
||||||
// there should be a way that this ServerApp be attached to a particular
|
// there should be a way that this ServerApp be attached to a particular
|
||||||
// RootLayer to know which RootLayer's cursor to modify.
|
// RootLayer to know which RootLayer's cursor to modify.
|
||||||
ServerCursor *defaultc=desktop->ActiveRootLayer()->GetCursorManager().GetCursor(B_CURSOR_DEFAULT);
|
ServerCursor *defaultCursor =
|
||||||
|
desktop->ActiveRootLayer()->GetCursorManager().GetCursor(B_CURSOR_DEFAULT);
|
||||||
|
|
||||||
fAppCursor=(defaultc)?new ServerCursor(defaultc):NULL;
|
if (defaultCursor) {
|
||||||
fAppCursor->SetOwningTeam(fClientTeamID);
|
fAppCursor = new ServerCursor(defaultCursor);
|
||||||
fLockSem=create_sem(1,"ServerApp sem");
|
fAppCursor->SetOwningTeam(fClientTeamID);
|
||||||
|
}
|
||||||
|
|
||||||
// Does this even belong here any more? --DW
|
fLockSem = create_sem(1, "ServerApp sem");
|
||||||
// _driver=desktop->GetDisplayDriver();
|
|
||||||
|
|
||||||
fCursorHidden=false;
|
|
||||||
|
|
||||||
Run();
|
Run();
|
||||||
|
|
||||||
STRACE(("ServerApp %s:\n",fSignature.String()));
|
STRACE(("ServerApp %s:\n", fSignature.String()));
|
||||||
STRACE(("\tBApp port: %ld\n",fClientAppPort));
|
STRACE(("\tBApp port: %ld\n", fClientAppPort));
|
||||||
STRACE(("\tReceiver port: %ld\n",fMessagePort));
|
STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Does all necessary teardown for application
|
//! Does all necessary teardown for application
|
||||||
ServerApp::~ServerApp(void)
|
ServerApp::~ServerApp(void)
|
||||||
{
|
{
|
||||||
@@ -181,11 +181,8 @@ ServerApp::~ServerApp(void)
|
|||||||
// in the MonitorApp thread never returns. Cleanup.
|
// in the MonitorApp thread never returns. Cleanup.
|
||||||
delete_port(fMessagePort);
|
delete_port(fMessagePort);
|
||||||
|
|
||||||
// Kill the monitor thread if it exists
|
|
||||||
thread_info info;
|
|
||||||
status_t dummyStatus;
|
status_t dummyStatus;
|
||||||
if (get_thread_info(fMonitorThreadID, &info) == B_OK)
|
wait_for_thread(fMonitorThreadID, &dummyStatus);
|
||||||
wait_for_thread(fMonitorThreadID, &dummyStatus);
|
|
||||||
|
|
||||||
delete fSharedMem;
|
delete fSharedMem;
|
||||||
|
|
||||||
@@ -196,15 +193,17 @@ ServerApp::~ServerApp(void)
|
|||||||
\brief Starts the ServerApp monitoring for messages
|
\brief Starts the ServerApp monitoring for messages
|
||||||
\return false if the application couldn't start, true if everything went OK.
|
\return false if the application couldn't start, true if everything went OK.
|
||||||
*/
|
*/
|
||||||
bool ServerApp::Run(void)
|
bool
|
||||||
|
ServerApp::Run(void)
|
||||||
{
|
{
|
||||||
// Unlike a BApplication, a ServerApp is *supposed* to return immediately
|
// Unlike a BApplication, a ServerApp is *supposed* to return immediately
|
||||||
// when its Run() function is called.
|
// when its Run() function is called.
|
||||||
fMonitorThreadID=spawn_thread(MonitorApp,fSignature.String(),B_NORMAL_PRIORITY,this);
|
fMonitorThreadID = spawn_thread(MonitorApp, fSignature.String(), B_NORMAL_PRIORITY, this);
|
||||||
if(fMonitorThreadID==B_NO_MORE_THREADS || fMonitorThreadID==B_NO_MEMORY)
|
if (fMonitorThreadID < B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
resume_thread(fMonitorThreadID);
|
resume_thread(fMonitorThreadID);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,20 +220,19 @@ bool ServerApp::Run(void)
|
|||||||
ports will be invalid. Thus, if get_port_info returns an error, we
|
ports will be invalid. Thus, if get_port_info returns an error, we
|
||||||
tell the app_server to delete the respective ServerApp.
|
tell the app_server to delete the respective ServerApp.
|
||||||
*/
|
*/
|
||||||
bool ServerApp::PingTarget(void)
|
bool
|
||||||
|
ServerApp::PingTarget(void)
|
||||||
{
|
{
|
||||||
team_info tinfo;
|
team_info tinfo;
|
||||||
if(get_team_info(fClientTeamID,&tinfo)==B_BAD_TEAM_ID)
|
if (get_team_info(fClientTeamID,&tinfo) == B_BAD_TEAM_ID) {
|
||||||
{
|
port_id serverport = find_port(SERVER_PORT_NAME);
|
||||||
port_id serverport=find_port(SERVER_PORT_NAME);
|
if (serverport == B_NAME_NOT_FOUND) {
|
||||||
if(serverport==B_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String());
|
printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fMsgSender->SetPort(serverport);
|
fMsgSender->SetPort(serverport);
|
||||||
fMsgSender->StartMessage(AS_DELETE_APP);
|
fMsgSender->StartMessage(AS_DELETE_APP);
|
||||||
fMsgSender->Attach(&fMonitorThreadID,sizeof(thread_id));
|
fMsgSender->Attach(&fMonitorThreadID, sizeof(thread_id));
|
||||||
fMsgSender->Flush();
|
fMsgSender->Flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -245,7 +243,8 @@ bool ServerApp::PingTarget(void)
|
|||||||
\brief Send a message to the ServerApp with no attachments
|
\brief Send a message to the ServerApp with no attachments
|
||||||
\param code ID code of the message to post
|
\param code ID code of the message to post
|
||||||
*/
|
*/
|
||||||
void ServerApp::PostMessage(int32 code)
|
void
|
||||||
|
ServerApp::PostMessage(int32 code)
|
||||||
{
|
{
|
||||||
BPortLink link(fMessagePort);
|
BPortLink link(fMessagePort);
|
||||||
link.StartMessage(code);
|
link.StartMessage(code);
|
||||||
@@ -256,13 +255,11 @@ void ServerApp::PostMessage(int32 code)
|
|||||||
\brief Send a message to the ServerApp's BApplication
|
\brief Send a message to the ServerApp's BApplication
|
||||||
\param msg The message to send
|
\param msg The message to send
|
||||||
*/
|
*/
|
||||||
void ServerApp::SendMessageToClient(const BMessage *msg) const
|
void
|
||||||
|
ServerApp::SendMessageToClient(const BMessage *msg) const
|
||||||
{
|
{
|
||||||
ssize_t size;
|
ssize_t size = msg->FlattenedSize();
|
||||||
char *buffer;
|
char *buffer = new char[size];
|
||||||
|
|
||||||
size=msg->FlattenedSize();
|
|
||||||
buffer=new char[size];
|
|
||||||
|
|
||||||
if (msg->Flatten(buffer, size) == B_OK)
|
if (msg->Flatten(buffer, size) == B_OK)
|
||||||
write_port(fClientLooperPort, msg->what, buffer, size);
|
write_port(fClientLooperPort, msg->what, buffer, size);
|
||||||
@@ -279,19 +276,21 @@ void ServerApp::SendMessageToClient(const BMessage *msg) const
|
|||||||
This changes an internal flag and also sets the current cursor to the one specified by
|
This changes an internal flag and also sets the current cursor to the one specified by
|
||||||
the application
|
the application
|
||||||
*/
|
*/
|
||||||
void ServerApp::Activate(bool value)
|
void
|
||||||
|
ServerApp::Activate(bool value)
|
||||||
{
|
{
|
||||||
fIsActive=value;
|
fIsActive = value;
|
||||||
SetAppCursor();
|
SetAppCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the cursor to the application cursor, if any.
|
//! Sets the cursor to the application cursor, if any.
|
||||||
void ServerApp::SetAppCursor(void)
|
void
|
||||||
|
ServerApp::SetAppCursor(void)
|
||||||
{
|
{
|
||||||
// although this isn't pretty, ATM we have only one RootLayer.
|
// although this isn't pretty, ATM we have only one RootLayer.
|
||||||
// there should be a way that this ServerApp be attached to a particular
|
// there should be a way that this ServerApp be attached to a particular
|
||||||
// RootLayer to know which RootLayer's cursor to modify.
|
// RootLayer to know which RootLayer's cursor to modify.
|
||||||
if(fAppCursor)
|
if (fAppCursor)
|
||||||
desktop->ActiveRootLayer()->GetDisplayDriver()->SetCursor(fAppCursor);
|
desktop->ActiveRootLayer()->GetDisplayDriver()->SetCursor(fAppCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +299,8 @@ void ServerApp::SetAppCursor(void)
|
|||||||
\param data Pointer to the thread's ServerApp object
|
\param data Pointer to the thread's ServerApp object
|
||||||
\return Throwaway value - always 0
|
\return Throwaway value - always 0
|
||||||
*/
|
*/
|
||||||
int32 ServerApp::MonitorApp(void *data)
|
int32
|
||||||
|
ServerApp::MonitorApp(void *data)
|
||||||
{
|
{
|
||||||
// Message-dispatching loop for the ServerApp
|
// Message-dispatching loop for the ServerApp
|
||||||
|
|
||||||
@@ -310,18 +310,15 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
int32 code;
|
int32 code;
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
|
|
||||||
while(!app->fQuitting)
|
while(!app->fQuitting) {
|
||||||
{
|
|
||||||
STRACE(("info: ServerApp::MonitorApp listening on port %ld.\n", app->fMessagePort));
|
STRACE(("info: ServerApp::MonitorApp listening on port %ld.\n", app->fMessagePort));
|
||||||
// err = msgqueue.GetNextReply(&code);
|
|
||||||
err = msgqueue.GetNextMessage(&code);
|
err = msgqueue.GetNextMessage(&code);
|
||||||
if (err < B_OK) {
|
if (err < B_OK) {
|
||||||
STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err)));
|
STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(code)
|
switch(code) {
|
||||||
{
|
|
||||||
case AS_CREATE_WINDOW:
|
case AS_CREATE_WINDOW:
|
||||||
{
|
{
|
||||||
// Create the ServerWindow to node monitor a new OBWindow
|
// Create the ServerWindow to node monitor a new OBWindow
|
||||||
@@ -366,8 +363,7 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
app->fSignature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
app->fSignature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
||||||
|
|
||||||
if (title)
|
free(title);
|
||||||
free(title);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -395,10 +391,8 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
|
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
|
||||||
// Our BApplication sent us this message when it quit.
|
// Our BApplication sent us this message when it quit.
|
||||||
// We need to ask the app_server to delete ourself.
|
// We need to ask the app_server to delete ourself.
|
||||||
app->fQuitting = true;
|
|
||||||
|
|
||||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
port_id serverport = find_port(SERVER_PORT_NAME);
|
||||||
if(serverport == B_NAME_NOT_FOUND){
|
if (serverport == B_NAME_NOT_FOUND){
|
||||||
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String());
|
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -418,7 +412,6 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
|
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
// clean exit.
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,13 +424,13 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
All attachments are placed in the buffer via a PortLink, so it will be a
|
All attachments are placed in the buffer via a PortLink, so it will be a
|
||||||
matter of casting and incrementing an index variable to access them.
|
matter of casting and incrementing an index variable to access them.
|
||||||
*/
|
*/
|
||||||
void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
void
|
||||||
|
ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
||||||
{
|
{
|
||||||
LayerData ld;
|
LayerData ld;
|
||||||
BPortLink replylink;
|
BPortLink replylink;
|
||||||
|
|
||||||
switch(code)
|
switch(code) {
|
||||||
{
|
|
||||||
case AS_UPDATE_COLORS:
|
case AS_UPDATE_COLORS:
|
||||||
{
|
{
|
||||||
// NOTE: R2: Eventually we will have windows which will notify their children of changes in
|
// NOTE: R2: Eventually we will have windows which will notify their children of changes in
|
||||||
@@ -493,13 +486,13 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
msg.Read<size_t>(&msgsize);
|
msg.Read<size_t>(&msgsize);
|
||||||
|
|
||||||
// Part sanity check, part get base pointer :)
|
// Part sanity check, part get base pointer :)
|
||||||
if(get_area_info(area,&ai)!=B_OK)
|
if (get_area_info(area, &ai) < B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
msgpointer=(int8*)ai.address + offset;
|
msgpointer = (int8*)ai.address + offset;
|
||||||
|
|
||||||
RAMLinkMsgReader mlink(msgpointer);
|
RAMLinkMsgReader mlink(msgpointer);
|
||||||
DispatchMessage(mlink.Code(),mlink);
|
DispatchMessage(mlink.Code(), mlink);
|
||||||
|
|
||||||
// This is a very special case in the sense that when ServerMemIO is used for this
|
// This is a very special case in the sense that when ServerMemIO is used for this
|
||||||
// purpose, it will be set to NOT automatically free the memory which it had
|
// purpose, it will be set to NOT automatically free the memory which it had
|
||||||
@@ -528,27 +521,26 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
|
|
||||||
// TODO: I wonder if ACQUIRE_SERVERMEM should have a minimum size requirement?
|
// TODO: I wonder if ACQUIRE_SERVERMEM should have a minimum size requirement?
|
||||||
|
|
||||||
void *sharedmem=fSharedMem->GetBuffer(memsize);
|
void *sharedmem = fSharedMem->GetBuffer(memsize);
|
||||||
|
|
||||||
replylink.SetSendPort(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
if(memsize<1 || sharedmem==NULL)
|
if (memsize < 1 || sharedmem == NULL) {
|
||||||
{
|
|
||||||
replylink.StartMessage(SERVER_FALSE);
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
area_id owningArea=area_for(sharedmem);
|
area_id owningArea = area_for(sharedmem);
|
||||||
area_info ai;
|
area_info ai;
|
||||||
|
|
||||||
if(owningArea==B_ERROR || get_area_info(owningArea,&ai)!=B_OK)
|
if (owningArea == B_ERROR || get_area_info(owningArea, &ai) < B_OK)
|
||||||
{
|
{
|
||||||
replylink.StartMessage(SERVER_FALSE);
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 areaoffset=((int32*)sharedmem)-((int32*)ai.address);
|
int32 areaoffset = ((int32*)sharedmem) - ((int32*)ai.address);
|
||||||
STRACE(("Successfully allocated shared memory of size %ld\n",memsize));
|
STRACE(("Successfully allocated shared memory of size %ld\n",memsize));
|
||||||
|
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
@@ -566,18 +558,17 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
// 2) int32 area offset
|
// 2) int32 area offset
|
||||||
|
|
||||||
area_id owningArea;
|
area_id owningArea;
|
||||||
area_info ai;
|
|
||||||
int32 areaoffset;
|
int32 areaoffset;
|
||||||
void *sharedmem;
|
|
||||||
|
|
||||||
msg.Read<area_id>(&owningArea);
|
msg.Read<area_id>(&owningArea);
|
||||||
msg.Read<int32>(&areaoffset);
|
msg.Read<int32>(&areaoffset);
|
||||||
|
|
||||||
if(owningArea<0 || get_area_info(owningArea,&ai)!=B_OK)
|
area_info areaInfo;
|
||||||
|
if (owningArea < 0 || get_area_info(owningArea, &areaInfo) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
STRACE(("Successfully freed shared memory\n"));
|
STRACE(("Successfully freed shared memory\n"));
|
||||||
sharedmem=((int32*)ai.address)+areaoffset;
|
void *sharedmem = ((int32*)areaInfo.address) + areaoffset;
|
||||||
|
|
||||||
fSharedMem->ReleaseBuffer(sharedmem);
|
fSharedMem->ReleaseBuffer(sharedmem);
|
||||||
|
|
||||||
@@ -589,9 +580,9 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
|
|
||||||
ServerWindow *win;
|
ServerWindow *win;
|
||||||
|
|
||||||
for(int32 i=0; i<fSWindowList->CountItems(); i++)
|
for(int32 i = 0; i < fSWindowList->CountItems(); i++)
|
||||||
{
|
{
|
||||||
win=(ServerWindow*)fSWindowList->ItemAt(i);
|
win = (ServerWindow*)fSWindowList->ItemAt(i);
|
||||||
win->Lock();
|
win->Lock();
|
||||||
win->fWinBorder->UpdateDecorator();
|
win->fWinBorder->UpdateDecorator();
|
||||||
win->Unlock();
|
win->Unlock();
|
||||||
@@ -631,22 +622,19 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
msg.Read<screen_id>(&s);
|
msg.Read<screen_id>(&s);
|
||||||
msg.Read<int32>(&replyport);
|
msg.Read<int32>(&replyport);
|
||||||
|
|
||||||
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
|
ServerBitmap *sbmp = bitmapmanager->CreateBitmap(r, cs, f ,bpr, s);
|
||||||
|
|
||||||
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
|
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
fSignature.String(),r.left,r.top,r.right,r.bottom));
|
fSignature.String(),r.left,r.top,r.right,r.bottom));
|
||||||
|
|
||||||
replylink.SetSendPort(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
if(sbmp)
|
if(sbmp) {
|
||||||
{
|
|
||||||
fBitmapList->AddItem(sbmp);
|
fBitmapList->AddItem(sbmp);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Attach<int32>(sbmp->Token());
|
replylink.Attach<int32>(sbmp->Token());
|
||||||
replylink.Attach<int32>(sbmp->Area());
|
replylink.Attach<int32>(sbmp->Area());
|
||||||
replylink.Attach<int32>(sbmp->AreaOffset());
|
replylink.Attach<int32>(sbmp->AreaOffset());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// alternatively, if something went wrong, we reply with SERVER_FALSE
|
// alternatively, if something went wrong, we reply with SERVER_FALSE
|
||||||
replylink.StartMessage(SERVER_FALSE);
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
}
|
}
|
||||||
@@ -673,16 +661,15 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
|
|
||||||
ServerBitmap *sbmp=FindBitmap(bmp_id);
|
ServerBitmap *sbmp=FindBitmap(bmp_id);
|
||||||
replylink.SetSendPort(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
if(sbmp)
|
if(sbmp) {
|
||||||
{
|
|
||||||
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id));
|
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id));
|
||||||
|
|
||||||
fBitmapList->RemoveItem(sbmp);
|
fBitmapList->RemoveItem(sbmp);
|
||||||
bitmapmanager->DeleteBitmap(sbmp);
|
bitmapmanager->DeleteBitmap(sbmp);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
|
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -716,34 +703,6 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_SET_SCREEN_MODE:
|
|
||||||
{
|
|
||||||
STRACE(("ServerApp %s: Set Screen Mode\n",fSignature.String()));
|
|
||||||
|
|
||||||
// Attached data
|
|
||||||
// 1) int32 workspace #
|
|
||||||
// 2) uint32 screen mode
|
|
||||||
// 3) bool make default
|
|
||||||
int32 index;
|
|
||||||
uint32 mode;
|
|
||||||
bool stick;
|
|
||||||
msg.Read<int32>(&index);
|
|
||||||
msg.Read<uint32>(&mode);
|
|
||||||
msg.Read<bool>(&stick);
|
|
||||||
|
|
||||||
RootLayer *root=desktop->ActiveRootLayer();
|
|
||||||
Workspace *workspace=root->WorkspaceAt(index);
|
|
||||||
|
|
||||||
if(!workspace)
|
|
||||||
{
|
|
||||||
// apparently out of range or something, so we do nothing. :)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Add mode-setting code to Workspace class
|
|
||||||
//workspace->SetMode(mode,stick);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AS_ACTIVATE_WORKSPACE:
|
case AS_ACTIVATE_WORKSPACE:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: Activate Workspace UNIMPLEMETED\n",fSignature.String()));
|
STRACE(("ServerApp %s: Activate Workspace UNIMPLEMETED\n",fSignature.String()));
|
||||||
@@ -1951,15 +1910,16 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
\param token ID token of the bitmap to find
|
\param token ID token of the bitmap to find
|
||||||
\return The bitmap having that ID or NULL if not found
|
\return The bitmap having that ID or NULL if not found
|
||||||
*/
|
*/
|
||||||
ServerBitmap *ServerApp::FindBitmap(int32 token)
|
ServerBitmap *
|
||||||
|
ServerApp::FindBitmap(int32 token) const
|
||||||
{
|
{
|
||||||
ServerBitmap *temp;
|
ServerBitmap *bitmap;
|
||||||
for(int32 i=0; i<fBitmapList->CountItems();i++)
|
for (int32 i = 0; i < fBitmapList->CountItems(); i++) {
|
||||||
{
|
bitmap = static_cast<ServerBitmap *>(fBitmapList->ItemAt(i));
|
||||||
temp=(ServerBitmap*)fBitmapList->ItemAt(i);
|
if (bitmap && bitmap->Token() == token)
|
||||||
if(temp && temp->Token()==token)
|
return bitmap;
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-11
@@ -1,5 +1,5 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2001-2002, Haiku, Inc.
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -51,27 +51,30 @@ class ServerApp {
|
|||||||
public:
|
public:
|
||||||
ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
||||||
team_id clientTeamID, int32 handlerID, char *signature);
|
team_id clientTeamID, int32 handlerID, char *signature);
|
||||||
virtual ~ServerApp(void);
|
virtual ~ServerApp(void);
|
||||||
|
|
||||||
bool Run(void);
|
bool Run(void);
|
||||||
|
/*
|
||||||
|
TODO: These aren't even implemented...
|
||||||
void Lock(void);
|
void Lock(void);
|
||||||
void Unlock(void);
|
void Unlock(void);
|
||||||
bool IsLocked(void);
|
bool IsLocked(void);
|
||||||
|
*/
|
||||||
/*!
|
/*!
|
||||||
\brief Determines whether the application is the active one
|
\brief Determines whether the application is the active one
|
||||||
\return true if active, false if not.
|
\return true if active, false if not.
|
||||||
*/
|
*/
|
||||||
bool IsActive(void) const { return fIsActive; }
|
bool IsActive(void) const { return fIsActive; }
|
||||||
|
|
||||||
void Activate(bool value);
|
void Activate(bool value);
|
||||||
|
|
||||||
bool PingTarget(void);
|
bool PingTarget(void);
|
||||||
|
|
||||||
void PostMessage(int32 code);
|
void PostMessage(int32 code);
|
||||||
|
|
||||||
void SendMessageToClient( const BMessage* msg ) const;
|
void SendMessageToClient( const BMessage* msg ) const;
|
||||||
|
|
||||||
void SetAppCursor(void);
|
void SetAppCursor(void);
|
||||||
ServerBitmap *FindBitmap(int32 token);
|
|
||||||
|
ServerBitmap *FindBitmap(int32 token) const;
|
||||||
|
|
||||||
team_id ClientTeamID() const;
|
team_id ClientTeamID() const;
|
||||||
thread_id MonitorThreadID() const;
|
thread_id MonitorThreadID() const;
|
||||||
@@ -87,15 +90,18 @@ private:
|
|||||||
|
|
||||||
static int32 MonitorApp(void *data);
|
static int32 MonitorApp(void *data);
|
||||||
|
|
||||||
port_id fClientAppPort,
|
// our BApplication's event port
|
||||||
fMessagePort,
|
port_id fClientAppPort;
|
||||||
|
// port we receive messages from our BApplication
|
||||||
|
port_id fMessagePort;
|
||||||
// TODO: find out why there is both the app port and the looper port. Do
|
// TODO: find out why there is both the app port and the looper port. Do
|
||||||
// we really need both?
|
// we really need both?
|
||||||
fClientLooperPort;
|
// To send a message to the client, write a BMessage to this port
|
||||||
|
port_id fClientLooperPort;
|
||||||
|
|
||||||
BString fSignature;
|
BString fSignature;
|
||||||
thread_id fMonitorThreadID;
|
|
||||||
|
|
||||||
|
thread_id fMonitorThreadID;
|
||||||
team_id fClientTeamID;
|
team_id fClientTeamID;
|
||||||
|
|
||||||
LinkMsgReader *fMsgReader;
|
LinkMsgReader *fMsgReader;
|
||||||
@@ -104,11 +110,19 @@ private:
|
|||||||
BList *fSWindowList,
|
BList *fSWindowList,
|
||||||
*fBitmapList,
|
*fBitmapList,
|
||||||
*fPictureList;
|
*fPictureList;
|
||||||
|
|
||||||
ServerCursor *fAppCursor;
|
ServerCursor *fAppCursor;
|
||||||
|
|
||||||
sem_id fLockSem;
|
sem_id fLockSem;
|
||||||
|
|
||||||
bool fCursorHidden;
|
bool fCursorHidden;
|
||||||
bool fIsActive;
|
bool fIsActive;
|
||||||
int32 fHandlerToken;
|
|
||||||
|
// token ID of the BApplication's BHandler object.
|
||||||
|
// Used for BMessage target specification
|
||||||
|
// TODO: Is it still needed ? We aren't using it.
|
||||||
|
//int32 fHandlerToken;
|
||||||
|
|
||||||
AreaPool *fSharedMem;
|
AreaPool *fSharedMem;
|
||||||
|
|
||||||
bool fQuitting;
|
bool fQuitting;
|
||||||
|
|||||||
Reference in New Issue
Block a user