1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2005, Haiku, Inc. 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: ServerApp.h 23 // Author: DarkWyrm <bpmagic@columbus.rr.com> 24 // Adi Oanca <adioanca@myrealbox.com> 25 // Description: Server-side BApplication counterpart 26 // 27 //------------------------------------------------------------------------------ 28 #ifndef _SERVERAPP_H_ 29 #define _SERVERAPP_H_ 30 31 #include <OS.h> 32 #include <String.h> 33 #include <PortLink.h> 34 35 class AreaPool; 36 class BMessage; 37 class BList; 38 class DisplayDriver; 39 class ServerPicture; 40 class ServerCursor; 41 class ServerBitmap; 42 43 namespace BPrivate { 44 class PortLink; 45 }; 46 47 /*! 48 \class ServerApp ServerApp.h 49 \brief Counterpart to BApplication within the app_server 50 */ 51 class ServerApp { 52 public: 53 ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort, 54 team_id clientTeamID, int32 handlerID, const char* signature); 55 virtual ~ServerApp(void); 56 57 bool Run(void); 58 /* 59 TODO: These aren't even implemented... 60 void Lock(void); 61 void Unlock(void); 62 bool IsLocked(void); 63 */ 64 /*! 65 \brief Determines whether the application is the active one 66 \return true if active, false if not. 67 */ 68 bool IsActive(void) const { return fIsActive; } 69 void Activate(bool value); 70 71 bool PingTarget(void); 72 73 void PostMessage(int32 code); 74 void SendMessageToClient( const BMessage* msg ) const; 75 76 void SetAppCursor(void); 77 78 team_id ClientTeamID() const; 79 thread_id MonitorThreadID() const; 80 81 const char *Title() const { return fSignature.String(); } 82 83 int32 CountBitmaps() const; 84 ServerBitmap *FindBitmap(int32 token) const; 85 86 int32 CountPictures() const; 87 ServerPicture *FindPicture(int32 token) const; 88 89 AreaPool *AppAreaPool() { return fSharedMem; } 90 91 private: 92 void DispatchMessage(int32 code, BPrivate::LinkReceiver &link); 93 94 static int32 MonitorApp(void *data); 95 96 // our BApplication's event port 97 port_id fClientAppPort; 98 // port we receive messages from our BApplication 99 port_id fMessagePort; 100 // TODO: find out why there is both the app port and the looper port. Do 101 // we really need both? Actually, we aren't using any of these ports, 102 // as BAppServerLink/BPortlink's messages always contain the reply port 103 // To send a message to the client, write a BMessage to this port 104 port_id fClientLooperPort; 105 106 BString fSignature; 107 108 thread_id fMonitorThreadID; 109 team_id fClientTeamID; 110 111 BPrivate::PortLink fLink; 112 113 // TODO: 114 // - Are really Bitmaps and Pictures stored per application and not globally ? 115 // - As we reference these stuff by token, what about putting them in hash tables ? 116 BList *fSWindowList, 117 *fBitmapList, 118 *fPictureList; 119 120 ServerCursor *fAppCursor; 121 122 // TODO: Not used. 123 sem_id fLockSem; 124 125 bool fCursorHidden; 126 bool fIsActive; 127 128 // token ID of the BApplication's BHandler object. 129 // Used for BMessage target specification 130 // TODO: Is it still needed ? We aren't using it. 131 //int32 fHandlerToken; 132 133 AreaPool *fSharedMem; 134 135 bool fQuitting; 136 }; 137 138 #endif // _SERVERAPP_H_ 139