This commit is contained in:
Daniel Gultsch 2014-04-16 19:48:04 +02:00 committed by Andreas Straub
parent a04d736f75
commit e29ce19f20
2 changed files with 21 additions and 2 deletions

View File

@ -287,7 +287,11 @@ public class XmppConnectionService extends Service {
} else { } else {
Contact contact = findContact(account, fromParts[0]); Contact contact = findContact(account, fromParts[0]);
if (contact == null) { if (contact == null) {
if ("subscribe".equals(type)) {
account.getXmppConnection().addPendingSubscription(fromParts[0]);
} else {
Log.d(LOGTAG,packet.getFrom()+ " could not be found"); Log.d(LOGTAG,packet.getFrom()+ " could not be found");
}
return; return;
} }
if (type == null) { if (type == null) {
@ -343,7 +347,7 @@ public class XmppConnectionService extends Service {
requestPresenceUpdatesFrom(contact); requestPresenceUpdatesFrom(contact);
} }
} else { } else {
// TODO: ask user to handle it maybe account.getXmppConnection().addPendingSubscription(fromParts[0]);
} }
} else { } else {
//Log.d(LOGTAG, packet.toString()); //Log.d(LOGTAG, packet.toString());
@ -1232,6 +1236,10 @@ public class XmppConnectionService extends Service {
account.getXmppConnection().sendIqPacket(iq, null); account.getXmppConnection().sendIqPacket(iq, null);
if (autoGrant) { if (autoGrant) {
requestPresenceUpdatesFrom(contact); requestPresenceUpdatesFrom(contact);
if (account.getXmppConnection().hasPendingSubscription(contact.getJid())) {
Log.d("xmppService","contact had pending subscription");
sendPresenceUpdatesTo(contact);
}
} }
replaceContactInConversation(contact.getJid(), contact); replaceContactInConversation(contact.getJid(), contact);
} }

View File

@ -77,6 +77,8 @@ public class XmppConnection implements Runnable {
private Element streamFeatures; private Element streamFeatures;
private HashMap<String, List<String>> disco = new HashMap<String, List<String>>(); private HashMap<String, List<String>> disco = new HashMap<String, List<String>>();
private HashSet<String> pendingSubscriptions = new HashSet<String>();
private String streamId = null; private String streamId = null;
private int smVersion = 3; private int smVersion = 3;
@ -904,4 +906,13 @@ public class XmppConnection implements Runnable {
public String getMucServer() { public String getMucServer() {
return findDiscoItemByFeature("http://jabber.org/protocol/muc"); 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);
}
} }