Pahtz's changes from PortLink/BSession/PortMessage/PortQueue to BPortLink
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8519 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d0021b64bc
commit
3ceb31b96a
@ -44,11 +44,16 @@
|
||||
namespace BPrivate {
|
||||
|
||||
BAppServerLink::BAppServerLink(void)
|
||||
: PortLink(0L)
|
||||
: BPortLink()
|
||||
{
|
||||
be_app->Lock();
|
||||
if (be_app)
|
||||
{
|
||||
be_app->Lock();
|
||||
SetSendPort(be_app->fServerTo);
|
||||
}
|
||||
receiver=create_port(100,"AppServerLink reply port");
|
||||
SetPort(be_app->fServerFrom);
|
||||
SetReplyPort(receiver);
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -56,7 +61,25 @@ BAppServerLink::BAppServerLink(void)
|
||||
BAppServerLink::~BAppServerLink()
|
||||
{
|
||||
delete_port(receiver);
|
||||
be_app->Unlock();
|
||||
if (be_app)
|
||||
be_app->Unlock();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BAppServerLink::FlushWithReply(int32 *code)
|
||||
{
|
||||
status_t err;
|
||||
|
||||
err = Attach<port_id>(receiver);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
err = Flush();
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
return GetNextReply(code);
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
@ -56,9 +56,7 @@
|
||||
#include <AppServerLink.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <PortLink.h>
|
||||
#include <PortMessage.h>
|
||||
|
||||
#include "PrivateScreen.h"
|
||||
#include <PrivateScreen.h>
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
@ -172,9 +170,6 @@ property_info gApplicationPropInfo[] =
|
||||
extern const int __libc_argc;
|
||||
extern const char * const *__libc_argv;
|
||||
|
||||
// TODO: We have a more or less complete BMenuWindow class in Menu.cpp.
|
||||
// If this file needs to include its interface, we'd better move it to
|
||||
// some private header.
|
||||
class BMenuWindow : public BWindow
|
||||
{
|
||||
};
|
||||
@ -186,7 +181,7 @@ class BMenuWindow : public BWindow
|
||||
#define OUT printf
|
||||
|
||||
enum {
|
||||
NOT_IMPLEMENTED = B_ERROR,
|
||||
NOT_IMPLEMENTED = B_ERROR
|
||||
};
|
||||
|
||||
// prototypes of helper functions
|
||||
@ -228,7 +223,8 @@ BApplication::BApplication(const char* signature, status_t* error)
|
||||
//------------------------------------------------------------------------------
|
||||
BApplication::~BApplication()
|
||||
{
|
||||
// tell all loopers(usualy windows) to quit. Also, wait for them.
|
||||
// tell all loopers(usually windows) to quit. Also, wait for them.
|
||||
|
||||
// TODO: As Axel suggested, this functionality should probably be moved
|
||||
// to quit_all_windows(), and that function should be called from both
|
||||
// here and QuitRequested().
|
||||
@ -255,13 +251,14 @@ BApplication::~BApplication()
|
||||
// unregister from the roster
|
||||
BRoster::Private().RemoveApp(Team());
|
||||
|
||||
// tell app_server we're quiting...
|
||||
PortLink link(fServerFrom);
|
||||
link.SetOpCode(B_QUIT_REQUESTED);
|
||||
// tell app_server we're quitting...
|
||||
BPortLink link(fServerFrom);
|
||||
link.StartMessage(B_QUIT_REQUESTED);
|
||||
link.Flush();
|
||||
|
||||
// uninitialize be_app and be_app_messenger
|
||||
be_app = NULL;
|
||||
|
||||
// R5 doesn't uninitialize be_app_messenger.
|
||||
//be_app_messenger = BMessenger();
|
||||
}
|
||||
@ -422,38 +419,37 @@ BHandler* BApplication::ResolveSpecifier(BMessage* msg, int32 index,
|
||||
BMessage* specifier, int32 form,
|
||||
const char* property)
|
||||
{
|
||||
return NULL; // TODO: implement
|
||||
return NULL; // TODO: implement? not implemented?
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
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_SHOW_CURSOR,&foo,sizeof(int32));
|
||||
BPrivate::BAppServerLink link;
|
||||
link.StartMessage(AS_SHOW_CURSOR);
|
||||
link.Flush();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
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_HIDE_CURSOR,&foo,sizeof(int32));
|
||||
BPrivate::BAppServerLink link;
|
||||
link.StartMessage(AS_HIDE_CURSOR);
|
||||
link.Flush();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
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_OBSCURE_CURSOR,&foo,sizeof(int32));
|
||||
BPrivate::BAppServerLink link;
|
||||
link.StartMessage(AS_OBSCURE_CURSOR);
|
||||
link.Flush();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool BApplication::IsCursorHidden() const
|
||||
{
|
||||
PortMessage msg;
|
||||
|
||||
BPrivate::BAppServerLink link;
|
||||
link.SetOpCode(AS_QUERY_CURSOR_HIDDEN);
|
||||
link.FlushWithReply(&msg);
|
||||
return (msg.Code()==SERVER_TRUE)?true:false;
|
||||
int32 code = SERVER_FALSE;
|
||||
link.StartMessage(AS_QUERY_CURSOR_HIDDEN);
|
||||
link.FlushWithReply(&code);
|
||||
return (code==SERVER_TRUE)?true:false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BApplication::SetCursor(const void* cursor)
|
||||
@ -468,13 +464,13 @@ void BApplication::SetCursor(const void* cursor)
|
||||
void BApplication::SetCursor(const BCursor* cursor, bool sync)
|
||||
{
|
||||
BPrivate::BAppServerLink link;
|
||||
PortMessage msg;
|
||||
int32 code=SERVER_FALSE;
|
||||
|
||||
link.SetOpCode(AS_SET_CURSOR_BCURSOR);
|
||||
link.StartMessage(AS_SET_CURSOR_BCURSOR);
|
||||
link.Attach<bool>(sync);
|
||||
link.Attach<int32>(cursor->m_serverToken);
|
||||
if(sync)
|
||||
link.FlushWithReply(&msg);
|
||||
link.FlushWithReply(&code);
|
||||
else
|
||||
link.Flush();
|
||||
}
|
||||
@ -728,7 +724,7 @@ void BApplication::_ReservedApplication8()
|
||||
//------------------------------------------------------------------------------
|
||||
bool BApplication::ScriptReceived(BMessage* msg, int32 index, BMessage* specifier, int32 form, const char* property)
|
||||
{
|
||||
return false; // TODO: Implement
|
||||
return false; // TODO: Implement? Not implemented?
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BApplication::run_task()
|
||||
@ -835,6 +831,9 @@ void BApplication::InitData(const char* signature, status_t* error)
|
||||
// Do that even, if we are B_ARGV_ONLY.
|
||||
// TODO: When BLooper::AddMessage() is done, use that instead of
|
||||
// PostMessage().
|
||||
|
||||
DBG(OUT("info: BApplication sucessfully registered.\n"));
|
||||
|
||||
if (__libc_argc > 1) {
|
||||
BMessage argvMessage(B_ARGV_RECEIVED);
|
||||
do_argv(&argvMessage);
|
||||
@ -896,7 +895,7 @@ void BApplication::InitData(const char* signature, status_t* error)
|
||||
void BApplication::BeginRectTracking(BRect r, bool trackWhole)
|
||||
{
|
||||
BPrivate::BAppServerLink link;
|
||||
link.Attach<int32>(AS_BEGIN_RECT_TRACKING);
|
||||
link.StartMessage(AS_BEGIN_RECT_TRACKING);
|
||||
link.Attach<BRect>(r);
|
||||
link.Attach<int32>(trackWhole);
|
||||
link.Flush();
|
||||
@ -904,8 +903,9 @@ void BApplication::BeginRectTracking(BRect r, bool trackWhole)
|
||||
//------------------------------------------------------------------------------
|
||||
void BApplication::EndRectTracking()
|
||||
{
|
||||
int32 foo=AS_END_RECT_TRACKING;
|
||||
write_port(fServerTo,AS_END_RECT_TRACKING,&foo,sizeof(int32));
|
||||
BPrivate::BAppServerLink link;
|
||||
link.StartMessage(AS_END_RECT_TRACKING);
|
||||
link.Flush();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BApplication::get_scs()
|
||||
@ -915,7 +915,12 @@ void BApplication::get_scs()
|
||||
//------------------------------------------------------------------------------
|
||||
void BApplication::setup_server_heaps()
|
||||
{
|
||||
// TODO: implement
|
||||
// TODO: implement?
|
||||
|
||||
// We may not need to implement this function or the XX_offs_to_ptr functions.
|
||||
// R5 sets up a couple of areas for various tasks having to do with the
|
||||
// app_server. Currently (7/29/04), the R1 app_server does not do this and
|
||||
// may never do this unless a significant need is found for it. --DW
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void* BApplication::rw_offs_to_ptr(uint32 offset)
|
||||
@ -940,6 +945,9 @@ void BApplication::connect_to_app_server()
|
||||
// Create the port so that the app_server knows where to send messages
|
||||
fServerTo = create_port(100, "a<fServerTo");
|
||||
if (fServerTo >= 0) {
|
||||
|
||||
//We can't use BAppServerLink because be_app == NULL
|
||||
|
||||
// AS_CREATE_APP:
|
||||
|
||||
// Attach data:
|
||||
@ -948,21 +956,23 @@ void BApplication::connect_to_app_server()
|
||||
// 3) team_id - team identification field
|
||||
// 4) int32 - handler ID token of the app
|
||||
// 5) char * - signature of the regular app
|
||||
PortLink link(fServerFrom);
|
||||
PortMessage pmsg;
|
||||
BPortLink link(fServerFrom);
|
||||
int32 code=SERVER_FALSE;
|
||||
|
||||
link.SetOpCode(AS_CREATE_APP);
|
||||
link.StartMessage(AS_CREATE_APP);
|
||||
link.Attach<port_id>(fServerTo);
|
||||
link.Attach<port_id>(_get_looper_port_(this));
|
||||
link.Attach<team_id>(Team());
|
||||
link.Attach<int32>(_get_object_token_(this));
|
||||
link.AttachString(fAppName);
|
||||
link.FlushWithReply(&pmsg);
|
||||
link.Flush();
|
||||
link.GetNextReply(&code);
|
||||
|
||||
// Reply code: AS_CREATE_APP
|
||||
// Reply data:
|
||||
// 1) port_id server-side application port (fServerFrom value)
|
||||
pmsg.Read<port_id>(&fServerFrom);
|
||||
if(code==AS_CREATE_APP)
|
||||
link.Read<port_id>(&fServerFrom);
|
||||
|
||||
} else
|
||||
fInitError = fServerTo;
|
||||
@ -987,7 +997,7 @@ void BApplication::write_drag(_BSession_* session, BMessage* a_message)
|
||||
//------------------------------------------------------------------------------
|
||||
bool BApplication::quit_all_windows(bool force)
|
||||
{
|
||||
return false; // TODO: implement
|
||||
return false; // TODO: implement?
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool BApplication::window_quit_loop(bool, bool)
|
||||
@ -1087,7 +1097,7 @@ status_t BApplication::get_window_list(BList* list, bool incl_menus) const
|
||||
//------------------------------------------------------------------------------
|
||||
int32 BApplication::async_quit_entry(void* data)
|
||||
{
|
||||
return 0; // TODO: implement ?
|
||||
return 0; // TODO: implement? not implemented?
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include <AppDefs.h>
|
||||
#include <Cursor.h>
|
||||
#include <PortLink.h>
|
||||
#include <PortMessage.h>
|
||||
#include <AppServerLink.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
@ -60,13 +59,13 @@ BCursor::BCursor(const void *cursorData)
|
||||
|
||||
// Send data directly to server
|
||||
BPrivate::BAppServerLink serverlink;
|
||||
PortMessage msg;
|
||||
int32 code=SERVER_FALSE;
|
||||
|
||||
serverlink.SetOpCode(AS_CREATE_BCURSOR);
|
||||
serverlink.StartMessage(AS_CREATE_BCURSOR);
|
||||
serverlink.Attach(cursorData, 68);
|
||||
serverlink.FlushWithReply(&msg);
|
||||
|
||||
msg.Read<int32>(&m_serverToken);
|
||||
serverlink.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
serverlink.Read<int32>(&m_serverToken);
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +81,7 @@ BCursor::~BCursor()
|
||||
{
|
||||
// Notify server to deallocate server-side objects for this cursor
|
||||
BPrivate::BAppServerLink serverlink;
|
||||
serverlink.SetOpCode(AS_DELETE_BCURSOR);
|
||||
serverlink.StartMessage(AS_DELETE_BCURSOR);
|
||||
serverlink.Attach<int32>(m_serverToken);
|
||||
serverlink.Flush();
|
||||
}
|
||||
|
@ -118,11 +118,11 @@ int _init_message_()
|
||||
int _delete_message_()
|
||||
{
|
||||
delete_port(BMessage::sReplyPorts[0]);
|
||||
BMessage::sReplyPorts[0] = NULL;
|
||||
BMessage::sReplyPorts[0] = -1;
|
||||
delete_port(BMessage::sReplyPorts[1]);
|
||||
BMessage::sReplyPorts[1] = NULL;
|
||||
BMessage::sReplyPorts[1] = -1;
|
||||
delete_port(BMessage::sReplyPorts[2]);
|
||||
BMessage::sReplyPorts[2] = NULL;
|
||||
BMessage::sReplyPorts[2] = -1;
|
||||
return 0;
|
||||
}
|
||||
} // extern "C"
|
||||
@ -698,7 +698,7 @@ status_t BMessage::Unflatten(BDataIO* stream)
|
||||
}
|
||||
|
||||
// Add each data field to the message
|
||||
uint32 itemSize;
|
||||
uint32 itemSize=0;
|
||||
if (flags & MSG_FLAG_FIXED_SIZE)
|
||||
{
|
||||
itemSize = dataLen / count;
|
||||
|
@ -20,146 +20,709 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: PortLink.cpp
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Description: Class for low-overhead packet-style port-based messaging
|
||||
// Author: Pahtz <pahtz@yahoo.com.au>
|
||||
// Description: Class for low-overhead port-based messaging
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
|
||||
#include <ServerProtocol.h>
|
||||
#include "PortLink.h"
|
||||
#include "PortMessage.h"
|
||||
|
||||
PortLink::PortLink(port_id port)
|
||||
#define DEBUG_BPORTLINK
|
||||
#ifdef DEBUG_BPORTLINK
|
||||
# include <stdio.h>
|
||||
# define STRACE(x) printf x
|
||||
const char *strcode(int32 code);
|
||||
#else
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
//set Initial==Max for a fixed buffer size
|
||||
static const int32 kInitialSendBufferSize = 2048;
|
||||
static const int32 kMaxSendBufferSize = 2048;
|
||||
static const int32 kInitialReceiveBufferSize = 2048;
|
||||
static const int32 kMaxReceiveBufferSize = 2048;
|
||||
//make the max receive buffer at least as large as max send
|
||||
|
||||
static const int32 kHeaderSize = sizeof(int32) * 3; //size + code + flags
|
||||
|
||||
BPortLink::BPortLink(port_id send, port_id receive) :
|
||||
fSendPort(send), fReceivePort(receive), fSendBuffer(NULL), fRecvBuffer(NULL),
|
||||
fSendPosition(0), fRecvPosition(0), fSendStart(0), fRecvStart(0),
|
||||
fSendBufferSize(0), fRecvBufferSize(0), fSendCount(0), fDataSize(0),
|
||||
fReplySize(0), fWriteError(B_OK), fReadError(B_OK)
|
||||
{
|
||||
port_info pi;
|
||||
fPortValid = (get_port_info(port, &pi)==B_OK)? true: false;
|
||||
|
||||
fSendPort = port;
|
||||
fReceivePort = create_port(30,"PortLink reply port");
|
||||
|
||||
fSendCode = 0;
|
||||
fSendBuffer = new char[SESSION_BUFFER_SIZE * 4];
|
||||
fSendPosition = 8;
|
||||
fDataSize = (int32*)(fSendBuffer+sizeof(int32));
|
||||
*fDataSize = 0;
|
||||
/* */
|
||||
}
|
||||
|
||||
PortLink::PortLink( const PortLink &link )
|
||||
BPortLink::~BPortLink()
|
||||
{
|
||||
fPortValid = link.fPortValid;
|
||||
if (fSendBuffer)
|
||||
free(fSendBuffer);
|
||||
if (fRecvBuffer)
|
||||
free(fRecvBuffer);
|
||||
}
|
||||
|
||||
fSendPort = link.fSendPort;
|
||||
fReceivePort = create_port(30,"PortLink reply port");
|
||||
status_t BPortLink::StartMessage(int32 code)
|
||||
{
|
||||
if (EndMessage() < B_OK) //end previous message
|
||||
CancelMessage(); //abandon previous message
|
||||
|
||||
if (fSendBufferSize == 0)
|
||||
{
|
||||
fSendBuffer = (char *)malloc(kInitialSendBufferSize);
|
||||
if (fSendBuffer == NULL)
|
||||
{
|
||||
fWriteError = B_NO_MEMORY;
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
fSendBufferSize = kInitialSendBufferSize;
|
||||
}
|
||||
|
||||
status_t err;
|
||||
//must have space for at least size + code + flags
|
||||
if (fSendBufferSize - fSendPosition < kHeaderSize)
|
||||
{
|
||||
err = Flush(); //will set fSendPosition and fSendStart to 0
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
}
|
||||
|
||||
int32 *p = (int32 *)(fSendBuffer + fSendStart); //start of current message
|
||||
*p = 0; //size
|
||||
*(++p) = code; //code
|
||||
*(++p) = 0; //flags
|
||||
fSendPosition += kHeaderSize; //size + code + flags
|
||||
|
||||
fSendCode = 0;
|
||||
fSendBuffer = new char[SESSION_BUFFER_SIZE * 4];
|
||||
fSendPosition = 8;
|
||||
fDataSize = (int32*)(fSendBuffer+sizeof(int32));
|
||||
*fDataSize = 0;
|
||||
STRACE(("info: BPortLink buffered header %s [%ld %ld %ld].\n", strcode(code), (int32)0, *(p-1), *p));
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
PortLink::~PortLink(void)
|
||||
status_t BPortLink::EndMessage()
|
||||
{
|
||||
delete [] fSendBuffer;
|
||||
}
|
||||
if (fSendPosition == fSendStart || fWriteError < B_OK)
|
||||
return fWriteError;
|
||||
|
||||
void PortLink::SetOpCode( int32 code )
|
||||
{
|
||||
fSendCode=code;
|
||||
int32 *cast=(int32*)fSendBuffer;
|
||||
*cast=code;
|
||||
}
|
||||
int32 *p = (int32 *)(fSendBuffer + fSendStart); //start of the message
|
||||
*p = fSendPosition - fSendStart; //record the size of the message
|
||||
fSendCount++; //increase the number of completed messages
|
||||
|
||||
void PortLink::SetPort( port_id port )
|
||||
{
|
||||
port_info pi;
|
||||
fSendStart = fSendPosition; //start of next new message
|
||||
|
||||
return B_OK;
|
||||
STRACE(("info: BPortLink EndMessage() of size %ld.\n", *p));
|
||||
}
|
||||
|
||||
void BPortLink::CancelMessage()
|
||||
{
|
||||
fSendPosition = fSendStart;
|
||||
fWriteError = B_OK;
|
||||
}
|
||||
|
||||
status_t BPortLink::Attach(const void *data, ssize_t size)
|
||||
{
|
||||
if (fWriteError < B_OK)
|
||||
return fWriteError;
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
fWriteError = B_BAD_VALUE;
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
if (fSendPosition == fSendStart)
|
||||
return B_NO_INIT; //need to call StartMessage() first
|
||||
|
||||
int32 remaining = fSendBufferSize - fSendPosition;
|
||||
if (remaining < size) //we have to make space for the data
|
||||
{
|
||||
int32 total = size + (fSendPosition - fSendStart);
|
||||
//resulting size of current message
|
||||
|
||||
int32 newbuffersize;
|
||||
if (total <= fSendBufferSize)
|
||||
newbuffersize = fSendBufferSize; //no change
|
||||
else if (total > kMaxSendBufferSize)
|
||||
{
|
||||
fWriteError = B_BAD_VALUE;
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
else if (total <= kInitialSendBufferSize)
|
||||
newbuffersize = kInitialSendBufferSize;
|
||||
else
|
||||
newbuffersize = (total + B_PAGE_SIZE) - (total % B_PAGE_SIZE);
|
||||
|
||||
//FlushCompleted() to make space
|
||||
status_t err;
|
||||
err = FlushCompleted(newbuffersize);
|
||||
if (err < B_OK)
|
||||
{
|
||||
fWriteError = err;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(fSendBuffer + fSendPosition, data, size);
|
||||
fSendPosition += size;
|
||||
return fWriteError;
|
||||
}
|
||||
|
||||
status_t BPortLink::FlushCompleted(ssize_t newbuffersize)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
if (newbuffersize == fSendBufferSize)
|
||||
buffer = fSendBuffer; //keep existing buffer
|
||||
else
|
||||
{
|
||||
//create new larger buffer
|
||||
buffer = (char *)malloc(newbuffersize);
|
||||
if (buffer == NULL)
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
int32 position = fSendPosition;
|
||||
int32 start = fSendStart;
|
||||
fSendPosition = fSendStart; //trick to hide the incomplete message
|
||||
|
||||
status_t err;
|
||||
err = Flush();
|
||||
if (err < B_OK)
|
||||
{
|
||||
fSendPosition = position;
|
||||
if (buffer != fSendBuffer)
|
||||
free(buffer);
|
||||
return err;
|
||||
}
|
||||
|
||||
//move the incomplete message to the start of the buffer
|
||||
fSendPosition = min_c(position - start, newbuffersize);
|
||||
memcpy(buffer, fSendBuffer + start, fSendPosition);
|
||||
|
||||
if (fSendBuffer != buffer)
|
||||
{
|
||||
free(fSendBuffer);
|
||||
fSendBuffer = buffer;
|
||||
fSendBufferSize = newbuffersize;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void BPortLink::SetSendPort( port_id port )
|
||||
{
|
||||
fSendPort=port;
|
||||
fPortValid=(get_port_info(port, &pi) == B_OK)? true: false;
|
||||
}
|
||||
|
||||
port_id PortLink::GetPort()
|
||||
port_id BPortLink::GetSendPort()
|
||||
{
|
||||
return fSendPort;
|
||||
}
|
||||
|
||||
status_t PortLink::Flush(bigtime_t timeout)
|
||||
void BPortLink::SetReplyPort( port_id port )
|
||||
{
|
||||
status_t write_stat;
|
||||
|
||||
if(!fPortValid)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if(timeout!=B_INFINITE_TIMEOUT)
|
||||
write_stat=write_port_etc(fSendPort, AS_SERVER_PORTLINK, fSendBuffer,
|
||||
fSendPosition, B_TIMEOUT, timeout);
|
||||
else
|
||||
write_stat=write_port(fSendPort, AS_SERVER_PORTLINK, fSendBuffer, fSendPosition);
|
||||
|
||||
fSendPosition=8;
|
||||
*fDataSize=0;
|
||||
|
||||
return write_stat;
|
||||
fReceivePort=port;
|
||||
}
|
||||
|
||||
status_t PortLink::FlushWithReply( PortMessage *msg,bigtime_t timeout )
|
||||
port_id BPortLink::GetReplyPort()
|
||||
{
|
||||
if(!fPortValid || !msg)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// attach our reply port_id at the end
|
||||
Attach<int32>(fReceivePort);
|
||||
|
||||
// Flush the thing....FOOSH! :P
|
||||
write_port(fSendPort, AS_SERVER_PORTLINK, fSendBuffer, fSendPosition);
|
||||
fSendPosition = 8;
|
||||
*fDataSize=0;
|
||||
|
||||
// Now we wait for the reply
|
||||
msg->ReadFromPort(fReceivePort,timeout);
|
||||
|
||||
return B_OK;
|
||||
return fReceivePort;
|
||||
}
|
||||
|
||||
// Deprecated compatibility hack added to allow PortLink to send messages in a fashion
|
||||
// like BSession. This was because originally there were differences in how they sent
|
||||
// messages across ports. This is no longer the case, so this call should never need to be
|
||||
// made. It remains only until current calls to it can be removed.
|
||||
status_t PortLink::FlushToSession()
|
||||
status_t BPortLink::Flush(bigtime_t timeout)
|
||||
{
|
||||
BSession ses(0, fSendPort);
|
||||
ses.CopyToSendBuffer(fSendBuffer, fSendPosition - 8);
|
||||
ses.Sync();
|
||||
return B_OK;
|
||||
}
|
||||
if (fWriteError < B_OK)
|
||||
return fWriteError;
|
||||
|
||||
status_t PortLink::Attach(const void *data, size_t size)
|
||||
{
|
||||
if (!data || size <= 0)
|
||||
return B_ERROR;
|
||||
|
||||
if (SESSION_BUFFER_SIZE - fSendPosition > (int32)size)
|
||||
EndMessage();
|
||||
if (fSendCount == 0)
|
||||
return B_OK;
|
||||
|
||||
STRACE(("info: BPortLink Flush() waiting to send %ld messages of %ld bytes on port %ld.\n", fSendCount, fSendPosition, fSendPort));
|
||||
|
||||
//TODO: we only need AS_SERVER_PORTLINK when all OBOS uses BPortLink
|
||||
int32 protocol = (fSendCount > 1 ? AS_SERVER_SESSION : AS_SERVER_PORTLINK);
|
||||
|
||||
status_t err;
|
||||
if(timeout != B_INFINITE_TIMEOUT)
|
||||
{
|
||||
memcpy(fSendBuffer + fSendPosition, data, size);
|
||||
fSendPosition += size;
|
||||
*fDataSize+=size;
|
||||
do {
|
||||
err = write_port_etc(fSendPort, protocol, fSendBuffer,
|
||||
fSendPosition, B_RELATIVE_TIMEOUT, timeout);
|
||||
} while(err == B_INTERRUPTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
do {
|
||||
err = write_port(fSendPort, protocol, fSendBuffer, fSendPosition);
|
||||
} while(err == B_INTERRUPTED);
|
||||
}
|
||||
|
||||
if (err == B_OK)
|
||||
{
|
||||
STRACE(("info: BPortLink Flush() %ld messages total of %ld bytes on port %ld.\n", fSendCount, fSendPosition, fSendPort));
|
||||
fSendPosition = 0;
|
||||
fSendStart = 0;
|
||||
fSendCount = 0;
|
||||
return B_OK;
|
||||
}
|
||||
return B_NO_MEMORY;
|
||||
|
||||
STRACE(("error info: BPortLink Flush() failed for %ld bytes (%s) on port %ld.\n", fSendPosition, strerror(err), fSendPort));
|
||||
return err;
|
||||
}
|
||||
|
||||
status_t PortLink::AttachString(const char *string)
|
||||
status_t BPortLink::GetNextReply(int32 *code, bigtime_t timeout)
|
||||
{
|
||||
int16 len = (int16)strlen(string)+1;
|
||||
int32 remaining;
|
||||
|
||||
Attach<int16>(len);
|
||||
return Attach(string, len);
|
||||
fReadError = B_OK;
|
||||
|
||||
remaining = fDataSize - (fRecvStart + fReplySize);
|
||||
STRACE(("info: BPortLink GetNextReply() reports %ld bytes remaining in buffer.\n", remaining));
|
||||
|
||||
//find the position of the next message header in the buffer
|
||||
int32 *header;
|
||||
if (remaining <= 0)
|
||||
{
|
||||
status_t err = ReadFromPort(timeout);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
remaining = fDataSize;
|
||||
header = (int32 *)fRecvBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
fRecvStart += fReplySize; //start of the next message
|
||||
fRecvPosition = fRecvStart;
|
||||
header = (int32 *)(fRecvBuffer + fRecvStart);
|
||||
}
|
||||
|
||||
//check we have a well-formed message
|
||||
if (remaining < kHeaderSize)
|
||||
//we don't have enough data for a complete header
|
||||
{
|
||||
STRACE(("error info: BPortLink remaining %ld bytes is less than header size.\n", remaining));
|
||||
ResetReplyBuffer();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
fReplySize = *header; //size of the first message
|
||||
if (fReplySize > remaining || fReplySize < kHeaderSize)
|
||||
//the header info declares more data than we have OR
|
||||
//the header info declares less data than kHeaderSize
|
||||
{
|
||||
STRACE(("error info: BPortLink message size of %ld bytes smaller than header size.\n", fReplySize));
|
||||
ResetReplyBuffer();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
*code = *(++header);
|
||||
fRecvPosition += kHeaderSize; //size + code + flags
|
||||
|
||||
STRACE(("info: BPortLink got header %s [%ld %ld %ld] from port %ld.\n", strcode(*code), fReplySize, *code, *(header + 1), fReceivePort));
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void PortLink::MakeEmpty()
|
||||
void BPortLink::ResetReplyBuffer()
|
||||
{
|
||||
fSendPosition=8;
|
||||
*fDataSize=0;
|
||||
fRecvPosition = 0;
|
||||
fRecvStart = 0;
|
||||
fDataSize = 0;
|
||||
fReplySize = 0;
|
||||
}
|
||||
|
||||
status_t BPortLink::AdjustReplyBuffer(bigtime_t timeout)
|
||||
{
|
||||
//Here we take advantage of the compiler's dead-code elimination
|
||||
if (kInitialReceiveBufferSize == kMaxReceiveBufferSize) //fixed buffer size
|
||||
{
|
||||
if (fRecvBuffer != NULL)
|
||||
return B_OK;
|
||||
|
||||
fRecvBuffer = (char *)malloc(kInitialReceiveBufferSize);
|
||||
if (fRecvBuffer == NULL)
|
||||
return B_NO_MEMORY;
|
||||
fRecvBufferSize = kInitialReceiveBufferSize;
|
||||
}
|
||||
else //if (kInitialReceiveBufferSize < kMaxReceiveBufferSize)
|
||||
{
|
||||
STRACE(("info: BPortLink getting port_buffer_size().\n"));
|
||||
ssize_t buffersize;
|
||||
if (timeout == B_INFINITE_TIMEOUT)
|
||||
buffersize = port_buffer_size(fReceivePort);
|
||||
else
|
||||
buffersize = port_buffer_size_etc(fReceivePort, B_TIMEOUT, timeout);
|
||||
STRACE(("info: BPortLink got port_buffer_size() = %ld.\n", buffersize));
|
||||
|
||||
if (buffersize < 0)
|
||||
return (status_t)buffersize;
|
||||
|
||||
//make sure our receive buffer is large enough
|
||||
if (buffersize > fRecvBufferSize)
|
||||
{
|
||||
if (buffersize <= kInitialReceiveBufferSize)
|
||||
buffersize = kInitialReceiveBufferSize;
|
||||
else
|
||||
buffersize = (buffersize + B_PAGE_SIZE) - (buffersize % B_PAGE_SIZE);
|
||||
if (buffersize > kMaxReceiveBufferSize)
|
||||
return B_ERROR; //we can't continue
|
||||
|
||||
STRACE(("info: BPortLink setting receive buffersize to %ld.\n", buffersize));
|
||||
char *buffer = (char *)malloc(buffersize);
|
||||
if (buffer == NULL)
|
||||
return B_NO_MEMORY;
|
||||
if (fRecvBuffer)
|
||||
free(fRecvBuffer);
|
||||
fRecvBuffer = buffer;
|
||||
fRecvBufferSize = buffersize;
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t BPortLink::ReadFromPort(bigtime_t timeout)
|
||||
{
|
||||
//we are here so it means we finished reading the buffer contents
|
||||
ResetReplyBuffer();
|
||||
|
||||
status_t err = AdjustReplyBuffer(timeout);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
int32 protocol;
|
||||
ssize_t bytesread;
|
||||
STRACE(("info: BPortLink reading port %ld.\n", fReceivePort));
|
||||
if (timeout != B_INFINITE_TIMEOUT)
|
||||
{
|
||||
do {
|
||||
bytesread = read_port_etc(fReceivePort, &protocol, fRecvBuffer,
|
||||
fRecvBufferSize, B_TIMEOUT, timeout);
|
||||
} while(bytesread == B_INTERRUPTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
do {
|
||||
bytesread = read_port(fReceivePort, &protocol, fRecvBuffer,
|
||||
fRecvBufferSize);
|
||||
} while(bytesread == B_INTERRUPTED);
|
||||
}
|
||||
|
||||
STRACE(("info: BPortLink read %ld bytes.\n", bytesread));
|
||||
if (bytesread < B_OK)
|
||||
return bytesread;
|
||||
|
||||
//TODO: we only need AS_SERVER_PORTLINK when all OBOS uses BPortLink
|
||||
if (protocol != AS_SERVER_PORTLINK && protocol != AS_SERVER_SESSION)
|
||||
return B_ERROR;
|
||||
if (protocol == AS_SERVER_PORTLINK && bytesread != *((int32 *)fRecvBuffer))
|
||||
//should only be one message for PORTLINK so the size declared in the header
|
||||
//(the first int32 in the header) should be the same as bytesread
|
||||
return B_ERROR;
|
||||
|
||||
fDataSize = bytesread;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t BPortLink::Read(void *data, ssize_t size)
|
||||
{
|
||||
// STRACE(("info: BPortLink Read()ing %ld bytes...\n", size));
|
||||
if (fReadError < B_OK)
|
||||
return fReadError;
|
||||
|
||||
if (size < 1)
|
||||
{
|
||||
fReadError = B_BAD_VALUE;
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
if (fDataSize == 0 || fReplySize == 0)
|
||||
return B_NO_INIT; //need to call GetNextReply() first
|
||||
|
||||
if (fRecvPosition + size > fRecvStart + fReplySize)
|
||||
{
|
||||
//reading past the end of current message
|
||||
fReadError = B_BAD_VALUE;
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
memcpy(data, fRecvBuffer + fRecvPosition, size);
|
||||
fRecvPosition += size;
|
||||
return fReadError;
|
||||
}
|
||||
|
||||
status_t BPortLink::ReadString(char **string)
|
||||
{
|
||||
status_t err;
|
||||
int32 len = 0;
|
||||
|
||||
err = Read<int32>(&len);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
if (len)
|
||||
{
|
||||
*string = (char *)malloc(len);
|
||||
if (*string == NULL)
|
||||
{
|
||||
fRecvPosition -= sizeof(int32); //rewind the transaction
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
err = Read(*string, len);
|
||||
if (err < B_OK)
|
||||
{
|
||||
free(*string);
|
||||
*string = NULL;
|
||||
fRecvPosition -= sizeof(int32); //rewind the transaction
|
||||
return err;
|
||||
}
|
||||
(*string)[len-1] = '\0';
|
||||
return B_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
fRecvPosition -= sizeof(int32); //rewind the transaction
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
status_t BPortLink::AttachString(const char *string)
|
||||
{
|
||||
status_t err;
|
||||
if (string == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
int32 len = strlen(string)+1;
|
||||
err = Attach<int32>(len);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
err = Attach(string, len);
|
||||
if (err < B_OK)
|
||||
fSendPosition -= sizeof(int32); //rewind the transaction
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BPORTLINK
|
||||
#include <ServerProtocol.h>
|
||||
|
||||
static const char *kASCodeNames[] =
|
||||
{
|
||||
"SERVER_TRUE",
|
||||
"SERVER_FALSE",
|
||||
"AS_SERVER_BMESSAGE",
|
||||
"AS_SERVER_AREALINK",
|
||||
"AS_SERVER_SESSION",
|
||||
"AS_SERVER_PORTLINK",
|
||||
"AS_CLIENT_DEAD",
|
||||
"AS_CREATE_APP",
|
||||
"AS_DELETE_APP",
|
||||
"AS_QUIT_APP",
|
||||
"AS_SET_SERVER_PORT",
|
||||
"AS_CREATE_WINDOW",
|
||||
"AS_DELETE_WINDOW",
|
||||
"AS_CREATE_BITMAP",
|
||||
"AS_DELETE_BITMAP",
|
||||
"AS_SET_CURSOR_DATA",
|
||||
"AS_SET_CURSOR_BCURSOR",
|
||||
"AS_SET_CURSOR_BBITMAP",
|
||||
"AS_SET_CURSOR_SYSTEM",
|
||||
"AS_SET_SYSCURSOR_DATA",
|
||||
"AS_SET_SYSCURSOR_BCURSOR",
|
||||
"AS_SET_SYSCURSOR_BBITMAP",
|
||||
"AS_SET_SYSCURSOR_DEFAULTS",
|
||||
"AS_GET_SYSCURSOR",
|
||||
"AS_SHOW_CURSOR",
|
||||
"AS_HIDE_CURSOR",
|
||||
"AS_OBSCURE_CURSOR",
|
||||
"AS_QUERY_CURSOR_HIDDEN",
|
||||
"AS_CREATE_BCURSOR",
|
||||
"AS_DELETE_BCURSOR",
|
||||
"AS_BEGIN_RECT_TRACKING",
|
||||
"AS_END_RECT_TRACKING",
|
||||
"AS_SHOW_WINDOW",
|
||||
"AS_HIDE_WINDOW",
|
||||
"AS_QUIT_WINDOW",
|
||||
"AS_SEND_BEHIND",
|
||||
"AS_SET_LOOK",
|
||||
"AS_SET_FEEL",
|
||||
"AS_SET_FLAGS",
|
||||
"AS_DISABLE_UPDATES",
|
||||
"AS_ENABLE_UPDATES",
|
||||
"AS_BEGIN_UPDATE",
|
||||
"AS_END_UPDATE",
|
||||
"AS_NEEDS_UPDATE",
|
||||
"AS_WINDOW_TITLE",
|
||||
"AS_ADD_TO_SUBSET",
|
||||
"AS_REM_FROM_SUBSET",
|
||||
"AS_SET_ALIGNMENT",
|
||||
"AS_GET_ALIGNMENT",
|
||||
"AS_GET_WORKSPACES",
|
||||
"AS_SET_WORKSPACES",
|
||||
"AS_WINDOW_RESIZE",
|
||||
"AS_WINDOW_MOVE",
|
||||
"AS_SET_SIZE_LIMITS",
|
||||
"AS_ACTIVATE_WINDOW",
|
||||
"AS_WINDOW_MINIMIZE",
|
||||
"AS_UPDATE_IF_NEEDED",
|
||||
"_ALL_UPDATED_",
|
||||
"AS_CREATE_PICTURE",
|
||||
"AS_DELETE_PICTURE",
|
||||
"AS_CLONE_PICTURE",
|
||||
"AS_DOWNLOAD_PICTURE",
|
||||
"AS_QUERY_FONTS_CHANGED",
|
||||
"AS_UPDATED_CLIENT_FONTLIST",
|
||||
"AS_GET_FAMILY_ID",
|
||||
"AS_GET_STYLE_ID",
|
||||
"AS_GET_STYLE_FOR_FACE",
|
||||
"AS_GET_SCREEN_MODE",
|
||||
"AS_SET_UI_COLORS",
|
||||
"AS_GET_UI_COLORS",
|
||||
"AS_GET_UI_COLOR",
|
||||
"AS_SET_DECORATOR",
|
||||
"AS_GET_DECORATOR",
|
||||
"AS_R5_SET_DECORATOR",
|
||||
"AS_COUNT_WORKSPACES",
|
||||
"AS_SET_WORKSPACE_COUNT",
|
||||
"AS_CURRENT_WORKSPACE",
|
||||
"AS_ACTIVATE_WORKSPACE",
|
||||
"AS_SET_SCREEN_MODE",
|
||||
"AS_GET_SCROLLBAR_INFO",
|
||||
"AS_SET_SCROLLBAR_INFO",
|
||||
"AS_IDLE_TIME",
|
||||
"AS_SELECT_PRINTER_PANEL",
|
||||
"AS_ADD_PRINTER_PANEL",
|
||||
"AS_RUN_BE_ABOUT",
|
||||
"AS_SET_FOCUS_FOLLOWS_MOUSE",
|
||||
"AS_FOCUS_FOLLOWS_MOUSE",
|
||||
"AS_SET_MOUSE_MODE",
|
||||
"AS_GET_MOUSE_MODE",
|
||||
"AS_WORKSPACE_ACTIVATED",
|
||||
"AS_WORKSPACES_CHANGED",
|
||||
"AS_WINDOW_ACTIVATED",
|
||||
"AS_SCREENMODE_CHANGED",
|
||||
"AS_BEGIN_TRANSACTION",
|
||||
"AS_END_TRANSACTION",
|
||||
"AS_SET_HIGH_COLOR",
|
||||
"AS_SET_LOW_COLOR",
|
||||
"AS_SET_VIEW_COLOR",
|
||||
"AS_STROKE_ARC",
|
||||
"AS_STROKE_BEZIER",
|
||||
"AS_STROKE_ELLIPSE",
|
||||
"AS_STROKE_LINE",
|
||||
"AS_STROKE_LINEARRAY",
|
||||
"AS_STROKE_POLYGON",
|
||||
"AS_STROKE_RECT",
|
||||
"AS_STROKE_ROUNDRECT",
|
||||
"AS_STROKE_SHAPE",
|
||||
"AS_STROKE_TRIANGLE",
|
||||
"AS_FILL_ARC",
|
||||
"AS_FILL_BEZIER",
|
||||
"AS_FILL_ELLIPSE",
|
||||
"AS_FILL_POLYGON",
|
||||
"AS_FILL_RECT",
|
||||
"AS_FILL_REGION",
|
||||
"AS_FILL_ROUNDRECT",
|
||||
"AS_FILL_SHAPE",
|
||||
"AS_FILL_TRIANGLE",
|
||||
"AS_MOVEPENBY",
|
||||
"AS_MOVEPENTO",
|
||||
"AS_SETPENSIZE",
|
||||
"AS_DRAW_STRING",
|
||||
"AS_SET_FONT",
|
||||
"AS_SET_FONT_SIZE",
|
||||
"AS_FLUSH",
|
||||
"AS_SYNC",
|
||||
"AS_LAYER_CREATE",
|
||||
"AS_LAYER_DELETE",
|
||||
"AS_LAYER_CREATE_ROOT",
|
||||
"AS_LAYER_DELETE_ROOT",
|
||||
"AS_LAYER_ADD_CHILD",
|
||||
"AS_LAYER_REMOVE_CHILD",
|
||||
"AS_LAYER_REMOVE_SELF",
|
||||
"AS_LAYER_SHOW",
|
||||
"AS_LAYER_HIDE",
|
||||
"AS_LAYER_MOVE",
|
||||
"AS_LAYER_RESIZE",
|
||||
"AS_LAYER_INVALIDATE",
|
||||
"AS_LAYER_DRAW",
|
||||
"AS_LAYER_GET_TOKEN",
|
||||
"AS_LAYER_ADD",
|
||||
"AS_LAYER_REMOVE",
|
||||
"AS_LAYER_GET_COORD",
|
||||
"AS_LAYER_SET_FLAGS",
|
||||
"AS_LAYER_SET_ORIGIN",
|
||||
"AS_LAYER_GET_ORIGIN",
|
||||
"AS_LAYER_RESIZE_MODE",
|
||||
"AS_LAYER_CURSOR",
|
||||
"AS_LAYER_BEGIN_RECT_TRACK",
|
||||
"AS_LAYER_END_RECT_TRACK",
|
||||
"AS_LAYER_DRAG_RECT",
|
||||
"AS_LAYER_DRAG_IMAGE",
|
||||
"AS_LAYER_GET_MOUSE_COORDS",
|
||||
"AS_LAYER_SCROLL",
|
||||
"AS_LAYER_SET_LINE_MODE",
|
||||
"AS_LAYER_GET_LINE_MODE",
|
||||
"AS_LAYER_PUSH_STATE",
|
||||
"AS_LAYER_POP_STATE",
|
||||
"AS_LAYER_SET_SCALE",
|
||||
"AS_LAYER_GET_SCALE",
|
||||
"AS_LAYER_SET_DRAW_MODE",
|
||||
"AS_LAYER_GET_DRAW_MODE",
|
||||
"AS_LAYER_SET_BLEND_MODE",
|
||||
"AS_LAYER_GET_BLEND_MODE",
|
||||
"AS_LAYER_SET_PEN_LOC",
|
||||
"AS_LAYER_GET_PEN_LOC",
|
||||
"AS_LAYER_SET_PEN_SIZE",
|
||||
"AS_LAYER_GET_PEN_SIZE",
|
||||
"AS_LAYER_SET_HIGH_COLOR",
|
||||
"AS_LAYER_SET_LOW_COLOR",
|
||||
"AS_LAYER_SET_VIEW_COLOR",
|
||||
"AS_LAYER_GET_COLORS",
|
||||
"AS_LAYER_PRINT_ALIASING",
|
||||
"AS_LAYER_CLIP_TO_PICTURE",
|
||||
"AS_LAYER_CLIP_TO_INVERSE_PICTURE",
|
||||
"AS_LAYER_GET_CLIP_REGION",
|
||||
"AS_LAYER_DRAW_BITMAP_ASYNC_IN_RECT",
|
||||
"AS_LAYER_DRAW_BITMAP_ASYNC_AT_POINT",
|
||||
"AS_LAYER_DRAW_BITMAP_SYNC_IN_RECT",
|
||||
"AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT",
|
||||
"AS_LAYER_DRAW_STRING",
|
||||
"AS_LAYER_SET_CLIP_REGION",
|
||||
"AS_LAYER_LINE_ARRAY",
|
||||
"AS_LAYER_BEGIN_PICTURE",
|
||||
"AS_LAYER_APPEND_TO_PICTURE",
|
||||
"AS_LAYER_END_PICTURE",
|
||||
"AS_LAYER_COPY_BITS",
|
||||
"AS_LAYER_DRAW_PICTURE",
|
||||
"AS_LAYER_INVAL_RECT",
|
||||
"AS_LAYER_INVAL_REGION",
|
||||
"AS_LAYER_INVERT_RECT",
|
||||
"AS_LAYER_MOVETO",
|
||||
"AS_LAYER_RESIZETO",
|
||||
"AS_LAYER_SET_STATE",
|
||||
"AS_LAYER_SET_FONT_STATE",
|
||||
"AS_LAYER_GET_STATE",
|
||||
"AS_LAYER_SET_VIEW_IMAGE",
|
||||
"AS_LAYER_SET_PATTERN",
|
||||
"AS_SET_CURRENT_LAYER",
|
||||
};
|
||||
|
||||
const char *strcode(int32 code)
|
||||
{
|
||||
code = code - SERVER_TRUE;
|
||||
if (code >= 0 && code <= AS_SET_CURRENT_LAYER - SERVER_TRUE)
|
||||
return kASCodeNames[code];
|
||||
else
|
||||
return "Unknown";
|
||||
}
|
||||
#endif //DEBUG_BPORTLINK
|
||||
|
||||
|
||||
|
@ -22,13 +22,10 @@ APP_KIT_SOURCE =
|
||||
MessageUtils.cpp
|
||||
PropertyInfo.cpp
|
||||
PortLink.cpp
|
||||
PortMessage.cpp
|
||||
PortQueue.cpp
|
||||
RegistrarDefs.cpp
|
||||
RegistrarThread.cpp
|
||||
RegistrarThreadManager.cpp
|
||||
Roster.cpp
|
||||
RosterPrivate.cpp
|
||||
Session.cpp
|
||||
TokenSpace.cpp
|
||||
;
|
||||
|
@ -416,14 +416,9 @@ BPoint BAlert::AlertPosition(float width, float height)
|
||||
dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
|
||||
|
||||
BScreen Screen(Window);
|
||||
if (!Screen.IsValid())
|
||||
{
|
||||
// We should never be here because a BScreen object will return
|
||||
// a valid screen.
|
||||
debugger("Couldn't find the screen!");
|
||||
}
|
||||
|
||||
BRect screenRect = Screen.Frame();
|
||||
BRect screenRect(0, 0, 640, 480);
|
||||
if (Screen.IsValid())
|
||||
screenRect = Screen.Frame();
|
||||
|
||||
// Horizontally, we're smack in the middle
|
||||
result.x = (screenRect.Width() / 2.0) - (width / 2.0);
|
||||
@ -474,7 +469,6 @@ void BAlert::InitObject(const char* text, const char* button0,
|
||||
// Set up the "_master_" view
|
||||
TAlertView* MasterView = new TAlertView(Bounds());
|
||||
MasterView->SetBitmap(InitIcon());
|
||||
AddChild(MasterView);
|
||||
|
||||
// Set up the buttons
|
||||
int buttonCount = 0;
|
||||
@ -621,6 +615,9 @@ void BAlert::InitObject(const char* text, const char* button0,
|
||||
fTextView = new BTextView(TextViewRect, "_tv_",
|
||||
TextViewRect,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
AddChild(MasterView);
|
||||
MasterView->AddChild(fTextView);
|
||||
|
||||
fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
fTextView->SetText(text, strlen(text));
|
||||
fTextView->MakeEditable(false);
|
||||
@ -636,8 +633,6 @@ void BAlert::InitObject(const char* text, const char* button0,
|
||||
TextViewRect.bottom += textHeight;
|
||||
fTextView->SetTextRect(TextViewRect);
|
||||
|
||||
MasterView->AddChild(fTextView);
|
||||
|
||||
AddCommonFilter(new _BAlertFilter_(this));
|
||||
|
||||
MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
|
||||
|
@ -39,11 +39,10 @@
|
||||
// Includes to be able to talk to the app_server
|
||||
#include <Application.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <PortMessage.h>
|
||||
#include <AppServerLink.h>
|
||||
|
||||
enum {
|
||||
NOT_IMPLEMENTED = B_ERROR,
|
||||
NOT_IMPLEMENTED = B_ERROR
|
||||
};
|
||||
|
||||
// TODO: system palette -- hard-coded for now, when the app server is ready
|
||||
@ -2140,7 +2139,7 @@ BBitmap::get_shared_pointer() const
|
||||
int32
|
||||
BBitmap::get_server_token() const
|
||||
{
|
||||
return -1; // not implemented
|
||||
return fServerToken;
|
||||
}
|
||||
|
||||
// InitObject
|
||||
@ -2159,8 +2158,7 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
{
|
||||
status_t error = B_OK;
|
||||
|
||||
PortMessage pmsg;
|
||||
BPrivate::BAppServerLink *link=new BPrivate::BAppServerLink();
|
||||
BPrivate::BAppServerLink link;
|
||||
|
||||
// clean up
|
||||
if (fBasePtr) {
|
||||
@ -2176,10 +2174,11 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
// Reply Data:
|
||||
// none
|
||||
// status_t freestat;
|
||||
link->SetOpCode(AS_DELETE_BITMAP);
|
||||
link->Attach<int32>(fServerToken);
|
||||
error=link->FlushWithReply(&pmsg);
|
||||
if(pmsg.Code()==SERVER_FALSE)
|
||||
int32 code = SERVER_FALSE;
|
||||
link.StartMessage(AS_DELETE_BITMAP);
|
||||
link.Attach<int32>(fServerToken);
|
||||
error=link.FlushWithReply(&code);
|
||||
if(code==SERVER_FALSE)
|
||||
error=B_NO_MEMORY;
|
||||
fBasePtr=NULL;
|
||||
fArea=-1;
|
||||
@ -2208,12 +2207,12 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
// 3) int32 bitmap_flags
|
||||
// 4) int32 bytes_per_row
|
||||
// 5) int32 screen_id::id
|
||||
link->SetOpCode(AS_CREATE_BITMAP);
|
||||
link->Attach<BRect>(bounds);
|
||||
link->Attach(&colorSpace, sizeof(color_space));
|
||||
link->Attach<int32>((int32)flags);
|
||||
link->Attach<int32>(bytesPerRow);
|
||||
link->Attach<int32>(screenID.id);
|
||||
link.StartMessage(AS_CREATE_BITMAP);
|
||||
link.Attach<BRect>(bounds);
|
||||
link.Attach<color_space>(colorSpace);
|
||||
link.Attach<int32>((int32)flags);
|
||||
link.Attach<int32>(bytesPerRow);
|
||||
link.Attach<int32>(screenID.id);
|
||||
|
||||
// Reply Code: SERVER_TRUE
|
||||
// Reply Data:
|
||||
@ -2225,21 +2224,22 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
// Reply Code: SERVER_FALSE
|
||||
// Reply Data:
|
||||
// None
|
||||
error=link->FlushWithReply(&pmsg);
|
||||
int32 code = SERVER_FALSE;
|
||||
error=link.FlushWithReply(&code);
|
||||
|
||||
// We shouldn't ever have to execute this block, but just in case...
|
||||
if(error!=B_OK)
|
||||
fBasePtr=NULL;
|
||||
|
||||
if(pmsg.Code()==SERVER_TRUE)
|
||||
if(code==SERVER_TRUE)
|
||||
{
|
||||
// Get token
|
||||
area_id bmparea;
|
||||
int32 areaoffset;
|
||||
|
||||
pmsg.Read<int32>(&fServerToken);
|
||||
pmsg.Read<area_id>(&bmparea);
|
||||
pmsg.Read<int32>(&areaoffset);
|
||||
link.Read<int32>(&fServerToken);
|
||||
link.Read<area_id>(&bmparea);
|
||||
link.Read<int32>(&areaoffset);
|
||||
|
||||
// Get the area in which the data resides
|
||||
fArea=clone_area("shared bitmap area",(void**)&fBasePtr,B_ANY_ADDRESS,
|
||||
@ -2266,7 +2266,6 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
fToken = -1;
|
||||
fOrigArea = -1;
|
||||
}
|
||||
delete link;
|
||||
fInitError = error;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
BButton::BButton(BRect frame, const char *name, const char *label, BMessage *message,
|
||||
uint32 resizingMode, uint32 flags)
|
||||
: BControl(frame, name, label, message, resizingMode, flags),
|
||||
: BControl(frame, name, label, message, resizingMode, flags |= B_WILL_DRAW),
|
||||
fDrawAsDefault(false)
|
||||
{
|
||||
// Resize to minimum height if needed
|
||||
@ -95,7 +95,7 @@ void BButton::Draw(BRect updateRect)
|
||||
// If the focus is changing, just redraw the focus indicator
|
||||
if (IsFocusChanging())
|
||||
{
|
||||
float x = bounds.right / 2 - StringWidth(Label()) / 2.0f;
|
||||
float x = (bounds.right - StringWidth(Label())) / 2.0f;
|
||||
float y = bounds.bottom - fh.descent - (IsDefault() ? 6.0f : 3.0f);
|
||||
|
||||
if (IsFocus())
|
||||
@ -185,7 +185,7 @@ void BButton::Draw(BRect updateRect)
|
||||
}
|
||||
|
||||
// Label
|
||||
float x = bounds.right / 2 - StringWidth(Label()) / 2.0f;
|
||||
float x = (bounds.right - StringWidth(Label())) / 2.0f;
|
||||
float y = bounds.bottom - fh.descent - (IsDefault() ? 8.0f : 5.0f);
|
||||
|
||||
if (Value())
|
||||
@ -260,7 +260,7 @@ void BButton::Draw(BRect updateRect)
|
||||
FillRect(rect);
|
||||
|
||||
// Label
|
||||
float x = bounds.right / 2 - StringWidth(Label()) / 2.0f;
|
||||
float x = (bounds.right - StringWidth(Label())) / 2.0f;
|
||||
float y = bounds.bottom - fh.descent - 5.0f;
|
||||
|
||||
SetHighColor(tint_color(no_tint, B_DISABLED_LABEL_TINT));
|
||||
@ -278,16 +278,23 @@ void BButton::MouseDown(BPoint point)
|
||||
|
||||
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
SetTracking(true);
|
||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
BRect bounds = Bounds();
|
||||
uint32 buttons;
|
||||
|
||||
do
|
||||
{
|
||||
Window()->UpdateIfNeeded();
|
||||
|
||||
snooze(40000);
|
||||
|
||||
GetMouse(&point, &buttons, true);
|
||||
|
||||
bool inside = bounds.Contains(point);
|
||||
bool inside = bounds.Contains(ConvertFromScreen(point));
|
||||
|
||||
if ((Value() == B_CONTROL_ON) != inside)
|
||||
SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||
@ -296,11 +303,6 @@ void BButton::MouseDown(BPoint point)
|
||||
if (Value() == B_CONTROL_ON)
|
||||
Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTracking(true);
|
||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BButton::AttachedToWindow()
|
||||
|
@ -34,11 +34,15 @@
|
||||
#include <String.h>
|
||||
|
||||
#include <PortLink.h>
|
||||
#include <PortMessage.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <ServerConfig.h>
|
||||
|
||||
//#define DEBUG_CLIENT_FONT_LIST
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
# define STRACE(x) printf x
|
||||
#else
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
class FontListFamily
|
||||
{
|
||||
@ -70,18 +74,15 @@ FontListFamily::~FontListFamily(void)
|
||||
|
||||
ClientFontList::ClientFontList(void)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList()\n");
|
||||
#endif
|
||||
STRACE(("ClientFontList()\n"));
|
||||
familylist=new BList(0);
|
||||
fontlock=create_sem(1,"fontlist_sem");
|
||||
}
|
||||
|
||||
ClientFontList::~ClientFontList(void)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("~ClientFontList()\n");
|
||||
#endif
|
||||
STRACE(("~ClientFontList()\n"));
|
||||
|
||||
acquire_sem(fontlock);
|
||||
|
||||
font_family *fam;
|
||||
@ -97,9 +98,8 @@ printf("~ClientFontList()\n");
|
||||
|
||||
bool ClientFontList::Update(bool check_only)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::Update(%s) - %s\n", (check_only)?"true":"false",SERVER_FONT_LIST);
|
||||
#endif
|
||||
STRACE(("ClientFontList::Update(%s) - %s\n", (check_only)?"true":"false",SERVER_FONT_LIST));
|
||||
|
||||
// Open the font list kept in font list
|
||||
acquire_sem(fontlock);
|
||||
|
||||
@ -108,29 +108,27 @@ printf("ClientFontList::Update(%s) - %s\n", (check_only)?"true":"false",SERVER_F
|
||||
serverport=find_port(SERVER_PORT_NAME);
|
||||
|
||||
bool needs_update=true;
|
||||
PortLink *serverlink=new PortLink(serverport);
|
||||
BPortLink serverlink(serverport);
|
||||
|
||||
if(serverport!=B_NAME_NOT_FOUND)
|
||||
{
|
||||
PortMessage pmsg;
|
||||
serverlink->SetOpCode(AS_QUERY_FONTS_CHANGED);
|
||||
serverlink->FlushWithReply(&pmsg);
|
||||
int32 code=SERVER_FALSE;
|
||||
serverlink.StartMessage(AS_QUERY_FONTS_CHANGED);
|
||||
serverlink.Flush();
|
||||
serverlink.GetNextReply(&code);
|
||||
|
||||
// Attached Data: none
|
||||
// Reply: SERVER_TRUE if fonts have changed, SERVER_FALSE if not
|
||||
|
||||
needs_update=(pmsg.Code()==SERVER_TRUE)?true:false;
|
||||
needs_update=(code==SERVER_TRUE)?true:false;
|
||||
}
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
else
|
||||
{
|
||||
printf("ClientFontList::Update(): Couldn't find app_server port\n");
|
||||
STRACE(("ClientFontList::Update(): Couldn't find app_server port\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
if(check_only)
|
||||
{
|
||||
delete serverlink;
|
||||
release_sem(fontlock);
|
||||
return needs_update;
|
||||
}
|
||||
@ -145,10 +143,11 @@ printf("ClientFontList::Update(%s) - %s\n", (check_only)?"true":"false",SERVER_F
|
||||
{
|
||||
if(fontmsg.Unflatten(&file)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Font message contents:\n");
|
||||
fontmsg.PrintToStream();
|
||||
#endif
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Font message contents:\n");
|
||||
fontmsg.PrintToStream();
|
||||
#endif
|
||||
|
||||
// Empty the font list
|
||||
FontListFamily *flf=(FontListFamily*)familylist->RemoveItem(0L);
|
||||
BString sty, extra;
|
||||
@ -157,15 +156,11 @@ fontmsg.PrintToStream();
|
||||
|
||||
while(flf)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Removing %s from list\n",flf->name.String());
|
||||
#endif
|
||||
STRACE(("Removing %s from list\n",flf->name.String()));
|
||||
delete flf;
|
||||
flf=(FontListFamily*)familylist->RemoveItem(0L);
|
||||
}
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("\n");
|
||||
#endif
|
||||
STRACE(("\n"));
|
||||
|
||||
famindex=0;
|
||||
|
||||
@ -178,44 +173,35 @@ printf("\n");
|
||||
familylist->AddItem(flf);
|
||||
familymsg.FindString("name",&(flf->name));
|
||||
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Adding %s to list\n",flf->name.String());
|
||||
#endif
|
||||
STRACE(("Adding %s to list\n",flf->name.String()));
|
||||
styindex=0;
|
||||
|
||||
// populate family with styles
|
||||
while(familymsg.FindString("styles",styindex,&sty)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("\tAdding %s\n",sty.String());
|
||||
#endif
|
||||
STRACE(("\tAdding %s\n",sty.String()));
|
||||
styindex++;
|
||||
flf->styles->AddItem(new BString(sty));
|
||||
}
|
||||
|
||||
if(familymsg.FindBool("tuned",&tempbool)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Family %s has tuned fonts\n", flf->name.String());
|
||||
#endif
|
||||
STRACE(("Family %s has tuned fonts\n", flf->name.String()));
|
||||
flf->flags|=B_HAS_TUNED_FONT;
|
||||
}
|
||||
|
||||
if(familymsg.FindBool("fixed",&tempbool)==B_OK)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("Family %s is fixed-width\n", flf->name.String());
|
||||
#endif
|
||||
STRACE(("Family %s is fixed-width\n", flf->name.String()));
|
||||
flf->flags|=B_IS_FIXED;
|
||||
}
|
||||
familymsg.MakeEmpty();
|
||||
|
||||
}
|
||||
|
||||
serverlink->SetOpCode(AS_UPDATED_CLIENT_FONTLIST);
|
||||
serverlink->Flush();
|
||||
serverlink.StartMessage(AS_UPDATED_CLIENT_FONTLIST);
|
||||
serverlink.Flush();
|
||||
|
||||
delete serverlink;
|
||||
release_sem(fontlock);
|
||||
return false;
|
||||
|
||||
@ -223,16 +209,13 @@ printf("Family %s is fixed-width\n", flf->name.String());
|
||||
} // end if InitCheck==B_OK
|
||||
} // end if needs_update
|
||||
|
||||
delete serverlink;
|
||||
release_sem(fontlock);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 ClientFontList::CountFamilies(void)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::CountFamilies\n");
|
||||
#endif
|
||||
STRACE(("ClientFontList::CountFamilies\n"));
|
||||
acquire_sem(fontlock);
|
||||
int32 count=familylist->CountItems();
|
||||
release_sem(fontlock);
|
||||
@ -241,14 +224,10 @@ printf("ClientFontList::CountFamilies\n");
|
||||
|
||||
status_t ClientFontList::GetFamily(int32 index, font_family *name, uint32 *flags)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::GetFamily(%ld)\n",index);
|
||||
#endif
|
||||
STRACE(("ClientFontList::GetFamily(%ld)\n",index));
|
||||
if(!name)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::GetFamily: NULL font_family parameter\n");
|
||||
#endif
|
||||
STRACE(("ClientFontList::GetFamily: NULL font_family parameter\n"));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@ -256,9 +235,7 @@ printf("ClientFontList::GetFamily: NULL font_family parameter\n");
|
||||
FontListFamily *flf=(FontListFamily*)familylist->ItemAt(index);
|
||||
if(!flf)
|
||||
{
|
||||
#ifdef DEBUG_CLIENT_FONT_LIST
|
||||
printf("ClientFontList::GetFamily: index not found\n");
|
||||
#endif
|
||||
STRACE(("ClientFontList::GetFamily: index not found\n"));
|
||||
return B_ERROR;
|
||||
}
|
||||
strcpy(*name,flf->name.String());
|
||||
@ -347,39 +324,29 @@ status_t ClientFontList::GetStyle(font_family family, int32 index, font_style *n
|
||||
style->ICompare("Plain")==0)
|
||||
{
|
||||
*face|=B_REGULAR_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Roman face\n", style->String());
|
||||
#endif
|
||||
STRACE(("GetStyle: %s Roman face\n", style->String()));
|
||||
}
|
||||
else
|
||||
if(style->ICompare("Bold")==0)
|
||||
{
|
||||
*face|=B_BOLD_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Bold face\n");
|
||||
#endif
|
||||
STRACE(("GetStyle: %s Bold face\n"));
|
||||
}
|
||||
else
|
||||
if(style->ICompare("Italic")==0)
|
||||
{
|
||||
*face|=B_ITALIC_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Italic face\n");
|
||||
#endif
|
||||
STRACE(("GetStyle: %s Italic face\n"));
|
||||
}
|
||||
else
|
||||
if(style->ICompare("Bold Italic")==0)
|
||||
{
|
||||
*face|=B_ITALIC_FACE | B_BOLD_FACE;
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Bold Italic face\n");
|
||||
#endif
|
||||
STRACE(("GetStyle: %s Bold Italic face\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_FONTSERVER
|
||||
printf("GetStyle: %s Unknown face %s\n", style->String());
|
||||
#endif
|
||||
STRACE(("GetStyle: %s Unknown face %s\n", style->String()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <PropertyInfo.h>
|
||||
#include <Window.h>
|
||||
#include <Errors.h>
|
||||
#include <Debug.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
@ -180,7 +181,7 @@ void BControl::WindowActivated(bool active)
|
||||
BView::WindowActivated(active);
|
||||
|
||||
if (IsFocus())
|
||||
Draw(Bounds());
|
||||
Invalidate(Bounds());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BControl::AttachedToWindow()
|
||||
@ -290,7 +291,7 @@ void BControl::MakeFocus(bool focused)
|
||||
if(Window())
|
||||
{
|
||||
fFocusChanging = true;
|
||||
Draw(Bounds());
|
||||
Invalidate(Bounds());
|
||||
Flush();
|
||||
fFocusChanging = false;
|
||||
}
|
||||
@ -345,7 +346,7 @@ void BControl::SetLabel(const char *string)
|
||||
if (string)
|
||||
fLabel = strdup(string);
|
||||
else
|
||||
fLabel = NULL;
|
||||
fLabel = strdup(B_EMPTY_STRING);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
@ -364,7 +365,7 @@ void BControl::SetValue(int32 value)
|
||||
|
||||
if (Window())
|
||||
{
|
||||
Draw(Bounds());
|
||||
Invalidate(Bounds());
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
@ -388,7 +389,7 @@ void BControl::SetEnabled(bool enabled)
|
||||
|
||||
if (Window())
|
||||
{
|
||||
Draw(Bounds());
|
||||
Invalidate(Bounds());
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
@ -435,8 +436,8 @@ status_t BControl::Invoke(BMessage *message)
|
||||
if (message)
|
||||
err = BInvoker::Invoke(&clone);
|
||||
|
||||
// TODO: assynchronous messaging
|
||||
// SendNotices(kind, &clone);
|
||||
// TODO: asynchronous messaging
|
||||
SendNotices(kind, &clone);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -513,6 +514,7 @@ BControl &BControl::operator=(const BControl &)
|
||||
void BControl::InitData(BMessage *data)
|
||||
{
|
||||
fLabel = NULL;
|
||||
SetLabel(B_EMPTY_STRING);
|
||||
fValue = B_CONTROL_OFF;
|
||||
fEnabled = true;
|
||||
fFocusChanging = false;
|
||||
@ -523,10 +525,3 @@ void BControl::InitData(BMessage *data)
|
||||
SetFont(be_plain_font, B_FONT_FAMILY_AND_STYLE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
@ -158,17 +158,18 @@ status_t set_font_cache_info(uint32 id, void *set)
|
||||
// BFont Class Definition
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
BFont::BFont(void)
|
||||
BFont::BFont(void)
|
||||
//initialise for be_plain_font (avoid circular definition)
|
||||
: fFamilyID(0), fStyleID(0), fSize(10.0), fShear(0.0), fRotation(0.0),
|
||||
fSpacing(0), fEncoding(0), fFace(0), fFlags(0)
|
||||
{
|
||||
fHeight.ascent = 7.0;
|
||||
fHeight.descent = 2.0;
|
||||
fHeight.leading = 13.0;
|
||||
|
||||
fFamilyID=be_plain_font->fFamilyID;
|
||||
fStyleID=be_plain_font->fStyleID;
|
||||
fSize=be_plain_font->fSize;
|
||||
fShear=be_plain_font->fShear;
|
||||
fRotation=be_plain_font->fRotation;
|
||||
fSpacing=be_plain_font->fSpacing;
|
||||
fEncoding=be_plain_font->fEncoding;
|
||||
fFace=be_plain_font->fFace;
|
||||
fHeight=be_plain_font->fHeight;
|
||||
}
|
||||
|
||||
BFont::BFont(const BFont &font)
|
||||
@ -422,13 +423,17 @@ void BFont::GetTruncatedStrings(const char *stringArray[], int32 numStrings,
|
||||
float BFont::StringWidth(const char *string) const
|
||||
{
|
||||
// TODO: implement
|
||||
return 0.0;
|
||||
|
||||
// an estimate
|
||||
return (fHeight.ascent - fHeight.descent) * strlen(string);
|
||||
}
|
||||
|
||||
float BFont::StringWidth(const char *string, int32 length) const
|
||||
{
|
||||
// TODO: implement
|
||||
return 0.0;
|
||||
|
||||
// an estimate
|
||||
return (fHeight.ascent - fHeight.descent) * length;
|
||||
}
|
||||
|
||||
void BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
|
||||
|
@ -41,10 +41,9 @@
|
||||
#include <WidthBuffer.h>
|
||||
|
||||
// Private definitions not placed in public headers
|
||||
#include <input_globals.h>
|
||||
|
||||
extern "C" void _init_global_fonts();
|
||||
extern "C" status_t _fini_interface_kit_();
|
||||
extern status_t _control_input_server_(BMessage *command, BMessage *reply);
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
@ -61,14 +60,15 @@ _IMPEXP_BE status_t
|
||||
set_screen_space(int32 index, uint32 res, bool stick)
|
||||
{
|
||||
BAppServerLink link;
|
||||
link.SetOpCode(AS_SET_SCREEN_MODE);
|
||||
int32 code = SERVER_FALSE;
|
||||
|
||||
link.StartMessage(AS_SET_SCREEN_MODE);
|
||||
link.Attach<int32>(index);
|
||||
link.Attach<int32>((int32)res);
|
||||
link.Attach<bool>(stick);
|
||||
link.Flush();
|
||||
link.FlushWithReply(&code);
|
||||
|
||||
//TODO: Read back the status from the app_server's reply
|
||||
return B_OK;
|
||||
return ((code==SERVER_TRUE)?B_OK:B_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@ -79,15 +79,14 @@ get_scroll_bar_info(scroll_bar_info *info)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_GET_SCROLLBAR_INFO);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<scroll_bar_info>(info);
|
||||
int32 code;
|
||||
link.StartMessage(AS_GET_SCROLLBAR_INFO);
|
||||
link.FlushWithReply(&code);
|
||||
link.Read<scroll_bar_info>(info);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
_IMPEXP_BE status_t
|
||||
set_scroll_bar_info(scroll_bar_info *info)
|
||||
{
|
||||
@ -95,11 +94,11 @@ set_scroll_bar_info(scroll_bar_info *info)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
int32 code;
|
||||
|
||||
link.SetOpCode(AS_SET_SCROLLBAR_INFO);
|
||||
link.StartMessage(AS_SET_SCROLLBAR_INFO);
|
||||
link.Attach<scroll_bar_info>(*info);
|
||||
link.FlushWithReply(&msg);
|
||||
link.FlushWithReply(&code);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -406,10 +405,10 @@ count_workspaces()
|
||||
int32 count;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_COUNT_WORKSPACES);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int32>(&count);
|
||||
int32 code;
|
||||
link.StartMessage(AS_COUNT_WORKSPACES);
|
||||
link.FlushWithReply(&code);
|
||||
link.Read<int32>(&count);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -418,7 +417,7 @@ _IMPEXP_BE void
|
||||
set_workspace_count(int32 count)
|
||||
{
|
||||
BAppServerLink link;
|
||||
link.SetOpCode(AS_SET_WORKSPACE_COUNT);
|
||||
link.StartMessage(AS_SET_WORKSPACE_COUNT);
|
||||
link.Attach<int32>(count);
|
||||
link.Flush();
|
||||
}
|
||||
@ -430,10 +429,10 @@ current_workspace()
|
||||
int32 index;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_CURRENT_WORKSPACE);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int32>(&index);
|
||||
int32 code;
|
||||
link.StartMessage(AS_CURRENT_WORKSPACE);
|
||||
link.FlushWithReply(&code);
|
||||
link.Read<int32>(&index);
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -443,7 +442,7 @@ _IMPEXP_BE void
|
||||
activate_workspace(int32 workspace)
|
||||
{
|
||||
BAppServerLink link;
|
||||
link.SetOpCode(AS_ACTIVATE_WORKSPACE);
|
||||
link.StartMessage(AS_ACTIVATE_WORKSPACE);
|
||||
link.Attach<int32>(workspace);
|
||||
link.Flush();
|
||||
}
|
||||
@ -455,10 +454,10 @@ idle_time()
|
||||
bigtime_t idletime;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_IDLE_TIME);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int64>(&idletime);
|
||||
int32 code;
|
||||
link.StartMessage(AS_IDLE_TIME);
|
||||
link.FlushWithReply(&code);
|
||||
link.Read<int64>(&idletime);
|
||||
|
||||
return idletime;
|
||||
}
|
||||
@ -493,7 +492,7 @@ _IMPEXP_BE void
|
||||
set_focus_follows_mouse(bool follow)
|
||||
{
|
||||
BAppServerLink link;
|
||||
link.SetOpCode(AS_SET_FOCUS_FOLLOWS_MOUSE);
|
||||
link.StartMessage(AS_SET_FOCUS_FOLLOWS_MOUSE);
|
||||
link.Attach<bool>(follow);
|
||||
link.Flush();
|
||||
}
|
||||
@ -505,10 +504,10 @@ focus_follows_mouse()
|
||||
bool ffm;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_FOCUS_FOLLOWS_MOUSE);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<bool>(&ffm);
|
||||
int32 code;
|
||||
link.StartMessage(AS_FOCUS_FOLLOWS_MOUSE);
|
||||
link.FlushWithReply(&code);
|
||||
link.Read<bool>(&ffm);
|
||||
return ffm;
|
||||
}
|
||||
|
||||
@ -517,7 +516,7 @@ _IMPEXP_BE void
|
||||
set_mouse_mode(mode_mouse mode)
|
||||
{
|
||||
BAppServerLink link;
|
||||
link.SetOpCode(AS_SET_MOUSE_MODE);
|
||||
link.StartMessage(AS_SET_MOUSE_MODE);
|
||||
link.Attach<mode_mouse>(mode);
|
||||
link.Flush();
|
||||
}
|
||||
@ -529,10 +528,10 @@ mouse_mode()
|
||||
mode_mouse mode;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_GET_MOUSE_MODE);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<mode_mouse>(&mode);
|
||||
int32 code;
|
||||
link.StartMessage(AS_GET_MOUSE_MODE);
|
||||
link.FlushWithReply(&code);
|
||||
link.Read<mode_mouse>(&mode);
|
||||
return mode;
|
||||
}
|
||||
|
||||
@ -543,11 +542,12 @@ ui_color(color_which which)
|
||||
rgb_color color;
|
||||
|
||||
BAppServerLink link;
|
||||
PortMessage msg;
|
||||
link.SetOpCode(AS_GET_UI_COLOR);
|
||||
int32 code;
|
||||
link.StartMessage(AS_GET_UI_COLOR);
|
||||
link.Attach<color_which>(which);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<rgb_color>(&color);
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<rgb_color>(&color);
|
||||
return color;
|
||||
}
|
||||
|
||||
@ -630,7 +630,7 @@ _init_global_fonts()
|
||||
void __set_window_decor(int32 theme)
|
||||
{
|
||||
BAppServerLink link;
|
||||
link.SetOpCode(AS_R5_SET_DECORATOR);
|
||||
link.StartMessage(AS_R5_SET_DECORATOR);
|
||||
link.Attach<int32>(theme);
|
||||
link.Flush();
|
||||
}
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <Errors.h>
|
||||
#include <List.h>
|
||||
#include <AppServerLink.h>
|
||||
#include <PortMessage.h>
|
||||
#include <ServerProtocol.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
@ -83,15 +82,14 @@ BPicture::BPicture(const BPicture &picture)
|
||||
|
||||
if (picture.token != -1)
|
||||
{
|
||||
|
||||
BPrivate::BAppServerLink link;
|
||||
PortMessage msg;
|
||||
int32 code=SERVER_FALSE;
|
||||
|
||||
link.Attach<int32>(AS_CLONE_PICTURE);
|
||||
link.StartMessage(AS_CLONE_PICTURE);
|
||||
link.Attach<int32>(picture.token);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int32>(&token);
|
||||
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<int32>(&token);
|
||||
}
|
||||
if (picture.extent->fNewData != NULL)
|
||||
{
|
||||
@ -160,10 +158,10 @@ BPicture::BPicture(BMessage *archive)
|
||||
if (extent->fNewSize != 0 && extent->fNewData != 0)
|
||||
{
|
||||
BPrivate::BAppServerLink link;
|
||||
PortMessage msg;
|
||||
int32 code=SERVER_FALSE;
|
||||
BPicture *pic;
|
||||
|
||||
link.Attach<int32>(AS_CREATE_PICTURE);
|
||||
link.StartMessage(AS_CREATE_PICTURE);
|
||||
link.Attach<int32>(extent->fPictures.CountItems());
|
||||
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
|
||||
{
|
||||
@ -173,8 +171,9 @@ BPicture::BPicture(BMessage *archive)
|
||||
}
|
||||
link.Attach<int32>(extent->fNewSize);
|
||||
link.Attach(extent->fNewData,extent->fNewSize);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int32>(&token);
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<int32>(&token);
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +204,7 @@ BPicture::~BPicture()
|
||||
{
|
||||
BPrivate::BAppServerLink link;
|
||||
|
||||
link.Attach<int32>(AS_DELETE_PICTURE);
|
||||
link.StartMessage(AS_DELETE_PICTURE);
|
||||
link.Attach<int32>(token);
|
||||
link.Flush();
|
||||
}
|
||||
@ -341,10 +340,10 @@ status_t BPicture::Unflatten(BDataIO *stream)
|
||||
// swap_data(extent->fNewData, extent->fNewSize);
|
||||
|
||||
BPrivate::BAppServerLink link;
|
||||
PortMessage msg;
|
||||
int32 code=SERVER_FALSE;
|
||||
BPicture *pic;
|
||||
|
||||
link.Attach<int32>(AS_CREATE_PICTURE);
|
||||
link.StartMessage(AS_CREATE_PICTURE);
|
||||
link.Attach<int32>(extent->fPictures.CountItems());
|
||||
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
|
||||
{
|
||||
@ -354,8 +353,9 @@ status_t BPicture::Unflatten(BDataIO *stream)
|
||||
}
|
||||
link.Attach<int32>(extent->fNewSize);
|
||||
link.Attach(extent->fNewData, extent->fNewSize);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int32>(&token);
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<int32>(&token);
|
||||
|
||||
if (extent->fNewData)
|
||||
{
|
||||
@ -395,9 +395,9 @@ void BPicture::import_data(const void *data, int32 size, BPicture **subs,
|
||||
return;
|
||||
|
||||
BPrivate::BAppServerLink link;
|
||||
PortMessage msg;
|
||||
int32 code=SERVER_FALSE;
|
||||
|
||||
link.Attach<int32>(AS_CREATE_PICTURE);
|
||||
link.StartMessage(AS_CREATE_PICTURE);
|
||||
link.Attach<int32>(subCount);
|
||||
|
||||
for (int32 i = 0; i < subCount; i++)
|
||||
@ -405,8 +405,9 @@ void BPicture::import_data(const void *data, int32 size, BPicture **subs,
|
||||
|
||||
link.Attach<int32>(size);
|
||||
link.Attach(data, size);
|
||||
link.FlushWithReply(&msg);
|
||||
msg.Read<int32>(&token);
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<int32>(&token);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BPicture::import_old_data(const void *data, int32 size)
|
||||
@ -421,12 +422,13 @@ void BPicture::import_old_data(const void *data, int32 size)
|
||||
convert_old_to_new(data, size, &extent->fNewData, &extent->fNewSize);
|
||||
|
||||
BPrivate::BAppServerLink link;
|
||||
link.Attach<int32>(AS_CREATE_PICTURE);
|
||||
link.StartMessage(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)
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<int32>(&token)
|
||||
|
||||
// Do we free all data now?
|
||||
free(extent->fNewData);
|
||||
@ -453,9 +455,9 @@ bool BPicture::assert_local_copy()
|
||||
/* BPrivate::BAppServerLink link;
|
||||
int32 count;
|
||||
|
||||
link.Attach<int32>(AS_DOWNLOAD_PICTURE);
|
||||
link.StartMessage(AS_DOWNLOAD_PICTURE);
|
||||
link.Attach<int32>(token);
|
||||
link.FlushWithReply(&msg);
|
||||
link.FlushWithReply(&code);
|
||||
count=*((int32*)replydata.buffer);
|
||||
|
||||
// Read sub picture tokens
|
||||
@ -501,14 +503,15 @@ bool BPicture::assert_server_copy()
|
||||
extent->fPictures.ItemAt(i)->assert_server_copy();
|
||||
|
||||
BPrivate::BAppServerLink link;
|
||||
link.Attach<int32>(AS_CREATE_PICTURE);
|
||||
link.StartMessage(AS_CREATE_PICTURE);
|
||||
link.Attach<int32>(extent->fPictures.CountItems());
|
||||
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
|
||||
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);
|
||||
link.FlushWithReply(&code);
|
||||
if(code==SERVER_TRUE)
|
||||
link.Read<int32>(&token);
|
||||
|
||||
return token != -1;*/
|
||||
return true;
|
||||
@ -548,7 +551,7 @@ void BPicture::usurp(BPicture *lameDuck)
|
||||
{
|
||||
BPrivate::BAppServerLink link;
|
||||
|
||||
link.Attach<int32>(AS_DELETE_PICTURE);
|
||||
link.StartMessage(AS_DELETE_PICTURE);
|
||||
link.Attach<int32>(token);
|
||||
link.Flush();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user