Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
IdentityNotificationEvent.cs
1using System.Text;
2using System.Xml;
3using Microsoft.Maui.Controls.Shapes;
9
11{
16 {
17 private LegalIdentity? identity;
18
23 : base()
24 {
25 }
26
31 public IdentityNotificationEvent(SignaturePetitionEventArgs e)
32 : base()
33 {
34 this.Identity = e.RequestorIdentity;
35 this.Category = e.RequestorIdentity.Id;
36 this.RequestorFullJid = e.RequestorFullJid;
37 this.SignatoryIdentityId = e.SignatoryIdentityId;
38 this.PetitionId = e.PetitionId;
39 this.Purpose = e.Purpose;
40 this.ContentToSign = e.ContentToSign;
41 this.Type = NotificationEventType.Contracts;
42 this.Received = DateTime.UtcNow;
43 }
44
49 public IdentityNotificationEvent(LegalIdentityPetitionEventArgs e)
50 : base()
51 {
52 this.Identity = e.RequestorIdentity;
53 this.Category = e.RequestorIdentity.Id;
54 this.RequestorFullJid = e.RequestorFullJid;
55 this.SignatoryIdentityId = e.RequestedIdentityId;
56 this.PetitionId = e.PetitionId;
57 this.Purpose = e.Purpose;
58 this.ContentToSign = null;
59 this.Type = NotificationEventType.Identities;
60 this.Received = DateTime.UtcNow;
61 }
62
67 public IdentityNotificationEvent(SignaturePetitionResponseEventArgs e)
68 : base()
69 {
70 this.Identity = e.RequestedIdentity;
71 this.Category = e.RequestedIdentity.Id;
72 this.Type = NotificationEventType.Identities;
73 this.PetitionId = e.PetitionId;
74 this.ContentToSign = e.Signature;
75 this.Received = DateTime.UtcNow;
76 }
77
82 public IdentityNotificationEvent(LegalIdentityPetitionResponseEventArgs e)
83 : base()
84 {
85 this.Identity = e.RequestedIdentity;
86 this.Category = e.RequestedIdentity.Id;
87 this.PetitionId = e.PetitionId;
88 this.Type = NotificationEventType.Identities;
89 }
90
94 public string? RequestorFullJid { get; }
95
99 public string? SignatoryIdentityId { get; }
100
104 public string? PetitionId { get; }
105
109 public string? Purpose { get; }
110
114 public byte[]? ContentToSign { get; }
115
119 public string? IdentityXml { get; set; }
120
126 {
127 get
128 {
129 if (this.identity is null && !string.IsNullOrEmpty(this.IdentityXml))
130 {
131 XmlDocument Doc = new()
132 {
133 PreserveWhitespace = true
134 };
135 Doc.LoadXml(this.IdentityXml);
136
137 this.identity = LegalIdentity.Parse(Doc.DocumentElement);
138 }
139
140 return this.identity;
141 }
142
143 set
144 {
145 this.identity = value;
146
147 if (value is null)
148 this.IdentityXml = null;
149 else
150 {
151 StringBuilder Xml = new();
152 value.Serialize(Xml, true, true, true, true, true, true, true);
153 this.IdentityXml = Xml.ToString();
154 }
155 }
156 }
157
162 public override Task<Geometry> GetCategoryIcon()
163 {
164 return Task.FromResult(Geometries.PersonPath);
165 }
166
170 public override Task<string> GetDescription()
171 {
172 if (this.identity is null)
173 return Task.FromResult(string.Empty);
174 else
175 return Task.FromResult(ContactInfo.GetFriendlyName(this.identity));
176 }
177
181 public override async Task Prepare()
182 {
183 if (this.identity?.Attachments is not null)
184 {
185 foreach (Attachment Attachment in this.identity.Attachments.GetImageAttachments())
186 {
187 try
188 {
189 await PhotosLoader.LoadPhoto(Attachment);
190 }
191 catch (Exception ex)
192 {
193 ServiceRef.LogService.LogException(ex);
194 }
195 }
196 }
197 }
198
199 }
200}
Contains information about a contact.
Definition: ContactInfo.cs:21
static async Task< string > GetFriendlyName(CaseInsensitiveString RemoteId)
Gets the friendly name of a remote identity (Legal ID or Bare JID).
Definition: ContactInfo.cs:257
IdentityNotificationEvent(LegalIdentityPetitionResponseEventArgs e)
Abstract base class of Identity notification events.
IdentityNotificationEvent(SignaturePetitionEventArgs e)
Abstract base class of Identity notification events.
override async Task Prepare()
Performs perparatory tasks, that will simplify opening the notification.
IdentityNotificationEvent()
Abstract base class of Identity notification events.
override Task< string > GetDescription()
Gets a descriptive text for the category of event.
override Task< Geometry > GetCategoryIcon()
Gets an icon for the category of event.
IdentityNotificationEvent(LegalIdentityPetitionEventArgs e)
Abstract base class of Identity notification events.
IdentityNotificationEvent(SignaturePetitionResponseEventArgs e)
Abstract base class of Identity notification events.
Base class that references services in the app.
Definition: ServiceRef.cs:31
static ILogService LogService
Log service.
Definition: ServiceRef.cs:91
Static class containing SVG Paths for symbols used in the app.
Definition: Geometries.cs:11
static readonly Geometry PersonPath
Person button glyph
Definition: Geometries.cs:460
Contains a reference to an attachment assigned to a legal object.
Definition: Attachment.cs:9
abstract class NotificationEvent()
Abstract base class of notification events.
NotificationEventType
Button on which event is to be displayed.