|
1 /* |
|
2 * Copyright (c) 2007-2008 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: common email folder object |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //<cmail> |
|
20 #include "emailtrace.h" |
|
21 #include "CFSMailFolder.h" |
|
22 #include "CFSMailPlugin.h" |
|
23 //</cmail> |
|
24 |
|
25 #include "CFSMailIterator.h" |
|
26 #include "CFSMailRequestObserver.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ========================================== |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CFSMailFolder::NewLC |
|
31 // ----------------------------------------------------------------------------- |
|
32 EXPORT_C CFSMailFolder* CFSMailFolder::NewLC( TFSMailMsgId aFolderId ) |
|
33 { |
|
34 FUNC_LOG; |
|
35 CFSMailFolder* api = new (ELeave) CFSMailFolder(); |
|
36 CleanupStack:: PushL(api); |
|
37 api->ConstructL( aFolderId ); |
|
38 return api; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CFSMailFolder::NewL |
|
43 // ----------------------------------------------------------------------------- |
|
44 EXPORT_C CFSMailFolder* CFSMailFolder::NewL( TFSMailMsgId aFolderId ) |
|
45 { |
|
46 FUNC_LOG; |
|
47 CFSMailFolder* api = CFSMailFolder::NewLC( aFolderId ); |
|
48 CleanupStack:: Pop(api); |
|
49 return api; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CFSMailFolder::CFSMailFolder |
|
54 // ----------------------------------------------------------------------------- |
|
55 CFSMailFolder::CFSMailFolder() |
|
56 { |
|
57 FUNC_LOG; |
|
58 |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CFSMailFolder::ConstructL |
|
63 // ----------------------------------------------------------------------------- |
|
64 void CFSMailFolder::ConstructL( TFSMailMsgId aFolderId ) |
|
65 { |
|
66 FUNC_LOG; |
|
67 // get requesthandler pointer |
|
68 iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls()); |
|
69 |
|
70 // set folder id |
|
71 iFolderId = aFolderId; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CFSMailFolder::~CFSMailFolder |
|
76 // ----------------------------------------------------------------------------- |
|
77 EXPORT_C CFSMailFolder::~CFSMailFolder() |
|
78 { |
|
79 FUNC_LOG; |
|
80 |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CFSMailFolder::ListMessagesL |
|
85 // ----------------------------------------------------------------------------- |
|
86 EXPORT_C MFSMailIterator* CFSMailFolder::ListMessagesL( const TFSMailDetails aDetails, |
|
87 const RArray<TFSMailSortCriteria>& aSorting) |
|
88 { |
|
89 FUNC_LOG; |
|
90 |
|
91 CFSMailIterator* iterator = NULL; |
|
92 if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId())) |
|
93 { |
|
94 MFSMailIterator* pluginIterator = |
|
95 plugin->ListMessagesL(GetMailBoxId(),GetFolderId(),aDetails,aSorting); |
|
96 if(pluginIterator) |
|
97 { |
|
98 iterator = CFSMailIterator::NewL(*pluginIterator,iRequestHandler ); |
|
99 } |
|
100 } |
|
101 return iterator; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CFSMailFolder::FetchMessagesL |
|
106 // ----------------------------------------------------------------------------- |
|
107 EXPORT_C TInt CFSMailFolder::FetchMessagesL( const RArray<TFSMailMsgId>& aMessageIds, |
|
108 TFSMailDetails aDetails, |
|
109 MFSMailRequestObserver& aObserver ) |
|
110 { |
|
111 FUNC_LOG; |
|
112 // init asynchronous request |
|
113 CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()); |
|
114 |
|
115 TFSPendingRequest request = |
|
116 iRequestHandler->InitAsyncRequestL( GetFolderId().PluginId(), aObserver ); |
|
117 |
|
118 MFSMailRequestObserver* observer = request.iObserver; |
|
119 TRAPD(err,plugin->FetchMessagesL( GetMailBoxId(), |
|
120 GetFolderId(), |
|
121 aMessageIds, |
|
122 aDetails, |
|
123 *observer, |
|
124 request.iRequestId)); |
|
125 if(err != KErrNone) |
|
126 { |
|
127 iRequestHandler->CompleteRequest(request.iRequestId); |
|
128 User::Leave(err); |
|
129 } |
|
130 return request.iRequestId; |
|
131 } |
|
132 |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CFSMailFolder::GetSubFoldersL |
|
136 // ----------------------------------------------------------------------------- |
|
137 EXPORT_C void CFSMailFolder::GetSubFoldersL(RPointerArray<CFSMailFolder>& aSubFolders) |
|
138 { |
|
139 FUNC_LOG; |
|
140 if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId())) |
|
141 { |
|
142 TRAPD(err,plugin->ListFoldersL( GetMailBoxId(), GetFolderId(), aSubFolders)); |
|
143 if(err != KErrNone) |
|
144 { |
|
145 aSubFolders.ResetAndDestroy(); |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CFSMailFolder::RemoveMessageL |
|
152 // ----------------------------------------------------------------------------- |
|
153 EXPORT_C void CFSMailFolder::RemoveMessageL(TFSMailMsgId aMessage) |
|
154 { |
|
155 FUNC_LOG; |
|
156 if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId())) |
|
157 { |
|
158 RArray<TFSMailMsgId> messages; |
|
159 messages.Reset(); |
|
160 messages.Append(aMessage); |
|
161 plugin->DeleteMessagesByUidL(GetMailBoxId(),GetFolderId(),messages); |
|
162 messages.Close(); |
|
163 } |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CFSMailFolder::SupportsCopyFromL |
|
168 // ----------------------------------------------------------------------------- |
|
169 EXPORT_C TBool CFSMailFolder::SupportsCopyFromL( TFSFolderType aFolderType ) |
|
170 { |
|
171 FUNC_LOG; |
|
172 |
|
173 if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId())) |
|
174 { |
|
175 TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId()); |
|
176 if(onlineStatus == EFSMailBoxOnline) |
|
177 { |
|
178 for(TInt i=0;i<iCopyOnlineBlocked.Count();i++) |
|
179 { |
|
180 if(iCopyOnlineBlocked[i] == aFolderType) |
|
181 { |
|
182 return EFalse; |
|
183 } |
|
184 } |
|
185 } |
|
186 else if(onlineStatus == EFSMailBoxOffline) |
|
187 { |
|
188 for(TInt i=0;i<iCopyOfflineBlocked.Count();i++) |
|
189 { |
|
190 if(iCopyOfflineBlocked[i] == aFolderType) |
|
191 { |
|
192 return EFalse; |
|
193 } |
|
194 } |
|
195 } |
|
196 } |
|
197 return ETrue; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CFSMailFolder::SupportsMoveFromL |
|
202 // ----------------------------------------------------------------------------- |
|
203 EXPORT_C TBool CFSMailFolder::SupportsMoveFromL( TFSFolderType aFolderType ) |
|
204 { |
|
205 FUNC_LOG; |
|
206 |
|
207 if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId())) |
|
208 { |
|
209 TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId()); |
|
210 if(onlineStatus == EFSMailBoxOnline) |
|
211 { |
|
212 for(TInt i=0;i<iMoveOnlineBlocked.Count();i++) |
|
213 { |
|
214 if(iMoveOnlineBlocked[i] == aFolderType) |
|
215 { |
|
216 return EFalse; |
|
217 } |
|
218 } |
|
219 } |
|
220 else if(onlineStatus == EFSMailBoxOffline) |
|
221 { |
|
222 for(TInt i=0;i<iMoveOfflineBlocked.Count();i++) |
|
223 { |
|
224 if(iMoveOfflineBlocked[i] == aFolderType) |
|
225 { |
|
226 return EFalse; |
|
227 } |
|
228 } |
|
229 } |
|
230 } |
|
231 return ETrue; |
|
232 |
|
233 } |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CFSMailFolder::RemoveDownLoadedAttachmentsL |
|
236 // ----------------------------------------------------------------------------- |
|
237 EXPORT_C void CFSMailFolder::RemoveDownLoadedAttachmentsL() |
|
238 { |
|
239 FUNC_LOG; |
|
240 |
|
241 CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()); |
|
242 if(plugin != NULL) |
|
243 { |
|
244 MFSMailIterator* iterator = NULL; |
|
245 |
|
246 // select message details to be listed |
|
247 TFSMailDetails details(EFSMsgDataEnvelope); |
|
248 |
|
249 // sorting is free, give empty array |
|
250 RArray<TFSMailSortCriteria> sorting; |
|
251 sorting.Reset(); |
|
252 iterator = plugin->ListMessagesL( GetMailBoxId(), |
|
253 GetFolderId(), |
|
254 details, |
|
255 sorting ); |
|
256 if(iterator) |
|
257 { |
|
258 TFSMailMsgId nullId; |
|
259 RPointerArray<CFSMailMessage> messages; |
|
260 messages.Reset(); |
|
261 iterator->NextL(nullId,GetMessageCount(),messages); |
|
262 for(TInt i=0;i<messages.Count();i++) |
|
263 { |
|
264 if(messages[i]->IsFlagSet(EFSMsgFlag_Attachments)) |
|
265 { |
|
266 messages[i]->RemoveDownLoadedAttachmentsL(); |
|
267 } |
|
268 } |
|
269 messages.ResetAndDestroy(); |
|
270 delete iterator; |
|
271 } |
|
272 } |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CFSMailFolder::ReleaseExtension |
|
277 // ----------------------------------------------------------------------------- |
|
278 EXPORT_C void CFSMailFolder::ReleaseExtension( CEmailExtension* aExtension ) |
|
279 { |
|
280 FUNC_LOG; |
|
281 // no specialized behaviour, call base class |
|
282 CExtendableEmail::ReleaseExtension( aExtension ); |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CFSMailFolder::ExtensionL |
|
287 // ----------------------------------------------------------------------------- |
|
288 EXPORT_C CEmailExtension* CFSMailFolder::ExtensionL( const TUid& aInterfaceUid ) |
|
289 { |
|
290 FUNC_LOG; |
|
291 return CExtendableEmail::ExtensionL( aInterfaceUid ); |
|
292 } |
|
293 |