diff options
Diffstat (limited to 'Swift/Controllers/MainController.cpp')
| -rw-r--r-- | Swift/Controllers/MainController.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 95094f2..a65a18a 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp | |||
| @@ -38,10 +38,14 @@ | |||
| 38 | #include <Swiften/Client/ClientXMLTracer.h> | 38 | #include <Swiften/Client/ClientXMLTracer.h> |
| 39 | #include <Swiften/Client/StanzaChannel.h> | 39 | #include <Swiften/Client/StanzaChannel.h> |
| 40 | #include <Swiften/Client/ClientBlockListManager.h> | 40 | #include <Swiften/Client/ClientBlockListManager.h> |
| 41 | #include <Swiften/Crypto/CryptoProvider.h> | 41 | #include <Swiften/Crypto/CryptoProvider.h> |
| 42 | 42 | ||
| 43 | #ifdef SWIFTEN_PLATFORM_WIN32 | ||
| 44 | #include <Swiften/SASL/WindowsAuthentication.h> | ||
| 45 | #endif | ||
| 46 | |||
| 43 | #include <SwifTools/Dock/Dock.h> | 47 | #include <SwifTools/Dock/Dock.h> |
| 44 | #include <SwifTools/Notifier/TogglableNotifier.h> | 48 | #include <SwifTools/Notifier/TogglableNotifier.h> |
| 45 | #include <SwifTools/Idle/IdleDetector.h> | 49 | #include <SwifTools/Idle/IdleDetector.h> |
| 46 | 50 | ||
| 47 | #include <Swift/Controllers/Intl.h> | 51 | #include <Swift/Controllers/Intl.h> |
| @@ -179,10 +183,15 @@ MainController::MainController( | |||
| 179 | ProfileSettingsProvider profileSettings(profile, settings); | 183 | ProfileSettingsProvider profileSettings(profile, settings); |
| 180 | std::string password = profileSettings.getStringSetting("pass"); | 184 | std::string password = profileSettings.getStringSetting("pass"); |
| 181 | std::string certificate = profileSettings.getStringSetting("certificate"); | 185 | std::string certificate = profileSettings.getStringSetting("certificate"); |
| 182 | std::string jid = profileSettings.getStringSetting("jid"); | 186 | std::string jid = profileSettings.getStringSetting("jid"); |
| 183 | ClientOptions clientOptions = parseClientOptions(profileSettings.getStringSetting("options")); | 187 | ClientOptions clientOptions = parseClientOptions(profileSettings.getStringSetting("options")); |
| 188 | |||
| 189 | #ifdef SWIFTEN_PLATFORM_WIN32 | ||
| 190 | clientOptions.singleSignOn = settings_->getSetting(SettingConstants::SINGLE_SIGN_ON); | ||
| 191 | #endif | ||
| 192 | |||
| 184 | loginWindow_->addAvailableAccount(jid, password, certificate, clientOptions); | 193 | loginWindow_->addAvailableAccount(jid, password, certificate, clientOptions); |
| 185 | if (jid == selectedLoginJID) { | 194 | if (jid == selectedLoginJID) { |
| 186 | cachedPassword = password; | 195 | cachedPassword = password; |
| 187 | cachedCertificate = certificate; | 196 | cachedCertificate = certificate; |
| 188 | cachedOptions = clientOptions; | 197 | cachedOptions = clientOptions; |
| @@ -509,14 +518,36 @@ void MainController::handleShowCertificateRequest() { | |||
| 509 | rosterController_->getWindow()->openCertificateDialog(chain); | 518 | rosterController_->getWindow()->openCertificateDialog(chain); |
| 510 | } | 519 | } |
| 511 | 520 | ||
| 512 | void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificatePath, CertificateWithKey::ref certificate, const ClientOptions& options, bool remember, bool loginAutomatically) { | 521 | void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificatePath, CertificateWithKey::ref certificate, const ClientOptions& options, bool remember, bool loginAutomatically) { |
| 513 | jid_ = JID(username); | 522 | jid_ = JID(username); |
| 514 | if (!jid_.isValid() || jid_.getNode().empty()) { | 523 | if (options.singleSignOn && (!jid_.isValid() || !jid_.getNode().empty())) { |
| 524 | loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'wonderland.lit'")); | ||
| 525 | loginWindow_->setIsLoggingIn(false); | ||
| 526 | } else if (!options.singleSignOn && (!jid_.isValid() || jid_.getNode().empty())) { | ||
| 515 | loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'alice@wonderland.lit'")); | 527 | loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'alice@wonderland.lit'")); |
| 516 | loginWindow_->setIsLoggingIn(false); | 528 | loginWindow_->setIsLoggingIn(false); |
| 517 | } else { | 529 | } else { |
| 530 | #ifdef SWIFTEN_PLATFORM_WIN32 | ||
| 531 | if (options.singleSignOn) { | ||
| 532 | std::string userName; | ||
| 533 | std::string clientName; | ||
| 534 | std::string serverName; | ||
| 535 | boost::shared_ptr<boost::system::error_code> errorCode = getUserNameEx(userName, clientName, serverName); | ||
| 536 | |||
| 537 | if (!errorCode) { | ||
| 538 | /* Create JID using the Windows logon name and user provided domain name */ | ||
| 539 | jid_ = JID(clientName, username); | ||
| 540 | } | ||
| 541 | else { | ||
| 542 | loginWindow_->setMessage(str(format(QT_TRANSLATE_NOOP("", "Error obtaining Windows user name (%1%)")) % errorCode->message())); | ||
| 543 | loginWindow_->setIsLoggingIn(false); | ||
| 544 | return; | ||
| 545 | } | ||
| 546 | } | ||
| 547 | #endif | ||
| 548 | |||
| 518 | loginWindow_->setMessage(""); | 549 | loginWindow_->setMessage(""); |
| 519 | loginWindow_->setIsLoggingIn(true); | 550 | loginWindow_->setIsLoggingIn(true); |
| 520 | profileSettings_ = new ProfileSettingsProvider(username, settings_); | 551 | profileSettings_ = new ProfileSettingsProvider(username, settings_); |
| 521 | if (!settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) { | 552 | if (!settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) { |
| 522 | profileSettings_->storeString("jid", username); | 553 | profileSettings_->storeString("jid", username); |
Swift