/// Create New Accept User Dialog public AcceptUser(PeerSocket peer) { XML xml = new XML(null, "AcceptUserDialog.glade", "dialog", null); xml.Autoconnect(this); // Get UserInfo UserInfo userInfo = peer.Info as UserInfo; // Initialize GUI this.labelTitle.Text = "<span size='x-large'><b>Accept User</b> ("; if (userInfo.SecureAuthentication == true) { this.image.Pixbuf = StockIcons.GetPixbuf("SecureAuth"); this.labelTitle.Text += "Secure"; this.dialog.Title += " (Secure Authentication)"; } else { this.image.Pixbuf = StockIcons.GetPixbuf("InsecureAuth"); this.labelTitle.Text += "Insecure"; this.dialog.Title += " (Insecure Authentication)"; } this.labelTitle.Text += ")</span>"; this.labelTitle.UseMarkup = true; entryName.Text = userInfo.Name; entryIP.Text = peer.GetRemoteIP().ToString(); this.dialog.ShowAll(); }
// ============================================ // PUBLIC STATIC Methods // ============================================ /// Generate Peer's Magic public static string GenerateMagic(PeerSocket peer) { UserInfo myInfo = MyInfo.GetInstance(); string userIp = CryptoUtils.SHA1String(peer.GetRemoteIP().ToString()); string userMagic = CryptoUtils.SHA1String((string) myInfo.Informations["magic"]); return(CryptoUtils.MD5String(userIp + userMagic)); }
// =================================================== // PRIVATE (Methods) Protocol Event Handler // =================================================== private void OnAcceptFileEvent(PeerSocket peer, XmlRequest xml) { try { string path = (string) xml.Attributes["path"]; UserInfo userInfo = peer.Info as UserInfo; UploadManager.Add(userInfo, path); } catch (Exception e) { Glue.Dialogs.MessageError("Accept File", "Peer Ip: " + peer.GetRemoteIP().ToString() + "\n" + e.Message); } }