public EventHeadlineMessage(Jid jid, HeadlineMessage headline)
            : base(string.Format("New Headline from {0}", jid), EventSeverity.Info)
        {
            _sender = jid;
            _headline = headline;

            Expiration = DateTime.Now.AddSeconds(Settings.Default.UI_Notify_Error_Exp);
        }
        private void SelectItem(HeadlineMessage item)
        {
            if (App.CheckAccessSafe())
            {
                _inlineSearch.NotFound = true;

                if (item != null)
                {
                    foreach (Block block in _flowViewer.Document.Blocks)
                    {
                        Section section = block as Section;

                        if (section != null)
                        {
                            foreach (Block sectionBlock in section.Blocks)
                            {
                                if (sectionBlock.DataContext == item)
                                {
                                    sectionBlock.BringIntoView();

                                    SelectText(sectionBlock as Paragraph, _textToSearch);

                                    _inlineSearch.NotFound = false;

                                    break;
                                }
                            }
                        }

                        if (!_inlineSearch.NotFound)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                App.InvokeSafe(DispatcherPriority.Send, new SelectItemCallback(SelectItem), item);
            }
        }
        private object SearchInList(ref bool stop, object param)
        {
            lock (_textsLock)
            {
                if (_texts == null)
                {
                    _texts = new List<KeyValuePair<string, HeadlineMessage>>();

                    lock (_headlinesChat.Messages._syncObject)
                    {
                        foreach (HeadlineMessage mucMessage in _headlinesChat.Messages)
                        {
                            if (!string.IsNullOrEmpty(mucMessage.Body))
                            {
                                _texts.Add(
                                    new KeyValuePair<string, HeadlineMessage>(mucMessage.Body.ToUpper().Trim(), mucMessage));
                            }
                        }
                    }
                }
            }

            HeadlineMessage found = null;

            _textToSearch = (string)param;

            string toFound = ((string)param).ToUpper();

            bool searchNext = (_lastSearch == toFound);

            _lastSearch = toFound;

            if (searchNext && _lastFoundItem != null)
            {
                bool fromHere = false;

                foreach (KeyValuePair<string, HeadlineMessage> body in _texts)
                {
                    if (stop)
                    {
                        return null;
                    }

                    if (fromHere && body.Key.Contains(toFound))
                    {
                        found = body.Value;
                        break;
                    }

                    if (_lastFoundItem == body.Value)
                    {
                        fromHere = true;
                    }
                }
            }
            else
            {
                foreach (KeyValuePair<string, HeadlineMessage> body in _texts)
                {
                    if (stop)
                    {
                        return null;
                    }

                    if (((string)param) == String.Empty)
                    {
                        return null;
                    }

                    if (body.Key.Contains(toFound))
                    {
                        found = body.Value;
                        break;
                    }
                }
            }

            _lastFoundItem = found;
            return found;
        }
        public static void SaveMessage(HeadlineMessage message)
        {
            try
            {
                Dictionary<string, object> values = message.GetData();

                Insert(values, "Message", false, _connection);
            }

            catch (Exception e)
            {
                Events.Instance.OnEvent(e, new EventError(e.Message, null));
            }
        }
Beispiel #5
0
        private void OnMessage(agsXMPP.protocol.client.Message msg)
        {
            switch (msg.Type)
            {
                case MessageType.chat:
                    {
                        Message message = new Message(msg);

                        if (msg.Body != null)
                        {
                            Database.SaveMessage(message);
                        }

                        DistributeMessage(message, msg.Chatstate);

                        break;
                    }
                case MessageType.headline:
                case MessageType.normal:
                case MessageType.error:
                    {
                        HeadlineMessage message = new HeadlineMessage(msg);

                        if (msg.Body != null)
                        {
                            Database.SaveMessage(message);
                        }

                        Events.Instance.OnEvent(this, new EventHeadlineMessage(msg.From, message));

                        break;
                    }
            }
        }