os/security/authorisation/userpromptservice/server/source/upsserver/updateevaluator.cpp
Update contrib.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Implements used to process RUpsManagement::UpdateDecisionL.
24 #include "upsserver.h"
25 #include <ups/upsdbw.h>
26 #include "updateevaluator.h"
28 namespace UserPromptService
30 inline CUpsSession *CUpdateEvaluator::UpsSession()
32 return static_cast<CUpsSession*>(iSession);
35 inline CUpsServer *CUpdateEvaluator::UpsServer()
37 return static_cast<CUpsServer *>(
38 &static_cast<CUpsSession*>(iSession)->iServer);
41 CUpdateEvaluator* CUpdateEvaluator::NewLC(CUpsSession* aSession, const RMessage2& aMessage)
43 CUpdateEvaluator* self = new(ELeave) CUpdateEvaluator(aSession, aMessage);
44 CleanupStack::PushL(self);
45 self->ConstructL(aMessage);
49 CUpdateEvaluator::~CUpdateEvaluator()
51 Normally cleanup should be done when DoCleanup function is called by the framework.
52 Sometime later, possibly after our parent CUpsSession has been deleted, this
53 destructor will be run. In this case the framework will have cleared our iSession variable
54 and we must do NOTHING.
56 Unfortunately there is a special case where this object fails inside ConstructL, when we must do
57 some cleanup. We can detect this be seeing iSession (and hence UpsServer()) is non-NULL.
60 CUpsSession *session = UpsSession();
63 /*lint -save -e1506*/ // ignore warning about calling a virtual function in a destructor
69 void CUpdateEvaluator::StartUpdate()
70 /// Starts evaluating the database view
72 iUpdateView->EvaluateView(iStatus);
76 CUpdateEvaluator::CUpdateEvaluator(CUpsSession* aSession, const RMessage2& aMessage)
77 : CAsyncRequest(aSession, 0, aMessage),
78 iUpdateDbHandle(UpsServer()->iDbHandle, this)
82 void CUpdateEvaluator::ConstructL(const RMessage2& aMessage)
84 // Read record id and new yes/no decision from client
85 TUint32 recordId = aMessage.Int0();
86 iNewResult = (aMessage.Int1() != 0);
88 CDecisionFilter *filter= CDecisionFilter::NewLC();
89 filter->SetRecordId(recordId, EEqual);
91 // Create the CDecisionView object
92 iUpdateView = iUpdateDbHandle->CreateViewL(*filter);
94 CleanupStack::PopAndDestroy(filter);
98 void CUpdateEvaluator::DoCleanup()
99 /// implement CAsyncRequest
106 iUpdateDbHandle.Close();
109 void CUpdateEvaluator::DoCancel()
110 /// implement CActive - Cancel the database CreateView
112 ASSERT(iUpdateView != 0);
113 iUpdateView->Cancel();
117 void CUpdateEvaluator::RunL()
118 /// implement CActive, override CAsyncRequset
120 User::LeaveIfError(iStatus.Int());
122 // We have created the view, which should have matched a single record.....
123 CDecisionRecord *record = iUpdateView->NextDecisionL();
124 CleanupStack::PushL(record);
127 User::Leave(KErrNotFound);
131 record->iResult = iNewResult;
133 // Prepare a filter with our complete key in it.
134 CDecisionFilter *filter = CDecisionFilter::NewLC(record->iClientSid,
135 record->iEvaluatorId,
138 record->iFingerprint,
139 record->iClientEntity,
140 record->iMajorPolicyVersion);
144 iUpdateDbHandle->UpdateDecisionL(*filter, *record);
147 CleanupStack::PopAndDestroy(filter);
148 CleanupStack::PopAndDestroy(record);
150 CompleteAndMarkForDeletion(KErrNone);
153 TInt CUpdateEvaluator::RunError(TInt aError)
155 iUpdateDbHandle.CloseMaster();
156 return CAsyncRequest::RunError(aError);
159 void CUpdateEvaluator::DbHandleAboutToBeDeleted()
161 Called just before the master database handle is shut.
162 Need to cancel and cleanup/delete our view and fail the client request.
165 // Make sure our request is cancelled
168 // Cleanup/delete our view object
171 // Abort the client view request.
172 CompleteAndMarkForDeletion(KErrAbort);
175 } // End of namespace UserPromptServer