2using System.Collections.Generic;
15 [ArchivingTime(nameof(ArchiveDays))]
16 [CollectionName(
"MucRooms")]
17 [Index(
"Domain",
"Room")]
20 private readonly Dictionary<CaseInsensitiveString, MucOccupant> occupantsByNick =
new Dictionary<CaseInsensitiveString, MucOccupant>();
21 private readonly Dictionary<CaseInsensitiveString, MucOccupant> occupantsByFullJid =
new Dictionary<CaseInsensitiveString, MucOccupant>();
22 private readonly Dictionary<CaseInsensitiveString, MucOccupant> occupantsByBareJid =
new Dictionary<CaseInsensitiveString, MucOccupant>();
23 private readonly
object synchObj =
new object();
24 private string objectId =
null;
28 private string name =
string.
Empty;
29 private string description =
string.
Empty;
30 private string language =
string.
Empty;
31 private string subject =
string.
Empty;
32 private string subjectJid =
string.
Empty;
33 private DateTime subjectTimestamp = DateTime.MinValue;
34 private bool logging =
false;
35 private bool allowChangeSubject =
false;
36 private bool allowInvites =
false;
37 private CanSendPrivateMessages allowPrivateMessages = CanSendPrivateMessages.Anyone;
38 private int maxOccupants = 20;
39 private BroadcastPresence presenceBroadcast = BroadcastPresence.All;
40 private RetrieveMembershipList getMemberList = RetrieveMembershipList.All;
41 private bool persistent =
false;
42 private bool archive =
false;
43 private bool moderated =
false;
44 private bool membersOnly =
false;
45 private bool passwordProtected =
false;
46 private bool _public =
false;
47 private bool locked =
false;
48 private string password =
string.
Empty;
49 private DiscoverReadJids discoverRealJids = DiscoverReadJids.Moderators;
50 private int maxHistoryFetch = 50;
51 private int archiveMessagesDays = 0;
64 public string ObjectID
67 set => this.objectId = value;
73 set => this.room = value;
79 set => this.domain = value;
85 set => this.creator = value;
88 [DefaultValueStringEmpty]
92 set => this.name = value;
95 [DefaultValueStringEmpty]
96 public string Description
98 get => this.description;
99 set => this.description = value;
102 [DefaultValueStringEmpty]
103 public string Language
105 get => this.language;
106 set => this.language = value;
109 [DefaultValue(
false)]
113 set => this.logging = value;
116 [DefaultValue(
false)]
117 public bool AllowChangeSubject
119 get => this.allowChangeSubject;
120 set => this.allowChangeSubject = value;
123 [DefaultValue(
false)]
124 public bool AllowInvites
126 get => this.allowInvites;
127 set => this.allowInvites = value;
130 [DefaultValue(CanSendPrivateMessages.Anyone)]
131 public CanSendPrivateMessages AllowPrivateMessages
133 get => this.allowPrivateMessages;
134 set => this.allowPrivateMessages = value;
138 public int MaxOccupants
140 get => this.maxOccupants;
141 set => this.maxOccupants = value;
144 [DefaultValue(BroadcastPresence.All)]
145 public BroadcastPresence PresenceBroadcast
147 get => this.presenceBroadcast;
148 set => this.presenceBroadcast = value;
151 [DefaultValue(RetrieveMembershipList.All)]
152 public RetrieveMembershipList GetMemberList
154 get => this.getMemberList;
155 set => this.getMemberList = value;
158 [DefaultValue(
false)]
159 public bool Persistent
161 get => this.persistent;
164 this.persistent = value;
165 this.archive |= value;
169 [DefaultValue(
false)]
173 set => this.archive = value;
176 [DefaultValue(
false)]
177 public bool Moderated
179 get => this.moderated;
180 set => this.moderated = value;
183 [DefaultValue(
false)]
184 public bool MembersOnly
186 get => this.membersOnly;
187 set => this.membersOnly = value;
190 [DefaultValue(
false)]
194 set => this._public = value;
197 [DefaultValue(
false)]
198 public bool PasswordProtected
200 get => this.passwordProtected;
201 set => this.passwordProtected = value;
204 [DefaultValueStringEmpty]
205 public string Password
207 get => this.password;
208 set => this.password = value;
211 [DefaultValue(DiscoverReadJids.Moderators)]
212 public DiscoverReadJids DiscoverRealJids
214 get => this.discoverRealJids;
215 set => this.discoverRealJids = value;
219 public int MaxHistoryFetch
221 get => this.maxHistoryFetch;
222 set => this.maxHistoryFetch = value;
226 public int ArchiveMessagesDays
228 get => this.archiveMessagesDays;
229 set => this.archiveMessagesDays = value;
236 set => this.admins = value;
243 set => this.owners = value;
250 set => this.locked = value;
253 [DefaultValueStringEmpty]
254 public string Subject
257 set => this.subject = value;
260 [DefaultValueStringEmpty]
263 get => this.subjectJid;
264 set => this.subjectJid = value;
267 [DefaultValueDateTimeMinValue]
268 public DateTime SubjectTimestamp
270 get => this.subjectTimestamp;
271 set => this.subjectTimestamp = value;
283 return this.occupantsByNick.TryGetValue(NickName, out Occupant);
291 return this.occupantsByFullJid.TryGetValue(FullJid, out Occupant);
299 return this.occupantsByBareJid.TryGetValue(BareJid, out Occupant);
307 if (this.occupantsByNick.Count >=
this.maxOccupants && !(Occupant.Affiliation is Affiliations.Admin) && !(Occupant.Affiliation is
Member))
310 this.occupantsByNick[Occupant.NickName] = Occupant;
311 this.occupantsByBareJid[Occupant.BareJid] = Occupant;
313 if (!(Occupant.FullJids is
null))
316 this.occupantsByFullJid[FullJid.
Address] = Occupant;
329 Result = this.occupantsByNick.Remove(Occupant.NickName);
330 this.occupantsByBareJid.Remove(Occupant.BareJid);
332 if (!(Occupant.FullJids is
null))
335 this.occupantsByFullJid.Remove(FullJid.
Address);
347 this.occupantsByNick.Values.CopyTo(Result, 0);
356 this.occupantsByFullJid[FullJid.
Address] = Occupant;
357 this.occupantsByBareJid[FullJid.
BareJid] = Occupant;
360 Occupant.AddFullJid(FullJid);
365 int c = Occupant.RemoveFullJid(FullJid);
369 this.occupantsByFullJid.Remove(FullJid.
Address);
373 this.occupantsByBareJid.Remove(FullJid.
BareJid);
383 if (!(this.owners is
null) && Array.IndexOf(
this.owners, BareJid) >= 0)
386 if (!(this.admins is
null) && Array.IndexOf(
this.admins, BareJid) >= 0)
387 return new Affiliations.Admin();
389 if (!(this.members is
null) && Array.IndexOf(
this.members, BareJid) >= 0)
392 return new Affiliations.None();
395 internal bool CanBroadcastPresence(
MucOccupant Occupant)
400 internal bool CanGetMembership(
MucOccupant Occupant)
405 internal bool CanDiscoverRealJids(
MucOccupant Occupant)
410 internal bool CanSendPrivateMessage(
MucOccupant Occupant)
425 if (!(this.admins is
null) && Array.IndexOf(
this.admins, Occupant.BareJid) >= 0)
428 return IsOwner(Occupant);
433 return this.IsOwner(Occupant.BareJid);
438 if (!(this.owners is
null) && Array.IndexOf(
this.owners, BareJid) >= 0)
446 return Add(ref this.members, BareJid);
451 return !(this.members is
null) && Array.IndexOf(
this.members, BareJid) >= 0;
456 return Add(ref this.admins, BareJid);
461 return Add(ref this.owners, BareJid);
466 return Remove(ref this.members, BareJid);
471 return Remove(ref this.admins, BareJid);
476 return Remove(ref this.owners, BareJid);
483 else if (Array.IndexOf(List, BareJid) >= 0)
489 Array.Resize(ref New, c + 1);
503 int i = Array.
IndexOf(New, BareJid);
510 Array.Copy(New, i + 1, New, i, c - 1 - i);
512 Array.Resize(ref New, c - 1);
Contains information about one XMPP address.
CaseInsensitiveString Address
XMPP Address
CaseInsensitiveString BareJid
Bare JID
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
int Length
Gets the number of characters in the current CaseInsensitiveString object.
int IndexOf(CaseInsensitiveString value, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
Abstract base class for MUC affiliations.
Represents a member of a room
Represents the owner of a room
Multi-user Chat Room Occupant
MucRoom()
Multi-user Chat Room
int ArchiveDays
Number of days to archive field.
abstract bool SendPrivateMessages
If user can send private messages
abstract bool CanSendPrivateMessage(CanSendPrivateMessages Level)
If occupants of this role can send private messages.
abstract bool CanBroadcastPresence(BroadcastPresence Level)
If occupants of this role should be broadcast.
abstract bool CanDiscoverRealJids(DiscoverReadJids Level)
If occupants of this role can discover occupant's real JIDs.
abstract bool CanGetMembership(RetrieveMembershipList Level)
If occupants of this role can get membership list.
TypeNameSerialization
How the type name should be serialized.