2using System.Collections.Generic;
3using System.Threading.Tasks;
4using System.Windows.Input;
16 private Dictionary<string, bool> capabilities =
null;
17 private readonly Dictionary<string, DataSource> dataSources =
new Dictionary<string, DataSource>();
18 private readonly
bool suportsEvents;
21 : base(
Parent, Client, BareJid, SupportsRdp)
23 this.suportsEvents = SupportsEventSubscripton;
24 this.children =
new SortedDictionary<string, TreeNode>()
26 {
string.Empty,
new Loading(
this) }
29 this.CheckCapabilities();
37 private void CheckCapabilities()
39 if (this.capabilities is
null)
41 string FullJid = this.FullJid;
43 if (!
string.IsNullOrEmpty(FullJid))
49 Dictionary<string, bool> Capabilities = new Dictionary<string, bool>();
51 foreach (string s in e.Capabilities)
52 Capabilities[s] = true;
54 this.capabilities = Capabilities;
57 return Task.CompletedTask;
63 public override string TypeName
65 get {
return "Concentrator"; }
72 XmppAccountNode AccountNode = this.XmppAccountNode;
73 if (AccountNode is
null || !AccountNode.IsOnline)
76 RosterItem Item = AccountNode.Client[this.BareJID];
86 private bool loadingChildren =
false;
90 if (!this.loadingChildren && !this.IsLoaded)
92 string FullJid = this.FullJid;
94 if (!
string.IsNullOrEmpty(FullJid))
96 Mouse.OverrideCursor = Cursors.Wait;
100 this.loadingChildren =
true;
103 this.loadingChildren =
false;
108 SortedDictionary<string, TreeNode> Children = new SortedDictionary<string, TreeNode>();
110 foreach (DataSourceReference Ref in e.DataSources)
112 DataSource DataSource = new DataSource(this, Ref.SourceID, Ref.SourceID, Ref.HasChildren);
113 Children[Ref.SourceID] = DataSource;
115 DataSource.SubscribeToEvents();
121 this.NodesAdded(
Children.Values,
this);
124 return Task.CompletedTask;
132 public void NodesAdded(IEnumerable<TreeNode> Nodes,
TreeNode Parent)
138 View?.NodeAdded(Parent, Node);
140 if (Node is DataSource DataSource)
142 lock (this.dataSources)
144 this.dataSources[DataSource.Key] = DataSource;
150 public void NodesRemoved(IEnumerable<TreeNode> Nodes, TreeNode Parent)
152 Controls.ConnectionView View = this.XmppAccountNode?.View;
153 LinkedList<KeyValuePair<TreeNode, TreeNode>> ToRemove =
new LinkedList<KeyValuePair<TreeNode, TreeNode>>();
155 foreach (TreeNode Node
in Nodes)
156 ToRemove.AddLast(
new KeyValuePair<TreeNode, TreeNode>(Parent, Node));
158 while (!(ToRemove.First is
null))
160 KeyValuePair<TreeNode, TreeNode> P = ToRemove.First.Value;
161 ToRemove.RemoveFirst();
164 TreeNode Node = P.Value;
166 if (Node.HasChildren.HasValue && Node.HasChildren.Value)
168 foreach (TreeNode Child
in Node.Children)
169 ToRemove.AddLast(
new KeyValuePair<TreeNode, TreeNode>(Node, Child));
172 View?.NodeRemoved(Parent, Node);
174 if (Node is DataSource DataSource)
176 if (this.XmppAccountNode.IsOnline)
177 DataSource.UnsubscribeFromEvents();
179 lock (this.dataSources)
181 this.dataSources.Remove(DataSource.Key);
189 base.UnloadChildren();
193 if (!(this.children is
null))
194 this.NodesRemoved(this.children.Values,
this);
196 this.children =
new SortedDictionary<string, TreeNode>()
198 {
string.Empty,
new Loading(
this) }
209 lock (this.dataSources)
211 if (!this.dataSources.TryGetValue(EventMessage.
Event.SourceId, out Source))
212 return Task.CompletedTask;
215 return Source.ConcentratorClient_OnEvent(Sender, EventMessage);
Interaction logic for ConnectionView.xaml
Interaction logic for xaml
Represents a data source in a concentrator.
Represents an XMPP concentrator.
bool SupportsEvents
If event subscription is supported for readable nodes.
override void LoadChildren()
Method is called to make sure children are loaded.
override void UnloadChildren()
Method is called to notify children can be unloaded.
Represents a data source in a concentrator.
Abstract base class for tree nodes in the connection view.
TreeNode[] Children
Children of the node. If null, children are not loaded.
TreeNode Parent
Parent node. May be null if a root node.
virtual void OnUpdated()
Raises the Updated event.
Class representing a normal XMPP account.
Implements an XMPP concentrator client interface.
Task GetRootDataSources(string To, EventHandlerAsync< DataSourcesEventArgs > Callback, object State)
Gets all root data sources from the server.
Task GetCapabilities(string To, EventHandlerAsync< CapabilitiesEventArgs > Callback, object State)
Gets the capabilities of a concentrator server.
Event arguments for data source section events.
SourceEvent Event
Source Event
Event arguments for presence events.
string From
From where the presence was received.
Availability Availability
Resource availability.
Maintains information about an item in the roster.
PresenceEventArgs LastPresence
Last presence received from a resource having this bare JID.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Availability
Resource availability.