Conversion to BSession messaging

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4931 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-10-03 00:37:56 +00:00
parent 5e69d02601
commit 582e2dddd5

View File

@ -50,7 +50,7 @@
// Project Includes ------------------------------------------------------------ // Project Includes ------------------------------------------------------------
#include <LooperList.h> #include <LooperList.h>
#include <ObjectLocker.h> #include <ObjectLocker.h>
#include <PortLink.h> #include <AppServerLink.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
// Local Includes -------------------------------------------------------------- // Local Includes --------------------------------------------------------------
@ -374,36 +374,35 @@ BHandler* BApplication::ResolveSpecifier(BMessage* msg, int32 index,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::ShowCursor() void BApplication::ShowCursor()
{ {
// Because we're just sending an opcode, we can skip the PortLink and simply // Because we're just sending an opcode, we can skip the BSession and fake the protocol
// call write_port top the server communications port. int32 foo=AS_SHOW_CURSOR;
write_port(fServerTo,AS_SHOW_CURSOR,NULL,0); write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::HideCursor() void BApplication::HideCursor()
{ {
// Because we're just sending an opcode, we can skip the PortLink and simply // Because we're just sending an opcode, we can skip the BSession and fake the protocol
// call write_port top the server communications port. int32 foo=AS_HIDE_CURSOR;
write_port(fServerTo,AS_HIDE_CURSOR,NULL,0); write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::ObscureCursor() void BApplication::ObscureCursor()
{ {
PortLink *link=new PortLink(fServerTo); // Because we're just sending an opcode, we can skip the BSession and fake the protocol
link->SetOpCode(AS_OBSCURE_CURSOR); int32 foo=AS_OBSCURE_CURSOR;
link->Flush(); write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
delete link;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool BApplication::IsCursorHidden() const bool BApplication::IsCursorHidden() const
{ {
PortLink::ReplyData data; int32 replycode;
PortLink *link=new PortLink(fServerTo); BPrivate::BAppServerLink link;
link->SetOpCode(AS_QUERY_CURSOR_HIDDEN); link.WriteInt32(AS_QUERY_CURSOR_HIDDEN);
link->FlushWithReply(&data); link.WriteInt32(link.GetRecvPort());
delete link; link.Sync();
link.ReadInt32(&replycode);
return (data.code==SERVER_TRUE)?true:false; return (replycode==SERVER_TRUE)?true:false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::SetCursor(const void* cursor) void BApplication::SetCursor(const void* cursor)
@ -417,13 +416,19 @@ void BApplication::SetCursor(const void* cursor)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::SetCursor(const BCursor* cursor, bool sync) void BApplication::SetCursor(const BCursor* cursor, bool sync)
{ {
// TODO: add sync support - working on updating FlushWithReply --DW BPrivate::BAppServerLink link;
PortLink *link=new PortLink(fServerTo); link.WriteInt32(AS_SET_CURSOR_BCURSOR);
link->SetOpCode(AS_SET_CURSOR_BCURSOR); link.WriteBool(sync);
link->Attach<bool>(sync); link.WriteInt32(cursor->m_serverToken);
link->Attach<int32>(cursor->m_serverToken); if(sync)
link->Flush(); link.WriteInt32(link.GetRecvPort());
delete link; link.Sync();
if(sync)
{
int32 foo;
link.ReadInt32(&foo);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int32 BApplication::CountWindows() const int32 BApplication::CountWindows() const
@ -753,24 +758,23 @@ void BApplication::InitData(const char* signature, status_t* error)
// Attach data: // Attach data:
// 1) port_id - receiver port of a regular app // 1) port_id - receiver port of a regular app
// 2) char * - signature of the regular app // 2) char * - signature of the regular app
PortLink::ReplyData replydata; port_id srcv=create_port(100,"BApp reply port");
BSession session(srcv,fServerTo);
session.WriteInt32(AS_CREATE_APP);
session.WriteInt32(fServerTo);
session.WriteInt32(_get_object_token_(this));
session.WriteData(signature,strlen(signature)+1);
session.Sync();
PortLink *link=new PortLink(fServerFrom); port_id serverapp_port;
link->SetOpCode(AS_CREATE_APP); session.ReadInt32(&serverapp_port);
link->Attach<int32>((int32)fServerTo);
link->Attach<int32>(_get_object_token_(this)); // Reply code: AS_CREATE_APP
link->Attach((char*)signature,strlen(signature)+1); // Reply data:
status_t replyerr=link->FlushWithReply(&replydata); // 1) port_id server-side application port (fServerFrom value)
if(replyerr==B_OK) fServerFrom=serverapp_port;
{
// Reply code: AS_CREATE_APP delete_port(srcv);
// Reply data:
// 1) port_id server-side application port (fServerFrom value)
fServerFrom=*((port_id*)replydata.buffer);
}
else
fInitError=replyerr;
delete link;
} }
else else
fInitError=fServerTo; fInitError=fServerTo;
@ -800,19 +804,17 @@ void BApplication::InitData(const char* signature, status_t* error)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::BeginRectTracking(BRect r, bool trackWhole) void BApplication::BeginRectTracking(BRect r, bool trackWhole)
{ {
PortLink *link=new PortLink(fServerTo); BPrivate::BAppServerLink link;
link->SetOpCode(AS_BEGIN_RECT_TRACKING); link.WriteInt32(AS_BEGIN_RECT_TRACKING);
link->Attach<BRect>(r); link.WriteRect(r);
link->Attach<int32>(trackWhole); link.WriteInt32(trackWhole);
link->Flush(); link.Sync();
delete link;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::EndRectTracking() void BApplication::EndRectTracking()
{ {
// Because we're just sending an opcode, we can skip the PortLink and simply int32 foo=AS_END_RECT_TRACKING;
// call write_port top the server communications port. write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
write_port(fServerTo,AS_END_RECT_TRACKING,NULL,0);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::get_scs() void BApplication::get_scs()
@ -840,15 +842,6 @@ void* BApplication::global_ro_offs_to_ptr(uint32 offset)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::connect_to_app_server() void BApplication::connect_to_app_server()
{ {
// TODO: implement. Working on updated FlushWithReply -- DW
// 1) get the app_server's main message port - find_port on SERVER_PORT_NAME
// 2) create a portlink pointed at the server
// 3) attach application's "inbox" port
// 4) attach length of signature
// 5) attach signature
// 6) set opcode to AS_CREATE_APP, Flush(), and wait for reply
// 7) receive from the server the message with the buffer being a port_id *.
// 8) set fServerTo to the value of the returned port_id
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BApplication::send_drag(BMessage* msg, int32 vs_token, BPoint offset, BRect drag_rect, BHandler* reply_to) void BApplication::send_drag(BMessage* msg, int32 vs_token, BPoint offset, BRect drag_rect, BHandler* reply_to)