From 8f55f01251b99d73291d4deb4311a0e0d1e9e06d Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 3 Nov 2015 15:59:35 +0100 Subject: Making virtual calls in constructor of ChatControllers explicit Virtual calls in ctors/dtors are tricky as it is not clear what method is going to be called. By changing the code to call the explicit method it is obvious. This issue was raised by Clang Analyzer. This commit also adds missing SWIFTEN_OVERRIDE annotations. Test-Information: Still compiles, tests pass and Clang Analyzer warning so gone. Change-Id: I8096994277ad32933f992b9a11079c761d3ec619 diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 51c7349..503a050 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -98,7 +98,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ chatWindow_->onUnblockUserRequest.connect(boost::bind(&ChatController::handleUnblockUserRequest, this)); chatWindow_->onInviteToChat.connect(boost::bind(&ChatController::handleInviteToChat, this, _1)); chatWindow_->onClosed.connect(boost::bind(&ChatController::handleWindowClosed, this)); - handleBareJIDCapsChanged(toJID_); + ChatController::handleBareJIDCapsChanged(toJID_); settings_->onSettingChanged.connect(boost::bind(&ChatController::handleSettingChanged, this, _1)); eventStream_->onUIEvent.connect(boost::bind(&ChatController::handleUIEvent, this, _1)); diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index a1f40be..9ee82eb 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -31,35 +32,35 @@ namespace Swift { public: ChatController(const JID& self, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, const JID &contact, NickResolver* nickResolver, PresenceOracle* presenceOracle, AvatarManager* avatarManager, bool isInMUC, bool useDelayForLatency, UIEventStream* eventStream, EventController* eventController, TimerFactory* timerFactory, EntityCapsProvider* entityCapsProvider, bool userWantsReceipts, SettingsProvider* settings, HistoryController* historyController, MUCRegistry* mucRegistry, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, boost::shared_ptr chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider); virtual ~ChatController(); - virtual void setToJID(const JID& jid); - virtual void setAvailableServerFeatures(boost::shared_ptr info); - virtual void setOnline(bool online); + virtual void setToJID(const JID& jid) SWIFTEN_OVERRIDE; + virtual void setAvailableServerFeatures(boost::shared_ptr info) SWIFTEN_OVERRIDE; + virtual void setOnline(bool online) SWIFTEN_OVERRIDE; virtual void handleNewFileTransferController(FileTransferController* ftc); virtual void handleWhiteboardSessionRequest(bool senderIsSelf); virtual void handleWhiteboardStateChange(const ChatWindow::WhiteboardSessionState state); - virtual void setContactIsReceivingPresence(bool /*isReceivingPresence*/); - virtual ChatWindow* detachChatWindow(); + virtual void setContactIsReceivingPresence(bool /*isReceivingPresence*/) SWIFTEN_OVERRIDE; + virtual ChatWindow* detachChatWindow() SWIFTEN_OVERRIDE; protected: - void cancelReplaces(); - JID getBaseJID(); - void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming); + virtual void cancelReplaces() SWIFTEN_OVERRIDE; + virtual JID getBaseJID() SWIFTEN_OVERRIDE; + virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) SWIFTEN_OVERRIDE; private: void handlePresenceChange(boost::shared_ptr newPresence); std::string getStatusChangeString(boost::shared_ptr presence); - bool isIncomingMessageFromMe(boost::shared_ptr message); - void postSendMessage(const std::string &body, boost::shared_ptr sentStanza); - void preHandleIncomingMessage(boost::shared_ptr messageEvent); - void postHandleIncomingMessage(boost::shared_ptr messageEvent, const HighlightAction&); - void preSendMessageRequest(boost::shared_ptr); - std::string senderHighlightNameFromMessage(const JID& from); - std::string senderDisplayNameFromMessage(const JID& from); - virtual boost::optional getMessageTimestamp(boost::shared_ptr) const; + virtual bool isIncomingMessageFromMe(boost::shared_ptr message) SWIFTEN_OVERRIDE; + virtual void postSendMessage(const std::string &body, boost::shared_ptr sentStanza) SWIFTEN_OVERRIDE; + virtual void preHandleIncomingMessage(boost::shared_ptr messageEvent) SWIFTEN_OVERRIDE; + virtual void postHandleIncomingMessage(boost::shared_ptr messageEvent, const HighlightAction&) SWIFTEN_OVERRIDE; + virtual void preSendMessageRequest(boost::shared_ptr) SWIFTEN_OVERRIDE; + virtual std::string senderHighlightNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; + virtual std::string senderDisplayNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; + virtual boost::optional getMessageTimestamp(boost::shared_ptr) const SWIFTEN_OVERRIDE; void handleStanzaAcked(boost::shared_ptr stanza); - void dayTicked() {lastWasPresence_ = false;} + virtual void dayTicked() SWIFTEN_OVERRIDE { lastWasPresence_ = false; } void handleContactNickChanged(const JID& jid, const std::string& /*oldNick*/); - void handleBareJIDCapsChanged(const JID& jid); + virtual void handleBareJIDCapsChanged(const JID& jid) SWIFTEN_OVERRIDE; void handleFileTransferCancel(std::string /* id */); void handleFileTransferStart(std::string /* id */, std::string /* description */); diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 042ed3a..ae0eed2 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -6,39 +6,39 @@ #include -#include #include +#include +#include #include -#include -#include #include #include -#include +#include +#include -#include +#include #include #include +#include +#include #include +#include #include #include #include -#include -#include #include -#include +#include +#include +#include +#include #include -#include #include #include #include #include +#include #include -#include -#include -#include -#include namespace Swift { @@ -49,7 +49,7 @@ ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaCha chatWindow_->onLogCleared.connect(boost::bind(&ChatControllerBase::handleLogCleared, this)); entityCapsProvider_->onCapsChanged.connect(boost::bind(&ChatControllerBase::handleCapsChanged, this, _1)); highlighter_ = highlightManager->createHighlighter(); - setOnline(stanzaChannel->isAvailable() && iqRouter->isAvailable()); + ChatControllerBase::setOnline(stanzaChannel->isAvailable() && iqRouter->isAvailable()); createDayChangeTimer(); } diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index 6c67985..4e68a2b 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -7,32 +7,32 @@ #pragma once #include -#include #include +#include -#include +#include #include #include -#include +#include -#include -#include -#include +#include #include #include -#include -#include #include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include #include +#include #include +#include +#include namespace Swift { class IQRouter; diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 35e79cc..e6c16b7 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -151,12 +151,12 @@ MUCController::MUCController ( chatWindow_->setName(muc->getJID().getNode()); } if (stanzaChannel->isAvailable()) { - setOnline(true); + MUCController::setOnline(true); } if (avatarManager_ != NULL) { avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1))); } - handleBareJIDCapsChanged(muc->getJID()); + MUCController::handleBareJIDCapsChanged(muc->getJID()); eventStream_->onUIEvent.connect(boost::bind(&MUCController::handleUIEvent, this, _1)); diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 36edbdd..a08d541 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -59,8 +60,8 @@ namespace Swift { boost::signal onUserJoined; boost::signal onImpromptuConfigCompleted; boost::signal onUserNicknameChanged; - virtual void setOnline(bool online); - virtual void setAvailableServerFeatures(boost::shared_ptr info); + virtual void setOnline(bool online) SWIFTEN_OVERRIDE; + virtual void setAvailableServerFeatures(boost::shared_ptr info) SWIFTEN_OVERRIDE; void rejoin(); static void appendToJoinParts(std::vector& joinParts, const NickJoinPart& newEvent); static std::string generateJoinPartString(const std::vector& joinParts, bool isImpromptu); @@ -74,16 +75,16 @@ namespace Swift { void sendInvites(const std::vector& jids, const std::string& reason) const; protected: - void preSendMessageRequest(boost::shared_ptr message); - bool isIncomingMessageFromMe(boost::shared_ptr message); - std::string senderHighlightNameFromMessage(const JID& from); - std::string senderDisplayNameFromMessage(const JID& from); - boost::optional getMessageTimestamp(boost::shared_ptr message) const; - virtual void preHandleIncomingMessage(boost::shared_ptr); - virtual void addMessageHandleIncomingMessage(const JID& from, const std::string& message, bool senderIsSelf, boost::shared_ptr label, const boost::posix_time::ptime& time, const HighlightAction& highlight); - virtual void postHandleIncomingMessage(boost::shared_ptr, const HighlightAction&); - void cancelReplaces(); - void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming); + virtual void preSendMessageRequest(boost::shared_ptr message) SWIFTEN_OVERRIDE; + virtual bool isIncomingMessageFromMe(boost::shared_ptr message) SWIFTEN_OVERRIDE; + virtual std::string senderHighlightNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; + virtual std::string senderDisplayNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; + virtual boost::optional getMessageTimestamp(boost::shared_ptr message) const SWIFTEN_OVERRIDE; + virtual void preHandleIncomingMessage(boost::shared_ptr) SWIFTEN_OVERRIDE; + virtual void addMessageHandleIncomingMessage(const JID& from, const std::string& message, bool senderIsSelf, boost::shared_ptr label, const boost::posix_time::ptime& time, const HighlightAction& highlight) SWIFTEN_OVERRIDE; + virtual void postHandleIncomingMessage(boost::shared_ptr, const HighlightAction&) SWIFTEN_OVERRIDE; + virtual void cancelReplaces() SWIFTEN_OVERRIDE; + virtual void logMessage(const std::string& message, const JID& fromJID, const JID& toJID, const boost::posix_time::ptime& timeStamp, bool isIncoming) SWIFTEN_OVERRIDE; private: void setAvailableRoomActions(const MUCOccupant::Affiliation& affiliation, const MUCOccupant::Role& role); @@ -112,9 +113,9 @@ namespace Swift { bool messageTargetsMe(boost::shared_ptr message); void updateJoinParts(); bool shouldUpdateJoinParts(); - void dayTicked() {clearPresenceQueue();} + virtual void dayTicked() SWIFTEN_OVERRIDE { clearPresenceQueue(); } void processUserPart(); - void handleBareJIDCapsChanged(const JID& jid); + virtual void handleBareJIDCapsChanged(const JID& jid) SWIFTEN_OVERRIDE; void handleConfigureRequest(Form::ref); void handleConfigurationFailed(ErrorPayload::ref); void handleConfigurationFormReceived(Form::ref); diff --git a/Swift/Controllers/XMPPEvents/MUCInviteEvent.h b/Swift/Controllers/XMPPEvents/MUCInviteEvent.h index 65ecece..1ae9891 100644 --- a/Swift/Controllers/XMPPEvents/MUCInviteEvent.h +++ b/Swift/Controllers/XMPPEvents/MUCInviteEvent.h @@ -4,8 +4,22 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once +#include + +#include + +#include + +#include + namespace Swift { class MUCInviteEvent : public StanzaEvent { -- cgit v0.10.2-6-g49f6