|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation for meeting request utils command iteration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ---------------------------------------------------------------------------- |
|
21 // INCLUDE FILES |
|
22 // ---------------------------------------------------------------------------- |
|
23 // |
|
24 #include "CMRUtilsCmdIterationAO.h" |
|
25 #include "CMRUtilsCalDbMgr.h" |
|
26 |
|
27 // CONSTANTS |
|
28 /// Unnamed namespace for local definitions |
|
29 namespace { |
|
30 |
|
31 enum TPanicCode |
|
32 { |
|
33 EPanicNonEmptyArrayWhenInactive = 1 |
|
34 }; |
|
35 |
|
36 _LIT( KPanicMsg, "CMRUtilsCmdIterationAO" ); |
|
37 |
|
38 void Panic( TPanicCode aReason ) |
|
39 { |
|
40 User::Panic( KPanicMsg, aReason ); |
|
41 } |
|
42 |
|
43 } // namespace |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // MEMBER FUNCTIONS |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CMRUtilsCmdIterationAO::NewL |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CMRUtilsCmdIterationAO* CMRUtilsCmdIterationAO::NewL( |
|
55 MMRUtilsCalDbMgr& aDbMgr ) |
|
56 { |
|
57 CMRUtilsCmdIterationAO* self = |
|
58 new( ELeave ) CMRUtilsCmdIterationAO( aDbMgr ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop(); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CMRUtilsCmdIterationAO::CMRUtilsCmdIterationAO |
|
67 // |
|
68 // Constructor. |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CMRUtilsCmdIterationAO::CMRUtilsCmdIterationAO( |
|
72 MMRUtilsCalDbMgr& aDbMgr ) |
|
73 : CActive( EPriorityStandard ), |
|
74 iDbMgr( aDbMgr ), |
|
75 iOpCode( CMRUtils::ENoOperation ) |
|
76 { |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CMRUtilsCmdIterationAO::~CMRUtilsCmdIterationAO |
|
81 // |
|
82 // Destructor. |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CMRUtilsCmdIterationAO::~CMRUtilsCmdIterationAO() |
|
86 { |
|
87 Cancel(); |
|
88 iCalEntryArray.Close(); |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // CMRUtilsCmdIterationAO::ConstructL |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 void CMRUtilsCmdIterationAO::ConstructL() |
|
96 { |
|
97 CActiveScheduler::Add( this ); |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------------------------------- |
|
101 // CMRUtilsCmdIterationAO::ConstructL |
|
102 // ---------------------------------------------------------------------------- |
|
103 // |
|
104 void CMRUtilsCmdIterationAO::StartCmdIterationL( |
|
105 const RPointerArray<CCalEntry> aCalEntryArray, |
|
106 TInt aOpCode ) |
|
107 { |
|
108 if ( IsActive() ) |
|
109 { |
|
110 User::Leave( KErrInUse ); |
|
111 } |
|
112 |
|
113 // array must be empty when we are not active: |
|
114 __ASSERT_DEBUG( iCalEntryArray.Count() == 0, |
|
115 Panic( EPanicNonEmptyArrayWhenInactive ) ); |
|
116 |
|
117 |
|
118 TInt count( aCalEntryArray.Count() ); |
|
119 for ( TInt i( 0 ); i < count; ++i ) |
|
120 { |
|
121 iCalEntryArray.AppendL( aCalEntryArray[i] ); |
|
122 } |
|
123 |
|
124 iOpCode = aOpCode; |
|
125 |
|
126 TRequestStatus* status = &iStatus; |
|
127 User::RequestComplete( status, KErrNone ); |
|
128 SetActive(); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CMRUtilsCmdIterationAO::RunL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CMRUtilsCmdIterationAO::RunL() |
|
136 { |
|
137 TInt lastIndex( iCalEntryArray.Count() -1 ); |
|
138 if ( lastIndex < 0 ) |
|
139 { // no more items, we are finished |
|
140 iDbMgr.Completed( KErrNone ); |
|
141 } |
|
142 |
|
143 else |
|
144 { |
|
145 CCalEntry* lastEntry = iCalEntryArray[lastIndex]; |
|
146 |
|
147 switch ( iOpCode ) |
|
148 { |
|
149 case CMRUtils::EDeleteEntries: |
|
150 { |
|
151 iDbMgr.DeleteEntryCondL( *lastEntry ); |
|
152 break; |
|
153 } |
|
154 } |
|
155 |
|
156 // The last entry was handled and can be removed from array: |
|
157 iCalEntryArray.Remove( lastIndex ); |
|
158 delete lastEntry; |
|
159 |
|
160 TRequestStatus* status = &iStatus; |
|
161 User::RequestComplete( status, KErrNone ); |
|
162 SetActive(); |
|
163 } |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CMRUtilsCmdIterationAO::DoCancel |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CMRUtilsCmdIterationAO::DoCancel() |
|
171 { |
|
172 iCalEntryArray.ResetAndDestroy(); |
|
173 iOpCode = CMRUtils::ENoOperation; |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CMRUtilsCmdIterationAO::RunError |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 TInt CMRUtilsCmdIterationAO::RunError( TInt aError ) |
|
181 { |
|
182 iCalEntryArray.ResetAndDestroy(); |
|
183 iDbMgr.Completed( aError ); |
|
184 iOpCode = CMRUtils::ENoOperation; |
|
185 return KErrNone; |
|
186 } |
|
187 |
|
188 // End of file |