Example #1
0
 public StatusEventArgs(S22.Xmpp.Jid jid, S22.Xmpp.Im.Status status)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     status.ThrowIfNull <S22.Xmpp.Im.Status>("status");
     this.Jid    = jid;
     this.Status = status;
 }
        /// <summary>
        /// Updates the status contact.
        /// </summary>
        /// <param name="jid">The jid of the contact.</param>
        /// <param name="status">The new status.</param>
        public void UpdateContact(Jid jid, S22.Xmpp.Im.Status status)
        {
            if (AllContacts.Count != 0)
            {
                foreach (var contact in AllContacts)
                {
                    if (jid.GetBareJid() == contact.Jid.GetBareJid())
                    {
                        contact.CurrentStatus = new S22.Xmpp.Im.Status(status.Availability, status.Messages, status.Priority);

                        break;
                    }
                }
            }
            else
            {
            }
        }
Example #3
0
        private void ProcessStatusNotification(S22.Xmpp.Im.Presence presence)
        {
            bool         flag         = presence.Type == PresenceType.Unavailable;
            XmlElement   element      = presence.Data["show"];
            Availability availability = flag ? Availability.Offline : Availability.Online;

            if (!flag && !((element == null) || string.IsNullOrEmpty(element.InnerText)))
            {
                string str = element.InnerText.Capitalize();
                availability = (Availability)Enum.Parse(typeof(Availability), str);
            }
            sbyte priority = 0;

            element = presence.Data["priority"];
            if (!((element == null) || string.IsNullOrEmpty(element.InnerText)))
            {
                priority = sbyte.Parse(element.InnerText);
            }
            string attribute = presence.Data.GetAttribute("xml:lang");
            Dictionary <string, string> messages = new Dictionary <string, string>();

            if (string.IsNullOrEmpty(attribute))
            {
                attribute = this.core.Language.Name;
            }
            foreach (XmlNode node in presence.Data.GetElementsByTagName("status"))
            {
                XmlElement element2 = node as XmlElement;
                if (element2 != null)
                {
                    string str3 = element2.GetAttribute("xml:lang");
                    if (string.IsNullOrEmpty(str3))
                    {
                        str3 = attribute;
                    }
                    messages.Add(str3, element2.InnerText);
                }
            }
            S22.Xmpp.Im.Status status = new S22.Xmpp.Im.Status(availability, messages, priority);
            this.Status.Raise <StatusEventArgs>(this, new StatusEventArgs(presence.From, status));
        }
Example #4
0
 public void SetStatus(S22.Xmpp.Im.Status status)
 {
     this.AssertValid(true);
     status.ThrowIfNull <S22.Xmpp.Im.Status>("status");
     this.SetStatus(status.Availability, status.Messages, status.Priority);
 }