feat: provisionnement du mode propriétaire par QR code (appairage et protection automatiques)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R9CBCVP5oDu2sfoYPisNCQ
This commit is contained in:
1 parent
c9547016eb
commit
1b5558ff8b
8 files changed
+199
-7
No files matched your search
@@ -61,6 +61,7 @@ class SettingsRepository @Inject constructor(
|
||||
val POLICY_VERSION = longPreferencesKey("policy_version")
|
||||
val EVENT_QUEUE = stringPreferencesKey("event_queue")
|
||||
val MIGRATED_V02 = booleanPreferencesKey("migrated_v02")
|
||||
val PENDING_PROVISION = stringPreferencesKey("pending_provision")
|
||||
}
|
||||
|
||||
/** Clés de la v0.1 (Firebase, liste blanche locale, coupure cyclique locale) retirées à la mise à jour. */
|
||||
@@ -325,6 +326,24 @@ class SettingsRepository @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// --- Appairage prévu par le QR de provisionnement -------------------------------------------
|
||||
|
||||
/** (serveur, code, nom) reçus du QR de provisionnement, en attente d'appairage. */
|
||||
suspend fun pendingProvision(): Triple<String, String, String>? = runCatching {
|
||||
val o = JSONObject(context.dataStore.data.first()[Keys.PENDING_PROVISION] ?: return null)
|
||||
Triple(o.getString("url"), o.getString("code"), o.optString("name"))
|
||||
}.getOrNull()
|
||||
|
||||
suspend fun setPendingProvision(url: String, code: String, name: String) {
|
||||
context.dataStore.edit {
|
||||
it[Keys.PENDING_PROVISION] = JSONObject().put("url", url).put("code", code).put("name", name).toString()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun clearPendingProvision() {
|
||||
context.dataStore.edit { it.remove(Keys.PENDING_PROVISION) }
|
||||
}
|
||||
|
||||
// --- File des évènements --------------------------------------------------------------------
|
||||
|
||||
suspend fun queueEvent(event: PendingEvent) {
|
||||
|
||||
Reference in new issue
Block a user