public ChatMessageView(BitChat chat, ChatListItem chatItem) { InitializeComponent(); _chat = chat; _chatItem = chatItem; _chat.MessageReceived += _chat_MessageReceived; _chat.PeerAdded += _chat_PeerAdded; _chat.PeerTyping += _chat_PeerTyping; _chat.PeerHasRevokedCertificate += _chat_PeerHasRevokedCertificate; _chat.PeerSecureChannelException += _chat_PeerSecureChannelException; if (_chat.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat) { if (_chat.NetworkName == null) this.Title = _chat.PeerEmailAddress.Address; else this.Title = _chat.NetworkName + " <" + _chat.PeerEmailAddress.Address + ">"; } else { this.Title = _chat.NetworkName; } }
public void RemoveBitChat(BitChat chat) { lock (_service._bitChats) { _service._bitChats.Remove(chat); } }
public BitChatPanel(BitChat chat, ChatListItem chatItem) { InitializeComponent(); _chat = chat; _chat.FileAdded += _chat_FileAdded; _chat.PeerAdded += _chat_PeerAdded; _chat.MessageReceived += _chat_MessageReceived; //create view _view = new ChatMessageView(_chat, chatItem); _view.Dock = DockStyle.Fill; _view.AllowDrop = true; _view.SettingsModified += _view_SettingsModified; _view.DragEnter += lstFiles_DragEnter; _view.DragDrop += lstFiles_DragDrop; //load all peers foreach (BitChat.Peer peer in _chat.GetPeerList()) { lstUsers.AddItem(new UserListItem(peer)); peer.StateChanged += _view.peer_StateChanged; peer.StateChanged += peer_StateChanged; } //load all files foreach (SharedFile sharedFile in _chat.GetSharedFileList()) _chat_FileAdded(chat, sharedFile); //add view to panel bitChatPanelSplitContainer.Panel1.Controls.Add(_view); }
public frmChatProperties(BitChat chat) { InitializeComponent(); _chat = chat; if (_chat.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat) { label1.Text = "Peer's Email Address"; txtNetwork.Text = chat.PeerEmailAddress.Address; } else { txtNetwork.Text = chat.NetworkName; } foreach (TrackerClient tracker in _chat.GetTrackers()) { ListViewItem item = lstTrackerInfo.Items.Add(tracker.TrackerUri.AbsoluteUri); item.Tag = tracker; item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); } _timer = new Timer(); _timer.Interval = 1000; _timer.Tick += _timer_Tick; _timer.Start(); }
internal Peer(BitChatNetwork.VirtualPeer virtualPeer, BitChat bitchat) { _virtualPeer = virtualPeer; _bitchat = bitchat; _isSelfPeer = (_virtualPeer.PeerCertificate.IssuedTo.EmailAddress.Address == _bitchat._profile.LocalCertificateStore.Certificate.IssuedTo.EmailAddress.Address); _virtualPeer.PacketReceived += _virtualPeer_PacketReceived; _virtualPeer.StreamStateChanged += _virtualPeer_StreamStateChanged; }
public BitChat CreateBitChat(string networkName, string sharedSecret) { BitChat bitChat = _manager.CreateBitChat(networkName, sharedSecret, null, new Certificate[] { }, new BitChatProfile.SharedFileInfo[] { }, null); lock (_bitChats) { _bitChats.Add(bitChat); } return(bitChat); }
public BitChat CreateBitChat(MailAddress peerEmailAddress, string sharedSecret) { BitChat bitChat = _manager.CreateBitChat(peerEmailAddress, sharedSecret, null, new Certificate[] { }, new BitChatProfile.SharedFileInfo[] { }, null); lock (_bitChats) { _bitChats.Add(bitChat); } return(bitChat); }
public ChatMessageItem(BitChat.Peer senderPeer, string message, DateTime date, bool myMessage) { InitializeComponent(); _senderPeer = senderPeer; _date = date; lblUsername.Text = _senderPeer.PeerCertificate.IssuedTo.Name; txtMessage.Text = message; lblDateTime.Text = date.ToString("HH:mm"); if (myMessage) lblUsername.ForeColor = Color.FromArgb(63, 186, 228); OnResize(EventArgs.Empty); }
public SharedFileItem(SharedFile file, BitChat chat) { InitializeComponent(); _file = file; _chat = chat; _fileSizeFormatted = WebUtilities.GetFormattedSize(_file.MetaData.FileSize); labFileName.Text = _file.MetaData.FileName; labSpeed.Text = ""; if (_file.TotalPeers > 1) labInfo1.Text = _fileSizeFormatted + " (" + _file.TotalPeers + " peers)"; else labInfo1.Text = _fileSizeFormatted + " (" + _file.TotalPeers + " peer)"; _file.FileDownloadStarted += OnFileDownloadStarted; _file.FileDownloaded += OnFileDownloaded; _file.BlockDownloaded += OnBlockDownloaded; _file.PeerCountUpdate += OnPeerCountUpdate; _file.FileTransferSpeedUpdate += OnFileTransferSpeedUpdate; _file.FileRemoved += OnFileRemoved; if (_file.State == SharedFileState.Advertisement) { _type = SharedFileItemType.Advertisement; this.BackColor = _BackColorAvailable; pbFileProgress.Visible = false; } else if (_file.IsComplete) { _type = SharedFileItemType.Sharing; labSpeed.ForeColor = Color.Blue; pbFileProgress.Visible = false; } else { _type = SharedFileItemType.Downloading; pbFileProgress.Visible = true; pbFileProgress.Value = _file.PercentComplete; } }
public UserListItem(BitChat.Peer peer) { InitializeComponent(); _peer = peer; _peer.StateChanged += _peer_StateChanged; _peer.NetworkStatusUpdated += _peer_NetworkStatusUpdated; if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.Name)) { string name = _peer.PeerCertificate.IssuedTo.Name; if (name.Length > 0) { labIcon.Text = name.Substring(0, 1).ToUpper(); int x = name.LastIndexOf(" ", StringComparison.CurrentCultureIgnoreCase); if (x > 0) { labIcon.Text += name.Substring(x + 1, 1).ToUpper(); } else if (name.Length > 1) { labIcon.Text += name.Substring(1, 1).ToLower(); } } else { labIcon.Text = ""; } labName.Text = name; } else { labIcon.Text = ""; labName.Text = "{missing name}"; labName.ForeColor = Color.Red; } labEmail.Text = _peer.PeerCertificate.IssuedTo.EmailAddress.Address; _peer_StateChanged(null, null); _peer_NetworkStatusUpdated(null, null); }
private void _chat_MessageReceived(BitChat.Peer sender, string message) { bool myMessage = sender.PeerCertificate.IssuedTo.EmailAddress.Address.Equals(_chat.LocalCertificate.IssuedTo.EmailAddress.Address); AddMessage(new ChatMessageItem(sender, message, DateTime.Now, myMessage)); if (!_chatItem.Selected) _chatItem.SetNewMessage(sender.PeerCertificate.IssuedTo.Name + ": " + message); ShowPeerTypingNotification(sender.PeerCertificate.IssuedTo.Name, false); }
private void _chat_PeerHasRevokedCertificate(BitChat sender, InvalidCertificateException ex) { AddMessage(new ChatMessageInfoItem(ex.Message)); }
private void _chat_PeerAdded(BitChat sender, BitChat.Peer peer) { lstUsers.AddItem(new UserListItem(peer)); peer.StateChanged += _view.peer_StateChanged; peer.StateChanged += peer_StateChanged; }
private void _chat_MessageReceived(BitChat.Peer sender, string message) { MessageNotification(_chat, sender, message); }
private void _chat_FileAdded(BitChat sender, SharedFile sharedFile) { SharedFileItem item = new SharedFileItem(sharedFile, _chat); item.FileRemoved += OnFileRemoved; lstFiles.AddItem(item); }
private void chatPanel_MessageNotification(BitChat sender, BitChat.Peer messageSender, string message) { sndMessageNotification.Play(); }
private void AddChatView(BitChat chat) { string title; if (chat.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat) { if (chat.NetworkName == null) title = chat.PeerEmailAddress.Address; else title = chat.NetworkName; } else { title = chat.NetworkName; } ChatListItem itm = new ChatListItem(title); BitChatPanel chatPanel = new BitChatPanel(chat, itm); chatPanel.Dock = DockStyle.Fill; chatPanel.SettingsModified += chatPanel_SettingsModified; chatPanel.MessageNotification += chatPanel_MessageNotification; mainContainer.Panel2.Controls.Add(chatPanel); itm.Tag = chatPanel; lstChats.AddItem(itm); if (lstChats.Controls.Count == 1) ShowSelectedChatView(); }
private void _chat_PeerAdded(BitChat sender, BitChat.Peer peer) { AddMessage(new ChatMessageInfoItem(peer.PeerCertificate.IssuedTo.Name + " joined chat", DateTime.Now)); if (sender.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat) { _chatItem.SetTitle(peer.PeerCertificate.IssuedTo.Name); this.Title = peer.PeerCertificate.IssuedTo.Name + " <" + peer.PeerCertificate.IssuedTo.EmailAddress.Address + ">"; } }
public frmViewUser(BitChat.Peer peer) { InitializeComponent(); _peer = peer; //name if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.Name)) { string name = _peer.PeerCertificate.IssuedTo.Name; //name icon if (name.Length > 0) { labIcon.Text = name.Substring(0, 1).ToUpper(); int x = name.LastIndexOf(" ", StringComparison.CurrentCultureIgnoreCase); if (x > 0) { labIcon.Text += name.Substring(x + 1, 1).ToUpper(); } else if (name.Length > 1) { labIcon.Text += name.Substring(1, 1).ToLower(); } } else { labIcon.Text = ""; } if (_peer.IsOnline) labIcon.BackColor = Color.FromArgb(102, 153, 255); else labIcon.BackColor = Color.Gray; labName.Text = name; } else { labIcon.Text = ""; labName.Text = "{missing name}"; labName.ForeColor = Color.Red; } //email if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.EmailAddress)) { labEmail.Text = _peer.PeerCertificate.IssuedTo.EmailAddress.Address; } else { labEmail.Text = "{missing email address}"; labEmail.ForeColor = Color.Red; } //location if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.City | CertificateProfileFlags.State | CertificateProfileFlags.Country)) { labLocation.Text = ""; if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.City)) labLocation.Text = _peer.PeerCertificate.IssuedTo.City + ", "; if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.State)) labLocation.Text += _peer.PeerCertificate.IssuedTo.State + ", "; if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.Country)) labLocation.Text += _peer.PeerCertificate.IssuedTo.Country; } else { labLocation.Text = "{missing location}"; labLocation.ForeColor = Color.Red; } //network status switch (_peer.NetworkStatus) { case BitChatNetworkStatus.NoNetwork: labNetworkStatus.Text = "No Network"; labNetworkStatus.ForeColor = Color.DimGray; picNetwork.Image = BitChatAppMono.Properties.Resources.NoNetwork; break; case BitChatNetworkStatus.PartialNetwork: labNetworkStatus.Text = "Partial Network"; labNetworkStatus.ForeColor = Color.OrangeRed; picNetwork.Image = BitChatAppMono.Properties.Resources.PartialNetwork; break; case BitChatNetworkStatus.FullNetwork: labNetworkStatus.Text = "Full Network"; labNetworkStatus.ForeColor = Color.Green; picNetwork.Image = BitChatAppMono.Properties.Resources.FullNetwork; break; default: labNetworkStatus.Text = "Unknown"; labNetworkStatus.ForeColor = Color.DimGray; picNetwork.Image = BitChatAppMono.Properties.Resources.NoNetwork; break; } //cipher suite labCipherSuite.Text = _peer.CipherSuite.ToString(); //connected with PeerInfo[] connectedWith = _peer.ConnectedWith; foreach (PeerInfo peerInfo in connectedWith) { string peerIPs = null; foreach (IPEndPoint peerEP in peerInfo.PeerEPList) { if (peerIPs == null) peerIPs = peerEP.ToString(); else peerIPs += ", " + peerEP.ToString(); } lstConnectedWith.Items.Add(peerInfo.PeerEmail).SubItems.Add(peerIPs); } //not connected with PeerInfo[] notConnectedWith = _peer.NotConnectedWith; foreach (PeerInfo peerInfo in notConnectedWith) { string peerIPs = null; foreach (IPEndPoint peerEP in peerInfo.PeerEPList) { if (peerIPs == null) peerIPs = peerEP.ToString(); else peerIPs += ", " + peerEP.ToString(); } lstNotConnectedWith.Items.Add(peerInfo.PeerEmail).SubItems.Add(peerIPs); } }
private void _chat_PeerSecureChannelException(BitChat sender, SecureChannelException ex) { string peerInfo; if (ex.PeerCertificate == null) peerInfo = "[" + ex.PeerEP.ToString() + "]"; else peerInfo = ex.PeerCertificate.IssuedTo.Name + " <" + ex.PeerCertificate.IssuedTo.EmailAddress.Address + "> [" + ex.PeerEP.ToString() + "]"; string desc; if (ex.Code == SecureChannelCode.RemoteError) desc = "RemoteError: " + (ex.InnerException as SecureChannelException).Code.ToString(); else desc = ex.Code.ToString(); AddMessage(new ChatMessageInfoItem("Secure channel with peer '" + peerInfo + "' encountered '" + desc + "' exception.", DateTime.Now)); }
private void _chat_PeerTyping(BitChat sender, BitChat.Peer peer) { ShowPeerTypingNotification(peer.PeerCertificate.IssuedTo.Name, true); }
private void chatPanel_MessageNotification(BitChat sender, BitChat.Peer messageSender, string message) { if (!this.Visible || !ApplicationIsActivated()) { if (messageSender == null) notifyIcon1.ShowBalloonTip(30000, sender.NetworkName + " - Bit Chat", message, ToolTipIcon.Info); else notifyIcon1.ShowBalloonTip(30000, sender.NetworkName + " - Bit Chat", messageSender.PeerCertificate.IssuedTo.Name + ": " + message, ToolTipIcon.Info); sndMessageNotification.Play(); } }