Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No commit message
Browse files Browse the repository at this point in the history
swan-amazon committed Dec 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a18466f commit 6118f53
Showing 5 changed files with 72 additions and 167 deletions.
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ using namespace chip::app::Clusters;
using namespace chip::app::Clusters::GeneralCommissioning;
using namespace chip::app::Clusters::GeneralCommissioning::Attributes;
using namespace chip::DeviceLayer;
using chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum;
using Transport::SecureSession;
using Transport::Session;

@@ -107,50 +108,26 @@ CHIP_ERROR GeneralCommissioningAttrAccess::Read(const ConcreteReadAttributePath
TermsAndConditionsProvider * const termsAndConditionsProvider = TermsAndConditionsManager::GetInstance();
Optional<TermsAndConditions> outTermsAndConditions;

if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

CHIP_ERROR err = termsAndConditionsProvider->GetAcceptance(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
VerifyOrReturnError(nullptr != termsAndConditionsProvider, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
ReturnErrorOnFailure(termsAndConditionsProvider->GetAcceptance(outTermsAndConditions));

return aEncoder.Encode(outTermsAndConditions.ValueOr(TermsAndConditions(0, 0)).GetVersion());
}
case TCMinRequiredVersion::Id: {
TermsAndConditionsProvider * const termsAndConditionsProvider = TermsAndConditionsManager::GetInstance();
Optional<TermsAndConditions> outTermsAndConditions;

if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

CHIP_ERROR err = termsAndConditionsProvider->GetRequirements(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
VerifyOrReturnError(nullptr != termsAndConditionsProvider, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
ReturnErrorOnFailure(termsAndConditionsProvider->GetRequirements(outTermsAndConditions));

return aEncoder.Encode(outTermsAndConditions.ValueOr(TermsAndConditions(0, 0)).GetVersion());
}
case TCAcknowledgements::Id: {
TermsAndConditionsProvider * const termsAndConditionsProvider = TermsAndConditionsManager::GetInstance();
Optional<TermsAndConditions> outTermsAndConditions;

if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

CHIP_ERROR err = termsAndConditionsProvider->GetAcceptance(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
VerifyOrReturnError(nullptr != termsAndConditionsProvider, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
ReturnErrorOnFailure(termsAndConditionsProvider->GetAcceptance(outTermsAndConditions));

return aEncoder.Encode(outTermsAndConditions.ValueOr(TermsAndConditions(0, 0)).GetValue());
}
@@ -159,22 +136,10 @@ CHIP_ERROR GeneralCommissioningAttrAccess::Read(const ConcreteReadAttributePath
Optional<TermsAndConditions> outTermsAndConditions;
TermsAndConditionsState termsAndConditionsState;

if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

CHIP_ERROR err = termsAndConditionsProvider->GetAcceptance(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
VerifyOrReturnError(nullptr != termsAndConditionsProvider, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);

err = termsAndConditionsProvider->CheckAcceptance(outTermsAndConditions, termsAndConditionsState);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
ReturnErrorOnFailure(termsAndConditionsProvider->GetAcceptance(outTermsAndConditions));
ReturnErrorOnFailure(termsAndConditionsProvider->CheckAcceptance(outTermsAndConditions, termsAndConditionsState));

bool setTermsAndConditionsCallRequiredBeforeCommissioningCompleteSuccess =
termsAndConditionsState != TermsAndConditionsState::OK;
@@ -184,16 +149,8 @@ CHIP_ERROR GeneralCommissioningAttrAccess::Read(const ConcreteReadAttributePath
TermsAndConditionsProvider * const termsAndConditionsProvider = TermsAndConditionsManager::GetInstance();
Optional<uint32_t> outUpdateAcceptanceDeadline;

if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

CHIP_ERROR err = termsAndConditionsProvider->GetUpdateAcceptanceDeadline(outUpdateAcceptanceDeadline);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
VerifyOrReturnError(nullptr != termsAndConditionsProvider, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
ReturnErrorOnFailure(termsAndConditionsProvider->GetUpdateAcceptanceDeadline(outUpdateAcceptanceDeadline));

if (!outUpdateAcceptanceDeadline.HasValue())
{
@@ -258,40 +215,31 @@ CommissioningErrorEnum CheckTermsAndConditionsAcknowledgementsState(TermsAndCond
{
TermsAndConditionsState termsAndConditionsState;

CHIP_ERROR err = termsAndConditionsProvider->CheckAcceptance(acceptedTermsAndConditions, termsAndConditionsState);
if (CHIP_NO_ERROR != err)
{
ChipLogError(FailSafe, "GeneralCommissioning: Failed to verify terms and conditions acceptance: %" CHIP_ERROR_FORMAT,
err.Format());
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kRequiredTCNotAccepted;
}
VerifyOrReturnValue(CHIP_NO_ERROR ==
termsAndConditionsProvider->CheckAcceptance(acceptedTermsAndConditions, termsAndConditionsState),
CommissioningErrorEnum::kRequiredTCNotAccepted);

switch (termsAndConditionsState)
{
case TermsAndConditionsState::OK:
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kOk;
return CommissioningErrorEnum::kOk;
case TermsAndConditionsState::TC_ACKNOWLEDGEMENTS_NOT_RECEIVED:
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kTCAcknowledgementsNotReceived;
return CommissioningErrorEnum::kTCAcknowledgementsNotReceived;
case TermsAndConditionsState::TC_MIN_VERSION_NOT_MET:
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kTCMinVersionNotMet;
return CommissioningErrorEnum::kTCMinVersionNotMet;
case TermsAndConditionsState::REQUIRED_TC_NOT_ACCEPTED:
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kRequiredTCNotAccepted;
return CommissioningErrorEnum::kRequiredTCNotAccepted;
}

return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kOk;
return CommissioningErrorEnum::kOk;
}

CommissioningErrorEnum CheckTermsAndConditionsAcknowledgements(TermsAndConditionsProvider * const termsAndConditionsProvider)
{
Optional<TermsAndConditions> acceptedTermsAndConditions;

CHIP_ERROR err = termsAndConditionsProvider->GetAcceptance(acceptedTermsAndConditions);
if (err != CHIP_NO_ERROR)
{
ChipLogError(FailSafe, "GeneralCommissioning: Failed to get terms and conditions acceptance: %" CHIP_ERROR_FORMAT,
err.Format());
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kTCAcknowledgementsNotReceived;
}
VerifyOrReturnValue(CHIP_NO_ERROR == termsAndConditionsProvider->GetAcceptance(acceptedTermsAndConditions),
CommissioningErrorEnum::kTCAcknowledgementsNotReceived);

return CheckTermsAndConditionsAcknowledgementsState(termsAndConditionsProvider, acceptedTermsAndConditions);
}
@@ -306,15 +254,13 @@ void NotifyTermsAndConditionsAttributesChange(TermsAndConditionsProvider * const
if (currentTermsAndConditionsAcceptance.ValueOr(TermsAndConditions(0, 0)).GetVersion() !=
updatedTermsAndConditions.ValueOr(TermsAndConditions(0, 0)).GetVersion())
{
MatterReportingAttributeChangeCallback(endpoint, GeneralCommissioning::Id,
GeneralCommissioning::Attributes::TCAcceptedVersion::Id);
MatterReportingAttributeChangeCallback(endpoint, GeneralCommissioning::Id, Attributes::TCAcceptedVersion::Id);
}

if (currentTermsAndConditionsAcceptance.ValueOr(TermsAndConditions(0, 0)).GetValue() !=
updatedTermsAndConditions.ValueOr(TermsAndConditions(0, 0)).GetValue())
{
MatterReportingAttributeChangeCallback(endpoint, GeneralCommissioning::Id,
GeneralCommissioning::Attributes::TCAcknowledgements::Id);
MatterReportingAttributeChangeCallback(endpoint, GeneralCommissioning::Id, Attributes::TCAcknowledgements::Id);
}

CommissioningErrorEnum previousState =
@@ -324,8 +270,7 @@ void NotifyTermsAndConditionsAttributesChange(TermsAndConditionsProvider * const

if (previousState != updatedState)
{
MatterReportingAttributeChangeCallback(endpoint, GeneralCommissioning::Id,
GeneralCommissioning::Attributes::TCAcknowledgementsRequired::Id);
MatterReportingAttributeChangeCallback(endpoint, GeneralCommissioning::Id, Attributes::TCAcknowledgementsRequired::Id);
}
}
}
@@ -547,7 +492,7 @@ bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(app::CommandH

bool emberAfGeneralCommissioningClusterSetTCAcknowledgementsCallback(
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
const chip::app::Clusters::GeneralCommissioning::Commands::SetTCAcknowledgements::DecodableType & commandData)
const GeneralCommissioning::Commands::SetTCAcknowledgements::DecodableType & commandData)
{
#if CHIP_CONFIG_TC_REQUIRED
MATTER_TRACE_SCOPE("SetTCAcknowledgements", "GeneralCommissioning");
99 changes: 35 additions & 64 deletions src/app/server/DefaultTermsAndConditionsProvider.cpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/DefaultStorageKeyAllocator.h>
#include <lib/support/SafeInt.h>
#include <protocols/Protocols.h>
#include <protocols/interaction_model/StatusCode.h>

namespace {
constexpr chip::TLV::Tag kSerializationVersionTag = chip::TLV::ContextTag(1);
@@ -52,7 +54,7 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsStorageDelegate::Delete()
VerifyOrReturnValue(nullptr != mStorageDelegate, CHIP_ERROR_UNINITIALIZED);

const chip::StorageKeyName kStorageKey = chip::DefaultStorageKeyAllocator::TermsAndConditionsAcceptance();
VerifyOrReturnValue(CHIP_NO_ERROR == mStorageDelegate->SyncDeleteKeyValue(kStorageKey.KeyName()), CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(mStorageDelegate->SyncDeleteKeyValue(kStorageKey.KeyName()));

return CHIP_NO_ERROR;
}
@@ -72,27 +74,27 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsStorageDelegate::Get(Optional<Ter
uint16_t bufferSize = sizeof(buffer);

const chip::StorageKeyName kStorageKey = chip::DefaultStorageKeyAllocator::TermsAndConditionsAcceptance();
CHIP_ERROR err = mStorageDelegate->SyncGetKeyValue(kStorageKey.KeyName(), &buffer, bufferSize);

CHIP_ERROR err = mStorageDelegate->SyncGetKeyValue(kStorageKey.KeyName(), &buffer, bufferSize);
VerifyOrReturnValue(CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err || CHIP_NO_ERROR == err, err);

if (CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err)
{
outTermsAndConditions.ClearValue();
return CHIP_NO_ERROR;
}

VerifyOrReturnValue(CHIP_NO_ERROR == err, CHIP_ERROR_INTERNAL);

tlvReader.Init(buffer, bufferSize);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag()),
CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.EnterContainer(tlvContainer), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Next(kSerializationVersionTag), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Get(serializationVersion), CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(tlvReader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag()));
ReturnErrorOnFailure(tlvReader.EnterContainer(tlvContainer));
ReturnErrorOnFailure(tlvReader.Next(kSerializationVersionTag));
ReturnErrorOnFailure(tlvReader.Get(serializationVersion));

if (serializationVersion < kSerializationSchemaMinimumVersion)
{
ChipLogError(AppServer, "The terms and conditions datastore schema (%hhu) is newer than oldest compatible schema (%hhu)",
serializationVersion, kSerializationSchemaMinimumVersion);
return CHIP_ERROR_INTERNAL;
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
}

if (serializationVersion != kSerializationSchemaCurrentVersion)
@@ -101,11 +103,11 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsStorageDelegate::Get(Optional<Ter
serializationVersion, kSerializationSchemaCurrentVersion);
}

VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Next(kAcceptedAcknowledgementsTag), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Get(acknowledgements), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Next(kAcceptedAcknowledgementsVersionTag), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.Get(acknowledgementsVersion), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvReader.ExitContainer(tlvContainer), CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(tlvReader.Next(kAcceptedAcknowledgementsTag));
ReturnErrorOnFailure(tlvReader.Get(acknowledgements));
ReturnErrorOnFailure(tlvReader.Next(kAcceptedAcknowledgementsVersionTag));
ReturnErrorOnFailure(tlvReader.Get(acknowledgementsVersion));
ReturnErrorOnFailure(tlvReader.ExitContainer(tlvContainer));

outTermsAndConditions = Optional<TermsAndConditions>(TermsAndConditions(acknowledgements, acknowledgementsVersion));

@@ -121,23 +123,16 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsStorageDelegate::Set(const TermsA
VerifyOrReturnValue(nullptr != mStorageDelegate, CHIP_ERROR_UNINITIALIZED);

tlvWriter.Init(buffer);
VerifyOrReturnValue(CHIP_NO_ERROR ==
tlvWriter.StartContainer(chip::TLV::AnonymousTag(), chip::TLV::kTLVType_Structure, tlvContainer),
CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvWriter.Put(kSerializationVersionTag, kSerializationSchemaCurrentVersion),
CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvWriter.Put(kAcceptedAcknowledgementsTag, inTermsAndConditions.GetValue()),
CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvWriter.Put(kAcceptedAcknowledgementsVersionTag, inTermsAndConditions.GetVersion()),
CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvWriter.EndContainer(tlvContainer), CHIP_ERROR_INTERNAL);
VerifyOrReturnValue(CHIP_NO_ERROR == tlvWriter.Finalize(), CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(tlvWriter.StartContainer(chip::TLV::AnonymousTag(), chip::TLV::kTLVType_Structure, tlvContainer));
ReturnErrorOnFailure(tlvWriter.Put(kSerializationVersionTag, kSerializationSchemaCurrentVersion));
ReturnErrorOnFailure(tlvWriter.Put(kAcceptedAcknowledgementsTag, inTermsAndConditions.GetValue()));
ReturnErrorOnFailure(tlvWriter.Put(kAcceptedAcknowledgementsVersionTag, inTermsAndConditions.GetVersion()));
ReturnErrorOnFailure(tlvWriter.EndContainer(tlvContainer));
ReturnErrorOnFailure(tlvWriter.Finalize());

const chip::StorageKeyName kStorageKey = chip::DefaultStorageKeyAllocator::TermsAndConditionsAcceptance();
VerifyOrReturnValue(
CHIP_NO_ERROR ==
mStorageDelegate->SyncSetKeyValue(kStorageKey.KeyName(), buffer, static_cast<uint16_t>(tlvWriter.GetLengthWritten())),
CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(
mStorageDelegate->SyncSetKeyValue(kStorageKey.KeyName(), buffer, static_cast<uint16_t>(tlvWriter.GetLengthWritten())));

return CHIP_NO_ERROR;
}
@@ -206,21 +201,13 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::CommitAcceptance()
{
VerifyOrReturnValue(nullptr != mTermsAndConditionsStorageDelegate, CHIP_ERROR_UNINITIALIZED);

if (!mTemporalAcceptance.HasValue())
{
ChipLogError(AppServer, "No terms and conditions to commit");
return CHIP_NO_ERROR;
}

CHIP_ERROR err = mTermsAndConditionsStorageDelegate->Set(mTemporalAcceptance.Value());
if (CHIP_NO_ERROR != err)
{
ChipLogError(AppServer, "Failed storage delegate Set(): %" CHIP_ERROR_FORMAT, err.Format());
return CHIP_ERROR_INTERNAL;
}
// No terms and conditions to commit
VerifyOrReturnValue(mTemporalAcceptance.HasValue(), CHIP_NO_ERROR);

ReturnErrorOnFailure(mTermsAndConditionsStorageDelegate->Set(mTemporalAcceptance.Value()));
ChipLogProgress(AppServer, "Terms and conditions have been committed");
mTemporalAcceptance.ClearValue();

return CHIP_NO_ERROR;
}

@@ -237,19 +224,15 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(Optional<

// Otherwise, try to get the persisted acceptance state
CHIP_ERROR err = mTermsAndConditionsStorageDelegate->Get(outTermsAndConditions);
VerifyOrReturnValue(CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err || CHIP_NO_ERROR == err, err);

if (CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err)
{
ChipLogError(AppServer, "No terms and conditions have been accepted");
outTermsAndConditions.ClearValue();
return CHIP_NO_ERROR;
}

// If the storage delegate returns an error, other than "value not found" then there was an unexpected datastore failure
if (CHIP_NO_ERROR != err)
{
ChipLogError(AppServer, "Failed storage delegate Get(): %" CHIP_ERROR_FORMAT, err.Format());
return CHIP_ERROR_INTERNAL;
}

return CHIP_NO_ERROR;
}

@@ -267,6 +250,7 @@ chip::app::DefaultTermsAndConditionsProvider::GetUpdateAcceptanceDeadline(Option
{
VerifyOrReturnValue(nullptr != mTermsAndConditionsStorageDelegate, CHIP_ERROR_UNINITIALIZED);

// No-op stub implementation. This feature is not implemented in this default implementation.
outUpdateAcceptanceDeadline = Optional<uint32_t>();

return CHIP_NO_ERROR;
@@ -276,12 +260,7 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::ResetAcceptance()
{
VerifyOrReturnValue(nullptr != mTermsAndConditionsStorageDelegate, CHIP_ERROR_UNINITIALIZED);

CHIP_ERROR err = mTermsAndConditionsStorageDelegate->Delete();
if (CHIP_NO_ERROR != err)
{
ChipLogError(AppServer, "Failed storage delegate Delete(): %" CHIP_ERROR_FORMAT, err.Format());
}

(void) mTermsAndConditionsStorageDelegate->Delete();
return RevertAcceptance();
}

@@ -298,15 +277,7 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::SetAcceptance(const Opt
{
VerifyOrReturnValue(nullptr != mTermsAndConditionsStorageDelegate, CHIP_ERROR_UNINITIALIZED);

TermsAndConditionsState termsAndConditionsState = TermsAndConditionsState::OK;

CHIP_ERROR err = CheckAcceptance(inTermsAndConditions, termsAndConditionsState);
if (CHIP_NO_ERROR != err)
{
ChipLogError(AppServer, "Failed to check acceptance state: %" CHIP_ERROR_FORMAT, err.Format());
return CHIP_ERROR_INVALID_ARGUMENT;
}

mTemporalAcceptance = inTermsAndConditions;

return CHIP_NO_ERROR;
}
6 changes: 3 additions & 3 deletions src/app/server/DefaultTermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
@@ -47,8 +47,8 @@ class TermsAndConditionsStorageDelegate
* effectively resetting their acceptance status in the persistent storage.
*
* @retval CHIP_NO_ERROR if the record was successfully deleted.
* @retval CHIP_ERROR_INTERNAL if there was an error deleting the record from storage.
* @retval CHIP_ERROR_UNINITIALIZED if the storage delegate is not properly initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR Delete() = 0;

@@ -61,8 +61,8 @@ class TermsAndConditionsStorageDelegate
* @param[out] outTermsAndConditions The retrieved terms and conditions, if any exist.
*
* @retval CHIP_NO_ERROR if the terms were successfully retrieved.
* @retval CHIP_ERROR_INTERNAL if an error occurred while retrieving from persistent storage.
* @retval CHIP_ERROR_UNINITIALIZED if the storage delegate is not properly initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR Get(Optional<TermsAndConditions> & outTermsAndConditions) = 0;

@@ -75,8 +75,8 @@ class TermsAndConditionsStorageDelegate
* @param[in] inTermsAndConditions The terms and conditions to be saved.
*
* @retval CHIP_NO_ERROR if the terms were successfully stored.
* @retval CHIP_ERROR_INTERNAL if there was an error during the storage operation.
* @retval CHIP_ERROR_UNINITIALIZED if the storage delegate is not properly initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR Set(const TermsAndConditions & inTermsAndConditions) = 0;
};
16 changes: 8 additions & 8 deletions src/app/server/TermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
@@ -74,8 +74,8 @@ class TermsAndConditionsProvider
* why they are invalid (e.g., version mismatch or required terms not accepted).
*
* @retval CHIP_NO_ERROR if the terms are successfully validated.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions,
TermsAndConditionsState & outState) const = 0;
@@ -87,8 +87,8 @@ class TermsAndConditionsProvider
* status in a permanent location and clears the temporary in-memory acceptance state after committing.
*
* @retval CHIP_NO_ERROR if the terms were successfully persisted.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR CommitAcceptance() = 0;

@@ -102,8 +102,8 @@ class TermsAndConditionsProvider
* @param[out] outTermsAndConditions The current accepted terms and conditions, if any.
*
* @retval CHIP_NO_ERROR if the terms were successfully retrieved or no terms were found.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR GetAcceptance(Optional<TermsAndConditions> & outTermsAndConditions) const = 0;

@@ -116,8 +116,8 @@ class TermsAndConditionsProvider
* @param[out] outTermsAndConditions The required terms and conditions.
*
* @retval CHIP_NO_ERROR if the required terms were successfully retrieved.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR GetRequirements(Optional<TermsAndConditions> & outTermsAndConditions) const = 0;

@@ -131,8 +131,8 @@ class TermsAndConditionsProvider
* Returns empty Optional if no deadline is set.
*
* @retval CHIP_NO_ERROR if the deadline was successfully retrieved or no deadline was found.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR GetUpdateAcceptanceDeadline(Optional<uint32_t> & outUpdateAcceptanceDeadline) const = 0;

@@ -144,8 +144,8 @@ class TermsAndConditionsProvider
* through this method.
*
* @retval CHIP_NO_ERROR if the terms were successfully reset.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR ResetAcceptance() = 0;

@@ -156,8 +156,8 @@ class TermsAndConditionsProvider
* not affect the persisted state stored in storage.
*
* @retval CHIP_NO_ERROR if the in-memory acceptance state was successfully cleared.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR RevertAcceptance() = 0;

@@ -170,9 +170,9 @@ class TermsAndConditionsProvider
* @param[in] inTermsAndConditions The terms and conditions to be accepted temporarily.
*
* @retval CHIP_NO_ERROR if the terms were successfully stored in-memory.
* @retval CHIP_ERROR_INTERNAL if there was an error during the operation.
* @retval CHIP_ERROR_INVALID_ARGUMENT if the provided terms and conditions are invalid.
* @retval CHIP_ERROR_UNINITIALIZED if the module has not been initialized.
* @retval CHIP_ERROR_* for other errors.
*/
virtual CHIP_ERROR SetAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions) = 0;
};
11 changes: 0 additions & 11 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
@@ -1845,17 +1845,6 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#define CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS 5
#endif // CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS

/**
* @def CHIP_CONFIG_TEST_GOOGLETEST
*
* @brief
* If asserted (1), enable APIs that support unit tests built with the GoogleTest framework
*
*/
#ifndef CHIP_CONFIG_TEST_GOOGLETEST
#define CHIP_CONFIG_TEST_GOOGLETEST 0
#endif // CHIP_CONFIG_TEST_GOOGLETEST

/**
* @file
* Configuration settings for Terms and Conditions (TC) acknowledgements during device commissioning.

0 comments on commit 6118f53

Please sign in to comment.