sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include "t_keystore_actions.h" sl@0: #include "t_keystore_defs.h" sl@0: #include "t_input.h" sl@0: #include "t_output.h" sl@0: sl@0: ///////////////////////////////////////////////////////////////////////////////// sl@0: // CSetTime sl@0: ///////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: CTestAction* CSetTime::NewL(RFs& aFs, sl@0: CConsoleBase& aConsole, sl@0: Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CTestAction* self = CSetTime::NewLC(aFs, aConsole, aOut, aTestActionSpec); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CTestAction* CSetTime::NewLC(RFs& aFs, sl@0: CConsoleBase& aConsole, sl@0: Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CSetTime* self = new (ELeave) CSetTime(aFs, aConsole, aOut); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aTestActionSpec); sl@0: return self; sl@0: } sl@0: sl@0: CSetTime::~CSetTime() sl@0: { sl@0: } sl@0: sl@0: CSetTime::CSetTime(RFs& aFs, CConsoleBase& aConsole, Output& aOut) : sl@0: CKeyStoreTestAction(aFs, aConsole, aOut), iState(EMain) sl@0: { sl@0: } sl@0: sl@0: void CSetTime::ConstructL(const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CKeyStoreTestAction::ConstructL(aTestActionSpec); sl@0: sl@0: TPtrC8 data = Input::ParseElement(aTestActionSpec.iActionBody, KHomeTimeStart); sl@0: SetNewTimeL(data); sl@0: } sl@0: sl@0: void CSetTime::PerformAction(TRequestStatus& aStatus) sl@0: { sl@0: switch (iState) sl@0: { sl@0: case EMain: sl@0: { sl@0: User::LeaveIfError(User::SetHomeTime(iNewTime)); sl@0: sl@0: iState = EFinished; sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, KErrNone); sl@0: break; sl@0: } sl@0: sl@0: case EFinished: sl@0: { sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, aStatus.Int()); sl@0: if (aStatus == iExpectedResult) sl@0: { sl@0: iResult = ETrue; sl@0: } sl@0: else sl@0: { sl@0: iResult = EFalse; sl@0: } sl@0: sl@0: iActionState = EPostrequisite; sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CSetTime::PerformCancel() sl@0: { sl@0: // nothing to cancel sl@0: } sl@0: sl@0: void CSetTime::Reset() sl@0: { sl@0: iState = EMain; sl@0: } sl@0: sl@0: void CSetTime::DoReportAction() sl@0: { sl@0: iOut.writeString(_L("Setting time...")); sl@0: iOut.writeNewLine(); sl@0: } sl@0: sl@0: void CSetTime::DoCheckResult(TInt aError) sl@0: { sl@0: if (iFinished) sl@0: { sl@0: if (aError == KErrNone) sl@0: { sl@0: _LIT(KSuccessful, "Time set successfully\n"); sl@0: iConsole.Write(KSuccessful); sl@0: iOut.writeString(KSuccessful); sl@0: iOut.writeNewLine(); sl@0: iOut.writeNewLine(); sl@0: } sl@0: else sl@0: { sl@0: if (aError!=iExpectedResult) sl@0: { sl@0: _LIT(KFailed, "!!!Set time failure!!!\n"); sl@0: iConsole.Write(KFailed); sl@0: iOut.writeString(KFailed); sl@0: } sl@0: else sl@0: { sl@0: _LIT(KFailed, "Set time failed, but expected\n"); sl@0: iConsole.Write(KFailed); sl@0: iOut.writeString(KFailed); sl@0: } sl@0: sl@0: iOut.writeNewLine(); sl@0: iOut.writeNewLine(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CSetTime::SetNewTimeL(const TDesC8& aData) sl@0: { sl@0: HBufC* buf = HBufC::NewLC(aData.Length()); sl@0: TPtr ptr = buf->Des(); sl@0: ptr.Copy(aData); sl@0: User::LeaveIfError(iNewTime.Parse(*buf)); sl@0: CleanupStack::PopAndDestroy(buf); sl@0: }