Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
swan-amazon committed Aug 29, 2024
1 parent 39e564c commit 35cf353
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,15 @@ CHIP_ERROR GeneralCommissioningAttrAccess::ReadSupportsConcurrentConnection(Attr
return aEncoder.Encode(supportsConcurrentConnection);
}

CommissioningErrorEnum CheckTermsAndConditionsAcknowledgementsState(TermsAndConditionsProvider * const termsAndConditionsProvider, const Optional<TermsAndConditions> & acceptedTermsAndConditions)
CommissioningErrorEnum CheckTermsAndConditionsAcknowledgementsState(TermsAndConditionsProvider * const termsAndConditionsProvider,
const Optional<TermsAndConditions> & acceptedTermsAndConditions)
{
TermsAndConditionsState termsAndConditionsState;

CHIP_ERROR err = termsAndConditionsProvider->CheckAcceptance(acceptedTermsAndConditions, termsAndConditionsState);
if (CHIP_NO_ERROR != err)
{
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kUnknownEnumValue;
return chip::app::Clusters::GeneralCommissioning::CommissioningErrorEnum::kUnknownEnumValue;
}

switch (termsAndConditionsState)
Expand Down Expand Up @@ -300,7 +301,8 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(
//
}

response.errorCode = CheckTermsAndConditionsAcknowledgementsState(termsAndConditionsProvider, acceptedTermsAndConditions);
response.errorCode =
CheckTermsAndConditionsAcknowledgementsState(termsAndConditionsProvider, acceptedTermsAndConditions);
if (CommissioningErrorEnum::kOk != response.errorCode)
{
commandObj->AddResponse(commandPath, response);
Expand Down Expand Up @@ -424,7 +426,7 @@ bool emberAfGeneralCommissioningClusterSetTCAcknowledgementsCallback(
#else
MATTER_TRACE_SCOPE("SetTCAcknowledgements", "GeneralCommissioning");

auto & failSafeContext = Server::GetInstance().GetFailSafeContext();
auto & failSafeContext = Server::GetInstance().GetFailSafeContext();
TermsAndConditionsProvider * const termsAndConditionsProvider = Server::GetInstance().GetTermsAndConditionsProvider();

Optional<TermsAndConditions> acceptedTermsAndConditions = Optional<TermsAndConditions>({
Expand Down
3 changes: 2 additions & 1 deletion src/app/server/DefaultTermsAndConditionsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::Init(
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions, TermsAndConditionsState & outState) const
CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions,
TermsAndConditionsState & outState) const
{
// No validation checks required if no required terms and conditions
if (!mRequiredAcknowledgements.HasValue())
Expand Down
3 changes: 2 additions & 1 deletion src/app/server/DefaultTermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider
CHIP_ERROR Init(PersistentStorageDelegate * const inPersistentStorageDelegate,
const chip::Optional<chip::app::TermsAndConditions> & inRequiredTermsAndConditions);

CHIP_ERROR CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions, TermsAndConditionsState & outState) const override;
CHIP_ERROR CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions,
TermsAndConditionsState & outState) const override;

CHIP_ERROR SetAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions) override;

Expand Down
9 changes: 5 additions & 4 deletions src/app/server/TermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ typedef struct sTermsAndConditions

typedef enum eTermsAndConditionsState
{
OK = 0,
OK = 0,
TC_ACKNOWLEDGEMENTS_NOT_RECEIVED = 1,
TC_MIN_VERSION_NOT_MET = 2,
REQUIRED_TC_NOT_ACCEPTED = 3,
TC_MIN_VERSION_NOT_MET = 2,
REQUIRED_TC_NOT_ACCEPTED = 3,
} TermsAndConditionsState;

/**
Expand All @@ -51,7 +51,8 @@ class TermsAndConditionsProvider
/**
* @brief Checks the acceptance status without latching the value, nor temporal storage.
*/
virtual CHIP_ERROR CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions, TermsAndConditionsState & outState) const = 0;
virtual CHIP_ERROR CheckAcceptance(const Optional<TermsAndConditions> & inTermsAndConditions,
TermsAndConditionsState & outState) const = 0;

/**
* @brief Sets the acceptance status of the required terms and conditions.
Expand Down

0 comments on commit 35cf353

Please sign in to comment.