#ifndef SERVER_APP_H
#define SERVER_APP_H
#include "AppFontManager.h"
#include "ClientMemoryAllocator.h"
#include "MessageLooper.h"
#include "ServerFont.h"
#include <ObjectList.h>
#include <TokenSpace.h>
#include <Messenger.h>
#include <String.h>
class AreaPool;
class BMessage;
class BList;
class Desktop;
class DrawingEngine;
class ServerPicture;
class ServerCursor;
class ServerBitmap;
class ServerWindow;
namespace BPrivate {
class PortLink;
};
class ServerApp : public MessageLooper {
public:
ServerApp(Desktop* desktop,
port_id clientAppPort,
port_id clientLooperPort,
team_id clientTeamID, int32 handlerID,
const char* signature);
virtual ~ServerApp();
status_t InitCheck();
virtual void Quit();
void Quit(sem_id shutdownSemaphore);
virtual port_id MessagePort() const { return fMessagePort; }
bool IsActive() const { return fIsActive; }
void Activate(bool value);
void SendMessageToClient(BMessage* message) const;
void SetCurrentCursor(ServerCursor* cursor);
ServerCursor* CurrentCursor() const;
team_id ClientTeam() const { return fClientTeam; }
const char* Signature() const
{ return fSignature.String(); }
const char* SignatureLeaf() const
{ return fSignature.String() + 12; }
bool AddWindow(ServerWindow* window);
void RemoveWindow(ServerWindow* window);
bool InWorkspace(int32 index) const;
uint32 Workspaces() const;
int32 InitialWorkspace() const
{ return fInitialWorkspace; }
ServerBitmap* GetBitmap(int32 token) const;
ServerPicture* CreatePicture(
const ServerPicture* original = NULL);
ServerPicture* GetPicture(int32 token) const;
bool AddPicture(ServerPicture* picture);
void RemovePicture(ServerPicture* picture);
Desktop* GetDesktop() const { return fDesktop; }
const ServerFont& PlainFont() const { return fPlainFont; }
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
AppFontManager* FontManager() { return fAppFontManager; }
private:
virtual void _GetLooperName(char* name, size_t size);
virtual void _DispatchMessage(int32 code,
BPrivate::LinkReceiver& link);
virtual void _MessageLooper();
status_t _CreateWindow(int32 code,
BPrivate::LinkReceiver& link,
port_id& clientReplyPort);
bool _HasWindowUnderMouse();
bool _AddBitmap(ServerBitmap* bitmap);
void _DeleteBitmap(ServerBitmap* bitmap);
ServerBitmap* _FindBitmap(int32 token) const;
ServerPicture* _FindPicture(int32 token) const;
private:
typedef std::map<int32, BReference<ServerBitmap> > BitmapMap;
typedef std::map<int32, BReference<ServerPicture> > PictureMap;
port_id fMessagePort;
port_id fClientReplyPort;
BMessenger fHandlerMessenger;
port_id fClientLooperPort;
int32 fClientToken;
Desktop* fDesktop;
BString fSignature;
team_id fClientTeam;
ServerFont fPlainFont;
ServerFont fBoldFont;
ServerFont fFixedFont;
mutable BLocker fWindowListLock;
BObjectList<ServerWindow> fWindowList;
BPrivate::BTokenSpace fViewTokens;
int32 fInitialWorkspace;
uint32 fTemporaryDisplayModeChange;
mutable BLocker fMapLocker;
BitmapMap fBitmapMap;
PictureMap fPictureMap;
BReference<ServerCursor>
fAppCursor;
BReference<ServerCursor>
fViewCursor;
int32 fCursorHideLevel;
bool fIsActive;
BReference<ClientMemoryAllocator> fMemoryAllocator;
AppFontManager* fAppFontManager;
};
#endif