|
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: Message store sort result iterator client implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "MsgStoreSortResultIterator.h" |
|
21 #include "MsgStoreSessionContext.h" |
|
22 #include "MsgStorePropertyContainersArray.h" |
|
23 |
|
24 // ---------------------------------- |
|
25 // CMsgStoreSortResultIterator |
|
26 // ---------------------------------- |
|
27 |
|
28 // ========================================================================== |
|
29 // FUNCTION: NewL |
|
30 // ========================================================================== |
|
31 CMsgStoreSortResultIterator* CMsgStoreSortResultIterator::NewL( CMsgStoreSessionContext& aContext, |
|
32 TMsgStoreId aSortSessionId ) |
|
33 { |
|
34 CMsgStoreSortResultIterator* self = new( ELeave) CMsgStoreSortResultIterator( aContext, aSortSessionId ); |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // ========================================================================== |
|
42 // FUNCTION: Constructor |
|
43 // ========================================================================== |
|
44 CMsgStoreSortResultIterator::CMsgStoreSortResultIterator( CMsgStoreSessionContext& aContext, |
|
45 TMsgStoreId aSortSessionId ) |
|
46 : iContext( aContext ), iSortSessionId( aSortSessionId ) |
|
47 { |
|
48 } |
|
49 |
|
50 // ========================================================================== |
|
51 // FUNCTION: ConstructL |
|
52 // ========================================================================== |
|
53 void CMsgStoreSortResultIterator::ConstructL() |
|
54 { |
|
55 } |
|
56 |
|
57 // ========================================================================== |
|
58 // FUNCTION: Destructor |
|
59 // ========================================================================== |
|
60 CMsgStoreSortResultIterator::~CMsgStoreSortResultIterator() |
|
61 { |
|
62 //close the sort session |
|
63 TRAP_IGNORE( iContext.iSession.EndSortL( iSortSessionId ) ); |
|
64 } |
|
65 |
|
66 // ========================================================================== |
|
67 // FUNCTION: NextL |
|
68 // ========================================================================== |
|
69 EXPORT_C TBool CMsgStoreSortResultIterator::NextL( TMsgStoreId aCurrentMessageId, |
|
70 TUint aCount, |
|
71 RPointerArray<CMsgStorePropertyContainer>& aProperties ) |
|
72 { |
|
73 TMsgStorePropertyContainersArray containersArray( aProperties ); |
|
74 |
|
75 return iContext.iSession.GetSortedRowsL( iSortSessionId, aCurrentMessageId, EMsgStoreIteratorForward, aCount, containersArray ); |
|
76 } |
|
77 |
|
78 // ========================================================================== |
|
79 // FUNCTION: NextL |
|
80 // ========================================================================== |
|
81 EXPORT_C TBool CMsgStoreSortResultIterator::NextL( const TDesC& aStartWith, |
|
82 TUint aCount, |
|
83 RPointerArray<CMsgStorePropertyContainer>& aProperties ) |
|
84 { |
|
85 TMsgStorePropertyContainersArray containersArray( aProperties ); |
|
86 |
|
87 return iContext.iSession.GetSortedRowsL( iSortSessionId, KMsgStoreSortResultTop, EMsgStoreIteratorForward, aCount, containersArray, aStartWith ); |
|
88 } |
|
89 |
|
90 // ========================================================================== |
|
91 // FUNCTION: PreviousL |
|
92 // ========================================================================== |
|
93 EXPORT_C TBool CMsgStoreSortResultIterator::PreviousL( TMsgStoreId aCurrentMessageId, |
|
94 TUint aCount, |
|
95 RPointerArray<CMsgStorePropertyContainer>& aProperties ) |
|
96 { |
|
97 TMsgStorePropertyContainersArray containersArray( aProperties ); |
|
98 |
|
99 return iContext.iSession.GetSortedRowsL( iSortSessionId, aCurrentMessageId, EMsgStoreIteratorBackward, aCount, containersArray ); |
|
100 } |
|
101 |
|
102 // ========================================================================== |
|
103 // FUNCTION: PreviousL |
|
104 // ========================================================================== |
|
105 EXPORT_C TBool CMsgStoreSortResultIterator::PreviousL( const TDesC& aStartWith, |
|
106 TUint aCount, |
|
107 RPointerArray<CMsgStorePropertyContainer>& aProperties ) |
|
108 { |
|
109 TMsgStorePropertyContainersArray containersArray( aProperties ); |
|
110 |
|
111 return iContext.iSession.GetSortedRowsL( iSortSessionId, KMsgStoreSortResultTop, EMsgStoreIteratorBackward, aCount, containersArray, aStartWith ); |
|
112 } |
|
113 |
|
114 // ========================================================================== |
|
115 // FUNCTION: SkipAndNextL |
|
116 // ========================================================================== |
|
117 EXPORT_C TBool CMsgStoreSortResultIterator::SkipAndNextL( TMsgStoreId aCurrentMessageId, |
|
118 TUint aCount, |
|
119 RPointerArray<CMsgStorePropertyContainer>& aProperties ) |
|
120 { |
|
121 TMsgStorePropertyContainersArray containersArray( aProperties ); |
|
122 TBool skipCurrentGroup = ETrue; |
|
123 |
|
124 return iContext.iSession.GetSortedRowsL( iSortSessionId, |
|
125 aCurrentMessageId, |
|
126 EMsgStoreIteratorForward, |
|
127 aCount, |
|
128 containersArray, |
|
129 KNullDesC, |
|
130 skipCurrentGroup ); |
|
131 } |
|
132 |
|
133 // ========================================================================== |
|
134 // FUNCTION: SkipAndPreviousL |
|
135 // ========================================================================== |
|
136 EXPORT_C TBool CMsgStoreSortResultIterator::SkipAndPreviousL( TMsgStoreId aCurrentMessageId, |
|
137 TUint aCount, |
|
138 RPointerArray<CMsgStorePropertyContainer>& aProperties ) |
|
139 { |
|
140 TMsgStorePropertyContainersArray containersArray( aProperties ); |
|
141 TBool skipCurrentGroup = ETrue; |
|
142 |
|
143 return iContext.iSession.GetSortedRowsL( iSortSessionId, |
|
144 aCurrentMessageId, |
|
145 EMsgStoreIteratorBackward, |
|
146 aCount, |
|
147 containersArray, |
|
148 KNullDesC, |
|
149 skipCurrentGroup ); |
|
150 } |
|
151 |
|
152 // ========================================================================== |
|
153 // FUNCTION: GroupCountL |
|
154 // ========================================================================== |
|
155 EXPORT_C TInt CMsgStoreSortResultIterator::GroupCountL( RArray<TUint>& aItemsInGroup ) |
|
156 { |
|
157 return iContext.iSession.SortIteratorGroupCountL( iSortSessionId, aItemsInGroup ); |
|
158 } |
|
159 |
|
160 // ========================================================================== |
|
161 // FUNCTION: IdsAndFlagsL |
|
162 // ========================================================================== |
|
163 EXPORT_C void CMsgStoreSortResultIterator::IdsAndFlagsL( RArray<TMsgStoreIdAndFlag>& aIdsAndFlags ) |
|
164 { |
|
165 iContext.iSession.SortedIdsAndFlagsL( iSortSessionId, aIdsAndFlags ); |
|
166 } |
|
167 |
|
168 // ========================================================================== |
|
169 // FUNCTION: IndexOfL |
|
170 // ========================================================================== |
|
171 EXPORT_C TInt CMsgStoreSortResultIterator::IndexOfL( TMsgStoreId aMessageId ) |
|
172 { |
|
173 return iContext.iSession.SortedIndexOfL( iSortSessionId, aMessageId ); |
|
174 } |
|
175 |
|
176 // ========================================================================== |
|
177 // FUNCTION: MessageIdsL |
|
178 // ========================================================================== |
|
179 EXPORT_C void CMsgStoreSortResultIterator::MessageIdsL( RArray<TMsgStoreId>& aMessageIds ) |
|
180 { |
|
181 return iContext.iSession.SortedIdsL( iSortSessionId, aMessageIds ); |
|
182 } |
|
183 |
|
184 /** Retrieve all message ids in the sorted order and |
|
185 * retrieve the number groups in this iterator. |
|
186 * NOTE: Customization work for Gimlet 2.0 |
|
187 */ |
|
188 EXPORT_C void CMsgStoreSortResultIterator::IdsAndGroupCountL( RArray<TMsgStoreId>& aMessageIds, RArray<TUint>& aItemsInGroup ) |
|
189 { |
|
190 return iContext.iSession.IdsAndGroupCountL( iSortSessionId, aMessageIds, aItemsInGroup ); |
|
191 } |
|
192 |