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); 61*a12aef2bSIngo Weinhold void HandleGetAppInfo(BMessage *request); 62*a12aef2bSIngo Weinhold void HandleGetAppList(BMessage *request); 63*a12aef2bSIngo Weinhold void HandleActivateApp(BMessage *request); 64*a12aef2bSIngo Weinhold 65*a12aef2bSIngo Weinhold status_t AddApp(RosterAppInfo *info); 66*a12aef2bSIngo Weinhold void RemoveApp(RosterAppInfo *info); 67*a12aef2bSIngo Weinhold void ActivateApp(RosterAppInfo *info); 68f9fd58ccSIngo Weinhold 69f9fd58ccSIngo Weinhold private: 70*a12aef2bSIngo Weinhold // hook functions 71*a12aef2bSIngo Weinhold void _AppAdded(RosterAppInfo *info); 72*a12aef2bSIngo Weinhold void _AppRemoved(RosterAppInfo *info); 73*a12aef2bSIngo Weinhold void _AppActivated(RosterAppInfo *info); 74*a12aef2bSIngo Weinhold void _AppDeactivated(RosterAppInfo *info); 75*a12aef2bSIngo Weinhold 76*a12aef2bSIngo Weinhold // helper functions 771d32138dSIngo Weinhold static status_t _AddMessageAppInfo(BMessage *message, 781d32138dSIngo Weinhold const app_info *info); 791d32138dSIngo Weinhold uint32 _NextToken(); 801d32138dSIngo Weinhold void _ReplyToIAPRRequest(BMessage *request, const RosterAppInfo *info); 811d32138dSIngo Weinhold 821d32138dSIngo Weinhold private: 831d32138dSIngo Weinhold AppInfoList fRegisteredApps; 841d32138dSIngo Weinhold AppInfoList fEarlyPreRegisteredApps; 851d32138dSIngo Weinhold IAPRRequestMap fIAPRRequests; 86*a12aef2bSIngo Weinhold RosterAppInfo *fActiveApp; 871d32138dSIngo Weinhold uint32 fLastToken; 88f9fd58ccSIngo Weinhold }; 89f9fd58ccSIngo Weinhold 90f9fd58ccSIngo Weinhold }; // namespace BPrivate 91f9fd58ccSIngo Weinhold 92f9fd58ccSIngo Weinhold // Only the registrar code uses this header. No need to hide TRoster in the 93f9fd58ccSIngo Weinhold // namespace. 94f9fd58ccSIngo Weinhold using BPrivate::TRoster; 95f9fd58ccSIngo Weinhold 96f9fd58ccSIngo Weinhold #endif // T_ROSTER_H 97