1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
8using System.Collections.ObjectModel;
20 private readonly PhotosLoader photosLoader;
21 private readonly
string? requestorFullJid;
22 private readonly
string? requestedIdentityId;
23 private readonly
string? petitionId;
24 private readonly
string? bareJid;
32 this.photosLoader =
new PhotosLoader(this.
Photos);
36 this.RequestorIdentity = Args.RequestorIdentity;
37 this.requestorFullJid = Args.RequestorFullJid;
38 this.requestedIdentityId = Args.RequestedIdentityId;
39 this.petitionId = Args.PetitionId;
40 this.Purpose = Args.Purpose;
42 if (!
string.IsNullOrEmpty(this.requestorFullJid))
44 else if (Args.RequestorIdentity is not
null)
45 this.bareJid = Args.RequestorIdentity.GetJid();
47 this.bareJid =
string.Empty;
54 await base.OnInitialize();
56 if (!
string.IsNullOrEmpty(this.bareJid))
63 Info.
LegalId !=
this.RequestorIdentity?.Id &&
68 Info.LegalId = this.LegalId;
76 this.ThirdPartyInContacts = Info is not
null;
79 this.AssignProperties();
80 EvaluateAllCommands();
85 private async
void ReloadPhotos()
89 this.photosLoader.CancelLoadPhotos();
93 if (Attachments is not
null)
95 Photo? First = await this.photosLoader.LoadPhotos(Attachments,
SignWith.LatestApprovedId);
97 this.FirstPhotoSource = First?.Source;
98 this.FirstPhotoRotation = First?.Rotation ?? 0;
110 this.photosLoader.CancelLoadPhotos();
112 await base.OnDispose();
115 private static void EvaluateAllCommands()
122 public ObservableCollection<Photo>
Photos {
get; } = [];
130 private async Task Accept()
137 return ServiceRef.
XmppService.SendPetitionIdentityResponse(this.requestedIdentityId, this.petitionId!,
138 this.requestorFullJid!,
true);
146 private async Task Decline()
150 return ServiceRef.
XmppService.SendPetitionIdentityResponse(this.requestedIdentityId, this.petitionId!,
151 this.requestorFullJid!,
false);
159 private async Task Ignore()
173 private DateTime created;
179 private DateTime? updated;
185 private DateTime? expires;
191 private string? legalId;
197 private string? networkId;
209 private DateTime? from;
215 private DateTime? to;
221 [NotifyPropertyChangedFor(nameof(FullName))]
222 private string? firstName;
228 [NotifyPropertyChangedFor(nameof(FullName))]
229 private string? middleNames;
235 [NotifyPropertyChangedFor(nameof(FullName))]
236 private string? lastNames;
242 private string? personalNumber;
248 private string? address;
254 private string? address2;
260 private string? zipCode;
266 private string? area;
272 private string? city;
278 private string? region;
284 private string? countryCode;
290 private string? nationalityCode;
296 private string? gender;
302 private DateTime? birthDate;
308 private string? orgName;
314 private string? orgNumber;
320 private string? orgDepartment;
326 private string? orgRole;
332 private string? orgAddress;
338 private string? orgAddress2;
344 private string? orgZipCode;
350 private string? orgArea;
356 private string? orgCity;
362 private string? orgRegion;
368 private string? orgCountryCode;
380 private bool hasPhotos;
386 private string? phoneNr;
392 private string? eMail;
398 private string? deviceId;
404 private bool isApproved;
410 private string? purpose;
416 [NotifyCanExecuteChangedFor(nameof(AddContactCommand))]
417 [NotifyCanExecuteChangedFor(nameof(RemoveContactCommand))]
418 private bool thirdPartyInContacts;
424 private ImageSource? firstPhotoSource;
430 private int firstPhotoRotation;
434 private void AssignProperties()
464 if (!
string.IsNullOrEmpty(BirthDayStr) &&
int.TryParse(BirthDayStr, out
int BirthDay) &&
465 !
string.IsNullOrEmpty(BirthMonthStr) &&
int.TryParse(BirthMonthStr, out
int BirthMonth) &&
466 !
string.IsNullOrEmpty(BirthYearStr) &&
int.TryParse(BirthYearStr, out
int BirthYear))
470 this.BirthDate =
new DateTime(BirthYear, BirthMonth, BirthDay);
475 this.BirthDate =
null;
491 !
string.IsNullOrEmpty(this.OrgName) ||
492 !
string.IsNullOrEmpty(this.OrgNumber) ||
493 !
string.IsNullOrEmpty(this.OrgDepartment) ||
494 !
string.IsNullOrEmpty(this.OrgRole) ||
495 !
string.IsNullOrEmpty(this.OrgAddress) ||
496 !
string.IsNullOrEmpty(this.OrgAddress2) ||
497 !
string.IsNullOrEmpty(this.OrgZipCode) ||
498 !
string.IsNullOrEmpty(this.OrgArea) ||
499 !
string.IsNullOrEmpty(this.OrgCity) ||
500 !
string.IsNullOrEmpty(this.OrgRegion) ||
501 !
string.IsNullOrEmpty(this.OrgCountryCode);
502 this.HasPhotos = this.Photos.Count > 0;
506 this.IsApproved = this.RequestorIdentity.State ==
IdentityState.Approved;
510 this.Created = DateTime.MinValue;
529 this.BirthDate =
null;
542 this.HasPhotos =
false;
546 this.IsApproved =
false;
554 private async Task Copy(
object Item)
558 if (Item is
string Label)
560 if (Label == this.LegalId)
569 await Clipboard.SetTextAsync(Label);
592 private async Task AddContact()
614 FriendlyName = FriendlyName,
622 Info.LegalId = this.requestedIdentityId;
624 Info.FriendlyName = FriendlyName;
632 this.ThirdPartyInContacts =
true;
649 private async Task RemoveContact()
663 if (Info is not
null)
671 if (Item is not
null)
674 this.ThirdPartyInContacts =
false;
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.
const string IotId
The IoT ID URI Scheme (iotid)
XMPP Protocol Properties.
const string PersonalNumber
Personal number
const string OrgAddress2
Organization Address line 2
const string DeviceId
Device ID
const string Country
Country
const string OrgArea
Organization Area
const string Region
Region
const string OrgRegion
Organization Region
const string Nationality
Nationality
const string ZipCode
Zip Code
const string BirthYear
Birth Year
const string OrgCity
Organization City
const string OrgRole
Organization Role
const string Phone
Phone number
const string EMail
e-Mail address
const string OrgZipCode
Organization Zip Code
const string MiddleNames
Middle names
const string BirthDay
Birth Day
const string OrgCountry
Organization Country
const string OrgDepartment
Organization Department
const string Address2
Address line 2
const string OrgAddress
Organization Address line 1
const string Address
Address line 1
const string LastNames
Last names
const string OrgNumber
Organization number
const string BirthMonth
Birth Month
const string FirstName
First name
const string Gender
Gender
const string OrgName
Organization name
A set of never changing property constants and helpful values.
const string NotAvailableValue
A generic "no value available" string.
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 IAttachmentCacheService AttachmentCacheService
AttachmentCache service.
static IStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
The view model to bind to when displaying petitioning of an identity in a view or page.
ObservableCollection< Photo > Photos
The list of photos related to the identity being petitioned.
LegalIdentity? RequestorIdentity
The identity of the requestor.
override async Task OnDispose()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
bool CanRemoveContact
If RemoveContactCommand can be executed.
bool CanAddContact
If AddContactCommand can be executed.
PetitionIdentityViewModel(PetitionIdentityNavigationArgs? Args)
Creates a new instance of the PetitionIdentityViewModel class.
Contains a reference to an attachment assigned to a legal object.
DateTime From
From what point in time the legal identity is valid.
DateTime Updated
When the identity object was last updated
DateTime To
To what point in time the legal identity is valid.
DateTime Created
When the identity object was created
IdentityState State
Current state of identity
string Id
ID of the legal identity
Attachment[] Attachments
Attachments assigned to the legal identity.
Maintains information about an item in the roster.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static string GetBareJID(string JID)
Gets the Bare JID from a JID, which may be a Full JID.
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 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.
Task Flush()
Persists any pending changes.
class Photo(byte[] Binary, int Rotation)
Class containing information about a photo.
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.
IdentityState
Lists recognized legal identity states.
SignWith
Options on what keys to use when signing data.