3using System.Threading.Tasks;
6using System.Windows.Controls;
7using System.Windows.Input;
8using System.Windows.Media;
9using System.Windows.Media.Imaging;
26 private readonly
string bareJid;
27 private readonly
bool supportsRdp;
33 this.bareJid = BareJid;
34 this.supportsRdp = SupportsRdp;
37 public override string Header => this.bareJid;
39 public override string TypeName
41 get {
return "Unknown"; }
44 public string BareJID => this.bareJid;
46 public override string FullJID
62 return this.client[this.bareJid];
69 this.client[this.bareJid] = value;
73 public override void Write(XmlWriter Output)
83 if (AccountNode is
null || !AccountNode.IsOnline)
100 XmppAccountNode AccountNode = this.XmppAccountNode;
101 if (AccountNode is
null || !AccountNode.IsOnline)
112 public override ImageSource ImageResource
119 return XmppAccountNode.away;
122 return XmppAccountNode.chat;
125 return XmppAccountNode.busy;
128 return XmppAccountNode.extendedAway;
131 return XmppAccountNode.online;
135 return XmppAccountNode.offline;
140 public override ImageSource ImageResource2
147 return XmppAccountNode.none;
150 return XmppAccountNode.from;
153 return XmppAccountNode.to;
156 return XmppAccountNode.both;
165 public override Visibility ImageResource2Visibility
175 return Visibility.Visible;
179 return Visibility.Hidden;
184 public override string ToolTip
188 XmppAccountNode AccountNode = this.XmppAccountNode;
189 if (AccountNode is
null)
191 else if (!AccountNode.IsOnline)
192 return AccountNode.BareJID +
" is not connected.";
197 return "Status unknown. No presence received.";
203 return "Contact is away.";
206 return "Contact is ready to chat.";
209 return "Contact is busy and doesn't want to be disturbed.";
212 return "Contact is away for an extended period.";
215 return "Contact is online.";
219 return "Contact is offline.";
225 public override bool CanAddChildren
227 get {
return false; }
230 public override bool CanDelete
235 public override bool CanEdit
237 get {
return false; }
240 public override bool CanRecycle
242 get {
return false; }
245 public override string Key => this.bareJid;
247 public override bool CanChat
257 public XmppAccountNode XmppAccountNode
262 XmppAccountNode Result = Loop as XmppAccountNode;
264 while (Result is
null && !(Loop is
null))
267 Result = Loop as XmppAccountNode;
280 if (
string.IsNullOrEmpty(To))
283 if (Markdown is
null)
288 await MultiFormatMessage(Message, Markdown),
string.Empty,
string.Empty,
string.Empty, ThreadId,
string.Empty,
null,
null);
293 public static async Task<string> MultiFormatMessage(
string PlainText,
MarkdownDocument Markdown)
295 if (PlainText is
null)
299 StringBuilder sb =
new StringBuilder();
303 sb.Append(
"</body>");
304 sb.Append(
"<html xmlns='http://jabber.org/protocol/xhtml-im'>");
305 sb.Append(
"<body xmlns='http://www.w3.org/1999/xhtml'>");
307 sb.Append(
"</body></html>");
308 sb.Append(
"<content xmlns='urn:xmpp:content' type='text/markdown'>");
310 sb.Append(
"</content>");
312 return sb.ToString();
317 base.AddContexMenuItems(ref CurrentGroup, Menu);
329 this.GroupSeparator(ref CurrentGroup,
"Subscriptions", Menu);
332 s =
"../Graphics/To.png";
334 s =
"../Graphics/Both.png";
336 Menu.Items.Add(MenuItem =
new MenuItem()
338 Header =
"_Subscribe to",
342 Source =
new BitmapImage(
new Uri(s, UriKind.Relative)),
348 MenuItem.Click += this.Subscribe_Click;
353 this.GroupSeparator(ref CurrentGroup,
"Subscriptions", Menu);
356 s =
"../Graphics/None.png";
358 s =
"../Graphics/From.png";
360 Menu.Items.Add(MenuItem =
new MenuItem()
362 Header =
"_Unsubscribe from",
366 Source =
new BitmapImage(
new Uri(s, UriKind.Relative)),
372 MenuItem.Click += this.Unsubscribe_Click;
378 private void Subscribe_Click(
object Sender, RoutedEventArgs e)
380 this.XmppAccountNode?.Client?.RequestPresenceSubscription(this.bareJid);
383 private void Unsubscribe_Click(
object Sender, RoutedEventArgs e)
385 this.XmppAccountNode?.Client?.RequestPresenceUnsubscription(this.bareJid);
388 public override bool CanConfigure => this.supportsRdp && !
string.IsNullOrEmpty(this.LastOnlineFullJid);
390 private string LastOnlineFullJid
396 if (this.client is
null)
404 if (e?.IsOnline ??
false)
423 if (this.UseActuatorControl)
429 string FullJid = this.LastOnlineFullJid;
430 if (
string.IsNullOrEmpty(FullJid))
434 if (RdpClient is
null)
438 bool DisposeRdpClient =
false;
442 Mouse.OverrideCursor = Cursors.Wait;
444 Guid SessionGuid = Guid.NewGuid();
447 this.XmppAccountNode.ReregisterView(SessionGuid.ToString(), View);
451 Mouse.OverrideCursor =
null;
453 TabItem TabItem =
MainWindow.NewTab(this.bareJid);
454 MainWindow.currentInstance.Tabs.Items.Add(TabItem);
456 TabItem.Content = View;
458 MainWindow.currentInstance.Tabs.SelectedItem = TabItem;
462 if (DisposeRdpClient)
479 Clipboard.SetText(
"xmpp:" + this.bareJid);
Interaction logic for RemoteDesktopView.xaml
Interaction logic for xaml
Abstract base class for tree nodes in the connection view.
TreeNode Parent
Parent node. May be null if a root node.
TreeNode(TreeNode Parent)
Abstract base class for tree nodes in the connection view.
Class representing a normal XMPP account.
static string GetBody(string Html)
Extracts the contents of the BODY element in a HTML string.
Contains a markdown document. This markdown document class supports original markdown,...
Task< string > GenerateMarkdown()
Generates Markdown from the markdown text.
async Task< string > GeneratePlainText()
Generates Plain Text from the markdown text.
async Task< string > GenerateHTML()
Generates HTML from the markdown text.
Helps with common XML-related tasks.
static string HtmlValueEncode(string s)
Differs from Encode(String), in that it does not encode the aposotrophe or the quote.
static string Encode(string s)
Encodes a string for use in XML.
Event arguments for presence events.
string From
From where the presence was received.
Availability Availability
Resource availability.
Task< RemoteDesktopSession > StartSessionAsync(string To)
Starts a Remote Desktop session.
override void Dispose()
Disposes of the extension.
Maintains information about an item in the roster.
SubscriptionState State
roup Current subscription state.
bool HasLastPresence
If the roster item has received presence from an online resource having the given bare JID.
string LastPresenceFullJid
Full JID of last resource sending online presence.
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....
Task SendMessage(MessageType Type, string To, string CustomXml, string Body, string Subject, string Language, string ThreadId, string ParentThreadId)
Sends a simple chat message
Task SendChatMessage(string To, string Body)
Sends a simple chat message
Availability
Resource availability.
QoSLevel
Quality of Service Level for asynchronous messages. Support for QoS Levels must be supported by the r...
SubscriptionState
State of a presence subscription.
MessageType
Type of message received.