xref: /haiku/src/tests/apps/fake_app_server/ServerApp.h (revision dd10337fd005a67a4947714fdeecf2121485b91d)
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 <LinkMsgReader.h>
34 #include <LinkMsgSender.h>
35 //#include "FMWList.h"
36 
37 class AppServer;
38 class BMessage;
39 class BList;
40 class DisplayDriver;
41 class ServerCursor;
42 class ServerBitmap;
43 class AreaPool;
44 
45 namespace BPrivate {
46 	class PortLink;
47 };
48 
49 /*!
50 	\class ServerApp ServerApp.h
51 	\brief Counterpart to BApplication within the app_server
52 */
53 class ServerApp
54 {
55 public:
56 	ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
57 		team_id clientTeamID, int32 handlerID, char *signature);
58 	virtual						~ServerApp(void);
59 
60 	bool Run(void);
61 	static int32 MonitorApp(void *data);
62 	void Lock(void);
63 	void Unlock(void);
64 	bool IsLocked(void);
65 
66 	/*!
67 		\brief Determines whether the application is the active one
68 		\return true if active, false if not.
69 	*/
70 	bool IsActive(void) const { return fIsActive; }
71 
72 	void Activate(bool value);
73 	bool PingTarget(void);
74 
75 	void PostMessage(int32 code);
76 
77 	void SendMessageToClient( const BMessage* msg ) const;
78 	void SetAppCursor(void);
79 
80 	team_id	ClientTeamID();
81 
82 const char * Title() const { return fSignature.String(); }
83 protected:
84 	friend class AppServer;
85 	friend class ServerWindow;
86 
87 	void DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
88 
89 	port_id	fClientAppPort,
90 			fMessagePort,
91 			// TODO: find out why there is both the app port and the looper port. Do
92 			// we really need both?
93 			fClientLooperPort;
94 
95 	BString fSignature;
96 	thread_id fMonitorThreadID;
97 
98 	team_id fClientTeamID;
99 
100 	BPrivate::LinkReceiver *fMsgReader;
101 	BPrivate::LinkSender *fMsgSender;
102 
103 /*	BList *fSWindowList,
104 		  *fBitmapList,
105 		  *fPictureList;
106 */	sem_id fLockSem;
107 	bool fCursorHidden;
108 	bool fIsActive;
109 	int32 fHandlerToken;
110 	AreaPool *fSharedMem;
111 };
112 
113 #endif
114