Пример #1
0
        // Look for subscribe message to subscribe to presence
        public override bool NewIQ(IQ iq)
        {
            if ((iqGetOurVCARD != null) && (iq.ID == iqGetOurVCARD.ID))
            {
                foreach (XElement vcard in iq.InitalXMLElement.Descendants("{vcard-temp}vCard"))
                {
                    vcard card = Utility.ParseObjectFromXMLString(vcard.ToString(), typeof(vcard)) as vcard;
                    if (card != null)
                    {
                        XMPPClient.vCard = card;
                    }
                }
                return(true);
            }

            if (iq.InitalXMLElement != null)
            {
                foreach (XElement vcard in iq.InitalXMLElement.Descendants("{vcard-temp}vCard"))
                {
                    vcard card = Utility.ParseObjectFromXMLString(vcard.ToString(), typeof(vcard)) as vcard;
                    if (card != null)
                    {
                        RosterItem item = XMPPClient.FindRosterItem(iq.From);
                        if (item != null)
                        {
                            item.vCard = card;
                        }
                        else if (iq.From.BareJID == XMPPClient.JID.BareJID)
                        {
                            XMPPClient.vCard = card;
                        }
                    }
                    ////suresh request vCard
                    if (iq.Type == "result")
                    {
                        if (iq.From != iq.To)
                        {
                            XMPPClient.FireDelegateVcardHandler(card, iq.From);
                        }
                    }

                    return(true);
                }

                foreach (XElement avaelem in iq.InitalXMLElement.Descendants("{jabber:iq:avatar}query"))
                {
                    IQAvatarQuery ava = Utility.ParseObjectFromXMLString(avaelem.ToString(), typeof(IQAvatarQuery)) as IQAvatarQuery;
                    if (ava != null)
                    {
                        /// Found a new avatar using this 3rd method, tell the client
                    }

                    return(true);
                }
            }

            return(base.NewIQ(iq));
        }
Пример #2
0
        public void UdpateVCARD(vcard vcard)
        {
            IQ iq = new IQ();

            iq.From     = XMPPClient.JID;
            iq.To       = null;
            iq.Type     = IQType.set.ToString();
            iq.InnerXML = Utility.GetXMLStringFromObject(vcard);

            XMPPClient.SendXMPP(iq);
        }
Пример #3
0
        public void UpdateRosterImage(vcard vcars)
        {
            IQ iq = new IQ();

            iq.From = XMPPClient.JID;
            iq.To   = null;
            iq.Type = IQType.set.ToString();
            //ser
            XmlSerializer serilise  = new XmlSerializer(typeof(vcard));
            TextWriter    txtWriter = new StreamWriter(vcars.ToString());

            serilise.Serialize(txtWriter, vcars);
            txtWriter.Close();
            iq.InnerXML = serilise.ToString();
            XMPPClient.SendXMPP(iq);
        }