summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-05 11:11:29 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-05 11:11:29 (GMT)
commit8159071adb232b68c2ce79479145fbcd04979245 (patch)
tree9282fc76499719c18fa9c9e892535d2f46030b43 /Swift/Controllers/Chat/ChatControllerBase.cpp
parent4c942cbb0b76383bfad10b3677a75a52f9193cf7 (diff)
downloadswift-contrib-8159071adb232b68c2ce79479145fbcd04979245.zip
swift-contrib-8159071adb232b68c2ce79479145fbcd04979245.tar.bz2
Don't crash with label item without a label
Diffstat (limited to 'Swift/Controllers/Chat/ChatControllerBase.cpp')
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index 4bcb4c7..ecb9288 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -72,24 +72,21 @@ void ChatControllerBase::setEnabled(bool enabled) {
chatWindow_->setInputEnabled(enabled);
}
void ChatControllerBase::setOnline(bool online) {
setEnabled(online);
}
void ChatControllerBase::setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info) {
if (iqRouter_->isAvailable() && info->hasFeature(DiscoInfo::SecurityLabelsCatalogFeature)) {
- //chatWindow_->setSecurityLabelsEnabled(true);
- //chatWindow_->setSecurityLabelsError();
GetSecurityLabelsCatalogRequest::ref request = GetSecurityLabelsCatalogRequest::create(JID(toJID_.toBare()), iqRouter_);
request->onResponse.connect(boost::bind(&ChatControllerBase::handleSecurityLabelsCatalogResponse, this, _1, _2));
request->send();
- //labelsEnabled_ = true;
} else {
chatWindow_->setSecurityLabelsEnabled(false);
labelsEnabled_ = false;
}
}
void ChatControllerBase::handleAllMessagesRead() {
if (!unreadMessages_.empty()) {
foreach (boost::shared_ptr<MessageEvent> messageEvent, unreadMessages_) {
@@ -108,19 +105,22 @@ int ChatControllerBase::getUnreadCount() {
void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool isCorrectionMessage) {
if (!stanzaChannel_->isAvailable() || body.empty()) {
return;
}
boost::shared_ptr<Message> message(new Message());
message->setTo(toJID_);
message->setType(Swift::Message::Chat);
message->setBody(body);
if (labelsEnabled_) {
- message->addPayload(chatWindow_->getSelectedSecurityLabel().getLabel());
+ SecurityLabelsCatalog::Item labelItem = chatWindow_->getSelectedSecurityLabel();
+ if (labelItem.getLabel()) {
+ message->addPayload(labelItem.getLabel());
+ }
}
preSendMessageRequest(message);
if (useDelayForLatency_) {
boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
message->addPayload(boost::shared_ptr<Delay>(new Delay(now, selfJID_)));
}
if (isCorrectionMessage) {
message->addPayload(boost::shared_ptr<Replace> (new Replace(lastSentMessageStanzaID_)));
}