Пример #1
0
        public AcceptKeyDialog(Network network, ReceivedKeyEventArgs args)
            : base(null, "AcceptKeyDialog")
        {
            var publicKey = new PublicKey(args.Key.Info, args.Key.Key);
            keyTextView.Buffer.Text = publicKey.ToArmoredString();
            string nodeID = FileFind.Common.SHA512Str(publicKey.Key);
            nodeIdLabel.Text = nodeID;

            if (args.Node != null)  {
                if (nodeID.ToUpper() != args.Node.NodeID.ToUpper()) {
                    throw new Exception ("The key recieved does not match this user!");
                }
                nicknameLabel.Text = args.Node.NickName;
            } else if (args.Connection != null) {
                var conn = args.Connection;

                connectionLabel.Text = String.Format("{0} ({1})", conn.RemoteAddress, conn.Incoming ? "Incoming" : "Outgoing");
                nicknameLabel.Text = args.Key.Info;

                connectionLabel.Show();
                connectionTitleLabel.Show();
            } else {
                nicknameLabel.Text = args.Key.Info;
            }

            denyKeyButtonLabel.Text = String.Format ("Deny Key ({0})", secondsLeft);
        }
Пример #2
0
        private void AskAcceptKey(Network network, ReceivedKeyEventArgs args, 
		                           AutoResetEvent receiveKeyWait, 
		                           ref bool acceptKey)
        {
            try {
                AcceptKeyDialog dialog = new AcceptKeyDialog(network, args);
                int response = dialog.Run();

                acceptKey = (response == (int)ResponseType.Ok);

                receiveKeyWait.Set ();

            } catch (Exception ex) {
                LoggingService.LogError(ex);
                Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
            }
        }
Пример #3
0
        private bool network_ReceivedKey(Network network, ReceivedKeyEventArgs args)
        {
            try {
                bool accept = false;
                AutoResetEvent receiveKeyWait = new AutoResetEvent (false);

                Application.Invoke(delegate {
                    AskAcceptKey(network, args, receiveKeyWait, ref accept);
                });

                receiveKeyWait.WaitOne ();
                return accept;

            } catch (Exception ex) {
                LoggingService.LogError(ex);
                return false;
            }
        }
Пример #4
0
 protected virtual bool OnReceivedKey(ReceivedKeyEventArgs args)
 {
     if (ReceivedKey != null) {
         return ReceivedKey (this, args);
     } else {
         return false;
     }
 }