aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java3
-rw-r--r--src/eu/siacs/conversations/parser/PresenceParser.java8
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java44
3 files changed, 30 insertions, 25 deletions
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index 728faf4b..60d8fc6b 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -109,6 +109,9 @@ public class MessageParser extends AbstractParser implements
private Message parseGroupchat(MessagePacket packet, Account account) {
int status;
String[] fromParts = packet.getFrom().split("/");
+ if (mXmppConnectionService.find(account.pendingConferenceLeaves,account,fromParts[0]) != null) {
+ return null;
+ }
Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account, fromParts[0], true);
if (packet.hasChild("subject")) {
diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java
index 3a06f302..489b0e98 100644
--- a/src/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/eu/siacs/conversations/parser/PresenceParser.java
@@ -21,14 +21,14 @@ public class PresenceParser extends AbstractParser implements
public void parseConferencePresence(PresencePacket packet, Account account) {
PgpEngine mPgpEngine = mXmppConnectionService.getPgpEngine();
if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) {
- Conversation muc = mXmppConnectionService.findMuc(packet
- .getAttribute("from").split("/")[0], account);
+ Conversation muc = mXmppConnectionService.find(account,packet
+ .getAttribute("from").split("/")[0]);
if (muc != null) {
muc.getMucOptions().processPacket(packet, mPgpEngine);
}
} else if (packet.hasChild("x", "http://jabber.org/protocol/muc")) {
- Conversation muc = mXmppConnectionService.findMuc(packet
- .getAttribute("from").split("/")[0], account);
+ Conversation muc = mXmppConnectionService.find(account,packet
+ .getAttribute("from").split("/")[0]);
if (muc != null) {
int error = muc.getMucOptions().getError();
muc.getMucOptions().processPacket(packet, mPgpEngine);
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 339438da..a7dccf1c 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -111,7 +111,7 @@ public class XmppConnectionService extends Service {
@Override
public void onContactStatusChanged(Contact contact, boolean online) {
- Conversation conversation = findActiveConversation(contact);
+ Conversation conversation = find(getConversations(),contact);
if (conversation != null) {
conversation.endOtrIfNeeded();
if (online && (contact.getPresences().size() == 1)) {
@@ -268,18 +268,12 @@ public class XmppConnectionService extends Service {
return message;
}
- public Conversation findMuc(Bookmark bookmark) {
- return findMuc(bookmark.getJid(), bookmark.getAccount());
+ public Conversation find(Bookmark bookmark) {
+ return find(bookmark.getAccount(),bookmark.getJid());
}
- public Conversation findMuc(String jid, Account account) {
- for (Conversation conversation : this.conversations) {
- if (conversation.getContactJid().split("/")[0].equals(jid)
- && (conversation.getAccount() == account)) {
- return conversation;
- }
- }
- return null;
+ public Conversation find(Account account, String jid) {
+ return find(getConversations(),account,jid);
}
public class XmppConnectionBinder extends Binder {
@@ -693,7 +687,7 @@ public class XmppConnectionService extends Service {
if (item.getName().equals("conference")) {
Bookmark bookmark = Bookmark.parse(item,account);
bookmarks.add(bookmark);
- Conversation conversation = findMuc(bookmark);
+ Conversation conversation = find(bookmark);
if (conversation!=null) {
conversation.setBookmark(bookmark);
} else {
@@ -802,8 +796,8 @@ public class XmppConnectionService extends Service {
return this.accounts;
}
- public Conversation findActiveConversation(Contact contact) {
- for (Conversation conversation : this.getConversations()) {
+ public Conversation find(List<Conversation> haystack, Contact contact) {
+ for (Conversation conversation : haystack) {
if (conversation.getContact() == contact) {
return conversation;
}
@@ -811,16 +805,24 @@ public class XmppConnectionService extends Service {
return null;
}
+ public Conversation find(List<Conversation> haystack, Account account, String jid) {
+ for (Conversation conversation : haystack) {
+ if ((conversation.getAccount().equals(account))
+ && (conversation.getContactJid().split("/")[0].equals(jid))) {
+ return conversation;
+ }
+ }
+ return null;
+ }
+
+
public Conversation findOrCreateConversation(Account account, String jid,
boolean muc) {
- for (Conversation conv : this.getConversations()) {
- if ((conv.getAccount().equals(account))
- && (conv.getContactJid().split("/")[0].equals(jid))) {
- return conv;
- }
+ Conversation conversation = find(account, jid);
+ if (conversation != null) {
+ return conversation;
}
- Conversation conversation = databaseBackend.findConversation(account,
- jid);
+ conversation = databaseBackend.findConversation(account,jid);
if (conversation != null) {
conversation.setStatus(Conversation.STATUS_AVAILABLE);
conversation.setAccount(account);