summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-06-24 16:09:00 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-06-24 16:09:04 (GMT)
commit59c3d7532b7768c6ab0c8cf6f4c587206c080c14 (patch)
tree490a46d3ff8852b781644475c4762d1c3f697b41 /Swift/Controllers
parentc779e07f6d1d23cc157ab3823a00edd95f70ab3b (diff)
downloadswift-contrib-59c3d7532b7768c6ab0c8cf6f4c587206c080c14.zip
swift-contrib-59c3d7532b7768c6ab0c8cf6f4c587206c080c14.tar.bz2
Fix VCard update not being broadcast when clearing avatar.
Test-Information: Connect two clients, set and clear the avatar from one of the clients, check that the second client receives a presence update with the correct hash and that the contacts avatar is updated in the roster and any open chat windows. Change-Id: I96ad8a9cfaa618aa07acf1cb4452855435ba1179
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 45a0df7..df137f4 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -436,73 +436,71 @@ void MainController::reconnectAfterError() {
}
void MainController::handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText) {
boost::shared_ptr<Presence> presence(new Presence());
if (show == StatusShow::None) {
// Note: this is misleading, None doesn't mean unavailable on the wire.
presence->setType(Presence::Unavailable);
resetPendingReconnects();
myStatusLooksOnline_ = false;
offlineRequested_ = true;
}
else {
offlineRequested_ = false;
presence->setShow(show);
}
presence->setStatus(statusText);
statusTracker_->setRequestedPresence(presence);
if (presence->getType() != Presence::Unavailable) {
profileSettings_->storeInt("lastShow", presence->getShow());
profileSettings_->storeString("lastStatus", presence->getStatus());
}
if (presence->getType() != Presence::Unavailable && !client_->isAvailable()) {
performLoginFromCachedCredentials();
} else {
sendPresence(presence);
}
}
void MainController::sendPresence(boost::shared_ptr<Presence> presence) {
rosterController_->getWindow()->setMyStatusType(presence->getShow());
rosterController_->getWindow()->setMyStatusText(presence->getStatus());
systemTrayController_->setMyStatusType(presence->getShow());
notifier_->setTemporarilyDisabled(presence->getShow() == StatusShow::DND);
// Add information and send
- if (!vCardPhotoHash_.empty()) {
- presence->updatePayload(boost::make_shared<VCardUpdate>(vCardPhotoHash_));
- }
+ presence->updatePayload(boost::make_shared<VCardUpdate>(vCardPhotoHash_));
client_->getPresenceSender()->sendPresence(presence);
if (presence->getType() == Presence::Unavailable) {
logout();
}
}
void MainController::handleInputIdleChanged(bool idle) {
if (!statusTracker_) {
//Haven't logged in yet.
return;
}
if (settings_->getSetting(SettingConstants::IDLE_GOES_OFFLINE)) {
if (idle) {
logout();
}
}
else {
if (idle) {
if (statusTracker_->goAutoAway(idleDetector_->getIdleTimeSeconds())) {
if (client_ && client_->isAvailable()) {
sendPresence(statusTracker_->getNextPresence());
}
}
} else {
if (statusTracker_->goAutoUnAway()) {
if (client_ && client_->isAvailable()) {
sendPresence(statusTracker_->getNextPresence());
}
}
}
}
}
void MainController::handleShowCertificateRequest() {
@@ -736,74 +734,77 @@ void MainController::logout() {
if (rosterController_ && myStatusLooksOnline_) {
rosterController_->getWindow()->setMyStatusType(StatusShow::None);
rosterController_->getWindow()->setMyStatusText("");
myStatusLooksOnline_ = false;
}
setManagersOffline();
}
void MainController::setManagersOffline() {
if (chatsManager_) {
chatsManager_->setOnline(false);
}
if (rosterController_) {
rosterController_->setEnabled(false);
}
if (profileController_) {
profileController_->setAvailable(false);
}
if (contactEditController_) {
contactEditController_->setAvailable(false);
}
}
void MainController::handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> info, ErrorPayload::ref error) {
if (!error) {
chatsManager_->setServerDiscoInfo(info);
adHocManager_->setServerDiscoInfo(info);
if (info->hasFeature(DiscoInfo::BlockingCommandFeature)) {
rosterController_->getWindow()->setBlockingCommandAvailable(true);
rosterController_->initBlockingCommand();
}
}
}
void MainController::handleVCardReceived(const JID& jid, VCard::ref vCard) {
- if (!jid.equals(jid_, JID::WithoutResource) || !vCard || vCard->getPhoto().empty()) {
+ if (!jid.equals(jid_, JID::WithoutResource) || !vCard) {
return;
}
- std::string hash = Hexify::hexify(networkFactories_->getCryptoProvider()->getSHA1Hash(vCard->getPhoto()));
+ std::string hash;
+ if (!vCard->getPhoto().empty()) {
+ hash = Hexify::hexify(networkFactories_->getCryptoProvider()->getSHA1Hash(vCard->getPhoto()));
+ }
if (hash != vCardPhotoHash_) {
vCardPhotoHash_ = hash;
if (client_ && client_->isAvailable()) {
sendPresence(statusTracker_->getNextPresence());
}
}
}
void MainController::handleNotificationClicked(const JID& jid) {
assert(chatsManager_);
if (clientInitialized_) {
if (client_->getMUCRegistry()->isMUC(jid)) {
uiEventStream_->send(boost::make_shared<JoinMUCUIEvent>(jid));
}
else {
uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(jid)));
}
}
}
void MainController::handleQuitRequest() {
if (client_ && client_->isActive()) {
quitRequested_ = true;
client_->disconnect();
}
else {
resetClient();
loginWindow_->quit();
}
}
#define SERIALIZE_BOOL(option) result += options.option ? "1" : "0"; result += ",";
#define SERIALIZE_INT(option) result += boost::lexical_cast<std::string>(options.option); result += ",";
#define SERIALIZE_STRING(option) result += Base64::encode(createByteArray(options.option)); result += ",";
#define SERIALIZE_SAFE_STRING(option) result += safeByteArrayToString(Base64::encode(options.option)); result += ",";