|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Defines runtime security manager script session class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include <aknlistquerydialog.h> |
|
24 #include <aknquerydialog.h> |
|
25 #include <aknmessagequerycontrol.h> |
|
26 #include <aknmessagequerydialog.h> |
|
27 #include <badesca.h> |
|
28 #include <bautils.h> |
|
29 #include <coemain.h> |
|
30 #include <data_caging_path_literals.hrh> |
|
31 #include <eikenv.h> |
|
32 #include <eikfrlb.h> |
|
33 #include <eikfrlbd.h> |
|
34 #include <pathinfo.h> |
|
35 #include <stringloader.h> |
|
36 |
|
37 #include <rtsecmanager.h> |
|
38 #include <rtsecmgrscriptsession.h> |
|
39 #include <rtsecmgrscript.h> |
|
40 #include "rtsecmgrclient.h" |
|
41 #include "rtsecmgrdef.h" |
|
42 |
|
43 //security manager resource file literal |
|
44 _LIT(KSecMgrResourceFile, "RTSecManager.RSC"); |
|
45 |
|
46 //constant for descriptor array granularity |
|
47 const TInt KDescArrayInit = 6; |
|
48 const TInt KMaxBuf=256; |
|
49 |
|
50 //typedef of selection index array |
|
51 typedef RArray<TInt> RSelIdxArray; |
|
52 |
|
53 //static resource IDs for capability text display in default prompt |
|
54 static const TInt CAPABILITY_RESOURCEID[KCapabilitySize] = |
|
55 { |
|
56 0, //ECapabilityTCB (0) |
|
57 R_RTSECMGR_COMMDD, //ECapabilityCommDD (1) |
|
58 R_RTSECMGR_POWERMGMT, //ECapabilityPowerMgmt (2) |
|
59 R_RTSECMGR_MMEDIADD, //ECapabilityMultimediaDD (3) |
|
60 R_RTSECMGR_READDEVICEDATA, //ECapabilityReadDeviceData (4) |
|
61 R_RTSECMGR_WRITEDEVICEDATA, //ECapabilityWriteDeviceData (5) |
|
62 R_RTSECMGR_DRM, //ECapabilityDRM (6) |
|
63 R_RTSECMGR_TRUSTEDUI, //ECapabilityTrustedUI (7) |
|
64 R_RTSECMGR_PROTSERV, //ECapabilityProtServ (8) |
|
65 R_RTSECMGR_DISKADMIN, //ECapabilityDiskAdmin (9) |
|
66 R_RTSECMGR_NWCONTROL, //ECapabilityNetworkControl (10) |
|
67 R_RTSECMGR_ALLFILES, //ECapabilityAllFiles (11) |
|
68 R_RTSECMGR_SWEVENT, //ECapabilitySwEvent (12) |
|
69 R_RTSECMGR_NWSERVICES, //ECapabilityNetworkServices (13) |
|
70 R_RTSECMGR_LOCALSERVICES, //ECapabilityLocalServices (14) |
|
71 R_RTSECMGR_READUSERDATA, //ECapabilityReadUserData (15) |
|
72 R_RTSECMGR_WRITEUSERDATA, //ECapabilityWriteUserData (16) |
|
73 R_RTSECMGR_LOCATION, //ECapabilityLocation (17) |
|
74 R_RTSECMGR_SURRDD, //ECapabilitySurroundingsDD (18) |
|
75 R_RTSECMGR_USERENV //ECapabilityUserEnvironment (19) |
|
76 }; |
|
77 |
|
78 static const TInt MOREINFO_CAP_RESOURCEID[KCapabilitySize] = |
|
79 { |
|
80 0, //ECapabilityTCB (0) |
|
81 R_RTSECMGR_MORE_INFO_COMMDD, //ECapabilityCommDD (1) |
|
82 R_RTSECMGR_POWERMGMT, //ECapabilityPowerMgmt (2) |
|
83 R_RTSECMGR_MORE_INFO_MMEDIADD, //ECapabilityMultimediaDD (3) |
|
84 R_RTSECMGR_MORE_INFO_READDEVICEDATA, //ECapabilityReadDeviceData (4) |
|
85 R_RTSECMGR_MORE_INFO_WRITEDEVICEDATA, //ECapabilityWriteDeviceData (5) |
|
86 0, //ECapabilityDRM (6) |
|
87 0, //ECapabilityTrustedUI (7) |
|
88 0, //ECapabilityProtServ (8) |
|
89 0, //ECapabilityDiskAdmin (9) |
|
90 R_RTSECMGR_MORE_INFO_NWCONTROL, //ECapabilityNetworkControl (10) |
|
91 0, //ECapabilityAllFiles (11) |
|
92 R_RTSECMGR_MORE_INFO_SWEVENT, //ECapabilitySwEvent (12) |
|
93 R_RTSECMGR_MORE_INFO_NWSERVICES, //ECapabilityNetworkServices (13) |
|
94 R_RTSECMGR_MORE_INFO_LOCALSERVICES, //ECapabilityLocalServices (14) |
|
95 R_RTSECMGR_MORE_INFO_READ_USERDATA, //ECapabilityReadUserData |
|
96 R_RTSECMGR_MORE_INFO_WRITE_USERDATA,//ECapabilityWriteUserData |
|
97 R_RTSECMGR_MORE_INFO_LOCATION,//ECapabilityLocation |
|
98 R_RTSECMGR_MORE_INFO_SURRDD, //ECapabilitySurroundingsDD |
|
99 R_RTSECMGR_MORE_INFO_USERENV //ECapabilityUserEnvironment |
|
100 }; |
|
101 |
|
102 struct TCallbackParam |
|
103 { |
|
104 CRTSecMgrScriptSession* iRTSecMgrScriptSession; |
|
105 CPromptData *iPromptData; |
|
106 }; |
|
107 |
|
108 /** |
|
109 * Proxy delegate class for runtime security manager client-side |
|
110 * sub-session handle. |
|
111 * |
|
112 * @lib rtsecmgrclient.lib |
|
113 */ |
|
114 class CRTSecMgrSubSessionProxy : public CBase |
|
115 { |
|
116 public: |
|
117 |
|
118 static CRTSecMgrSubSessionProxy* NewL() |
|
119 { |
|
120 CRTSecMgrSubSessionProxy* self = CRTSecMgrSubSessionProxy::NewLC (); |
|
121 CleanupStack::Pop (self); |
|
122 return self; |
|
123 } |
|
124 |
|
125 static CRTSecMgrSubSessionProxy* NewLC() |
|
126 { |
|
127 CRTSecMgrSubSessionProxy* self = new (ELeave) CRTSecMgrSubSessionProxy(); |
|
128 CleanupStack::PushL (self); |
|
129 self->ConstructL (); |
|
130 return self; |
|
131 } |
|
132 |
|
133 virtual ~CRTSecMgrSubSessionProxy() |
|
134 { |
|
135 iSubSession.Close (); |
|
136 } |
|
137 |
|
138 inline RSecMgrSubSession& SubSession() |
|
139 { |
|
140 return iSubSession; |
|
141 } |
|
142 RSecMgrSubSession* operator ->() |
|
143 { |
|
144 return &iSubSession; |
|
145 } |
|
146 private: |
|
147 inline CRTSecMgrSubSessionProxy() |
|
148 { |
|
149 } |
|
150 void ConstructL() |
|
151 { |
|
152 } |
|
153 |
|
154 RSecMgrSubSession iSubSession; |
|
155 }; |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // Defintiion of default private constructor |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 CRTSecMgrScriptSession::CRTSecMgrScriptSession(MSecMgrPromptHandler* aPromptHdlr) : |
|
162 iPermBits(KDefaultNullBit), iDeniedBits(KDefaultNullBit), |
|
163 iPromptHdlr(aPromptHdlr), iUIPromptOption(RTPROMPTUI_DEFAULT), isCustomPrompt(EFalse) |
|
164 { |
|
165 _sessionInfo.AllowedCaps = KDefaultNullBit; |
|
166 _sessionInfo.DeniedCaps = KDefaultNullBit; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // Defintiion of second-phase constructor |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 CRTSecMgrScriptSession* CRTSecMgrScriptSession::NewL( |
|
174 MSecMgrPromptHandler* aPromptHdlr) |
|
175 { |
|
176 CRTSecMgrScriptSession* self = CRTSecMgrScriptSession::NewLC (aPromptHdlr); |
|
177 CleanupStack::Pop (self); |
|
178 return self; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // Defintiion of second-phase constructor |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 CRTSecMgrScriptSession* CRTSecMgrScriptSession::NewLC( |
|
186 MSecMgrPromptHandler* aPromptHdlr) |
|
187 { |
|
188 CRTSecMgrScriptSession* self = new (ELeave) CRTSecMgrScriptSession(aPromptHdlr); |
|
189 CleanupStack::PushL (self); |
|
190 self->ConstructL (); |
|
191 return self; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // Defintiion of second-phase constructor |
|
196 // This method instantiates client side sub-session proxy instance. |
|
197 // In addition, this method loads the security manager resource |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void CRTSecMgrScriptSession::ConstructL() |
|
201 { |
|
202 iCoeEnv = CCoeEnv::Static (); |
|
203 if ( !iCoeEnv && !iPromptHdlr) |
|
204 User::Leave (KErrNotSupported); |
|
205 |
|
206 iSubSessionProxy = CRTSecMgrSubSessionProxy::NewL (); |
|
207 |
|
208 if ( !iPromptHdlr) |
|
209 { |
|
210 iPromptHdlr = this; //default prompt handler |
|
211 isCustomPrompt = ETrue ; |
|
212 } |
|
213 |
|
214 |
|
215 } |
|
216 |
|
217 void CRTSecMgrScriptSession::AddResourceFiles() |
|
218 { |
|
219 if(iCoeEnv) |
|
220 { |
|
221 |
|
222 CDesCArray* diskList = new (ELeave) CDesCArrayFlat(KDescArrayInit); |
|
223 CleanupStack::PushL (diskList); |
|
224 |
|
225 BaflUtils::GetDiskListL (iCoeEnv->FsSession (), *diskList); |
|
226 for (TInt idx(0); idx<diskList->Count ();++idx) |
|
227 { |
|
228 TInt intDrive; |
|
229 TChar ch = ((*diskList)[idx])[0]; |
|
230 RFs::CharToDrive (ch, intDrive); |
|
231 TDriveUnit curDrive(intDrive); |
|
232 |
|
233 TFileName resFile(curDrive.Name ()); |
|
234 resFile.Append (KDC_APP_RESOURCE_DIR); |
|
235 resFile.Append (KSecMgrResourceFile); |
|
236 BaflUtils::NearestLanguageFile (iCoeEnv->FsSession (), resFile); |
|
237 if ( BaflUtils::FileExists (iCoeEnv->FsSession (), resFile)) |
|
238 { |
|
239 TRAPD (err, iResourceOffset = iCoeEnv->AddResourceFileL (resFile)); |
|
240 User::LeaveIfError (err); |
|
241 break; |
|
242 } |
|
243 } |
|
244 |
|
245 CleanupStack::PopAndDestroy (diskList); |
|
246 } |
|
247 } |
|
248 |
|
249 void CRTSecMgrScriptSession::CloseResourceFiles() |
|
250 { |
|
251 if ( iResourceOffset && iCoeEnv) |
|
252 iCoeEnv->DeleteResourceFile (iResourceOffset); |
|
253 iResourceOffset = 0; |
|
254 } |
|
255 // --------------------------------------------------------------------------- |
|
256 // Destructor |
|
257 // Closes script sub-session handle |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 EXPORT_C CRTSecMgrScriptSession::~CRTSecMgrScriptSession() |
|
261 { |
|
262 Close (); |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // Opens script session, in turn opening client-side sub-session handle |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 TInt CRTSecMgrScriptSession::Open(const RSessionBase& aParentSession, |
|
270 TPolicyID aPolicyID, TExecutableID aExecID) |
|
271 { |
|
272 if (iScript) |
|
273 { |
|
274 delete iScript; |
|
275 iScript = NULL; |
|
276 } |
|
277 |
|
278 iScript = CScript::NewL (aPolicyID, aExecID); |
|
279 |
|
280 TInt ret((*iSubSessionProxy)->Open (aParentSession, *iScript, aPolicyID)); |
|
281 if ( KErrNone==ret) |
|
282 { |
|
283 iPermBits = iScript->PermGranted (); |
|
284 iDeniedBits = iScript->PermDenied (); |
|
285 } |
|
286 |
|
287 return ret; |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // Opens script session, in turn opening client-side sub-session handle |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 TInt CRTSecMgrScriptSession::Open(const RSessionBase& aParentSession, |
|
295 TPolicyID aPolicyID, TExecutableID aExecID, const TDesC& aHashValue) |
|
296 { |
|
297 if (iScript) |
|
298 { |
|
299 delete iScript; |
|
300 iScript = NULL; |
|
301 } |
|
302 |
|
303 iScript = CScript::NewL (aPolicyID, aExecID); |
|
304 TInt ret((*iSubSessionProxy)->Open (aParentSession, *iScript, aPolicyID, aHashValue)); |
|
305 if ( KErrNone==ret) |
|
306 { |
|
307 iPermBits = iScript->PermGranted (); |
|
308 iDeniedBits = iScript->PermDenied (); |
|
309 } |
|
310 |
|
311 return ret; |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // Opens script session, in turn opening client-side sub-session handle |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 TInt CRTSecMgrScriptSession::Open(const RSessionBase& aParentSession, |
|
319 TPolicyID aPolicyID, TExecutableID aExecID, const CTrustInfo& aTrustInfo) |
|
320 { |
|
321 if (iScript) |
|
322 { |
|
323 delete iScript; |
|
324 iScript = NULL; |
|
325 } |
|
326 |
|
327 iScript = CScript::NewL (aPolicyID, aExecID); |
|
328 TInt ret((*iSubSessionProxy)->Open (aParentSession, *iScript, aPolicyID, aTrustInfo)); |
|
329 |
|
330 if ( KErrNone==ret) |
|
331 { |
|
332 iPermBits = iScript->PermGranted (); |
|
333 iDeniedBits = iScript->PermDenied (); |
|
334 } |
|
335 |
|
336 return ret; |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // Performs access permission check, returns unmatched capabilities if any |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C TInt CRTSecMgrScriptSession::IsAllowed(const RCapabilityArray& aCapabilitiesToCheck,RCapabilityArray& aUnMatchedCapabilities) |
|
344 { |
|
345 RPromptDataList promptDataList; |
|
346 TCapabilityBitSet unMatchedCapBits(KDefaultNullBit); |
|
347 TInt ret(IsAllowed(aCapabilitiesToCheck,promptDataList,unMatchedCapBits)); |
|
348 |
|
349 promptDataList.ResetAndDestroy(); |
|
350 |
|
351 if(KDefaultNullBit!=unMatchedCapBits) |
|
352 BuildCapsL(unMatchedCapBits,aUnMatchedCapabilities); |
|
353 return ret; |
|
354 } |
|
355 |
|
356 // --------------------------------------------------------------------------- |
|
357 // Performs access permission check |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 EXPORT_C TInt CRTSecMgrScriptSession::IsAllowed(const RCapabilityArray& aCapabilitiesToCheck) |
|
361 { |
|
362 RPromptDataList promptDataList; |
|
363 TCapabilityBitSet unMatchedCapBits(KDefaultNullBit); |
|
364 TInt ret(IsAllowed(aCapabilitiesToCheck,promptDataList,unMatchedCapBits)); |
|
365 promptDataList.ResetAndDestroy(); |
|
366 return ret; |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // Private implementation to perform access perform access check. |
|
371 // This function is the real task master |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 TInt CRTSecMgrScriptSession::IsAllowed( |
|
375 const RCapabilityArray& aCapabilitiesToCheck, |
|
376 RPromptDataList& aPromptDataList, TCapabilityBitSet& aUnMatchedCaps) |
|
377 { |
|
378 if ( aCapabilitiesToCheck.Count ()<=0) |
|
379 { |
|
380 return EAccessOk; //if no capabilities are required, safely return |
|
381 } |
|
382 if ( aCapabilitiesToCheck.Find(ECapabilityTCB) != KErrNotFound) |
|
383 return EAccessNok; |
|
384 aPromptDataList.Reset (); |
|
385 |
|
386 TCapabilityBitSet capToCheck(KDefaultNullBit); |
|
387 TCapabilityBitSet finalCaps(KDefaultNullBit); |
|
388 for (TInt i(0); i!=aCapabilitiesToCheck.Count (); ++i) |
|
389 AddCapability (capToCheck, aCapabilitiesToCheck[i]); |
|
390 |
|
391 capToCheck &= ~(iScript->PermissionSet().UnconditionalCaps()); |
|
392 |
|
393 /* Check if a;ready denied. No point in going forward */ |
|
394 if(capToCheck & _sessionInfo.DeniedCaps || capToCheck & iDeniedBits) |
|
395 return EAccessNok; |
|
396 |
|
397 TCapabilityBitSet allowedCaps(KDefaultNullBit); |
|
398 allowedCaps |= _sessionInfo.AllowedCaps; //for session allowed |
|
399 allowedCaps &= ~iDeniedBits; |
|
400 allowedCaps |= iPermBits; //for permanently allowed |
|
401 |
|
402 //In case if all the capabilities required by the service provider |
|
403 //are allowed without prompting |
|
404 TCapabilityBitSet original_capToCheck = capToCheck; |
|
405 capToCheck &= allowedCaps; |
|
406 if(original_capToCheck == capToCheck) |
|
407 return EAccessOk; |
|
408 |
|
409 capToCheck ^= original_capToCheck ; |
|
410 TBool isPermGrantModified(EFalse); |
|
411 |
|
412 RPermissions perms = iScript->PermissionSet().Permissions (); |
|
413 |
|
414 for (TInt i(0); (i!=perms.Count ())&& capToCheck ;++i) |
|
415 { |
|
416 CPermission* perm = CPermission::NewLC(*perms[i]); |
|
417 |
|
418 TCapabilityBitSet tempCapToCheck(KDefaultNullBit); |
|
419 |
|
420 RCapabilityArray capabilities; |
|
421 perm->Capabilitilites (capabilities); |
|
422 |
|
423 for (TInt capsIdx(0); capsIdx!=capabilities.Count();++capsIdx) |
|
424 { |
|
425 TCapability cap(capabilities[capsIdx]); |
|
426 tempCapToCheck |= LOWBIT << cap; |
|
427 } |
|
428 capToCheck &= tempCapToCheck; |
|
429 if ( capToCheck ) |
|
430 { |
|
431 if ( capToCheck & iDeniedBits) //check if permanently disabled |
|
432 { |
|
433 allowedCaps &= ~tempCapToCheck; //just in case... |
|
434 _sessionInfo.DeniedCaps &= ~tempCapToCheck; //just in case... |
|
435 } |
|
436 else |
|
437 if ( capToCheck & _sessionInfo.DeniedCaps) //not necessary to do this check... |
|
438 { |
|
439 allowedCaps &= ~tempCapToCheck; //just in case... |
|
440 } |
|
441 else |
|
442 if ((capToCheck & allowedCaps) != capToCheck) //check if it's already allowed |
|
443 { |
|
444 //capToCheck &= allowedCaps; |
|
445 TCapabilityBitSet temp = capToCheck; |
|
446 temp &= allowedCaps; |
|
447 temp ^= capToCheck; |
|
448 capToCheck = temp; |
|
449 if ( (perm->Condition() & RTUserPrompt_OneShot) ||(perm->Condition() & RTUserPrompt_Session) ||((perm->Condition() & RTUserPrompt_Permanent) && |
|
450 (iScript->ScriptID()!=KAnonymousScript))) |
|
451 { |
|
452 if ( !(_sessionInfo.AllowedCaps & capToCheck)) |
|
453 { |
|
454 //check if it's denied for this session |
|
455 if ( !(_sessionInfo.DeniedCaps & capToCheck)) |
|
456 { |
|
457 CPromptData* promptData = CPromptData::NewL();//should write NewL Function |
|
458 promptData->SetPermissions(*perm); |
|
459 promptData->SetUserSelection(perm->Default ()) ; |
|
460 aPromptDataList.Append (promptData); |
|
461 } |
|
462 |
|
463 } |
|
464 else |
|
465 { |
|
466 allowedCaps |= tempCapToCheck; //enable in allowed |
|
467 } |
|
468 } |
|
469 } |
|
470 } |
|
471 capToCheck ^= original_capToCheck; |
|
472 capabilities.Close (); |
|
473 CleanupStack::PopAndDestroy(perm); |
|
474 }//for loop |
|
475 |
|
476 if ( aPromptDataList.Count ()>0) |
|
477 { |
|
478 //TInt ret = EPromptOk; |
|
479 TInt ret = iPromptHdlr->Prompt (aPromptDataList , iScript->ScriptID()); |
|
480 |
|
481 //Iterate over promptDataList and check the user selection |
|
482 RCapabilityArray capArray; |
|
483 for (TInt i(0); i!=aPromptDataList.Count ();++i) |
|
484 { |
|
485 CPermission *perm = (aPromptDataList[i])->iPermission; |
|
486 perm->Capabilitilites(capArray); |
|
487 TCapabilityBitSet tempCapToCheck(KDefaultEnableBit); |
|
488 TCapabilityBitSet userSelectedCaps = 0; |
|
489 for(TInt idx(0); idx != capArray.Count(); idx++) |
|
490 userSelectedCaps |= tempCapToCheck <<capArray[idx]; |
|
491 |
|
492 capArray.Close(); |
|
493 HandleGrantChosen (aPromptDataList[i], userSelectedCaps, allowedCaps, isPermGrantModified); |
|
494 finalCaps |= allowedCaps ; |
|
495 } |
|
496 |
|
497 if ( EPromptOk!=ret) |
|
498 { |
|
499 return EAccessNok; |
|
500 } |
|
501 |
|
502 if ( (iScript->ScriptID()!=KAnonymousScript)&&(isPermGrantModified)) |
|
503 UpdatePermGrant ();//commit perm grant change |
|
504 |
|
505 finalCaps |= iPermBits ; |
|
506 |
|
507 if((finalCaps & NetworkServices_CAP) && isCustomPrompt) |
|
508 PromptCostL() ; |
|
509 |
|
510 finalCaps |= _sessionInfo.AllowedCaps ; |
|
511 |
|
512 |
|
513 if ( KErrNone == ((finalCaps & original_capToCheck) ^ original_capToCheck)) |
|
514 return EAccessOk; |
|
515 else |
|
516 { |
|
517 aUnMatchedCaps = (finalCaps & original_capToCheck) ^ original_capToCheck; |
|
518 return EAccessNok; |
|
519 } |
|
520 } |
|
521 else |
|
522 { |
|
523 return EAccessNok; |
|
524 } |
|
525 |
|
526 } |
|
527 |
|
528 // --------------------------------------------------------------------------- |
|
529 // Default prompt handler implementation |
|
530 // --------------------------------------------------------------------------- |
|
531 // |
|
532 TInt CRTSecMgrScriptSession::Prompt(RPromptDataList& aPromptDataList,TExecutableID /*aExecID*/) |
|
533 { |
|
534 AddResourceFiles(); |
|
535 TInt ret(EPromptOk); |
|
536 TInt promptCount = aPromptDataList.Count (); |
|
537 |
|
538 for (TInt i(0); i<promptCount; ++i) |
|
539 { |
|
540 ret = Prompt (aPromptDataList[i]); |
|
541 if ( EPromptOk!=ret) |
|
542 { |
|
543 for(TInt inLoopCnt(promptCount-1); inLoopCnt>=i; --inLoopCnt) |
|
544 { |
|
545 TUserPromptOption selected = aPromptDataList[inLoopCnt]->iUserSelection; |
|
546 if(!(selected == RTUserPrompt_Denied || selected == RTUserPrompt_SessionDenied || selected == RTUserPrompt_PermDenied)) |
|
547 { |
|
548 delete aPromptDataList[inLoopCnt]; |
|
549 aPromptDataList.Remove(inLoopCnt); |
|
550 } |
|
551 } |
|
552 break; |
|
553 } |
|
554 |
|
555 |
|
556 } |
|
557 CloseResourceFiles(); |
|
558 return ret; |
|
559 } |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // Private default prompt handler implementation |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 TInt CRTSecMgrScriptSession::Prompt(CPromptData* aPromptData) |
|
566 { |
|
567 if ( RTPROMPTUI_DEFAULT!=iUIPromptOption) |
|
568 return PromptAdvanced (aPromptData); |
|
569 |
|
570 TInt ret(EPromptOk); |
|
571 TInt stackResCnt(0); |
|
572 |
|
573 CDesCArray* settingPageText = new(ELeave) CDesCArrayFlat(KDescArrayInit); |
|
574 CleanupStack::PushL(settingPageText); |
|
575 |
|
576 HBufC* oneShotOptionText= NULL; |
|
577 HBufC* oneShotDenyText= NULL; |
|
578 HBufC* sessionOptionText= NULL; |
|
579 HBufC* sessionDenyOption= NULL; |
|
580 HBufC* permGrantOptionText= NULL; |
|
581 HBufC* permDenyOption= NULL; |
|
582 |
|
583 TInt selIndex(PROMPT_SELIDX_ZERO); |
|
584 RSelIdxArray selIdxArray; |
|
585 CleanupClosePushL (selIdxArray); |
|
586 |
|
587 if ( (RTUserPrompt_Permanent & (aPromptData->iPermission->Default ())) || (RTUserPrompt_Permanent & (aPromptData->iPermission->Condition ()))) |
|
588 { |
|
589 permGrantOptionText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_PERM_YES); |
|
590 settingPageText->AppendL (permGrantOptionText->Des ()); |
|
591 ++stackResCnt; |
|
592 |
|
593 selIdxArray.Append (R_RTSECMGR_PROMPT_PERM_YES); |
|
594 |
|
595 if ( RTUserPrompt_Permanent&aPromptData->iPermission->Default ()) |
|
596 selIndex = selIdxArray.Count ()-1; |
|
597 |
|
598 /* permDenyOption = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_PERM_NO); |
|
599 ++stackResCnt; |
|
600 */ |
|
601 } |
|
602 |
|
603 if ( (RTUserPrompt_Session & (aPromptData->iPermission->Default ())) || (RTUserPrompt_Session & (aPromptData->iPermission->Condition ()))) |
|
604 { |
|
605 sessionOptionText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_SESSION_YES); |
|
606 settingPageText->AppendL (sessionOptionText->Des()); |
|
607 ++stackResCnt; |
|
608 |
|
609 selIdxArray.Append (R_RTSECMGR_PROMPT_SESSION_YES); |
|
610 |
|
611 TUserPromptOption def = aPromptData->iPermission->Default (); |
|
612 if ( RTUserPrompt_Session&def) |
|
613 selIndex = selIdxArray.Count()-1; |
|
614 |
|
615 /* if ( !permDenyOption) |
|
616 { |
|
617 sessionDenyOption = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_SESSION_NO); |
|
618 ++stackResCnt; |
|
619 }*/ |
|
620 } |
|
621 |
|
622 if ( (RTUserPrompt_OneShot & aPromptData->iPermission->Default ()) || (RTUserPrompt_OneShot & aPromptData->iPermission->Condition ())) |
|
623 { |
|
624 oneShotOptionText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_ONESHOT_YES); |
|
625 settingPageText->AppendL (oneShotOptionText->Des ()); |
|
626 ++stackResCnt; |
|
627 |
|
628 selIdxArray.Append (R_RTSECMGR_PROMPT_ONESHOT_YES); |
|
629 |
|
630 TUserPromptOption def = aPromptData->iPermission->Default (); |
|
631 if ( RTUserPrompt_OneShot&def) |
|
632 selIndex = selIdxArray.Count()-1; |
|
633 /* if ( !permDenyOption && !sessionDenyOption) |
|
634 { |
|
635 oneShotDenyText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_ONESHOT_NO); |
|
636 ++stackResCnt; |
|
637 }*/ |
|
638 } |
|
639 |
|
640 |
|
641 if ( (RTUserPrompt_OneShot & (aPromptData->iPermission->Default ())) || (RTUserPrompt_OneShot & (aPromptData->iPermission->Condition ()))) |
|
642 { |
|
643 oneShotDenyText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_ONESHOT_NO); |
|
644 ++stackResCnt; |
|
645 |
|
646 } |
|
647 |
|
648 if ( (RTUserPrompt_Session & (aPromptData->iPermission->Default ())) || (RTUserPrompt_Session & (aPromptData->iPermission->Condition ()))) |
|
649 { |
|
650 if ( !oneShotDenyText) |
|
651 { |
|
652 sessionDenyOption = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_SESSION_NO); |
|
653 ++stackResCnt; |
|
654 } |
|
655 } |
|
656 |
|
657 if ( (RTUserPrompt_Permanent & aPromptData->iPermission->Default ()) || (RTUserPrompt_Permanent & aPromptData->iPermission->Condition ())) |
|
658 { |
|
659 if ( !oneShotDenyText && !sessionDenyOption) |
|
660 { |
|
661 permDenyOption = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_PERM_NO); |
|
662 ++stackResCnt; |
|
663 } |
|
664 } |
|
665 |
|
666 if ( oneShotDenyText) |
|
667 { |
|
668 settingPageText->AppendL (oneShotDenyText->Des ()); |
|
669 selIdxArray.Append (R_RTSECMGR_PROMPT_ONESHOT_NO); |
|
670 } |
|
671 |
|
672 if ( sessionDenyOption) |
|
673 { |
|
674 settingPageText->AppendL (sessionDenyOption->Des ()); |
|
675 selIdxArray.Append (R_RTSECMGR_PROMPT_SESSION_NO); |
|
676 } |
|
677 |
|
678 if ( permDenyOption) |
|
679 { |
|
680 settingPageText->AppendL (permDenyOption->Des ()); |
|
681 selIdxArray.Append (R_RTSECMGR_PROMPT_PERM_NO); |
|
682 } |
|
683 |
|
684 HBufC* body(NULL); |
|
685 HBufC *moreInfo(NULL); |
|
686 |
|
687 if(((aPromptData->iPermission->PermName()).Compare(KNullDesC)) != KErrNone) |
|
688 { |
|
689 if(((aPromptData->iPermission->PermName()).Compare(_L("UserDataGroup"))) == KErrNone ) |
|
690 { |
|
691 body = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_USERDATA_GROUP); |
|
692 ++stackResCnt; |
|
693 } |
|
694 else if(((aPromptData->iPermission->PermName()).Compare(_L("DeviceResourcesGroup"))) == KErrNone ) |
|
695 { |
|
696 body = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_DEVICERESOURCES_GROUP); |
|
697 ++stackResCnt; |
|
698 } |
|
699 else if(((aPromptData->iPermission->PermName()).Compare(_L("NetworkGroup"))) == KErrNone ) |
|
700 { |
|
701 body = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_NETWORK_GROUP); |
|
702 ++stackResCnt; |
|
703 } |
|
704 } |
|
705 else if ( (aPromptData->iPermission->Capability()<KCapabilitySize) && (aPromptData->iPermission->Capability()>ECapabilityTCB)) |
|
706 { |
|
707 TInt textResID(CAPABILITY_RESOURCEID[aPromptData->iPermission->Capability()]); |
|
708 if(KErrNone!=textResID) |
|
709 { |
|
710 body = iCoeEnv->AllocReadResourceLC (textResID); |
|
711 ++stackResCnt; |
|
712 } |
|
713 } |
|
714 |
|
715 if(((aPromptData->iPermission->PermName()).Compare(KNullDesC)) != KErrNone) |
|
716 { |
|
717 moreInfo = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_ITEM_MORE_INFO); |
|
718 ++stackResCnt; |
|
719 if( moreInfo ) |
|
720 { |
|
721 settingPageText->AppendL (moreInfo->Des ()); |
|
722 selIdxArray.Append (R_RTSECMGR_ITEM_MORE_INFO); |
|
723 } |
|
724 } |
|
725 |
|
726 CAknListQueryDialog* queryDialog = new (ELeave) CAknListQueryDialog(&selIndex); |
|
727 CleanupStack::PushL (queryDialog); |
|
728 ++stackResCnt; |
|
729 |
|
730 queryDialog->PrepareLC (R_LIST_QUERY_MSGBOX); |
|
731 |
|
732 queryDialog->SetItemTextArray (settingPageText); |
|
733 queryDialog->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
734 |
|
735 CAknMessageQueryControl* msgBox = queryDialog->MessageBox (); |
|
736 if ( msgBox && body ) |
|
737 msgBox->SetMessageTextL (body); |
|
738 |
|
739 CAknPopupHeadingPane* heading = queryDialog->QueryHeading (); |
|
740 HBufC* headerText(NULL); |
|
741 if ( heading) |
|
742 { |
|
743 heading->SetLayout (CAknPopupHeadingPane::EMessageQueryHeadingPane); |
|
744 headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_QUERY_HEADER); |
|
745 heading->SetTextL (headerText->Des ()); |
|
746 ++stackResCnt; |
|
747 } |
|
748 |
|
749 if(moreInfo) |
|
750 { |
|
751 TListItemProperties moreInfoProperties; |
|
752 moreInfoProperties.SetUnderlined(ETrue); |
|
753 queryDialog->ListControl()->Listbox()->ItemDrawer()->SetPropertiesL(settingPageText->Count()-1,moreInfoProperties); |
|
754 } |
|
755 |
|
756 CleanupStack::Pop (stackResCnt); |
|
757 |
|
758 queryDialog->ListBox()->SetCurrentItemIndex(selIndex); |
|
759 |
|
760 TInt queryOk = queryDialog->RunLD (); |
|
761 if ( queryOk == EAknSoftkeyOk) |
|
762 { |
|
763 if ( (selIndex>=0) && (selIndex<selIdxArray.Count())) |
|
764 { |
|
765 if ( R_RTSECMGR_PROMPT_ONESHOT_YES==selIdxArray[selIndex]) |
|
766 aPromptData->iUserSelection = RTUserPrompt_OneShot; |
|
767 |
|
768 else if ( R_RTSECMGR_PROMPT_ONESHOT_NO==selIdxArray[selIndex]) |
|
769 { |
|
770 aPromptData->iUserSelection = RTUserPrompt_Denied; |
|
771 ret = EPromptCancel; |
|
772 } |
|
773 |
|
774 else if ( R_RTSECMGR_PROMPT_SESSION_YES==selIdxArray[selIndex]) |
|
775 aPromptData->iUserSelection = RTUserPrompt_Session; |
|
776 |
|
777 else if ( R_RTSECMGR_PROMPT_SESSION_NO==selIdxArray[selIndex]) |
|
778 { |
|
779 aPromptData->iUserSelection = RTUserPrompt_SessionDenied; |
|
780 ret = EPromptCancel; |
|
781 } |
|
782 |
|
783 else if ( R_RTSECMGR_PROMPT_PERM_YES==selIdxArray[selIndex]) |
|
784 aPromptData->iUserSelection = RTUserPrompt_Permanent; |
|
785 |
|
786 else if ( R_RTSECMGR_PROMPT_PERM_NO==selIdxArray[selIndex]) |
|
787 { |
|
788 aPromptData->iUserSelection = RTUserPrompt_PermDenied; |
|
789 ret = EPromptCancel; |
|
790 } |
|
791 |
|
792 else if ( R_RTSECMGR_ITEM_MORE_INFO == selIdxArray[selIndex]) |
|
793 { |
|
794 ret = MoreInfoL(*aPromptData); |
|
795 } |
|
796 } |
|
797 } |
|
798 else |
|
799 { |
|
800 ret = EPromptCancel; |
|
801 } |
|
802 |
|
803 if ( headerText) |
|
804 delete headerText; |
|
805 |
|
806 if ( body) |
|
807 delete body; |
|
808 |
|
809 if ( oneShotOptionText) |
|
810 delete oneShotOptionText; |
|
811 |
|
812 if ( sessionOptionText) |
|
813 delete sessionOptionText; |
|
814 |
|
815 if ( permGrantOptionText) |
|
816 delete permGrantOptionText; |
|
817 |
|
818 if ( oneShotDenyText) |
|
819 delete oneShotDenyText; |
|
820 |
|
821 if ( sessionDenyOption) |
|
822 delete sessionDenyOption; |
|
823 |
|
824 if ( permDenyOption) |
|
825 delete permDenyOption; |
|
826 |
|
827 if (moreInfo) |
|
828 delete moreInfo; |
|
829 |
|
830 CleanupStack::PopAndDestroy ();//settingPageText |
|
831 CleanupStack::PopAndDestroy ();//selIdxArray |
|
832 return ret; |
|
833 } |
|
834 |
|
835 |
|
836 |
|
837 // --------------------------------------------------------------------------- |
|
838 // Private default prompt handler implementation for advanced prompt UI |
|
839 // --------------------------------------------------------------------------- |
|
840 // |
|
841 TInt CRTSecMgrScriptSession::PromptAdvanced(CPromptData* aPromptData) |
|
842 { |
|
843 TInt ret(EPromptOk); |
|
844 TInt selIndex(PROMPT_SELIDX_ZERO); //R_RTSECMGR_PROMPT_ONESHOT_YES |
|
845 TInt stackResCnt(0); |
|
846 |
|
847 HBufC* msgText(NULL); |
|
848 HBufC* moreInfo(NULL); |
|
849 TBuf<256> LinkText; |
|
850 |
|
851 if(((aPromptData->iPermission->PermName()).Compare(KNullDesC)) != KErrNone) |
|
852 { |
|
853 if(((aPromptData->iPermission->PermName()).Compare(_L("UserDataGroup"))) == KErrNone ) |
|
854 { |
|
855 msgText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_USERDATA_GROUP); |
|
856 LinkText.Append(msgText->Des()); |
|
857 ++stackResCnt; |
|
858 } |
|
859 else if(((aPromptData->iPermission->PermName()).Compare(_L("DeviceResourcesGroup"))) == KErrNone ) |
|
860 { |
|
861 msgText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_DEVICERESOURCES_GROUP); |
|
862 LinkText.Append(msgText->Des()); |
|
863 ++stackResCnt; |
|
864 } |
|
865 else if(((aPromptData->iPermission->PermName()).Compare(_L("NetworkGroup"))) == KErrNone ) |
|
866 { |
|
867 msgText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_NETWORK_GROUP); |
|
868 LinkText.Append(msgText->Des()); |
|
869 ++stackResCnt; |
|
870 } |
|
871 } |
|
872 else if ((aPromptData->iPermission->Capability()<KCapabilitySize) && (aPromptData->iPermission->Capability()>ECapabilityTCB)) |
|
873 { |
|
874 TInt textResID(CAPABILITY_RESOURCEID[aPromptData->iPermission->Capability()]); |
|
875 if(KErrNone!=textResID) |
|
876 { |
|
877 msgText = iCoeEnv->AllocReadResourceLC (textResID); |
|
878 ++stackResCnt; |
|
879 LinkText.Append(msgText->Des()); |
|
880 } |
|
881 } |
|
882 |
|
883 if(((aPromptData->iPermission->PermName()).Compare(KNullDesC)) != KErrNone) |
|
884 { |
|
885 moreInfo = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_LINK_MORE_INFO); |
|
886 ++stackResCnt; |
|
887 |
|
888 LinkText.Append(_L("\n\n")); |
|
889 LinkText.Append(_L("<AknMessageQuery Link>")); |
|
890 LinkText.Append(moreInfo->Des()); |
|
891 LinkText.Append(_L("</AknMessageQuery Link>")); |
|
892 } |
|
893 |
|
894 CAknMessageQueryDialog* queryDialog = new(ELeave) CAknMessageQueryDialog(); |
|
895 CleanupStack::PushL (queryDialog); |
|
896 ++stackResCnt; |
|
897 |
|
898 queryDialog->PrepareLC (R_ADVPROMPT_MESSAGE_QUERY); |
|
899 |
|
900 queryDialog->SetMessageTextL(LinkText); |
|
901 HBufC* headerText(NULL); |
|
902 CAknPopupHeadingPane* heading = queryDialog->QueryHeading (); |
|
903 if ( heading) |
|
904 { |
|
905 heading->SetLayout (CAknPopupHeadingPane::EMessageQueryHeadingPane); |
|
906 headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_QUERY_HEADER); |
|
907 heading->SetTextL (headerText->Des ()); |
|
908 ++stackResCnt; |
|
909 } |
|
910 |
|
911 if(moreInfo) |
|
912 { |
|
913 TCallBack callback; |
|
914 TCallbackParam callbackParam; |
|
915 |
|
916 callbackParam.iPromptData = aPromptData; |
|
917 callbackParam.iRTSecMgrScriptSession = this; |
|
918 callback.iFunction = LinkCallback; |
|
919 callback.iPtr = &callbackParam; |
|
920 |
|
921 queryDialog->SetLink(callback); |
|
922 } |
|
923 |
|
924 CleanupStack::Pop (stackResCnt); |
|
925 TInt queryOk = queryDialog->RunLD (); |
|
926 if ( queryOk == EAknSoftkeyYes) |
|
927 { |
|
928 if ( selIndex==0) |
|
929 { |
|
930 if ( aPromptData->iPermission->Default ()& RTUserPrompt_OneShot) |
|
931 { |
|
932 aPromptData->SetUserSelection(RTUserPrompt_OneShot); |
|
933 } |
|
934 else |
|
935 if ( aPromptData->iPermission->Default ()& RTUserPrompt_Session) |
|
936 { |
|
937 aPromptData->SetUserSelection(RTUserPrompt_Session); |
|
938 } |
|
939 else |
|
940 if ( aPromptData->iPermission->Default ()& RTUserPrompt_Permanent) |
|
941 { |
|
942 aPromptData->SetUserSelection(RTUserPrompt_Permanent); |
|
943 } |
|
944 } |
|
945 else |
|
946 { |
|
947 aPromptData->SetUserSelection(RTUserPrompt_Denied); |
|
948 } |
|
949 } |
|
950 else |
|
951 { |
|
952 ret = EPromptCancel; |
|
953 } |
|
954 |
|
955 if ( headerText) |
|
956 delete headerText; |
|
957 |
|
958 if ( msgText) |
|
959 delete msgText; |
|
960 |
|
961 if ( moreInfo) |
|
962 delete moreInfo; |
|
963 |
|
964 return ret; |
|
965 } |
|
966 // --------------------------------------------------------------------------- |
|
967 // Pops up a new query dialog when the user clicks on more info. |
|
968 // --------------------------------------------------------------------------- |
|
969 // |
|
970 TInt CRTSecMgrScriptSession::MoreInfoL(CPromptData& aPromptData) |
|
971 { |
|
972 TInt ret(EPromptOk); |
|
973 TInt stackResCnt = 0; |
|
974 HBufC *msgText = NULL; |
|
975 HBufC *body = NULL; |
|
976 TBuf<KMaxBuf> message; |
|
977 RCapabilityArray Caps; |
|
978 |
|
979 msgText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_MORE_INFO_QUERY); |
|
980 ++stackResCnt; |
|
981 message.Append(msgText->Des()); |
|
982 |
|
983 aPromptData.Permission()->Capabilitilites(Caps); |
|
984 for(TInt i = 0; i != Caps.Count(); ++i) |
|
985 { |
|
986 TInt textResID(MOREINFO_CAP_RESOURCEID[Caps[i]]); |
|
987 body = iCoeEnv->AllocReadResourceLC (textResID); |
|
988 message.Append(_L("\n")); |
|
989 message.Append(body->Des()); |
|
990 if(body) |
|
991 CleanupStack :: PopAndDestroy(body); |
|
992 } |
|
993 Caps.Close(); |
|
994 |
|
995 CAknMessageQueryDialog* queryDialog = new(ELeave) CAknMessageQueryDialog(); |
|
996 CleanupStack::PushL (queryDialog); |
|
997 ++stackResCnt; |
|
998 |
|
999 queryDialog->PrepareLC (R_MOREINFO_MESSAGE_QUERY); |
|
1000 |
|
1001 queryDialog->SetMessageTextL(message); |
|
1002 |
|
1003 HBufC* headerText(NULL); |
|
1004 CAknPopupHeadingPane* heading = queryDialog->QueryHeading (); |
|
1005 if ( heading) |
|
1006 { |
|
1007 heading->SetLayout (CAknPopupHeadingPane::EMessageQueryHeadingPane); |
|
1008 |
|
1009 if(((aPromptData.iPermission->PermName()).Compare(_L("UserDataGroup"))) == KErrNone ) |
|
1010 { |
|
1011 headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_MORE_INFO_HEADER_USERDATA); |
|
1012 } |
|
1013 else if(((aPromptData.iPermission->PermName()).Compare(_L("DeviceResourcesGroup"))) == KErrNone ) |
|
1014 { |
|
1015 headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_MORE_INFO_HEADER_DEVICERESOURCES); |
|
1016 } |
|
1017 else if(((aPromptData.iPermission->PermName()).Compare(_L("NetworkGroup"))) == KErrNone ) |
|
1018 { |
|
1019 headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_MORE_INFO_HEADER_NETWORK); |
|
1020 } |
|
1021 |
|
1022 // headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_QUERY_HEADER); |
|
1023 heading->SetTextL (headerText->Des ()); |
|
1024 ++stackResCnt; |
|
1025 } |
|
1026 |
|
1027 CleanupStack::Pop(stackResCnt); |
|
1028 |
|
1029 TInt queryOk = queryDialog->RunLD (); |
|
1030 |
|
1031 if(headerText) |
|
1032 delete headerText; |
|
1033 |
|
1034 if(msgText) |
|
1035 delete msgText; |
|
1036 |
|
1037 if(iUIPromptOption!=RTPROMPTUI_ADVANCED) |
|
1038 ret = Prompt(&aPromptData); |
|
1039 |
|
1040 return ret; |
|
1041 } |
|
1042 |
|
1043 |
|
1044 // --------------------------------------------------------------------------- |
|
1045 // Pops up a new query dialog when the user clicks on more info. |
|
1046 // --------------------------------------------------------------------------- |
|
1047 // |
|
1048 void CRTSecMgrScriptSession::PromptCostL() |
|
1049 { |
|
1050 AddResourceFiles(); |
|
1051 TInt stackResCnt = 0; |
|
1052 HBufC *msgText = NULL; |
|
1053 TBuf<KMaxBuf> message; |
|
1054 RCapabilityArray Caps; |
|
1055 |
|
1056 |
|
1057 msgText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_COST_INFO); |
|
1058 ++stackResCnt; |
|
1059 message.Append(msgText->Des()); |
|
1060 |
|
1061 CAknMessageQueryDialog* queryDialog = new(ELeave) CAknMessageQueryDialog(); |
|
1062 CleanupStack::PushL (queryDialog); |
|
1063 ++stackResCnt; |
|
1064 |
|
1065 queryDialog->PrepareLC (R_MOREINFO_MESSAGE_QUERY); |
|
1066 |
|
1067 queryDialog->SetMessageTextL(message); |
|
1068 |
|
1069 HBufC* headerText(NULL); |
|
1070 CAknPopupHeadingPane* heading = queryDialog->QueryHeading (); |
|
1071 if ( heading) |
|
1072 { |
|
1073 heading->SetLayout (CAknPopupHeadingPane::EMessageQueryHeadingPane); |
|
1074 headerText = iCoeEnv->AllocReadResourceLC (R_RTSECMGR_PROMPT_QUERY_HEADER); |
|
1075 heading->SetTextL (headerText->Des ()); |
|
1076 ++stackResCnt; |
|
1077 } |
|
1078 |
|
1079 CleanupStack::Pop(stackResCnt); |
|
1080 |
|
1081 TInt queryOk = queryDialog->RunLD (); |
|
1082 |
|
1083 if(headerText) |
|
1084 delete headerText; |
|
1085 |
|
1086 if(msgText) |
|
1087 delete msgText; |
|
1088 CloseResourceFiles(); |
|
1089 } |
|
1090 // --------------------------------------------------------------------------- |
|
1091 // Handles the prompt option chosen by the user through default prompt UI |
|
1092 // --------------------------------------------------------------------------- |
|
1093 // |
|
1094 void CRTSecMgrScriptSession::HandleGrantChosen(CPromptData* aPromptData, |
|
1095 TCapabilityBitSet aCapBitSet, TCapabilityBitSet& aAllowedCaps, |
|
1096 TBool& aIsPermGrantModified) |
|
1097 { |
|
1098 TUserPromptOption optionChosen = aPromptData->iUserSelection; |
|
1099 |
|
1100 if ( RTUserPrompt_OneShot==optionChosen) |
|
1101 { |
|
1102 _sessionInfo.AllowedCaps &= ~aCapBitSet; |
|
1103 aAllowedCaps = aCapBitSet; |
|
1104 } |
|
1105 else |
|
1106 if ( RTUserPrompt_Denied==optionChosen) //one-shot denied |
|
1107 { |
|
1108 aAllowedCaps &= ~aCapBitSet; |
|
1109 _sessionInfo.AllowedCaps &= ~aCapBitSet; //disable in session pattern too... |
|
1110 } |
|
1111 else |
|
1112 if ( RTUserPrompt_Session==optionChosen) |
|
1113 { |
|
1114 _sessionInfo.AllowedCaps |= aCapBitSet;//Enable in _sessionInfo.Allowed & allowed |
|
1115 aAllowedCaps = aCapBitSet; |
|
1116 } |
|
1117 else |
|
1118 if ( RTUserPrompt_SessionDenied==optionChosen) //session denied |
|
1119 { |
|
1120 aAllowedCaps &= ~aCapBitSet; |
|
1121 _sessionInfo.AllowedCaps &= ~aCapBitSet; //disable in session pattern too... |
|
1122 _sessionInfo.DeniedCaps |= aCapBitSet; //enable denied in session bit |
|
1123 } |
|
1124 else |
|
1125 if ( RTUserPrompt_Permanent==optionChosen) |
|
1126 { |
|
1127 aIsPermGrantModified = ETrue; //to commit the change to persistent store |
|
1128 _sessionInfo.AllowedCaps |= aCapBitSet; |
|
1129 aAllowedCaps = aCapBitSet; |
|
1130 iPermBits |= aCapBitSet; |
|
1131 iDeniedBits &= ~aCapBitSet; //just in case.... |
|
1132 } |
|
1133 else |
|
1134 if ( RTUserPrompt_PermDenied==optionChosen) //permanent denied |
|
1135 { |
|
1136 aIsPermGrantModified = ETrue; |
|
1137 aAllowedCaps &= ~aCapBitSet; |
|
1138 _sessionInfo.AllowedCaps &= ~aCapBitSet; //disable in session pattern too... |
|
1139 _sessionInfo.DeniedCaps |= aCapBitSet; //enable denied in session bit |
|
1140 iPermBits &= ~aCapBitSet; //disable in perm bits |
|
1141 iDeniedBits |= aCapBitSet; //enable in perm denied bit pattern |
|
1142 //Commit the change to persistent store... |
|
1143 } |
|
1144 } |
|
1145 |
|
1146 // --------------------------------------------------------------------------- |
|
1147 // Updates blanket permission data |
|
1148 // --------------------------------------------------------------------------- |
|
1149 // |
|
1150 void CRTSecMgrScriptSession::UpdatePermGrant() |
|
1151 { |
|
1152 (*iSubSessionProxy)->UpdatePermGrant (iScript->ScriptID (), iPermBits, |
|
1153 iDeniedBits); |
|
1154 } |
|
1155 |
|
1156 // |
|
1157 // Conversion utility to convert a single 32-bit value to the list of |
|
1158 // capabilities (RArray<TCapability>) |
|
1159 // |
|
1160 void CRTSecMgrScriptSession::BuildCapsL(TCapabilityBitSet aCapBitSet, |
|
1161 RCapabilityArray& aInOutTCapList) |
|
1162 { |
|
1163 TInt idx(KErrNotFound); |
|
1164 |
|
1165 while (++idx!=KCapabilitySize) |
|
1166 { |
|
1167 TCapabilityBitSet temp(KDefaultEnableBit); |
|
1168 temp = temp << idx; |
|
1169 if ( aCapBitSet & temp) |
|
1170 aInOutTCapList.AppendL ((TCapability)(idx+1)); |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 // |
|
1175 // Conversion utility to generate a single 32-bit value from a list of |
|
1176 // capabilities (RArray<TCapability>) |
|
1177 // |
|
1178 void CRTSecMgrScriptSession::AddCapability(TCapabilityBitSet& aInOutCapBitSet, |
|
1179 TCapability aCapToSet) |
|
1180 { |
|
1181 if ( aCapToSet>=0) |
|
1182 aInOutCapBitSet = aInOutCapBitSet | (LOWBIT << aCapToSet); |
|
1183 } |
|
1184 |
|
1185 /* |
|
1186 * Closes the script sub-session |
|
1187 * |
|
1188 */ |
|
1189 void CRTSecMgrScriptSession::Close() |
|
1190 { |
|
1191 if ( iResourceOffset && iCoeEnv) |
|
1192 iCoeEnv->DeleteResourceFile (iResourceOffset); |
|
1193 |
|
1194 if ( iScript) |
|
1195 { |
|
1196 delete iScript; |
|
1197 iScript = NULL; |
|
1198 } |
|
1199 |
|
1200 if ( iSubSessionProxy) |
|
1201 { |
|
1202 delete iSubSessionProxy; |
|
1203 iSubSessionProxy = NULL; |
|
1204 } |
|
1205 } |
|
1206 |
|
1207 //--------------------------------------------------------------------------- |
|
1208 // Callback function called from moreinfo link in advanced prompt |
|
1209 //--------------------------------------------------------------------------- |
|
1210 TInt CRTSecMgrScriptSession::LinkCallback(TAny * aCallbackParam) |
|
1211 { |
|
1212 TCallbackParam *cb = (TCallbackParam*)aCallbackParam; |
|
1213 (cb->iRTSecMgrScriptSession)->MoreInfoL(*(cb->iPromptData)); |
|
1214 return KErrNone; |
|
1215 } |