|
1 // Copyright (c) 2001-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDES |
|
19 #include <EPos_CPosModules.h> |
|
20 #include <EPos_CPosModuleUpdate.h> |
|
21 #include <EPos_CPosModuleIdList.h> |
|
22 #include "ctlbsclientpostp21.h" |
|
23 // CONSTANTS |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ====================== |
|
26 |
|
27 // --------------------------------------------------------- |
|
28 // Constructor. |
|
29 // --------------------------------------------------------- |
|
30 CT_LbsClientPosTp21::CT_LbsClientPosTp21(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
31 { |
|
32 _LIT(KTestName, "TP21 - Enable/Disable PSY"); |
|
33 SetTestStepName(KTestName); |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // Destructor. |
|
38 // --------------------------------------------------------- |
|
39 CT_LbsClientPosTp21::~CT_LbsClientPosTp21() |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------- |
|
44 // CT_LbsClientPosTp21::CloseTest |
|
45 // Always called after the test, even if the test leaves |
|
46 // (other items were commented in a header). |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 void CT_LbsClientPosTp21::CloseTest() |
|
50 { |
|
51 ClosePositioner(); |
|
52 Disconnect(); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CT_LbsClientPosTp21::StartL |
|
57 // |
|
58 // (other items were commented in a header). |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 void CT_LbsClientPosTp21::StartL() |
|
62 { |
|
63 _LIT(KTestFailedText1, "Unable to open positioner, error code = %d"); |
|
64 _LIT(KRequestor, "SAAA"); |
|
65 |
|
66 TUid myPsyId = iUidStubPositioner; |
|
67 |
|
68 // Setup - copy files |
|
69 |
|
70 ConnectL(); |
|
71 |
|
72 // Enable myPsyId, disable all others |
|
73 SetupPsyL(myPsyId, ETrue); |
|
74 // Open subsession to enabled PSY |
|
75 TInt error = OpenPositionerByName(myPsyId); // Psy is enabled by default |
|
76 if (error != KErrNone) |
|
77 { |
|
78 TBuf<100> errMsg; |
|
79 errMsg.Format(KTestFailedText1, error); |
|
80 LogErrorAndLeaveL(errMsg); |
|
81 } |
|
82 // Make a request |
|
83 PerformRequestL(KRequestor, CRequestor::ERequestorService, CRequestor::EFormatTelephone); |
|
84 CheckRequestResultL(KErrNone); |
|
85 |
|
86 // Disable the PSY and perform another request |
|
87 SetupPsyL(myPsyId, EFalse); |
|
88 User::After(10000000); |
|
89 PerformRequestL(KRequestor, CRequestor::ERequestorService, CRequestor::EFormatTelephone); |
|
90 CheckRequestResultL(KErrNotFound); |
|
91 |
|
92 // Close the subsession and create another one |
|
93 ClosePositioner(); |
|
94 |
|
95 error = OpenPositionerByName(myPsyId); |
|
96 if (error != KErrNotFound) |
|
97 { |
|
98 TBuf<100> errMsg; |
|
99 errMsg.Format(KTestFailedText1, error); |
|
100 LogErrorAndLeaveL(errMsg); |
|
101 } |
|
102 |
|
103 // Enable the module and make a request |
|
104 SetupPsyL(myPsyId, ETrue); |
|
105 |
|
106 error = OpenPositionerByName(myPsyId); |
|
107 PerformRequestL(KRequestor, CRequestor::ERequestorService, CRequestor::EFormatTelephone); |
|
108 CheckRequestResultL(KErrNone); |
|
109 |
|
110 ClosePositioner(); |
|
111 Disconnect(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CT_LbsClientPosTp21::SetupPsyL |
|
116 // |
|
117 // (other items were commented in a header). |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 void CT_LbsClientPosTp21::SetupPsyL(const TUid aPsyUid, |
|
121 TBool aChoice) |
|
122 { |
|
123 CPosModules* db = CPosModules::OpenL(); |
|
124 CleanupStack::PushL(db); |
|
125 CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); |
|
126 |
|
127 // Disable PSY |
|
128 moduleUpdate->SetUpdateAvailability(EFalse); |
|
129 CPosModuleIdList* prioList = db->ModuleIdListLC(); |
|
130 |
|
131 // Disable all PSY:s |
|
132 TInt size = prioList->Count(); |
|
133 for (TInt i = 0 ; i < size; i++) |
|
134 { |
|
135 db->UpdateModuleL((*prioList)[i], *moduleUpdate); |
|
136 } |
|
137 |
|
138 // Enable/Disable the PSY that came as an in parameter |
|
139 if (aChoice) |
|
140 { |
|
141 moduleUpdate->SetUpdateAvailability(ETrue); |
|
142 } |
|
143 else |
|
144 { |
|
145 moduleUpdate->SetUpdateAvailability(EFalse); |
|
146 } |
|
147 |
|
148 db->UpdateModuleL(aPsyUid, *moduleUpdate); |
|
149 |
|
150 CleanupStack::PopAndDestroy(prioList); |
|
151 CleanupStack::PopAndDestroy(moduleUpdate); |
|
152 CleanupStack::PopAndDestroy(db); |
|
153 |
|
154 } |
|
155 |
|
156 // End of File |