|
1 // Copyright (c) 1998-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 #include <e32std.h> |
|
18 |
|
19 #include "MSVSTD.H" |
|
20 |
|
21 #include "MTSR.H" |
|
22 #include "MSVENTRY.H" |
|
23 #include "MSVSERV.H" |
|
24 #include "MSVROPS.H" |
|
25 #include "MSVPANIC.H" |
|
26 |
|
27 |
|
28 //********************************** |
|
29 // CMsvServerOperation |
|
30 //********************************** |
|
31 |
|
32 CMsvServerOperation::CMsvServerOperation(const RMessage2& aMessage, TMsvOp aId, TUid aMtmUid, TMsvId aServiceId, TInt aSessionId) |
|
33 : CActive(EPriorityStandard), iMessage(aMessage), iId(aId), iMtmUid(aMtmUid), iServiceId(aServiceId), iSessionId(aSessionId), iState(EMsvOperationNull) |
|
34 // |
|
35 // |
|
36 // |
|
37 { |
|
38 __DECLARE_NAME(_S("CMsvServerOperation")); |
|
39 } |
|
40 |
|
41 |
|
42 CMsvServerOperation::~CMsvServerOperation() |
|
43 // |
|
44 // |
|
45 // |
|
46 { |
|
47 } |
|
48 |
|
49 /** |
|
50 This method should be overridden by SystemProgress() in other server MTMs to populate the |
|
51 TMsvSystemProgress structure. |
|
52 @param aOutSysProg The TMsvSystemProgress structure to be populated by the server |
|
53 @return KErrExtensionNotSupported |
|
54 */ |
|
55 TInt CMsvServerOperation::SystemProgress(TMsvSystemProgress& /*aSysProgress*/) |
|
56 { |
|
57 return KErrExtensionNotSupported; |
|
58 } |
|
59 |
|
60 //********************************** |
|
61 // CMsvMtmOperation |
|
62 //********************************** |
|
63 |
|
64 CMsvMtmOperation* CMsvMtmOperation::NewL(const RMessage2& aMessage, TMsvOp aId, TUid aMtmUid, TMsvId aServiceId, TInt aSessionId, MMsvOperationObserver& aOpObserver) |
|
65 // |
|
66 // |
|
67 // |
|
68 { |
|
69 CMsvMtmOperation* self = new(ELeave) CMsvMtmOperation(aMessage, aId, aMtmUid, aServiceId, aSessionId, aOpObserver); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 CMsvMtmOperation::CMsvMtmOperation(const RMessage2& aMessage, TMsvOp aId, TUid aMtmUid, TMsvId aServiceId, TInt aSessionId, MMsvOperationObserver& aOpObserver) |
|
78 : CMsvServerOperation(aMessage, aId, aMtmUid, aServiceId, aSessionId), iOpType(EMtmOpNone), iOpObserver(aOpObserver) |
|
79 // |
|
80 // |
|
81 // |
|
82 { |
|
83 __DECLARE_NAME(_S("CMsvMtmOperation")); |
|
84 } |
|
85 |
|
86 |
|
87 void CMsvMtmOperation::ConstructL() |
|
88 // |
|
89 // |
|
90 // |
|
91 { |
|
92 CActiveScheduler::Add(this); |
|
93 } |
|
94 |
|
95 |
|
96 void CMsvMtmOperation::Start(CBaseServerMtm& aServerMtm, TBool aCapabilityCheck) |
|
97 // |
|
98 // |
|
99 // |
|
100 { |
|
101 iServerMtm = &aServerMtm; |
|
102 TRAPD(leave, DoStartL(aCapabilityCheck)); |
|
103 if (leave) |
|
104 { |
|
105 iStatus=KRequestPending; |
|
106 TRequestStatus* st = &iStatus; |
|
107 User::RequestComplete(st, leave); |
|
108 } |
|
109 SetActive(); |
|
110 } |
|
111 |
|
112 |
|
113 void CMsvMtmOperation::Failed(TInt aError) |
|
114 // |
|
115 // |
|
116 // |
|
117 { |
|
118 iMessage.Complete(aError); |
|
119 SetState(EMsvOperationFailed); |
|
120 } |
|
121 |
|
122 |
|
123 void CMsvMtmOperation::DoStartL(TBool aCapabilityCheck) |
|
124 // |
|
125 // |
|
126 // |
|
127 { |
|
128 #if (defined SYMBIAN_USER_PROMPT_SERVICE) |
|
129 iServerMtm->ClientThreadInfo(iThreadId, aCapabilityCheck); |
|
130 #else |
|
131 // For versions which don't support SYMBIAN_USER_PROMPT_SERVICE, |
|
132 // this is needed to stop compiler warnings . |
|
133 aCapabilityCheck = aCapabilityCheck; |
|
134 #endif |
|
135 switch (iOpType) |
|
136 { |
|
137 case EMtmOpCopyFromLocal: |
|
138 iServerMtm->CopyFromLocalL(*iSelection, iIntParam, iStatus); |
|
139 break; |
|
140 case EMtmOpCopyToLocal: |
|
141 iServerMtm->CopyToLocalL(*iSelection, iIntParam, iStatus); |
|
142 break; |
|
143 case EMtmOpCopyWithinService: |
|
144 iServerMtm->CopyWithinServiceL(*iSelection, iIntParam, iStatus); |
|
145 break; |
|
146 case EMtmOpMoveFromLocal: |
|
147 iServerMtm->MoveFromLocalL(*iSelection, iIntParam, iStatus); |
|
148 break; |
|
149 case EMtmOpMoveToLocal: |
|
150 iServerMtm->MoveToLocalL(*iSelection, iIntParam, iStatus); |
|
151 break; |
|
152 case EMtmOpMoveWithinService: |
|
153 iServerMtm->MoveWithinServiceL(*iSelection, iIntParam, iStatus); |
|
154 break; |
|
155 case EMtmOpDeleteAll: |
|
156 iServerMtm->DeleteAllL(*iSelection, iStatus); |
|
157 break; |
|
158 case EMtmOpCreate: |
|
159 iServerMtm->CreateL(*iEntry, iStatus); |
|
160 break; |
|
161 case EMtmOpChange: |
|
162 iServerMtm->ChangeL(*iEntry, iStatus); |
|
163 break; |
|
164 case EMtmOpCommand: |
|
165 iServerMtm->StartCommandL(*iSelection, iIntParam, *iDesParam, iStatus); |
|
166 break; |
|
167 default: |
|
168 PanicServer(EMsvUnknownMtmOpType); |
|
169 break; |
|
170 } |
|
171 } |
|
172 |
|
173 CMsvMtmOperation::~CMsvMtmOperation() |
|
174 // |
|
175 // |
|
176 // |
|
177 { |
|
178 Cancel(); |
|
179 |
|
180 |
|
181 switch (State()) |
|
182 { |
|
183 case EMsvOperationQueued: |
|
184 __ASSERT_DEBUG(iServerMtm==NULL, PanicServer(EMsvDeletingMtmOperation1)); |
|
185 iMessage.Complete(KErrCancel); |
|
186 iOpObserver.OperationCancelled(*this); |
|
187 break; |
|
188 case EMsvOperationCompleted: |
|
189 __ASSERT_DEBUG(iServerMtm, PanicServer(EMsvDeletingMtmOperation2)); |
|
190 iOpObserver.OperationCompleted(ServiceId(), Id()); |
|
191 break; |
|
192 default: |
|
193 __ASSERT_DEBUG(State()!=EMsvOperationRunning, PanicServer(EMsvDeletingMtmOperation3)); |
|
194 break; |
|
195 } |
|
196 |
|
197 delete iEntry; |
|
198 delete iSelection; |
|
199 delete iBuf1; |
|
200 delete iBuf2; |
|
201 delete iDesParam; |
|
202 } |
|
203 |
|
204 |
|
205 void CMsvMtmOperation::DoCancel() |
|
206 // |
|
207 // |
|
208 // |
|
209 { |
|
210 __ASSERT_DEBUG(State()==EMsvOperationRunning, PanicServer(EMsvCancellingNonRunningOp)); |
|
211 iServerMtm->Cancel(); |
|
212 // inform client of the cancellation (or completion) |
|
213 iMessage.Complete(iStatus.Int()); |
|
214 SetState(EMsvOperationCompleted); |
|
215 } |
|
216 |
|
217 |
|
218 void CMsvMtmOperation::RunL() |
|
219 // |
|
220 // |
|
221 // |
|
222 { |
|
223 __ASSERT_DEBUG(State()==EMsvOperationRunning, PanicServer(EMsvCompletedNonRunningOp)); |
|
224 // inform client of the completion |
|
225 iMessage.Complete(iStatus.Int()); |
|
226 SetState(EMsvOperationCompleted); |
|
227 } |
|
228 |
|
229 |
|
230 const TDesC8& CMsvMtmOperation::Progress() |
|
231 // |
|
232 // |
|
233 // |
|
234 { |
|
235 __ASSERT_DEBUG(iServerMtm, PanicServer(EMsvProgressOnQueuedOp)); |
|
236 return iServerMtm->Progress(); |
|
237 } |
|
238 |
|
239 /** |
|
240 Call one of the server MTMs to populate the TMsvSystemProgress structure. |
|
241 @param aOutSysProg The TMsvSystemProgress structure to be populated by the server |
|
242 @return error if SystemProgress method fails |
|
243 */ |
|
244 TInt CMsvMtmOperation::SystemProgress(TMsvSystemProgress& aSysProgress) |
|
245 // |
|
246 // |
|
247 // |
|
248 { |
|
249 __ASSERT_DEBUG(iServerMtm, PanicServer(EMsvSystemProgressOnQueuedOp)); |
|
250 return iServerMtm->SystemProgress(aSysProgress); |
|
251 } |
|
252 |
|
253 void CMsvMtmOperation::StoreParametersL(TMtmOpType aOpType, const TMsvEntry& aNewEntry) |
|
254 // |
|
255 // |
|
256 // |
|
257 { |
|
258 iOpType = aOpType; |
|
259 iEntry = new (ELeave) TMsvEntry(aNewEntry); |
|
260 iBuf1 = HBufC::NewL(iEntry->iDescription.Length()); |
|
261 iBuf1->Des() = iEntry->iDescription; |
|
262 iEntry->iDescription.Set(iBuf1->Des()); |
|
263 iBuf2 = HBufC::NewL(iEntry->iDetails.Length()); |
|
264 iBuf2->Des() = iEntry->iDetails; |
|
265 iEntry->iDetails.Set(iBuf2->Des()); |
|
266 } |
|
267 |
|
268 void CMsvMtmOperation::StoreParameters(TMtmOpType aOpType, CMsvEntrySelection* aSelection, TInt aIntParam, HBufC8* aDesParam) |
|
269 // |
|
270 // |
|
271 // |
|
272 { |
|
273 iOpType = aOpType; |
|
274 iSelection = aSelection; |
|
275 iIntParam = aIntParam; |
|
276 iDesParam = aDesParam; |
|
277 } |
|
278 |