|
1 /* |
|
2 * Copyright (c) 2006 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: ImumCreatorPredefinedMailbox.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <smtpset.h> // SMTP enumerations |
|
23 #include <imapset.h> // IMAP4 mail settings |
|
24 #include <pop3set.h> // POP3 mail settings |
|
25 #include <iapprefs.h> |
|
26 #include <SendUiConsts.h> |
|
27 |
|
28 #include "ImumDaSettingsKeys.h" |
|
29 #include "ImumInSettingsKeys.h" |
|
30 #include "ImumCreatorPredefinedMailbox.h" |
|
31 #include "ImumPrivateCRKeys.h" // Predefined mailbox keys |
|
32 #include "EmailUtils.H" |
|
33 #include "ImumInternalApi.h" // CImumInternalApi |
|
34 #include "ImumInSettingsData.h" |
|
35 #include "ImumInSettingsDataCollection.h" |
|
36 #include "ImumMtmLogging.h" |
|
37 #include "ImumDaErrorCodes.h" |
|
38 |
|
39 // EXTERNAL DATA STRUCTURES |
|
40 // EXTERNAL FUNCTION PROTOTYPES |
|
41 // CONSTANTS |
|
42 const TInt KImumMailboxIndex = 0x100; |
|
43 const TInt KImumMboxMaxTextLength = 500; |
|
44 const TInt KImumConvertValue = 0x02; |
|
45 |
|
46 // MACROS |
|
47 // LOCAL CONSTANTS AND MACROS |
|
48 // MODULE DATA STRUCTURES |
|
49 // LOCAL FUNCTION PROTOTYPES |
|
50 // FORWARD DECLARATIONS |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS ============================== |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CImumCreatorPredefinedMailbox::Newl() |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 CImumCreatorPredefinedMailbox* CImumCreatorPredefinedMailbox::NewL( |
|
59 CImumInternalApi& aMailboxApi ) |
|
60 { |
|
61 IMUM_STATIC_CONTEXT( CImumCreatorPredefinedMailbox::NewL, 0, mtm, KImumMtmLog ); |
|
62 IMUM_IN(); |
|
63 |
|
64 // Create the object |
|
65 CImumCreatorPredefinedMailbox* self = NewLC( aMailboxApi ); |
|
66 CleanupStack::Pop(); // self |
|
67 |
|
68 IMUM_OUT(); |
|
69 |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CImumCreatorPredefinedMailbox::NewlC() |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 CImumCreatorPredefinedMailbox* CImumCreatorPredefinedMailbox::NewLC( |
|
78 CImumInternalApi& aMailboxApi ) |
|
79 { |
|
80 IMUM_STATIC_CONTEXT( CImumCreatorPredefinedMailbox::NewLC, 0, mtm, KImumMtmLog ); |
|
81 IMUM_IN(); |
|
82 |
|
83 // Create the object |
|
84 CImumCreatorPredefinedMailbox* self = |
|
85 new ( ELeave ) CImumCreatorPredefinedMailbox( aMailboxApi ); |
|
86 CleanupStack::PushL( self ); |
|
87 |
|
88 // Constuct the object |
|
89 self->ConstructL(); |
|
90 |
|
91 IMUM_OUT(); |
|
92 |
|
93 return self; |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CImumCreatorPredefinedMailbox::~CImumCreatorPredefinedMailbox() |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 CImumCreatorPredefinedMailbox::~CImumCreatorPredefinedMailbox() |
|
101 { |
|
102 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::~CImumCreatorPredefinedMailbox, 0, KImumMtmLog ); |
|
103 IMUM_IN(); |
|
104 |
|
105 delete iCenRepSession; |
|
106 iCenRepSession = NULL; |
|
107 |
|
108 iMailboxName.Close(); |
|
109 iMailboxRcvServer.Close(); |
|
110 iMailboxSndServer.Close(); |
|
111 iMailboxEmailAddress.Close(); |
|
112 iMailboxRcvUsername.Close(); |
|
113 iMailboxRcvPassword.Close(); |
|
114 iMailboxSndUsername.Close(); |
|
115 iMailboxSndPassword.Close(); |
|
116 |
|
117 IMUM_OUT(); |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // CImumCreatorPredefinedMailbox::CImumCreatorPredefinedMailbox() |
|
122 // ---------------------------------------------------------------------------- |
|
123 // |
|
124 CImumCreatorPredefinedMailbox::CImumCreatorPredefinedMailbox( |
|
125 CImumInternalApi& aMailboxApi ) |
|
126 : |
|
127 iMailboxApi( aMailboxApi ), |
|
128 iCenRepSession( NULL ) |
|
129 { |
|
130 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CImumCreatorPredefinedMailbox, 0, KImumMtmLog ); |
|
131 IMUM_IN(); |
|
132 |
|
133 // Clear all fields |
|
134 ClearFields(); |
|
135 |
|
136 IMUM_OUT(); |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------------------------------- |
|
140 // CImumCreatorPredefinedMailbox::ConstructL() |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 void CImumCreatorPredefinedMailbox::ConstructL() |
|
144 { |
|
145 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ConstructL, 0, KImumMtmLog ); |
|
146 IMUM_IN(); |
|
147 |
|
148 iCenRepSession = CRepository::NewL( KCRUidImum ); |
|
149 |
|
150 iMailboxName.CreateMax( KImumMboxMaxTextLength ); |
|
151 iMailboxRcvServer.CreateMax( KImumMboxMaxTextLength ); |
|
152 iMailboxSndServer.CreateMax( KImumMboxMaxTextLength ); |
|
153 iMailboxEmailAddress.CreateMax( KImumMboxMaxTextLength ); |
|
154 iMailboxRcvUsername.CreateMax( KImumMboxMaxTextLength ); |
|
155 iMailboxRcvPassword.CreateMax( KImumMboxMaxTextLength ); |
|
156 iMailboxSndUsername.CreateMax( KImumMboxMaxTextLength ); |
|
157 iMailboxSndPassword.CreateMax( KImumMboxMaxTextLength ); |
|
158 |
|
159 IMUM_OUT(); |
|
160 } |
|
161 |
|
162 // ---------------------------------------------------------------------------- |
|
163 // CImumCreatorPredefinedMailbox::ReadAndCreate() |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 TBool CImumCreatorPredefinedMailbox::ReadAndCreate() |
|
167 { |
|
168 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ReadAndCreate, 0, KImumMtmLog ); |
|
169 IMUM_IN(); |
|
170 |
|
171 // Read SMTP settings and validate them |
|
172 ReadSMTPParameters(); |
|
173 TBool create = EFalse; |
|
174 |
|
175 // Continue settings reading, if everything is fine |
|
176 if ( ProtocolOk() ) |
|
177 { |
|
178 IMUM0( 0, "Protocol information ok, proceed with reading receiving settings" ); |
|
179 // Read settings based on protocol |
|
180 if ( !iMailboxProtocol ) |
|
181 { |
|
182 IMUM0( 0, "Read POP3 Parameters" ); |
|
183 |
|
184 // Read POP3 settings and validate them |
|
185 ReadPOP3Parameters(); |
|
186 } |
|
187 else |
|
188 { |
|
189 IMUM0( 0, "Read IMAP4 Parameters" ); |
|
190 |
|
191 // Read IMAP4 settings and validate them |
|
192 ReadIMAP4Parameters(); |
|
193 } |
|
194 |
|
195 create = CompulsoryFilled(); |
|
196 } |
|
197 |
|
198 // Settings are ok |
|
199 if ( create ) |
|
200 { |
|
201 IMUM0( 0, "Mailbox can be created, perform final finetuning" ); |
|
202 FixSettings(); |
|
203 } |
|
204 |
|
205 IMUM_OUT(); |
|
206 return create; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // From class . |
|
211 // CImumCreatorPredefinedMailbox::ProtocolOk() |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 TBool CImumCreatorPredefinedMailbox::ProtocolOk() |
|
215 { |
|
216 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ProtocolOk, 0, KImumMtmLog ); |
|
217 IMUM_IN(); |
|
218 IMUM_OUT(); |
|
219 |
|
220 return ( iMailboxProtocol == 0 || iMailboxProtocol == 1 ); |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CImumCreatorPredefinedMailbox::CompulsoryFilled() |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 TBool CImumCreatorPredefinedMailbox::CompulsoryFilled() |
|
229 { |
|
230 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CompulsoryFilled, 0, KImumMtmLog ); |
|
231 IMUM_IN(); |
|
232 |
|
233 TBool sendServerOk = iMailboxSndServer.Length() > 0; |
|
234 TBool rcvServerOk = iMailboxRcvServer.Length() > 0; |
|
235 TBool nameOk = iMailboxName.Length() > 0; |
|
236 |
|
237 IMUM_OUT(); |
|
238 |
|
239 return sendServerOk && rcvServerOk && nameOk; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CImumCreatorPredefinedMailbox::FixSettings() |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CImumCreatorPredefinedMailbox::FixSettings() |
|
247 { |
|
248 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::FixSettings, 0, KImumMtmLog ); |
|
249 IMUM_IN(); |
|
250 |
|
251 // Set correct flag for the attachment setting |
|
252 TBool set = iMailboxFetchStates > 0; |
|
253 iMailboxFetchStates = set ? |
|
254 TImumInSettings::EFlagDownloadHeader: |
|
255 TImumInSettings::EFlagSetDownloadAll; |
|
256 |
|
257 IMUM_OUT(); |
|
258 } |
|
259 |
|
260 |
|
261 // ---------------------------------------------------------------------------- |
|
262 // CImumCreatorPredefinedMailbox::DefinePredefinedMailboxL() |
|
263 // ---------------------------------------------------------------------------- |
|
264 // |
|
265 TBool CImumCreatorPredefinedMailbox::DefinePredefinedMailboxL( |
|
266 const TUint aMailbox, |
|
267 CImumInSettingsData& aSettings ) |
|
268 { |
|
269 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::DefinePredefinedMailboxL, 0, KImumMtmLog ); |
|
270 IMUM_IN(); |
|
271 |
|
272 // Clear all fields |
|
273 ClearFields( aMailbox ); |
|
274 aSettings.ResetAll(); |
|
275 |
|
276 // Create settings if things are fine |
|
277 if ( ReadAndCreate() ) |
|
278 { |
|
279 // Check the mailbox type |
|
280 if ( !iMailboxProtocol ) |
|
281 { |
|
282 CreatePOP3MailboxL( aSettings ); |
|
283 } |
|
284 else |
|
285 { |
|
286 CreateIMAP4MailboxL( aSettings ); |
|
287 } |
|
288 } |
|
289 |
|
290 IMUM_OUT(); |
|
291 return !aSettings.Validate(); |
|
292 } |
|
293 |
|
294 // ---------------------------------------------------------------------------- |
|
295 // CImumCreatorPredefinedMailbox::ReadSMTPParameters() |
|
296 // ---------------------------------------------------------------------------- |
|
297 // |
|
298 void CImumCreatorPredefinedMailbox::ReadSMTPParameters() |
|
299 { |
|
300 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ReadSMTPParameters, 0, KImumMtmLog ); |
|
301 IMUM_IN(); |
|
302 |
|
303 // Get mailbox name |
|
304 GetKey( KImumMailName1, iMailboxName ); |
|
305 |
|
306 // Get protocol |
|
307 GetKey( KImumMailProtocol1, iMailboxProtocol ); |
|
308 |
|
309 // Get sending server address |
|
310 GetKey( KImumMailSendingHost1, iMailboxSndServer ); |
|
311 |
|
312 // Get access point |
|
313 GetKey( KImumMailIAP1, iMailboxAccessPoint ); |
|
314 |
|
315 // Get own email address |
|
316 GetKey( KImumMailOwnAddress1, iMailboxEmailAddress ); |
|
317 |
|
318 // Get copy email address to CC setting |
|
319 GetKey( KImumMailCopyToOwn1, iMailboxFillCC ); |
|
320 |
|
321 // Get sending delay setting |
|
322 GetKey( KImumMailSendMessage1, iMailboxMessageSend ); |
|
323 |
|
324 // Get sending security setting |
|
325 GetKey( KImumSmtpSecurity1, iMailboxSndSecurity ); |
|
326 DoSecurityConversion( iMailboxSndSecurity ); |
|
327 |
|
328 // Get OMA Email Notifications setting |
|
329 GetKey( KImumOmaEmnEnabled1, iMailboxOmaEmnEnabled ); |
|
330 |
|
331 // Get username setting |
|
332 GetKey( KImumMailOutgoingUsername1, iMailboxSndUsername ); |
|
333 |
|
334 // Get password setting |
|
335 GetKey( KImumMailOutgoingPassword1, iMailboxSndPassword ); |
|
336 |
|
337 // Get sending port number setting |
|
338 GetKey( KImumMailOutgoingPortNumber1, iMailboxSndPort ); |
|
339 |
|
340 if(iMailboxSndPort <= 0) |
|
341 { |
|
342 iMailboxSndPort = GetDefaultSecurityPort( iMailboxSndSecurity, |
|
343 TImumDaSettings::EValueProtocolSmtp ); |
|
344 } |
|
345 |
|
346 IMUM_OUT(); |
|
347 } |
|
348 |
|
349 // ---------------------------------------------------------------------------- |
|
350 // CImumCreatorPredefinedMailbox::ReadPOP3Parameters() |
|
351 // ---------------------------------------------------------------------------- |
|
352 // |
|
353 void CImumCreatorPredefinedMailbox::ReadPOP3Parameters() |
|
354 { |
|
355 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ReadPOP3Parameters, 0, KImumMtmLog ); |
|
356 IMUM_IN(); |
|
357 |
|
358 // Get receiving server address |
|
359 GetKey( KImumMailReceivingHost1, iMailboxRcvServer ); |
|
360 |
|
361 // Get APop settings |
|
362 GetKey( KImumMailAPop1, iMailboxAPop ); |
|
363 |
|
364 // Get header fetching setting |
|
365 GetKey( KImumMailFetchHeaders1, iMailboxHeaderCount ); |
|
366 |
|
367 // Get username setting |
|
368 GetKey( KImumMailIncomingUsername1, iMailboxRcvUsername ); |
|
369 |
|
370 // Get password setting |
|
371 GetKey( KImumMailIncomingPassword1, iMailboxRcvPassword ); |
|
372 |
|
373 // Get receiving security setting |
|
374 GetKey( KImumMailSecurity1, iMailboxRcvSecurity ); |
|
375 DoSecurityConversion( iMailboxRcvSecurity ); |
|
376 |
|
377 // Get receiving port number |
|
378 GetKey( KImumMailIncomingPortNumber1, iMailboxRcvPort ); |
|
379 |
|
380 if(iMailboxRcvPort <= 0) |
|
381 { |
|
382 iMailboxRcvPort = GetDefaultSecurityPort( iMailboxRcvSecurity, |
|
383 TImumDaSettings::EValueProtocolPop3 ); |
|
384 } |
|
385 |
|
386 IMUM_OUT(); |
|
387 } |
|
388 |
|
389 // ---------------------------------------------------------------------------- |
|
390 // CImumCreatorPredefinedMailbox::ReadIMAP4Parameters() |
|
391 // ---------------------------------------------------------------------------- |
|
392 // |
|
393 void CImumCreatorPredefinedMailbox::ReadIMAP4Parameters() |
|
394 { |
|
395 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ReadIMAP4Parameters, 0, KImumMtmLog ); |
|
396 IMUM_IN(); |
|
397 |
|
398 // Get receiving host |
|
399 GetKey( KImumMailReceivingHost1, iMailboxRcvServer ); |
|
400 |
|
401 // Get attachment fetching setting |
|
402 GetKey( KImumMailFetchAttachment1, iMailboxFetchStates ); |
|
403 |
|
404 // Get header fetching setting |
|
405 GetKey( KImumMailFetchHeaders1, iMailboxHeaderCount ); |
|
406 |
|
407 // Get username setting |
|
408 GetKey( KImumMailIncomingUsername1, iMailboxRcvUsername ); |
|
409 |
|
410 // Get password setting |
|
411 GetKey( KImumMailIncomingPassword1, iMailboxRcvPassword ); |
|
412 |
|
413 // Get receiving security setting |
|
414 GetKey( KImumMailSecurity1, iMailboxRcvSecurity ); |
|
415 DoSecurityConversion( iMailboxRcvSecurity ); |
|
416 |
|
417 // Get receiving port number |
|
418 GetKey( KImumMailIncomingPortNumber1, iMailboxRcvPort ); |
|
419 |
|
420 if(iMailboxRcvPort <= 0) |
|
421 { |
|
422 iMailboxRcvPort = GetDefaultSecurityPort( iMailboxRcvSecurity, |
|
423 TImumDaSettings::EValueProtocolImap4 ); |
|
424 } |
|
425 |
|
426 IMUM_OUT(); |
|
427 } |
|
428 |
|
429 // ---------------------------------------------------------------------------- |
|
430 // CImumCreatorPredefinedMailbox::CreateIMAP4MailboxL() |
|
431 // ---------------------------------------------------------------------------- |
|
432 // |
|
433 void CImumCreatorPredefinedMailbox::CreateIMAP4MailboxL( |
|
434 CImumInSettingsData& aSettings ) |
|
435 { |
|
436 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CreateIMAP4MailboxL, 0, KImumMtmLog ); |
|
437 IMUM_IN(); |
|
438 |
|
439 CreateIMAP4SettingsL( aSettings ); |
|
440 CreateSMTPSettingsL( aSettings ); |
|
441 CreateGeneralSettingsL( aSettings ); |
|
442 |
|
443 IMUM_OUT(); |
|
444 } |
|
445 |
|
446 // ---------------------------------------------------------------------------- |
|
447 // CImumCreatorPredefinedMailbox::CreatePOP3MailboxL() |
|
448 // ---------------------------------------------------------------------------- |
|
449 // |
|
450 void CImumCreatorPredefinedMailbox::CreatePOP3MailboxL( |
|
451 CImumInSettingsData& aSettings ) |
|
452 { |
|
453 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CreatePOP3MailboxL, 0, KImumMtmLog ); |
|
454 IMUM_IN(); |
|
455 |
|
456 CreatePOP3SettingsL( aSettings ); |
|
457 CreateSMTPSettingsL( aSettings ); |
|
458 CreateGeneralSettingsL( aSettings ); |
|
459 |
|
460 IMUM_OUT(); |
|
461 } |
|
462 |
|
463 // ---------------------------------------------------------------------------- |
|
464 // CImumCreatorPredefinedMailbox::CreateGeneralSettingsL() |
|
465 // ---------------------------------------------------------------------------- |
|
466 // |
|
467 void CImumCreatorPredefinedMailbox::CreateGeneralSettingsL( |
|
468 CImumInSettingsData& aSettings ) |
|
469 { |
|
470 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CreateGeneralSettingsL, 0, KImumMtmLog ); |
|
471 IMUM_IN(); |
|
472 |
|
473 // Set OMA EMN state |
|
474 aSettings.SetAttr( |
|
475 TImumDaSettings::EKeyAutoNotifications, iMailboxOmaEmnEnabled ); |
|
476 |
|
477 // Add email address to settings |
|
478 aSettings.SetAttr( |
|
479 TImumDaSettings::EKeyEmailAddress, iMailboxEmailAddress ); |
|
480 |
|
481 // Set mail address can be empty |
|
482 aSettings.SetAttr( |
|
483 TImumInSettings::EKeyAllowEmptyEmailAddress, ETrue ); |
|
484 |
|
485 // Set mailbox name |
|
486 aSettings.SetAttr( |
|
487 TImumDaSettings::EKeyMailboxName, iMailboxName ); |
|
488 |
|
489 // Generate mailbox name when necessary |
|
490 aSettings.SetAttr( |
|
491 TImumInSettings::EKeyGenerateMailboxName, ETrue ); |
|
492 |
|
493 // Set send message delay |
|
494 aSettings.SetAttr( |
|
495 TImumDaSettings::EKeySendDelay, iMailboxMessageSend ); |
|
496 |
|
497 // Set send copy to self |
|
498 aSettings.SetAttr( |
|
499 TImumDaSettings::EKeySendCopyToSelf, iMailboxFillCC ); |
|
500 |
|
501 // Update inbox update limit |
|
502 aSettings.SetAttr( |
|
503 TImumDaSettings::EKeyInboxUpdateLimit, |
|
504 static_cast<TInt32>( iMailboxHeaderCount ) ); |
|
505 |
|
506 // Update folder update limit |
|
507 aSettings.GetInSetL( 0 ).SetAttr( |
|
508 TImumDaSettings::EKeyFolderUpdateLimit, |
|
509 static_cast<TInt32>( iMailboxHeaderCount ) ); |
|
510 |
|
511 // Set download flags |
|
512 aSettings.GetInSetL( 0 ).SetAttr( |
|
513 TImumInSettings::EKeyDownloadFlags, |
|
514 static_cast<TInt32>( iMailboxFetchStates ) ); |
|
515 |
|
516 // Set predefined mailbox flag |
|
517 aSettings.SetAttr( |
|
518 TImumInSettings::EKeyIsPredefinedMailbox, ETrue ); |
|
519 |
|
520 IMUM_OUT(); |
|
521 } |
|
522 |
|
523 // ---------------------------------------------------------------------------- |
|
524 // CImumCreatorPredefinedMailbox::CreateSMTPSettingsL() |
|
525 // ---------------------------------------------------------------------------- |
|
526 // |
|
527 void CImumCreatorPredefinedMailbox::CreateSMTPSettingsL( |
|
528 CImumInSettingsData& aSettings ) |
|
529 { |
|
530 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CreateSMTPSettingsL, 0, KImumMtmLog ); |
|
531 IMUM_IN(); |
|
532 |
|
533 // Create Imap4 settings |
|
534 MImumInSettingsDataCollection& smtpSettings = |
|
535 aSettings.AddInSetL( KSenduiMtmSmtpUid ); |
|
536 |
|
537 // Add security setting to settings |
|
538 smtpSettings.SetAttr( |
|
539 TImumDaSettings::EKeyAccessPoint, iMailboxAccessPoint ); |
|
540 |
|
541 // Add access point detail to settings |
|
542 smtpSettings.SetAttr( |
|
543 TImumInSettings::EKeyAccessPointType, |
|
544 TImumInSettings::EValueApIsIapId ); |
|
545 |
|
546 // Add server address to settings |
|
547 smtpSettings.SetAttr( |
|
548 TImumDaSettings::EKeyServer, iMailboxSndServer ); |
|
549 |
|
550 // Add security settings |
|
551 smtpSettings.SetAttr( |
|
552 TImumDaSettings::EKeySecurity, iMailboxSndSecurity ); |
|
553 |
|
554 // Add sending port number settings |
|
555 smtpSettings.SetAttr( |
|
556 TImumDaSettings::EKeyPort, iMailboxSndPort ); |
|
557 |
|
558 // Fill in the login info |
|
559 FillInLoginInfoL( iMailboxSndUsername, iMailboxSndPassword, smtpSettings ); |
|
560 |
|
561 IMUM_OUT(); |
|
562 } |
|
563 |
|
564 // ---------------------------------------------------------------------------- |
|
565 // CImumCreatorPredefinedMailbox::CreateIMAP4SettingsL() |
|
566 // ---------------------------------------------------------------------------- |
|
567 // |
|
568 void CImumCreatorPredefinedMailbox::CreateIMAP4SettingsL( |
|
569 CImumInSettingsData& aSettings ) |
|
570 { |
|
571 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CreateIMAP4SettingsL, 0, KImumMtmLog ); |
|
572 IMUM_IN(); |
|
573 |
|
574 // Create Imap4 settings |
|
575 MImumInSettingsDataCollection& imap4Settings = |
|
576 aSettings.AddInSetL( KSenduiMtmImap4Uid ); |
|
577 |
|
578 // Add security setting to settings |
|
579 imap4Settings.SetAttr( |
|
580 TImumDaSettings::EKeyAccessPoint, iMailboxAccessPoint ); |
|
581 |
|
582 // Add access point detail to settings |
|
583 imap4Settings.SetAttr( |
|
584 TImumInSettings::EKeyAccessPointType, |
|
585 TImumInSettings::EValueApIsIapId ); |
|
586 |
|
587 // Add server address to settings |
|
588 imap4Settings.SetAttr( |
|
589 TImumDaSettings::EKeyServer, iMailboxRcvServer ); |
|
590 |
|
591 // Add security settings |
|
592 imap4Settings.SetAttr( |
|
593 TImumDaSettings::EKeySecurity, iMailboxRcvSecurity ); |
|
594 |
|
595 // Add receiving port number settings |
|
596 imap4Settings.SetAttr( |
|
597 TImumDaSettings::EKeyPort, iMailboxRcvPort ); |
|
598 |
|
599 // Fill in the login info |
|
600 FillInLoginInfoL( iMailboxRcvUsername, iMailboxRcvPassword, imap4Settings ); |
|
601 |
|
602 IMUM_OUT(); |
|
603 } |
|
604 |
|
605 // ---------------------------------------------------------------------------- |
|
606 // CImumCreatorPredefinedMailbox::CreatePOP3SettingsL() |
|
607 // ---------------------------------------------------------------------------- |
|
608 // |
|
609 void CImumCreatorPredefinedMailbox::CreatePOP3SettingsL( |
|
610 CImumInSettingsData& aSettings ) |
|
611 { |
|
612 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::CreatePOP3SettingsL, 0, KImumMtmLog ); |
|
613 IMUM_IN(); |
|
614 |
|
615 // Create Imap4 settings |
|
616 MImumInSettingsDataCollection& pop3Settings = |
|
617 aSettings.AddInSetL( KSenduiMtmPop3Uid ); |
|
618 |
|
619 // Add access point to settings |
|
620 pop3Settings.SetAttr( |
|
621 TImumDaSettings::EKeyAccessPoint, iMailboxAccessPoint ); |
|
622 |
|
623 // Add access point detail to settings |
|
624 pop3Settings.SetAttr( |
|
625 TImumInSettings::EKeyAccessPointType, |
|
626 TImumInSettings::EValueApIsIapId ); |
|
627 |
|
628 // Add server address to settings |
|
629 pop3Settings.SetAttr( |
|
630 TImumDaSettings::EKeyServer, iMailboxRcvServer ); |
|
631 |
|
632 // Add security settings |
|
633 pop3Settings.SetAttr( |
|
634 TImumDaSettings::EKeySecurity, iMailboxRcvSecurity ); |
|
635 |
|
636 // Add APOP setting |
|
637 pop3Settings.SetAttr( |
|
638 TImumDaSettings::EKeyAPop, iMailboxAPop ); |
|
639 |
|
640 // Add receiving port number settings |
|
641 pop3Settings.SetAttr( |
|
642 TImumDaSettings::EKeyPort, iMailboxRcvPort ); |
|
643 |
|
644 |
|
645 // Fill in the login info |
|
646 FillInLoginInfoL( iMailboxRcvUsername, iMailboxRcvPassword, pop3Settings ); |
|
647 |
|
648 IMUM_OUT(); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // CImumCreatorPredefinedMailbox::FillInLoginInfoL() |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 void CImumCreatorPredefinedMailbox::FillInLoginInfoL( |
|
656 const TDesC& aUsername, |
|
657 const TDesC& aPassword, |
|
658 MImumInSettingsDataCollection& aConnectionSettings ) const |
|
659 { |
|
660 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::FillInLoginInfoL, 0, KImumMtmLog ); |
|
661 IMUM_IN(); |
|
662 |
|
663 // Convert to 8-bit format |
|
664 RBuf8 temp; |
|
665 temp.CreateMax( KImumMboxMaxTextLength ); |
|
666 temp.Copy( aUsername ); |
|
667 aConnectionSettings.SetAttr( TImumDaSettings::EKeyUsername, temp ); |
|
668 |
|
669 temp.Copy( aPassword ); |
|
670 aConnectionSettings.SetAttr( TImumDaSettings::EKeyPassword, temp ); |
|
671 |
|
672 // Reset descriptors |
|
673 temp.Close(); |
|
674 |
|
675 IMUM_OUT(); |
|
676 } |
|
677 |
|
678 // ---------------------------------------------------------------------------- |
|
679 // CImumCreatorPredefinedMailbox::ClearFields() |
|
680 // ---------------------------------------------------------------------------- |
|
681 // |
|
682 void CImumCreatorPredefinedMailbox::ClearFields( const TUint aMailbox ) |
|
683 { |
|
684 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::ClearFields, 0, KImumMtmLog ); |
|
685 IMUM1_IN( "Resetting with mailbox: %d", aMailbox ); |
|
686 |
|
687 iMailbox = aMailbox; |
|
688 iMailboxName.Zero(); |
|
689 iMailboxSndServer.Zero(); |
|
690 iMailboxRcvServer.Zero(); |
|
691 iMailboxAccessPoint = KErrUnknown; |
|
692 iMailboxProtocol = KErrUnknown; |
|
693 iMailboxEmailAddress.Zero(); |
|
694 iMailboxFillCC = KErrUnknown; |
|
695 iMailboxMessageSend = KErrUnknown; |
|
696 iMailboxSndSecurity = KErrUnknown; |
|
697 iMailboxAPop = KErrUnknown; |
|
698 iMailboxRcvSecurity = KErrUnknown; |
|
699 iMailboxHeaderCount = KErrUnknown; |
|
700 iMailboxRcvUsername.Zero(); |
|
701 iMailboxRcvPassword.Zero(); |
|
702 iMailboxSndUsername.Zero(); |
|
703 iMailboxSndPassword.Zero(); |
|
704 iMailboxOmaEmnEnabled = KErrUnknown; |
|
705 iMailboxRcvPort = KErrUnknown; |
|
706 iMailboxSndPort = KErrUnknown; |
|
707 |
|
708 IMUM_OUT(); |
|
709 } |
|
710 |
|
711 // ---------------------------------------------------------------------------- |
|
712 // CImumCreatorPredefinedMailbox::GetKey() |
|
713 // ---------------------------------------------------------------------------- |
|
714 // |
|
715 TInt CImumCreatorPredefinedMailbox::GetKey( |
|
716 TUint32 aId, |
|
717 TDes& aString ) |
|
718 { |
|
719 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::GetKey, 0, KImumMtmLog ); |
|
720 IMUM2_IN( "aId = %d, iMailbox = %d", aId, iMailbox ); |
|
721 |
|
722 // Get the mailbox by index |
|
723 aId += iMailbox * KImumMailboxIndex; |
|
724 TInt error = iCenRepSession->Get( aId, aString ); |
|
725 |
|
726 IMUM3( 0, "Key (%d) loading result: error = %d, aString = %S", aId, error, &aString ); |
|
727 IMUM_OUT(); |
|
728 return error; |
|
729 } |
|
730 |
|
731 // ---------------------------------------------------------------------------- |
|
732 // CImumCreatorPredefinedMailbox::GetKey() |
|
733 // ---------------------------------------------------------------------------- |
|
734 // |
|
735 TInt CImumCreatorPredefinedMailbox::GetKey( |
|
736 TUint32 aId, |
|
737 TInt& aInt) |
|
738 { |
|
739 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::GetKey, 0, KImumMtmLog ); |
|
740 IMUM2_IN( "aId = %d, iMailbox = %d", aId, iMailbox ); |
|
741 |
|
742 // Get the mailbox by index |
|
743 aId += iMailbox * KImumMailboxIndex; |
|
744 TInt error = iCenRepSession->Get( aId, aInt ); |
|
745 |
|
746 IMUM3( 0, "Key (%d) loading result: error = %d, aInt = %d", aId, error, aInt ); |
|
747 IMUM_OUT(); |
|
748 return error; |
|
749 } |
|
750 |
|
751 // --------------------------------------------------------------------------- |
|
752 // CImumCreatorPredefinedMailbox::DoSecurityConversion() |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 void CImumCreatorPredefinedMailbox::DoSecurityConversion( TInt& aSecurity ) const |
|
756 { |
|
757 //Conversion concerns only even numbers |
|
758 if ( ( aSecurity % 2 ) == 0 ) |
|
759 { |
|
760 //convert 0 -> 2 and 2 -> 0 |
|
761 aSecurity ^= KImumConvertValue; |
|
762 } |
|
763 } |
|
764 |
|
765 // ---------------------------------------------------------------------------- |
|
766 // CImumInSettingsDataValidator::GetDefaultSecurityPortL() |
|
767 // ---------------------------------------------------------------------------- |
|
768 // |
|
769 TInt CImumCreatorPredefinedMailbox::GetDefaultSecurityPort( |
|
770 const TInt aSecurity, |
|
771 const TInt aProtocol ) |
|
772 { |
|
773 IMUM_CONTEXT( CImumCreatorPredefinedMailbox::GetDefaultSecurityPortL, 0, KImumMtmLog ); |
|
774 IMUM_IN(); |
|
775 |
|
776 TInt port( 0 ); |
|
777 |
|
778 switch( aSecurity ) |
|
779 { |
|
780 case KErrUnknown: //value is not set at all |
|
781 case TImumDaSettings::EValueSecurityTls: |
|
782 case TImumDaSettings::EValueSecurityOff: |
|
783 { |
|
784 switch ( aProtocol ) |
|
785 { |
|
786 case TImumDaSettings::EValueProtocolImap4: |
|
787 port = TImumDaSettings::EDefaultPortImap4; |
|
788 break; |
|
789 |
|
790 case TImumDaSettings::EValueProtocolPop3: |
|
791 port = TImumDaSettings::EDefaultPortPop3; |
|
792 break; |
|
793 |
|
794 case TImumDaSettings::EValueProtocolSmtp: |
|
795 port = TImumDaSettings::EDefaultPortSmtp; |
|
796 break; |
|
797 } |
|
798 break; |
|
799 } |
|
800 case TImumDaSettings::EValueSecuritySsl: |
|
801 { |
|
802 switch ( aProtocol ) |
|
803 { |
|
804 case TImumDaSettings::EValueProtocolImap4: |
|
805 port = TImumDaSettings::EDefaultSecurityPortImap4; |
|
806 break; |
|
807 |
|
808 case TImumDaSettings::EValueProtocolPop3: |
|
809 port = TImumDaSettings::EDefaultSecurityPortPop3; |
|
810 break; |
|
811 |
|
812 case TImumDaSettings::EValueProtocolSmtp: |
|
813 port = TImumDaSettings::EDefaultSecurityPortSmtp; |
|
814 break; |
|
815 } |
|
816 } |
|
817 break; |
|
818 } |
|
819 |
|
820 IMUM_OUT(); |
|
821 |
|
822 return port; |
|
823 } |
|
824 |
|
825 |
|
826 // End of File |
|
827 |