diff -r e78d6e055a5b -r b34d53f6acdf activityfw/storage/client/src/afasyncrequest_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/storage/client/src/afasyncrequest_p.cpp Fri Aug 06 13:40:46 2010 +0300 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "afasyncrequest_p.h" +#include "afstorageclient_p.h" +#include "afstorageclient.h" +#include "afentry.h" + +#include + +// ----------------------------------------------------------------------------- +/** + * Create and initialize handler for anyc. activity requests + * @param observer - request completion observer + * @param session - activity client implementation + * @param cmd - requested functionality + */ +void CAfAsyncRequestPrivate::NewLD(MAfAsyncRequestObserver &observer, + MAfAsyncSession & session, + ActivityCmd cmd) +{ + CAfAsyncRequestPrivate* self = new(ELeave)CAfAsyncRequestPrivate(observer, session, cmd); + CleanupStack::PushL(self); + self->ConstructL(); + session.PushL(self); + CleanupStack::Pop(self); +} + +// ----------------------------------------------------------------------------- +/** + * First phase construction + * @param observer - request completion observer + * @param session - activity client implementation + * @param cmd - requested functionality + */ +CAfAsyncRequestPrivate::CAfAsyncRequestPrivate(MAfAsyncRequestObserver & observer, + MAfAsyncSession & session, + ActivityCmd cmd) +: +CActive(EPriorityStandard), +mObserver(observer), +mSession(session), +mCmd(cmd) +{ + CActiveScheduler::Add(this); + RProcess process; + mIds[0] = static_cast(process.SecureId().iId); +} + +// ----------------------------------------------------------------------------- +/** + * Second phase construction + */ +void CAfAsyncRequestPrivate::ConstructL() +{ + mSession.sendAsync(mCmd, + TIpcArgs(&mIds[0],&mIds[1], &mIds[2], &mIds[3]), + iStatus); + SetActive(); +} + +// ----------------------------------------------------------------------------- +/** + * Destructor + */ +CAfAsyncRequestPrivate::~CAfAsyncRequestPrivate() +{ + Cancel(); +} + +// ----------------------------------------------------------------------------- +/** + * Cancel pending requst + */ +void CAfAsyncRequestPrivate::DoCancel() +{ + TRAP_IGNORE( + switch (mCmd) { + case WaitActivity: mSession.executeL(CancelWait); break; + case NotifyChange: mSession.executeL(CancelNotify); break; + } + ) +} + +// ----------------------------------------------------------------------------- +/** + * Function handle request completion, copy data, forward information and destroy handler + */ +void CAfAsyncRequestPrivate::RunL() +{ + User::LeaveIfError(iStatus.Int()); + switch (mCmd) { + case WaitActivity: + { + RBuf8 data; + CleanupClosePushL(data); + CAfEntry::ReallocL(data, (mIds[0])()); + mSession.getDataL((mIds[3])(), data); + mObserver.waitActivityRequestCompleted(iStatus.Int(), data); + CleanupStack::PopAndDestroy(&data); + break; + } + case NotifyChange: + mObserver.dataChangeNotificationCompleted(iStatus.Int()); + break; + } + mSession.Pop(this); + delete this; +} + +// ----------------------------------------------------------------------------- +/** + * Function handle request processing errors + * @param error - error code + */ +TInt CAfAsyncRequestPrivate::RunError(TInt error) +{ + (WaitActivity == mCmd) ? mObserver.waitActivityRequestCompleted(error, KNullDesC8()) : + mObserver.dataChangeNotificationCompleted(error); + mSession.Pop(this); + delete this; + return KErrNone; +} + +