src/PowerAuth/Session.cpp
/*
	 The function deletes _ad and commits new persistent state, which is represented
	 by the combination of the parameters:
	 
	 | new_pd   | new_state    | Behavior
	 -----------------------------------------------------------------
	 | null     | any state    | Resets session to initial state
	 | not-null | SS_Empty     | Resets session to initial state
	 | not-null | SS_Activated | Keeps new PD and state
	 ------------------------------------------------------------------------------
	 
	 All other combination of parameters leads to fallback state.
	 */
The function deletes _ad and commits new persistent state, which is represented
by the combination of the parameters.





All other combination of parameters leads to fallback state.
The function deletes _ad and commits new persistent state which is represented by the combination of the parameters . All other combination of parameters leads to fallback state .
void Session::commitNewPersistentState(protocol::PersistentData *new_pd, Session::State new_state)
	{
		delete _ad;
		_ad = nullptr;
		delete _pd;
		if (new_pd != nullptr && new_state == SS_Activated) {
			_pd = new_pd;
		} else {
			delete new_pd;
			_pd = new_pd = nullptr;
			new_state = SS_Empty;
		}
		changeState(new_state);
	}
void Session :: commitNewPersistentState ( protocol :: PersistentData * new_pd , Session :: State new_state ) { delete _ad ; _ad = nullptr ; delete _pd ; if ( new_pd != nullptr && new_state == SS_Activated ) { _pd = new_pd ; } else { delete new_pd ; _pd = new_pd = nullptr ; new_state = SS_Empty ; } changeState ( new_state ) ; }
The function deletes _ad and commits new persistent state, which is represented
by the combination of the parameters:
The function deletes _ad and commits new persistent state which is represented by the combination of the parameters :
// At first, delete possible activation data. In all cases, commit must clear // any instance of activation data. // The next structure is PersistentData. We have to delete possible previous instance // of PD and if state is correct, then keep the new one. // Ok, keep the new structure // Delete everything // PD was not commited, so, we have to adjust new state. // Finally, change internal state of the session