Skip to content
Snippets Groups Projects
Commit d74b184e authored by Adrien Béraud's avatar Adrien Béraud
Browse files

contact: never write profile data

Remove logic that would override contact profile
when received from SIP.

Change-Id: I0204db4df3f56feeeb141486a978a72c4890156d
parent 83063cac
No related branches found
No related tags found
No related merge requests found
......@@ -433,21 +433,6 @@ class ContactServiceImpl(val mContext: Context, preferenceService: PreferencesSe
return profile.onErrorReturn { Profile.EMPTY_PROFILE }
}
override fun saveVCardContactData(contact: Contact, accountId: String, vcard: VCard) {
contact.setProfile(VCardServiceImpl.loadVCardProfile(vcard))
val filename = contact.primaryNumber + ".vcf"
VCardUtils.savePeerProfileToDisk(vcard, accountId, filename, mContext.filesDir)
AvatarFactory.clearCache()
}
override fun saveVCardContact(accountId: String, uri: String?, displayName: String?, picture: String?): Single<VCard> =
Single.fromCallable {
val vcard = VCardUtils.writeData(uri, displayName, Base64.decode(picture, Base64.DEFAULT))
val filename = "$uri.vcf"
VCardUtils.savePeerProfileToDisk(vcard, accountId, filename, mContext.filesDir)
vcard
}
private fun loadVCardContactData(contact: Contact, accountId: String): Single<Profile> =
Single.fromCallable {
val id = Base64.encodeToString(contact.primaryNumber.toByteArray(), Base64.NO_WRAP)
......
......@@ -210,30 +210,6 @@ class Call : Interaction {
field = direction == Direction.INCOMING
}*/
fun appendToVCard(messages: Map<String, String>): VCard? {
for ((key, value) in messages) {
val messageKeyValue = VCardUtils.parseMimeAttributes(key)
val mimeType = messageKeyValue[VCardUtils.VCARD_KEY_MIME_TYPE]
if (VCardUtils.MIME_PROFILE_VCARD != mimeType) {
continue
}
val part = messageKeyValue[VCardUtils.VCARD_KEY_PART]!!.toInt()
val nbPart = messageKeyValue[VCardUtils.VCARD_KEY_OF]!!.toInt()
if (null == mProfileChunk) {
mProfileChunk = ProfileChunk(nbPart)
}
mProfileChunk?.let { profile ->
profile.addPartAtIndex(value, part)
if (profile.isProfileComplete) {
val ret = Ezvcard.parse(profile.completeProfile).first()
mProfileChunk = null
return@appendToVCard ret
}
}
}
return null
}
fun hasMedia(label: Media.MediaType): Boolean {
val mediaList = mediaList ?: return false
for (media in mediaList) {
......
......@@ -626,11 +626,8 @@ abstract class CallService(
Log.w(TAG, "incomingMessage: unknown call or no message: $callId $from")
return
}
call.appendToVCard(messages)?.let { vcard ->
mContactService.saveVCardContactData(call.contact!!, call.account!!, vcard)
}
if (messages.containsKey(MIME_TEXT_PLAIN)) {
mAccountService.incomingAccountMessage(call.account!!, null, callId, from, messages)
mAccountService.incomingAccountMessage(accountId, null, callId, from, messages)
}
}
......
......@@ -46,10 +46,6 @@ abstract class ContactService(
abstract fun saveContact(uri: String, profile: Profile)
abstract fun deleteContact(uri: String)
abstract fun saveVCardContactData(contact: Contact, accountId: String, vcard: VCard)
abstract fun saveVCardContact(accountId: String, uri: String?, displayName: String?, pictureB64: String?): Single<VCard>
/**
* Load contacts from system and generate a local contact cache
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment