|
1 /* |
|
2 * Copyright (c) 2004 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: DM Email Settings Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <implementationproxy.h> // For TImplementationProxy definition |
|
22 #include <utf.h> |
|
23 #include <iapprefs.h> |
|
24 #include <smtpset.h> |
|
25 #include <pop3set.h> |
|
26 #include <imapset.h> |
|
27 #include <sysutil.h> |
|
28 #include <etelmm.h> |
|
29 |
|
30 #include <cemailaccounts.h> |
|
31 |
|
32 #include "nsmldmimpluids.h" |
|
33 #include "nsmldmemailadapter.h" |
|
34 #include "nsmldebug.h" |
|
35 #include "nsmlconstants.h" |
|
36 #include "nsmldmconst.h" |
|
37 #include "nsmldmiapmatcher.h" |
|
38 |
|
39 #ifndef __WINS__ |
|
40 // This lowers the unnecessary compiler warning (armv5) to remark. |
|
41 // "Warning: #174-D: expression has no effect..." is caused by |
|
42 // DBG_ARGS8 macro in no-debug builds. |
|
43 #pragma diag_remark 174 |
|
44 #endif |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CNSmlDmEmailAdapter* CNSmlDmEmailAdapter::NewL( ) |
|
48 // ----------------------------------------------------------------------------- |
|
49 CNSmlDmEmailAdapter* CNSmlDmEmailAdapter::NewL(MSmlDmCallback* aDmCallback ) |
|
50 { |
|
51 _DBG_FILE("CNSmlDmEmailAdapter::NewL(): begin"); |
|
52 CNSmlDmEmailAdapter* self = new (ELeave) CNSmlDmEmailAdapter(aDmCallback); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop(); |
|
56 _DBG_FILE("CNSmlDmEmailAdapter::NewL(): end"); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CNSmlDmEmailAdapter::CNSmlDmEmailAdapter() |
|
62 // ----------------------------------------------------------------------------- |
|
63 |
|
64 CNSmlDmEmailAdapter::CNSmlDmEmailAdapter( MSmlDmCallback* aDmCallback ) |
|
65 : CSmlDmAdapter(aDmCallback) |
|
66 { |
|
67 _DBG_FILE("CNSmlDmEmailAdapter::CNSmlDmEmailAdapter(): begin"); |
|
68 iMsvSession = NULL; |
|
69 _DBG_FILE("CNSmlDmEmailAdapter::CNSmlDmEmailAdapter(): end"); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CNSmlDmEmailAdapter::ConstructL() |
|
74 // ----------------------------------------------------------------------------- |
|
75 void CNSmlDmEmailAdapter::ConstructL() |
|
76 { |
|
77 iBuffer = new (ELeave) CArrayFixFlat <TNSmlEmailSettingsElement> |
|
78 (KNSmlDmEmailGranularity); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter() |
|
83 // ----------------------------------------------------------------------------- |
|
84 CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter() |
|
85 { |
|
86 _DBG_FILE("CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter(): begin"); |
|
87 delete iMsvSession; |
|
88 if(iBuffer) |
|
89 { |
|
90 for(TInt i=0;i<iBuffer->Count();i++) |
|
91 { |
|
92 delete iBuffer->At(i).iMappingName; |
|
93 delete iBuffer->At(i).iName; |
|
94 delete iBuffer->At(i).iSmtpSettings; |
|
95 delete iBuffer->At(i).iPop3Settings; |
|
96 delete iBuffer->At(i).iImap4Settings; |
|
97 delete iBuffer->At(i).iIapPref; |
|
98 delete iBuffer->At(i).iSmtpIapPref; |
|
99 |
|
100 if(iBuffer->At(i).iNodeBuf) |
|
101 { |
|
102 for(TInt j=0;j<iBuffer->At(i).iNodeBuf->Count();j++) |
|
103 { |
|
104 delete iBuffer->At(i).iNodeBuf->At(j).iLastUriSeg; |
|
105 delete iBuffer->At(i).iNodeBuf->At(j).iData; |
|
106 } |
|
107 iBuffer->At(i).iNodeBuf->Reset(); |
|
108 delete iBuffer->At(i).iNodeBuf; |
|
109 } |
|
110 } |
|
111 iBuffer->Reset(); |
|
112 delete iBuffer; |
|
113 } |
|
114 |
|
115 _DBG_FILE("CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter(): end"); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CNSmlDmEmailAdapter::DDFVersionL() |
|
120 // ----------------------------------------------------------------------------- |
|
121 void CNSmlDmEmailAdapter::DDFVersionL(CBufBase& aDDFVersion) |
|
122 { |
|
123 _DBG_FILE("CNSmlDmEmailAdapter::DDFVersionL(TDes& aDDFVersion): begin"); |
|
124 aDDFVersion.InsertL(0,KNSmlDMEmailDDFVersion); |
|
125 _DBG_FILE("CNSmlDmEmailAdapter::DDFVersionL(TDes& aDDFVersion): end"); |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CNSmlDmEmailAdapter::DDFStructureL() |
|
131 // |
|
132 // ----------------------------------------------------------------------------- |
|
133 void CNSmlDmEmailAdapter::DDFStructureL(MSmlDmDDFObject& aDDF) |
|
134 { |
|
135 _DBG_FILE("CNSmlDmEmailAdapter::DDFStructureL(): begin"); |
|
136 |
|
137 TSmlDmAccessTypes accessTypesNode; |
|
138 |
|
139 accessTypesNode.SetGet(); |
|
140 |
|
141 // Email |
|
142 MSmlDmDDFObject& email = aDDF.AddChildObjectL(KNSmlDMEmailNodeName); |
|
143 FillNodeInfoL(email,accessTypesNode,MSmlDmDDFObject::EOne, |
|
144 MSmlDmDDFObject::EPermanent, |
|
145 MSmlDmDDFObject::ENode,KNSmlDMEmailDescription); |
|
146 |
|
147 accessTypesNode.SetAdd(); |
|
148 accessTypesNode.SetDelete(); |
|
149 accessTypesNode.SetReplace(); |
|
150 MSmlDmDDFObject& rtNode = email.AddChildObjectGroupL(); |
|
151 |
|
152 |
|
153 FillNodeInfoL(rtNode,accessTypesNode,MSmlDmDDFObject::EZeroOrMore, |
|
154 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::ENode, |
|
155 KNSmlDMDynamicNodeDescription); |
|
156 |
|
157 TSmlDmAccessTypes accessTypes; |
|
158 accessTypes.SetGet(); |
|
159 accessTypes.SetAdd(); |
|
160 accessTypes.SetReplace(); |
|
161 //displayable account name |
|
162 MSmlDmDDFObject& name = rtNode.AddChildObjectL(KNSmlDMEmailName); |
|
163 FillNodeInfoL(name,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
164 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
165 KNSmlDMNameDescription); |
|
166 |
|
167 //user id for email account |
|
168 MSmlDmDDFObject& uid = rtNode.AddChildObjectL(KNSmlDMEmailUID); |
|
169 FillNodeInfoL(uid,accessTypes,MSmlDmDDFObject::EOne, |
|
170 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
171 KNSmlDMUIDDescription); |
|
172 |
|
173 //password for email account |
|
174 TSmlDmAccessTypes accessTypesPw; |
|
175 accessTypesPw.SetAdd(); |
|
176 accessTypesPw.SetReplace(); |
|
177 MSmlDmDDFObject& pw = rtNode.AddChildObjectL(KNSmlDMEmailPW); |
|
178 FillNodeInfoL(pw,accessTypesPw,MSmlDmDDFObject::EZeroOrOne, |
|
179 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
180 KNSmlDMPWDescription); |
|
181 |
|
182 //user's email address |
|
183 MSmlDmDDFObject& uaddr = rtNode.AddChildObjectL(KNSmlDMEmailUAddr); |
|
184 FillNodeInfoL(uaddr,accessTypes,MSmlDmDDFObject::EOne, |
|
185 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
186 KNSmlDMUAddrDescription); |
|
187 |
|
188 //Displayable name for the user |
|
189 MSmlDmDDFObject& uname = rtNode.AddChildObjectL(KNSmlDMEmailUName); |
|
190 FillNodeInfoL(uname,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
191 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
192 KNSmlDMUNameDescription); |
|
193 |
|
194 //Host name for the receiving server |
|
195 MSmlDmDDFObject& mrcv = rtNode.AddChildObjectL(KNSmlDMEmailMrcv); |
|
196 FillNodeInfoL(mrcv,accessTypes,MSmlDmDDFObject::EOne, |
|
197 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
198 KNSmlDMMrcvDescription); |
|
199 |
|
200 //Host name for the sending server |
|
201 MSmlDmDDFObject& msnd = rtNode.AddChildObjectL(KNSmlDMEmailMsnd); |
|
202 FillNodeInfoL(msnd,accessTypes,MSmlDmDDFObject::EOne, |
|
203 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
204 KNSmlDMMsndDescription); |
|
205 |
|
206 //Remote mailbox protocol |
|
207 MSmlDmDDFObject& mpro = rtNode.AddChildObjectL(KNSmlDMEmailMpro); |
|
208 FillNodeInfoL(mpro,accessTypes,MSmlDmDDFObject::EOne, |
|
209 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
210 KNSmlDMMproDescription); |
|
211 |
|
212 //Use secure connection |
|
213 MSmlDmDDFObject& useSecCon = rtNode.AddChildObjectL(KNSmlDMEmailUseSecCon); |
|
214 FillNodeInfoL(useSecCon,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
215 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool, |
|
216 KNSmlDMUseSecConDescription); |
|
217 |
|
218 //Use APop |
|
219 MSmlDmDDFObject& useAPOP = rtNode.AddChildObjectL(KNSmlDMEmailUseAPOP); |
|
220 FillNodeInfoL(useAPOP, accessTypes, MSmlDmDDFObject::EZeroOrOne, |
|
221 MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EBool, |
|
222 KNSmlDMUseAPOPDescription ); |
|
223 |
|
224 //Use smtp authentication |
|
225 MSmlDmDDFObject& useSauth = rtNode.AddChildObjectL(KNSmlDMEmailUseSauth); |
|
226 FillNodeInfoL(useSauth,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
227 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool, |
|
228 KNSmlDMUseSauthDescription); |
|
229 |
|
230 //smtp authentication user id |
|
231 MSmlDmDDFObject& sauthUid = rtNode.AddChildObjectL(KNSmlDMEmailSauthUID); |
|
232 FillNodeInfoL(sauthUid,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
233 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
234 KNSmlDMSauthUIDDescription); |
|
235 |
|
236 //Use smtp authentication |
|
237 MSmlDmDDFObject& sauthPw = rtNode.AddChildObjectL(KNSmlDMEmailSauthPW); |
|
238 FillNodeInfoL(sauthPw,accessTypesPw,MSmlDmDDFObject::EZeroOrOne, |
|
239 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
240 KNSmlDMSauthPWDescription); |
|
241 |
|
242 //Use smtp authentication |
|
243 MSmlDmDDFObject& ptxtSAuth = rtNode.AddChildObjectL(KNSmlDMEmailPtxtSAuth); |
|
244 FillNodeInfoL(ptxtSAuth,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
245 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool, |
|
246 KNSmlDMPtxtSAuthDescription); |
|
247 |
|
248 //Link to IAP |
|
249 MSmlDmDDFObject& toNapId = rtNode.AddChildObjectL(KNSmlDMEmailToNapID); |
|
250 FillNodeInfoL(toNapId,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
251 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
252 KNSmlDMToNapIDDescription); |
|
253 |
|
254 //Link to IAP for SMTP |
|
255 MSmlDmDDFObject& sToNapId = rtNode.AddChildObjectL(KNSmlDMEmailSToNapID); |
|
256 FillNodeInfoL(sToNapId,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
257 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
258 KNSmlDMSToNapIDDescription); |
|
259 |
|
260 //SSL/TLS used in SMTP |
|
261 MSmlDmDDFObject& sUseSecCon = rtNode. |
|
262 AddChildObjectL(KNSmlDMEmailSUseSecCon); |
|
263 FillNodeInfoL(sUseSecCon,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
264 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool, |
|
265 KNSmlDMSUseSecConDescription); |
|
266 |
|
267 //StartTLS used in IMAP/POP |
|
268 MSmlDmDDFObject& useStartTls = rtNode. |
|
269 AddChildObjectL(KNSmlDMEmailUseStartTLS); |
|
270 FillNodeInfoL(useStartTls,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
271 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool, |
|
272 KNSmlDMUseStartTLSDescription); |
|
273 |
|
274 //StartTLS used in SMTP |
|
275 MSmlDmDDFObject& sUseStartTls = rtNode. |
|
276 AddChildObjectL(KNSmlDMEmailSUseStartTLS); |
|
277 FillNodeInfoL(sUseStartTls,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
278 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool, |
|
279 KNSmlDMSUseStartTLSDescription); |
|
280 |
|
281 //port of IMAP/POP server |
|
282 MSmlDmDDFObject& mrcvPort = rtNode.AddChildObjectL(KNSmlDMEmailMrcvPort); |
|
283 FillNodeInfoL(mrcvPort,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
284 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EInt, |
|
285 KNSmlDMMrcvPortDescription); |
|
286 |
|
287 //port of SMTP server |
|
288 MSmlDmDDFObject& msndPort = rtNode.AddChildObjectL(KNSmlDMEmailMsndPort); |
|
289 FillNodeInfoL(msndPort,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
290 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EInt, |
|
291 KNSmlDMMsndPortDescription); |
|
292 |
|
293 //IMAP folder path |
|
294 MSmlDmDDFObject& folderPath = rtNode. |
|
295 AddChildObjectL(KNSmlDMEmailFolderPath); |
|
296 FillNodeInfoL(folderPath,accessTypes,MSmlDmDDFObject::EZeroOrOne, |
|
297 MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr, |
|
298 KNSmlDMFolderPathDescription); |
|
299 |
|
300 _DBG_FILE("CNSmlDmEmailAdapter::DDFStructureL(): end"); |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CNSmlDmEmailAdapter::UpdateLeafObjectL() |
|
305 // ----------------------------------------------------------------------------- |
|
306 void CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
307 const TDesC8& aLUID, |
|
308 const TDesC8& aObject, |
|
309 const TDesC8& /*aType*/, |
|
310 const TInt aStatusRef ) |
|
311 { |
|
312 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): begin"); |
|
313 |
|
314 TInt index = -1; |
|
315 TBool firstAdd = EFalse; |
|
316 |
|
317 for(TInt i = 0; i<iBuffer->Count(); i++) |
|
318 { |
|
319 TPtrC8 parentUri = RemoveLastURISeg(aURI); |
|
320 //Check Node from buffer if match |
|
321 if(iBuffer->At(i).iMappingName->Compare(parentUri) == 0 ) |
|
322 { |
|
323 firstAdd = ETrue; |
|
324 index = i; |
|
325 break; |
|
326 } |
|
327 } |
|
328 |
|
329 TInt luid = DesToInt(aLUID); |
|
330 |
|
331 if(aLUID.Length()==0 && index<0) |
|
332 { |
|
333 luid = ConstructTreeL(aURI); |
|
334 if(luid == -1) |
|
335 { |
|
336 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound); |
|
337 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end"); |
|
338 return; |
|
339 } |
|
340 } |
|
341 |
|
342 if( OpenSessionL() != KErrNone ) |
|
343 { |
|
344 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
345 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end"); |
|
346 return; |
|
347 } |
|
348 |
|
349 if(!firstAdd) |
|
350 { |
|
351 |
|
352 if(LastURISeg(aURI).Compare(KNSmlDMEmailMpro)==0) |
|
353 { |
|
354 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
355 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end"); |
|
356 return; |
|
357 } |
|
358 index = -1; |
|
359 for(TInt i=0;i<iBuffer->Count();i++) |
|
360 { |
|
361 if(iBuffer->At(i).iLuid == luid) |
|
362 { |
|
363 index = i; |
|
364 break; |
|
365 } |
|
366 } |
|
367 |
|
368 if(index<0) |
|
369 { |
|
370 TNSmlEmailSettingsElement newNode; |
|
371 newNode.iImap4Settings = NULL; |
|
372 newNode.iPop3Settings = NULL; |
|
373 newNode.iSmtpSettings = NULL; |
|
374 newNode.iIapPref = NULL; |
|
375 newNode.iSmtpIapPref = NULL; |
|
376 newNode.iLuid = luid; |
|
377 newNode.iMappingName = aURI.AllocLC(); |
|
378 newNode.iName = HBufC::NewLC(0); |
|
379 newNode.iNodeBuf = new (ELeave) CArrayFixFlat |
|
380 <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity); |
|
381 newNode.iExecuted = ETrue; |
|
382 GetIdByLuid(newNode.iAccType, newNode.iAccId, luid); |
|
383 iBuffer->AppendL(newNode); |
|
384 index = iBuffer->Count() - 1; |
|
385 TInt err = DoRestoreSettingsL(index); |
|
386 if(err!=KErrNone) |
|
387 { |
|
388 CleanupStack::PopAndDestroy(2); //newNode.iMappingName,newNode.iName |
|
389 newNode.iMappingName = NULL; |
|
390 newNode.iName = NULL; |
|
391 iBuffer->At(index).iNodeBuf->Reset(); |
|
392 delete iBuffer->At(index).iNodeBuf; |
|
393 iBuffer->Delete(index); |
|
394 } |
|
395 if(err==KErrNotFound) |
|
396 { |
|
397 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound); |
|
398 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end"); |
|
399 return; |
|
400 } |
|
401 else if(err!=KErrNone) |
|
402 { |
|
403 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
404 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end"); |
|
405 return; |
|
406 } |
|
407 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
408 } |
|
409 TNSmlEmailCommandElement newCommand; |
|
410 newCommand.iLastUriSeg = LastURISeg(aURI).AllocLC(); |
|
411 newCommand.iData = NULL; |
|
412 newCommand.iStatusRef = aStatusRef; |
|
413 newCommand.iLeaf = ETrue; |
|
414 newCommand.iStatus = CSmlDmAdapter::EOk; |
|
415 iBuffer->At(index).iNodeBuf->AppendL(newCommand); |
|
416 CleanupStack::Pop(); //newCommand.iLastUriSeg |
|
417 iBuffer->At(index).iJustFetch=EFalse; |
|
418 DoAddLeafObjectL(newCommand.iLastUriSeg->Des(),aObject,index, |
|
419 iBuffer->At(index).iNodeBuf->Count()-1); |
|
420 } |
|
421 else |
|
422 { |
|
423 FirstAddLeafL(aURI,aObject,aStatusRef,index); |
|
424 } |
|
425 |
|
426 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end"); |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CNSmlDmEmailAdapter::DeleteObjectL( const TDesC8& aURI, |
|
431 // const TDesC8& aLUID, |
|
432 // const TInt aStatusRef ) |
|
433 // ----------------------------------------------------------------------------- |
|
434 void CNSmlDmEmailAdapter::DeleteObjectL( const TDesC8& aURI, |
|
435 const TDesC8& aLUID, |
|
436 const TInt aStatusRef ) |
|
437 { |
|
438 _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): begin"); |
|
439 if(NumOfURISegs(aURI)==2) |
|
440 { |
|
441 if(aLUID.Length()==0) |
|
442 { |
|
443 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound); |
|
444 _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): ENotFound end"); |
|
445 return; |
|
446 } |
|
447 |
|
448 TInt luid = DesToInt(aLUID); |
|
449 TInt err = OpenSessionL(); |
|
450 if(err!=KErrNone) |
|
451 { |
|
452 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
453 _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): EError end"); |
|
454 return; |
|
455 } |
|
456 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
457 TNSmlEmailAccountType accType; |
|
458 TInt id; |
|
459 GetIdByLuid(accType, id, luid ); |
|
460 if( AccountExistsL( emailAccs, accType, id, -1 ) ) |
|
461 { |
|
462 switch ( accType ) |
|
463 { |
|
464 case EImap: |
|
465 { |
|
466 RArray<TImapAccount> imap4Accs; |
|
467 CleanupClosePushL( imap4Accs ); |
|
468 emailAccs->GetImapAccountsL( imap4Accs ); |
|
469 |
|
470 for (TInt i(0); i < imap4Accs.Count(); i++) |
|
471 { |
|
472 if ( imap4Accs[i].iImapAccountId == id ) |
|
473 { |
|
474 // Delete also related Smtp account |
|
475 TSmtpAccount relatedSmtp; |
|
476 emailAccs->GetSmtpAccountL( imap4Accs[i].iSmtpService, relatedSmtp ); |
|
477 emailAccs->DeleteImapAccountL( imap4Accs[i] ); |
|
478 emailAccs->DeleteSmtpAccountL( relatedSmtp ); |
|
479 //The only email a/c in phone gettiong deleted , so delete the default sntp a/c |
|
480 if( imap4Accs.Count() == 1 ) |
|
481 { |
|
482 TInt deferr = KErrNone; |
|
483 TRAP(deferr, emailAccs->DeleteDefaultSmtpAccountL()); |
|
484 DBG_ARGS(_S16("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): Delete default smtp account Error code %d"),deferr); |
|
485 } |
|
486 break; |
|
487 } |
|
488 } |
|
489 |
|
490 CleanupStack::PopAndDestroy(&imap4Accs); //imap4Accs |
|
491 |
|
492 // If the default account was just deleted, |
|
493 // new one needs to be set. |
|
494 // |
|
495 TSmtpAccount defaultSmtp; |
|
496 TInt retVal = emailAccs->DefaultSmtpAccountL( defaultSmtp ); |
|
497 if ( retVal != KErrNone ) |
|
498 { |
|
499 RArray<TImapAccount> imapAccs; |
|
500 CleanupClosePushL( imapAccs ); |
|
501 emailAccs->GetImapAccountsL( imapAccs ); |
|
502 if ( imapAccs.Count() > 0 ) |
|
503 { |
|
504 TSmtpAccount relatedSmtp; |
|
505 emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp ); |
|
506 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
507 } |
|
508 CleanupStack::PopAndDestroy( &imapAccs ); |
|
509 RArray<TPopAccount> popAccounts; |
|
510 CleanupClosePushL( popAccounts ); |
|
511 emailAccs->GetPopAccountsL( popAccounts ); |
|
512 if ( popAccounts.Count() > 0 ) |
|
513 { |
|
514 TSmtpAccount relatedSmtp; |
|
515 emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp ); |
|
516 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
517 } |
|
518 CleanupStack::PopAndDestroy( &popAccounts ); |
|
519 } |
|
520 break; |
|
521 } |
|
522 |
|
523 case EPop: |
|
524 { |
|
525 RArray<TPopAccount> popAccs; |
|
526 CleanupClosePushL( popAccs ); |
|
527 emailAccs->GetPopAccountsL( popAccs ); |
|
528 |
|
529 for (TInt i(0); i < popAccs.Count(); i++) |
|
530 { |
|
531 if ( popAccs[i].iPopAccountId == id ) |
|
532 { |
|
533 // Delete also related Smtp account |
|
534 TSmtpAccount relatedSmtp; |
|
535 emailAccs->GetSmtpAccountL( popAccs[i].iSmtpService, relatedSmtp ); |
|
536 emailAccs->DeletePopAccountL( popAccs[i] ); |
|
537 emailAccs->DeleteSmtpAccountL( relatedSmtp ); |
|
538 if( popAccs.Count() == 1 ) |
|
539 { |
|
540 TInt deferr = KErrNone; |
|
541 TRAP(deferr, emailAccs->DeleteDefaultSmtpAccountL()); |
|
542 DBG_ARGS(_S16("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): Delete default smtp account Error code %d "),deferr); |
|
543 } |
|
544 break; |
|
545 } |
|
546 } |
|
547 |
|
548 CleanupStack::PopAndDestroy(); //popAccs |
|
549 |
|
550 // If the default account was just deleted, |
|
551 // new one needs to be set. |
|
552 // |
|
553 TSmtpAccount defSmtp; |
|
554 TInt retVal = emailAccs->DefaultSmtpAccountL( defSmtp ); |
|
555 if ( retVal != KErrNone ) |
|
556 { |
|
557 RArray<TPopAccount> popAccounts; |
|
558 CleanupClosePushL( popAccounts ); |
|
559 emailAccs->GetPopAccountsL( popAccounts ); |
|
560 if ( popAccounts.Count() > 0 ) |
|
561 { |
|
562 TSmtpAccount relatedSmtp; |
|
563 emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp ); |
|
564 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
565 } |
|
566 CleanupStack::PopAndDestroy( &popAccounts ); |
|
567 RArray<TImapAccount> imapAccs; |
|
568 CleanupClosePushL( imapAccs ); |
|
569 emailAccs->GetImapAccountsL( imapAccs ); |
|
570 if ( imapAccs.Count() > 0 ) |
|
571 { |
|
572 TSmtpAccount relatedSmtp; |
|
573 emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp ); |
|
574 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
575 } |
|
576 CleanupStack::PopAndDestroy( &imapAccs ); |
|
577 } |
|
578 break; |
|
579 } |
|
580 |
|
581 default: |
|
582 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound); |
|
583 break; |
|
584 } |
|
585 |
|
586 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EOk); |
|
587 } |
|
588 else |
|
589 { |
|
590 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound); |
|
591 } |
|
592 CleanupStack::PopAndDestroy(); //emailAccs |
|
593 } |
|
594 else |
|
595 { |
|
596 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
597 } |
|
598 |
|
599 _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): end"); |
|
600 } |
|
601 |
|
602 // ----------------------------------------------------------------------------- |
|
603 // CNSmlDmEmailAdapter::FetchLeafObjectL( const TDesC8& aURI, |
|
604 // const TDesC8& aLUID, |
|
605 // const TDesC8& aType, |
|
606 // const TInt aResultsRef, |
|
607 // const TInt aStatusRef ) |
|
608 // |
|
609 // ----------------------------------------------------------------------------- |
|
610 void CNSmlDmEmailAdapter::FetchLeafObjectL( const TDesC8& aURI, |
|
611 const TDesC8& aLUID, |
|
612 const TDesC8& aType, |
|
613 const TInt aResultsRef, |
|
614 const TInt aStatusRef ) |
|
615 { |
|
616 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): begin"); |
|
617 |
|
618 TInt luid = DesToInt(aLUID); |
|
619 |
|
620 if(aLUID.Length()==0) |
|
621 { |
|
622 luid = ConstructTreeL(aURI); |
|
623 if(luid == -1) |
|
624 { |
|
625 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound); |
|
626 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): ENotFound end"); |
|
627 return; |
|
628 } |
|
629 } |
|
630 if( OpenSessionL() != KErrNone ) |
|
631 { |
|
632 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
633 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): EError end"); |
|
634 return; |
|
635 } |
|
636 |
|
637 TInt index = -1; |
|
638 for(TInt i=0;i<iBuffer->Count();i++) |
|
639 { |
|
640 if(iBuffer->At(i).iLuid == luid) |
|
641 { |
|
642 index = i; |
|
643 break; |
|
644 } |
|
645 } |
|
646 |
|
647 if(index<0) |
|
648 { |
|
649 TNSmlEmailSettingsElement newNode; |
|
650 newNode.iImap4Settings = NULL; |
|
651 newNode.iPop3Settings = NULL; |
|
652 newNode.iSmtpSettings = NULL; |
|
653 newNode.iIapPref = NULL; |
|
654 newNode.iSmtpIapPref = NULL; |
|
655 newNode.iLuid = luid; |
|
656 newNode.iMappingName = aURI.AllocLC(); |
|
657 newNode.iName = HBufC::NewLC(0); |
|
658 newNode.iNodeBuf = new (ELeave) |
|
659 CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity); |
|
660 newNode.iExecuted = ETrue; |
|
661 newNode.iJustFetch = ETrue; |
|
662 GetIdByLuid(newNode.iAccType, newNode.iAccId, luid); |
|
663 iBuffer->AppendL(newNode); |
|
664 index = iBuffer->Count() - 1; |
|
665 if( DoRestoreSettingsL(index) != KErrNone ) |
|
666 { |
|
667 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
668 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
669 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): EError end"); |
|
670 return; |
|
671 } |
|
672 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
673 } |
|
674 |
|
675 TPtrC8 lastUriSeg = LastURISeg(aURI); |
|
676 CBufBase* object = CBufFlat::NewL(32); |
|
677 CleanupStack::PushL(object); |
|
678 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
679 |
|
680 if(lastUriSeg.Compare(KNSmlDMEmailName)==0) |
|
681 { |
|
682 HBufC8 *data = HBufC8::NewLC(iBuffer->At(index).iName->Length()); |
|
683 TPtr8 dataPtr = data->Des(); |
|
684 CnvUtfConverter::ConvertFromUnicodeToUtf8( |
|
685 dataPtr,iBuffer->At(index).iName->Des() ); |
|
686 object->InsertL(0,dataPtr); |
|
687 CleanupStack::PopAndDestroy(); //data |
|
688 } |
|
689 |
|
690 else if(lastUriSeg.Compare(KNSmlDMEmailUID)==0) |
|
691 { |
|
692 HBufC *data = NULL; |
|
693 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
694 { |
|
695 data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->LoginName().Length()); |
|
696 data->Des().Copy(iBuffer->At(index).iPop3Settings->LoginName()); |
|
697 } |
|
698 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
699 { |
|
700 data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->LoginName().Length()); |
|
701 data->Des().Copy(iBuffer->At(index).iImap4Settings->LoginName()); |
|
702 } |
|
703 if(data) |
|
704 { |
|
705 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
706 CleanupStack::PushL(data8); |
|
707 object->InsertL(0,*data8); |
|
708 CleanupStack::PopAndDestroy(2);//data, data8 |
|
709 } |
|
710 } |
|
711 |
|
712 else if(lastUriSeg.Compare(KNSmlDMEmailPW)==0) |
|
713 { |
|
714 HBufC *data = NULL; |
|
715 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
716 { |
|
717 data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->Password().Length()); |
|
718 data->Des().Copy(iBuffer->At(index).iPop3Settings->Password()); |
|
719 } |
|
720 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
721 { |
|
722 data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->Password().Length()); |
|
723 data->Des().Copy(iBuffer->At(index).iImap4Settings->Password()); |
|
724 } |
|
725 if(data) |
|
726 { |
|
727 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
728 CleanupStack::PushL(data8); |
|
729 object->InsertL(0,*data8); |
|
730 CleanupStack::PopAndDestroy(2);//data, data8 |
|
731 } |
|
732 } |
|
733 |
|
734 else if(lastUriSeg.Compare(KNSmlDMEmailUAddr)==0) |
|
735 { |
|
736 HBufC *data = NULL; |
|
737 data = iBuffer->At(index).iSmtpSettings->EmailAddress().AllocLC(); |
|
738 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
739 TPtr8 dataPtr8 = data8->Des(); |
|
740 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
741 |
|
742 object->InsertL(0,dataPtr8); |
|
743 CleanupStack::PopAndDestroy(2); //data, data8 |
|
744 } |
|
745 |
|
746 else if(lastUriSeg.Compare(KNSmlDMEmailUName)==0) |
|
747 { |
|
748 |
|
749 HBufC *data = NULL; |
|
750 data = iBuffer->At(index).iSmtpSettings->EmailAlias().AllocLC(); |
|
751 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
752 TPtr8 dataPtr8 = data8->Des(); |
|
753 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
754 |
|
755 object->InsertL(0,dataPtr8); |
|
756 CleanupStack::PopAndDestroy(2); //data, data8 |
|
757 } |
|
758 |
|
759 else if(lastUriSeg.Compare( KNSmlDMEmailMrcv)==0) |
|
760 { |
|
761 HBufC *data = NULL; |
|
762 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
763 { |
|
764 data = iBuffer->At(index).iPop3Settings->ServerAddress().AllocLC(); |
|
765 } |
|
766 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
767 { |
|
768 data = iBuffer->At(index).iImap4Settings->ServerAddress().AllocLC(); |
|
769 } |
|
770 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
771 TPtr8 dataPtr8 = data8->Des(); |
|
772 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
773 |
|
774 object->InsertL(0,dataPtr8); |
|
775 CleanupStack::PopAndDestroy(2); //data, data8 |
|
776 } |
|
777 |
|
778 else if(lastUriSeg.Compare(KNSmlDMEmailMsnd)==0) |
|
779 { |
|
780 HBufC *data = NULL; |
|
781 data = iBuffer->At(index).iSmtpSettings->ServerAddress().AllocLC(); |
|
782 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
783 TPtr8 dataPtr8 = data8->Des(); |
|
784 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
785 |
|
786 object->InsertL(0,dataPtr8); |
|
787 CleanupStack::PopAndDestroy(2); //data, data8 |
|
788 } |
|
789 |
|
790 else if(lastUriSeg.Compare(KNSmlDMEmailMpro)==0) |
|
791 { |
|
792 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
793 { |
|
794 object->InsertL(0,KNSmlDMEmailMproPOP); |
|
795 } |
|
796 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
797 { |
|
798 object->InsertL(0,KNSmlDMEmailMproIMAP); |
|
799 } |
|
800 } |
|
801 |
|
802 else if(lastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0) |
|
803 { |
|
804 FetchSecurityValueL(*object, &iBuffer->At(index), EUseSecCon ); |
|
805 } |
|
806 |
|
807 else if(lastUriSeg.Compare(KNSmlDMEmailUseSauth)==0) |
|
808 { |
|
809 if(iBuffer->At(index).iSmtpSettings->SMTPAuth()) |
|
810 { |
|
811 object->InsertL(0,KNSmlDMEmailTrue); |
|
812 } |
|
813 else |
|
814 { |
|
815 object->InsertL(0,KNSmlDMEmailFalse); |
|
816 } |
|
817 } |
|
818 |
|
819 else if(lastUriSeg.Compare(KNSmlDMEmailSauthUID)==0) |
|
820 { |
|
821 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->LoginName().Length()); |
|
822 data->Des().Copy(iBuffer->At(index).iSmtpSettings->LoginName()); |
|
823 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
824 CleanupStack::PushL(data8); |
|
825 object->InsertL(0,*data8); |
|
826 CleanupStack::PopAndDestroy(2);//data, data8 |
|
827 } |
|
828 |
|
829 else if(lastUriSeg.Compare(KNSmlDMEmailSauthPW)==0) |
|
830 { |
|
831 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->Password().Length()); |
|
832 data->Des().Copy(iBuffer->At(index).iSmtpSettings->Password()); |
|
833 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
834 CleanupStack::PushL(data8); |
|
835 object->InsertL(0,*data8); |
|
836 CleanupStack::PopAndDestroy(2);//data, data8 |
|
837 } |
|
838 |
|
839 else if(lastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0) |
|
840 { |
|
841 if(iBuffer->At(index).iSmtpSettings->InboxLoginDetails()) |
|
842 { |
|
843 object->InsertL(0,KNSmlDMEmailTrue); |
|
844 } |
|
845 else |
|
846 { |
|
847 object->InsertL(0,KNSmlDMEmailFalse); |
|
848 } |
|
849 } |
|
850 |
|
851 else if (lastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0) |
|
852 { |
|
853 FetchSecurityValueL(*object, &iBuffer->At(index), ESuseSecCon ); |
|
854 } |
|
855 |
|
856 else if (lastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0) |
|
857 { |
|
858 FetchSecurityValueL(*object, &iBuffer->At(index), EUseStartTls ); |
|
859 } |
|
860 |
|
861 else if (lastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0) |
|
862 { |
|
863 FetchSecurityValueL(*object, &iBuffer->At(index), ESuseStartTls ); |
|
864 } |
|
865 |
|
866 else if(lastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0) |
|
867 { |
|
868 TUint port; |
|
869 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
870 { |
|
871 port = iBuffer->At(index).iPop3Settings->Port(); |
|
872 } |
|
873 else |
|
874 { |
|
875 port = iBuffer->At(index).iImap4Settings->Port(); |
|
876 } |
|
877 HBufC8 *data = IntToDes8LC(port); |
|
878 object->InsertL(0,data->Des()); |
|
879 CleanupStack::PopAndDestroy(); //data |
|
880 } |
|
881 |
|
882 else if(lastUriSeg.Compare(KNSmlDMEmailMsndPort)==0) |
|
883 { |
|
884 TUint port = iBuffer->At(index).iSmtpSettings->Port(); |
|
885 HBufC8 *data = IntToDes8LC(port); |
|
886 object->InsertL(0,data->Des()); |
|
887 CleanupStack::PopAndDestroy(); //data |
|
888 } |
|
889 |
|
890 else if(lastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0) |
|
891 { |
|
892 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
893 { |
|
894 if(iBuffer->At(index).iPop3Settings->Apop()) |
|
895 { |
|
896 object->InsertL(0,KNSmlDMEmailTrue); |
|
897 } |
|
898 else |
|
899 { |
|
900 object->InsertL(0,KNSmlDMEmailFalse); |
|
901 } |
|
902 } |
|
903 else |
|
904 { |
|
905 status = CSmlDmAdapter::ENotFound; |
|
906 } |
|
907 } |
|
908 |
|
909 else if (lastUriSeg.Compare(KNSmlDMEmailFolderPath)==0) |
|
910 { |
|
911 if(iBuffer->At(index).iImap4Settings) |
|
912 { |
|
913 object->InsertL(0, iBuffer->At(index).iImap4Settings->FolderPath() ); |
|
914 } |
|
915 else |
|
916 { |
|
917 status = CSmlDmAdapter::ENotFound; |
|
918 } |
|
919 } |
|
920 |
|
921 else if(lastUriSeg.Compare(KNSmlDMEmailToNapID)==0) |
|
922 { |
|
923 |
|
924 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
925 CleanupStack::PushL(iapmatch); |
|
926 HBufC8* uri8 = NULL; |
|
927 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
928 if ( iapCount ) |
|
929 { |
|
930 TImIAPChoice localIAP = iBuffer->At(index).iIapPref->IAPPreference(0); |
|
931 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
932 } |
|
933 |
|
934 if( uri8 ) |
|
935 { |
|
936 CleanupStack::PushL(uri8); |
|
937 object->InsertL(0,uri8->Des()); |
|
938 status = CSmlDmAdapter::EOk; |
|
939 CleanupStack::PopAndDestroy(); // uri8 |
|
940 } |
|
941 else |
|
942 { |
|
943 status = CSmlDmAdapter::ENotFound; |
|
944 } |
|
945 |
|
946 CleanupStack::PopAndDestroy(); // iapMatch |
|
947 } |
|
948 else if(lastUriSeg.Compare(KNSmlDMEmailSToNapID)==0) |
|
949 { |
|
950 |
|
951 // SToNapID exists only for SMTP |
|
952 if (iBuffer->At(index).iSmtpSettings!= NULL) |
|
953 { |
|
954 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
955 CleanupStack::PushL(iapmatch); |
|
956 HBufC8* uri8 = NULL; |
|
957 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
958 if ( iapCount ) |
|
959 { |
|
960 TImIAPChoice localIAP = iBuffer->At(index).iSmtpIapPref->IAPPreference(0); |
|
961 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
962 } |
|
963 |
|
964 if( uri8 ) |
|
965 { |
|
966 CleanupStack::PushL(uri8); |
|
967 object->InsertL(0,uri8->Des()); |
|
968 status = CSmlDmAdapter::EOk; |
|
969 CleanupStack::PopAndDestroy(); // uri8 |
|
970 } |
|
971 else |
|
972 { |
|
973 status = CSmlDmAdapter::ENotFound; |
|
974 } |
|
975 |
|
976 CleanupStack::PopAndDestroy(); // iapMatch |
|
977 } |
|
978 else |
|
979 { |
|
980 status = CSmlDmAdapter::ENotFound; |
|
981 } |
|
982 } |
|
983 |
|
984 if(status == CSmlDmAdapter::EOk) |
|
985 { |
|
986 Callback().SetResultsL(aResultsRef,*object,aType); |
|
987 } |
|
988 Callback().SetStatusL(aStatusRef, status); |
|
989 CleanupStack::PopAndDestroy(object); //object |
|
990 |
|
991 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): end"); |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CNSmlDmEmailAdapter::ChildURIListL( const TDesC8& aURI, |
|
996 // const TDesC8& aParentLUID, |
|
997 // const CArrayFix<TSmlDmMappingInfo>& |
|
998 // aPreviousURISegmentList, |
|
999 // const TInt aResultsRef, |
|
1000 // const TInt aStatusRef ) |
|
1001 // ----------------------------------------------------------------------------- |
|
1002 void CNSmlDmEmailAdapter::ChildURIListL( const TDesC8& aURI, |
|
1003 const TDesC8& aParentLUID, |
|
1004 const CArrayFix<TSmlDmMappingInfo>& |
|
1005 aPreviousURISegmentList, |
|
1006 const TInt aResultsRef, |
|
1007 const TInt aStatusRef ) |
|
1008 { |
|
1009 _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): begin"); |
|
1010 |
|
1011 CSmlDmAdapter::TError ret = CSmlDmAdapter::EError; |
|
1012 |
|
1013 if( OpenSessionL() != KErrNone ) |
|
1014 { |
|
1015 Callback().SetStatusL(aStatusRef, ret); |
|
1016 _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): end"); |
|
1017 return; |
|
1018 } |
|
1019 CBufBase *currentList = CBufFlat::NewL(128); |
|
1020 CleanupStack::PushL(currentList); |
|
1021 |
|
1022 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
1023 |
|
1024 if(aURI.Compare(KNSmlDMEmailNodeName)==0) |
|
1025 { |
|
1026 RArray<TImapAccount> imap4Accounts; |
|
1027 CleanupClosePushL( imap4Accounts ); |
|
1028 emailAccs->GetImapAccountsL(imap4Accounts); |
|
1029 |
|
1030 // First, IMAP accounts |
|
1031 // |
|
1032 TInt luid; |
|
1033 TPtrC8 name; |
|
1034 // cycle through every found account |
|
1035 for(TInt count = 0; count < imap4Accounts.Count(); count++) |
|
1036 { |
|
1037 SetLuidById( EImap, imap4Accounts[count].iImapAccountId, luid ); |
|
1038 |
|
1039 TBool found = EFalse; |
|
1040 // cycle through every known account |
|
1041 for(TInt i = 0; i<aPreviousURISegmentList.Count();i++) |
|
1042 { |
|
1043 // compare if found is known |
|
1044 if( luid == DesToInt(aPreviousURISegmentList.At(i).iURISegLUID)) |
|
1045 { |
|
1046 found = ETrue; |
|
1047 name.Set(aPreviousURISegmentList.At(i).iURISeg); |
|
1048 break; |
|
1049 } |
|
1050 } |
|
1051 // if found != known add mapping to it |
|
1052 if(!found) |
|
1053 { |
|
1054 HBufC8 *uri = HBufC8::NewLC(aURI.Length() + |
|
1055 KNSmlDMEmailMproIMAP().Length() + 6); |
|
1056 |
|
1057 TPtr8 uriPtr = uri->Des(); |
|
1058 uriPtr.Format(aURI); |
|
1059 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
1060 uriPtr.Append(KNSmlDMEmailMproIMAP); |
|
1061 TUint16 crc; |
|
1062 Mem::Crc ( crc, &imap4Accounts[count],sizeof(TImapAccount) ); |
|
1063 HBufC8 *crcBuf = IntToDes8LC(crc); |
|
1064 uriPtr.Append(*crcBuf); |
|
1065 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
1066 Callback().SetMappingL(uriPtr,luidBuf->Des()); |
|
1067 currentList->InsertL( currentList->Size(),LastURISeg(uriPtr)); |
|
1068 CleanupStack::PopAndDestroy(3); //uri,luidBuf, crcBuf |
|
1069 } |
|
1070 else |
|
1071 { |
|
1072 currentList->InsertL( currentList->Size(),name ); |
|
1073 } |
|
1074 // in all cases: add it to results. |
|
1075 if(count < imap4Accounts.Count()-1 ) |
|
1076 { |
|
1077 currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8); |
|
1078 } |
|
1079 } |
|
1080 CleanupStack::PopAndDestroy(); //imap4Accounts |
|
1081 |
|
1082 // Then, POP accounts |
|
1083 // |
|
1084 RArray<TPopAccount> pop3Accounts; |
|
1085 CleanupClosePushL( pop3Accounts ); |
|
1086 emailAccs->GetPopAccountsL( pop3Accounts ); |
|
1087 if (pop3Accounts.Count()&¤tList->Size()>0) |
|
1088 { |
|
1089 // there is at least one account; insert separator |
|
1090 currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8); |
|
1091 } |
|
1092 // cycle through every found account |
|
1093 for(TInt count = 0; count < pop3Accounts.Count(); count++) |
|
1094 { |
|
1095 SetLuidById( EPop, pop3Accounts[count].iPopAccountId, luid ); |
|
1096 |
|
1097 TBool found = EFalse; |
|
1098 // cycle through every known account |
|
1099 for(TInt i = 0; i<aPreviousURISegmentList.Count();i++) |
|
1100 { |
|
1101 // compare if found is known |
|
1102 if( luid == DesToInt(aPreviousURISegmentList.At(i).iURISegLUID)) |
|
1103 |
|
1104 { |
|
1105 found = ETrue; |
|
1106 name.Set(aPreviousURISegmentList.At(i).iURISeg); |
|
1107 break; |
|
1108 } |
|
1109 } |
|
1110 // if found != known add mapping to it |
|
1111 if(!found) |
|
1112 { |
|
1113 |
|
1114 HBufC8 *uri = HBufC8::NewLC(aURI.Length() + |
|
1115 KNSmlDMEmailMproPOP().Length() + 5); |
|
1116 TPtr8 uriPtr = uri->Des(); |
|
1117 uriPtr.Format(aURI); |
|
1118 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
1119 uriPtr.Append(KNSmlDMEmailMproPOP); |
|
1120 TUint16 crc; |
|
1121 Mem::Crc ( crc, &pop3Accounts[count],sizeof(TPopAccount) ); |
|
1122 HBufC8 *crcBuf = IntToDes8LC(crc); |
|
1123 uriPtr.Append(*crcBuf); |
|
1124 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
1125 Callback().SetMappingL(uriPtr,luidBuf->Des()); |
|
1126 currentList->InsertL( currentList->Size(),LastURISeg(uriPtr)); |
|
1127 CleanupStack::PopAndDestroy(3); //uri,luidBuf,crcBuf |
|
1128 } |
|
1129 else |
|
1130 { |
|
1131 currentList->InsertL( currentList->Size(),name ); |
|
1132 } |
|
1133 // in all cases: add it to results. |
|
1134 if(count < pop3Accounts.Count()-1) |
|
1135 { |
|
1136 currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8); |
|
1137 } |
|
1138 } |
|
1139 CleanupStack::PopAndDestroy(); //pop3Accounts |
|
1140 ret = CSmlDmAdapter::EOk; |
|
1141 } |
|
1142 else |
|
1143 { |
|
1144 if(aParentLUID.Length() > 0) |
|
1145 { |
|
1146 TInt err = KErrNotFound; |
|
1147 TInt luid = DesToInt(aParentLUID); |
|
1148 TNSmlEmailAccountType accType; |
|
1149 TInt id; |
|
1150 GetIdByLuid( accType, id, luid ); |
|
1151 switch ( accType ) |
|
1152 { |
|
1153 case EImap: |
|
1154 { |
|
1155 RArray<TImapAccount> imap4Accounts; |
|
1156 CleanupClosePushL( imap4Accounts ); |
|
1157 emailAccs->GetImapAccountsL( imap4Accounts ); |
|
1158 for ( TInt i=0; i<imap4Accounts.Count(); i++ ) |
|
1159 { |
|
1160 if ( imap4Accounts[i].iImapAccountId == id ) |
|
1161 { |
|
1162 err = KErrNone; |
|
1163 break; |
|
1164 } |
|
1165 } |
|
1166 CleanupStack::PopAndDestroy(); //imap4Accounts |
|
1167 break; |
|
1168 } |
|
1169 case EPop: |
|
1170 { |
|
1171 RArray<TPopAccount> pop3Accounts; |
|
1172 CleanupClosePushL( pop3Accounts ); |
|
1173 emailAccs->GetPopAccountsL(pop3Accounts); |
|
1174 for ( TInt i=0; i<pop3Accounts.Count(); i++ ) |
|
1175 { |
|
1176 if ( pop3Accounts[i].iPopAccountId == id ) |
|
1177 { |
|
1178 err = KErrNone; |
|
1179 break; |
|
1180 } |
|
1181 } |
|
1182 CleanupStack::PopAndDestroy(); //pop3Accounts |
|
1183 break; |
|
1184 } |
|
1185 default: |
|
1186 ret = CSmlDmAdapter::EError; |
|
1187 break; |
|
1188 } |
|
1189 if( err == KErrNotFound ) |
|
1190 { |
|
1191 ret = CSmlDmAdapter::ENotFound; |
|
1192 } |
|
1193 |
|
1194 if ( err == KErrNone ) |
|
1195 { |
|
1196 ret = CSmlDmAdapter::EOk; |
|
1197 currentList->InsertL(0,KNSmlDMEmailListOfLeafs); |
|
1198 } |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 ret = CSmlDmAdapter::ENotFound; |
|
1203 } |
|
1204 } |
|
1205 // Common part |
|
1206 Callback().SetStatusL(aStatusRef, ret); |
|
1207 if( ret == CSmlDmAdapter::EOk ) |
|
1208 { |
|
1209 Callback().SetResultsL(aResultsRef,*currentList,KNullDesC8); |
|
1210 } |
|
1211 |
|
1212 CleanupStack::PopAndDestroy(emailAccs); //emailAccs |
|
1213 CleanupStack::PopAndDestroy(currentList); //currentList |
|
1214 _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): end"); |
|
1215 } |
|
1216 |
|
1217 // ----------------------------------------------------------------------------- |
|
1218 // CNSmlDmEmailAdapter::AddNodeObjectL( const TDesC8& aURI, |
|
1219 // const TDesC8& aParentLUID, const TInt aStatusRef ) |
|
1220 // ----------------------------------------------------------------------------- |
|
1221 void CNSmlDmEmailAdapter::AddNodeObjectL( const TDesC8& aURI, |
|
1222 const TDesC8& aParentLUID, |
|
1223 const TInt aStatusRef ) |
|
1224 { |
|
1225 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): begin"); |
|
1226 |
|
1227 if(aParentLUID.Length()>0) |
|
1228 { |
|
1229 TInt luid = DesToInt(aParentLUID); |
|
1230 TInt accId; |
|
1231 TNSmlEmailAccountType accType; |
|
1232 GetIdByLuid( accType, accId, luid ); |
|
1233 TInt err = OpenSessionL(); |
|
1234 if(err!=KErrNone) |
|
1235 { |
|
1236 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1237 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end"); |
|
1238 return; |
|
1239 } |
|
1240 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
1241 TBool accEx = AccountExistsL( emailAccs, accType, accId, -1 ); |
|
1242 CleanupStack::PopAndDestroy( emailAccs ); |
|
1243 if( accEx ) |
|
1244 { |
|
1245 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EAlreadyExists); |
|
1246 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EAlreadyExists end"); |
|
1247 return; |
|
1248 } |
|
1249 Callback().SetMappingL(aURI,KNullDesC8); |
|
1250 } |
|
1251 |
|
1252 if( aURI.Find(KNSmlDMEmailNodeName)>=0 && NumOfURISegs(aURI)==2 ) |
|
1253 { |
|
1254 if( OpenSessionL() != KErrNone ) |
|
1255 { |
|
1256 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1257 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end"); |
|
1258 return; |
|
1259 } |
|
1260 |
|
1261 RFs fs; |
|
1262 User::LeaveIfError( fs.Connect() ); |
|
1263 CleanupClosePushL(fs); |
|
1264 //2files and 2 folders are needed for settings |
|
1265 if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs, |
|
1266 KNSmlDmFatMinimumFileSize*4)) |
|
1267 { |
|
1268 CleanupStack::PopAndDestroy(); //fs |
|
1269 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EDiskFull); |
|
1270 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EDiskFull end"); |
|
1271 return; |
|
1272 // do not write |
|
1273 } |
|
1274 CleanupStack::PopAndDestroy(); //fs |
|
1275 |
|
1276 |
|
1277 TNSmlEmailSettingsElement newNode; |
|
1278 newNode.iMappingName = aURI.AllocLC(); |
|
1279 newNode.iName = HBufC::NewLC(0); |
|
1280 newNode.iNodeBuf = new (ELeave) |
|
1281 CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity); |
|
1282 newNode.iExecuted = EFalse; |
|
1283 newNode.iImap4Settings = NULL; |
|
1284 newNode.iPop3Settings = NULL; |
|
1285 newNode.iSmtpSettings = NULL; |
|
1286 newNode.iIapPref = NULL; |
|
1287 newNode.iSmtpIapPref = NULL; |
|
1288 newNode.iLuid = 0; |
|
1289 newNode.iJustFetch=EFalse; |
|
1290 iBuffer->AppendL(newNode); |
|
1291 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
1292 TNSmlEmailCommandElement newCommand; |
|
1293 newCommand.iLastUriSeg = LastURISeg(aURI).AllocLC(); //aURI.AllocLC(); |
|
1294 newCommand.iData = NULL; |
|
1295 newCommand.iStatusRef = aStatusRef; |
|
1296 newCommand.iLeaf = EFalse; |
|
1297 newCommand.iStatus = CSmlDmAdapter::EOk; |
|
1298 TInt index = iBuffer->Count() - 1; |
|
1299 iBuffer->At(index).iNodeBuf->AppendL(newCommand); |
|
1300 CleanupStack::Pop(); //newCommand.iLastUriSeg |
|
1301 |
|
1302 |
|
1303 } |
|
1304 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): end"); |
|
1305 } |
|
1306 // ----------------------------------------------------------------------------- |
|
1307 // CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
1308 // const TDesC8& aLUID, RWriteStream*& aStream, const TDesC8& aType, |
|
1309 // const TInt aStatusRef ) |
|
1310 // This should update a stream object, but in case of Email settings streaming |
|
1311 // is not supported. |
|
1312 // ----------------------------------------------------------------------------- |
|
1313 void CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& /*aURI*/, |
|
1314 const TDesC8& /*aLUID*/, |
|
1315 RWriteStream*& /*aStream*/, |
|
1316 const TDesC8& /*aType*/, |
|
1317 const TInt aStatusRef ) |
|
1318 { |
|
1319 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(stream): begin"); |
|
1320 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1321 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(stream): end"); |
|
1322 } |
|
1323 // ----------------------------------------------------------------------------- |
|
1324 // void CNSmlDmEmailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
1325 // const TDesC8& aLUID, const TDesC8& aType, const TInt aResultsRef, |
|
1326 // const TInt aStatusRef ) |
|
1327 // Fetches data object and returns its size. |
|
1328 // ----------------------------------------------------------------------------- |
|
1329 void CNSmlDmEmailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
1330 const TDesC8& aLUID, |
|
1331 const TDesC8& aType, |
|
1332 const TInt aResultsRef, |
|
1333 const TInt aStatusRef ) |
|
1334 { |
|
1335 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectSizeL(): begin"); |
|
1336 |
|
1337 CBufBase *result = CBufFlat::NewL(32); |
|
1338 CleanupStack::PushL(result); |
|
1339 CSmlDmAdapter::TError status = FetchObjectL(aURI, aLUID, *result); |
|
1340 if( status == CSmlDmAdapter::EOk ) |
|
1341 { |
|
1342 TInt objSizeInBytes = result->Size(); |
|
1343 TBuf8<4> stringObjSizeInBytes; |
|
1344 stringObjSizeInBytes.Num( objSizeInBytes ); |
|
1345 result->Reset(); |
|
1346 result->InsertL( 0, stringObjSizeInBytes ); |
|
1347 Callback().SetResultsL(aResultsRef, *result, aType); |
|
1348 } |
|
1349 Callback().SetStatusL(aStatusRef, status); |
|
1350 CleanupStack::PopAndDestroy(); //result |
|
1351 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectSizeL(): end"); |
|
1352 } |
|
1353 // ----------------------------------------------------------------------------- |
|
1354 // CNSmlDmEmailAdapter::ExecuteCommandL() |
|
1355 // ----------------------------------------------------------------------------- |
|
1356 void CNSmlDmEmailAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, |
|
1357 const TDesC8& /*aLUID*/, |
|
1358 const TDesC8& /*aArgument*/, |
|
1359 const TDesC8& /*aType*/, |
|
1360 const TInt aStatusRef ) |
|
1361 { |
|
1362 //Not supported |
|
1363 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): begin"); |
|
1364 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1365 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): end"); |
|
1366 } |
|
1367 |
|
1368 // ----------------------------------------------------------------------------- |
|
1369 // CNSmlDmEmailAdapter::ExecuteCommandL() |
|
1370 // ----------------------------------------------------------------------------- |
|
1371 void CNSmlDmEmailAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, |
|
1372 const TDesC8& /*aLUID*/, |
|
1373 RWriteStream*& /*aStream*/, |
|
1374 const TDesC8& /*aType*/, |
|
1375 const TInt aStatusRef ) |
|
1376 { |
|
1377 //Not supported |
|
1378 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): begin"); |
|
1379 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1380 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): end"); |
|
1381 } |
|
1382 |
|
1383 // ----------------------------------------------------------------------------- |
|
1384 // CNSmlDmEmailAdapter::CopyCommandL() |
|
1385 // ----------------------------------------------------------------------------- |
|
1386 void CNSmlDmEmailAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, |
|
1387 const TDesC8& /*aTargetLUID*/, |
|
1388 const TDesC8& /*aSourceURI*/, |
|
1389 const TDesC8& /*aSourceLUID*/, |
|
1390 const TDesC8& /*aType*/, |
|
1391 TInt aStatusRef ) |
|
1392 { |
|
1393 //Not supported |
|
1394 _DBG_FILE("CNSmlDmEmailAdapter::CopyCommandL(): begin"); |
|
1395 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1396 _DBG_FILE("CNSmlDmEmailAdapter::CopyCommandL(): end"); |
|
1397 } |
|
1398 |
|
1399 // ----------------------------------------------------------------------------- |
|
1400 // CNSmlDmEmailAdapter::StartAtomicL() |
|
1401 // ----------------------------------------------------------------------------- |
|
1402 void CNSmlDmEmailAdapter::StartAtomicL() |
|
1403 { |
|
1404 //Not supported |
|
1405 _DBG_FILE("CNSmlDmEmailAdapter::StartAtomicL(): begin"); |
|
1406 _DBG_FILE("CNSmlDmEmailAdapter::StartAtomicL(): end"); |
|
1407 } |
|
1408 |
|
1409 // ----------------------------------------------------------------------------- |
|
1410 // CNSmlDmEmailAdapter::CommitAtomicL() |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 void CNSmlDmEmailAdapter::CommitAtomicL() |
|
1413 { |
|
1414 //Not supported |
|
1415 _DBG_FILE("CNSmlDmEmailAdapter::CommitAtomicL(): begin"); |
|
1416 _DBG_FILE("CNSmlDmEmailAdapter::CommitAtomicL(): end"); |
|
1417 } |
|
1418 |
|
1419 // ----------------------------------------------------------------------------- |
|
1420 // CNSmlDmEmailAdapter::RollbackAtomicL() |
|
1421 // ----------------------------------------------------------------------------- |
|
1422 void CNSmlDmEmailAdapter::RollbackAtomicL() |
|
1423 { |
|
1424 //Not supported |
|
1425 _DBG_FILE("CNSmlDmEmailAdapter::RollbackAtomicL(): begin"); |
|
1426 _DBG_FILE("CNSmlDmEmailAdapter::RollbackAtomicL(): end"); |
|
1427 } |
|
1428 |
|
1429 // ----------------------------------------------------------------------------- |
|
1430 // CNSmlDmEmailAdapter::StreamingSupport() |
|
1431 // ----------------------------------------------------------------------------- |
|
1432 TBool CNSmlDmEmailAdapter::StreamingSupport( TInt& /*aItemSize*/ ) |
|
1433 { |
|
1434 _DBG_FILE("CNSmlDmEmailAdapter::StreamingSupport(): begin"); |
|
1435 _DBG_FILE("CNSmlDmEmailAdapter::StreamingSupport(): end"); |
|
1436 return EFalse; |
|
1437 } |
|
1438 |
|
1439 // ----------------------------------------------------------------------------- |
|
1440 // CNSmlDmEmailAdapter::StreamCommittedL() |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 void CNSmlDmEmailAdapter::StreamCommittedL() |
|
1443 { |
|
1444 //Not supported |
|
1445 _DBG_FILE("CNSmlDmEmailAdapter::StreamCommittedL(): begin"); |
|
1446 _DBG_FILE("CNSmlDmEmailAdapter::StreamCommittedL(): end"); |
|
1447 } |
|
1448 // ----------------------------------------------------------------------------- |
|
1449 // CNSmlDmEmailAdapter::CompleteOutstandingCmdsL() |
|
1450 // Indication of message ending. The buffered commands must be executed |
|
1451 // before return of this function. |
|
1452 // ----------------------------------------------------------------------------- |
|
1453 void CNSmlDmEmailAdapter::CompleteOutstandingCmdsL() |
|
1454 { |
|
1455 _DBG_FILE("CNSmlDmEmailAdapter::CompleteOutstandingCmdsL(): begin"); |
|
1456 |
|
1457 for(TInt i=0;i<iBuffer->Count();i++) |
|
1458 { |
|
1459 |
|
1460 //Set buffered port values |
|
1461 for(TInt cmd=0;cmd<iBuffer->At(i).iNodeBuf->Count();cmd++) |
|
1462 { |
|
1463 |
|
1464 TNSmlEmailSettingsElement& bufElem = iBuffer->At(i); |
|
1465 TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(cmd); |
|
1466 |
|
1467 if(elem.iLastUriSeg->Compare(KNSmlDMEmailMrcvPort)==0) |
|
1468 { |
|
1469 TUint port = DesToInt(*elem.iData); |
|
1470 |
|
1471 if(port>0 && port <= KNSmlDMEmailMaxPortNbr) |
|
1472 { |
|
1473 if(bufElem.iPop3Settings!= NULL) |
|
1474 { |
|
1475 bufElem.iPop3Settings->SetPort(port); |
|
1476 } |
|
1477 else if(bufElem.iImap4Settings!= NULL) |
|
1478 { |
|
1479 bufElem.iImap4Settings->SetPort(port); |
|
1480 } |
|
1481 } |
|
1482 else |
|
1483 { |
|
1484 elem.iStatus = CSmlDmAdapter::EInvalidObject; |
|
1485 } |
|
1486 } |
|
1487 else if(elem.iLastUriSeg->Compare(KNSmlDMEmailMsndPort)==0) |
|
1488 { |
|
1489 TUint port = DesToInt(*elem.iData); |
|
1490 |
|
1491 if(port>0 && port <= KNSmlDMEmailMaxPortNbr) |
|
1492 { |
|
1493 bufElem.iSmtpSettings->SetPort(port); |
|
1494 } |
|
1495 else |
|
1496 { |
|
1497 elem.iStatus = CSmlDmAdapter::EInvalidObject; |
|
1498 } |
|
1499 } |
|
1500 if((iBuffer->At(i).iSmtpSettings->LoginName()==KNullDesC8) && elem.iLastUriSeg->Compare(KNSmlDMEmailUID)==0) |
|
1501 { |
|
1502 elem.iStatus = CSmlDmAdapter::EError; |
|
1503 } |
|
1504 } |
|
1505 |
|
1506 |
|
1507 CSmlDmAdapter::TError stat = CSmlDmAdapter::EOk; |
|
1508 TInt luid=-1; |
|
1509 |
|
1510 if(iBuffer->At(i).iExecuted) |
|
1511 { |
|
1512 TRAPD( leaveCode,luid = ValidateAndStoreSettingsL(i) ); |
|
1513 if(leaveCode!=KErrNone) |
|
1514 { |
|
1515 stat = CSmlDmAdapter::EError; |
|
1516 } |
|
1517 } |
|
1518 else |
|
1519 { |
|
1520 stat = CSmlDmAdapter::EError; |
|
1521 } |
|
1522 |
|
1523 for(TInt cmd=0;cmd<iBuffer->At(i).iNodeBuf->Count();cmd++) |
|
1524 { |
|
1525 |
|
1526 if(iBuffer->At(i).iNodeBuf->At(cmd).iStatus==CSmlDmAdapter::EOk) |
|
1527 { |
|
1528 Callback().SetStatusL(iBuffer->At(i).iNodeBuf->At(cmd).iStatusRef, |
|
1529 stat); |
|
1530 if(!iBuffer->At(i).iNodeBuf->At(cmd).iLeaf) |
|
1531 { |
|
1532 if(stat==CSmlDmAdapter::EOk) |
|
1533 { |
|
1534 HBufC8* luidDes = IntToDes8LC(luid); |
|
1535 Callback().SetMappingL( iBuffer->At(i).iMappingName->Des(), |
|
1536 luidDes->Des() ); |
|
1537 CleanupStack::PopAndDestroy(); //luidDes |
|
1538 } |
|
1539 } |
|
1540 } |
|
1541 else |
|
1542 { |
|
1543 Callback().SetStatusL(iBuffer->At(i).iNodeBuf->At(cmd).iStatusRef, |
|
1544 iBuffer->At(i).iNodeBuf->At(cmd).iStatus); |
|
1545 } |
|
1546 |
|
1547 delete iBuffer->At(i).iNodeBuf->At(cmd).iLastUriSeg; |
|
1548 iBuffer->At(i).iNodeBuf->At(cmd).iLastUriSeg= NULL; |
|
1549 delete iBuffer->At(i).iNodeBuf->At(cmd).iData; |
|
1550 iBuffer->At(i).iNodeBuf->At(cmd).iData= NULL; |
|
1551 |
|
1552 } |
|
1553 iBuffer->At(i).iNodeBuf->Reset(); |
|
1554 delete iBuffer->At(i).iNodeBuf; |
|
1555 iBuffer->At(i).iNodeBuf = NULL; |
|
1556 delete iBuffer->At(i).iMappingName; |
|
1557 iBuffer->At(i).iMappingName= NULL; |
|
1558 delete iBuffer->At(i).iName; |
|
1559 iBuffer->At(i).iName= NULL; |
|
1560 delete iBuffer->At(i).iSmtpSettings; |
|
1561 iBuffer->At(i).iSmtpSettings= NULL; |
|
1562 delete iBuffer->At(i).iPop3Settings; |
|
1563 iBuffer->At(i).iPop3Settings= NULL; |
|
1564 delete iBuffer->At(i).iImap4Settings; |
|
1565 iBuffer->At(i).iImap4Settings= NULL; |
|
1566 delete iBuffer->At(i).iIapPref; |
|
1567 iBuffer->At(i).iIapPref= NULL; |
|
1568 delete iBuffer->At(i).iSmtpIapPref; |
|
1569 iBuffer->At(i).iSmtpIapPref= NULL; |
|
1570 |
|
1571 } // end for |
|
1572 iBuffer->Reset(); |
|
1573 |
|
1574 _DBG_FILE("CNSmlDmEmailAdapter::CompleteOutstandingCmdsL(): end"); |
|
1575 } |
|
1576 |
|
1577 // ----------------------------------------------------------------------------- |
|
1578 // |
|
1579 // ----------------------------------------------------------------------------- |
|
1580 |
|
1581 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
1582 #define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) {{aUid},(aFuncPtr)} |
|
1583 #endif |
|
1584 |
|
1585 const TImplementationProxy ImplementationTable[] = |
|
1586 { |
|
1587 IMPLEMENTATION_PROXY_ENTRY(KNSmlDMEmailAdapterImplUid, |
|
1588 CNSmlDmEmailAdapter::NewL) |
|
1589 }; |
|
1590 |
|
1591 // ----------------------------------------------------------------------------- |
|
1592 // |
|
1593 // ----------------------------------------------------------------------------- |
|
1594 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
1595 { |
|
1596 _DBG_FILE("ImplementationGroupProxy() for CNSmlDmEmailAdapter: begin"); |
|
1597 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
1598 _DBG_FILE("ImplementationGroupProxy() for CNSmlDmEmailAdapter: end"); |
|
1599 return ImplementationTable; |
|
1600 } |
|
1601 |
|
1602 |
|
1603 |
|
1604 // ----------------------------------------------------------------------------- |
|
1605 // TPtrC8 CNSmlDmEmailAdapter::LastURISeg(const TDesC8& aURI) |
|
1606 // Returns only the last uri segemnt |
|
1607 // ----------------------------------------------------------------------------- |
|
1608 TPtrC8 CNSmlDmEmailAdapter::LastURISeg(const TDesC8& aURI) const |
|
1609 { |
|
1610 _DBG_FILE("CNSmlDmEmailAdapter::LastURISeg() : begin"); |
|
1611 TInt i; |
|
1612 for(i=aURI.Length()-1;i>=0;i--) |
|
1613 { |
|
1614 if(aURI[i]=='/') |
|
1615 { |
|
1616 break; |
|
1617 } |
|
1618 } |
|
1619 _DBG_FILE("CNSmlDmEmailAdapter::LastURISeg() : end"); |
|
1620 if(i==0) |
|
1621 { |
|
1622 return aURI; |
|
1623 } |
|
1624 else |
|
1625 { |
|
1626 return aURI.Mid(i+1); |
|
1627 } |
|
1628 } |
|
1629 |
|
1630 // ----------------------------------------------------------------------------- |
|
1631 // TPtrC8 CNSmlDmEmailAdapter::RemoveLastURISeg(const TDesC8& aURI) |
|
1632 // returns parent uri, i.e. removes last uri segment |
|
1633 // ----------------------------------------------------------------------------- |
|
1634 TPtrC8 CNSmlDmEmailAdapter::RemoveLastURISeg(const TDesC8& aURI) const |
|
1635 { |
|
1636 TInt i; |
|
1637 for(i=aURI.Length()-1;i>=0;i--) |
|
1638 { |
|
1639 if(aURI[i]=='/') |
|
1640 { |
|
1641 break; |
|
1642 } |
|
1643 } |
|
1644 return aURI.Left(i); |
|
1645 } |
|
1646 |
|
1647 |
|
1648 |
|
1649 // ----------------------------------------------------------------------------- |
|
1650 // TInt CNSmlDmEmailAdapter::NumOfURISegs(const TDesC8& aURI) |
|
1651 // Returns the num of uri segs |
|
1652 // ----------------------------------------------------------------------------- |
|
1653 TInt CNSmlDmEmailAdapter::NumOfURISegs(const TDesC8& aURI) const |
|
1654 { |
|
1655 TInt numOfURISegs = 1; |
|
1656 for(TInt i=0;i<aURI.Length();i++) |
|
1657 { |
|
1658 if(aURI[i]=='/') |
|
1659 { |
|
1660 numOfURISegs++; |
|
1661 } |
|
1662 } |
|
1663 return numOfURISegs; |
|
1664 } |
|
1665 |
|
1666 |
|
1667 |
|
1668 // ----------------------------------------------------------------------------- |
|
1669 // void CNSmlDmEmailAdapter::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, |
|
1670 // TAny* /*aArg1*/, |
|
1671 // TAny* /*aArg2*/, |
|
1672 // TAny* /*aArg3*/ ) |
|
1673 // ----------------------------------------------------------------------------- |
|
1674 void CNSmlDmEmailAdapter::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, |
|
1675 TAny* /*aArg1*/, |
|
1676 TAny* /*aArg2*/, |
|
1677 TAny* /*aArg3*/ ) |
|
1678 { |
|
1679 _DBG_FILE("CNSmlDmEmailAdapter::HandleSessionEventL(): begin"); |
|
1680 _DBG_FILE("CNSmlDmEmailAdapter::HandleSessionEventL(): end"); |
|
1681 } |
|
1682 |
|
1683 |
|
1684 // ----------------------------------------------------------------------------- |
|
1685 // TInt CNSmlDmEmailAdapter::DesToInt(const TDesC& aLuid) const |
|
1686 // Converts 16bit descriptor to int |
|
1687 // ----------------------------------------------------------------------------- |
|
1688 TInt CNSmlDmEmailAdapter::DesToInt(const TDesC& aLuid) const |
|
1689 { |
|
1690 TLex16 lex(aLuid); |
|
1691 TInt value = 0; |
|
1692 lex.Val(value); |
|
1693 return value; |
|
1694 } |
|
1695 |
|
1696 // ----------------------------------------------------------------------------- |
|
1697 // TInt CNSmlDmEmailAdapter::DesToInt(const TDesC8& aLuid) const |
|
1698 // Converts 8bit descriptor to int |
|
1699 // ----------------------------------------------------------------------------- |
|
1700 TInt CNSmlDmEmailAdapter::DesToInt(const TDesC8& aLuid) const |
|
1701 { |
|
1702 TLex8 lex(aLuid); |
|
1703 TInt value = 0; |
|
1704 lex.Val(value); |
|
1705 return value; |
|
1706 } |
|
1707 |
|
1708 // ----------------------------------------------------------------------------- |
|
1709 // CNSmlDmEmailAdapter::FirstAddLeafL() |
|
1710 // ----------------------------------------------------------------------------- |
|
1711 TInt CNSmlDmEmailAdapter::FirstAddLeafL(const TDesC8& aURI, |
|
1712 const TDesC8& aObject, |
|
1713 TInt aStatusRef, |
|
1714 TInt aIndex) |
|
1715 { |
|
1716 _DBG_FILE("CNSmlDmEmailAdapter::FirstAddLeafL() :: begin"); |
|
1717 |
|
1718 TPtrC8 lastSeg = LastURISeg(aURI); |
|
1719 |
|
1720 TNSmlEmailCommandElement newCommand; |
|
1721 newCommand.iLastUriSeg = lastSeg.AllocLC(); |
|
1722 newCommand.iData = aObject.AllocLC(); |
|
1723 newCommand.iStatusRef = aStatusRef; |
|
1724 newCommand.iLeaf = ETrue; |
|
1725 newCommand.iStatus = CSmlDmAdapter::EOk; |
|
1726 iBuffer->At(aIndex).iNodeBuf->AppendL(newCommand); |
|
1727 CleanupStack::Pop(2); //newCommand.iLastUriSeg, newCommand.iData |
|
1728 if(!iBuffer->At(aIndex).iExecuted) |
|
1729 { |
|
1730 if(lastSeg.Compare(KNSmlDMEmailMpro)==0) |
|
1731 { |
|
1732 TBool ok = EFalse; |
|
1733 HBufC8* object = aObject.AllocLC(); |
|
1734 TPtr8 objectPtr = object->Des(); |
|
1735 objectPtr.UpperCase(); |
|
1736 |
|
1737 if(objectPtr.Find(KNSmlDMEmailMproPOP) >= 0) |
|
1738 { |
|
1739 iBuffer->At(aIndex).iPop3Settings = new(ELeave) CImPop3Settings; |
|
1740 ok=ETrue; |
|
1741 } |
|
1742 |
|
1743 else if(objectPtr.Find(KNSmlDMEmailMproIMAP) >= 0) |
|
1744 { |
|
1745 iBuffer->At(aIndex).iImap4Settings = new(ELeave) CImImap4Settings; |
|
1746 ok=ETrue; |
|
1747 } |
|
1748 if(ok) |
|
1749 { |
|
1750 iBuffer->At(aIndex).iSmtpSettings = new(ELeave) CImSmtpSettings; |
|
1751 iBuffer->At(aIndex).iIapPref = CImIAPPreferences::NewLC(); |
|
1752 iBuffer->At(aIndex).iSmtpIapPref = CImIAPPreferences::NewLC(); |
|
1753 CleanupStack::Pop(); //iBuffer->At(index).iIapPref |
|
1754 CleanupStack::Pop(); //iBuffer->At(index).iSmtpIapPref |
|
1755 SetDefaultSettingsL(aIndex); |
|
1756 |
|
1757 for(TInt i = 0; i<iBuffer->At(aIndex).iNodeBuf->Count();i++) |
|
1758 { |
|
1759 if(iBuffer->At(aIndex).iNodeBuf->At(i).iLeaf) |
|
1760 { |
|
1761 DoAddLeafObjectL(iBuffer->At(aIndex).iNodeBuf->At(i).iLastUriSeg->Des(), |
|
1762 iBuffer->At(aIndex).iNodeBuf->At(i).iData->Des(), |
|
1763 aIndex, i); |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 iBuffer->At(aIndex).iExecuted = ETrue; |
|
1768 } |
|
1769 CleanupStack::PopAndDestroy(); //object |
|
1770 } |
|
1771 } |
|
1772 else |
|
1773 { |
|
1774 DoAddLeafObjectL(lastSeg,aObject,aIndex, |
|
1775 iBuffer->At(aIndex).iNodeBuf->Count()-1); |
|
1776 } |
|
1777 |
|
1778 _DBG_FILE("CNSmlDmEmailAdapter::FirstAddLeafL() :: end"); |
|
1779 return KErrNone; |
|
1780 } |
|
1781 |
|
1782 |
|
1783 // ----------------------------------------------------------------------------- |
|
1784 // CNSmlDmEmailAdapter::DoAddLeafObjectL |
|
1785 // ----------------------------------------------------------------------------- |
|
1786 TInt CNSmlDmEmailAdapter::DoAddLeafObjectL(const TDesC8& aLastUriSeg, |
|
1787 const TDesC8& aObject, |
|
1788 TInt aIndex, |
|
1789 TInt aCommand) |
|
1790 { |
|
1791 _DBG_FILE("CNSmlDmEmailAdapter::DoAddLeafObjectL() :: begin"); |
|
1792 if(aLastUriSeg.Compare(KNSmlDMEmailName)==0) |
|
1793 { |
|
1794 if ( aObject.Size() < KEmailAccountNameSize ) |
|
1795 { |
|
1796 delete iBuffer->At(aIndex).iName; |
|
1797 iBuffer->At(aIndex).iName = NULL; |
|
1798 iBuffer->At(aIndex).iName = HBufC::NewL(aObject.Size()); |
|
1799 TPtr namePtr = iBuffer->At(aIndex).iName->Des(); |
|
1800 CnvUtfConverter::ConvertToUnicodeFromUtf8( namePtr, aObject ); |
|
1801 } |
|
1802 else |
|
1803 { |
|
1804 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = |
|
1805 CSmlDmAdapter::ETooLargeObject; |
|
1806 } |
|
1807 } |
|
1808 |
|
1809 else if(aLastUriSeg.Compare(KNSmlDMEmailUID)==0) |
|
1810 { |
|
1811 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1812 { |
|
1813 iBuffer->At(aIndex).iPop3Settings->SetLoginNameL(aObject); |
|
1814 } |
|
1815 else if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
1816 { |
|
1817 iBuffer->At(aIndex).iImap4Settings->SetLoginNameL(aObject); |
|
1818 } |
|
1819 if(iBuffer->At(aIndex).iSmtpSettings->LoginName()==KNullDesC8) |
|
1820 { |
|
1821 iBuffer->At(aIndex).iSmtpSettings->SetLoginNameL(aObject); |
|
1822 } |
|
1823 } |
|
1824 |
|
1825 else if(aLastUriSeg.Compare(KNSmlDMEmailPW)==0) |
|
1826 { |
|
1827 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1828 { |
|
1829 iBuffer->At(aIndex).iPop3Settings->SetPasswordL(aObject); |
|
1830 } |
|
1831 else if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
1832 { |
|
1833 iBuffer->At(aIndex).iImap4Settings->SetPasswordL(aObject); |
|
1834 } |
|
1835 if(iBuffer->At(aIndex).iSmtpSettings->Password()==KNullDesC8) |
|
1836 { |
|
1837 iBuffer->At(aIndex).iSmtpSettings->SetPasswordL(aObject); |
|
1838 } |
|
1839 } |
|
1840 |
|
1841 else if(aLastUriSeg.Compare(KNSmlDMEmailUAddr)==0) |
|
1842 { |
|
1843 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1844 TPtr objectPtr = object->Des(); |
|
1845 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1846 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1847 { |
|
1848 iBuffer->At(aIndex).iSmtpSettings->SetEmailAddressL(objectPtr); |
|
1849 iBuffer->At(aIndex).iSmtpSettings->SetReplyToAddressL(objectPtr); |
|
1850 iBuffer->At(aIndex).iSmtpSettings->SetReceiptAddressL(objectPtr); |
|
1851 } |
|
1852 |
|
1853 CleanupStack::PopAndDestroy(); //object |
|
1854 } |
|
1855 |
|
1856 else if(aLastUriSeg.Compare(KNSmlDMEmailUName)==0) |
|
1857 { |
|
1858 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1859 TPtr objectPtr = object->Des(); |
|
1860 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1861 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1862 { |
|
1863 iBuffer->At(aIndex).iSmtpSettings->SetEmailAliasL(objectPtr); |
|
1864 } |
|
1865 CleanupStack::PopAndDestroy(); //object |
|
1866 } |
|
1867 |
|
1868 else if(aLastUriSeg.Compare( KNSmlDMEmailMrcv)==0) |
|
1869 { |
|
1870 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1871 TPtr objectPtr = object->Des(); |
|
1872 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1873 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1874 { |
|
1875 iBuffer->At(aIndex).iPop3Settings->SetServerAddressL(objectPtr); |
|
1876 } |
|
1877 else if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
1878 { |
|
1879 iBuffer->At(aIndex).iImap4Settings->SetServerAddressL(objectPtr); |
|
1880 } |
|
1881 CleanupStack::PopAndDestroy(); //object |
|
1882 } |
|
1883 |
|
1884 else if(aLastUriSeg.Compare(KNSmlDMEmailMsnd)==0) |
|
1885 { |
|
1886 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1887 TPtr objectPtr = object->Des(); |
|
1888 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1889 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1890 { |
|
1891 iBuffer->At(aIndex).iSmtpSettings->SetServerAddressL(objectPtr); |
|
1892 } |
|
1893 CleanupStack::PopAndDestroy(); //object |
|
1894 } |
|
1895 |
|
1896 else if(aLastUriSeg.Compare(KNSmlDMEmailMpro)==0) |
|
1897 { |
|
1898 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = CSmlDmAdapter::EOk; |
|
1899 } |
|
1900 |
|
1901 else if(aLastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0) |
|
1902 { |
|
1903 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), EUseSecCon ); |
|
1904 } |
|
1905 |
|
1906 else if(aLastUriSeg.Compare(KNSmlDMEmailUseSauth)==0) |
|
1907 { |
|
1908 HBufC8 *data = aObject.AllocLC(); |
|
1909 TPtr8 dataPtr = data->Des(); |
|
1910 dataPtr.Capitalize(); |
|
1911 TBool object=EFalse; |
|
1912 if(dataPtr.Find(KNSmlDMEmailTrue)>=0) |
|
1913 { |
|
1914 object = ETrue; |
|
1915 } |
|
1916 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1917 { |
|
1918 iBuffer->At(aIndex).iSmtpSettings->SetSMTPAuth(object); |
|
1919 } |
|
1920 CleanupStack::PopAndDestroy(); //data |
|
1921 } |
|
1922 |
|
1923 else if(aLastUriSeg.Compare(KNSmlDMEmailSauthUID)==0) |
|
1924 { |
|
1925 if( iBuffer->At(aIndex).iSmtpSettings ) |
|
1926 { |
|
1927 iBuffer->At(aIndex).iSmtpSettings->SetLoginNameL(aObject); |
|
1928 } |
|
1929 } |
|
1930 |
|
1931 else if(aLastUriSeg.Compare(KNSmlDMEmailSauthPW)==0) |
|
1932 { |
|
1933 if( iBuffer->At(aIndex).iSmtpSettings ) |
|
1934 { |
|
1935 iBuffer->At(aIndex).iSmtpSettings->SetPasswordL( aObject ); |
|
1936 } |
|
1937 } |
|
1938 |
|
1939 else if(aLastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0) |
|
1940 { |
|
1941 HBufC8 *data = aObject.AllocLC(); |
|
1942 TPtr8 dataPtr = data->Des(); |
|
1943 dataPtr.Capitalize(); |
|
1944 TBool object=EFalse; |
|
1945 if(dataPtr.Find(KNSmlDMEmailTrue)>=0) |
|
1946 { |
|
1947 object = ETrue; |
|
1948 } |
|
1949 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1950 { |
|
1951 iBuffer->At(aIndex).iSmtpSettings->SetInboxLoginDetails(object); |
|
1952 } |
|
1953 CleanupStack::PopAndDestroy(); //data |
|
1954 } |
|
1955 |
|
1956 else if(aLastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0) |
|
1957 { |
|
1958 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), ESuseSecCon ); |
|
1959 } |
|
1960 |
|
1961 else if(aLastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0) |
|
1962 { |
|
1963 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), EUseStartTls ); |
|
1964 } |
|
1965 |
|
1966 else if(aLastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0) |
|
1967 { |
|
1968 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), ESuseStartTls ); |
|
1969 } |
|
1970 |
|
1971 else if(aLastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0) |
|
1972 { |
|
1973 TNSmlEmailSettingsElement& bufElem = iBuffer->At(aIndex); |
|
1974 TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(aCommand); |
|
1975 elem.iData = aObject.AllocL(); |
|
1976 } |
|
1977 |
|
1978 else if(aLastUriSeg.Compare(KNSmlDMEmailMsndPort)==0) |
|
1979 { |
|
1980 TNSmlEmailSettingsElement& bufElem = iBuffer->At(aIndex); |
|
1981 TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(aCommand); |
|
1982 elem.iData = aObject.AllocL(); |
|
1983 } |
|
1984 |
|
1985 else if(aLastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0) |
|
1986 { |
|
1987 TBool object=EFalse; |
|
1988 if(aObject.Find(_L8("True"))>=0 || aObject.Find(_L8("true"))>=0) |
|
1989 { |
|
1990 object = ETrue; |
|
1991 } |
|
1992 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1993 { |
|
1994 iBuffer->At(aIndex).iPop3Settings->SetApop(object); |
|
1995 } |
|
1996 } |
|
1997 |
|
1998 else if(aLastUriSeg.Compare(KNSmlDMEmailFolderPath)==0) |
|
1999 { |
|
2000 if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
2001 { |
|
2002 iBuffer->At(aIndex).iImap4Settings->SetFolderPathL(aObject); |
|
2003 } |
|
2004 } |
|
2005 |
|
2006 else if(aLastUriSeg.Compare(KNSmlDMEmailToNapID)==0) |
|
2007 { |
|
2008 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
2009 CleanupStack::PushL(iapmatch); |
|
2010 |
|
2011 TInt iap = iapmatch->IAPIdFromURIL( aObject ); |
|
2012 |
|
2013 if ( iap != KErrNotFound ) |
|
2014 { |
|
2015 TImIAPChoice localIAP; |
|
2016 localIAP.iIAP = iap; |
|
2017 DBG_ARGS(_S("IAP = %d"), localIAP.iIAP); |
|
2018 localIAP.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
2019 |
|
2020 if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() ) |
|
2021 { |
|
2022 iBuffer->At(aIndex).iIapPref->RemoveIAPL(0); |
|
2023 } |
|
2024 iBuffer->At(aIndex).iIapPref->AddIAPL(localIAP,0); |
|
2025 if (iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
2026 { |
|
2027 if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() ) |
|
2028 { |
|
2029 iBuffer->At(aIndex).iSmtpIapPref->RemoveIAPL(0); |
|
2030 } |
|
2031 iBuffer->At(aIndex).iSmtpIapPref->AddIAPL(localIAP,0); |
|
2032 } |
|
2033 } |
|
2034 else |
|
2035 { |
|
2036 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = CSmlDmAdapter::ENotFound; |
|
2037 } |
|
2038 |
|
2039 CleanupStack::PopAndDestroy(); // iapmatch |
|
2040 } |
|
2041 |
|
2042 else if(aLastUriSeg.Compare(KNSmlDMEmailSToNapID)==0) |
|
2043 { |
|
2044 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
2045 CleanupStack::PushL(iapmatch); |
|
2046 |
|
2047 TInt iap = iapmatch->IAPIdFromURIL( aObject ); |
|
2048 |
|
2049 if ( iap != KErrNotFound ) |
|
2050 { |
|
2051 TImIAPChoice localIAP; |
|
2052 localIAP.iIAP = iap; |
|
2053 DBG_ARGS(_S("SMTP IAP = %d"), localIAP.iIAP); |
|
2054 localIAP.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
2055 if ( iBuffer->At(aIndex).iSmtpSettings!= NULL ) |
|
2056 { |
|
2057 if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() ) |
|
2058 { |
|
2059 iBuffer->At(aIndex).iSmtpIapPref->RemoveIAPL(0); |
|
2060 } |
|
2061 iBuffer->At(aIndex).iSmtpIapPref->AddIAPL(localIAP,0); |
|
2062 } |
|
2063 else |
|
2064 { |
|
2065 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = |
|
2066 CSmlDmAdapter::ENotFound; |
|
2067 } |
|
2068 } |
|
2069 else |
|
2070 { |
|
2071 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = |
|
2072 CSmlDmAdapter::ENotFound; |
|
2073 } |
|
2074 |
|
2075 CleanupStack::PopAndDestroy(); // iapmatch |
|
2076 } |
|
2077 _DBG_FILE("CNSmlDmEmailAdapter::DoAddLeafObjectL() :: end"); |
|
2078 return KErrNone; |
|
2079 } |
|
2080 |
|
2081 |
|
2082 // ----------------------------------------------------------------------------- |
|
2083 // void CNSmlDmEmailAdapter::SetDefaultSettingsL(TInt aIndex) |
|
2084 // Set defaults for used protocol |
|
2085 // ----------------------------------------------------------------------------- |
|
2086 void CNSmlDmEmailAdapter::SetDefaultSettingsL(TInt aIndex) |
|
2087 { |
|
2088 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSettingsL() :: begin"); |
|
2089 TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex); |
|
2090 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
2091 if( thisElem.iPop3Settings ) |
|
2092 { |
|
2093 |
|
2094 emailAccs->PopulateDefaultPopSettingsL(*thisElem.iPop3Settings, |
|
2095 *thisElem.iIapPref |
|
2096 ); |
|
2097 emailAccs->PopulateDefaultSmtpSettingsL(*thisElem.iSmtpSettings, |
|
2098 *thisElem.iSmtpIapPref |
|
2099 ); |
|
2100 |
|
2101 thisElem.iPop3Settings->SetDeleteEmailsWhenDisconnecting( EFalse ); |
|
2102 thisElem.iPop3Settings->SetInboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount ); |
|
2103 thisElem.iPop3Settings->SetSecureSockets( EFalse ); |
|
2104 thisElem.iPop3Settings->SetAutoSendOnConnect( ETrue ); |
|
2105 thisElem.iPop3Settings->SetDisconnectedUserMode( ETrue ); |
|
2106 thisElem.iPop3Settings->SetAcknowledgeReceipts( EFalse ); |
|
2107 } |
|
2108 else if( thisElem.iImap4Settings ) |
|
2109 { |
|
2110 |
|
2111 emailAccs->PopulateDefaultImapSettingsL(*thisElem.iImap4Settings, |
|
2112 *thisElem.iIapPref |
|
2113 ); |
|
2114 |
|
2115 emailAccs->PopulateDefaultSmtpSettingsL(*thisElem.iSmtpSettings, |
|
2116 *thisElem.iSmtpIapPref |
|
2117 ); |
|
2118 |
|
2119 thisElem.iImap4Settings->SetDeleteEmailsWhenDisconnecting( EFalse ); |
|
2120 thisElem.iImap4Settings->SetInboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount ); |
|
2121 thisElem.iImap4Settings->SetMailboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount ); |
|
2122 thisElem.iImap4Settings->SetSecureSockets( EFalse ); |
|
2123 thisElem.iImap4Settings->SetAutoSendOnConnect( ETrue ); |
|
2124 thisElem.iImap4Settings->SetDisconnectedUserMode( ETrue ); |
|
2125 thisElem.iImap4Settings->SetImapIdle( ETrue ); |
|
2126 thisElem.iImap4Settings->SetUpdatingSeenFlags( ETrue ); |
|
2127 } |
|
2128 thisElem.iSmtpSettings->SetLoginNameL(KNullDesC8); |
|
2129 thisElem.iSmtpSettings->SetPasswordL(KNullDesC8); |
|
2130 // Set IAP id to 0 and ask from user if ToNapID/SToNapID not sent |
|
2131 TImIAPChoice tmpIap; |
|
2132 tmpIap.iIAP = KNSmlDmEmailAlwaysAskIap; |
|
2133 tmpIap.iDialogPref = ECommDbDialogPrefPrompt; |
|
2134 thisElem.iIapPref->AddIAPL( tmpIap, 0 ); |
|
2135 thisElem.iSmtpIapPref->AddIAPL( tmpIap, 0 ); |
|
2136 CleanupStack::PopAndDestroy(); //emailAccs |
|
2137 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSettingsL() :: end"); |
|
2138 } |
|
2139 |
|
2140 // ----------------------------------------------------------------------------- |
|
2141 // HBufC* CNSmlDmEmailAdapter::IntToDesLC(const TInt aLuid) const |
|
2142 // Converts integer to 16bit descriptor |
|
2143 // ----------------------------------------------------------------------------- |
|
2144 HBufC* CNSmlDmEmailAdapter::IntToDesLC(const TInt aLuid) const |
|
2145 { |
|
2146 HBufC* buf = HBufC::NewLC(10); //10 = max length of 32bit integer |
|
2147 TPtr ptrBuf = buf->Des(); |
|
2148 ptrBuf.Num(aLuid); |
|
2149 return buf; |
|
2150 } |
|
2151 |
|
2152 // ----------------------------------------------------------------------------- |
|
2153 // HBufC8* CNSmlDmEmailAdapter::IntToDes8LC(const TInt aLuid) const |
|
2154 // Converts integer to 8bit descriptor |
|
2155 // ----------------------------------------------------------------------------- |
|
2156 HBufC8* CNSmlDmEmailAdapter::IntToDes8LC(const TInt aLuid) const |
|
2157 { |
|
2158 HBufC8* buf = HBufC8::NewLC(10); //10 = max length of 32bit integer |
|
2159 TPtr8 ptrBuf = buf->Des(); |
|
2160 ptrBuf.Num(aLuid); |
|
2161 return buf; |
|
2162 } |
|
2163 |
|
2164 // ----------------------------------------------------------------------------- |
|
2165 // CNSmlDmEmailAdapter::ConvertTo8LC() |
|
2166 // Converts string value to 8-bit |
|
2167 // |
|
2168 // ----------------------------------------------------------------------------- |
|
2169 HBufC8* CNSmlDmEmailAdapter::ConvertTo8LC( const TDesC& aSource ) const |
|
2170 { |
|
2171 HBufC8* buf = HBufC8::NewLC( aSource.Length()*2); |
|
2172 TPtr8 bufPtr = buf->Des(); |
|
2173 CnvUtfConverter::ConvertFromUnicodeToUtf8( bufPtr, aSource ); |
|
2174 |
|
2175 return buf; |
|
2176 } |
|
2177 |
|
2178 // ----------------------------------------------------------------------------- |
|
2179 // TInt CNSmlDmEmailAdapter::ValidateAndStoreSettingsL(TInt aIndex |
|
2180 // Transfers the email settings from memory to phones permanent data store |
|
2181 // ----------------------------------------------------------------------------- |
|
2182 TInt CNSmlDmEmailAdapter::ValidateAndStoreSettingsL(TInt aIndex) |
|
2183 { |
|
2184 _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : begin"); |
|
2185 TInt luid = 0; |
|
2186 |
|
2187 TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex); |
|
2188 |
|
2189 if( iBuffer->At( aIndex ).iJustFetch ) |
|
2190 { |
|
2191 _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : end"); |
|
2192 return luid; |
|
2193 } |
|
2194 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
2195 if( iBuffer->At( aIndex ).iLuid != 0 ) |
|
2196 { |
|
2197 switch ( thisElem.iAccType ) |
|
2198 { |
|
2199 case EPop: |
|
2200 { |
|
2201 TPopAccount accId; |
|
2202 emailAccs->GetPopAccountL( thisElem.iServiceId, accId ); |
|
2203 //Copy name field |
|
2204 accId.iPopAccountName.Copy(thisElem.iName->Des()); |
|
2205 emailAccs->SavePopSettingsL( accId, *thisElem.iPop3Settings ); |
|
2206 emailAccs->SavePopIapSettingsL( accId, *thisElem.iIapPref ); |
|
2207 TSmtpAccount smtpAcc; |
|
2208 emailAccs->GetSmtpAccountL( accId.iSmtpService, smtpAcc ); |
|
2209 //Copy name field |
|
2210 smtpAcc.iSmtpAccountName.Copy(thisElem.iName->Des()); |
|
2211 emailAccs->SaveSmtpSettingsL( smtpAcc, *thisElem.iSmtpSettings ); |
|
2212 emailAccs->SaveSmtpIapSettingsL( smtpAcc, *thisElem.iSmtpIapPref ); |
|
2213 break; |
|
2214 } |
|
2215 case EImap: |
|
2216 { |
|
2217 TImapAccount accId2; |
|
2218 emailAccs->GetImapAccountL( thisElem.iServiceId, accId2 ); |
|
2219 //Copy name field |
|
2220 accId2.iImapAccountName.Copy(thisElem.iName->Des()); |
|
2221 emailAccs->SaveImapSettingsL( accId2, *thisElem.iImap4Settings ); |
|
2222 emailAccs->SaveImapIapSettingsL( accId2, *thisElem.iIapPref ); |
|
2223 TSmtpAccount smtpAccForImap; |
|
2224 emailAccs->GetSmtpAccountL( accId2.iSmtpService, smtpAccForImap ); |
|
2225 //Copy name field |
|
2226 smtpAccForImap.iSmtpAccountName.Copy(thisElem.iName->Des()); |
|
2227 emailAccs->SaveSmtpSettingsL( smtpAccForImap, *thisElem.iSmtpSettings ); |
|
2228 emailAccs->SaveSmtpIapSettingsL( smtpAccForImap, *thisElem.iSmtpIapPref ); |
|
2229 break; |
|
2230 } |
|
2231 default: |
|
2232 |
|
2233 break; |
|
2234 } |
|
2235 } |
|
2236 else // if(iBuffer->At(aIndex).iLuid != 0) |
|
2237 { |
|
2238 RTelServer telServer; |
|
2239 User::LeaveIfError( telServer.Connect() ); |
|
2240 CleanupClosePushL(telServer); |
|
2241 |
|
2242 TInt numPhones = 0; |
|
2243 User::LeaveIfError( telServer.EnumeratePhones( numPhones ) ); |
|
2244 if ( numPhones < 1 ) |
|
2245 { |
|
2246 User::Leave( KErrNotFound ); |
|
2247 } |
|
2248 |
|
2249 RTelServer::TPhoneInfo info; |
|
2250 User::LeaveIfError( telServer.GetPhoneInfo( 0, info ) ); |
|
2251 RMobilePhone mobilePhone; |
|
2252 User::LeaveIfError( mobilePhone.Open( telServer, info.iName ) ); |
|
2253 CleanupClosePushL( mobilePhone ); |
|
2254 TRequestStatus status; |
|
2255 RMobilePhone::TMobilePhoneIdentityV1 mobilePhoneIdentity; |
|
2256 mobilePhone.GetPhoneId( status, mobilePhoneIdentity ); |
|
2257 User::WaitForRequest( status ); |
|
2258 User::LeaveIfError( status.Int() ); |
|
2259 TBuf<50> imei; |
|
2260 imei.Copy( mobilePhoneIdentity.iSerialNumber ); |
|
2261 |
|
2262 CleanupStack::PopAndDestroy(&mobilePhone); |
|
2263 CleanupStack::PopAndDestroy(&telServer); |
|
2264 if ( thisElem.iPop3Settings ) |
|
2265 { |
|
2266 TPopAccount accId; |
|
2267 accId = emailAccs->CreatePopAccountL( *thisElem.iName, |
|
2268 *thisElem.iPop3Settings, |
|
2269 *thisElem.iIapPref, |
|
2270 EFalse ); |
|
2271 |
|
2272 TSmtpAccount smtpAcc = emailAccs->CreateSmtpAccountL( accId, |
|
2273 *thisElem.iSmtpSettings, |
|
2274 *thisElem.iSmtpIapPref, |
|
2275 EFalse ); |
|
2276 TMsvEntry smtpEntry; |
|
2277 TMsvEntry popEntry; |
|
2278 CMsvEntry* entry = iMsvSession->GetEntryL(smtpAcc.iSmtpService); |
|
2279 CleanupStack::PushL(entry); |
|
2280 smtpEntry = entry->Entry(); |
|
2281 smtpEntry.iMtmData2 = smtpAcc.iSmtpAccountId; |
|
2282 smtpEntry.iDescription.Set( imei ); |
|
2283 entry->ChangeL(smtpEntry); |
|
2284 CleanupStack::PopAndDestroy(entry); |
|
2285 |
|
2286 entry = iMsvSession->GetEntryL(smtpAcc.iRelatedService); |
|
2287 CleanupStack::PushL(entry); |
|
2288 popEntry = entry->Entry(); |
|
2289 popEntry.iMtmData2 = accId.iPopAccountId; |
|
2290 popEntry.iDescription.Set( imei ); |
|
2291 entry->ChangeL(popEntry); |
|
2292 CleanupStack::PopAndDestroy(entry); |
|
2293 |
|
2294 if ( accId.iSmtpService != smtpAcc.iSmtpService || smtpAcc.iRelatedService != accId.iPopService ) |
|
2295 { |
|
2296 DBG_ARGS8(_S8("ERROR!!! PopAccount creation: iSmtpService=%d, smtpAcc.iSmtpService=%d, iRelatedService=%d, iPopService=%d"), |
|
2297 accId.iSmtpService, smtpAcc.iSmtpService, smtpAcc.iRelatedService, accId.iPopService ); |
|
2298 } |
|
2299 |
|
2300 thisElem.iAccType = EPop; |
|
2301 thisElem.iAccId = accId.iPopAccountId; |
|
2302 SetLuidById( thisElem.iAccType, thisElem.iAccId, thisElem.iLuid ); |
|
2303 |
|
2304 RArray<TPopAccount> popAccs; |
|
2305 CleanupClosePushL( popAccs ); |
|
2306 emailAccs->GetPopAccountsL( popAccs ); |
|
2307 |
|
2308 RArray<TImapAccount> imapAccs; |
|
2309 CleanupClosePushL( imapAccs ); |
|
2310 emailAccs->GetImapAccountsL( imapAccs ); |
|
2311 |
|
2312 if ( popAccs.Count() == 1 && !imapAccs.Count()) |
|
2313 { |
|
2314 emailAccs->SetDefaultSmtpAccountL( smtpAcc ); |
|
2315 } |
|
2316 |
|
2317 CleanupStack::PopAndDestroy( &imapAccs ); |
|
2318 CleanupStack::PopAndDestroy( &popAccs ); |
|
2319 // Check and set the default account |
|
2320 TSmtpAccount defSmtp; |
|
2321 TInt retVal = emailAccs->DefaultSmtpAccountL( defSmtp ); |
|
2322 if ( retVal != KErrNone ) |
|
2323 { |
|
2324 RArray<TPopAccount> popAccounts; |
|
2325 CleanupClosePushL( popAccounts ); |
|
2326 emailAccs->GetPopAccountsL( popAccounts ); |
|
2327 if ( popAccounts.Count() > 0 ) |
|
2328 { |
|
2329 TSmtpAccount relatedSmtp; |
|
2330 emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp ); |
|
2331 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
2332 } |
|
2333 CleanupStack::PopAndDestroy( &popAccounts ); |
|
2334 } |
|
2335 } |
|
2336 else if ( thisElem.iImap4Settings ) |
|
2337 { |
|
2338 TImapAccount accId2; |
|
2339 accId2 = emailAccs->CreateImapAccountL(*thisElem.iName, |
|
2340 *thisElem.iImap4Settings, |
|
2341 *thisElem.iIapPref, |
|
2342 EFalse); |
|
2343 |
|
2344 TSmtpAccount smtpAcc = emailAccs->CreateSmtpAccountL( accId2, |
|
2345 *thisElem.iSmtpSettings, |
|
2346 *thisElem.iSmtpIapPref, |
|
2347 EFalse ); |
|
2348 |
|
2349 TMsvEntry smtpEntry; |
|
2350 TMsvEntry imapEntry; |
|
2351 CMsvEntry* entry = iMsvSession->GetEntryL(smtpAcc.iSmtpService); |
|
2352 CleanupStack::PushL(entry); |
|
2353 smtpEntry = entry->Entry(); |
|
2354 smtpEntry.iMtmData2 = smtpAcc.iSmtpAccountId; |
|
2355 smtpEntry.iDescription.Set( imei ); |
|
2356 entry->ChangeL(smtpEntry); |
|
2357 CleanupStack::PopAndDestroy(entry); |
|
2358 |
|
2359 entry = iMsvSession->GetEntryL(smtpAcc.iRelatedService); |
|
2360 CleanupStack::PushL(entry); |
|
2361 imapEntry = entry->Entry(); |
|
2362 imapEntry.iMtmData2 = accId2.iImapAccountId; |
|
2363 imapEntry.iDescription.Set( imei ); |
|
2364 entry->ChangeL(imapEntry); |
|
2365 CleanupStack::PopAndDestroy(entry); |
|
2366 |
|
2367 if ( accId2.iSmtpService != smtpAcc.iSmtpService || smtpAcc.iRelatedService != accId2.iImapService ) |
|
2368 { |
|
2369 DBG_ARGS8(_S8("ERROR!!! ImapAccount creation: iSmtpService=%d, smtpAcc.iSmtpService=%d, iRelatedService=%d, iImapService=%d"), |
|
2370 accId2.iSmtpService, smtpAcc.iSmtpService, smtpAcc.iRelatedService, accId2.iImapService ); |
|
2371 } |
|
2372 |
|
2373 |
|
2374 thisElem.iAccType = EImap; |
|
2375 thisElem.iAccId = accId2.iImapAccountId; |
|
2376 SetLuidById( thisElem.iAccType, thisElem.iAccId, thisElem.iLuid ); |
|
2377 |
|
2378 // Check and set the default account |
|
2379 RArray<TPopAccount> popAccs; |
|
2380 CleanupClosePushL( popAccs ); |
|
2381 emailAccs->GetPopAccountsL( popAccs ); |
|
2382 |
|
2383 RArray<TImapAccount> imapAccs; |
|
2384 CleanupClosePushL( imapAccs ); |
|
2385 emailAccs->GetImapAccountsL( imapAccs ); |
|
2386 |
|
2387 if ( imapAccs.Count() == 1 && !popAccs.Count()) |
|
2388 { |
|
2389 emailAccs->SetDefaultSmtpAccountL( smtpAcc ); |
|
2390 } |
|
2391 |
|
2392 CleanupStack::PopAndDestroy( &imapAccs ); |
|
2393 CleanupStack::PopAndDestroy( &popAccs ); |
|
2394 TSmtpAccount defaultSmtp; |
|
2395 TInt retVal = emailAccs->DefaultSmtpAccountL( defaultSmtp ); |
|
2396 if ( retVal != KErrNone ) |
|
2397 { |
|
2398 RArray<TImapAccount> imapAccs; |
|
2399 CleanupClosePushL( imapAccs ); |
|
2400 emailAccs->GetImapAccountsL( imapAccs ); |
|
2401 if ( imapAccs.Count() > 0 ) |
|
2402 { |
|
2403 TSmtpAccount relatedSmtp; |
|
2404 emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp ); |
|
2405 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
2406 } |
|
2407 CleanupStack::PopAndDestroy( &imapAccs ); |
|
2408 } |
|
2409 } |
|
2410 |
|
2411 } |
|
2412 luid = thisElem.iLuid; |
|
2413 CleanupStack::PopAndDestroy(); //emailAccs |
|
2414 _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : end"); |
|
2415 return luid; |
|
2416 } |
|
2417 // ----------------------------------------------------------------------------- |
|
2418 // void CNSmlDmEmailAdapter::GetIdByLuid( TNSmlEmailAccountType& aAccType, |
|
2419 // TInt& aAccId, |
|
2420 // const TInt aLuid ) const |
|
2421 // Calculates the account type and id on basis of luid |
|
2422 // ----------------------------------------------------------------------------- |
|
2423 void CNSmlDmEmailAdapter::GetIdByLuid( TNSmlEmailAccountType& aAccType, |
|
2424 TInt& aAccId, |
|
2425 const TInt aLuid ) const |
|
2426 { |
|
2427 if ( ( aLuid > KNSmlDmEmailImapLuidLow ) && |
|
2428 ( aLuid < KNSmlDmEmailImapLuidHigh ) ) |
|
2429 { |
|
2430 aAccType = EImap; |
|
2431 aAccId = aLuid - KNSmlDmEmailImapLuidLow; |
|
2432 } |
|
2433 else if (( aLuid > KNSmlDmEmailImapLuidHigh ) && |
|
2434 ( aLuid < KNSmlDmEmailPopLuidHigh )) |
|
2435 { |
|
2436 aAccType = EPop; |
|
2437 aAccId = aLuid - KNSmlDmEmailImapLuidHigh; |
|
2438 } |
|
2439 else |
|
2440 { |
|
2441 aAccType = EUnknown; |
|
2442 } |
|
2443 |
|
2444 } |
|
2445 |
|
2446 |
|
2447 // ----------------------------------------------------------------------------- |
|
2448 // void CNSmlDmEmailAdapter::SetLuidById( const TNSmlEmailAccountType& aAccType, |
|
2449 // const TInt& aAccId, TInt& aLuid ) const |
|
2450 // Sets the luid on basis of account type and id |
|
2451 // ----------------------------------------------------------------------------- |
|
2452 void CNSmlDmEmailAdapter::SetLuidById( const TNSmlEmailAccountType& aAccType, |
|
2453 const TInt& aAccId, TInt& aLuid ) const |
|
2454 { |
|
2455 switch (aAccType) |
|
2456 { |
|
2457 case EImap : |
|
2458 aLuid = KNSmlDmEmailImapLuidLow + aAccId; |
|
2459 break; |
|
2460 |
|
2461 case EPop : |
|
2462 aLuid = KNSmlDmEmailImapLuidHigh + aAccId; |
|
2463 break; |
|
2464 |
|
2465 default : |
|
2466 aLuid = -1; |
|
2467 break; |
|
2468 } |
|
2469 } |
|
2470 |
|
2471 // ----------------------------------------------------------------------------- |
|
2472 // TBool CNSmlDmEmailAdapter::AccountExistsL( const CEmailAccounts* aAccs, |
|
2473 // const TNSmlEmailAccountType aAccType, |
|
2474 // const TInt aId, |
|
2475 // TInt aIndex ) |
|
2476 // Checks if the accout matching the given parameters is found. |
|
2477 // returns True if found. |
|
2478 // ----------------------------------------------------------------------------- |
|
2479 TBool CNSmlDmEmailAdapter::AccountExistsL( CEmailAccounts* aAccs, |
|
2480 const TNSmlEmailAccountType aAccType, |
|
2481 const TInt aId, |
|
2482 TInt aIndex ) |
|
2483 { |
|
2484 RArray<TImapAccount> imap4Accs; |
|
2485 CleanupClosePushL( imap4Accs ); |
|
2486 RArray<TPopAccount> pop3Accs; |
|
2487 CleanupClosePushL( pop3Accs ); |
|
2488 switch ( aAccType ) |
|
2489 { |
|
2490 case EImap: |
|
2491 aAccs->GetImapAccountsL(imap4Accs); |
|
2492 for(TInt i=0;i<imap4Accs.Count();i++) |
|
2493 { |
|
2494 if ( imap4Accs[i].iImapAccountId == aId ) |
|
2495 { |
|
2496 |
|
2497 if ( aIndex >= 0 ) |
|
2498 { |
|
2499 iBuffer->At(aIndex).iServiceId = imap4Accs[i].iImapService; |
|
2500 delete iBuffer->At(aIndex).iName; |
|
2501 iBuffer->At(aIndex).iName = NULL; |
|
2502 iBuffer->At(aIndex).iName = HBufC::NewL(imap4Accs[i].iImapAccountName.Size()); |
|
2503 *iBuffer->At(aIndex).iName = imap4Accs[i].iImapAccountName; |
|
2504 } |
|
2505 CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs |
|
2506 return ETrue; |
|
2507 } |
|
2508 } |
|
2509 break; |
|
2510 |
|
2511 case EPop: |
|
2512 aAccs->GetPopAccountsL(pop3Accs); |
|
2513 for(TInt i=0;i<pop3Accs.Count();i++) |
|
2514 { |
|
2515 if ( pop3Accs[i].iPopAccountId == aId ) |
|
2516 { |
|
2517 if ( aIndex >= 0 ) |
|
2518 { |
|
2519 iBuffer->At(aIndex).iServiceId = pop3Accs[i].iPopService; |
|
2520 delete iBuffer->At(aIndex).iName; |
|
2521 iBuffer->At(aIndex).iName = NULL; |
|
2522 iBuffer->At(aIndex).iName = HBufC::NewL(pop3Accs[i].iPopAccountName.Size()); |
|
2523 *iBuffer->At(aIndex).iName = pop3Accs[i].iPopAccountName; |
|
2524 } |
|
2525 CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs |
|
2526 return ETrue; |
|
2527 } |
|
2528 } |
|
2529 break; |
|
2530 default: |
|
2531 // Returns EFalse in this case. |
|
2532 break; |
|
2533 } |
|
2534 CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs |
|
2535 return EFalse; |
|
2536 } |
|
2537 |
|
2538 // ----------------------------------------------------------------------------- |
|
2539 // TInt CNSmlDmEmailAdapter::DoRestoreSettingsL(TInt aIndex) |
|
2540 // Restores the settings to the adapter from settings store |
|
2541 // ----------------------------------------------------------------------------- |
|
2542 TInt CNSmlDmEmailAdapter::DoRestoreSettingsL(TInt aIndex) |
|
2543 { |
|
2544 _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : begin"); |
|
2545 TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex); |
|
2546 |
|
2547 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
2548 TInt err = KErrNone; |
|
2549 |
|
2550 // These are destroyed latest at destructor |
|
2551 thisElem.iSmtpSettings = new (ELeave) CImSmtpSettings; |
|
2552 thisElem.iIapPref = CImIAPPreferences::NewLC(); |
|
2553 thisElem.iSmtpIapPref = CImIAPPreferences::NewLC(); |
|
2554 |
|
2555 switch( thisElem.iAccType ) |
|
2556 { |
|
2557 case EImap: |
|
2558 if (AccountExistsL(emailAccs, thisElem.iAccType, thisElem.iAccId, aIndex )) |
|
2559 { |
|
2560 TImapAccount imapAccId; |
|
2561 |
|
2562 thisElem.iImap4Settings = new(ELeave) CImImap4Settings; |
|
2563 |
|
2564 //Get IMAP account by iAccId id |
|
2565 emailAccs->GetImapAccountL(thisElem.iServiceId, imapAccId); |
|
2566 //Get IMAP settings by account id |
|
2567 emailAccs->LoadImapSettingsL( imapAccId, *thisElem.iImap4Settings ); |
|
2568 //Get IMAP settings IAP prefs |
|
2569 emailAccs->LoadImapIapSettingsL( imapAccId, *thisElem.iIapPref ); |
|
2570 |
|
2571 TSmtpAccount smtpAccount; |
|
2572 //Get smtp account by related IMAP id |
|
2573 emailAccs->GetSmtpAccountL( imapAccId.iSmtpService, smtpAccount ); |
|
2574 //Get smtp settings by IMAP id |
|
2575 emailAccs->LoadSmtpSettingsL( smtpAccount, *thisElem.iSmtpSettings ); |
|
2576 //Get Smtp settings IAP prefs |
|
2577 emailAccs->LoadSmtpIapSettingsL( smtpAccount, *thisElem.iSmtpIapPref ); |
|
2578 } |
|
2579 else |
|
2580 { |
|
2581 err = KErrNotFound; |
|
2582 } |
|
2583 break; |
|
2584 |
|
2585 case EPop: |
|
2586 if (AccountExistsL(emailAccs, thisElem.iAccType, thisElem.iAccId, aIndex )) |
|
2587 { |
|
2588 TPopAccount popAccId; |
|
2589 |
|
2590 thisElem.iPop3Settings = new(ELeave) CImPop3Settings; |
|
2591 |
|
2592 //Get POP3 account by iAccId id |
|
2593 emailAccs->GetPopAccountL( thisElem.iServiceId, popAccId ); |
|
2594 //Get POP3 settings by account id |
|
2595 emailAccs->LoadPopSettingsL( popAccId, *thisElem.iPop3Settings ); |
|
2596 //Get POP3 setting IAP prefs |
|
2597 emailAccs->LoadPopIapSettingsL( popAccId, *thisElem.iIapPref ); |
|
2598 |
|
2599 TSmtpAccount smtpAccount; |
|
2600 //Get smtp account by related POP id |
|
2601 emailAccs->GetSmtpAccountL( popAccId.iSmtpService, smtpAccount ); |
|
2602 //Get smtp settings |
|
2603 emailAccs->LoadSmtpSettingsL( smtpAccount, *thisElem.iSmtpSettings ); |
|
2604 //Get Smtp setting IAP prefs |
|
2605 emailAccs->LoadSmtpIapSettingsL( smtpAccount, *thisElem.iSmtpIapPref ); |
|
2606 } |
|
2607 else |
|
2608 { |
|
2609 err = KErrNotFound; |
|
2610 } |
|
2611 break; |
|
2612 |
|
2613 default: |
|
2614 err = KErrNotFound; |
|
2615 break; |
|
2616 } |
|
2617 |
|
2618 if ( err ) |
|
2619 { |
|
2620 _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : \ |
|
2621 KErrNotFound end"); |
|
2622 CleanupStack::PopAndDestroy(2); // iIapPref, iSmtpIapPref |
|
2623 CleanupStack::PopAndDestroy(emailAccs); //emailAccs |
|
2624 return KErrNotFound; |
|
2625 } |
|
2626 |
|
2627 CleanupStack::Pop(2); // iIapPref, iSmtpIapPref |
|
2628 CleanupStack::PopAndDestroy(emailAccs); //emailAccs |
|
2629 _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : end"); |
|
2630 return KErrNone; |
|
2631 } |
|
2632 |
|
2633 // ----------------------------------------------------------------------------- |
|
2634 // CNSmlDmEmailAdapter::OpenSessionL() |
|
2635 // Opens the CMsvSession if it is not open already |
|
2636 // ----------------------------------------------------------------------------- |
|
2637 TInt CNSmlDmEmailAdapter::OpenSessionL() |
|
2638 { |
|
2639 _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : begin"); |
|
2640 if(!iMsvSession) |
|
2641 { |
|
2642 TRAPD(err, iMsvSession = CMsvSession::OpenSyncL(*this)); |
|
2643 _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : end"); |
|
2644 return err; |
|
2645 } |
|
2646 |
|
2647 _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : end"); |
|
2648 return KErrNone; |
|
2649 } |
|
2650 |
|
2651 // ----------------------------------------------------------------------------- |
|
2652 // CNSmlDmEmailAdapter::FillNodeInfoL() |
|
2653 // Fills the node info in ddf structure |
|
2654 // ----------------------------------------------------------------------------- |
|
2655 void CNSmlDmEmailAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
2656 const TSmlDmAccessTypes& aAccTypes, |
|
2657 MSmlDmDDFObject::TOccurence aOccurrence, |
|
2658 MSmlDmDDFObject::TScope aScope, |
|
2659 MSmlDmDDFObject::TDFFormat aFormat, |
|
2660 const TDesC8& aDescription) const |
|
2661 { |
|
2662 aNode.SetAccessTypesL(aAccTypes); |
|
2663 aNode.SetOccurenceL(aOccurrence); |
|
2664 aNode.SetScopeL(aScope); |
|
2665 aNode.SetDFFormatL(aFormat); |
|
2666 if(aFormat!=MSmlDmDDFObject::ENode) |
|
2667 { |
|
2668 aNode.AddDFTypeMimeTypeL(KNSmlDMEmailTextPlain); |
|
2669 } |
|
2670 aNode.SetDescriptionL(aDescription); |
|
2671 |
|
2672 } |
|
2673 |
|
2674 // ----------------------------------------------------------------------------- |
|
2675 // TPtrC8 CNSmlDmEmailAdapter::RemoveDotSlash(const TDesC8& aURI) |
|
2676 // return uri without dot and slash in start |
|
2677 // ----------------------------------------------------------------------------- |
|
2678 TPtrC8 CNSmlDmEmailAdapter::RemoveDotSlash(const TDesC8& aURI) const |
|
2679 { |
|
2680 if(aURI.Find(KNSmlEmailUriDotSlash)==0) |
|
2681 { |
|
2682 return aURI.Right(aURI.Length()-KNSmlEmailUriDotSlash().Length()); |
|
2683 } |
|
2684 else |
|
2685 { |
|
2686 return aURI; |
|
2687 } |
|
2688 } |
|
2689 // ----------------------------------------------------------------------------- |
|
2690 // CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchObjectL(const TDesC8& aURI, |
|
2691 // const TDesC8& aLUID, CBufBase& aObject) |
|
2692 // Fetches object acording to URI & LUID. Retur codes acording to |
|
2693 // CSmlDmAdapter::TError. |
|
2694 // ----------------------------------------------------------------------------- |
|
2695 CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchObjectL(const TDesC8& aURI, |
|
2696 const TDesC8& aLUID, |
|
2697 CBufBase& aObject) |
|
2698 { |
|
2699 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : begin"); |
|
2700 CSmlDmAdapter::TError status = EOk; |
|
2701 if(aLUID.Length()==0) |
|
2702 { |
|
2703 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : ENotFound end"); |
|
2704 return CSmlDmAdapter::ENotFound; |
|
2705 } |
|
2706 if( OpenSessionL() != KErrNone ) |
|
2707 { |
|
2708 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : EError end"); |
|
2709 return CSmlDmAdapter::EError; |
|
2710 } |
|
2711 TInt luid = DesToInt(aLUID); |
|
2712 TInt index = -1; |
|
2713 for(TInt i=0;i<iBuffer->Count();i++) |
|
2714 { |
|
2715 if(iBuffer->At(i).iLuid == luid) |
|
2716 { |
|
2717 index = i; |
|
2718 break; |
|
2719 } |
|
2720 } |
|
2721 |
|
2722 if(index<0) |
|
2723 { |
|
2724 TNSmlEmailSettingsElement newNode; |
|
2725 newNode.iImap4Settings = NULL; |
|
2726 newNode.iPop3Settings = NULL; |
|
2727 newNode.iSmtpSettings = NULL; |
|
2728 newNode.iIapPref = NULL; |
|
2729 newNode.iLuid = luid; |
|
2730 newNode.iMappingName = aURI.AllocLC(); |
|
2731 newNode.iName = HBufC::NewLC(0); |
|
2732 newNode.iNodeBuf = new (ELeave) |
|
2733 CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity); |
|
2734 newNode.iExecuted = ETrue; |
|
2735 newNode.iJustFetch = ETrue; |
|
2736 GetIdByLuid(newNode.iAccType, newNode.iAccId, luid); |
|
2737 iBuffer->AppendL(newNode); |
|
2738 index = iBuffer->Count() - 1; |
|
2739 if(DoRestoreSettingsL(index)!=KErrNone) |
|
2740 { |
|
2741 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
2742 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : EError end"); |
|
2743 return CSmlDmAdapter::EError; |
|
2744 } |
|
2745 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
2746 } |
|
2747 |
|
2748 TPtrC8 lastUriSeg = LastURISeg(aURI); |
|
2749 |
|
2750 if(lastUriSeg.Compare(KNSmlDMEmailName)==0) |
|
2751 { |
|
2752 HBufC8 *data = HBufC8::NewLC(iBuffer->At(index).iName->Length()); |
|
2753 TPtr8 dataPtr = data->Des(); |
|
2754 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr, iBuffer->At(index).iName->Des() ); |
|
2755 aObject.InsertL(0,dataPtr); |
|
2756 CleanupStack::PopAndDestroy(); //data |
|
2757 } |
|
2758 else if(lastUriSeg.Compare(KNSmlDMEmailUID)==0) |
|
2759 { |
|
2760 HBufC *data = NULL; |
|
2761 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2762 { |
|
2763 data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->LoginName().Length()); |
|
2764 data->Des().Copy(iBuffer->At(index).iPop3Settings->LoginName()); |
|
2765 } |
|
2766 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2767 { |
|
2768 data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->LoginName().Length()); |
|
2769 data->Des().Copy(iBuffer->At(index).iImap4Settings->LoginName()); |
|
2770 } |
|
2771 if(data) |
|
2772 { |
|
2773 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2774 CleanupStack::PushL(data8); |
|
2775 aObject.InsertL(0,*data8); |
|
2776 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2777 } |
|
2778 } |
|
2779 else if(lastUriSeg.Compare(KNSmlDMEmailPW)==0) |
|
2780 { |
|
2781 HBufC *data = NULL; |
|
2782 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2783 { |
|
2784 data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->Password().Length()); |
|
2785 data->Des().Copy(iBuffer->At(index).iPop3Settings->Password()); |
|
2786 } |
|
2787 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2788 { |
|
2789 data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->Password().Length()); |
|
2790 data->Des().Copy(iBuffer->At(index).iImap4Settings->Password()); |
|
2791 } |
|
2792 if(data) |
|
2793 { |
|
2794 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2795 CleanupStack::PushL(data8); |
|
2796 aObject.InsertL(0,*data8); |
|
2797 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2798 } |
|
2799 } |
|
2800 else if(lastUriSeg.Compare(KNSmlDMEmailUAddr)==0) |
|
2801 { |
|
2802 HBufC *data = NULL; |
|
2803 data = iBuffer->At(index).iSmtpSettings->EmailAddress().AllocLC(); |
|
2804 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2805 TPtr8 dataPtr8 = data8->Des(); |
|
2806 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2807 |
|
2808 aObject.InsertL(0,dataPtr8); |
|
2809 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2810 } |
|
2811 else if(lastUriSeg.Compare(KNSmlDMEmailUName)==0) |
|
2812 { |
|
2813 |
|
2814 HBufC *data = NULL; |
|
2815 data = iBuffer->At(index).iSmtpSettings->EmailAlias().AllocLC(); |
|
2816 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2817 TPtr8 dataPtr8 = data8->Des(); |
|
2818 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2819 |
|
2820 aObject.InsertL(0,dataPtr8); |
|
2821 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2822 } |
|
2823 |
|
2824 else if(lastUriSeg.Compare( KNSmlDMEmailMrcv)==0) |
|
2825 { |
|
2826 HBufC *data = NULL; |
|
2827 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2828 { |
|
2829 data = iBuffer->At(index).iPop3Settings->ServerAddress().AllocLC(); |
|
2830 } |
|
2831 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2832 { |
|
2833 data = iBuffer->At(index).iImap4Settings->ServerAddress().AllocLC(); |
|
2834 } |
|
2835 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2836 TPtr8 dataPtr8 = data8->Des(); |
|
2837 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2838 |
|
2839 aObject.InsertL(0,dataPtr8); |
|
2840 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2841 } |
|
2842 else if(lastUriSeg.Compare(KNSmlDMEmailMsnd)==0) |
|
2843 { |
|
2844 HBufC *data = NULL; |
|
2845 data = iBuffer->At(index).iSmtpSettings->ServerAddress().AllocLC(); |
|
2846 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2847 TPtr8 dataPtr8 = data8->Des(); |
|
2848 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2849 |
|
2850 aObject.InsertL(0,dataPtr8); |
|
2851 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2852 } |
|
2853 else if(lastUriSeg.Compare(KNSmlDMEmailMpro)==0) |
|
2854 { |
|
2855 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2856 { |
|
2857 aObject.InsertL(0,KNSmlDMEmailMproPOP); |
|
2858 } |
|
2859 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2860 { |
|
2861 aObject.InsertL(0,KNSmlDMEmailMproIMAP); |
|
2862 } |
|
2863 } |
|
2864 else if(lastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0) |
|
2865 { |
|
2866 FetchSecurityValueL(aObject, &iBuffer->At(index), EUseSecCon ); |
|
2867 } |
|
2868 |
|
2869 else if(lastUriSeg.Compare(KNSmlDMEmailUseSauth)==0) |
|
2870 { |
|
2871 if(iBuffer->At(index).iSmtpSettings->SMTPAuth()) |
|
2872 { |
|
2873 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
2874 } |
|
2875 else |
|
2876 { |
|
2877 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
2878 } |
|
2879 } |
|
2880 else if(lastUriSeg.Compare(KNSmlDMEmailSauthUID)==0) |
|
2881 { |
|
2882 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->LoginName().Length()); |
|
2883 data->Des().Copy(iBuffer->At(index).iSmtpSettings->LoginName()); |
|
2884 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2885 CleanupStack::PushL(data8); |
|
2886 aObject.InsertL(0,*data8); |
|
2887 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2888 } |
|
2889 else if(lastUriSeg.Compare(KNSmlDMEmailSauthPW)==0) |
|
2890 { |
|
2891 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->Password().Length()); |
|
2892 data->Des().Copy(iBuffer->At(index).iSmtpSettings->Password()); |
|
2893 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2894 CleanupStack::PushL(data8); |
|
2895 aObject.InsertL(0,*data8); |
|
2896 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2897 } |
|
2898 else if(lastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0) |
|
2899 { |
|
2900 if(iBuffer->At(index).iSmtpSettings->InboxLoginDetails()) |
|
2901 { |
|
2902 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
2903 } |
|
2904 else |
|
2905 { |
|
2906 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
2907 } |
|
2908 } |
|
2909 |
|
2910 else if (lastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0) |
|
2911 { |
|
2912 FetchSecurityValueL(aObject, &iBuffer->At(index), ESuseSecCon ); |
|
2913 } |
|
2914 |
|
2915 else if (lastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0) |
|
2916 { |
|
2917 FetchSecurityValueL(aObject, &iBuffer->At(index), EUseStartTls ); |
|
2918 } |
|
2919 |
|
2920 else if (lastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0) |
|
2921 { |
|
2922 FetchSecurityValueL(aObject, &iBuffer->At(index), ESuseStartTls ); |
|
2923 } |
|
2924 |
|
2925 else if(lastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0) |
|
2926 { |
|
2927 TUint port; |
|
2928 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2929 { |
|
2930 port = iBuffer->At(index).iPop3Settings->Port(); |
|
2931 } |
|
2932 else |
|
2933 { |
|
2934 port = iBuffer->At(index).iImap4Settings->Port(); |
|
2935 } |
|
2936 HBufC8 *data = IntToDes8LC(port); |
|
2937 aObject.InsertL(0,data->Des()); |
|
2938 CleanupStack::PopAndDestroy(); //data |
|
2939 } |
|
2940 |
|
2941 else if(lastUriSeg.Compare(KNSmlDMEmailMsndPort)==0) |
|
2942 { |
|
2943 TUint port = iBuffer->At(index).iSmtpSettings->Port(); |
|
2944 HBufC8 *data = IntToDes8LC(port); |
|
2945 aObject.InsertL(0,data->Des()); |
|
2946 CleanupStack::PopAndDestroy(); //data |
|
2947 } |
|
2948 |
|
2949 else if(lastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0) |
|
2950 { |
|
2951 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2952 { |
|
2953 if(iBuffer->At(index).iPop3Settings->Apop()) |
|
2954 { |
|
2955 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
2956 } |
|
2957 else |
|
2958 { |
|
2959 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
2960 } |
|
2961 } |
|
2962 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2963 { |
|
2964 status = CSmlDmAdapter::ENotFound; |
|
2965 } |
|
2966 } |
|
2967 |
|
2968 else if (lastUriSeg.Compare(KNSmlDMEmailFolderPath)==0) |
|
2969 { |
|
2970 if( iBuffer->At(index).iImap4Settings ) |
|
2971 { |
|
2972 aObject.InsertL(0, iBuffer->At(index).iImap4Settings->FolderPath() ); |
|
2973 } |
|
2974 else |
|
2975 { |
|
2976 status = CSmlDmAdapter::ENotFound; |
|
2977 } |
|
2978 } |
|
2979 |
|
2980 else if(lastUriSeg.Compare(KNSmlDMEmailToNapID)==0) |
|
2981 { |
|
2982 CNSmlDMIAPMatcher* iapmatch=CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
2983 CleanupStack::PushL(iapmatch); |
|
2984 HBufC8* uri8 = NULL; |
|
2985 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
2986 if ( iapCount ) |
|
2987 { |
|
2988 TImIAPChoice localIAP = iBuffer->At(index).iIapPref->IAPPreference(0); |
|
2989 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
2990 } |
|
2991 |
|
2992 if( uri8 ) |
|
2993 { |
|
2994 CleanupStack::PushL(uri8); |
|
2995 aObject.InsertL(0,uri8->Des()); |
|
2996 status = CSmlDmAdapter::EOk; |
|
2997 CleanupStack::PopAndDestroy(); // uri8 |
|
2998 } |
|
2999 else |
|
3000 { |
|
3001 status = CSmlDmAdapter::ENotFound; |
|
3002 } |
|
3003 |
|
3004 CleanupStack::PopAndDestroy(); // iapMatch |
|
3005 } |
|
3006 else if(lastUriSeg.Compare(KNSmlDMEmailSToNapID)==0) |
|
3007 { |
|
3008 // SToNapID exists only for SMTP |
|
3009 if (iBuffer->At(index).iSmtpSettings!= NULL) |
|
3010 { |
|
3011 CNSmlDMIAPMatcher* iapmatch=CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
3012 CleanupStack::PushL(iapmatch); |
|
3013 HBufC8* uri8 = NULL; |
|
3014 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
3015 if ( iapCount ) |
|
3016 { |
|
3017 TImIAPChoice localIAP = iBuffer->At(index).iSmtpIapPref->IAPPreference(0); |
|
3018 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
3019 } |
|
3020 |
|
3021 if( uri8 ) |
|
3022 { |
|
3023 CleanupStack::PushL(uri8); |
|
3024 aObject.InsertL(0,uri8->Des()); |
|
3025 status = CSmlDmAdapter::EOk; |
|
3026 CleanupStack::PopAndDestroy(); // uri8 |
|
3027 } |
|
3028 else |
|
3029 { |
|
3030 status = CSmlDmAdapter::ENotFound; |
|
3031 } |
|
3032 |
|
3033 CleanupStack::PopAndDestroy(); // iapMatch |
|
3034 } |
|
3035 else |
|
3036 { |
|
3037 status = CSmlDmAdapter::ENotFound; |
|
3038 } |
|
3039 } |
|
3040 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : end"); |
|
3041 return status; |
|
3042 } |
|
3043 |
|
3044 // ----------------------------------------------------------------------------- |
|
3045 // void CNSmlDmEmailAdapter::SetDefaultSecurityL(const TDesC8& aObject, |
|
3046 // const TNSmlEmailSettingsElement* thisElem, |
|
3047 // const TNSmlEmailSecuritySetting aSetting ) |
|
3048 // Sets (on/off) the security modes: SSL/TLS, StartTLS |
|
3049 // ----------------------------------------------------------------------------- |
|
3050 void CNSmlDmEmailAdapter::SetDefaultSecurityL(const TDesC8& aObject, |
|
3051 const TNSmlEmailSettingsElement* aThisElem, |
|
3052 const TNSmlEmailSecuritySetting aSetting |
|
3053 ) const |
|
3054 { |
|
3055 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSecurityL(): begin"); |
|
3056 HBufC8 *data = aObject.AllocLC(); |
|
3057 TPtr8 dataPtr = data->Des(); |
|
3058 dataPtr.Capitalize(); |
|
3059 TBool object=EFalse; |
|
3060 if(dataPtr.Find(KNSmlDMEmailTrue)>=0) |
|
3061 { |
|
3062 object = ETrue; |
|
3063 } |
|
3064 switch ( aSetting ) |
|
3065 { |
|
3066 case EUseSecCon : |
|
3067 if ( object ) |
|
3068 { |
|
3069 if ( aThisElem->iImap4Settings ) |
|
3070 { |
|
3071 aThisElem->iImap4Settings->SetSecureSockets(EFalse); |
|
3072 aThisElem->iImap4Settings->SetSSLWrapper(ETrue); |
|
3073 aThisElem->iImap4Settings->SetPort( KNSmlDMEmailSslWrappedImap4Port ); |
|
3074 } |
|
3075 else if ( aThisElem->iPop3Settings ) |
|
3076 { |
|
3077 aThisElem->iPop3Settings->SetSecureSockets(EFalse); |
|
3078 aThisElem->iPop3Settings->SetSSLWrapper(ETrue); |
|
3079 aThisElem->iPop3Settings->SetPort( KNSmlDMEmailSslWrappedPop3Port ); |
|
3080 } |
|
3081 } |
|
3082 else |
|
3083 { |
|
3084 if ( aThisElem->iImap4Settings ) |
|
3085 { |
|
3086 aThisElem->iImap4Settings->SetPort( KNSmlDMEmailNormalImap4Port ); |
|
3087 aThisElem->iImap4Settings->SetSSLWrapper(EFalse); |
|
3088 } |
|
3089 else if ( aThisElem->iPop3Settings ) |
|
3090 { |
|
3091 aThisElem->iPop3Settings->SetPort( KNSmlDMEmailNormalPop3Port ); |
|
3092 aThisElem->iPop3Settings->SetSSLWrapper(EFalse); |
|
3093 } |
|
3094 } |
|
3095 break; |
|
3096 case EUseStartTls : |
|
3097 if ( object ) |
|
3098 { |
|
3099 if ( aThisElem->iImap4Settings ) |
|
3100 { |
|
3101 aThisElem->iImap4Settings->SetSecureSockets(ETrue); |
|
3102 aThisElem->iImap4Settings->SetSSLWrapper(EFalse); |
|
3103 aThisElem->iImap4Settings->SetPort( KNSmlDMEmailNormalImap4Port ); |
|
3104 } |
|
3105 else if ( aThisElem->iPop3Settings ) |
|
3106 { |
|
3107 aThisElem->iPop3Settings->SetSecureSockets(ETrue); |
|
3108 aThisElem->iPop3Settings->SetSSLWrapper(EFalse); |
|
3109 aThisElem->iPop3Settings->SetPort( KNSmlDMEmailNormalPop3Port ); |
|
3110 } |
|
3111 } |
|
3112 else |
|
3113 { |
|
3114 if ( aThisElem->iImap4Settings ) |
|
3115 { |
|
3116 aThisElem->iImap4Settings->SetSecureSockets(EFalse); |
|
3117 } |
|
3118 else if ( aThisElem->iPop3Settings ) |
|
3119 { |
|
3120 aThisElem->iPop3Settings->SetSecureSockets(EFalse); |
|
3121 } |
|
3122 } |
|
3123 break; |
|
3124 case ESuseSecCon : |
|
3125 if ( object ) |
|
3126 { |
|
3127 // The port is same in all cases |
|
3128 aThisElem->iSmtpSettings->SetSecureSockets(EFalse); |
|
3129 aThisElem->iSmtpSettings->SetSSLWrapper(ETrue); |
|
3130 aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailSslSmtpPort ); |
|
3131 } |
|
3132 else |
|
3133 { |
|
3134 aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailNormalSmtpPort ); |
|
3135 aThisElem->iSmtpSettings->SetSSLWrapper( EFalse ); |
|
3136 } |
|
3137 break; |
|
3138 case ESuseStartTls : |
|
3139 if ( object ) |
|
3140 { |
|
3141 // The port is same in all cases |
|
3142 aThisElem->iSmtpSettings->SetSecureSockets(ETrue); |
|
3143 aThisElem->iSmtpSettings->SetSSLWrapper(EFalse); |
|
3144 aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailNormalSmtpPort ); |
|
3145 } |
|
3146 else |
|
3147 { |
|
3148 aThisElem->iSmtpSettings->SetSecureSockets( EFalse ); |
|
3149 } |
|
3150 |
|
3151 break; |
|
3152 default : |
|
3153 break; |
|
3154 } |
|
3155 CleanupStack::PopAndDestroy(); // object |
|
3156 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSecurityL(): end"); |
|
3157 } |
|
3158 |
|
3159 // ----------------------------------------------------------------------------- |
|
3160 // CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchSecurityValueL( |
|
3161 // CBufBase& aObject, |
|
3162 // const TNSmlEmailSettingsElement* aElem, |
|
3163 // const TNSmlEmailSecuritySetting aSetting ) |
|
3164 // Gets the status(on/off) of security modes SSL/TLS or StartTLS |
|
3165 // ----------------------------------------------------------------------------- |
|
3166 |
|
3167 CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchSecurityValueL( |
|
3168 CBufBase& aObject, |
|
3169 const TNSmlEmailSettingsElement* aElem, |
|
3170 const TNSmlEmailSecuritySetting aSetting ) const |
|
3171 { |
|
3172 _DBG_FILE("CNSmlDmEmailAdapter::FetchSecurityValueL(): start"); |
|
3173 TBool result=EFalse; |
|
3174 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
3175 switch ( aSetting ) |
|
3176 { |
|
3177 |
|
3178 case EUseStartTls : |
|
3179 if ( aElem->iImap4Settings) |
|
3180 { |
|
3181 result = aElem->iImap4Settings->SecureSockets(); |
|
3182 } |
|
3183 else if(aElem->iPop3Settings) |
|
3184 { |
|
3185 result = aElem->iPop3Settings->SecureSockets(); |
|
3186 } |
|
3187 else |
|
3188 { |
|
3189 status = CSmlDmAdapter::EError; |
|
3190 } |
|
3191 break; |
|
3192 case EUseSecCon : |
|
3193 if ( aElem->iImap4Settings) |
|
3194 { |
|
3195 result = aElem->iImap4Settings->SSLWrapper(); |
|
3196 } |
|
3197 else if(aElem->iPop3Settings) |
|
3198 { |
|
3199 result = aElem->iPop3Settings->SSLWrapper(); |
|
3200 } |
|
3201 else |
|
3202 { |
|
3203 status = CSmlDmAdapter::EError; |
|
3204 } |
|
3205 break; |
|
3206 case ESuseStartTls : |
|
3207 if(aElem->iSmtpSettings) |
|
3208 { |
|
3209 result = aElem->iSmtpSettings->SecureSockets(); |
|
3210 } |
|
3211 else |
|
3212 { |
|
3213 status = CSmlDmAdapter::EError; |
|
3214 } |
|
3215 break; |
|
3216 case ESuseSecCon : |
|
3217 if(aElem->iSmtpSettings) |
|
3218 { |
|
3219 result = aElem->iSmtpSettings->SSLWrapper(); |
|
3220 } |
|
3221 else |
|
3222 { |
|
3223 status = CSmlDmAdapter::EError; |
|
3224 } |
|
3225 break; |
|
3226 default: |
|
3227 status = CSmlDmAdapter::EError; |
|
3228 break; |
|
3229 } |
|
3230 |
|
3231 if ( result ) |
|
3232 { |
|
3233 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
3234 } |
|
3235 else |
|
3236 { |
|
3237 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
3238 } |
|
3239 _DBG_FILE("CNSmlDmEmailAdapter::FetchSecurityValueL(): end"); |
|
3240 return status; |
|
3241 } |
|
3242 |
|
3243 //-------------------------------------------------------------------- |
|
3244 //TInt CNSmlDmEmailAdapter::ConstructTreeL(const TDesC8& aURI) |
|
3245 // |
|
3246 //------------------------------------------------------------------- |
|
3247 |
|
3248 TInt CNSmlDmEmailAdapter::ConstructTreeL(const TDesC8& aURI) |
|
3249 { |
|
3250 TInt ret = KErrNotFound; |
|
3251 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
3252 |
|
3253 if(aURI.Find(KNSmlDMEmailNodeName)!= KErrNotFound) |
|
3254 { |
|
3255 RArray<TImapAccount> imap4Accounts; |
|
3256 CleanupClosePushL( imap4Accounts ); |
|
3257 emailAccs->GetImapAccountsL(imap4Accounts); |
|
3258 |
|
3259 // First, IMAP accounts |
|
3260 // |
|
3261 TInt luid; |
|
3262 TPtrC8 name; |
|
3263 // cycle through every found account |
|
3264 for(TInt count = 0; count < imap4Accounts.Count(); count++) |
|
3265 { |
|
3266 |
|
3267 SetLuidById( EImap, imap4Accounts[count].iImapAccountId, luid ); |
|
3268 HBufC8 *uri = HBufC8::NewLC(KNSmlDMEmailNodeName().Length() + |
|
3269 KNSmlDMEmailMproIMAP().Length() + 6); |
|
3270 |
|
3271 TPtr8 uriPtr = uri->Des(); |
|
3272 uriPtr.Append(KNSmlDMEmailNodeName); |
|
3273 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
3274 uriPtr.Append(KNSmlDMEmailMproIMAP); |
|
3275 uriPtr.AppendNumFixedWidth(count,EDecimal,3); |
|
3276 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
3277 HBufC8* mapInfo = Callback().GetLuidAllocL(uriPtr); |
|
3278 if (mapInfo->Length() == 0) |
|
3279 { |
|
3280 Callback().SetMappingL(uriPtr, luidBuf->Des()); |
|
3281 if( aURI.Find(uriPtr) >= 0 ) |
|
3282 { |
|
3283 ret = luid; |
|
3284 } |
|
3285 } |
|
3286 else |
|
3287 { |
|
3288 delete mapInfo; |
|
3289 } |
|
3290 |
|
3291 CleanupStack::PopAndDestroy(2); //uri,luidBuf |
|
3292 } |
|
3293 CleanupStack::PopAndDestroy(); //imap4Accounts |
|
3294 |
|
3295 // Then, POP accounts |
|
3296 // |
|
3297 RArray<TPopAccount> pop3Accounts; |
|
3298 CleanupClosePushL( pop3Accounts ); |
|
3299 emailAccs->GetPopAccountsL( pop3Accounts ); |
|
3300 // cycle through every found account |
|
3301 for(TInt count = 0; count < pop3Accounts.Count(); count++) |
|
3302 { |
|
3303 SetLuidById( EPop, pop3Accounts[count].iPopAccountId, luid ); |
|
3304 |
|
3305 HBufC8 *uri = HBufC8::NewLC(KNSmlDMEmailNodeName().Length() + |
|
3306 KNSmlDMEmailMproPOP().Length() + 5); |
|
3307 TPtr8 uriPtr = uri->Des(); |
|
3308 uriPtr.Append(KNSmlDMEmailNodeName); |
|
3309 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
3310 uriPtr.Append(KNSmlDMEmailMproPOP); |
|
3311 uriPtr.AppendNumFixedWidth(count,EDecimal,3); |
|
3312 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
3313 HBufC8* mapInfo = Callback().GetLuidAllocL(uriPtr); |
|
3314 if (mapInfo->Length() == 0) |
|
3315 { |
|
3316 Callback().SetMappingL(uriPtr,luidBuf->Des()); |
|
3317 if( aURI.Find(uriPtr) >= 0 ) |
|
3318 { |
|
3319 ret = luid; |
|
3320 } |
|
3321 } |
|
3322 else |
|
3323 { |
|
3324 delete mapInfo; |
|
3325 } |
|
3326 |
|
3327 CleanupStack::PopAndDestroy(2); //uri,luidBuf |
|
3328 } |
|
3329 CleanupStack::PopAndDestroy(); //pop3Accounts |
|
3330 } |
|
3331 CleanupStack::PopAndDestroy(); //emailAccs |
|
3332 return ret; |
|
3333 } |
|
3334 // End of File |