Changeset View
Changeset View
Standalone View
Standalone View
resources/imap/setupserver.cpp
Show First 20 Lines • Show All 277 Lines • ▼ Show 20 Line(s) | 273 | if (KMessageBox::warningContinueCancel( | |||
---|---|---|---|---|---|
278 | return; | 278 | return; | ||
279 | } | 279 | } | ||
280 | } | 280 | } | ||
281 | 281 | | |||
282 | m_folderArchiveSettingPage->writeSettings(); | 282 | m_folderArchiveSettingPage->writeSettings(); | ||
283 | m_shouldClearCache = (m_parentResource->settings()->imapServer() != m_ui->imapServer->text()) | 283 | m_shouldClearCache = (m_parentResource->settings()->imapServer() != m_ui->imapServer->text()) | ||
284 | || (m_parentResource->settings()->userName() != m_ui->userName->text()); | 284 | || (m_parentResource->settings()->userName() != m_ui->userName->text()); | ||
285 | 285 | | |||
286 | const MailTransport::Transport::EnumAuthenticationType::type authtype = getCurrentAuthMode(m_ui->authenticationCombo); | ||||
287 | if (!m_ui->userName->text().contains(QLatin1Char('@')) | ||||
288 | && authtype == MailTransport::Transport::EnumAuthenticationType::XOAUTH2 | ||||
289 | && m_ui->imapServer->text().contains(QLatin1String("gmail.com"))) { | ||||
290 | // Normalize gmail username so that it matches the JSON account info returned by GMail authentication. | ||||
291 | // If we don't do this, we will look up cached auth without @gmail.com and save it with @gmail.com => very frequent auth dialog popping up. | ||||
292 | qCDebug(IMAPRESOURCE_LOG) << "Fixing up username" << m_ui->userName->text() << "by adding @gmail.com"; | ||||
293 | m_ui->userName->setText(m_ui->userName->text() + QLatin1String("@gmail.com")); | ||||
294 | } | ||||
295 | | ||||
286 | m_parentResource->setName(m_ui->accountName->text()); | 296 | m_parentResource->setName(m_ui->accountName->text()); | ||
287 | 297 | | |||
288 | m_parentResource->settings()->setImapServer(m_ui->imapServer->text()); | 298 | m_parentResource->settings()->setImapServer(m_ui->imapServer->text()); | ||
289 | m_parentResource->settings()->setImapPort(m_ui->portSpin->value()); | 299 | m_parentResource->settings()->setImapPort(m_ui->portSpin->value()); | ||
290 | m_parentResource->settings()->setUserName(m_ui->userName->text()); | 300 | m_parentResource->settings()->setUserName(m_ui->userName->text()); | ||
291 | QString encryption; | 301 | QString encryption; | ||
292 | switch (m_ui->safeImapGroup->checkedId()) { | 302 | switch (m_ui->safeImapGroup->checkedId()) { | ||
293 | case KIMAP::LoginJob::Unencrypted: | 303 | case KIMAP::LoginJob::Unencrypted: | ||
294 | encryption = QStringLiteral("None"); | 304 | encryption = QStringLiteral("None"); | ||
295 | break; | 305 | break; | ||
296 | case KIMAP::LoginJob::SSLorTLS: | 306 | case KIMAP::LoginJob::SSLorTLS: | ||
297 | encryption = QStringLiteral("SSL"); | 307 | encryption = QStringLiteral("SSL"); | ||
298 | break; | 308 | break; | ||
299 | case KIMAP::LoginJob::STARTTLS: | 309 | case KIMAP::LoginJob::STARTTLS: | ||
300 | encryption = QStringLiteral("STARTTLS"); | 310 | encryption = QStringLiteral("STARTTLS"); | ||
301 | break; | 311 | break; | ||
302 | default: | 312 | default: | ||
303 | qFatal("Shouldn't happen"); | 313 | qFatal("Shouldn't happen"); | ||
304 | } | 314 | } | ||
305 | m_parentResource->settings()->setSafety(encryption); | 315 | m_parentResource->settings()->setSafety(encryption); | ||
306 | MailTransport::Transport::EnumAuthenticationType::type authtype = getCurrentAuthMode(m_ui->authenticationCombo); | 316 | | ||
307 | qCDebug(IMAPRESOURCE_LOG) << "saving IMAP auth mode: " << authenticationModeString(authtype); | 317 | qCDebug(IMAPRESOURCE_LOG) << "saving IMAP auth mode: " << authenticationModeString(authtype); | ||
308 | m_parentResource->settings()->setAuthentication(authtype); | 318 | m_parentResource->settings()->setAuthentication(authtype); | ||
309 | m_parentResource->settings()->setPassword(m_ui->password->password()); | 319 | m_parentResource->settings()->setPassword(m_ui->password->password()); | ||
310 | m_parentResource->settings()->setSubscriptionEnabled(m_ui->subscriptionEnabled->isChecked()); | 320 | m_parentResource->settings()->setSubscriptionEnabled(m_ui->subscriptionEnabled->isChecked()); | ||
311 | m_parentResource->settings()->setIntervalCheckTime(m_ui->checkInterval->value()); | 321 | m_parentResource->settings()->setIntervalCheckTime(m_ui->checkInterval->value()); | ||
312 | m_parentResource->settings()->setDisconnectedModeEnabled(m_ui->disconnectedModeEnabled->isChecked()); | 322 | m_parentResource->settings()->setDisconnectedModeEnabled(m_ui->disconnectedModeEnabled->isChecked()); | ||
313 | 323 | | |||
314 | MailTransport::Transport::EnumAuthenticationType::type alternateAuthtype = getCurrentAuthMode(m_ui->authenticationAlternateCombo); | 324 | MailTransport::Transport::EnumAuthenticationType::type alternateAuthtype = getCurrentAuthMode(m_ui->authenticationAlternateCombo); | ||
▲ Show 20 Lines • Show All 396 Lines • Show Last 20 Lines |