From b1e1234271e8c4cdd25aed02be0eebb3b5dc946a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de>
Date: Mon, 13 Sep 2021 10:03:54 +0200
Subject: [PATCH] List contacts after singning in and print to stdout

---
 .../kotlin/org/briarproject/briar/desktop/BriarService.kt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt b/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt
index d063de45c8..8f155758e6 100644
--- a/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt
+++ b/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt
@@ -7,6 +7,8 @@ import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
 import org.briarproject.bramble.api.account.AccountManager
+import org.briarproject.bramble.api.contact.Contact
+import org.briarproject.bramble.api.contact.ContactManager
 import org.briarproject.bramble.api.crypto.DecryptionException
 import org.briarproject.bramble.api.crypto.PasswordStrengthEstimator
 import org.briarproject.bramble.api.lifecycle.LifecycleManager
@@ -29,6 +31,7 @@ internal class BriarServiceImpl
 @Inject
 constructor(
     private val accountManager: AccountManager,
+    private val contactManager: ContactManager,
     private val lifecycleManager: LifecycleManager,
     private val passwordStrengthEstimator: PasswordStrengthEstimator
 ) : BriarService {
@@ -82,5 +85,10 @@ constructor(
         val dbKey = accountManager.databaseKey ?: throw AssertionError()
         lifecycleManager.startServices(dbKey)
         lifecycleManager.waitForStartup()
+        val contacts: Collection<Contact> = contactManager.getContacts()
+        // TODO: do something useful with contacts
+        for (contact in contacts) {
+            println("${contact.author.name} (${contact.alias})")
+        }
     }
 }
-- 
GitLab