1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
10using System.Collections.ObjectModel;
11using System.ComponentModel;
38 this.navigationArguments = Args;
47 this.@
event = Args.
Event;
66 if (this.FriendlyName == this.BareJid)
69 this.RemoteFriendlyNameAvailable = this.RemoteFriendlyName != this.RemoteJid;
70 if (!this.RemoteFriendlyNameAvailable)
78 await base.OnInitializeAsync();
80 if (this.navigationArguments is not
null)
86 if (Thing?.MetaData is not
null)
93 this.CallerInContactsList = Caller is not
null;
94 if (Caller?.MetaData is not
null)
100 if (this.navigationArguments.UserTokens is not
null &&
this.navigationArguments.UserTokens.Length > 0)
108 if (this.navigationArguments.ServiceTokens is not
null &&
this.navigationArguments.ServiceTokens.Length > 0)
113 this.HasService =
true;
116 if (this.navigationArguments.DeviceTokens is not
null &&
this.navigationArguments.DeviceTokens.Length > 0)
121 this.HasDevice =
true;
126 SortedDictionary<string, bool> PermittedFields = [];
127 string[]? AllFields = this.navigationArguments.AllFields;
129 if (AllFields is
null && !
string.IsNullOrEmpty(this.BareJid))
133 if (AllFields is not
null && this.navigationArguments.Event is not
null)
135 this.navigationArguments.Event.AllFields = AllFields;
140 bool AllFieldsPermitted = this.navigationArguments.Fields is
null;
142 if (AllFields is not
null)
144 foreach (
string Field in AllFields)
145 PermittedFields[
Field] = AllFieldsPermitted;
148 if (!AllFieldsPermitted && this.navigationArguments?.
Fields is not
null)
150 foreach (
string Field in this.navigationArguments.Fields)
151 PermittedFields[
Field] =
true;
154 foreach (KeyValuePair<string, bool> P
in PermittedFields)
156 FieldReference
Field =
new(P.Key, P.Value);
175 this.SelectedRuleRangeIndex = 0;
184 public ObservableCollection<HumanReadableTag>
Tags {
get; }
189 public ObservableCollection<HumanReadableTag>
CallerTags {
get; }
194 public ObservableCollection<FieldReference>
Fields {
get; }
199 public ObservableCollection<RuleRangeModel>
RuleRanges {
get; }
205 private string? bareJid;
211 private string? friendlyName;
217 private string? remoteJid;
223 private string? remoteFriendlyName;
229 private bool remoteFriendlyNameAvailable;
241 private bool hasUser;
247 private bool hasService;
253 private bool hasDevice;
259 private string? provisioningService;
265 private bool callerInContactsList;
271 private int selectedRuleRangeIndex;
283 [NotifyCanExecuteChangedFor(nameof(AcceptCommand))]
284 private bool permitMomentary;
290 [NotifyCanExecuteChangedFor(nameof(AcceptCommand))]
291 private bool permitIdentity;
297 [NotifyCanExecuteChangedFor(nameof(AcceptCommand))]
298 private bool permitStatus;
304 [NotifyCanExecuteChangedFor(nameof(AcceptCommand))]
305 private bool permitComputed;
311 [NotifyCanExecuteChangedFor(nameof(AcceptCommand))]
312 private bool permitPeak;
318 [NotifyCanExecuteChangedFor(nameof(AcceptCommand))]
319 private bool permitHistorical;
325 private string? nodeId;
331 private string? sourceId;
337 private string? partitionId;
345 private static Task Click(
object obj)
349 else if (obj is
string s)
352 return Task.CompletedTask;
359 private async Task AddContact()
361 if (!this.CallerInContactsList)
365 BareJid = this.RemoteJid,
366 FriendlyName = (this.RemoteFriendlyNameAvailable ? this.RemoteFriendlyName : this.RemoteJid) ??
string.Empty
371 this.CallerInContactsList =
true;
379 private async Task RemoveContact()
381 if (this.CallerInContactsList)
384 if (Info is not
null)
387 this.CallerInContactsList =
false;
394 [RelayCommand(CanExecute = nameof(CanExecuteAccept))]
395 private void Accept()
403 base.OnPropertyChanged(e);
405 switch (e.PropertyName)
407 case nameof(this.IsConnected):
408 this.AcceptCommand.NotifyCanExecuteChanged();
413 private bool CanExecuteAccept()
415 if (!this.IsConnected)
418 if (this.PermitMomentary || this.PermitIdentity || this.PermitStatus || this.PermitComputed || this.PermitPeak || this.PermitHistorical)
433 [RelayCommand(CanExecute = nameof(IsConnected))]
434 private void Reject()
439 private void Respond(
bool Accepts)
441 if (this.SelectedRuleRangeIndex >= 0)
444 ThingReference Thing =
new(this.NodeId, this.SourceId, this.PartitionId);
447 if (this.PermitMomentary)
450 if (this.PermitIdentity)
453 if (this.PermitStatus)
456 if (this.PermitComputed)
462 if (this.PermitHistorical)
467 ReadoutRequestResolver Resolver =
new(this.BareJid ??
string.Empty, this.RemoteFriendlyName ??
string.Empty,
RuleRange);
474 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts, FieldTypes,
this.GetFields(), Thing, this.ResponseHandler, Resolver);
479 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts, FieldTypes,
this.GetFields(), Thing, this.ResponseHandler, Resolver);
484 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts, FieldTypes,
this.GetFields(), Thing, this.ResponseHandler, Resolver);
491 ReadoutRequestResolver Resolver =
new(this.BareJid ??
string.Empty, this.RemoteFriendlyName ??
string.Empty, Token);
497 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts, FieldTypes,
this.GetFields(), Token.Token, Thing, this.ResponseHandler, Resolver);
502 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts, FieldTypes,
this.GetFields(), Token.Token, Thing, this.ResponseHandler, Resolver);
507 this.BareJid!,
this.RemoteJid!,
this.Key!, Accepts, FieldTypes,
this.GetFields(), Token.Token, Thing, this.ResponseHandler, Resolver);
514 private string[]? GetFields()
516 List<string> Result = [];
517 bool AllPermitted =
true;
519 foreach (FieldReference
Field in this.Fields)
524 AllPermitted =
false;
537 if (this.@event is not
null)
542 MainThread.BeginInvokeOnMainThread(async () =>
558 private async Task Ignore()
560 if (this.@event is not
null)
570 private void AllFieldTypes()
572 this.PermitMomentary =
true;
573 this.PermitIdentity =
true;
574 this.PermitStatus =
true;
575 this.PermitComputed =
true;
576 this.PermitPeak =
true;
577 this.PermitHistorical =
true;
584 private void NoFieldTypes()
586 this.PermitMomentary =
false;
587 this.PermitIdentity =
false;
588 this.PermitStatus =
false;
589 this.PermitComputed =
false;
590 this.PermitPeak =
false;
591 this.PermitHistorical =
false;
598 private void AllFields()
600 foreach (FieldReference
Field in this.Fields)
601 Field.Permitted =
true;
608 private void NoFields()
610 foreach (FieldReference
Field in this.Fields)
611 Field.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[]?> GetAvailableFieldNames(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-read provisioning question.
FieldType FieldTypes
Field Types
new? CanReadNotificationEvent Event
Notification event objcet.
The view model to bind to when displaying a thing.
ObservableCollection< HumanReadableTag > CallerTags
Holds a list of meta-data tags associated with the caller.
ObservableCollection< HumanReadableTag > Tags
Holds a list of meta-data tags associated with a thing.
override void OnPropertyChanged(PropertyChangedEventArgs e)
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
ObservableCollection< FieldReference > Fields
Holds a list of fields that will be permitted.
ObservableCollection< RuleRangeModel > RuleRanges
Available Rule Ranges
CanReadViewModel(CanReadNavigationArgs? Args)
Creates an instance of the CanReadViewModel class.
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.
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.
Base class for all sensor data fields.
string Name
Unlocalized field name.
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
FieldType
Field Type flags