mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 01:32:17 -05:00
resetting fetch status error when mutual subscription is reestablished
This commit is contained in:
parent
8d595c1fc2
commit
9ce2cfa3d2
@ -77,7 +77,7 @@ public final class Config {
|
||||
public static final boolean DISABLE_HTTP_UPLOAD = false;
|
||||
public static final boolean DISABLE_STRING_PREP = false; // setting to true might increase startup performance
|
||||
public static final boolean EXTENDED_SM_LOGGING = false; // log stanza counts
|
||||
public static final boolean EXTENDED_IQ_LOGGING = true; // log iq requests
|
||||
public static final boolean BACKGROUND_STANZA_LOGGING = true;
|
||||
public static final boolean RESET_ATTEMPT_COUNT_ON_NETWORK_CHANGE = true; //setting to true might increase power consumption
|
||||
|
||||
public static final boolean ENCRYPT_ON_HTTP_UPLOADED = false;
|
||||
|
@ -216,6 +216,20 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
|
||||
|
||||
private static class FetchStatusMap extends AxolotlAddressMap<FetchStatus> {
|
||||
|
||||
public void clearErrorFor(Jid jid) {
|
||||
synchronized (MAP_LOCK) {
|
||||
Map<Integer, FetchStatus> devices = this.map.get(jid.toBareJid().toString());
|
||||
if (devices == null) {
|
||||
return;
|
||||
}
|
||||
for(Map.Entry<Integer, FetchStatus> entry : devices.entrySet()) {
|
||||
if (entry.getValue() == FetchStatus.ERROR) {
|
||||
Log.d(Config.LOGTAG,"resetting error for "+jid.toBareJid()+"("+entry.getKey()+")");
|
||||
entry.setValue(FetchStatus.TIMEOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLogprefix(Account account) {
|
||||
@ -320,6 +334,10 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
|
||||
numPublishTriesOnEmptyPep = 0;
|
||||
}
|
||||
|
||||
public void clearErrorsInFetchStatusMap(Jid jid) {
|
||||
fetchStatusMap.clearErrorFor(jid);
|
||||
}
|
||||
|
||||
public void regenerateKeys(boolean wipeOther) {
|
||||
axolotlStore.regenerate();
|
||||
sessions.clear();
|
||||
|
@ -54,6 +54,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||
final String name = item.getAttribute("name");
|
||||
final String subscription = item.getAttribute("subscription");
|
||||
final Contact contact = account.getRoster().getContact(jid);
|
||||
boolean bothPre = contact.getOption(Contact.Options.TO) && contact.getOption(Contact.Options.FROM);
|
||||
if (!contact.getOption(Contact.Options.DIRTY_PUSH)) {
|
||||
contact.setServerName(name);
|
||||
contact.parseGroupsFromElement(item);
|
||||
@ -69,6 +70,14 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||
contact.parseSubscriptionFromElement(item);
|
||||
}
|
||||
}
|
||||
boolean both = contact.getOption(Contact.Options.TO) && contact.getOption(Contact.Options.FROM);
|
||||
if ((both != bothPre) && both) {
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": gained mutual presence subscription with "+contact.getJid());
|
||||
AxolotlService axolotlService = account.getAxolotlService();
|
||||
if (axolotlService != null) {
|
||||
axolotlService.clearErrorsInFetchStatusMap(contact.getJid());
|
||||
}
|
||||
}
|
||||
mXmppConnectionService.getAvatarService().clear(contact);
|
||||
}
|
||||
}
|
||||
@ -268,7 +277,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||
|
||||
@Override
|
||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||
if (Config.EXTENDED_IQ_LOGGING && (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET)) {
|
||||
if (Config.BACKGROUND_STANZA_LOGGING && (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET)) {
|
||||
Element first = packet.getChildren().size() > 0 ? packet.getChildren().get(0) : null;
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": IQ request from "+packet.getFrom()+(first == null ? "" : " "+first));
|
||||
}
|
||||
|
@ -533,6 +533,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||
}
|
||||
}
|
||||
} else if (!packet.hasChild("body")){ //no body
|
||||
if (Config.BACKGROUND_STANZA_LOGGING && !mXmppConnectionService.checkListeners()) {
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": " + original);
|
||||
}
|
||||
Conversation conversation = mXmppConnectionService.find(account, from.toBareJid());
|
||||
if (isTypeGroupChat) {
|
||||
if (packet.hasChild("subject")) {
|
||||
@ -563,6 +566,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||
for(Element child : mucUserElement.getChildren()) {
|
||||
if ("item".equals(child.getName())) {
|
||||
MucOptions.User user = AbstractParser.parseItem(conversation,child);
|
||||
Log.d(Config.LOGTAG,account.getJid()+": changing affiliation for "
|
||||
+user.getRealJid()+" to "+user.getAffiliation()+" in "
|
||||
+conversation.getJid().toBareJid());
|
||||
if (!user.realJidMatchesAccount()) {
|
||||
conversation.getMucOptions().addUser(user);
|
||||
}
|
||||
@ -572,6 +578,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Element received = packet.findChild("received", "urn:xmpp:chat-markers:0");
|
||||
if (received == null) {
|
||||
received = packet.findChild("received", "urn:xmpp:receipts");
|
||||
|
Loading…
Reference in New Issue
Block a user