private IdentityPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity Identity, bool Personal)
        {
            this.xmppConfiguration = XmppConfiguration;
            this.owner             = Owner;
            this.identity          = Identity;
            this.personal          = Personal;
            this.BindingContext    = this;
            InitializeComponent();

            byte[] Png = QR.GenerateCodePng("iotid:" + Identity.Id, (int)this.QrCode.WidthRequest, (int)this.QrCode.HeightRequest);
            this.QrCode.Source    = ImageSource.FromStream(() => new MemoryStream(Png));
            this.QrCode.IsVisible = true;

            this.CompromizedButton.IsVisible = Personal;
            this.RevokeButton.IsVisible      = Personal;

            if (!Personal)
            {
                this.IdentitySection.Remove(this.NetworkView);
                this.ButtonSection.Remove(this.CompromizedButtonView);
                this.ButtonSection.Remove(this.RevokeButtonView);
            }

            this.LoadPhotos();
        }
Example #2
0
 public AccountPage(XmppConfiguration XmppConfiguration)
 {
     this.xmppConfiguration = XmppConfiguration;
     InitializeComponent();
     this.BindingContext    = this;
     this.Introduction.Text = this.Introduction.Text.Replace("{Binding Domain}", XmppConfiguration.Domain);
 }
        private IdentityPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity Identity, bool Personal, SignaturePetitionEventArgs Review)
        {
            this.xmppConfiguration = XmppConfiguration;
            this.owner             = Owner;
            this.identity          = Identity;
            this.personal          = Personal;
            this.review            = Review;

            this.BindingContext = this;
            InitializeComponent();

            byte[] Png = QR.GenerateCodePng("iotid:" + Identity.Id, (int)this.QrCode.WidthRequest, (int)this.QrCode.HeightRequest);
            this.QrCode.Source    = ImageSource.FromStream(() => new MemoryStream(Png));
            this.QrCode.IsVisible = true;

            if (!Personal)
            {
                this.IdentitySection.Remove(this.NetworkView);
                this.ButtonSection.Remove(this.CompromizedCell);
                this.ButtonSection.Remove(this.RevokeCell);
            }

            if (this.review is null)
            {
                this.ButtonSection.Remove(this.CarefulReviewCell);
                this.ButtonSection.Remove(this.ApprovePiiCell);
                this.ButtonSection.Remove(this.PinCell);
                this.ButtonSection.Remove(this.ApproveReviewCell);
                this.ButtonSection.Remove(this.RejectReviewCell);
            }

            this.LoadPhotos();
        }
Example #4
0
        private async void Initialize()
        {
            instance = this;

            Log.Register(new InternalSink());

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                if (e.IsTerminating)
                {
                    Stop().Wait();
                }
            };

            TaskScheduler.UnobservedTaskException += (sender, e) =>
            {
                e.SetObserved();
            };

            Types.Initialize(
                typeof(App).Assembly,
                typeof(Database).Assembly,
                typeof(FilesProvider).Assembly,
                typeof(ObjectSerializer).Assembly,
                typeof(XmppClient).Assembly,
                typeof(ContractsClient).Assembly,
                typeof(Waher.Things.ThingReference).Assembly,
                typeof(Waher.Runtime.Settings.RuntimeSettings).Assembly,
                typeof(Waher.Runtime.Language.Language).Assembly,
                typeof(Waher.Networking.DNS.DnsResolver).Assembly,
                typeof(Waher.Networking.XMPP.Sensor.SensorClient).Assembly,
                typeof(Waher.Networking.XMPP.Control.ControlClient).Assembly,
                typeof(Waher.Networking.XMPP.Concentrator.ConcentratorClient).Assembly,
                typeof(Waher.Networking.XMPP.P2P.XmppServerlessMessaging).Assembly,
                typeof(Waher.Networking.XMPP.Provisioning.ProvisioningClient).Assembly,
                typeof(Waher.Security.EllipticCurves.EllipticCurve).Assembly);

            string AppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string DataFolder    = Path.Combine(AppDataFolder, "Data");

            FilesProvider Provider = await FilesProvider.CreateAsync(DataFolder, "Default", 8192, 10000, 8192, Encoding.UTF8, 10000, this.GetCustomKey);

            await Provider.RepairIfInproperShutdown(string.Empty);

            Database.Register(Provider);

            configuration = await Database.FindFirstDeleteRest <XmppConfiguration>();

            if (configuration is null)
            {
                await Task.Delay(1000);

                configuration = new XmppConfiguration();
                await Database.Insert(configuration);
            }



            await ShowPage();
        }
Example #5
0
        public IdentityPage(XmppConfiguration XmppConfiguration)
        {
            this.xmppConfiguration = XmppConfiguration;
            this.BindingContext    = this;
            InitializeComponent();

            this.LoadPhotos();
        }
 public NewContractPage(XmppConfiguration XmppConfiguration, Page Owner,
                        SortedDictionary <string, SortedDictionary <string, string> > ContractTypesPerCategory)
 {
     this.xmppConfiguration        = XmppConfiguration;
     this.owner                    = Owner;
     this.contractTypesPerCategory = ContractTypesPerCategory;
     this.BindingContext           = this;
     InitializeComponent();
 }
        public MyContractsPage(XmppConfiguration XmppConfiguration, Page Owner, bool CreatedContracts)
        {
            this.xmppConfiguration = XmppConfiguration;
            this.owner             = Owner;
            this.createdContracts  = CreatedContracts;
            this.BindingContext    = this;
            InitializeComponent();

            this.LoadMyContracts();
        }
        public NewContractPage(XmppConfiguration XmppConfiguration, Page Owner, Contract Template)
        {
            this.xmppConfiguration        = XmppConfiguration;
            this.owner                    = Owner;
            this.contractTypesPerCategory = null;
            this.template                 = Template;
            this.BindingContext           = this;
            InitializeComponent();

            this.ContractCategoryLabel.IsVisible  = false;
            this.ContractCategoryPicker.IsVisible = false;
            this.ContractTypeLabel.IsVisible      = false;
            this.ContractTypePicker.IsVisible     = false;

            this.PopulateTemplateForm();
        }
        public PetitionContractPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity RequestorIdentity, string RequestorFullJid,
                                    Contract RequestedContract, string PetitionId, string Purpose)
        {
            this.owner             = Owner;
            this.requestorIdentity = RequestorIdentity;
            this.requestorFullJid  = RequestorFullJid;
            this.requestedContract = RequestedContract;
            this.petitionId        = PetitionId;
            this.purpose           = Purpose;
            this.BindingContext    = this;
            InitializeComponent();

            ViewContractPage Info = new ViewContractPage(XmppConfiguration, Owner, RequestedContract, true);

            Info.MoveInfo(this.TableView);

            this.LoadPhotos();
        }
        public OperatorPage(XmppConfiguration XmppConfiguration)
        {
            this.xmppConfiguration = XmppConfiguration;
            InitializeComponent();

            int Selected = -1;
            int i        = 0;

            foreach (string Domain in XmppConfiguration.Domains)
            {
                this.Operators.Items.Add(Domain);

                if (Domain == XmppConfiguration.Domain)
                {
                    Selected = i;
                }

                i++;
            }

            this.Operators.Items.Add("<Other>");

            if (!string.IsNullOrEmpty(XmppConfiguration.Domain))
            {
                this.domainName = XmppConfiguration.Domain;

                if (Selected >= 0)
                {
                    this.Operators.SelectedIndex = Selected;
                }
                else
                {
                    this.ConnectButton.IsEnabled = true;
                    this.Operators.IsVisible     = false;
                    this.Domain.IsVisible        = true;
                    this.Domain.Text             = XmppConfiguration.Domain;
                    this.Domain.Keyboard         = Keyboard.Create(KeyboardFlags.None);
                    this.Domain.Focus();
                }
            }
        }
 public IdentityPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity Identity)
     : this(XmppConfiguration, Owner, Identity, XmppConfiguration.LegalIdentity.Id == Identity.Id)
 {
 }
 public IdentityPage(XmppConfiguration XmppConfiguration, Page Owner)
     : this(XmppConfiguration, Owner, XmppConfiguration.LegalIdentity, true)
 {
 }
Example #13
0
 public DefinePinPage(XmppConfiguration XmppConfiguration)
 {
     this.xmppConfiguration = XmppConfiguration;
     InitializeComponent();
     this.BindingContext = this;
 }
Example #14
0
        public ViewContractPage(XmppConfiguration XmppConfiguration, Page Owner, Contract Contract, bool ReadOnly)
        {
            this.xmppConfiguration = XmppConfiguration;
            this.owner             = Owner;
            this.contract          = Contract;
            this.BindingContext    = this;
            InitializeComponent();

            // General Information

            AddTag(this.GeneralInformation, "Created", Contract.Created.ToString());

            if (Contract.Updated != DateTime.MinValue)
            {
                AddTag(this.GeneralInformation, "Updated", Contract.Updated.ToString());
            }

            AddTag(this.GeneralInformation, "State", Contract.State.ToString());
            AddTag(this.GeneralInformation, "Visibility", Contract.Visibility.ToString());
            AddTag(this.GeneralInformation, "Duration", Contract.Duration.ToString());
            AddTag(this.GeneralInformation, "From", Contract.From.ToString());
            AddTag(this.GeneralInformation, "To", Contract.To.ToString());
            AddTag(this.GeneralInformation, "Archiving (optional)", Contract.ArchiveOptional.ToString());
            AddTag(this.GeneralInformation, "Archiving (required)", Contract.ArchiveRequired.ToString());
            AddTag(this.GeneralInformation, "Can act as template", Contract.CanActAsTemplate.ToString());

            // QR Code

            byte[] Png = QR.GenerateCodePng("iotsc:" + Contract.ContractId, (int)this.QrCode.WidthRequest, (int)this.QrCode.HeightRequest);
            this.QrCode.Source    = ImageSource.FromStream(() => new MemoryStream(Png));
            this.QrCode.IsVisible = true;

            // Parts

            bool HasSigned         = false;
            bool AcceptsSignatures =
                (Contract.State == ContractState.Approved || Contract.State == ContractState.BeingSigned) &&
                (!Contract.SignAfter.HasValue || Contract.SignAfter.Value < DateTime.Now) &&
                (!Contract.SignBefore.HasValue || Contract.SignBefore.Value > DateTime.Now);
            Dictionary <string, int> NrSignatures = new Dictionary <string, int>();

            if (!(Contract.ClientSignatures is null))
            {
                foreach (ClientSignature Signature in Contract.ClientSignatures)
                {
                    if (Signature.LegalId == this.xmppConfiguration.LegalIdentity.Id)
                    {
                        HasSigned = true;
                    }

                    if (!NrSignatures.TryGetValue(Signature.Role, out int Count))
                    {
                        Count = 0;
                    }

                    NrSignatures[Signature.Role] = Count + 1;
                }
            }

            if (Contract.SignAfter.HasValue)
            {
                AddTag(this.Parts, "Sign after", Contract.SignAfter.Value.ToString());
            }

            if (Contract.SignBefore.HasValue)
            {
                AddTag(this.Parts, "Sign before", Contract.SignBefore.Value.ToString());
            }

            AddTag(this.Parts, "Mode", Contract.PartsMode.ToString());

            if (!(Contract.Parts is null))
            {
                TapGestureRecognizer OpenLegalId = new TapGestureRecognizer();
                OpenLegalId.Tapped += this.ShowLegalId;

                foreach (Part Part in Contract.Parts)
                {
                    AddTag(this.Parts, Part.Role, Part.LegalId, false, Part.LegalId, OpenLegalId);

                    if (!ReadOnly && AcceptsSignatures && !HasSigned && Part.LegalId == this.xmppConfiguration.LegalIdentity.Id)
                    {
                        Button Button;

                        this.Parts.Add(new ViewCell()
                        {
                            View = Button = new Button()
                            {
                                Text    = "Sign as " + Part.Role,
                                StyleId = Part.Role
                            }
                        });

                        Button.Clicked += SignButton_Clicked;
                    }
                }
            }

            // Roles

            if (!(Contract.Roles is null))
            {
                foreach (Role Role in Contract.Roles)
                {
                    string Html = Role.ToHTML(Contract.DefaultLanguage, Contract);
                    Html = Waher.Content.Html.HtmlDocument.GetBody(Html);

                    AddTag(this.Roles, Role.Name, Html + CountString(Role.MinCount, Role.MaxCount), true, string.Empty, null);

                    if (!ReadOnly && AcceptsSignatures && !HasSigned && this.contract.PartsMode == ContractParts.Open &&
                        (!NrSignatures.TryGetValue(Role.Name, out int Count) || Count < Role.MaxCount))
                    {
                        Button Button;

                        this.Roles.Add(new ViewCell()
                        {
                            View = Button = new Button()
                            {
                                Text    = "Sign as " + Role.Name,
                                StyleId = Role.Name
                            }
                        });

                        Button.Clicked += SignButton_Clicked;
                    }
                }
            }

            // Parameters

            if (!(Contract.Parameters is null))
            {
                foreach (Parameter Parameter in Contract.Parameters)
                {
                    AddTag(this.Parameters, Parameter.Name, Parameter.ObjectValue?.ToString());
                }
            }

            // Human-readable text

            string      Xaml          = Contract.ToXamarinForms(Contract.DefaultLanguage);
            StackLayout HumanReadable = new StackLayout().LoadFromXaml(Xaml);

            List <View> Children = new List <View>();

            Children.AddRange(HumanReadable.Children);

            foreach (View Element in Children)
            {
                this.HumanReadableText.Children.Add(Element);
            }

            // Machine-readable information

            AddTag(this.MachineReadableSection, "Contract ID", Contract.ContractId.ToString());

            if (!string.IsNullOrEmpty(Contract.TemplateId))
            {
                AddTag(this.MachineReadableSection, "Template ID", Contract.TemplateId);
            }

            AddTag(this.MachineReadableSection, "Digest", Convert.ToBase64String(Contract.ContentSchemaDigest));
            AddTag(this.MachineReadableSection, "Hash Function", Contract.ContentSchemaHashFunction.ToString());
            AddTag(this.MachineReadableSection, "Local Name", Contract.ForMachinesLocalName.ToString());
            AddTag(this.MachineReadableSection, "Namespace", Contract.ForMachinesNamespace.ToString());

            // Client signatures

            if (!(Contract.ClientSignatures is null))
            {
                TapGestureRecognizer OpenClientSignature = new TapGestureRecognizer();
                OpenClientSignature.Tapped += this.ShowClientSignature;

                foreach (ClientSignature Signature in Contract.ClientSignatures)
                {
                    string Sign = Convert.ToBase64String(Signature.DigitalSignature);

                    AddTag(this.ClientSignatures, Signature.Role, Signature.LegalId + ", " + Signature.BareJid + ", " +
                           Signature.Timestamp.ToString() + ", " + Sign, false, Sign, OpenClientSignature);
                }
            }

            // Server signature

            if (!(Contract.ServerSignature is null))
            {
                TapGestureRecognizer OpenServerSignature = new TapGestureRecognizer();
                OpenServerSignature.Tapped += this.ShowServerSignature;

                AddTag(this.ServerSignature, Contract.Provider, Contract.ServerSignature.Timestamp.ToString() + ", " +
                       Convert.ToBase64String(Contract.ServerSignature.DigitalSignature), false, Contract.ContractId, OpenServerSignature);
            }

            // Buttons

            if (!ReadOnly && !Contract.IsLegallyBinding(true))
            {
                Button Button;

                this.ButtonSection.Insert(0, new ViewCell()
                {
                    View = Button = new Button()
                    {
                        Text = "Obsolete Contract"
                    }
                });

                Button.Clicked += ObsoleteButton_Clicked;

                this.ButtonSection.Insert(1, new ViewCell()
                {
                    View = Button = new Button()
                    {
                        Text = "Delete Contract"
                    }
                });

                Button.Clicked += DeleteButton_Clicked;
            }

            this.LoadPhotos();
        }
 public IdentityPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity Identity, SignaturePetitionEventArgs Review)
     : this(XmppConfiguration, Owner, Identity, XmppConfiguration.LegalIdentity.Id == Identity.Id, Review)
 {
 }