|
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 #include <e32base.h> |
|
17 |
|
18 #include "MSVCMBSE.H" |
|
19 #include "MSVPANIC.H" |
|
20 |
|
21 //********************************** |
|
22 // CMsvCopyMoveEntriesBase |
|
23 //********************************** |
|
24 |
|
25 |
|
26 CMsvCopyMoveEntriesBase::CMsvCopyMoveEntriesBase() |
|
27 : CActive(EPriorityStandard) |
|
28 // |
|
29 // |
|
30 // |
|
31 {} |
|
32 |
|
33 |
|
34 CMsvCopyMoveEntriesBase::~CMsvCopyMoveEntriesBase() |
|
35 // |
|
36 // |
|
37 // |
|
38 { |
|
39 Cancel(); |
|
40 |
|
41 delete iFailedIds; |
|
42 delete iCompletedIds; |
|
43 } |
|
44 |
|
45 |
|
46 void CMsvCopyMoveEntriesBase::ConstructL() |
|
47 // |
|
48 // |
|
49 // |
|
50 { |
|
51 iFailedIds = new(ELeave) CMsvEntrySelection; |
|
52 iCompletedIds = new(ELeave) CMsvEntrySelection; |
|
53 |
|
54 CActiveScheduler::Add(this); |
|
55 } |
|
56 |
|
57 void CMsvCopyMoveEntriesBase::StartL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TRequestStatus& aObserverStatus) |
|
58 // |
|
59 // |
|
60 // |
|
61 { |
|
62 __ASSERT_DEBUG(aSelection.Count() > 0, PanicServer(EMsvEmptySelection)); |
|
63 |
|
64 iCompletedIds->Reset(); |
|
65 iCompletedIds->SetReserveL(aSelection.Count()); |
|
66 |
|
67 iFailedIds->Reset(); |
|
68 iFailedIds->AppendL(aSelection.Back(0), aSelection.Count()); |
|
69 |
|
70 iCurrentIndex = iFailedIds->Count(); |
|
71 iError = KErrNone; |
|
72 |
|
73 iTargetId = aTargetId; |
|
74 |
|
75 if (!StartNext()) |
|
76 { |
|
77 __ASSERT_DEBUG(iError, PanicServer(EMsvNoErrorSet)); |
|
78 User::Leave(iError); |
|
79 } |
|
80 |
|
81 iObserverStatus = &aObserverStatus; |
|
82 *iObserverStatus = KRequestPending; |
|
83 } |
|
84 |
|
85 void CMsvCopyMoveEntriesBase::RunL() |
|
86 // |
|
87 // |
|
88 // |
|
89 { |
|
90 if (iStatus != KErrNone) |
|
91 { |
|
92 if (iError == KErrNone) |
|
93 iError = iStatus.Int(); |
|
94 } |
|
95 else |
|
96 { |
|
97 iCompletedIds->AppendL(iFailedIds->At(iCurrentIndex)); |
|
98 iFailedIds->Delete(iCurrentIndex); |
|
99 } |
|
100 |
|
101 if (!StartNext()) |
|
102 User::RequestComplete(iObserverStatus, iError); |
|
103 } |
|
104 |
|
105 TBool CMsvCopyMoveEntriesBase::StartNext() |
|
106 { |
|
107 while(iCurrentIndex > 0) |
|
108 { |
|
109 TRAPD(error, DoStartNextL()); |
|
110 if (error) |
|
111 { |
|
112 if (iError == KErrNone) |
|
113 iError = error; |
|
114 } |
|
115 else |
|
116 return ETrue; |
|
117 } |
|
118 |
|
119 return EFalse; |
|
120 } |
|
121 |
|
122 void CMsvCopyMoveEntriesBase::DoStartNextL() |
|
123 { |
|
124 __ASSERT_DEBUG(iCurrentIndex > 0, PanicServer(EMsvInvalidCurrentIndex)); |
|
125 |
|
126 iCurrentIndex--; |
|
127 DoStartL(iFailedIds->At(iCurrentIndex), iTargetId, iStatus); |
|
128 SetActive(); |
|
129 } |