1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
9using System.Collections.ObjectModel;
10using System.ComponentModel;
11using System.Text.RegularExpressions;
36 if (this.Uri is not
null)
40 this.RegistryJid =
null;
46 if (
string.Equals(Tag.
Name,
"R", StringComparison.OrdinalIgnoreCase))
50 if (
string.IsNullOrEmpty(this.RegistryJid))
59 MainThread.BeginInvokeOnMainThread(() =>
62 this.ClaimThingCommand.NotifyCanExecuteChanged();
65 return Task.CompletedTask;
79 public ObservableCollection<HumanReadableTag>
Tags {
get; }
85 private bool makePublic;
91 private string? registryJid;
99 private static Task Click(
object obj)
102 return LabelClicked(Tag.Name, Tag.Value, Tag.LocalizedValue);
103 else if (obj is
string s)
106 return Task.CompletedTask;
115 public static async Task
LabelClicked(
string Name,
string Value,
string LocalizedValue)
122 if (System.Uri.TryCreate(
"https://" + Value, UriKind.Absolute, out Uri? Uri) && await Launcher.TryOpenAsync(Uri))
127 if (System.Uri.TryCreate(Value, UriKind.Absolute, out Uri) && await Launcher.TryOpenAsync(Uri))
143 if (System.Uri.TryCreate(
"https://" +
SRV.
TargetHost, UriKind.Absolute, out Uri) && await Launcher.TryOpenAsync(Uri))
148 if ((Value.StartsWith(
"http://", StringComparison.CurrentCultureIgnoreCase) ||
149 Value.StartsWith(
"https://", StringComparison.CurrentCultureIgnoreCase)) &&
150 System.Uri.TryCreate(Value, UriKind.Absolute, out Uri) &&
151 await Launcher.TryOpenAsync(Uri))
159 if (M.Success && M.Index == 0 && M.Length == Value.Length)
162 if (Info is not
null)
168 int i = Value.IndexOf(
'@');
169 if (i > 0 && Guid.TryParse(Value[..i], out _))
193 await Clipboard.SetTextAsync(LocalizedValue);
239 base.OnPropertyChanged(e);
241 switch (e.PropertyName)
243 case nameof(this.IsConnected):
244 this.ClaimThingCommand.NotifyCanExecuteChanged();
253 private async Task ClaimThing()
257 if (
string.IsNullOrEmpty(this.Uri))
266 if (!Succeeded || e is
null)
281 this.Tags.Remove(Tag);
291 LegalId =
string.Empty,
293 FriendlyName = FriendlyName ??
string.Empty,
296 SourceId = e.Node.SourceId,
297 Partition = e.Node.Partition,
298 NodeId = e.Node.NodeId,
300 RegistryJid = this.RegistryJid
307 Info.FriendlyName = FriendlyName ??
string.Empty;
318 string Msg = e.ErrorText;
319 if (
string.IsNullOrEmpty(Msg))
339 List<Property> Result = [];
354 List<Property> Result = [];
The Application class, representing an instance of the Neuro-Access app.
static Task< bool > AuthenticateUser(AuthenticationPurpose Purpose, bool Force=false)
Authenticates the user using the configured authentication method.
XMPP Protocol Properties.
A set of never changing property constants and helpful values.
Base class that references services in the app.
static ILogService LogService
Log service.
static INetworkService NetworkService
Network service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static IStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
Holds navigation parameters specific to views displaying a list of contacts.
A page that displays a list of the current user's contacts.
A page to display when the user wants to view an identity.
Class used to present a meta-data tag in a human interface.
Holds navigation parameters specific to claiming things.
string? Uri
The iotdisco claim URI
The view model to bind to for when displaying thing claim information.
ViewClaimThingViewModel(ViewClaimThingNavigationArgs? Args)
Creates an instance of the ViewClaimThingViewModel class.
bool CanClaimThing
Gets or sets whether a user can claim a thing.
static ? string GetFriendlyName(IEnumerable< Property > Tags)
Get Friendly name of thing
static ? string GetFriendlyName(IEnumerable< HumanReadableTag > Tags)
Get Friendly name of thing
override void OnPropertyChanged(PropertyChangedEventArgs e)
override Task XmppService_ConnectionStateChanged(object? Sender, XmppState NewState)
Listens to connection state changes from the XMPP server.
static Property[] ToProperties(IEnumerable< HumanReadableTag > Tags)
Converts an enumerable set of HumanReadableTag to an enumerable set of Property.
static async Task LabelClicked(string Name, string Value, string LocalizedValue)
Processes the click of a localized meta-data label.
static ? string GetFriendlyName(IEnumerable< MetaDataTag > Tags)
Get Friendly name of thing
ObservableCollection< HumanReadableTag > Tags
Holds a list of meta-data tags associated with a thing.
static Property[] ToProperties(IEnumerable< MetaDataTag > Tags)
Converts an enumerable set of MetaDataTag to an enumerable set of Property.
Holds navigation parameters specific to viewing things.
A page that displays information about a thing and allows the user to interact with it.
A view model that holds the XMPP state.
virtual void SetConnectionStateAndText(XmppState State)
Sets both the connection state and connection text to the appropriate value.
DNS resolver, as defined in:
static Task< SRV > LookupServiceEndpoint(string DomainName, string ServiceName, string Protocol)
Looks up a service endpoint for a domain. If multiple are available, an appropriate one is selected a...
string TargetHost
Target Host
Maintains information about an item in the roster.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static readonly Regex BareJidRegEx
Regular expression for Bare JIDs
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static IDatabaseProvider Provider
Registered database provider.
static async Task Update(object Object)
Updates an object in the database.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Task Flush()
Persists any pending changes.
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.
XmppState
State of XMPP connection.