40 \param mailboxId Mailbox identifier. |
40 \param mailboxId Mailbox identifier. |
41 \param account CEmailAccounts created by the settings manager factory. Takes ownership after |
41 \param account CEmailAccounts created by the settings manager factory. Takes ownership after |
42 successful construction. |
42 successful construction. |
43 \param accountType AccountType identifier. |
43 \param accountType AccountType identifier. |
44 */ |
44 */ |
45 NmIpsSettingsManagerBase::NmIpsSettingsManagerBase(const NmId &mailboxId, CEmailAccounts *account, |
45 NmIpsSettingsManagerBase::NmIpsSettingsManagerBase(const NmId &mailboxId, CEmailAccounts *account, |
46 IpsServices::TIpsSetAccountTypes accountType) |
46 IpsServices::TIpsSetAccountTypes accountType) |
47 : mAccountType(accountType), |
47 : mAccountType(accountType), |
48 mMailboxId(mailboxId.id()) |
48 mMailboxId(mailboxId.id()) |
49 { |
49 { |
50 QScopedPointer<NmIpsExtendedSettingsManager> extendedSettings( |
50 QScopedPointer<NmIpsExtendedSettingsManager> extendedSettings( |
65 delete mAccount; |
65 delete mAccount; |
66 delete mSmtpSettings; |
66 delete mSmtpSettings; |
67 delete mExtendedSettingsManager; |
67 delete mExtendedSettingsManager; |
68 } |
68 } |
69 |
69 |
70 /*! |
70 /*! |
71 Finds and returns the SMTP specific setting or uses NmIpsExtendedSettingsManager to find |
71 Finds and returns the SMTP specific setting or uses NmIpsExtendedSettingsManager to find |
72 extended settings. |
72 extended settings. |
73 \param settingItem SettingItem enum of the setting to return |
73 \param settingItem SettingItem enum of the setting to return |
74 \param QVariant SettingValue of the found setting value. |
74 \param QVariant SettingValue of the found setting value. |
75 \return bool <true> when the setting item was found otherwise <false>. |
75 \return bool <true> when the setting item was found otherwise <false>. |
76 */ |
76 */ |
77 bool NmIpsSettingsManagerBase::readSetting(IpsServices::SettingItem settingItem, |
77 bool NmIpsSettingsManagerBase::readSetting(IpsServices::SettingItem settingItem, |
78 QVariant &settingValue) |
78 QVariant &settingValue) |
79 { |
79 { |
80 bool found(false); |
80 bool found(false); |
81 |
81 |
82 switch (settingItem) { |
82 switch (settingItem) { |
83 case IpsServices::EmailAlias: |
83 case IpsServices::EmailAlias: |
84 settingValue = XQConversions::s60DescToQString(mSmtpSettings->EmailAlias()); |
84 settingValue = XQConversions::s60DescToQString(mSmtpSettings->EmailAlias()); |
85 found = true; |
85 found = true; |
86 break; |
86 break; |
87 case IpsServices::EmailAddress: |
87 case IpsServices::EmailAddress: |
88 settingValue = XQConversions::s60DescToQString(mSmtpSettings->EmailAddress()); |
88 settingValue = XQConversions::s60DescToQString(mSmtpSettings->EmailAddress()); |
89 found = true; |
89 found = true; |
90 break; |
90 break; |
91 case IpsServices::ReplyAddress: |
91 case IpsServices::ReplyAddress: |
92 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ReplyToAddress()); |
92 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ReplyToAddress()); |
93 found = true; |
93 found = true; |
94 break; |
94 break; |
95 case IpsServices::OutgoingMailServer: |
95 case IpsServices::OutgoingMailServer: |
96 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ServerAddress()); |
96 settingValue = XQConversions::s60DescToQString(mSmtpSettings->ServerAddress()); |
97 found = true; |
97 found = true; |
98 break; |
98 break; |
99 case IpsServices::OutgoingPort: |
99 case IpsServices::OutgoingPort: |
100 settingValue = mSmtpSettings->Port(); |
100 settingValue = mSmtpSettings->Port(); |
101 found = true; |
101 found = true; |
102 break; |
102 break; |
103 case IpsServices::OutgoingLoginName: |
103 case IpsServices::OutgoingLoginName: |
104 settingValue = XQConversions::s60Desc8ToQString(mSmtpSettings->LoginName()); |
104 settingValue = XQConversions::s60Desc8ToQString(mSmtpSettings->LoginName()); |
105 found = true; |
105 found = true; |
106 break; |
106 break; |
107 case IpsServices::OutgoingPassword: |
107 case IpsServices::OutgoingPassword: |
108 settingValue = XQConversions::s60Desc8ToQString(mSmtpSettings->Password()); |
108 settingValue = XQConversions::s60Desc8ToQString(mSmtpSettings->Password()); |
109 found = true; |
109 found = true; |
110 break; |
110 break; |
111 case IpsServices::SMTPAuthentication: |
111 case IpsServices::SMTPAuthentication: |
112 settingValue = mSmtpSettings->SMTPAuth(); |
112 settingValue = mSmtpSettings->SMTPAuth(); |
113 found = true; |
113 found = true; |
114 break; |
114 break; |
115 case IpsServices::OutgoingSecureSockets: |
115 case IpsServices::OutgoingSecureSockets: |
116 settingValue = mSmtpSettings->SecureSockets(); |
116 settingValue = mSmtpSettings->SecureSockets(); |
117 found = true; |
117 found = true; |
118 break; |
118 break; |
119 case IpsServices::OutgoingSSLWrapper: |
119 case IpsServices::OutgoingSSLWrapper: |
120 settingValue = mSmtpSettings->SSLWrapper(); |
120 settingValue = mSmtpSettings->SSLWrapper(); |
121 found = true; |
121 found = true; |
122 break; |
122 break; |
123 case IpsServices::Connection: |
123 case IpsServices::Connection: |
131 ); |
131 ); |
132 break; |
132 break; |
133 default: |
133 default: |
134 found = mExtendedSettingsManager->readSetting(settingItem, settingValue); |
134 found = mExtendedSettingsManager->readSetting(settingItem, settingValue); |
135 break; |
135 break; |
136 } |
136 } |
137 return found; |
137 return found; |
138 } |
138 } |
139 |
139 |
140 /*! |
140 /*! |
141 Writes SMTP settings or passes the extended settings to NmIpsExtendedSettingsManager. |
141 Writes SMTP settings or passes the extended settings to NmIpsExtendedSettingsManager. |
142 \param settingItem SettingItem enum of the setting to replace. |
142 \param settingItem SettingItem enum of the setting to replace. |
143 \param settingValue QVariant of the new setting value. |
143 \param settingValue QVariant of the new setting value. |
144 \return bool <true> when the setting item was succesfully written, otherwise <false>. |
144 \return bool <true> when the setting item was succesfully written, otherwise <false>. |
145 */ |
145 */ |
146 bool NmIpsSettingsManagerBase::writeSetting(IpsServices::SettingItem settingItem, |
146 bool NmIpsSettingsManagerBase::writeSetting(IpsServices::SettingItem settingItem, |
147 const QVariant &settingValue) |
147 const QVariant &settingValue) |
148 { |
148 { |
149 HBufC *tmp = 0; |
149 HBufC *tmp = NULL; |
150 HBufC8 *tmp8 = 0; |
150 HBufC8 *tmp8 = NULL; |
151 |
151 |
152 bool ret(false); |
152 bool ret(false); |
153 TInt err(KErrNone); |
153 TInt err(KErrNone); |
154 |
154 |
155 switch (settingItem) { |
155 switch (settingItem) { |
156 case IpsServices::EmailAlias: |
156 case IpsServices::EmailAlias: |
158 TRAP(err, mSmtpSettings->SetEmailAliasL(*tmp)); |
158 TRAP(err, mSmtpSettings->SetEmailAliasL(*tmp)); |
159 delete tmp; |
159 delete tmp; |
160 if (err==KErrNone) { |
160 if (err==KErrNone) { |
161 ret = saveSettings(); |
161 ret = saveSettings(); |
162 } |
162 } |
163 break; |
163 break; |
164 case IpsServices::EmailAddress: |
164 case IpsServices::EmailAddress: |
165 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
165 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
166 TRAP(err, mSmtpSettings->SetEmailAddressL(*tmp)); |
166 TRAP(err, mSmtpSettings->SetEmailAddressL(*tmp)); |
167 delete tmp; |
167 delete tmp; |
168 if (err==KErrNone) { |
168 if (err==KErrNone) { |
169 ret = saveSettings(); |
169 ret = saveSettings(); |
170 } |
170 } |
171 break; |
171 break; |
172 case IpsServices::ReplyAddress: |
172 case IpsServices::ReplyAddress: |
173 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
173 tmp = XQConversions::qStringToS60Desc(settingValue.toString()); |
174 TRAP(err, mSmtpSettings->SetReplyToAddressL(*tmp)); |
174 TRAP(err, mSmtpSettings->SetReplyToAddressL(*tmp)); |
175 delete tmp; |
175 delete tmp; |
176 if (err==KErrNone) { |
176 if (err==KErrNone) { |
203 delete tmp8; |
203 delete tmp8; |
204 if (err==KErrNone) { |
204 if (err==KErrNone) { |
205 ret = saveSettings(); |
205 ret = saveSettings(); |
206 } |
206 } |
207 break; |
207 break; |
208 case IpsServices::SMTPAuthentication: |
208 case IpsServices::SMTPAuthentication: |
209 mSmtpSettings->SetSMTPAuth(settingValue.toBool()); |
209 mSmtpSettings->SetSMTPAuth(settingValue.toBool()); |
210 ret = saveSettings(); |
210 ret = saveSettings(); |
211 break; |
211 break; |
212 case IpsServices::OutgoingSecureSockets: |
212 case IpsServices::OutgoingSecureSockets: |
213 mSmtpSettings->SetSecureSockets(settingValue.toBool()); |
213 mSmtpSettings->SetSecureSockets(settingValue.toBool()); |
214 ret = saveSettings(); |
214 ret = saveSettings(); |
215 break; |
215 break; |
216 case IpsServices::OutgoingSSLWrapper: |
216 case IpsServices::OutgoingSSLWrapper: |
217 mSmtpSettings->SetSSLWrapper(settingValue.toBool()); |
217 mSmtpSettings->SetSSLWrapper(settingValue.toBool()); |
218 ret = saveSettings(); |
218 ret = saveSettings(); |
219 break; |
219 break; |
220 case IpsServices::Connection: |
220 case IpsServices::Connection: |
221 ret = saveIAPSettings(settingValue.toUInt()); |
221 ret = saveIAPSettings(settingValue.toUInt()); |
222 break; |
222 break; |
223 default: |
223 default: |
224 ret = mExtendedSettingsManager->writeSetting(settingItem, settingValue); |
224 ret = mExtendedSettingsManager->writeSetting(settingItem, settingValue); |
225 break; |
225 break; |
226 } |
226 } |
227 return ret; |
227 return ret; |
228 } |
228 } |
229 |
229 |
230 /*! |
230 /*! |
231 Deletes the mailbox. |
231 Deletes the mailbox. |
232 \return Error code <code>0</code> if mailbox deletion was successful, otherwise error |
232 \return Error code <code>0</code> if mailbox deletion was successful, otherwise error |
233 code is returned. |
233 code is returned. |
234 */ |
234 */ |
235 int NmIpsSettingsManagerBase::deleteMailbox() |
235 int NmIpsSettingsManagerBase::deleteMailbox() |