diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llgroupmgr.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llgroupmgr.h | 362 |
1 files changed, 362 insertions, 0 deletions
diff --git a/linden/indra/newview/llgroupmgr.h b/linden/indra/newview/llgroupmgr.h new file mode 100644 index 0000000..506f4e6 --- /dev/null +++ b/linden/indra/newview/llgroupmgr.h | |||
@@ -0,0 +1,362 @@ | |||
1 | /** | ||
2 | * @file llgroupmgr.h | ||
3 | * @brief Manager for aggregating all client knowledge for specific groups | ||
4 | * | ||
5 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLGROUPMGR_H | ||
29 | #define LL_LLGROUPMGR_H | ||
30 | |||
31 | #include "lluuid.h" | ||
32 | #include "roles_constants.h" | ||
33 | #include <vector> | ||
34 | #include <string> | ||
35 | #include <map> | ||
36 | |||
37 | class LLMessageSystem; | ||
38 | |||
39 | class LLGroupMgrObserver | ||
40 | { | ||
41 | public: | ||
42 | LLGroupMgrObserver(const LLUUID& id) : mID(id){}; | ||
43 | virtual ~LLGroupMgrObserver(){}; | ||
44 | virtual void changed(LLGroupChange gc) = 0; | ||
45 | const LLUUID& getID() { return mID; } | ||
46 | protected: | ||
47 | LLUUID mID; | ||
48 | }; | ||
49 | |||
50 | class LLGroupRoleData; | ||
51 | |||
52 | class LLGroupMemberData | ||
53 | { | ||
54 | friend class LLGroupMgrGroupData; | ||
55 | |||
56 | public: | ||
57 | LLGroupMemberData(const LLUUID& id, | ||
58 | S32 contribution, | ||
59 | U64 agent_powers, | ||
60 | const std::string& title, | ||
61 | const std::string& online_status, | ||
62 | BOOL is_owner); | ||
63 | |||
64 | ~LLGroupMemberData(); | ||
65 | |||
66 | const LLUUID& getID() const { return mID; } | ||
67 | S32 getContribution() const { return mContribution; } | ||
68 | U64 getAgentPowers() const { return mAgentPowers; } | ||
69 | BOOL isOwner() const { return mIsOwner; } | ||
70 | const std::string& getTitle() const { return mTitle; } | ||
71 | const std::string& getOnlineStatus() const { return mOnlineStatus; } | ||
72 | void addRole(const LLUUID& role, LLGroupRoleData* rd); | ||
73 | bool removeRole(const LLUUID& role); | ||
74 | void clearRoles() { mRoles.clear(); }; | ||
75 | std::map<LLUUID,LLGroupRoleData*>::iterator roleBegin() { return mRoles.begin(); } | ||
76 | std::map<LLUUID,LLGroupRoleData*>::iterator roleEnd() { return mRoles.end(); } | ||
77 | |||
78 | BOOL isInRole(const LLUUID& role_id) { return (mRoles.find(role_id) != mRoles.end()); } | ||
79 | |||
80 | protected: | ||
81 | LLUUID mID; | ||
82 | S32 mContribution; | ||
83 | U64 mAgentPowers; | ||
84 | std::string mTitle; | ||
85 | std::string mOnlineStatus; | ||
86 | BOOL mIsOwner; | ||
87 | std::map<LLUUID,LLGroupRoleData*> mRoles; | ||
88 | }; | ||
89 | |||
90 | struct LLRoleData | ||
91 | { | ||
92 | LLRoleData() : mRolePowers(0), mChangeType(RC_UPDATE_NONE) { } | ||
93 | LLRoleData(const LLRoleData& rd) | ||
94 | : mRoleName(rd.mRoleName), | ||
95 | mRoleTitle(rd.mRoleTitle), | ||
96 | mRoleDescription(rd.mRoleDescription), | ||
97 | mRolePowers(rd.mRolePowers), | ||
98 | mChangeType(rd.mChangeType) { } | ||
99 | |||
100 | std::string mRoleName; | ||
101 | std::string mRoleTitle; | ||
102 | std::string mRoleDescription; | ||
103 | U64 mRolePowers; | ||
104 | LLRoleChangeType mChangeType; | ||
105 | }; | ||
106 | |||
107 | class LLGroupRoleData | ||
108 | { | ||
109 | friend class LLGroupMgrGroupData; | ||
110 | |||
111 | public: | ||
112 | LLGroupRoleData(const LLUUID& role_id, | ||
113 | const std::string& role_name, | ||
114 | const std::string& role_title, | ||
115 | const std::string& role_desc, | ||
116 | const U64 role_powers, | ||
117 | const S32 member_count); | ||
118 | |||
119 | LLGroupRoleData(const LLUUID& role_id, | ||
120 | LLRoleData role_data, | ||
121 | const S32 member_count); | ||
122 | |||
123 | ~LLGroupRoleData(); | ||
124 | |||
125 | const LLUUID& getID() const { return mRoleID; } | ||
126 | |||
127 | const std::vector<LLUUID>& getRoleMembers() const { return mMemberIDs; } | ||
128 | S32 getMembersInRole(std::vector<LLUUID> members, BOOL needs_sort = TRUE); | ||
129 | S32 getTotalMembersInRole() { return mMemberIDs.size(); } | ||
130 | |||
131 | LLRoleData getRoleData() const { return mRoleData; } | ||
132 | void setRoleData(LLRoleData data) { mRoleData = data; } | ||
133 | |||
134 | void addMember(const LLUUID& member); | ||
135 | bool removeMember(const LLUUID& member); | ||
136 | void clearMembers(); | ||
137 | |||
138 | const std::vector<LLUUID>::const_iterator getMembersBegin() const | ||
139 | { return mMemberIDs.begin(); } | ||
140 | |||
141 | const std::vector<LLUUID>::const_iterator getMembersEnd() const | ||
142 | { return mMemberIDs.end(); } | ||
143 | |||
144 | |||
145 | protected: | ||
146 | LLGroupRoleData() | ||
147 | : mMemberCount(0), mMembersNeedsSort(FALSE) {} | ||
148 | |||
149 | LLUUID mRoleID; | ||
150 | LLRoleData mRoleData; | ||
151 | |||
152 | std::vector<LLUUID> mMemberIDs; | ||
153 | S32 mMemberCount; | ||
154 | |||
155 | private: | ||
156 | BOOL mMembersNeedsSort; | ||
157 | }; | ||
158 | |||
159 | struct LLRoleMemberChange | ||
160 | { | ||
161 | LLRoleMemberChange() : mChange(RMC_NONE) { } | ||
162 | LLRoleMemberChange(const LLUUID& role, const LLUUID& member, LLRoleMemberChangeType change) | ||
163 | : mRole(role), mMember(member), mChange(change) { } | ||
164 | LLRoleMemberChange(const LLRoleMemberChange& rc) | ||
165 | : mRole(rc.mRole), mMember(rc.mMember), mChange(rc.mChange) { } | ||
166 | LLUUID mRole; | ||
167 | LLUUID mMember; | ||
168 | LLRoleMemberChangeType mChange; | ||
169 | }; | ||
170 | |||
171 | typedef std::pair<LLUUID,LLUUID> lluuid_pair; | ||
172 | |||
173 | struct lluuid_pair_less | ||
174 | { | ||
175 | bool operator()(const lluuid_pair& lhs, const lluuid_pair& rhs) const | ||
176 | { | ||
177 | if (lhs.first == rhs.first) | ||
178 | return lhs.second < rhs.second; | ||
179 | else | ||
180 | return lhs.first < rhs.first; | ||
181 | } | ||
182 | }; | ||
183 | |||
184 | typedef std::map<lluuid_pair,LLRoleMemberChange,lluuid_pair_less> change_map; | ||
185 | |||
186 | struct LLGroupTitle | ||
187 | { | ||
188 | std::string mTitle; | ||
189 | LLUUID mRoleID; | ||
190 | BOOL mSelected; | ||
191 | }; | ||
192 | |||
193 | class LLGroupMgr; | ||
194 | |||
195 | class LLGroupMgrGroupData | ||
196 | { | ||
197 | friend class LLGroupMgr; | ||
198 | |||
199 | public: | ||
200 | LLGroupMgrGroupData(const LLUUID& id); | ||
201 | ~LLGroupMgrGroupData(); | ||
202 | |||
203 | const LLUUID& getID() { return mID; } | ||
204 | |||
205 | BOOL getRoleData(const LLUUID& role_id, LLRoleData& role_data); | ||
206 | void setRoleData(const LLUUID& role_id, LLRoleData role_data); | ||
207 | void createRole(const LLUUID& role_id, LLRoleData role_data); | ||
208 | void deleteRole(const LLUUID& role_id); | ||
209 | BOOL pendingRoleChanges(); | ||
210 | |||
211 | void addRolePower(const LLUUID& role_id, U64 power); | ||
212 | void removeRolePower(const LLUUID& role_id, U64 power); | ||
213 | U64 getRolePowers(const LLUUID& role_id); | ||
214 | |||
215 | void removeData(); | ||
216 | void removeRoleData(); | ||
217 | void removeMemberData(); | ||
218 | void removeRoleMemberData(); | ||
219 | |||
220 | bool changeRoleMember(const LLUUID& role_id, const LLUUID& member_id, LLRoleMemberChangeType rmc); | ||
221 | void recalcAllAgentPowers(); | ||
222 | void recalcAgentPowers(const LLUUID& agent_id); | ||
223 | |||
224 | BOOL isMemberDataComplete() { return mMemberDataComplete; } | ||
225 | BOOL isRoleDataComplete() { return mRoleDataComplete; } | ||
226 | BOOL isRoleMemberDataComplete() { return mRoleMemberDataComplete; } | ||
227 | BOOL isGroupPropertiesDataComplete() { return mGroupPropertiesDataComplete; } | ||
228 | |||
229 | public: | ||
230 | typedef std::map<LLUUID,LLGroupMemberData*> member_list; | ||
231 | typedef member_list::iterator member_iter; | ||
232 | typedef std::map<LLUUID,LLGroupRoleData*> role_list; | ||
233 | typedef role_list::iterator role_iter; | ||
234 | |||
235 | member_list mMembers; | ||
236 | role_list mRoles; | ||
237 | |||
238 | |||
239 | change_map mRoleMemberChanges; | ||
240 | std::map<LLUUID,LLRoleData> mRoleChanges; | ||
241 | |||
242 | std::vector<LLGroupTitle> mTitles; | ||
243 | |||
244 | LLUUID mID; | ||
245 | LLUUID mOwnerRole; | ||
246 | std::string mName; | ||
247 | std::string mCharter; | ||
248 | BOOL mShowInList; | ||
249 | LLUUID mInsigniaID; | ||
250 | LLUUID mFounderID; | ||
251 | BOOL mOpenEnrollment; | ||
252 | S32 mMembershipFee; | ||
253 | BOOL mAllowPublish; | ||
254 | BOOL mMaturePublish; | ||
255 | BOOL mChanged; | ||
256 | S32 mMemberCount; | ||
257 | S32 mRoleCount; | ||
258 | |||
259 | protected: | ||
260 | void sendRoleChanges(); | ||
261 | void cancelRoleChanges(); | ||
262 | |||
263 | private: | ||
264 | LLUUID mMemberRequestID; | ||
265 | LLUUID mRoleDataRequestID; | ||
266 | LLUUID mRoleMembersRequestID; | ||
267 | LLUUID mTitlesRequestID; | ||
268 | U32 mReceivedRoleMemberPairs; | ||
269 | |||
270 | BOOL mMemberDataComplete; | ||
271 | BOOL mRoleDataComplete; | ||
272 | BOOL mRoleMemberDataComplete; | ||
273 | BOOL mGroupPropertiesDataComplete; | ||
274 | |||
275 | BOOL mPendingRoleMemberRequest; | ||
276 | }; | ||
277 | |||
278 | struct LLRoleAction | ||
279 | { | ||
280 | std::string mName; | ||
281 | std::string mDescription; | ||
282 | std::string mLongDescription; | ||
283 | U64 mPowerBit; | ||
284 | }; | ||
285 | |||
286 | struct LLRoleActionSet | ||
287 | { | ||
288 | LLRoleActionSet(); | ||
289 | ~LLRoleActionSet(); | ||
290 | LLRoleAction* mActionSetData; | ||
291 | std::vector<LLRoleAction*> mActions; | ||
292 | }; | ||
293 | |||
294 | class LLGroupMgr | ||
295 | { | ||
296 | public: | ||
297 | LLGroupMgr(); | ||
298 | ~LLGroupMgr(); | ||
299 | |||
300 | void addObserver(LLGroupMgrObserver* observer); | ||
301 | void removeObserver(LLGroupMgrObserver* observer); | ||
302 | LLGroupMgrGroupData* getGroupData(const LLUUID& id); | ||
303 | |||
304 | void sendGroupPropertiesRequest(const LLUUID& group_id); | ||
305 | void sendGroupRoleDataRequest(const LLUUID& group_id); | ||
306 | void sendGroupRoleMembersRequest(const LLUUID& group_id); | ||
307 | void sendGroupMembersRequest(const LLUUID& group_id); | ||
308 | void sendGroupTitlesRequest(const LLUUID& group_id); | ||
309 | void sendGroupTitleUpdate(const LLUUID& group_id, const LLUUID& title_role_id); | ||
310 | void sendUpdateGroupInfo(const LLUUID& group_id); | ||
311 | void sendGroupRoleMemberChanges(const LLUUID& group_id); | ||
312 | void sendGroupRoleChanges(const LLUUID& group_id); | ||
313 | |||
314 | static void sendCreateGroupRequest(const std::string& name, | ||
315 | const std::string& charter, | ||
316 | U8 show_in_list, | ||
317 | const LLUUID& insignia, | ||
318 | S32 membership_fee, | ||
319 | BOOL open_enrollment, | ||
320 | BOOL allow_publish, | ||
321 | BOOL mature_publish); | ||
322 | |||
323 | static void sendGroupMemberJoin(const LLUUID& group_id); | ||
324 | static void sendGroupMemberInvites(const LLUUID& group_id, std::map<LLUUID,LLUUID>& role_member_pairs); | ||
325 | static void sendGroupMemberEjects(const LLUUID& group_id, | ||
326 | std::vector<LLUUID>& member_ids); | ||
327 | |||
328 | void cancelGroupRoleChanges(const LLUUID& group_id); | ||
329 | |||
330 | static void processGroupPropertiesReply(LLMessageSystem* msg, void** data); | ||
331 | static void processGroupMembersReply(LLMessageSystem* msg, void** data); | ||
332 | static void processGroupRoleDataReply(LLMessageSystem* msg, void** data); | ||
333 | static void processGroupRoleMembersReply(LLMessageSystem* msg, void** data); | ||
334 | static void processGroupTitlesReply(LLMessageSystem* msg, void** data); | ||
335 | static void processCreateGroupReply(LLMessageSystem* msg, void** data); | ||
336 | static void processJoinGroupReply(LLMessageSystem* msg, void ** data); | ||
337 | static void processEjectGroupMemberReply(LLMessageSystem* msg, void ** data); | ||
338 | static void processLeaveGroupReply(LLMessageSystem* msg, void ** data); | ||
339 | |||
340 | static bool parseRoleActions(const LLString& xml_filename); | ||
341 | |||
342 | std::vector<LLRoleActionSet*> mRoleActionSets; | ||
343 | |||
344 | static void debugClearAllGroups(void*); | ||
345 | void clearGroups(); | ||
346 | void clearGroupData(const LLUUID& group_id); | ||
347 | protected: | ||
348 | void notifyObservers(LLGroupChange gc); | ||
349 | void addGroup(LLGroupMgrGroupData* group_datap); | ||
350 | LLGroupMgrGroupData* createGroupData(const LLUUID &id); | ||
351 | |||
352 | protected: | ||
353 | typedef std::multimap<LLUUID,LLGroupMgrObserver*>::iterator observer_iter; | ||
354 | std::multimap<LLUUID,LLGroupMgrObserver*> mObservers; | ||
355 | typedef std::map<LLUUID, LLGroupMgrGroupData*>::iterator group_iter; | ||
356 | std::map<LLUUID, LLGroupMgrGroupData*> mGroups; | ||
357 | }; | ||
358 | |||
359 | extern LLGroupMgr* gGroupMgr; | ||
360 | |||
361 | #endif | ||
362 | |||