summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2013-06-01 08:26:46 (GMT)
committerKevin Smith <git@kismith.co.uk>2013-08-01 09:22:45 (GMT)
commitdb698bbb6d8c7e878e2cb997e18e572f3646e11d (patch)
tree61aa3ff72c64dd8f309a2fe4b31b5b2d3f22f04b /Swift/Controllers/Chat/MUCController.cpp
parentb45602bcd36fb9d2e7a22998434e31014f072d33 (diff)
downloadswift-db698bbb6d8c7e878e2cb997e18e572f3646e11d.zip
swift-db698bbb6d8c7e878e2cb997e18e572f3646e11d.tar.bz2
Refactor chat messages so parsing of links/emoticons happens in controllers.
Change-Id: I07256f23ffbb6520f5063bdfbed9111946c46746
Diffstat (limited to 'Swift/Controllers/Chat/MUCController.cpp')
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 6bf3e5f..0033297 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Kevin Smith
+ * Copyright (c) 2010-2013 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -64,8 +64,9 @@ MUCController::MUCController (
XMPPRoster* roster,
HistoryController* historyController,
MUCRegistry* mucRegistry,
- HighlightManager* highlightManager) :
- ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc->getJID(), presenceOracle, avatarManager, useDelayForLatency, uiEventStream, eventController, timerFactory, entityCapsProvider, historyController, mucRegistry, highlightManager), muc_(muc), nick_(nick), desiredNick_(nick), password_(password), renameCounter_(0) {
+ HighlightManager* highlightManager,
+ std::map<std::string, std::string>* emoticons) :
+ ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc->getJID(), presenceOracle, avatarManager, useDelayForLatency, uiEventStream, eventController, timerFactory, entityCapsProvider, historyController, mucRegistry, highlightManager, emoticons), muc_(muc), nick_(nick), desiredNick_(nick), password_(password), renameCounter_(0) {
parting_ = true;
joined_ = false;
lastWasPresence_ = false;
@@ -226,7 +227,7 @@ const std::string& MUCController::getNick() {
void MUCController::handleJoinTimeoutTick() {
receivedActivity();
- chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "Room %1% is not responding. This operation may never complete.")) % toJID_.toString()), ChatWindow::DefaultDirection);
+ chatWindow_->addSystemMessage(parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "Room %1% is not responding. This operation may never complete.")) % toJID_.toString())), ChatWindow::DefaultDirection);
}
void MUCController::receivedActivity() {
@@ -277,7 +278,7 @@ void MUCController::handleJoinFailed(boost::shared_ptr<ErrorPayload> error) {
}
}
errorMessage = str(format(QT_TRANSLATE_NOOP("", "Couldn't join room: %1%.")) % errorMessage);
- chatWindow_->addErrorMessage(errorMessage);
+ chatWindow_->addErrorMessage(parseMessageBody(errorMessage));
parting_ = true;
if (!rejoinNick.empty() && renameCounter_ < 10) {
renameCounter_++;
@@ -294,7 +295,7 @@ void MUCController::handleJoinComplete(const std::string& nick) {
joined_ = true;
std::string joinMessage = str(format(QT_TRANSLATE_NOOP("", "You have entered room %1% as %2%.")) % toJID_.toString() % nick);
setNick(nick);
- chatWindow_->addSystemMessage(joinMessage, ChatWindow::DefaultDirection);
+ chatWindow_->addSystemMessage(parseMessageBody(joinMessage), ChatWindow::DefaultDirection);
#ifdef SWIFT_EXPERIMENTAL_HISTORY
addRecentLogs();
@@ -360,7 +361,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) {
void MUCController::addPresenceMessage(const std::string& message) {
lastWasPresence_ = true;
- chatWindow_->addPresenceMessage(message, ChatWindow::DefaultDirection);
+ chatWindow_->addPresenceMessage(parseMessageBody(message), ChatWindow::DefaultDirection);
}
@@ -447,7 +448,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes
joined_ = true;
if (message->hasSubject() && message->getBody().empty()) {
- chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject()), ChatWindow::DefaultDirection);;
+ chatWindow_->addSystemMessage(parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "The room subject is now: %1%")) % message->getSubject())), ChatWindow::DefaultDirection);;
chatWindow_->setSubject(message->getSubject());
doneGettingHistory_ = true;
}
@@ -484,7 +485,7 @@ void MUCController::handleOccupantRoleChanged(const std::string& nick, const MUC
std::string group(roleToGroupName(occupant.getRole()));
roster_->addContact(jid, realJID, nick, group, avatarManager_->getAvatarPath(jid));
roster_->getGroup(group)->setManualSort(roleToSortName(occupant.getRole()));
- chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "%1% is now a %2%")) % nick % roleToFriendlyName(occupant.getRole())), ChatWindow::DefaultDirection);
+ chatWindow_->addSystemMessage(parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "%1% is now a %2%")) % nick % roleToFriendlyName(occupant.getRole()))), ChatWindow::DefaultDirection);
if (nick == nick_) {
setAvailableRoomActions(occupant.getAffiliation(), occupant.getRole());
}
@@ -517,7 +518,7 @@ void MUCController::setOnline(bool online) {
} else {
if (shouldJoinOnReconnect_) {
renameCounter_ = 0;
- chatWindow_->addSystemMessage(str(format(QT_TRANSLATE_NOOP("", "Trying to enter room %1%")) % toJID_.toString()), ChatWindow::DefaultDirection);
+ chatWindow_->addSystemMessage(parseMessageBody(str(format(QT_TRANSLATE_NOOP("", "Trying to enter room %1%")) % toJID_.toString())), ChatWindow::DefaultDirection);
if (loginCheckTimer_) {
loginCheckTimer_->start();
}
@@ -615,7 +616,7 @@ boost::optional<boost::posix_time::ptime> MUCController::getMessageTimestamp(boo
}
void MUCController::updateJoinParts() {
- chatWindow_->replaceLastMessage(generateJoinPartString(joinParts_));
+ chatWindow_->replaceLastMessage(parseMessageBody(generateJoinPartString(joinParts_)));
}
void MUCController::appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent) {
@@ -735,13 +736,13 @@ void MUCController::handleConfigureRequest(Form::ref form) {
void MUCController::handleConfigurationFailed(ErrorPayload::ref error) {
std::string errorMessage = getErrorMessage(error);
errorMessage = str(format(QT_TRANSLATE_NOOP("", "Room configuration failed: %1%.")) % errorMessage);
- chatWindow_->addErrorMessage(errorMessage);
+ chatWindow_->addErrorMessage(parseMessageBody(errorMessage));
}
void MUCController::handleOccupantRoleChangeFailed(ErrorPayload::ref error, const JID&, MUCOccupant::Role) {
std::string errorMessage = getErrorMessage(error);
errorMessage = str(format(QT_TRANSLATE_NOOP("", "Occupant role change failed: %1%.")) % errorMessage);
- chatWindow_->addErrorMessage(errorMessage);
+ chatWindow_->addErrorMessage(parseMessageBody(errorMessage));
}
void MUCController::handleConfigurationFormReceived(Form::ref form) {