47
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Email message iterator
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CMESSAGEITERATOR_H
|
|
19 |
#define CMESSAGEITERATOR_H
|
|
20 |
|
|
21 |
#include <mmessageiterator.h>
|
|
22 |
#include "emailapidefs.h"
|
62
|
23 |
#include "CFSMailCommon.h"
|
47
|
24 |
|
|
25 |
using namespace EmailInterface;
|
|
26 |
|
|
27 |
class MFSMailIterator;
|
|
28 |
class CPluginData;
|
|
29 |
class CFSMailMessage;
|
|
30 |
class CEmailMessage;
|
|
31 |
/**
|
|
32 |
* Iterator for email messages
|
|
33 |
* @since S60 v5.2
|
|
34 |
*/
|
|
35 |
NONSHARABLE_CLASS( CMessageIterator ) : public CBase, public MMessageIterator
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
/**
|
|
39 |
* Constructor
|
|
40 |
* @param aIterator
|
|
41 |
* @param aPluginData
|
|
42 |
* @return new iterator
|
|
43 |
*/
|
|
44 |
static CMessageIterator* NewL( MFSMailIterator* aIterator,
|
|
45 |
CPluginData& aPluginData,
|
|
46 |
TUint aCount );
|
|
47 |
|
|
48 |
~CMessageIterator();
|
|
49 |
|
|
50 |
private:
|
|
51 |
CMessageIterator( MFSMailIterator* aIterator, CPluginData& aPluginData, TUint aCount );
|
|
52 |
|
|
53 |
void ConstructL();
|
|
54 |
|
|
55 |
public: // from MEmailInterface
|
|
56 |
|
|
57 |
TEmailTypeId InterfaceId() const;
|
|
58 |
|
|
59 |
void Release();
|
|
60 |
|
|
61 |
public: // from MMessageIterator
|
|
62 |
|
|
63 |
/** @see MMessageIterator */
|
|
64 |
MEmailMessage* NextL();
|
|
65 |
|
|
66 |
/** @see MMessageIterator
|
|
67 |
(not implemented) */
|
|
68 |
|
|
69 |
MEmailMessage* PreviousL();
|
|
70 |
|
|
71 |
TUint Count() const;
|
|
72 |
|
|
73 |
|
|
74 |
private:
|
|
75 |
// Reads next chunk of messages from protocol plugin
|
|
76 |
TBool ReadNextChunkL();
|
|
77 |
TBool ReadPreviousChunkL();
|
|
78 |
MEmailMessage* ReadFromChunkL();
|
|
79 |
void CleanCache();
|
|
80 |
void AddToCacheL( CFSMailMessage* aFsMsg );
|
|
81 |
private: // data
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Iterator internal states. "Consuming" in state names mean getting and
|
|
85 |
* returning next message from the iterator.
|
|
86 |
*/
|
|
87 |
enum TState {
|
|
88 |
// No messages available in iterator, read them from protocl plugin.
|
|
89 |
// NextL returns a message from chunk (or NULL if folder is empty)
|
|
90 |
// This is initial state.
|
|
91 |
EReadNextMessageChunk,
|
|
92 |
EReadPreviousMessageChunk,
|
|
93 |
|
|
94 |
// Message(s) are available (retrieved from plugin). No remaining
|
|
95 |
// messages excepted from the plugin. NextL returns a message from chunk.
|
|
96 |
EConsumeFromChunk,
|
|
97 |
|
|
98 |
// Message(s) are available in chunk and more in protocol plugin.
|
|
99 |
EConsumeFromChunkWithMoreChunksToFollow,
|
|
100 |
|
|
101 |
// Iterator is iterated throuh and NextL would return NULL.
|
|
102 |
EIteratorConsumed
|
|
103 |
};
|
|
104 |
|
|
105 |
// plugin iterator, owned
|
|
106 |
MFSMailIterator* iIterator;
|
|
107 |
|
|
108 |
// reference to plugin data
|
|
109 |
CPluginData& iPluginData;
|
|
110 |
|
|
111 |
CFSMailPlugin* iPlugin;
|
|
112 |
|
|
113 |
// message id used for reading messages from plugin
|
|
114 |
TFSMailMsgId iStartMsgId;
|
|
115 |
|
|
116 |
// Internal state
|
|
117 |
TState iState;
|
|
118 |
|
|
119 |
// pointer array of messages read from protocol plugin (aka message chunk)
|
|
120 |
RPointerArray<CFSMailMessage> iFsMessageArray;
|
|
121 |
RPointerArray<CEmailMessage> iMessageArray;
|
|
122 |
|
|
123 |
TUint iCount;
|
|
124 |
|
|
125 |
TInt iCursor;
|
|
126 |
|
|
127 |
TFSMailMsgId iFirstMsgId;
|
|
128 |
|
|
129 |
TBool iHasMoreNextItems;
|
|
130 |
TBool iHasMorePrevItems;
|
|
131 |
};
|
|
132 |
|
|
133 |
#endif // CMESSAGEITERATOR_H
|
|
134 |
|
|
135 |
// End of file
|