use of net.sf.jml.Email in project Openfire by igniterealtime.
the class MSNSession method completedPendingContactAdd.
/**
* Completes the addition of groups to a new contact after the contact has been created.
*
* @param msnContact Contact that was added.
*/
public void completedPendingContactAdd(MsnContact msnContact) {
try {
Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
Email contact = msnContact.getEmail();
JID contactJID = getTransport().convertIDToJID(contact.toString());
RosterItem item = roster.getRosterItem(contactJID);
getBuddyManager().storeBuddy(new MSNBuddy(getBuddyManager(), msnContact));
syncContactGroups(contact, item.getGroups());
} catch (UserNotFoundException e) {
Log.debug("MSN: Unable to find roster when adding pendingcontact for " + getJID());
}
}
use of net.sf.jml.Email in project Openfire by igniterealtime.
the class MSNSession method updateContact.
/**
* @see net.sf.kraken.session.TransportSession#updateContact(net.sf.kraken.roster.TransportBuddy)
*/
@Override
public void updateContact(MSNBuddy contact) {
Email email = Email.parseStr(getTransport().convertJIDToID(contact.getJID()));
if (email == null) {
Log.debug("MSN: Unable to update illegal contact " + contact.getJID());
return;
}
String nickname = getTransport().convertJIDToID(contact.getJID());
if (contact.getNickname() != null && !contact.getNickname().equals("")) {
nickname = contact.getNickname();
}
try {
MSNBuddy msnBuddy = getBuddyManager().getBuddy(contact.getJID());
if (msnBuddy.msnContact == null) {
MsnContact msnContact = msnMessenger.getContactList().getContactByEmail(email);
if (msnContact == null) {
Log.debug("MSN: Contact updated but doesn't exist? Adding.");
addContact(contact.getJID(), nickname, (ArrayList<String>) contact.getGroups());
return;
} else {
msnBuddy.setMsnContact(msnContact);
}
}
if (!msnBuddy.msnContact.getFriendlyName().equals(nickname)) {
msnMessenger.renameFriend(email, nickname);
}
syncContactGroups(email, (List<String>) contact.getGroups());
} catch (NotFoundException e) {
Log.debug("MSN: Newly added buddy not found in buddy manager: " + email.getEmailAddress());
}
}
use of net.sf.jml.Email in project Openfire by igniterealtime.
the class MSNSession method completedPendingGroupAdd.
/**
* Completes the addition of a contact to a new group after the group has been created.
*
* @param msnGroup Group that was added.
*/
public void completedPendingGroupAdd(MsnGroup msnGroup) {
if (!msnPendingGroups.containsKey(msnGroup.getGroupName())) {
// Nothing to do, no pending.
return;
}
try {
Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
for (Email contact : msnPendingGroups.get(msnGroup.getGroupName())) {
JID contactJID = getTransport().convertIDToJID(contact.toString());
RosterItem item = roster.getRosterItem(contactJID);
syncContactGroups(contact, item.getGroups());
}
} catch (UserNotFoundException e) {
Log.debug("MSN: Unable to find roster when adding pending group contacts for " + getJID());
}
}
use of net.sf.jml.Email in project Openfire by igniterealtime.
the class MSNSession method removeContact.
/**
* @see net.sf.kraken.session.TransportSession#removeContact(net.sf.kraken.roster.TransportBuddy)
*/
@Override
public void removeContact(MSNBuddy contact) {
Email email = Email.parseStr(getTransport().convertJIDToID(contact.getJID()));
if (email == null) {
Log.debug("MSN: Unable to remove illegal contact " + contact.getJID());
return;
}
msnMessenger.removeFriend(email, false);
}
use of net.sf.jml.Email in project Openfire by igniterealtime.
the class MSNSession method sendBuzzNotification.
/**
* @see net.sf.kraken.session.TransportSession#sendBuzzNotification(org.xmpp.packet.JID, String)
*/
@Override
public void sendBuzzNotification(JID jid, String message) {
final MsnDatacastMessage nudge = new MsnDatacastMessage();
// 1=nudge, 2=wink
nudge.setId(1);
final Email jidEmail = Email.parseStr(getTransport().convertJIDToID(jid));
for (MsnSwitchboard sb : msnMessenger.getActiveSwitchboards()) {
if (sb.containContact(jidEmail)) {
sb.sendMessage(nudge, false);
}
}
}
Aggregations