Tweaked all messaging classes to comply with new message protocol policies

AppServerLink no longer inherits from BSession
Modified client files which talk to the server to sync with changes in messaging classes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4942 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-10-04 19:08:06 +00:00
parent 7507620c3a
commit 45799af7b5
9 changed files with 199 additions and 191 deletions

View File

@ -44,12 +44,11 @@
namespace BPrivate {
BAppServerLink::BAppServerLink(void)
: BSession(0L,0L)
: PortLink(0L)
{
be_app->Lock();
receiver=create_port(100,"AppServerLink reply port");
SetSendPort(be_app->fServerFrom);
SetRecvPort(receiver);
SetPort(be_app->fServerFrom);
}
//------------------------------------------------------------------------------

View File

@ -378,33 +378,31 @@ void BApplication::ShowCursor()
{
// Because we're just sending an opcode, we can skip the BSession and fake the protocol
int32 foo=AS_SHOW_CURSOR;
write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
write_port(fServerTo,AS_SHOW_CURSOR,&foo,sizeof(int32));
}
//------------------------------------------------------------------------------
void BApplication::HideCursor()
{
// Because we're just sending an opcode, we can skip the BSession and fake the protocol
int32 foo=AS_HIDE_CURSOR;
write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
write_port(fServerTo,AS_HIDE_CURSOR,&foo,sizeof(int32));
}
//------------------------------------------------------------------------------
void BApplication::ObscureCursor()
{
// Because we're just sending an opcode, we can skip the BSession and fake the protocol
int32 foo=AS_OBSCURE_CURSOR;
write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
write_port(fServerTo,AS_OBSCURE_CURSOR,&foo,sizeof(int32));
}
//------------------------------------------------------------------------------
bool BApplication::IsCursorHidden() const
{
int32 replycode;
PortMessage msg;
BPrivate::BAppServerLink link;
link.WriteInt32(AS_QUERY_CURSOR_HIDDEN);
link.WriteInt32(link.GetRecvPort());
link.Sync();
link.ReadInt32(&replycode);
return (replycode==SERVER_TRUE)?true:false;
link.SetOpCode(AS_QUERY_CURSOR_HIDDEN);
link.FlushWithReply(&msg);
return (msg.Code()==SERVER_TRUE)?true:false;
}
//------------------------------------------------------------------------------
void BApplication::SetCursor(const void* cursor)
@ -419,18 +417,15 @@ void BApplication::SetCursor(const void* cursor)
void BApplication::SetCursor(const BCursor* cursor, bool sync)
{
BPrivate::BAppServerLink link;
link.WriteInt32(AS_SET_CURSOR_BCURSOR);
link.WriteBool(sync);
link.WriteInt32(cursor->m_serverToken);
PortMessage msg;
link.SetOpCode(AS_SET_CURSOR_BCURSOR);
link.Attach<bool>(sync);
link.Attach<int32>(cursor->m_serverToken);
if(sync)
link.WriteInt32(link.GetRecvPort());
link.Sync();
if(sync)
{
int32 foo;
link.ReadInt32(&foo);
}
link.FlushWithReply(&msg);
else
link.Flush();
}
//------------------------------------------------------------------------------
int32 BApplication::CountWindows() const
@ -804,16 +799,16 @@ void BApplication::InitData(const char* signature, status_t* error)
void BApplication::BeginRectTracking(BRect r, bool trackWhole)
{
BPrivate::BAppServerLink link;
link.WriteInt32(AS_BEGIN_RECT_TRACKING);
link.WriteRect(r);
link.WriteInt32(trackWhole);
link.Sync();
link.Attach<int32>(AS_BEGIN_RECT_TRACKING);
link.Attach<BRect>(r);
link.Attach<int32>(trackWhole);
link.Flush();
}
//------------------------------------------------------------------------------
void BApplication::EndRectTracking()
{
int32 foo=AS_END_RECT_TRACKING;
write_port(fServerTo,AS_SERVER_SESSION,&foo,sizeof(int32));
write_port(fServerTo,AS_END_RECT_TRACKING,&foo,sizeof(int32));
}
//------------------------------------------------------------------------------
void BApplication::get_scs()

View File

@ -62,12 +62,13 @@ BCursor::BCursor(const void *cursorData)
// Send data directly to server
BPrivate::BAppServerLink serverlink;
PortMessage msg;
serverlink.WriteInt32(AS_CREATE_BCURSOR);
serverlink.WriteData(cursorData,68);
serverlink.WriteInt32(serverlink.GetRecvPort());
serverlink.Sync();
serverlink.ReadInt32(&m_serverToken);
serverlink.SetOpCode(AS_CREATE_BCURSOR);
serverlink.Attach(cursorData,68);
serverlink.FlushWithReply(&msg);
msg.Read<int32>(&m_serverToken);
}
//------------------------------------------------------------------------------
// undefined on BeOS
@ -80,9 +81,9 @@ BCursor::~BCursor()
{
// Notify server to deallocate server-side objects for this cursor
BPrivate::BAppServerLink serverlink;
serverlink.WriteInt32(AS_DELETE_BCURSOR);
serverlink.WriteInt32(m_serverToken);
serverlink.Sync();
serverlink.SetOpCode(AS_DELETE_BCURSOR);
serverlink.Attach<int32>(m_serverToken);
serverlink.Flush();
}
//------------------------------------------------------------------------------
// not implemented on BeOS

View File

@ -1,3 +1,29 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: PortLink.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Class for low-overhead port-based messaging
//
//------------------------------------------------------------------------------
#include <ServerProtocol.h>
#include "PortLink.h"
#include "PortMessage.h"
@ -60,10 +86,10 @@ status_t PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT)
return B_BAD_VALUE;
if(timeout!=B_INFINITE_TIMEOUT)
write_stat=write_port_etc(fSendPort, AS_SERVER_SESSION, fSendBuffer,
write_stat=write_port_etc(fSendPort, fSendCode, fSendBuffer,
fSendPosition, B_TIMEOUT, timeout);
else
write_stat=write_port(fSendPort, AS_SERVER_SESSION, fSendBuffer, fSendPosition);
write_stat=write_port(fSendPort, fSendCode, fSendBuffer, fSendPosition);
fSendPosition=4;
@ -79,7 +105,7 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE
Attach<int32>(fReceivePort);
// Flush the thing....FOOSH! :P
write_port(fSendPort, AS_SERVER_SESSION, fSendBuffer, fSendPosition);
write_port(fSendPort, fSendCode, fSendBuffer, fSendPosition);
fSendPosition = 4;
// Now we wait for the reply
@ -88,27 +114,21 @@ status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout=B_INFINITE
int32 rcode;
if( timeout == B_INFINITE_TIMEOUT )
{
rbuffersize = port_buffer_size(fReceivePort);
if( rbuffersize > 0 )
rbuffer = new int8[rbuffersize];
read_port( fReceivePort, &rcode, rbuffer, rbuffersize);
}
else
{
rbuffersize = port_buffer_size_etc( fReceivePort, 0, timeout);
if( rbuffersize == B_TIMED_OUT )
return B_TIMED_OUT;
if( rbuffersize > 0 )
rbuffer = new int8[rbuffersize];
read_port( fReceivePort, &rcode, rbuffer, rbuffersize);
}
if( rbuffersize > 0 )
rbuffer = new int8[rbuffersize];
read_port( fReceivePort, &rcode, rbuffer, rbuffersize);
// We got this far, so we apparently have some data
msg->SetCode(rcode);
msg->SetBuffer(rbuffer,rbuffersize,false);
msg->BSessionWorkaround();
return B_OK;
}

View File

@ -29,12 +29,14 @@
#include "PortMessage.h"
#include <string.h>
// TODO: Eliminate the reallocation of the message buffer - allocate it on construction
// and free it on destruction.
PortMessage::PortMessage(const int32 &code, const void *buffer, const ssize_t &buffersize,
const bool &copy)
{
_code=code;
SetBuffer(buffer,buffersize,copy);
is_session_msg=false;
}
PortMessage::PortMessage(void)
@ -43,7 +45,6 @@ PortMessage::PortMessage(void)
_buffer=NULL;
_buffersize=0;
_index=NULL;
is_session_msg=false;
}
PortMessage::~PortMessage(void)
@ -52,7 +53,6 @@ PortMessage::~PortMessage(void)
delete _buffer;
}
status_t PortMessage::ReadFromPort(const port_id &port, const bigtime_t &timeout)
{
if(_buffersize>0 && _buffer!=NULL)
@ -61,16 +61,11 @@ status_t PortMessage::ReadFromPort(const port_id &port, const bigtime_t &timeout
_index=NULL;
_buffersize=0;
is_session_msg=false;
if(timeout==B_INFINITE_TIMEOUT)
{
_buffersize=port_buffer_size(port);
if(_buffersize==B_BAD_PORT_ID)
return (status_t)_buffersize;
if(_buffersize>0)
_buffer=new uint8[_buffersize];
read_port(port, &_code, _buffer, _buffersize);
}
else
{
@ -78,13 +73,13 @@ status_t PortMessage::ReadFromPort(const port_id &port, const bigtime_t &timeout
if(_buffersize==B_TIMED_OUT || _buffersize==B_BAD_PORT_ID ||
_buffersize==B_WOULD_BLOCK)
return (status_t)_buffersize;
if(_buffersize>0)
_buffer=new uint8[_buffersize];
read_port(port, &_code, _buffer, _buffersize);
}
_index=_buffer;
BSessionWorkaround();
if(_buffersize>0)
_buffer=new uint8[_buffersize];
read_port(port, &_code, _buffer, _buffersize);
_index=_buffer+4;
return B_OK;
}
@ -93,10 +88,12 @@ status_t PortMessage::WriteToPort(const port_id &port)
{
// Check port validity
port_info pi;
is_session_msg=false;
if(get_port_info(port,&pi)!=B_OK)
return B_BAD_VALUE;
int32 *cast=(int32*)_buffer;
*cast=_code;
write_port(port,_code, _buffer, _buffersize);
if(_buffer && _buffersize>0)
@ -119,9 +116,9 @@ void PortMessage::SetBuffer(const void *buffer, const ssize_t &size, const bool
if(_buffersize>0 && _buffer!=NULL)
delete _buffer;
_buffer=NULL;
_buffersize=0;
_buffersize=4;
if(!buffer || size<1)
if(!buffer || size<5)
return;
if(copy)
@ -135,7 +132,7 @@ void PortMessage::SetBuffer(const void *buffer, const ssize_t &size, const bool
_buffersize=size;
_buffer=(uint8 *)buffer;
}
_index=_buffer;
_index=_buffer+4;
}
status_t PortMessage::Read(void *data, ssize_t size)
@ -155,22 +152,7 @@ status_t PortMessage::Read(void *data, ssize_t size)
void PortMessage::Rewind(void)
{
_index=(is_session_msg)?_buffer+4:_buffer;
}
void PortMessage::BSessionWorkaround(void)
{
// Do some stuff to work around BSession stupidity with packaging the message code as
// the first attachment in the message's data buffer.
if(_code==AS_SERVER_SESSION)
{
is_session_msg=true;
_index+=4;
_code=*((int32*)_buffer);
}
else
is_session_msg=false;
_index=_buffer+4;
}
status_t PortMessage::ReadString(char **string)

View File

@ -76,7 +76,6 @@ void PortQueue::GetMessagesFromPort(bool wait_for_messages)
delete msg;
break;
}
msg->BSessionWorkaround();
_q.push(msg);
}
@ -90,7 +89,6 @@ PortMessage *PortQueue::GetMessageFromQueue(void)
PortMessage *msg=_q.front();
_q.pop();
msg->BSessionWorkaround();
return msg;
}

View File

@ -10,7 +10,7 @@ BSession::BSession(port_id receivePort, port_id sendPort, bool isPortLink = fals
fSendPort = sendPort;
fReceivePort = receivePort;
fSendCode = AS_SERVER_SESSION;
fSendCode = 0;
fSendBuffer = NULL;
fSendPosition = 4;
@ -28,7 +28,7 @@ BSession::BSession( const BSession &ses){
fSendPort = ses.fSendPort;
fReceivePort = ses.fReceivePort;
fSendCode = AS_SERVER_SESSION;
fSendCode = 0;
fSendBuffer = NULL;
fSendPosition = 4;
@ -40,8 +40,7 @@ BSession::BSession( const BSession &ses){
fReceiveBuffer = (char*)malloc(1024);
}
//------------------------------------------------------------------------------
BSession::~BSession()
{
BSession::~BSession(){
free(fSendBuffer);
free(fReceiveBuffer);
}
@ -54,13 +53,15 @@ void BSession::SetRecvPort( port_id port ){
fReceivePort = port;
}
//------------------------------------------------------------------------------
bool BSession::DropInputBuffer(void)
{
bool BSession::DropInputBuffer(void){
// TODO: Implement
}
//------------------------------------------------------------------------------
char *BSession::ReadString()
{
void BSession::SetMsgCode(int32 code){
fSendCode=code;
}
//------------------------------------------------------------------------------
char *BSession::ReadString(){
int16 len = 0;
char *str = NULL;
@ -190,16 +191,15 @@ status_t BSession::ReadData( void *data, int32 size)
{
int32 fRecvCode;
status_t rv;
do{
while( (rv = read_port(fReceivePort, &fRecvCode, fReceiveBuffer, 1024)) ==
B_WOULD_BLOCK);
} while( fRecvCode != AS_SERVER_SESSION && rv != B_BAD_PORT_ID );
while( (rv = port_buffer_size(fReceivePort) ) == B_WOULD_BLOCK);
rv=read_port(fReceivePort, &fRecvCode, fReceiveBuffer, 1024);
if ( rv == B_BAD_PORT_ID )
return B_BAD_PORT_ID;
fReceivePosition = 4;
fReceiveSize = *(int32*)fReceiveBuffer;
fReceivePosition = 0;
fReceiveSize = rv;
}
int32 copySize = fReceiveSize - fReceivePosition;
@ -389,7 +389,7 @@ status_t BSession::Sync()
status_t rv;
*(int32*)fSendBuffer = fSendPosition;
*(int32*)fSendBuffer = fSendCode;
while( (rv = write_port(fSendPort, fSendCode, fSendBuffer,
fSendPosition)) == B_WOULD_BLOCK);

View File

@ -30,6 +30,7 @@
#include <InterfaceDefs.h>
#include <ServerProtocol.h>
#include <Screen.h>
#include <PortMessage.h>
#include <Roster.h>
@ -52,11 +53,11 @@ _IMPEXP_BE status_t
set_screen_space(int32 index, uint32 res, bool stick)
{
BAppServerLink link;
link.WriteInt32(AS_SET_SCREEN_MODE);
link.WriteInt32(index);
link.WriteInt32((int32)res);
link.WriteBool(stick);
link.Sync();
link.SetOpCode(AS_SET_SCREEN_MODE);
link.Attach<int32>(index);
link.Attach<int32>((int32)res);
link.Attach<bool>(stick);
link.Flush();
//TODO: Read back the status from the app_server's reply
return B_OK;
@ -70,10 +71,11 @@ set_scroll_bar_info(scroll_bar_info *info)
return B_ERROR;
BAppServerLink link;
link.WriteInt32(AS_SET_SCROLLBAR_INFO);
link.WriteData(info, sizeof(scroll_bar_info));
link.Sync();
link.ReadData(info,sizeof(scroll_bar_info));
PortMessage msg;
link.SetOpCode(AS_SET_SCROLLBAR_INFO);
link.Attach<scroll_bar_info>(*info);
link.FlushWithReply(&msg);
return B_OK;
}
@ -252,9 +254,10 @@ count_workspaces()
int32 count;
BAppServerLink link;
link.WriteInt32(AS_COUNT_WORKSPACES);
link.Sync();
link.ReadInt32(&count);
PortMessage msg;
link.SetOpCode(AS_COUNT_WORKSPACES);
link.FlushWithReply(&msg);
msg.Read<int32>(&count);
return count;
}
@ -263,9 +266,9 @@ _IMPEXP_BE void
set_workspace_count(int32 count)
{
BAppServerLink link;
link.WriteInt32(AS_SET_WORKSPACE_COUNT);
link.WriteInt32(count);
link.Sync();
link.SetOpCode(AS_SET_WORKSPACE_COUNT);
link.Attach<int32>(count);
link.Flush();
}
@ -275,9 +278,10 @@ current_workspace()
int32 index;
BAppServerLink link;
link.WriteInt32(AS_CURRENT_WORKSPACE);
link.Sync();
link.ReadInt32(&index);
PortMessage msg;
link.SetOpCode(AS_CURRENT_WORKSPACE);
link.FlushWithReply(&msg);
msg.Read<int32>(&index);
return index;
}
@ -287,9 +291,9 @@ _IMPEXP_BE void
activate_workspace(int32 workspace)
{
BAppServerLink link;
link.WriteInt32(AS_ACTIVATE_WORKSPACE);
link.WriteInt32(workspace);
link.Sync();
link.SetOpCode(AS_ACTIVATE_WORKSPACE);
link.Attach<int32>(workspace);
link.Flush();
}
@ -299,9 +303,10 @@ idle_time()
bigtime_t idletime;
BAppServerLink link;
link.WriteInt32(AS_IDLE_TIME);
link.Sync();
link.ReadInt64(&idletime);
PortMessage msg;
link.SetOpCode(AS_IDLE_TIME);
link.FlushWithReply(&msg);
msg.Read<int64>(&idletime);
return idletime;
}
@ -336,9 +341,9 @@ _IMPEXP_BE void
set_focus_follows_mouse(bool follow)
{
BAppServerLink link;
link.WriteInt32(AS_SET_FOCUS_FOLLOWS_MOUSE);
link.WriteBool(follow);
link.Sync();
link.SetOpCode(AS_SET_FOCUS_FOLLOWS_MOUSE);
link.Attach<bool>(follow);
link.Flush();
}
@ -348,9 +353,10 @@ focus_follows_mouse()
bool ffm;
BAppServerLink link;
link.WriteInt32(AS_FOCUS_FOLLOWS_MOUSE);
link.Sync();
link.ReadBool(&ffm);
PortMessage msg;
link.SetOpCode(AS_FOCUS_FOLLOWS_MOUSE);
link.FlushWithReply(&msg);
msg.Read<bool>(&ffm);
return ffm;
}
@ -359,9 +365,9 @@ _IMPEXP_BE void
set_mouse_mode(mode_mouse mode)
{
BAppServerLink link;
link.WriteInt32(AS_SET_MOUSE_MODE);
link.WriteData(&mode,sizeof(mode_mouse));
link.Sync();
link.SetOpCode(AS_SET_MOUSE_MODE);
link.Attach<mode_mouse>(mode);
link.Flush();
}
@ -371,9 +377,10 @@ mouse_mode()
mode_mouse mode;
BAppServerLink link;
link.WriteInt32(AS_GET_MOUSE_MODE);
link.Sync();
link.ReadData(&mode,sizeof(mode_mouse));
PortMessage msg;
link.SetOpCode(AS_GET_MOUSE_MODE);
link.FlushWithReply(&msg);
msg.Read<mode_mouse>(&mode);
return mode;
}
@ -384,10 +391,11 @@ ui_color(color_which which)
rgb_color color;
BAppServerLink link;
link.WriteInt32(AS_GET_UI_COLOR);
link.WriteData(&which, sizeof(which));
link.Sync();
link.ReadData(&color,sizeof(rgb_color));
PortMessage msg;
link.SetOpCode(AS_GET_UI_COLOR);
link.Attach<color_which>(which);
link.FlushWithReply(&msg);
msg.Read<rgb_color>(&color);
return color;
}
@ -448,7 +456,7 @@ bitmaps_support_space(color_space space, uint32 * support_flags)
void __set_window_decor(int32 theme)
{
BAppServerLink link;
link.WriteInt32(AS_R5_SET_DECORATOR);
link.WriteInt32(theme);
link.Sync();
link.SetOpCode(AS_R5_SET_DECORATOR);
link.Attach<int32>(theme);
link.Flush();
}

View File

@ -38,6 +38,7 @@
#include <Errors.h>
#include <List.h>
#include <AppServerLink.h>
#include <PortMessage.h>
#include <ServerProtocol.h>
// Project Includes ------------------------------------------------------------
@ -84,11 +85,12 @@ BPicture::BPicture(const BPicture &picture)
{
BPrivate::BAppServerLink link;
PortMessage msg;
link.WriteInt32(AS_CLONE_PICTURE);
link.WriteInt32(picture.token);
link.Sync();
link.ReadInt32(&token);
link.Attach<int32>(AS_CLONE_PICTURE);
link.Attach<int32>(picture.token);
link.FlushWithReply(&msg);
msg.Read<int32>(&token);
}
if (picture.extent->fNewData != NULL)
@ -158,20 +160,21 @@ BPicture::BPicture(BMessage *archive)
if (extent->fNewSize != 0 && extent->fNewData != 0)
{
BPrivate::BAppServerLink link;
PortMessage msg;
BPicture *pic;
link.WriteInt32(AS_CREATE_PICTURE);
link.WriteInt32(extent->fPictures.CountItems());
link.Attach<int32>(AS_CREATE_PICTURE);
link.Attach<int32>(extent->fPictures.CountItems());
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
{
pic=(BPicture*)extent->fPictures.ItemAt(i);
if(pic)
link.WriteInt32(pic->token);
link.Attach<int32>(pic->token);
}
link.WriteInt32(extent->fNewSize);
link.WriteData(extent->fNewData,extent->fNewSize);
link.Sync();
link.ReadInt32(&token);
link.Attach<int32>(extent->fNewSize);
link.Attach(extent->fNewData,extent->fNewSize);
link.FlushWithReply(&msg);
msg.Read<int32>(&token);
}
}
@ -202,9 +205,9 @@ BPicture::~BPicture()
{
BPrivate::BAppServerLink link;
link.WriteInt32(AS_DELETE_PICTURE);
link.WriteInt32(token);
link.Sync();
link.Attach<int32>(AS_DELETE_PICTURE);
link.Attach<int32>(token);
link.Flush();
}
if (extent->fNewData != NULL)
@ -338,20 +341,21 @@ status_t BPicture::Unflatten(BDataIO *stream)
// swap_data(extent->fNewData, extent->fNewSize);
BPrivate::BAppServerLink link;
PortMessage msg;
BPicture *pic;
link.WriteInt32(AS_CREATE_PICTURE);
link.WriteInt32(extent->fPictures.CountItems());
link.Attach<int32>(AS_CREATE_PICTURE);
link.Attach<int32>(extent->fPictures.CountItems());
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
{
pic=(BPicture*)extent->fPictures.ItemAt(i);
if(pic)
link.WriteInt32(pic->token);
link.Attach<int32>(pic->token);
}
link.WriteInt32(extent->fNewSize);
link.WriteData(extent->fNewData, extent->fNewSize);
link.Sync();
link.ReadInt32(&token);
link.Attach<int32>(extent->fNewSize);
link.Attach(extent->fNewData, extent->fNewSize);
link.FlushWithReply(&msg);
msg.Read<int32>(&token);
if (extent->fNewData)
{
@ -391,17 +395,18 @@ void BPicture::import_data(const void *data, int32 size, BPicture **subs,
return;
BPrivate::BAppServerLink link;
link.WriteInt32(AS_CREATE_PICTURE);
link.WriteInt32(subCount);
PortMessage msg;
link.Attach<int32>(AS_CREATE_PICTURE);
link.Attach<int32>(subCount);
for (int32 i = 0; i < subCount; i++)
link.WriteInt32(subs[i]->token);
link.Attach<int32>(subs[i]->token);
link.WriteInt32(size);
link.WriteData(data, size);
link.Sync();
link.ReadInt32(&token);
link.Attach<int32>(size);
link.Attach(data, size);
link.FlushWithReply(&msg);
msg.Read<int32>(&token);
}
//------------------------------------------------------------------------------
void BPicture::import_old_data(const void *data, int32 size)
@ -416,12 +421,12 @@ void BPicture::import_old_data(const void *data, int32 size)
convert_old_to_new(data, size, &extent->fNewData, &extent->fNewSize);
BPrivate::BAppServerLink link;
link.WriteInt32(AS_CREATE_PICTURE);
link.WriteInt32(0L);
link.WriteInt32(extent->fNewSize);
link.WriteData(extent->fNewData,extent->fNewSize);
link.Sync();
link.ReadInt32(&token)
link.Attach<int32>(AS_CREATE_PICTURE);
link.Attach<int32>(0L);
link.Attach<int32>(extent->fNewSize);
link.Attach(extent->fNewData,extent->fNewSize);
link.FlushWithReply(&msg);
msg.Read<int32>(&token)
// Do we free all data now?
free(extent->fNewData);
@ -448,9 +453,9 @@ bool BPicture::assert_local_copy()
/* BPrivate::BAppServerLink link;
int32 count;
link.WriteInt32(AS_DOWNLOAD_PICTURE);
link.WriteInt32(token);
link.Sync();
link.Attach<int32>(AS_DOWNLOAD_PICTURE);
link.Attach<int32>(token);
link.FlushWithReply(&msg);
count=*((int32*)replydata.buffer);
// Read sub picture tokens
@ -496,14 +501,14 @@ bool BPicture::assert_server_copy()
extent->fPictures.ItemAt(i)->assert_server_copy();
BPrivate::BAppServerLink link;
link.WriteInt32(AS_CREATE_PICTURE);
link.WriteInt32(extent->fPictures.CountItems());
link.Attach<int32>(AS_CREATE_PICTURE);
link.Attach<int32>(extent->fPictures.CountItems());
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
link.WriteInt32(extent->fPictures.ItemAt(i)->token);
link.WriteInt32(extent->fNewSize);
link.WriteData(extent->fNewData,extent->fNewSize);
link.Sync();
link.ReadInt32(&token);
link.Attach<int32>(extent->fPictures.ItemAt(i)->token);
link.Attach<int32>(extent->fNewSize);
link.Attach(extent->fNewData,extent->fNewSize);
link.FlushWithReply(&msg);
msg.Read<int32>(&token);
return token != -1;*/
return true;
@ -543,9 +548,9 @@ void BPicture::usurp(BPicture *lameDuck)
{
BPrivate::BAppServerLink link;
link.WriteInt32(AS_DELETE_PICTURE);
link.WriteInt32(token);
link.Sync();
link.Attach<int32>(AS_DELETE_PICTURE);
link.Attach<int32>(token);
link.Flush();
}
if (extent->fNewData != NULL)