Ejemplo n.º 1
0
        public Matrix.Xmpp.Vcard.Vcard saveVCard(User user, AppPreferences appPref)
        {
            var vCard = new Matrix.Xmpp.Vcard.Vcard();

            vCard.SetElementValue("First", user.First);
            vCard.SetElementValue("Last", user.Last);
            vCard.Fullname     = user.First + " " + user.Last;
            vCard.Nickname     = user.username;
            vCard.Photo        = new Matrix.Xmpp.Vcard.Photo();
            vCard.Photo.Binval = ByteBufferFromImage(Base64ToBitmap(appPref.getValueKey(AppPreferences.AVATAR)));
            vCard.SetElementValue("Phone", user.Phone);
            return(vCard);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Stores vCard with current users profile information ie avatar, nickname, first/last
 /// </summary>
 /// <param name="vCard"></param>
 public void SetMyVCard(Matrix.Xmpp.Vcard.Vcard vCard)
 {
     try
     {
         var vIq = new VcardIq {
             Type = Matrix.Xmpp.IqType.Set
         };
         vIq.Vcard = vCard;
         xmppClient.IqFilter.SendIq(vIq, null);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
Ejemplo n.º 3
0
        public Matrix.Xmpp.Vcard.Vcard saveVCard(User user, AppPreferences appPref, string avatar)
        {
            var vCard = new Matrix.Xmpp.Vcard.Vcard();

            vCard.SetElementValue("First", user.First);
            vCard.SetElementValue("Last", user.Last);
            vCard.Fullname = user.First + " " + user.Last;
            vCard.Nickname = user.username;
            vCard.Photo    = new Matrix.Xmpp.Vcard.Photo();
            if (avatar != null)
            {
                vCard.Photo.Binval = ByteBufferFromImage(Base64ToBitmap(avatar));
            }
            vCard.SetElementValue("Phone", user.Phone);
            return(vCard);
        }
Ejemplo n.º 4
0
        public AppCore.User getValidUser(Matrix.Xmpp.Vcard.Vcard vc, string resourceName)
        {
            AppCore.User contac = new AppCore.User();
            contac.Jid = vc.Jid;

            if (vc.Nickname != null && vc.Nickname != "")
            {
                contac.username = vc.Nickname;
                contac.First    = vc.Fullname;

                if (vc.GetTagXElement("Phone") != null)
                {
                    contac.Phone = vc.GetTagXElement("Phone").ToString();
                }

                if (vc.Photo != null)
                {
                    if (vc.Photo.Binval != null)
                    {
                        contac.Photo = LegionUtils.bitmapToBase64(vc.Photo.Binval);
                        appPreferences.saveKey(contac.username + "_ICON", contac.Photo);
                    }
                }
            }
            else
            {
                vc.Nickname     = vc.Jid.ToString().Replace("@" + resourceName, "");
                contac.username = vc.Nickname;
                if (vc.Photo != null)
                {
                    if (vc.Photo.Binval != null)
                    {
                        contac.Photo = LegionUtils.bitmapToBase64(vc.Photo.Binval);
                    }
                }
            }

            return(contac);
        }