Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitfireAT/vcard4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/bitfire/vcard4android/contactrow/SipAddressHandler.kt')
-rw-r--r--src/main/java/at/bitfire/vcard4android/contactrow/SipAddressHandler.kt39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/at/bitfire/vcard4android/contactrow/SipAddressHandler.kt b/src/main/java/at/bitfire/vcard4android/contactrow/SipAddressHandler.kt
new file mode 100644
index 0000000..5fd48e3
--- /dev/null
+++ b/src/main/java/at/bitfire/vcard4android/contactrow/SipAddressHandler.kt
@@ -0,0 +1,39 @@
+package at.bitfire.vcard4android.contactrow
+
+import android.content.ContentValues
+import android.provider.ContactsContract.CommonDataKinds.SipAddress
+import at.bitfire.vcard4android.Constants
+import at.bitfire.vcard4android.Contact
+import at.bitfire.vcard4android.LabeledProperty
+import ezvcard.parameter.ImppType
+import ezvcard.property.Impp
+
+object SipAddressHandler: DataRowHandler() {
+
+ override fun forMimeType() = SipAddress.CONTENT_ITEM_TYPE
+
+ override fun handle(values: ContentValues, contact: Contact) {
+ super.handle(values, contact)
+ val sip = values.getAsString(SipAddress.SIP_ADDRESS) ?: return
+
+ try {
+ val impp = Impp("sip:$sip")
+ val labeledImpp = LabeledProperty(impp)
+
+ when (values.getAsInteger(SipAddress.TYPE)) {
+ SipAddress.TYPE_HOME ->
+ impp.types += ImppType.HOME
+ SipAddress.TYPE_WORK ->
+ impp.types += ImppType.WORK
+ SipAddress.TYPE_CUSTOM ->
+ values.getAsString(SipAddress.LABEL)?.let {
+ labeledImpp.label = it
+ }
+ }
+ contact.impps.add(labeledImpp)
+ } catch(e: IllegalArgumentException) {
+ Constants.log.warning("Ignoring invalid locally stored SIP address")
+ }
+ }
+
+} \ No newline at end of file