public Vcard Get(string username)
        {
            Vcard vcard = null;

            using (SqlDataContext dc = new SqlDataContext())
            {
                try
                {
                    var user = dc.DatabaseUserItems.Single(x => string.Compare(username, x.Username, true) == 0);
                    var data = HeaderManager.Load(username);
                    vcard             = new Vcard();
                    vcard.Nickname    = user.Nickname;
                    vcard.Description = user.Signature;
                    vcard.Jid         = JIDEscaping.Escape(user.Username) + "@gjtalk.com";
                    vcard.AddEmail(new Email(user.Mail));
                    if (data != null)
                    {
                        vcard.Photo = new Photo(data, ImageFormat.Png);
                    }
                }
                catch (System.Exception ex)
                {
                }
            }
            return(vcard);
        }
 public Vcard Get(Jid jid)
 {
     if (jid == null)
     {
         return(null);
     }
     return(Get(JIDEscaping.Unescape(jid.User)));
 }
Exemple #3
0
        public void PutPresence(Presence presence)
        {
            var db         = GetDatabase();
            var collection = db.GetCollection("offline_presence");

            collection.Insert(
                new BsonDocument(
                    new BsonElement("from", JIDEscaping.Unescape(presence.From.User)),
                    new BsonElement("to", JIDEscaping.Unescape(presence.To.User)),
                    new BsonElement("type", presence.Type.ToString()),
                    new BsonElement("value", presence.ToString())
                    ));
        }
 public bool Set(Jid jid, Vcard vcard)
 {
     return(Set(JIDEscaping.Unescape(jid), vcard));
 }
 public Session GetSession(Jid jid)
 {
     return(GetSession(JIDEscaping.Unescape(jid.User)));
 }
Exemple #6
0
 public RosterItem ToRosterItem()
 {
     return(new RosterItem(JIDEscaping.Escape(Username) + "@gjtalk.com",
                           Remark == null ? Nickname : Remark, GroupName));
 }