1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-09-26 17:59:34 +02:00

Added automatic acknowledge receipt for the unsubscribe notification. SMACK-98

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2998 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-10-27 15:22:14 +00:00 committed by gato
parent 03b8362dd2
commit 6a7f7826cd

View file

@ -42,9 +42,9 @@ import java.util.*;
public class Roster { public class Roster {
/** /**
* Automatically accept all subscription requests. This is the default mode * Automatically accept all subscription and unsubscription requests. This is
* and is suitable for simple client. More complex client will likely wish to * the default mode and is suitable for simple client. More complex client will
* handle subscription requests manually. * likely wish to handle subscription requests manually.
*/ */
public static final int SUBSCRIPTION_ACCEPT_ALL = 0; public static final int SUBSCRIPTION_ACCEPT_ALL = 0;
@ -56,7 +56,8 @@ public class Roster {
/** /**
* Subscription requests are ignored, which means they must be manually * Subscription requests are ignored, which means they must be manually
* processed by registering a listener for presence packets and then looking * processed by registering a listener for presence packets and then looking
* for any presence requests that have the type Presence.Type.SUBSCRIBE. * for any presence requests that have the type Presence.Type.SUBSCRIBE or
* Presence.Type.UNSUBSCRIBE.
*/ */
public static final int SUBSCRIPTION_MANUAL = 2; public static final int SUBSCRIPTION_MANUAL = 2;
@ -646,6 +647,17 @@ public class Roster {
} }
// Otherwise, in manual mode so ignore. // Otherwise, in manual mode so ignore.
} }
else if (presence.getType() == Presence.Type.UNSUBSCRIBE) {
if (subscriptionMode != SUBSCRIPTION_MANUAL) {
// Acknowledge and accept unsubscription notification so that the
// server will stop sending notifications saying that the contact
// has unsubscribed to our presence.
Presence response = new Presence(Presence.Type.UNSUBSCRIBED);
response.setTo(presence.getFrom());
connection.sendPacket(response);
}
// Otherwise, in manual mode so ignore.
}
} }
} }