1c2f641f2SAxel Dörfler /* 2c2f641f2SAxel Dörfler * Copyright 2001-2007, Ingo Weinhold, bonefish@users.sf.net. 3c2f641f2SAxel Dörfler * Distributed under the terms of the MIT License. 4c2f641f2SAxel Dörfler */ 5f9fd58ccSIngo Weinhold #ifndef T_ROSTER_H 6f9fd58ccSIngo Weinhold #define T_ROSTER_H 7f9fd58ccSIngo Weinhold 8f9fd58ccSIngo Weinhold 9f9fd58ccSIngo Weinhold #include "AppInfoList.h" 10230719b5STyler Dauwalder #include "RecentApps.h" 11fde0f1b8STyler Dauwalder #include "RecentEntries.h" 127a0335c8SIngo Weinhold #include "WatchingService.h" 13f9fd58ccSIngo Weinhold 14c2f641f2SAxel Dörfler #include <Locker.h> 15c2f641f2SAxel Dörfler #include <MessageQueue.h> 16323b6546SOliver Tappe #include <Path.h> 17c8e7c8efSAxel Dörfler #include <Roster.h> 18c2f641f2SAxel Dörfler #include <SupportDefs.h> 19c2f641f2SAxel Dörfler 20c2f641f2SAxel Dörfler #include <hash_set> 21c2f641f2SAxel Dörfler #include <map> 22c2f641f2SAxel Dörfler 23c2f641f2SAxel Dörfler 24758b1d0eSIngo Weinhold #if __GNUC__ >= 4 25758b1d0eSIngo Weinhold using __gnu_cxx::hash_set; 26758b1d0eSIngo Weinhold #endif 27758b1d0eSIngo Weinhold 28758b1d0eSIngo Weinhold using std::map; 29758b1d0eSIngo Weinhold 30f9fd58ccSIngo Weinhold class BMessage; 317a0335c8SIngo Weinhold class WatchingService; 32f9fd58ccSIngo Weinhold 336bfd06d1SIngo Weinhold typedef map<int32, BMessageQueue*> IARRequestMap; 341d32138dSIngo Weinhold 35f9fd58ccSIngo Weinhold class TRoster { 36f9fd58ccSIngo Weinhold public: 37f9fd58ccSIngo Weinhold TRoster(); 38f9fd58ccSIngo Weinhold virtual ~TRoster(); 39f9fd58ccSIngo Weinhold 401d32138dSIngo Weinhold void HandleAddApplication(BMessage* request); 411d32138dSIngo Weinhold void HandleCompleteRegistration(BMessage* request); 426bfd06d1SIngo Weinhold void HandleIsAppRegistered(BMessage* request); 431d32138dSIngo Weinhold void HandleRemovePreRegApp(BMessage* request); 441d32138dSIngo Weinhold void HandleRemoveApp(BMessage* request); 451d32138dSIngo Weinhold void HandleSetThreadAndTeam(BMessage* request); 46af8eec40SIngo Weinhold void HandleSetSignature(BMessage* request); 47a12aef2bSIngo Weinhold void HandleGetAppInfo(BMessage* request); 48a12aef2bSIngo Weinhold void HandleGetAppList(BMessage* request); 49c2f641f2SAxel Dörfler void HandleUpdateActiveApp(BMessage* request); 5056d4d637SIngo Weinhold void HandleBroadcast(BMessage* request); 517a0335c8SIngo Weinhold void HandleStartWatching(BMessage* request); 527a0335c8SIngo Weinhold void HandleStopWatching(BMessage* request); 53230719b5STyler Dauwalder void HandleGetRecentDocuments(BMessage* request); 54230719b5STyler Dauwalder void HandleGetRecentFolders(BMessage* request); 55230719b5STyler Dauwalder void HandleGetRecentApps(BMessage* request); 56230719b5STyler Dauwalder void HandleAddToRecentDocuments(BMessage* request); 57230719b5STyler Dauwalder void HandleAddToRecentFolders(BMessage* request); 58230719b5STyler Dauwalder void HandleAddToRecentApps(BMessage* request); 591bde02aeSTyler Dauwalder void HandleLoadRecentLists(BMessage* request); 601bde02aeSTyler Dauwalder void HandleSaveRecentLists(BMessage* request); 611bde02aeSTyler Dauwalder 6204209cddSczeidler void HandleRestartAppServer(BMessage* request); 6304209cddSczeidler 641bde02aeSTyler Dauwalder void ClearRecentDocuments(); 651bde02aeSTyler Dauwalder void ClearRecentFolders(); 661bde02aeSTyler Dauwalder void ClearRecentApps(); 67a12aef2bSIngo Weinhold 685e949b7dSIngo Weinhold status_t Init(); 695e949b7dSIngo Weinhold 70a12aef2bSIngo Weinhold status_t AddApp(RosterAppInfo* info); 71a12aef2bSIngo Weinhold void RemoveApp(RosterAppInfo* info); 72c2f641f2SAxel Dörfler void UpdateActiveApp(RosterAppInfo* info); 73f9fd58ccSIngo Weinhold 74b48b6fb5SIngo Weinhold void CheckSanity(); 75b48b6fb5SIngo Weinhold 76553ea301SIngo Weinhold void SetShuttingDown(bool shuttingDown); 77c8e7c8efSAxel Dörfler status_t GetShutdownApps(AppInfoList& userApps, 78c8e7c8efSAxel Dörfler AppInfoList& systemApps, 79c8e7c8efSAxel Dörfler AppInfoList& backgroundApps, 80c8e7c8efSAxel Dörfler hash_set<team_id>& vitalSystemApps); 81*6899a856SJérôme Duval status_t AddAppInfo(AppInfoList& apps, team_id team); 82553ea301SIngo Weinhold 83553ea301SIngo Weinhold status_t AddWatcher(Watcher* watcher); 84553ea301SIngo Weinhold void RemoveWatcher(Watcher* watcher); 85553ea301SIngo Weinhold 86f9fd58ccSIngo Weinhold private: 87a12aef2bSIngo Weinhold // hook functions 88a12aef2bSIngo Weinhold void _AppAdded(RosterAppInfo* info); 89a12aef2bSIngo Weinhold void _AppRemoved(RosterAppInfo* info); 90a12aef2bSIngo Weinhold void _AppActivated(RosterAppInfo* info); 91a12aef2bSIngo Weinhold void _AppDeactivated(RosterAppInfo* info); 92a12aef2bSIngo Weinhold 93a12aef2bSIngo Weinhold // helper functions 94c8e7c8efSAxel Dörfler static status_t _AddMessageAppInfo(BMessage* message, 95c8e7c8efSAxel Dörfler const app_info* info); 967a0335c8SIngo Weinhold static status_t _AddMessageWatchingInfo(BMessage* message, 977a0335c8SIngo Weinhold const app_info* info); 981d32138dSIngo Weinhold uint32 _NextToken(); 996bfd06d1SIngo Weinhold 100c8e7c8efSAxel Dörfler void _AddIARRequest(IARRequestMap& map, int32 key, 101c8e7c8efSAxel Dörfler BMessage* request); 1026bfd06d1SIngo Weinhold void _ReplyToIARRequests(BMessageQueue* requests, 1036bfd06d1SIngo Weinhold const RosterAppInfo* info); 104c8e7c8efSAxel Dörfler void _ReplyToIARRequest(BMessage* request, 105c8e7c8efSAxel Dörfler const RosterAppInfo* info); 1061d32138dSIngo Weinhold 107fde0f1b8STyler Dauwalder void _HandleGetRecentEntries(BMessage* request); 108fde0f1b8STyler Dauwalder 109c8e7c8efSAxel Dörfler void _ValidateRunning(const entry_ref& ref, 110c8e7c8efSAxel Dörfler const char* signature); 111553ea301SIngo Weinhold bool _IsSystemApp(RosterAppInfo* info) const; 112553ea301SIngo Weinhold 1134f03f5d2STyler Dauwalder status_t _LoadRosterSettings(const char* path = NULL); 1144f03f5d2STyler Dauwalder status_t _SaveRosterSettings(const char* path = NULL); 1154f03f5d2STyler Dauwalder static const char* kDefaultRosterSettingsFile; 1164f03f5d2STyler Dauwalder 1171d32138dSIngo Weinhold private: 118553ea301SIngo Weinhold BLocker fLock; 1191d32138dSIngo Weinhold AppInfoList fRegisteredApps; 1201d32138dSIngo Weinhold AppInfoList fEarlyPreRegisteredApps; 1216bfd06d1SIngo Weinhold IARRequestMap fIARRequestsByID; 1226bfd06d1SIngo Weinhold IARRequestMap fIARRequestsByToken; 123a12aef2bSIngo Weinhold RosterAppInfo* fActiveApp; 1247a0335c8SIngo Weinhold WatchingService fWatchingService; 125230719b5STyler Dauwalder RecentApps fRecentApps; 126fde0f1b8STyler Dauwalder RecentEntries fRecentDocuments; 127fde0f1b8STyler Dauwalder RecentEntries fRecentFolders; 1281d32138dSIngo Weinhold uint32 fLastToken; 129553ea301SIngo Weinhold bool fShuttingDown; 130323b6546SOliver Tappe BPath fSystemAppPath; 131323b6546SOliver Tappe BPath fSystemServerPath; 132f9fd58ccSIngo Weinhold }; 133f9fd58ccSIngo Weinhold 134f9fd58ccSIngo Weinhold #endif // T_ROSTER_H 135