private IQ SetVCardSearch(XmppStream stream, IQ iq, XmppHandlerContext context) { var answer = new IQ(IqType.result); answer.Id = iq.Id; answer.To = iq.From; answer.From = iq.To; var search = (Search)iq.Query; var pattern = new Vcard(); pattern.Nickname = search.Nickname; pattern.Name = new Name(search.Lastname, search.Firstname, null); //pattern.AddEmailAddress(new Email() { UserId = search.Email }); search = new Search(); foreach (var vcard in context.StorageManager.VCardStorage.Search(pattern)) { var item = new SearchItem(); item.Jid = vcard.JabberId; item.Nickname = vcard.Nickname; if (vcard.Name != null) { item.Firstname = vcard.Name.Given; item.Lastname = vcard.Name.Family; } var email = vcard.GetPreferedEmailAddress(); if (email != null) { item.Email = email.UserId; } search.AddChild(item); } answer.Query = search; return answer; }
/// <summary> /// Retrieve the result items of a search /// </summary> //public ElementList GetItems //{ // get // { // return this.SelectElements("item"); // } //} public SearchItem[] GetItems() { ElementList nl = SelectElements(typeof (SearchItem)); var items = new SearchItem[nl.Count]; int i = 0; foreach (Element e in nl) { items[i] = (SearchItem) e; i++; } return items; }