|
1 // Copyright (c) 2008-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 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include <e32property.h> |
|
23 #include <ssm/ssmstatemanager.h> |
|
24 #include "ssmdebug.h" |
|
25 |
|
26 #include "tsus_swpchangesup.h" |
|
27 |
|
28 |
|
29 |
|
30 EXPORT_C MSsmUtility* CSwpLoadSup1::NewL() |
|
31 { |
|
32 return new (ELeave) CSwpLoadSup1; |
|
33 } |
|
34 |
|
35 CSwpLoadSup1::CSwpLoadSup1() : CActive(CActive::EPriorityStandard) |
|
36 { |
|
37 } |
|
38 |
|
39 CSwpLoadSup1::~CSwpLoadSup1() |
|
40 { |
|
41 if(IsAdded()) |
|
42 { |
|
43 Deque(); |
|
44 } |
|
45 } |
|
46 |
|
47 void CSwpLoadSup1::InitializeL() |
|
48 { |
|
49 CActiveScheduler::Add(this); |
|
50 } |
|
51 |
|
52 void CSwpLoadSup1::StartL() |
|
53 { |
|
54 if(IsAdded()) |
|
55 { |
|
56 if(!IsActive()) |
|
57 { |
|
58 RSsmStateManager client; |
|
59 const TInt connect = client.Connect(); |
|
60 client.RegisterSwpMapping(KTestSwpLoadSup, KTestSwpLoadSupFile); |
|
61 |
|
62 TSsmSwp swp(KTestSwpLoadSup, KTestSwpLoadSupNewValue); |
|
63 TRequestStatus trs; |
|
64 client.RequestSwpChange(swp, trs); |
|
65 User::LeaveIfError(trs==KRequestPending); |
|
66 User::WaitForRequest(trs); |
|
67 |
|
68 SetActive(); |
|
69 TRequestStatus* status = &iStatus; |
|
70 User::RequestComplete(status, trs.Int()); |
|
71 } |
|
72 } |
|
73 else |
|
74 { |
|
75 User::Leave(KErrNotReady); |
|
76 } |
|
77 } |
|
78 |
|
79 void CSwpLoadSup1::Release() |
|
80 { |
|
81 delete this; |
|
82 } |
|
83 |
|
84 void CSwpLoadSup1::DoCancel() |
|
85 { |
|
86 } |
|
87 |
|
88 void CSwpLoadSup1::RunL() |
|
89 { |
|
90 RSemaphore sem; |
|
91 if(KErrNone == sem.OpenGlobal(KTestSwpLoadSupSemaphore)) |
|
92 { |
|
93 sem.Signal(); |
|
94 sem.Close(); |
|
95 } |
|
96 } |
|
97 |
|
98 TInt CSwpLoadSup1::RunError(TInt aError) |
|
99 { |
|
100 return aError; |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 EXPORT_C MSsmUtility* CSwpLoadSup2::NewL() |
|
106 { |
|
107 return new (ELeave) CSwpLoadSup2; |
|
108 } |
|
109 |
|
110 CSwpLoadSup2::CSwpLoadSup2() : CActive(CActive::EPriorityStandard) |
|
111 { |
|
112 } |
|
113 |
|
114 CSwpLoadSup2::~CSwpLoadSup2() |
|
115 { |
|
116 if(IsAdded()) |
|
117 { |
|
118 Deque(); |
|
119 } |
|
120 } |
|
121 |
|
122 void CSwpLoadSup2::InitializeL() |
|
123 { |
|
124 CActiveScheduler::Add(this); |
|
125 } |
|
126 |
|
127 void CSwpLoadSup2::StartL() |
|
128 { |
|
129 if(IsAdded()) |
|
130 { |
|
131 if(!IsActive()) |
|
132 { |
|
133 RSsmStateManager client; |
|
134 const TInt connect = client.Connect(); |
|
135 client.RegisterSwpMapping(KTestSwpLoadSup, KTestSwpLoadSupFile); |
|
136 |
|
137 TSsmSwp swp(KTestSwpLoadSup, KTestSwpLoadSupNewValue); |
|
138 TRequestStatus trs; |
|
139 client.RequestSwpChange(swp, trs); |
|
140 User::LeaveIfError(trs==KRequestPending); |
|
141 User::WaitForRequest(trs); |
|
142 |
|
143 SetActive(); |
|
144 TRequestStatus* status = &iStatus; |
|
145 User::RequestComplete(status, trs.Int()); |
|
146 } |
|
147 } |
|
148 else |
|
149 { |
|
150 User::Leave(KErrNotReady); |
|
151 } |
|
152 } |
|
153 |
|
154 void CSwpLoadSup2::Release() |
|
155 { |
|
156 delete this; |
|
157 } |
|
158 |
|
159 void CSwpLoadSup2::DoCancel() |
|
160 { |
|
161 } |
|
162 |
|
163 void CSwpLoadSup2::RunL() |
|
164 { |
|
165 RSemaphore sem; |
|
166 if(KErrNone == sem.OpenGlobal(KTestSwpLoadSupSemaphore)) |
|
167 { |
|
168 sem.Signal(); |
|
169 sem.Close(); |
|
170 } |
|
171 } |
|
172 |
|
173 TInt CSwpLoadSup2::RunError(TInt aError) |
|
174 { |
|
175 return aError; |
|
176 } |