Ejemplo n.º 1
0
//        private void _OnReadText(xobject sender, string text)
//        {
//                Session.AddTextToChat(_NetworkChat, "-!- RECV: " + text);
//        }

//        private void _OnWriteText(xobject sender, string text)
//        {
//                Session.AddTextToChat(_NetworkChat, "-!- SENT: " + text);
//        }


        private void MsnClient_ConversationCreated(object sender, ConversationCreatedEventArgs e)
        {
            Trace.Call(sender, e);



            // Session.AddTextToChat(_NetworkChat, "Conversation bla");
            //e.Conversation.Switchboard.Co
            //_MsnClient.Nameserver.RequestScreenName();

            // NetworkChatModel nchat = new NetworkChatModel("MSN", "MSN", this);
            //Session.AddChat(nchat);

            e.Conversation.Switchboard.TextMessageReceived += delegate(object sender2, TextMessageEventArgs e2) {
                PersonModel person = new PersonModel(e2.Sender.Name,
                                                     e2.Sender.Name,
                                                     NetworkID, Protocol,
                                                     this);
                PersonChatModel personChat = new PersonChatModel(person,
                                                                 e2.Sender.Name,
                                                                 e2.Sender.Name,
                                                                 this);
                Session.AddChat(personChat);
                Session.AddTextToChat(personChat, e2.Message.Text);
            };
        }
Ejemplo n.º 2
0
        public IrcPersonChatView(PersonChatModel personChat)
            : base(personChat)
        {
            Trace.Call(personChat);

            OutputMessageTextView.PopulatePopup += OnOutputMessageTextViewPopulatePopup;
        }
Ejemplo n.º 3
0
        //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);
        }
Ejemplo n.º 4
0
        public XmppPersonChatView(PersonChatModel personChat)
            : base(personChat)
        {
            Trace.Call(personChat);

            OutputMessageTextView.PopulatePopup += _OnOutputMessageTextViewPopulatePopup;
            ChatStateStartPosition = new Gtk.TextMark("ChatStateStartPosition", true);
            IsDisposed = false;
        }
Ejemplo n.º 5
0
        public PersonChatView(PersonChatModel chat)
            : base(chat)
        {
            Trace.Call(chat);

            PersonChatModel = chat;

            Add(OutputScrolledWindow);
        }
Ejemplo n.º 6
0
        public IrcPersonChatView(PersonChatModel personChat)
            : base(personChat)
        {
            Trace.Call(personChat);

            _IrcProtocolManager = (IrcProtocolManager)personChat.ProtocolManager;

            OutputMessageTextView.PopulatePopup += _OnOutputMessageTextViewPopulatePopup;
        }
Ejemplo n.º 7
0
        public PersonChatView(PersonChatModel chat)
            : base(chat)
        {
            Trace.Call(chat);

            PersonChatModel = chat;

            var tabImage = new Gtk.Image(IconPixbuf);
            TabHBox.PackStart(tabImage, false, false, 2);
            TabHBox.ShowAll();

            Add(OutputScrolledWindow);
        }
Ejemplo n.º 8
0
        void OnPrivateMessage(string fromUserName, string toUserName, string message)
        {
            Trace.Call(fromUserName, toUserName, message);

            string targetChat;
            string targetUser;

            if (fromUserName == Username)
            {
                targetChat = toUserName;
                targetUser = toUserName;
            }
            else
            {
                targetChat = fromUserName;
                targetUser = fromUserName;
            }
            var chat = (PersonChatModel)GetChat(targetChat, ChatType.Person);

            if (chat == null)
            {
                var person = CreatePerson(targetUser);
                chat = new PersonChatModel(person, targetUser, targetUser, this);
                chat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
                Session.AddChat(chat);
                Session.SyncChat(chat);
            }
            var builder = CreateMessageBuilder <JabbrMessageBuilder>();

            if (fromUserName == Username)
            {
                builder.AppendSenderPrefix(Me);
            }
            else
            {
                builder.AppendSenderPrefix(chat.Person, true);
            }
            builder.AppendMessage(message);
            Session.AddMessageToChat(chat, builder.ToMessage());
        }
Ejemplo n.º 9
0
        public override void OpenChat(FrontendManager fm, ChatModel chat)
        {
            Trace.Call(fm, chat);

            switch (chat.ChatType)
            {
            case ChatType.Person:
                var personChat = (PersonChatModel)GetChat(chat.ID, ChatType.Person);
                if (personChat != null)
                {
                    return;
                }
                var person = CreatePerson(chat.ID);
                personChat = new PersonChatModel(person, chat.ID, chat.ID, this);
                personChat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
                Session.AddChat(personChat);
                Session.SyncChat(personChat);
                break;

            case ChatType.Group:
                Client.JoinRoom(chat.ID);
                break;
            }
        }
Ejemplo n.º 10
0
        private void _OnQueryMessage(object sender, IrcEventArgs e)
        {
            var chat = (PersonChatModel) GetChat(e.Data.Nick, ChatType.Person);
            bool newChat = false;
            if (chat == null) {
                var person = CreatePerson(e.Data.Nick);
                person.Ident = e.Data.Ident;
                person.Host = e.Data.Host;
                chat = new PersonChatModel(person, e.Data.Nick, e.Data.Nick, this);
                newChat = true;
            }

            var builder = CreateMessageBuilder();
            builder.AppendSenderPrefix(chat.Person, true);
            builder.AppendMessage(e.Data.Message);
            var msg = builder.ToMessage();

            if (newChat) {
                // don't create chats for filtered messages
                if (Session.IsFilteredMessage(chat, msg)) {
                    Session.LogMessage(chat, msg, true);
                    return;
                }
                Session.AddChat(chat);
                Session.SyncChat(chat);
            }

            Session.AddMessageToChat(chat, msg);
        }
Ejemplo n.º 11
0
        public void CommandMessageQuery(CommandModel cd)
        {
            ChatModel chat = null;
            if (cd.DataArray.Length >= 2) {
                string nickname = cd.DataArray[1];
                chat = GetChat(nickname, ChatType.Person);
                if (chat == null) {
                    var person = CreatePerson(nickname);
                    chat = new PersonChatModel(person, nickname, nickname, this);
                    Session.AddChat(chat);
                    Session.SyncChat(chat);
                }
            }

            if (cd.DataArray.Length >= 3) {
                string message = String.Join(" ", cd.DataArray, 2, cd.DataArray.Length-2);
                // ignore empty messages
                if (message.TrimEnd(' ').Length > 0) {
                    _Say(chat, message);
                }
            }
        }
Ejemplo n.º 12
0
        void OnPrivateMessage(string fromUserName, string toUserName, string message)
        {
            Trace.Call(fromUserName, toUserName, message);

            string targetChat;
            string targetUser;
            if (fromUserName == Username) {
                targetChat = toUserName;
                targetUser = toUserName;
            } else {
                targetChat = fromUserName;
                targetUser = fromUserName;
            }
            var chat = (PersonChatModel) GetChat(targetChat, ChatType.Person);
            if (chat == null) {
                var person = CreatePerson(targetUser);
                chat = new PersonChatModel(person, targetUser, targetUser, this);
                chat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
                Session.AddChat(chat);
                Session.SyncChat(chat);
            }
            var builder = CreateMessageBuilder<JabbrMessageBuilder>();
            if (fromUserName == Username) {
                builder.AppendSenderPrefix(Me);
            } else {
                builder.AppendSenderPrefix(chat.Person, true);
            }
            builder.AppendMessage(message);
            Session.AddMessageToChat(chat, builder.ToMessage());
        }
Ejemplo n.º 13
0
        public void CommandMessageQuery(CommandModel cd)
        {
            ChatModel chat = null;
            if (cd.DataArray.Length >= 2) {
                string nickname = cd.DataArray[1];
                JID jid = null;
                foreach (JID j in _RosterManager) {
                    Item item = _RosterManager[j];
                    if (item.Nickname != null &&
                        item.Nickname.Replace(" ", "_") == nickname) {
                        jid = item.JID;
                        break;
                    }
                }
                if (jid == null) {
                    jid = nickname; // TODO check validity
                }

                chat = GetChat(jid, ChatType.Person);
                if (chat == null) {
                    PersonModel person = new PersonModel(jid, nickname,
                                                         NetworkID, Protocol,
                                                         this);
                    chat = new PersonChatModel(person, jid, nickname, this);
                    Session.AddChat(chat);
                    Session.SyncChat(chat);
                }
            }

            if (cd.DataArray.Length >= 3) {
                string message = String.Join(" ", cd.DataArray, 2, cd.DataArray.Length-2);
                // ignore empty messages
                if (message.TrimEnd(' ').Length > 0) {
                    _Say(chat, message);
                }
            }
        }
Ejemplo n.º 14
0
        protected virtual void OnPersonsRowActivated(object sender, Gtk.RowActivatedArgs e)
        {
            Trace.Call(sender, e);

            IList<PersonModel> persons = GetSelectedPersons();
            if (persons == null || persons.Count == 0) {
                return;
            }

            var protocolManager = ProtocolManager;
            if (protocolManager == null) {
            #if LOG4NET
                _Logger.WarnFormat(
                    "{0}.OnPersonsRowActivated(): ProtocolManager is null, " +
                    "bailing out!", this
                );
            #endif
                return;
            }

            // jump to person chat if available
            foreach (var chatView in Frontend.MainWindow.ChatViewManager.Chats) {
                if (!(chatView is PersonChatView)) {
                    continue;
                }
                var personChatView = (PersonChatView) chatView;
                if (personChatView.PersonModel == persons[0]) {
                    Frontend.MainWindow.ChatViewManager.CurrentChatView = personChatView;
                    return;
                }
            }

            // this is a generic implemention that should be able to open/create
            // a private chat in most cases, as it depends what OpenChat()
            // of the specific protocol actually expects/needs
            foreach (PersonModel person in persons) {
                PersonChatModel personChat = new PersonChatModel(
                    person,
                    person.ID,
                    person.IdentityName,
                    null
                );

                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        protocolManager.OpenChat(
                            Frontend.FrontendManager,
                            personChat
                        );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
Ejemplo n.º 15
0
        private void _OnQueryNotice(object sender, IrcEventArgs e)
        {
            ChatModel chat = null;
            if (e.Data.Nick != null) {
                chat = GetChat(e.Data.Nick, ChatType.Person);
            }
            if (chat == null) {
                // use server chat as fallback
                if (e.Data.Nick == null) {
                    // this seems to be a notice from the server
                    chat = _NetworkChat;
                } else {
                    // create new chat
                    IrcPersonModel person = new IrcPersonModel(e.Data.Nick,
                                                               null,
                                                               e.Data.Ident,
                                                               e.Data.Host,
                                                               NetworkID,
                                                               this);
                    chat = new PersonChatModel(person, e.Data.Nick, e.Data.Nick, this);
                    Session.AddChat(chat);
                    Session.SyncChat(chat);
                }
            }

            MessageModel fmsg = new MessageModel();
            TextMessagePartModel fmsgti;

            fmsgti = new TextMessagePartModel();
            fmsgti.Text = String.Format("-{0} ({1}@{2})- ",
                                        e.Data.Nick,
                                        e.Data.Ident,
                                        e.Data.Host);
            // notice shouldn't be a highlight
            //fmsgti.IsHighlight = true;
            fmsg.MessageParts.Add(fmsgti);

            _IrcMessageToMessageModel(ref fmsg, e.Data.Message);

            Session.AddMessageToChat(chat, fmsg);
        }
Ejemplo n.º 16
0
        private void OnMessage(object sender, Message msg)
        {
            if (msg.Body == null)
            {
                return;
            }

            var    delay = msg["delay"];
            string stamp = null;

            if (delay != null)
            {
                stamp = delay.Attributes["stamp"].Value;
            }
            bool display = true;

            ChatModel   chat   = null;
            PersonModel person = null;

            if (msg.Type != XmppMessageType.groupchat)
            {
                string jid      = msg.From.Bare;
                var    contact  = _RosterManager[jid];
                string nickname = null;
                if (contact == null || String.IsNullOrEmpty(contact.Nickname))
                {
                    nickname = jid;
                }
                else
                {
                    nickname = contact.Nickname;
                }
                PersonChatModel personChat = (PersonChatModel)Session.GetChat(jid, ChatType.Person, this);
                if (personChat == null)
                {
                    person = new PersonModel(jid, nickname, NetworkID,
                                             Protocol, this);
                    personChat = Session.CreatePersonChat(
                        person, jid, nickname, this
                        );
                    Session.AddChat(personChat);
                    Session.SyncChat(personChat);
                }
                else
                {
                    person = personChat.Person;
                }
                chat = personChat;
            }
            else
            {
                string             group_jid  = msg.From.Bare;
                string             group_name = group_jid;
                string             sender_jid = msg.From.ToString();
                XmppGroupChatModel groupChat  = (XmppGroupChatModel)Session.GetChat(group_jid, ChatType.Group, this);
                if (groupChat == null)
                {
                    // FIXME shouldn't happen?
                    groupChat = Session.CreateChat <XmppGroupChatModel>(
                        group_jid, group_name, this
                        );
                    Session.AddChat(groupChat);
                    Session.SyncChat(groupChat);
                }
                person = groupChat.GetPerson(msg.From.Resource);
                if (person == null)
                {
                    // happens in case of a delayed message if the participant has left meanwhile
                    person = new PersonModel(msg.From.Resource,
                                             msg.From.Resource,
                                             NetworkID, Protocol, this);
                }

                // XXX maybe only a Google Talk bug requires this:
                if (stamp != null)
                {
                    // XXX can't use > because of seconds precision :-(
                    if (stamp.CompareTo(groupChat.LatestSeenStamp) >= 0)
                    {
                        groupChat.LatestSeenStamp = stamp;
                    }
                    else
                    {
                        display = false; // already seen newer delayed message
                    }
                    if (groupChat.SeenNewMessages)
                    {
                        display = false; // already seen newer messages
                    }
                }
                else
                {
                    groupChat.SeenNewMessages = true;
                }

                chat = groupChat;
            }

            if (display)
            {
                var builder = CreateMessageBuilder();
                if (msg.Type != XmppMessageType.error)
                {
                    builder.AppendMessage(person, msg.Body);
                }
                else
                {
                    // TODO: nicer formatting
                    builder.AppendMessage(msg.Error.ToString());
                }
                if (stamp != null)
                {
                    string format = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern.Replace(" ", "T");
                    builder.TimeStamp = DateTime.ParseExact(stamp, format, null);
                }
                Session.AddMessageToChat(chat, builder.ToMessage());
            }
        }
Ejemplo n.º 17
0
        private ChatModel OpenPrivateChat(decimal userId)
        {
            ChatModel chat =  Session.GetChat(
                userId.ToString(),
                ChatType.Person,
                this
            );

            if (chat != null) {
                return chat;
            }

            TwitterUser user = TwitterUser.Show(f_OAuthTokens, userId,
                                                f_OptionalProperties);
            PersonModel person = CreatePerson(user);
            PersonChatModel personChat = new PersonChatModel(
                person,
                user.Id.ToString(),
                user.ScreenName,
                this
            );
            Session.AddChat(personChat);
            Session.SyncChat(personChat);
            return personChat;
        }
Ejemplo n.º 18
0
 void OnPrivateChatMessageError(Message msg, PersonChatModel chat)
 {
     var builder = CreateMessageBuilder();
     // TODO: nicer formatting
     if (msg.Error.ErrorText != null) {
         builder.AppendErrorText(msg.Error.ErrorText);
     } else {
         builder.AppendErrorText(msg.Error.ToString());
     }
     Session.AddMessageToChat(chat, builder.ToMessage());
 }
Ejemplo n.º 19
0
        private void _OnMessage(object sender, Message xmppMsg)
        {
            if (xmppMsg.Body == null) {
                return;
            }

            var delay = xmppMsg["delay"];
            string stamp = null;
            if (delay != null) {
                stamp = delay.Attributes["stamp"].Value;
            }
            bool display = true;

            ChatModel chat = null;
            PersonModel person = null;
            if (xmppMsg.Type != XmppMessageType.groupchat) {
                string jid = xmppMsg.From.Bare;
                var contact = _RosterManager[jid];
                string nickname = jid;
                if (contact != null && contact.Nickname != null) {
                    nickname = contact.Nickname.Replace(" ", "_");
                }
                PersonChatModel personChat = (PersonChatModel) Session.GetChat(jid, ChatType.Person, this);
                if (personChat == null) {
                    person = new PersonModel(jid, nickname, NetworkID,
                                             Protocol, this);
                    personChat = new PersonChatModel(person, jid, nickname, this);
                    Session.AddChat(personChat);
                    Session.SyncChat(personChat);
                } else {
                    person = personChat.Person;
                }
                chat = personChat;
            } else {
                string group_jid = xmppMsg.From.Bare;
                string group_name = group_jid;
                string sender_jid = xmppMsg.From.ToString();
                XmppGroupChatModel groupChat = (XmppGroupChatModel) Session.GetChat(group_jid, ChatType.Group, this);
                if (groupChat == null) {
                    // FIXME shouldn't happen?
                    groupChat = new XmppGroupChatModel(group_jid, group_name, this);
                    Session.AddChat(groupChat);
                    Session.SyncChat(groupChat);
                }
                person = groupChat.GetPerson(xmppMsg.From.Resource);
                if (person == null) {
                    // happens in case of a delayed message if the participant has left meanwhile
                    person = new PersonModel(xmppMsg.From.Resource, xmppMsg.From.Resource,
                                             NetworkID, Protocol, this);
                }

                // XXX maybe only a Google Talk bug requires this:
                if (stamp != null) {
                    // XXX can't use > because of seconds precision :-(
                    if (stamp.CompareTo(groupChat.LatestSeenStamp) >= 0) {
                        groupChat.LatestSeenStamp = stamp;
                    } else {
                        display = false; // already seen newer delayed message
                    }
                    if (groupChat.SeenNewMessages) {
                        display = false; // already seen newer messages
                    }
                } else {
                    groupChat.SeenNewMessages = true;
                }

                chat = groupChat;
            }

            if (display) {
                var builder = CreateMessageBuilder();
                if (xmppMsg.Type != XmppMessageType.error) {
                    builder.AppendMessage(person, xmppMsg.Body);
                } else {
                    // TODO: nicer formatting
                    builder.AppendMessage(xmppMsg.Error.ToString());
                }
                var msg = builder.ToMessage();
                if (stamp != null) {
                    string format = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern.Replace(" ", "T");
                    msg.TimeStamp = DateTime.ParseExact(stamp, format, null);
                }
                Session.AddMessageToChat(chat, msg);
            }
        }
Ejemplo n.º 20
0
        private void _OnQueryNotice(object sender, IrcEventArgs e)
        {
            ChatModel chat = null;
            bool newChat = false;
            if (e.Data.Nick != null) {
                chat = GetChat(e.Data.Nick, ChatType.Person);
            }
            if (chat == null) {
                // use server chat as fallback
                if (e.Data.Nick == null) {
                    // this seems to be a notice from the server
                    chat = _NetworkChat;
                } else {
                    // create new chat
                    IrcPersonModel person = CreatePerson(e.Data.Nick,
                                                         null,
                                                         e.Data.Ident,
                                                         e.Data.Host);
                    chat = new PersonChatModel(person, e.Data.Nick, e.Data.Nick, this);
                    newChat = true;
                }
            }

            var builder = CreateMessageBuilder();
            if (e.Data.Nick == null) {
                // server message
                builder.AppendText("!{0} ", e.Data.From);
            } else {
                builder.AppendText("-");
                builder.AppendIdendityName(GetPerson(chat, e.Data.Nick));
                builder.AppendText(" ({0}@{1})- ", e.Data.Ident, e.Data.Host);
            }
            builder.AppendMessage(e.Data.Message);
            var msg = builder.ToMessage();
            MarkHighlights(msg);

            if (newChat) {
                // don't create chats for filtered messages
                if (Session.IsFilteredMessage(chat, msg)) {
                    Session.LogMessage(chat, msg, true);
                    return;
                }
                Session.AddChat(chat);
                Session.SyncChat(chat);
            }
            Session.AddMessageToChat(chat, msg);
        }
Ejemplo n.º 21
0
        protected virtual void OnChatOpenChatButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                OpenChatDialog dialog = new OpenChatDialog(this);
                int res = dialog.Run();

                var chatView = Notebook.CurrentChatView;
                if (chatView == null) {
                    return;
                }

                var manager = chatView.ChatModel.ProtocolManager;
                if (manager == null) {
                    return;
                }
                ChatModel chat;
                switch (dialog.ChatType) {
                    case ChatType.Group:
                        chat = new GroupChatModel(
                            dialog.ChatName,
                            dialog.ChatName,
                            manager
                        );
                        break;
                    case ChatType.Person:
                        chat = new PersonChatModel(
                            null,
                            dialog.ChatName,
                            dialog.ChatName,
                            manager
                        );
                        break;
                    default:
                        throw new ApplicationException(
                            String.Format(
                                _("Unknown ChatType: {0}"),
                                dialog.ChatType
                            )
                        );
                }

                dialog.Destroy();
                if (res != (int) Gtk.ResponseType.Ok) {
                    return;
                }

                manager.OpenChat(Frontend.FrontendManager, chat);
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
Ejemplo n.º 22
0
        protected virtual void OnPersonsRowActivated(object sender, Gtk.RowActivatedArgs e)
        {
            Trace.Call(sender, e);

            IList<PersonModel> persons = GetSelectedPersons();
            if (persons == null) {
                return;
            }

            // this is a generic implemention that should be able to open/create
            // a private chat in most cases, as it depends what OpenChat()
            // of the specific protocol actually expects/needs
            foreach (PersonModel person in persons) {
                PersonChatModel personChat = new PersonChatModel(
                    person,
                    person.ID,
                    person.IdentityName,
                    null
                );

                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        ChatModel.ProtocolManager.OpenChat(
                            Frontend.FrontendManager,
                            personChat
                        );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
Ejemplo n.º 23
0
        public void CommandMessageQuery(CommandModel cd)
        {
            ChatModel chat = null;
            if (cd.DataArray.Length >= 2) {
                string nickname = cd.DataArray[1];
                chat = GetChat(nickname, ChatType.Person);
                if (chat == null) {
                    IrcPersonModel person = new IrcPersonModel(nickname,
                                                               NetworkID,
                                                               this);
                    chat = new PersonChatModel(person, nickname, nickname, this);
                    Session.AddChat(chat);
                    Session.SyncChat(chat);
                }
            }

            if (cd.DataArray.Length >= 3) {
                string message = String.Join(" ", cd.DataArray, 2, cd.DataArray.Length-2);
                _Say(chat, message);
            }
        }
Ejemplo n.º 24
0
        //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);
        }
Ejemplo n.º 25
0
        private void _OnQueryMessage(object sender, IrcEventArgs e)
        {
            ChatModel chat = GetChat(e.Data.Nick, ChatType.Person);
            if (chat == null) {
                IrcPersonModel person = new IrcPersonModel(e.Data.Nick,
                                                           null,
                                                           e.Data.Ident,
                                                           e.Data.Host,
                                                           NetworkID,
                                                           this);
                chat = new PersonChatModel(person, e.Data.Nick, e.Data.Nick, this);
                Session.AddChat(chat);
                Session.SyncChat(chat);
            }

            MessageModel fmsg = new MessageModel();
            TextMessagePartModel fmsgti;

            fmsgti = new TextMessagePartModel();
            fmsgti.Text = String.Format("<{0}> ", e.Data.Nick);
            fmsgti.IsHighlight = true;
            fmsg.MessageParts.Add(fmsgti);

            _IrcMessageToMessageModel(ref fmsg, e.Data.Message);

            Session.AddMessageToChat(chat, fmsg);
        }
Ejemplo n.º 26
0
        public override void OpenChat(FrontendManager fm, ChatModel chat)
        {
            Trace.Call(fm, chat);

            switch (chat.ChatType) {
                case ChatType.Person:
                    var personChat = (PersonChatModel) GetChat(chat.ID, ChatType.Person);
                    if (personChat != null) {
                        return;
                    }
                    var person = CreatePerson(chat.ID);
                    personChat = new PersonChatModel(person, chat.ID, chat.ID, this);
                    personChat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
                    Session.AddChat(personChat);
                    Session.SyncChat(personChat);
                    break;
                case ChatType.Group:
                    Client.JoinRoom(chat.ID);
                    break;
            }
        }
Ejemplo n.º 27
0
        //        private void _OnReadText(xobject sender, string text)
        //        {
        //                Session.AddTextToChat(_NetworkChat, "-!- RECV: " + text);
        //        }
        //        private void _OnWriteText(xobject sender, string text)
        //        {
        //                Session.AddTextToChat(_NetworkChat, "-!- SENT: " + text);
        //        }
        private void MsnClient_ConversationCreated(object sender, ConversationCreatedEventArgs e)
        {
            Trace.Call(sender, e);

            // Session.AddTextToChat(_NetworkChat, "Conversation bla");
            //e.Conversation.Switchboard.Co
            //_MsnClient.Nameserver.RequestScreenName();

            // NetworkChatModel nchat = new NetworkChatModel("MSN", "MSN", this);
             //Session.AddChat(nchat);

            e.Conversation.Switchboard.TextMessageReceived +=  delegate(object sender2, TextMessageEventArgs e2) {
                PersonModel person = new PersonModel(e2.Sender.Name,
                                                     e2.Sender.Name,
                                                     NetworkID, Protocol,
                                                     this);
                PersonChatModel personChat = new PersonChatModel(person,
                                                                 e2.Sender.Name,
                                                                 e2.Sender.Name,
                                                                 this);
                Session.AddChat(personChat);
                Session.AddTextToChat(personChat, e2.Message.Text);
             };
        }
Ejemplo n.º 28
0
        private ChatModel OpenPrivateChat(decimal userId)
        {
            ChatModel chat =  Session.GetChat(
                userId.ToString(),
                ChatType.Person,
                this
            );

            if (chat != null) {
                return chat;
            }

            TwitterUser user = TwitterUser.Show(f_OAuthTokens, userId,
                                                f_OptionalProperties);
            PersonModel person = CreatePerson(user);
            PersonChatModel personChat = new PersonChatModel(
                person,
                user.Id.ToString(),
                user.ScreenName,
                this
            );
            personChat.InitMessageBuffer(
                MessageBufferPersistencyType.Volatile
            );
            personChat.ApplyConfig(Session.UserConfig);
            Session.AddChat(personChat);
            Session.SyncChat(personChat);
            return personChat;
        }
Ejemplo n.º 29
0
 public TwitterPersonChatView(PersonChatModel personChat)
     : base(personChat)
 {
     Trace.Call(personChat);
 }
Ejemplo n.º 30
0
        private void _OnMessage(object sender, Message xmppMsg)
        {
            // TODO: implement group chat
            if (xmppMsg.Type == jabberMessageType.chat) {
                string jid = xmppMsg.From.ToString();
                string user = xmppMsg.From.User;
                ChatModel chat = Session.GetChat(user, ChatType.Person, this);
                if (chat == null) {
                    PersonModel person = new PersonModel(jid, user,
                                                NetworkID, Protocol, this);
                    chat = new PersonChatModel(person, jid, user, this);
                    Session.AddChat(chat);
                }

                MessageModel msg = new MessageModel();
                TextMessagePartModel msgPart;

                // TODO: parse possible markup in body
                msgPart = new TextMessagePartModel();
                msgPart.Text = String.Format("<{0}> {1}", xmppMsg.From.User, xmppMsg.Body);
                msg.MessageParts.Add(msgPart);

                Session.AddMessageToChat(chat, msg);
            }
        }