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: Definition for mailbox cache
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef EMAILMAILBOXCACHE_H
|
|
19 |
#define EMAILMAILBOXCACHE_H
|
|
20 |
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <emailapidefs.h>
|
|
23 |
|
|
24 |
using namespace EmailInterface;
|
|
25 |
|
|
26 |
class CPluginData;
|
|
27 |
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Cache associating mailbox with a protocol plugin. Improves performance by
|
|
31 |
* removing need to load protocol plugins every time a mailbox needs to be
|
|
32 |
* accessed (and keeping plugin loaded when it is not needed)
|
|
33 |
* @since s60 v5.2
|
|
34 |
*/
|
|
35 |
NONSHARABLE_CLASS( CEmailMailboxCache ) : public CBase
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
/**
|
|
39 |
* Cache entry to access plugin by mailbox id
|
|
40 |
*/
|
|
41 |
class TCacheEntry
|
|
42 |
{
|
|
43 |
public:
|
|
44 |
inline TCacheEntry(
|
|
45 |
CPluginData* aPluginData,
|
|
46 |
TMailboxId aId ) :
|
|
47 |
iPluginData( aPluginData ),
|
|
48 |
iMailboxId( aId ) {}
|
|
49 |
CPluginData* iPluginData;
|
|
50 |
TMailboxId iMailboxId;
|
|
51 |
};
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Constructor
|
|
55 |
*/
|
|
56 |
static CEmailMailboxCache* NewL();
|
|
57 |
|
|
58 |
/** destructor */
|
|
59 |
~CEmailMailboxCache();
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Clears cache and indicates that one or more AddMailboxL calls will
|
|
63 |
* follow.
|
|
64 |
* Cleanup support invalidates cache if leave occurs before EndCachingPop()
|
|
65 |
* is called
|
|
66 |
*/
|
|
67 |
void StartCachingPushL();
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Marks caching fully complete for all mailboxes (call when no more
|
|
71 |
* AddMailboxL will follow) and pops cleanup item.
|
|
72 |
*/
|
|
73 |
void EndCachingPop();
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Returns if mailboxes are cached
|
|
77 |
*/
|
|
78 |
TBool IsCached() const;
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Adds mailbox to cache.
|
|
82 |
* @param aPluginData mailbox associated with plugin(data)
|
|
83 |
* @param aMailboxId mailbox id
|
|
84 |
* @precondition: StartCaching must have been called.
|
|
85 |
*/
|
|
86 |
void AddMailboxL( CPluginData& aPluginData, const TMailboxId& aMailboxId );
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Returns plugin data by mailbox id
|
|
90 |
* @param aMailboxId
|
|
91 |
* @return plugin data associated with specified mailbox
|
|
92 |
*/
|
|
93 |
CPluginData* PluginDataL( const TMailboxId& aMailboxId ) const;
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Returns plugin data by plugin id
|
|
97 |
* @param aPluginId
|
|
98 |
* @return plugin data associated with specified plugin
|
|
99 |
*/
|
|
100 |
CPluginData* PluginDataL( const TUid& aPluginId ) const;
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Gets all mailbox ids in all protocol plugins
|
|
104 |
*/
|
|
105 |
void GetIdsL( REmailMailboxIdArray& aIdArray ) const;
|
|
106 |
|
|
107 |
private:
|
|
108 |
|
|
109 |
TInt FindById( const TMailboxId& aMailboxId ) const;
|
|
110 |
TInt FindByPluginIdL( const TUid& aPluginId ) const;
|
|
111 |
static TBool Equals( const TCacheEntry& a1, const TCacheEntry& a2 );
|
|
112 |
static TBool PluginEquals( const TCacheEntry& a1, const TCacheEntry& a2 );
|
|
113 |
|
|
114 |
static void CleanupOp( TAny* aAny );
|
|
115 |
|
|
116 |
private:
|
|
117 |
|
|
118 |
CEmailMailboxCache();
|
|
119 |
|
|
120 |
void ConstructL();
|
|
121 |
|
|
122 |
enum TCacheState {
|
|
123 |
EEmpty,
|
|
124 |
ECaching,
|
|
125 |
EComplete
|
|
126 |
};
|
|
127 |
private:
|
|
128 |
// empty, caching or caching complete
|
|
129 |
TCacheState iState;
|
|
130 |
|
|
131 |
// cached mailbox id with associated plugin data
|
|
132 |
RArray<TCacheEntry> iEntries;
|
|
133 |
};
|
|
134 |
|
|
135 |
|
|
136 |
#endif // EMAILMAILBOXCACHE_H
|
|
137 |
|
|
138 |
// End of file
|