1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
11using System.Collections.ObjectModel;
12using System.ComponentModel;
37 this.navigationArguments = Args;
46 this.@
event = Args.
Event;
57 if (this.FriendlyName == this.BareJid)
60 this.RemoteFriendlyNameAvailable = this.RemoteFriendlyName != this.RemoteJid;
61 if (!this.RemoteFriendlyNameAvailable)
69 await base.OnInitializeAsync();
71 if (this.navigationArguments is not
null)
77 if (Thing?.MetaData is not
null)
84 this.CallerInContactsList = Caller is not
null;
85 if (Caller?.MetaData is not
null)
91 if (this.navigationArguments.UserTokens is not
null &&
this.navigationArguments.UserTokens.Length > 0)
99 if (this.navigationArguments.ServiceTokens is not
null &&
this.navigationArguments.ServiceTokens.Length > 0)
104 this.HasService =
true;
107 if (this.navigationArguments.DeviceTokens is not
null &&
this.navigationArguments.DeviceTokens.Length > 0)
112 this.HasDevice =
true;
117 SortedDictionary<string, bool> PermittedParameters = [];
118 string[]? AllParameters = this.navigationArguments.AllParameters;
120 if (AllParameters is
null && !
string.IsNullOrEmpty(this.BareJid))
123 new ThingReference(this.NodeId, this.SourceId, this.PartitionId));
125 if (AllParameters is not
null && this.navigationArguments?.Event is not
null)
127 this.navigationArguments.Event.AllParameters = AllParameters;
132 bool AllParametersPermitted = this.navigationArguments?.Parameters is
null;
134 if (AllParameters is not
null)
136 foreach (
string Parameter in AllParameters)
137 PermittedParameters[
Parameter] = AllParametersPermitted;
140 if (!AllParametersPermitted && this.navigationArguments?.
Parameters is not
null)
142 foreach (
string Parameter in this.navigationArguments.Parameters)
146 foreach (KeyValuePair<string, bool> P
in PermittedParameters)
148 FieldReference
Parameter =
new(P.Key, P.Value);
167 this.SelectedRuleRangeIndex = 0;
176 public ObservableCollection<HumanReadableTag>
Tags {
get; }
181 public ObservableCollection<HumanReadableTag>
CallerTags {
get; }
186 public ObservableCollection<FieldReference>
Parameters {
get; }
191 public ObservableCollection<RuleRangeModel>
RuleRanges {
get; }
197 private string? bareJid;
203 private string? friendlyName;
209 private string? remoteJid;
216 private string? remoteFriendlyName;
222 private bool remoteFriendlyNameAvailable;
234 private bool hasUser;
240 private bool hasService;
246 private bool hasDevice;
252 private string? provisioningService;
258 private bool callerInContactsList;
264 private int selectedRuleRangeIndex;
270 private string? nodeId;
276 private string? sourceId;
282 private string? partitionId;
290 private static Task Click(
object obj)
294 else if (obj is
string s)
297 return Task.CompletedTask;
304 private async Task AddContact()
306 if (!this.CallerInContactsList)
310 BareJid = this.RemoteJid,
311 FriendlyName = (this.RemoteFriendlyNameAvailable ? this.RemoteFriendlyName : this.RemoteJid) ??
string.Empty
316 this.CallerInContactsList =
true;
324 private async Task RemoveContact()
326 if (this.CallerInContactsList && !
string.IsNullOrEmpty(this.RemoteJid))
329 if (Info is not
null)
332 this.CallerInContactsList =
false;
339 [RelayCommand(CanExecute = nameof(CanExecuteAccept))]
340 private void Accept()
348 base.OnPropertyChanged(e);
350 switch (e.PropertyName)
352 case nameof(this.IsConnected):
353 this.AcceptCommand.NotifyCanExecuteChanged();
358 private bool CanExecuteAccept()
360 if (!this.IsConnected)
365 if (Parameter.Permitted)
375 [RelayCommand(CanExecute = nameof(IsConnected))]
376 private void Reject()
381 private void Respond(
bool Accepts)
383 if (this.SelectedRuleRangeIndex >= 0)
386 ThingReference Thing =
new(this.NodeId, this.SourceId, this.PartitionId);
390 ControlRequestResolver Resolver =
new(this.BareJid!, this.RemoteFriendlyName ??
string.Empty,
RuleRange);
397 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts,
this.GetParameters(), Thing, this.ResponseHandler, Resolver);
402 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts,
this.GetParameters(), Thing, this.ResponseHandler, Resolver);
407 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts,
this.GetParameters(), Thing, this.ResponseHandler, Resolver);
414 ControlRequestResolver Resolver =
new(this.BareJid!, this.RemoteFriendlyName ??
string.Empty, Token);
420 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts,
this.GetParameters(), Token.Token, Thing, this.ResponseHandler, Resolver);
425 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts,
this.GetParameters(), Token.Token, Thing, this.ResponseHandler, Resolver);
430 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts,
this.GetParameters(), Token.Token, Thing, this.ResponseHandler, Resolver);
437 private string[]? GetParameters()
439 List<string> Result = [];
440 bool AllPermitted =
true;
442 foreach (FieldReference
Parameter in this.Parameters)
447 AllPermitted =
false;
460 if (this.@event is not
null)
465 MainThread.BeginInvokeOnMainThread(async () =>
481 private async Task Ignore()
483 if (this.@event is not
null)
493 private void AllParameters()
495 foreach (FieldReference
Parameter in this.Parameters)
496 Parameter.Permitted =
true;
503 private void NoParameters()
505 foreach (FieldReference
Parameter in this.Parameters)
506 Parameter.Permitted =
false;
A strongly-typed resource class, for looking up localized strings, etc.
static string ToService
Looks up a localized string similar to To service, regardless of source.
static string NotAvailable
Looks up a localized string similar to Not Available.
static string Device
Looks up a localized string similar to Device.
static string UnableToRespond
Looks up a localized string similar to Unable to respond to request..
static string ToDevice
Looks up a localized string similar to To device, regardless of source.
static string CallerOnly
Looks up a localized string similar to Caller Only.
static string ToUser
Looks up a localized string similar to To user, regardless of source.
static string Service
Looks up a localized string similar to Service.
static string EntireDomain
Looks up a localized string similar to Everyone from {0}.
static string Everyone
Looks up a localized string similar to Everyone.
static string User
Looks up a localized string similar to User.
Contains information about a request to read a thing.
static async Task< string[]?> GetAvailableParameterNames(string BareJid, ThingReference Thing)
Gets available fields for a thing.
A record of a token used in provisioning.
string? FriendlyName
Friendly Name of certificate
Base class that references services in the app.
static IUiService UiService
Service serializing and managing UI-related tasks.
static INotificationService NotificationService
Service for managing notifications for the user.
static ITagProfile TagProfile
TAG Profile service.
static IReportingStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
Holds navigation parameters specific to displaying the can-control provisioning question.
new? CanControlNotificationEvent Event
Notification event objcet.
The view model to bind to when displaying a thing.
override void OnPropertyChanged(PropertyChangedEventArgs e)
ObservableCollection< RuleRangeModel > RuleRanges
Available Rule Ranges
CanControlViewModel(CanControlNavigationArgs? Args)
Creates an instance of the CanControlViewModel class.
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
ObservableCollection< HumanReadableTag > Tags
Holds a list of meta-data tags associated with a thing.
ObservableCollection< HumanReadableTag > CallerTags
Holds a list of meta-data tags associated with the caller.
ObservableCollection< FieldReference > Parameters
Holds a list of parameters that will be permitted.
string? PartitionId
Partition ID
string? SourceId
Source ID
Class used to present a meta-data tag in a human interface.
string? Key
Provisioning key
string? BareJid
Bare JID of device.
string? RemoteFriendlyName
Friendly name of remote entity.
string? FriendlyName
Friendly name of device.
string? RemoteJid
Bare JID of remote entity trying to connect to device.
string? ProvisioningService
Provisioning Service
The view model to bind to for when displaying thing claim information.
static async Task LabelClicked(string Name, string Value, string LocalizedValue)
Processes the click of a localized meta-data label.
A view model that holds the XMPP state.
Abstract base class for contractual parameters
string Name
Parameter name
Event arguments for responses to IQ queries.
bool Ok
If the response is an OK result response (true), or an error response (false).
object State
State object passed to the original request.
XmppException StanzaError
Any stanza error returned.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static string GetDomain(string JID)
Gets the domain part of a JID.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static async Task Delete(object Object)
Deletes an object in the database.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Contains a reference to a thing
Interface for event resolvers. Such can be used to resolve multiple pending notifications at once.
Task DeleteEvents(NotificationEventType Type, CaseInsensitiveString Category)
Deletes events for a given button and category.
Task DeleteResolvedEvents(IEventResolver Resolver)
Deletes pending events that have already been resolved.
TokenType
Provisioning Token Type
abstract class NotificationEvent()
Abstract base class of notification events.
class RuleRangeModel(object RuleRange, string Label)
Rule Range model
RuleRange
Range of a rule change