Beispiel #1
0
        public static void PublishAvatar(string filetype, byte[] image)
        {
            try
            {
                foreach (var account in Frontend.Accounts.Enabled)
                {
                    if (account.CurrentVCard != null)
                    {
                        var iq = new Tags.jabber.client.iq();
                        iq.from = account.CurrentJID;
                        iq.type = Tags.jabber.client.iq.typeEnum.set;

                        var vcard = new Tags.vcard_temp.vCard();

                        foreach (var element in account.CurrentVCard.Elements())
                        {
                            if (element.Name != XName.Get("PHOTO", "vcard-temp") &&     // I know how ugly this is, but I have to get this done~!
                                element.Name != XName.Get("TYPE", "vcard-temp") &&
                                element.Name != XName.Get("BINVAL", "vcard-temp"))
                            {
                                vcard.Add(element);
                            }
                        }

                        var photo = new XElement(XName.Get("PHOTO", "vcard-temp"));
                        photo.Add(new XElement(XName.Get("TYPE", "vcard-temp"), filetype));
                        photo.Add(new XElement(XName.Get("BINVAL", "vcard-temp"), System.Convert.ToBase64String(image)));
                        vcard.Add(photo);

                        iq.Add(vcard);

                        Frontend.Backend.SendTag(account.jid, iq);

                        account.OwnContact.SetAvatar(image);
                    }
                }
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }
        }
Beispiel #2
0
        public static void PublishAvatar(string filetype, byte[] image)
        {
            try
            {
                foreach (var account in Frontend.Accounts.Enabled)
                {
                    if (account.CurrentVCard != null)
                    {
                        var iq = new Tags.jabber.client.iq();
                        iq.from = account.CurrentJID;
                        iq.type = Tags.jabber.client.iq.typeEnum.set;

                        var vcard = new Tags.vcard_temp.vCard();

                        foreach (var element in account.CurrentVCard.Elements())
                        {
                            if (element.Name != XName.Get("PHOTO", "vcard-temp") &&     // I know how ugly this is, but I have to get this done~!
                                element.Name != XName.Get("TYPE", "vcard-temp") &&
                                element.Name != XName.Get("BINVAL", "vcard-temp"))
                                vcard.Add(element);
                        }

                        var photo = new XElement(XName.Get("PHOTO", "vcard-temp"));
                        photo.Add(new XElement(XName.Get("TYPE", "vcard-temp"), filetype));
                        photo.Add(new XElement(XName.Get("BINVAL", "vcard-temp"), System.Convert.ToBase64String(image)));
                        vcard.Add(photo);

                        iq.Add(vcard);

                        Frontend.Backend.SendTag(account.jid, iq);

                        account.OwnContact.SetAvatar(image);
                    }
                }
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }
        }