diff --git a/platform/platform-impl/src/com/intellij/ui/JBAccountInfoService.java b/platform/platform-impl/src/com/intellij/ui/JBAccountInfoService.java index 8a05f8d01d5f..5fd3eb8fed5d 100644 --- a/platform/platform-impl/src/com/intellij/ui/JBAccountInfoService.java +++ b/platform/platform-impl/src/com/intellij/ui/JBAccountInfoService.java @@ -1,6 +1,8 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.ui; +import com.intellij.ide.gdpr.EndUserAgreement; +import com.intellij.ide.gdpr.Version; import com.intellij.idea.AppMode; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -111,6 +113,16 @@ public interface JBAccountInfoService { */ @NotNull CompletableFuture<@NotNull LicenseListResult> issueTrialLicense(@NotNull String productCode, @NotNull List consentOptions); + /** + * Records the accepted version of the specified EUA document, and responds whether a newer version of the document is available. + *

+ * The returned future never completes exceptionally, other than because of cancellation that + * may happen in case of remote dev when the controlling client handling the request is disconnected. + */ + @NotNull CompletableFuture<@NotNull AgreementAcceptanceResult> recordAgreementAcceptance(@NotNull String productCode, + @NotNull String documentName, + @NotNull Version acceptedVersion); + static @Nullable JBAccountInfoService getInstance() { if (AppMode.isRemoteDevHost()) { // see BackendJbaInfoServiceImpl @@ -201,11 +213,18 @@ public interface JBAccountInfoService { record RequestFailed(@NlsSafe @NotNull String errorMessage) implements LicenseListResult { } } + sealed interface AgreementAcceptanceResult permits AgreementAcceptanceResult.AckAccepted, + AgreementAcceptanceResult.RequestFailed, + AuthRequired { + record AckAccepted(@Nullable EndUserAgreement.Document newerDocument) implements AgreementAcceptanceResult { } + record RequestFailed(@NlsSafe @NotNull String errorMessage) implements AgreementAcceptanceResult { } + } + /** * Returned in cases the method returning it is called while unauthenticated, * or when the current auth credentials have expired and need to be revalidated by {@link #startLoginSession signing in} again. */ - enum AuthRequired implements LicenseListResult { + enum AuthRequired implements LicenseListResult, AgreementAcceptanceResult { INSTANCE; @Override diff --git a/plugins/settings-sync/src/com/intellij/settingsSync/auth/DummyJBAccountInfoService.kt b/plugins/settings-sync/src/com/intellij/settingsSync/auth/DummyJBAccountInfoService.kt index 29cc18f2383e..ff4e6dcd5639 100644 --- a/plugins/settings-sync/src/com/intellij/settingsSync/auth/DummyJBAccountInfoService.kt +++ b/plugins/settings-sync/src/com/intellij/settingsSync/auth/DummyJBAccountInfoService.kt @@ -1,5 +1,6 @@ package com.intellij.settingsSync.auth +import com.intellij.ide.gdpr.Version import com.intellij.settingsSync.SettingsSyncEvents import com.intellij.ui.JBAccountInfoService import java.util.concurrent.CompletableFuture @@ -33,6 +34,10 @@ object DummyJBAccountInfoService : JBAccountInfoService { TODO("Not yet implemented") } + override fun recordAgreementAcceptance(productCode: String, documentName: String, acceptedVersion: Version): CompletableFuture { + TODO("Not yet implemented") + } + override fun invokeJBALogin(userIdConsumer: Consumer?, onFailure: Runnable?) { refreshIdToken() SettingsSyncEvents.getInstance().fireLoginStateChanged()