diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-03-04 10:56:07 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-03-04 10:58:16 (GMT) |
commit | 37bfeaf6f2e0145731c32f79291ff3d48ae0e1b1 (patch) | |
tree | e6455b4f21b3a5ba716526916a67cfd4b7e55051 /Swift/QtUI | |
parent | 12024229138787d7df91cb8101d0986996880e3d (diff) | |
download | swift-contrib-37bfeaf6f2e0145731c32f79291ff3d48ae0e1b1.zip swift-contrib-37bfeaf6f2e0145731c32f79291ff3d48ae0e1b1.tar.bz2 |
Upgrade XEP-0258 support to match 0.6.
Resolves: #183
Release-Notes: Security labels (XEP-0258) support has been updated to match the latest version of the specification.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 12 |
2 files changed, 20 insertions, 13 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index f056a1d..998912a 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -151,15 +151,22 @@ void QtChatWindow::setRosterModel(Roster* roster) { treeWidget_->setRosterModel(roster); } -void QtChatWindow::setAvailableSecurityLabels(const std::vector<SecurityLabel>& labels) { +void QtChatWindow::setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels) { availableLabels_ = labels; labelsWidget_->clear(); int i = 0; - foreach (SecurityLabel label, labels) { - QString labelName = P2QSTRING(label.getDisplayMarking()); + int defaultIndex = 0; + foreach (SecurityLabelsCatalog::Item label, labels) { + std::string selector = label.getSelector(); + std::string displayMarking = label.getLabel() ? label.getLabel()->getDisplayMarking() : ""; + QString labelName = selector.empty() ? displayMarking.c_str() : selector.c_str(); labelsWidget_->addItem(labelName, QVariant(i)); + if (label.getIsDefault()) { + defaultIndex = i; + } i++; } + labelsWidget_->setCurrentIndex(defaultIndex); } @@ -176,7 +183,7 @@ void QtChatWindow::setSecurityLabelsEnabled(bool enabled) { } } -SecurityLabel QtChatWindow::getSelectedSecurityLabel() { +SecurityLabelsCatalog::Item QtChatWindow::getSelectedSecurityLabel() { assert(labelsWidget_->isEnabled()); return availableLabels_[labelsWidget_->currentIndex()]; } @@ -248,11 +255,11 @@ void QtChatWindow::updateTitleWithUnreadCount() { emit titleUpdated(); } -std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) { return addMessage(message, senderName, senderIsSelf, label, avatarPath, "", time); } -std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -299,7 +306,7 @@ int QtChatWindow::getCount() { return unreadCount_; } -std::string QtChatWindow::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) { return addMessage(" *" + message + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time); } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index dbcfe9c..910019b 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -30,8 +30,8 @@ namespace Swift { public: QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream); ~QtChatWindow(); - std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time); - std::string addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time); + std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time); + std::string addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time); void addSystemMessage(const std::string& message); void addPresenceMessage(const std::string& message); void addErrorMessage(const std::string& errorMessage); @@ -40,10 +40,10 @@ namespace Swift { void setUnreadMessageCount(int count); void convertToMUC(); // TreeWidget *getTreeWidget(); - void setAvailableSecurityLabels(const std::vector<SecurityLabel>& labels); + void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels); void setSecurityLabelsEnabled(bool enabled); void setSecurityLabelsError(); - SecurityLabel getSelectedSecurityLabel(); + SecurityLabelsCatalog::Item getSelectedSecurityLabel(); void setName(const std::string& name); void setInputEnabled(bool enabled); QtTabbable::AlertType getWidgetAlertState(); @@ -75,7 +75,7 @@ namespace Swift { private: void updateTitleWithUnreadCount(); void tabComplete(); - std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time); + std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time); int unreadCount_; bool contactIsTyping_; @@ -86,7 +86,7 @@ namespace Swift { QComboBox* labelsWidget_; QtTreeWidget* treeWidget_; TabComplete* completer_; - std::vector<SecurityLabel> availableLabels_; + std::vector<SecurityLabelsCatalog::Item> availableLabels_; bool previousMessageWasSelf_; bool previousMessageWasSystem_; bool previousMessageWasPresence_; |