|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @publishedPartner |
|
19 @released |
|
20 */ |
|
21 |
|
22 #include "rfstatusswppolicy.h" |
|
23 #include "ssmdebug.h" |
|
24 #include "clayerpanic.h" |
|
25 #include <ssm/ssmcommandlistresourcereader.h> |
|
26 #include <ssm/ssmpatchableconstants.h> |
|
27 #include <ssm/clayerswp.hrh> |
|
28 |
|
29 |
|
30 //Path for RF status SwP command list resource file |
|
31 _LIT(KRFStatusSwPCmdListPath, "z:\\private\\2000d75b\\rfstatusswpcmdlist\\"); |
|
32 |
|
33 _LIT_SECURE_ID(KSsmSecureId , 0x2000D75B); |
|
34 |
|
35 EXPORT_C MSsmSwpPolicy* CRFStatusSwPPolicy ::NewL() |
|
36 { |
|
37 CRFStatusSwPPolicy * self = new (ELeave) CRFStatusSwPPolicy ; |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CRFStatusSwPPolicy ::CRFStatusSwPPolicy () |
|
45 { |
|
46 } |
|
47 |
|
48 CRFStatusSwPPolicy ::~CRFStatusSwPPolicy () |
|
49 { |
|
50 iFs.Close(); |
|
51 delete iCommandListResourceReader; |
|
52 } |
|
53 |
|
54 void CRFStatusSwPPolicy ::ConstructL() |
|
55 { |
|
56 User::LeaveIfError(iFs.Connect()); |
|
57 // create resource reader |
|
58 iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KRFStatusSwPCmdListPath(), *this); |
|
59 } |
|
60 |
|
61 void CRFStatusSwPPolicy ::Initialize(TRequestStatus& aStatus) |
|
62 { |
|
63 __ASSERT_DEBUG(iCommandListResourceReader, CLAYER_PANIC(ECLayerInvalidResourceReader)); |
|
64 |
|
65 //Initialise the command list resource reader. |
|
66 iCommandListResourceReader->Initialise(aStatus); |
|
67 } |
|
68 |
|
69 void CRFStatusSwPPolicy ::InitializeCancel() |
|
70 { |
|
71 __ASSERT_DEBUG(iCommandListResourceReader, CLAYER_PANIC(ECLayerInvalidResourceReader)); |
|
72 |
|
73 iCommandListResourceReader->InitialiseCancel(); |
|
74 } |
|
75 |
|
76 void CRFStatusSwPPolicy ::Release() |
|
77 { |
|
78 delete this; |
|
79 } |
|
80 |
|
81 MSsmSwpPolicy::TResponse CRFStatusSwPPolicy ::TransitionAllowed(const TSsmSwp& aSwp, const RMessagePtr2& aMessage) |
|
82 { |
|
83 MSsmSwpPolicy::TResponse isTransitionAllowed = ENotAllowed; |
|
84 TBool hasCapability = aMessage.HasCapability(ECapabilityWriteDeviceData, ECapabilityPowerMgmt, |
|
85 __PLATSEC_DIAGNOSTIC_STRING( "Platsec violation, RF status SwP transition" )); |
|
86 |
|
87 if(hasCapability) |
|
88 { |
|
89 if (IsSsmGracefulOffline()) |
|
90 { |
|
91 //RF ON/OFF is implemented as a substate in Normal instead of SwP for graceful offline notification. |
|
92 //Hence the SwP RF OFF/RF ON is restricted for the request which has SSM SID. Only BtSap SwP transition is |
|
93 //allowed to any client with appropriate capability. |
|
94 if (aMessage.SecureId() == KSsmSecureId || aSwp.Value() == ESsmBtSap ) |
|
95 { |
|
96 //Allow SwP change only if request has SsmSecureId or the SwP request for BtSap |
|
97 isTransitionAllowed = EAllowed; |
|
98 } |
|
99 } |
|
100 else |
|
101 { |
|
102 isTransitionAllowed = EAllowed; |
|
103 } |
|
104 } |
|
105 return isTransitionAllowed; |
|
106 } |
|
107 |
|
108 void CRFStatusSwPPolicy ::PrepareCommandList(const TSsmSwp& aSwp, TRequestStatus& aStatus) |
|
109 { |
|
110 __ASSERT_DEBUG(iCommandListResourceReader, CLAYER_PANIC(ECLayerInvalidResourceReader)); |
|
111 |
|
112 iCommandListResourceReader->PrepareCommandList(aSwp.Value(), aSwp, aStatus); |
|
113 } |
|
114 |
|
115 void CRFStatusSwPPolicy ::PrepareCommandListCancel() |
|
116 { |
|
117 __ASSERT_DEBUG(iCommandListResourceReader, CLAYER_PANIC(ECLayerInvalidResourceReader)); |
|
118 iCommandListResourceReader->PrepareCommandListCancel(); |
|
119 } |
|
120 |
|
121 CSsmCommandList* CRFStatusSwPPolicy ::CommandList() |
|
122 { |
|
123 __ASSERT_DEBUG(iCommandListResourceReader, CLAYER_PANIC(ECLayerInvalidResourceReader)); |
|
124 return iCommandListResourceReader->GetCommandList(); |
|
125 } |
|
126 |
|
127 void CRFStatusSwPPolicy ::HandleCleReturnValue(const TSsmSwp& aSwp, TInt aError, TInt /*aSeverity*/, TRequestStatus& aStatus) |
|
128 { |
|
129 TRequestStatus* rs = &aStatus; |
|
130 (void)aSwp; |
|
131 (void)aError; |
|
132 |
|
133 #if defined(_DEBUG) |
|
134 if(KErrNone != aError) |
|
135 { |
|
136 DEBUGPRINT3A("ERROR: Request SwP change for RF status (SwP key %d) completed with error %d", aSwp.Key(), aError); |
|
137 } |
|
138 //Complete the status with the error which inturn panics SSM server |
|
139 User::RequestComplete(rs, aError); |
|
140 #else |
|
141 //Completing the status with KErrNone to avoid panic in SSM server |
|
142 User::RequestComplete(rs, KErrNone); |
|
143 #endif |
|
144 } |
|
145 |
|
146 |
|
147 void CRFStatusSwPPolicy ::HandleCleReturnValueCancel() |
|
148 { |
|
149 // Nothing to do as HandleCleReturnValue always completes immediately |
|
150 } |
|
151 |
|
152 TBool CRFStatusSwPPolicy ::ConditionalCommandAllowedL(CResourceFile& /*aResourceFile*/, TInt /*aResourceId*/) |
|
153 { |
|
154 __ASSERT_DEBUG(iCommandListResourceReader, CLAYER_PANIC(ECLayerConditionalInfoNotImplemented)); |
|
155 return EFalse; |
|
156 } |