|
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 else |
|
771 { |
|
772 status = CSmlDmAdapter::ENotFound; |
|
773 } |
|
774 if(data) |
|
775 { |
|
776 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
777 TPtr8 dataPtr8 = data8->Des(); |
|
778 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
779 |
|
780 object->InsertL(0,dataPtr8); |
|
781 CleanupStack::PopAndDestroy(2); //data, data8 |
|
782 } |
|
783 } |
|
784 |
|
785 else if(lastUriSeg.Compare(KNSmlDMEmailMsnd)==0) |
|
786 { |
|
787 HBufC *data = NULL; |
|
788 data = iBuffer->At(index).iSmtpSettings->ServerAddress().AllocLC(); |
|
789 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
790 TPtr8 dataPtr8 = data8->Des(); |
|
791 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
792 |
|
793 object->InsertL(0,dataPtr8); |
|
794 CleanupStack::PopAndDestroy(2); //data, data8 |
|
795 } |
|
796 |
|
797 else if(lastUriSeg.Compare(KNSmlDMEmailMpro)==0) |
|
798 { |
|
799 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
800 { |
|
801 object->InsertL(0,KNSmlDMEmailMproPOP); |
|
802 } |
|
803 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
804 { |
|
805 object->InsertL(0,KNSmlDMEmailMproIMAP); |
|
806 } |
|
807 } |
|
808 |
|
809 else if(lastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0) |
|
810 { |
|
811 FetchSecurityValueL(*object, &iBuffer->At(index), EUseSecCon ); |
|
812 } |
|
813 |
|
814 else if(lastUriSeg.Compare(KNSmlDMEmailUseSauth)==0) |
|
815 { |
|
816 if(iBuffer->At(index).iSmtpSettings->SMTPAuth()) |
|
817 { |
|
818 object->InsertL(0,KNSmlDMEmailTrue); |
|
819 } |
|
820 else |
|
821 { |
|
822 object->InsertL(0,KNSmlDMEmailFalse); |
|
823 } |
|
824 } |
|
825 |
|
826 else if(lastUriSeg.Compare(KNSmlDMEmailSauthUID)==0) |
|
827 { |
|
828 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->LoginName().Length()); |
|
829 data->Des().Copy(iBuffer->At(index).iSmtpSettings->LoginName()); |
|
830 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
831 CleanupStack::PushL(data8); |
|
832 object->InsertL(0,*data8); |
|
833 CleanupStack::PopAndDestroy(2);//data, data8 |
|
834 } |
|
835 |
|
836 else if(lastUriSeg.Compare(KNSmlDMEmailSauthPW)==0) |
|
837 { |
|
838 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->Password().Length()); |
|
839 data->Des().Copy(iBuffer->At(index).iSmtpSettings->Password()); |
|
840 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
841 CleanupStack::PushL(data8); |
|
842 object->InsertL(0,*data8); |
|
843 CleanupStack::PopAndDestroy(2);//data, data8 |
|
844 } |
|
845 |
|
846 else if(lastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0) |
|
847 { |
|
848 if(iBuffer->At(index).iSmtpSettings->InboxLoginDetails()) |
|
849 { |
|
850 object->InsertL(0,KNSmlDMEmailTrue); |
|
851 } |
|
852 else |
|
853 { |
|
854 object->InsertL(0,KNSmlDMEmailFalse); |
|
855 } |
|
856 } |
|
857 |
|
858 else if (lastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0) |
|
859 { |
|
860 FetchSecurityValueL(*object, &iBuffer->At(index), ESuseSecCon ); |
|
861 } |
|
862 |
|
863 else if (lastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0) |
|
864 { |
|
865 FetchSecurityValueL(*object, &iBuffer->At(index), EUseStartTls ); |
|
866 } |
|
867 |
|
868 else if (lastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0) |
|
869 { |
|
870 FetchSecurityValueL(*object, &iBuffer->At(index), ESuseStartTls ); |
|
871 } |
|
872 |
|
873 else if(lastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0) |
|
874 { |
|
875 TUint port; |
|
876 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
877 { |
|
878 port = iBuffer->At(index).iPop3Settings->Port(); |
|
879 } |
|
880 else |
|
881 { |
|
882 port = iBuffer->At(index).iImap4Settings->Port(); |
|
883 } |
|
884 HBufC8 *data = IntToDes8LC(port); |
|
885 object->InsertL(0,data->Des()); |
|
886 CleanupStack::PopAndDestroy(); //data |
|
887 } |
|
888 |
|
889 else if(lastUriSeg.Compare(KNSmlDMEmailMsndPort)==0) |
|
890 { |
|
891 TUint port = iBuffer->At(index).iSmtpSettings->Port(); |
|
892 HBufC8 *data = IntToDes8LC(port); |
|
893 object->InsertL(0,data->Des()); |
|
894 CleanupStack::PopAndDestroy(); //data |
|
895 } |
|
896 |
|
897 else if(lastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0) |
|
898 { |
|
899 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
900 { |
|
901 if(iBuffer->At(index).iPop3Settings->Apop()) |
|
902 { |
|
903 object->InsertL(0,KNSmlDMEmailTrue); |
|
904 } |
|
905 else |
|
906 { |
|
907 object->InsertL(0,KNSmlDMEmailFalse); |
|
908 } |
|
909 } |
|
910 else |
|
911 { |
|
912 status = CSmlDmAdapter::ENotFound; |
|
913 } |
|
914 } |
|
915 |
|
916 else if (lastUriSeg.Compare(KNSmlDMEmailFolderPath)==0) |
|
917 { |
|
918 if(iBuffer->At(index).iImap4Settings) |
|
919 { |
|
920 object->InsertL(0, iBuffer->At(index).iImap4Settings->FolderPath() ); |
|
921 } |
|
922 else |
|
923 { |
|
924 status = CSmlDmAdapter::ENotFound; |
|
925 } |
|
926 } |
|
927 |
|
928 else if(lastUriSeg.Compare(KNSmlDMEmailToNapID)==0) |
|
929 { |
|
930 |
|
931 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
932 CleanupStack::PushL(iapmatch); |
|
933 HBufC8* uri8 = NULL; |
|
934 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
935 if ( iapCount ) |
|
936 { |
|
937 TImIAPChoice localIAP = iBuffer->At(index).iIapPref->IAPPreference(0); |
|
938 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
939 } |
|
940 |
|
941 if( uri8 ) |
|
942 { |
|
943 CleanupStack::PushL(uri8); |
|
944 object->InsertL(0,uri8->Des()); |
|
945 status = CSmlDmAdapter::EOk; |
|
946 CleanupStack::PopAndDestroy(); // uri8 |
|
947 } |
|
948 |
|
949 CleanupStack::PopAndDestroy(); // iapMatch |
|
950 } |
|
951 else if(lastUriSeg.Compare(KNSmlDMEmailSToNapID)==0) |
|
952 { |
|
953 |
|
954 // SToNapID exists only for SMTP |
|
955 if (iBuffer->At(index).iSmtpSettings!= NULL) |
|
956 { |
|
957 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
958 CleanupStack::PushL(iapmatch); |
|
959 HBufC8* uri8 = NULL; |
|
960 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
961 if ( iapCount ) |
|
962 { |
|
963 TImIAPChoice localIAP = iBuffer->At(index).iSmtpIapPref->IAPPreference(0); |
|
964 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
965 } |
|
966 |
|
967 if( uri8 ) |
|
968 { |
|
969 CleanupStack::PushL(uri8); |
|
970 object->InsertL(0,uri8->Des()); |
|
971 status = CSmlDmAdapter::EOk; |
|
972 CleanupStack::PopAndDestroy(); // uri8 |
|
973 } |
|
974 |
|
975 CleanupStack::PopAndDestroy(); // iapMatch |
|
976 } |
|
977 else |
|
978 { |
|
979 status = CSmlDmAdapter::ENotFound; |
|
980 } |
|
981 } |
|
982 |
|
983 if(status == CSmlDmAdapter::EOk) |
|
984 { |
|
985 Callback().SetResultsL(aResultsRef,*object,aType); |
|
986 } |
|
987 Callback().SetStatusL(aStatusRef, status); |
|
988 CleanupStack::PopAndDestroy(object); //object |
|
989 |
|
990 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): end"); |
|
991 } |
|
992 |
|
993 // ----------------------------------------------------------------------------- |
|
994 // CNSmlDmEmailAdapter::ChildURIListL( const TDesC8& aURI, |
|
995 // const TDesC8& aParentLUID, |
|
996 // const CArrayFix<TSmlDmMappingInfo>& |
|
997 // aPreviousURISegmentList, |
|
998 // const TInt aResultsRef, |
|
999 // const TInt aStatusRef ) |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 void CNSmlDmEmailAdapter::ChildURIListL( const TDesC8& aURI, |
|
1002 const TDesC8& aParentLUID, |
|
1003 const CArrayFix<TSmlDmMappingInfo>& |
|
1004 aPreviousURISegmentList, |
|
1005 const TInt aResultsRef, |
|
1006 const TInt aStatusRef ) |
|
1007 { |
|
1008 _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): begin"); |
|
1009 |
|
1010 CSmlDmAdapter::TError ret = CSmlDmAdapter::EError; |
|
1011 |
|
1012 if( OpenSessionL() != KErrNone ) |
|
1013 { |
|
1014 Callback().SetStatusL(aStatusRef, ret); |
|
1015 _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): end"); |
|
1016 return; |
|
1017 } |
|
1018 CBufBase *currentList = CBufFlat::NewL(128); |
|
1019 CleanupStack::PushL(currentList); |
|
1020 |
|
1021 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
1022 |
|
1023 if(aURI.Compare(KNSmlDMEmailNodeName)==0) |
|
1024 { |
|
1025 RArray<TImapAccount> imap4Accounts; |
|
1026 CleanupClosePushL( imap4Accounts ); |
|
1027 emailAccs->GetImapAccountsL(imap4Accounts); |
|
1028 |
|
1029 // First, IMAP accounts |
|
1030 // |
|
1031 TInt luid; |
|
1032 TPtrC8 name; |
|
1033 // cycle through every found account |
|
1034 for(TInt count = 0; count < imap4Accounts.Count(); count++) |
|
1035 { |
|
1036 SetLuidById( EImap, imap4Accounts[count].iImapAccountId, luid ); |
|
1037 |
|
1038 TBool found = EFalse; |
|
1039 // cycle through every known account |
|
1040 for(TInt i = 0; i<aPreviousURISegmentList.Count();i++) |
|
1041 { |
|
1042 // compare if found is known |
|
1043 if( luid == DesToInt(aPreviousURISegmentList.At(i).iURISegLUID)) |
|
1044 { |
|
1045 found = ETrue; |
|
1046 name.Set(aPreviousURISegmentList.At(i).iURISeg); |
|
1047 break; |
|
1048 } |
|
1049 } |
|
1050 // if found != known add mapping to it |
|
1051 if(!found) |
|
1052 { |
|
1053 HBufC8 *uri = HBufC8::NewLC(aURI.Length() + |
|
1054 KNSmlDMEmailMproIMAP().Length() + 6); |
|
1055 |
|
1056 TPtr8 uriPtr = uri->Des(); |
|
1057 uriPtr.Format(aURI); |
|
1058 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
1059 uriPtr.Append(KNSmlDMEmailMproIMAP); |
|
1060 TUint16 crc; |
|
1061 Mem::Crc ( crc, &imap4Accounts[count],sizeof(TImapAccount) ); |
|
1062 HBufC8 *crcBuf = IntToDes8LC(crc); |
|
1063 uriPtr.Append(*crcBuf); |
|
1064 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
1065 Callback().SetMappingL(uriPtr,luidBuf->Des()); |
|
1066 currentList->InsertL( currentList->Size(),LastURISeg(uriPtr)); |
|
1067 CleanupStack::PopAndDestroy(3); //uri,luidBuf, crcBuf |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 currentList->InsertL( currentList->Size(),name ); |
|
1072 } |
|
1073 // in all cases: add it to results. |
|
1074 if(count < imap4Accounts.Count()-1 ) |
|
1075 { |
|
1076 currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8); |
|
1077 } |
|
1078 } |
|
1079 CleanupStack::PopAndDestroy(); //imap4Accounts |
|
1080 |
|
1081 // Then, POP accounts |
|
1082 // |
|
1083 RArray<TPopAccount> pop3Accounts; |
|
1084 CleanupClosePushL( pop3Accounts ); |
|
1085 emailAccs->GetPopAccountsL( pop3Accounts ); |
|
1086 if (pop3Accounts.Count()&¤tList->Size()>0) |
|
1087 { |
|
1088 // there is at least one account; insert separator |
|
1089 currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8); |
|
1090 } |
|
1091 // cycle through every found account |
|
1092 for(TInt count = 0; count < pop3Accounts.Count(); count++) |
|
1093 { |
|
1094 SetLuidById( EPop, pop3Accounts[count].iPopAccountId, luid ); |
|
1095 |
|
1096 TBool found = EFalse; |
|
1097 // cycle through every known account |
|
1098 for(TInt i = 0; i<aPreviousURISegmentList.Count();i++) |
|
1099 { |
|
1100 // compare if found is known |
|
1101 if( luid == DesToInt(aPreviousURISegmentList.At(i).iURISegLUID)) |
|
1102 |
|
1103 { |
|
1104 found = ETrue; |
|
1105 name.Set(aPreviousURISegmentList.At(i).iURISeg); |
|
1106 break; |
|
1107 } |
|
1108 } |
|
1109 // if found != known add mapping to it |
|
1110 if(!found) |
|
1111 { |
|
1112 |
|
1113 HBufC8 *uri = HBufC8::NewLC(aURI.Length() + |
|
1114 KNSmlDMEmailMproPOP().Length() + 5); |
|
1115 TPtr8 uriPtr = uri->Des(); |
|
1116 uriPtr.Format(aURI); |
|
1117 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
1118 uriPtr.Append(KNSmlDMEmailMproPOP); |
|
1119 TUint16 crc; |
|
1120 Mem::Crc ( crc, &pop3Accounts[count],sizeof(TPopAccount) ); |
|
1121 HBufC8 *crcBuf = IntToDes8LC(crc); |
|
1122 uriPtr.Append(*crcBuf); |
|
1123 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
1124 Callback().SetMappingL(uriPtr,luidBuf->Des()); |
|
1125 currentList->InsertL( currentList->Size(),LastURISeg(uriPtr)); |
|
1126 CleanupStack::PopAndDestroy(3); //uri,luidBuf,crcBuf |
|
1127 } |
|
1128 else |
|
1129 { |
|
1130 currentList->InsertL( currentList->Size(),name ); |
|
1131 } |
|
1132 // in all cases: add it to results. |
|
1133 if(count < pop3Accounts.Count()-1) |
|
1134 { |
|
1135 currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8); |
|
1136 } |
|
1137 } |
|
1138 CleanupStack::PopAndDestroy(); //pop3Accounts |
|
1139 ret = CSmlDmAdapter::EOk; |
|
1140 } |
|
1141 else |
|
1142 { |
|
1143 if(aParentLUID.Length() > 0) |
|
1144 { |
|
1145 TInt err = KErrNotFound; |
|
1146 TInt luid = DesToInt(aParentLUID); |
|
1147 TNSmlEmailAccountType accType; |
|
1148 TInt id; |
|
1149 GetIdByLuid( accType, id, luid ); |
|
1150 switch ( accType ) |
|
1151 { |
|
1152 case EImap: |
|
1153 { |
|
1154 RArray<TImapAccount> imap4Accounts; |
|
1155 CleanupClosePushL( imap4Accounts ); |
|
1156 emailAccs->GetImapAccountsL( imap4Accounts ); |
|
1157 for ( TInt i=0; i<imap4Accounts.Count(); i++ ) |
|
1158 { |
|
1159 if ( imap4Accounts[i].iImapAccountId == id ) |
|
1160 { |
|
1161 err = KErrNone; |
|
1162 break; |
|
1163 } |
|
1164 } |
|
1165 CleanupStack::PopAndDestroy(); //imap4Accounts |
|
1166 break; |
|
1167 } |
|
1168 case EPop: |
|
1169 { |
|
1170 RArray<TPopAccount> pop3Accounts; |
|
1171 CleanupClosePushL( pop3Accounts ); |
|
1172 emailAccs->GetPopAccountsL(pop3Accounts); |
|
1173 for ( TInt i=0; i<pop3Accounts.Count(); i++ ) |
|
1174 { |
|
1175 if ( pop3Accounts[i].iPopAccountId == id ) |
|
1176 { |
|
1177 err = KErrNone; |
|
1178 break; |
|
1179 } |
|
1180 } |
|
1181 CleanupStack::PopAndDestroy(); //pop3Accounts |
|
1182 break; |
|
1183 } |
|
1184 default: |
|
1185 ret = CSmlDmAdapter::EError; |
|
1186 break; |
|
1187 } |
|
1188 if( err == KErrNotFound ) |
|
1189 { |
|
1190 ret = CSmlDmAdapter::ENotFound; |
|
1191 } |
|
1192 |
|
1193 if ( err == KErrNone ) |
|
1194 { |
|
1195 ret = CSmlDmAdapter::EOk; |
|
1196 currentList->InsertL(0,KNSmlDMEmailListOfLeafs); |
|
1197 } |
|
1198 } |
|
1199 else |
|
1200 { |
|
1201 ret = CSmlDmAdapter::ENotFound; |
|
1202 } |
|
1203 } |
|
1204 // Common part |
|
1205 Callback().SetStatusL(aStatusRef, ret); |
|
1206 if( ret == CSmlDmAdapter::EOk ) |
|
1207 { |
|
1208 Callback().SetResultsL(aResultsRef,*currentList,KNullDesC8); |
|
1209 } |
|
1210 |
|
1211 CleanupStack::PopAndDestroy(emailAccs); //emailAccs |
|
1212 CleanupStack::PopAndDestroy(currentList); //currentList |
|
1213 _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): end"); |
|
1214 } |
|
1215 |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // CNSmlDmEmailAdapter::AddNodeObjectL( const TDesC8& aURI, |
|
1218 // const TDesC8& aParentLUID, const TInt aStatusRef ) |
|
1219 // ----------------------------------------------------------------------------- |
|
1220 void CNSmlDmEmailAdapter::AddNodeObjectL( const TDesC8& aURI, |
|
1221 const TDesC8& aParentLUID, |
|
1222 const TInt aStatusRef ) |
|
1223 { |
|
1224 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): begin"); |
|
1225 |
|
1226 if(aParentLUID.Length()>0) |
|
1227 { |
|
1228 TInt luid = DesToInt(aParentLUID); |
|
1229 TInt accId; |
|
1230 TNSmlEmailAccountType accType; |
|
1231 GetIdByLuid( accType, accId, luid ); |
|
1232 TInt err = OpenSessionL(); |
|
1233 if(err!=KErrNone) |
|
1234 { |
|
1235 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1236 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end"); |
|
1237 return; |
|
1238 } |
|
1239 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
1240 TBool accEx = AccountExistsL( emailAccs, accType, accId, -1 ); |
|
1241 CleanupStack::PopAndDestroy( emailAccs ); |
|
1242 if( accEx ) |
|
1243 { |
|
1244 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EAlreadyExists); |
|
1245 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EAlreadyExists end"); |
|
1246 return; |
|
1247 } |
|
1248 else |
|
1249 { |
|
1250 TInt ret = Callback().RemoveMappingL( KNSmlDMEmailAdapterImplUid, |
|
1251 GetDynamicEmailNodeUri(aURI), ETrue ); |
|
1252 if(ret != KErrNone) |
|
1253 { |
|
1254 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1255 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end"); |
|
1256 return; |
|
1257 } |
|
1258 } |
|
1259 Callback().SetMappingL(aURI,KNullDesC8); |
|
1260 } |
|
1261 |
|
1262 if( aURI.Find(KNSmlDMEmailNodeName)>=0 && NumOfURISegs(aURI)==2 ) |
|
1263 { |
|
1264 if( OpenSessionL() != KErrNone ) |
|
1265 { |
|
1266 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1267 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end"); |
|
1268 return; |
|
1269 } |
|
1270 |
|
1271 RFs fs; |
|
1272 User::LeaveIfError( fs.Connect() ); |
|
1273 CleanupClosePushL(fs); |
|
1274 //2files and 2 folders are needed for settings |
|
1275 if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs, |
|
1276 KNSmlDmFatMinimumFileSize*4)) |
|
1277 { |
|
1278 CleanupStack::PopAndDestroy(); //fs |
|
1279 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EDiskFull); |
|
1280 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EDiskFull end"); |
|
1281 return; |
|
1282 // do not write |
|
1283 } |
|
1284 CleanupStack::PopAndDestroy(); //fs |
|
1285 |
|
1286 |
|
1287 TNSmlEmailSettingsElement newNode; |
|
1288 newNode.iMappingName = aURI.AllocLC(); |
|
1289 newNode.iName = HBufC::NewLC(0); |
|
1290 newNode.iNodeBuf = new (ELeave) |
|
1291 CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity); |
|
1292 newNode.iExecuted = EFalse; |
|
1293 newNode.iImap4Settings = NULL; |
|
1294 newNode.iPop3Settings = NULL; |
|
1295 newNode.iSmtpSettings = NULL; |
|
1296 newNode.iIapPref = NULL; |
|
1297 newNode.iSmtpIapPref = NULL; |
|
1298 newNode.iLuid = 0; |
|
1299 newNode.iJustFetch=EFalse; |
|
1300 iBuffer->AppendL(newNode); |
|
1301 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
1302 TNSmlEmailCommandElement newCommand; |
|
1303 newCommand.iLastUriSeg = LastURISeg(aURI).AllocLC(); //aURI.AllocLC(); |
|
1304 newCommand.iData = NULL; |
|
1305 newCommand.iStatusRef = aStatusRef; |
|
1306 newCommand.iLeaf = EFalse; |
|
1307 newCommand.iStatus = CSmlDmAdapter::EOk; |
|
1308 TInt index = iBuffer->Count() - 1; |
|
1309 iBuffer->At(index).iNodeBuf->AppendL(newCommand); |
|
1310 CleanupStack::Pop(); //newCommand.iLastUriSeg |
|
1311 |
|
1312 |
|
1313 } |
|
1314 _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): end"); |
|
1315 } |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 // CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
1318 // const TDesC8& aLUID, RWriteStream*& aStream, const TDesC8& aType, |
|
1319 // const TInt aStatusRef ) |
|
1320 // This should update a stream object, but in case of Email settings streaming |
|
1321 // is not supported. |
|
1322 // ----------------------------------------------------------------------------- |
|
1323 void CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& /*aURI*/, |
|
1324 const TDesC8& /*aLUID*/, |
|
1325 RWriteStream*& /*aStream*/, |
|
1326 const TDesC8& /*aType*/, |
|
1327 const TInt aStatusRef ) |
|
1328 { |
|
1329 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(stream): begin"); |
|
1330 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1331 _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(stream): end"); |
|
1332 } |
|
1333 // ----------------------------------------------------------------------------- |
|
1334 // void CNSmlDmEmailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
1335 // const TDesC8& aLUID, const TDesC8& aType, const TInt aResultsRef, |
|
1336 // const TInt aStatusRef ) |
|
1337 // Fetches data object and returns its size. |
|
1338 // ----------------------------------------------------------------------------- |
|
1339 void CNSmlDmEmailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
1340 const TDesC8& aLUID, |
|
1341 const TDesC8& aType, |
|
1342 const TInt aResultsRef, |
|
1343 const TInt aStatusRef ) |
|
1344 { |
|
1345 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectSizeL(): begin"); |
|
1346 |
|
1347 CBufBase *result = CBufFlat::NewL(32); |
|
1348 CleanupStack::PushL(result); |
|
1349 CSmlDmAdapter::TError status = FetchObjectL(aURI, aLUID, *result); |
|
1350 if( status == CSmlDmAdapter::EOk ) |
|
1351 { |
|
1352 TInt objSizeInBytes = result->Size(); |
|
1353 TBuf8<4> stringObjSizeInBytes; |
|
1354 stringObjSizeInBytes.Num( objSizeInBytes ); |
|
1355 result->Reset(); |
|
1356 result->InsertL( 0, stringObjSizeInBytes ); |
|
1357 Callback().SetResultsL(aResultsRef, *result, aType); |
|
1358 } |
|
1359 Callback().SetStatusL(aStatusRef, status); |
|
1360 CleanupStack::PopAndDestroy(); //result |
|
1361 _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectSizeL(): end"); |
|
1362 } |
|
1363 // ----------------------------------------------------------------------------- |
|
1364 // CNSmlDmEmailAdapter::ExecuteCommandL() |
|
1365 // ----------------------------------------------------------------------------- |
|
1366 void CNSmlDmEmailAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, |
|
1367 const TDesC8& /*aLUID*/, |
|
1368 const TDesC8& /*aArgument*/, |
|
1369 const TDesC8& /*aType*/, |
|
1370 const TInt aStatusRef ) |
|
1371 { |
|
1372 //Not supported |
|
1373 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): begin"); |
|
1374 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1375 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): end"); |
|
1376 } |
|
1377 |
|
1378 // ----------------------------------------------------------------------------- |
|
1379 // CNSmlDmEmailAdapter::ExecuteCommandL() |
|
1380 // ----------------------------------------------------------------------------- |
|
1381 void CNSmlDmEmailAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, |
|
1382 const TDesC8& /*aLUID*/, |
|
1383 RWriteStream*& /*aStream*/, |
|
1384 const TDesC8& /*aType*/, |
|
1385 const TInt aStatusRef ) |
|
1386 { |
|
1387 //Not supported |
|
1388 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): begin"); |
|
1389 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1390 _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): end"); |
|
1391 } |
|
1392 |
|
1393 // ----------------------------------------------------------------------------- |
|
1394 // CNSmlDmEmailAdapter::CopyCommandL() |
|
1395 // ----------------------------------------------------------------------------- |
|
1396 void CNSmlDmEmailAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, |
|
1397 const TDesC8& /*aTargetLUID*/, |
|
1398 const TDesC8& /*aSourceURI*/, |
|
1399 const TDesC8& /*aSourceLUID*/, |
|
1400 const TDesC8& /*aType*/, |
|
1401 TInt aStatusRef ) |
|
1402 { |
|
1403 //Not supported |
|
1404 _DBG_FILE("CNSmlDmEmailAdapter::CopyCommandL(): begin"); |
|
1405 Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); |
|
1406 _DBG_FILE("CNSmlDmEmailAdapter::CopyCommandL(): end"); |
|
1407 } |
|
1408 |
|
1409 // ----------------------------------------------------------------------------- |
|
1410 // CNSmlDmEmailAdapter::StartAtomicL() |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 void CNSmlDmEmailAdapter::StartAtomicL() |
|
1413 { |
|
1414 //Not supported |
|
1415 _DBG_FILE("CNSmlDmEmailAdapter::StartAtomicL(): begin"); |
|
1416 _DBG_FILE("CNSmlDmEmailAdapter::StartAtomicL(): end"); |
|
1417 } |
|
1418 |
|
1419 // ----------------------------------------------------------------------------- |
|
1420 // CNSmlDmEmailAdapter::CommitAtomicL() |
|
1421 // ----------------------------------------------------------------------------- |
|
1422 void CNSmlDmEmailAdapter::CommitAtomicL() |
|
1423 { |
|
1424 //Not supported |
|
1425 _DBG_FILE("CNSmlDmEmailAdapter::CommitAtomicL(): begin"); |
|
1426 _DBG_FILE("CNSmlDmEmailAdapter::CommitAtomicL(): end"); |
|
1427 } |
|
1428 |
|
1429 // ----------------------------------------------------------------------------- |
|
1430 // CNSmlDmEmailAdapter::RollbackAtomicL() |
|
1431 // ----------------------------------------------------------------------------- |
|
1432 void CNSmlDmEmailAdapter::RollbackAtomicL() |
|
1433 { |
|
1434 //Not supported |
|
1435 _DBG_FILE("CNSmlDmEmailAdapter::RollbackAtomicL(): begin"); |
|
1436 _DBG_FILE("CNSmlDmEmailAdapter::RollbackAtomicL(): end"); |
|
1437 } |
|
1438 |
|
1439 // ----------------------------------------------------------------------------- |
|
1440 // CNSmlDmEmailAdapter::StreamingSupport() |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 TBool CNSmlDmEmailAdapter::StreamingSupport( TInt& /*aItemSize*/ ) |
|
1443 { |
|
1444 _DBG_FILE("CNSmlDmEmailAdapter::StreamingSupport(): begin"); |
|
1445 _DBG_FILE("CNSmlDmEmailAdapter::StreamingSupport(): end"); |
|
1446 return EFalse; |
|
1447 } |
|
1448 |
|
1449 // ----------------------------------------------------------------------------- |
|
1450 // CNSmlDmEmailAdapter::StreamCommittedL() |
|
1451 // ----------------------------------------------------------------------------- |
|
1452 void CNSmlDmEmailAdapter::StreamCommittedL() |
|
1453 { |
|
1454 //Not supported |
|
1455 _DBG_FILE("CNSmlDmEmailAdapter::StreamCommittedL(): begin"); |
|
1456 _DBG_FILE("CNSmlDmEmailAdapter::StreamCommittedL(): end"); |
|
1457 } |
|
1458 // ----------------------------------------------------------------------------- |
|
1459 // CNSmlDmEmailAdapter::CompleteOutstandingCmdsL() |
|
1460 // Indication of message ending. The buffered commands must be executed |
|
1461 // before return of this function. |
|
1462 // ----------------------------------------------------------------------------- |
|
1463 void CNSmlDmEmailAdapter::CompleteOutstandingCmdsL() |
|
1464 { |
|
1465 _DBG_FILE("CNSmlDmEmailAdapter::CompleteOutstandingCmdsL(): begin"); |
|
1466 |
|
1467 for(TInt i=0;i<iBuffer->Count();i++) |
|
1468 { |
|
1469 |
|
1470 //Set buffered port values |
|
1471 for(TInt cmd=0;cmd<iBuffer->At(i).iNodeBuf->Count();cmd++) |
|
1472 { |
|
1473 |
|
1474 TNSmlEmailSettingsElement& bufElem = iBuffer->At(i); |
|
1475 TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(cmd); |
|
1476 |
|
1477 if(elem.iLastUriSeg->Compare(KNSmlDMEmailMrcvPort)==0) |
|
1478 { |
|
1479 TUint port = DesToInt(*elem.iData); |
|
1480 |
|
1481 if(port>0 && port <= KNSmlDMEmailMaxPortNbr) |
|
1482 { |
|
1483 if(bufElem.iPop3Settings!= NULL) |
|
1484 { |
|
1485 bufElem.iPop3Settings->SetPort(port); |
|
1486 } |
|
1487 else if(bufElem.iImap4Settings!= NULL) |
|
1488 { |
|
1489 bufElem.iImap4Settings->SetPort(port); |
|
1490 } |
|
1491 } |
|
1492 else |
|
1493 { |
|
1494 elem.iStatus = CSmlDmAdapter::EInvalidObject; |
|
1495 } |
|
1496 } |
|
1497 else if(elem.iLastUriSeg->Compare(KNSmlDMEmailMsndPort)==0) |
|
1498 { |
|
1499 TUint port = DesToInt(*elem.iData); |
|
1500 |
|
1501 if(port>0 && port <= KNSmlDMEmailMaxPortNbr) |
|
1502 { |
|
1503 bufElem.iSmtpSettings->SetPort(port); |
|
1504 } |
|
1505 else |
|
1506 { |
|
1507 elem.iStatus = CSmlDmAdapter::EInvalidObject; |
|
1508 } |
|
1509 } |
|
1510 if((iBuffer->At(i).iSmtpSettings->LoginName()==KNullDesC8) && elem.iLastUriSeg->Compare(KNSmlDMEmailUID)==0) |
|
1511 { |
|
1512 elem.iStatus = CSmlDmAdapter::EError; |
|
1513 } |
|
1514 } |
|
1515 |
|
1516 |
|
1517 CSmlDmAdapter::TError stat = CSmlDmAdapter::EOk; |
|
1518 TInt luid=-1; |
|
1519 |
|
1520 if(iBuffer->At(i).iExecuted) |
|
1521 { |
|
1522 TRAPD( leaveCode,luid = ValidateAndStoreSettingsL(i) ); |
|
1523 if(leaveCode!=KErrNone) |
|
1524 { |
|
1525 stat = CSmlDmAdapter::EError; |
|
1526 } |
|
1527 } |
|
1528 else |
|
1529 { |
|
1530 stat = CSmlDmAdapter::EError; |
|
1531 } |
|
1532 |
|
1533 for(TInt cmd=0;cmd<iBuffer->At(i).iNodeBuf->Count();cmd++) |
|
1534 { |
|
1535 |
|
1536 if(iBuffer->At(i).iNodeBuf->At(cmd).iStatus==CSmlDmAdapter::EOk) |
|
1537 { |
|
1538 Callback().SetStatusL(iBuffer->At(i).iNodeBuf->At(cmd).iStatusRef, |
|
1539 stat); |
|
1540 if(!iBuffer->At(i).iNodeBuf->At(cmd).iLeaf) |
|
1541 { |
|
1542 if(stat==CSmlDmAdapter::EOk) |
|
1543 { |
|
1544 HBufC8* luidDes = IntToDes8LC(luid); |
|
1545 Callback().SetMappingL( iBuffer->At(i).iMappingName->Des(), |
|
1546 luidDes->Des() ); |
|
1547 CleanupStack::PopAndDestroy(); //luidDes |
|
1548 } |
|
1549 } |
|
1550 } |
|
1551 else |
|
1552 { |
|
1553 Callback().SetStatusL(iBuffer->At(i).iNodeBuf->At(cmd).iStatusRef, |
|
1554 iBuffer->At(i).iNodeBuf->At(cmd).iStatus); |
|
1555 } |
|
1556 |
|
1557 delete iBuffer->At(i).iNodeBuf->At(cmd).iLastUriSeg; |
|
1558 iBuffer->At(i).iNodeBuf->At(cmd).iLastUriSeg= NULL; |
|
1559 delete iBuffer->At(i).iNodeBuf->At(cmd).iData; |
|
1560 iBuffer->At(i).iNodeBuf->At(cmd).iData= NULL; |
|
1561 |
|
1562 } |
|
1563 iBuffer->At(i).iNodeBuf->Reset(); |
|
1564 delete iBuffer->At(i).iNodeBuf; |
|
1565 iBuffer->At(i).iNodeBuf = NULL; |
|
1566 delete iBuffer->At(i).iMappingName; |
|
1567 iBuffer->At(i).iMappingName= NULL; |
|
1568 delete iBuffer->At(i).iName; |
|
1569 iBuffer->At(i).iName= NULL; |
|
1570 delete iBuffer->At(i).iSmtpSettings; |
|
1571 iBuffer->At(i).iSmtpSettings= NULL; |
|
1572 delete iBuffer->At(i).iPop3Settings; |
|
1573 iBuffer->At(i).iPop3Settings= NULL; |
|
1574 delete iBuffer->At(i).iImap4Settings; |
|
1575 iBuffer->At(i).iImap4Settings= NULL; |
|
1576 delete iBuffer->At(i).iIapPref; |
|
1577 iBuffer->At(i).iIapPref= NULL; |
|
1578 delete iBuffer->At(i).iSmtpIapPref; |
|
1579 iBuffer->At(i).iSmtpIapPref= NULL; |
|
1580 |
|
1581 } // end for |
|
1582 iBuffer->Reset(); |
|
1583 |
|
1584 _DBG_FILE("CNSmlDmEmailAdapter::CompleteOutstandingCmdsL(): end"); |
|
1585 } |
|
1586 |
|
1587 // ----------------------------------------------------------------------------- |
|
1588 // |
|
1589 // ----------------------------------------------------------------------------- |
|
1590 |
|
1591 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
1592 #define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) {{aUid},(aFuncPtr)} |
|
1593 #endif |
|
1594 |
|
1595 const TImplementationProxy ImplementationTable[] = |
|
1596 { |
|
1597 IMPLEMENTATION_PROXY_ENTRY(KNSmlDMEmailAdapterImplUid, |
|
1598 CNSmlDmEmailAdapter::NewL) |
|
1599 }; |
|
1600 |
|
1601 // ----------------------------------------------------------------------------- |
|
1602 // |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
1605 { |
|
1606 _DBG_FILE("ImplementationGroupProxy() for CNSmlDmEmailAdapter: begin"); |
|
1607 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
1608 _DBG_FILE("ImplementationGroupProxy() for CNSmlDmEmailAdapter: end"); |
|
1609 return ImplementationTable; |
|
1610 } |
|
1611 |
|
1612 |
|
1613 |
|
1614 // ----------------------------------------------------------------------------- |
|
1615 // TPtrC8 CNSmlDmEmailAdapter::LastURISeg(const TDesC8& aURI) |
|
1616 // Returns only the last uri segemnt |
|
1617 // ----------------------------------------------------------------------------- |
|
1618 TPtrC8 CNSmlDmEmailAdapter::LastURISeg(const TDesC8& aURI) const |
|
1619 { |
|
1620 _DBG_FILE("CNSmlDmEmailAdapter::LastURISeg() : begin"); |
|
1621 TInt i; |
|
1622 for(i=aURI.Length()-1;i>=0;i--) |
|
1623 { |
|
1624 if(aURI[i]=='/') |
|
1625 { |
|
1626 break; |
|
1627 } |
|
1628 } |
|
1629 _DBG_FILE("CNSmlDmEmailAdapter::LastURISeg() : end"); |
|
1630 if(i==0) |
|
1631 { |
|
1632 return aURI; |
|
1633 } |
|
1634 else |
|
1635 { |
|
1636 return aURI.Mid(i+1); |
|
1637 } |
|
1638 } |
|
1639 |
|
1640 // ----------------------------------------------------------------------------- |
|
1641 // TPtrC8 CNSmlDmEmailAdapter::RemoveLastURISeg(const TDesC8& aURI) |
|
1642 // returns parent uri, i.e. removes last uri segment |
|
1643 // ----------------------------------------------------------------------------- |
|
1644 TPtrC8 CNSmlDmEmailAdapter::RemoveLastURISeg(const TDesC8& aURI) const |
|
1645 { |
|
1646 TInt i; |
|
1647 for(i=aURI.Length()-1;i>=0;i--) |
|
1648 { |
|
1649 if(aURI[i]=='/') |
|
1650 { |
|
1651 break; |
|
1652 } |
|
1653 } |
|
1654 return aURI.Left(i); |
|
1655 } |
|
1656 |
|
1657 |
|
1658 |
|
1659 // ----------------------------------------------------------------------------- |
|
1660 // TInt CNSmlDmEmailAdapter::NumOfURISegs(const TDesC8& aURI) |
|
1661 // Returns the num of uri segs |
|
1662 // ----------------------------------------------------------------------------- |
|
1663 TInt CNSmlDmEmailAdapter::NumOfURISegs(const TDesC8& aURI) const |
|
1664 { |
|
1665 TInt numOfURISegs = 1; |
|
1666 for(TInt i=0;i<aURI.Length();i++) |
|
1667 { |
|
1668 if(aURI[i]=='/') |
|
1669 { |
|
1670 numOfURISegs++; |
|
1671 } |
|
1672 } |
|
1673 return numOfURISegs; |
|
1674 } |
|
1675 |
|
1676 |
|
1677 |
|
1678 // ----------------------------------------------------------------------------- |
|
1679 // void CNSmlDmEmailAdapter::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, |
|
1680 // TAny* /*aArg1*/, |
|
1681 // TAny* /*aArg2*/, |
|
1682 // TAny* /*aArg3*/ ) |
|
1683 // ----------------------------------------------------------------------------- |
|
1684 void CNSmlDmEmailAdapter::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, |
|
1685 TAny* /*aArg1*/, |
|
1686 TAny* /*aArg2*/, |
|
1687 TAny* /*aArg3*/ ) |
|
1688 { |
|
1689 _DBG_FILE("CNSmlDmEmailAdapter::HandleSessionEventL(): begin"); |
|
1690 _DBG_FILE("CNSmlDmEmailAdapter::HandleSessionEventL(): end"); |
|
1691 } |
|
1692 |
|
1693 |
|
1694 // ----------------------------------------------------------------------------- |
|
1695 // TInt CNSmlDmEmailAdapter::DesToInt(const TDesC& aLuid) const |
|
1696 // Converts 16bit descriptor to int |
|
1697 // ----------------------------------------------------------------------------- |
|
1698 TInt CNSmlDmEmailAdapter::DesToInt(const TDesC& aLuid) const |
|
1699 { |
|
1700 TLex16 lex(aLuid); |
|
1701 TInt value = 0; |
|
1702 lex.Val(value); |
|
1703 return value; |
|
1704 } |
|
1705 |
|
1706 // ----------------------------------------------------------------------------- |
|
1707 // TInt CNSmlDmEmailAdapter::DesToInt(const TDesC8& aLuid) const |
|
1708 // Converts 8bit descriptor to int |
|
1709 // ----------------------------------------------------------------------------- |
|
1710 TInt CNSmlDmEmailAdapter::DesToInt(const TDesC8& aLuid) const |
|
1711 { |
|
1712 TLex8 lex(aLuid); |
|
1713 TInt value = 0; |
|
1714 lex.Val(value); |
|
1715 return value; |
|
1716 } |
|
1717 |
|
1718 // ----------------------------------------------------------------------------- |
|
1719 // CNSmlDmEmailAdapter::FirstAddLeafL() |
|
1720 // ----------------------------------------------------------------------------- |
|
1721 TInt CNSmlDmEmailAdapter::FirstAddLeafL(const TDesC8& aURI, |
|
1722 const TDesC8& aObject, |
|
1723 TInt aStatusRef, |
|
1724 TInt aIndex) |
|
1725 { |
|
1726 _DBG_FILE("CNSmlDmEmailAdapter::FirstAddLeafL() :: begin"); |
|
1727 |
|
1728 TPtrC8 lastSeg = LastURISeg(aURI); |
|
1729 |
|
1730 TNSmlEmailCommandElement newCommand; |
|
1731 newCommand.iLastUriSeg = lastSeg.AllocLC(); |
|
1732 newCommand.iData = aObject.AllocLC(); |
|
1733 newCommand.iStatusRef = aStatusRef; |
|
1734 newCommand.iLeaf = ETrue; |
|
1735 newCommand.iStatus = CSmlDmAdapter::EOk; |
|
1736 iBuffer->At(aIndex).iNodeBuf->AppendL(newCommand); |
|
1737 CleanupStack::Pop(2); //newCommand.iLastUriSeg, newCommand.iData |
|
1738 if(!iBuffer->At(aIndex).iExecuted) |
|
1739 { |
|
1740 if(lastSeg.Compare(KNSmlDMEmailMpro)==0) |
|
1741 { |
|
1742 TBool ok = EFalse; |
|
1743 HBufC8* object = aObject.AllocLC(); |
|
1744 TPtr8 objectPtr = object->Des(); |
|
1745 objectPtr.UpperCase(); |
|
1746 |
|
1747 if(objectPtr.Find(KNSmlDMEmailMproPOP) >= 0) |
|
1748 { |
|
1749 iBuffer->At(aIndex).iPop3Settings = new(ELeave) CImPop3Settings; |
|
1750 ok=ETrue; |
|
1751 } |
|
1752 |
|
1753 else if(objectPtr.Find(KNSmlDMEmailMproIMAP) >= 0) |
|
1754 { |
|
1755 iBuffer->At(aIndex).iImap4Settings = new(ELeave) CImImap4Settings; |
|
1756 ok=ETrue; |
|
1757 } |
|
1758 if(ok) |
|
1759 { |
|
1760 iBuffer->At(aIndex).iSmtpSettings = new(ELeave) CImSmtpSettings; |
|
1761 iBuffer->At(aIndex).iIapPref = CImIAPPreferences::NewLC(); |
|
1762 iBuffer->At(aIndex).iSmtpIapPref = CImIAPPreferences::NewLC(); |
|
1763 CleanupStack::Pop(); //iBuffer->At(index).iIapPref |
|
1764 CleanupStack::Pop(); //iBuffer->At(index).iSmtpIapPref |
|
1765 SetDefaultSettingsL(aIndex); |
|
1766 |
|
1767 for(TInt i = 0; i<iBuffer->At(aIndex).iNodeBuf->Count();i++) |
|
1768 { |
|
1769 if(iBuffer->At(aIndex).iNodeBuf->At(i).iLeaf) |
|
1770 { |
|
1771 DoAddLeafObjectL(iBuffer->At(aIndex).iNodeBuf->At(i).iLastUriSeg->Des(), |
|
1772 iBuffer->At(aIndex).iNodeBuf->At(i).iData->Des(), |
|
1773 aIndex, i); |
|
1774 } |
|
1775 } |
|
1776 |
|
1777 iBuffer->At(aIndex).iExecuted = ETrue; |
|
1778 } |
|
1779 CleanupStack::PopAndDestroy(); //object |
|
1780 } |
|
1781 } |
|
1782 else |
|
1783 { |
|
1784 DoAddLeafObjectL(lastSeg,aObject,aIndex, |
|
1785 iBuffer->At(aIndex).iNodeBuf->Count()-1); |
|
1786 } |
|
1787 |
|
1788 _DBG_FILE("CNSmlDmEmailAdapter::FirstAddLeafL() :: end"); |
|
1789 return KErrNone; |
|
1790 } |
|
1791 |
|
1792 |
|
1793 // ----------------------------------------------------------------------------- |
|
1794 // CNSmlDmEmailAdapter::DoAddLeafObjectL |
|
1795 // ----------------------------------------------------------------------------- |
|
1796 TInt CNSmlDmEmailAdapter::DoAddLeafObjectL(const TDesC8& aLastUriSeg, |
|
1797 const TDesC8& aObject, |
|
1798 TInt aIndex, |
|
1799 TInt aCommand) |
|
1800 { |
|
1801 _DBG_FILE("CNSmlDmEmailAdapter::DoAddLeafObjectL() :: begin"); |
|
1802 if(aLastUriSeg.Compare(KNSmlDMEmailName)==0) |
|
1803 { |
|
1804 if ( aObject.Size() < KEmailAccountNameSize ) |
|
1805 { |
|
1806 delete iBuffer->At(aIndex).iName; |
|
1807 iBuffer->At(aIndex).iName = NULL; |
|
1808 iBuffer->At(aIndex).iName = HBufC::NewL(aObject.Size()); |
|
1809 TPtr namePtr = iBuffer->At(aIndex).iName->Des(); |
|
1810 CnvUtfConverter::ConvertToUnicodeFromUtf8( namePtr, aObject ); |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = |
|
1815 CSmlDmAdapter::ETooLargeObject; |
|
1816 } |
|
1817 } |
|
1818 |
|
1819 else if(aLastUriSeg.Compare(KNSmlDMEmailUID)==0) |
|
1820 { |
|
1821 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1822 { |
|
1823 iBuffer->At(aIndex).iPop3Settings->SetLoginNameL(aObject); |
|
1824 } |
|
1825 else if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
1826 { |
|
1827 iBuffer->At(aIndex).iImap4Settings->SetLoginNameL(aObject); |
|
1828 } |
|
1829 if(iBuffer->At(aIndex).iSmtpSettings->LoginName()==KNullDesC8) |
|
1830 { |
|
1831 iBuffer->At(aIndex).iSmtpSettings->SetLoginNameL(aObject); |
|
1832 } |
|
1833 } |
|
1834 |
|
1835 else if(aLastUriSeg.Compare(KNSmlDMEmailPW)==0) |
|
1836 { |
|
1837 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1838 { |
|
1839 iBuffer->At(aIndex).iPop3Settings->SetPasswordL(aObject); |
|
1840 } |
|
1841 else if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
1842 { |
|
1843 iBuffer->At(aIndex).iImap4Settings->SetPasswordL(aObject); |
|
1844 } |
|
1845 if(iBuffer->At(aIndex).iSmtpSettings->Password()==KNullDesC8) |
|
1846 { |
|
1847 iBuffer->At(aIndex).iSmtpSettings->SetPasswordL(aObject); |
|
1848 } |
|
1849 } |
|
1850 |
|
1851 else if(aLastUriSeg.Compare(KNSmlDMEmailUAddr)==0) |
|
1852 { |
|
1853 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1854 TPtr objectPtr = object->Des(); |
|
1855 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1856 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1857 { |
|
1858 iBuffer->At(aIndex).iSmtpSettings->SetEmailAddressL(objectPtr); |
|
1859 iBuffer->At(aIndex).iSmtpSettings->SetReplyToAddressL(objectPtr); |
|
1860 iBuffer->At(aIndex).iSmtpSettings->SetReceiptAddressL(objectPtr); |
|
1861 } |
|
1862 |
|
1863 CleanupStack::PopAndDestroy(); //object |
|
1864 } |
|
1865 |
|
1866 else if(aLastUriSeg.Compare(KNSmlDMEmailUName)==0) |
|
1867 { |
|
1868 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1869 TPtr objectPtr = object->Des(); |
|
1870 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1871 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1872 { |
|
1873 iBuffer->At(aIndex).iSmtpSettings->SetEmailAliasL(objectPtr); |
|
1874 } |
|
1875 CleanupStack::PopAndDestroy(); //object |
|
1876 } |
|
1877 |
|
1878 else if(aLastUriSeg.Compare( KNSmlDMEmailMrcv)==0) |
|
1879 { |
|
1880 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1881 TPtr objectPtr = object->Des(); |
|
1882 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1883 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
1884 { |
|
1885 iBuffer->At(aIndex).iPop3Settings->SetServerAddressL(objectPtr); |
|
1886 } |
|
1887 else if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
1888 { |
|
1889 iBuffer->At(aIndex).iImap4Settings->SetServerAddressL(objectPtr); |
|
1890 } |
|
1891 CleanupStack::PopAndDestroy(); //object |
|
1892 } |
|
1893 |
|
1894 else if(aLastUriSeg.Compare(KNSmlDMEmailMsnd)==0) |
|
1895 { |
|
1896 HBufC *object = HBufC::NewLC(aObject.Size()); |
|
1897 TPtr objectPtr = object->Des(); |
|
1898 CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject ); |
|
1899 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1900 { |
|
1901 iBuffer->At(aIndex).iSmtpSettings->SetServerAddressL(objectPtr); |
|
1902 } |
|
1903 CleanupStack::PopAndDestroy(); //object |
|
1904 } |
|
1905 |
|
1906 else if(aLastUriSeg.Compare(KNSmlDMEmailMpro)==0) |
|
1907 { |
|
1908 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = CSmlDmAdapter::EOk; |
|
1909 } |
|
1910 |
|
1911 else if(aLastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0) |
|
1912 { |
|
1913 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), EUseSecCon ); |
|
1914 } |
|
1915 |
|
1916 else if(aLastUriSeg.Compare(KNSmlDMEmailUseSauth)==0) |
|
1917 { |
|
1918 HBufC8 *data = aObject.AllocLC(); |
|
1919 TPtr8 dataPtr = data->Des(); |
|
1920 dataPtr.Capitalize(); |
|
1921 TBool object=EFalse; |
|
1922 if(dataPtr.Find(KNSmlDMEmailTrue)>=0) |
|
1923 { |
|
1924 object = ETrue; |
|
1925 } |
|
1926 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1927 { |
|
1928 iBuffer->At(aIndex).iSmtpSettings->SetSMTPAuth(object); |
|
1929 } |
|
1930 CleanupStack::PopAndDestroy(); //data |
|
1931 } |
|
1932 |
|
1933 else if(aLastUriSeg.Compare(KNSmlDMEmailSauthUID)==0) |
|
1934 { |
|
1935 if( iBuffer->At(aIndex).iSmtpSettings ) |
|
1936 { |
|
1937 iBuffer->At(aIndex).iSmtpSettings->SetLoginNameL(aObject); |
|
1938 } |
|
1939 } |
|
1940 |
|
1941 else if(aLastUriSeg.Compare(KNSmlDMEmailSauthPW)==0) |
|
1942 { |
|
1943 if( iBuffer->At(aIndex).iSmtpSettings ) |
|
1944 { |
|
1945 iBuffer->At(aIndex).iSmtpSettings->SetPasswordL( aObject ); |
|
1946 } |
|
1947 } |
|
1948 |
|
1949 else if(aLastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0) |
|
1950 { |
|
1951 HBufC8 *data = aObject.AllocLC(); |
|
1952 TPtr8 dataPtr = data->Des(); |
|
1953 dataPtr.Capitalize(); |
|
1954 TBool object=EFalse; |
|
1955 if(dataPtr.Find(KNSmlDMEmailTrue)>=0) |
|
1956 { |
|
1957 object = ETrue; |
|
1958 } |
|
1959 if(iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
1960 { |
|
1961 iBuffer->At(aIndex).iSmtpSettings->SetInboxLoginDetails(object); |
|
1962 } |
|
1963 CleanupStack::PopAndDestroy(); //data |
|
1964 } |
|
1965 |
|
1966 else if(aLastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0) |
|
1967 { |
|
1968 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), ESuseSecCon ); |
|
1969 } |
|
1970 |
|
1971 else if(aLastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0) |
|
1972 { |
|
1973 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), EUseStartTls ); |
|
1974 } |
|
1975 |
|
1976 else if(aLastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0) |
|
1977 { |
|
1978 SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), ESuseStartTls ); |
|
1979 } |
|
1980 |
|
1981 else if(aLastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0) |
|
1982 { |
|
1983 TNSmlEmailSettingsElement& bufElem = iBuffer->At(aIndex); |
|
1984 TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(aCommand); |
|
1985 elem.iData = aObject.AllocL(); |
|
1986 } |
|
1987 |
|
1988 else if(aLastUriSeg.Compare(KNSmlDMEmailMsndPort)==0) |
|
1989 { |
|
1990 TNSmlEmailSettingsElement& bufElem = iBuffer->At(aIndex); |
|
1991 TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(aCommand); |
|
1992 elem.iData = aObject.AllocL(); |
|
1993 } |
|
1994 |
|
1995 else if(aLastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0) |
|
1996 { |
|
1997 TBool object=EFalse; |
|
1998 if(aObject.Find(_L8("True"))>=0 || aObject.Find(_L8("true"))>=0) |
|
1999 { |
|
2000 object = ETrue; |
|
2001 } |
|
2002 if(iBuffer->At(aIndex).iPop3Settings!= NULL) |
|
2003 { |
|
2004 iBuffer->At(aIndex).iPop3Settings->SetApop(object); |
|
2005 } |
|
2006 } |
|
2007 |
|
2008 else if(aLastUriSeg.Compare(KNSmlDMEmailFolderPath)==0) |
|
2009 { |
|
2010 if(iBuffer->At(aIndex).iImap4Settings!= NULL) |
|
2011 { |
|
2012 iBuffer->At(aIndex).iImap4Settings->SetFolderPathL(aObject); |
|
2013 } |
|
2014 } |
|
2015 |
|
2016 else if(aLastUriSeg.Compare(KNSmlDMEmailToNapID)==0) |
|
2017 { |
|
2018 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
2019 CleanupStack::PushL(iapmatch); |
|
2020 |
|
2021 TInt iap = iapmatch->IAPIdFromURIL( aObject ); |
|
2022 |
|
2023 if ( iap != KErrNotFound ) |
|
2024 { |
|
2025 TImIAPChoice localIAP; |
|
2026 localIAP.iIAP = iap; |
|
2027 DBG_ARGS(_S("IAP = %d"), localIAP.iIAP); |
|
2028 localIAP.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
2029 |
|
2030 if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() ) |
|
2031 { |
|
2032 iBuffer->At(aIndex).iIapPref->RemoveIAPL(0); |
|
2033 } |
|
2034 iBuffer->At(aIndex).iIapPref->AddIAPL(localIAP,0); |
|
2035 if (iBuffer->At(aIndex).iSmtpSettings!= NULL) |
|
2036 { |
|
2037 if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() ) |
|
2038 { |
|
2039 iBuffer->At(aIndex).iSmtpIapPref->RemoveIAPL(0); |
|
2040 } |
|
2041 iBuffer->At(aIndex).iSmtpIapPref->AddIAPL(localIAP,0); |
|
2042 } |
|
2043 } |
|
2044 else |
|
2045 { |
|
2046 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = CSmlDmAdapter::ENotFound; |
|
2047 } |
|
2048 |
|
2049 CleanupStack::PopAndDestroy(); // iapmatch |
|
2050 } |
|
2051 |
|
2052 else if(aLastUriSeg.Compare(KNSmlDMEmailSToNapID)==0) |
|
2053 { |
|
2054 CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
2055 CleanupStack::PushL(iapmatch); |
|
2056 |
|
2057 TInt iap = iapmatch->IAPIdFromURIL( aObject ); |
|
2058 |
|
2059 if ( iap != KErrNotFound ) |
|
2060 { |
|
2061 TImIAPChoice localIAP; |
|
2062 localIAP.iIAP = iap; |
|
2063 DBG_ARGS(_S("SMTP IAP = %d"), localIAP.iIAP); |
|
2064 localIAP.iDialogPref = ECommDbDialogPrefDoNotPrompt; |
|
2065 if ( iBuffer->At(aIndex).iSmtpSettings!= NULL ) |
|
2066 { |
|
2067 if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() ) |
|
2068 { |
|
2069 iBuffer->At(aIndex).iSmtpIapPref->RemoveIAPL(0); |
|
2070 } |
|
2071 iBuffer->At(aIndex).iSmtpIapPref->AddIAPL(localIAP,0); |
|
2072 } |
|
2073 else |
|
2074 { |
|
2075 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = |
|
2076 CSmlDmAdapter::ENotFound; |
|
2077 } |
|
2078 } |
|
2079 else |
|
2080 { |
|
2081 iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = |
|
2082 CSmlDmAdapter::ENotFound; |
|
2083 } |
|
2084 |
|
2085 CleanupStack::PopAndDestroy(); // iapmatch |
|
2086 } |
|
2087 _DBG_FILE("CNSmlDmEmailAdapter::DoAddLeafObjectL() :: end"); |
|
2088 return KErrNone; |
|
2089 } |
|
2090 |
|
2091 |
|
2092 // ----------------------------------------------------------------------------- |
|
2093 // void CNSmlDmEmailAdapter::SetDefaultSettingsL(TInt aIndex) |
|
2094 // Set defaults for used protocol |
|
2095 // ----------------------------------------------------------------------------- |
|
2096 void CNSmlDmEmailAdapter::SetDefaultSettingsL(TInt aIndex) |
|
2097 { |
|
2098 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSettingsL() :: begin"); |
|
2099 TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex); |
|
2100 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
2101 if( thisElem.iPop3Settings ) |
|
2102 { |
|
2103 |
|
2104 emailAccs->PopulateDefaultPopSettingsL(*thisElem.iPop3Settings, |
|
2105 *thisElem.iIapPref |
|
2106 ); |
|
2107 emailAccs->PopulateDefaultSmtpSettingsL(*thisElem.iSmtpSettings, |
|
2108 *thisElem.iSmtpIapPref |
|
2109 ); |
|
2110 |
|
2111 thisElem.iPop3Settings->SetDeleteEmailsWhenDisconnecting( EFalse ); |
|
2112 thisElem.iPop3Settings->SetInboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount ); |
|
2113 thisElem.iPop3Settings->SetSecureSockets( EFalse ); |
|
2114 thisElem.iPop3Settings->SetAutoSendOnConnect( ETrue ); |
|
2115 thisElem.iPop3Settings->SetDisconnectedUserMode( ETrue ); |
|
2116 thisElem.iPop3Settings->SetAcknowledgeReceipts( EFalse ); |
|
2117 } |
|
2118 else if( thisElem.iImap4Settings ) |
|
2119 { |
|
2120 |
|
2121 emailAccs->PopulateDefaultImapSettingsL(*thisElem.iImap4Settings, |
|
2122 *thisElem.iIapPref |
|
2123 ); |
|
2124 |
|
2125 emailAccs->PopulateDefaultSmtpSettingsL(*thisElem.iSmtpSettings, |
|
2126 *thisElem.iSmtpIapPref |
|
2127 ); |
|
2128 |
|
2129 thisElem.iImap4Settings->SetDeleteEmailsWhenDisconnecting( EFalse ); |
|
2130 thisElem.iImap4Settings->SetInboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount ); |
|
2131 thisElem.iImap4Settings->SetMailboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount ); |
|
2132 thisElem.iImap4Settings->SetSecureSockets( EFalse ); |
|
2133 thisElem.iImap4Settings->SetAutoSendOnConnect( ETrue ); |
|
2134 thisElem.iImap4Settings->SetDisconnectedUserMode( ETrue ); |
|
2135 thisElem.iImap4Settings->SetImapIdle( ETrue ); |
|
2136 thisElem.iImap4Settings->SetUpdatingSeenFlags( ETrue ); |
|
2137 } |
|
2138 thisElem.iSmtpSettings->SetLoginNameL(KNullDesC8); |
|
2139 thisElem.iSmtpSettings->SetPasswordL(KNullDesC8); |
|
2140 // Set IAP id to 0 and ask from user if ToNapID/SToNapID not sent |
|
2141 TImIAPChoice tmpIap; |
|
2142 tmpIap.iIAP = KNSmlDmEmailAlwaysAskIap; |
|
2143 tmpIap.iDialogPref = ECommDbDialogPrefPrompt; |
|
2144 thisElem.iIapPref->AddIAPL( tmpIap, 0 ); |
|
2145 thisElem.iSmtpIapPref->AddIAPL( tmpIap, 0 ); |
|
2146 CleanupStack::PopAndDestroy(); //emailAccs |
|
2147 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSettingsL() :: end"); |
|
2148 } |
|
2149 |
|
2150 // ----------------------------------------------------------------------------- |
|
2151 // HBufC* CNSmlDmEmailAdapter::IntToDesLC(const TInt aLuid) const |
|
2152 // Converts integer to 16bit descriptor |
|
2153 // ----------------------------------------------------------------------------- |
|
2154 HBufC* CNSmlDmEmailAdapter::IntToDesLC(const TInt aLuid) const |
|
2155 { |
|
2156 HBufC* buf = HBufC::NewLC(10); //10 = max length of 32bit integer |
|
2157 TPtr ptrBuf = buf->Des(); |
|
2158 ptrBuf.Num(aLuid); |
|
2159 return buf; |
|
2160 } |
|
2161 |
|
2162 // ----------------------------------------------------------------------------- |
|
2163 // HBufC8* CNSmlDmEmailAdapter::IntToDes8LC(const TInt aLuid) const |
|
2164 // Converts integer to 8bit descriptor |
|
2165 // ----------------------------------------------------------------------------- |
|
2166 HBufC8* CNSmlDmEmailAdapter::IntToDes8LC(const TInt aLuid) const |
|
2167 { |
|
2168 HBufC8* buf = HBufC8::NewLC(10); //10 = max length of 32bit integer |
|
2169 TPtr8 ptrBuf = buf->Des(); |
|
2170 ptrBuf.Num(aLuid); |
|
2171 return buf; |
|
2172 } |
|
2173 |
|
2174 // ----------------------------------------------------------------------------- |
|
2175 // CNSmlDmEmailAdapter::ConvertTo8LC() |
|
2176 // Converts string value to 8-bit |
|
2177 // |
|
2178 // ----------------------------------------------------------------------------- |
|
2179 HBufC8* CNSmlDmEmailAdapter::ConvertTo8LC( const TDesC& aSource ) const |
|
2180 { |
|
2181 HBufC8* buf = HBufC8::NewLC( aSource.Length()*2); |
|
2182 TPtr8 bufPtr = buf->Des(); |
|
2183 CnvUtfConverter::ConvertFromUnicodeToUtf8( bufPtr, aSource ); |
|
2184 |
|
2185 return buf; |
|
2186 } |
|
2187 |
|
2188 // ----------------------------------------------------------------------------- |
|
2189 // TInt CNSmlDmEmailAdapter::ValidateAndStoreSettingsL(TInt aIndex |
|
2190 // Transfers the email settings from memory to phones permanent data store |
|
2191 // ----------------------------------------------------------------------------- |
|
2192 TInt CNSmlDmEmailAdapter::ValidateAndStoreSettingsL(TInt aIndex) |
|
2193 { |
|
2194 _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : begin"); |
|
2195 TInt luid = 0; |
|
2196 |
|
2197 TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex); |
|
2198 |
|
2199 if( iBuffer->At( aIndex ).iJustFetch ) |
|
2200 { |
|
2201 _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : end"); |
|
2202 return luid; |
|
2203 } |
|
2204 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
2205 if( iBuffer->At( aIndex ).iLuid != 0 ) |
|
2206 { |
|
2207 switch ( thisElem.iAccType ) |
|
2208 { |
|
2209 case EPop: |
|
2210 { |
|
2211 TPopAccount accId; |
|
2212 emailAccs->GetPopAccountL( thisElem.iServiceId, accId ); |
|
2213 //Copy name field |
|
2214 accId.iPopAccountName.Copy(thisElem.iName->Des()); |
|
2215 emailAccs->SavePopSettingsL( accId, *thisElem.iPop3Settings ); |
|
2216 emailAccs->SavePopIapSettingsL( accId, *thisElem.iIapPref ); |
|
2217 TSmtpAccount smtpAcc; |
|
2218 emailAccs->GetSmtpAccountL( accId.iSmtpService, smtpAcc ); |
|
2219 //Copy name field |
|
2220 smtpAcc.iSmtpAccountName.Copy(thisElem.iName->Des()); |
|
2221 emailAccs->SaveSmtpSettingsL( smtpAcc, *thisElem.iSmtpSettings ); |
|
2222 emailAccs->SaveSmtpIapSettingsL( smtpAcc, *thisElem.iSmtpIapPref ); |
|
2223 break; |
|
2224 } |
|
2225 case EImap: |
|
2226 { |
|
2227 TImapAccount accId2; |
|
2228 emailAccs->GetImapAccountL( thisElem.iServiceId, accId2 ); |
|
2229 //Copy name field |
|
2230 accId2.iImapAccountName.Copy(thisElem.iName->Des()); |
|
2231 emailAccs->SaveImapSettingsL( accId2, *thisElem.iImap4Settings ); |
|
2232 emailAccs->SaveImapIapSettingsL( accId2, *thisElem.iIapPref ); |
|
2233 TSmtpAccount smtpAccForImap; |
|
2234 emailAccs->GetSmtpAccountL( accId2.iSmtpService, smtpAccForImap ); |
|
2235 //Copy name field |
|
2236 smtpAccForImap.iSmtpAccountName.Copy(thisElem.iName->Des()); |
|
2237 emailAccs->SaveSmtpSettingsL( smtpAccForImap, *thisElem.iSmtpSettings ); |
|
2238 emailAccs->SaveSmtpIapSettingsL( smtpAccForImap, *thisElem.iSmtpIapPref ); |
|
2239 break; |
|
2240 } |
|
2241 default: |
|
2242 |
|
2243 break; |
|
2244 } |
|
2245 } |
|
2246 else // if(iBuffer->At(aIndex).iLuid != 0) |
|
2247 { |
|
2248 RTelServer telServer; |
|
2249 User::LeaveIfError( telServer.Connect() ); |
|
2250 CleanupClosePushL(telServer); |
|
2251 |
|
2252 TInt numPhones = 0; |
|
2253 User::LeaveIfError( telServer.EnumeratePhones( numPhones ) ); |
|
2254 if ( numPhones < 1 ) |
|
2255 { |
|
2256 User::Leave( KErrNotFound ); |
|
2257 } |
|
2258 |
|
2259 RTelServer::TPhoneInfo info; |
|
2260 User::LeaveIfError( telServer.GetPhoneInfo( 0, info ) ); |
|
2261 RMobilePhone mobilePhone; |
|
2262 User::LeaveIfError( mobilePhone.Open( telServer, info.iName ) ); |
|
2263 CleanupClosePushL( mobilePhone ); |
|
2264 TRequestStatus status; |
|
2265 RMobilePhone::TMobilePhoneIdentityV1 mobilePhoneIdentity; |
|
2266 mobilePhone.GetPhoneId( status, mobilePhoneIdentity ); |
|
2267 User::WaitForRequest( status ); |
|
2268 User::LeaveIfError( status.Int() ); |
|
2269 TBuf<50> imei; |
|
2270 imei.Copy( mobilePhoneIdentity.iSerialNumber ); |
|
2271 |
|
2272 CleanupStack::PopAndDestroy(&mobilePhone); |
|
2273 CleanupStack::PopAndDestroy(&telServer); |
|
2274 if ( thisElem.iPop3Settings ) |
|
2275 { |
|
2276 TPopAccount accId; |
|
2277 accId = emailAccs->CreatePopAccountL( *thisElem.iName, |
|
2278 *thisElem.iPop3Settings, |
|
2279 *thisElem.iIapPref, |
|
2280 EFalse ); |
|
2281 |
|
2282 TSmtpAccount smtpAcc = emailAccs->CreateSmtpAccountL( accId, |
|
2283 *thisElem.iSmtpSettings, |
|
2284 *thisElem.iSmtpIapPref, |
|
2285 EFalse ); |
|
2286 TMsvEntry smtpEntry; |
|
2287 TMsvEntry popEntry; |
|
2288 CMsvEntry* entry = iMsvSession->GetEntryL(smtpAcc.iSmtpService); |
|
2289 CleanupStack::PushL(entry); |
|
2290 smtpEntry = entry->Entry(); |
|
2291 smtpEntry.iMtmData2 = smtpAcc.iSmtpAccountId; |
|
2292 smtpEntry.iDescription.Set( imei ); |
|
2293 entry->ChangeL(smtpEntry); |
|
2294 CleanupStack::PopAndDestroy(entry); |
|
2295 |
|
2296 entry = iMsvSession->GetEntryL(smtpAcc.iRelatedService); |
|
2297 CleanupStack::PushL(entry); |
|
2298 popEntry = entry->Entry(); |
|
2299 popEntry.iMtmData2 = accId.iPopAccountId; |
|
2300 popEntry.iDescription.Set( imei ); |
|
2301 entry->ChangeL(popEntry); |
|
2302 CleanupStack::PopAndDestroy(entry); |
|
2303 |
|
2304 if ( accId.iSmtpService != smtpAcc.iSmtpService || smtpAcc.iRelatedService != accId.iPopService ) |
|
2305 { |
|
2306 DBG_ARGS8(_S8("ERROR!!! PopAccount creation: iSmtpService=%d, smtpAcc.iSmtpService=%d, iRelatedService=%d, iPopService=%d"), |
|
2307 accId.iSmtpService, smtpAcc.iSmtpService, smtpAcc.iRelatedService, accId.iPopService ); |
|
2308 } |
|
2309 |
|
2310 thisElem.iAccType = EPop; |
|
2311 thisElem.iAccId = accId.iPopAccountId; |
|
2312 SetLuidById( thisElem.iAccType, thisElem.iAccId, thisElem.iLuid ); |
|
2313 |
|
2314 RArray<TPopAccount> popAccs; |
|
2315 CleanupClosePushL( popAccs ); |
|
2316 emailAccs->GetPopAccountsL( popAccs ); |
|
2317 |
|
2318 RArray<TImapAccount> imapAccs; |
|
2319 CleanupClosePushL( imapAccs ); |
|
2320 emailAccs->GetImapAccountsL( imapAccs ); |
|
2321 |
|
2322 if ( popAccs.Count() == 1 && !imapAccs.Count()) |
|
2323 { |
|
2324 emailAccs->SetDefaultSmtpAccountL( smtpAcc ); |
|
2325 } |
|
2326 |
|
2327 CleanupStack::PopAndDestroy( &imapAccs ); |
|
2328 CleanupStack::PopAndDestroy( &popAccs ); |
|
2329 // Check and set the default account |
|
2330 TSmtpAccount defSmtp; |
|
2331 TInt retVal = emailAccs->DefaultSmtpAccountL( defSmtp ); |
|
2332 if ( retVal != KErrNone ) |
|
2333 { |
|
2334 RArray<TPopAccount> popAccounts; |
|
2335 CleanupClosePushL( popAccounts ); |
|
2336 emailAccs->GetPopAccountsL( popAccounts ); |
|
2337 if ( popAccounts.Count() > 0 ) |
|
2338 { |
|
2339 TSmtpAccount relatedSmtp; |
|
2340 emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp ); |
|
2341 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
2342 } |
|
2343 CleanupStack::PopAndDestroy( &popAccounts ); |
|
2344 } |
|
2345 } |
|
2346 else if ( thisElem.iImap4Settings ) |
|
2347 { |
|
2348 TImapAccount accId2; |
|
2349 accId2 = emailAccs->CreateImapAccountL(*thisElem.iName, |
|
2350 *thisElem.iImap4Settings, |
|
2351 *thisElem.iIapPref, |
|
2352 EFalse); |
|
2353 |
|
2354 TSmtpAccount smtpAcc = emailAccs->CreateSmtpAccountL( accId2, |
|
2355 *thisElem.iSmtpSettings, |
|
2356 *thisElem.iSmtpIapPref, |
|
2357 EFalse ); |
|
2358 |
|
2359 TMsvEntry smtpEntry; |
|
2360 TMsvEntry imapEntry; |
|
2361 CMsvEntry* entry = iMsvSession->GetEntryL(smtpAcc.iSmtpService); |
|
2362 CleanupStack::PushL(entry); |
|
2363 smtpEntry = entry->Entry(); |
|
2364 smtpEntry.iMtmData2 = smtpAcc.iSmtpAccountId; |
|
2365 smtpEntry.iDescription.Set( imei ); |
|
2366 entry->ChangeL(smtpEntry); |
|
2367 CleanupStack::PopAndDestroy(entry); |
|
2368 |
|
2369 entry = iMsvSession->GetEntryL(smtpAcc.iRelatedService); |
|
2370 CleanupStack::PushL(entry); |
|
2371 imapEntry = entry->Entry(); |
|
2372 imapEntry.iMtmData2 = accId2.iImapAccountId; |
|
2373 imapEntry.iDescription.Set( imei ); |
|
2374 entry->ChangeL(imapEntry); |
|
2375 CleanupStack::PopAndDestroy(entry); |
|
2376 |
|
2377 if ( accId2.iSmtpService != smtpAcc.iSmtpService || smtpAcc.iRelatedService != accId2.iImapService ) |
|
2378 { |
|
2379 DBG_ARGS8(_S8("ERROR!!! ImapAccount creation: iSmtpService=%d, smtpAcc.iSmtpService=%d, iRelatedService=%d, iImapService=%d"), |
|
2380 accId2.iSmtpService, smtpAcc.iSmtpService, smtpAcc.iRelatedService, accId2.iImapService ); |
|
2381 } |
|
2382 |
|
2383 |
|
2384 thisElem.iAccType = EImap; |
|
2385 thisElem.iAccId = accId2.iImapAccountId; |
|
2386 SetLuidById( thisElem.iAccType, thisElem.iAccId, thisElem.iLuid ); |
|
2387 |
|
2388 // Check and set the default account |
|
2389 RArray<TPopAccount> popAccs; |
|
2390 CleanupClosePushL( popAccs ); |
|
2391 emailAccs->GetPopAccountsL( popAccs ); |
|
2392 |
|
2393 RArray<TImapAccount> imapAccs; |
|
2394 CleanupClosePushL( imapAccs ); |
|
2395 emailAccs->GetImapAccountsL( imapAccs ); |
|
2396 |
|
2397 if ( imapAccs.Count() == 1 && !popAccs.Count()) |
|
2398 { |
|
2399 emailAccs->SetDefaultSmtpAccountL( smtpAcc ); |
|
2400 } |
|
2401 |
|
2402 CleanupStack::PopAndDestroy( &imapAccs ); |
|
2403 CleanupStack::PopAndDestroy( &popAccs ); |
|
2404 TSmtpAccount defaultSmtp; |
|
2405 TInt retVal = emailAccs->DefaultSmtpAccountL( defaultSmtp ); |
|
2406 if ( retVal != KErrNone ) |
|
2407 { |
|
2408 RArray<TImapAccount> imapAccs; |
|
2409 CleanupClosePushL( imapAccs ); |
|
2410 emailAccs->GetImapAccountsL( imapAccs ); |
|
2411 if ( imapAccs.Count() > 0 ) |
|
2412 { |
|
2413 TSmtpAccount relatedSmtp; |
|
2414 emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp ); |
|
2415 emailAccs->SetDefaultSmtpAccountL( relatedSmtp ); |
|
2416 } |
|
2417 CleanupStack::PopAndDestroy( &imapAccs ); |
|
2418 } |
|
2419 } |
|
2420 |
|
2421 } |
|
2422 luid = thisElem.iLuid; |
|
2423 CleanupStack::PopAndDestroy(); //emailAccs |
|
2424 _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : end"); |
|
2425 return luid; |
|
2426 } |
|
2427 // ----------------------------------------------------------------------------- |
|
2428 // void CNSmlDmEmailAdapter::GetIdByLuid( TNSmlEmailAccountType& aAccType, |
|
2429 // TInt& aAccId, |
|
2430 // const TInt aLuid ) const |
|
2431 // Calculates the account type and id on basis of luid |
|
2432 // ----------------------------------------------------------------------------- |
|
2433 void CNSmlDmEmailAdapter::GetIdByLuid( TNSmlEmailAccountType& aAccType, |
|
2434 TInt& aAccId, |
|
2435 const TInt aLuid ) const |
|
2436 { |
|
2437 if ( ( aLuid > KNSmlDmEmailImapLuidLow ) && |
|
2438 ( aLuid < KNSmlDmEmailImapLuidHigh ) ) |
|
2439 { |
|
2440 aAccType = EImap; |
|
2441 aAccId = aLuid - KNSmlDmEmailImapLuidLow; |
|
2442 } |
|
2443 else if (( aLuid > KNSmlDmEmailImapLuidHigh ) && |
|
2444 ( aLuid < KNSmlDmEmailPopLuidHigh )) |
|
2445 { |
|
2446 aAccType = EPop; |
|
2447 aAccId = aLuid - KNSmlDmEmailImapLuidHigh; |
|
2448 } |
|
2449 else |
|
2450 { |
|
2451 aAccType = EUnknown; |
|
2452 } |
|
2453 |
|
2454 } |
|
2455 |
|
2456 |
|
2457 // ----------------------------------------------------------------------------- |
|
2458 // void CNSmlDmEmailAdapter::SetLuidById( const TNSmlEmailAccountType& aAccType, |
|
2459 // const TInt& aAccId, TInt& aLuid ) const |
|
2460 // Sets the luid on basis of account type and id |
|
2461 // ----------------------------------------------------------------------------- |
|
2462 void CNSmlDmEmailAdapter::SetLuidById( const TNSmlEmailAccountType& aAccType, |
|
2463 const TInt& aAccId, TInt& aLuid ) const |
|
2464 { |
|
2465 switch (aAccType) |
|
2466 { |
|
2467 case EImap : |
|
2468 aLuid = KNSmlDmEmailImapLuidLow + aAccId; |
|
2469 break; |
|
2470 |
|
2471 case EPop : |
|
2472 aLuid = KNSmlDmEmailImapLuidHigh + aAccId; |
|
2473 break; |
|
2474 |
|
2475 default : |
|
2476 aLuid = -1; |
|
2477 break; |
|
2478 } |
|
2479 } |
|
2480 |
|
2481 // ----------------------------------------------------------------------------- |
|
2482 // TBool CNSmlDmEmailAdapter::AccountExistsL( const CEmailAccounts* aAccs, |
|
2483 // const TNSmlEmailAccountType aAccType, |
|
2484 // const TInt aId, |
|
2485 // TInt aIndex ) |
|
2486 // Checks if the accout matching the given parameters is found. |
|
2487 // returns True if found. |
|
2488 // ----------------------------------------------------------------------------- |
|
2489 TBool CNSmlDmEmailAdapter::AccountExistsL( CEmailAccounts* aAccs, |
|
2490 const TNSmlEmailAccountType aAccType, |
|
2491 const TInt aId, |
|
2492 TInt aIndex ) |
|
2493 { |
|
2494 RArray<TImapAccount> imap4Accs; |
|
2495 CleanupClosePushL( imap4Accs ); |
|
2496 RArray<TPopAccount> pop3Accs; |
|
2497 CleanupClosePushL( pop3Accs ); |
|
2498 switch ( aAccType ) |
|
2499 { |
|
2500 case EImap: |
|
2501 aAccs->GetImapAccountsL(imap4Accs); |
|
2502 for(TInt i=0;i<imap4Accs.Count();i++) |
|
2503 { |
|
2504 if ( imap4Accs[i].iImapAccountId == aId ) |
|
2505 { |
|
2506 |
|
2507 if ( aIndex >= 0 ) |
|
2508 { |
|
2509 iBuffer->At(aIndex).iServiceId = imap4Accs[i].iImapService; |
|
2510 delete iBuffer->At(aIndex).iName; |
|
2511 iBuffer->At(aIndex).iName = NULL; |
|
2512 iBuffer->At(aIndex).iName = HBufC::NewL(imap4Accs[i].iImapAccountName.Size()); |
|
2513 *iBuffer->At(aIndex).iName = imap4Accs[i].iImapAccountName; |
|
2514 } |
|
2515 CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs |
|
2516 return ETrue; |
|
2517 } |
|
2518 } |
|
2519 break; |
|
2520 |
|
2521 case EPop: |
|
2522 aAccs->GetPopAccountsL(pop3Accs); |
|
2523 for(TInt i=0;i<pop3Accs.Count();i++) |
|
2524 { |
|
2525 if ( pop3Accs[i].iPopAccountId == aId ) |
|
2526 { |
|
2527 if ( aIndex >= 0 ) |
|
2528 { |
|
2529 iBuffer->At(aIndex).iServiceId = pop3Accs[i].iPopService; |
|
2530 delete iBuffer->At(aIndex).iName; |
|
2531 iBuffer->At(aIndex).iName = NULL; |
|
2532 iBuffer->At(aIndex).iName = HBufC::NewL(pop3Accs[i].iPopAccountName.Size()); |
|
2533 *iBuffer->At(aIndex).iName = pop3Accs[i].iPopAccountName; |
|
2534 } |
|
2535 CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs |
|
2536 return ETrue; |
|
2537 } |
|
2538 } |
|
2539 break; |
|
2540 default: |
|
2541 // Returns EFalse in this case. |
|
2542 break; |
|
2543 } |
|
2544 CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs |
|
2545 return EFalse; |
|
2546 } |
|
2547 |
|
2548 // ----------------------------------------------------------------------------- |
|
2549 // TInt CNSmlDmEmailAdapter::DoRestoreSettingsL(TInt aIndex) |
|
2550 // Restores the settings to the adapter from settings store |
|
2551 // ----------------------------------------------------------------------------- |
|
2552 TInt CNSmlDmEmailAdapter::DoRestoreSettingsL(TInt aIndex) |
|
2553 { |
|
2554 _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : begin"); |
|
2555 TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex); |
|
2556 |
|
2557 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
2558 TInt err = KErrNone; |
|
2559 |
|
2560 // These are destroyed latest at destructor |
|
2561 thisElem.iSmtpSettings = new (ELeave) CImSmtpSettings; |
|
2562 thisElem.iIapPref = CImIAPPreferences::NewLC(); |
|
2563 thisElem.iSmtpIapPref = CImIAPPreferences::NewLC(); |
|
2564 |
|
2565 switch( thisElem.iAccType ) |
|
2566 { |
|
2567 case EImap: |
|
2568 if (AccountExistsL(emailAccs, thisElem.iAccType, thisElem.iAccId, aIndex )) |
|
2569 { |
|
2570 TImapAccount imapAccId; |
|
2571 |
|
2572 thisElem.iImap4Settings = new(ELeave) CImImap4Settings; |
|
2573 |
|
2574 //Get IMAP account by iAccId id |
|
2575 emailAccs->GetImapAccountL(thisElem.iServiceId, imapAccId); |
|
2576 //Get IMAP settings by account id |
|
2577 emailAccs->LoadImapSettingsL( imapAccId, *thisElem.iImap4Settings ); |
|
2578 //Get IMAP settings IAP prefs |
|
2579 emailAccs->LoadImapIapSettingsL( imapAccId, *thisElem.iIapPref ); |
|
2580 |
|
2581 TSmtpAccount smtpAccount; |
|
2582 //Get smtp account by related IMAP id |
|
2583 emailAccs->GetSmtpAccountL( imapAccId.iSmtpService, smtpAccount ); |
|
2584 //Get smtp settings by IMAP id |
|
2585 emailAccs->LoadSmtpSettingsL( smtpAccount, *thisElem.iSmtpSettings ); |
|
2586 //Get Smtp settings IAP prefs |
|
2587 emailAccs->LoadSmtpIapSettingsL( smtpAccount, *thisElem.iSmtpIapPref ); |
|
2588 } |
|
2589 else |
|
2590 { |
|
2591 err = KErrNotFound; |
|
2592 } |
|
2593 break; |
|
2594 |
|
2595 case EPop: |
|
2596 if (AccountExistsL(emailAccs, thisElem.iAccType, thisElem.iAccId, aIndex )) |
|
2597 { |
|
2598 TPopAccount popAccId; |
|
2599 |
|
2600 thisElem.iPop3Settings = new(ELeave) CImPop3Settings; |
|
2601 |
|
2602 //Get POP3 account by iAccId id |
|
2603 emailAccs->GetPopAccountL( thisElem.iServiceId, popAccId ); |
|
2604 //Get POP3 settings by account id |
|
2605 emailAccs->LoadPopSettingsL( popAccId, *thisElem.iPop3Settings ); |
|
2606 //Get POP3 setting IAP prefs |
|
2607 emailAccs->LoadPopIapSettingsL( popAccId, *thisElem.iIapPref ); |
|
2608 |
|
2609 TSmtpAccount smtpAccount; |
|
2610 //Get smtp account by related POP id |
|
2611 emailAccs->GetSmtpAccountL( popAccId.iSmtpService, smtpAccount ); |
|
2612 //Get smtp settings |
|
2613 emailAccs->LoadSmtpSettingsL( smtpAccount, *thisElem.iSmtpSettings ); |
|
2614 //Get Smtp setting IAP prefs |
|
2615 emailAccs->LoadSmtpIapSettingsL( smtpAccount, *thisElem.iSmtpIapPref ); |
|
2616 } |
|
2617 else |
|
2618 { |
|
2619 err = KErrNotFound; |
|
2620 } |
|
2621 break; |
|
2622 |
|
2623 default: |
|
2624 err = KErrNotFound; |
|
2625 break; |
|
2626 } |
|
2627 |
|
2628 if ( err ) |
|
2629 { |
|
2630 _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : \ |
|
2631 KErrNotFound end"); |
|
2632 CleanupStack::PopAndDestroy(2); // iIapPref, iSmtpIapPref |
|
2633 CleanupStack::PopAndDestroy(emailAccs); //emailAccs |
|
2634 return KErrNotFound; |
|
2635 } |
|
2636 |
|
2637 CleanupStack::Pop(2); // iIapPref, iSmtpIapPref |
|
2638 CleanupStack::PopAndDestroy(emailAccs); //emailAccs |
|
2639 _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : end"); |
|
2640 return KErrNone; |
|
2641 } |
|
2642 |
|
2643 // ----------------------------------------------------------------------------- |
|
2644 // CNSmlDmEmailAdapter::OpenSessionL() |
|
2645 // Opens the CMsvSession if it is not open already |
|
2646 // ----------------------------------------------------------------------------- |
|
2647 TInt CNSmlDmEmailAdapter::OpenSessionL() |
|
2648 { |
|
2649 _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : begin"); |
|
2650 if(!iMsvSession) |
|
2651 { |
|
2652 TRAPD(err, iMsvSession = CMsvSession::OpenSyncL(*this)); |
|
2653 _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : end"); |
|
2654 return err; |
|
2655 } |
|
2656 |
|
2657 _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : end"); |
|
2658 return KErrNone; |
|
2659 } |
|
2660 |
|
2661 // ----------------------------------------------------------------------------- |
|
2662 // CNSmlDmEmailAdapter::FillNodeInfoL() |
|
2663 // Fills the node info in ddf structure |
|
2664 // ----------------------------------------------------------------------------- |
|
2665 void CNSmlDmEmailAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
2666 const TSmlDmAccessTypes& aAccTypes, |
|
2667 MSmlDmDDFObject::TOccurence aOccurrence, |
|
2668 MSmlDmDDFObject::TScope aScope, |
|
2669 MSmlDmDDFObject::TDFFormat aFormat, |
|
2670 const TDesC8& aDescription) const |
|
2671 { |
|
2672 aNode.SetAccessTypesL(aAccTypes); |
|
2673 aNode.SetOccurenceL(aOccurrence); |
|
2674 aNode.SetScopeL(aScope); |
|
2675 aNode.SetDFFormatL(aFormat); |
|
2676 if(aFormat!=MSmlDmDDFObject::ENode) |
|
2677 { |
|
2678 aNode.AddDFTypeMimeTypeL(KNSmlDMEmailTextPlain); |
|
2679 } |
|
2680 aNode.SetDescriptionL(aDescription); |
|
2681 |
|
2682 } |
|
2683 |
|
2684 // ----------------------------------------------------------------------------- |
|
2685 // TPtrC8 CNSmlDmEmailAdapter::RemoveDotSlash(const TDesC8& aURI) |
|
2686 // return uri without dot and slash in start |
|
2687 // ----------------------------------------------------------------------------- |
|
2688 TPtrC8 CNSmlDmEmailAdapter::RemoveDotSlash(const TDesC8& aURI) const |
|
2689 { |
|
2690 if(aURI.Find(KNSmlEmailUriDotSlash)==0) |
|
2691 { |
|
2692 return aURI.Right(aURI.Length()-KNSmlEmailUriDotSlash().Length()); |
|
2693 } |
|
2694 else |
|
2695 { |
|
2696 return aURI; |
|
2697 } |
|
2698 } |
|
2699 // ----------------------------------------------------------------------------- |
|
2700 // CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchObjectL(const TDesC8& aURI, |
|
2701 // const TDesC8& aLUID, CBufBase& aObject) |
|
2702 // Fetches object acording to URI & LUID. Retur codes acording to |
|
2703 // CSmlDmAdapter::TError. |
|
2704 // ----------------------------------------------------------------------------- |
|
2705 CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchObjectL(const TDesC8& aURI, |
|
2706 const TDesC8& aLUID, |
|
2707 CBufBase& aObject) |
|
2708 { |
|
2709 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : begin"); |
|
2710 CSmlDmAdapter::TError status = EOk; |
|
2711 if(aLUID.Length()==0) |
|
2712 { |
|
2713 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : ENotFound end"); |
|
2714 return CSmlDmAdapter::ENotFound; |
|
2715 } |
|
2716 if( OpenSessionL() != KErrNone ) |
|
2717 { |
|
2718 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : EError end"); |
|
2719 return CSmlDmAdapter::EError; |
|
2720 } |
|
2721 TInt luid = DesToInt(aLUID); |
|
2722 TInt index = -1; |
|
2723 for(TInt i=0;i<iBuffer->Count();i++) |
|
2724 { |
|
2725 if(iBuffer->At(i).iLuid == luid) |
|
2726 { |
|
2727 index = i; |
|
2728 break; |
|
2729 } |
|
2730 } |
|
2731 |
|
2732 if(index<0) |
|
2733 { |
|
2734 TNSmlEmailSettingsElement newNode; |
|
2735 newNode.iImap4Settings = NULL; |
|
2736 newNode.iPop3Settings = NULL; |
|
2737 newNode.iSmtpSettings = NULL; |
|
2738 newNode.iIapPref = NULL; |
|
2739 newNode.iLuid = luid; |
|
2740 newNode.iMappingName = aURI.AllocLC(); |
|
2741 newNode.iName = HBufC::NewLC(0); |
|
2742 newNode.iNodeBuf = new (ELeave) |
|
2743 CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity); |
|
2744 newNode.iExecuted = ETrue; |
|
2745 newNode.iJustFetch = ETrue; |
|
2746 GetIdByLuid(newNode.iAccType, newNode.iAccId, luid); |
|
2747 iBuffer->AppendL(newNode); |
|
2748 index = iBuffer->Count() - 1; |
|
2749 if(DoRestoreSettingsL(index)!=KErrNone) |
|
2750 { |
|
2751 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
2752 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : EError end"); |
|
2753 return CSmlDmAdapter::EError; |
|
2754 } |
|
2755 CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName |
|
2756 } |
|
2757 |
|
2758 TPtrC8 lastUriSeg = LastURISeg(aURI); |
|
2759 |
|
2760 if(lastUriSeg.Compare(KNSmlDMEmailName)==0) |
|
2761 { |
|
2762 HBufC8 *data = HBufC8::NewLC(iBuffer->At(index).iName->Length()); |
|
2763 TPtr8 dataPtr = data->Des(); |
|
2764 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr, iBuffer->At(index).iName->Des() ); |
|
2765 aObject.InsertL(0,dataPtr); |
|
2766 CleanupStack::PopAndDestroy(); //data |
|
2767 } |
|
2768 else if(lastUriSeg.Compare(KNSmlDMEmailUID)==0) |
|
2769 { |
|
2770 HBufC *data = NULL; |
|
2771 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2772 { |
|
2773 data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->LoginName().Length()); |
|
2774 data->Des().Copy(iBuffer->At(index).iPop3Settings->LoginName()); |
|
2775 } |
|
2776 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2777 { |
|
2778 data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->LoginName().Length()); |
|
2779 data->Des().Copy(iBuffer->At(index).iImap4Settings->LoginName()); |
|
2780 } |
|
2781 if(data) |
|
2782 { |
|
2783 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2784 CleanupStack::PushL(data8); |
|
2785 aObject.InsertL(0,*data8); |
|
2786 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2787 } |
|
2788 } |
|
2789 else if(lastUriSeg.Compare(KNSmlDMEmailPW)==0) |
|
2790 { |
|
2791 HBufC *data = NULL; |
|
2792 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2793 { |
|
2794 data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->Password().Length()); |
|
2795 data->Des().Copy(iBuffer->At(index).iPop3Settings->Password()); |
|
2796 } |
|
2797 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2798 { |
|
2799 data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->Password().Length()); |
|
2800 data->Des().Copy(iBuffer->At(index).iImap4Settings->Password()); |
|
2801 } |
|
2802 if(data) |
|
2803 { |
|
2804 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2805 CleanupStack::PushL(data8); |
|
2806 aObject.InsertL(0,*data8); |
|
2807 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2808 } |
|
2809 } |
|
2810 else if(lastUriSeg.Compare(KNSmlDMEmailUAddr)==0) |
|
2811 { |
|
2812 HBufC *data = NULL; |
|
2813 data = iBuffer->At(index).iSmtpSettings->EmailAddress().AllocLC(); |
|
2814 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2815 TPtr8 dataPtr8 = data8->Des(); |
|
2816 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2817 |
|
2818 aObject.InsertL(0,dataPtr8); |
|
2819 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2820 } |
|
2821 else if(lastUriSeg.Compare(KNSmlDMEmailUName)==0) |
|
2822 { |
|
2823 |
|
2824 HBufC *data = NULL; |
|
2825 data = iBuffer->At(index).iSmtpSettings->EmailAlias().AllocLC(); |
|
2826 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2827 TPtr8 dataPtr8 = data8->Des(); |
|
2828 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2829 |
|
2830 aObject.InsertL(0,dataPtr8); |
|
2831 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2832 } |
|
2833 |
|
2834 else if(lastUriSeg.Compare( KNSmlDMEmailMrcv)==0) |
|
2835 { |
|
2836 HBufC *data = NULL; |
|
2837 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2838 { |
|
2839 data = iBuffer->At(index).iPop3Settings->ServerAddress().AllocLC(); |
|
2840 } |
|
2841 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2842 { |
|
2843 data = iBuffer->At(index).iImap4Settings->ServerAddress().AllocLC(); |
|
2844 } |
|
2845 else |
|
2846 { |
|
2847 status = CSmlDmAdapter::ENotFound; |
|
2848 return status; |
|
2849 } |
|
2850 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2851 TPtr8 dataPtr8 = data8->Des(); |
|
2852 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2853 |
|
2854 aObject.InsertL(0,dataPtr8); |
|
2855 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2856 } |
|
2857 else if(lastUriSeg.Compare(KNSmlDMEmailMsnd)==0) |
|
2858 { |
|
2859 HBufC *data = NULL; |
|
2860 data = iBuffer->At(index).iSmtpSettings->ServerAddress().AllocLC(); |
|
2861 HBufC8 *data8 = HBufC8::NewLC(data->Size()); |
|
2862 TPtr8 dataPtr8 = data8->Des(); |
|
2863 CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() ); |
|
2864 |
|
2865 aObject.InsertL(0,dataPtr8); |
|
2866 CleanupStack::PopAndDestroy(2); //data, data8 |
|
2867 } |
|
2868 else if(lastUriSeg.Compare(KNSmlDMEmailMpro)==0) |
|
2869 { |
|
2870 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2871 { |
|
2872 aObject.InsertL(0,KNSmlDMEmailMproPOP); |
|
2873 } |
|
2874 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2875 { |
|
2876 aObject.InsertL(0,KNSmlDMEmailMproIMAP); |
|
2877 } |
|
2878 } |
|
2879 else if(lastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0) |
|
2880 { |
|
2881 FetchSecurityValueL(aObject, &iBuffer->At(index), EUseSecCon ); |
|
2882 } |
|
2883 |
|
2884 else if(lastUriSeg.Compare(KNSmlDMEmailUseSauth)==0) |
|
2885 { |
|
2886 if(iBuffer->At(index).iSmtpSettings->SMTPAuth()) |
|
2887 { |
|
2888 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
2889 } |
|
2890 else |
|
2891 { |
|
2892 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
2893 } |
|
2894 } |
|
2895 else if(lastUriSeg.Compare(KNSmlDMEmailSauthUID)==0) |
|
2896 { |
|
2897 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->LoginName().Length()); |
|
2898 data->Des().Copy(iBuffer->At(index).iSmtpSettings->LoginName()); |
|
2899 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2900 CleanupStack::PushL(data8); |
|
2901 aObject.InsertL(0,*data8); |
|
2902 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2903 } |
|
2904 else if(lastUriSeg.Compare(KNSmlDMEmailSauthPW)==0) |
|
2905 { |
|
2906 HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->Password().Length()); |
|
2907 data->Des().Copy(iBuffer->At(index).iSmtpSettings->Password()); |
|
2908 HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data); |
|
2909 CleanupStack::PushL(data8); |
|
2910 aObject.InsertL(0,*data8); |
|
2911 CleanupStack::PopAndDestroy(2);//data, data8 |
|
2912 } |
|
2913 else if(lastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0) |
|
2914 { |
|
2915 if(iBuffer->At(index).iSmtpSettings->InboxLoginDetails()) |
|
2916 { |
|
2917 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
2918 } |
|
2919 else |
|
2920 { |
|
2921 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
2922 } |
|
2923 } |
|
2924 |
|
2925 else if (lastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0) |
|
2926 { |
|
2927 FetchSecurityValueL(aObject, &iBuffer->At(index), ESuseSecCon ); |
|
2928 } |
|
2929 |
|
2930 else if (lastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0) |
|
2931 { |
|
2932 FetchSecurityValueL(aObject, &iBuffer->At(index), EUseStartTls ); |
|
2933 } |
|
2934 |
|
2935 else if (lastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0) |
|
2936 { |
|
2937 FetchSecurityValueL(aObject, &iBuffer->At(index), ESuseStartTls ); |
|
2938 } |
|
2939 |
|
2940 else if(lastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0) |
|
2941 { |
|
2942 TUint port; |
|
2943 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2944 { |
|
2945 port = iBuffer->At(index).iPop3Settings->Port(); |
|
2946 } |
|
2947 else |
|
2948 { |
|
2949 port = iBuffer->At(index).iImap4Settings->Port(); |
|
2950 } |
|
2951 HBufC8 *data = IntToDes8LC(port); |
|
2952 aObject.InsertL(0,data->Des()); |
|
2953 CleanupStack::PopAndDestroy(); //data |
|
2954 } |
|
2955 |
|
2956 else if(lastUriSeg.Compare(KNSmlDMEmailMsndPort)==0) |
|
2957 { |
|
2958 TUint port = iBuffer->At(index).iSmtpSettings->Port(); |
|
2959 HBufC8 *data = IntToDes8LC(port); |
|
2960 aObject.InsertL(0,data->Des()); |
|
2961 CleanupStack::PopAndDestroy(); //data |
|
2962 } |
|
2963 |
|
2964 else if(lastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0) |
|
2965 { |
|
2966 if(iBuffer->At(index).iPop3Settings!= NULL) |
|
2967 { |
|
2968 if(iBuffer->At(index).iPop3Settings->Apop()) |
|
2969 { |
|
2970 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
2971 } |
|
2972 else |
|
2973 { |
|
2974 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
2975 } |
|
2976 } |
|
2977 else if(iBuffer->At(index).iImap4Settings!= NULL) |
|
2978 { |
|
2979 status = CSmlDmAdapter::ENotFound; |
|
2980 } |
|
2981 } |
|
2982 |
|
2983 else if (lastUriSeg.Compare(KNSmlDMEmailFolderPath)==0) |
|
2984 { |
|
2985 if( iBuffer->At(index).iImap4Settings ) |
|
2986 { |
|
2987 aObject.InsertL(0, iBuffer->At(index).iImap4Settings->FolderPath() ); |
|
2988 } |
|
2989 else |
|
2990 { |
|
2991 status = CSmlDmAdapter::ENotFound; |
|
2992 } |
|
2993 } |
|
2994 |
|
2995 else if(lastUriSeg.Compare(KNSmlDMEmailToNapID)==0) |
|
2996 { |
|
2997 CNSmlDMIAPMatcher* iapmatch=CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
2998 CleanupStack::PushL(iapmatch); |
|
2999 HBufC8* uri8 = NULL; |
|
3000 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
3001 if ( iapCount ) |
|
3002 { |
|
3003 TImIAPChoice localIAP = iBuffer->At(index).iIapPref->IAPPreference(0); |
|
3004 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
3005 } |
|
3006 |
|
3007 if( uri8 ) |
|
3008 { |
|
3009 CleanupStack::PushL(uri8); |
|
3010 aObject.InsertL(0,uri8->Des()); |
|
3011 status = CSmlDmAdapter::EOk; |
|
3012 CleanupStack::PopAndDestroy(); // uri8 |
|
3013 } |
|
3014 |
|
3015 CleanupStack::PopAndDestroy(); // iapMatch |
|
3016 } |
|
3017 else if(lastUriSeg.Compare(KNSmlDMEmailSToNapID)==0) |
|
3018 { |
|
3019 // SToNapID exists only for SMTP |
|
3020 if (iBuffer->At(index).iSmtpSettings!= NULL) |
|
3021 { |
|
3022 CNSmlDMIAPMatcher* iapmatch=CNSmlDMIAPMatcher::NewL( &Callback() ); |
|
3023 CleanupStack::PushL(iapmatch); |
|
3024 HBufC8* uri8 = NULL; |
|
3025 TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs(); |
|
3026 if ( iapCount ) |
|
3027 { |
|
3028 TImIAPChoice localIAP = iBuffer->At(index).iSmtpIapPref->IAPPreference(0); |
|
3029 uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP ); |
|
3030 } |
|
3031 |
|
3032 if( uri8 ) |
|
3033 { |
|
3034 CleanupStack::PushL(uri8); |
|
3035 aObject.InsertL(0,uri8->Des()); |
|
3036 status = CSmlDmAdapter::EOk; |
|
3037 CleanupStack::PopAndDestroy(); // uri8 |
|
3038 } |
|
3039 |
|
3040 CleanupStack::PopAndDestroy(); // iapMatch |
|
3041 } |
|
3042 else |
|
3043 { |
|
3044 status = CSmlDmAdapter::ENotFound; |
|
3045 } |
|
3046 } |
|
3047 _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : end"); |
|
3048 return status; |
|
3049 } |
|
3050 |
|
3051 // ----------------------------------------------------------------------------- |
|
3052 // void CNSmlDmEmailAdapter::SetDefaultSecurityL(const TDesC8& aObject, |
|
3053 // const TNSmlEmailSettingsElement* thisElem, |
|
3054 // const TNSmlEmailSecuritySetting aSetting ) |
|
3055 // Sets (on/off) the security modes: SSL/TLS, StartTLS |
|
3056 // ----------------------------------------------------------------------------- |
|
3057 void CNSmlDmEmailAdapter::SetDefaultSecurityL(const TDesC8& aObject, |
|
3058 const TNSmlEmailSettingsElement* aThisElem, |
|
3059 const TNSmlEmailSecuritySetting aSetting |
|
3060 ) const |
|
3061 { |
|
3062 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSecurityL(): begin"); |
|
3063 HBufC8 *data = aObject.AllocLC(); |
|
3064 TPtr8 dataPtr = data->Des(); |
|
3065 dataPtr.Capitalize(); |
|
3066 TBool object=EFalse; |
|
3067 if(dataPtr.Find(KNSmlDMEmailTrue)>=0) |
|
3068 { |
|
3069 object = ETrue; |
|
3070 } |
|
3071 switch ( aSetting ) |
|
3072 { |
|
3073 case EUseSecCon : |
|
3074 if ( object ) |
|
3075 { |
|
3076 if ( aThisElem->iImap4Settings ) |
|
3077 { |
|
3078 aThisElem->iImap4Settings->SetSecureSockets(EFalse); |
|
3079 aThisElem->iImap4Settings->SetSSLWrapper(ETrue); |
|
3080 aThisElem->iImap4Settings->SetPort( KNSmlDMEmailSslWrappedImap4Port ); |
|
3081 } |
|
3082 else if ( aThisElem->iPop3Settings ) |
|
3083 { |
|
3084 aThisElem->iPop3Settings->SetSecureSockets(EFalse); |
|
3085 aThisElem->iPop3Settings->SetSSLWrapper(ETrue); |
|
3086 aThisElem->iPop3Settings->SetPort( KNSmlDMEmailSslWrappedPop3Port ); |
|
3087 } |
|
3088 } |
|
3089 else |
|
3090 { |
|
3091 if ( aThisElem->iImap4Settings ) |
|
3092 { |
|
3093 aThisElem->iImap4Settings->SetPort( KNSmlDMEmailNormalImap4Port ); |
|
3094 aThisElem->iImap4Settings->SetSSLWrapper(EFalse); |
|
3095 } |
|
3096 else if ( aThisElem->iPop3Settings ) |
|
3097 { |
|
3098 aThisElem->iPop3Settings->SetPort( KNSmlDMEmailNormalPop3Port ); |
|
3099 aThisElem->iPop3Settings->SetSSLWrapper(EFalse); |
|
3100 } |
|
3101 } |
|
3102 break; |
|
3103 case EUseStartTls : |
|
3104 if ( object ) |
|
3105 { |
|
3106 if ( aThisElem->iImap4Settings ) |
|
3107 { |
|
3108 aThisElem->iImap4Settings->SetSecureSockets(ETrue); |
|
3109 aThisElem->iImap4Settings->SetSSLWrapper(EFalse); |
|
3110 aThisElem->iImap4Settings->SetPort( KNSmlDMEmailNormalImap4Port ); |
|
3111 } |
|
3112 else if ( aThisElem->iPop3Settings ) |
|
3113 { |
|
3114 aThisElem->iPop3Settings->SetSecureSockets(ETrue); |
|
3115 aThisElem->iPop3Settings->SetSSLWrapper(EFalse); |
|
3116 aThisElem->iPop3Settings->SetPort( KNSmlDMEmailNormalPop3Port ); |
|
3117 } |
|
3118 } |
|
3119 else |
|
3120 { |
|
3121 if ( aThisElem->iImap4Settings ) |
|
3122 { |
|
3123 aThisElem->iImap4Settings->SetSecureSockets(EFalse); |
|
3124 } |
|
3125 else if ( aThisElem->iPop3Settings ) |
|
3126 { |
|
3127 aThisElem->iPop3Settings->SetSecureSockets(EFalse); |
|
3128 } |
|
3129 } |
|
3130 break; |
|
3131 case ESuseSecCon : |
|
3132 if ( object ) |
|
3133 { |
|
3134 // The port is same in all cases |
|
3135 aThisElem->iSmtpSettings->SetSecureSockets(EFalse); |
|
3136 aThisElem->iSmtpSettings->SetSSLWrapper(ETrue); |
|
3137 aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailSslSmtpPort ); |
|
3138 } |
|
3139 else |
|
3140 { |
|
3141 aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailNormalSmtpPort ); |
|
3142 aThisElem->iSmtpSettings->SetSSLWrapper( EFalse ); |
|
3143 } |
|
3144 break; |
|
3145 case ESuseStartTls : |
|
3146 if ( object ) |
|
3147 { |
|
3148 // The port is same in all cases |
|
3149 aThisElem->iSmtpSettings->SetSecureSockets(ETrue); |
|
3150 aThisElem->iSmtpSettings->SetSSLWrapper(EFalse); |
|
3151 aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailNormalSmtpPort ); |
|
3152 } |
|
3153 else |
|
3154 { |
|
3155 aThisElem->iSmtpSettings->SetSecureSockets( EFalse ); |
|
3156 } |
|
3157 |
|
3158 break; |
|
3159 default : |
|
3160 break; |
|
3161 } |
|
3162 CleanupStack::PopAndDestroy(); // object |
|
3163 _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSecurityL(): end"); |
|
3164 } |
|
3165 |
|
3166 // ----------------------------------------------------------------------------- |
|
3167 // CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchSecurityValueL( |
|
3168 // CBufBase& aObject, |
|
3169 // const TNSmlEmailSettingsElement* aElem, |
|
3170 // const TNSmlEmailSecuritySetting aSetting ) |
|
3171 // Gets the status(on/off) of security modes SSL/TLS or StartTLS |
|
3172 // ----------------------------------------------------------------------------- |
|
3173 |
|
3174 CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchSecurityValueL( |
|
3175 CBufBase& aObject, |
|
3176 const TNSmlEmailSettingsElement* aElem, |
|
3177 const TNSmlEmailSecuritySetting aSetting ) const |
|
3178 { |
|
3179 _DBG_FILE("CNSmlDmEmailAdapter::FetchSecurityValueL(): start"); |
|
3180 TBool result=EFalse; |
|
3181 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
3182 switch ( aSetting ) |
|
3183 { |
|
3184 |
|
3185 case EUseStartTls : |
|
3186 if ( aElem->iImap4Settings) |
|
3187 { |
|
3188 result = aElem->iImap4Settings->SecureSockets(); |
|
3189 } |
|
3190 else if(aElem->iPop3Settings) |
|
3191 { |
|
3192 result = aElem->iPop3Settings->SecureSockets(); |
|
3193 } |
|
3194 else |
|
3195 { |
|
3196 status = CSmlDmAdapter::EError; |
|
3197 } |
|
3198 break; |
|
3199 case EUseSecCon : |
|
3200 if ( aElem->iImap4Settings) |
|
3201 { |
|
3202 result = aElem->iImap4Settings->SSLWrapper(); |
|
3203 } |
|
3204 else if(aElem->iPop3Settings) |
|
3205 { |
|
3206 result = aElem->iPop3Settings->SSLWrapper(); |
|
3207 } |
|
3208 else |
|
3209 { |
|
3210 status = CSmlDmAdapter::EError; |
|
3211 } |
|
3212 break; |
|
3213 case ESuseStartTls : |
|
3214 if(aElem->iSmtpSettings) |
|
3215 { |
|
3216 result = aElem->iSmtpSettings->SecureSockets(); |
|
3217 } |
|
3218 else |
|
3219 { |
|
3220 status = CSmlDmAdapter::EError; |
|
3221 } |
|
3222 break; |
|
3223 case ESuseSecCon : |
|
3224 if(aElem->iSmtpSettings) |
|
3225 { |
|
3226 result = aElem->iSmtpSettings->SSLWrapper(); |
|
3227 } |
|
3228 else |
|
3229 { |
|
3230 status = CSmlDmAdapter::EError; |
|
3231 } |
|
3232 break; |
|
3233 default: |
|
3234 status = CSmlDmAdapter::EError; |
|
3235 break; |
|
3236 } |
|
3237 |
|
3238 if ( result ) |
|
3239 { |
|
3240 aObject.InsertL(0,KNSmlDMEmailTrue); |
|
3241 } |
|
3242 else |
|
3243 { |
|
3244 aObject.InsertL(0,KNSmlDMEmailFalse); |
|
3245 } |
|
3246 _DBG_FILE("CNSmlDmEmailAdapter::FetchSecurityValueL(): end"); |
|
3247 return status; |
|
3248 } |
|
3249 |
|
3250 //-------------------------------------------------------------------- |
|
3251 //TInt CNSmlDmEmailAdapter::ConstructTreeL(const TDesC8& aURI) |
|
3252 // |
|
3253 //------------------------------------------------------------------- |
|
3254 |
|
3255 TInt CNSmlDmEmailAdapter::ConstructTreeL(const TDesC8& aURI) |
|
3256 { |
|
3257 TInt ret = KErrNotFound; |
|
3258 CEmailAccounts* emailAccs = CEmailAccounts::NewLC(); |
|
3259 |
|
3260 if(aURI.Find(KNSmlDMEmailNodeName)!= KErrNotFound) |
|
3261 { |
|
3262 RArray<TImapAccount> imap4Accounts; |
|
3263 CleanupClosePushL( imap4Accounts ); |
|
3264 emailAccs->GetImapAccountsL(imap4Accounts); |
|
3265 |
|
3266 // First, IMAP accounts |
|
3267 // |
|
3268 TInt luid; |
|
3269 TPtrC8 name; |
|
3270 // cycle through every found account |
|
3271 for(TInt count = 0; count < imap4Accounts.Count(); count++) |
|
3272 { |
|
3273 |
|
3274 SetLuidById( EImap, imap4Accounts[count].iImapAccountId, luid ); |
|
3275 HBufC8 *uri = HBufC8::NewLC(KNSmlDMEmailNodeName().Length() + |
|
3276 KNSmlDMEmailMproIMAP().Length() + 6); |
|
3277 |
|
3278 TPtr8 uriPtr = uri->Des(); |
|
3279 uriPtr.Append(KNSmlDMEmailNodeName); |
|
3280 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
3281 uriPtr.Append(KNSmlDMEmailMproIMAP); |
|
3282 uriPtr.AppendNumFixedWidth(count,EDecimal,3); |
|
3283 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
3284 HBufC8* mapInfo = Callback().GetLuidAllocL(uriPtr); |
|
3285 if (mapInfo->Length() == 0) |
|
3286 { |
|
3287 Callback().SetMappingL(uriPtr, luidBuf->Des()); |
|
3288 if( aURI.Find(uriPtr) >= 0 ) |
|
3289 { |
|
3290 ret = luid; |
|
3291 } |
|
3292 } |
|
3293 else |
|
3294 { |
|
3295 delete mapInfo; |
|
3296 } |
|
3297 |
|
3298 CleanupStack::PopAndDestroy(2); //uri,luidBuf |
|
3299 } |
|
3300 CleanupStack::PopAndDestroy(); //imap4Accounts |
|
3301 |
|
3302 // Then, POP accounts |
|
3303 // |
|
3304 RArray<TPopAccount> pop3Accounts; |
|
3305 CleanupClosePushL( pop3Accounts ); |
|
3306 emailAccs->GetPopAccountsL( pop3Accounts ); |
|
3307 // cycle through every found account |
|
3308 for(TInt count = 0; count < pop3Accounts.Count(); count++) |
|
3309 { |
|
3310 SetLuidById( EPop, pop3Accounts[count].iPopAccountId, luid ); |
|
3311 |
|
3312 HBufC8 *uri = HBufC8::NewLC(KNSmlDMEmailNodeName().Length() + |
|
3313 KNSmlDMEmailMproPOP().Length() + 5); |
|
3314 TPtr8 uriPtr = uri->Des(); |
|
3315 uriPtr.Append(KNSmlDMEmailNodeName); |
|
3316 uriPtr.Append(KNSmlDMEmailSeparator8); |
|
3317 uriPtr.Append(KNSmlDMEmailMproPOP); |
|
3318 uriPtr.AppendNumFixedWidth(count,EDecimal,3); |
|
3319 HBufC8 *luidBuf = IntToDes8LC(luid); |
|
3320 HBufC8* mapInfo = Callback().GetLuidAllocL(uriPtr); |
|
3321 if (mapInfo->Length() == 0) |
|
3322 { |
|
3323 Callback().SetMappingL(uriPtr,luidBuf->Des()); |
|
3324 if( aURI.Find(uriPtr) >= 0 ) |
|
3325 { |
|
3326 ret = luid; |
|
3327 } |
|
3328 } |
|
3329 else |
|
3330 { |
|
3331 delete mapInfo; |
|
3332 } |
|
3333 |
|
3334 CleanupStack::PopAndDestroy(2); //uri,luidBuf |
|
3335 } |
|
3336 CleanupStack::PopAndDestroy(); //pop3Accounts |
|
3337 } |
|
3338 CleanupStack::PopAndDestroy(); //emailAccs |
|
3339 return ret; |
|
3340 } |
|
3341 |
|
3342 //------------------------------------------------------------------------------ |
|
3343 // TPtrC8 CNSmlDmEmailAdapter::GetDynamicEmailNodeUri( const TDesC8& aURI ) |
|
3344 // returns Email/xxx URI |
|
3345 //------------------------------------------------------------------------------ |
|
3346 TPtrC8 CNSmlDmEmailAdapter::GetDynamicEmailNodeUri( const TDesC8& aURI ) |
|
3347 { |
|
3348 DBG_ARGS8(_S8("CNSmlDmEmailAdapter::GetDynamicEmailNodeUri() - <%S> "), &aURI); |
|
3349 TInt i= 0; |
|
3350 TBuf8<50> EmailAccRoot(KNSmlDMEmailNodeName); |
|
3351 for ( i = aURI.Find( KNSmlDMEmailNodeName ) + EmailAccRoot.Length() + 1; |
|
3352 i < aURI.Length(); i++ ) |
|
3353 { |
|
3354 if( aURI[i] == '/' ) |
|
3355 { |
|
3356 break; |
|
3357 } |
|
3358 } |
|
3359 _DBG_FILE("CNSmlDmEmailAdapter::GetDynamicEmailNodeUri(): end"); |
|
3360 return aURI.Left( i ); |
|
3361 } |
|
3362 |
|
3363 |
|
3364 // End of File |