1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
9using System.Collections.ObjectModel;
23 private readonly PhotosLoader photosLoader;
24 private readonly
string? requestorFullJid;
25 private readonly
string? requestedIdentityId;
26 private readonly
string? petitionId;
27 private readonly
string? bareJid;
35 this.photosLoader =
new PhotosLoader(this.
Photos);
39 this.RequestorIdentity = Args.RequestorIdentity;
40 this.requestorFullJid = Args.RequestorFullJid;
41 this.requestedIdentityId = Args.RequestedIdentityId;
42 this.petitionId = Args.PetitionId;
43 this.Purpose = Args.Purpose;
45 if (!
string.IsNullOrEmpty(this.requestorFullJid))
47 else if (Args.RequestorIdentity is not
null)
48 this.bareJid = Args.RequestorIdentity.GetJid();
50 this.bareJid =
string.Empty;
57 await base.OnInitializeAsync();
59 if (!
string.IsNullOrEmpty(this.bareJid))
66 Info.
LegalId !=
this.RequestorIdentity?.Id &&
71 Info.LegalId = this.LegalId;
79 this.ThirdPartyInContacts = Info is not
null;
82 this.AssignProperties();
83 EvaluateAllCommands();
88 private async
void ReloadPhotos()
92 this.photosLoader.CancelLoadPhotos();
96 if (Attachments is not
null)
98 Photo? First = await this.photosLoader.LoadPhotos(Attachments,
SignWith.LatestApprovedId);
100 this.FirstPhotoSource = First?.Source;
101 this.FirstPhotoRotation = First?.Rotation ?? 0;
113 this.photosLoader.CancelLoadPhotos();
115 await base.OnDisposeAsync();
118 private static void EvaluateAllCommands()
125 public ObservableCollection<Photo>
Photos {
get; } = [];
133 private async Task Accept()
140 return ServiceRef.
XmppService.SendPetitionIdentityResponse(this.requestedIdentityId, this.petitionId!,
141 this.requestorFullJid!,
true);
146 bool AddContact =
false;
148 if (!this.ThirdPartyInContacts)
158 await this.AddContact();
167 private async Task Decline()
171 return ServiceRef.
XmppService.SendPetitionIdentityResponse(this.requestedIdentityId, this.petitionId!,
172 this.requestorFullJid!,
false);
180 private async Task Ignore()
194 private DateTime created;
200 private DateTime? updated;
206 private DateTime? expires;
212 private string? legalId;
218 private string? networkId;
230 private DateTime? from;
236 private DateTime? to;
242 [NotifyPropertyChangedFor(nameof(FullName))]
243 private string? firstName;
249 [NotifyPropertyChangedFor(nameof(FullName))]
250 private string? middleNames;
256 [NotifyPropertyChangedFor(nameof(FullName))]
257 private string? lastNames;
263 private string? personalNumber;
269 private string? address;
275 private string? address2;
281 private string? zipCode;
287 private string? area;
293 private string? city;
299 private string? region;
305 private string? countryCode;
311 private string? nationalityCode;
317 private string? gender;
323 private DateTime? birthDate;
329 private string? orgName;
335 private string? orgNumber;
341 private string? orgDepartment;
347 private string? orgRole;
353 private string? orgAddress;
359 private string? orgAddress2;
365 private string? orgZipCode;
371 private string? orgArea;
377 private string? orgCity;
383 private string? orgRegion;
389 private string? orgCountryCode;
401 private bool hasPhotos;
407 private string? phoneNr;
413 private string? eMail;
419 private string? deviceId;
425 private bool isApproved;
431 private string? purpose;
437 [NotifyCanExecuteChangedFor(nameof(AddContactCommand))]
438 [NotifyCanExecuteChangedFor(nameof(RemoveContactCommand))]
439 private bool thirdPartyInContacts;
445 private ImageSource? firstPhotoSource;
451 private int firstPhotoRotation;
455 private void AssignProperties()
485 if (!
string.IsNullOrEmpty(BirthDayStr) &&
int.TryParse(BirthDayStr, out
int BirthDay) &&
486 !
string.IsNullOrEmpty(BirthMonthStr) &&
int.TryParse(BirthMonthStr, out
int BirthMonth) &&
487 !
string.IsNullOrEmpty(BirthYearStr) &&
int.TryParse(BirthYearStr, out
int BirthYear))
491 this.BirthDate =
new DateTime(BirthYear, BirthMonth, BirthDay);
496 this.BirthDate =
null;
512 !
string.IsNullOrEmpty(this.OrgName) ||
513 !
string.IsNullOrEmpty(this.OrgNumber) ||
514 !
string.IsNullOrEmpty(this.OrgDepartment) ||
515 !
string.IsNullOrEmpty(this.OrgRole) ||
516 !
string.IsNullOrEmpty(this.OrgAddress) ||
517 !
string.IsNullOrEmpty(this.OrgAddress2) ||
518 !
string.IsNullOrEmpty(this.OrgZipCode) ||
519 !
string.IsNullOrEmpty(this.OrgArea) ||
520 !
string.IsNullOrEmpty(this.OrgCity) ||
521 !
string.IsNullOrEmpty(this.OrgRegion) ||
522 !
string.IsNullOrEmpty(this.OrgCountryCode);
523 this.HasPhotos = this.Photos.Count > 0;
527 this.IsApproved = this.RequestorIdentity.State ==
IdentityState.Approved;
531 this.Created = DateTime.MinValue;
550 this.BirthDate =
null;
563 this.HasPhotos =
false;
567 this.IsApproved =
false;
575 private async Task Copy(
object Item)
579 if (Item is
string Label)
581 if (Label == this.LegalId)
590 await Clipboard.SetTextAsync(Label);
613 private async Task AddContact()
635 FriendlyName = FriendlyName,
643 Info.LegalId = this.requestedIdentityId;
645 Info.FriendlyName = FriendlyName;
653 this.ThirdPartyInContacts =
true;
670 private async Task RemoveContact()
684 if (Info is not
null)
692 if (Item is not
null)
695 this.ThirdPartyInContacts =
false;
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.
A strongly-typed resource class, for looking up localized strings, etc.
static string Yes
Looks up a localized string similar to Yes.
static string Cancel
Looks up a localized string similar to Cancel.
static string WouldYouLikeToAddThisIdentityToYourContacts
Looks up a localized string similar to Would you like to add this identity to your contacts?...
static string AreYouSureYouWantToRemoveContact
Looks up a localized string similar to Are you sure you want to remove this contact from your list of...
static string IdCopiedSuccessfully
Looks up a localized string similar to A link to the ID was copied to the clipboard....
static string TagValueCopiedToClipboard
Looks up a localized string similar to Tag value copied to clipboard.
static string Confirm
Looks up a localized string similar to Confirm.
static string AddContact
Looks up a localized string similar to Add Contact.
static string No
Looks up a localized string similar to No.
static string SuccessTitle
Looks up a localized string similar to Success.
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 IAttachmentCacheService AttachmentCacheService
AttachmentCache service.
static IReportingStringLocalizer 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.
bool CanRemoveContact
If RemoveContactCommand can be executed.
override async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
bool CanAddContact
If AddContactCommand can be executed.
override async Task OnDisposeAsync()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
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, Attachment? Attachment)
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.