|
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 of Email API main interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef EMAILCLIENTAPIIMPL_H |
|
19 #define EMAILCLIENTAPIIMPL_H |
|
20 |
|
21 |
|
22 #include <implementationinformation.h> |
|
23 #include "emailapiutils.h" |
|
24 #include "cfsmailcommon.h" |
|
25 #include "mfsmaileventobserver.h" |
|
26 #include <memailclientapi.h> |
|
27 #include "emailclientpluginmanager.h" |
|
28 |
|
29 |
|
30 using namespace EmailInterface; |
|
31 |
|
32 class CFSMailBox; |
|
33 class MEmailEventObserver; |
|
34 class CVwsSessionWrapper; |
|
35 class CFSMailPlugin; |
|
36 class TFSMailMsgId; |
|
37 class CEmailMailboxCache; |
|
38 class CFSMailClient; |
|
39 |
|
40 /** |
|
41 * "Framework" class including plugin management |
|
42 * @since S60 v5.2 |
|
43 */ |
|
44 NONSHARABLE_CLASS( CEmailClientApi ) : public CBase, public MEmailClientApi |
|
45 { |
|
46 public: |
|
47 /** |
|
48 * Constructor |
|
49 * @return |
|
50 */ |
|
51 static CEmailClientApi* NewL(); |
|
52 |
|
53 /** |
|
54 * |
|
55 */ |
|
56 CEmailClientApi(); |
|
57 |
|
58 public: // from MEmailInterface |
|
59 TEmailTypeId InterfaceId() const; |
|
60 |
|
61 void Release(); |
|
62 |
|
63 public: // from MEmailClientApi |
|
64 |
|
65 /** @see MEmailClientApi */ |
|
66 MEmailMailbox* MailboxL( const TMailboxId& aId ); |
|
67 |
|
68 /** @see MEmailClientApi */ |
|
69 MEmailMailbox* MailboxL( const TPtrC& aAddress ); |
|
70 |
|
71 /** |
|
72 * Gets all mailboxes in pointer array. It is recommended to free other |
|
73 * mailboxes besides needed one to optimise memory usage. |
|
74 */ |
|
75 TInt GetMailboxesL( RMailboxPtrArray& aMailboxes ); |
|
76 |
|
77 /** |
|
78 */ |
|
79 void LaunchEmailL( const TLaunchPolicy aPolicy ); |
|
80 |
|
81 public: // new methods |
|
82 |
|
83 /** |
|
84 * Gets array of mailbox ids |
|
85 * @param aMailboxes mailbox ids from all plugins |
|
86 * @return number of mailboxes returned in aMailboxes |
|
87 */ |
|
88 TInt GetMailboxIdsL( REmailMailboxIdArray& aMailboxes ); |
|
89 |
|
90 private: |
|
91 |
|
92 /** |
|
93 * Constructor |
|
94 */ |
|
95 void ConstructL(); |
|
96 |
|
97 /** |
|
98 * Destructor |
|
99 */ |
|
100 ~CEmailClientApi(); |
|
101 |
|
102 /** |
|
103 * Push ECom implementation info to cleanup operation to cleanup stack |
|
104 */ |
|
105 void CleanupImplInfoPushL( RPointerArray<CImplementationInformation>& aArray ); |
|
106 |
|
107 /** |
|
108 * Cleanup operation for ECom implementation info |
|
109 */ |
|
110 static void CleanupImplInfo( TAny* aAny ); |
|
111 |
|
112 |
|
113 // Group of methods for book keeping of loaded protocol plugins by this object. |
|
114 // In certain situations it is preferable to have a plugin in memory |
|
115 // instead of loading/unloading frequently. |
|
116 |
|
117 /** Increases plugin reference count if CEmailClientApi already doesn't |
|
118 * have active instance. When plugin is needed internally, this method |
|
119 * should be accessor to a plugin. Counterpart is ReleasePlugin() when |
|
120 * CEmailClientApi doesn't itself need plugin any more. |
|
121 */ |
|
122 CFSMailPlugin* UsePlugin( CPluginData& aPluginData ); |
|
123 |
|
124 /** |
|
125 * For finding plugin data |
|
126 */ |
|
127 TInt IndexOfLoadedPluginData( const TPluginData& aPluginData ) const; |
|
128 |
|
129 /** |
|
130 * Used in comparing plugin data in array (part of find algorithm) |
|
131 */ |
|
132 static TBool PluginDataEquals( const TPluginData& a1, const TPluginData& a2 ); |
|
133 |
|
134 /** |
|
135 * This object doesn't need related protocol plugin |
|
136 */ |
|
137 void ReleasePlugin( CPluginData& aPluginData ); |
|
138 |
|
139 /** |
|
140 * This object doesn't need any protocol plugin |
|
141 */ |
|
142 void ReleaseAllPlugins(); |
|
143 |
|
144 /** |
|
145 * Return mailbox cache, creates it when called first time |
|
146 */ |
|
147 CEmailMailboxCache& MailboxInfoCacheL(); |
|
148 |
|
149 /** |
|
150 * Caches mailbox ids and their mapping to related plugin data for quick |
|
151 * lookup. When a mailbox with specific id is next time asked, related |
|
152 * protocol plugin is already known. |
|
153 */ |
|
154 void UpdateMailboxInfoCacheL(); |
|
155 |
|
156 /** |
|
157 * Internal, used from UpdateMailboxInfoCacheL |
|
158 */ |
|
159 TBool CachePluginMailboxesL( |
|
160 CPluginData& aPluginData, |
|
161 CFSMailPlugin& aPlugin ); |
|
162 |
|
163 private: |
|
164 typedef RPointerArray<CPluginData> RPluginDataArray; |
|
165 |
|
166 /** |
|
167 * Iterator for CPluginData elements in an array |
|
168 */ |
|
169 class TPluginIterator |
|
170 { |
|
171 public: |
|
172 // constructor |
|
173 inline TPluginIterator( RPluginDataArray& aArray ) : |
|
174 iArray( aArray ), iIndex( 0 ) {} |
|
175 |
|
176 /** |
|
177 * return next element |
|
178 */ |
|
179 CPluginData* Next(); |
|
180 private: |
|
181 // iterator array |
|
182 RPluginDataArray& iArray; |
|
183 // current iterator index |
|
184 TInt iIndex; |
|
185 }; |
|
186 |
|
187 private: |
|
188 // plugin data array for all protocol plugins |
|
189 RPluginDataArray iPluginDataArray; |
|
190 |
|
191 // singleton instance counter |
|
192 TInt iInstanceCounter; |
|
193 |
|
194 // book keeping of loaded plugins |
|
195 RArray<TPluginData> iLoadedPluginsArray; |
|
196 |
|
197 // Mailbox ids are cached when first time listed. Related plugin uid |
|
198 // is include in the cache. |
|
199 CEmailMailboxCache* iMailboxCache; |
|
200 |
|
201 CFSMailClient* iMailClient; |
|
202 |
|
203 }; |
|
204 |
|
205 /** |
|
206 * Email application launcher. |
|
207 */ |
|
208 NONSHARABLE_CLASS( CEmailLauncher ) : public CBase |
|
209 { |
|
210 public: |
|
211 static CEmailLauncher* NewL(); |
|
212 |
|
213 ~CEmailLauncher(); |
|
214 |
|
215 /** |
|
216 * |
|
217 */ |
|
218 void LaunchL( const TMailboxId& aMailboxId ); |
|
219 private: |
|
220 |
|
221 CEmailLauncher(); |
|
222 |
|
223 void ConstructL(); |
|
224 |
|
225 // Owned window server session. |
|
226 CVwsSessionWrapper* iViewSrvSession; |
|
227 }; |
|
228 |
|
229 |
|
230 #endif // EMAILCLIENTAPIIMPL_H |
|
231 |
|
232 // End of file |