public MessageNode(MailView view, LocalMail message) { View = view; Message = message; SubItems.Add(""); SubItems.Add(""); }
private void AddMessage(LocalMail message, bool ensureVisible) { bool local = (message.Header.TargetID == Core.UserID); if (local && !ReceivedButton.Checked) { return; } if (!local && !SentButton.Checked) { return; } // find thread id and add to thread MessageNode node = new MessageNode(this, message); // interate through parents foreach (MessageNode parent in MessageView.Nodes) { if (Utilities.MemCompare(parent.Message.Header.MailID, node.Message.Header.MailID)) { parent.UpdateRow(); return; } // iterate through children if (parent.Message.Header.ThreadID == message.Header.ThreadID) { foreach (MessageNode child in parent.Nodes) { if (Utilities.MemCompare(child.Message.Header.MailID, node.Message.Header.MailID)) { child.UpdateRow(); return; } } // not found add to thread parent.Nodes.Add(node); node.UpdateRow(); if (!message.Header.Read || ensureVisible) { parent.Expand(); } return; } } // thread not found add as parent, sort new to old MessageView.Nodes.Insert(0, node); node.UpdateRow(); // update here so node knows whether to put subject or quip }
public void Mail_ShowCompose(ulong userID, LocalMail message, string title, string body) { ComposeMail compose = new ComposeMail(UI, Mail, userID); compose.CustomTitle = title; compose.ThreadID = message.Header.ThreadID; compose.SubjectTextBox.Text = message.Info.Subject; compose.SubjectTextBox.Enabled = false; compose.SubjectTextBox.BackColor = System.Drawing.Color.WhiteSmoke; //crit attach files UI.ShowView(compose, true); }
public MessageMenuItem(LocalMail message, string text, Image icon, EventHandler onClick) : base(text, icon, onClick) { Message = message; }
public MessageMenuItem(LocalMail message) { Message = message; }
private void MessageHeader_Navigating(object sender, WebBrowserNavigatingEventArgs e) { string url = e.Url.OriginalString; if (GuiUtils.IsRunningOnMono() && url.StartsWith("wyciwyg")) { return; } url = url.Replace("http://", ""); url = url.TrimEnd('/'); string[] parts = url.Split('/'); if (parts.Length < 1) { return; } if (MessageView.SelectedNodes.Count == 0) { return; } if (parts[0] == "about") { return; } MessageNode item = MessageView.SelectedNodes[0] as MessageNode; if (item == null) { return; } LocalMail message = item.Message; if (parts[0] == "attach" && parts.Length > 1) { int index = int.Parse(parts[1]); if (index < message.Attached.Count) { string path = Core.User.RootPath + Path.DirectorySeparatorChar + "Downloads" + Path.DirectorySeparatorChar + message.Attached[index].Name; try { if (!File.Exists(path)) { Utilities.ExtractAttachedFile(Mail.GetLocalPath(message.Header), message.Header.LocalKey, message.Header.FileStart, message.Attached.Select(a => a.Size).ToArray(), index, path); } Process.Start(path); } catch (Exception ex) { MessageBox.Show(this, "Error Opening Attachment: " + ex.Message); } } } if (parts[0] == "reply") { Message_Reply(new MessageMenuItem(message), null); } else if (parts[0] == "forward") { Message_Forward(new MessageMenuItem(message), null); } else if (parts[0] == "delete") { Message_Delete(new MessageMenuItem(message), null); } e.Cancel = true; }
private void ShowMessage(LocalMail message) { if (message == null) { SetHeader(""); MessageBody.Clear(); return; } string content = "<b><font size=2>" + message.Info.Subject + "</font></b> from " + Core.GetName(message.Header.SourceID) + ", sent " + Utilities.FormatTime(message.Info.Date) + @"<br> <b>To:</b> " + Mail.GetNames(message.To) + "<br>"; if (message.CC.Count > 0) { content += "<b>CC:</b> " + Mail.GetNames(message.CC) + "<br>"; } if (message.Attached.Count > 1) { string attachHtml = ""; for (int i = 0; i < message.Attached.Count; i++) { if (message.Attached[i].Name == "body") { continue; } attachHtml += "<a href='http://attach/" + i.ToString() + "'>" + message.Attached[i].Name + "</a> (" + Utilities.ByteSizetoString(message.Attached[i].Size) + "), "; } attachHtml = attachHtml.TrimEnd(new char[] { ' ', ',' }); content += "<b>Attachments: </b> " + attachHtml; } content += "<br>"; string actions = ""; if (message.Header.TargetID == Core.UserID) { actions += @"<a href='http://reply" + "'>Reply</a>"; } actions += @", <a href='http://forward'>Forward</a>"; actions += @", <a href='http://delete'>Delete</a>"; content += "<b>Actions: </b>" + actions.Trim(',', ' '); SetHeader(content); // body try { using (TaggedStream stream = new TaggedStream(Mail.GetLocalPath(message.Header), Core.GuiProtocol)) using (CryptoStream crypto = IVCryptoStream.Load(stream, message.Header.LocalKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = message.Header.FileStart; while (bytesLeft > 0) { int readSize = (bytesLeft > buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= read; } // load file foreach (MailFile file in message.Attached) { if (file.Name == "body") { byte[] msgBytes = new byte[file.Size]; crypto.Read(msgBytes, 0, (int)file.Size); UTF8Encoding utf = new UTF8Encoding(); MessageBody.Clear(); MessageBody.SelectionFont = new Font("Tahoma", 9.75f); MessageBody.SelectionColor = Color.Black; if (message.Info.Format == TextFormat.RTF) { MessageBody.Rtf = utf.GetString(msgBytes); } else { MessageBody.Text = utf.GetString(msgBytes); } MessageBody.DetectLinksDefault(); } } } } catch (Exception ex) { MessageBox.Show(this, "Error Opening Mail: " + ex.Message); } if (message.Header.Read == false) { message.Header.Read = true; Mail.SaveMailbox = true; if (MessageView.SelectedNodes.Count > 0) { ((MessageNode)MessageView.SelectedNodes[0]).UpdateRow(); } } }
void OnMailUpdate(LocalMail message) { AddMessage(message, true); }
private void ShowMessage(LocalMail message) { if (message == null) { SetHeader(""); MessageBody.Clear(); return; } string content = "<b><font size=2>" + message.Info.Subject + "</font></b> from " + Core.GetName(message.Header.SourceID) + ", sent " + Utilities.FormatTime(message.Info.Date) + @"<br> <b>To:</b> " + Mail.GetNames(message.To) + "<br>"; if(message.CC.Count > 0) content += "<b>CC:</b> " + Mail.GetNames(message.CC) + "<br>"; if(message.Attached.Count > 1) { string attachHtml = ""; for (int i = 0; i < message.Attached.Count; i++) { if (message.Attached[i].Name == "body") continue; attachHtml += "<a href='http://attach/" + i.ToString() + "'>" + message.Attached[i].Name + "</a> (" + Utilities.ByteSizetoString(message.Attached[i].Size) + "), "; } attachHtml = attachHtml.TrimEnd(new char[] { ' ', ',' }); content += "<b>Attachments: </b> " + attachHtml; } content += "<br>"; string actions = ""; if (message.Header.TargetID == Core.UserID) actions += @"<a href='http://reply" + "'>Reply</a>"; actions += @", <a href='http://forward'>Forward</a>"; actions += @", <a href='http://delete'>Delete</a>"; content += "<b>Actions: </b>" + actions.Trim(',', ' '); SetHeader(content); // body try { using (TaggedStream stream = new TaggedStream(Mail.GetLocalPath(message.Header), Core.GuiProtocol)) using (CryptoStream crypto = IVCryptoStream.Load(stream, message.Header.LocalKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = message.Header.FileStart; while (bytesLeft > 0) { int readSize = (bytesLeft > buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= read; } // load file foreach (MailFile file in message.Attached) if (file.Name == "body") { byte[] msgBytes = new byte[file.Size]; crypto.Read(msgBytes, 0, (int)file.Size); UTF8Encoding utf = new UTF8Encoding(); MessageBody.Clear(); MessageBody.SelectionFont = new Font("Tahoma", 9.75f); MessageBody.SelectionColor = Color.Black; if (message.Info.Format == TextFormat.RTF) MessageBody.Rtf = utf.GetString(msgBytes); else MessageBody.Text = utf.GetString(msgBytes); MessageBody.DetectLinksDefault(); } } } catch (Exception ex) { MessageBox.Show(this, "Error Opening Mail: " + ex.Message); } if (message.Header.Read == false) { message.Header.Read = true; Mail.SaveMailbox = true; if (MessageView.SelectedNodes.Count > 0) ((MessageNode)MessageView.SelectedNodes[0]).UpdateRow(); } }
private void AddMessage(LocalMail message, bool ensureVisible) { bool local = (message.Header.TargetID == Core.UserID); if(local && !ReceivedButton.Checked) return; if(!local && !SentButton.Checked) return; // find thread id and add to thread MessageNode node = new MessageNode(this, message); // interate through parents foreach (MessageNode parent in MessageView.Nodes) { if (Utilities.MemCompare(parent.Message.Header.MailID, node.Message.Header.MailID)) { parent.UpdateRow(); return; } // iterate through children if (parent.Message.Header.ThreadID == message.Header.ThreadID) { foreach (MessageNode child in parent.Nodes) if (Utilities.MemCompare(child.Message.Header.MailID, node.Message.Header.MailID)) { child.UpdateRow(); return; } // not found add to thread parent.Nodes.Add(node); node.UpdateRow(); if(!message.Header.Read || ensureVisible) parent.Expand(); return; } } // thread not found add as parent, sort new to old MessageView.Nodes.Insert(0, node); node.UpdateRow(); // update here so node knows whether to put subject or quip }