2using System.Collections.Generic;
3using System.Threading.Tasks;
5using System.Windows.Controls;
6using System.Windows.Media;
21 private readonly
string roomId;
22 private readonly
string domain;
23 private readonly
string nickName;
34 this.nickName = NickName;
38 this.availability =
null;
43 public string RoomId => this.roomId;
44 public string Domain => this.domain;
45 public string NickName => this.nickName;
50 set => this.jid = value;
55 get => this.affiliation;
56 set => this.affiliation = value;
62 set => this.role = value;
67 get => this.availability;
68 set => this.availability = value;
77 private void SetParameters()
79 List<Parameter> Parameters =
new List<Parameter>()
86 if (!
string.IsNullOrEmpty(this.jid))
89 if (this.affiliation.HasValue)
90 Parameters.Add(
new StringParameter(
"Affiliation",
"Affiliation", this.Affiliation.ToString()));
92 if (this.role.HasValue)
93 Parameters.Add(
new StringParameter(
"Role",
"Role", this.Role.ToString()));
95 if (this.availability.HasValue)
101 public override string ToolTip => this.Jid;
102 public override bool CanRecycle =>
false;
104 public override string TypeName
112 public override ImageSource ImageResource
116 if (!this.availability.HasValue)
117 return XmppAccountNode.offline;
119 switch (this.availability.Value)
121 case Networking.XMPP.Availability.Away:
122 return XmppAccountNode.away;
124 case Networking.XMPP.Availability.Chat:
125 return XmppAccountNode.chat;
127 case Networking.XMPP.Availability.DoNotDisturb:
128 return XmppAccountNode.busy;
130 case Networking.XMPP.Availability.ExtendedAway:
131 return XmppAccountNode.away;
134 case Networking.XMPP.Availability.Online:
135 return XmppAccountNode.online;
137 case Networking.XMPP.Availability.Offline:
139 return XmppAccountNode.offline;
144 public override void Write(XmlWriter Output)
155 while (!(Loop is
null))
171 return this.Service?.MucClient;
175 public override string Key => this.nickName;
176 public override string Header => this.nickName;
177 public override bool CanAddChildren =>
false;
178 public override bool CanDelete =>
true;
179 public override bool CanEdit =>
true;
180 public override bool CanChat =>
true;
184 if (!(this.MucClient is
null))
185 await this.MucClient.
Kick(this.RoomId, this.domain, this.nickName,
null,
null);
187 await base.Delete(
Parent, OnDeleted);
194 Form.Affiliation.SelectedIndex = (int)this.affiliation;
195 Form.Role.SelectedIndex = (int)this.role;
197 if (
string.IsNullOrEmpty(this.jid))
198 Form.Affiliation.IsEnabled =
false;
200 bool? b = Form.ShowDialog();
201 if (b.HasValue && b.Value)
204 Role NewRole = (
Role)Form.Role.SelectedIndex;
205 string Reason = Form.Reason.Text;
207 Task.Run(() => this.Config(NewAffiliation, NewRole, Reason));
222 if (this.role !=
Role)
237 if (Markdown is
null)
248 base.AddContexMenuItems(ref CurrentGroup, Menu);
254 this.GroupSeparator(ref CurrentGroup,
"MUC", Menu);
258 Header =
"_Affiliation",
267 IsChecked = this.affiliation == Networking.XMPP.MUC.Affiliation.Owner
270 Item.Click += this.SetAffiliationOwner_Click;
274 Header =
"Administrator",
277 IsChecked = this.affiliation == Networking.XMPP.MUC.Affiliation.Admin
280 Item.Click += this.SetAffiliationAdministrator_Click;
287 IsChecked = this.affiliation == Networking.XMPP.MUC.Affiliation.Member
290 Item.Click += this.SetAffiliationMember_Click;
297 IsChecked = this.affiliation == Networking.XMPP.MUC.Affiliation.None
300 Item.Click += this.SetAffiliationNone_Click;
307 IsChecked = this.affiliation == Networking.XMPP.MUC.Affiliation.Outcast
310 Item.Click += this.SetAffiliationOutcast_Click;
312 Menu.Items.Add(
Role =
new MenuItem()
318 Role.Items.Add(Item =
new MenuItem()
320 Header =
"Moderator",
323 IsChecked = this.role == Networking.XMPP.MUC.Role.Moderator
326 Item.Click += this.SetRoleModerator_Click;
328 Role.Items.Add(Item =
new MenuItem()
330 Header =
"Participant",
333 IsChecked = this.role == Networking.XMPP.MUC.Role.Participant
336 Item.Click += this.SetRoleParticipant_Click;
338 Role.Items.Add(Item =
new MenuItem()
343 IsChecked = this.role == Networking.XMPP.MUC.Role.Visitor
346 Item.Click += this.SetRoleVisitor_Click;
348 Role.Items.Add(Item =
new MenuItem()
353 IsChecked = this.role == Networking.XMPP.MUC.Role.None
356 Item.Click += this.SetRoleNone_Click;
358 Menu.Items.Add(Item =
new MenuItem()
364 Item.Click += this.Ban_Click;
367 private void Ban_Click(
object Sender, RoutedEventArgs e)
370 bool? b = Form.ShowDialog();
372 if (b.HasValue && b.Value)
374 this.MucClient.
Ban(this.roomId, this.domain, this.jid, Form.Reason.Text, async (sender2, e2) =>
377 await
this.Delete(
this.Parent,
null);
379 MainWindow.ErrorBox(
string.IsNullOrEmpty(e2.ErrorText) ?
"Unable to ban the occupant." : e2.ErrorText);
384 private void SetAffiliationOwner_Click(
object Sender, RoutedEventArgs e)
386 this.SetAffiliation(Networking.XMPP.MUC.Affiliation.Owner);
389 private void SetAffiliationAdministrator_Click(
object Sender, RoutedEventArgs e)
391 this.SetAffiliation(Networking.XMPP.MUC.Affiliation.Admin);
394 private void SetAffiliationMember_Click(
object Sender, RoutedEventArgs e)
396 this.SetAffiliation(Networking.XMPP.MUC.Affiliation.Member);
399 private void SetAffiliationNone_Click(
object Sender, RoutedEventArgs e)
401 this.SetAffiliation(Networking.XMPP.MUC.Affiliation.None);
404 private void SetAffiliationOutcast_Click(
object Sender, RoutedEventArgs e)
406 this.SetAffiliation(Networking.XMPP.MUC.Affiliation.Outcast);
415 this.affiliation = Affiliation;
419 MainWindow.ErrorBox(
string.IsNullOrEmpty(e.ErrorText) ?
"Unable to change affiliation." : e.ErrorText);
421 return Task.CompletedTask;
425 private void SetRoleModerator_Click(
object Sender, RoutedEventArgs e)
427 this.SetRole(Networking.XMPP.MUC.Role.Moderator);
430 private void SetRoleParticipant_Click(
object Sender, RoutedEventArgs e)
432 this.SetRole(Networking.XMPP.MUC.Role.Participant);
435 private void SetRoleVisitor_Click(
object Sender, RoutedEventArgs e)
437 this.SetRole(Networking.XMPP.MUC.Role.Visitor);
440 private void SetRoleNone_Click(
object Sender, RoutedEventArgs e)
442 this.SetRole(Networking.XMPP.MUC.Role.None);
447 this.MucClient.ConfigureOccupant(this.roomId, this.domain, this.nickName,
Role,
string.Empty, (Sender, e) =>
455 MainWindow.ErrorBox(
string.IsNullOrEmpty(e.ErrorText) ?
"Unable to change role." : e.ErrorText);
457 return Task.CompletedTask;
Interaction logic for xaml
Represents an occupant in a room hosted by a Multi-User Chat service.
override async Task SendChatMessage(string Message, string ThreadId, MarkdownDocument Markdown)
Sends a chat message.
override void OnUpdated()
Raises the Updated event.
override void AddContexMenuItems(ref string CurrentGroup, ContextMenu Menu)
Adds context sensitive menu items to a context menu.
override void Edit()
Is called when the user wants to edit a node.
override async Task Delete(TreeNode Parent, EventHandler OnDeleted)
Method called when a node is to be deleted.
override void Write(XmlWriter Output)
Saves the object to a file.
Abstract base class for tree nodes in the connection view.
virtual DisplayableParameters DisplayableParameters
Gets available displayable parameters.
TreeNode Parent
Parent node. May be null if a root node.
Contains a markdown document. This markdown document class supports original markdown,...
Client managing communication with a Multi-User-Chat service. https://xmpp.org/extensions/xep-0045....
Task Ban(string RoomId, string Domain, string OccupantBareJid, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Bans an occupant out of a room.
Task SendPrivateMessage(string RoomId, string Domain, string NickName, string Message)
Sends a simple private message to a chat room.
Task< IqResultEventArgs > ConfigureOccupantAsync(string RoomId, string Domain, string OccupantNickName, Role Role, string Reason)
Configures the role of an occupant.
Task Kick(string RoomId, string Domain, string OccupantNickName, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Kicks an occupant out of a room.
Task SendCustomPrivateMessage(string RoomId, string Domain, string NickName, string Xml)
Sends a simple private message to a chat room.
Task ConfigureOccupant(string RoomId, string Domain, string OccupantNickName, Role Role, string Reason, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Configures the role of an occupant.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static string GetBareJID(string JID)
Gets the Bare JID from a JID, which may be a Full JID.
Contains information about a message logged on a node.
Affiliation
Affiliation enumeration
Availability
Resource availability.