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 "RecentEntries.h" 38 #include "WatchingService.h" 39 40 class BMessage; 41 class WatchingService; 42 43 struct IAPRRequest { 44 entry_ref ref; 45 team_id team; 46 BMessage *request; 47 }; 48 49 typedef map<team_id, IAPRRequest> IAPRRequestMap; 50 51 // For strategic reasons, as TRoster appears in the BMessenger header. 52 namespace BPrivate { 53 54 class TRoster { 55 public: 56 TRoster(); 57 virtual ~TRoster(); 58 59 void HandleAddApplication(BMessage *request); 60 void HandleCompleteRegistration(BMessage *request); 61 void HandleIsAppPreRegistered(BMessage *request); 62 void HandleRemovePreRegApp(BMessage *request); 63 void HandleRemoveApp(BMessage *request); 64 void HandleSetThreadAndTeam(BMessage *request); 65 void HandleSetSignature(BMessage *request); 66 void HandleGetAppInfo(BMessage *request); 67 void HandleGetAppList(BMessage *request); 68 void HandleActivateApp(BMessage *request); 69 void HandleBroadcast(BMessage *request); 70 void HandleStartWatching(BMessage *request); 71 void HandleStopWatching(BMessage *request); 72 void HandleGetRecentDocuments(BMessage *request); 73 void HandleGetRecentFolders(BMessage *request); 74 void HandleGetRecentApps(BMessage *request); 75 void HandleAddToRecentDocuments(BMessage *request); 76 void HandleAddToRecentFolders(BMessage *request); 77 void HandleAddToRecentApps(BMessage *request); 78 void HandleLoadRecentLists(BMessage *request); 79 void HandleSaveRecentLists(BMessage *request); 80 81 void ClearRecentDocuments(); 82 void ClearRecentFolders(); 83 void ClearRecentApps(); 84 85 status_t Init(); 86 87 status_t AddApp(RosterAppInfo *info); 88 void RemoveApp(RosterAppInfo *info); 89 void ActivateApp(RosterAppInfo *info); 90 91 void CheckSanity(); 92 93 private: 94 // hook functions 95 void _AppAdded(RosterAppInfo *info); 96 void _AppRemoved(RosterAppInfo *info); 97 void _AppActivated(RosterAppInfo *info); 98 void _AppDeactivated(RosterAppInfo *info); 99 100 // helper functions 101 static status_t _AddMessageAppInfo(BMessage *message, 102 const app_info *info); 103 static status_t _AddMessageWatchingInfo(BMessage *message, 104 const app_info *info); 105 uint32 _NextToken(); 106 void _ReplyToIAPRRequest(BMessage *request, const RosterAppInfo *info); 107 108 void _HandleGetRecentEntries(BMessage *request); 109 110 status_t _LoadRosterSettings(const char *path = NULL); 111 status_t _SaveRosterSettings(const char *path = NULL); 112 static const char *kDefaultRosterSettingsFile; 113 114 private: 115 AppInfoList fRegisteredApps; 116 AppInfoList fEarlyPreRegisteredApps; 117 IAPRRequestMap fIAPRRequests; 118 RosterAppInfo *fActiveApp; 119 WatchingService fWatchingService; 120 RecentApps fRecentApps; 121 RecentEntries fRecentDocuments; 122 RecentEntries fRecentFolders; 123 uint32 fLastToken; 124 }; 125 126 }; // namespace BPrivate 127 128 // Only the registrar code uses this header. No need to hide TRoster in the 129 // namespace. 130 using BPrivate::TRoster; 131 132 #endif // T_ROSTER_H 133