1 /* |
|
2 * Copyright (c) 2002 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: Saves SMTP IMAP settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CWPEmailSaveSmtpImapItem.h" |
|
21 #include "CWPEmailItem.h" |
|
22 #include "WPEmail.hrh" |
|
23 #include "EmailAdapter.pan" |
|
24 #include "Cwplog.h" |
|
25 #include <CWPParameter.h> |
|
26 #include <imapset.h> |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CSaveSmtpImapItem::CSaveSmtpImapItem |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CSaveSmtpImapItem::CSaveSmtpImapItem( CWPEmailItem* aSmtpItem, |
|
38 CWPEmailItem* aImapItem ) |
|
39 : iSmtpItem( aSmtpItem ), |
|
40 iImapItem( aImapItem ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CSaveSmtpImapItem::ConstructL |
|
46 // Symbian 2nd phase constructor can leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CSaveSmtpImapItem::ConstructL() |
|
50 { |
|
51 CWPEmailSaveItem::ConstructL(); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSaveSmtpImapItem::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CSaveSmtpImapItem* CSaveSmtpImapItem::NewLC( CWPEmailItem* aSmtpItem, |
|
60 CWPEmailItem* aImapItem ) |
|
61 { |
|
62 __ASSERT_DEBUG(aSmtpItem && aImapItem , Panic(EMailAdapterNullPointer)); |
|
63 CSaveSmtpImapItem* self = new( ELeave ) CSaveSmtpImapItem( aSmtpItem, |
|
64 aImapItem ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // Destructor |
|
72 // ----------------------------------------------------------------------------- |
|
73 CSaveSmtpImapItem::~CSaveSmtpImapItem() |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CSaveSmtpImapItem::SaveL |
|
79 // (other items were commented in a header). |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CSaveSmtpImapItem::SaveL( CMsvSession* aSession ) |
|
83 { |
|
84 SaveMailSettingsToMessageServerL( *iSmtpItem, *iImapItem, EFalse, aSession ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSaveSmtpImapItem::SummaryText |
|
89 // (other items were commented in a header). |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 TBool CSaveSmtpImapItem::ValidateL() |
|
93 { |
|
94 // Check items |
|
95 return ( ValidateSmtpItemL() && ValidateImapItemL() && |
|
96 iSmtpItem->ParameterValue(EWPParameterProviderID) == |
|
97 iImapItem->ParameterValue(EWPParameterProviderID)); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CSaveSmtpImapItem::SummaryText |
|
102 // (other items were commented in a header). |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 const TDesC& CSaveSmtpImapItem::SummaryText() |
|
106 { |
|
107 // return default name for settings |
|
108 return CWPEmailSaveItem::SummaryText(); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CSaveSmtpImapItem::ValidateSmtpItemL |
|
113 // (other items were commented in a header). |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TBool CSaveSmtpImapItem::ValidateSmtpItemL() |
|
117 { |
|
118 const TDesC& ownAddress = iSmtpItem->ParameterValue(EWPParameterFrom); |
|
119 const TDesC& serverAddress = iSmtpItem->ParameterValue(EWPParameterAddr); |
|
120 |
|
121 if (ownAddress.Length() > 0 |
|
122 && ownAddress.Length() <= KIacMaxAddressLength |
|
123 && KErrNone == ValidateServerAddress(serverAddress) |
|
124 && serverAddress.Length() <= KIacMaxSendHostLength ) |
|
125 { |
|
126 LOG1("CSaveSmtpImapItem::ValidateSmtpItemL %d", IsValidEmailAddressL(ownAddress)); |
|
127 return (IsValidEmailAddressL(ownAddress)); |
|
128 } |
|
129 LOG("CSaveSmtpImapItem::ValidateSmtpItemL: Not Valid"); |
|
130 return EFalse; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CSaveSmtpImapItem::ValidateImapItemL |
|
135 // (other items were commented in a header). |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 TBool CSaveSmtpImapItem::ValidateImapItemL() |
|
139 { |
|
140 const TDesC& userName = iImapItem->ParameterValue(EWPParameterAAuthName); |
|
141 const TDesC& password = iImapItem->ParameterValue(EWPParameterAAuthSecret); |
|
142 const TDesC& serverAddress = iImapItem->ParameterValue(EWPParameterAddr); |
|
143 const TDesC& imapName = iImapItem->ParameterValue(EWPParameterName); |
|
144 const TDesC& smtpName = iSmtpItem->ParameterValue(EWPParameterName); |
|
145 |
|
146 // Replace default name if found |
|
147 if (imapName.Length() > 0) |
|
148 { |
|
149 SetDefaultNameL(imapName); |
|
150 } |
|
151 else |
|
152 { |
|
153 if (smtpName.Length() > 0) |
|
154 { |
|
155 SetDefaultNameL(smtpName); |
|
156 } |
|
157 } |
|
158 |
|
159 if (KErrNone == ValidateServerAddress(serverAddress) |
|
160 && serverAddress.Length() <= KIacMaxRecHostLength |
|
161 && userName.Length() <= KIacMaxRemMbxUserNameLength |
|
162 && password.Length() <= KIacMaxPasswdLength && imapName.Length()<=30 && smtpName.Length()<=30 ) |
|
163 { |
|
164 LOG("CSaveSmtpImapItem::ValidateImapItemL: Valid"); |
|
165 return ETrue; |
|
166 } |
|
167 LOG("CSaveSmtpImapItem::ValidateImapItemL: Not Valid"); |
|
168 return EFalse; |
|
169 } |
|
170 |
|
171 // End of File |
|