void SendPrivateMessage(XmppPersonModel person, Jid jid, string text)
{
if (jid == null) {
jid = person.Jid;
}
if ((jid.Server == "gmail.com") ||
(jid.Server == "googlemail.com")) {
// don't send to all high prio resources or to specific resources
// because gtalk clones any message to all resources anyway
_SendPrivateMessage(person, jid.Bare, text);
} else if (!String.IsNullOrEmpty(jid.Resource)) {
_SendPrivateMessage(person, jid, text);
} else {
var resources = person.GetResourcesWithHighestPriority();
if (resources.Count == 0) {
// no connected resource, send to bare jid
_SendPrivateMessage(person, jid.Bare, text);
} else {
foreach (var res in resources) {
if (String.IsNullOrEmpty(res.Name)) {
// don't send messages to empty resources
continue;
}
Jid j = new Jid(jid);
j.Resource = res.Name;
_SendPrivateMessage(person, j, text);
}
}
}
}