1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogCli/src/LogClientObserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,95 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "LogClientObserver.h"
1.20 +
1.21 +// System includes
1.22 +#include <s32mem.h>
1.23 +
1.24 +// User includes
1.25 +#include <logwrap.h>
1.26 +#include <logcli.h>
1.27 +#include "logservcli.h"
1.28 +#include <logclientchangeobserver.h>
1.29 +
1.30 +/////////////////////////////////////////////////////////////////////////////////////////
1.31 +// -----> CLogClientObserver (source)
1.32 +/////////////////////////////////////////////////////////////////////////////////////////
1.33 +
1.34 +CLogClientObserver::CLogClientObserver(CLogClient& aClient, MLogClientChangeObserver& aObserver, TInt aPriority)
1.35 +: CActive(aPriority), iClient(aClient), iObserver(aObserver)
1.36 + {
1.37 + CActiveScheduler::Add(this);
1.38 + }
1.39 +
1.40 +CLogClientObserver::~CLogClientObserver()
1.41 + {
1.42 + Cancel();
1.43 + }
1.44 +
1.45 +CLogClientObserver* CLogClientObserver::NewL(CLogClient& aClient, MLogClientChangeObserver& aObserver, TInt aPriority)
1.46 + {
1.47 + CLogClientObserver* self = new(ELeave) CLogClientObserver(aClient, aObserver, aPriority);
1.48 + self->RequestChanges();
1.49 + return self;
1.50 + }
1.51 +
1.52 +/////////////////////////////////////////////////////////////////////////////////////////
1.53 +/////////////////////////////////////////////////////////////////////////////////////////
1.54 +/////////////////////////////////////////////////////////////////////////////////////////
1.55 +
1.56 +void CLogClientObserver::RunL()
1.57 + {
1.58 + if (iStatus.Int() == KErrNone)
1.59 + NotifyObserverL();
1.60 + RequestChanges();
1.61 + }
1.62 +
1.63 +void CLogClientObserver::DoCancel()
1.64 + {
1.65 + RequestChangesCancel();
1.66 + }
1.67 +
1.68 +TInt CLogClientObserver::RunError(TInt /*aError*/)
1.69 + {
1.70 + // Ignore any leave when notifying the client
1.71 + return KErrNone;
1.72 + }
1.73 +
1.74 +/////////////////////////////////////////////////////////////////////////////////////////
1.75 +/////////////////////////////////////////////////////////////////////////////////////////
1.76 +/////////////////////////////////////////////////////////////////////////////////////////
1.77 +
1.78 +void CLogClientObserver::RequestChanges()
1.79 + {
1.80 + __ASSERT_DEBUG(!IsActive(), User::Invariant());
1.81 + iClient.Session().Send(ELogNotifyExtended, TIpcArgs(&iContextBuf,&iParamBuf1,&iParamBuf2,&iParamBuf3), iStatus);
1.82 + SetActive();
1.83 + }
1.84 +
1.85 +void CLogClientObserver::RequestChangesCancel()
1.86 + {
1.87 + iClient.Session().Send(ELogNotifyExtendedCancel, TIpcArgs());
1.88 + }
1.89 +
1.90 +void CLogClientObserver::NotifyObserverL()
1.91 + {
1.92 + const TUid contextUid = { iContextBuf() };
1.93 + const TInt param1 = iParamBuf1();
1.94 + const TInt param2 = iParamBuf2();
1.95 + const TInt param3 = iParamBuf3();
1.96 + //
1.97 + iObserver.HandleLogClientChangeEventL(contextUid, param1, param2, param3);
1.98 + }