aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/persistance/DatabaseBackend.java10
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java15
2 files changed, 15 insertions, 10 deletions
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
index 852a9315..68fc56cd 100644
--- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -201,9 +201,13 @@ public class DatabaseBackend extends SQLiteOpenHelper {
+ "=?", args);
}
- public void updateContact(Contact contact) {
+ public void updateContact(Contact contact, boolean updatePresences) {
SQLiteDatabase db = this.getWritableDatabase();
String[] args = { contact.getUuid() };
+ ContentValues values = contact.getContentValues();
+ if (!updatePresences) {
+ values.remove(Contact.PRESENCES);
+ }
db.update(Contact.TABLENAME, contact.getContentValues(), Contact.UUID
+ "=?", args);
}
@@ -227,8 +231,8 @@ public class DatabaseBackend extends SQLiteOpenHelper {
if (cursor.getCount()>=1) {
cursor.moveToFirst();
contact.setUuid(cursor.getString(0));
- contact.setPresences(Presences.fromJsonString(cursor.getString(1)));
- updateContact(contact);
+ //contact.setPresences(Presences.fromJsonString(cursor.getString(1)));
+ updateContact(contact,false);
} else {
contact.setUuid(UUID.randomUUID().toString());
createContact(contact);
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 0dea3731..69f0b8af 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -317,7 +317,7 @@ public class XmppConnectionService extends Service {
}
}
replaceContactInConversation(contact.getJid(), contact);
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,true);
} else {
//Log.d(LOGTAG,"presence without resource "+packet.toString());
}
@@ -328,7 +328,7 @@ public class XmppConnectionService extends Service {
contact.removePresence(fromParts[1]);
}
replaceContactInConversation(contact.getJid(), contact);
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,true);
} else if (type.equals("subscribe")) {
Log.d(LOGTAG,"received subscribe packet from "+packet.getFrom());
if (contact
@@ -339,7 +339,7 @@ public class XmppConnectionService extends Service {
contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
replaceContactInConversation(contact.getJid(),
contact);
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,false);
if ((contact
.getSubscriptionOption(Contact.Subscription.ASKING))
&& (!contact
@@ -469,7 +469,7 @@ public class XmppConnectionService extends Service {
replaceContactInConversation(contact.getJid(), null);
} else {
contact.parseSubscriptionFromElement(item);
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,false);
replaceContactInConversation(contact.getJid(), contact);
}
}
@@ -667,6 +667,7 @@ public class XmppConnectionService extends Service {
@Override
public void onBind(Account account) {
+ Log.d("xmppService","bount. cleaning presences");
databaseBackend.clearPresences(account);
account.clearPresences(); // self presences
if (account.getXmppConnection().hasFeatureRosterManagment()) {
@@ -912,7 +913,7 @@ public class XmppConnectionService extends Service {
.getString("photouri"));
contact.setDisplayName(phoneContact
.getString("displayname"));
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,false);
replaceContactInConversation(contact.getJid(),
contact);
} else {
@@ -920,7 +921,7 @@ public class XmppConnectionService extends Service {
|| (contact.getProfilePhoto() != null)) {
contact.setSystemAccount(null);
contact.setPhotoUri(null);
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,false);
replaceContactInConversation(
contact.getJid(), contact);
}
@@ -1212,7 +1213,7 @@ public class XmppConnectionService extends Service {
}
public void updateContact(Contact contact) {
- databaseBackend.updateContact(contact);
+ databaseBackend.updateContact(contact,false);
replaceContactInConversation(contact.getJid(), contact);
}