16
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Maintain contexts for WebDAV transactions
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <httperr.h>
|
|
21 |
#include <dnd_err.h>
|
|
22 |
//#include "rsfwdavtransaction.h"
|
|
23 |
#include "rsfwdavaccesscontext.h"
|
|
24 |
#include "rsfwdavaccess.h"
|
|
25 |
#include "rsfwdavfileinfo.h"
|
|
26 |
#include "mdebug.h"
|
|
27 |
#include "xml/xmlparsererrors.h"
|
|
28 |
#include "rsfwdirentattr.h"
|
|
29 |
#include "rsfwdirent.h"
|
|
30 |
|
|
31 |
|
|
32 |
// CRsfwDavAccessContext
|
|
33 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
34 |
// Destructor
|
|
35 |
CRsfwDavAccessContext::~CRsfwDavAccessContext()
|
|
36 |
{
|
|
37 |
}
|
|
38 |
|
|
39 |
// ----------------------------------------------------------------------------
|
|
40 |
// CRsfwDavAccessContext::SubmitL
|
|
41 |
// Submit the operation.
|
|
42 |
// ----------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
void CRsfwDavAccessContext::SubmitL()
|
|
45 |
{
|
|
46 |
iWebDavTransactionId = iWebDavTransaction->Id();
|
|
47 |
iWebDavTransaction->SubmitL();
|
|
48 |
}
|
|
49 |
|
|
50 |
// ----------------------------------------------------------------------------
|
|
51 |
// CRsfwDavAccessContext::Retry
|
|
52 |
// Retry the operation.
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
void CRsfwDavAccessContext::Retry()
|
|
56 |
{
|
|
57 |
TRAPD(err, StartL());
|
|
58 |
if (err != KErrNone)
|
|
59 |
{
|
|
60 |
iStatus = err;
|
|
61 |
iDone = ETrue;
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
// ----------------------------------------------------------------------------
|
|
66 |
// CRsfwDavAccessContext::MapError
|
|
67 |
// Map an HTTP error code to SymbianOS error code.
|
|
68 |
// Whenever possible, these default mappings should be overriden
|
|
69 |
// in the derived classes.
|
|
70 |
// ----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CRsfwDavAccessContext::MapError(TInt& aError)
|
|
73 |
{
|
|
74 |
switch (aError)
|
|
75 |
{
|
|
76 |
case HTTPStatus::EBadRequest:
|
|
77 |
aError = KErrBadName;
|
|
78 |
break;
|
|
79 |
|
|
80 |
case HTTPStatus::EMovedPermanently:
|
|
81 |
case HTTPStatus::ETemporaryRedirect:
|
|
82 |
aError = KErrNotFound;
|
|
83 |
break;
|
|
84 |
|
|
85 |
default:
|
|
86 |
if (HTTPStatus::IsServerError(aError))
|
|
87 |
{
|
|
88 |
aError = KErrNotSupported;
|
|
89 |
}
|
|
90 |
else if (HTTPStatus::IsClientError(aError))
|
|
91 |
{
|
|
92 |
aError = KErrAccessDenied;
|
|
93 |
}
|
|
94 |
else if (HTTPStatus::IsRedirection(aError))
|
|
95 |
{
|
|
96 |
aError = KErrNotFound;
|
|
97 |
}
|
|
98 |
else
|
|
99 |
{
|
|
100 |
if (aError > 0)
|
|
101 |
{
|
|
102 |
// An arbitrary choice for error codes that should not occur
|
|
103 |
aError = KErrAccessDenied;
|
|
104 |
}
|
|
105 |
}
|
|
106 |
break;
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
// ----------------------------------------------------------------------------
|
|
111 |
// CRsfwDavAccessContext::TargetPath
|
|
112 |
// return target path, to support cancel by path from
|
|
113 |
// FM local dialogs
|
|
114 |
// This can be NULL for some non-cancellable operations like OPTIONS
|
|
115 |
// but note that for example when reading files the active operation may be
|
|
116 |
// PROPFIND when user presses cancel.
|
|
117 |
// ----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
const TDesC& CRsfwDavAccessContext::TargetPath()
|
|
120 |
{
|
|
121 |
return iRemotePathName;
|
|
122 |
}
|
|
123 |
|
|
124 |
|
|
125 |
// ----------------------------------------------------------------------------
|
|
126 |
// Derived access contexts
|
|
127 |
// ----------------------------------------------------------------------------
|
|
128 |
|
|
129 |
// CRsfwDavAccessContextOptions
|
|
130 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
131 |
// ----------------------------------------------------------------------------
|
|
132 |
// CRsfwDavAccessContextOptions::NewL
|
|
133 |
// Two-phased constructor.
|
|
134 |
// ----------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
CRsfwDavAccessContextOptions*
|
|
137 |
CRsfwDavAccessContextOptions::NewL(CRsfwDavAccess* aDavAccess,
|
|
138 |
MRsfwRemoteAccessResponseHandler* aResponseHandler)
|
|
139 |
{
|
|
140 |
CRsfwDavAccessContextOptions* self = new (ELeave) CRsfwDavAccessContextOptions;
|
|
141 |
CleanupStack::PushL(self);
|
|
142 |
self->ConstructL(aDavAccess, aResponseHandler);
|
|
143 |
CleanupStack::Pop(self);
|
|
144 |
return self;
|
|
145 |
}
|
|
146 |
|
|
147 |
// ----------------------------------------------------------------------------
|
|
148 |
// CRsfwDavAccessContextOptions::ConstructL
|
|
149 |
// Symbian 2nd phase constructor can leave.
|
|
150 |
// ----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
void CRsfwDavAccessContextOptions::ConstructL(
|
|
153 |
CRsfwDavAccess* aDavAccess,
|
|
154 |
MRsfwRemoteAccessResponseHandler* aResponseHandler)
|
|
155 |
{
|
|
156 |
DEBUGSTRING(("======= START ======="));
|
|
157 |
iDavAccess = aDavAccess;
|
|
158 |
iResponseHandler = aResponseHandler;
|
|
159 |
iTryCount = KCommRetries;
|
|
160 |
iRemotePathName = KNullDesC;
|
|
161 |
}
|
|
162 |
|
|
163 |
// ----------------------------------------------------------------------------
|
|
164 |
// CRsfwDavAccessContextOptions::StartL
|
|
165 |
// Submit the WebDAV transaction
|
|
166 |
// ----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CRsfwDavAccessContextOptions::StartL()
|
|
169 |
{
|
|
170 |
DEBUGSTRING(("DAV: Options StartL"));
|
|
171 |
iWebDavTransaction = iDavAccess->WebDavSession()->OptionsL();
|
|
172 |
SubmitL();
|
|
173 |
}
|
|
174 |
|
|
175 |
// ----------------------------------------------------------------------------
|
|
176 |
// CRsfwDavAccessContextOptions::TransactionCompleteL
|
|
177 |
// Handle a successfully completed transaction
|
|
178 |
// ----------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
void CRsfwDavAccessContextOptions::TransactionCompleteL()
|
|
181 |
{
|
|
182 |
DEBUGSTRING(("DAV: OptionsL done"));
|
|
183 |
iStatus = KErrNone;
|
|
184 |
iDone = ETrue;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ----------------------------------------------------------------------------
|
|
188 |
// CRsfwDavAccessContextOptions::TransactionError
|
|
189 |
// Handle a transaction fault
|
|
190 |
// ----------------------------------------------------------------------------
|
|
191 |
//
|
|
192 |
void CRsfwDavAccessContextOptions::TransactionError(TInt aError)
|
|
193 |
{
|
|
194 |
DEBUGSTRING(("DAV: OptionsL raw err=%d", aError));
|
|
195 |
if ((aError == KErrCommsLineFail) ||
|
|
196 |
(aError == KErrNotReady) )
|
|
197 |
// (aError == KErrDisconnected))
|
|
198 |
{
|
|
199 |
iTryCount--;
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
// Map protocol specific error codes into symbian error codes
|
|
204 |
switch (aError)
|
|
205 |
{
|
|
206 |
case HTTPStatus::EMethodNotAllowed:
|
|
207 |
// Server doesn't support DAV
|
|
208 |
aError = KErrNotSupported;
|
|
209 |
break;
|
|
210 |
|
|
211 |
case HTTPStatus::EBadRequest:
|
|
212 |
aError = KErrPathNotFound;
|
|
213 |
break;
|
|
214 |
|
|
215 |
case HTTPStatus::EBadGateway: // Proxy didn't find the server
|
|
216 |
case HTTPStatus::ENotFound:
|
|
217 |
case KErrDndNameNotFound: // name resolver didn't find the server
|
|
218 |
case KErrDndAddrNotFound:
|
|
219 |
case KErrHttpCannotEstablishTunnel: // ssl error when server not found
|
|
220 |
aError = KErrNotFound;
|
|
221 |
break;
|
|
222 |
|
|
223 |
default:
|
|
224 |
MapError(aError);
|
|
225 |
break;
|
|
226 |
}
|
|
227 |
|
|
228 |
DEBUGSTRING(("DAV: OptionsL err=%d", aError));
|
|
229 |
iStatus = aError;
|
|
230 |
iTryCount = 0;
|
|
231 |
}
|
|
232 |
|
|
233 |
if (iTryCount)
|
|
234 |
{
|
|
235 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
236 |
Retry();
|
|
237 |
}
|
|
238 |
else
|
|
239 |
{
|
|
240 |
iStatus = aError;
|
|
241 |
iDone = ETrue;
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
// CRsfwDavAccessContextPropFindDir
|
|
246 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
247 |
// ----------------------------------------------------------------------------
|
|
248 |
// CRsfwDavAccessContextPropFindDir::NewL
|
|
249 |
// Two-phased constructor.
|
|
250 |
// ----------------------------------------------------------------------------
|
|
251 |
//
|
|
252 |
CRsfwDavAccessContextPropFindDir* CRsfwDavAccessContextPropFindDir::NewL(
|
|
253 |
CRsfwDavAccess* aDavAccess,
|
|
254 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
255 |
const TDesC& aPathName,
|
|
256 |
TInt aDepth,
|
|
257 |
CRsfwDirEntAttr** aDirEntAttr,
|
|
258 |
RPointerArray<CRsfwDirEnt>* aDirEnts)
|
|
259 |
{
|
|
260 |
CRsfwDavAccessContextPropFindDir* self =
|
|
261 |
new (ELeave) CRsfwDavAccessContextPropFindDir;
|
|
262 |
CleanupStack::PushL(self);
|
|
263 |
self->ConstructL(aDavAccess,
|
|
264 |
aResponseHandler,
|
|
265 |
aPathName,
|
|
266 |
aDepth,
|
|
267 |
aDirEntAttr,
|
|
268 |
aDirEnts);
|
|
269 |
CleanupStack::Pop(self);
|
|
270 |
return self;
|
|
271 |
}
|
|
272 |
|
|
273 |
CRsfwDavAccessContextPropFindDir::~CRsfwDavAccessContextPropFindDir()
|
|
274 |
{
|
|
275 |
iOwnDirEnts.ResetAndDestroy();
|
|
276 |
}
|
|
277 |
|
|
278 |
// ----------------------------------------------------------------------------
|
|
279 |
// CRsfwDavAccessContextPropFindDir::ConstructL
|
|
280 |
// Symbian 2nd phase constructor can leave.
|
|
281 |
// ----------------------------------------------------------------------------
|
|
282 |
//
|
|
283 |
void CRsfwDavAccessContextPropFindDir::ConstructL(
|
|
284 |
CRsfwDavAccess* aDavAccess,
|
|
285 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
286 |
const TDesC& aPathName,
|
|
287 |
TInt aDepth,
|
|
288 |
CRsfwDirEntAttr** aDirEntAttr,
|
|
289 |
RPointerArray<CRsfwDirEnt>* aDirEnts)
|
|
290 |
{
|
|
291 |
DEBUGSTRING(("CRsfwDavAccessContextPropFindDir::ConstructL"));
|
|
292 |
DEBUGSTRING16(("aPathName ='%S'", &aPathName));
|
|
293 |
iDavAccess = aDavAccess;
|
|
294 |
iResponseHandler = aResponseHandler;
|
|
295 |
iDepth = aDepth;
|
|
296 |
iDirEntAttr = aDirEntAttr;
|
|
297 |
iDirEnts = aDirEnts;
|
|
298 |
if (aDirEnts)
|
|
299 |
{
|
|
300 |
iDirEnts = aDirEnts;
|
|
301 |
}
|
|
302 |
else
|
|
303 |
{
|
|
304 |
iDirEnts = &iOwnDirEnts;
|
|
305 |
}
|
|
306 |
iTryCount = KCommRetries;
|
|
307 |
iRemotePathName = aPathName;
|
|
308 |
}
|
|
309 |
|
|
310 |
// ----------------------------------------------------------------------------
|
|
311 |
// CRsfwDavAccessContextPropfindDir::StartL
|
|
312 |
// Submit the WebDAV transaction
|
|
313 |
// ----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
void CRsfwDavAccessContextPropFindDir::StartL()
|
|
316 |
{
|
|
317 |
/*
|
|
318 |
Preconditions:
|
|
319 |
- we haven't seen the directory at all (there is no CRsfwDavFileInfo for it)
|
|
320 |
- we have seen the directory and now the e-tag,
|
|
321 |
but haven't fetched the contents
|
|
322 |
- we have cached the contents also
|
|
323 |
*/
|
|
324 |
DEBUGSTRING(("DAV: PropFindDir StartL"));
|
|
325 |
iDirEnts->ResetAndDestroy();
|
|
326 |
iWebDavTransaction = iDavAccess->WebDavSession()->PropFindL(iRemotePathName,
|
|
327 |
iDepth,
|
|
328 |
ETrue,
|
|
329 |
*iDirEnts);
|
|
330 |
SubmitL();
|
|
331 |
}
|
|
332 |
|
|
333 |
// ----------------------------------------------------------------------------
|
|
334 |
// CRsfwDavAccessContextPropFindDir::TransactionCompleteL
|
|
335 |
// Handle a successfully completed transaction
|
|
336 |
// ----------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
void CRsfwDavAccessContextPropFindDir::TransactionCompleteL()
|
|
339 |
{
|
|
340 |
TInt err = KErrNone;
|
|
341 |
DEBUGSTRING(("DAV: PropFindDir complete"));
|
|
342 |
|
|
343 |
if (iDirEntAttr)
|
|
344 |
{
|
|
345 |
if (iDirEnts->Count())
|
|
346 |
{
|
|
347 |
*iDirEntAttr = (*iDirEnts)[0]->ExtractAttr();
|
|
348 |
}
|
|
349 |
}
|
|
350 |
|
|
351 |
#ifdef _DEBUG
|
|
352 |
DEBUGSTRING(("DAV: DoPropFindDir: returning %d", err));
|
|
353 |
TInt i;
|
|
354 |
for (i = 0; i < iDirEnts->Count(); i++)
|
|
355 |
{
|
|
356 |
CRsfwDirEnt* d = (*iDirEnts)[i];
|
|
357 |
TPtrC name(*d->Name());
|
|
358 |
DEBUGSTRING16(("'%S' - (size=%d, attr=0x%x)",
|
|
359 |
&name,
|
|
360 |
d->Attr()->Size(),
|
|
361 |
d->Attr()->Att()));
|
|
362 |
}
|
|
363 |
#endif // DEBUG
|
|
364 |
|
|
365 |
iStatus = err;
|
|
366 |
iDone = ETrue;
|
|
367 |
}
|
|
368 |
|
|
369 |
// ----------------------------------------------------------------------------
|
|
370 |
// CRsfwDavAccessContextPropFindDir::TransactionError
|
|
371 |
// Handle a transaction fault
|
|
372 |
// ----------------------------------------------------------------------------
|
|
373 |
//
|
|
374 |
void CRsfwDavAccessContextPropFindDir::TransactionError(TInt aError)
|
|
375 |
{
|
|
376 |
DEBUGSTRING(("DAV: PropFindDir raw err=%d", aError));
|
|
377 |
if ((aError == KErrCommsLineFail) ||
|
|
378 |
(aError == KErrNotReady) ||
|
|
379 |
(aError == KErrDisconnected))
|
|
380 |
{
|
|
381 |
iTryCount--;
|
|
382 |
}
|
|
383 |
else
|
|
384 |
{
|
|
385 |
// Map XML parser errors to KErrCorrupt
|
|
386 |
if ((aError <= EXmlFeatureLockedWhileParsing) &&
|
|
387 |
(aError >= EXmlParserError))
|
|
388 |
{
|
|
389 |
aError = EXmlParserError;
|
|
390 |
}
|
|
391 |
|
|
392 |
// Map protocol specific error codes into symbian error codes
|
|
393 |
switch (aError)
|
|
394 |
{
|
|
395 |
case EXmlParserError:
|
|
396 |
aError = KErrCorrupt;
|
|
397 |
break;
|
|
398 |
case HTTPStatus::ENotFound:
|
|
399 |
aError = KErrNotFound;
|
|
400 |
break;
|
|
401 |
|
|
402 |
case HTTPStatus::EForbidden:
|
|
403 |
case HTTPStatus::EUnauthorized:
|
|
404 |
aError = KErrAccessDenied;
|
|
405 |
break;
|
|
406 |
case HTTPStatus::EMovedPermanently:
|
|
407 |
case HTTPStatus::ETemporaryRedirect:
|
|
408 |
// The object we are looking for exists, but has a different
|
|
409 |
// type (e.g. we were looking for a file but it is a directory).
|
|
410 |
// PROPFIND should return not found...
|
|
411 |
aError = KErrNotFound;
|
|
412 |
break;
|
|
413 |
default:
|
|
414 |
MapError(aError);
|
|
415 |
break;
|
|
416 |
}
|
|
417 |
|
|
418 |
DEBUGSTRING(("DAV: PropFindDir err=%d", aError));
|
|
419 |
iStatus = aError;
|
|
420 |
iTryCount = 0;
|
|
421 |
}
|
|
422 |
|
|
423 |
if (iTryCount)
|
|
424 |
{
|
|
425 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
426 |
Retry();
|
|
427 |
}
|
|
428 |
else
|
|
429 |
{
|
|
430 |
iStatus = aError;
|
|
431 |
iDone = ETrue;
|
|
432 |
}
|
|
433 |
}
|
|
434 |
|
|
435 |
// CRsfwDavAccessContextPropFindFile
|
|
436 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
437 |
// ----------------------------------------------------------------------------
|
|
438 |
// CRsfwDavAccessContextPropFindFile::NewL
|
|
439 |
// Two-phased constructor.
|
|
440 |
// ----------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
CRsfwDavAccessContextPropFindFile* CRsfwDavAccessContextPropFindFile::NewL(
|
|
443 |
CRsfwDavAccess* aDavAccess,
|
|
444 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
445 |
const TDesC& aPathName,
|
|
446 |
CRsfwDirEntAttr** aDirEntAttr)
|
|
447 |
{
|
|
448 |
CRsfwDavAccessContextPropFindFile* self =
|
|
449 |
new (ELeave) CRsfwDavAccessContextPropFindFile;
|
|
450 |
CleanupStack::PushL(self);
|
|
451 |
self->ConstructL(aDavAccess, aResponseHandler, aPathName, aDirEntAttr);
|
|
452 |
CleanupStack::Pop(self);
|
|
453 |
return self;
|
|
454 |
}
|
|
455 |
|
|
456 |
CRsfwDavAccessContextPropFindFile::~CRsfwDavAccessContextPropFindFile()
|
|
457 |
{
|
|
458 |
iOwnDirEnts.ResetAndDestroy();
|
|
459 |
}
|
|
460 |
|
|
461 |
// ----------------------------------------------------------------------------
|
|
462 |
// CRsfwDavAccessContextPropfindFile::ConstructL
|
|
463 |
// Symbian 2nd phase constructor can leave.
|
|
464 |
// ----------------------------------------------------------------------------
|
|
465 |
//
|
|
466 |
void CRsfwDavAccessContextPropFindFile::ConstructL(
|
|
467 |
CRsfwDavAccess* aDavAccess,
|
|
468 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
469 |
const TDesC& aPathName,
|
|
470 |
CRsfwDirEntAttr** aDirEntAttr)
|
|
471 |
{
|
|
472 |
DEBUGSTRING(("CRsfwDavAccessContextPropFindFile::ConstructL"));
|
|
473 |
DEBUGSTRING16(("aPathName ='%S'", &aPathName));
|
|
474 |
iDavAccess = aDavAccess;
|
|
475 |
iResponseHandler = aResponseHandler;
|
|
476 |
iDirEntAttr = aDirEntAttr;
|
|
477 |
iTryCount = KCommRetries;
|
|
478 |
iRemotePathName = aPathName;
|
|
479 |
}
|
|
480 |
|
|
481 |
// ----------------------------------------------------------------------------
|
|
482 |
// CRsfwDavAccessContextPropFindFile::StartL
|
|
483 |
// Submit the WebDAV transaction
|
|
484 |
// ----------------------------------------------------------------------------
|
|
485 |
//
|
|
486 |
void CRsfwDavAccessContextPropFindFile::StartL()
|
|
487 |
{
|
|
488 |
DEBUGSTRING(("DAV: PropFindFile StartL"));
|
|
489 |
iOwnDirEnts.ResetAndDestroy();
|
|
490 |
iWebDavTransaction = iDavAccess->WebDavSession()->PropFindL(iRemotePathName,
|
|
491 |
0,
|
|
492 |
EFalse,
|
|
493 |
iOwnDirEnts);
|
|
494 |
SubmitL();
|
|
495 |
}
|
|
496 |
|
|
497 |
// ----------------------------------------------------------------------------
|
|
498 |
// CRsfwDavAccessContextPropFindFile::TransactionCompleteL
|
|
499 |
// Handle a successfully completed transaction
|
|
500 |
// ----------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
void CRsfwDavAccessContextPropFindFile::TransactionCompleteL()
|
|
503 |
{
|
|
504 |
DEBUGSTRING(("DAV: PropFindFile complete"));
|
|
505 |
|
|
506 |
if (iOwnDirEnts.Count() > 0)
|
|
507 |
{
|
|
508 |
*iDirEntAttr = iOwnDirEnts[0]->ExtractAttr();
|
|
509 |
}
|
|
510 |
|
|
511 |
iStatus = KErrNone;
|
|
512 |
iDone = ETrue;
|
|
513 |
}
|
|
514 |
|
|
515 |
// ----------------------------------------------------------------------------
|
|
516 |
// CRsfwDavAccessContextPropFindFile::TransactionError
|
|
517 |
// Handle a transaction fault
|
|
518 |
// ----------------------------------------------------------------------------
|
|
519 |
//
|
|
520 |
void CRsfwDavAccessContextPropFindFile::TransactionError(TInt aError)
|
|
521 |
{
|
|
522 |
DEBUGSTRING(("DAV: PropFindFile raw err=%d", aError));
|
|
523 |
if ((aError == KErrCommsLineFail) ||
|
|
524 |
(aError == KErrNotReady) ||
|
|
525 |
(aError == KErrDisconnected))
|
|
526 |
{
|
|
527 |
iTryCount--;
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
// Map XML parser errors to KErrCorrupt
|
|
532 |
if ((aError <= EXmlFeatureLockedWhileParsing) &&
|
|
533 |
(aError >= EXmlParserError))
|
|
534 |
{
|
|
535 |
aError = EXmlParserError;
|
|
536 |
}
|
|
537 |
// Map protocol specific error codes into symbian error codes
|
|
538 |
switch (aError)
|
|
539 |
{
|
|
540 |
case EXmlParserError:
|
|
541 |
aError = KErrCorrupt;
|
|
542 |
break;
|
|
543 |
|
|
544 |
case HTTPStatus::ENotFound:
|
|
545 |
aError = KErrNotFound;
|
|
546 |
break;
|
|
547 |
|
|
548 |
case HTTPStatus::EForbidden:
|
|
549 |
case HTTPStatus::EUnauthorized:
|
|
550 |
aError = KErrAccessDenied;
|
|
551 |
break;
|
|
552 |
case HTTPStatus::EMovedPermanently:
|
|
553 |
case HTTPStatus::ETemporaryRedirect:
|
|
554 |
// The object we are looking for exists, but has a different
|
|
555 |
// type (e.g. we were looking for a file but it is a directory).
|
|
556 |
// PROPFIND should return not found...
|
|
557 |
aError = KErrNotFound;
|
|
558 |
break;
|
|
559 |
default:
|
|
560 |
MapError(aError);
|
|
561 |
break;
|
|
562 |
}
|
|
563 |
|
|
564 |
DEBUGSTRING(("DAV: PropFindFile err=%d", aError));
|
|
565 |
iStatus = aError;
|
|
566 |
iTryCount = 0;
|
|
567 |
}
|
|
568 |
|
|
569 |
if (iTryCount)
|
|
570 |
{
|
|
571 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
572 |
Retry();
|
|
573 |
}
|
|
574 |
else
|
|
575 |
{
|
|
576 |
iStatus = aError;
|
|
577 |
iDone = ETrue;
|
|
578 |
}
|
|
579 |
}
|
|
580 |
|
|
581 |
// CRsfwDavAccessContextGet
|
|
582 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
583 |
// ----------------------------------------------------------------------------
|
|
584 |
// CRsfwDavAccessContextGet::NewL
|
|
585 |
// Two-phased constructor.
|
|
586 |
// ----------------------------------------------------------------------------
|
|
587 |
//
|
|
588 |
CRsfwDavAccessContextGet*
|
|
589 |
CRsfwDavAccessContextGet::NewL(CRsfwDavAccess* aDavAccess,
|
|
590 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
591 |
const TDesC& aRemotePathName,
|
|
592 |
const TDesC& aLocalPathName,
|
|
593 |
TInt aOffset,
|
|
594 |
TInt* aLength,
|
|
595 |
TUint aFlags)
|
|
596 |
{
|
|
597 |
CRsfwDavAccessContextGet* self = new (ELeave) CRsfwDavAccessContextGet;
|
|
598 |
CleanupStack::PushL(self);
|
|
599 |
self->ConstructL(aDavAccess,
|
|
600 |
aResponseHandler,
|
|
601 |
aRemotePathName,
|
|
602 |
aLocalPathName,
|
|
603 |
aOffset,
|
|
604 |
aLength,
|
|
605 |
aFlags);
|
|
606 |
CleanupStack::Pop(self);
|
|
607 |
return self;
|
|
608 |
}
|
|
609 |
|
|
610 |
// ----------------------------------------------------------------------------
|
|
611 |
// CRsfwDavAccessContextGet::ConstructL
|
|
612 |
// Symbian 2nd phase constructor can leave.
|
|
613 |
// ----------------------------------------------------------------------------
|
|
614 |
//
|
|
615 |
void CRsfwDavAccessContextGet::ConstructL(
|
|
616 |
CRsfwDavAccess* aDavAccess,
|
|
617 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
618 |
const TDesC& aRemotePathName,
|
|
619 |
const TDesC& aLocalPathName,
|
|
620 |
TInt aOffset,
|
|
621 |
TInt* aLength,
|
|
622 |
TUint aFlags)
|
|
623 |
{
|
|
624 |
iDavAccess = aDavAccess;
|
|
625 |
iResponseHandler = aResponseHandler;
|
|
626 |
iRemotePathName = aRemotePathName;
|
|
627 |
iLocalPathName = aLocalPathName;
|
|
628 |
iOffset = aOffset;
|
|
629 |
iLength = aLength;
|
|
630 |
iFlags = aFlags;
|
|
631 |
iTryCount = KCommRetries;
|
|
632 |
}
|
|
633 |
|
|
634 |
// ----------------------------------------------------------------------------
|
|
635 |
// CRsfwDavAccessContextGet::StartL
|
|
636 |
// Submit the WebDAV transaction
|
|
637 |
// ----------------------------------------------------------------------------
|
|
638 |
//
|
|
639 |
void CRsfwDavAccessContextGet::StartL()
|
|
640 |
{
|
|
641 |
DEBUGSTRING(("DAV: Get StartL"));
|
|
642 |
iWebDavTransaction = iDavAccess->WebDavSession()->GetL(iRemotePathName,
|
|
643 |
iLocalPathName,
|
|
644 |
iOffset,
|
|
645 |
iLength,
|
|
646 |
iFlags);
|
|
647 |
SubmitL();
|
|
648 |
}
|
|
649 |
|
|
650 |
// ----------------------------------------------------------------------------
|
|
651 |
// CRsfwDavAccessContextGet::TransactionCompleteL
|
|
652 |
// Handle a successfully completed transaction
|
|
653 |
// ----------------------------------------------------------------------------
|
|
654 |
//
|
|
655 |
void CRsfwDavAccessContextGet::TransactionCompleteL()
|
|
656 |
{
|
|
657 |
DEBUGSTRING(("DAV: Get done"));
|
|
658 |
|
|
659 |
iStatus = KErrNone;
|
|
660 |
iDone = ETrue;
|
|
661 |
}
|
|
662 |
|
|
663 |
// ----------------------------------------------------------------------------
|
|
664 |
// CRsfwDavAccessContextGet::TransactionError
|
|
665 |
// Handle a transaction fault
|
|
666 |
// ----------------------------------------------------------------------------
|
|
667 |
//
|
|
668 |
void CRsfwDavAccessContextGet::TransactionError(TInt aError)
|
|
669 |
{
|
|
670 |
DEBUGSTRING(("DAV: Get raw err=%d", aError));
|
|
671 |
if ((aError == KErrCommsLineFail) ||
|
|
672 |
(aError == KErrNotReady) ||
|
|
673 |
(aError == KErrDisconnected))
|
|
674 |
{
|
|
675 |
iTryCount--;
|
|
676 |
}
|
|
677 |
else
|
|
678 |
{
|
|
679 |
// Map protocol specific error codes into symbian error codes
|
|
680 |
switch (aError)
|
|
681 |
{
|
|
682 |
case HTTPStatus::ENotFound:
|
|
683 |
aError = KErrNotFound;
|
|
684 |
break;
|
|
685 |
|
|
686 |
case HTTPStatus::ENotModified:
|
|
687 |
aError = KErrNone;
|
|
688 |
break;
|
|
689 |
|
|
690 |
case HTTPStatus::EForbidden:
|
|
691 |
aError = KErrAccessDenied;
|
|
692 |
break;
|
|
693 |
|
|
694 |
default:
|
|
695 |
MapError(aError);
|
|
696 |
break;
|
|
697 |
}
|
|
698 |
|
|
699 |
DEBUGSTRING(("DAV: Get err=%d", aError));
|
|
700 |
iStatus = aError;
|
|
701 |
iTryCount = 0;
|
|
702 |
}
|
|
703 |
|
|
704 |
if (iTryCount)
|
|
705 |
{
|
|
706 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
707 |
Retry();
|
|
708 |
}
|
|
709 |
else
|
|
710 |
{
|
|
711 |
iStatus = aError;
|
|
712 |
iDone = ETrue;
|
|
713 |
}
|
|
714 |
}
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
// CRsfwDavAccessContextPut
|
|
719 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
720 |
// ----------------------------------------------------------------------------
|
|
721 |
// CRsfwDavAccessContextPut::NewL
|
|
722 |
// Two-phased constructor.
|
|
723 |
// ----------------------------------------------------------------------------
|
|
724 |
//
|
|
725 |
CRsfwDavAccessContextPut*
|
|
726 |
CRsfwDavAccessContextPut::NewL(CRsfwDavAccess* aDavAccess,
|
|
727 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
728 |
const TDesC& aLocalPathName,
|
|
729 |
const TDesC& aRemotePathName,
|
|
730 |
const TDesC8& aMimeType,
|
|
731 |
TInt aOffset,
|
|
732 |
TInt aLength,
|
|
733 |
TInt aTotalLength,
|
|
734 |
const TDesC8* aLockToken)
|
|
735 |
{
|
|
736 |
CRsfwDavAccessContextPut* self = new (ELeave) CRsfwDavAccessContextPut;
|
|
737 |
CleanupStack::PushL(self);
|
|
738 |
self->ConstructL(aDavAccess,
|
|
739 |
aResponseHandler,
|
|
740 |
aLocalPathName,
|
|
741 |
aRemotePathName,
|
|
742 |
aMimeType,
|
|
743 |
aOffset,
|
|
744 |
aLength,
|
|
745 |
aTotalLength,
|
|
746 |
aLockToken);
|
|
747 |
CleanupStack::Pop(self);
|
|
748 |
return self;
|
|
749 |
}
|
|
750 |
|
|
751 |
// ----------------------------------------------------------------------------
|
|
752 |
// CRsfwDavAccessContextPut::ConstructL
|
|
753 |
// Symbian 2nd phase constructor can leave.
|
|
754 |
// ----------------------------------------------------------------------------
|
|
755 |
//
|
|
756 |
void CRsfwDavAccessContextPut::ConstructL(
|
|
757 |
CRsfwDavAccess* aDavAccess,
|
|
758 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
759 |
const TDesC& aLocalPathName,
|
|
760 |
const TDesC& aRemotePathName,
|
|
761 |
const TDesC8& aMimeType,
|
|
762 |
TInt aOffset,
|
|
763 |
TInt aLength,
|
|
764 |
TInt aTotalLength,
|
|
765 |
const TDesC8* aLockToken)
|
|
766 |
{
|
|
767 |
iDavAccess = aDavAccess;
|
|
768 |
iResponseHandler = aResponseHandler;
|
|
769 |
iLocalPathName = aLocalPathName;
|
|
770 |
iRemotePathName = aRemotePathName;
|
|
771 |
iMimeType = aMimeType;
|
|
772 |
iOffset = aOffset;
|
|
773 |
iLength = aLength;
|
|
774 |
iTotalLength = aTotalLength;
|
|
775 |
iLockToken = aLockToken;
|
|
776 |
iTryCount = KCommRetries;
|
|
777 |
iContentRangeSupported = ETrue;
|
|
778 |
}
|
|
779 |
|
|
780 |
// ----------------------------------------------------------------------------
|
|
781 |
// CRsfwDavAccessContextPut::StartL
|
|
782 |
// Submit the WebDAV transaction
|
|
783 |
// ----------------------------------------------------------------------------
|
|
784 |
//
|
|
785 |
void CRsfwDavAccessContextPut::StartL()
|
|
786 |
{
|
|
787 |
DEBUGSTRING(("DAV: Put StartL"));
|
|
788 |
iWebDavTransaction =
|
|
789 |
iDavAccess->
|
|
790 |
WebDavSession()->
|
|
791 |
PutL(iLocalPathName,
|
|
792 |
iRemotePathName,
|
|
793 |
iMimeType,
|
|
794 |
iOffset,
|
|
795 |
iLength,
|
|
796 |
iTotalLength,
|
|
797 |
iContentRangeSupported,
|
|
798 |
iLockToken);
|
|
799 |
|
|
800 |
SubmitL();
|
|
801 |
}
|
|
802 |
|
|
803 |
// ----------------------------------------------------------------------------
|
|
804 |
// CRsfwDavAccessContextPut::TransactionCompleteL
|
|
805 |
// Handle a successfully completed transaction
|
|
806 |
// ----------------------------------------------------------------------------
|
|
807 |
//
|
|
808 |
void CRsfwDavAccessContextPut::TransactionCompleteL()
|
|
809 |
{
|
|
810 |
DEBUGSTRING(("DAV: Put done"));
|
|
811 |
iStatus = KErrNone;
|
|
812 |
iDone = ETrue;
|
|
813 |
}
|
|
814 |
|
|
815 |
|
|
816 |
// ----------------------------------------------------------------------------
|
|
817 |
// CRsfwDavAccessContextPut::TransactionError
|
|
818 |
// Handle a transaction fault
|
|
819 |
// ----------------------------------------------------------------------------
|
|
820 |
//
|
|
821 |
void CRsfwDavAccessContextPut::TransactionError(TInt aError)
|
|
822 |
{
|
|
823 |
DEBUGSTRING(("DAV: Put raw err=%d", aError));
|
|
824 |
if ((aError == KErrCommsLineFail) ||
|
|
825 |
(aError == KErrNotReady) ||
|
|
826 |
(aError == KErrDisconnected) ||
|
|
827 |
(aError == HTTPStatus::ENotImplemented))
|
|
828 |
{
|
|
829 |
iTryCount--;
|
|
830 |
}
|
|
831 |
else
|
|
832 |
{
|
|
833 |
// Map protocol specific error codes into Symbian error codes
|
|
834 |
switch (aError)
|
|
835 |
{
|
|
836 |
case HTTPStatus::EForbidden:
|
|
837 |
aError = KErrAccessDenied;
|
|
838 |
break;
|
|
839 |
|
|
840 |
case HTTPStatus::EMethodNotAllowed:
|
|
841 |
case HTTPStatus::EConflict:
|
|
842 |
// EConflict can mean either resource already exists or
|
|
843 |
// the parent does not exist.
|
|
844 |
// However, in our code we make sure that the parent exists.
|
|
845 |
aError = KErrAlreadyExists;
|
|
846 |
break;
|
|
847 |
|
|
848 |
case HTTPStatus::EUnsupportedMediaType:
|
|
849 |
aError = KErrNotSupported;
|
|
850 |
break;
|
|
851 |
case HTTPStatus::EInternalServerError:
|
|
852 |
case RsfwDavStatus::EInsufficientStorage:
|
|
853 |
aError = KErrDiskFull;
|
|
854 |
break;
|
|
855 |
case HTTPStatus::EMovedPermanently:
|
|
856 |
case HTTPStatus::ETemporaryRedirect:
|
|
857 |
// It is not allowed to write a file with the same name
|
|
858 |
// as an existing directory.
|
|
859 |
aError = KErrAccessDenied;
|
|
860 |
break;
|
|
861 |
default:
|
|
862 |
MapError(aError);
|
|
863 |
break;
|
|
864 |
}
|
|
865 |
|
|
866 |
DEBUGSTRING(("DAV: Put err=%d", aError));
|
|
867 |
iStatus = aError;
|
|
868 |
iTryCount = 0;
|
|
869 |
}
|
|
870 |
|
|
871 |
if (aError == HTTPStatus::ENotImplemented)
|
|
872 |
{
|
|
873 |
// we assume that the server does not support Content-Range: with PUT
|
|
874 |
iContentRangeSupported = EFalse;
|
|
875 |
}
|
|
876 |
|
|
877 |
if (iTryCount)
|
|
878 |
{
|
|
879 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
880 |
Retry();
|
|
881 |
}
|
|
882 |
else
|
|
883 |
{
|
|
884 |
iStatus = aError;
|
|
885 |
iDone = ETrue;
|
|
886 |
}
|
|
887 |
}
|
|
888 |
|
|
889 |
// CRsfwDavAccessContextMkDir
|
|
890 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
891 |
// ----------------------------------------------------------------------------
|
|
892 |
// CRsfwDavAccessContextMkDir::NewL
|
|
893 |
// Two-phased constructor.
|
|
894 |
// ----------------------------------------------------------------------------
|
|
895 |
//
|
|
896 |
CRsfwDavAccessContextMkDir*
|
|
897 |
CRsfwDavAccessContextMkDir::NewL(CRsfwDavAccess* aDavAccess,
|
|
898 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
899 |
const TDesC& aPathName)
|
|
900 |
{
|
|
901 |
CRsfwDavAccessContextMkDir* self = new (ELeave) CRsfwDavAccessContextMkDir;
|
|
902 |
CleanupStack::PushL(self);
|
|
903 |
self->ConstructL(aDavAccess, aResponseHandler, aPathName);
|
|
904 |
CleanupStack::Pop(self);
|
|
905 |
return self;
|
|
906 |
}
|
|
907 |
|
|
908 |
// ----------------------------------------------------------------------------
|
|
909 |
// CRsfwDavAccessContextMkDir::ConstructL
|
|
910 |
// Symbian 2nd phase constructor can leave.
|
|
911 |
// ----------------------------------------------------------------------------
|
|
912 |
//
|
|
913 |
void CRsfwDavAccessContextMkDir::ConstructL(
|
|
914 |
CRsfwDavAccess* aDavAccess,
|
|
915 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
916 |
const TDesC& aPathName)
|
|
917 |
{
|
|
918 |
iDavAccess = aDavAccess;
|
|
919 |
iResponseHandler = aResponseHandler;
|
|
920 |
iTryCount = KCommRetries;
|
|
921 |
iRemotePathName = aPathName;
|
|
922 |
}
|
|
923 |
|
|
924 |
// ----------------------------------------------------------------------------
|
|
925 |
// CRsfwDavAccessContextMkDir::StartL
|
|
926 |
// Submit the WebDAV transaction
|
|
927 |
// ----------------------------------------------------------------------------
|
|
928 |
//
|
|
929 |
void CRsfwDavAccessContextMkDir::StartL()
|
|
930 |
{
|
|
931 |
DEBUGSTRING(("DAV: MkDir StartL"));
|
|
932 |
iWebDavTransaction = iDavAccess->WebDavSession()->MkDirL(iRemotePathName);
|
|
933 |
SubmitL();
|
|
934 |
}
|
|
935 |
|
|
936 |
// ----------------------------------------------------------------------------
|
|
937 |
// CRsfwDavAccessContextMkDir::TransactionCompleteL
|
|
938 |
// Handle a successfully completed transaction
|
|
939 |
// ----------------------------------------------------------------------------
|
|
940 |
//
|
|
941 |
void CRsfwDavAccessContextMkDir::TransactionCompleteL()
|
|
942 |
{
|
|
943 |
DEBUGSTRING(("DAV: MkDir done"));
|
|
944 |
iStatus = KErrNone;
|
|
945 |
iDone = ETrue;
|
|
946 |
}
|
|
947 |
|
|
948 |
// ----------------------------------------------------------------------------
|
|
949 |
// CRsfwDavAccessContextMkDir::TransactionError
|
|
950 |
// Handle a transaction fault
|
|
951 |
// ----------------------------------------------------------------------------
|
|
952 |
//
|
|
953 |
void CRsfwDavAccessContextMkDir::TransactionError(TInt aError)
|
|
954 |
{
|
|
955 |
DEBUGSTRING(("DAV: MkDir raw err=%d", aError));
|
|
956 |
if ((aError == KErrCommsLineFail) ||
|
|
957 |
(aError == KErrNotReady) ||
|
|
958 |
(aError == KErrDisconnected))
|
|
959 |
{
|
|
960 |
iTryCount--;
|
|
961 |
}
|
|
962 |
else
|
|
963 |
{
|
|
964 |
/*
|
|
965 |
Map protocol specific error codes into Symbian error codes
|
|
966 |
KErrAlreadyExists dirD already exists in /dirA/dirB/dirC/
|
|
967 |
KErrAccessDenied dirD already exists but is not a directory.
|
|
968 |
KErrDirFull There is no room in /dirA/dirB/dirC/ for the new entry,
|
|
969 |
which is especially applicable to the root directory.
|
|
970 |
*/
|
|
971 |
switch (aError)
|
|
972 |
{
|
|
973 |
case HTTPStatus::EForbidden:
|
|
974 |
case HTTPStatus::EConflict:
|
|
975 |
/*
|
|
976 |
EConflict can mean either resource already exists
|
|
977 |
but is not a collection or the parent does not exist.
|
|
978 |
However, in our code we make sure that the parent exists.
|
|
979 |
*/
|
|
980 |
aError = KErrAccessDenied;
|
|
981 |
break;
|
|
982 |
|
|
983 |
case HTTPStatus::EMethodNotAllowed:
|
|
984 |
case HTTPStatus::EMovedPermanently:
|
|
985 |
aError = KErrAlreadyExists;
|
|
986 |
break;
|
|
987 |
|
|
988 |
case HTTPStatus::EUnsupportedMediaType:
|
|
989 |
aError = KErrNotSupported;
|
|
990 |
break;
|
|
991 |
|
|
992 |
case HTTPStatus::EInternalServerError:
|
|
993 |
case RsfwDavStatus::EInsufficientStorage:
|
|
994 |
aError = KErrDirFull;
|
|
995 |
break;
|
|
996 |
|
|
997 |
default:
|
|
998 |
MapError(aError);
|
|
999 |
break;
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
DEBUGSTRING(("DAV: MkDir err=%d", aError));
|
|
1003 |
iStatus = aError;
|
|
1004 |
iTryCount = 0;
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
if (iTryCount)
|
|
1008 |
{
|
|
1009 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
1010 |
Retry();
|
|
1011 |
}
|
|
1012 |
else
|
|
1013 |
{
|
|
1014 |
iStatus = aError;
|
|
1015 |
iDone = ETrue;
|
|
1016 |
}
|
|
1017 |
}
|
|
1018 |
|
|
1019 |
// CRsfwDavAccessContextDelete
|
|
1020 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
1021 |
// ----------------------------------------------------------------------------
|
|
1022 |
// CRsfwDavAccessContextDelete::NewL
|
|
1023 |
// Two-phased constructor.
|
|
1024 |
// ----------------------------------------------------------------------------
|
|
1025 |
//
|
|
1026 |
CRsfwDavAccessContextDelete*
|
|
1027 |
CRsfwDavAccessContextDelete::NewL(CRsfwDavAccess* aDavAccess,
|
|
1028 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1029 |
const TDesC& aPathName,
|
|
1030 |
TBool aIsDir,
|
|
1031 |
const TDesC8* aLockToken)
|
|
1032 |
{
|
|
1033 |
CRsfwDavAccessContextDelete* self = new (ELeave) CRsfwDavAccessContextDelete;
|
|
1034 |
CleanupStack::PushL(self);
|
|
1035 |
self->ConstructL(aDavAccess, aResponseHandler, aPathName, aIsDir, aLockToken);
|
|
1036 |
CleanupStack::Pop(self);
|
|
1037 |
return self;
|
|
1038 |
}
|
|
1039 |
|
|
1040 |
// ----------------------------------------------------------------------------
|
|
1041 |
// CRsfwDavAccessContextDelete::ConstructL
|
|
1042 |
// Symbian 2nd phase constructor can leave.
|
|
1043 |
// ----------------------------------------------------------------------------
|
|
1044 |
//
|
|
1045 |
void CRsfwDavAccessContextDelete::ConstructL(
|
|
1046 |
CRsfwDavAccess* aDavAccess,
|
|
1047 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1048 |
const TDesC& aPathName,
|
|
1049 |
TBool aIsDir,
|
|
1050 |
const TDesC8* aLockToken)
|
|
1051 |
{
|
|
1052 |
iDavAccess = aDavAccess;
|
|
1053 |
iResponseHandler = aResponseHandler;
|
|
1054 |
iIsDir = aIsDir;
|
|
1055 |
iLockToken = aLockToken;
|
|
1056 |
iTryCount = KCommRetries;
|
|
1057 |
iRemotePathName = aPathName;
|
|
1058 |
}
|
|
1059 |
|
|
1060 |
// ----------------------------------------------------------------------------
|
|
1061 |
// CRsfwDavAccessContextDelete::StartL
|
|
1062 |
// Submit the WebDAV transaction
|
|
1063 |
// ----------------------------------------------------------------------------
|
|
1064 |
//
|
|
1065 |
void CRsfwDavAccessContextDelete::StartL()
|
|
1066 |
{
|
|
1067 |
DEBUGSTRING(("DAV: Delete StartL"));
|
|
1068 |
iWebDavTransaction = iDavAccess->WebDavSession()->DeleteL(iRemotePathName,
|
|
1069 |
iIsDir,
|
|
1070 |
iLockToken);
|
|
1071 |
SubmitL();
|
|
1072 |
}
|
|
1073 |
|
|
1074 |
// ----------------------------------------------------------------------------
|
|
1075 |
// CRsfwDavAccessContextDelete::TransactionCompleteL
|
|
1076 |
// Handle a successfully completed transaction
|
|
1077 |
// ----------------------------------------------------------------------------
|
|
1078 |
//
|
|
1079 |
void CRsfwDavAccessContextDelete::TransactionCompleteL()
|
|
1080 |
{
|
|
1081 |
DEBUGSTRING(("DAV: Delete done"));
|
|
1082 |
iDavAccess->RemoveDavFileInfoL(iRemotePathName);
|
|
1083 |
iStatus = KErrNone;
|
|
1084 |
iDone = ETrue;
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
// ----------------------------------------------------------------------------
|
|
1088 |
// CRsfwDavAccessContextDelete::TransactionError
|
|
1089 |
// Handle a transaction fault
|
|
1090 |
// ----------------------------------------------------------------------------
|
|
1091 |
//
|
|
1092 |
void CRsfwDavAccessContextDelete::TransactionError(TInt aError)
|
|
1093 |
{
|
|
1094 |
DEBUGSTRING(("DAV: Delete raw err=%d", aError));
|
|
1095 |
if ((aError == KErrCommsLineFail) ||
|
|
1096 |
(aError == KErrNotReady) ||
|
|
1097 |
(aError == KErrDisconnected))
|
|
1098 |
{
|
|
1099 |
iTryCount--;
|
|
1100 |
}
|
|
1101 |
else
|
|
1102 |
{
|
|
1103 |
switch (aError)
|
|
1104 |
{
|
|
1105 |
case HTTPStatus::ENotFound:
|
|
1106 |
aError = KErrNotFound;
|
|
1107 |
break;
|
|
1108 |
|
|
1109 |
case HTTPStatus::EForbidden:
|
|
1110 |
case RsfwDavStatus::ELocked:
|
|
1111 |
aError = KErrAccessDenied;
|
|
1112 |
break;
|
|
1113 |
case HTTPStatus::EMovedPermanently:
|
|
1114 |
case HTTPStatus::ETemporaryRedirect:
|
|
1115 |
// We are attempting to delete a file
|
|
1116 |
// with the same name as an existing directory
|
|
1117 |
aError = KErrBadName;
|
|
1118 |
break;
|
|
1119 |
|
|
1120 |
default:
|
|
1121 |
MapError(aError);
|
|
1122 |
break;
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
DEBUGSTRING(("DAV: Delete err=%d", aError));
|
|
1126 |
iStatus = aError;
|
|
1127 |
iTryCount = 0;
|
|
1128 |
}
|
|
1129 |
|
|
1130 |
if (iTryCount)
|
|
1131 |
{
|
|
1132 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
1133 |
Retry();
|
|
1134 |
}
|
|
1135 |
else
|
|
1136 |
{
|
|
1137 |
iStatus = aError;
|
|
1138 |
iDone = ETrue;
|
|
1139 |
}
|
|
1140 |
}
|
|
1141 |
|
|
1142 |
// CRsfwDavAccessContextMove
|
|
1143 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
1144 |
// ----------------------------------------------------------------------------
|
|
1145 |
// CRsfwDavAccessContextMove::NewL
|
|
1146 |
// Two-phased constructor.
|
|
1147 |
// ----------------------------------------------------------------------------
|
|
1148 |
//
|
|
1149 |
CRsfwDavAccessContextMove*
|
|
1150 |
CRsfwDavAccessContextMove::NewL(CRsfwDavAccess* aDavAccess,
|
|
1151 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1152 |
const TDesC& aSrcPathName,
|
|
1153 |
const TDesC& aDstPathName,
|
|
1154 |
TBool aOverwrite,
|
|
1155 |
const TDesC8* aSrcLockToken,
|
|
1156 |
const TDesC8* aDstLockToken)
|
|
1157 |
{
|
|
1158 |
CRsfwDavAccessContextMove* self = new (ELeave) CRsfwDavAccessContextMove;
|
|
1159 |
CleanupStack::PushL(self);
|
|
1160 |
self->ConstructL(aDavAccess,
|
|
1161 |
aResponseHandler,
|
|
1162 |
aSrcPathName,
|
|
1163 |
aDstPathName,
|
|
1164 |
aOverwrite,
|
|
1165 |
aSrcLockToken,
|
|
1166 |
aDstLockToken);
|
|
1167 |
CleanupStack::Pop(self);
|
|
1168 |
return self;
|
|
1169 |
}
|
|
1170 |
|
|
1171 |
// ----------------------------------------------------------------------------
|
|
1172 |
// CRsfwDavAccessContextMove::ConstructL
|
|
1173 |
// Symbian 2nd phase constructor can leave.
|
|
1174 |
// ----------------------------------------------------------------------------
|
|
1175 |
//
|
|
1176 |
void CRsfwDavAccessContextMove::ConstructL(
|
|
1177 |
CRsfwDavAccess* aDavAccess,
|
|
1178 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1179 |
const TDesC& aSrcPathName,
|
|
1180 |
const TDesC& aDstPathName,
|
|
1181 |
TBool aOverwrite,
|
|
1182 |
const TDesC8* aSrcLockToken,
|
|
1183 |
const TDesC8* aDstLockToken)
|
|
1184 |
{
|
|
1185 |
iDavAccess = aDavAccess;
|
|
1186 |
iResponseHandler = aResponseHandler;
|
|
1187 |
iSrcPathName = aSrcPathName;
|
|
1188 |
iOverwrite = aOverwrite;
|
|
1189 |
iSrcLockToken = aSrcLockToken;
|
|
1190 |
iDstLockToken = aDstLockToken;
|
|
1191 |
iTryCount = KCommRetries;
|
|
1192 |
iRemotePathName = aDstPathName;
|
|
1193 |
}
|
|
1194 |
|
|
1195 |
// ----------------------------------------------------------------------------
|
|
1196 |
// CRsfwDavAccessContextMove::StartL
|
|
1197 |
// Submit the WebDAV transaction
|
|
1198 |
// ----------------------------------------------------------------------------
|
|
1199 |
//
|
|
1200 |
void CRsfwDavAccessContextMove::StartL()
|
|
1201 |
{
|
|
1202 |
DEBUGSTRING(("DAV: Move StartL"));
|
|
1203 |
iWebDavTransaction = iDavAccess->WebDavSession()->MoveL(iSrcPathName,
|
|
1204 |
iRemotePathName,
|
|
1205 |
iOverwrite,
|
|
1206 |
iSrcLockToken,
|
|
1207 |
iDstLockToken);
|
|
1208 |
SubmitL();
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
// ----------------------------------------------------------------------------
|
|
1212 |
// CRsfwDavAccessContextMove::TransactionCompleteL
|
|
1213 |
// Handle a successfully completed transaction
|
|
1214 |
// ----------------------------------------------------------------------------
|
|
1215 |
//
|
|
1216 |
void CRsfwDavAccessContextMove::TransactionCompleteL()
|
|
1217 |
{
|
|
1218 |
DEBUGSTRING(("DAV: Move done"));
|
|
1219 |
// move will delete the old file and does not lock the new one
|
|
1220 |
// so we just remove the token lock info
|
|
1221 |
iDavAccess->RemoveDavFileInfoL(iSrcPathName);
|
|
1222 |
iStatus = KErrNone;
|
|
1223 |
iDone = ETrue;
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
// ----------------------------------------------------------------------------
|
|
1227 |
// CRsfwDavAccessContextMove::TransactionError
|
|
1228 |
// Handle a transaction fault
|
|
1229 |
// ----------------------------------------------------------------------------
|
|
1230 |
//
|
|
1231 |
void CRsfwDavAccessContextMove::TransactionError(TInt aError)
|
|
1232 |
{
|
|
1233 |
DEBUGSTRING(("DAV: Move raw err=%d", aError));
|
|
1234 |
if ((aError == KErrCommsLineFail) ||
|
|
1235 |
(aError == KErrNotReady) ||
|
|
1236 |
(aError == KErrDisconnected))
|
|
1237 |
{
|
|
1238 |
iTryCount--;
|
|
1239 |
}
|
|
1240 |
else
|
|
1241 |
{
|
|
1242 |
// Map protocol specific error codes into Symbian error codes
|
|
1243 |
switch (aError)
|
|
1244 |
{
|
|
1245 |
case HTTPStatus::ENotFound:
|
|
1246 |
aError = KErrNotFound;
|
|
1247 |
break;
|
|
1248 |
|
|
1249 |
case HTTPStatus::EConflict: // source file not found
|
|
1250 |
aError = KErrNotFound;
|
|
1251 |
break;
|
|
1252 |
|
|
1253 |
case HTTPStatus::EBadGateway:
|
|
1254 |
case HTTPStatus::EForbidden:
|
|
1255 |
aError = KErrBadName;
|
|
1256 |
break;
|
|
1257 |
|
|
1258 |
case HTTPStatus::EPreconditionFailed:
|
|
1259 |
// Not performed due to the value of the Overwrite header
|
|
1260 |
aError = KErrAlreadyExists;
|
|
1261 |
break;
|
|
1262 |
|
|
1263 |
case RsfwDavStatus::ELocked:
|
|
1264 |
aError = KErrAccessDenied;
|
|
1265 |
break;
|
|
1266 |
|
|
1267 |
case HTTPStatus::EMovedPermanently:
|
|
1268 |
case HTTPStatus::ETemporaryRedirect:
|
|
1269 |
// The operation failed as object exists, although its type
|
|
1270 |
// didn't match the type of our parameter (file vs. dir)
|
|
1271 |
aError = KErrAlreadyExists;
|
|
1272 |
break;
|
|
1273 |
default:
|
|
1274 |
MapError(aError);
|
|
1275 |
break;
|
|
1276 |
}
|
|
1277 |
|
|
1278 |
DEBUGSTRING(("DAV: Move err=%d", aError));
|
|
1279 |
iStatus = aError;
|
|
1280 |
iTryCount = 0;
|
|
1281 |
}
|
|
1282 |
|
|
1283 |
if (iTryCount)
|
|
1284 |
{
|
|
1285 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
1286 |
Retry();
|
|
1287 |
}
|
|
1288 |
else
|
|
1289 |
{
|
|
1290 |
iStatus = aError;
|
|
1291 |
iDone = ETrue;
|
|
1292 |
}
|
|
1293 |
}
|
|
1294 |
|
|
1295 |
// CRsfwDavAccessContextLock
|
|
1296 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
1297 |
// ----------------------------------------------------------------------------
|
|
1298 |
// CRsfwDavAccessContextLock::NewL
|
|
1299 |
// Two-phased constructor.
|
|
1300 |
// ----------------------------------------------------------------------------
|
|
1301 |
//
|
|
1302 |
CRsfwDavAccessContextLock*
|
|
1303 |
CRsfwDavAccessContextLock::NewL(CRsfwDavAccess* aDavAccess,
|
|
1304 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1305 |
const TDesC& aPathName,
|
|
1306 |
TUint aLockFlags,
|
|
1307 |
TUint& aTimeout,
|
|
1308 |
TDesC8** aLockToken)
|
|
1309 |
{
|
|
1310 |
CRsfwDavAccessContextLock* self = new (ELeave) CRsfwDavAccessContextLock;
|
|
1311 |
CleanupStack::PushL(self);
|
|
1312 |
self->ConstructL(aDavAccess,
|
|
1313 |
aResponseHandler,
|
|
1314 |
aPathName,
|
|
1315 |
aLockFlags,
|
|
1316 |
aTimeout,
|
|
1317 |
aLockToken);
|
|
1318 |
CleanupStack::Pop(self);
|
|
1319 |
return self;
|
|
1320 |
}
|
|
1321 |
|
|
1322 |
CRsfwDavAccessContextLock::~CRsfwDavAccessContextLock()
|
|
1323 |
{
|
|
1324 |
delete iDavFileInfo;
|
|
1325 |
}
|
|
1326 |
|
|
1327 |
// ----------------------------------------------------------------------------
|
|
1328 |
// CRsfwDavAccessContextLock::ConstructL
|
|
1329 |
// Symbian 2nd phase constructor can leave.
|
|
1330 |
// ----------------------------------------------------------------------------
|
|
1331 |
//
|
|
1332 |
void CRsfwDavAccessContextLock::ConstructL(
|
|
1333 |
CRsfwDavAccess* aDavAccess,
|
|
1334 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1335 |
const TDesC& aPathName,
|
|
1336 |
TUint aLockFlags,
|
|
1337 |
TUint& aTimeout,
|
|
1338 |
TDesC8** aLockToken)
|
|
1339 |
{
|
|
1340 |
iDavAccess = aDavAccess;
|
|
1341 |
iResponseHandler = aResponseHandler;
|
|
1342 |
iLockFlags = aLockFlags;
|
|
1343 |
iTimeout = &aTimeout;
|
|
1344 |
iLockToken = aLockToken;
|
|
1345 |
iTryCount = KCommRetries;
|
|
1346 |
iRemotePathName = aPathName;
|
|
1347 |
}
|
|
1348 |
|
|
1349 |
// ----------------------------------------------------------------------------
|
|
1350 |
// CRsfwDavAccessContextLock::StartL
|
|
1351 |
// Submit the WebDAV transaction
|
|
1352 |
// ----------------------------------------------------------------------------
|
|
1353 |
//
|
|
1354 |
void CRsfwDavAccessContextLock::StartL()
|
|
1355 |
{
|
|
1356 |
DEBUGSTRING(("DAV: Lock StartL"));
|
|
1357 |
iWebDavTransaction = iDavAccess->WebDavSession()->LockL(iRemotePathName,
|
|
1358 |
iLockFlags,
|
|
1359 |
*iTimeout,
|
|
1360 |
&iDavFileInfo);
|
|
1361 |
SubmitL();
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
// ----------------------------------------------------------------------------
|
|
1365 |
// CRsfwDavAccessContextLock::TransactionCompleteL
|
|
1366 |
// Handle a successfully completed transaction
|
|
1367 |
// ----------------------------------------------------------------------------
|
|
1368 |
//
|
|
1369 |
void CRsfwDavAccessContextLock::TransactionCompleteL()
|
|
1370 |
{
|
|
1371 |
DEBUGSTRING(("DAV: Lock done"));
|
|
1372 |
|
|
1373 |
/*
|
|
1374 |
Preconditions:
|
|
1375 |
- we haven't seen the file at all (there is no fileInfo for it)
|
|
1376 |
or
|
|
1377 |
- we have cached it and there is fileinfo with a
|
|
1378 |
lock token (lock token is never assumed to be valid,
|
|
1379 |
if FileEngine decides to call this function)
|
|
1380 |
*/
|
|
1381 |
*iTimeout = iDavFileInfo->Timeout();
|
|
1382 |
|
|
1383 |
CRsfwDavFileInfo* storedFileInfo = iDavAccess->DavFileInfoL(iRemotePathName);
|
|
1384 |
HBufC8* lockToken;
|
|
1385 |
if (storedFileInfo)
|
|
1386 |
{
|
|
1387 |
// Lock operation succesful, set lock timeout
|
|
1388 |
if (iDavFileInfo->Name())
|
|
1389 |
{
|
|
1390 |
storedFileInfo->SetNameL(*(iDavFileInfo->Name()));
|
|
1391 |
}
|
|
1392 |
if (iDavFileInfo->LockToken())
|
|
1393 |
{
|
|
1394 |
storedFileInfo->SetLockTokenL(*(iDavFileInfo->LockToken()));
|
|
1395 |
}
|
|
1396 |
storedFileInfo->SetTimeout(iDavFileInfo->Timeout());
|
|
1397 |
lockToken = storedFileInfo->LockToken();
|
|
1398 |
}
|
|
1399 |
else
|
|
1400 |
{
|
|
1401 |
// new file
|
|
1402 |
iDavAccess->AddDavFileInfo(iDavFileInfo);
|
|
1403 |
lockToken = iDavFileInfo->LockToken();
|
|
1404 |
// Ownership transferred to CRsfwDavAccess
|
|
1405 |
iDavFileInfo = NULL;
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
if (iLockToken)
|
|
1409 |
{
|
|
1410 |
// Allocate and return the lock token to the caller
|
|
1411 |
*iLockToken = lockToken->Des().AllocL();
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
iStatus = KErrNone;
|
|
1415 |
iDone = ETrue;
|
|
1416 |
}
|
|
1417 |
|
|
1418 |
// ----------------------------------------------------------------------------
|
|
1419 |
// CRsfwDavAccessContextLock::TransactionError
|
|
1420 |
// Handle a transaction fault
|
|
1421 |
// ----------------------------------------------------------------------------
|
|
1422 |
//
|
|
1423 |
void CRsfwDavAccessContextLock::TransactionError(TInt aError)
|
|
1424 |
{
|
|
1425 |
DEBUGSTRING(("DAV: Lock raw err=%d", aError));
|
|
1426 |
if ((aError == KErrCommsLineFail) ||
|
|
1427 |
(aError == KErrNotReady) ||
|
|
1428 |
(aError == KErrDisconnected))
|
|
1429 |
{
|
|
1430 |
iTryCount--;
|
|
1431 |
}
|
|
1432 |
else
|
|
1433 |
{
|
|
1434 |
// Map XML parser errors to KErrCorrupt
|
|
1435 |
if ((aError <= EXmlFeatureLockedWhileParsing) &&
|
|
1436 |
(aError >= EXmlParserError))
|
|
1437 |
{
|
|
1438 |
aError = EXmlParserError;
|
|
1439 |
}
|
|
1440 |
|
|
1441 |
// Map protocol specific error codes into Symbian error codes
|
|
1442 |
switch (aError)
|
|
1443 |
{
|
|
1444 |
case EXmlParserError:
|
|
1445 |
aError = KErrCorrupt;
|
|
1446 |
break;
|
|
1447 |
case HTTPStatus::ENotFound:
|
|
1448 |
aError = KErrNotFound;
|
|
1449 |
break;
|
|
1450 |
|
|
1451 |
case RsfwDavStatus::ELocked:
|
|
1452 |
aError = KErrAccessDenied;
|
|
1453 |
break;
|
|
1454 |
|
|
1455 |
default:
|
|
1456 |
MapError(aError);
|
|
1457 |
break;
|
|
1458 |
}
|
|
1459 |
|
|
1460 |
// Lock operation not successful.
|
|
1461 |
// If we have file info for this let's "reset" relevant parts
|
|
1462 |
// DavFileInfoL may leave if the path is over 255 chars
|
|
1463 |
// that shouldn't happen anymore here as we have already used the path
|
|
1464 |
CRsfwDavFileInfo* davFileInfo = NULL;
|
|
1465 |
TRAPD(err, davFileInfo = iDavAccess->DavFileInfoL(iRemotePathName));
|
|
1466 |
if (!err && davFileInfo)
|
|
1467 |
{
|
|
1468 |
davFileInfo->ResetLockToken();
|
|
1469 |
davFileInfo->SetTimeout(0);
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
DEBUGSTRING(("DAV: Lock err=%d", aError));
|
|
1473 |
iStatus = aError;
|
|
1474 |
iTryCount = 0;
|
|
1475 |
}
|
|
1476 |
|
|
1477 |
if (iTryCount)
|
|
1478 |
{
|
|
1479 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
1480 |
Retry();
|
|
1481 |
}
|
|
1482 |
else
|
|
1483 |
{
|
|
1484 |
iStatus = aError;
|
|
1485 |
iDone = ETrue;
|
|
1486 |
}
|
|
1487 |
}
|
|
1488 |
|
|
1489 |
// CRsfwDavAccessContextRefreshLock
|
|
1490 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
1491 |
// ----------------------------------------------------------------------------
|
|
1492 |
// CRsfwDavAccessContextRefreshLock::NewL
|
|
1493 |
// Two-phased constructor.
|
|
1494 |
// ----------------------------------------------------------------------------
|
|
1495 |
//
|
|
1496 |
CRsfwDavAccessContextRefreshLock* CRsfwDavAccessContextRefreshLock::NewL(
|
|
1497 |
CRsfwDavAccess* aDavAccess,
|
|
1498 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1499 |
const TDesC& aPathName,
|
|
1500 |
const TDesC8* aLockToken,
|
|
1501 |
TUint& aTimeout)
|
|
1502 |
{
|
|
1503 |
CRsfwDavAccessContextRefreshLock* self =
|
|
1504 |
new (ELeave) CRsfwDavAccessContextRefreshLock;
|
|
1505 |
CleanupStack::PushL(self);
|
|
1506 |
self->ConstructL(aDavAccess,
|
|
1507 |
aResponseHandler,
|
|
1508 |
aPathName,
|
|
1509 |
aLockToken,
|
|
1510 |
aTimeout);
|
|
1511 |
CleanupStack::Pop(self);
|
|
1512 |
return self;
|
|
1513 |
}
|
|
1514 |
|
|
1515 |
CRsfwDavAccessContextRefreshLock::~CRsfwDavAccessContextRefreshLock()
|
|
1516 |
{
|
|
1517 |
delete iDavFileInfo;
|
|
1518 |
}
|
|
1519 |
|
|
1520 |
// ----------------------------------------------------------------------------
|
|
1521 |
// CRsfwDavAccessContextRefreshLock::ConstructL
|
|
1522 |
// Symbian 2nd phase constructor can leave.
|
|
1523 |
// ----------------------------------------------------------------------------
|
|
1524 |
//
|
|
1525 |
void CRsfwDavAccessContextRefreshLock::ConstructL(
|
|
1526 |
CRsfwDavAccess* aDavAccess,
|
|
1527 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1528 |
const TDesC& aPathName,
|
|
1529 |
const TDesC8* aLockToken,
|
|
1530 |
TUint& aTimeout)
|
|
1531 |
{
|
|
1532 |
iDavAccess = aDavAccess;
|
|
1533 |
iResponseHandler = aResponseHandler;
|
|
1534 |
iPathName = aPathName;
|
|
1535 |
iLockToken = aLockToken;
|
|
1536 |
iTimeout = &aTimeout;
|
|
1537 |
iTryCount = KCommRetries;
|
|
1538 |
|
|
1539 |
// set remotepathname to null, so that this request cannot be cancelled
|
|
1540 |
// cancellations come from the UI and this is internal to RFE
|
|
1541 |
iRemotePathName = KNullDesC;
|
|
1542 |
}
|
|
1543 |
|
|
1544 |
// ----------------------------------------------------------------------------
|
|
1545 |
// CRsfwDavAccessContextRefreshLock::StartL
|
|
1546 |
// Submit the WebDAV transaction
|
|
1547 |
// ----------------------------------------------------------------------------
|
|
1548 |
//
|
|
1549 |
void CRsfwDavAccessContextRefreshLock::StartL()
|
|
1550 |
{
|
|
1551 |
DEBUGSTRING(("DAV: RefreshLock StartL"));
|
|
1552 |
iWebDavTransaction =
|
|
1553 |
iDavAccess->
|
|
1554 |
WebDavSession()->
|
|
1555 |
RefreshLockL(iPathName,
|
|
1556 |
*iTimeout,
|
|
1557 |
iLockToken,
|
|
1558 |
&iDavFileInfo);
|
|
1559 |
SubmitL();
|
|
1560 |
}
|
|
1561 |
|
|
1562 |
// ----------------------------------------------------------------------------
|
|
1563 |
// CRsfwDavAccessContextRefreshLock::TransactionCompleteL
|
|
1564 |
// Handle a successfully completed transaction
|
|
1565 |
// ----------------------------------------------------------------------------
|
|
1566 |
//
|
|
1567 |
void CRsfwDavAccessContextRefreshLock::TransactionCompleteL()
|
|
1568 |
{
|
|
1569 |
DEBUGSTRING(("DAV: RefreshLock done"));
|
|
1570 |
|
|
1571 |
// The server may have changed the timeout,
|
|
1572 |
*iTimeout = iDavFileInfo->Timeout();
|
|
1573 |
iStatus = KErrNone;
|
|
1574 |
iDone = ETrue;
|
|
1575 |
}
|
|
1576 |
|
|
1577 |
// ----------------------------------------------------------------------------
|
|
1578 |
// CRsfwDavAccessContextRefreshLock::TransactionError
|
|
1579 |
// Handle a transaction fault
|
|
1580 |
// ----------------------------------------------------------------------------
|
|
1581 |
//
|
|
1582 |
void CRsfwDavAccessContextRefreshLock::TransactionError(TInt aError)
|
|
1583 |
{
|
|
1584 |
DEBUGSTRING(("DAV: RefreshLock raw err=%d", aError));
|
|
1585 |
if ((aError == KErrCommsLineFail) ||
|
|
1586 |
// ? (aError == KErrNotReady) ||
|
|
1587 |
(aError == KErrDisconnected))
|
|
1588 |
{
|
|
1589 |
iTryCount--;
|
|
1590 |
}
|
|
1591 |
else
|
|
1592 |
{
|
|
1593 |
// Map XML parser errors to KErrCorrupt
|
|
1594 |
if ((aError <= EXmlFeatureLockedWhileParsing) &&
|
|
1595 |
(aError >= EXmlParserError))
|
|
1596 |
{
|
|
1597 |
aError = EXmlParserError;
|
|
1598 |
}
|
|
1599 |
|
|
1600 |
// Map protocol specific error codes into Symbian error codes
|
|
1601 |
switch (aError)
|
|
1602 |
{
|
|
1603 |
case EXmlParserError:
|
|
1604 |
aError = KErrCorrupt;
|
|
1605 |
break;
|
|
1606 |
case HTTPStatus::ENotFound:
|
|
1607 |
aError = KErrNotFound;
|
|
1608 |
break;
|
|
1609 |
|
|
1610 |
case HTTPStatus::EPreconditionFailed:
|
|
1611 |
aError = KErrArgument;
|
|
1612 |
break;
|
|
1613 |
|
|
1614 |
case RsfwDavStatus::ELocked:
|
|
1615 |
aError = KErrLocked;
|
|
1616 |
break;
|
|
1617 |
|
|
1618 |
default:
|
|
1619 |
MapError(aError);
|
|
1620 |
break;
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
DEBUGSTRING(("DAV: RefreshLock err=%d", aError));
|
|
1624 |
iStatus = aError;
|
|
1625 |
iTryCount = 0;
|
|
1626 |
}
|
|
1627 |
|
|
1628 |
if (iTryCount)
|
|
1629 |
{
|
|
1630 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
1631 |
Retry();
|
|
1632 |
}
|
|
1633 |
else
|
|
1634 |
{
|
|
1635 |
iStatus = aError;
|
|
1636 |
iDone = ETrue;
|
|
1637 |
}
|
|
1638 |
}
|
|
1639 |
|
|
1640 |
// CRsfwDavAccessContextUnlock
|
|
1641 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
1642 |
// ----------------------------------------------------------------------------
|
|
1643 |
// CRsfwDavAccessContextUnlock::NewL
|
|
1644 |
// Two-phased constructor.
|
|
1645 |
// ----------------------------------------------------------------------------
|
|
1646 |
//
|
|
1647 |
CRsfwDavAccessContextUnlock*
|
|
1648 |
CRsfwDavAccessContextUnlock::NewL(CRsfwDavAccess* aDavAccess,
|
|
1649 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1650 |
const TDesC& aPathName,
|
|
1651 |
const TDesC8* aLockToken)
|
|
1652 |
{
|
|
1653 |
CRsfwDavAccessContextUnlock* self = new (ELeave) CRsfwDavAccessContextUnlock;
|
|
1654 |
CleanupStack::PushL(self);
|
|
1655 |
self->ConstructL(aDavAccess,
|
|
1656 |
aResponseHandler,
|
|
1657 |
aPathName,
|
|
1658 |
aLockToken);
|
|
1659 |
CleanupStack::Pop(self);
|
|
1660 |
return self;
|
|
1661 |
}
|
|
1662 |
|
|
1663 |
// ----------------------------------------------------------------------------
|
|
1664 |
// CRsfwDavAccessContextUnlock::ConstructL
|
|
1665 |
// Symbian 2nd phase constructor can leave.
|
|
1666 |
// ----------------------------------------------------------------------------
|
|
1667 |
//
|
|
1668 |
void CRsfwDavAccessContextUnlock::ConstructL(
|
|
1669 |
CRsfwDavAccess* aDavAccess,
|
|
1670 |
MRsfwRemoteAccessResponseHandler* aResponseHandler,
|
|
1671 |
const TDesC& aPathName,
|
|
1672 |
const TDesC8* aLockToken)
|
|
1673 |
{
|
|
1674 |
iDavAccess = aDavAccess;
|
|
1675 |
iResponseHandler = aResponseHandler;
|
|
1676 |
iLockToken = aLockToken;
|
|
1677 |
iTryCount = KCommRetries;
|
|
1678 |
iRemotePathName = aPathName;
|
|
1679 |
}
|
|
1680 |
|
|
1681 |
// ----------------------------------------------------------------------------
|
|
1682 |
// CRsfwDavAccessContextUnlock::StartL
|
|
1683 |
// Submit the WebDAV transaction
|
|
1684 |
// ----------------------------------------------------------------------------
|
|
1685 |
//
|
|
1686 |
void CRsfwDavAccessContextUnlock::StartL()
|
|
1687 |
{
|
|
1688 |
DEBUGSTRING(("DAV: Unlock StartL"));
|
|
1689 |
iWebDavTransaction = iDavAccess->WebDavSession()->UnlockL(iRemotePathName,
|
|
1690 |
iLockToken);
|
|
1691 |
SubmitL();
|
|
1692 |
}
|
|
1693 |
|
|
1694 |
// ----------------------------------------------------------------------------
|
|
1695 |
// CRsfwDavAccessContextUnlock::TransactionCompleteL
|
|
1696 |
// Handle a successfully completed transaction
|
|
1697 |
// ----------------------------------------------------------------------------
|
|
1698 |
//
|
|
1699 |
void CRsfwDavAccessContextUnlock::TransactionCompleteL()
|
|
1700 |
{
|
|
1701 |
DEBUGSTRING(("DAV: Unlock done"));
|
|
1702 |
|
|
1703 |
// Remove the lock
|
|
1704 |
CRsfwDavFileInfo* davFileInfo = iDavAccess->DavFileInfoL(iRemotePathName);
|
|
1705 |
if (davFileInfo)
|
|
1706 |
{
|
|
1707 |
davFileInfo->ResetFlag(TRsfwDavFileInfoFlags::EUnlockPending);
|
|
1708 |
davFileInfo->ResetLockToken();
|
|
1709 |
iDavAccess->RemoveDavFileInfoL(iRemotePathName);
|
|
1710 |
}
|
|
1711 |
|
|
1712 |
iStatus = KErrNone;
|
|
1713 |
iDone = ETrue;
|
|
1714 |
}
|
|
1715 |
|
|
1716 |
// ----------------------------------------------------------------------------
|
|
1717 |
// CRsfwDavAccessContextUnlock::TransactionError
|
|
1718 |
// Handle a transaction fault
|
|
1719 |
// ----------------------------------------------------------------------------
|
|
1720 |
//
|
|
1721 |
void CRsfwDavAccessContextUnlock::TransactionError(TInt aError)
|
|
1722 |
{
|
|
1723 |
DEBUGSTRING(("DAV: Unlock raw err=%d", aError));
|
|
1724 |
|
|
1725 |
// Currently we don't remove the lock token (CRsfwDavFileInfo struct)
|
|
1726 |
// if UNLOCK returns an error for some reason.
|
|
1727 |
// If lock timeouts are smallish, deleting would make sense
|
|
1728 |
// as the lock may have timed out in which case server returns an
|
|
1729 |
// error for UNLOCK and our client might not even care about
|
|
1730 |
// the result of UNLOCK.
|
|
1731 |
// In this case we have a risk of unwanted never-to-be-deleted
|
|
1732 |
// CRsfwDavFileInfos.
|
|
1733 |
// On the other hand,
|
|
1734 |
// if infinite timeout is used, the current behaviour is better
|
|
1735 |
// (if UNLOCK fails for some reason the client must re-try).
|
|
1736 |
|
|
1737 |
// at least remove 'unlock pending' flag
|
|
1738 |
CRsfwDavFileInfo* davFileInfo = NULL;
|
|
1739 |
TRAP_IGNORE(davFileInfo = iDavAccess->DavFileInfoL(iRemotePathName));
|
|
1740 |
|
|
1741 |
if (davFileInfo)
|
|
1742 |
{
|
|
1743 |
davFileInfo->ResetFlag(TRsfwDavFileInfoFlags::EUnlockPending);
|
|
1744 |
}
|
|
1745 |
|
|
1746 |
if ((aError == KErrCommsLineFail) ||
|
|
1747 |
(aError == KErrNotReady) ||
|
|
1748 |
(aError == KErrDisconnected))
|
|
1749 |
{
|
|
1750 |
iTryCount--;
|
|
1751 |
}
|
|
1752 |
else
|
|
1753 |
{
|
|
1754 |
// Map protocol specific error codes into Symbian error codes
|
|
1755 |
MapError(aError);
|
|
1756 |
DEBUGSTRING(("DAV: Unlock err=%d", aError));
|
|
1757 |
iStatus = aError;
|
|
1758 |
iTryCount = 0;
|
|
1759 |
}
|
|
1760 |
|
|
1761 |
if (iTryCount)
|
|
1762 |
{
|
|
1763 |
DEBUGSTRING(("DAV: Retry %d", iTryCount));
|
|
1764 |
Retry();
|
|
1765 |
}
|
|
1766 |
else
|
|
1767 |
{
|
|
1768 |
iStatus = aError;
|
|
1769 |
iDone = ETrue;
|
|
1770 |
}
|
|
1771 |
}
|
|
1772 |
|
|
1773 |
// End of File
|