1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2010 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". |
108 */ |
108 */ |
109 TSsmState CSsmStateMonitor::State() const |
109 TSsmState CSsmStateMonitor::State() const |
110 { |
110 { |
111 return iState; |
111 return iState; |
112 } |
112 } |
|
113 |
|
114 |
|
115 CSsmDeferralMonitor::CSsmDeferralMonitor(RSsmStateAwareSession& aStateAwareSession, CSsmStateAwareSession2& aOwnerActiveObject) |
|
116 : CActive(CActive::EPriorityHigh), iSsmStateAwareSession(aStateAwareSession), iOwnerActiveObject(aOwnerActiveObject), iCeaseDeferral(EFalse) |
|
117 { |
|
118 CActiveScheduler::Add(this); |
|
119 } |
|
120 |
|
121 CSsmDeferralMonitor::~CSsmDeferralMonitor() |
|
122 { |
|
123 Cancel(); |
|
124 } |
|
125 |
|
126 /** |
|
127 * Defers the Acknowledgement. |
|
128 */ |
|
129 void CSsmDeferralMonitor::DeferNotification() |
|
130 { |
|
131 __ASSERT_ALWAYS(!IsActive(), User::Panic(KPanicSsmCmn, ECmnErrDeferNotif)); |
|
132 iSsmStateAwareSession.DeferAcknowledgement(iStatus); |
|
133 SetActive(); |
|
134 } |
|
135 |
|
136 /** |
|
137 Informs the object that the state transition has |
|
138 been _successfully_ acknowledged |
|
139 */ |
|
140 void CSsmDeferralMonitor::NotifyOfAcknowledgement() |
|
141 { |
|
142 if (IsActive()) |
|
143 { |
|
144 iCeaseDeferral = ETrue; |
|
145 } |
|
146 } |
|
147 |
|
148 void CSsmDeferralMonitor::RunL() |
|
149 { |
|
150 const TInt error = iStatus.Int(); |
|
151 TBool ceaseDeferral = iCeaseDeferral; |
|
152 iCeaseDeferral = EFalse; |
|
153 // We are leaving with error after resetting iCeaseDeferral. This is because |
|
154 // we might again RequestStateNotification() in HandleDeferralError(), in which case |
|
155 // we need to reset iCeaseDeferral to EFalse so that deferral may happen again. |
|
156 User::LeaveIfError(error); |
|
157 |
|
158 if(!ceaseDeferral) |
|
159 { |
|
160 DeferNotification(); |
|
161 } |
|
162 else |
|
163 { |
|
164 // At this point we know error == KErrNone |
|
165 // However, we return the error code KErrCompletion, as this |
|
166 // is what would have happened, had the acknowledgment come in |
|
167 // a little earlier, |
|
168 // whilst the deferral was still outstanding on the server. |
|
169 User::Leave(KErrCompletion); |
|
170 } |
|
171 } |
|
172 |
|
173 /** |
|
174 Handle errors thrown from RunL() - call HandleDeferralErrror() |
|
175 */ |
|
176 TInt CSsmDeferralMonitor::RunError(TInt aError) |
|
177 { |
|
178 DEBUGPRINT2A("CSsmDeferralMonitor::RunError: %d", aError); |
|
179 return iOwnerActiveObject.HandleDeferralError(aError); |
|
180 } |
|
181 |
|
182 /** |
|
183 * Cancels the outstanding deferral request. |
|
184 */ |
|
185 void CSsmDeferralMonitor::DoCancel() |
|
186 { |
|
187 iSsmStateAwareSession.CancelDeferral(); |
|
188 } |
|
189 |
|
190 |