mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-23 02:58:00 +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:
parent
b840bed4a6
commit
41733effe9
2 changed files with 18 additions and 2 deletions
|
@ -440,6 +440,9 @@ public class Roster {
|
||||||
|
|
||||||
for (String resource : userPresences.keySet()) {
|
for (String resource : userPresences.keySet()) {
|
||||||
Presence p = userPresences.get(resource);
|
Presence p = userPresences.get(resource);
|
||||||
|
if (!p.isAvailable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Chose presence with highest priority first.
|
// Chose presence with highest priority first.
|
||||||
if (presence == null || p.getPriority() > presence.getPriority()) {
|
if (presence == null || p.getPriority() > presence.getPriority()) {
|
||||||
presence = p;
|
presence = p;
|
||||||
|
@ -523,7 +526,20 @@ public class Roster {
|
||||||
return Arrays.asList(presence).iterator();
|
return Arrays.asList(presence).iterator();
|
||||||
}
|
}
|
||||||
else {
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -523,7 +523,7 @@ public class RosterTest extends SmackTestCase {
|
||||||
Presence.Type.unavailable, presence.getType());
|
Presence.Type.unavailable, presence.getType());
|
||||||
|
|
||||||
// Check that the returned presences are correct
|
// Check that the returned presences are correct
|
||||||
Iterator presences = roster.getPresences(getBareJID(1));
|
Iterator<Presence> presences = roster.getPresences(getBareJID(1));
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (presences.hasNext()) {
|
while (presences.hasNext()) {
|
||||||
count++;
|
count++;
|
||||||
|
|
Loading…
Reference in a new issue