ported pending subscription support to new roster mgmt

This commit is contained in:
Daniel Gultsch 2014-05-20 10:48:07 +02:00
parent a582d44dba
commit 8f92d8d109
3 changed files with 5 additions and 28 deletions

View File

@ -286,5 +286,6 @@ public class Contact {
public static final int ASKING = 2;
public static final int PREEMPTIVE_GRANT = 4;
public static final int IN_ROSTER = 8;
public static final int PENDING_SUBSCRIPTION_REQUEST = 16;
}
}

View File

@ -303,12 +303,6 @@ public class XmppConnectionService extends Service {
} else {
Contact contact = account.getRoster().getContact(
packet.getFrom());
/*
* if (contact == null) { if ("subscribe".equals(type)) {
* account.getXmppConnection().addPendingSubscription(
* fromParts[0]); } else { // Log.d(LOGTAG,packet.getFrom()+
* // " could not be found"); } return; }
*/
if (type == null) {
if (fromParts.length == 2) {
contact.updatePresence(fromParts[1], Presences
@ -327,12 +321,6 @@ public class XmppConnectionService extends Service {
}
contact.setPgpKeyId(pgp.fetchKeyId(account,
msg, x.getContent()));
Log.d("xmppService",
account.getJid()
+ ": fetched key id for "
+ contact.getJid()
+ " was:"
+ contact.getPgpKeyId());
}
}
} else {
@ -357,8 +345,7 @@ public class XmppConnectionService extends Service {
requestPresenceUpdatesFrom(contact);
}
} else {
account.getXmppConnection().addPendingSubscription(
fromParts[0]);
contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
}
} else {
// Log.d(LOGTAG, packet.toString());
@ -1198,8 +1185,7 @@ public class XmppConnectionService extends Service {
pushContactToServer(contact);
if (autoGrant) {
requestPresenceUpdatesFrom(contact);
if (contact.getAccount().getXmppConnection().hasPendingSubscription(
contact.getJid())) {
if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
Log.d("xmppService", "contact had pending subscription");
sendPresenceUpdatesTo(contact);
}
@ -1260,6 +1246,7 @@ public class XmppConnectionService extends Service {
packet.setAttribute("from", contact.getAccount().getJid());
Log.d(LOGTAG, packet.toString());
contact.getAccount().getXmppConnection().sendPresencePacket(packet);
contact.resetOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
}
public void sendPresence(Account account) {

View File

@ -74,9 +74,7 @@ public class XmppConnection implements Runnable {
private boolean shouldAuthenticate = true;
private Element streamFeatures;
private HashMap<String, List<String>> disco = new HashMap<String, List<String>>();
private HashSet<String> pendingSubscriptions = new HashSet<String>();
private String streamId = null;
private int smVersion = 3;
@ -904,15 +902,6 @@ public class XmppConnection implements Runnable {
return findDiscoItemByFeature("http://jabber.org/protocol/muc");
}
public boolean hasPendingSubscription(String jid) {
return this.pendingSubscriptions.contains(jid);
}
public void addPendingSubscription(String jid) {
Log.d(LOGTAG,"adding "+jid+" to pending subscriptions");
this.pendingSubscriptions.add(jid);
}
public int getTimeToNextAttempt() {
int interval = (int) (25 * Math.pow(1.5,attempt));
int secondsSinceLast = (int) ((SystemClock.elapsedRealtime() - this.lastConnect) / 1000);