1 /* |
|
2 * Copyright (c) 2002-2007 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: Asynchronous FSQ Atom |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <asynchfsq.h> |
|
22 #include <sysutil.h> // for disk space query |
|
23 #include <bautils.h> // for deleting files |
|
24 #include "asynchatom.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CAsynchFSQAtom::CAsynchFSQAtom |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CAsynchFSQAtom::CAsynchFSQAtom() : CActive( EPriorityNormal ) |
|
37 { |
|
38 LOGTEXT( _L( "CAsynchFSQAtom::CAsynchFSQAtom() entering" ) ); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CAsynchFSQAtom::ConstructL |
|
43 // Symbian 2nd phase constructor can leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CAsynchFSQAtom::ConstructL( CAsynchFSQ* aOwner, |
|
47 TInt aPriority, |
|
48 TFSQActionType aActionType, |
|
49 TDesC8& aData, |
|
50 const TDesC& aPath, |
|
51 const TDesC& aURL, |
|
52 TFSQSchemaType aSchema, |
|
53 const TDesC& aUserName, |
|
54 const TDesC& aPassword ) |
|
55 { |
|
56 LOGTEXT( _L( "CAsynchFSQAtom::ConstructL() entering" ) ); |
|
57 iOwner = aOwner; |
|
58 iState = EPending; |
|
59 iDelayedFileName = NULL; |
|
60 SetPriority(aPriority); |
|
61 iSchema = aSchema; |
|
62 |
|
63 // prep to copy |
|
64 iData = NULL; |
|
65 iPath = NULL; |
|
66 iURL = NULL; |
|
67 iUserName = NULL; |
|
68 iPassword = NULL; |
|
69 |
|
70 // copy |
|
71 iActionType = aActionType; |
|
72 |
|
73 iData = &aData; |
|
74 if ( aPath != KNullDesC ) |
|
75 { |
|
76 iPath = HBufC::NewL( aPath.Length() ); |
|
77 iPath->Des().Append( aPath ); |
|
78 } |
|
79 if ( aURL != KNullDesC ) |
|
80 { |
|
81 iURL = HBufC::NewL( aURL.Length() ); |
|
82 iURL->Des().Append( aURL ); |
|
83 } |
|
84 if ( aUserName != KNullDesC ) |
|
85 { |
|
86 iUserName = HBufC::NewL( aUserName.Length() ); |
|
87 iUserName->Des().Append( aUserName ); |
|
88 } |
|
89 if ( aPassword != KNullDesC ) |
|
90 { |
|
91 iPassword = HBufC::NewL( aPassword.Length() ); |
|
92 iPassword->Des().Append( aPassword ); |
|
93 } |
|
94 |
|
95 LOGTEXT( _L( "CAsynchFSQAtom::ConstructL() adding AO" ) ); |
|
96 CActiveScheduler::Add( this ); |
|
97 LOGTEXT( _L( "CAsynchFSQAtom::ConstructL() exiting" ) ); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CAsynchFSQAtom::NewL |
|
102 // Two-phased constructor. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CAsynchFSQAtom* CAsynchFSQAtom::NewL( CAsynchFSQ* aOwner, |
|
106 TInt aPriority, |
|
107 TFSQActionType aActionType, |
|
108 TDesC8& aData, |
|
109 const TDesC& aPath, |
|
110 const TDesC& aURL, |
|
111 TFSQSchemaType aSchema, |
|
112 const TDesC& aUserName, |
|
113 const TDesC& aPassword ) |
|
114 { |
|
115 LOGTEXT( _L( "CAsynchFSQAtom::NewL() entering" ) ); |
|
116 CAsynchFSQAtom* self = new( ELeave ) CAsynchFSQAtom(); |
|
117 CleanupStack::PushL( self ); |
|
118 self->ConstructL( aOwner, |
|
119 aPriority, |
|
120 aActionType, |
|
121 aData, |
|
122 aPath, |
|
123 aURL, |
|
124 aSchema, |
|
125 aUserName, |
|
126 aPassword ); |
|
127 |
|
128 CleanupStack::Pop(); |
|
129 return self; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CAsynchFSQAtom::~CAsynchFSQAtom |
|
134 // Destructor for the atom class |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 CAsynchFSQAtom::~CAsynchFSQAtom() |
|
138 { |
|
139 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() entering" ) ); |
|
140 |
|
141 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() canceling" ) ); |
|
142 Cancel(); |
|
143 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() canceled" ) ); |
|
144 |
|
145 // Close file |
|
146 iFile.Close(); |
|
147 |
|
148 // Close file system |
|
149 iFs.Close(); |
|
150 |
|
151 // Free leftover data |
|
152 if( iData ) |
|
153 { |
|
154 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() deleting iData" ) ); |
|
155 delete iData; |
|
156 iData = NULL; |
|
157 } |
|
158 |
|
159 if( iPath ) |
|
160 { |
|
161 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() deleting iPath" ) ); |
|
162 delete iPath; |
|
163 iPath = NULL; |
|
164 } |
|
165 |
|
166 if( iURL ) |
|
167 { |
|
168 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() deleting iURL" ) ); |
|
169 delete iURL; |
|
170 iURL = NULL; |
|
171 } |
|
172 |
|
173 if( iUserName ) |
|
174 { |
|
175 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() deleting iUserName" ) ); |
|
176 delete iUserName; |
|
177 iUserName = NULL; |
|
178 } |
|
179 |
|
180 if( iPassword ) |
|
181 { |
|
182 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() deleting iPassword" ) ); |
|
183 delete iPassword; |
|
184 iPassword = NULL; |
|
185 } |
|
186 |
|
187 if( iDelayedFileName ) |
|
188 { |
|
189 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() deleting iDelayedFileName" ) ); |
|
190 delete iDelayedFileName; |
|
191 iPassword = NULL; |
|
192 } |
|
193 |
|
194 LOGTEXT( _L( "CAsynchFSQAtom::~CAsynchFSQAtom() exiting" ) ); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CAsynchFSQAtom::Go |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 TInt CAsynchFSQAtom::Go() |
|
202 { |
|
203 LOGTEXT( _L( "CAsynchFSQAtom::Go() entering" ) ); |
|
204 TInt err = KErrNone; |
|
205 |
|
206 if (( iState != EPending )||( IsActive() )) |
|
207 { |
|
208 err = KErrInUse; |
|
209 } |
|
210 else |
|
211 { |
|
212 // set new state |
|
213 switch ( iActionType ) |
|
214 { |
|
215 case EFileSave: |
|
216 case EFileSaveAndWebUpload: |
|
217 { |
|
218 LOGTEXT( _L( "CAsynchFSQAtom::Go() iState => ESaving" ) ); |
|
219 iState = ESaving; |
|
220 break; |
|
221 } |
|
222 case EWebUpload: |
|
223 { |
|
224 LOGTEXT( _L( "CAsynchFSQAtom::Go() iState => EUploading" ) ); |
|
225 iState = EUploading; |
|
226 break; |
|
227 } |
|
228 default: |
|
229 { |
|
230 LOGTEXT( _L( "CAsynchFSQAtom::Go() undefined activity requested" ) ); |
|
231 err = KErrNotSupported; |
|
232 break; |
|
233 } |
|
234 } |
|
235 |
|
236 // initiate AO activity |
|
237 LOGTEXT( _L( "CAsynchFSQAtom::Go() setting active" ) ); |
|
238 SetActive(); |
|
239 TRequestStatus* statusPtr = &iStatus; |
|
240 User::RequestComplete( statusPtr, KErrNone ); |
|
241 LOGTEXT( _L( "CAsynchFSQAtom::Go() request completed" ) ); |
|
242 } |
|
243 |
|
244 LOGTEXT( _L( "CAsynchFSQAtom::Go() returning" ) ); |
|
245 return err; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CAsynchFSQAtom::GetState |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TFSQAtomState CAsynchFSQAtom::GetState() |
|
253 { |
|
254 LOGTEXT( _L( "CAsynchFSQAtom::GetState() entering & returning" ) ); |
|
255 return iState; |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CAsynchFSQAtom::DoesLocalSave |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 TBool CAsynchFSQAtom::DoesLocalSave() |
|
263 { |
|
264 LOGTEXT( _L( "CAsynchFSQAtom::DoesLocalSave() entering" ) ); |
|
265 TBool ret = EFalse; |
|
266 if (( iActionType == EFileSave )||( iActionType == EFileSaveAndWebUpload )) |
|
267 { |
|
268 ret = ETrue; |
|
269 } |
|
270 LOGTEXT2( _L( "CAsynchFSQAtom::DoesLocalSave() returning, ret=%d" ),ret ); |
|
271 return ret; |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CAsynchFSQAtom::GetPath |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 const TDesC& CAsynchFSQAtom::GetPath() const |
|
279 { |
|
280 LOGTEXT( _L( "CAsynchFSQAtom::GetPath() entering & returning" ) ); |
|
281 return *iPath; |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CAsynchFSQAtom::DeleteLocal |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CAsynchFSQAtom::DeleteLocal() |
|
289 { |
|
290 LOGTEXT( _L( "CAsynchFSQAtom::DeleteLocal() entering" ) ); |
|
291 TInt err = KErrNone; |
|
292 |
|
293 // delete or delayed delete |
|
294 if (( iState == EPending ) || ( iState == ESaving )||( iState == ESavePending )) |
|
295 { |
|
296 LOGTEXT( _L( "CAsynchFSQAtom::DeleteLocal() delayed delete" ) ); |
|
297 // we are currently saving, so we have to delete later |
|
298 iDelayedLocalDelete = ETrue; |
|
299 } |
|
300 else |
|
301 { |
|
302 LOGTEXT( _L( "CAsynchFSQAtom::DeleteLocal() deleting now" ) ); |
|
303 // delete now |
|
304 err = KErrNotFound; |
|
305 RFs fs; |
|
306 TInt connectError = fs.Connect(); |
|
307 BaflUtils ba; |
|
308 if( !connectError && ba.FileExists( fs, *iPath ) ) |
|
309 { |
|
310 err = KErrNone; |
|
311 ba.DeleteFile( fs, *iPath ); |
|
312 } |
|
313 fs.Close(); |
|
314 } |
|
315 |
|
316 LOGTEXT2( _L( "CAsynchFSQAtom::DeleteLocal() returning, err=%d" ),err ); |
|
317 return err; |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CAsynchFSQAtom::RenameLocal |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 TInt CAsynchFSQAtom::RenameLocal( const TDesC& aNew ) |
|
325 { |
|
326 LOGTEXT( _L( "CAsynchFSQAtom::RenameLocal() entering" ) ); |
|
327 TInt err = KErrNone; |
|
328 |
|
329 // delete or delayed delete |
|
330 if (( iState == EPending ) || ( iState == ESaving )||( iState == ESavePending )) |
|
331 { |
|
332 LOGTEXT( _L( "CAsynchFSQAtom::RenameLocal() delayed rename" ) ); |
|
333 // we are currently saving, so we have to delete later |
|
334 iDelayedLocalRename = ETrue; |
|
335 TRAP( err, |
|
336 iDelayedFileName = HBufC::NewL( aNew.Length() ); |
|
337 iDelayedFileName->Des().Append( aNew ); |
|
338 ); |
|
339 } |
|
340 else |
|
341 { |
|
342 LOGTEXT( _L( "CAsynchFSQAtom::RenameLocal() renaming now" ) ); |
|
343 err = KErrNotFound; |
|
344 RFs fs; |
|
345 TInt connectError = fs.Connect(); |
|
346 BaflUtils ba; |
|
347 if( !connectError && ba.FileExists( fs, *iPath ) ) |
|
348 { |
|
349 err = KErrNone; |
|
350 ba.RenameFile( fs, *iPath, aNew ); |
|
351 } |
|
352 fs.Close(); |
|
353 } |
|
354 |
|
355 LOGTEXT2( _L( "CAsynchFSQAtom::RenameLocal() returning, err=%d" ),err ); |
|
356 return err; |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CAsynchFSQAtom::SaveL |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 void CAsynchFSQAtom::SaveL() |
|
364 { |
|
365 LOGTEXT( _L( "CAsynchFSQAtom::SaveL() entering" ) ); |
|
366 iError = KErrNone; |
|
367 |
|
368 if ( iState != ESaving ) |
|
369 { |
|
370 // the state machine is lost |
|
371 LOGTEXT( _L( "CAsynchFSQAtom::SaveL() bad state, leaving..." ) ); |
|
372 User::Leave( KErrGeneral ); |
|
373 } |
|
374 |
|
375 // Init |
|
376 iError = iFs.Connect(); |
|
377 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() fsSession.Connect iError=%d" ),iError ); |
|
378 |
|
379 // Get drive number |
|
380 TInt drive = 0; |
|
381 if( !iError ) |
|
382 { |
|
383 iError = RFs::CharToDrive( iPath->Des()[0], drive ); |
|
384 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() CharToDrive iError=%d" ),iError ); |
|
385 } |
|
386 |
|
387 // Check disk space |
|
388 if ( !iError ) |
|
389 { |
|
390 TBool fullDisk = EFalse; |
|
391 TRAPD( utilErr, |
|
392 fullDisk = SysUtil::DiskSpaceBelowCriticalLevelL( |
|
393 &iFs, iData->Length(), drive ) ); |
|
394 if( utilErr ) |
|
395 { |
|
396 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() SysUtil iError=%d" ),iError ); |
|
397 iError = utilErr; |
|
398 } |
|
399 else if( fullDisk ) |
|
400 { |
|
401 iError = KErrDiskFull; |
|
402 } |
|
403 } |
|
404 |
|
405 // Attempt to create the file |
|
406 if( !iError ) |
|
407 { |
|
408 if ( iOverwrite ) |
|
409 { |
|
410 iError = iFile.Replace( iFs, iPath->Des(), EFileWrite ); |
|
411 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() file.Replace iError=%d" ),iError ); |
|
412 } |
|
413 else |
|
414 { |
|
415 iError = iFile.Create( iFs, iPath->Des(), EFileWrite ); |
|
416 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() file.Open iError=%d" ),iError ); |
|
417 } |
|
418 } |
|
419 |
|
420 // Write the file |
|
421 if( !iError ) |
|
422 { |
|
423 LOGTEXT( _L( "CAsynchFSQAtom::SaveL() about to write" ) ); |
|
424 SetActive(); |
|
425 iFile.Write( *iData, iStatus ); |
|
426 LOGTEXT( _L( "CAsynchFSQAtom::SaveL() write requested" ) ); |
|
427 } |
|
428 |
|
429 // Update state |
|
430 LOGTEXT( _L( "CAsynchFSQAtom::SaveL() iState => ESavePending" ) ); |
|
431 iState = ESavePending; |
|
432 |
|
433 // leave if error |
|
434 if ( iError ) |
|
435 { |
|
436 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() Leaving with iError=%d" ),iError ); |
|
437 User::Leave( iError ); |
|
438 } |
|
439 |
|
440 LOGTEXT2( _L( "CAsynchFSQAtom::SaveL() exiting, iError=%d" ), iError ); |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // CAsynchFSQAtom::SaveCleanupL |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 void CAsynchFSQAtom::SaveCleanupL() |
|
448 { |
|
449 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() entering" ) ); |
|
450 |
|
451 if ( iState != ESavePending ) |
|
452 { |
|
453 // the state machine is lost |
|
454 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() bad state, leaving..." ) ); |
|
455 User::Leave( KErrGeneral ); |
|
456 } |
|
457 |
|
458 // Flush file. |
|
459 if( !iError ) |
|
460 { |
|
461 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() flushing" ) ); |
|
462 iError = iFile.Flush(); |
|
463 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() flushed" ) ); |
|
464 } |
|
465 |
|
466 // Close file |
|
467 iFile.Close(); |
|
468 |
|
469 // Delayed rename, if needed |
|
470 if (( !iError ) && ( iDelayedLocalRename )) |
|
471 { |
|
472 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() doing delayed rename" ) ); |
|
473 BaflUtils ba; |
|
474 if( ba.FileExists( iFs, *iPath ) ) |
|
475 { |
|
476 iError = KErrNone; |
|
477 TPtrC newPath = *iDelayedFileName; |
|
478 ba.RenameFile( iFs, *iPath, newPath ); |
|
479 } |
|
480 iDelayedLocalRename = EFalse; |
|
481 } |
|
482 |
|
483 // Delayed delete, if needed |
|
484 if (( !iError ) && ( iDelayedLocalDelete )) |
|
485 { |
|
486 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() doing delayed delete" ) ); |
|
487 iError = KErrNotFound; |
|
488 BaflUtils ba; |
|
489 if( ba.FileExists( iFs, *iPath ) ) |
|
490 { |
|
491 iError = KErrNone; |
|
492 ba.DeleteFile( iFs, *iPath ); |
|
493 } |
|
494 iDelayedLocalDelete = EFalse; |
|
495 LOGTEXT2( _L( "CAsynchFSQAtom::SaveCleanupL() delete done, iError=%d" ), iError ); |
|
496 } |
|
497 |
|
498 // Close file system |
|
499 iFs.Close(); |
|
500 |
|
501 // Update state |
|
502 switch ( iActionType ) |
|
503 { |
|
504 case EFileSave: |
|
505 { |
|
506 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() iState => EComplete" ) ); |
|
507 iState = EComplete; |
|
508 break; |
|
509 } |
|
510 case EFileSaveAndWebUpload: |
|
511 { |
|
512 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() iState => EUploading" ) ); |
|
513 iState = EUploading; |
|
514 |
|
515 // re-initiate AO activity |
|
516 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() setting active" ) ); |
|
517 SetActive(); |
|
518 TRequestStatus* statusPtr = &iStatus; |
|
519 User::RequestComplete( statusPtr, KErrNone ); |
|
520 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() request completed" ) ); |
|
521 break; |
|
522 } |
|
523 default: |
|
524 { |
|
525 // the state machine is lost |
|
526 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() bad action, leaving" ) ); |
|
527 User::Leave( KErrGeneral ); |
|
528 break; |
|
529 } |
|
530 } |
|
531 |
|
532 // report completion |
|
533 LOGTEXT2( _L( "CAsynchFSQAtom::SaveCleanupL() notifying, iError=%d" ), iError ); |
|
534 iOwner->Notify( iError ); |
|
535 |
|
536 LOGTEXT( _L( "CAsynchFSQAtom::SaveCleanupL() exiting" )); |
|
537 } |
|
538 |
|
539 // ----------------------------------------------------------------------------- |
|
540 // CAsynchFSQAtom::UploadL |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 void CAsynchFSQAtom::UploadL() |
|
544 { |
|
545 LOGTEXT( _L( "CAsynchFSQAtom::UploadL() entering" ) ); |
|
546 iError = KErrNone; |
|
547 |
|
548 if ( iState != EUploading ) |
|
549 { |
|
550 // the state machine is lost |
|
551 LOGTEXT( _L( "CAsynchFSQAtom::UploadL() bad state, leaving..." ) ); |
|
552 User::Leave( KErrGeneral ); |
|
553 } |
|
554 |
|
555 // This activity is not yet supported, so just feign completion |
|
556 LOGTEXT( _L( "CAsynchFSQAtom::UploadL() iState => EComplete" ) ); |
|
557 iState = EUploadPending; |
|
558 |
|
559 // re-initiate AO activity |
|
560 LOGTEXT( _L( "CAsynchFSQAtom::UploadL() setting active" ) ); |
|
561 SetActive(); |
|
562 TRequestStatus* statusPtr = &iStatus; |
|
563 User::RequestComplete( statusPtr, KErrNone ); |
|
564 LOGTEXT( _L( "CAsynchFSQAtom::UploadL() request completed" ) ); |
|
565 |
|
566 LOGTEXT( _L( "CAsynchFSQAtom::UploadL() exiting" ) ); |
|
567 } |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CAsynchFSQAtom::UploadCleanup |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 void CAsynchFSQAtom::UploadCleanupL() |
|
574 { |
|
575 LOGTEXT( _L( "CAsynchFSQAtom::UploadCleanupL() entering" ) ); |
|
576 |
|
577 if ( iState != ESaving ) |
|
578 { |
|
579 // the state machine is lost |
|
580 LOGTEXT( _L( "CAsynchFSQAtom::UploadCleanupL() bad state, leaving..." ) ); |
|
581 User::Leave( KErrGeneral ); |
|
582 } |
|
583 |
|
584 // This activity is not yet supported, so just feign completion |
|
585 LOGTEXT( _L( "CAsynchFSQAtom::UploadCleanupL() iState => EComplete" ) ); |
|
586 iState = EComplete; |
|
587 |
|
588 // report completion |
|
589 LOGTEXT2( _L( "CAsynchFSQAtom::UploadCleanupL() notifying, iError=%d" ), iError ); |
|
590 iOwner->Notify( iError ); |
|
591 |
|
592 LOGTEXT( _L( "CAsynchFSQAtom::UploadCleanupL() exiting" ) ); |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CAsynchFSQAtom::ActionsLeft |
|
597 // ----------------------------------------------------------------------------- |
|
598 // |
|
599 TInt CAsynchFSQAtom::ActionsLeft() |
|
600 { |
|
601 TInt actionsLeft = 0; |
|
602 |
|
603 // logically, this section is liable to change if more |
|
604 // action types are added to the class |
|
605 switch ( iState ) |
|
606 { |
|
607 case EPending: |
|
608 { |
|
609 if ( iActionType == EFileSaveAndWebUpload ) |
|
610 { |
|
611 actionsLeft = 2; |
|
612 } |
|
613 else |
|
614 { |
|
615 actionsLeft = 1; |
|
616 } |
|
617 break; |
|
618 } |
|
619 case ESaving: |
|
620 case ESavePending: |
|
621 { |
|
622 if ( iActionType == EFileSave ) |
|
623 { |
|
624 actionsLeft = 1; |
|
625 } |
|
626 else |
|
627 { |
|
628 actionsLeft = 2; |
|
629 } |
|
630 break; |
|
631 } |
|
632 case EUploading: |
|
633 case EUploadPending: |
|
634 { |
|
635 actionsLeft = 1; |
|
636 break; |
|
637 } |
|
638 case EComplete: |
|
639 { |
|
640 actionsLeft = 0; |
|
641 break; |
|
642 } |
|
643 } |
|
644 |
|
645 LOGTEXT2( _L( "CAsynchFSQAtom::ActionsLeft() returning, actionsLeft=%d" ), actionsLeft ); |
|
646 return actionsLeft; |
|
647 } |
|
648 |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // CAsynchFSQAtom::RunL |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 void CAsynchFSQAtom::RunL() |
|
655 { |
|
656 LOGTEXT( _L( "CAsynchFSQAtom::RunL() entering" ) ); |
|
657 |
|
658 switch ( iState ) |
|
659 { |
|
660 case ESaving: |
|
661 { |
|
662 SaveL(); |
|
663 break; |
|
664 } |
|
665 case ESavePending: |
|
666 { |
|
667 SaveCleanupL(); |
|
668 break; |
|
669 } |
|
670 case EUploading: |
|
671 { |
|
672 UploadL(); |
|
673 break; |
|
674 } |
|
675 case EUploadPending: |
|
676 { |
|
677 UploadCleanupL(); |
|
678 break; |
|
679 } |
|
680 default: |
|
681 { |
|
682 // the state machine is lost |
|
683 LOGTEXT( _L( "CAsynchFSQAtom::RunL() bad state, leaving..." ) ); |
|
684 User::Leave( KErrGeneral ); |
|
685 break; |
|
686 } |
|
687 } |
|
688 |
|
689 LOGTEXT( _L( "CAsynchFSQAtom::RunL() exiting" ) ); |
|
690 } |
|
691 |
|
692 // ----------------------------------------------------------------------------- |
|
693 // CAsynchFSQAtom::RunError |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 TInt CAsynchFSQAtom::RunError( TInt aError ) |
|
697 { |
|
698 LOGTEXT2( _L( "CAsynchFSQAtom::RunError() entering, aError=%d" ), aError ); |
|
699 // notify and wait for teardown |
|
700 iState = EComplete; |
|
701 iOwner->Notify( aError ); |
|
702 LOGTEXT( _L( "CAsynchFSQAtom::RunError() returning" ) ); |
|
703 return KErrNone; |
|
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CAsynchFSQAtom::DoCancel |
|
708 // ----------------------------------------------------------------------------- |
|
709 // |
|
710 void CAsynchFSQAtom::DoCancel() |
|
711 { |
|
712 LOGTEXT( _L( "CAsynchFSQAtom::DoCancel() entering" ) ); |
|
713 |
|
714 LOGTEXT( _L( "CAsynchFSQAtom::DoCancel() exit" ) ); |
|
715 } |
|
716 |
|
717 |
|
718 // End of File |
|