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