1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

Updated handling of offline presence.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10916 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2008-11-21 04:54:59 +00:00 committed by matt
parent b840bed4a6
commit 41733effe9
2 changed files with 18 additions and 2 deletions

View file

@ -440,6 +440,9 @@ public class Roster {
for (String resource : userPresences.keySet()) {
Presence p = userPresences.get(resource);
if (!p.isAvailable()) {
continue;
}
// Chose presence with highest priority first.
if (presence == null || p.getPriority() > presence.getPriority()) {
presence = p;
@ -523,7 +526,20 @@ public class Roster {
return Arrays.asList(presence).iterator();
}
else {
return userPresences.values().iterator();
Collection<Presence> answer = new ArrayList<Presence>();
for (Presence presence : userPresences.values()) {
if (presence.isAvailable()) {
answer.add(presence);
}
}
if (!answer.isEmpty()) {
return answer.iterator();
}
else {
Presence presence = new Presence(Presence.Type.unavailable);
presence.setFrom(user);
return Arrays.asList(presence).iterator();
}
}
}

View file

@ -523,7 +523,7 @@ public class RosterTest extends SmackTestCase {
Presence.Type.unavailable, presence.getType());
// Check that the returned presences are correct
Iterator presences = roster.getPresences(getBareJID(1));
Iterator<Presence> presences = roster.getPresences(getBareJID(1));
int count = 0;
while (presences.hasNext()) {
count++;