|
1 /* |
|
2 * Copyright (c) 2006 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: MFSMailIterator implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <e32std.h> |
|
21 |
|
22 #include "baseplugincommonutils.h" |
|
23 #include "MailIterator.h" |
|
24 |
|
25 |
|
26 /** |
|
27 * |
|
28 */ |
|
29 HMailIterator::HMailIterator( |
|
30 CBasePlugin& aPlugin, |
|
31 CMsgStoreSortResultIterator* aIter, |
|
32 TFSMailMsgId aMailBox ) |
|
33 : iIter( aIter ), iPlugin( aPlugin ), iMailBox( aMailBox ) |
|
34 |
|
35 { |
|
36 __LOG_CONSTRUCT( "baseplugin", "HMailIterator" ) |
|
37 } |
|
38 |
|
39 |
|
40 /** |
|
41 * |
|
42 */ |
|
43 /*virtual*/ HMailIterator::~HMailIterator() |
|
44 { |
|
45 delete iIter; |
|
46 __LOG_DESTRUCT |
|
47 } |
|
48 |
|
49 |
|
50 /** |
|
51 * |
|
52 */ |
|
53 TBool HMailIterator::NextL( |
|
54 TFSMailMsgId aCurrentMessageId, |
|
55 TUint aCount, |
|
56 RPointerArray<CFSMailMessage>& aMessages ) |
|
57 |
|
58 { |
|
59 return DoNextL( &aCurrentMessageId, NULL, aCount, aMessages ); |
|
60 }; |
|
61 |
|
62 /** |
|
63 * |
|
64 */ |
|
65 TBool HMailIterator::NextL( |
|
66 const TDesC& aStartWith, |
|
67 TUint aCount, |
|
68 RPointerArray<CFSMailMessage>& aMessages ) |
|
69 |
|
70 { |
|
71 return DoNextL( NULL, &aStartWith, aCount, aMessages ); |
|
72 }; |
|
73 |
|
74 /** |
|
75 * |
|
76 */ |
|
77 TBool HMailIterator::PreviousL( |
|
78 TFSMailMsgId aCurrentMessageId, |
|
79 TUint aCount, |
|
80 RPointerArray<CFSMailMessage>& aMessages ) |
|
81 |
|
82 { |
|
83 return DoPreviousL( &aCurrentMessageId, NULL, aCount, aMessages ); |
|
84 }; |
|
85 |
|
86 /** |
|
87 * |
|
88 */ |
|
89 TBool HMailIterator::PreviousL( |
|
90 const TDesC& aStartWith, |
|
91 TUint aCount, |
|
92 RPointerArray<CFSMailMessage>& aMessages ) |
|
93 |
|
94 { |
|
95 return DoPreviousL( NULL, &aStartWith, aCount, aMessages ); |
|
96 }; |
|
97 |
|
98 |
|
99 #pragma mark - |
|
100 #pragma mark PRIVATE METHODS |
|
101 |
|
102 |
|
103 /** |
|
104 * |
|
105 */ |
|
106 TBool HMailIterator::DoNextL( |
|
107 TFSMailMsgId* /*ref*/ aCurrentMessageId, |
|
108 const TDesC* /*ref*/ aStartWith, |
|
109 TUint aCount, |
|
110 RPointerArray<CFSMailMessage>& aMessages ) |
|
111 |
|
112 { |
|
113 __LOG_ENTER( "DoNextL" ) |
|
114 |
|
115 RPointerArray<CMsgStorePropertyContainer> msMsgs; |
|
116 CleanupResetAndDestroyClosePushL( msMsgs ); |
|
117 |
|
118 TBool result = |
|
119 NULL == aStartWith |
|
120 ? iIter->NextL( (*aCurrentMessageId).Id(), aCount, msMsgs ) |
|
121 : iIter->NextL( *aStartWith, aCount, msMsgs ); |
|
122 |
|
123 __LOG_WRITE8_FORMAT1_INFO( "MsgStore's NextL returned %d messages.", msMsgs.Count() ) |
|
124 |
|
125 for ( TInt i = 0; i < msMsgs.Count(); i++ ) |
|
126 { |
|
127 CFSMailMessage* fsMsg = CFSMailMessage::NewLC( |
|
128 TFSMailMsgId( iPlugin.GetPluginId(), msMsgs[i]->Id() ) ); |
|
129 |
|
130 fsMsg->SetMailBoxId( iMailBox ); |
|
131 fsMsg->SetContentType( KNullDesC() ); |
|
132 fsMsg->SetContentDescription( KNullDesC() ); |
|
133 fsMsg->SetContentDisposition( KNullDesC() ); |
|
134 |
|
135 iPlugin.TranslateMsgStorePropsL( iMailBox, *msMsgs[i], *fsMsg ); |
|
136 |
|
137 aMessages.Append( fsMsg ); |
|
138 CleanupStack::Pop( fsMsg ); |
|
139 } |
|
140 |
|
141 CleanupStack::PopAndDestroy( &msMsgs ); |
|
142 __LOG_EXIT |
|
143 return result; |
|
144 } |
|
145 |
|
146 |
|
147 /** |
|
148 * |
|
149 */ |
|
150 TBool HMailIterator::DoPreviousL( |
|
151 TFSMailMsgId* /*ref*/ aCurrentMessageId, |
|
152 const TDesC* /*ref*/ aStartWith, |
|
153 TUint aCount, |
|
154 RPointerArray<CFSMailMessage>& aMessages ) |
|
155 |
|
156 { |
|
157 __LOG_ENTER( "DoPreviousL" ) |
|
158 |
|
159 RPointerArray<CMsgStorePropertyContainer> msMsgs; |
|
160 CleanupResetAndDestroyClosePushL( msMsgs ); |
|
161 |
|
162 TBool result; |
|
163 if ( NULL != aCurrentMessageId ) |
|
164 { |
|
165 TMsgStoreId id = ( 0 == aCurrentMessageId->Id() |
|
166 ? KMsgStoreSortResultBottom : aCurrentMessageId->Id() ); |
|
167 |
|
168 result = iIter->PreviousL( id, aCount, msMsgs ); |
|
169 } |
|
170 else |
|
171 { |
|
172 result = iIter->PreviousL( *aStartWith, aCount, msMsgs ); |
|
173 } |
|
174 |
|
175 for ( TInt i = 0; i < msMsgs.Count(); i++ ) |
|
176 { |
|
177 CFSMailMessage* fsMsg = CFSMailMessage::NewLC( |
|
178 TFSMailMsgId( iPlugin.GetPluginId(), msMsgs[i]->Id() ) ); |
|
179 |
|
180 fsMsg->SetMailBoxId( iMailBox ); |
|
181 fsMsg->SetContentType( KNullDesC() ); |
|
182 fsMsg->SetContentDescription( KNullDesC() ); |
|
183 fsMsg->SetContentDisposition( KNullDesC() ); |
|
184 |
|
185 iPlugin.TranslateMsgStorePropsL( iMailBox, *msMsgs[i], *fsMsg ); |
|
186 |
|
187 aMessages.Append( fsMsg ); |
|
188 CleanupStack::Pop( fsMsg ); |
|
189 } |
|
190 |
|
191 CleanupStack::PopAndDestroy( &msMsgs ); |
|
192 __LOG_EXIT |
|
193 return result; |
|
194 } |