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

Roster and presence packet reading fixes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1899 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-04-25 20:18:49 +00:00 committed by mtucker
parent 949933a9d1
commit 6cea9b8bd3

View file

@ -436,8 +436,15 @@ class PacketReader {
String jid = parser.getAttributeValue("", "jid"); String jid = parser.getAttributeValue("", "jid");
String name = parser.getAttributeValue("", "name"); String name = parser.getAttributeValue("", "name");
String subscription = parser.getAttributeValue("", "subscription"); String subscription = parser.getAttributeValue("", "subscription");
String ask = parser.getAttributeValue("", "ask");
item = new RosterPacket.Item(jid, name); item = new RosterPacket.Item(jid, name);
item.setItemType(RosterPacket.ItemType.fromString(subscription)); RosterPacket.ItemType type = RosterPacket.ItemType.fromString(subscription);
if (type == RosterPacket.ItemType.NONE && "subscribe".equals(ask)) {
item.setItemType(RosterPacket.ItemType.PENDING);
}
else {
item.setItemType(type);
}
} }
if (parser.getName().equals("group")) { if (parser.getName().equals("group")) {
String groupName = parser.nextText(); String groupName = parser.nextText();
@ -590,12 +597,6 @@ class PacketReader {
*/ */
private static Packet parsePresence(XmlPullParser parser) throws Exception { private static Packet parsePresence(XmlPullParser parser) throws Exception {
Presence.Type type = Presence.Type.fromString(parser.getAttributeValue("", "type")); Presence.Type type = Presence.Type.fromString(parser.getAttributeValue("", "type"));
// We only handle "available" or "unavailable" packets for now.
if (!(type == Presence.Type.AVAILABLE || type == Presence.Type.UNAVAILABLE)) {
System.out.println("FOUND OTHER PRESENCE TYPE: " + type);
}
// Otherwise, it's a presence packet that has nothing to do with roster items.
Presence presence = new Presence(type); Presence presence = new Presence(type);
presence.setTo(parser.getAttributeValue("", "to")); presence.setTo(parser.getAttributeValue("", "to"));