diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index c2371e993c..f6f2b71cbe 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -52,6 +52,8 @@ #include #include #include +#include +#include // Local Includes -------------------------------------------------------------- @@ -757,24 +759,21 @@ void BApplication::InitData(const char* signature, status_t* error) // Attach data: // 1) port_id - receiver port of a regular app - // 2) char * - signature of the regular app - 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(); - - port_id serverapp_port; - session.ReadInt32(&serverapp_port); + // 2) int32 - handler ID token of the app + // 3) char * - signature of the regular app + PortLink link(fServerFrom); + PortMessage pmsg; + link.SetOpCode(AS_CREATE_APP); + link.Attach(fServerTo); + link.Attach(_get_object_token_(this)); + link.AttachString(signature); + link.FlushWithReply(&pmsg); + // Reply code: AS_CREATE_APP // Reply data: // 1) port_id server-side application port (fServerFrom value) - fServerFrom=serverapp_port; - - delete_port(srcv); + pmsg.Read(&fServerFrom); } else fInitError=fServerTo; diff --git a/src/kits/app/Cursor.cpp b/src/kits/app/Cursor.cpp index f26b164f24..a8bef2e65f 100644 --- a/src/kits/app/Cursor.cpp +++ b/src/kits/app/Cursor.cpp @@ -65,6 +65,7 @@ BCursor::BCursor(const void *cursorData) serverlink.WriteInt32(AS_CREATE_BCURSOR); serverlink.WriteData(cursorData,68); + serverlink.WriteInt32(serverlink.GetRecvPort()); serverlink.Sync(); serverlink.ReadInt32(&m_serverToken); } diff --git a/src/kits/app/PortLink.cpp b/src/kits/app/PortLink.cpp index fd94bc1ba1..88d21c8902 100644 --- a/src/kits/app/PortLink.cpp +++ b/src/kits/app/PortLink.cpp @@ -79,7 +79,7 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE Attach(fReceivePort); // Flush the thing....FOOSH! :P - write_port(fSendPort, fSendCode, fSendBuffer, fSendPosition); + write_port(fSendPort, AS_SERVER_SESSION, fSendBuffer, fSendPosition); fSendPosition = 4; // Now we wait for the reply @@ -126,6 +126,14 @@ status_t PortLink::Attach(const void *data, size_t size) return B_NO_MEMORY; } +status_t PortLink::AttachString(const char *string) +{ + int16 len = (int16)strlen(string)+1; + + Attach(len); + return Attach(string, len); +} + void PortLink::MakeEmpty() { fSendPosition=4; diff --git a/src/kits/app/PortMessage.cpp b/src/kits/app/PortMessage.cpp index 5ab9ebd8db..e052d79d5d 100644 --- a/src/kits/app/PortMessage.cpp +++ b/src/kits/app/PortMessage.cpp @@ -172,3 +172,23 @@ void PortMessage::BSessionWorkaround(void) else is_session_msg=false; } + +status_t PortMessage::ReadString(char **string) +{ + int16 len=0; + + if(Read(&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; +} diff --git a/src/kits/app/PortQueue.cpp b/src/kits/app/PortQueue.cpp index bd47c93117..1f88907f39 100644 --- a/src/kits/app/PortQueue.cpp +++ b/src/kits/app/PortQueue.cpp @@ -76,7 +76,7 @@ void PortQueue::GetMessagesFromPort(bool wait_for_messages) delete msg; break; } - + msg->BSessionWorkaround(); _q.push(msg); } @@ -90,6 +90,7 @@ PortMessage *PortQueue::GetMessageFromQueue(void) PortMessage *msg=_q.front(); _q.pop(); + msg->BSessionWorkaround(); return msg; }