1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 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: TRoster.h 23 // Author: Ingo Weinhold (bonefish@users.sf.net) 24 // Description: TRoster is the incarnation of The Roster. It manages the 25 // running applications. 26 //------------------------------------------------------------------------------ 27 28 #ifndef T_ROSTER_H 29 #define T_ROSTER_H 30 31 #include <map> 32 33 #include <SupportDefs.h> 34 35 #include "AppInfoList.h" 36 #include "RecentApps.h" 37 #include "WatchingService.h" 38 39 class BMessage; 40 class WatchingService; 41 42 struct IAPRRequest { 43 entry_ref ref; 44 team_id team; 45 BMessage *request; 46 }; 47 48 typedef map<team_id, IAPRRequest> IAPRRequestMap; 49 50 // For strategic reasons, as TRoster appears in the BMessenger header. 51 namespace BPrivate { 52 53 class TRoster { 54 public: 55 TRoster(); 56 virtual ~TRoster(); 57 58 void HandleAddApplication(BMessage *request); 59 void HandleCompleteRegistration(BMessage *request); 60 void HandleIsAppPreRegistered(BMessage *request); 61 void HandleRemovePreRegApp(BMessage *request); 62 void HandleRemoveApp(BMessage *request); 63 void HandleSetThreadAndTeam(BMessage *request); 64 void HandleSetSignature(BMessage *request); 65 void HandleGetAppInfo(BMessage *request); 66 void HandleGetAppList(BMessage *request); 67 void HandleActivateApp(BMessage *request); 68 void HandleBroadcast(BMessage *request); 69 void HandleStartWatching(BMessage *request); 70 void HandleStopWatching(BMessage *request); 71 void HandleGetRecentDocuments(BMessage *request); 72 void HandleGetRecentFolders(BMessage *request); 73 void HandleGetRecentApps(BMessage *request); 74 void HandleAddToRecentDocuments(BMessage *request); 75 void HandleAddToRecentFolders(BMessage *request); 76 void HandleAddToRecentApps(BMessage *request); 77 void HandleClearRecentDocuments(BMessage *request); 78 void HandleClearRecentFolders(BMessage *request); 79 void HandleClearRecentApps(BMessage *request); 80 81 status_t Init(); 82 83 status_t AddApp(RosterAppInfo *info); 84 void RemoveApp(RosterAppInfo *info); 85 void ActivateApp(RosterAppInfo *info); 86 87 void CheckSanity(); 88 89 private: 90 // hook functions 91 void _AppAdded(RosterAppInfo *info); 92 void _AppRemoved(RosterAppInfo *info); 93 void _AppActivated(RosterAppInfo *info); 94 void _AppDeactivated(RosterAppInfo *info); 95 96 // helper functions 97 static status_t _AddMessageAppInfo(BMessage *message, 98 const app_info *info); 99 static status_t _AddMessageWatchingInfo(BMessage *message, 100 const app_info *info); 101 uint32 _NextToken(); 102 void _ReplyToIAPRRequest(BMessage *request, const RosterAppInfo *info); 103 104 private: 105 AppInfoList fRegisteredApps; 106 AppInfoList fEarlyPreRegisteredApps; 107 IAPRRequestMap fIAPRRequests; 108 RosterAppInfo *fActiveApp; 109 WatchingService fWatchingService; 110 RecentApps fRecentApps; 111 uint32 fLastToken; 112 }; 113 114 }; // namespace BPrivate 115 116 // Only the registrar code uses this header. No need to hide TRoster in the 117 // namespace. 118 using BPrivate::TRoster; 119 120 #endif // T_ROSTER_H 121