diff options
Diffstat (limited to 'OpenSim/Addons/Groups/GroupsExtendedData.cs')
-rw-r--r-- | OpenSim/Addons/Groups/GroupsExtendedData.cs | 509 |
1 files changed, 509 insertions, 0 deletions
diff --git a/OpenSim/Addons/Groups/GroupsExtendedData.cs b/OpenSim/Addons/Groups/GroupsExtendedData.cs new file mode 100644 index 0000000..6f4db28 --- /dev/null +++ b/OpenSim/Addons/Groups/GroupsExtendedData.cs | |||
@@ -0,0 +1,509 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Groups | ||
35 | { | ||
36 | public class ExtendedGroupRecord : GroupRecord | ||
37 | { | ||
38 | public int MemberCount; | ||
39 | public int RoleCount; | ||
40 | public string ServiceLocation; | ||
41 | public string FounderUUI; | ||
42 | } | ||
43 | |||
44 | public class ExtendedGroupMembershipData : GroupMembershipData | ||
45 | { | ||
46 | public string AccessToken; | ||
47 | } | ||
48 | |||
49 | public class ExtendedGroupMembersData | ||
50 | { | ||
51 | // This is the only difference: this is a string | ||
52 | public string AgentID; | ||
53 | public int Contribution; | ||
54 | public string OnlineStatus; | ||
55 | public ulong AgentPowers; | ||
56 | public string Title; | ||
57 | public bool IsOwner; | ||
58 | public bool ListInProfile; | ||
59 | public bool AcceptNotices; | ||
60 | public string AccessToken; | ||
61 | } | ||
62 | |||
63 | public class ExtendedGroupRoleMembersData | ||
64 | { | ||
65 | public UUID RoleID; | ||
66 | // This is the only difference: this is a string | ||
67 | public string MemberID; | ||
68 | |||
69 | } | ||
70 | |||
71 | public struct ExtendedGroupNoticeData | ||
72 | { | ||
73 | public UUID NoticeID; | ||
74 | public uint Timestamp; | ||
75 | public string FromName; | ||
76 | public string Subject; | ||
77 | public bool HasAttachment; | ||
78 | public byte AttachmentType; | ||
79 | public string AttachmentName; | ||
80 | public UUID AttachmentItemID; | ||
81 | public string AttachmentOwnerID; | ||
82 | |||
83 | public GroupNoticeData ToGroupNoticeData() | ||
84 | { | ||
85 | GroupNoticeData n = new GroupNoticeData(); | ||
86 | n.FromName = this.FromName; | ||
87 | n.AssetType = this.AttachmentType; | ||
88 | n.HasAttachment = this.HasAttachment; | ||
89 | n.NoticeID = this.NoticeID; | ||
90 | n.Subject = this.Subject; | ||
91 | n.Timestamp = this.Timestamp; | ||
92 | |||
93 | return n; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public class GroupsDataUtils | ||
98 | { | ||
99 | public static string Sanitize(string s) | ||
100 | { | ||
101 | return s == null ? string.Empty : s; | ||
102 | } | ||
103 | |||
104 | public static Dictionary<string, object> GroupRecord(ExtendedGroupRecord grec) | ||
105 | { | ||
106 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
107 | if (grec == null) | ||
108 | return dict; | ||
109 | |||
110 | dict["AllowPublish"] = grec.AllowPublish.ToString(); | ||
111 | dict["Charter"] = Sanitize(grec.Charter); | ||
112 | dict["FounderID"] = grec.FounderID.ToString(); | ||
113 | dict["FounderUUI"] = Sanitize(grec.FounderUUI); | ||
114 | dict["GroupID"] = grec.GroupID.ToString(); | ||
115 | dict["GroupName"] = Sanitize(grec.GroupName); | ||
116 | dict["InsigniaID"] = grec.GroupPicture.ToString(); | ||
117 | dict["MaturePublish"] = grec.MaturePublish.ToString(); | ||
118 | dict["MembershipFee"] = grec.MembershipFee.ToString(); | ||
119 | dict["OpenEnrollment"] = grec.OpenEnrollment.ToString(); | ||
120 | dict["OwnerRoleID"] = grec.OwnerRoleID.ToString(); | ||
121 | dict["ServiceLocation"] = Sanitize(grec.ServiceLocation); | ||
122 | dict["ShownInList"] = grec.ShowInList.ToString(); | ||
123 | dict["MemberCount"] = grec.MemberCount.ToString(); | ||
124 | dict["RoleCount"] = grec.RoleCount.ToString(); | ||
125 | |||
126 | return dict; | ||
127 | } | ||
128 | |||
129 | public static ExtendedGroupRecord GroupRecord(Dictionary<string, object> dict) | ||
130 | { | ||
131 | if (dict == null) | ||
132 | return null; | ||
133 | |||
134 | ExtendedGroupRecord grec = new ExtendedGroupRecord(); | ||
135 | if (dict.ContainsKey("AllowPublish") && dict["AllowPublish"] != null) | ||
136 | grec.AllowPublish = bool.Parse(dict["AllowPublish"].ToString()); | ||
137 | |||
138 | if (dict.ContainsKey("Charter") && dict["Charter"] != null) | ||
139 | grec.Charter = dict["Charter"].ToString(); | ||
140 | else | ||
141 | grec.Charter = string.Empty; | ||
142 | |||
143 | if (dict.ContainsKey("FounderID") && dict["FounderID"] != null) | ||
144 | grec.FounderID = UUID.Parse(dict["FounderID"].ToString()); | ||
145 | |||
146 | if (dict.ContainsKey("FounderUUI") && dict["FounderUUI"] != null) | ||
147 | grec.FounderUUI = dict["FounderUUI"].ToString(); | ||
148 | else | ||
149 | grec.FounderUUI = string.Empty; | ||
150 | |||
151 | if (dict.ContainsKey("GroupID") && dict["GroupID"] != null) | ||
152 | grec.GroupID = UUID.Parse(dict["GroupID"].ToString()); | ||
153 | |||
154 | if (dict.ContainsKey("GroupName") && dict["GroupName"] != null) | ||
155 | grec.GroupName = dict["GroupName"].ToString(); | ||
156 | else | ||
157 | grec.GroupName = string.Empty; | ||
158 | |||
159 | if (dict.ContainsKey("InsigniaID") && dict["InsigniaID"] != null) | ||
160 | grec.GroupPicture = UUID.Parse(dict["InsigniaID"].ToString()); | ||
161 | |||
162 | if (dict.ContainsKey("MaturePublish") && dict["MaturePublish"] != null) | ||
163 | grec.MaturePublish = bool.Parse(dict["MaturePublish"].ToString()); | ||
164 | |||
165 | if (dict.ContainsKey("MembershipFee") && dict["MembershipFee"] != null) | ||
166 | grec.MembershipFee = Int32.Parse(dict["MembershipFee"].ToString()); | ||
167 | |||
168 | if (dict.ContainsKey("OpenEnrollment") && dict["OpenEnrollment"] != null) | ||
169 | grec.OpenEnrollment = bool.Parse(dict["OpenEnrollment"].ToString()); | ||
170 | |||
171 | if (dict.ContainsKey("OwnerRoleID") && dict["OwnerRoleID"] != null) | ||
172 | grec.OwnerRoleID = UUID.Parse(dict["OwnerRoleID"].ToString()); | ||
173 | |||
174 | if (dict.ContainsKey("ServiceLocation") && dict["ServiceLocation"] != null) | ||
175 | grec.ServiceLocation = dict["ServiceLocation"].ToString(); | ||
176 | else | ||
177 | grec.GroupName = string.Empty; | ||
178 | |||
179 | if (dict.ContainsKey("ShownInList") && dict["ShownInList"] != null) | ||
180 | grec.ShowInList = bool.Parse(dict["ShownInList"].ToString()); | ||
181 | |||
182 | if (dict.ContainsKey("MemberCount") && dict["MemberCount"] != null) | ||
183 | grec.MemberCount = Int32.Parse(dict["MemberCount"].ToString()); | ||
184 | |||
185 | if (dict.ContainsKey("RoleCount") && dict["RoleCount"] != null) | ||
186 | grec.RoleCount = Int32.Parse(dict["RoleCount"].ToString()); | ||
187 | |||
188 | return grec; | ||
189 | } | ||
190 | |||
191 | public static Dictionary<string, object> GroupMembershipData(ExtendedGroupMembershipData membership) | ||
192 | { | ||
193 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
194 | if (membership == null) | ||
195 | return dict; | ||
196 | |||
197 | dict["AcceptNotices"] = membership.AcceptNotices.ToString(); | ||
198 | dict["AccessToken"] = Sanitize(membership.AccessToken); | ||
199 | dict["Active"] = membership.Active.ToString(); | ||
200 | dict["ActiveRole"] = membership.ActiveRole.ToString(); | ||
201 | dict["AllowPublish"] = membership.AllowPublish.ToString(); | ||
202 | dict["Charter"] = Sanitize(membership.Charter); | ||
203 | dict["Contribution"] = membership.Contribution.ToString(); | ||
204 | dict["FounderID"] = membership.FounderID.ToString(); | ||
205 | dict["GroupID"] = membership.GroupID.ToString(); | ||
206 | dict["GroupName"] = Sanitize(membership.GroupName); | ||
207 | dict["GroupPicture"] = membership.GroupPicture.ToString(); | ||
208 | dict["GroupPowers"] = membership.GroupPowers.ToString(); | ||
209 | dict["GroupTitle"] = Sanitize(membership.GroupTitle); | ||
210 | dict["ListInProfile"] = membership.ListInProfile.ToString(); | ||
211 | dict["MaturePublish"] = membership.MaturePublish.ToString(); | ||
212 | dict["MembershipFee"] = membership.MembershipFee.ToString(); | ||
213 | dict["OpenEnrollment"] = membership.OpenEnrollment.ToString(); | ||
214 | dict["ShowInList"] = membership.ShowInList.ToString(); | ||
215 | |||
216 | return dict; | ||
217 | } | ||
218 | |||
219 | public static ExtendedGroupMembershipData GroupMembershipData(Dictionary<string, object> dict) | ||
220 | { | ||
221 | if (dict == null) | ||
222 | return null; | ||
223 | |||
224 | ExtendedGroupMembershipData membership = new ExtendedGroupMembershipData(); | ||
225 | |||
226 | if (dict.ContainsKey("AcceptNotices") && dict["AcceptNotices"] != null) | ||
227 | membership.AcceptNotices = bool.Parse(dict["AcceptNotices"].ToString()); | ||
228 | |||
229 | if (dict.ContainsKey("AccessToken") && dict["AccessToken"] != null) | ||
230 | membership.AccessToken = dict["AccessToken"].ToString(); | ||
231 | else | ||
232 | membership.AccessToken = string.Empty; | ||
233 | |||
234 | if (dict.ContainsKey("Active") && dict["Active"] != null) | ||
235 | membership.Active = bool.Parse(dict["Active"].ToString()); | ||
236 | |||
237 | if (dict.ContainsKey("ActiveRole") && dict["ActiveRole"] != null) | ||
238 | membership.ActiveRole = UUID.Parse(dict["ActiveRole"].ToString()); | ||
239 | |||
240 | if (dict.ContainsKey("AllowPublish") && dict["AllowPublish"] != null) | ||
241 | membership.AllowPublish = bool.Parse(dict["AllowPublish"].ToString()); | ||
242 | |||
243 | if (dict.ContainsKey("Charter") && dict["Charter"] != null) | ||
244 | membership.Charter = dict["Charter"].ToString(); | ||
245 | else | ||
246 | membership.Charter = string.Empty; | ||
247 | |||
248 | if (dict.ContainsKey("Contribution") && dict["Contribution"] != null) | ||
249 | membership.Contribution = Int32.Parse(dict["Contribution"].ToString()); | ||
250 | |||
251 | if (dict.ContainsKey("FounderID") && dict["FounderID"] != null) | ||
252 | membership.FounderID = UUID.Parse(dict["FounderID"].ToString()); | ||
253 | |||
254 | if (dict.ContainsKey("GroupID") && dict["GroupID"] != null) | ||
255 | membership.GroupID = UUID.Parse(dict["GroupID"].ToString()); | ||
256 | |||
257 | if (dict.ContainsKey("GroupName") && dict["GroupName"] != null) | ||
258 | membership.GroupName = dict["GroupName"].ToString(); | ||
259 | else | ||
260 | membership.GroupName = string.Empty; | ||
261 | |||
262 | if (dict.ContainsKey("GroupPicture") && dict["GroupPicture"] != null) | ||
263 | membership.GroupPicture = UUID.Parse(dict["GroupPicture"].ToString()); | ||
264 | |||
265 | if (dict.ContainsKey("GroupPowers") && dict["GroupPowers"] != null) | ||
266 | membership.GroupPowers = UInt64.Parse(dict["GroupPowers"].ToString()); | ||
267 | |||
268 | if (dict.ContainsKey("GroupTitle") && dict["GroupTitle"] != null) | ||
269 | membership.GroupTitle = dict["GroupTitle"].ToString(); | ||
270 | else | ||
271 | membership.GroupTitle = string.Empty; | ||
272 | |||
273 | if (dict.ContainsKey("ListInProfile") && dict["ListInProfile"] != null) | ||
274 | membership.ListInProfile = bool.Parse(dict["ListInProfile"].ToString()); | ||
275 | |||
276 | if (dict.ContainsKey("MaturePublish") && dict["MaturePublish"] != null) | ||
277 | membership.MaturePublish = bool.Parse(dict["MaturePublish"].ToString()); | ||
278 | |||
279 | if (dict.ContainsKey("MembershipFee") && dict["MembershipFee"] != null) | ||
280 | membership.MembershipFee = Int32.Parse(dict["MembershipFee"].ToString()); | ||
281 | |||
282 | if (dict.ContainsKey("OpenEnrollment") && dict["OpenEnrollment"] != null) | ||
283 | membership.OpenEnrollment = bool.Parse(dict["OpenEnrollment"].ToString()); | ||
284 | |||
285 | if (dict.ContainsKey("ShowInList") && dict["ShowInList"] != null) | ||
286 | membership.ShowInList = bool.Parse(dict["ShowInList"].ToString()); | ||
287 | |||
288 | return membership; | ||
289 | } | ||
290 | |||
291 | public static Dictionary<string, object> GroupMembersData(ExtendedGroupMembersData member) | ||
292 | { | ||
293 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
294 | |||
295 | dict["AcceptNotices"] = member.AcceptNotices.ToString(); | ||
296 | dict["AccessToken"] = Sanitize(member.AccessToken); | ||
297 | dict["AgentID"] = Sanitize(member.AgentID); | ||
298 | dict["AgentPowers"] = member.AgentPowers.ToString(); | ||
299 | dict["Contribution"] = member.Contribution.ToString(); | ||
300 | dict["IsOwner"] = member.IsOwner.ToString(); | ||
301 | dict["ListInProfile"] = member.ListInProfile.ToString(); | ||
302 | dict["OnlineStatus"] = Sanitize(member.OnlineStatus); | ||
303 | dict["Title"] = Sanitize(member.Title); | ||
304 | |||
305 | return dict; | ||
306 | } | ||
307 | |||
308 | public static ExtendedGroupMembersData GroupMembersData(Dictionary<string, object> dict) | ||
309 | { | ||
310 | ExtendedGroupMembersData member = new ExtendedGroupMembersData(); | ||
311 | |||
312 | if (dict == null) | ||
313 | return member; | ||
314 | |||
315 | if (dict.ContainsKey("AcceptNotices") && dict["AcceptNotices"] != null) | ||
316 | member.AcceptNotices = bool.Parse(dict["AcceptNotices"].ToString()); | ||
317 | |||
318 | if (dict.ContainsKey("AccessToken") && dict["AccessToken"] != null) | ||
319 | member.AccessToken = Sanitize(dict["AccessToken"].ToString()); | ||
320 | else | ||
321 | member.AccessToken = string.Empty; | ||
322 | |||
323 | if (dict.ContainsKey("AgentID") && dict["AgentID"] != null) | ||
324 | member.AgentID = Sanitize(dict["AgentID"].ToString()); | ||
325 | else | ||
326 | member.AgentID = UUID.Zero.ToString(); | ||
327 | |||
328 | if (dict.ContainsKey("AgentPowers") && dict["AgentPowers"] != null) | ||
329 | member.AgentPowers = UInt64.Parse(dict["AgentPowers"].ToString()); | ||
330 | |||
331 | if (dict.ContainsKey("Contribution") && dict["Contribution"] != null) | ||
332 | member.Contribution = Int32.Parse(dict["Contribution"].ToString()); | ||
333 | |||
334 | if (dict.ContainsKey("IsOwner") && dict["IsOwner"] != null) | ||
335 | member.IsOwner = bool.Parse(dict["IsOwner"].ToString()); | ||
336 | |||
337 | if (dict.ContainsKey("ListInProfile") && dict["ListInProfile"] != null) | ||
338 | member.ListInProfile = bool.Parse(dict["ListInProfile"].ToString()); | ||
339 | |||
340 | if (dict.ContainsKey("OnlineStatus") && dict["OnlineStatus"] != null) | ||
341 | member.OnlineStatus = Sanitize(dict["OnlineStatus"].ToString()); | ||
342 | else | ||
343 | member.OnlineStatus = string.Empty; | ||
344 | |||
345 | if (dict.ContainsKey("Title") && dict["Title"] != null) | ||
346 | member.Title = Sanitize(dict["Title"].ToString()); | ||
347 | else | ||
348 | member.Title = string.Empty; | ||
349 | |||
350 | return member; | ||
351 | } | ||
352 | |||
353 | public static Dictionary<string, object> GroupRolesData(GroupRolesData role) | ||
354 | { | ||
355 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
356 | |||
357 | dict["Description"] = Sanitize(role.Description); | ||
358 | dict["Members"] = role.Members.ToString(); | ||
359 | dict["Name"] = Sanitize(role.Name); | ||
360 | dict["Powers"] = role.Powers.ToString(); | ||
361 | dict["RoleID"] = role.RoleID.ToString(); | ||
362 | dict["Title"] = Sanitize(role.Title); | ||
363 | |||
364 | return dict; | ||
365 | } | ||
366 | |||
367 | public static GroupRolesData GroupRolesData(Dictionary<string, object> dict) | ||
368 | { | ||
369 | GroupRolesData role = new GroupRolesData(); | ||
370 | |||
371 | if (dict == null) | ||
372 | return role; | ||
373 | |||
374 | if (dict.ContainsKey("Description") && dict["Description"] != null) | ||
375 | role.Description = Sanitize(dict["Description"].ToString()); | ||
376 | else | ||
377 | role.Description = string.Empty; | ||
378 | |||
379 | if (dict.ContainsKey("Members") && dict["Members"] != null) | ||
380 | role.Members = Int32.Parse(dict["Members"].ToString()); | ||
381 | |||
382 | if (dict.ContainsKey("Name") && dict["Name"] != null) | ||
383 | role.Name = Sanitize(dict["Name"].ToString()); | ||
384 | else | ||
385 | role.Name = string.Empty; | ||
386 | |||
387 | if (dict.ContainsKey("Powers") && dict["Powers"] != null) | ||
388 | role.Powers = UInt64.Parse(dict["Powers"].ToString()); | ||
389 | |||
390 | if (dict.ContainsKey("Title") && dict["Title"] != null) | ||
391 | role.Title = Sanitize(dict["Title"].ToString()); | ||
392 | else | ||
393 | role.Title = string.Empty; | ||
394 | |||
395 | if (dict.ContainsKey("RoleID") && dict["RoleID"] != null) | ||
396 | role.RoleID = UUID.Parse(dict["RoleID"].ToString()); | ||
397 | |||
398 | return role; | ||
399 | } | ||
400 | |||
401 | public static Dictionary<string, object> GroupRoleMembersData(ExtendedGroupRoleMembersData rmember) | ||
402 | { | ||
403 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
404 | |||
405 | dict["RoleID"] = rmember.RoleID.ToString(); | ||
406 | dict["MemberID"] = rmember.MemberID; | ||
407 | return dict; | ||
408 | } | ||
409 | |||
410 | public static ExtendedGroupRoleMembersData GroupRoleMembersData(Dictionary<string, object> dict) | ||
411 | { | ||
412 | ExtendedGroupRoleMembersData rmember = new ExtendedGroupRoleMembersData(); | ||
413 | |||
414 | if (dict.ContainsKey("RoleID") && dict["RoleID"] != null) | ||
415 | rmember.RoleID = new UUID(dict["RoleID"].ToString()); | ||
416 | |||
417 | if (dict.ContainsKey("MemberID") && dict["MemberID"] != null) | ||
418 | rmember.MemberID = dict["MemberID"].ToString(); | ||
419 | |||
420 | return rmember; | ||
421 | } | ||
422 | |||
423 | public static Dictionary<string, object> GroupInviteInfo(GroupInviteInfo invite) | ||
424 | { | ||
425 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
426 | |||
427 | dict["InviteID"] = invite.InviteID.ToString(); | ||
428 | dict["GroupID"] = invite.GroupID.ToString(); | ||
429 | dict["RoleID"] = invite.RoleID.ToString(); | ||
430 | dict["AgentID"] = invite.AgentID; | ||
431 | |||
432 | return dict; | ||
433 | } | ||
434 | |||
435 | public static GroupInviteInfo GroupInviteInfo(Dictionary<string, object> dict) | ||
436 | { | ||
437 | if (dict == null) | ||
438 | return null; | ||
439 | |||
440 | GroupInviteInfo invite = new GroupInviteInfo(); | ||
441 | |||
442 | invite.InviteID = new UUID(dict["InviteID"].ToString()); | ||
443 | invite.GroupID = new UUID(dict["GroupID"].ToString()); | ||
444 | invite.RoleID = new UUID(dict["RoleID"].ToString()); | ||
445 | invite.AgentID = Sanitize(dict["AgentID"].ToString()); | ||
446 | |||
447 | return invite; | ||
448 | } | ||
449 | |||
450 | public static Dictionary<string, object> GroupNoticeData(ExtendedGroupNoticeData notice) | ||
451 | { | ||
452 | Dictionary<string, object> dict = new Dictionary<string, object>(); | ||
453 | |||
454 | dict["NoticeID"] = notice.NoticeID.ToString(); | ||
455 | dict["Timestamp"] = notice.Timestamp.ToString(); | ||
456 | dict["FromName"] = Sanitize(notice.FromName); | ||
457 | dict["Subject"] = Sanitize(notice.Subject); | ||
458 | dict["HasAttachment"] = notice.HasAttachment.ToString(); | ||
459 | dict["AttachmentItemID"] = notice.AttachmentItemID.ToString(); | ||
460 | dict["AttachmentName"] = Sanitize(notice.AttachmentName); | ||
461 | dict["AttachmentType"] = notice.AttachmentType.ToString(); | ||
462 | dict["AttachmentOwnerID"] = Sanitize(notice.AttachmentOwnerID); | ||
463 | |||
464 | return dict; | ||
465 | } | ||
466 | |||
467 | public static ExtendedGroupNoticeData GroupNoticeData(Dictionary<string, object> dict) | ||
468 | { | ||
469 | ExtendedGroupNoticeData notice = new ExtendedGroupNoticeData(); | ||
470 | |||
471 | if (dict == null) | ||
472 | return notice; | ||
473 | |||
474 | notice.NoticeID = new UUID(dict["NoticeID"].ToString()); | ||
475 | notice.Timestamp = UInt32.Parse(dict["Timestamp"].ToString()); | ||
476 | notice.FromName = Sanitize(dict["FromName"].ToString()); | ||
477 | notice.Subject = Sanitize(dict["Subject"].ToString()); | ||
478 | notice.HasAttachment = bool.Parse(dict["HasAttachment"].ToString()); | ||
479 | notice.AttachmentItemID = new UUID(dict["AttachmentItemID"].ToString()); | ||
480 | notice.AttachmentName = dict["AttachmentName"].ToString(); | ||
481 | notice.AttachmentType = byte.Parse(dict["AttachmentType"].ToString()); | ||
482 | notice.AttachmentOwnerID = dict["AttachmentOwnerID"].ToString(); | ||
483 | |||
484 | return notice; | ||
485 | } | ||
486 | |||
487 | public static Dictionary<string, object> GroupNoticeInfo(GroupNoticeInfo notice) | ||
488 | { | ||
489 | Dictionary<string, object> dict = GroupNoticeData(notice.noticeData); | ||
490 | |||
491 | dict["GroupID"] = notice.GroupID.ToString(); | ||
492 | dict["Message"] = Sanitize(notice.Message); | ||
493 | |||
494 | return dict; | ||
495 | } | ||
496 | |||
497 | public static GroupNoticeInfo GroupNoticeInfo(Dictionary<string, object> dict) | ||
498 | { | ||
499 | GroupNoticeInfo notice = new GroupNoticeInfo(); | ||
500 | |||
501 | notice.noticeData = GroupNoticeData(dict); | ||
502 | notice.GroupID = new UUID(dict["GroupID"].ToString()); | ||
503 | notice.Message = Sanitize(dict["Message"].ToString()); | ||
504 | |||
505 | return notice; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | } | ||