1*c2f641f2SAxel Dörfler /* 2*c2f641f2SAxel Dörfler * Copyright 2001-2007, Ingo Weinhold, bonefish@users.sf.net. 3*c2f641f2SAxel Dörfler * Distributed under the terms of the MIT License. 4*c2f641f2SAxel 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*c2f641f2SAxel Dörfler #include <Locker.h> 15*c2f641f2SAxel Dörfler #include <MessageQueue.h> 16*c2f641f2SAxel Dörfler #include <SupportDefs.h> 17*c2f641f2SAxel Dörfler 18*c2f641f2SAxel Dörfler #include <hash_set> 19*c2f641f2SAxel Dörfler #include <map> 20*c2f641f2SAxel Dörfler 21*c2f641f2SAxel Dörfler 22758b1d0eSIngo Weinhold #if __GNUC__ >= 4 23758b1d0eSIngo Weinhold using __gnu_cxx::hash_set; 24758b1d0eSIngo Weinhold #endif 25758b1d0eSIngo Weinhold 26758b1d0eSIngo Weinhold using std::map; 27758b1d0eSIngo Weinhold 28f9fd58ccSIngo Weinhold class BMessage; 297a0335c8SIngo Weinhold class WatchingService; 30f9fd58ccSIngo Weinhold 316bfd06d1SIngo Weinhold typedef map<int32, BMessageQueue*> IARRequestMap; 321d32138dSIngo Weinhold 33f9fd58ccSIngo Weinhold class TRoster { 34f9fd58ccSIngo Weinhold public: 35f9fd58ccSIngo Weinhold TRoster(); 36f9fd58ccSIngo Weinhold virtual ~TRoster(); 37f9fd58ccSIngo Weinhold 381d32138dSIngo Weinhold void HandleAddApplication(BMessage *request); 391d32138dSIngo Weinhold void HandleCompleteRegistration(BMessage *request); 406bfd06d1SIngo Weinhold void HandleIsAppRegistered(BMessage *request); 411d32138dSIngo Weinhold void HandleRemovePreRegApp(BMessage *request); 421d32138dSIngo Weinhold void HandleRemoveApp(BMessage *request); 431d32138dSIngo Weinhold void HandleSetThreadAndTeam(BMessage *request); 44af8eec40SIngo Weinhold void HandleSetSignature(BMessage *request); 45a12aef2bSIngo Weinhold void HandleGetAppInfo(BMessage *request); 46a12aef2bSIngo Weinhold void HandleGetAppList(BMessage *request); 47*c2f641f2SAxel Dörfler void HandleUpdateActiveApp(BMessage *request); 4856d4d637SIngo Weinhold void HandleBroadcast(BMessage *request); 497a0335c8SIngo Weinhold void HandleStartWatching(BMessage *request); 507a0335c8SIngo Weinhold void HandleStopWatching(BMessage *request); 51230719b5STyler Dauwalder void HandleGetRecentDocuments(BMessage *request); 52230719b5STyler Dauwalder void HandleGetRecentFolders(BMessage *request); 53230719b5STyler Dauwalder void HandleGetRecentApps(BMessage *request); 54230719b5STyler Dauwalder void HandleAddToRecentDocuments(BMessage *request); 55230719b5STyler Dauwalder void HandleAddToRecentFolders(BMessage *request); 56230719b5STyler Dauwalder void HandleAddToRecentApps(BMessage *request); 571bde02aeSTyler Dauwalder void HandleLoadRecentLists(BMessage *request); 581bde02aeSTyler Dauwalder void HandleSaveRecentLists(BMessage *request); 591bde02aeSTyler Dauwalder 601bde02aeSTyler Dauwalder void ClearRecentDocuments(); 611bde02aeSTyler Dauwalder void ClearRecentFolders(); 621bde02aeSTyler Dauwalder void ClearRecentApps(); 63a12aef2bSIngo Weinhold 645e949b7dSIngo Weinhold status_t Init(); 655e949b7dSIngo Weinhold 66a12aef2bSIngo Weinhold status_t AddApp(RosterAppInfo *info); 67a12aef2bSIngo Weinhold void RemoveApp(RosterAppInfo *info); 68*c2f641f2SAxel Dörfler void UpdateActiveApp(RosterAppInfo *info); 69f9fd58ccSIngo Weinhold 70b48b6fb5SIngo Weinhold void CheckSanity(); 71b48b6fb5SIngo Weinhold 72553ea301SIngo Weinhold void SetShuttingDown(bool shuttingDown); 73553ea301SIngo Weinhold status_t GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps, 74252f4767SRyan Leavengood AppInfoList &backgroundApps, hash_set<team_id> &vitalSystemApps); 75553ea301SIngo Weinhold 76553ea301SIngo Weinhold status_t AddWatcher(Watcher *watcher); 77553ea301SIngo Weinhold void RemoveWatcher(Watcher *watcher); 78553ea301SIngo Weinhold 79f9fd58ccSIngo Weinhold private: 80a12aef2bSIngo Weinhold // hook functions 81a12aef2bSIngo Weinhold void _AppAdded(RosterAppInfo *info); 82a12aef2bSIngo Weinhold void _AppRemoved(RosterAppInfo *info); 83a12aef2bSIngo Weinhold void _AppActivated(RosterAppInfo *info); 84a12aef2bSIngo Weinhold void _AppDeactivated(RosterAppInfo *info); 85a12aef2bSIngo Weinhold 86a12aef2bSIngo Weinhold // helper functions 871d32138dSIngo Weinhold static status_t _AddMessageAppInfo(BMessage *message, 881d32138dSIngo Weinhold const app_info *info); 897a0335c8SIngo Weinhold static status_t _AddMessageWatchingInfo(BMessage *message, 907a0335c8SIngo Weinhold const app_info *info); 911d32138dSIngo Weinhold uint32 _NextToken(); 926bfd06d1SIngo Weinhold 936bfd06d1SIngo Weinhold void _AddIARRequest(IARRequestMap& map, int32 key, BMessage* request); 946bfd06d1SIngo Weinhold void _ReplyToIARRequests(BMessageQueue *requests, 956bfd06d1SIngo Weinhold const RosterAppInfo *info); 966bfd06d1SIngo Weinhold void _ReplyToIARRequest(BMessage *request, const RosterAppInfo *info); 971d32138dSIngo Weinhold 98fde0f1b8STyler Dauwalder void _HandleGetRecentEntries(BMessage *request); 99fde0f1b8STyler Dauwalder 100553ea301SIngo Weinhold bool _IsSystemApp(RosterAppInfo *info) const; 101553ea301SIngo Weinhold 1024f03f5d2STyler Dauwalder status_t _LoadRosterSettings(const char *path = NULL); 1034f03f5d2STyler Dauwalder status_t _SaveRosterSettings(const char *path = NULL); 1044f03f5d2STyler Dauwalder static const char *kDefaultRosterSettingsFile; 1054f03f5d2STyler Dauwalder 1061d32138dSIngo Weinhold private: 107553ea301SIngo Weinhold BLocker fLock; 1081d32138dSIngo Weinhold AppInfoList fRegisteredApps; 1091d32138dSIngo Weinhold AppInfoList fEarlyPreRegisteredApps; 1106bfd06d1SIngo Weinhold IARRequestMap fIARRequestsByID; 1116bfd06d1SIngo Weinhold IARRequestMap fIARRequestsByToken; 112a12aef2bSIngo Weinhold RosterAppInfo *fActiveApp; 1137a0335c8SIngo Weinhold WatchingService fWatchingService; 114230719b5STyler Dauwalder RecentApps fRecentApps; 115fde0f1b8STyler Dauwalder RecentEntries fRecentDocuments; 116fde0f1b8STyler Dauwalder RecentEntries fRecentFolders; 1171d32138dSIngo Weinhold uint32 fLastToken; 118553ea301SIngo Weinhold bool fShuttingDown; 119f9fd58ccSIngo Weinhold }; 120f9fd58ccSIngo Weinhold 121f9fd58ccSIngo Weinhold #endif // T_ROSTER_H 122