5using System.Security.Cryptography.X509Certificates;
7using System.Threading.Tasks;
8using Microsoft.Maui.Storage;
19using System.Xml.Schema;
40 if (uri.Scheme.Equals(
"xmpp", StringComparison.OrdinalIgnoreCase))
47 grade =
Grade.NotAtAll;
57 X509Certificate certificate,
58 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
59 params KeyValuePair<string, string>[] headers)
61 return this.
GetAsync(uri, certificate, remoteCertificateValidator, 60000, headers);
69 X509Certificate certificate,
70 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
72 params KeyValuePair<string, string>[] headers)
78 string Full = uri.OriginalString;
79 string WithoutScheme = Full.Substring(uri.Scheme.Length + 1);
84 int SlashIndex = WithoutScheme.IndexOf(
'/');
87 NodeAtDomain = WithoutScheme;
92 NodeAtDomain = WithoutScheme.Substring(0, SlashIndex);
93 Resource = WithoutScheme.Substring(SlashIndex + 1);
98 int AtIndex = NodeAtDomain.IndexOf(
'@');
103 Domain = NodeAtDomain;
107 Node = NodeAtDomain.Substring(0, AtIndex);
108 Domain = NodeAtDomain.Substring(AtIndex + 1);
148 bool IsComponent =
true;
161 new InvalidOperationException(
"TagProfile service is not available."));
168 new InvalidOperationException($
"Domain '{Domain}' is not the configured PubSub JID."));
180 throw new InvalidOperationException(
"XMPP service is not connected. Cannot fetch PubSub item.");
190 new InvalidOperationException($
"No PubSub item found for node '{Node}' and ID '{Resource}'."));
194 string ItemXml = Item.Item.InnerXml ??
string.Empty;
195 byte[] ItemBytes = Encoding.UTF8.GetBytes(Item.
Item.InnerXml ??
string.Empty);
198 XmlDocument XmlDoc =
new XmlDocument();
201 XmlDoc.LoadXml(ItemXml);
203 catch (XmlException XmlEx)
206 new InvalidOperationException(
"PubSub payload is not well-formed XML.", XmlEx));
222 new NotSupportedException($
"Fetching for account JID '{Node}@{Domain}' is not implemented."));
231 X509Certificate certificate,
232 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
233 params KeyValuePair<string, string>[] headers)
236 if (Response.
Error is not
null)
250 X509Certificate certificate,
251 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
253 params KeyValuePair<string, string>[] headers)
255 ContentResponse Response = await this.
GetAsync(uri, certificate, remoteCertificateValidator, timeoutMs, headers);
256 if (Response.
Error is not
null)
270 X509Certificate certificate,
271 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
273 params KeyValuePair<string, string>[] headers)
277 return this.
GetTempStreamAsync(uri, certificate, remoteCertificateValidator, headers);
285 X509Certificate certificate,
286 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
288 params KeyValuePair<string, string>[] headers)
290 return this.
GetTempStreamAsync(uri, certificate, remoteCertificateValidator, timeoutMs, headers);
298 X509Certificate certificate,
299 EventHandler<RemoteCertificateEventArgs> remoteCertificateValidator,
302 params KeyValuePair<string, string>[] headers)
305 return this.
GetTempStreamAsync(uri, certificate, remoteCertificateValidator, timeoutMs, headers);
static readonly TimeSpan XmppConnect
XMPP Connect timeout
A set of never changing property constants and helpful values.
Android Resource Designer class. Exposes the Android Resource designer assembly into the project Name...
An IContentGetter that handles XMPP URIs of the form "xmpp:node@domain/resource". Example: xmpp:foo@p...
async Task< ContentStreamResponse > GetTempStreamAsync(Uri uri, X509Certificate certificate, EventHandler< RemoteCertificateEventArgs > remoteCertificateValidator, int timeoutMs, params KeyValuePair< string, string >[] headers)
Gets a (possibly large) resource from an XMPP URI, writing it to a temporary stream,...
string[] UriSchemes
Supported URI schemes for this getter.
bool CanGet(Uri uri, out Grade grade)
If the getter is able to get a resource, given its URI.
Task< ContentResponse > GetAsync(Uri uri, X509Certificate certificate, EventHandler< RemoteCertificateEventArgs > remoteCertificateValidator, params KeyValuePair< string, string >[] headers)
Gets a resource from an XMPP URI.
async Task< ContentResponse > GetAsync(Uri uri, X509Certificate certificate, EventHandler< RemoteCertificateEventArgs > remoteCertificateValidator, int timeoutMs, params KeyValuePair< string, string >[] headers)
Gets a resource from an XMPP URI, with timeout.
async Task< ContentStreamResponse > GetTempStreamAsync(Uri uri, X509Certificate certificate, EventHandler< RemoteCertificateEventArgs > remoteCertificateValidator, params KeyValuePair< string, string >[] headers)
Gets a (possibly large) resource from an XMPP URI, writing it to a temporary stream.
Base class that references services in the app.
static ITagProfile TagProfile
TAG Profile service.
static IXmppService XmppService
The XMPP service for XMPP communication.
The TAG Profile is the heart of the digital identity for a specific user/device. Use this instance to...
string? PubSubJid
The XMPP server's PubSub JID.
Contains information about a response to a content request.
byte[] Encoded
Encoded object.
string ContentType
Internet Content-Type of encoded object.
Exception Error
Error response.
Contains information about a stream response to a content request.
Represents a published item.
XmlElement Item
Item XML Element.
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within...
The TAG Profile is the heart of the digital identity for a specific user/device. Use this instance to...
Basic interface for Internet Content getters. A class implementing this interface and having a defaul...
Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, X509Certificate Certificate, EventHandler< RemoteCertificateEventArgs > RemoteCertificateValidator, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, using a Uniform Resource Identifier (or Locator).