sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* Implements CUpsSession. See class and function definitions for
|
sl@0
|
16 |
* more information.
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "upsserver.h"
|
sl@0
|
26 |
#include "authoriser.h"
|
sl@0
|
27 |
#include <ups/upserr.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
namespace UserPromptService
|
sl@0
|
30 |
{
|
sl@0
|
31 |
|
sl@0
|
32 |
CUpsSubsession* CUpsSubsession::NewL(CUpsSession &aSession, const RMessage2& aMessage)
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Factory function allocates a new, initialized instance of CUpsSubsession.
|
sl@0
|
35 |
|
sl@0
|
36 |
@param aMessage Standard server-side handle to message.
|
sl@0
|
37 |
@return New, initialized instance of CUpsSubsession which
|
sl@0
|
38 |
is owned by the caller.
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CUpsSubsession* self = new(ELeave) CUpsSubsession(aSession);
|
sl@0
|
42 |
// Note that CUpsSubsession ulitmately derives from CObject and therefore it MUST NOT be deleted directly,
|
sl@0
|
43 |
// instead it should be closed if we leave.
|
sl@0
|
44 |
// nb. CUpsSession does NOT derive from CObject...
|
sl@0
|
45 |
CleanupClosePushL(*self);
|
sl@0
|
46 |
self->ConstructL(aMessage);
|
sl@0
|
47 |
CleanupStack::Pop(self);
|
sl@0
|
48 |
return self;
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
CUpsSubsession::CUpsSubsession(CUpsSession &aSession)
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
This private constructor prevents direct instantiation and provides
|
sl@0
|
54 |
a single point of definition from which to call the superclass c'tor.
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
: CScsSubsession(aSession)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
// empty.
|
sl@0
|
59 |
//RDebug::Printf("0x%x CUpsSubsession(session %x)\n", this, &aSession);
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
void CUpsSubsession::ConstructL(const RMessage2& aMessage)
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
Initialize this subsession object by opening a handle to the
|
sl@0
|
65 |
thread whose identifier has been sent.
|
sl@0
|
66 |
|
sl@0
|
67 |
@param aSession Ref to session creating us
|
sl@0
|
68 |
@param aMessage Standard server-side handle to message.
|
sl@0
|
69 |
*/
|
sl@0
|
70 |
{
|
sl@0
|
71 |
// ARGS: TThreadId, TProcessId
|
sl@0
|
72 |
|
sl@0
|
73 |
TPckg<TThreadId> tidBuf(iClientTid);
|
sl@0
|
74 |
aMessage.ReadL(0, tidBuf);
|
sl@0
|
75 |
|
sl@0
|
76 |
TPckg<TProcessId> pidBuf(iClientPid);
|
sl@0
|
77 |
aMessage.ReadL(1, pidBuf);
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
CUpsSubsession::~CUpsSubsession()
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
Close this object's handle to the SS client thread.
|
sl@0
|
83 |
*/
|
sl@0
|
84 |
{
|
sl@0
|
85 |
//RDebug::Printf("0x%x ~CUpsSubsession()\n", this);
|
sl@0
|
86 |
iDestination.Close();
|
sl@0
|
87 |
iOpaqueData.Close();
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
TBool CUpsSubsession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
|
sl@0
|
91 |
/**
|
sl@0
|
92 |
Implement CScsSubsession by handling the supplied message.
|
sl@0
|
93 |
|
sl@0
|
94 |
@param aFunction Function identifier without SCS code.
|
sl@0
|
95 |
@param aMessage Standard server-side handle to message.
|
sl@0
|
96 |
@return ETrue means complete client request now.
|
sl@0
|
97 |
*/
|
sl@0
|
98 |
{
|
sl@0
|
99 |
UserPromptService::TSubsessionFunction f =
|
sl@0
|
100 |
static_cast<UserPromptService::TSubsessionFunction>(aFunction);
|
sl@0
|
101 |
//RDebug::Printf("0x%x CUpsSubsession::DoServiceL function %d\n", this, f);
|
sl@0
|
102 |
switch (f)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
case UserPromptService::ESubsessPreparePrompt:
|
sl@0
|
105 |
PreparePromptL(aMessage);
|
sl@0
|
106 |
break;
|
sl@0
|
107 |
|
sl@0
|
108 |
case UserPromptService::ESubsessExecutePrompt:
|
sl@0
|
109 |
ExecutePromptL(aMessage);
|
sl@0
|
110 |
return EFalse; // If ExecutePrompt returns, instead of leaving, it must have setup an async req
|
sl@0
|
111 |
BULLSEYE_OFF
|
sl@0
|
112 |
default:
|
sl@0
|
113 |
User::Leave(KErrNotSupported);
|
sl@0
|
114 |
break;
|
sl@0
|
115 |
BULLSEYE_RESTORE
|
sl@0
|
116 |
}
|
sl@0
|
117 |
return ETrue;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
void CUpsSubsession::PreparePromptL(const RMessage2& aMessage)
|
sl@0
|
121 |
/**
|
sl@0
|
122 |
Save service, description, and opaque data for use in the
|
sl@0
|
123 |
following execute prompt command.
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
{
|
sl@0
|
126 |
// TIpcArgs is TServiceId aServiceId, const TDesC* aDestination, const TDesC8* aOpaqueData
|
sl@0
|
127 |
|
sl@0
|
128 |
iServiceId.iUid = aMessage.Int0();
|
sl@0
|
129 |
|
sl@0
|
130 |
// Get Description
|
sl@0
|
131 |
TInt destinationLength = aMessage.GetDesLengthL(1);
|
sl@0
|
132 |
iDestination.Close();
|
sl@0
|
133 |
iDestination.CreateL(destinationLength);
|
sl@0
|
134 |
aMessage.ReadL(1, iDestination);
|
sl@0
|
135 |
|
sl@0
|
136 |
// Get Opaque Data
|
sl@0
|
137 |
TInt opaqueDataLength = aMessage.GetDesLengthL(2);
|
sl@0
|
138 |
iOpaqueData.Close();
|
sl@0
|
139 |
if(opaqueDataLength)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
iOpaqueData.CreateL(opaqueDataLength);
|
sl@0
|
142 |
aMessage.ReadL(2, iOpaqueData);
|
sl@0
|
143 |
}
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
void CUpsSubsession::ExecutePromptL(const RMessage2& aMessage)
|
sl@0
|
147 |
/**
|
sl@0
|
148 |
Create and start the CAuthoriser to process the request.
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
{
|
sl@0
|
151 |
// TIpcArgs is OUT:TUpsDecision& aDecision, IN:TBool aServerCheckOk
|
sl@0
|
152 |
|
sl@0
|
153 |
// The authorizer object is derived from CAsyncRequest and its
|
sl@0
|
154 |
// lifecycle is automatically managed by the SCS framework
|
sl@0
|
155 |
//
|
sl@0
|
156 |
// iDestination and iOpaqueData are transfered to the CAuthoriser,
|
sl@0
|
157 |
// our handles will be closed.
|
sl@0
|
158 |
TBool serverCheckOk = aMessage.Int1();
|
sl@0
|
159 |
CUpsSession *session = static_cast<CUpsSession*>(&iSession);
|
sl@0
|
160 |
RPolicyCacheCountedHandle &cacheManager = session->UpsServer()->iPolicyCache;
|
sl@0
|
161 |
CleanupReleasePushL(cacheManager);
|
sl@0
|
162 |
if(!cacheManager.IsOpen())
|
sl@0
|
163 |
{
|
sl@0
|
164 |
cacheManager.OpenL();
|
sl@0
|
165 |
}
|
sl@0
|
166 |
CAuthoriser *authoriser = CAuthoriser::NewL(cacheManager,
|
sl@0
|
167 |
session, this, serverCheckOk,
|
sl@0
|
168 |
iClientTid, iClientPid,
|
sl@0
|
169 |
aMessage, iServiceId, iDestination, iOpaqueData);
|
sl@0
|
170 |
CleanupStack::Pop(&cacheManager); // transfered ownership to the new CAuthoriser
|
sl@0
|
171 |
CleanupStack::PushL(authoriser);
|
sl@0
|
172 |
authoriser->TransferToScsFrameworkL();
|
sl@0
|
173 |
CleanupStack::Pop(authoriser); // authoriser now owned by SCS framework
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
The authoriser is now responsible for completing the request,
|
sl@0
|
177 |
so we must NOT leave.
|
sl@0
|
178 |
|
sl@0
|
179 |
We could start the request processing off by calling an
|
sl@0
|
180 |
authoriser function from within a TRAP handler, but for future
|
sl@0
|
181 |
proofing we tell the authoriser to self complete so the
|
sl@0
|
182 |
processing all happens within the active scheduler framework
|
sl@0
|
183 |
and the authoriser state machine. This will make it much easier
|
sl@0
|
184 |
to completly restart request processing (if we decide to when
|
sl@0
|
185 |
policies are changed).
|
sl@0
|
186 |
*/
|
sl@0
|
187 |
authoriser->Wakeup();
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
|
sl@0
|
191 |
} // End of namespace UserPromptService
|
sl@0
|
192 |
// End of file
|