Renamed BAppServerLink to AppServerLink, BPortLink to PortLink, LinkMsgReader

to LinkReceiver, LinkMsgSender to LinkSender, and put everything into the
BPrivate namespace.
Made AppServerLink a cheap object - it will use the applications receiver/sender
and not create its own buffers.
Fixed broken communication stuff here and there (mostly Font.cpp).
Put the newly introduced set|get_system_colors() into the BPrivate namespace -
please don't introduce private functions into the public namespace!!!
Also fixed their broken communication use, as Darkwyrm obviously forgot about
it again: the sequence Flush(); GetNextMessage() without error checking is
purely wrong and can make the app hang and/or crash! :-)
Other minor cleanup.
The input_server used some test mode with the haiku build target which is
probably wrong.
Hopefully I did not forget anything this time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13128 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-14 21:28:56 +00:00
parent e274da0fa5
commit dd10337fd0
52 changed files with 1102 additions and 1192 deletions
+21 -61
View File
@@ -1,37 +1,14 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2002, OpenBeOS * Copyright 2001-2005, Haiku.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Erik Jaesler ([email protected])
// 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: Application.h
// Author: Erik Jaesler ([email protected])
// Description: BApplication class is the center of the application
// universe. The global be_app and be_app_messenger
// variables are defined here as well.
//------------------------------------------------------------------------------
#ifndef _APPLICATION_H #ifndef _APPLICATION_H
#define _APPLICATION_H #define _APPLICATION_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h> #include <BeBuild.h>
#include <AppDefs.h> // For convenience #include <AppDefs.h> // For convenience
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
@@ -40,13 +17,6 @@
#include <Point.h> #include <Point.h>
#include <Rect.h> #include <Rect.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BCursor; class BCursor;
class BList; class BList;
@@ -56,12 +26,15 @@ class BResources;
class BMessageRunner; class BMessageRunner;
struct _server_heap_; struct _server_heap_;
struct _drag_data_; struct _drag_data_;
namespace BPrivate { class BAppServerLink; }
namespace BPrivate {
class AppServerLink;
class PortLink;
}
// BApplication class ---------------------------------------------------------- // BApplication class ----------------------------------------------------------
class BApplication : public BLooper { class BApplication : public BLooper {
public: public:
BApplication(const char* signature); BApplication(const char* signature);
BApplication(const char* signature, BApplication(const char* signature,
@@ -121,7 +94,6 @@ public:
virtual status_t Perform(perform_code d, void* arg); virtual status_t Perform(perform_code d, void* arg);
private: private:
typedef BLooper _inherited; typedef BLooper _inherited;
friend class BWindow; friend class BWindow;
@@ -129,7 +101,7 @@ private:
friend class BBitmap; friend class BBitmap;
friend class BScrollBar; friend class BScrollBar;
friend class BPrivateScreen; friend class BPrivateScreen;
friend class BPrivate::BAppServerLink; friend class BPrivate::AppServerLink;
friend void _toggle_handles_(bool); friend void _toggle_handles_(bool);
BApplication(uint32 signature); BApplication(uint32 signature);
@@ -145,11 +117,9 @@ private:
virtual void _ReservedApplication7(); virtual void _ReservedApplication7();
virtual void _ReservedApplication8(); virtual void _ReservedApplication8();
virtual bool ScriptReceived(BMessage* msg, virtual bool ScriptReceived(BMessage* msg, int32 index,
int32 index, BMessage* specifier, int32 form,
BMessage* specifier, const char* property);
int32 form,
const char* property);
void run_task(); void run_task();
void InitData(const char* signature, status_t* error); void InitData(const char* signature, status_t* error);
void BeginRectTracking(BRect r, bool trackWhole); void BeginRectTracking(BRect r, bool trackWhole);
@@ -186,8 +156,10 @@ private:
static BLocker _app_resources_lock; static BLocker _app_resources_lock;
const char* fAppName; const char* fAppName;
int32 fServerFrom; BPrivate::PortLink* fServerLink;
int32 fServerTo; // uint32 _unused0;
// int32 fServerFrom;
// int32 fServerTo;
#ifndef FIX_FOR_4_6 #ifndef FIX_FOR_4_6
void* fCursorData; void* fCursorData;
#else #else
@@ -199,26 +171,14 @@ private:
_drag_data_* fDraggedMessage; _drag_data_* fDraggedMessage;
BMessageRunner* fPulseRunner; BMessageRunner* fPulseRunner;
status_t fInitError; status_t fInitError;
uint32 _reserved[11]; uint32 _reserved[12];
bool fReadyToRunCalled; bool fReadyToRunCalled;
}; };
//------------------------------------------------------------------------------
// Global Objects -------------------------------------------------------------- // Global Objects --------------------------------------------------------------
extern _IMPEXP_BE BApplication* be_app; extern _IMPEXP_BE BApplication* be_app;
extern _IMPEXP_BE BMessenger be_app_messenger; extern _IMPEXP_BE BMessenger be_app_messenger;
//------------------------------------------------------------------------------
#endif // _APPLICATION_H #endif // _APPLICATION_H
/*
* $Log $
*
* $Id $
*
*/
+13 -14
View File
@@ -15,21 +15,24 @@
#include <BeBuild.h> #include <BeBuild.h>
#include <Rect.h> #include <Rect.h>
namespace BPrivate {
class ServerLink;
};
/* Integer rect used to define a cliping rectangle. All bounds are included */ /* Integer rect used to define a cliping rectangle. All bounds are included */
/* Moved from DirectWindow.h */ /* Moved from DirectWindow.h */
typedef struct { typedef struct {
int32 left; int32 left;
int32 top; int32 top;
int32 right; int32 right;
int32 bottom; int32 bottom;
} clipping_rect; } clipping_rect;
/*----------------------------------------------------------------*/
/*----- BRegion class --------------------------------------------*/ /*----- BRegion class --------------------------------------------*/
class BRegion { class BRegion {
public: public:
BRegion(); BRegion();
BRegion(const BRegion &region); BRegion(const BRegion &region);
@@ -64,11 +67,10 @@ clipping_rect RectAtInt(int32 index);
class Support; class Support;
private: private:
friend class BView;
friend class BView; friend class BDirectWindow;
friend class BDirectWindow; friend class Support;
friend class Support; friend class BPrivate::ServerLink;
friend class BPortLink;
void _AddRect(clipping_rect r); void _AddRect(clipping_rect r);
void set_size(long new_size); void set_size(long new_size);
@@ -80,7 +82,4 @@ private:
clipping_rect *data; clipping_rect *data;
}; };
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _REGION_H */ #endif /* _REGION_H */
+6 -1
View File
@@ -14,6 +14,11 @@
#include <BeBuild.h> #include <BeBuild.h>
#include <Archivable.h> #include <Archivable.h>
namespace BPrivate {
class ServerLink;
};
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----- BShapeIterator class -------------------------------------*/ /*----- BShapeIterator class -------------------------------------*/
@@ -78,7 +83,7 @@ virtual void _ReservedShape4();
friend class TPicture; friend class TPicture;
friend class BView; friend class BView;
friend class BFont; friend class BFont;
friend class BPortLink; friend class BPrivate::ServerLink;
void GetData(int32 *opCount, int32 *ptCount, uint32 **opList, BPoint **ptList); void GetData(int32 *opCount, int32 *ptCount, uint32 **opList, BPoint **ptList);
void SetData(int32 opCount, int32 ptCount, uint32 *opList, BPoint *ptList); void SetData(int32 opCount, int32 ptCount, uint32 *opList, BPoint *ptList);
+1 -18
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS // Copyright (c) 2001-2005, Haiku
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -28,23 +28,13 @@
#ifndef _VIEW_H #ifndef _VIEW_H
#define _VIEW_H #define _VIEW_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h> #include <BeBuild.h>
#include <Font.h> #include <Font.h>
#include <Handler.h> #include <Handler.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Rect.h> #include <Rect.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// view definitions ------------------------------------------------------------ // view definitions ------------------------------------------------------------
@@ -675,10 +665,3 @@ inline void BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#endif // _VIEW_H #endif // _VIEW_H
/*
@log
* added PrintToStream() method for debugging BView.
*/
+5 -7
View File
@@ -35,7 +35,9 @@
#include <StorageDefs.h> #include <StorageDefs.h>
#include <View.h> #include <View.h>
class BPortLink; namespace BPrivate {
class PortLink;
};
// window definitions ---------------------------------------------------------- // window definitions ----------------------------------------------------------
@@ -389,13 +391,9 @@ private:
short fShowLevel; short fShowLevel;
uint32 fFlags; uint32 fFlags;
port_id send_port;
port_id receive_port;
BView *top_view; BView *top_view;
BView *fFocus; BView *fFocus;
BView *fLastMouseMovedView; BView *fLastMouseMovedView;
void *a_session; // unusedm was _BSession_
BMenuBar *fKeyMenuBar; BMenuBar *fKeyMenuBar;
BButton *fDefaultButton; BButton *fDefaultButton;
BList accelList; BList accelList;
@@ -419,11 +417,11 @@ private:
ViewAttr *fCurDrawViewState; // not yet used ViewAttr *fCurDrawViewState; // not yet used
window_feel fFeel; window_feel fFeel;
int32 fLastViewToken; int32 fLastViewToken;
BPortLink *fLink; BPrivate::PortLink *fLink;
BMessageRunner *fPulseRunner; BMessageRunner *fPulseRunner;
BRect fCurrentFrame; // not yet used BRect fCurrentFrame; // not yet used
uint32 _reserved[2]; // was 8 uint32 _reserved[5]; // was 8
#if !_PR3_COMPATIBLE_ #if !_PR3_COMPATIBLE_
uint32 _more_reserved[4]; uint32 _more_reserved[4];
#endif #endif
+11 -33
View File
@@ -1,31 +1,11 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku * Copyright 2001-2005, Haiku.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Erik Jaesler ([email protected])
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * Axel Dörfler, [email protected]
// 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: AppServerLink.h
// Author(s): Erik Jaesler ([email protected])
// Description: BAppServerLink provides proxied access to the application's
// connection with the app_server. It has BAutolock semantics:
// creating one locks the app_server connection; destroying one
// unlocks the connection.
//------------------------------------------------------------------------------
#ifndef APPSERVERLINK_H #ifndef APPSERVERLINK_H
#define APPSERVERLINK_H #define APPSERVERLINK_H
@@ -35,12 +15,10 @@
namespace BPrivate { namespace BPrivate {
class BAppServerLink : public BPortLink { class AppServerLink : public ServerLink {
public: public:
BAppServerLink(void); AppServerLink(void);
~BAppServerLink(void); ~AppServerLink(void);
status_t FlushWithReply(int32 *code);
}; };
} // namespace BPrivate } // namespace BPrivate
+6 -6
View File
@@ -12,12 +12,12 @@
#include <OS.h> #include <OS.h>
//namespace BPrivate { namespace BPrivate {
class LinkMsgReader { class LinkReceiver {
public: public:
LinkMsgReader(port_id port); LinkReceiver(port_id port);
virtual ~LinkMsgReader(void); virtual ~LinkReceiver(void);
void SetPort(port_id port); void SetPort(port_id port);
port_id Port(void) { return fReceivePort; } port_id Port(void) { return fReceivePort; }
@@ -53,6 +53,6 @@ class LinkMsgReader {
status_t fReadError; //Read failed for current message status_t fReadError; //Read failed for current message
}; };
//} // namespace BPrivate } // namespace BPrivate
#endif #endif // _LINKMSGREADER_H
+5 -5
View File
@@ -14,12 +14,12 @@
#include <OS.h> #include <OS.h>
//namespace BPrivate { namespace BPrivate {
class LinkMsgSender { class LinkSender {
public: public:
LinkMsgSender(port_id sendport); LinkSender(port_id sendport);
virtual ~LinkMsgSender(void); virtual ~LinkSender(void);
void SetPort(port_id port); void SetPort(port_id port);
port_id Port() { return fPort; } port_id Port() { return fPort; }
@@ -58,6 +58,6 @@ class LinkMsgSender {
status_t fCurrentStatus; status_t fCurrentStatus;
}; };
//} // namespace BPrivate } // namespace BPrivate
#endif /* LINKMSGSENDER_H */ #endif /* LINKMSGSENDER_H */
+44 -39
View File
@@ -29,21 +29,17 @@
*/ */
// ToDo: put this into the private namespace namespace BPrivate {
//namespace BPrivate {
//class LinkMsgReader; class ServerLink {
//class LinkMsgSender;
class BPortLink {
public: public:
BPortLink(port_id send = -1, port_id reply = -1); ServerLink();
virtual ~BPortLink(); virtual ~ServerLink();
// send methods // send methods
void SetSendPort(port_id port); void SetSenderPort(port_id port);
port_id SendPort(); port_id SenderPort();
status_t StartMessage(int32 code, size_t minSize = 0); status_t StartMessage(int32 code, size_t minSize = 0);
void CancelMessage(); void CancelMessage();
@@ -58,8 +54,8 @@ class BPortLink {
// receive methods // receive methods
void SetReplyPort(port_id port); void SetReceiverPort(port_id port);
port_id ReplyPort(); port_id ReceiverPort();
status_t GetNextMessage(int32 &code, bigtime_t timeout = B_INFINITE_TIMEOUT); status_t GetNextMessage(int32 &code, bigtime_t timeout = B_INFINITE_TIMEOUT);
bool NeedsReply() const; bool NeedsReply() const;
@@ -72,66 +68,75 @@ class BPortLink {
// convenience methods // convenience methods
status_t FlushWithReply(int32 &code); status_t FlushWithReply(int32 &code);
LinkMsgReader &Reader() { return *fReader; } LinkSender &Sender() { return *fSender; }
LinkMsgSender &Sender() { return *fSender; } LinkReceiver &Receiver() { return *fReceiver; }
protected: protected:
LinkMsgReader *fReader; LinkSender *fSender;
LinkMsgSender *fSender; LinkReceiver *fReceiver;
}; };
class PortLink : public ServerLink {
public:
PortLink(port_id sender = -1, port_id receiver = -1);
virtual ~PortLink();
void SetTo(port_id sender, port_id receiver);
};
// sender inline functions // sender inline functions
inline void inline void
BPortLink::SetSendPort(port_id port) ServerLink::SetSenderPort(port_id port)
{ {
fSender->SetPort(port); fSender->SetPort(port);
} }
inline port_id inline port_id
BPortLink::SendPort() ServerLink::SenderPort()
{ {
return fSender->Port(); return fSender->Port();
} }
inline status_t inline status_t
BPortLink::StartMessage(int32 code, size_t minSize) ServerLink::StartMessage(int32 code, size_t minSize)
{ {
return fSender->StartMessage(code, minSize); return fSender->StartMessage(code, minSize);
} }
inline status_t inline status_t
BPortLink::EndMessage() ServerLink::EndMessage()
{ {
return fSender->EndMessage(); return fSender->EndMessage();
} }
inline void inline void
BPortLink::CancelMessage() ServerLink::CancelMessage()
{ {
fSender->CancelMessage(); fSender->CancelMessage();
} }
inline status_t inline status_t
BPortLink::Flush(bigtime_t timeout, bool needsReply) ServerLink::Flush(bigtime_t timeout, bool needsReply)
{ {
return fSender->Flush(timeout, needsReply); return fSender->Flush(timeout, needsReply);
} }
inline status_t inline status_t
BPortLink::Attach(const void *data, ssize_t size) ServerLink::Attach(const void *data, ssize_t size)
{ {
return fSender->Attach(data, size); return fSender->Attach(data, size);
} }
inline status_t inline status_t
BPortLink::AttachString(const char *string, int32 length) ServerLink::AttachString(const char *string, int32 length)
{ {
return fSender->AttachString(string, length); return fSender->AttachString(string, length);
} }
template<class Type> status_t template<class Type> status_t
BPortLink::Attach(const Type &data) ServerLink::Attach(const Type &data)
{ {
return Attach(&data, sizeof(Type)); return Attach(&data, sizeof(Type));
} }
@@ -139,47 +144,47 @@ BPortLink::Attach(const Type &data)
// #pragma mark - receiver inline functions // #pragma mark - receiver inline functions
inline void inline void
BPortLink::SetReplyPort(port_id port) ServerLink::SetReceiverPort(port_id port)
{ {
fReader->SetPort(port); fReceiver->SetPort(port);
} }
inline port_id inline port_id
BPortLink::ReplyPort() ServerLink::ReceiverPort()
{ {
return fReader->Port(); return fReceiver->Port();
} }
inline status_t inline status_t
BPortLink::GetNextMessage(int32 &code, bigtime_t timeout) ServerLink::GetNextMessage(int32 &code, bigtime_t timeout)
{ {
return fReader->GetNextMessage(code, timeout); return fReceiver->GetNextMessage(code, timeout);
} }
inline bool inline bool
BPortLink::NeedsReply() const ServerLink::NeedsReply() const
{ {
return fReader->NeedsReply(); return fReceiver->NeedsReply();
} }
inline status_t inline status_t
BPortLink::Read(void *data, ssize_t size) ServerLink::Read(void *data, ssize_t size)
{ {
return fReader->Read(data, size); return fReceiver->Read(data, size);
} }
inline status_t inline status_t
BPortLink::ReadString(char **string) ServerLink::ReadString(char **string)
{ {
return fReader->ReadString(string); return fReceiver->ReadString(string);
} }
template <class Type> status_t template <class Type> status_t
BPortLink::Read(Type *data) ServerLink::Read(Type *data)
{ {
return Read(data, sizeof(Type)); return Read(data, sizeof(Type));
} }
//} // namespace BPrivate } // namespace BPrivate
#endif /* _PORTLINK_H */ #endif /* _PORTLINK_H */
+7 -5
View File
@@ -40,8 +40,10 @@
#include "PatternHandler.h" #include "PatternHandler.h"
class BRegion; class BRegion;
class LinkMsgReader; namespace BPrivate {
class LinkMsgSender; class LinkReceiver;
class LinkSender;
};
class DrawData { class DrawData {
public: public:
@@ -174,12 +176,12 @@ class LayerData : public DrawData {
// convenience functions // convenience functions
virtual void PrintToStream() const; virtual void PrintToStream() const;
void ReadFontFromLink(LinkMsgReader& link); void ReadFontFromLink(BPrivate::LinkReceiver& link);
// NOTE: ReadFromLink() does not read Font state!! // NOTE: ReadFromLink() does not read Font state!!
// It was separate in ServerWindow, and I didn't // It was separate in ServerWindow, and I didn't
// want to change it without knowing implications. // want to change it without knowing implications.
void ReadFromLink(LinkMsgReader& link); void ReadFromLink(BPrivate::LinkReceiver& link);
void WriteToLink(LinkMsgSender& link) const; void WriteToLink(BPrivate::LinkSender& link) const;
public: public:
// used for the state stack // used for the state stack
+24 -45
View File
@@ -1,31 +1,12 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku * Copyright 2001-2005, Haiku.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Erik Jaesler ([email protected])
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * Axel Dörfler, [email protected]
// 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: AppServerLink.cpp
// Author(s): Erik Jaesler ([email protected])
// Description: BAppServerLink provides proxied access to the application's
// connection with the app_server. It has BAutolock semantics:
// creating one locks the app_server connection; destroying one
// unlocks the connection.
//------------------------------------------------------------------------------
#include <Application.h> #include <Application.h>
#include <Locker.h> #include <Locker.h>
@@ -33,37 +14,35 @@
#include <AppServerLink.h> #include <AppServerLink.h>
/** AppServerLink provides proxied access to the application's
* connection with the app_server.
* It has BAutolock semantics:
* creating one locks the app_server connection; destroying one
* unlocks the connection.
*/
BLocker sLock; BLocker sLock;
#include <stdio.h>
namespace BPrivate { namespace BPrivate {
BAppServerLink::BAppServerLink(void) AppServerLink::AppServerLink(void)
{ {
sLock.Lock(); sLock.Lock();
// if there is no be_app, we can't do a whole lot, anyway // if there is no be_app, we can't do a whole lot, anyway
if (be_app) { if (be_app) {
SetSendPort(be_app->fServerFrom); fReceiver = &be_app->fServerLink->Receiver();
SetReplyPort(be_app->fServerTo); fSender = &be_app->fServerLink->Sender();
} } else
puts("Noooooooooooooooooooooooooooo");
} }
BAppServerLink::~BAppServerLink() AppServerLink::~AppServerLink()
{ {
sLock.Unlock(); sLock.Unlock();
} }
status_t
BAppServerLink::FlushWithReply(int32 *code)
{
status_t status = Flush(B_INFINITE_TIMEOUT, true);
if (status < B_OK)
return status;
return GetNextMessage(*code);
}
} // namespace BPrivate } // namespace BPrivate
+50 -68
View File
@@ -1,38 +1,17 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, inc. * Copyright 2001-2005, Haiku.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Erik Jaesler ([email protected])
// 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: Application.cpp
// Author: Erik Jaesler ([email protected])
// Description: BApplication class is the center of the application
// universe. The global be_app and be_app_messenger
// variables are defined here as well.
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <new> #include <new>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
// System Includes -------------------------------------------------------------
#include <Alert.h> #include <Alert.h>
#include <AppFileInfo.h> #include <AppFileInfo.h>
#include <Application.h> #include <Application.h>
@@ -51,7 +30,6 @@
#include <RosterPrivate.h> #include <RosterPrivate.h>
#include <Window.h> #include <Window.h>
// Project Includes ------------------------------------------------------------
#include <AppServerLink.h> #include <AppServerLink.h>
#include <LooperList.h> #include <LooperList.h>
#include <MenuWindow.h> #include <MenuWindow.h>
@@ -69,8 +47,7 @@ BResources *BApplication::_app_resources = NULL;
BLocker BApplication::_app_resources_lock("_app_resources_lock"); BLocker BApplication::_app_resources_lock("_app_resources_lock");
static property_info static property_info sPropertyInfo[] = {
sPropertyInfo[] = {
{ {
"Window", "Window",
{}, {},
@@ -234,13 +211,14 @@ BApplication::~BApplication()
#ifndef RUN_WITHOUT_APP_SERVER #ifndef RUN_WITHOUT_APP_SERVER
// tell app_server we're quitting... // tell app_server we're quitting...
BPortLink link(fServerFrom); BPrivate::AppServerLink link;
link.StartMessage(B_QUIT_REQUESTED); link.StartMessage(B_QUIT_REQUESTED);
link.Flush(); link.Flush();
#endif // RUN_WITHOUT_APP_SERVER #endif // RUN_WITHOUT_APP_SERVER
// ToDo: since we add the port, I guess we should remove it as well? -- axeld. delete_port(fServerLink->SenderPort());
//delete_port(fServerTo); delete_port(fServerLink->ReceiverPort());
delete fServerLink;
// uninitialize be_app, the be_app_messenger is invalidated automatically // uninitialize be_app, the be_app_messenger is invalidated automatically
be_app = NULL; be_app = NULL;
@@ -257,12 +235,12 @@ BApplication::operator=(const BApplication &rhs)
void void
BApplication::InitData(const char *signature, status_t *_error) BApplication::InitData(const char *signature, status_t *_error)
{ {
DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error)); DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
// check whether there exists already an application // check whether there exists already an application
if (be_app) if (be_app)
debugger("2 BApplication objects were created. Only one is allowed."); debugger("2 BApplication objects were created. Only one is allowed.");
fServerFrom = fServerTo = -1; fServerLink = new BPrivate::PortLink(-1, -1);
fServerHeap = NULL; fServerHeap = NULL;
fInitialWorkspace = 0; fInitialWorkspace = 0;
fDraggedMessage = NULL; fDraggedMessage = NULL;
@@ -420,7 +398,7 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
be_app = this; be_app = this;
be_app_messenger = BMessenger(NULL, this); be_app_messenger = BMessenger(NULL, this);
} }
// set the BHandler's name // set the BHandler's name
if (fInitError == B_OK) if (fInitError == B_OK)
SetName(ref.name); SetName(ref.name);
@@ -433,7 +411,7 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
#ifndef RUN_WITHOUT_APP_SERVER #ifndef RUN_WITHOUT_APP_SERVER
// Initialize the IK after we have set be_app because of a construction of a // Initialize the IK after we have set be_app because of a construction of a
// BAppServerLink (which depends on be_app) nested inside the call to get_menu_info. // AppServerLink (which depends on be_app) nested inside the call to get_menu_info.
if (fInitError == B_OK) if (fInitError == B_OK)
fInitError = _init_interface_kit_(); fInitError = _init_interface_kit_();
// create global system cursors // create global system cursors
@@ -660,7 +638,7 @@ BApplication::ResolveSpecifier(BMessage *msg, int32 index,
void void
BApplication::ShowCursor() BApplication::ShowCursor()
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SHOW_CURSOR); link.StartMessage(AS_SHOW_CURSOR);
link.Flush(); link.Flush();
} }
@@ -669,7 +647,7 @@ BApplication::ShowCursor()
void void
BApplication::HideCursor() BApplication::HideCursor()
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_HIDE_CURSOR); link.StartMessage(AS_HIDE_CURSOR);
link.Flush(); link.Flush();
} }
@@ -678,7 +656,7 @@ BApplication::HideCursor()
void void
BApplication::ObscureCursor() BApplication::ObscureCursor()
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_OBSCURE_CURSOR); link.StartMessage(AS_OBSCURE_CURSOR);
link.Flush(); link.Flush();
} }
@@ -687,10 +665,10 @@ BApplication::ObscureCursor()
bool bool
BApplication::IsCursorHidden() const BApplication::IsCursorHidden() const
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
int32 code = SERVER_FALSE; int32 code = SERVER_FALSE;
link.StartMessage(AS_QUERY_CURSOR_HIDDEN); link.StartMessage(AS_QUERY_CURSOR_HIDDEN);
link.FlushWithReply(&code); link.FlushWithReply(code);
return code == SERVER_TRUE; return code == SERVER_TRUE;
} }
@@ -710,14 +688,14 @@ BApplication::SetCursor(const void *cursor)
void void
BApplication::SetCursor(const BCursor *cursor, bool sync) BApplication::SetCursor(const BCursor *cursor, bool sync)
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
int32 code = SERVER_FALSE; int32 code = SERVER_FALSE;
link.StartMessage(AS_SET_CURSOR_BCURSOR); link.StartMessage(AS_SET_CURSOR_BCURSOR);
link.Attach<bool>(sync); link.Attach<bool>(sync);
link.Attach<int32>(cursor->m_serverToken); link.Attach<int32>(cursor->m_serverToken);
if (sync) if (sync)
link.FlushWithReply(&code); link.FlushWithReply(code);
else else
link.Flush(); link.Flush();
} }
@@ -1018,7 +996,7 @@ BApplication::run_task()
void void
BApplication::BeginRectTracking(BRect rect, bool trackWhole) BApplication::BeginRectTracking(BRect rect, bool trackWhole)
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_BEGIN_RECT_TRACKING); link.StartMessage(AS_BEGIN_RECT_TRACKING);
link.Attach<BRect>(rect); link.Attach<BRect>(rect);
link.Attach<int32>(trackWhole); link.Attach<int32>(trackWhole);
@@ -1029,7 +1007,7 @@ BApplication::BeginRectTracking(BRect rect, bool trackWhole)
void void
BApplication::EndRectTracking() BApplication::EndRectTracking()
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_END_RECT_TRACKING); link.StartMessage(AS_END_RECT_TRACKING);
link.Flush(); link.Flush();
} }
@@ -1071,20 +1049,20 @@ BApplication::global_ro_offs_to_ptr(uint32 offset)
void void
BApplication::connect_to_app_server() BApplication::connect_to_app_server()
{ {
fServerFrom = find_port(SERVER_PORT_NAME); port_id serverPort = find_port(SERVER_PORT_NAME);
if (fServerFrom < B_OK) { if (serverPort < B_OK) {
fInitError = fServerFrom; fInitError = serverPort;
return; return;
} }
// Create the port so that the app_server knows where to send messages // Create the port so that the app_server knows where to send messages
fServerTo = create_port(100, "a<fServerTo"); port_id clientPort = create_port(100, "a<app_server");
if (fServerTo < B_OK) { if (clientPort < B_OK) {
fInitError = fServerTo; fInitError = clientPort;
return; return;
} }
// We can't use BAppServerLink because be_app == NULL // We can't use AppServerLink because be_app == NULL
// AS_CREATE_APP: // AS_CREATE_APP:
// //
@@ -1094,21 +1072,25 @@ BApplication::connect_to_app_server()
// 3) team_id - team identification field // 3) team_id - team identification field
// 4) int32 - handler ID token of the app // 4) int32 - handler ID token of the app
// 5) char * - signature of the regular app // 5) char * - signature of the regular app
BPortLink link(fServerFrom, fServerTo); fServerLink->SetTo(serverPort, clientPort);
fServerLink->StartMessage(AS_CREATE_APP);
fServerLink->Attach<port_id>(clientPort);
fServerLink->Attach<port_id>(_get_looper_port_(this));
fServerLink->Attach<team_id>(Team());
fServerLink->Attach<int32>(_get_object_token_(this));
fServerLink->AttachString(fAppName);
int32 code; int32 code;
if (fServerLink->FlushWithReply(code) == B_OK
link.StartMessage(AS_CREATE_APP); && code == SERVER_TRUE) {
link.Attach<port_id>(fServerTo); fServerLink->Read<port_id>(&serverPort);
link.Attach<port_id>(_get_looper_port_(this)); // ToDo: what are we supposed to do with this port?
link.Attach<team_id>(Team()); fServerLink->SetSenderPort(serverPort);
link.Attach<int32>(_get_object_token_(this)); } else {
link.AttachString(fAppName); fServerLink->SetSenderPort(-1);
if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE)
link.Read<port_id>(&fServerFrom);
else
debugger("BApplication: couldn't obtain new app_server comm port"); debugger("BApplication: couldn't obtain new app_server comm port");
}
} }
+6 -6
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2004, Haiku // Copyright (c) 2001-2005, Haiku
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -58,13 +58,13 @@ BCursor::BCursor(const void *cursorData)
return; return;
// Send data directly to server // Send data directly to server
BPrivate::BAppServerLink serverlink; BPrivate::AppServerLink serverlink;
int32 code=SERVER_FALSE; int32 code = SERVER_FALSE;
serverlink.StartMessage(AS_CREATE_BCURSOR); serverlink.StartMessage(AS_CREATE_BCURSOR);
serverlink.Attach(cursorData, 68); serverlink.Attach(cursorData, 68);
serverlink.FlushWithReply(&code); serverlink.FlushWithReply(code);
if(code==SERVER_TRUE) if (code == SERVER_TRUE)
serverlink.Read<int32>(&m_serverToken); serverlink.Read<int32>(&m_serverToken);
} }
@@ -80,7 +80,7 @@ BCursor::BCursor(BMessage *data)
BCursor::~BCursor() BCursor::~BCursor()
{ {
// Notify server to deallocate server-side objects for this cursor // Notify server to deallocate server-side objects for this cursor
BPrivate::BAppServerLink serverlink; BPrivate::AppServerLink serverlink;
serverlink.StartMessage(AS_DELETE_BCURSOR); serverlink.StartMessage(AS_DELETE_BCURSOR);
serverlink.Attach<int32>(m_serverToken); serverlink.Attach<int32>(m_serverToken);
serverlink.Flush(); serverlink.Flush();
+22 -20
View File
@@ -30,8 +30,9 @@ extern const char *bstrcode(int32 code);
# define STRACE(x) ; # define STRACE(x) ;
#endif #endif
namespace BPrivate {
LinkMsgReader::LinkMsgReader(port_id port) LinkReceiver::LinkReceiver(port_id port)
: :
fReceivePort(port), fRecvBuffer(NULL), fRecvPosition(0), fRecvStart(0), fReceivePort(port), fRecvBuffer(NULL), fRecvPosition(0), fRecvStart(0),
fRecvBufferSize(0), fDataSize(0), fRecvBufferSize(0), fDataSize(0),
@@ -40,28 +41,28 @@ LinkMsgReader::LinkMsgReader(port_id port)
} }
LinkMsgReader::~LinkMsgReader() LinkReceiver::~LinkReceiver()
{ {
free(fRecvBuffer); free(fRecvBuffer);
} }
void void
LinkMsgReader::SetPort(port_id port) LinkReceiver::SetPort(port_id port)
{ {
fReceivePort = port; fReceivePort = port;
} }
status_t status_t
LinkMsgReader::GetNextMessage(int32 &code, bigtime_t timeout) LinkReceiver::GetNextMessage(int32 &code, bigtime_t timeout)
{ {
int32 remaining; int32 remaining;
fReadError = B_OK; fReadError = B_OK;
remaining = fDataSize - (fRecvStart + fReplySize); remaining = fDataSize - (fRecvStart + fReplySize);
STRACE(("info: LinkMsgReader GetNextReply() reports %ld bytes remaining in buffer.\n", remaining)); STRACE(("info: LinkReceiver GetNextReply() reports %ld bytes remaining in buffer.\n", remaining));
// find the position of the next message header in the buffer // find the position of the next message header in the buffer
message_header *header; message_header *header;
@@ -80,14 +81,14 @@ LinkMsgReader::GetNextMessage(int32 &code, bigtime_t timeout)
// check we have a well-formed message // check we have a well-formed message
if (remaining < (int32)sizeof(message_header)) { if (remaining < (int32)sizeof(message_header)) {
// we don't have enough data for a complete header // we don't have enough data for a complete header
STRACE(("error info: LinkMsgReader remaining %ld bytes is less than header size.\n", remaining)); STRACE(("error info: LinkReceiver remaining %ld bytes is less than header size.\n", remaining));
ResetBuffer(); ResetBuffer();
return B_ERROR; return B_ERROR;
} }
fReplySize = header->size; fReplySize = header->size;
if (fReplySize > remaining || fReplySize < (int32)sizeof(message_header)) { if (fReplySize > remaining || fReplySize < (int32)sizeof(message_header)) {
STRACE(("error info: LinkMsgReader message size of %ld bytes smaller than header size.\n", fReplySize)); STRACE(("error info: LinkReceiver message size of %ld bytes smaller than header size.\n", fReplySize));
ResetBuffer(); ResetBuffer();
return B_ERROR; return B_ERROR;
} }
@@ -95,7 +96,7 @@ LinkMsgReader::GetNextMessage(int32 &code, bigtime_t timeout)
code = header->code; code = header->code;
fRecvPosition += sizeof(message_header); fRecvPosition += sizeof(message_header);
STRACE(("info: LinkMsgReader got header %s [%ld %ld %ld] from port %ld.\n", STRACE(("info: LinkReceiver got header %s [%ld %ld %ld] from port %ld.\n",
strcode(header->code), fReplySize, header->code, header->flags, fReceivePort)); strcode(header->code), fReplySize, header->code, header->flags, fReceivePort));
return B_OK; return B_OK;
@@ -103,7 +104,7 @@ LinkMsgReader::GetNextMessage(int32 &code, bigtime_t timeout)
bool bool
LinkMsgReader::NeedsReply() const LinkReceiver::NeedsReply() const
{ {
if (fReplySize == 0) if (fReplySize == 0)
return false; return false;
@@ -114,7 +115,7 @@ LinkMsgReader::NeedsReply() const
void void
LinkMsgReader::ResetBuffer() LinkReceiver::ResetBuffer()
{ {
fRecvPosition = 0; fRecvPosition = 0;
fRecvStart = 0; fRecvStart = 0;
@@ -124,7 +125,7 @@ LinkMsgReader::ResetBuffer()
status_t status_t
LinkMsgReader::AdjustReplyBuffer(bigtime_t timeout) LinkReceiver::AdjustReplyBuffer(bigtime_t timeout)
{ {
// Here we take advantage of the compiler's dead-code elimination // Here we take advantage of the compiler's dead-code elimination
if (kInitialBufferSize == kMaxBufferSize) { if (kInitialBufferSize == kMaxBufferSize) {
@@ -139,13 +140,13 @@ LinkMsgReader::AdjustReplyBuffer(bigtime_t timeout)
fRecvBufferSize = kInitialBufferSize; fRecvBufferSize = kInitialBufferSize;
} else { } else {
STRACE(("info: LinkMsgReader getting port_buffer_size().\n")); STRACE(("info: LinkReceiver getting port_buffer_size().\n"));
ssize_t bufferSize; ssize_t bufferSize;
if (timeout == B_INFINITE_TIMEOUT) if (timeout == B_INFINITE_TIMEOUT)
bufferSize = port_buffer_size(fReceivePort); bufferSize = port_buffer_size(fReceivePort);
else else
bufferSize = port_buffer_size_etc(fReceivePort, B_TIMEOUT, timeout); bufferSize = port_buffer_size_etc(fReceivePort, B_TIMEOUT, timeout);
STRACE(("info: LinkMsgReader got port_buffer_size() = %ld.\n", bufferSize)); STRACE(("info: LinkReceiver got port_buffer_size() = %ld.\n", bufferSize));
if (bufferSize < 0) if (bufferSize < 0)
return (status_t)bufferSize; return (status_t)bufferSize;
@@ -159,7 +160,7 @@ LinkMsgReader::AdjustReplyBuffer(bigtime_t timeout)
if (bufferSize > (ssize_t)kMaxBufferSize) if (bufferSize > (ssize_t)kMaxBufferSize)
return B_ERROR; // we can't continue return B_ERROR; // we can't continue
STRACE(("info: LinkMsgReader setting receive buffersize to %ld.\n", bufferSize)); STRACE(("info: LinkReceiver setting receive buffersize to %ld.\n", bufferSize));
char *buffer = (char *)malloc(bufferSize); char *buffer = (char *)malloc(bufferSize);
if (buffer == NULL) if (buffer == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -175,7 +176,7 @@ LinkMsgReader::AdjustReplyBuffer(bigtime_t timeout)
status_t status_t
LinkMsgReader::ReadFromPort(bigtime_t timeout) LinkReceiver::ReadFromPort(bigtime_t timeout)
{ {
// we are here so it means we finished reading the buffer contents // we are here so it means we finished reading the buffer contents
ResetBuffer(); ResetBuffer();
@@ -187,7 +188,7 @@ LinkMsgReader::ReadFromPort(bigtime_t timeout)
int32 code; int32 code;
ssize_t bytesRead; ssize_t bytesRead;
STRACE(("info: LinkMsgReader reading port %ld.\n", fReceivePort)); STRACE(("info: LinkReceiver reading port %ld.\n", fReceivePort));
while (true) { while (true) {
if (timeout != B_INFINITE_TIMEOUT) { if (timeout != B_INFINITE_TIMEOUT) {
do { do {
@@ -201,7 +202,7 @@ LinkMsgReader::ReadFromPort(bigtime_t timeout)
} while (bytesRead == B_INTERRUPTED); } while (bytesRead == B_INTERRUPTED);
} }
STRACE(("info: LinkMsgReader read %ld bytes.\n", bytesRead)); STRACE(("info: LinkReceiver read %ld bytes.\n", bytesRead));
if (bytesRead < B_OK) if (bytesRead < B_OK)
return bytesRead; return bytesRead;
@@ -222,9 +223,9 @@ LinkMsgReader::ReadFromPort(bigtime_t timeout)
status_t status_t
LinkMsgReader::Read(void *data, ssize_t size) LinkReceiver::Read(void *data, ssize_t size)
{ {
// STRACE(("info: LinkMsgReader Read()ing %ld bytes...\n", size)); // STRACE(("info: LinkReceiver Read()ing %ld bytes...\n", size));
if (fReadError < B_OK) if (fReadError < B_OK)
return fReadError; return fReadError;
@@ -249,7 +250,7 @@ LinkMsgReader::Read(void *data, ssize_t size)
status_t status_t
LinkMsgReader::ReadString(char **_string) LinkReceiver::ReadString(char **_string)
{ {
int32 length = 0; int32 length = 0;
status_t status; status_t status;
@@ -285,3 +286,4 @@ LinkMsgReader::ReadString(char **_string)
} }
} }
} // namespace BPrivate
+18 -16
View File
@@ -33,8 +33,9 @@
static const size_t kWatermark = kInitialBufferSize - 24; static const size_t kWatermark = kInitialBufferSize - 24;
// if a message is started after this mark, the buffer is flushed automatically // if a message is started after this mark, the buffer is flushed automatically
namespace BPrivate {
LinkMsgSender::LinkMsgSender(port_id port) LinkSender::LinkSender(port_id port)
: :
fPort(port), fPort(port),
fBuffer(NULL), fBuffer(NULL),
@@ -47,21 +48,21 @@ LinkMsgSender::LinkMsgSender(port_id port)
} }
LinkMsgSender::~LinkMsgSender() LinkSender::~LinkSender()
{ {
free(fBuffer); free(fBuffer);
} }
void void
LinkMsgSender::SetPort(port_id port) LinkSender::SetPort(port_id port)
{ {
fPort = port; fPort = port;
} }
status_t status_t
LinkMsgSender::StartMessage(int32 code, size_t minSize) LinkSender::StartMessage(int32 code, size_t minSize)
{ {
// end previous message // end previous message
if (EndMessage() < B_OK) if (EndMessage() < B_OK)
@@ -92,7 +93,7 @@ LinkMsgSender::StartMessage(int32 code, size_t minSize)
header->code = code; header->code = code;
header->flags = 0; header->flags = 0;
STRACE(("info: LinkMsgSender buffered header %s (%lx) [%lu %lu %lu].\n", STRACE(("info: LinkSender buffered header %s (%lx) [%lu %lu %lu].\n",
strcode(code), code, header->size, header->code, header->flags)); strcode(code), code, header->size, header->code, header->flags));
fCurrentEnd += sizeof(message_header); fCurrentEnd += sizeof(message_header);
@@ -101,7 +102,7 @@ LinkMsgSender::StartMessage(int32 code, size_t minSize)
status_t status_t
LinkMsgSender::EndMessage(bool needsReply) LinkSender::EndMessage(bool needsReply)
{ {
if (fCurrentEnd == fCurrentStart || fCurrentStatus < B_OK) if (fCurrentEnd == fCurrentStart || fCurrentStatus < B_OK)
return fCurrentStatus; return fCurrentStatus;
@@ -112,7 +113,7 @@ LinkMsgSender::EndMessage(bool needsReply)
if (needsReply) if (needsReply)
header->flags |= needsReply; header->flags |= needsReply;
STRACE(("info: LinkMsgSender EndMessage() of size %ld.\n", header->size)); STRACE(("info: LinkSender EndMessage() of size %ld.\n", header->size));
// bump to start of next message // bump to start of next message
fCurrentStart = fCurrentEnd; fCurrentStart = fCurrentEnd;
@@ -121,7 +122,7 @@ LinkMsgSender::EndMessage(bool needsReply)
void void
LinkMsgSender::CancelMessage() LinkSender::CancelMessage()
{ {
fCurrentEnd = fCurrentStart; fCurrentEnd = fCurrentStart;
fCurrentStatus = B_OK; fCurrentStatus = B_OK;
@@ -129,7 +130,7 @@ LinkMsgSender::CancelMessage()
status_t status_t
LinkMsgSender::Attach(const void *data, size_t size) LinkSender::Attach(const void *data, size_t size)
{ {
if (fCurrentStatus < B_OK) if (fCurrentStatus < B_OK)
return fCurrentStatus; return fCurrentStatus;
@@ -156,7 +157,7 @@ LinkMsgSender::Attach(const void *data, size_t size)
status_t status_t
LinkMsgSender::AttachString(const char *string, int32 length) LinkSender::AttachString(const char *string, int32 length)
{ {
if (string == NULL) if (string == NULL)
string = ""; string = "";
@@ -179,7 +180,7 @@ LinkMsgSender::AttachString(const char *string, int32 length)
status_t status_t
LinkMsgSender::AdjustBuffer(size_t newSize, char **_oldBuffer) LinkSender::AdjustBuffer(size_t newSize, char **_oldBuffer)
{ {
// make sure the new size is within bounds // make sure the new size is within bounds
if (newSize <= kInitialBufferSize) if (newSize <= kInitialBufferSize)
@@ -214,7 +215,7 @@ LinkMsgSender::AdjustBuffer(size_t newSize, char **_oldBuffer)
status_t status_t
LinkMsgSender::FlushCompleted(size_t newBufferSize) LinkSender::FlushCompleted(size_t newBufferSize)
{ {
// we need to hide the incomplete message so that it's not flushed // we need to hide the incomplete message so that it's not flushed
int32 end = fCurrentEnd; int32 end = fCurrentEnd;
@@ -245,7 +246,7 @@ LinkMsgSender::FlushCompleted(size_t newBufferSize)
status_t status_t
LinkMsgSender::Flush(bigtime_t timeout, bool needsReply) LinkSender::Flush(bigtime_t timeout, bool needsReply)
{ {
if (fCurrentStatus < B_OK) if (fCurrentStatus < B_OK)
return fCurrentStatus; return fCurrentStatus;
@@ -254,7 +255,7 @@ LinkMsgSender::Flush(bigtime_t timeout, bool needsReply)
if (fCurrentStart == 0) if (fCurrentStart == 0)
return B_OK; return B_OK;
STRACE(("info: LinkMsgSender Flush() waiting to send messages of %ld bytes on port %ld.\n", STRACE(("info: LinkSender Flush() waiting to send messages of %ld bytes on port %ld.\n",
fCurrentEnd, fPort)); fCurrentEnd, fPort));
status_t err; status_t err;
@@ -270,12 +271,12 @@ LinkMsgSender::Flush(bigtime_t timeout, bool needsReply)
} }
if (err < B_OK) { if (err < B_OK) {
STRACE(("error info: LinkMsgSender Flush() failed for %ld bytes (%s) on port %ld.\n", STRACE(("error info: LinkSender Flush() failed for %ld bytes (%s) on port %ld.\n",
fCurrentEnd, strerror(err), fPort)); fCurrentEnd, strerror(err), fPort));
return err; return err;
} }
STRACE(("info: LinkMsgSender Flush() messages total of %ld bytes on port %ld.\n", STRACE(("info: LinkSender Flush() messages total of %ld bytes on port %ld.\n",
fCurrentEnd, fPort)); fCurrentEnd, fPort));
fCurrentEnd = 0; fCurrentEnd = 0;
@@ -284,6 +285,7 @@ LinkMsgSender::Flush(bigtime_t timeout, bool needsReply)
return B_OK; return B_OK;
} }
} // namespace BPrivate
// #pragma mark - // #pragma mark -
+43 -19
View File
@@ -21,33 +21,30 @@
#include <ServerProtocol.h> #include <ServerProtocol.h>
BPortLink::BPortLink(port_id send, port_id receive) namespace BPrivate {
:
fReader(new LinkMsgReader(receive)), ServerLink::ServerLink()
fSender(new LinkMsgSender(send))
{ {
} }
BPortLink::~BPortLink() ServerLink::~ServerLink()
{ {
delete fReader;
delete fSender;
} }
status_t status_t
BPortLink::ReadRegion(BRegion *region) ServerLink::ReadRegion(BRegion *region)
{ {
fReader->Read(&region->count, sizeof(long)); fReceiver->Read(&region->count, sizeof(long));
fReader->Read(&region->bound, sizeof(clipping_rect)); fReceiver->Read(&region->bound, sizeof(clipping_rect));
region->set_size(region->count + 1); region->set_size(region->count + 1);
return fReader->Read(region->data, region->count * sizeof(clipping_rect)); return fReceiver->Read(region->data, region->count * sizeof(clipping_rect));
} }
status_t status_t
BPortLink::AttachRegion(const BRegion &region) ServerLink::AttachRegion(const BRegion &region)
{ {
fSender->Attach(&region.count, sizeof(long)); fSender->Attach(&region.count, sizeof(long));
fSender->Attach(&region.bound, sizeof(clipping_rect)); fSender->Attach(&region.bound, sizeof(clipping_rect));
@@ -56,17 +53,17 @@ BPortLink::AttachRegion(const BRegion &region)
status_t status_t
BPortLink::ReadShape(BShape *shape) ServerLink::ReadShape(BShape *shape)
{ {
int32 opCount, ptCount; int32 opCount, ptCount;
fReader->Read(&opCount, sizeof(int32)); fReceiver->Read(&opCount, sizeof(int32));
fReader->Read(&ptCount, sizeof(int32)); fReceiver->Read(&ptCount, sizeof(int32));
uint32 opList[opCount]; uint32 opList[opCount];
fReader->Read(opList, opCount * sizeof(uint32)); fReceiver->Read(opList, opCount * sizeof(uint32));
BPoint ptList[ptCount]; BPoint ptList[ptCount];
fReader->Read(ptList, ptCount * sizeof(BPoint)); fReceiver->Read(ptList, ptCount * sizeof(BPoint));
shape->SetData(opCount, ptCount, opList, ptList); shape->SetData(opCount, ptCount, opList, ptList);
return B_OK; return B_OK;
@@ -74,7 +71,7 @@ BPortLink::ReadShape(BShape *shape)
status_t status_t
BPortLink::AttachShape(BShape &shape) ServerLink::AttachShape(BShape &shape)
{ {
int32 opCount, ptCount; int32 opCount, ptCount;
uint32 *opList; uint32 *opList;
@@ -90,7 +87,7 @@ BPortLink::AttachShape(BShape &shape)
status_t status_t
BPortLink::FlushWithReply(int32 &code) ServerLink::FlushWithReply(int32 &code)
{ {
status_t status = Flush(B_INFINITE_TIMEOUT, true); status_t status = Flush(B_INFINITE_TIMEOUT, true);
if (status < B_OK) if (status < B_OK)
@@ -98,3 +95,30 @@ BPortLink::FlushWithReply(int32 &code)
return GetNextMessage(code); return GetNextMessage(code);
} }
// #pragma mark -
PortLink::PortLink(port_id send, port_id receive)
{
fSender = new LinkSender(send);
fReceiver = new LinkReceiver(receive);
}
PortLink::~PortLink()
{
delete fReceiver;
delete fSender;
}
void
PortLink::SetTo(port_id sender, port_id receiver)
{
fSender->SetPort(sender);
fReceiver->SetPort(receiver);
}
} // namespace BPrivate
+15 -18
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku // Copyright (c) 2001-2005, Haiku
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -41,20 +41,20 @@
ServerMemIO::ServerMemIO(size_t size) ServerMemIO::ServerMemIO(size_t size)
: fLen(0), :
fPhys(0), fLen(0),
fPos(0) fPhys(0),
fPos(0)
{ {
if (size == 0) if (size == 0)
return; return;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_ACQUIRE_SERVERMEM); link.StartMessage(AS_ACQUIRE_SERVERMEM);
link.Attach<size_t>(size); link.Attach<size_t>(size);
link.Attach<port_id>(link.ReplyPort());
int32 code; int32 code;
if (link.FlushWithReply(&code) == B_OK if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE) { && code == SERVER_TRUE) {
area_info info; area_info info;
@@ -77,7 +77,7 @@ ServerMemIO::ServerMemIO(size_t size)
// Destruction // Destruction
ServerMemIO::~ServerMemIO() ServerMemIO::~ServerMemIO()
{ {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_RELEASE_SERVERMEM); link.StartMessage(AS_RELEASE_SERVERMEM);
link.Attach<area_id>(fSourceArea); link.Attach<area_id>(fSourceArea);
link.Attach<int32>(fOffset); link.Attach<int32>(fOffset);
@@ -91,10 +91,9 @@ ServerMemIO::ReadAt(off_t pos, void *buffer, size_t size)
{ {
if (buffer == NULL || pos < 0) if (buffer == NULL || pos < 0)
return B_BAD_VALUE; return B_BAD_VALUE;
ssize_t sizeRead = 0; ssize_t sizeRead = 0;
if (pos < fLen) if (pos < fLen) {
{
sizeRead = min_c(static_cast<off_t>(size), fLen - pos); sizeRead = min_c(static_cast<off_t>(size), fLen - pos);
memcpy(buffer, fBuf + pos, sizeRead); memcpy(buffer, fBuf + pos, sizeRead);
} }
@@ -108,17 +107,16 @@ ServerMemIO::WriteAt(off_t pos, const void *buffer, size_t size)
{ {
if (buffer == NULL || pos < 0) if (buffer == NULL || pos < 0)
return B_BAD_VALUE; return B_BAD_VALUE;
ssize_t sizeWritten = 0; ssize_t sizeWritten = 0;
if (pos < fPhys) if (pos < fPhys) {
{
sizeWritten = min_c(static_cast<off_t>(size), fPhys - pos); sizeWritten = min_c(static_cast<off_t>(size), fPhys - pos);
memcpy(fBuf + pos, buffer, sizeWritten); memcpy(fBuf + pos, buffer, sizeWritten);
} }
if (pos + sizeWritten > fLen) if (pos + sizeWritten > fLen)
fLen = pos + sizeWritten; fLen = pos + sizeWritten;
return sizeWritten; return sizeWritten;
} }
@@ -127,8 +125,7 @@ ServerMemIO::WriteAt(off_t pos, const void *buffer, size_t size)
off_t off_t
ServerMemIO::Seek(off_t position, uint32 seek_mode) ServerMemIO::Seek(off_t position, uint32 seek_mode)
{ {
switch (seek_mode) switch (seek_mode) {
{
case SEEK_SET: case SEEK_SET:
fPos = position; fPos = position;
break; break;
+18 -17
View File
@@ -1,15 +1,16 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, Inc. * Copyright 2001-2005, Haiku Inc.
// * Distributed under the terms of the MIT License.
// Distributed under the terms of the MIT license. *
// * Authors:
// File Name: Bitmap.cpp * Ingo Weinhold (bonefish@users.sf.net)
// Author: Ingo Weinhold ([email protected]) * DarkWyrm <bpmagic@columbus.rr.com>
// DarkWyrm <[email protected]> * Stephan Aßmus <superstippi@gmx.de>
// Stephan Aßmus <[email protected]> */
// Description: BBitmap objects represent off-screen windows that
// contain bitmap data. /** BBitmap objects represent off-screen windows that
//------------------------------------------------------------------------------ * contain bitmap data.
*/
#include <algorithm> #include <algorithm>
#include <limits.h> #include <limits.h>
@@ -2219,7 +2220,7 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
error = B_NO_MEMORY; error = B_NO_MEMORY;
} else { } else {
// Ask the server (via our owning application) to create a bitmap. // Ask the server (via our owning application) to create a bitmap.
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
// Attach Data: // Attach Data:
// 1) BRect bounds // 1) BRect bounds
@@ -2245,8 +2246,8 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags,
// Reply Data: // Reply Data:
// None // None
int32 code = SERVER_FALSE; int32 code = SERVER_FALSE;
error = link.FlushWithReply(&code); error = link.FlushWithReply(code);
if (error >= B_OK) { if (error >= B_OK) {
// *communication* with server successful // *communication* with server successful
if (code == SERVER_TRUE) { if (code == SERVER_TRUE) {
@@ -2314,7 +2315,7 @@ BBitmap::CleanUp()
if (fFlags & B_BITMAP_NO_SERVER_LINK) { if (fFlags & B_BITMAP_NO_SERVER_LINK) {
free(fBasePtr); free(fBasePtr);
} else { } else {
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
// AS_DELETE_BITMAP: // AS_DELETE_BITMAP:
// Attached Data: // Attached Data:
// 1) int32 server token // 1) int32 server token
@@ -2326,7 +2327,7 @@ BBitmap::CleanUp()
int32 code = SERVER_FALSE; int32 code = SERVER_FALSE;
link.StartMessage(AS_DELETE_BITMAP); link.StartMessage(AS_DELETE_BITMAP);
link.Attach<int32>(fServerToken); link.Attach<int32>(fServerToken);
link.FlushWithReply(&code); link.FlushWithReply(code);
if (code == SERVER_FALSE) { if (code == SERVER_FALSE) {
// TODO: Find out if "SERVER_FALSE if the buffer // TODO: Find out if "SERVER_FALSE if the buffer
// was already deleted" is true. If not, maybe we // was already deleted" is true. If not, maybe we
+3 -2
View File
@@ -77,7 +77,7 @@ ClientFontList::ClientFontList(void)
{ {
STRACE(("ClientFontList()\n")); STRACE(("ClientFontList()\n"));
familylist = new BList(0); familylist = new BList(0);
fontlock = create_sem(1,"fontlist_sem"); fontlock = create_sem(1, "fontlist_sem");
} }
@@ -105,11 +105,12 @@ ClientFontList::Update(bool checkOnly)
// Open the font list kept in font list // Open the font list kept in font list
acquire_sem(fontlock); acquire_sem(fontlock);
// ToDo: can't we use BPrivate::AppServerLink here?
// We're going to ask the server whether the list has changed // We're going to ask the server whether the list has changed
port_id port = find_port(SERVER_PORT_NAME); port_id port = find_port(SERVER_PORT_NAME);
bool needsUpdate = true; bool needsUpdate = true;
BPortLink link(port); BPrivate::PortLink link(port);
if (port >= B_OK) { if (port >= B_OK) {
link.StartMessage(AS_QUERY_FONTS_CHANGED); link.StartMessage(AS_QUERY_FONTS_CHANGED);
+251 -302
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2004, Haiku // Copyright (c) 2001-2005, Haiku
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -75,28 +75,27 @@ _init_global_fonts()
void void
_font_control_(BFont *font, int32 cmd, void *data) _font_control_(BFont *font, int32 cmd, void *data)
{ {
if(!font || (cmd!=AS_SET_SYSFONT_PLAIN && cmd!=AS_SET_SYSFONT_BOLD && if (!font
cmd!=AS_SET_SYSFONT_FIXED) ) || (cmd != AS_SET_SYSFONT_PLAIN && cmd != AS_SET_SYSFONT_BOLD
{ && cmd != AS_SET_SYSFONT_FIXED)) {
// this shouldn't ever happen, but just in case.... // this shouldn't ever happen, but just in case....
printf("DEBUG: Bad parameters in _font_control_()\n"); printf("DEBUG: Bad parameters in _font_control_()\n");
return; return;
} }
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(cmd); link.StartMessage(cmd);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE) {
{
// Once again, this shouldn't ever happen, but I want to know about it // Once again, this shouldn't ever happen, but I want to know about it
// if it does // if it does
printf("DEBUG: Couldn't initialize font in _font_control()\n"); printf("DEBUG: Couldn't initialize font in _font_control()\n");
return; return;
} }
// there really isn't that much data that we need to set for such cases -- most // there really isn't that much data that we need to set for such cases -- most
// of them need to be set to the defaults. The stuff that can change are family, // of them need to be set to the defaults. The stuff that can change are family,
// style/face, size, and height. // style/face, size, and height.
@@ -121,15 +120,14 @@ void
_set_system_font_(const char *which, font_family family, font_style style, _set_system_font_(const char *which, font_family family, font_style style,
float size) float size)
{ {
if(!which) if (!which)
return; return;
if( (strcmp(which,"plain")==0) || if (!strcmp(which,"plain")
(strcmp(which,"bold")==0) || || !strcmp(which,"bold")
(strcmp(which,"fixed")==0) ) || !strcmp(which,"fixed")) {
{ BPrivate::AppServerLink link;
BPrivate::BAppServerLink link;
link.StartMessage(AS_SET_SYSTEM_FONT); link.StartMessage(AS_SET_SYSTEM_FONT);
link.AttachString(which); link.AttachString(which);
link.AttachString(family); link.AttachString(family);
@@ -149,14 +147,14 @@ int32
count_font_families(void) count_font_families(void)
{ {
int32 code, count; int32 code, count;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_COUNT_FONT_FAMILIES); link.StartMessage(AS_COUNT_FONT_FAMILIES);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return -1; return -1;
link.Read<int32>(&count); link.Read<int32>(&count);
return count; return count;
} }
@@ -171,14 +169,14 @@ int32
count_font_styles(font_family name) count_font_styles(font_family name)
{ {
int32 code, count; int32 code, count;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_COUNT_FONT_STYLES); link.StartMessage(AS_COUNT_FONT_STYLES);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) && code != SERVER_TRUE)
return -1; return -1;
link.Read<int32>(&count); link.Read<int32>(&count);
return count; return count;
} }
@@ -196,24 +194,24 @@ status_t
get_font_family(int32 index, font_family *name, uint32 *flags) get_font_family(int32 index, font_family *name, uint32 *flags)
{ {
// Fix over R5, which does not check for NULL font family names - it just crashes // Fix over R5, which does not check for NULL font family names - it just crashes
if(!name) if (!name)
return B_ERROR; return B_ERROR;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_FAMILY_NAME); link.StartMessage(AS_GET_FAMILY_NAME);
link.Attach<int32>(index); link.Attach<int32>(index);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
link.Read<font_family>(name); link.Read<font_family>(name);
if(flags) if (flags)
link.Read<uint32>(flags); link.Read<uint32>(flags);
return B_OK; return B_OK;
} }
@@ -234,19 +232,18 @@ get_font_style(font_family family, int32 index, font_style *name,
return B_ERROR; return B_ERROR;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_STYLE_NAME); link.StartMessage(AS_GET_STYLE_NAME);
link.Attach(family,sizeof(font_family)); link.Attach(family,sizeof(font_family));
link.Attach<int32>(index); link.Attach<int32>(index);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
link.Read<font_style>(name); link.Read<font_style>(name);
if(flags) if (flags) {
{
uint16 face; uint16 face;
link.Read<uint16>(&face); link.Read<uint16>(&face);
link.Read<uint32>(flags); link.Read<uint32>(flags);
@@ -275,21 +272,21 @@ get_font_style(font_family family, int32 index, font_style *name,
return B_ERROR; return B_ERROR;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_STYLE_NAME); link.StartMessage(AS_GET_STYLE_NAME);
link.Attach(family,sizeof(font_family)); link.Attach(family, sizeof(font_family));
link.Attach<int32>(index); link.Attach<int32>(index);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
link.Read<font_style>(name); link.Read<font_style>(name);
link.Read<uint16>(face); link.Read<uint16>(face);
if(flags) if (flags)
link.Read<uint32>(flags); link.Read<uint32>(flags);
return B_OK; return B_OK;
} }
@@ -305,15 +302,15 @@ update_font_families(bool check_only)
{ {
int32 code; int32 code;
bool value; bool value;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_QUERY_FONTS_CHANGED); link.StartMessage(AS_QUERY_FONTS_CHANGED);
link.Attach<bool>(check_only); link.Attach<bool>(check_only);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return false; return false;
link.Read<bool>(&value); link.Read<bool>(&value);
return value; return value;
} }
@@ -422,38 +419,35 @@ status_t
BFont::SetFamilyAndStyle(const font_family family, const font_style style) BFont::SetFamilyAndStyle(const font_family family, const font_style style)
{ {
// R5 version always returns B_OK. That's a problem... // R5 version always returns B_OK. That's a problem...
if(!family) if (!family)
return B_ERROR; return B_ERROR;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
if(!style) if (!style) {
{
// The BeBook states that a NULL style means set only the family // The BeBook states that a NULL style means set only the family
link.StartMessage(AS_SET_FAMILY_NAME); link.StartMessage(AS_SET_FAMILY_NAME);
link.Attach(family,sizeof(font_family)); link.Attach(family, sizeof(font_family));
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
link.Read<uint16>(&fFamilyID); link.Read<uint16>(&fFamilyID);
} } else {
else
{
link.StartMessage(AS_SET_FAMILY_AND_STYLE); link.StartMessage(AS_SET_FAMILY_AND_STYLE);
link.Attach(family,sizeof(font_family)); link.Attach(family, sizeof(font_family));
link.Attach(style,sizeof(font_style)); link.Attach(style, sizeof(font_style));
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
link.Read<uint16>(&fFamilyID); link.Read<uint16>(&fFamilyID);
link.Read<uint16>(&fStyleID); link.Read<uint16>(&fStyleID);
} }
return B_OK; return B_OK;
} }
@@ -473,19 +467,19 @@ BFont::SetFamilyAndStyle(uint32 fontcode)
uint16 family,style,face; uint16 family,style,face;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
style = fontcode & 0xFFFF; style = fontcode & 0xFFFF;
family = (fontcode & 0xFFFF0000) >> 16; family = (fontcode & 0xFFFF0000) >> 16;
link.StartMessage(AS_SET_FAMILY_AND_STYLE_FROM_ID); link.StartMessage(AS_SET_FAMILY_AND_STYLE_FROM_ID);
link.Attach<uint16>(family); link.Attach<uint16>(family);
link.Attach<uint16>(style); link.Attach<uint16>(style);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return; return;
link.Read<uint16>(&face); link.Read<uint16>(&face);
fStyleID = style; fStyleID = style;
@@ -493,8 +487,8 @@ BFont::SetFamilyAndStyle(uint32 fontcode)
// Mask off any references in the face to Bold/Normal/Italic and set the face // Mask off any references in the face to Bold/Normal/Italic and set the face
// value to reflect the new font style // value to reflect the new font style
fFace&=B_UNDERSCORE_FACE | B_NEGATIVE_FACE | B_OUTLINED_FACE | B_STRIKEOUT_FACE; fFace &= B_UNDERSCORE_FACE | B_NEGATIVE_FACE | B_OUTLINED_FACE | B_STRIKEOUT_FACE;
fFace|=face; fFace |= face;
} }
@@ -516,25 +510,23 @@ BFont::SetFamilyAndFace(const font_family family, uint16 face)
| B_STRIKEOUT_FACE | B_BOLD_FACE | B_REGULAR_FACE) != 0) | B_STRIKEOUT_FACE | B_BOLD_FACE | B_REGULAR_FACE) != 0)
fFace = face; fFace = face;
if(family) if (family) {
{
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_FAMILY_AND_FACE); link.StartMessage(AS_SET_FAMILY_AND_FACE);
link.Attach(family,sizeof(font_family)); link.Attach(family, sizeof(font_family));
link.Attach<uint16>(face); link.Attach<uint16>(face);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
link.Read<uint16>(&fFamilyID); link.Read<uint16>(&fFamilyID);
link.Read<uint16>(&fStyleID); link.Read<uint16>(&fStyleID);
} } else
else fFace = face;
fFace=face;
return B_OK; return B_OK;
} }
@@ -591,20 +583,20 @@ BFont::SetFlags(uint32 flags)
void void
BFont::GetFamilyAndStyle(font_family *family, font_style *style) const BFont::GetFamilyAndStyle(font_family *family, font_style *style) const
{ {
if(!family || !style) if (!family || !style)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_FAMILY_AND_STYLE); link.StartMessage(AS_GET_FAMILY_AND_STYLE);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return; return;
link.Read<font_family>(family); link.Read<font_family>(family);
link.Read<font_style>(style); link.Read<font_style>(style);
} }
@@ -671,16 +663,16 @@ font_direction
BFont::Direction(void) const BFont::Direction(void) const
{ {
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_FONT_DIRECTION); link.StartMessage(AS_GET_FONT_DIRECTION);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return B_FONT_LEFT_TO_RIGHT; return B_FONT_LEFT_TO_RIGHT;
font_direction fdir; font_direction fdir;
link.Read<font_direction>(&fdir); link.Read<font_direction>(&fdir);
return fdir; return fdir;
@@ -691,16 +683,16 @@ bool
BFont::IsFixed(void) const BFont::IsFixed(void) const
{ {
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_QUERY_FONT_FIXED); link.StartMessage(AS_QUERY_FONT_FIXED);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return false; return false;
bool fixed; bool fixed;
link.Read<bool>(&fixed); link.Read<bool>(&fixed);
return fixed; return fixed;
@@ -725,16 +717,16 @@ BRect
BFont::BoundingBox(void) const BFont::BoundingBox(void) const
{ {
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_FONT_BOUNDING_BOX); link.StartMessage(AS_GET_FONT_BOUNDING_BOX);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return BRect(0,0,0,0); return BRect(0, 0, 0 ,0);
BRect box; BRect box;
link.Read<BRect>(&box); link.Read<BRect>(&box);
return box; return box;
@@ -761,16 +753,16 @@ int32
BFont::CountTuned(void) const BFont::CountTuned(void) const
{ {
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_TUNED_COUNT); link.StartMessage(AS_GET_TUNED_COUNT);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return -1; return -1;
int32 count; int32 count;
link.Read<int32>(&count); link.Read<int32>(&count);
return count; return count;
@@ -780,21 +772,21 @@ BFont::CountTuned(void) const
void void
BFont::GetTunedInfo(int32 index, tuned_font_info *info) const BFont::GetTunedInfo(int32 index, tuned_font_info *info) const
{ {
if(!info) if (!info)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_TUNED_INFO); link.StartMessage(AS_GET_TUNED_INFO);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<uint32>(index); link.Attach<uint32>(index);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code!=SERVER_TRUE) || code != SERVER_TRUE)
return; return;
link.Read<tuned_font_info>(info); link.Read<tuned_font_info>(info);
} }
@@ -872,8 +864,8 @@ BFont::StringWidth(const char *string, int32 length) const
return 0.0; return 0.0;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_STRING_WIDTH); link.StartMessage(AS_GET_STRING_WIDTH);
link.AttachString(string); link.AttachString(string);
link.Attach<int32>(length); link.Attach<int32>(length);
@@ -881,11 +873,11 @@ BFont::StringWidth(const char *string, int32 length) const
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<float>(fSize); link.Attach<float>(fSize);
link.Attach<uint8>(fSpacing); link.Attach<uint8>(fSpacing);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if (code != SERVER_TRUE) || code != SERVER_TRUE)
return 0.0; return 0.0;
float width; float width;
link.Read<float>(&width); link.Read<float>(&width);
return width; return width;
@@ -896,36 +888,32 @@ void
BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[], BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
int32 numStrings, float widthArray[]) const int32 numStrings, float widthArray[]) const
{ {
if(!stringArray || !lengthArray || numStrings<1 || !widthArray) if (!stringArray || !lengthArray || numStrings < 1 || !widthArray)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_STRING_WIDTHS); link.StartMessage(AS_GET_STRING_WIDTHS);
link.Attach<int32>(numStrings); link.Attach<int32>(numStrings);
for(int32 i=0; i<numStrings; i++) for (int32 i = 0; i < numStrings; i++) {
{
link.AttachString(stringArray[i]); link.AttachString(stringArray[i]);
link.Attach<int32>(lengthArray[i]); link.Attach<int32>(lengthArray[i]);
} }
link.FlushWithReply(&code);
if(code!=SERVER_TRUE) if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return; return;
for(int32 i=0; i<numStrings; i++) link.Read(widthArray, sizeof(float) * numStrings);
link.Read<float>(&widthArray[i]);
} }
void void
BFont::GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) const BFont::GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) const
{ {
GetEscapements(charArray, numChars,NULL,escapementArray); GetEscapements(charArray, numChars, NULL, escapementArray);
} }
@@ -933,16 +921,15 @@ void
BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta,
float escapementArray[]) const float escapementArray[]) const
{ {
if (!charArray || numChars<1 || !escapementArray) if (!charArray || numChars < 1 || !escapementArray)
return; return;
// NOTE: The R5 implementation crashes if delta == NULL! // NOTE: The R5 implementation crashes if delta == NULL!
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_ESCAPEMENTS_AS_FLOATS); link.StartMessage(AS_GET_ESCAPEMENTS_AS_FLOATS);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<float>(fSize); link.Attach<float>(fSize);
@@ -957,13 +944,10 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
uint32 bytesInBuffer = UTF8CountBytes(charArray, numChars); uint32 bytesInBuffer = UTF8CountBytes(charArray, numChars);
link.Attach<int32>(bytesInBuffer); link.Attach<int32>(bytesInBuffer);
link.Attach(charArray, bytesInBuffer); link.Attach(charArray, bytesInBuffer);
if (link.FlushWithReply(code) != B_OK
link.FlushWithReply(&code); || code != SERVER_TRUE)
if (code != SERVER_TRUE)
return; return;
link.Read(escapementArray, numChars * sizeof(float)); link.Read(escapementArray, numChars * sizeof(float));
@@ -974,7 +958,7 @@ void
BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta,
BPoint escapementArray[]) const BPoint escapementArray[]) const
{ {
GetEscapements(charArray, numChars,delta,escapementArray,NULL); GetEscapements(charArray, numChars, delta, escapementArray, NULL);
} }
@@ -982,95 +966,83 @@ void
BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta,
BPoint escapementArray[], BPoint offsetArray[]) const BPoint escapementArray[], BPoint offsetArray[]) const
{ {
if(!charArray || numChars<1 || !escapementArray) if (!charArray || numChars<1 || !escapementArray)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_ESCAPEMENTS); link.StartMessage(AS_GET_ESCAPEMENTS);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<float>(fSize); link.Attach<float>(fSize);
link.Attach<float>(fRotation); link.Attach<float>(fRotation);
link.Attach<uint32>(fFlags); link.Attach<uint32>(fFlags);
link.Attach<int32>(numChars); link.Attach<int32>(numChars);
// TODO: Support UTF8 characters // TODO: Support UTF8 characters
if(offsetArray) if (offsetArray) {
{ for (int32 i = 0; i < numChars; i++) {
for(int32 i=0; i<numChars; i++)
{
link.Attach<char>(charArray[i]); link.Attach<char>(charArray[i]);
link.Attach<BPoint>(offsetArray[i]); link.Attach<BPoint>(offsetArray[i]);
} }
} } else {
else BPoint dummypt(0, 0);
{
BPoint dummypt(0,0); for (int32 i = 0; i < numChars; i++) {
for(int32 i=0; i<numChars; i++)
{
link.Attach<char>(charArray[i]); link.Attach<char>(charArray[i]);
link.Attach<BPoint>(dummypt); link.Attach<BPoint>(dummypt);
} }
} }
link.FlushWithReply(&code);
if(code!=SERVER_TRUE) if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return; return;
for(int32 i=0; i<numChars; i++) link.Read(escapementArray, sizeof(BPoint) * numChars);
link.Read<BPoint>(&escapementArray[i]);
} }
void void
BFont::GetEdges(const char charArray[], int32 numBytes, edge_info edgeArray[]) const BFont::GetEdges(const char charArray[], int32 numBytes, edge_info edgeArray[]) const
{ {
if(!charArray || numBytes<1 || !edgeArray) if (!charArray || numBytes < 1 || !edgeArray)
return; return;
int32 code;
BPrivate::BAppServerLink link;
link.StartMessage(AS_GET_EDGES);
link.Attach<int32>(numBytes);
for(int32 i=0; i<numBytes; i++)
link.Attach<char>(charArray[i]);
link.FlushWithReply(&code);
if(code!=SERVER_TRUE) int32 code;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_EDGES);
link.Attach<int32>(numBytes);
link.Attach(charArray, numBytes);
if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return; return;
for(int32 i=0; i<numBytes; i++) link.Read(edgeArray, sizeof(edge_info) * numBytes);
link.Read<edge_info>(&edgeArray[i]);
} }
void void
BFont::GetHeight(font_height *height) const BFont::GetHeight(font_height *height) const
{ {
if(height) if (height) {
{
// R5's version actually contacts the server in this call. The more and more // R5's version actually contacts the server in this call. The more and more
// I work with this class, the more and more I can't wait for R2 to fix it. Yeesh. // I work with this class, the more and more I can't wait for R2 to fix it. Yeesh.
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_FONT_HEIGHT); link.StartMessage(AS_GET_FONT_HEIGHT);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<float>(fSize); link.Attach<float>(fSize);
link.FlushWithReply(&code);
if (link.FlushWithReply(code) != B_OK
if(code==SERVER_FALSE) || code != SERVER_TRUE)
return; return;
link.Read<font_height>(height); link.Read<font_height>(height);
} }
} }
@@ -1088,38 +1060,30 @@ void
BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode, BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode,
escapement_delta *delta, BRect boundingBoxArray[]) const escapement_delta *delta, BRect boundingBoxArray[]) const
{ {
if(!charArray || numChars<1 || !boundingBoxArray) if (!charArray || numChars < 1 || !boundingBoxArray)
return; return;
int32 code;
BPrivate::BAppServerLink link;
link.StartMessage(AS_GET_BOUNDINGBOXES_CHARS);
link.Attach<font_metric_mode>(mode);
if(delta)
{
link.Attach<escapement_delta>(*delta);
}
else
{
escapement_delta esd={0,0};
link.Attach<escapement_delta>(esd);
}
link.Attach<int32>(numChars);
for(int32 i=0; i<numChars; i++)
link.Attach<char>(charArray[i]);
link.FlushWithReply(&code);
if(code!=SERVER_TRUE) int32 code;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_BOUNDINGBOXES_CHARS);
link.Attach<font_metric_mode>(mode);
if (delta) {
link.Attach<escapement_delta>(*delta);
} else {
escapement_delta emptyDelta = {0, 0};
link.Attach<escapement_delta>(emptyDelta);
}
link.Attach<int32>(numChars);
link.Attach(charArray, numChars);
if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return; return;
for(int32 i=0; i<numChars; i++) link.Read(boundingBoxArray, sizeof(BRect) * numChars);
link.Read<BRect>(&boundingBoxArray[i]);
} }
@@ -1127,42 +1091,35 @@ void
BFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings, BFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings,
font_metric_mode mode, escapement_delta deltas[], BRect boundingBoxArray[]) const font_metric_mode mode, escapement_delta deltas[], BRect boundingBoxArray[]) const
{ {
if(!stringArray || numStrings<1 || !boundingBoxArray) if (!stringArray || numStrings < 1 || !boundingBoxArray)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_BOUNDINGBOXES_STRINGS); link.StartMessage(AS_GET_BOUNDINGBOXES_STRINGS);
link.Attach<font_metric_mode>(mode); link.Attach<font_metric_mode>(mode);
link.Attach<int32>(numStrings); link.Attach<int32>(numStrings);
if(deltas) if (deltas) {
{ for (int32 i = 0; i < numStrings; i++) {
for(int32 i=0; i<numStrings; i++)
{
link.AttachString(stringArray[i]); link.AttachString(stringArray[i]);
link.Attach<escapement_delta>(deltas[i]); link.Attach<escapement_delta>(deltas[i]);
} }
} } else {
else escapement_delta emptyDelta = {0, 0};
{
escapement_delta esd={0,0}; for (int32 i = 0; i < numStrings; i++) {
for(int32 i=0; i<numStrings; i++)
{
link.AttachString(stringArray[i]); link.AttachString(stringArray[i]);
link.Attach<escapement_delta>(esd); link.Attach<escapement_delta>(emptyDelta);
} }
} }
link.FlushWithReply(&code);
if(code!=SERVER_TRUE) if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return; return;
for(int32 i=0; i<numStrings; i++) link.Read(boundingBoxArray, sizeof(BRect) * numStrings);
link.Read<BRect>(&boundingBoxArray[i]);
} }
@@ -1170,14 +1127,13 @@ void
BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShapeArray[]) const BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShapeArray[]) const
{ {
// TODO: implement code specifically for passing BShapes to and from the server // TODO: implement code specifically for passing BShapes to and from the server
if(!charArray || numChars<1 || !glyphShapeArray) if (!charArray || numChars < 1 || !glyphShapeArray)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_GLYPH_SHAPES); link.StartMessage(AS_GET_GLYPH_SHAPES);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<float>(fSize); link.Attach<float>(fSize);
@@ -1186,42 +1142,35 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShape
link.Attach<uint32>(fFlags); link.Attach<uint32>(fFlags);
link.Attach<int32>(numChars); link.Attach<int32>(numChars);
for(int32 i = 0; i < numChars; i++) link.Attach(charArray, numChars);
link.Attach<char>(charArray[i]);
if (link.FlushWithReply(code) != B_OK
link.FlushWithReply(&code); || code != SERVER_TRUE)
if(code!=SERVER_TRUE)
return; return;
for(int32 i = 0; i < numChars; i++) for (int32 i = 0; i < numChars; i++)
link.ReadShape(glyphShapeArray[i]); link.ReadShape(glyphShapeArray[i]);
} }
void void
BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) const BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) const
{ {
if(!charArray || numChars<1 || !hasArray) if (!charArray || numChars < 1 || !hasArray)
return; return;
int32 code; int32 code;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_HAS_GLYPHS);
link.Attach<int32>(numChars);
for(int32 i=0; i<numChars; i++)
link.Attach<char>(charArray[i]);
link.FlushWithReply(&code);
if(code!=SERVER_TRUE) link.StartMessage(AS_GET_HAS_GLYPHS);
link.Attach<int32>(numChars);
link.Attach(charArray, numChars);
if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
return; return;
for(int32 i=0; i<numChars; i++) link.Read(hasArray, sizeof(bool) * numChars);
link.Read<bool>(&hasArray[i]);
} }
+73 -56
View File
@@ -209,14 +209,17 @@ get_scroll_bar_info(scroll_bar_info *info)
if (info == NULL) if (info == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_GET_SCROLLBAR_INFO); link.StartMessage(AS_GET_SCROLLBAR_INFO);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE) {
link.Read<scroll_bar_info>(info); link.Read<scroll_bar_info>(info);
return B_OK;
return ((code==SERVER_TRUE)?B_OK:B_ERROR); }
return B_ERROR;
} }
@@ -226,13 +229,17 @@ set_scroll_bar_info(scroll_bar_info *info)
if (info == NULL) if (info == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code; int32 code;
link.StartMessage(AS_SET_SCROLLBAR_INFO); link.StartMessage(AS_SET_SCROLLBAR_INFO);
link.Attach<scroll_bar_info>(*info); link.Attach<scroll_bar_info>(*info);
link.FlushWithReply(&code);
return ((code==SERVER_TRUE)?B_OK:B_ERROR); if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE)
return B_OK;
return B_ERROR;
} }
#endif // COMPILE_FOR_R5 #endif // COMPILE_FOR_R5
@@ -550,14 +557,15 @@ keyboard_navigation_color()
_IMPEXP_BE int32 _IMPEXP_BE int32
count_workspaces() count_workspaces()
{ {
int32 count=1; int32 count = 1;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_COUNT_WORKSPACES); link.StartMessage(AS_COUNT_WORKSPACES);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<int32>(&count); link.Read<int32>(&count);
return count; return count;
} }
@@ -565,7 +573,7 @@ count_workspaces()
_IMPEXP_BE void _IMPEXP_BE void
set_workspace_count(int32 count) set_workspace_count(int32 count)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_WORKSPACE_COUNT); link.StartMessage(AS_SET_WORKSPACE_COUNT);
link.Attach<int32>(count); link.Attach<int32>(count);
link.Flush(); link.Flush();
@@ -577,12 +585,13 @@ current_workspace()
{ {
int32 index = 0; int32 index = 0;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_CURRENT_WORKSPACE); link.StartMessage(AS_CURRENT_WORKSPACE);
if (link.FlushWithReply(&code) == B_OK && code == SERVER_TRUE)
int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<int32>(&index); link.Read<int32>(&index);
return index; return index;
} }
@@ -590,7 +599,7 @@ current_workspace()
_IMPEXP_BE void _IMPEXP_BE void
activate_workspace(int32 workspace) activate_workspace(int32 workspace)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_ACTIVATE_WORKSPACE); link.StartMessage(AS_ACTIVATE_WORKSPACE);
link.Attach<int32>(workspace); link.Attach<int32>(workspace);
link.Flush(); link.Flush();
@@ -601,14 +610,14 @@ _IMPEXP_BE bigtime_t
idle_time() idle_time()
{ {
bigtime_t idletime = 0; bigtime_t idletime = 0;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_IDLE_TIME); link.StartMessage(AS_IDLE_TIME);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<int64>(&idletime); link.Read<int64>(&idletime);
return idletime; return idletime;
} }
@@ -641,7 +650,7 @@ run_be_about()
_IMPEXP_BE void _IMPEXP_BE void
set_focus_follows_mouse(bool follow) set_focus_follows_mouse(bool follow)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_FOCUS_FOLLOWS_MOUSE); link.StartMessage(AS_SET_FOCUS_FOLLOWS_MOUSE);
link.Attach<bool>(follow); link.Attach<bool>(follow);
link.Flush(); link.Flush();
@@ -652,13 +661,14 @@ _IMPEXP_BE bool
focus_follows_mouse() focus_follows_mouse()
{ {
bool ffm = false; bool ffm = false;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_FOCUS_FOLLOWS_MOUSE); link.StartMessage(AS_FOCUS_FOLLOWS_MOUSE);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<bool>(&ffm); link.Read<bool>(&ffm);
return ffm; return ffm;
} }
@@ -666,7 +676,7 @@ focus_follows_mouse()
_IMPEXP_BE void _IMPEXP_BE void
set_mouse_mode(mode_mouse mode) set_mouse_mode(mode_mouse mode)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_MOUSE_MODE); link.StartMessage(AS_SET_MOUSE_MODE);
link.Attach<mode_mouse>(mode); link.Attach<mode_mouse>(mode);
link.Flush(); link.Flush();
@@ -676,14 +686,16 @@ set_mouse_mode(mode_mouse mode)
_IMPEXP_BE mode_mouse _IMPEXP_BE mode_mouse
mouse_mode() mouse_mode()
{ {
// ToDo: what is mouse_mode? Get a default value over here now! :-)
mode_mouse mode; mode_mouse mode;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_GET_MOUSE_MODE); link.StartMessage(AS_GET_MOUSE_MODE);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<mode_mouse>(&mode); link.Read<mode_mouse>(&mode);
return mode; return mode;
} }
@@ -692,14 +704,15 @@ _IMPEXP_BE rgb_color
ui_color(color_which which) ui_color(color_which which)
{ {
rgb_color color; rgb_color color;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_GET_UI_COLOR); link.StartMessage(AS_GET_UI_COLOR);
link.Attach<color_which>(which); link.Attach<color_which>(which);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<rgb_color>(&color); link.Read<rgb_color>(&color);
return color; return color;
} }
@@ -794,43 +807,47 @@ _fini_interface_kit_()
void void
__set_window_decor(int32 theme) __set_window_decor(int32 theme)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_R5_SET_DECORATOR); link.StartMessage(AS_R5_SET_DECORATOR);
link.Attach<int32>(theme); link.Attach<int32>(theme);
link.Flush(); link.Flush();
} }
namespace BPrivate {
/*! /*!
\brief Private function to get the system's GUI colors as a set \brief Private function to get the system's GUI colors as a set
\param colors The recipient color set \param colors The recipient color set
*/ */
void get_system_colors(ColorSet *colors) void
get_system_colors(ColorSet *colors)
{ {
if(!colors) if (!colors)
return; return;
BAppServerLink link; BPrivate::AppServerLink link;
int32 code;
link.StartMessage(AS_GET_UI_COLORS); link.StartMessage(AS_GET_UI_COLORS);
link.Flush();
link.GetNextMessage(code); int32 code;
link.Read<ColorSet>(colors); if (link.FlushWithReply(code) == B_OK)
link.Read<ColorSet>(colors);
} }
/*! /*!
\brief Private function to set the system's GUI colors all at once \brief Private function to set the system's GUI colors all at once
\param colors The color set to use \param colors The color set to use
*/ */
void set_system_colors(const ColorSet &colors) void
set_system_colors(const ColorSet &colors)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_UI_COLORS); link.StartMessage(AS_SET_UI_COLORS);
link.Attach<ColorSet>(colors); link.Attach<ColorSet>(colors);
link.Flush(); link.Flush();
} }
} // namespace BPrivate
// These methods were marked with "Danger, will Robinson!" in // These methods were marked with "Danger, will Robinson!" in
// the OpenTracker source, so we might not want to be compatible // the OpenTracker source, so we might not want to be compatible
+169 -158
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS // Copyright (c) 2001-2005, Haiku
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -25,12 +25,11 @@
// be "replayed" later. // be "replayed" later.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
// System Includes -------------------------------------------------------------
#include <Picture.h> #include <Picture.h>
#include <Message.h> #include <Message.h>
#include <ByteOrder.h> #include <ByteOrder.h>
@@ -40,13 +39,6 @@
#include <AppServerLink.h> #include <AppServerLink.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
struct _BPictureExtent_ { struct _BPictureExtent_ {
void *fNewData; void *fNewData;
@@ -60,11 +52,12 @@ struct _BPictureExtent_ {
status_t do_playback(void * data, int32 size, BList& pictures, status_t do_playback(void * data, int32 size, BList& pictures,
void **callBackTable, int32 tableEntries, void *user); void **callBackTable, int32 tableEntries, void *user);
//------------------------------------------------------------------------------
BPicture::BPicture() BPicture::BPicture()
: token(-1), :
extent(NULL), token(-1),
usurped(NULL) extent(NULL),
usurped(NULL)
{ {
extent = new _BPictureExtent_; extent = new _BPictureExtent_;
extent->fNewData = NULL; extent->fNewData = NULL;
@@ -72,53 +65,51 @@ BPicture::BPicture()
extent->fOldData = NULL; extent->fOldData = NULL;
extent->fOldSize = 0; extent->fOldSize = 0;
} }
//------------------------------------------------------------------------------
BPicture::BPicture(const BPicture &picture)
: token(-1), BPicture::BPicture(const BPicture &otherPicture)
extent(NULL), :
usurped(NULL) token(-1),
extent(NULL),
usurped(NULL)
{ {
init_data(); init_data();
if (picture.token != -1) if (otherPicture.token != -1) {
{ BPrivate::AppServerLink link;
BPrivate::BAppServerLink link;
int32 code=SERVER_FALSE;
link.StartMessage(AS_CLONE_PICTURE); link.StartMessage(AS_CLONE_PICTURE);
link.Attach<int32>(picture.token); link.Attach<int32>(otherPicture.token);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE)
link.Read<int32>(&token); link.Read<int32>(&token);
} }
if (picture.extent->fNewData != NULL)
{ if (otherPicture.extent->fNewData != NULL) {
extent->fNewSize = picture.extent->fNewSize; extent->fNewSize = otherPicture.extent->fNewSize;
extent->fNewData = malloc(extent->fNewSize); extent->fNewData = malloc(extent->fNewSize);
memcpy(extent->fNewData, picture.extent->fNewData, extent->fNewSize); memcpy(extent->fNewData, otherPicture.extent->fNewData, extent->fNewSize);
BPicture *pic; for (int32 i = 0; i < otherPicture.extent->fPictures.CountItems(); i++) {
BPicture *picture = new BPicture(*(BPicture*)otherPicture.extent->fPictures.ItemAt(i));
for (int32 i = 0; i < picture.extent->fPictures.CountItems(); i++) extent->fPictures.AddItem(picture);
{
pic = new BPicture(*(BPicture*)picture.extent->fPictures.ItemAt(i));
extent->fPictures.AddItem(pic);
} }
} } else if (otherPicture.extent->fOldData != NULL) {
else if (picture.extent->fOldData != NULL) extent->fOldSize = otherPicture.extent->fOldSize;
{
extent->fOldSize = picture.extent->fOldSize;
extent->fOldData = malloc(extent->fOldSize); extent->fOldData = malloc(extent->fOldSize);
memcpy(extent->fOldData, picture.extent->fOldData, extent->fOldSize); memcpy(extent->fOldData, otherPicture.extent->fOldData, extent->fOldSize);
// In old data the sub pictures are inside the data // In old data the sub pictures are inside the data
} }
} }
//------------------------------------------------------------------------------
BPicture::BPicture(BMessage *archive) BPicture::BPicture(BMessage *archive)
: token(-1), :
extent(NULL), token(-1),
usurped(NULL) extent(NULL),
usurped(NULL)
{ {
init_data(); init_data();
@@ -147,39 +138,36 @@ BPicture::BPicture(BMessage *archive)
if (version == 0) if (version == 0)
import_old_data(data, size); import_old_data(data, size);
else if (version == 1) else if (version == 1) {
{
extent->fNewSize = size; extent->fNewSize = size;
extent->fNewData = malloc(extent->fNewSize); extent->fNewData = malloc(extent->fNewSize);
memcpy(extent->fNewData, data, extent->fNewSize); memcpy(extent->fNewData, data, extent->fNewSize);
// swap_data(extent->fNewData, extent->fNewSize); // swap_data(extent->fNewData, extent->fNewSize);
if (extent->fNewSize != 0 && extent->fNewData != 0) if (extent->fNewSize != 0 && extent->fNewData != 0) {
{ BPrivate::AppServerLink link;
BPrivate::BAppServerLink link;
int32 code=SERVER_FALSE;
BPicture *pic;
link.StartMessage(AS_CREATE_PICTURE); link.StartMessage(AS_CREATE_PICTURE);
link.Attach<int32>(extent->fPictures.CountItems()); link.Attach<int32>(extent->fPictures.CountItems());
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
{ for (int32 i = 0; i < extent->fPictures.CountItems(); i++) {
pic=(BPicture*)extent->fPictures.ItemAt(i); BPicture *picture = (BPicture *)extent->fPictures.ItemAt(i);
if(pic) if (picture != NULL)
link.Attach<int32>(pic->token); link.Attach<int32>(picture->token);
} }
link.Attach<int32>(extent->fNewSize); link.Attach<int32>(extent->fNewSize);
link.Attach(extent->fNewData,extent->fNewSize); link.Attach(extent->fNewData, extent->fNewSize);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE)
link.Read<int32>(&token); link.Read<int32>(&token);
} }
} }
// Do we just free the data now? // Do we just free the data now?
if (extent->fNewData) if (extent->fNewData) {
{
free(extent->fNewData); free(extent->fNewData);
extent->fNewData = NULL; extent->fNewData = NULL;
extent->fNewSize = 0; extent->fNewSize = 0;
@@ -197,27 +185,25 @@ BPicture::BPicture(BMessage *archive)
delete (BPicture *)extent->fPictures.ItemAt(i); delete (BPicture *)extent->fPictures.ItemAt(i);
extent->fPictures.MakeEmpty(); extent->fPictures.MakeEmpty();
} }
//------------------------------------------------------------------------------
BPicture::~BPicture() BPicture::~BPicture()
{ {
if (token != -1) if (token != -1) {
{ BPrivate::AppServerLink link;
BPrivate::BAppServerLink link;
link.StartMessage(AS_DELETE_PICTURE); link.StartMessage(AS_DELETE_PICTURE);
link.Attach<int32>(token); link.Attach<int32>(token);
link.Flush(); link.Flush();
} }
if (extent->fNewData != NULL) if (extent->fNewData != NULL) {
{
free(extent->fNewData); free(extent->fNewData);
extent->fNewData = NULL; extent->fNewData = NULL;
extent->fNewSize = 0; extent->fNewSize = 0;
} }
if (extent->fOldData != NULL) if (extent->fOldData != NULL) {
{
free(extent->fOldData); free(extent->fOldData);
extent->fOldData = NULL; extent->fOldData = NULL;
extent->fOldSize = 0; extent->fOldSize = 0;
@@ -229,56 +215,59 @@ BPicture::~BPicture()
free(extent); free(extent);
} }
//------------------------------------------------------------------------------
BArchivable *BPicture::Instantiate(BMessage *archive)
BArchivable *
BPicture::Instantiate(BMessage *archive)
{ {
if (validate_instantiation(archive, "BPicture")) if (validate_instantiation(archive, "BPicture"))
return new BPicture(archive); return new BPicture(archive);
else
return NULL; return NULL;
} }
//------------------------------------------------------------------------------
status_t BPicture::Archive(BMessage *archive, bool deep) const
status_t
BPicture::Archive(BMessage *archive, bool deep) const
{ {
if (!const_cast<BPicture*>(this)->assert_local_copy()) if (!const_cast<BPicture*>(this)->assert_local_copy())
return B_ERROR; return B_ERROR;
status_t err = BArchivable::Archive(archive, deep); status_t err = BArchivable::Archive(archive, deep);
if (err != B_OK) if (err != B_OK)
return err; return err;
err = archive->AddInt32("_ver", 1); err = archive->AddInt32("_ver", 1);
if (err != B_OK) if (err != B_OK)
return err; return err;
err = archive->AddInt8("_endian", B_HOST_IS_BENDIAN); err = archive->AddInt8("_endian", B_HOST_IS_BENDIAN);
if (err != B_OK) if (err != B_OK)
return err; return err;
err = archive->AddData("_data", B_RAW_TYPE, extent->fNewData, err = archive->AddData("_data", B_RAW_TYPE, extent->fNewData,
extent->fNewSize); extent->fNewSize);
for (int32 i = 0; i < extent->fPictures.CountItems(); i++) for (int32 i = 0; i < extent->fPictures.CountItems(); i++) {
{
BMessage picMsg; BMessage picMsg;
((BPicture*)extent->fPictures.ItemAt(i))->Archive(&picMsg, deep); ((BPicture*)extent->fPictures.ItemAt(i))->Archive(&picMsg, deep);
archive->AddMessage("piclib", &picMsg); archive->AddMessage("piclib", &picMsg);
} }
return err; return err;
} }
//------------------------------------------------------------------------------
status_t BPicture::Perform(perform_code d, void *arg)
status_t
BPicture::Perform(perform_code d, void *arg)
{ {
return BArchivable::Perform(d, arg); return BArchivable::Perform(d, arg);
} }
//------------------------------------------------------------------------------
status_t BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
status_t
BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
{ {
if (!assert_local_copy()) if (!assert_local_copy())
return B_ERROR; return B_ERROR;
@@ -286,8 +275,10 @@ status_t BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
return do_playback(extent->fNewData, extent->fNewSize, extent->fPictures, return do_playback(extent->fNewData, extent->fNewSize, extent->fPictures,
callBackTable, tableEntries, user); callBackTable, tableEntries, user);
} }
//------------------------------------------------------------------------------
status_t BPicture::Flatten(BDataIO *stream)
status_t
BPicture::Flatten(BDataIO *stream)
{ {
if (!assert_local_copy()) if (!assert_local_copy())
return B_ERROR; return B_ERROR;
@@ -311,8 +302,10 @@ status_t BPicture::Flatten(BDataIO *stream)
return B_OK; return B_OK;
} }
//------------------------------------------------------------------------------
status_t BPicture::Unflatten(BDataIO *stream)
status_t
BPicture::Unflatten(BDataIO *stream)
{ {
// TODO check the header // TODO check the header
int32 bla1 = 2; int32 bla1 = 2;
@@ -324,12 +317,10 @@ status_t BPicture::Unflatten(BDataIO *stream)
stream->Read(&count, 4); stream->Read(&count, 4);
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++) {
{
BPicture *pic = new BPicture; BPicture *pic = new BPicture;
pic->Unflatten(stream); pic->Unflatten(stream);
extent->fPictures.AddItem(pic); extent->fPictures.AddItem(pic);
} }
@@ -339,26 +330,25 @@ status_t BPicture::Unflatten(BDataIO *stream)
// swap_data(extent->fNewData, extent->fNewSize); // swap_data(extent->fNewData, extent->fNewSize);
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
int32 code=SERVER_FALSE;
BPicture *pic;
link.StartMessage(AS_CREATE_PICTURE); link.StartMessage(AS_CREATE_PICTURE);
link.Attach<int32>(extent->fPictures.CountItems()); link.Attach<int32>(extent->fPictures.CountItems());
for (int32 i = 0; i < extent->fPictures.CountItems(); i++)
{ for (int32 i = 0; i < extent->fPictures.CountItems(); i++) {
pic=(BPicture*)extent->fPictures.ItemAt(i); BPicture *picture = (BPicture *)extent->fPictures.ItemAt(i);
if(pic) if (picture)
link.Attach<int32>(pic->token); link.Attach<int32>(picture->token);
} }
link.Attach<int32>(extent->fNewSize); link.Attach<int32>(extent->fNewSize);
link.Attach(extent->fNewData, extent->fNewSize); link.Attach(extent->fNewData, extent->fNewSize);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE)
link.Read<int32>(&token); link.Read<int32>(&token);
if (extent->fNewData) if (extent->fNewData) {
{
free(extent->fNewData); free(extent->fNewData);
extent->fNewData = NULL; extent->fNewData = NULL;
extent->fNewSize = 0; extent->fNewSize = 0;
@@ -366,17 +356,22 @@ status_t BPicture::Unflatten(BDataIO *stream)
return B_OK; return B_OK;
} }
//------------------------------------------------------------------------------
void BPicture::_ReservedPicture1() {} void BPicture::_ReservedPicture1() {}
void BPicture::_ReservedPicture2() {} void BPicture::_ReservedPicture2() {}
void BPicture::_ReservedPicture3() {} void BPicture::_ReservedPicture3() {}
//------------------------------------------------------------------------------
BPicture &BPicture::operator=(const BPicture &)
BPicture &
BPicture::operator=(const BPicture &)
{ {
return *this; return *this;
} }
//------------------------------------------------------------------------------
void BPicture::init_data()
void
BPicture::init_data()
{ {
token = -1; token = -1;
usurped = NULL; usurped = NULL;
@@ -387,15 +382,16 @@ void BPicture::init_data()
extent->fOldData = NULL; extent->fOldData = NULL;
extent->fOldSize = 0; extent->fOldSize = 0;
} }
//------------------------------------------------------------------------------
void BPicture::import_data(const void *data, int32 size, BPicture **subs,
int32 subCount) void
BPicture::import_data(const void *data, int32 size, BPicture **subs,
int32 subCount)
{ {
if (data == NULL || size == 0) if (data == NULL || size == 0)
return; return;
BPrivate::BAppServerLink link; BPrivate::AppServerLink link;
int32 code=SERVER_FALSE;
link.StartMessage(AS_CREATE_PICTURE); link.StartMessage(AS_CREATE_PICTURE);
link.Attach<int32>(subCount); link.Attach<int32>(subCount);
@@ -405,12 +401,16 @@ void BPicture::import_data(const void *data, int32 size, BPicture **subs,
link.Attach<int32>(size); link.Attach<int32>(size);
link.Attach(data, size); link.Attach(data, size);
link.FlushWithReply(&code);
if(code==SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE)
link.Read<int32>(&token); link.Read<int32>(&token);
} }
//------------------------------------------------------------------------------
void BPicture::import_old_data(const void *data, int32 size)
void
BPicture::import_old_data(const void *data, int32 size)
{ {
// TODO: do we need to support old data, what is old data? // TODO: do we need to support old data, what is old data?
/*if (data == NULL) /*if (data == NULL)
@@ -438,13 +438,17 @@ void BPicture::import_old_data(const void *data, int32 size)
extent->fOldData = 0; extent->fOldData = 0;
extent->fOldSize = 0;*/ extent->fOldSize = 0;*/
} }
//------------------------------------------------------------------------------
void BPicture::set_token(int32 _token)
void
BPicture::set_token(int32 _token)
{ {
token = _token; token = _token;
} }
//------------------------------------------------------------------------------
bool BPicture::assert_local_copy()
bool
BPicture::assert_local_copy()
{ {
if (extent->fNewData != NULL) if (extent->fNewData != NULL)
return true; return true;
@@ -476,8 +480,10 @@ bool BPicture::assert_local_copy()
return true; return true;
} }
//------------------------------------------------------------------------------
bool BPicture::assert_old_local_copy()
bool
BPicture::assert_old_local_copy()
{ {
if (extent->fOldData != NULL) if (extent->fOldData != NULL)
return true; return true;
@@ -490,8 +496,10 @@ bool BPicture::assert_old_local_copy()
return true; return true;
} }
//------------------------------------------------------------------------------
bool BPicture::assert_server_copy()
bool
BPicture::assert_server_copy()
{ {
if (token != -1) if (token != -1)
return true; return true;
@@ -516,55 +524,57 @@ bool BPicture::assert_server_copy()
return token != -1;*/ return token != -1;*/
return true; return true;
} }
//------------------------------------------------------------------------------
BPicture::BPicture(const void *data, int32 size) BPicture::BPicture(const void *data, int32 size)
{ {
init_data(); init_data();
import_old_data(data, size); import_old_data(data, size);
} }
//------------------------------------------------------------------------------
const void *BPicture::Data() const
const void *
BPicture::Data() const
{ {
if (extent->fNewData == NULL) if (extent->fNewData == NULL) {
{
const_cast<BPicture*>(this)->assert_local_copy(); const_cast<BPicture*>(this)->assert_local_copy();
//convert_new_to_old(void *, long, void **, long *); //convert_new_to_old(void *, long, void **, long *);
} }
return extent->fNewData; return extent->fNewData;
} }
//------------------------------------------------------------------------------
int32 BPicture::DataSize() const
int32
BPicture::DataSize() const
{ {
if (extent->fNewData == NULL) if (extent->fNewData == NULL) {
{
const_cast<BPicture*>(this)->assert_local_copy(); const_cast<BPicture*>(this)->assert_local_copy();
//convert_new_to_old(void *, long, void **, long *); //convert_new_to_old(void *, long, void **, long *);
} }
return extent->fNewSize; return extent->fNewSize;
} }
//------------------------------------------------------------------------------
void BPicture::usurp(BPicture *lameDuck)
void
BPicture::usurp(BPicture *lameDuck)
{ {
if (token != -1) if (token != -1) {
{ BPrivate::AppServerLink link;
BPrivate::BAppServerLink link;
link.StartMessage(AS_DELETE_PICTURE); link.StartMessage(AS_DELETE_PICTURE);
link.Attach<int32>(token); link.Attach<int32>(token);
link.Flush(); link.Flush();
} }
if (extent->fNewData != NULL) if (extent->fNewData != NULL) {
{
free(extent->fNewData); free(extent->fNewData);
extent->fNewData = NULL; extent->fNewData = NULL;
extent->fNewSize = 0; extent->fNewSize = 0;
} }
if (extent->fOldData != NULL) if (extent->fOldData != NULL) {
{
free(extent->fOldData); free(extent->fOldData);
extent->fOldData = NULL; extent->fOldData = NULL;
extent->fOldSize = 0; extent->fOldSize = 0;
@@ -581,23 +591,24 @@ void BPicture::usurp(BPicture *lameDuck)
// Do the usurping // Do the usurping
usurped = lameDuck; usurped = lameDuck;
} }
//------------------------------------------------------------------------------
BPicture *BPicture::step_down()
BPicture *
BPicture::step_down()
{ {
BPicture *lameDuck = usurped; BPicture *lameDuck = usurped;
usurped = NULL; usurped = NULL;
return lameDuck; return lameDuck;
} }
//------------------------------------------------------------------------------
status_t do_playback(void * data, int32 size, BList& pictures,
status_t
do_playback(void * data, int32 size, BList& pictures,
void **callBackTable, int32 tableEntries, void *user) void **callBackTable, int32 tableEntries, void *user)
{ {
TPicture pic(data, size, pictures); TPicture picture(data, size, pictures);
return pic.Play(callBackTable, tableEntries, user); return picture.Play(callBackTable, tableEntries, user);
} }
//------------------------------------------------------------------------------
+22 -25
View File
@@ -158,7 +158,7 @@ BPrivateScreen::RetraceSemaphore()
sem_id id = B_BAD_SEM_ID; sem_id id = B_BAD_SEM_ID;
// TODO: Implement // TODO: Implement
/* /*
BAppServerLink link; BPrivate::AppServerLink link;
PortMessage reply; PortMessage reply;
link.SetOpCode(AS_GET_RETRACE_SEMAPHORE); link.SetOpCode(AS_GET_RETRACE_SEMAPHORE);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
@@ -233,13 +233,13 @@ rgb_color
BPrivateScreen::DesktopColor(uint32 workspace) BPrivateScreen::DesktopColor(uint32 workspace)
{ {
rgb_color color = { 51, 102, 152, 255 }; rgb_color color = { 51, 102, 152, 255 };
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_DESKTOP_COLOR); link.StartMessage(AS_GET_DESKTOP_COLOR);
link.Attach<int32>(workspace); link.Attach<int32>(workspace);
int32 code; int32 code;
if (link.FlushWithReply(&code) == B_OK if (link.FlushWithReply(code) == B_OK
&& code == SERVER_TRUE) && code == SERVER_TRUE)
link.Read<rgb_color>(&color); link.Read<rgb_color>(&color);
@@ -250,7 +250,7 @@ BPrivateScreen::DesktopColor(uint32 workspace)
void void
BPrivateScreen::SetDesktopColor(rgb_color color, uint32 workspace, bool makeDefault) BPrivateScreen::SetDesktopColor(rgb_color color, uint32 workspace, bool makeDefault)
{ {
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_DESKTOP_COLOR); link.StartMessage(AS_SET_DESKTOP_COLOR);
link.Attach<rgb_color>(color); link.Attach<rgb_color>(color);
@@ -282,20 +282,19 @@ BPrivateScreen::GetMode(uint32 workspace, display_mode *mode)
if (mode == NULL) if (mode == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SCREEN_GET_MODE); link.StartMessage(AS_SCREEN_GET_MODE);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
link.Attach<uint32>(workspace); link.Attach<uint32>(workspace);
int32 code = SERVER_FALSE; int32 code;
link.FlushWithReply(&code); if (link.FlushWithReply(code) != B_OK
|| code != SERVER_TRUE)
if (code != SERVER_TRUE)
return B_ERROR; return B_ERROR;
display_mode currentMode; display_mode currentMode;
link.Read<display_mode>(&currentMode); link.Read<display_mode>(&currentMode);
status_t status = B_ERROR; status_t status = B_ERROR;
link.Read<status_t>(&status); link.Read<status_t>(&status);
if (status == B_OK && mode) if (status == B_OK && mode)
@@ -311,20 +310,18 @@ BPrivateScreen::SetMode(uint32 workspace, display_mode *mode, bool makeDefault)
if (mode == NULL) if (mode == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SCREEN_SET_MODE); link.StartMessage(AS_SCREEN_SET_MODE);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
link.Attach<uint32>(workspace); link.Attach<uint32>(workspace);
link.Attach<display_mode>(*mode); link.Attach<display_mode>(*mode);
link.Attach<bool>(makeDefault); link.Attach<bool>(makeDefault);
int32 code = SERVER_FALSE;
link.FlushWithReply(&code);
status_t status = B_ERROR; status_t status = B_ERROR;
if (code == SERVER_TRUE) int32 code;
if (link.FlushWithReply(code) == B_OK && code == SERVER_TRUE)
link.Read<status_t>(&status); link.Read<status_t>(&status);
return status; return status;
} }
@@ -358,7 +355,7 @@ BPrivateScreen::SetDPMS(uint32 dpmsState)
{ {
status_t status = B_ERROR; status_t status = B_ERROR;
/* /*
BAppServerLink link; BPrivate::AppServerLink link;
PortMessage reply; PortMessage reply;
link.SetOpCode(AS_SET_DPMS); link.SetOpCode(AS_SET_DPMS);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
@@ -376,7 +373,7 @@ BPrivateScreen::DPMSState()
// TODO: Implement // TODO: Implement
uint32 state = 0; uint32 state = 0;
/* /*
BAppServerLink link; BPrivate::AppServerLink link;
PortMessage reply; PortMessage reply;
link.SetOpCode(AS_GET_DPMS_STATE); link.SetOpCode(AS_GET_DPMS_STATE);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
@@ -393,7 +390,7 @@ BPrivateScreen::DPMSCapabilites()
// TODO: Implement // TODO: Implement
uint32 capabilities = 0; uint32 capabilities = 0;
/* /*
BAppServerLink link; BPrivate::AppServerLink link;
PortMessage reply; PortMessage reply;
link.SetOpCode(AS_GET_DPMS_CAPABILITIES); link.SetOpCode(AS_GET_DPMS_CAPABILITIES);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
@@ -430,7 +427,7 @@ BPrivateScreen::get_screen_desc(screen_desc *desc)
{ {
status_t status = B_ERROR; status_t status = B_ERROR;
/* /*
BAppServerLink link; BPrivate::AppServerLink link;
PortMessage reply; PortMessage reply;
link.SetOpCode(AS_GET_SCREEN_DESC); link.SetOpCode(AS_GET_SCREEN_DESC);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
@@ -451,12 +448,12 @@ BPrivateScreen::BPrivateScreen()
// TODO: BeOS R5 here gets the colormap pointer // TODO: BeOS R5 here gets the colormap pointer
// (with BApplication::ro_offset_to_ptr() ?) // (with BApplication::ro_offset_to_ptr() ?)
// which is contained in a shared area created by the server. // which is contained in a shared area created by the server.
BAppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SCREEN_GET_COLORMAP); link.StartMessage(AS_SCREEN_GET_COLORMAP);
link.Attach<screen_id>(ID()); link.Attach<screen_id>(ID());
int32 reply; int32 reply;
link.FlushWithReply(&reply); if (link.FlushWithReply(reply) == B_OK && reply == SERVER_TRUE) {
if (reply == SERVER_TRUE) {
fColorMap = (color_map *)malloc(sizeof(color_map)); fColorMap = (color_map *)malloc(sizeof(color_map));
fOwnsColorMap = true; fOwnsColorMap = true;
link.Read<color_map>(fColorMap); link.Read<color_map>(fColorMap);
+26 -29
View File
@@ -201,9 +201,7 @@ BWindow::BWindow(BRect frame, color_space depth,
BWindow::~BWindow() BWindow::~BWindow()
{ {
// the following lines, remove all existing shortcuts and delete accelList // the following lines, remove all existing shortcuts and delete accelList
int32 noOfItems; int32 noOfItems = accelList.CountItems();
noOfItems = accelList.CountItems();
for (int index = noOfItems-1; index >= 0; index--) { for (int index = noOfItems-1; index >= 0; index--) {
delete (_BCmdKey*)accelList.ItemAt(index); delete (_BCmdKey*)accelList.ItemAt(index);
} }
@@ -221,8 +219,9 @@ BWindow::~BWindow()
fLink->StartMessage(AS_DELETE_WINDOW); fLink->StartMessage(AS_DELETE_WINDOW);
fLink->Flush(); fLink->Flush();
delete_port(fLink->SenderPort());
delete_port(fLink->ReceiverPort());
delete fLink; delete fLink;
delete_port(receive_port);
} }
@@ -2054,8 +2053,8 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
// Here, we will contact app_server and let him know that a window has // Here, we will contact app_server and let him know that a window has
// been created // been created
receive_port = create_port( B_LOOPER_PORT_DEFAULT_CAPACITY ,"w_rcv_port"); port_id receivePort = create_port( B_LOOPER_PORT_DEFAULT_CAPACITY ,"w_rcv_port");
if (receive_port < B_OK) { if (receivePort < B_OK) {
debugger("Could not create BWindow's receive port, used for interacting with the app_server!"); debugger("Could not create BWindow's receive port, used for interacting with the app_server!");
delete this; delete this;
return; return;
@@ -2064,8 +2063,8 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
STRACE(("BWindow::InitData(): contacting app_server...\n")); STRACE(("BWindow::InitData(): contacting app_server...\n"));
// let app_server to know that a window has been created. // let app_server to know that a window has been created.
fLink = new BPortLink(be_app->fServerFrom, receive_port); fLink = new BPrivate::PortLink(be_app->fServerLink->SenderPort(), receivePort);
// HERE we are in BApplication's thread, so for locking we use be_app variable // HERE we are in BApplication's thread, so for locking we use be_app variable
// we'll lock the be_app to be sure we're the only one writing at BApplication's server port // we'll lock the be_app to be sure we're the only one writing at BApplication's server port
bool locked = false; bool locked = false;
@@ -2074,8 +2073,6 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
locked = true; locked = true;
} }
STRACE(("be_app->fServerTo is %ld\n", be_app->fServerFrom));
fLink->StartMessage(AS_CREATE_WINDOW); fLink->StartMessage(AS_CREATE_WINDOW);
fLink->Attach<BRect>(fFrame); fLink->Attach<BRect>(fFrame);
fLink->Attach<int32>((int32)fLook); fLink->Attach<int32>((int32)fLook);
@@ -2083,22 +2080,23 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
fLink->Attach<uint32>(fFlags); fLink->Attach<uint32>(fFlags);
fLink->Attach<uint32>(workspace); fLink->Attach<uint32>(workspace);
fLink->Attach<int32>(_get_object_token_(this)); fLink->Attach<int32>(_get_object_token_(this));
fLink->Attach<port_id>(receive_port); fLink->Attach<port_id>(receivePort);
fLink->Attach<port_id>(fMsgPort); fLink->Attach<port_id>(fMsgPort);
fLink->AttachString(title); fLink->AttachString(title);
port_id sendPort;
int32 code; int32 code;
if (fLink->FlushWithReply(code) == B_OK if (fLink->FlushWithReply(code) == B_OK
&& code == SERVER_TRUE && code == SERVER_TRUE
&& fLink->Read<port_id>(&send_port) == B_OK) && fLink->Read<port_id>(&sendPort) == B_OK)
fLink->SetSendPort(send_port); fLink->SetSenderPort(sendPort);
else else
send_port = -1; sendPort = -1;
if (locked) if (locked)
be_app->Unlock(); be_app->Unlock();
STRACE(("Server says that our send port is %ld\n", send_port)); STRACE(("Server says that our send port is %ld\n", sendPort));
STRACE(("Window locked?: %s\n", IsLocked() ? "True" : "False")); STRACE(("Window locked?: %s\n", IsLocked() ? "True" : "False"));
@@ -2137,7 +2135,7 @@ void
BWindow::task_looper() BWindow::task_looper()
{ {
STRACE(("info: BWindow::task_looper() started.\n")); STRACE(("info: BWindow::task_looper() started.\n"));
// Check that looper is locked (should be) // Check that looper is locked (should be)
AssertLocked(); AssertLocked();
// Unlock the looper // Unlock the looper
@@ -2943,25 +2941,24 @@ BWindow::PrintToStream() const
top_view name = %s\ top_view name = %s\
focus view name = %s\ focus view name = %s\
lastMouseMoved = %s\ lastMouseMoved = %s\
fLink = %s\ fLink = %p\
KeyMenuBar name = %s\ KeyMenuBar name = %s\
DefaultButton = %s\ DefaultButton = %s\
# of shortcuts = %ld", # of shortcuts = %ld",
Name(), Name(), fTitle,
fTitle!=NULL? fTitle:"NULL",
_get_object_token_(this), _get_object_token_(this),
fInTransaction==true? "yes":"no", fInTransaction == true ? "yes" : "no",
fActive==true? "yes":"no", fActive == true ? "yes" : "no",
fShowLevel, fShowLevel,
fFlags, fFlags,
send_port, fLink->SenderPort(),
receive_port, fLink->ReceiverPort(),
top_view!=NULL? top_view->Name():"NULL", top_view != NULL ? top_view->Name() : "NULL",
fFocus!=NULL? fFocus->Name():"NULL", fFocus != NULL ? fFocus->Name() : "NULL",
fLastMouseMovedView!=NULL? fLastMouseMovedView->Name():"NULL", fLastMouseMovedView != NULL ? fLastMouseMovedView->Name() : "NULL",
fLink!=NULL? "In place":"NULL", fLink,
fKeyMenuBar!=NULL? fKeyMenuBar->Name():"NULL", fKeyMenuBar != NULL ? fKeyMenuBar->Name() : "NULL",
fDefaultButton!=NULL? fDefaultButton->Name():"NULL", fDefaultButton != NULL ? fDefaultButton->Name() : "NULL",
accelList.CountItems()); accelList.CountItems());
/* /*
for( int32 i=0; i<accelList.CountItems(); i++){ for( int32 i=0; i<accelList.CountItems(); i++){
+2 -2
View File
@@ -627,7 +627,7 @@ void APRView::LoadSettings(void)
if(port!=B_NAME_NOT_FOUND) if(port!=B_NAME_NOT_FOUND)
{ {
STRACE(("Retrieving settings from app_server\n")); STRACE(("Retrieving settings from app_server\n"));
BPortLink link(port); BPrivate::PortLink link(port);
int32 code; int32 code;
link.StartMessage(AS_GET_UI_COLORS); link.StartMessage(AS_GET_UI_COLORS);
@@ -701,7 +701,7 @@ void APRView::NotifyServer(void)
if(port!=B_NAME_NOT_FOUND) if(port!=B_NAME_NOT_FOUND)
{ {
STRACE(("Notifying app_server\n")); STRACE(("Notifying app_server\n"));
BPortLink link(port); BPrivate::PortLink link(port);
link.StartMessage(AS_SET_UI_COLORS); link.StartMessage(AS_SET_UI_COLORS);
link.Attach<ColorSet>(*currentset); link.Attach<ColorSet>(*currentset);
+1 -1
View File
@@ -395,7 +395,7 @@ void CurView::SetDefaults(void)
if(port==B_NAME_NOT_FOUND) if(port==B_NAME_NOT_FOUND)
return; return;
BPortLink link(port); BPrivate::PortLink link(port);
int32 code; int32 code;
link.StartMessage(AS_SET_SYSCURSOR_DEFAULTS); link.StartMessage(AS_SET_SYSCURSOR_DEFAULTS);
+1 -1
View File
@@ -264,7 +264,7 @@ void DecView::NotifyServer(void)
return; return;
BPortLink pl(serverport); BPrivate::PortLink pl(serverport);
pl.StartMessage(AS_SET_DECORATOR); pl.StartMessage(AS_SET_DECORATOR);
pl.AttachString(item->Text()); pl.AttachString(item->Text());
pl.Flush(); pl.Flush();
+2 -2
View File
@@ -39,7 +39,7 @@ cursor_which get_syscursor(void)
if(server!=B_NAME_NOT_FOUND) if(server!=B_NAME_NOT_FOUND)
{ {
int32 code; int32 code;
BPortLink link(server); BPrivate::PortLink link(server);
link.StartMessage(AS_GET_SYSCURSOR); link.StartMessage(AS_GET_SYSCURSOR);
link.GetNextMessage(code); link.GetNextMessage(code);
@@ -59,7 +59,7 @@ void setcursor(cursor_which which)
port_id server=find_port(SERVER_PORT_NAME); port_id server=find_port(SERVER_PORT_NAME);
if(server!=B_NAME_NOT_FOUND) if(server!=B_NAME_NOT_FOUND)
{ {
BPortLink link(server); BPrivate::PortLink link(server);
link.StartMessage(AS_SET_CURSOR_SYSTEM); link.StartMessage(AS_SET_CURSOR_SYSTEM);
link.Flush(); link.Flush();
} }
+30 -38
View File
@@ -395,7 +395,7 @@ AppServer::Run(void)
void void
AppServer::MainLoop(void) AppServer::MainLoop(void)
{ {
BPortLink pmsg(-1, fMessagePort); BPrivate::PortLink pmsg(-1, fMessagePort);
while (1) { while (1) {
STRACE(("info: AppServer::MainLoop listening on port %ld.\n", fMessagePort)); STRACE(("info: AppServer::MainLoop listening on port %ld.\n", fMessagePort));
@@ -523,7 +523,7 @@ AppServer::InitDecorators(void)
*/ */
void void
AppServer::DispatchMessage(int32 code, BPortLink &msg) AppServer::DispatchMessage(int32 code, BPrivate::PortLink &msg)
{ {
switch (code) { switch (code) {
case AS_CREATE_APP: case AS_CREATE_APP:
@@ -575,7 +575,7 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
release_sem(fAppListLock); release_sem(fAppListLock);
BPortLink replylink(clientReplyPort); BPrivate::PortLink replylink(clientReplyPort);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<int32>(serverListen); replylink.Attach<int32>(serverListen);
replylink.Flush(); replylink.Flush();
@@ -605,13 +605,11 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
for (i = 0; i < appnum; i++) { for (i = 0; i < appnum; i++) {
srvapp = (ServerApp *)fAppList->ItemAt(i); srvapp = (ServerApp *)fAppList->ItemAt(i);
if(srvapp != NULL && srvapp->MonitorThreadID() == srvapp_id) if (srvapp != NULL && srvapp->MonitorThreadID() == srvapp_id) {
{ srvapp = (ServerApp *)fAppList->RemoveItem(i);
srvapp=(ServerApp *)fAppList->RemoveItem(i); if (srvapp) {
if(srvapp)
{
delete srvapp; delete srvapp;
srvapp= NULL; srvapp = NULL;
} }
break; // jump out of our for() loop break; // jump out of our for() loop
} }
@@ -646,7 +644,7 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
port_id replyport; port_id replyport;
if (msg.Read<port_id>(&replyport) < B_OK) if (msg.Read<port_id>(&replyport) < B_OK)
break; break;
BPortLink replylink(replyport); BPrivate::PortLink replylink(replyport);
replylink.StartMessage(needs_update ? SERVER_TRUE : SERVER_FALSE); replylink.StartMessage(needs_update ? SERVER_TRUE : SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -662,36 +660,31 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
char *decname=NULL; char *decname=NULL;
msg.ReadString(&decname); msg.ReadString(&decname);
if(decname) if (decname) {
{ if (strcmp(decname, "Default") != 0) {
if(strcmp(decname,"Default")!=0)
{
BString decpath; BString decpath;
decpath.SetTo(DECORATORS_DIR); decpath.SetTo(DECORATORS_DIR);
decpath+=decname; decpath += decname;
if(LoadDecorator(decpath.String())) if (LoadDecorator(decpath.String()))
Broadcast(AS_UPDATE_DECORATOR); Broadcast(AS_UPDATE_DECORATOR);
} } else {
else
{
LoadDecorator(NULL); LoadDecorator(NULL);
Broadcast(AS_UPDATE_DECORATOR); Broadcast(AS_UPDATE_DECORATOR);
} }
} }
free(decname); free(decname);
break; break;
} }
case AS_GET_DECORATOR: case AS_GET_DECORATOR:
{ {
// Attached Data: // Attached Data:
// 1) port_id reply port // 1) port_id reply port
port_id replyport=-1; port_id replyport = -1;
if(msg.Read<port_id>(&replyport)<B_OK) if (msg.Read<port_id>(&replyport)<B_OK)
return; return;
BPortLink replylink(replyport); BPrivate::PortLink replylink(replyport);
replylink.StartMessage(AS_GET_DECORATOR); replylink.StartMessage(AS_GET_DECORATOR);
replylink.AttachString(fDecoratorName.String()); replylink.AttachString(fDecoratorName.String());
replylink.Flush(); replylink.Flush();
@@ -705,14 +698,13 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
// Attached Data: // Attached Data:
// char * name of the decorator in the decorators path to use // char * name of the decorator in the decorators path to use
int32 decindex=0; int32 decindex = 0;
if(msg.Read<int32>(&decindex)<B_OK) if (msg.Read<int32>(&decindex)<B_OK)
break; break;
BString decpath; BString decpath;
decpath.SetTo(DECORATORS_DIR); decpath.SetTo(DECORATORS_DIR);
switch(decindex) switch(decindex) {
{
case 0: decpath+="BeOS"; break; case 0: decpath+="BeOS"; break;
case 1: decpath+="AmigaOS"; break; case 1: decpath+="AmigaOS"; break;
case 2: decpath+="Windows"; break; case 2: decpath+="Windows"; break;
@@ -720,7 +712,7 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
default: default:
break; break;
} }
if(LoadDecorator(decpath.String())) if (LoadDecorator(decpath.String()))
Broadcast(AS_UPDATE_DECORATOR); Broadcast(AS_UPDATE_DECORATOR);
break; break;
@@ -805,16 +797,16 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
void void
AppServer::Broadcast(int32 code) AppServer::Broadcast(int32 code)
{ {
ServerApp *app= NULL;
acquire_sem(fAppListLock); acquire_sem(fAppListLock);
for(int32 i= 0; i < fAppList->CountItems(); i++)
{ for (int32 i = 0; i < fAppList->CountItems(); i++) {
app=(ServerApp*)fAppList->ItemAt(i); ServerApp *app = (ServerApp *)fAppList->ItemAt(i);
if(!app)
if (!app)
{ printf("PANIC in AppServer::Broadcast()\n"); continue; } { printf("PANIC in AppServer::Broadcast()\n"); continue; }
app->PostMessage(code); app->PostMessage(code);
} }
release_sem(fAppListLock); release_sem(fAppListLock);
} }
@@ -829,7 +821,7 @@ AppServer::Broadcast(int32 code)
ServerApp * ServerApp *
AppServer::FindApp(const char *sig) AppServer::FindApp(const char *sig)
{ {
if(!sig) if (!sig)
return NULL; return NULL;
ServerApp *foundapp=NULL; ServerApp *foundapp=NULL;
+5 -2
View File
@@ -20,10 +20,13 @@ class Layer;
class BMessage; class BMessage;
class ServerApp; class ServerApp;
class DisplayDriver; class DisplayDriver;
class BPortLink;
class CursorManager; class CursorManager;
class BitmapManager; class BitmapManager;
namespace BPrivate {
class PortLink;
};
/*! /*!
\class AppServer AppServer.h \class AppServer AppServer.h
\brief main manager object for the app_server \brief main manager object for the app_server
@@ -50,7 +53,7 @@ public:
bool LoadDecorator(const char *path); bool LoadDecorator(const char *path);
void InitDecorators(void); void InitDecorators(void);
void DispatchMessage(int32 code, BPortLink &link); void DispatchMessage(int32 code, BPrivate::PortLink &link);
void Broadcast(int32 code); void Broadcast(int32 code);
ServerApp* FindApp(const char *sig); ServerApp* FindApp(const char *sig);
+2 -2
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc. // Copyright (c) 2001-2005, Haiku, Inc.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -106,7 +106,7 @@ Desktop::AddDriver(DisplayDriver *driver)
// The driver is now owned by the screen // The driver is now owned by the screen
// TODO: be careful of screen initialization - monitor may not support 640x480 // TODO: be careful of screen initialization - monitor may not support 640x480
screen->SetMode(640, 480, B_RGB32, 60.f); screen->SetMode(800, 600, B_RGB32, 60.f);
fScreenList.AddItem(screen); fScreenList.AddItem(screen);
} else { } else {
+3 -3
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc. // Copyright (c) 2001-2005, Haiku, Inc.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -984,7 +984,7 @@ Layer::MoveBy(float x, float y)
return; return;
} }
BPortLink msg(-1, -1); BPrivate::PortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE); msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE);
msg.Attach<Layer*>(this); msg.Attach<Layer*>(this);
msg.Attach<float>(x); msg.Attach<float>(x);
@@ -1005,7 +1005,7 @@ Layer::ResizeBy(float x, float y)
return; return;
} }
BPortLink msg(-1, -1); BPrivate::PortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE); msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE);
msg.Attach<Layer*>(this); msg.Attach<Layer*>(this);
msg.Attach<float>(x); msg.Attach<float>(x);
+4 -3
View File
@@ -35,6 +35,7 @@
#include "LayerData.h" #include "LayerData.h"
// constructor // constructor
DrawData::DrawData() DrawData::DrawData()
: fOrigin(0.0, 0.0), : fOrigin(0.0, 0.0),
@@ -377,7 +378,7 @@ LayerData::PrintToStream() const
// ReadFontFromLink // ReadFontFromLink
void void
LayerData::ReadFontFromLink(LinkMsgReader& link) LayerData::ReadFontFromLink(BPrivate::LinkReceiver& link)
{ {
uint16 mask; uint16 mask;
link.Read<uint16>(&mask); link.Read<uint16>(&mask);
@@ -433,7 +434,7 @@ LayerData::ReadFontFromLink(LinkMsgReader& link)
// ReadFromLink // ReadFromLink
void void
LayerData::ReadFromLink(LinkMsgReader& link) LayerData::ReadFromLink(BPrivate::LinkReceiver& link)
{ {
rgb_color highColor; rgb_color highColor;
rgb_color lowColor; rgb_color lowColor;
@@ -478,7 +479,7 @@ LayerData::ReadFromLink(LinkMsgReader& link)
// WriteToLink // WriteToLink
void void
LayerData::WriteToLink(LinkMsgSender& link) const LayerData::WriteToLink(BPrivate::LinkSender& link) const
{ {
rgb_color hc = fHighColor.GetColor32(); rgb_color hc = fHighColor.GetColor32();
rgb_color lc = fLowColor.GetColor32(); rgb_color lc = fLowColor.GetColor32();
+17 -22
View File
@@ -2,20 +2,16 @@
#include <malloc.h> #include <malloc.h>
RAMLinkMsgReader::RAMLinkMsgReader(int8 *buffer) RAMLinkMsgReader::RAMLinkMsgReader(int8 *buffer)
: LinkMsgReader(B_ERROR) : BPrivate::LinkReceiver(-1)
{ {
SetBuffer(buffer); SetBuffer(buffer);
} }
RAMLinkMsgReader::RAMLinkMsgReader(void) RAMLinkMsgReader::RAMLinkMsgReader(void)
: LinkMsgReader(B_ERROR) : BPrivate::LinkReceiver(-1)
{ {
fBuffer=NULL; SetBuffer(NULL);
fAttachStart=NULL;
fPosition=NULL;
fAttachSize=0;
fCode=B_ERROR;
} }
@@ -28,23 +24,22 @@ RAMLinkMsgReader::~RAMLinkMsgReader(void)
void void
RAMLinkMsgReader::SetBuffer(int8 *buffer) RAMLinkMsgReader::SetBuffer(int8 *buffer)
{ {
if(!buffer) if (!buffer) {
{ fBuffer = NULL;
fBuffer=NULL; fAttachStart = NULL;
fAttachStart=NULL; fPosition = NULL;
fPosition=NULL; fAttachSize = 0;
fAttachSize=0; fCode = B_ERROR;
fCode=B_ERROR;
return; return;
} }
fBuffer=buffer; fBuffer = buffer;
fPosition=fBuffer+4; fPosition = fBuffer + 4;
fCode=*((int32*)fBuffer); fCode = *((int32*)fBuffer);
fAttachSize=*( (size_t*) fPosition); fAttachSize = *((size_t *)fPosition);
fPosition+=sizeof(size_t); fPosition += sizeof(size_t);
fAttachStart=fPosition; fAttachStart = fPosition;
} }
+1 -1
View File
@@ -39,7 +39,7 @@
size_t buffer size size_t buffer size
[data buffer] [data buffer]
*/ */
class RAMLinkMsgReader : public LinkMsgReader { class RAMLinkMsgReader : public BPrivate::LinkReceiver {
public: public:
RAMLinkMsgReader(int8 *buffer); RAMLinkMsgReader(int8 *buffer);
RAMLinkMsgReader(void); RAMLinkMsgReader(void);
+40 -20
View File
@@ -178,7 +178,7 @@ RootLayer::~RootLayer()
{ {
fQuiting = true; fQuiting = true;
BPortLink msg(fListenPort, -1); BPrivate::PortLink msg(fListenPort, -1);
msg.StartMessage(B_QUIT_REQUESTED); msg.StartMessage(B_QUIT_REQUESTED);
msg.EndMessage(); msg.EndMessage();
msg.Flush(); msg.Flush();
@@ -222,7 +222,7 @@ RootLayer::WorkingThread(void *data)
int32 code = 0; int32 code = 0;
status_t err = B_OK; status_t err = B_OK;
RootLayer *oneRootLayer = (RootLayer*)data; RootLayer *oneRootLayer = (RootLayer*)data;
BPortLink messageQueue(-1, oneRootLayer->fListenPort); BPrivate::PortLink messageQueue(-1, oneRootLayer->fListenPort);
// first make sure we are actualy visible // first make sure we are actualy visible
oneRootLayer->Lock(); oneRootLayer->Lock();
@@ -372,7 +372,7 @@ RootLayer::WorkingThread(void *data)
void void
RootLayer::GoInvalidate(const Layer *layer, const BRegion &region) RootLayer::GoInvalidate(const Layer *layer, const BRegion &region)
{ {
BPortLink msg(fListenPort, -1); BPrivate::PortLink msg(fListenPort, -1);
msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE); msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE);
msg.Attach<const Layer*>(layer); msg.Attach<const Layer*>(layer);
msg.AttachRegion(region); msg.AttachRegion(region);
@@ -390,48 +390,62 @@ void RootLayer::invalidate_layer(Layer *layer, const BRegion &region)
layer->FullInvalidate(region); layer->FullInvalidate(region);
} }
status_t RootLayer::EnqueueMessage(BPortLink &message)
status_t
RootLayer::EnqueueMessage(BPrivate::PortLink &message)
{ {
message.SetSendPort(fListenPort); message.SetSenderPort(fListenPort);
message.Flush(); message.Flush();
return B_OK; return B_OK;
} }
void RootLayer::GoRedraw(const Layer *layer, const BRegion &region)
void
RootLayer::GoRedraw(const Layer *layer, const BRegion &region)
{ {
BPortLink msg(fListenPort, -1); BPrivate::PortLink msg(fListenPort, -1);
msg.StartMessage(AS_ROOTLAYER_DO_REDRAW); msg.StartMessage(AS_ROOTLAYER_DO_REDRAW);
msg.Attach<const Layer*>(layer); msg.Attach<const Layer*>(layer);
msg.AttachRegion(region); msg.AttachRegion(region);
msg.Flush(); msg.Flush();
} }
void RootLayer::redraw_layer(Layer *layer, const BRegion &region)
void
RootLayer::redraw_layer(Layer *layer, const BRegion &region)
{ {
// NOTE: our thread (WorkingThread) is locked here. // NOTE: our thread (WorkingThread) is locked here.
layer->Invalidate(region); layer->Invalidate(region);
} }
void RootLayer::GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel)
void
RootLayer::GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel)
{ {
BPortLink msg(fListenPort, -1); BPrivate::PortLink msg(fListenPort, -1);
msg.StartMessage(AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL); msg.StartMessage(AS_ROOTLAYER_DO_CHANGE_WINBORDER_FEEL);
msg.Attach<const WinBorder*>(winBorder); msg.Attach<const WinBorder*>(winBorder);
msg.Attach<int32>(newFeel); msg.Attach<int32>(newFeel);
msg.Flush(); msg.Flush();
} }
void RootLayer::MoveBy(float x, float y)
void
RootLayer::MoveBy(float x, float y)
{ {
} }
void RootLayer::ResizeBy(float x, float y)
void
RootLayer::ResizeBy(float x, float y)
{ {
// TODO: implement // TODO: implement
} }
Layer* RootLayer::VirtualTopChild() const
Layer *
RootLayer::VirtualTopChild() const
{ {
fWinBorderIndex = fWinBorderCount-1; fWinBorderIndex = fWinBorderCount-1;
@@ -914,23 +928,29 @@ void RootLayer::SaveWorkspaceData(const char *path)
} }
void RootLayer::HideWinBorder(WinBorder* winBorder) void
RootLayer::HideWinBorder(WinBorder* winBorder)
{ {
BPortLink msg(fListenPort, -1); BPrivate::PortLink msg(fListenPort, -1);
msg.StartMessage(AS_ROOTLAYER_HIDE_WINBORDER); msg.StartMessage(AS_ROOTLAYER_HIDE_WINBORDER);
msg.Attach<WinBorder*>(winBorder); msg.Attach<WinBorder*>(winBorder);
msg.Flush(); msg.Flush();
} }
void RootLayer::ShowWinBorder(WinBorder* winBorder)
void
RootLayer::ShowWinBorder(WinBorder* winBorder)
{ {
BPortLink msg(fListenPort, -1); BPrivate::PortLink msg(fListenPort, -1);
msg.StartMessage(AS_ROOTLAYER_SHOW_WINBORDER); msg.StartMessage(AS_ROOTLAYER_SHOW_WINBORDER);
msg.Attach<WinBorder*>(winBorder); msg.Attach<WinBorder*>(winBorder);
msg.Flush(); msg.Flush();
} }
WinBorder* RootLayer::WinBorderAt(const BPoint& pt) const{
WinBorder *
RootLayer::WinBorderAt(const BPoint& pt) const
{
for (int32 i = 0; i < fWinBorderCount; i++) for (int32 i = 0; i < fWinBorderCount; i++)
{ {
if (fWinBorderList[i]->fFullVisible.Contains(pt)) if (fWinBorderList[i]->fFullVisible.Contains(pt))
@@ -1004,7 +1024,7 @@ RootLayer::SetScreenMode(int32 width, int32 height, uint32 colorSpace, float fre
// Input related methods // Input related methods
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
inline void inline void
RootLayer::MouseEventHandler(int32 code, BPortLink& msg) RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg)
{ {
switch(code) { switch(code) {
case B_MOUSE_DOWN: { case B_MOUSE_DOWN: {
@@ -1376,7 +1396,7 @@ fprintf(stderr, "mouse position changed in B_MOUSE_UP (%.1f, %.1f) from last B_M
} }
inline inline
void RootLayer::KeyboardEventHandler(int32 code, BPortLink& msg) void RootLayer::KeyboardEventHandler(int32 code, BPrivate::PortLink& msg)
{ {
switch(code) switch(code)
+7 -4
View File
@@ -43,7 +43,10 @@ class Screen;
class WinBorder; class WinBorder;
class Desktop; class Desktop;
class DisplayDriver; class DisplayDriver;
class BPortLink;
namespace BPrivate {
class PortLink;
};
#ifndef DISPLAY_HAIKU_LOGO #ifndef DISPLAY_HAIKU_LOGO
#define DISPLAY_HAIKU_LOGO 1 #define DISPLAY_HAIKU_LOGO 1
@@ -127,7 +130,7 @@ public:
void Unlock() { fAllRegionsLock.Unlock(); } void Unlock() { fAllRegionsLock.Unlock(); }
bool IsLocked() { return fAllRegionsLock.IsLocked(); } bool IsLocked() { return fAllRegionsLock.IsLocked(); }
void RunThread(); void RunThread();
status_t EnqueueMessage(BPortLink &message); status_t EnqueueMessage(BPrivate::PortLink &message);
void GoInvalidate(const Layer *layer, const BRegion &region); void GoInvalidate(const Layer *layer, const BRegion &region);
void GoRedraw(const Layer *layer, const BRegion &region); void GoRedraw(const Layer *layer, const BRegion &region);
void GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel); void GoChangeWinBorderFeel(const WinBorder *winBorder, int32 newFeel);
@@ -168,8 +171,8 @@ friend class Desktop;
void show_final_scene(WinBorder *exFocus, WinBorder *exActive); void show_final_scene(WinBorder *exFocus, WinBorder *exActive);
// Input related methods // Input related methods
void MouseEventHandler(int32 code, BPortLink& link); void MouseEventHandler(int32 code, BPrivate::PortLink& link);
void KeyboardEventHandler(int32 code, BPortLink& link); void KeyboardEventHandler(int32 code, BPrivate::PortLink& link);
Desktop* fDesktop; Desktop* fDesktop;
BMessage* fDragMessage; BMessage* fDragMessage;
+7 -8
View File
@@ -190,8 +190,8 @@ bool
ServerApp::PingTarget(void) ServerApp::PingTarget(void)
{ {
team_info tinfo; team_info tinfo;
if (get_team_info(fClientTeamID,&tinfo) == B_BAD_TEAM_ID) { if (get_team_info(fClientTeamID, &tinfo) == B_BAD_TEAM_ID) {
LinkMsgSender link(gAppServerPort); BPrivate::LinkSender link(gAppServerPort);
link.StartMessage(AS_DELETE_APP); link.StartMessage(AS_DELETE_APP);
link.Attach(&fMonitorThreadID, sizeof(thread_id)); link.Attach(&fMonitorThreadID, sizeof(thread_id));
link.Flush(); link.Flush();
@@ -207,7 +207,7 @@ ServerApp::PingTarget(void)
void void
ServerApp::PostMessage(int32 code) ServerApp::PostMessage(int32 code)
{ {
LinkMsgSender link(fMessagePort); BPrivate::LinkSender link(fMessagePort);
link.StartMessage(code); link.StartMessage(code);
link.Flush(); link.Flush();
} }
@@ -268,7 +268,7 @@ ServerApp::MonitorApp(void *data)
// Message-dispatching loop for the ServerApp // Message-dispatching loop for the ServerApp
ServerApp *app = (ServerApp *)data; ServerApp *app = (ServerApp *)data;
LinkMsgReader &reader = app->fLink.Reader(); BPrivate::LinkReceiver &reader = app->fLink.Receiver();
int32 code; int32 code;
status_t err = B_OK; status_t err = B_OK;
@@ -280,7 +280,7 @@ ServerApp::MonitorApp(void *data)
STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err))); STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err)));
// ToDo: this should kill the app, but it doesn't work // ToDo: this should kill the app, but it doesn't work
LinkMsgSender link(gAppServerPort); BPrivate::LinkSender link(gAppServerPort);
link.StartMessage(AS_DELETE_APP); link.StartMessage(AS_DELETE_APP);
link.Attach(&app->fMonitorThreadID, sizeof(thread_id)); link.Attach(&app->fMonitorThreadID, sizeof(thread_id));
link.Flush(); link.Flush();
@@ -362,7 +362,7 @@ ServerApp::MonitorApp(void *data)
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String())); STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
// Our BApplication sent us this message when it quit. // Our BApplication sent us this message when it quit.
// We need to ask the app_server to delete ourself. // We need to ask the app_server to delete ourself.
LinkMsgSender sender(gAppServerPort); BPrivate::LinkSender sender(gAppServerPort);
sender.StartMessage(AS_DELETE_APP); sender.StartMessage(AS_DELETE_APP);
sender.Attach(&app->fMonitorThreadID, sizeof(thread_id)); sender.Attach(&app->fMonitorThreadID, sizeof(thread_id));
sender.Flush(); sender.Flush();
@@ -390,7 +390,7 @@ ServerApp::MonitorApp(void *data)
matter of casting and incrementing an index variable to access them. matter of casting and incrementing an index variable to access them.
*/ */
void void
ServerApp::DispatchMessage(int32 code, LinkMsgReader &link) ServerApp::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{ {
LayerData ld; LayerData ld;
@@ -963,7 +963,6 @@ ServerApp::DispatchMessage(int32 code, LinkMsgReader &link)
// 1) font_family - name of family // 1) font_family - name of family
// 2) uint32 - flags of font family (B_IS_FIXED || B_HAS_TUNED_FONT) // 2) uint32 - flags of font family (B_IS_FIXED || B_HAS_TUNED_FONT)
int32 id; int32 id;
debugger("");
link.Read<int32>(&id); link.Read<int32>(&id);
fontserver->Lock(); fontserver->Lock();
+7 -4
View File
@@ -36,13 +36,16 @@
class AreaPool; class AreaPool;
class BMessage; class BMessage;
class BPortLink;
class BList; class BList;
class DisplayDriver; class DisplayDriver;
class ServerPicture; class ServerPicture;
class ServerCursor; class ServerCursor;
class ServerBitmap; class ServerBitmap;
namespace BPrivate {
class PortLink;
};
/*! /*!
\class ServerApp ServerApp.h \class ServerApp ServerApp.h
\brief Counterpart to BApplication within the app_server \brief Counterpart to BApplication within the app_server
@@ -90,7 +93,7 @@ public:
FMWList fAppFMWList; FMWList fAppFMWList;
private: private:
void DispatchMessage(int32 code, LinkMsgReader &link); void DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
static int32 MonitorApp(void *data); static int32 MonitorApp(void *data);
@@ -109,7 +112,7 @@ private:
thread_id fMonitorThreadID; thread_id fMonitorThreadID;
team_id fClientTeamID; team_id fClientTeamID;
BPortLink fLink; BPrivate::PortLink fLink;
// TODO: // TODO:
// - Are really Bitmaps and Pictures stored per application and not globally ? // - Are really Bitmaps and Pictures stored per application and not globally ?
@@ -136,4 +139,4 @@ private:
bool fQuitting; bool fQuitting;
}; };
#endif #endif // _SERVERAPP_H_
+23 -26
View File
@@ -107,8 +107,8 @@ ServerWindow::ServerWindow(const char *string, ServerApp *winapp,
// fMessagePort is the port to which the app sends messages for the server // fMessagePort is the port to which the app sends messages for the server
fMessagePort = create_port(30, fName); fMessagePort = create_port(30, fName);
fMsgSender = new LinkMsgSender(fClientWinPort); fMsgSender = new BPrivate::LinkSender(fClientWinPort);
fMsgReader = new LinkMsgReader(fMessagePort); fMsgReceiver = new BPrivate::LinkReceiver(fMessagePort);
// Send a reply to our window - it is expecting fMessagePort port. // Send a reply to our window - it is expecting fMessagePort port.
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
@@ -143,7 +143,7 @@ ServerWindow::~ServerWindow(void)
delete fWinBorder; delete fWinBorder;
delete fMsgSender; delete fMsgSender;
delete fMsgReader; delete fMsgReceiver;
STRACE(("#ServerWindow(%s) will exit NOW\n", fName)); STRACE(("#ServerWindow(%s) will exit NOW\n", fName));
} }
@@ -290,7 +290,7 @@ ServerWindow::IsLocked() const
\param layer The layer to set the font \param layer The layer to set the font
*/ */
inline void inline void
ServerWindow::SetLayerFontState(Layer *layer, LinkMsgReader &link) ServerWindow::SetLayerFontState(Layer *layer, BPrivate::LinkReceiver &link)
{ {
STRACE(("ServerWindow %s: SetLayerFontStateMessage for layer %s\n", STRACE(("ServerWindow %s: SetLayerFontStateMessage for layer %s\n",
fName, layer->fName->String())); fName, layer->fName->String()));
@@ -301,7 +301,7 @@ ServerWindow::SetLayerFontState(Layer *layer, LinkMsgReader &link)
inline void inline void
ServerWindow::SetLayerState(Layer *layer, LinkMsgReader &link) ServerWindow::SetLayerState(Layer *layer, BPrivate::LinkReceiver &link)
{ {
STRACE(("ServerWindow %s: SetLayerState for layer %s\n",fName, STRACE(("ServerWindow %s: SetLayerState for layer %s\n",fName,
layer->fName->String())); layer->fName->String()));
@@ -313,7 +313,7 @@ ServerWindow::SetLayerState(Layer *layer, LinkMsgReader &link)
inline Layer* inline Layer*
ServerWindow::CreateLayerTree(Layer *localRoot, LinkMsgReader &link) ServerWindow::CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link)
{ {
// NOTE: no need to check for a lock. This is a private method. // NOTE: no need to check for a lock. This is a private method.
@@ -362,7 +362,7 @@ ServerWindow::CreateLayerTree(Layer *localRoot, LinkMsgReader &link)
void void
ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) ServerWindow::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{ {
if (fCurrentLayer == NULL && code != AS_LAYER_CREATE_ROOT) { if (fCurrentLayer == NULL && code != AS_LAYER_CREATE_ROOT) {
printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n",fName, code - SERVER_TRUE); printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n",fName, code - SERVER_TRUE);
@@ -1087,21 +1087,19 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
link.Read<int32>(&mainToken); link.Read<int32>(&mainToken);
link.Read(&teamID, sizeof(team_id)); link.Read(&teamID, sizeof(team_id));
wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
if(wb) if (wb) {
{
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Flush(); fMsgSender->Flush();
BPortLink msg(-1, -1); // ToDo: this is a pretty expensive and complicated way to send a message...
BPrivate::PortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET); msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET);
msg.Attach<WinBorder*>(fWinBorder); msg.Attach<WinBorder*>(fWinBorder);
msg.Attach<WinBorder*>(wb); msg.Attach<WinBorder*>(wb);
fWinBorder->GetRootLayer()->EnqueueMessage(msg); fWinBorder->GetRootLayer()->EnqueueMessage(msg);
} } else {
else
{
fMsgSender->StartMessage(SERVER_FALSE); fMsgSender->StartMessage(SERVER_FALSE);
fMsgSender->Flush(); fMsgSender->Flush();
} }
@@ -1118,19 +1116,16 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
link.Read(&teamID, sizeof(team_id)); link.Read(&teamID, sizeof(team_id));
wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
if(wb) if (wb) {
{
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Flush(); fMsgSender->Flush();
BPortLink msg(-1, -1); BPrivate::PortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET); msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET);
msg.Attach<WinBorder*>(fWinBorder); msg.Attach<WinBorder*>(fWinBorder);
msg.Attach<WinBorder*>(wb); msg.Attach<WinBorder*>(wb);
fWinBorder->GetRootLayer()->EnqueueMessage(msg); fWinBorder->GetRootLayer()->EnqueueMessage(msg);
} } else {
else
{
fMsgSender->StartMessage(SERVER_FALSE); fMsgSender->StartMessage(SERVER_FALSE);
fMsgSender->Flush(); fMsgSender->Flush();
} }
@@ -1151,7 +1146,7 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
case AS_SET_FEEL: case AS_SET_FEEL:
{ {
STRACE(("ServerWindow %s: Message AS_SET_FEEL\n",fName)); STRACE(("ServerWindow %s: Message AS_SET_FEEL\n",fName));
int32 newFeel; int32 newFeel;
link.Read<int32>(&newFeel); link.Read<int32>(&newFeel);
myRootLayer->GoChangeWinBorderFeel(fWinBorder, newFeel); myRootLayer->GoChangeWinBorderFeel(fWinBorder, newFeel);
break; break;
@@ -1180,10 +1175,10 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
{ {
// TODO: Implement AS_SET_WORKSPACES // TODO: Implement AS_SET_WORKSPACES
STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n",fName)); STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n",fName));
uint32 newWorkspaces; uint32 newWorkspaces;
link.Read<uint32>(&newWorkspaces); link.Read<uint32>(&newWorkspaces);
BPortLink msg(-1, -1); BPrivate::PortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_WINBORDER_SET_WORKSPACES); msg.StartMessage(AS_ROOTLAYER_WINBORDER_SET_WORKSPACES);
msg.Attach<WinBorder*>(fWinBorder); msg.Attach<WinBorder*>(fWinBorder);
msg.Attach<uint32>(fWinBorder->Workspaces()); msg.Attach<uint32>(fWinBorder->Workspaces());
@@ -1421,10 +1416,12 @@ ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
break; break;
} }
} }
// -------------------- Graphics messages ---------------------------------- // -------------------- Graphics messages ----------------------------------
inline inline
void void
ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link) ServerWindow::DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
{ {
fWinBorder->GetRootLayer()->Lock(); fWinBorder->GetRootLayer()->Lock();
BRegion rreg(fCurrentLayer->fVisible); BRegion rreg(fCurrentLayer->fVisible);
@@ -1951,7 +1948,7 @@ int32
ServerWindow::MonitorWin(void *data) ServerWindow::MonitorWin(void *data)
{ {
ServerWindow *win = (ServerWindow *)data; ServerWindow *win = (ServerWindow *)data;
LinkMsgReader *ses = win->fMsgReader; BPrivate::LinkReceiver *ses = win->fMsgReceiver;
bool quitting = false; bool quitting = false;
int32 code; int32 code;
+9 -9
View File
@@ -119,14 +119,14 @@ public:
private: private:
// methods for retrieving and creating a tree strcture of Layers. // methods for retrieving and creating a tree strcture of Layers.
Layer* CreateLayerTree(Layer *localRoot, LinkMsgReader &link); Layer* CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link);
void SetLayerState(Layer *layer, LinkMsgReader &link); void SetLayerState(Layer *layer, BPrivate::LinkReceiver &link);
void SetLayerFontState(Layer *layer, LinkMsgReader &link); void SetLayerFontState(Layer *layer, BPrivate::LinkReceiver &link);
void ClientDied(bool crashed); void ClientDied(bool crashed);
// message handle methods. // message handle methods.
void DispatchMessage(int32 code, LinkMsgReader &link); void DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
void DispatchGraphicsMessage(int32 code, LinkMsgReader &link); void DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link);
static int32 MonitorWin(void *data); static int32 MonitorWin(void *data);
// used by CopyBits and Scrolling // used by CopyBits and Scrolling
@@ -153,9 +153,9 @@ private:
port_id fMessagePort; port_id fMessagePort;
port_id fClientWinPort; port_id fClientWinPort;
port_id fClientLooperPort; port_id fClientLooperPort;
LinkMsgReader* fMsgReader; BPrivate::LinkReceiver* fMsgReceiver;
LinkMsgSender* fMsgSender; BPrivate::LinkSender* fMsgSender;
BMessage fClientViewsWithInvalidCoords; BMessage fClientViewsWithInvalidCoords;
@@ -166,4 +166,4 @@ private:
Layer* fCurrentLayer; Layer* fCurrentLayer;
}; };
#endif #endif // _SERVERWIN_H_
+5 -6
View File
@@ -45,7 +45,7 @@ set_syscursor(cursor_which which, const BCursor *cursor)
if (server < B_OK) if (server < B_OK)
return; return;
BPortLink link(server); BPrivate::PortLink link(server);
link.StartMessage(AS_SET_SYSCURSOR_BCURSOR); link.StartMessage(AS_SET_SYSCURSOR_BCURSOR);
link.Attach<cursor_which>(which); link.Attach<cursor_which>(which);
@@ -72,7 +72,7 @@ set_syscursor(cursor_which which, const BBitmap *bitmap)
if (server < B_OK) if (server < B_OK)
return; return;
BPortLink link(server); BPrivate::PortLink link(server);
link.StartMessage(AS_SET_SYSCURSOR_BBITMAP); link.StartMessage(AS_SET_SYSCURSOR_BBITMAP);
link.Attach<cursor_which>(which); link.Attach<cursor_which>(which);
@@ -94,12 +94,11 @@ get_syscursor(void)
port_id server = find_port(SERVER_PORT_NAME); port_id server = find_port(SERVER_PORT_NAME);
if (server >= B_OK) { if (server >= B_OK) {
int32 code = SERVER_FALSE; int32 code = SERVER_FALSE;
BPrivate::BAppServerLink link; BPrivate::PortLink link(server);
cursor_which which; cursor_which which;
link.SetSendPort(server);
link.StartMessage(AS_GET_SYSCURSOR); link.StartMessage(AS_GET_SYSCURSOR);
link.FlushWithReply(&code); link.FlushWithReply(code);
if (code == SERVER_TRUE if (code == SERVER_TRUE
&& link.Read<cursor_which>(&which) == B_OK) && link.Read<cursor_which>(&which) == B_OK)
@@ -119,7 +118,7 @@ setcursor(cursor_which which)
if (server < B_OK) if (server < B_OK)
return; return;
BPortLink link(server); BPrivate::PortLink link(server);
link.StartMessage(AS_SET_CURSOR_SYSTEM); link.StartMessage(AS_SET_CURSOR_SYSTEM);
link.Flush(); link.Flush();
} }
+5 -5
View File
@@ -109,14 +109,14 @@ class CardView : public BView {
// CardView // CardView
void SetBitmap(const BBitmap* bimtap); void SetBitmap(const BBitmap* bimtap);
inline BPortLink* ServerLink() const inline BPrivate::PortLink* ServerLink() const
{ return fServerLink; } { return fServerLink; }
void ForwardMessage(); void ForwardMessage();
private: private:
port_id fInputPort; port_id fInputPort;
BPortLink* fServerLink; BPrivate::PortLink* fServerLink;
const BBitmap* fBitmap; const BBitmap* fBitmap;
}; };
@@ -153,7 +153,7 @@ CardView::CardView(BRect bounds)
// This link for sending mouse messages to the Haiku app_server. // This link for sending mouse messages to the Haiku app_server.
// This is only to take the place of the input_server. // This is only to take the place of the input_server.
port_id input_port = find_port(SERVER_INPUT_PORT); port_id input_port = find_port(SERVER_INPUT_PORT);
fServerLink = new BPortLink(input_port); fServerLink = new BPrivate::PortLink(input_port);
#else #else
fInputPort = create_port(100, "ViewInputDevice"); fInputPort = create_port(100, "ViewInputDevice");
#endif #endif
@@ -329,7 +329,7 @@ CardWindow::QuitRequested()
port_id serverport = find_port(SERVER_PORT_NAME); port_id serverport = find_port(SERVER_PORT_NAME);
if (serverport >= 0) { if (serverport >= 0) {
BPortLink link(serverport); BPrivate::PortLink link(serverport);
link.StartMessage(B_QUIT_REQUESTED); link.StartMessage(B_QUIT_REQUESTED);
link.Flush(); link.Flush();
} else } else
@@ -22,7 +22,7 @@
// send_mouse_down // send_mouse_down
void void
send_mouse_down(BPortLink* serverLink, BPoint pt, send_mouse_down(BPrivate::PortLink* serverLink, BPoint pt,
BMessage* currentMessage) BMessage* currentMessage)
{ {
// Attach data: // Attach data:
@@ -53,7 +53,7 @@ send_mouse_down(BPortLink* serverLink, BPoint pt,
// send_mouse_moved // send_mouse_moved
void void
send_mouse_moved(BPortLink* serverLink, BPoint pt, send_mouse_moved(BPrivate::PortLink* serverLink, BPoint pt,
BMessage* currentMessage) BMessage* currentMessage)
{ {
// Attach data: // Attach data:
@@ -76,7 +76,7 @@ send_mouse_moved(BPortLink* serverLink, BPoint pt,
// send_mouse_up // send_mouse_up
void void
send_mouse_up(BPortLink* serverLink, BPoint pt, send_mouse_up(BPrivate::PortLink* serverLink, BPoint pt,
BMessage* currentMessage) BMessage* currentMessage)
{ {
// Attach data: // Attach data:
@@ -99,7 +99,7 @@ send_mouse_up(BPortLink* serverLink, BPoint pt,
// handle_message // handle_message
bool bool
handle_message(BPortLink* serverLink, BMessage* msg) handle_message(BPrivate::PortLink* serverLink, BMessage* msg)
{ {
bool handled = true; bool handled = true;
switch (msg->what) switch (msg->what)
+7 -5
View File
@@ -13,22 +13,24 @@
#include <Point.h> #include <Point.h>
class BPortLink; namespace BPrivate {
class PortLink;
};
class BMessage; class BMessage;
void void
send_mouse_down(BPortLink* serverLink, BPoint pt, send_mouse_down(BPrivate::PortLink* serverLink, BPoint pt,
BMessage* currentMessage); BMessage* currentMessage);
void void
send_mouse_moved(BPortLink* serverLink, BPoint pt, send_mouse_moved(BPrivate::PortLink* serverLink, BPoint pt,
BMessage* currentMessage); BMessage* currentMessage);
void void
send_mouse_up(BPortLink* serverLink, BPoint pt, send_mouse_up(BPrivate::PortLink* serverLink, BPoint pt,
BMessage* currentMessage); BMessage* currentMessage);
bool bool
handle_message(BPortLink* serverLink, BMessage* msg); handle_message(BPrivate::PortLink* serverLink, BMessage* msg);
#endif // FAKE_INPUT_SERVER_H #endif // FAKE_INPUT_SERVER_H
+1 -1
View File
@@ -184,7 +184,7 @@ InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE),
port_id input_port = find_port(SERVER_INPUT_PORT); port_id input_port = find_port(SERVER_INPUT_PORT);
if (input_port == B_NAME_NOT_FOUND) if (input_port == B_NAME_NOT_FOUND)
PRINTERR(("input_server couldn't find app_server's input port\n")); PRINTERR(("input_server couldn't find app_server's input port\n"));
fAppServerLink = new BPortLink(input_port); fAppServerLink = new BPrivate::PortLink(input_port);
#endif #endif
InitKeyboardMouseStates(); InitKeyboardMouseStates();
+7 -5
View File
@@ -4,7 +4,7 @@
// This is the primary application class for the Haiku input_server. // This is the primary application class for the Haiku input_server.
// //
// //
// Copyright (c) 2001-2004 Haiku Project // Copyright (c) 2001-2005 Haiku Project
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
@@ -54,8 +54,8 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#define APPSERVER_PORTLINK_COMM #define APPSERVER_PORTLINK_COMM
//#define R5_CURSOR_COMM // define this when R5 cursor communication should be used #define R5_CURSOR_COMM // define this when R5 cursor communication should be used
// #define APPSERVER_R5_COMM // define this when R5 app_server communication should be used //#define APPSERVER_R5_COMM // define this when R5 app_server communication should be used
#define INPUTSERVER_SIGNATURE "application/x-vnd.Be-input_server" // use this when target should replace R5 input_server #define INPUTSERVER_SIGNATURE "application/x-vnd.Be-input_server" // use this when target should replace R5 input_server
@@ -65,7 +65,9 @@
#endif #endif
#ifdef APPSERVER_PORTLINK_COMM #ifdef APPSERVER_PORTLINK_COMM
class BPortLink; namespace BPrivate {
class PortLink;
};
#endif #endif
class InputDeviceListItem class InputDeviceListItem
@@ -241,7 +243,7 @@ private:
#ifdef APPSERVER_PORTLINK_COMM #ifdef APPSERVER_PORTLINK_COMM
// added this to communicate via portlink // added this to communicate via portlink
BPortLink *fAppServerLink; BPrivate::PortLink *fAppServerLink;
#endif #endif
#ifdef R5_CURSOR_COMM #ifdef R5_CURSOR_COMM
sem_id fCursorSem; sem_id fCursorSem;
+1 -1
View File
@@ -47,7 +47,7 @@ if $(TARGET_PLATFORM) != haiku {
SubDirC++Flags -DAPPSERVER_R5_COMM ; SubDirC++Flags -DAPPSERVER_R5_COMM ;
} }
} else { } else {
APPSERVER_TEST_MODE = 1 ; APPSERVER_TEST_MODE = 0 ;
} }
Server input_server : Server input_server :
+7 -7
View File
@@ -137,7 +137,7 @@ AppServer::Run(void)
void void
AppServer::MainLoop(void) AppServer::MainLoop(void)
{ {
BPortLink pmsg(-1,fMessagePort); BPrivate::PortLink pmsg(-1,fMessagePort);
int32 code=0; int32 code=0;
status_t err=B_OK; status_t err=B_OK;
@@ -178,7 +178,7 @@ AppServer::MainLoop(void)
void void
AppServer::DispatchMessage(int32 code, BPortLink &msg) AppServer::DispatchMessage(int32 code, BPrivate::PortLink &msg)
{ {
switch(code) switch(code)
{ {
@@ -226,12 +226,12 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
release_sem(fAppListLock); release_sem(fAppListLock);
BPortLink replylink(app_port); BPrivate::PortLink replylink(app_port);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<int32>(newapp->fMessagePort); replylink.Attach<int32>(newapp->fMessagePort);
replylink.Flush(); replylink.Flush();
// This is necessary because BPortLink::ReadString allocates memory // This is necessary because BPrivate::PortLink::ReadString allocates memory
if(app_signature) if(app_signature)
free(app_signature); free(app_signature);
@@ -281,12 +281,12 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
#endif #endif
case AS_QUERY_FONTS_CHANGED: case AS_QUERY_FONTS_CHANGED:
{ {
// Seeing how the client merely wants an answer, we'll skip the BPortLink // Seeing how the client merely wants an answer, we'll skip the BPrivate::PortLink
// and all its overhead and just write the code to port. // and all its overhead and just write the code to port.
port_id replyport; port_id replyport;
if (msg.Read<port_id>(&replyport) < B_OK) if (msg.Read<port_id>(&replyport) < B_OK)
break; break;
BPortLink replylink(replyport); BPrivate::PortLink replylink(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
break; break;
@@ -300,7 +300,7 @@ AppServer::DispatchMessage(int32 code, BPortLink &msg)
if(msg.Read<port_id>(&replyport)<B_OK) if(msg.Read<port_id>(&replyport)<B_OK)
return; return;
BPortLink replylink(replyport); BPrivate::PortLink replylink(replyport);
replylink.StartMessage(AS_GET_DECORATOR); replylink.StartMessage(AS_GET_DECORATOR);
replylink.AttachString("none"); replylink.AttachString("none");
replylink.Flush(); replylink.Flush();
+6 -4
View File
@@ -14,12 +14,14 @@ class Layer;
class BMessage; class BMessage;
class ServerApp; class ServerApp;
class DisplayDriver; class DisplayDriver;
class BPortLink;
class CursorManager; class CursorManager;
class BitmapManager; class BitmapManager;
class AppServer namespace BPrivate {
{ class PortLink;
};
class AppServer {
public: public:
AppServer(void); AppServer(void);
~AppServer(void); ~AppServer(void);
@@ -29,7 +31,7 @@ public:
thread_id Run(void); thread_id Run(void);
void MainLoop(void); void MainLoop(void);
void DispatchMessage(int32 code, BPortLink &link); void DispatchMessage(int32 code, BPrivate::PortLink &link);
private: private:
port_id fMessagePort; port_id fMessagePort;
+31 -31
View File
@@ -107,8 +107,8 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort
// fMessagePort is the port we receive messages from our BApplication // fMessagePort is the port we receive messages from our BApplication
fMessagePort=rcvport; fMessagePort=rcvport;
fMsgReader = new LinkMsgReader(fMessagePort); fMsgReader = new BPrivate::LinkReceiver(fMessagePort);
fMsgSender = new LinkMsgSender(fClientAppPort); fMsgSender = new BPrivate::LinkSender(fClientAppPort);
fIsActive=false; fIsActive=false;
@@ -186,7 +186,7 @@ ServerApp::PingTarget(void)
*/ */
void ServerApp::PostMessage(int32 code) void ServerApp::PostMessage(int32 code)
{ {
BPortLink link(fMessagePort); BPrivate::PortLink link(fMessagePort);
link.StartMessage(code); link.StartMessage(code);
link.Flush(); link.Flush();
} }
@@ -239,7 +239,7 @@ int32 ServerApp::MonitorApp(void *data)
// Message-dispatching loop for the ServerApp // Message-dispatching loop for the ServerApp
ServerApp *app = (ServerApp *)data; ServerApp *app = (ServerApp *)data;
LinkMsgReader msgqueue(app->fMessagePort); BPrivate::LinkReceiver msgqueue(app->fMessagePort);
bool quitting = false; bool quitting = false;
int32 code; int32 code;
@@ -340,9 +340,9 @@ int32 ServerApp::MonitorApp(void *data)
All attachments are placed in the buffer via a PortLink, so it will be a All attachments are placed in the buffer via a PortLink, so it will be a
matter of casting and incrementing an index variable to access them. matter of casting and incrementing an index variable to access them.
*/ */
void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg) void ServerApp::DispatchMessage(int32 code, BPrivate::LinkReceiver &msg)
{ {
BPortLink replylink; BPrivate::PortLink replylink;
switch(code) switch(code)
{ {
@@ -371,7 +371,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
void *sharedmem=fSharedMem->GetBuffer(memsize); void *sharedmem=fSharedMem->GetBuffer(memsize);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
if(memsize<1 || sharedmem==NULL) if(memsize<1 || sharedmem==NULL)
{ {
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
@@ -460,7 +460,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n", STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
fSignature.String(),r.left,r.top,r.right,r.bottom)); fSignature.String(),r.left,r.top,r.right,r.bottom));
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
/* if(sbmp) /* if(sbmp)
{ {
fBitmapList->AddItem(sbmp); fBitmapList->AddItem(sbmp);
@@ -495,7 +495,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&bmp_id); msg.Read<int32>(&bmp_id);
msg.Read<int32>(&replyport); msg.Read<int32>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Flush(); replylink.Flush();
break; break;
@@ -549,7 +549,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
int32 replyport; int32 replyport;
msg.Read<int32>(&replyport); msg.Read<int32>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(fCursorHidden ? SERVER_TRUE : SERVER_FALSE); replylink.StartMessage(fCursorHidden ? SERVER_TRUE : SERVER_FALSE);
replylink.Flush(); replylink.Flush();
break; break;
@@ -571,7 +571,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&replyport); msg.Read<int32>(&replyport);
// Synchronous message - BApplication is waiting on the cursor's ID // Synchronous message - BApplication is waiting on the cursor's ID
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<int32>(-1); replylink.Attach<int32>(-1);
replylink.Flush(); replylink.Flush();
@@ -597,7 +597,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
port_id replyport; port_id replyport;
msg.Read<int32>(&replyport); msg.Read<int32>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<scroll_bar_info>(sbi); replylink.Attach<scroll_bar_info>(sbi);
replylink.Flush(); replylink.Flush();
@@ -621,7 +621,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
port_id replyport; port_id replyport;
msg.Read<int32>(&replyport); msg.Read<int32>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<bool>(true); replylink.Attach<bool>(true);
replylink.Flush(); replylink.Flush();
@@ -658,7 +658,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
port_id replyport = -1; port_id replyport = -1;
msg.Read<int32>(&replyport); msg.Read<int32>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<mode_mouse>(mmode); replylink.Attach<mode_mouse>(mmode);
replylink.Flush(); replylink.Flush();
@@ -675,7 +675,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&whichcolor); msg.Read<int32>(&whichcolor);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<rgb_color>(color); replylink.Attach<rgb_color>(color);
replylink.Flush(); replylink.Flush();
@@ -714,7 +714,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&famid); msg.Read<int32>(&famid);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -741,7 +741,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&styid); msg.Read<int32>(&styid);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -765,7 +765,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<uint16>(&styid); msg.Read<uint16>(&styid);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -793,7 +793,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&styid); msg.Read<int32>(&styid);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
/* fontserver->Lock(); /* fontserver->Lock();
FontStyle *fstyle=fontserver->GetStyle(famid,styid); FontStyle *fstyle=fontserver->GetStyle(famid,styid);
@@ -843,7 +843,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<uint8>(&spacing); msg.Read<uint8>(&spacing);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
break; break;
@@ -878,7 +878,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&styid); msg.Read<int32>(&styid);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -914,7 +914,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<int32>(&styid); msg.Read<int32>(&styid);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -936,7 +936,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read(fam,sizeof(font_family)); msg.Read(fam,sizeof(font_family));
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -962,7 +962,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read(sty,sizeof(font_style)); msg.Read(sty,sizeof(font_style));
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -986,7 +986,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<uint16>(&sty); msg.Read<uint16>(&sty);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -1019,7 +1019,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<int32>(0); replylink.Attach<int32>(0);
replylink.Flush(); replylink.Flush();
@@ -1040,7 +1040,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read(fam,sizeof(font_family)); msg.Read(fam,sizeof(font_family));
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
break; break;
@@ -1060,7 +1060,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
port_id replyport; port_id replyport;
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -1083,7 +1083,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
msg.Read<float>(&ptsize); msg.Read<float>(&ptsize);
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -1104,7 +1104,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
port_id replyport; port_id replyport;
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
@@ -1125,7 +1125,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
port_id replyport; port_id replyport;
msg.Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
replylink.SetSendPort(replyport); replylink.SetSenderPort(replyport);
replylink.StartMessage(SERVER_FALSE); replylink.StartMessage(SERVER_FALSE);
replylink.Flush(); replylink.Flush();
+8 -5
View File
@@ -36,13 +36,16 @@
class AppServer; class AppServer;
class BMessage; class BMessage;
class BPortLink;
class BList; class BList;
class DisplayDriver; class DisplayDriver;
class ServerCursor; class ServerCursor;
class ServerBitmap; class ServerBitmap;
class AreaPool; class AreaPool;
namespace BPrivate {
class PortLink;
};
/*! /*!
\class ServerApp ServerApp.h \class ServerApp ServerApp.h
\brief Counterpart to BApplication within the app_server \brief Counterpart to BApplication within the app_server
@@ -81,7 +84,7 @@ protected:
friend class AppServer; friend class AppServer;
friend class ServerWindow; friend class ServerWindow;
void DispatchMessage(int32 code, LinkMsgReader &link); void DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
port_id fClientAppPort, port_id fClientAppPort,
fMessagePort, fMessagePort,
@@ -94,9 +97,9 @@ protected:
team_id fClientTeamID; team_id fClientTeamID;
LinkMsgReader *fMsgReader; BPrivate::LinkReceiver *fMsgReader;
LinkMsgSender *fMsgSender; BPrivate::LinkSender *fMsgSender;
/* BList *fSWindowList, /* BList *fSWindowList,
*fBitmapList, *fBitmapList,
*fPictureList; *fPictureList;