public void entriesAdded(Collection<String> arg0) {
for (Iterator it = arg0.iterator(); it.hasNext();) {
String address = (String) it.next();
System.out.println("Adresse zum Hinzufügen: " + address);
RosterEntry entry = xmppconnection.getRoster().getEntry(address);
//When the entry is only from the other user, then send a subscription request
if (entry != null && entry.getType() == RosterPacket.ItemType.from) {
System.out.println("Eintrag durchführen für from-ItemType");
try {
System.out.println("Erstelle Eintrag to: " + entry.getUser());
xmppconnection.getRoster().createEntry(entry.getUser(), entry.getName(), new String[0]);
} catch (XMPPException e) {
e.printStackTrace();
}
}
}
updateContacts();
setContactList();
}
});
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries) {
//System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: " + entry.toString());
if (entry != null && entry.getType() == RosterPacket.ItemType.to) {
//System.out.println("aaaaaaaaaaaaaaaaaaa- Eintrag durchführen für to-ItemType");
try {
//System.out.println("Erstelle Eintrag from: " + entry.getUser());
xmppconnection.getRoster().createEntry(entry.getUser(), entry.getName(), new String[0]);
} catch (XMPPException e) {
e.printStackTrace();
}
}
if (entry != null && entry.getType() == RosterPacket.ItemType.from) {
//System.out.println("bbbbbbbbbbbbbbbbbbbbbbb- Eintrag durchführen für to-ItemType");
try {
//System.out.println("Erstelle Eintrag from: " + entry.getUser());
xmppconnection.getRoster().createEntry(entry.getUser(), entry.getName(), new String[0]);
} catch (XMPPException e) {
e.printStackTrace();
}
}
String strBareJID = entry.getUser();
if(contacts.getContact(strBareJID, "") == null){
if (roster.getPresence(entry.getUser()).isAvailable()) {
//System.out.println(entry.getUser() + " mode: " + roster.getPresence(entry.getUser()).getMode().toString());
contacts.addContact(new Contact(entry.getUser(),roster.getPresence(entry.getUser()).getFrom(),entry.getName(),roster.getPresence(entry.getUser()).toString()));
}
else {
contacts.addContact(new Contact(entry.getUser(),"",entry.getName(),roster.getPresence(entry.getUser()).toString()));
//contacts.addContact(new Contact(entry.getUser(),roster.getPresence(entry.getUser()).getFrom(),entry.getName(),roster.getPresence(entry.getUser()).toString()));
}
}
}
System.out.println("in der Roster:");