Jid GetJidFromNickname(string nickname)
{
XmppPersonModel it;
Jid jid = nickname;
if (Contacts.TryGetValue(jid, out it)) {
// nickname is a jid we know
return jid;
}
if (Contacts.TryGetValue(jid.Bare, out it)) {
// is a jid with resource
return jid;
}
// arg is not a jid in our rostermanager
// find a jid to which the nickname belongs
foreach (var pair in Contacts) {
if (pair.Value.IdentityName != null &&
pair.Value.IdentityName.Replace(" ", "_") == nickname) {
return pair.Key;
}
}
// not found in roster, message directly to jid
// TODO: check jid for validity
return jid;
}