kill pending queries when archiving conversation
This commit is contained in:
parent
3c60de54cb
commit
8764d11cce
|
@ -45,7 +45,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
|
||||
public static Version get(Account account) {
|
||||
return get(account,null);
|
||||
return get(account, null);
|
||||
}
|
||||
|
||||
public static Version get(Account account, Conversation conversation) {
|
||||
|
@ -58,8 +58,8 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
|
||||
private static Version get(List<String> features) {
|
||||
final Version[] values = values();
|
||||
for(int i = values.length -1; i >= 0; --i) {
|
||||
for(String feature : features) {
|
||||
for (int i = values.length - 1; i >= 0; --i) {
|
||||
for (String feature : features) {
|
||||
if (values[i].namespace.equals(feature)) {
|
||||
return values[i];
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
|
||||
public static boolean has(List<String> features) {
|
||||
for(String feature : features) {
|
||||
for(Version version : values()) {
|
||||
for (String feature : features) {
|
||||
for (Version version : values()) {
|
||||
if (version.namespace.equals(feature)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
|
||||
public static Element findResult(MessagePacket packet) {
|
||||
for(Version version : values()) {
|
||||
for (Version version : values()) {
|
||||
Element result = packet.findChild("result", version.namespace);
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
@ -209,7 +209,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
|
||||
void executePendingQueries(final Account account) {
|
||||
List<Query> pending = new ArrayList<>();
|
||||
final List<Query> pending = new ArrayList<>();
|
||||
synchronized (this.pendingQueries) {
|
||||
for (Iterator<Query> iterator = this.pendingQueries.iterator(); iterator.hasNext(); ) {
|
||||
Query query = iterator.next();
|
||||
|
@ -250,7 +250,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
if (running) {
|
||||
processFin(query, fin);
|
||||
} else {
|
||||
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": ignoring MAM iq result because query had been killed");
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring MAM iq result because query had been killed");
|
||||
}
|
||||
} else if (p.getType() == IqPacket.TYPE.RESULT && query.isLegacy()) {
|
||||
//do nothing
|
||||
|
@ -303,7 +303,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
|
||||
public boolean isCatchupInProgress(Conversation conversation) {
|
||||
synchronized (this.queries) {
|
||||
for(Query query : queries) {
|
||||
for (Query query : queries) {
|
||||
if (query.account == conversation.getAccount() && query.isCatchup()) {
|
||||
final Jid with = query.getWith() == null ? null : query.getWith().asBareJid();
|
||||
if ((conversation.getMode() == Conversational.MODE_SINGLE && with == null) || (conversation.getJid().asBareJid().equals(with))) {
|
||||
|
@ -390,8 +390,17 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
}
|
||||
|
||||
void kill(Conversation conversation) {
|
||||
void kill(final Conversation conversation) {
|
||||
final ArrayList<Query> toBeKilled = new ArrayList<>();
|
||||
synchronized (this.pendingQueries) {
|
||||
for (final Iterator<Query> iterator = this.pendingQueries.iterator(); iterator.hasNext(); ) {
|
||||
final Query query = iterator.next();
|
||||
if (query.getConversation() == conversation) {
|
||||
iterator.remove();
|
||||
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": killed pending MAM query for archived conversation");
|
||||
}
|
||||
}
|
||||
}
|
||||
synchronized (this.queries) {
|
||||
for (final Query q : queries) {
|
||||
if (q.conversation == conversation) {
|
||||
|
@ -399,7 +408,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Query q : toBeKilled) {
|
||||
for (final Query q : toBeKilled) {
|
||||
kill(q);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue