vfs: check userland buffers before reading them.
[haiku.git] / src / servers / registrar / TRoster.h
bloba9303f7811b869d0c3854c4e19459ca5d1a66a6d
1 /*
2 * Copyright 2001-2007, Ingo Weinhold, bonefish@users.sf.net.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef T_ROSTER_H
6 #define T_ROSTER_H
9 #include "AppInfoList.h"
10 #include "RecentApps.h"
11 #include "RecentEntries.h"
12 #include "WatchingService.h"
14 #include <Locker.h>
15 #include <MessageQueue.h>
16 #include <Path.h>
17 #include <Roster.h>
18 #include <SupportDefs.h>
20 #include <hash_set>
21 #include <map>
24 #if __GNUC__ >= 4
25 using __gnu_cxx::hash_set;
26 #endif
28 using std::map;
30 class BMessage;
31 class WatchingService;
33 typedef map<int32, BMessageQueue*> IARRequestMap;
35 class TRoster {
36 public:
37 TRoster();
38 virtual ~TRoster();
40 void HandleAddApplication(BMessage* request);
41 void HandleCompleteRegistration(BMessage* request);
42 void HandleIsAppRegistered(BMessage* request);
43 void HandleRemovePreRegApp(BMessage* request);
44 void HandleRemoveApp(BMessage* request);
45 void HandleSetThreadAndTeam(BMessage* request);
46 void HandleSetSignature(BMessage* request);
47 void HandleGetAppInfo(BMessage* request);
48 void HandleGetAppList(BMessage* request);
49 void HandleUpdateActiveApp(BMessage* request);
50 void HandleBroadcast(BMessage* request);
51 void HandleStartWatching(BMessage* request);
52 void HandleStopWatching(BMessage* request);
53 void HandleGetRecentDocuments(BMessage* request);
54 void HandleGetRecentFolders(BMessage* request);
55 void HandleGetRecentApps(BMessage* request);
56 void HandleAddToRecentDocuments(BMessage* request);
57 void HandleAddToRecentFolders(BMessage* request);
58 void HandleAddToRecentApps(BMessage* request);
59 void HandleLoadRecentLists(BMessage* request);
60 void HandleSaveRecentLists(BMessage* request);
62 void HandleRestartAppServer(BMessage* request);
64 void ClearRecentDocuments();
65 void ClearRecentFolders();
66 void ClearRecentApps();
68 status_t Init();
70 status_t AddApp(RosterAppInfo* info);
71 void RemoveApp(RosterAppInfo* info);
72 void UpdateActiveApp(RosterAppInfo* info);
74 void CheckSanity();
76 void SetShuttingDown(bool shuttingDown);
77 status_t GetShutdownApps(AppInfoList& userApps,
78 AppInfoList& systemApps,
79 AppInfoList& backgroundApps,
80 hash_set<team_id>& vitalSystemApps);
82 status_t AddWatcher(Watcher* watcher);
83 void RemoveWatcher(Watcher* watcher);
85 private:
86 // hook functions
87 void _AppAdded(RosterAppInfo* info);
88 void _AppRemoved(RosterAppInfo* info);
89 void _AppActivated(RosterAppInfo* info);
90 void _AppDeactivated(RosterAppInfo* info);
92 // helper functions
93 static status_t _AddMessageAppInfo(BMessage* message,
94 const app_info* info);
95 static status_t _AddMessageWatchingInfo(BMessage* message,
96 const app_info* info);
97 uint32 _NextToken();
99 void _AddIARRequest(IARRequestMap& map, int32 key,
100 BMessage* request);
101 void _ReplyToIARRequests(BMessageQueue* requests,
102 const RosterAppInfo* info);
103 void _ReplyToIARRequest(BMessage* request,
104 const RosterAppInfo* info);
106 void _HandleGetRecentEntries(BMessage* request);
108 void _ValidateRunning(const entry_ref& ref,
109 const char* signature);
110 bool _IsSystemApp(RosterAppInfo* info) const;
112 status_t _LoadRosterSettings(const char* path = NULL);
113 status_t _SaveRosterSettings(const char* path = NULL);
114 static const char* kDefaultRosterSettingsFile;
116 private:
117 BLocker fLock;
118 AppInfoList fRegisteredApps;
119 AppInfoList fEarlyPreRegisteredApps;
120 IARRequestMap fIARRequestsByID;
121 IARRequestMap fIARRequestsByToken;
122 RosterAppInfo* fActiveApp;
123 WatchingService fWatchingService;
124 RecentApps fRecentApps;
125 RecentEntries fRecentDocuments;
126 RecentEntries fRecentFolders;
127 uint32 fLastToken;
128 bool fShuttingDown;
129 BPath fSystemAppPath;
130 BPath fSystemServerPath;
133 #endif // T_ROSTER_H