Added PortMessage::ReadString and PortLink::AttachString to support BSession-style string attachments
Tweaks to startup code for BApplication Tweaked PortQueue to utilize the BSession workaround for PortMessages Tweaks to message protocol for BCursor git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4939 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -52,6 +52,8 @@
|
|||||||
#include <ObjectLocker.h>
|
#include <ObjectLocker.h>
|
||||||
#include <AppServerLink.h>
|
#include <AppServerLink.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
#include <PortLink.h>
|
||||||
|
#include <PortMessage.h>
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
// Local Includes --------------------------------------------------------------
|
||||||
|
|
||||||
@@ -757,24 +759,21 @@ 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) int32 - handler ID token of the app
|
||||||
port_id srcv=create_port(100,"BApp reply port");
|
// 3) char * - signature of the regular app
|
||||||
BSession session(srcv,fServerTo);
|
PortLink link(fServerFrom);
|
||||||
session.WriteInt32(AS_CREATE_APP);
|
PortMessage pmsg;
|
||||||
session.WriteInt32(fServerTo);
|
|
||||||
session.WriteInt32(_get_object_token_(this));
|
|
||||||
session.WriteData(signature,strlen(signature)+1);
|
|
||||||
session.Sync();
|
|
||||||
|
|
||||||
port_id serverapp_port;
|
link.SetOpCode(AS_CREATE_APP);
|
||||||
session.ReadInt32(&serverapp_port);
|
link.Attach<port_id>(fServerTo);
|
||||||
|
link.Attach<port_id>(_get_object_token_(this));
|
||||||
|
link.AttachString(signature);
|
||||||
|
link.FlushWithReply(&pmsg);
|
||||||
|
|
||||||
// Reply code: AS_CREATE_APP
|
// Reply code: AS_CREATE_APP
|
||||||
// Reply data:
|
// Reply data:
|
||||||
// 1) port_id server-side application port (fServerFrom value)
|
// 1) port_id server-side application port (fServerFrom value)
|
||||||
fServerFrom=serverapp_port;
|
pmsg.Read<port_id>(&fServerFrom);
|
||||||
|
|
||||||
delete_port(srcv);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fInitError=fServerTo;
|
fInitError=fServerTo;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ BCursor::BCursor(const void *cursorData)
|
|||||||
|
|
||||||
serverlink.WriteInt32(AS_CREATE_BCURSOR);
|
serverlink.WriteInt32(AS_CREATE_BCURSOR);
|
||||||
serverlink.WriteData(cursorData,68);
|
serverlink.WriteData(cursorData,68);
|
||||||
|
serverlink.WriteInt32(serverlink.GetRecvPort());
|
||||||
serverlink.Sync();
|
serverlink.Sync();
|
||||||
serverlink.ReadInt32(&m_serverToken);
|
serverlink.ReadInt32(&m_serverToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE
|
|||||||
Attach<int32>(fReceivePort);
|
Attach<int32>(fReceivePort);
|
||||||
|
|
||||||
// Flush the thing....FOOSH! :P
|
// Flush the thing....FOOSH! :P
|
||||||
write_port(fSendPort, fSendCode, fSendBuffer, fSendPosition);
|
write_port(fSendPort, AS_SERVER_SESSION, fSendBuffer, fSendPosition);
|
||||||
fSendPosition = 4;
|
fSendPosition = 4;
|
||||||
|
|
||||||
// Now we wait for the reply
|
// Now we wait for the reply
|
||||||
@@ -126,6 +126,14 @@ status_t PortLink::Attach(const void *data, size_t size)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t PortLink::AttachString(const char *string)
|
||||||
|
{
|
||||||
|
int16 len = (int16)strlen(string)+1;
|
||||||
|
|
||||||
|
Attach<int16>(len);
|
||||||
|
return Attach(string, len);
|
||||||
|
}
|
||||||
|
|
||||||
void PortLink::MakeEmpty()
|
void PortLink::MakeEmpty()
|
||||||
{
|
{
|
||||||
fSendPosition=4;
|
fSendPosition=4;
|
||||||
|
|||||||
@@ -172,3 +172,23 @@ void PortMessage::BSessionWorkaround(void)
|
|||||||
else
|
else
|
||||||
is_session_msg=false;
|
is_session_msg=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t PortMessage::ReadString(char **string)
|
||||||
|
{
|
||||||
|
int16 len=0;
|
||||||
|
|
||||||
|
if(Read<int16>(&len)!= B_OK)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
*string=new char[len];
|
||||||
|
if(Read(*string, len)!= B_OK)
|
||||||
|
{
|
||||||
|
delete *string;
|
||||||
|
*string=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void PortQueue::GetMessagesFromPort(bool wait_for_messages)
|
|||||||
delete msg;
|
delete msg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
msg->BSessionWorkaround();
|
||||||
_q.push(msg);
|
_q.push(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +90,7 @@ PortMessage *PortQueue::GetMessageFromQueue(void)
|
|||||||
|
|
||||||
PortMessage *msg=_q.front();
|
PortMessage *msg=_q.front();
|
||||||
_q.pop();
|
_q.pop();
|
||||||
|
msg->BSessionWorkaround();
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user