1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: This adaptation plugin implementation is for test/reference purposes. |
13 // Description: |
14 // The loading of this plugin is controlled through test macro defined in the iby file "ssmcompatibility.iby". |
|
15 // If the macro "TEST_SSM_MACRO" is not defined, original plugins are loaded and this plugin is not loaded. |
|
16 // If the test P & S key is set in the test code, the calls are routed to the reference or dummy implementations. |
|
17 // Else the actual plugins are loaded and the calls are routed to the actual implementations. |
|
18 // The test P & S key which it looks for is KSimPluginPropertyKey (0x2000D76A) |
|
19 // |
14 // |
20 |
15 |
21 #include "simadaptationref.h" |
16 #include "simadaptationref.h" |
22 #include "ssmdebug.h" |
|
23 #include <e32property.h> |
|
24 |
|
25 const TUint32 KSimPluginPropertyKey = 0x2000D76B; |
|
26 const TUid KPropertyCategory={0x2000D75B}; |
|
27 |
17 |
28 /** |
18 /** |
29 Function to create new Sim Adaptation Plugin. |
19 Function to create new Sim Adaptation Plugin. |
30 |
20 |
31 @return a new plugin object for Sim Adaptations. |
21 @return a new plugin object for Sim Adaptations. |
48 } |
38 } |
49 |
39 |
50 CSimAdaptationRef::~CSimAdaptationRef() |
40 CSimAdaptationRef::~CSimAdaptationRef() |
51 { |
41 { |
52 delete iTimer; |
42 delete iTimer; |
53 iSaaSimAdaptationLib.Close(); |
|
54 } |
43 } |
55 |
44 |
56 CSimAdaptationRef::CSimAdaptationRef() |
45 CSimAdaptationRef::CSimAdaptationRef() |
57 { |
46 { |
58 } |
47 } |
59 |
48 |
60 void CSimAdaptationRef::ConstructL() |
49 void CSimAdaptationRef::ConstructL() |
61 { |
50 { |
62 DEBUGPRINT1A("Loading Actual plugins"); |
|
63 _LIT(KSaaSimAdaptationDLL, "saaSimadaptation.dll"); |
|
64 User::LeaveIfError(iSaaSimAdaptationLib.Load(KSaaSimAdaptationDLL)); |
|
65 iSaaSimAdaptationDll = (MSimAdaptation *)(iSaaSimAdaptationLib.Lookup(1)()); |
|
66 |
|
67 iTimer = CSimRefAdaptationTimer::NewL(); |
51 iTimer = CSimRefAdaptationTimer::NewL(); |
68 } |
52 } |
69 |
53 |
70 //from MSimAdaptation |
54 //from MSimAdaptation |
71 void CSimAdaptationRef::Release() |
55 void CSimAdaptationRef::Release() |
72 { |
56 { |
73 delete this; |
57 delete this; |
74 } |
58 } |
75 |
59 |
76 void CSimAdaptationRef::GetSimOwned(TDes8& aOwnedPckg, TRequestStatus& aStatus) |
60 void CSimAdaptationRef::GetSimOwned(TDes8& /*aOwnedPckg*/, TRequestStatus& aStatus) |
77 { |
61 { |
78 if(!IsTestPsKeyDefined()) |
62 aStatus = KRequestPending; |
79 { |
63 TRequestStatus* pStatus = &aStatus; |
80 DEBUGPRINT1A("GetSimOwned:: Calling Actual plugins functions (saaSimadaptation.dll)"); |
64 User::RequestComplete(pStatus, KErrNone); |
81 iSaaSimAdaptationDll->GetSimOwned(aOwnedPckg,aStatus); |
|
82 } |
|
83 else |
|
84 { |
|
85 DEBUGPRINT1A("GetSimOwned :: Calling ref plugins functions (Simadaptationref.dll)"); |
|
86 aStatus = KRequestPending; |
|
87 TRequestStatus* pStatus = &aStatus; |
|
88 User::RequestComplete(pStatus, KErrNone); |
|
89 } |
|
90 } |
65 } |
91 |
66 |
92 /** |
67 /** |
93 Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel. |
68 Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel. |
94 On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled. |
69 On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled. |
95 */ |
70 */ |
96 void CSimAdaptationRef::GetCancel() |
71 void CSimAdaptationRef::GetCancel() |
97 { |
72 { |
98 if(!IsTestPsKeyDefined()) |
|
99 { |
|
100 DEBUGPRINT1A("GetCancel ::Calling Actual plugins functions (saaSimadaptation.dll)"); |
|
101 iSaaSimAdaptationDll->GetCancel(); |
|
102 } |
|
103 } |
73 } |
104 |
74 |
105 /** |
75 /** |
106 The reference implementation completes with KErrNotSupported. This is required for automated testing. |
76 The reference implementation completes with KErrNotSupported since there is no SIM support on HRP/Techview. |
107 Actual plugins return expected values and this can be verified by manual testing |
|
108 On a device, Sim Adaptation Plug-in would complete 'aTypePckg' with one of the event types in TSsmSimEventType. |
77 On a device, Sim Adaptation Plug-in would complete 'aTypePckg' with one of the event types in TSsmSimEventType. |
109 |
78 |
110 |
79 |
111 The above mentioned implementation is modified to facilitate testing and increase the code coverage of the Adaptation |
80 The above mentioned implementation is modified to facilitate testing and increase the code coverage of the Adaptation |
112 server code.The modified functionality is as follows. |
81 server code.The modified functionality is as follows. |
123 |
92 |
124 |
93 |
125 */ |
94 */ |
126 void CSimAdaptationRef::NotifySimEvent(TDes8& /*aTypePckg*/, TRequestStatus& aStatus) |
95 void CSimAdaptationRef::NotifySimEvent(TDes8& /*aTypePckg*/, TRequestStatus& aStatus) |
127 { |
96 { |
128 if(!IsTestPsKeyDefined()) |
97 aStatus = KRequestPending; |
129 { |
98 iTimer->After(2000000,aStatus); |
130 DEBUGPRINT1A("NotifySimEvent :: Calling Actual plugins functions (saaSimadaptation.dll)"); |
|
131 /* Only clayersup.dll has an outstanding request. If this is passed to the actual plugin, the |
|
132 request will never complete till a SIM event happens. This would add the test code requests in a queue |
|
133 and the test code waits indefinitely. Hence, complete the request with KErrCancel. This would free the |
|
134 queue for test code to be executed. It has not impact on the test environment */ |
|
135 TRequestStatus *request = &aStatus; |
|
136 User::RequestComplete(request, KErrCancel); |
|
137 } |
|
138 else |
|
139 { |
|
140 DEBUGPRINT1A("NotifySimEvent :: Calling ref plugins functions (Simadaptationref.dll)"); |
|
141 aStatus = KRequestPending; |
|
142 iTimer->After(2000000,aStatus); |
|
143 } |
|
144 |
|
145 } |
99 } |
146 |
100 |
147 /** |
101 /** |
148 Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel. |
102 Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel. |
149 On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled. |
103 On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled. |
150 */ |
104 */ |
151 void CSimAdaptationRef::NotifyCancel() |
105 void CSimAdaptationRef::NotifyCancel() |
152 { |
106 { |
153 if(!IsTestPsKeyDefined()) |
107 if(iTimer->IsActive()) |
154 { |
108 { |
155 DEBUGPRINT1A("NotifyCancel :: Calling Actual plugins functions (saaSimadaptation.dll)"); |
109 iTimer->Cancel(); |
156 iSaaSimAdaptationDll->NotifyCancel(); |
110 } |
157 } |
|
158 else |
|
159 { |
|
160 DEBUGPRINT1A("NotifyCancel :: Calling ref plugins functions (Simadaptationref.dll)"); |
|
161 if(iTimer->IsActive()) |
|
162 { |
|
163 iTimer->Cancel(); |
|
164 } |
|
165 } |
|
166 } |
111 } |
167 |
112 |
168 /** |
|
169 Helper function to check for P&S Key |
|
170 */ |
|
171 TBool CSimAdaptationRef::IsTestPsKeyDefined() |
|
172 { |
|
173 TBool testPsKeyDefined = EFalse; |
|
174 TInt result = RProperty::Get(KPropertyCategory, KSimPluginPropertyKey, testPsKeyDefined); |
|
175 DEBUGPRINT3(_L("KSimPluginPropertyKey %d Error %d"), testPsKeyDefined, result); |
|
176 if ((KErrNone != result) && (KErrNotFound != result)) |
|
177 { |
|
178 //Could not retrieve property value. Tests might fail |
|
179 DEBUGPRINT1A("IsTestPsKeyDefined ERROR :: Could not retrieve property value)"); |
|
180 } |
|
181 return testPsKeyDefined; |
|
182 } |
|
183 |
113 |
184 |
114 |
185 CSimRefAdaptationTimer::CSimRefAdaptationTimer():CTimer(CActive::EPriorityUserInput) |
115 CSimRefAdaptationTimer::CSimRefAdaptationTimer():CTimer(CActive::EPriorityUserInput) |
186 { |
116 { |
187 CActiveScheduler::Add(this); |
117 CActiveScheduler::Add(this); |