fixed replace contact in conversation

This commit is contained in:
Daniel Gultsch 2014-04-19 02:58:34 +02:00
parent 8c59668273
commit 7299fe7c8b
1 changed files with 15 additions and 15 deletions

View File

@ -316,7 +316,7 @@ public class XmppConnectionService extends Service {
} }
} }
} }
replaceContactInConversation(contact.getJid(), contact); replaceContactInConversation(account,contact.getJid(), contact);
databaseBackend.updateContact(contact,true); databaseBackend.updateContact(contact,true);
} else { } else {
//Log.d(LOGTAG,"presence without resource "+packet.toString()); //Log.d(LOGTAG,"presence without resource "+packet.toString());
@ -327,7 +327,7 @@ public class XmppConnectionService extends Service {
} else { } else {
contact.removePresence(fromParts[1]); contact.removePresence(fromParts[1]);
} }
replaceContactInConversation(contact.getJid(), contact); replaceContactInConversation(account,contact.getJid(), contact);
databaseBackend.updateContact(contact,true); databaseBackend.updateContact(contact,true);
} else if (type.equals("subscribe")) { } else if (type.equals("subscribe")) {
Log.d(LOGTAG,"received subscribe packet from "+packet.getFrom()); Log.d(LOGTAG,"received subscribe packet from "+packet.getFrom());
@ -337,7 +337,7 @@ public class XmppConnectionService extends Service {
sendPresenceUpdatesTo(contact); sendPresenceUpdatesTo(contact);
contact.setSubscriptionOption(Contact.Subscription.FROM); contact.setSubscriptionOption(Contact.Subscription.FROM);
contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT); contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
replaceContactInConversation(contact.getJid(), replaceContactInConversation(account,contact.getJid(),
contact); contact);
databaseBackend.updateContact(contact,false); databaseBackend.updateContact(contact,false);
if ((contact if ((contact
@ -466,22 +466,22 @@ public class XmppConnectionService extends Service {
} else { } else {
if (subscription.equals("remove")) { if (subscription.equals("remove")) {
databaseBackend.deleteContact(contact); databaseBackend.deleteContact(contact);
replaceContactInConversation(contact.getJid(), null); replaceContactInConversation(account,contact.getJid(), null);
} else { } else {
contact.parseSubscriptionFromElement(item); contact.parseSubscriptionFromElement(item);
databaseBackend.updateContact(contact,false); databaseBackend.updateContact(contact,false);
replaceContactInConversation(contact.getJid(), contact); replaceContactInConversation(account,contact.getJid(), contact);
} }
} }
} }
} }
} }
private void replaceContactInConversation(String jid, Contact contact) { private void replaceContactInConversation(Account account, String jid, Contact contact) {
List<Conversation> conversations = getConversations(); List<Conversation> conversations = getConversations();
for (int i = 0; i < conversations.size(); ++i) { for (Conversation c : conversations) {
if ((conversations.get(i).getContactJid().equals(jid))) { if (c.getContactJid().equals(jid)&&(c.getAccount()==account)) {
conversations.get(i).setContact(contact); c.setContact(contact);
break; break;
} }
} }
@ -868,7 +868,7 @@ public class XmppConnectionService extends Service {
.getContacts(mWhere.toString()); .getContacts(mWhere.toString());
for (Contact contact : contactsToDelete) { for (Contact contact : contactsToDelete) {
databaseBackend.deleteContact(contact); databaseBackend.deleteContact(contact);
replaceContactInConversation(contact.getJid(), replaceContactInConversation(account,contact.getJid(),
null); null);
} }
@ -913,7 +913,7 @@ public class XmppConnectionService extends Service {
contact.setDisplayName(phoneContact contact.setDisplayName(phoneContact
.getString("displayname")); .getString("displayname"));
databaseBackend.updateContact(contact,false); databaseBackend.updateContact(contact,false);
replaceContactInConversation(contact.getJid(), replaceContactInConversation(contact.getAccount(),contact.getJid(),
contact); contact);
} else { } else {
if ((contact.getSystemAccount() != null) if ((contact.getSystemAccount() != null)
@ -921,7 +921,7 @@ public class XmppConnectionService extends Service {
contact.setSystemAccount(null); contact.setSystemAccount(null);
contact.setPhotoUri(null); contact.setPhotoUri(null);
databaseBackend.updateContact(contact,false); databaseBackend.updateContact(contact,false);
replaceContactInConversation( replaceContactInConversation(contact.getAccount(),
contact.getJid(), contact); contact.getJid(), contact);
} }
} }
@ -1055,7 +1055,7 @@ public class XmppConnectionService extends Service {
Element query = iq.query("jabber:iq:roster"); Element query = iq.query("jabber:iq:roster");
query.addChild("item").setAttribute("jid", contact.getJid()).setAttribute("subscription", "remove"); query.addChild("item").setAttribute("jid", contact.getJid()).setAttribute("subscription", "remove");
contact.getAccount().getXmppConnection().sendIqPacket(iq, null); contact.getAccount().getXmppConnection().sendIqPacket(iq, null);
replaceContactInConversation(contact.getJid(), null); replaceContactInConversation(contact.getAccount(),contact.getJid(), null);
databaseBackend.deleteContact(contact); databaseBackend.deleteContact(contact);
} }
@ -1213,7 +1213,7 @@ public class XmppConnectionService extends Service {
public void updateContact(Contact contact) { public void updateContact(Contact contact) {
databaseBackend.updateContact(contact,false); databaseBackend.updateContact(contact,false);
replaceContactInConversation(contact.getJid(), contact); replaceContactInConversation(contact.getAccount(),contact.getJid(), contact);
} }
public void updateMessage(Message message) { public void updateMessage(Message message) {
@ -1245,7 +1245,7 @@ public class XmppConnectionService extends Service {
sendPresenceUpdatesTo(contact); sendPresenceUpdatesTo(contact);
} }
} }
replaceContactInConversation(contact.getJid(), contact); replaceContactInConversation(contact.getAccount(),contact.getJid(), contact);
} }
public void requestPresenceUpdatesFrom(Contact contact) { public void requestPresenceUpdatesFrom(Contact contact) {