xref: /haiku/src/servers/registrar/TRoster.h (revision 5e949b7dfcb1beacd57377e0d887abc6058587bf)
1f9fd58ccSIngo Weinhold //------------------------------------------------------------------------------
2f9fd58ccSIngo Weinhold //	Copyright (c) 2001-2002, OpenBeOS
3f9fd58ccSIngo Weinhold //
4f9fd58ccSIngo Weinhold //	Permission is hereby granted, free of charge, to any person obtaining a
5f9fd58ccSIngo Weinhold //	copy of this software and associated documentation files (the "Software"),
6f9fd58ccSIngo Weinhold //	to deal in the Software without restriction, including without limitation
7f9fd58ccSIngo Weinhold //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8f9fd58ccSIngo Weinhold //	and/or sell copies of the Software, and to permit persons to whom the
9f9fd58ccSIngo Weinhold //	Software is furnished to do so, subject to the following conditions:
10f9fd58ccSIngo Weinhold //
11f9fd58ccSIngo Weinhold //	The above copyright notice and this permission notice shall be included in
12f9fd58ccSIngo Weinhold //	all copies or substantial portions of the Software.
13f9fd58ccSIngo Weinhold //
14f9fd58ccSIngo Weinhold //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15f9fd58ccSIngo Weinhold //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16f9fd58ccSIngo Weinhold //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17f9fd58ccSIngo Weinhold //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18f9fd58ccSIngo Weinhold //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19f9fd58ccSIngo Weinhold //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20f9fd58ccSIngo Weinhold //	DEALINGS IN THE SOFTWARE.
21f9fd58ccSIngo Weinhold //
22f9fd58ccSIngo Weinhold //	File Name:		TRoster.h
23f9fd58ccSIngo Weinhold //	Author:			Ingo Weinhold (bonefish@users.sf.net)
24f9fd58ccSIngo Weinhold //	Description:	TRoster is the incarnation of The Roster. It manages the
25f9fd58ccSIngo Weinhold //					running applications.
26f9fd58ccSIngo Weinhold //------------------------------------------------------------------------------
27f9fd58ccSIngo Weinhold 
28f9fd58ccSIngo Weinhold #ifndef T_ROSTER_H
29f9fd58ccSIngo Weinhold #define T_ROSTER_H
30f9fd58ccSIngo Weinhold 
311d32138dSIngo Weinhold #include <map>
321d32138dSIngo Weinhold 
33f9fd58ccSIngo Weinhold #include <SupportDefs.h>
34f9fd58ccSIngo Weinhold 
35f9fd58ccSIngo Weinhold #include "AppInfoList.h"
36f9fd58ccSIngo Weinhold 
37f9fd58ccSIngo Weinhold class BMessage;
38f9fd58ccSIngo Weinhold 
391d32138dSIngo Weinhold struct IAPRRequest {
401d32138dSIngo Weinhold 	entry_ref	ref;
411d32138dSIngo Weinhold 	team_id		team;
421d32138dSIngo Weinhold 	BMessage	*request;
431d32138dSIngo Weinhold };
441d32138dSIngo Weinhold 
451d32138dSIngo Weinhold typedef map<team_id, IAPRRequest>	IAPRRequestMap;
461d32138dSIngo Weinhold 
47f9fd58ccSIngo Weinhold // For strategic reasons, as TRoster appears in the BMessenger header.
48f9fd58ccSIngo Weinhold namespace BPrivate {
49f9fd58ccSIngo Weinhold 
50f9fd58ccSIngo Weinhold class TRoster {
51f9fd58ccSIngo Weinhold public:
52f9fd58ccSIngo Weinhold 	TRoster();
53f9fd58ccSIngo Weinhold 	virtual ~TRoster();
54f9fd58ccSIngo Weinhold 
551d32138dSIngo Weinhold 	void HandleAddApplication(BMessage *request);
561d32138dSIngo Weinhold 	void HandleCompleteRegistration(BMessage *request);
571d32138dSIngo Weinhold 	void HandleIsAppPreRegistered(BMessage *request);
581d32138dSIngo Weinhold 	void HandleRemovePreRegApp(BMessage *request);
591d32138dSIngo Weinhold 	void HandleRemoveApp(BMessage *request);
601d32138dSIngo Weinhold 	void HandleSetThreadAndTeam(BMessage *request);
61a12aef2bSIngo Weinhold 	void HandleGetAppInfo(BMessage *request);
62a12aef2bSIngo Weinhold 	void HandleGetAppList(BMessage *request);
63a12aef2bSIngo Weinhold 	void HandleActivateApp(BMessage *request);
64a12aef2bSIngo Weinhold 
65*5e949b7dSIngo Weinhold 	status_t Init();
66*5e949b7dSIngo Weinhold 
67a12aef2bSIngo Weinhold 	status_t AddApp(RosterAppInfo *info);
68a12aef2bSIngo Weinhold 	void RemoveApp(RosterAppInfo *info);
69a12aef2bSIngo Weinhold 	void ActivateApp(RosterAppInfo *info);
70f9fd58ccSIngo Weinhold 
71f9fd58ccSIngo Weinhold private:
72a12aef2bSIngo Weinhold 	// hook functions
73a12aef2bSIngo Weinhold 	void _AppAdded(RosterAppInfo *info);
74a12aef2bSIngo Weinhold 	void _AppRemoved(RosterAppInfo *info);
75a12aef2bSIngo Weinhold 	void _AppActivated(RosterAppInfo *info);
76a12aef2bSIngo Weinhold 	void _AppDeactivated(RosterAppInfo *info);
77a12aef2bSIngo Weinhold 
78a12aef2bSIngo Weinhold 	// helper functions
791d32138dSIngo Weinhold 	static status_t _AddMessageAppInfo(BMessage *message,
801d32138dSIngo Weinhold 									   const app_info *info);
811d32138dSIngo Weinhold 	uint32 _NextToken();
821d32138dSIngo Weinhold 	void _ReplyToIAPRRequest(BMessage *request, const RosterAppInfo *info);
831d32138dSIngo Weinhold 
841d32138dSIngo Weinhold private:
851d32138dSIngo Weinhold 	AppInfoList		fRegisteredApps;
861d32138dSIngo Weinhold 	AppInfoList		fEarlyPreRegisteredApps;
871d32138dSIngo Weinhold 	IAPRRequestMap	fIAPRRequests;
88a12aef2bSIngo Weinhold 	RosterAppInfo	*fActiveApp;
891d32138dSIngo Weinhold 	uint32			fLastToken;
90f9fd58ccSIngo Weinhold };
91f9fd58ccSIngo Weinhold 
92f9fd58ccSIngo Weinhold };	// namespace BPrivate
93f9fd58ccSIngo Weinhold 
94f9fd58ccSIngo Weinhold // Only the registrar code uses this header. No need to hide TRoster in the
95f9fd58ccSIngo Weinhold // namespace.
96f9fd58ccSIngo Weinhold using BPrivate::TRoster;
97f9fd58ccSIngo Weinhold 
98f9fd58ccSIngo Weinhold #endif	// T_ROSTER_H
99