diff options
author | Tobias Markmann <tm@ayena.de> | 2015-11-03 14:59:35 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-11-06 13:43:05 (GMT) |
commit | 8f55f01251b99d73291d4deb4311a0e0d1e9e06d (patch) | |
tree | 768917680b19f898dc8333824c86410b2ebb7180 /Swift | |
parent | d3d767ba12d88fcb8d16b9a70f95781bacb19bfc (diff) | |
download | swift-8f55f01251b99d73291d4deb4311a0e0d1e9e06d.zip swift-8f55f01251b99d73291d4deb4311a0e0d1e9e06d.tar.bz2 |
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
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatController.h | 37 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 28 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.h | 26 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 4 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 29 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/MUCInviteEvent.h | 14 |
7 files changed, 78 insertions, 62 deletions
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 <map> #include <string> +#include <Swiften/Base/Override.h> #include <Swiften/Base/Tristate.h> #include <Swift/Controllers/Chat/ChatControllerBase.h> @@ -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> chatMessageParser, AutoAcceptMUCInviteDecider* autoAcceptMUCInviteDecider); virtual ~ChatController(); - virtual void setToJID(const JID& jid); - virtual void setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info); - virtual void setOnline(bool online); + virtual void setToJID(const JID& jid) SWIFTEN_OVERRIDE; + virtual void setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> 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<Presence> newPresence); std::string getStatusChangeString(boost::shared_ptr<Presence> presence); - bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - void postSendMessage(const std::string &body, boost::shared_ptr<Stanza> sentStanza); - void preHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent); - void postHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent, const HighlightAction&); - void preSendMessageRequest(boost::shared_ptr<Message>); - std::string senderHighlightNameFromMessage(const JID& from); - std::string senderDisplayNameFromMessage(const JID& from); - virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message>) const; + virtual bool isIncomingMessageFromMe(boost::shared_ptr<Message> message) SWIFTEN_OVERRIDE; + virtual void postSendMessage(const std::string &body, boost::shared_ptr<Stanza> sentStanza) SWIFTEN_OVERRIDE; + virtual void preHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent) SWIFTEN_OVERRIDE; + virtual void postHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent, const HighlightAction&) SWIFTEN_OVERRIDE; + virtual void preSendMessageRequest(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<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message>) const SWIFTEN_OVERRIDE; void handleStanzaAcked(boost::shared_ptr<Stanza> 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 <Swift/Controllers/Chat/ChatControllerBase.h> -#include <sstream> #include <map> +#include <sstream> +#include <boost/algorithm/string.hpp> #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/numeric/conversion/cast.hpp> -#include <boost/algorithm/string.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/smart_ptr/make_shared.hpp> -#include <Swiften/Base/format.h> +#include <Swiften/Avatars/AvatarManager.h> #include <Swiften/Base/Path.h> #include <Swiften/Base/String.h> +#include <Swiften/Base/foreach.h> +#include <Swiften/Base/format.h> #include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Disco/EntityCapsProvider.h> #include <Swiften/Elements/Delay.h> #include <Swiften/Elements/MUCInvitationPayload.h> #include <Swiften/Elements/MUCUserPayload.h> -#include <Swiften/Base/foreach.h> -#include <Swiften/Disco/EntityCapsProvider.h> #include <Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h> -#include <Swiften/Avatars/AvatarManager.h> +#include <Swift/Controllers/Chat/AutoAcceptMUCInviteDecider.h> +#include <Swift/Controllers/Chat/ChatMessageParser.h> +#include <Swift/Controllers/HighlightManager.h> +#include <Swift/Controllers/Highlighter.h> #include <Swift/Controllers/Intl.h> -#include <Swift/Controllers/XMPPEvents/EventController.h> #include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/ChatWindow.h> #include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h> +#include <Swift/Controllers/XMPPEvents/EventController.h> #include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> -#include <Swift/Controllers/HighlightManager.h> -#include <Swift/Controllers/Highlighter.h> -#include <Swift/Controllers/Chat/AutoAcceptMUCInviteDecider.h> -#include <Swift/Controllers/Chat/ChatMessageParser.h> 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 <map> -#include <vector> #include <string> +#include <vector> -#include <boost/shared_ptr.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/filesystem/path.hpp> #include <boost/optional.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/shared_ptr.hpp> -#include <Swiften/Network/Timer.h> -#include <Swiften/Network/TimerFactory.h> -#include <Swiften/Elements/Stanza.h> +#include <Swiften/Base/IDGenerator.h> #include <Swiften/Base/boost_bsignals.h> #include <Swiften/Elements/DiscoInfo.h> -#include <Swiften/JID/JID.h> -#include <Swiften/Elements/SecurityLabelsCatalog.h> #include <Swiften/Elements/ErrorPayload.h> +#include <Swiften/Elements/SecurityLabelsCatalog.h> +#include <Swiften/Elements/Stanza.h> +#include <Swiften/JID/JID.h> +#include <Swiften/MUC/MUCRegistry.h> +#include <Swiften/Network/Timer.h> +#include <Swiften/Network/TimerFactory.h> #include <Swiften/Presence/PresenceOracle.h> #include <Swiften/Queries/IQRouter.h> -#include <Swiften/Base/IDGenerator.h> -#include <Swiften/MUC/MUCRegistry.h> -#include <Swift/Controllers/XMPPEvents/MessageEvent.h> -#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> -#include <Swift/Controllers/HistoryController.h> #include <Swift/Controllers/HighlightManager.h> +#include <Swift/Controllers/HistoryController.h> #include <Swift/Controllers/UIInterfaces/ChatWindow.h> +#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> +#include <Swift/Controllers/XMPPEvents/MessageEvent.h> 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 <boost/shared_ptr.hpp> #include <boost/signals/connection.hpp> +#include <Swiften/Base/Override.h> #include <Swiften/Base/boost_bsignals.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/MUCOccupant.h> @@ -59,8 +60,8 @@ namespace Swift { boost::signal<void ()> onUserJoined; boost::signal<void ()> onImpromptuConfigCompleted; boost::signal<void (const std::string&, const std::string& )> onUserNicknameChanged; - virtual void setOnline(bool online); - virtual void setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info); + virtual void setOnline(bool online) SWIFTEN_OVERRIDE; + virtual void setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info) SWIFTEN_OVERRIDE; void rejoin(); static void appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent); static std::string generateJoinPartString(const std::vector<NickJoinPart>& joinParts, bool isImpromptu); @@ -74,16 +75,16 @@ namespace Swift { void sendInvites(const std::vector<JID>& jids, const std::string& reason) const; protected: - void preSendMessageRequest(boost::shared_ptr<Message> message); - bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - std::string senderHighlightNameFromMessage(const JID& from); - std::string senderDisplayNameFromMessage(const JID& from); - boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message> message) const; - virtual void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>); - virtual void addMessageHandleIncomingMessage(const JID& from, const std::string& message, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& time, const HighlightAction& highlight); - virtual void postHandleIncomingMessage(boost::shared_ptr<MessageEvent>, 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> message) SWIFTEN_OVERRIDE; + virtual bool isIncomingMessageFromMe(boost::shared_ptr<Message> message) SWIFTEN_OVERRIDE; + virtual std::string senderHighlightNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; + virtual std::string senderDisplayNameFromMessage(const JID& from) SWIFTEN_OVERRIDE; + virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message> message) const SWIFTEN_OVERRIDE; + virtual void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>) SWIFTEN_OVERRIDE; + virtual void addMessageHandleIncomingMessage(const JID& from, const std::string& message, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const boost::posix_time::ptime& time, const HighlightAction& highlight) SWIFTEN_OVERRIDE; + virtual void postHandleIncomingMessage(boost::shared_ptr<MessageEvent>, 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> 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 <string> + +#include <boost/shared_ptr.hpp> + +#include <Swiften/JID/JID.h> + +#include <Swift/Controllers/XMPPEvents/StanzaEvent.h> + namespace Swift { class MUCInviteEvent : public StanzaEvent { |