summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-02-22 13:31:39 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-02-22 14:16:18 (GMT)
commitfa705718be1f98185557a09cf155ed66cbc740e2 (patch)
treeb73c65981c6e879df40c40c4b5436a4d4386e5a4 /Swift/Controllers
parent110eb87e848b85dd74a6f19413c775520a75ea35 (diff)
downloadswift-contrib-fa705718be1f98185557a09cf155ed66cbc740e2.zip
swift-contrib-fa705718be1f98185557a09cf155ed66cbc740e2.tar.bz2
Fix up for previous CAPI patch
Now connects successfully with or without TLS(with cert)
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp15
-rw-r--r--Swift/Controllers/MainController.h4
-rw-r--r--Swift/Controllers/UIInterfaces/LoginWindow.h8
3 files changed, 15 insertions, 12 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 4f869a7..d60bcbb 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -153,35 +153,36 @@ MainController::MainController(
cachedPassword = password;
cachedCertificate = certificate;
}
}
loginWindow_->selectUser(selectedLoginJID);
loginWindow_->setLoginAutomatically(loginAutomatically);
}
- loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4, _5));
+ loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4, _5, _6));
loginWindow_->onPurgeSavedLoginRequest.connect(boost::bind(&MainController::handlePurgeSavedLoginRequest, this, _1));
loginWindow_->onCancelLoginRequest.connect(boost::bind(&MainController::handleCancelLoginRequest, this));
loginWindow_->onQuitRequest.connect(boost::bind(&MainController::handleQuitRequest, this));
idleDetector_->setIdleTimeSeconds(settings->getSetting(SettingConstants::IDLE_TIMEOUT));
idleDetector_->onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1));
xmlConsoleController_ = new XMLConsoleController(uiEventStream_, uiFactory_);
fileTransferListController_ = new FileTransferListController(uiEventStream_, uiFactory_);
settings_->onSettingChanged.connect(boost::bind(&MainController::handleSettingChanged, this, _1));
if (loginAutomatically) {
profileSettings_ = new ProfileSettingsProvider(selectedLoginJID, settings_);
- handleLoginRequest(selectedLoginJID, cachedPassword, cachedCertificate, true, true);
+ /* FIXME: deal with autologin with a cert*/
+ handleLoginRequest(selectedLoginJID, cachedPassword, cachedCertificate, CertificateWithKey::ref(), true, true);
} else {
profileSettings_ = NULL;
}
}
MainController::~MainController() {
idleDetector_->onIdleChanged.disconnect(boost::bind(&MainController::handleInputIdleChanged, this, _1));
purgeCachedCredentials();
@@ -410,38 +411,38 @@ void MainController::handleInputIdleChanged(bool idle) {
if (statusTracker_->goAutoUnAway()) {
if (client_ && client_->isAvailable()) {
sendPresence(statusTracker_->getNextPresence());
}
}
}
}
}
-void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificateFile, bool remember, bool loginAutomatically) {
+void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificatePath, CertificateWithKey::ref certificate, bool remember, bool loginAutomatically) {
jid_ = JID(username);
if (!jid_.isValid() || jid_.getNode().empty()) {
loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "User address invalid. User address should be of the form 'alice@wonderland.lit'"));
loginWindow_->setIsLoggingIn(false);
} else {
loginWindow_->setMessage("");
loginWindow_->setIsLoggingIn(true);
profileSettings_ = new ProfileSettingsProvider(username, settings_);
if (!settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) {
profileSettings_->storeString("jid", username);
- profileSettings_->storeString("certificate", certificateFile);
+ profileSettings_->storeString("certificate", certificatePath);
profileSettings_->storeString("pass", (remember || loginAutomatically) ? password : "");
settings_->storeSetting(SettingConstants::LAST_LOGIN_JID, username);
settings_->storeSetting(SettingConstants::LOGIN_AUTOMATICALLY, loginAutomatically);
loginWindow_->addAvailableAccount(profileSettings_->getStringSetting("jid"), profileSettings_->getStringSetting("pass"), profileSettings_->getStringSetting("certificate"));
}
password_ = password;
- certificateFile_ = certificateFile;
+ certificate_ = certificate;
performLoginFromCachedCredentials();
}
}
void MainController::handlePurgeSavedLoginRequest(const std::string& username) {
settings_->removeProfile(username);
loginWindow_->removeAvailableAccount(username);
}
@@ -474,20 +475,20 @@ void MainController::performLoginFromCachedCredentials() {
client_->onConnected.connect(boost::bind(&MainController::handleConnected, this));
client_->setSoftwareVersion(CLIENT_NAME, buildVersion);
client_->getVCardManager()->onVCardChanged.connect(boost::bind(&MainController::handleVCardReceived, this, _1, _2));
presenceNotifier_ = new PresenceNotifier(client_->getStanzaChannel(), notifier_, client_->getMUCRegistry(), client_->getAvatarManager(), client_->getNickResolver(), client_->getPresenceOracle(), networkFactories_->getTimerFactory());
presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
eventNotifier_ = new EventNotifier(eventController_, notifier_, client_->getAvatarManager(), client_->getNickResolver());
eventNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
- if (!certificateFile_.empty()) {
- client_->setCertificate(certificateFile_);
+ if (certificate_ && !certificate_->isNull()) {
+ client_->setCertificate(certificate_);
}
boost::shared_ptr<Presence> presence(new Presence());
presence->setShow(static_cast<StatusShow::Type>(profileSettings_->getIntSetting("lastShow", StatusShow::Online)));
presence->setStatus(profileSettings_->getStringSetting("lastStatus"));
statusTracker_->setRequestedPresence(presence);
} else {
/* In case we're in the middle of another login, make sure they don't overlap */
client_->disconnect();
}
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 45e4ccf..14de4eb 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -85,19 +85,19 @@ namespace Swift {
URIHandler* uriHandler,
IdleDetector* idleDetector,
bool useDelayForLatency);
~MainController();
private:
void resetClient();
void handleConnected();
- void handleLoginRequest(const std::string& username, const std::string& password, const std::string& certificateFile, bool remember, bool loginAutomatically);
+ void handleLoginRequest(const std::string& username, const std::string& password, const std::string& certificatePath, CertificateWithKey::ref certificate, bool remember, bool loginAutomatically);
void handleCancelLoginRequest();
void handleQuitRequest();
void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText);
void handleDisconnected(const boost::optional<ClientError>& error);
void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, ErrorPayload::ref);
void handleEventQueueLengthChange(int count);
void handleVCardReceived(const JID& j, VCard::ref vCard);
void handleSettingChanged(const std::string& settingPath);
void handlePurgeSavedLoginRequest(const std::string& username);
@@ -147,19 +147,19 @@ namespace Swift {
ProfileController* profileController_;
ContactEditController* contactEditController_;
JID jid_;
JID boundJID_;
SystemTrayController* systemTrayController_;
SoundEventController* soundEventController_;
XMPPURIController* xmppURIController_;
std::string vCardPhotoHash_;
std::string password_;
- std::string certificateFile_;
+ CertificateWithKey::ref certificate_;
boost::shared_ptr<ErrorEvent> lastDisconnectError_;
bool useDelayForLatency_;
UserSearchController* userSearchControllerChat_;
UserSearchController* userSearchControllerAdd_;
int timeBeforeNextReconnect_;
Timer::ref reconnectTimer_;
StatusTracker* statusTracker_;
bool myStatusLooksOnline_;
bool quitRequested_;
diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h
index a8ee5a4..bbbbe35 100644
--- a/Swift/Controllers/UIInterfaces/LoginWindow.h
+++ b/Swift/Controllers/UIInterfaces/LoginWindow.h
@@ -1,37 +1,39 @@
/*
- * Copyright (c) 2010 Kevin Smith
+ * Copyright (c) 2010-2012 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
-#include "Swiften/Base/boost_bsignals.h"
+#include <Swiften/Base/boost_bsignals.h>
#include <boost/shared_ptr.hpp>
#include <string>
#include <Swiften/TLS/Certificate.h>
+#include <Swiften/TLS/CertificateWithKey.h>
namespace Swift {
class MainWindow;
class LoginWindow {
public:
virtual ~LoginWindow() {};
virtual void selectUser(const std::string&) = 0;
virtual void morphInto(MainWindow *mainWindow) = 0;
virtual void loggedOut() = 0;
virtual void setShowNotificationToggle(bool) = 0;
virtual void setMessage(const std::string&) = 0;
virtual void setIsLoggingIn(bool loggingIn) = 0;
virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate) = 0;
virtual void removeAvailableAccount(const std::string& jid) = 0;
- boost::signal<void (const std::string&, const std::string&, const std::string& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest;
+ /** The certificate is what is used for login, the certificatePath is used for remembering paths to populate the loginwindow with*/
+ boost::signal<void (const std::string&, const std::string&, const std::string& /*CertificatePath*/, CertificateWithKey::ref /* clientCertificate */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest;
virtual void setLoginAutomatically(bool loginAutomatically) = 0;
virtual void quit() = 0;
/** Blocking request whether a cert should be permanently trusted.*/
virtual bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref) = 0;
boost::signal<void ()> onCancelLoginRequest;
boost::signal<void ()> onQuitRequest;
boost::signal<void (const std::string&)> onPurgeSavedLoginRequest;
};