Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RosterItemNode.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
9
10namespace Waher.Things.Xmpp
11{
16 {
21 : base()
22 {
23 }
24
28 [Page(28, "Roster", 110)]
29 [Header(29, "Bare JID:")]
30 [ToolTip(30, "Bare JID of roster item.")]
31 public string BareJID { get; set; }
32
36 [Page(28, "Roster", 110)]
37 [Header(34, "Subscription State:")]
38 [ToolTip(35, "State of presence subscription for roster item.")]
39 [Option(SubscriptionState.None, 36, "None")]
40 [Option(SubscriptionState.To, 37, "To")]
41 [Option(SubscriptionState.From, 38, "From")]
42 [Option(SubscriptionState.Both, 39, "Both")]
43 [Option(SubscriptionState.Remove, 40, "Remove")]
44 [Option(SubscriptionState.Unknown, 41, "Unknown")]
46
50 [Page(28, "Roster", 110)]
51 [Header(42, "Name:")]
52 [ToolTip(43, "Name of contact.")]
53 public string ContactName { get; set; }
54
58 [Page(28, "Roster", 110)]
59 [Header(44, "Pending Subscription:")]
60 [ToolTip(47, "If a pending subscription request exists.")]
61 [Option(PendingSubscription.None, 36, "None")]
62 [Option(PendingSubscription.Subscribe, 45, "Subscribe")]
63 [Option(PendingSubscription.Unsubscribe, 46, "Unsubscribe")]
65
69 [Page(28, "Roster", 110)]
70 [Header(48, "Groups:")]
71 [ToolTip(49, "Groups to which the roster item belongs.")]
72 public string[] Groups { get; set; }
73
77 public override string LocalId => this.BareJID;
78
84 public override Task<string> GetTypeNameAsync(Language Language)
85 {
86 return Language.GetStringAsync(typeof(ConcentratorDevice), 31, "Roster Item");
87 }
88
94 public override Task<bool> AcceptsParentAsync(INode Parent)
95 {
96 return Task.FromResult(Parent is XmppBrokerNode);
97 }
98
104 public override Task<bool> AcceptsChildAsync(INode Child)
105 {
106 return Task.FromResult(false);
107 }
108
115 public async override Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
116 {
117 LinkedList<Parameter> Result = await base.GetDisplayableParametersAsync(Language, Caller) as LinkedList<Parameter>;
118
119 if (await this.GetParent() is XmppBrokerNode BrokerNode)
120 {
121 XmppBroker Broker = await BrokerNode.GetBroker();
122 XmppClient Client = Broker.Client;
124
125 RosterItem Item = Client[this.BareJID];
126 if (!(Item is null))
127 Result.AddLast(new StringParameter("SubscriptionState", await Namespace.GetStringAsync(51, "Subscription State"), Item.State.ToString()));
128
129 Result.AddLast(new StringParameter("ContactName", await Namespace.GetStringAsync(50, "Contact Name"), this.ContactName));
130 }
131
132 return Result;
133 }
134
138 public override async Task DestroyAsync()
139 {
140 await base.DestroyAsync();
141
142 if (await this.GetParent() is XmppBrokerNode BrokerNode)
143 {
144 XmppBroker Broker = await BrokerNode.GetBroker();
145 XmppClient Client = Broker.Client;
146 RosterItem Item = Client[this.BareJID];
147
148 if (!(Item is null))
149 await Client.RemoveRosterItem(this.BareJID);
150 }
151 }
152 }
153}
Maintains information about an item in the roster.
Definition: RosterItem.cs:75
SubscriptionState State
roup Current subscription state.
Definition: RosterItem.cs:268
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
Task RemoveRosterItem(string BareJID)
Removes an item from the roster.
Definition: XmppClient.cs:4631
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Definition: Language.cs:99
Contains information about a namespace in a language.
Definition: Namespace.cs:17
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Definition: Namespace.cs:65
INode Parent
Parent Node, or null if a root node.
async Task< INode > GetParent()
Gets the parent of the node.
Base class for all provisioned metering nodes.
Tokens available in request.
Definition: RequestOrigin.cs:9
Node representing an XMPP concentrator.
Represents an XMPP broker.
Definition: XmppBroker.cs:14
Node representing a roster item in the roster of an XMPP account.
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
async override Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
override async Task DestroyAsync()
Destroys the node. If it is a child to a parent node, it is removed from the parent first.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a presumptive child, i.e. can receive as a child (if that child accepts the node ...
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
string[] Groups
Subscription State
RosterItemNode()
Node representing a roster item in the roster of an XMPP account.
override string LocalId
If provided, an ID for the node, but unique locally between siblings. Can be null,...
Node representing an XMPP broker.
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
SubscriptionState
State of a presence subscription.
Definition: RosterItem.cs:16
PendingSubscription
Pending subscription states.
Definition: RosterItem.cs:54