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 14*c2073305SAugustin Cavalier #include <HashSet.h> 15*c2073305SAugustin Cavalier #include <HashMap.h> 16c2f641f2SAxel Dörfler #include <Locker.h> 17c2f641f2SAxel Dörfler #include <MessageQueue.h> 18323b6546SOliver Tappe #include <Path.h> 19c8e7c8efSAxel Dörfler #include <Roster.h> 20c2f641f2SAxel Dörfler #include <SupportDefs.h> 21c2f641f2SAxel Dörfler 22c2f641f2SAxel Dörfler #include <map> 23c2f641f2SAxel Dörfler 24c2f641f2SAxel Dörfler 25758b1d0eSIngo Weinhold using std::map; 26758b1d0eSIngo Weinhold 27f9fd58ccSIngo Weinhold class BMessage; 287a0335c8SIngo Weinhold class WatchingService; 29f9fd58ccSIngo Weinhold 306bfd06d1SIngo Weinhold typedef map<int32, BMessageQueue*> IARRequestMap; 311d32138dSIngo Weinhold 32f9fd58ccSIngo Weinhold class TRoster { 33f9fd58ccSIngo Weinhold public: 34f9fd58ccSIngo Weinhold TRoster(); 35f9fd58ccSIngo Weinhold virtual ~TRoster(); 36f9fd58ccSIngo Weinhold 371d32138dSIngo Weinhold void HandleAddApplication(BMessage* request); 381d32138dSIngo Weinhold void HandleCompleteRegistration(BMessage* request); 396bfd06d1SIngo Weinhold void HandleIsAppRegistered(BMessage* request); 401d32138dSIngo Weinhold void HandleRemovePreRegApp(BMessage* request); 411d32138dSIngo Weinhold void HandleRemoveApp(BMessage* request); 421d32138dSIngo Weinhold void HandleSetThreadAndTeam(BMessage* request); 43af8eec40SIngo Weinhold void HandleSetSignature(BMessage* request); 44a12aef2bSIngo Weinhold void HandleGetAppInfo(BMessage* request); 45a12aef2bSIngo Weinhold void HandleGetAppList(BMessage* request); 46c2f641f2SAxel Dörfler void HandleUpdateActiveApp(BMessage* request); 4756d4d637SIngo Weinhold void HandleBroadcast(BMessage* request); 487a0335c8SIngo Weinhold void HandleStartWatching(BMessage* request); 497a0335c8SIngo Weinhold void HandleStopWatching(BMessage* request); 50230719b5STyler Dauwalder void HandleGetRecentDocuments(BMessage* request); 51230719b5STyler Dauwalder void HandleGetRecentFolders(BMessage* request); 52230719b5STyler Dauwalder void HandleGetRecentApps(BMessage* request); 53230719b5STyler Dauwalder void HandleAddToRecentDocuments(BMessage* request); 54230719b5STyler Dauwalder void HandleAddToRecentFolders(BMessage* request); 55230719b5STyler Dauwalder void HandleAddToRecentApps(BMessage* request); 561bde02aeSTyler Dauwalder void HandleLoadRecentLists(BMessage* request); 571bde02aeSTyler Dauwalder void HandleSaveRecentLists(BMessage* request); 581bde02aeSTyler Dauwalder 5904209cddSczeidler void HandleRestartAppServer(BMessage* request); 6004209cddSczeidler 611bde02aeSTyler Dauwalder void ClearRecentDocuments(); 621bde02aeSTyler Dauwalder void ClearRecentFolders(); 631bde02aeSTyler Dauwalder void ClearRecentApps(); 64a12aef2bSIngo Weinhold 655e949b7dSIngo Weinhold status_t Init(); 665e949b7dSIngo Weinhold 67a12aef2bSIngo Weinhold status_t AddApp(RosterAppInfo* info); 68a12aef2bSIngo Weinhold void RemoveApp(RosterAppInfo* info); 69c2f641f2SAxel Dörfler void UpdateActiveApp(RosterAppInfo* info); 70f9fd58ccSIngo Weinhold 71b48b6fb5SIngo Weinhold void CheckSanity(); 72b48b6fb5SIngo Weinhold 73553ea301SIngo Weinhold void SetShuttingDown(bool shuttingDown); 74c8e7c8efSAxel Dörfler status_t GetShutdownApps(AppInfoList& userApps, 75c8e7c8efSAxel Dörfler AppInfoList& systemApps, 76c8e7c8efSAxel Dörfler AppInfoList& backgroundApps, 77*c2073305SAugustin Cavalier HashSet<HashKey32<team_id> >& vitalSystemApps); 786899a856SJérôme Duval status_t AddAppInfo(AppInfoList& apps, team_id team); 79553ea301SIngo Weinhold 80553ea301SIngo Weinhold status_t AddWatcher(Watcher* watcher); 81553ea301SIngo Weinhold void RemoveWatcher(Watcher* watcher); 82553ea301SIngo Weinhold 83f9fd58ccSIngo Weinhold private: 84a12aef2bSIngo Weinhold // hook functions 85a12aef2bSIngo Weinhold void _AppAdded(RosterAppInfo* info); 86a12aef2bSIngo Weinhold void _AppRemoved(RosterAppInfo* info); 87a12aef2bSIngo Weinhold void _AppActivated(RosterAppInfo* info); 88a12aef2bSIngo Weinhold void _AppDeactivated(RosterAppInfo* info); 89a12aef2bSIngo Weinhold 90a12aef2bSIngo Weinhold // helper functions 91c8e7c8efSAxel Dörfler static status_t _AddMessageAppInfo(BMessage* message, 92c8e7c8efSAxel Dörfler const app_info* info); 937a0335c8SIngo Weinhold static status_t _AddMessageWatchingInfo(BMessage* message, 947a0335c8SIngo Weinhold const app_info* info); 951d32138dSIngo Weinhold uint32 _NextToken(); 966bfd06d1SIngo Weinhold 97c8e7c8efSAxel Dörfler void _AddIARRequest(IARRequestMap& map, int32 key, 98c8e7c8efSAxel Dörfler BMessage* request); 996bfd06d1SIngo Weinhold void _ReplyToIARRequests(BMessageQueue* requests, 1006bfd06d1SIngo Weinhold const RosterAppInfo* info); 101c8e7c8efSAxel Dörfler void _ReplyToIARRequest(BMessage* request, 102c8e7c8efSAxel Dörfler const RosterAppInfo* info); 1031d32138dSIngo Weinhold 104fde0f1b8STyler Dauwalder void _HandleGetRecentEntries(BMessage* request); 105fde0f1b8STyler Dauwalder 106c8e7c8efSAxel Dörfler void _ValidateRunning(const entry_ref& ref, 107c8e7c8efSAxel Dörfler const char* signature); 108553ea301SIngo Weinhold bool _IsSystemApp(RosterAppInfo* info) const; 109553ea301SIngo Weinhold 1104f03f5d2STyler Dauwalder status_t _LoadRosterSettings(const char* path = NULL); 1114f03f5d2STyler Dauwalder status_t _SaveRosterSettings(const char* path = NULL); 1124f03f5d2STyler Dauwalder static const char* kDefaultRosterSettingsFile; 1134f03f5d2STyler Dauwalder 1141d32138dSIngo Weinhold private: 115553ea301SIngo Weinhold BLocker fLock; 1161d32138dSIngo Weinhold AppInfoList fRegisteredApps; 1171d32138dSIngo Weinhold AppInfoList fEarlyPreRegisteredApps; 1186bfd06d1SIngo Weinhold IARRequestMap fIARRequestsByID; 1196bfd06d1SIngo Weinhold IARRequestMap fIARRequestsByToken; 120a12aef2bSIngo Weinhold RosterAppInfo* fActiveApp; 1217a0335c8SIngo Weinhold WatchingService fWatchingService; 122230719b5STyler Dauwalder RecentApps fRecentApps; 123fde0f1b8STyler Dauwalder RecentEntries fRecentDocuments; 124fde0f1b8STyler Dauwalder RecentEntries fRecentFolders; 1251d32138dSIngo Weinhold uint32 fLastToken; 126553ea301SIngo Weinhold bool fShuttingDown; 127323b6546SOliver Tappe BPath fSystemAppPath; 128323b6546SOliver Tappe BPath fSystemServerPath; 129f9fd58ccSIngo Weinhold }; 130f9fd58ccSIngo Weinhold 131f9fd58ccSIngo Weinhold #endif // T_ROSTER_H 132