Beispiel #1
0
 /**
  * @see net.sf.kraken.session.TransportSession#removeContact(net.sf.kraken.roster.TransportBuddy)
  */
 @Override
 public void removeContact(XMPPBuddy contact) {
   RosterEntry user2remove;
   String mail = getTransport().convertJIDToID(contact.getJID());
   user2remove = conn.getRoster().getEntry(mail);
   try {
     conn.getRoster().removeEntry(user2remove);
   } catch (XMPPException ex) {
     Log.debug("XMPP: unable to remove:" + mail);
   }
 }
Beispiel #2
0
 /**
  * @see net.sf.kraken.session.TransportSession#updateContact(net.sf.kraken.roster.TransportBuddy)
  */
 @Override
 public void updateContact(XMPPBuddy contact) {
   RosterEntry user2Update;
   String mail = getTransport().convertJIDToID(contact.getJID());
   user2Update = conn.getRoster().getEntry(mail);
   user2Update.setName(contact.getNickname());
   Collection<String> newgroups = contact.getGroups();
   if (newgroups == null) {
     newgroups = new ArrayList<String>();
   }
   for (RosterGroup group : conn.getRoster().getGroups()) {
     if (newgroups.contains(group.getName())) {
       if (!group.contains(user2Update)) {
         try {
           group.addEntry(user2Update);
         } catch (XMPPException e) {
           Log.debug("XMPP: Unable to add roster item to group.");
         }
       }
       newgroups.remove(group.getName());
     } else {
       if (group.contains(user2Update)) {
         try {
           group.removeEntry(user2Update);
         } catch (XMPPException e) {
           Log.debug("XMPP: Unable to delete roster item from group.");
         }
       }
     }
   }
   for (String group : newgroups) {
     RosterGroup newgroup = conn.getRoster().createGroup(group);
     try {
       newgroup.addEntry(user2Update);
     } catch (XMPPException e) {
       Log.debug("XMPP: Unable to add roster item to new group.");
     }
   }
 }