1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
10using System.Collections.ObjectModel;
11using System.ComponentModel;
12using System.Text.RegularExpressions;
40 if (this.Uri is not
null)
44 this.RegistryJid =
null;
50 if (
string.Equals(Tag.
Name,
"R", StringComparison.OrdinalIgnoreCase))
54 if (
string.IsNullOrEmpty(this.RegistryJid))
63 MainThread.BeginInvokeOnMainThread(() =>
66 this.ClaimThingCommand.NotifyCanExecuteChanged();
69 return Task.CompletedTask;
83 public ObservableCollection<HumanReadableTag>
Tags {
get; }
89 private bool makePublic;
95 private string? registryJid;
103 private static Task Click(
object obj)
106 return LabelClicked(Tag.Name, Tag.Value, Tag.LocalizedValue);
107 else if (obj is
string s)
110 return Task.CompletedTask;
119 public static async Task
LabelClicked(
string Name,
string Value,
string LocalizedValue)
126 if (
System.Uri.TryCreate(
"https://" + Value, UriKind.Absolute, out Uri? Uri) && await Launcher.TryOpenAsync(Uri))
131 if (
System.Uri.TryCreate(Value, UriKind.Absolute, out Uri) && await Launcher.TryOpenAsync(Uri))
147 if (
System.Uri.TryCreate(
"https://" +
SRV.
TargetHost, UriKind.Absolute, out Uri) && await Launcher.TryOpenAsync(Uri))
152 if ((Value.StartsWith(
"http://", StringComparison.CurrentCultureIgnoreCase) ||
153 Value.StartsWith(
"https://", StringComparison.CurrentCultureIgnoreCase)) &&
154 System.Uri.TryCreate(Value, UriKind.Absolute, out Uri) &&
155 await Launcher.TryOpenAsync(Uri))
163 if (M.Success && M.Index == 0 && M.Length == Value.Length)
166 if (Info is not
null)
172 int i = Value.IndexOf(
'@');
173 if (i > 0 && Guid.TryParse(Value[..i], out
_))
197 await Clipboard.SetTextAsync(LocalizedValue);
243 base.OnPropertyChanged(e);
245 switch (e.PropertyName)
247 case nameof(this.IsConnected):
248 this.ClaimThingCommand.NotifyCanExecuteChanged();
257 private async Task ClaimThing()
261 if (
string.IsNullOrEmpty(this.Uri))
270 if (!Succeeded || e is
null)
285 this.Tags.Remove(Tag);
296 LegalId =
string.Empty,
298 FriendlyName = FriendlyName ??
string.Empty,
301 SourceId = e.Node.SourceId,
302 Partition = e.Node.Partition,
303 NodeId = e.Node.NodeId,
305 RegistryJid = this.RegistryJid
312 Info.FriendlyName = FriendlyName ??
string.Empty;
325 string Msg = e.ErrorText;
326 if (
string.IsNullOrEmpty(Msg))
346 List<Property> Result = [];
361 List<Property> Result = [];
XMPP Protocol Properties.
A set of never changing property constants and helpful values.
A strongly-typed resource class, for looking up localized strings, etc.
static string TagValueCopiedToClipboard
Looks up a localized string similar to Tag value copied to clipboard.
static string SuccessTitle
Looks up a localized string similar to Success.
static string UnableToClaimThing
Looks up a localized string similar to Unable to claim thing.
static string ErrorTitle
Looks up a localized string similar to An error has occurred.
Base class that references services in the app.
static IServiceProvider Provider
The service provider for the app. This is set before the app is started, and will be used to resolve ...
static ILogService LogService
Log service.
static INetworkService NetworkService
Network service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static INavigationService NavigationService
The navigation service for navigating between pages.
static IReportingStringLocalizer 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
Event arguments for node callback methods.
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.