62
|
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 |
case EMtmOpChangeEntries:
|
|
168 |
iServerMtm->ChangeEntriesL(*iSelection,iIntParam,iStatus);
|
|
169 |
break;
|
|
170 |
default:
|
|
171 |
PanicServer(EMsvUnknownMtmOpType);
|
|
172 |
break;
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
|
176 |
CMsvMtmOperation::~CMsvMtmOperation()
|
|
177 |
//
|
|
178 |
//
|
|
179 |
//
|
|
180 |
{
|
|
181 |
Cancel();
|
|
182 |
|
|
183 |
|
|
184 |
switch (State())
|
|
185 |
{
|
|
186 |
case EMsvOperationQueued:
|
|
187 |
__ASSERT_DEBUG(iServerMtm==NULL, PanicServer(EMsvDeletingMtmOperation1));
|
|
188 |
iMessage.Complete(KErrCancel);
|
|
189 |
iOpObserver.OperationCancelled(*this);
|
|
190 |
break;
|
|
191 |
case EMsvOperationCompleted:
|
|
192 |
__ASSERT_DEBUG(iServerMtm, PanicServer(EMsvDeletingMtmOperation2));
|
|
193 |
iOpObserver.OperationCompleted(ServiceId(), Id());
|
|
194 |
break;
|
|
195 |
default:
|
|
196 |
__ASSERT_DEBUG(State()!=EMsvOperationRunning, PanicServer(EMsvDeletingMtmOperation3));
|
|
197 |
break;
|
|
198 |
}
|
|
199 |
|
|
200 |
delete iEntry;
|
|
201 |
delete iSelection;
|
|
202 |
delete iBuf1;
|
|
203 |
delete iBuf2;
|
|
204 |
delete iDesParam;
|
|
205 |
}
|
|
206 |
|
|
207 |
|
|
208 |
void CMsvMtmOperation::DoCancel()
|
|
209 |
//
|
|
210 |
//
|
|
211 |
//
|
|
212 |
{
|
|
213 |
__ASSERT_DEBUG(State()==EMsvOperationRunning, PanicServer(EMsvCancellingNonRunningOp));
|
|
214 |
iServerMtm->Cancel();
|
|
215 |
// inform client of the cancellation (or completion)
|
|
216 |
iMessage.Complete(iStatus.Int());
|
|
217 |
SetState(EMsvOperationCompleted);
|
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
void CMsvMtmOperation::RunL()
|
|
222 |
//
|
|
223 |
//
|
|
224 |
//
|
|
225 |
{
|
|
226 |
__ASSERT_DEBUG(State()==EMsvOperationRunning, PanicServer(EMsvCompletedNonRunningOp));
|
|
227 |
// inform client of the completion
|
|
228 |
iMessage.Complete(iStatus.Int());
|
|
229 |
SetState(EMsvOperationCompleted);
|
|
230 |
}
|
|
231 |
|
|
232 |
|
|
233 |
const TDesC8& CMsvMtmOperation::Progress()
|
|
234 |
//
|
|
235 |
//
|
|
236 |
//
|
|
237 |
{
|
|
238 |
__ASSERT_DEBUG(iServerMtm, PanicServer(EMsvProgressOnQueuedOp));
|
|
239 |
return iServerMtm->Progress();
|
|
240 |
}
|
|
241 |
|
|
242 |
/**
|
|
243 |
Call one of the server MTMs to populate the TMsvSystemProgress structure.
|
|
244 |
@param aOutSysProg The TMsvSystemProgress structure to be populated by the server
|
|
245 |
@return error if SystemProgress method fails
|
|
246 |
*/
|
|
247 |
TInt CMsvMtmOperation::SystemProgress(TMsvSystemProgress& aSysProgress)
|
|
248 |
//
|
|
249 |
//
|
|
250 |
//
|
|
251 |
{
|
|
252 |
__ASSERT_DEBUG(iServerMtm, PanicServer(EMsvSystemProgressOnQueuedOp));
|
|
253 |
return iServerMtm->SystemProgress(aSysProgress);
|
|
254 |
}
|
|
255 |
|
|
256 |
void CMsvMtmOperation::StoreParametersL(TMtmOpType aOpType, const TMsvEntry& aNewEntry)
|
|
257 |
//
|
|
258 |
//
|
|
259 |
//
|
|
260 |
{
|
|
261 |
iOpType = aOpType;
|
|
262 |
iEntry = new (ELeave) TMsvEntry(aNewEntry);
|
|
263 |
iBuf1 = HBufC::NewL(iEntry->iDescription.Length());
|
|
264 |
iBuf1->Des() = iEntry->iDescription;
|
|
265 |
iEntry->iDescription.Set(iBuf1->Des());
|
|
266 |
iBuf2 = HBufC::NewL(iEntry->iDetails.Length());
|
|
267 |
iBuf2->Des() = iEntry->iDetails;
|
|
268 |
iEntry->iDetails.Set(iBuf2->Des());
|
|
269 |
}
|
|
270 |
|
|
271 |
void CMsvMtmOperation::StoreParameters(TMtmOpType aOpType, CMsvEntrySelection* aSelection, TInt aIntParam, HBufC8* aDesParam)
|
|
272 |
//
|
|
273 |
//
|
|
274 |
//
|
|
275 |
{
|
|
276 |
iOpType = aOpType;
|
|
277 |
iSelection = aSelection;
|
|
278 |
iIntParam = aIntParam;
|
|
279 |
iDesParam = aDesParam;
|
|
280 |
}
|
|
281 |
|