public MessageHookEnvironment(MessageModel msg, string sender, string receiver) { if (msg == null) { throw new ArgumentNullException("msg"); } if (sender == null) { throw new ArgumentNullException("sender"); } if (receiver == null) { throw new ArgumentNullException("receiver"); } var nick = msg.GetNick(); var message = msg.ToString(); if (String.IsNullOrEmpty(nick)) { this["MSG"] = message; } else { this["MSG"] = message.Substring(nick.Length + 3); } this["MSG_TYPE"] = msg.MessageType.ToString(); var timestamp = (Int64) (msg .TimeStamp - UnixEpoch).TotalSeconds; this["MSG_TIMESTAMP_UNIX"] = timestamp.ToString(); this["MSG_TIMESTAMP_ISO_UTC"] = msg.TimeStamp.ToString("u").Replace('Z', ' ').TrimEnd(); this["MSG_TIMESTAMP_ISO_LOCAL"] = msg.TimeStamp.ToLocalTime().ToString("u").Replace('Z', ' ').TrimEnd(); this["SENDER"] = sender; this["RECEIVER"] = receiver; }
public static void ParseSmileys(MessageModel msg) { string simleyRegex; simleyRegex = @":-?(\(|\))"; Regex reg = new Regex(simleyRegex); // clone MessageParts IList<MessagePartModel> parts = new List<MessagePartModel>(msg.MessageParts); foreach (MessagePartModel part in parts) { if (!(part is TextMessagePartModel)) { continue; } TextMessagePartModel textPart = (TextMessagePartModel) part; Match simleyMatch = reg.Match(textPart.Text); // OPT: fast regex scan if (!simleyMatch.Success) { // no smileys in this MessagePart, nothing to do continue; } // found smiley(s) // remove current MessagePartModel as we need to split it int idx = msg.MessageParts.IndexOf(part); msg.MessageParts.RemoveAt(idx); string[] textPartParts = textPart.Text.Split(new char[] {' '}); for (int i = 0; i < textPartParts.Length; i++) { string textPartPart = textPartParts[i]; simleyMatch = reg.Match(textPartPart); if (simleyMatch.Success) { string filename = null; if (textPartPart == ":-)") { filename = "smile.png"; } ImageMessagePartModel imagePart = new ImageMessagePartModel( filename, textPartPart ); msg.MessageParts.Insert(idx++, imagePart); msg.MessageParts.Insert(idx++, new TextMessagePartModel(" ")); } else { // FIXME: we put each text part into it's own object, instead of combining them (the smart way) TextMessagePartModel notUrlPart = new TextMessagePartModel(textPartPart + " "); // restore formatting / colors from the original text part notUrlPart.IsHighlight = textPart.IsHighlight; notUrlPart.ForegroundColor = textPart.ForegroundColor; notUrlPart.BackgroundColor = textPart.BackgroundColor; notUrlPart.Bold = textPart.Bold; notUrlPart.Italic = textPart.Italic; notUrlPart.Underline = textPart.Underline; msg.MessageParts.Insert(idx++, notUrlPart); } } } }
public MessageModel(MessageModel msg) : this() { if (msg == null) { throw new ArgumentNullException("msg"); } var writer = SerializationWriter.GetWriter(); msg.GetObjectData(writer); var data = writer.GetData(); var reader = SerializationReader.GetReader(data); SetObjectData(reader); }
public void AddMessageToChat(ChatModel chat, MessageModel msg) { Trace.Call(chat, msg); ChatView chatView = _ChatViewManager.GetChat(chat); #if LOG4NET if (chatView == null) { _Logger.Fatal(String.Format("AddMessageToChat(): _ChatViewManager.GetChat(chat) chat.Name: {0} returned null!", chat.Name)); return; } #endif chatView.AddMessage(msg); }
public void ToMarkup() { MessageModel testmodel = new MessageModel(); testmodel.IsCompactable = false; TextMessagePartModel textmodel; UrlMessagePartModel urlmodel; textmodel = new TextMessagePartModel("normal"); testmodel.MessageParts.Add(textmodel); textmodel = new TextMessagePartModel("blue"); textmodel.ForegroundColor = TextColor.Parse("0000FF"); testmodel.MessageParts.Add(textmodel); textmodel = new TextMessagePartModel("bold"); textmodel.Bold = true; testmodel.MessageParts.Add(textmodel); textmodel = new TextMessagePartModel("bold2"); textmodel.Bold = true; testmodel.MessageParts.Add(textmodel); textmodel = new TextMessagePartModel("normal"); testmodel.MessageParts.Add(textmodel); textmodel = new TextMessagePartModel("underline"); textmodel.Underline = true; testmodel.MessageParts.Add(textmodel); textmodel = new TextMessagePartModel("combined"); textmodel.Underline = true; textmodel.Bold = true; textmodel.Italic = true; textmodel.ForegroundColor = TextColor.Parse("00FF00"); textmodel.BackgroundColor = TextColor.Parse("0000FF"); testmodel.MessageParts.Add(textmodel); urlmodel = new UrlMessagePartModel("http://www.smuxi.org"); testmodel.MessageParts.Add(urlmodel); textmodel = new TextMessagePartModel("normal"); testmodel.MessageParts.Add(textmodel); string expected = "normal<span color='#0000FF'>blue</span>" + "<b>bold</b><b>bold2</b>normal<u>underline</u>" + "<span color='#00FF00'><u><b><i>combined</i></b></u></span>" + "<span color='#00008B'><u>http://www.smuxi.org</u></span>normal"; string tested = PangoTools.ToMarkup(testmodel); Assert.AreEqual(expected, tested); }
public override void Sync() { base.Sync(); var groupChat = (GroupChatModel) ChatModel; Topic = groupChat.Topic; var persons = groupChat.Persons; if (persons != null) { Participants.Clear(); foreach (var person in persons.Values.OrderBy(x => x)) { Participants.Add(person); } } }
public override void AddMessage(MessageModel msg) { base.AddMessage(msg); var nick = msg.GetNick(); if (nick == null) { return; } // update who spoke last for (int i = 0; i < Participants.Count; ++i) { var speaker = Participants[i]; if (speaker.IdentityName == nick) { Participants.RemoveAt(i); Participants.Insert(0, speaker); break; } } }
public void AddMessageToChat(ChatModel chat, MessageModel msg) { Trace.Call(chat, msg); try { ChatView chatView = _ChatViewManager.GetChat(chat); if (chatView == null) { #if LOG4NET _Logger.Fatal(String.Format("AddMessageToChat(): _ChatViewManager.GetChat(chat) chat.Name: {0} returned null!", chat.Name)); #endif return; } // FIXME: this must be marshalled into the UI thread! chatView.AddMessage(msg); _ChatViewManager.UpdateNavigation(); } catch (Exception ex) { #if LOG4NET _Logger.Fatal(ex); #endif } }
protected override void InsertTimeStamp(Gtk.TextBuffer buffer, ref Gtk.TextIter iter, string timestamp, MessageModel msg) { if (String.IsNullOrWhiteSpace(msg.ID)) { buffer.Insert(ref iter, timestamp); } else { var uri = new Uri(String.Format("https://twitter.com/{0}/status/{1}", msg.GetNick(), msg.ID)); var tags = new List<Gtk.TextTag>(); // link URI tag var linkTag = new LinkTag(uri); linkTag.TextEvent += OnLinkTagTextEvent; _MessageTextTagTable.Add(linkTag); tags.Add(linkTag); // link style tag tags.Add(LinkTag); buffer.InsertWithTags(ref iter, timestamp, tags.ToArray()); } buffer.Insert(ref iter, " "); }
public void AddMessageToChat(ChatModel page, MessageModel msg) { Trace.Call(page, msg); string finalMsg = String.Empty; foreach (MessagePartModel msgPart in msg.MessageParts) { // TODO: implement other types if (msgPart is TextMessagePartModel) { TextMessagePartModel fmsgti = (TextMessagePartModel) msgPart; finalMsg += fmsgti.Text; } } string timestamp; try { timestamp = msg.TimeStamp.ToLocalTime().ToString((string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"]); } catch (FormatException e) { timestamp = "Timestamp Format ERROR: " + e.Message; } finalMsg = timestamp + " " + page.Name + " " + finalMsg; Console.WriteLine(finalMsg); }
public abstract bool Remove(MessageModel item);
public void Compact() { var msg = new MessageModel("foo bar"); msg.Compact(); Assert.AreEqual(1, msg.MessageParts.Count); var textPart = (TextMessagePartModel)msg.MessageParts[0]; Assert.AreEqual("foo bar", textPart.Text); msg = new MessageModel(); msg.MessageParts.Add(new TextMessagePartModel("foo")); msg.MessageParts.Add(new TextMessagePartModel(" bar")); msg.MessageParts.Add(new TextMessagePartModel(" me")); msg.Compact(); Assert.AreEqual(1, msg.MessageParts.Count); textPart = (TextMessagePartModel)msg.MessageParts[0]; Assert.AreEqual("foo bar me", textPart.Text); msg = new MessageModel(); msg.MessageParts.Add(new TextMessagePartModel("foo")); msg.MessageParts.Add(new TextMessagePartModel(" bar")); msg.MessageParts.Add(new TextMessagePartModel(" me", true)); msg.Compact(); Assert.AreEqual(2, msg.MessageParts.Count); textPart = (TextMessagePartModel)msg.MessageParts[0]; Assert.AreEqual("foo bar", textPart.Text); textPart = (TextMessagePartModel)msg.MessageParts[1]; Assert.AreEqual(" me", textPart.Text); Assert.IsTrue(textPart.IsHighlight); var msgA = new MessageModel(); msgA.MessageParts.Add(new TextMessagePartModel(TextColor.Black, null, false, false, false, "foo")); msgA.MessageParts.Add(new TextMessagePartModel(TextColor.White, null, false, false, false, " bar")); var msgB = new MessageModel(); msgB.TimeStamp = msgA.TimeStamp; msgB.MessageParts.Add(new TextMessagePartModel(TextColor.Black, null, false, false, false, "foo")); msgB.MessageParts.Add(new TextMessagePartModel(TextColor.White, null, false, false, false, " bar")); msgB.Compact(); Assert.AreEqual(2, msg.MessageParts.Count); Assert.AreEqual(msgA, msgB); msg = new MessageModel(); msg.MessageParts.Add(new TextMessagePartModel("foo ")); msg.MessageParts.Add(new UrlMessagePartModel("http://foo.tld")); msg.MessageParts.Add(new UrlMessagePartModel("http://bar.tld")); msg.MessageParts.Add(new TextMessagePartModel(" bar", true)); msg.MessageParts.Add(new TextMessagePartModel(" me", true)); msg.MessageParts.Add(new TextMessagePartModel(" real")); msg.MessageParts.Add(new TextMessagePartModel(" good")); msg.Compact(); Assert.AreEqual(5, msg.MessageParts.Count); Assert.IsInstanceOfType(typeof(TextMessagePartModel), msg.MessageParts[0]); textPart = (TextMessagePartModel)msg.MessageParts[0]; Assert.AreEqual("foo ", textPart.Text); Assert.IsInstanceOfType(typeof(UrlMessagePartModel), msg.MessageParts[1]); var urlPart = (UrlMessagePartModel)msg.MessageParts[1]; Assert.AreEqual("http://foo.tld", urlPart.Url); Assert.IsInstanceOfType(typeof(UrlMessagePartModel), msg.MessageParts[2]); urlPart = (UrlMessagePartModel)msg.MessageParts[2]; Assert.AreEqual("http://bar.tld", urlPart.Url); Assert.IsInstanceOfType(typeof(TextMessagePartModel), msg.MessageParts[3]); textPart = (TextMessagePartModel)msg.MessageParts[3]; Assert.AreEqual(" bar me", textPart.Text); Assert.IsTrue(textPart.IsHighlight); Assert.IsInstanceOfType(typeof(TextMessagePartModel), msg.MessageParts[4]); textPart = (TextMessagePartModel)msg.MessageParts[4]; Assert.AreEqual(" real good", textPart.Text); Assert.IsFalse(textPart.IsHighlight); }
public ChatViewMessageHighlightedEventArgs(MessageModel msg) { Message = msg; }
public override bool Contains(MessageModel item) { if (item == null) { throw new ArgumentNullException("item"); } // TODO: benchmark me! //return Database.Query<MessageModel>().Contains(item); return IndexOf(item) != -1; }
public void CommandHelp(CommandModel cd) { MessageModel fmsg = new MessageModel(); TextMessagePartModel fmsgti; fmsgti = new TextMessagePartModel(); fmsgti.Text = _("[OscarProtocolManager Commands]"); fmsgti.Bold = true; fmsg.MessageParts.Add(fmsgti); this.Session.AddMessageToChat(cd.FrontendManager.CurrentChat, fmsg); string[] help = { "help", "connect aim/icq username password", }; foreach (string line in help) { cd.FrontendManager.AddTextToCurrentChat("-!- " + line); } }
private void _Say(ChatModel chat, string message) { if (!chat.IsEnabled) { return; } MessageModel msg = new MessageModel(); TextMessagePartModel msgPart; _OscarSession.Messages.SendMessage(chat.ID, message); msgPart = new TextMessagePartModel(); msgPart.Text = "<"; msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = _OscarSession.ScreenName; msgPart.ForegroundColor = new TextColor(0x0000FF); msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = "> "; msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = message; msg.MessageParts.Add(msgPart); Session.AddMessageToChat(chat, msg); }
public void AddMessage(MessageModel msg, bool addLinebreak, bool showTimestamps) { #if MSG_DEBUG Trace.Call(msg, addLinebreak); #endif if (msg == null) { throw new ArgumentNullException("msg"); } var buffer = Buffer; var iter = buffer.EndIter; var startMark = new Gtk.TextMark(null, true); buffer.AddMark(startMark, iter); var senderPrefixWidth = GetSenderPrefixWidth(msg); Gtk.TextTag indentTag = null; if (senderPrefixWidth != 0) { // TODO: re-use text tags that have the same indent width indentTag = new Gtk.TextTag(null) { Indent = -senderPrefixWidth }; _MessageTextTagTable.Add(indentTag); } if (showTimestamps) { var msgTimeStamp = msg.TimeStamp.ToLocalTime(); if (_LastMessage != null) { var lastMsgTimeStamp = _LastMessage.TimeStamp.ToLocalTime(); var span = msgTimeStamp.Date - lastMsgTimeStamp.Date; if (span.Days > 0) { var dayLine = new MessageBuilder(). AppendEventPrefix(); if (span.Days > 1) { dayLine.AppendText(_("Day changed from {0} to {1}"), lastMsgTimeStamp.ToShortDateString(), msgTimeStamp.ToShortDateString()); } else { dayLine.AppendText(_("Day changed to {0}"), msgTimeStamp.ToLongDateString()); } dayLine.AppendText("\n"); var dayLineMsg = dayLine.ToMessage().ToString(); Buffer.InsertWithTags(ref iter, dayLineMsg, EventTag); } } string timestamp = null; try { string format = (string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"]; if (!String.IsNullOrEmpty(format)) { timestamp = msgTimeStamp.ToString(format); } } catch (FormatException e) { timestamp = "Timestamp Format ERROR: " + e.Message; } if (timestamp != null) { timestamp = String.Format("{0} ", timestamp); buffer.Insert(ref iter, timestamp); // apply timestamp width to indent tag if (indentTag != null) { indentTag.Indent -= GetPangoWidth(timestamp); } } } var msgStartMark = new Gtk.TextMark(null, true); buffer.AddMark(msgStartMark, iter); bool hasHighlight = false; foreach (MessagePartModel msgPart in msg.MessageParts) { // supposed to be used only in a ChatView if (msgPart.IsHighlight) { hasHighlight = true; } // TODO: implement all types if (msgPart is UrlMessagePartModel) { var urlPart = (UrlMessagePartModel) msgPart; var linkText = urlPart.Text ?? urlPart.Url; var url = urlPart.Url; Uri uri; try { uri = new Uri(url); } catch (UriFormatException ex) { #if LOG4NET _Logger.Error("AddMessage(): Invalid URL: " + url, ex); #endif buffer.Insert(ref iter, linkText); continue; } var tags = new List<Gtk.TextTag>(); // link URI tag var linkTag = new LinkTag(uri); linkTag.TextEvent += OnLinkTagTextEvent; _MessageTextTagTable.Add(linkTag); tags.Add(linkTag); // link style tag tags.Add(LinkTag); buffer.InsertWithTags(ref iter, linkText, tags.ToArray()); } else if (msgPart is TextMessagePartModel) { var tags = new List<Gtk.TextTag>(); TextMessagePartModel fmsgti = (TextMessagePartModel) msgPart; if (fmsgti.ForegroundColor != TextColor.None) { var bg = ColorConverter.GetTextColor(BackgroundColor); if (fmsgti.BackgroundColor != TextColor.None) { bg = fmsgti.BackgroundColor; } TextColor color = TextColorTools.GetBestTextColor( fmsgti.ForegroundColor, bg ); string tagname = GetTextTagName(color, null); var tag = _MessageTextTagTable.Lookup(tagname); tags.Add(tag); } if (fmsgti.BackgroundColor != TextColor.None) { // TODO: get this from ChatView string tagname = GetTextTagName(null, fmsgti.BackgroundColor); var tag = _MessageTextTagTable.Lookup(tagname); tags.Add(tag); } if (fmsgti.Underline) { #if LOG4NET && MSG_DEBUG _Logger.Debug("AddMessage(): fmsgti.Underline is true"); #endif tags.Add(UnderlineTag); } if (fmsgti.Bold) { #if LOG4NET && MSG_DEBUG _Logger.Debug("AddMessage(): fmsgti.Bold is true"); #endif tags.Add(BoldTag); } if (fmsgti.Italic) { #if LOG4NET && MSG_DEBUG _Logger.Debug("AddMessage(): fmsgti.Italic is true"); #endif tags.Add(ItalicTag); } if (tags.Count > 0) { buffer.InsertWithTags(ref iter, fmsgti.Text, tags.ToArray()); } else { buffer.Insert(ref iter, fmsgti.Text); } } } var startIter = buffer.GetIterAtMark(startMark); if (msg.MessageType == MessageType.Event) { buffer.ApplyTag(EventTag, startIter, iter); } if (indentTag != null) { buffer.ApplyTag(indentTag, startIter, iter); } var nick = msg.GetNick(); if (nick != null) { // TODO: re-use the same person tag for the same nick var personTag = new PersonTag(nick, nick); personTag.TextEvent += OnPersonTagTextEvent; _MessageTextTagTable.Add(personTag); var msgStartIter = buffer.GetIterAtMark(msgStartMark); var nickEndIter = msgStartIter; nickEndIter.ForwardChars(nick.Length + 2); buffer.ApplyTag(PersonTag, msgStartIter, nickEndIter); buffer.ApplyTag(personTag, msgStartIter, nickEndIter); } buffer.DeleteMark(startMark); buffer.DeleteMark(msgStartMark); if (addLinebreak) { buffer.Insert(ref iter, "\n"); } CheckBufferSize(); if (IsGtk2_17) { // HACK: force a redraw of the widget, as for some reason // GTK+ 2.17.6 is not redrawing some lines we add here, especially // for local messages. See: // http://projects.qnetp.net/issues/show/185 QueueDraw(); } if (Frontend.IsWindows && _LastMessage == null) { // HACK: workaround rendering issue on Windows where the // first inserted text is not showing up until the next insert QueueDraw(); } if (MessageAdded != null) { MessageAdded(this, new MessageTextViewMessageAddedEventArgs(msg)); } if (hasHighlight) { if (MessageHighlighted != null) { MessageHighlighted(this, new MessageTextViewMessageHighlightedEventArgs(msg)); } } _LastMessage = msg; }
public abstract void Insert(int index, MessageModel item);
public void SetUp() { Buffer = CreateBuffer(); TestMessages = new List <MessageModel>(); var builder = new MessageBuilder(); builder.TimeStamp = DateTime.MinValue; builder.AppendText("msg1"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg2"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendErrorText("msg3"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg4"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg5"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg6"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg7"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg8"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg9"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg10"); TestMessages.Add(builder.ToMessage()); builder = new MessageBuilder(); builder.AppendText("msg11"); TestMessages.Add(builder.ToMessage()); foreach (var msg in TestMessages) { Buffer.Add(msg); } builder = new MessageBuilder(); builder.AppendIdendityName( new ContactModel("meeebey", "meebey", "netid", "netprot") ); builder.AppendSpace(); builder.AppendText("solange eine message aber keine url hat ist der vorteil nur gering (wenn ueberhaupt)"); SimpleMessage = builder.ToMessage(); }
public abstract void Add(MessageModel item);
public override void Insert(int index, MessageModel item) { throw new NotImplementedException(); }
public override int IndexOf(MessageModel item) { throw new NotImplementedException(); }
public override bool Remove(MessageModel item) { throw new NotImplementedException(); }
public void AddMessage(MessageModel msg) { AddMessage(msg, true); }
public MessageTextViewMessageAddedEventArgs(MessageModel message) { f_Message = message; }
public void AddMessage(MessageModel msg, bool addLinebreak) { AddMessage(msg, addLinebreak, _ShowTimestamps); }
public abstract int IndexOf(MessageModel item);
int GetSenderPrefixWidth(MessageModel msg) { // HACK: try to obtain the nickname from the message // TODO: extend MessageModel with Origin property var msgText = msg.ToString(); var nickMatch = Regex.Match(msgText, "^(<([^ ]+)> )"); if (nickMatch.Success) { // HACK: the nick can be bold if (msg.MessageParts.Count >= 3) { // possibly colored nick, see MessageBuilder.CreateNick() var prefixPart = msg.MessageParts[0]; var nickPart = msg.MessageParts[1]; var suffixPart = msg.MessageParts[2]; if (prefixPart.ToString() == "<" && nickPart is TextMessagePartModel && suffixPart.ToString().StartsWith(">")) { // colored nick var nickTextPart = (TextMessagePartModel) nickPart; if (nickTextPart.Bold) { return GetPangoWidth( String.Format( "{0}<b>{1}</b>{2} ", GLib.Markup.EscapeText("<"), GLib.Markup.EscapeText( nickMatch.Groups[2].Value ), GLib.Markup.EscapeText(">") ), true ); } } } return GetPangoWidth(nickMatch.Groups[1].Value, false); } else { var eventMatch = Regex.Match(msgText, "^(-!- )"); if (eventMatch.Success && eventMatch.Groups.Count >= 2) { return GetPangoWidth(eventMatch.Groups[1].Value, false); } } return 0; }
public MessageBuilder() { Message = new MessageModel(); Settings = new MessageBuilderSettings(); }
public MessageTextViewMessageHighlightedEventArgs(MessageModel message) { f_Message = message; }
private void _UpdateTopicInGroupChat(GroupChatModel groupChat, MessageModel topic) { f_TaskQueue.Queue(delegate { _UI.UpdateTopicInGroupChat(groupChat, topic); }); }
//private void _OnMessageReceived(OscarSession sess, UserInfo userInfo, string message, Encoding encoding, MessageFlags msgFlags) private void _OnMessageReceived(object sender, MessageReceivedEventArgs e) { ChatModel chat = GetChat(e.Message.ScreenName, ChatType.Person); if (chat == null) { PersonModel person = new PersonModel(e.Message.ScreenName, e.Message.ScreenName, NetworkID, Protocol, this); chat = new PersonChatModel(person, e.Message.ScreenName, e.Message.ScreenName, this); Session.AddChat(chat); Session.SyncChat(chat); } MessageModel msg = new MessageModel(); TextMessagePartModel textMsg; textMsg = new TextMessagePartModel(); textMsg.Text = String.Format("<{0}> ", e.Message.ScreenName); textMsg.IsHighlight = true; msg.MessageParts.Add(textMsg); textMsg = new TextMessagePartModel(); textMsg.Text = e.Message.Message; msg.MessageParts.Add(textMsg); Session.AddMessageToChat(chat, msg); }
public override int IndexOf(MessageModel item) { if (item == null) { throw new ArgumentNullException("item"); } var res = Database.QueryByExample(item); // return -1 if not found if (res.Count == 0) { return -1; } var dbMsg = (MessageModel) res[0]; var dbId = Database.Ext().GetID(dbMsg); return Index.IndexOf(dbId); }
public virtual void AddMessage(MessageModel msg) { switch (msg.MessageType) { case MessageType.ChatNameChanged: ThreadPool.QueueUserWorkItem(delegate { try { // REMOTING CALL var newname = ChatModel.Name; Gtk.Application.Invoke(delegate { Name = newname; }); } catch (Exception ex) { Frontend.ShowException(ex); } }); return; } _OutputMessageTextView.AddMessage(msg); }
public override bool Remove(MessageModel item) { if (item == null) { throw new ArgumentNullException("item"); } if (!Contains(item)) { return false; } var dbId = Database.Ext().GetID(item); Index.Remove(dbId); Database.Delete(item); return true; }
public override void Add(MessageModel item) { if (item == null) { throw new ArgumentNullException("item"); } // make sure the index is initialized at this point else we will // load the 1st added item of db4o and end up with a duplicate here InitIndex(); if (MaxCapacity > 0 && Index.Count >= MaxCapacity) { RemoveAt(0); } // TODO: auto-flush every 60 seconds var dbMsg = new MessageModel(item); Database.Store(dbMsg); Database.Deactivate(dbMsg, 5); var dbId = Database.Ext().GetID(dbMsg); Index.Add(dbId); FlushCounter++; if (FlushCounter >= FlushInterval) { Flush(); } }
public bool Equals(MessageModel msg) { if ((object) msg == null) { return false; } if (f_TimeStamp != msg.TimeStamp) { return false; } if (f_MessageType != msg.MessageType) { return false; } if (f_MessageParts.Count != msg.MessageParts.Count) { return false; } for (int i = 0; i < f_MessageParts.Count; i++) { if (f_MessageParts[i] != msg.MessageParts[i]) { return false; } } return true; }
public override void CopyTo(MessageModel[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } int i = arrayIndex; foreach (var msg in this) { array[i++] = msg; } }
public abstract bool Contains(MessageModel item);
public override void Insert(int index, MessageModel item) { throw new NotSupportedException(); }
public void AddMessageToCurrentChat(MessageModel msg) { AddMessageToChat(CurrentChat, msg); }
MessageModel GetMessage(MessageModel dbMsg) { Database.Activate(dbMsg, 10); var msg = new MessageModel(dbMsg); Database.Deactivate(dbMsg, 10); return msg; }
private void _Say(CommandModel command, string text) { if (!command.Chat.IsEnabled) { return; } // string target = command.Chat.ID; // // _JabberClient.Message(target, text); MessageModel msg = new MessageModel(); TextMessagePartModel msgPart; msgPart = new TextMessagePartModel(); msgPart.Text = "<"; msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = _UsersAddress; //msgPart.ForegroundColor = IrcTextColor.Blue; msgPart.ForegroundColor = new TextColor(0x0000FF); msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = "> "; msg.MessageParts.Add(msgPart); msgPart = new TextMessagePartModel(); msgPart.Text = text; msg.MessageParts.Add(msgPart); Session.AddMessageToChat(command.Chat, msg); }
private void _AddMessageToChat(ChatModel chat, MessageModel msg) { f_TaskQueue.Queue(delegate { _UI.AddMessageToChat(chat, msg); }); }
public void CompactBenchmark() { var formatter = new BinaryFormatter(); var topic = "Smuxi the IRC client for sophisticated users: http://smuxi.org/ | Smuxi 0.7.2.2 'Lovegood' released (2010-07-27) http://bit.ly/9nvsZF | FAQ: http://smuxi.org/faq/ | Deutsch? -> #smuxi.de | Español? -> #smuxi.es | Smuxi @ FOSDEM 2010 talk: http://bit.ly/anHJfm"; var msg = new MessageModel(topic) { IsCompactable = false }; MessageParser.ParseUrls(msg); var stream = new MemoryStream(1024); formatter.Serialize(stream, msg); Console.WriteLine("Parts: " + msg.MessageParts.Count); Console.WriteLine("Size: " + stream.Length); msg.Compact(); stream = new MemoryStream(1024); formatter.Serialize(stream, msg); Console.WriteLine("Compacted Parts: " + msg.MessageParts.Count); Console.WriteLine("Compacted Size: " + stream.Length); // regular message without URL // <meebey> solange eine message aber keine url hat ist der vorteil nur gering (wenn ueberhaupt) msg = new MessageModel() { IsCompactable = false }; msg.MessageParts.Add(new TextMessagePartModel("<")); msg.MessageParts.Add( new TextMessagePartModel( TextColor.White, null, false, false, false, "meebey" ) ); msg.MessageParts.Add(new TextMessagePartModel("> ")); msg.MessageParts.Add( new TextMessagePartModel( "solange eine message aber keine url hat ist der " + "vorteil nur gering (wenn ueberhaupt)" ) ); stream = new MemoryStream(1024); formatter.Serialize(stream, msg); Console.WriteLine("Parts: " + msg.MessageParts.Count); Console.WriteLine("Size: " + stream.Length); msg.Compact(); stream = new MemoryStream(1024); formatter.Serialize(stream, msg); Console.WriteLine("Compacted Parts: " + msg.MessageParts.Count); Console.WriteLine("Compacted Size: " + stream.Length); // regular short message with URL // <meebey> http://www.smuxi.org/issues/show/107 kannst ja watchen msg = new MessageModel() { IsCompactable = false }; msg.MessageParts.Add(new TextMessagePartModel("<")); msg.MessageParts.Add( new TextMessagePartModel( TextColor.White, null, false, false, false, "meebey" ) ); msg.MessageParts.Add(new TextMessagePartModel("> ")); msg.MessageParts.Add( new UrlMessagePartModel( "http://www.smuxi.org/issues/show/107" ) ); msg.MessageParts.Add(new TextMessagePartModel(" kannst ja watchen")); MessageParser.ParseUrls(msg); stream = new MemoryStream(1024); formatter.Serialize(stream, msg); Console.WriteLine("Parts: " + msg.MessageParts.Count); Console.WriteLine("Size: " + stream.Length); msg.Compact(); stream = new MemoryStream(1024); formatter.Serialize(stream, msg); Console.WriteLine("Compacted Parts: " + msg.MessageParts.Count); Console.WriteLine("Compacted Size: " + stream.Length); }