1 /* 2 * Copyright 2001-2005, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * DarkWyrm <bpmagic@columbus.rr.com> 7 * Adrian Oanca <adioanca@cotty.iren.ro> 8 * Stephan Aßmus <superstippi@gmx.de> 9 * Stefano Ceccherini (burton666@libero.it) 10 * Axel Dörfler, axeld@pinc-software.de 11 */ 12 #ifndef _SERVERAPP_H_ 13 #define _SERVERAPP_H_ 14 15 16 #include "MessageLooper.h" 17 #include "SubWindowList.h" 18 #include "BGet++.h" 19 20 #include <String.h> 21 22 23 class AreaPool; 24 class BMessage; 25 class BList; 26 class DisplayDriver; 27 class ServerPicture; 28 class ServerCursor; 29 class ServerBitmap; 30 class Desktop; 31 32 namespace BPrivate { 33 class PortLink; 34 }; 35 36 class ServerApp : public MessageLooper { 37 public: 38 ServerApp(Desktop* desktop, port_id clientAppPort, 39 port_id clientLooperPort, team_id clientTeamID, 40 int32 handlerID, const char* signature); 41 virtual ~ServerApp(); 42 43 status_t InitCheck(); 44 void Quit(sem_id shutdownSemaphore = -1); 45 46 virtual bool Run(); 47 virtual port_id MessagePort() const { return fMessagePort; } 48 49 /*! 50 \brief Determines whether the application is the active one 51 \return true if active, false if not. 52 */ 53 bool IsActive(void) const { return fIsActive; } 54 void Activate(bool value); 55 56 void SendMessageToClient(const BMessage* msg) const; 57 58 void SetAppCursor(void); 59 60 team_id ClientTeam() const; 61 const char *Signature() const { return fSignature.String(); } 62 63 void RemoveWindow(ServerWindow* window); 64 65 int32 CountBitmaps() const; 66 ServerBitmap *FindBitmap(int32 token) const; 67 68 int32 CountPictures() const; 69 ServerPicture *FindPicture(int32 token) const; 70 71 AreaPool *AppAreaPool() { return &fSharedMem; } 72 73 Desktop* GetDesktop() const { return fDesktop; } 74 75 // ToDo: public? 76 SubWindowList fAppSubWindowList; 77 78 private: 79 virtual void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link); 80 virtual void _MessageLooper(); 81 virtual void _GetLooperName(char* name, size_t size); 82 83 port_id fMessagePort; 84 port_id fClientReplyPort; 85 // our BApplication's event port 86 87 port_id fClientLooperPort; 88 int32 fClientToken; 89 // To send a BMessage to the client (port + token) 90 91 Desktop* fDesktop; 92 BString fSignature; 93 team_id fClientTeam; 94 95 BLocker fWindowListLock; 96 BList fWindowList; 97 98 // TODO: 99 // - Are really Bitmaps and Pictures stored per application and not globally ? 100 // - As we reference these stuff by token, what about putting them in hash tables ? 101 BList fBitmapList; 102 BList fPictureList; 103 104 ServerCursor *fAppCursor; 105 bool fCursorHidden; 106 107 bool fIsActive; 108 109 AreaPool fSharedMem; 110 }; 111 112 #endif // _SERVERAPP_H_ 113