diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-06-13 15:33:13 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-06-13 16:57:09 (GMT) |
commit | 790134ceb34ab6047fe204517d263f343dbeb920 (patch) | |
tree | d8002133de67108f380248a0ec7d063c8f1956b7 | |
parent | a03cedb3942e4c7c90e62fe9a73c6d15e38fbb68 (diff) | |
download | swift-contrib-790134ceb34ab6047fe204517d263f343dbeb920.zip swift-contrib-790134ceb34ab6047fe204517d263f343dbeb920.tar.bz2 |
Added CppCheck script.
Tweaked the sources to satisfy cppcheck.
55 files changed, 102 insertions, 406 deletions
@@ -38,3 +38,4 @@ Swift/QtUI/swift Swift/QtUI/DefaultTheme.qrc checker-report.xml VERSION.* +cppcheck.log diff --git a/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp b/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp index 82cc902..ccd5925 100644 --- a/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp +++ b/BuildTools/CLang/CLangDiagnosticsFlagsTool.cpp @@ -54,7 +54,7 @@ static const size_t diagnostics_count = sizeof(diagnostics) / sizeof(diagnostics using namespace boost; struct Properties { - Properties() : missing(false), redundant(false) { + Properties() : have(false), implicitHave(false), dontWant(false), implicitDontWant(false), ignored(false), available(false), missing(false), redundant(false), alreadyCovered(false) { } std::string name; diff --git a/BuildTools/Cppcheck.sh b/BuildTools/Cppcheck.sh new file mode 100755 index 0000000..93b5d13 --- /dev/null +++ b/BuildTools/Cppcheck.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +cppcheck $@ \ + --enable=all \ + -i 3rdParty -i .git -i .sconf_temp \ + -i 3rdParty/hippomocks.h \ + -i Swiftob/linit.cpp \ + -i Swift/QtUI/EventViewer/main.cpp \ + -i Swift/QtUI/ApplicationTest \ + -i Swift/QtUI/ChatView/main.cpp \ + -i Swift/QtUI/Roster/main.cpp \ + -i Swift/QtUI/NotifierTest/NotifierTest.cpp \ + \ + -I . \ + -I Swift/QtUI \ + . 2> cppcheck.tmp +cat cppcheck.tmp | grep -v "(style)" | grep -v "\[3rdParty/hippomocks.h" > cppcheck.log +rm cppcheck.tmp + +echo "Result (cppcheck.log):" +cat cppcheck.log diff --git a/Slimber/Qt/main.cpp b/Slimber/Qt/main.cpp index 9885aec..517a253 100644 --- a/Slimber/Qt/main.cpp +++ b/Slimber/Qt/main.cpp @@ -12,7 +12,7 @@ #include "QtMenulet.h" #include "Slimber/MainController.h" #include <Swiften/EventLoop/Qt/QtEventLoop.h> -#include "Slimber/Qt/BuildVersion.h" +#include <Slimber/Qt/BuildVersion.h> int main(int argc, char* argv[]) { QApplication app(argc, argv); diff --git a/Sluift/linit.c b/Sluift/linit.c index bb5d985..73f0522 100644 --- a/Sluift/linit.c +++ b/Sluift/linit.c @@ -1,6 +1,6 @@ -#include "lua.h" -#include "lualib.h" -#include "lauxlib.h" +#include <lua.h> +#include <lualib.h> +#include <lauxlib.h> #include "sluift.h" // A built-in table print function diff --git a/Sluift/sluift.h b/Sluift/sluift.h index f28862e..27b4eab 100644 --- a/Sluift/sluift.h +++ b/Sluift/sluift.h @@ -12,6 +12,6 @@ #define SLUIFT_API extern #endif -#include "lua.h" +#include <lua.h> SLUIFT_API int (luaopen_sluift)(lua_State *L); diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp index 15fd9a5..2ca284d 100644 --- a/SwifTools/Linkify.cpp +++ b/SwifTools/Linkify.cpp @@ -42,7 +42,7 @@ std::string Linkify::linkify(const std::string& input) { } } } - if (currentURL.size() > 0) { + if (!currentURL.empty()) { std::string url(¤tURL[0], currentURL.size()); result << "<a href=\"" << url << "\">" << url << "</a>"; } diff --git a/SwifTools/Notifier/GrowlNotifier.cpp b/SwifTools/Notifier/GrowlNotifier.cpp index c9397f1..d83634d 100644 --- a/SwifTools/Notifier/GrowlNotifier.cpp +++ b/SwifTools/Notifier/GrowlNotifier.cpp @@ -18,7 +18,7 @@ namespace { struct Context { - Context() {} + Context() : callback(0) {} Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {} boost::function<void()>* callback; diff --git a/SwifTools/Notifier/SnarlNotifier.h b/SwifTools/Notifier/SnarlNotifier.h index 065c9ec..c96dfa6 100644 --- a/SwifTools/Notifier/SnarlNotifier.h +++ b/SwifTools/Notifier/SnarlNotifier.h @@ -9,7 +9,7 @@ #include <map> #include <SwifTools/Notifier/Notifier.h> -#include "SnarlInterface.h" +#include <SnarlInterface.h> namespace Swift { class Win32NotifierWindow; diff --git a/SwifTools/TabComplete.cpp b/SwifTools/TabComplete.cpp index 4c295ab..f4ef837 100644 --- a/SwifTools/TabComplete.cpp +++ b/SwifTools/TabComplete.cpp @@ -28,7 +28,7 @@ void TabComplete::removeWord(const std::string& word) { std::string TabComplete::completeWord(const std::string& word) { if (word == lastCompletion_) { - if (lastCompletionCandidates_.size() != 0) { + if (!lastCompletionCandidates_.empty()) { size_t match = 0; for (match = 0; match < lastCompletionCandidates_.size(); match++) { if (lastCompletionCandidates_[match] == lastCompletion_) { @@ -47,7 +47,7 @@ std::string TabComplete::completeWord(const std::string& word) { lastCompletionCandidates_.push_back(candidate); } } - lastCompletion_ = lastCompletionCandidates_.size() > 0 ? lastCompletionCandidates_[0] : word; + lastCompletion_ = !lastCompletionCandidates_.empty() ? lastCompletionCandidates_[0] : word; } return lastCompletion_; } diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index a735ed9..513b446 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -143,7 +143,7 @@ void ChatController::handleStanzaAcked(boost::shared_ptr<Stanza> stanza) { void ChatController::setOnline(bool online) { if (!online) { std::map<boost::shared_ptr<Stanza>, std::string>::iterator it = unackedStanzas_.begin(); - for ( ; it != unackedStanzas_.end(); it++) { + for ( ; it != unackedStanzas_.end(); ++it) { chatWindow_->setAckState(it->second, ChatWindow::Failed); } unackedStanzas_.clear(); diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 0af1a81..ef85107 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -188,7 +188,7 @@ void ChatsManager::prependRecent(const ChatListWindow::Chat& chat) { void ChatsManager::handleUserLeftMUC(MUCController* mucController) { std::map<JID, MUCController*>::iterator it; - for (it = mucControllers_.begin(); it != mucControllers_.end(); it++) { + for (it = mucControllers_.begin(); it != mucControllers_.end(); ++it) { if ((*it).second == mucController) { mucControllers_.erase(it); delete mucController; diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index e43dc52..ac4689f 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -426,7 +426,7 @@ void MUCController::updateJoinParts() { void MUCController::appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent) { std::vector<NickJoinPart>::iterator it = joinParts.begin(); bool matched = false; - for (; it != joinParts.end(); it++) { + for (; it != joinParts.end(); ++it) { if ((*it).nick == newEvent.nick) { matched = true; JoinPart type = (*it).type; diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index f8fda9a..07afc73 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -97,7 +97,6 @@ public: //delete chatListWindowFactory_; delete settings_; delete profileSettings_; - delete mocks_; delete avatarManager_; delete manager_; delete directedPresenceSender_; @@ -115,6 +114,7 @@ public: delete entityCapsManager_; delete capsProvider_; delete chatListWindow_; + delete mocks_; } void testFirstOpenWindowIncoming() { diff --git a/Swift/Controllers/ChatMessageSummarizer.cpp b/Swift/Controllers/ChatMessageSummarizer.cpp index 682d88b..d95a177 100644 --- a/Swift/Controllers/ChatMessageSummarizer.cpp +++ b/Swift/Controllers/ChatMessageSummarizer.cpp @@ -37,7 +37,7 @@ string ChatMessageSummarizer::getSummary(const string& current, const vector<Unr if (others.size() > 1) { string result(QT_TRANSLATE_NOOP("", "%1% and %2% others (%3%)")); myString = str(format(result) % myString % others.size() % otherCount); - } else if (others.size() > 0) { + } else if (!others.empty()) { string result(QT_TRANSLATE_NOOP("", "%1%, %2% (%3%)")); myString = str(format(result) % myString % others[0].first % otherCount); } diff --git a/Swift/Controllers/DiscoServiceWalker.cpp b/Swift/Controllers/DiscoServiceWalker.cpp index 6aed6eb..1ca4930 100644 --- a/Swift/Controllers/DiscoServiceWalker.cpp +++ b/Swift/Controllers/DiscoServiceWalker.cpp @@ -141,7 +141,7 @@ void DiscoServiceWalker::markNodeCompleted(const JID& jid) { servicesBeingSearched_.erase(jid); /* All results are in */ - if (servicesBeingSearched_.size() == 0) { + if (servicesBeingSearched_.empty()) { active_ = false; onWalkComplete(); } diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp index 947cdc7..ca0a12e 100644 --- a/Swift/Controllers/PreviousStatusStore.cpp +++ b/Swift/Controllers/PreviousStatusStore.cpp @@ -40,7 +40,7 @@ std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const std::strin suggestions.push_back(status); } } - if (suggestions.size() == 0) { + if (suggestions.empty()) { TypeStringPair suggestion(StatusShow::Online, message); suggestions.push_back(suggestion); } diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index 894f64b..bbe81e6 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -91,7 +91,7 @@ void ContactRosterItem::applyPresence(const std::string& resource, boost::shared presences_.erase(resource); } } - if (presences_.size() == 0) { + if (presences_.empty()) { offlinePresence_ = presence; } } else { diff --git a/Swift/Controllers/Roster/GroupRosterItem.cpp b/Swift/Controllers/Roster/GroupRosterItem.cpp index 2b56d1f..2a7bfa5 100644 --- a/Swift/Controllers/Roster/GroupRosterItem.cpp +++ b/Swift/Controllers/Roster/GroupRosterItem.cpp @@ -89,7 +89,7 @@ void GroupRosterItem::removeAll() { delete group; } } - it++; + ++it; } children_.clear(); } @@ -117,7 +117,7 @@ ContactRosterItem* GroupRosterItem::removeChild(const JID& jid) { removed = groupRemoved; } } - it++; + ++it; } onChildrenChanged(); onDataChanged(); @@ -136,7 +136,7 @@ GroupRosterItem* GroupRosterItem::removeGroupChild(const std::string& groupName) it = children_.erase(it); continue; } - it++; + ++it; } onChildrenChanged(); onDataChanged(); diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index 4e34105..a62a18a 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp @@ -107,7 +107,7 @@ void Roster::removeAll() { void Roster::removeContact(const JID& jid) { std::vector<ContactRosterItem*>* items = &itemMap_[fullJIDMapping_ ? jid : jid.toBare()]; items->erase(std::remove_if(items->begin(), items->end(), JIDEqualsTo(jid)), items->end()); - if (items->size() == 0) { + if (items->empty()) { itemMap_.erase(fullJIDMapping_ ? jid : jid.toBare()); } //Causes the delete @@ -124,7 +124,7 @@ void Roster::removeContactFromGroup(const JID& jid, const std::string& groupName std::vector<ContactRosterItem*>* items = &itemMap_[fullJIDMapping_ ? jid : jid.toBare()]; items->erase(std::remove(items->begin(), items->end(), deleted), items->end()); } - it++; + ++it; } foreach (ContactRosterItem* item, itemMap_[fullJIDMapping_ ? jid : jid.toBare()]) { item->removeGroup(groupName); @@ -179,7 +179,7 @@ void Roster::filterContact(ContactRosterItem* contact, GroupRosterItem* group) { foreach (RosterFilter *filter, filters_) { hide &= (*filter)(contact); } - group->setDisplayed(contact, filters_.size() == 0 || !hide); + group->setDisplayed(contact, filters_.empty() || !hide); int newDisplayedSize = group->getDisplayedChildren().size(); if (oldDisplayedSize == 0 && newDisplayedSize > 0) { onGroupAdded(group); diff --git a/Swift/Controllers/SystemTrayController.cpp b/Swift/Controllers/SystemTrayController.cpp index 598771c..31fd4ff 100644 --- a/Swift/Controllers/SystemTrayController.cpp +++ b/Swift/Controllers/SystemTrayController.cpp @@ -22,7 +22,7 @@ SystemTrayController::SystemTrayController(EventController* eventController, Sys void SystemTrayController::handleEventQueueLengthChange(int /*length*/) { EventList events = eventController_->getEvents(); bool found = false; - for (EventList::iterator it = events.begin(); it != events.end(); it++) { + for (EventList::iterator it = events.begin(); it != events.end(); ++it) { if (boost::dynamic_pointer_cast<MessageEvent>(*it)) { found = true; break; diff --git a/Swift/Controllers/UIInterfaces/EventWindow.h b/Swift/Controllers/UIInterfaces/EventWindow.h index e756655..3ca2c82 100644 --- a/Swift/Controllers/UIInterfaces/EventWindow.h +++ b/Swift/Controllers/UIInterfaces/EventWindow.h @@ -6,7 +6,8 @@ #pragma once -#include "boost/shared_ptr.hpp" +#include <boost/shared_ptr.hpp> + #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" namespace Swift { diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index 82c5b52..a5765fd 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -11,7 +11,7 @@ namespace Swift { class MockChatWindow : public ChatWindow { public: - MockChatWindow() {}; + MockChatWindow() : labelsEnabled_(false) {}; virtual ~MockChatWindow(); virtual 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&) {lastMessageBody_ = message; return "";}; diff --git a/Swift/QtUI/ChatList/ChatListMUCItem.cpp b/Swift/QtUI/ChatList/ChatListMUCItem.cpp index e374ed5..68f9581 100644 --- a/Swift/QtUI/ChatList/ChatListMUCItem.cpp +++ b/Swift/QtUI/ChatList/ChatListMUCItem.cpp @@ -13,7 +13,7 @@ ChatListMUCItem::ChatListMUCItem(const MUCBookmark& bookmark, ChatListGroupItem* } -const MUCBookmark& ChatListMUCItem::getBookmark() { +const MUCBookmark& ChatListMUCItem::getBookmark() const { return bookmark_; } diff --git a/Swift/QtUI/ChatList/ChatListMUCItem.h b/Swift/QtUI/ChatList/ChatListMUCItem.h index f26aa67..046d1d4 100644 --- a/Swift/QtUI/ChatList/ChatListMUCItem.h +++ b/Swift/QtUI/ChatList/ChatListMUCItem.h @@ -24,7 +24,7 @@ namespace Swift { StatusShowTypeRole = Qt::UserRole + 3*/ }; ChatListMUCItem(const MUCBookmark& bookmark, ChatListGroupItem* parent); - const MUCBookmark& getBookmark(); + const MUCBookmark& getBookmark() const; QVariant data(int role) const; private: MUCBookmark bookmark_; diff --git a/Swift/QtUI/ChatList/ChatListRecentItem.cpp b/Swift/QtUI/ChatList/ChatListRecentItem.cpp index 8b6707c..38f9a5e 100644 --- a/Swift/QtUI/ChatList/ChatListRecentItem.cpp +++ b/Swift/QtUI/ChatList/ChatListRecentItem.cpp @@ -13,7 +13,7 @@ ChatListRecentItem::ChatListRecentItem(const ChatListWindow::Chat& chat, ChatLis } -const ChatListWindow::Chat& ChatListRecentItem::getChat() { +const ChatListWindow::Chat& ChatListRecentItem::getChat() const { return chat_; } diff --git a/Swift/QtUI/ChatList/ChatListRecentItem.h b/Swift/QtUI/ChatList/ChatListRecentItem.h index c2646cc..f88de77 100644 --- a/Swift/QtUI/ChatList/ChatListRecentItem.h +++ b/Swift/QtUI/ChatList/ChatListRecentItem.h @@ -25,7 +25,7 @@ namespace Swift { StatusShowTypeRole = Qt::UserRole + 3*/ }; ChatListRecentItem(const ChatListWindow::Chat& chat, ChatListGroupItem* parent); - const ChatListWindow::Chat& getChat(); + const ChatListWindow::Chat& getChat() const; QVariant data(int role) const; private: ChatListWindow::Chat chat_; diff --git a/Swift/QtUI/ChatSnippet.h b/Swift/QtUI/ChatSnippet.h index 7cbb3b3..0d864c1 100644 --- a/Swift/QtUI/ChatSnippet.h +++ b/Swift/QtUI/ChatSnippet.h @@ -21,7 +21,7 @@ namespace Swift { virtual const QString& getContent() const = 0; virtual QString getContinuationElementID() const { return ""; } - boost::shared_ptr<ChatSnippet> getContinuationFallbackSnippet() {return continuationFallback_;} + boost::shared_ptr<ChatSnippet> getContinuationFallbackSnippet() const {return continuationFallback_;} bool getAppendToPrevious() const { return appendToPrevious_; diff --git a/Swift/QtUI/EventViewer/QtEventWindow.h b/Swift/QtUI/EventViewer/QtEventWindow.h index 03f009b..a20e5ab 100644 --- a/Swift/QtUI/EventViewer/QtEventWindow.h +++ b/Swift/QtUI/EventViewer/QtEventWindow.h @@ -6,7 +6,7 @@ #pragma once -#include "boost/shared_ptr.hpp" +#include <boost/shared_ptr.hpp> #include <QTreeView> diff --git a/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h b/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h index 920aaae..a9eb74d 100644 --- a/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h +++ b/Swift/QtUI/MUCSearch/MUCSearchRoomItem.h @@ -15,7 +15,7 @@ namespace Swift { MUCSearchRoomItem(const QString& node, MUCSearchServiceItem* parent); MUCSearchServiceItem* getParent(); QVariant data(int role); - QString getNode() {return node_;} + QString getNode() const {return node_;} private: MUCSearchServiceItem* parent_; QString node_; diff --git a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h index 411727d..2a28922 100644 --- a/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h +++ b/Swift/QtUI/MUCSearch/MUCSearchServiceItem.h @@ -24,7 +24,7 @@ namespace Swift { default: return QVariant(); } } - QString getHost() {return jidString_;} + QString getHost() const {return jidString_;} private: QList<MUCSearchItem*> rooms_; QString jidString_; diff --git a/Swift/QtUI/QtChatTheme.cpp b/Swift/QtUI/QtChatTheme.cpp index afcf665..1d7a970 100644 --- a/Swift/QtUI/QtChatTheme.cpp +++ b/Swift/QtUI/QtChatTheme.cpp @@ -60,7 +60,7 @@ QtChatTheme::QtChatTheme(const QString& themePath) : qrc_(themePath.isEmpty()), } -QString QtChatTheme::getBase() { +QString QtChatTheme::getBase() const { return qrc_ ? "qrc" + themePath_ : "file://" + themePath_; } diff --git a/Swift/QtUI/QtChatTheme.h b/Swift/QtUI/QtChatTheme.h index 199c66d..c6b02a0 100644 --- a/Swift/QtUI/QtChatTheme.h +++ b/Swift/QtUI/QtChatTheme.h @@ -13,23 +13,23 @@ namespace Swift { class QtChatTheme { public: QtChatTheme(const QString& themePath); - QString getHeader() {return fileContents_[Header];}; - QString getFooter() {return fileContents_[Footer];}; - QString getContent() {return fileContents_[Content];}; - QString getStatus() {return fileContents_[Status];}; - QString getTopic() {return fileContents_[Topic];}; - QString getFileTransferRequest() {return fileContents_[FileTransferRequest];}; - QString getIncomingContent() {return fileContents_[IncomingContent];}; - QString getIncomingNextContent() {return fileContents_[IncomingNextContent];}; - QString getIncomingContext() {return fileContents_[IncomingContext];}; - QString getIncomingNextContext() {return fileContents_[IncomingNextContext];}; - QString getOutgoingContent() {return fileContents_[OutgoingContent];}; - QString getOutgoingNextContent() {return fileContents_[OutgoingNextContent];}; - QString getOutgoingContext() {return fileContents_[OutgoingContext];}; - QString getOutgoingNextContext() {return fileContents_[OutgoingNextContext];}; - QString getTemplate() {return fileContents_[Template];} - QString getMainCSS() {return fileContents_[MainCSS];} - QString getBase(); + QString getHeader() const {return fileContents_[Header];}; + QString getFooter() const {return fileContents_[Footer];}; + QString getContent() const {return fileContents_[Content];}; + QString getStatus() const {return fileContents_[Status];}; + QString getTopic() const {return fileContents_[Topic];}; + QString getFileTransferRequest() const {return fileContents_[FileTransferRequest];}; + QString getIncomingContent() const {return fileContents_[IncomingContent];}; + QString getIncomingNextContent() const {return fileContents_[IncomingNextContent];}; + QString getIncomingContext() const {return fileContents_[IncomingContext];}; + QString getIncomingNextContext() const {return fileContents_[IncomingNextContext];}; + QString getOutgoingContent() const {return fileContents_[OutgoingContent];}; + QString getOutgoingNextContent() const {return fileContents_[OutgoingNextContent];}; + QString getOutgoingContext() const {return fileContents_[OutgoingContext];}; + QString getOutgoingNextContext() const {return fileContents_[OutgoingNextContext];}; + QString getTemplate() const {return fileContents_[Template];} + QString getMainCSS() const {return fileContents_[MainCSS];} + QString getBase() const; private: enum files {Header = 0, Footer, Content, Status, Topic, FileTransferRequest, IncomingContent, IncomingNextContent, IncomingContext, IncomingNextContext, OutgoingContent, OutgoingNextContent, OutgoingContext, OutgoingNextContext, Template, MainCSS, TemplateDefault, EndMarker}; diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp deleted file mode 100644 index fcd8691..0000000 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "Swift/QtUI/Roster/QtTreeWidgetItem.h" -#include "Swift/QtUI/Roster/QtTreeWidget.h" - -#include <qdebug.h> -#include <QtAlgorithms> -#include <algorithm> - -namespace Swift { - -QtTreeWidgetItem::QtTreeWidgetItem(QtTreeWidgetItem* parentItem) : QObject(), textColor_(0,0,0), backgroundColor_(255,255,255) { - parent_ = parentItem; - shown_ = true; - expanded_ = true; -} - - -void QtTreeWidgetItem::setText(const std::string& text) { - displayName_ = P2QSTRING(text); - displayNameLower_ = displayName_.toLower(); - emit changed(this); -} - -void QtTreeWidgetItem::setStatusText(const std::string& text) { - statusText_ = P2QSTRING(text); - emit changed(this); -} - -void QtTreeWidgetItem::setAvatarPath(const std::string& path) { - avatar_ = QIcon(P2QSTRING(path)); - emit changed(this); -} - -void QtTreeWidgetItem::setStatusShow(StatusShow::Type show) { - statusShowType_ = show; - int color = 0; - switch (show) { - case StatusShow::Online: color = 0x000000; mergedShowType_ = StatusShow::Online; break; - case StatusShow::Away: color = 0x336699; mergedShowType_ = StatusShow::Away; break; - case StatusShow::XA: color = 0x336699; mergedShowType_ = StatusShow::Away; break; - case StatusShow::FFC: color = 0x000000; mergedShowType_ = StatusShow::Online; break; - case StatusShow::DND: color = 0x990000; mergedShowType_ = show; break; - case StatusShow::None: color = 0x7F7F7F; mergedShowType_ = show; break; - } - setTextColor(color); - emit changed(this); -} - -void QtTreeWidgetItem::setTextColor(unsigned long color) { - textColor_ = QColor( - ((color & 0xFF0000)>>16), - ((color & 0xFF00)>>8), - (color & 0xFF)); -} - -void QtTreeWidgetItem::setBackgroundColor(unsigned long color) { - backgroundColor_ = QColor( - ((color & 0xFF0000)>>16), - ((color & 0xFF00)>>8), - (color & 0xFF)); -} - -void QtTreeWidgetItem::setExpanded(bool expanded) { - expanded_ = expanded; - emit changed(this); -} - -void QtTreeWidgetItem::hide() { - shown_ = false; - emit changed(this); -} - -void QtTreeWidgetItem::show() { - shown_ = true; - emit changed(this); -} - -bool QtTreeWidgetItem::isShown() { - return isContact() ? shown_ : shownChildren_.size() > 0; -} - -QWidget* QtTreeWidgetItem::getCollapsedRosterWidget() { - QWidget* widget = new QWidget(); - return widget; -} - -QWidget* QtTreeWidgetItem::getExpandedRosterWidget() { - QWidget* widget = new QWidget(); - return widget; -} - -QtTreeWidgetItem::~QtTreeWidgetItem() { - //It's possible (due to the way the roster deletes items in unknown order when it is deleted) - // That the children will be deleted before the groups, or that the groups are deleted - // before the children. If the children are deleted first, they will let the parent know that - // They've been deleted. If the parent is deleted first, it must tell the children not to - // tell it when they're deleted. Everything will be deleted in the end, because all the - // widgets are owned by the Roster in Swiften. - if (parent_) { - parent_->removeChild(this); - } - - for (int i = 0; i < children_.size(); i++) { - children_[i]->parentItemHasBeenDeleted(); - } -} - -void QtTreeWidgetItem::parentItemHasBeenDeleted() { - parent_ = NULL; -} - -QtTreeWidgetItem* QtTreeWidgetItem::getParentItem() { - return parent_; -} - -void QtTreeWidgetItem::addChild(QtTreeWidgetItem* child) { - children_.append(child); - connect(child, SIGNAL(changed(QtTreeWidgetItem*)), this, SLOT(handleChanged(QtTreeWidgetItem*))); - handleChanged(child); -} - -void QtTreeWidgetItem::removeChild(QtTreeWidgetItem* child) { - children_.removeAll(child); - handleChanged(this); -} - -void bubbleSort(QList<QtTreeWidgetItem*>& list) { - bool done = false; - for (int i = 0; i < list.size() - 1 && !done; i++) { - done = true; - for (int j = i + 1; j < list.size(); j++) { - if (*(list[j]) < *(list[j - 1])) { - done = false; - QtTreeWidgetItem* lower = list[j]; - list[j] = list[j - 1]; - list[j - 1] = lower; - } - } - } -} - -void QtTreeWidgetItem::handleChanged(QtTreeWidgetItem* child) { - /*We don't use the much faster qStableSort because it causes changed(child) and all sorts of nasty recursion*/ - //qStableSort(children_.begin(), children_.end(), itemLessThan); - //bubbleSort(children_); - std::stable_sort(children_.begin(), children_.end(), itemLessThan); - shownChildren_.clear(); - for (int i = 0; i < children_.size(); i++) { - if (children_[i]->isShown()) { - shownChildren_.append(children_[i]); - } - } - emit changed(child); -} - -int QtTreeWidgetItem::rowCount() { - //qDebug() << "Returning size of " << children_.size() << " for item " << displayName_; - return shownChildren_.size(); -} - -int QtTreeWidgetItem::rowOf(QtTreeWidgetItem* item) { - return shownChildren_.indexOf(item); -} - -int QtTreeWidgetItem::row() { - return parent_ ? parent_->rowOf(this) : 0; -} - -QtTreeWidgetItem* QtTreeWidgetItem::getItem(int row) { - //qDebug() << "Returning row " << row << " from item " << displayName_; - Q_ASSERT(row >= 0); - Q_ASSERT(row < rowCount()); - return shownChildren_[row]; -} - - -QVariant QtTreeWidgetItem::data(int role) { - if (!isContact()) { - setTextColor(0xFFFFFF); - setBackgroundColor(0x969696); - } - switch (role) { - case Qt::DisplayRole: return displayName_; - case Qt::TextColorRole: return textColor_; - case Qt::BackgroundColorRole: return backgroundColor_; - case Qt::ToolTipRole: return isContact() ? toolTipString() : QVariant(); - case StatusTextRole: return statusText_; - case AvatarRole: return avatar_; - case PresenceIconRole: return getPresenceIcon(); - default: return QVariant(); - } -} - -QString QtTreeWidgetItem::toolTipString() { - return displayName_ + "\n " + statusText_; -} - -QIcon QtTreeWidgetItem::getPresenceIcon() { - QString iconString; - switch (statusShowType_) { - case StatusShow::Online: iconString = "online";break; - case StatusShow::Away: iconString = "away";break; - case StatusShow::XA: iconString = "away";break; - case StatusShow::FFC: iconString = "online";break; - case StatusShow::DND: iconString = "dnd";break; - case StatusShow::None: iconString = "offline";break; - } - return QIcon(":/icons/" + iconString + ".png"); -} - -bool QtTreeWidgetItem::isContact() const { - return children_.size() == 0; -} - -bool QtTreeWidgetItem::isExpanded() { - return expanded_; -} - -bool QtTreeWidgetItem::operator<(const QtTreeWidgetItem& item) const { - if (isContact()) { - if (!item.isContact()) { - return false; - } - return getStatusShowMerged() == item.getStatusShowMerged() ? getLowerName() < item.getLowerName() : getStatusShowMerged() < item.getStatusShowMerged(); - } else { - if (item.isContact()) { - return true; - } - return getLowerName() < item.getLowerName(); - } -} - -bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right) { - return *left < *right; -} - -} diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h deleted file mode 100644 index 6855989..0000000 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <QColor> -#include <QVariant> -#include <string> - -#include "Swiften/Roster/TreeWidgetFactory.h" -#include "Swiften/Roster/TreeWidget.h" -#include "Swiften/Roster/TreeWidgetItem.h" -#include "Swift/QtUI/QtSwiftUtil.h" - -namespace Swift { - enum RosterRoles { - StatusTextRole = Qt::UserRole, - AvatarRole = Qt::UserRole + 1, - PresenceIconRole = Qt::UserRole + 2, - StatusShowTypeRole = Qt::UserRole + 3 - }; - -class QtTreeWidget; -class QtTreeWidgetItem : public QObject, public TreeWidgetItem { - Q_OBJECT - public: - ~QtTreeWidgetItem(); - void addChild(QtTreeWidgetItem* child); - void removeChild(QtTreeWidgetItem* child); - QtTreeWidgetItem* getParentItem(); - int rowCount(); - int rowOf(QtTreeWidgetItem* item); - int row(); - QtTreeWidgetItem* getItem(int row); - QVariant data(int role); - QIcon getPresenceIcon(); - QtTreeWidgetItem(QtTreeWidgetItem* parentItem); - void setText(const std::string& text); - void setAvatarPath(const std::string& path); - void setStatusText(const std::string& text); - void setStatusShow(StatusShow::Type show); - void setTextColor(unsigned long color); - void setBackgroundColor(unsigned long color); - void setExpanded(bool b); - void parentItemHasBeenDeleted(); - void hide(); - void show(); - bool isShown(); - bool isContact() const; - bool isExpanded(); - const QString& getName() const {return displayName_;}; - const QString& getLowerName() const {return displayNameLower_;}; - StatusShow::Type getStatusShow() const {return statusShowType_;}; - StatusShow::Type getStatusShowMerged() const {return mergedShowType_;}; - - QWidget* getCollapsedRosterWidget(); - QWidget* getExpandedRosterWidget(); - bool operator<(const QtTreeWidgetItem& item) const; - - signals: - void changed(QtTreeWidgetItem*); - private slots: - void handleChanged(QtTreeWidgetItem* item); - private: - QString toolTipString(); - QList<QtTreeWidgetItem*> children_; - QList<QtTreeWidgetItem*> shownChildren_; - QtTreeWidgetItem* parent_; - QString displayName_; - QString displayNameLower_; - QString statusText_; - QColor textColor_; - QColor backgroundColor_; - QVariant avatar_; - bool shown_; - bool expanded_; - StatusShow::Type statusShowType_; - StatusShow::Type mergedShowType_; -}; - -bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right); - -} diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp index c486d6d..c27ade5 100644 --- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp +++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp @@ -187,7 +187,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { } Event popEvent() { - CPPUNIT_ASSERT(receivedEvents.size() > 0); + CPPUNIT_ASSERT(!receivedEvents.empty()); Event event = receivedEvents.front(); receivedEvents.pop_front(); return event; diff --git a/Swiften/Elements/Last.h b/Swiften/Elements/Last.h index ba302e3..fe0323a 100644 --- a/Swiften/Elements/Last.h +++ b/Swiften/Elements/Last.h @@ -11,8 +11,7 @@ namespace Swift { class Last : public Payload { public: - Last() {}; - Last(int seconds) : seconds_(seconds) {}; + Last(int seconds = 0) : seconds_(seconds) {}; int getSeconds() const {return seconds_;} void setSeconds(int seconds) {seconds_ = seconds;} diff --git a/Swiften/Elements/RosterItemExchangePayload.cpp b/Swiften/Elements/RosterItemExchangePayload.cpp index a425551..abd5296 100644 --- a/Swiften/Elements/RosterItemExchangePayload.cpp +++ b/Swiften/Elements/RosterItemExchangePayload.cpp @@ -9,7 +9,7 @@ namespace Swift { -RosterItemExchangePayload::Item::Item() { +RosterItemExchangePayload::Item::Item(Action action) : action(action) { } RosterItemExchangePayload::RosterItemExchangePayload() { diff --git a/Swiften/Elements/RosterItemExchangePayload.h b/Swiften/Elements/RosterItemExchangePayload.h index cbe9ffa..c39c084 100644 --- a/Swiften/Elements/RosterItemExchangePayload.h +++ b/Swiften/Elements/RosterItemExchangePayload.h @@ -23,7 +23,7 @@ namespace Swift { public: enum Action { Add, Modify, Delete }; - Item(); + Item(Action action = Add); Action getAction() const { return action; diff --git a/Swiften/Elements/VCard.cpp b/Swiften/Elements/VCard.cpp index 4f7700e..8bf3eb9 100644 --- a/Swiften/Elements/VCard.cpp +++ b/Swiften/Elements/VCard.cpp @@ -16,7 +16,7 @@ VCard::EMailAddress VCard::getPreferredEMailAddress() const { return address; } } - if (emailAddresses_.size() > 0) { + if (!emailAddresses_.empty()) { return emailAddresses_[0]; } return EMailAddress(); diff --git a/Swiften/EventLoop/DummyEventLoop.h b/Swiften/EventLoop/DummyEventLoop.h index f814ed9..4c01c16 100644 --- a/Swiften/EventLoop/DummyEventLoop.h +++ b/Swiften/EventLoop/DummyEventLoop.h @@ -24,7 +24,7 @@ namespace Swift { } bool hasEvents() { - return events_.size() > 0; + return !events_.empty(); } virtual void post(const Event& event) { diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp index 74fea01..63b8ba5 100644 --- a/Swiften/EventLoop/SimpleEventLoop.cpp +++ b/Swiften/EventLoop/SimpleEventLoop.cpp @@ -30,7 +30,7 @@ void SimpleEventLoop::doRun(bool breakAfterEvents) { std::vector<Event> events; { boost::unique_lock<boost::mutex> lock(eventsMutex_); - while (events_.size() == 0) { + while (events_.empty()) { eventsAvailable_.wait(lock); } events.swap(events_); diff --git a/Swiften/History/SQLiteHistoryManager.cpp b/Swiften/History/SQLiteHistoryManager.cpp index 8a809bd..3b65f62 100644 --- a/Swiften/History/SQLiteHistoryManager.cpp +++ b/Swiften/History/SQLiteHistoryManager.cpp @@ -7,7 +7,7 @@ #include <iostream> #include <boost/lexical_cast.hpp> -#include "sqlite3.h" +#include <sqlite3.h> #include <Swiften/History/SQLiteHistoryManager.h> namespace { diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp index f437fc2..516d303 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp @@ -56,7 +56,8 @@ ByteArray LinkLocalServiceInfo::getEncoded(const std::string& s) { LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray& record) { LinkLocalServiceInfo info; size_t i = 0; - while (i < record.size()) { + size_t recordCount = record.size(); + while (i < recordCount) { std::pair<std::string,std::string> entry = readEntry(record, &i); if (entry.first.empty()) { break; diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp index 2e0b79e..643a8c4 100644 --- a/Swiften/MUC/MUCBookmarkManager.cpp +++ b/Swiften/MUC/MUCBookmarkManager.cpp @@ -86,7 +86,7 @@ void MUCBookmarkManager::addBookmark(const MUCBookmark& bookmark) { void MUCBookmarkManager::removeBookmark(const MUCBookmark& bookmark) { if (!ready_) return; std::vector<MUCBookmark>::iterator it; - for (it = bookmarks_.begin(); it != bookmarks_.end(); it++) { + for (it = bookmarks_.begin(); it != bookmarks_.end(); ++it) { if ((*it) == bookmark) { bookmarks_.erase(it); onBookmarkRemoved(bookmark); diff --git a/Swiften/Network/MacOSXProxyProvider.cpp b/Swiften/Network/MacOSXProxyProvider.cpp index dd44eff..eaadd28 100644 --- a/Swiften/Network/MacOSXProxyProvider.cpp +++ b/Swiften/Network/MacOSXProxyProvider.cpp @@ -48,7 +48,7 @@ static HostAddressPort getFromDictionary(CFDictionaryRef dict, CFStringRef enabl CFIndex length = CFStringGetLength(stringValue) + 1; buffer.resize(length); if(CFStringGetCString(stringValue, &buffer[0], length, kCFStringEncodingMacRoman)) { - for(std::vector<char>::iterator iter = buffer.begin(); iter != buffer.end(); iter++) { + for(std::vector<char>::iterator iter = buffer.begin(); iter != buffer.end(); ++iter) { host += *iter; } } diff --git a/Swiften/Presence/PresenceOracle.cpp b/Swiften/Presence/PresenceOracle.cpp index 1ad6fbf..bfb5a3d 100644 --- a/Swiften/Presence/PresenceOracle.cpp +++ b/Swiften/Presence/PresenceOracle.cpp @@ -84,7 +84,7 @@ std::vector<Presence::ref> PresenceOracle::getAllPresence(const JID& bareJID) co } PresenceMap presenceMap = i->second; PresenceMap::const_iterator j = presenceMap.begin(); - for (; j != presenceMap.end(); j++) { + for (; j != presenceMap.end(); ++j) { Presence::ref current = j->second; results.push_back(current); } @@ -99,7 +99,7 @@ Presence::ref PresenceOracle::getHighestPriorityPresence(const JID& bareJID) con PresenceMap presenceMap = i->second; PresenceMap::const_iterator j = presenceMap.begin(); Presence::ref highest; - for (; j != presenceMap.end(); j++) { + for (; j != presenceMap.end(); ++j) { Presence::ref current = j->second; if (!highest || current->getPriority() > highest->getPriority() diff --git a/Swiften/QA/DNSSDTest/DNSSDTest.cpp b/Swiften/QA/DNSSDTest/DNSSDTest.cpp index 2409f66..7e2a189 100644 --- a/Swiften/QA/DNSSDTest/DNSSDTest.cpp +++ b/Swiften/QA/DNSSDTest/DNSSDTest.cpp @@ -94,7 +94,7 @@ class DNSSDTest : public CppUnit::TestFixture { toRemove.clear(); toRemove.insert(toRemove.begin(), added.begin(), added.end()); registerQuery->unregisterService(); - while (toRemove.size() > 0) { + while (!toRemove.empty()) { Swift::sleep(100); eventLoop->processEvents(); } diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp index 9eb2680..6d406e0 100644 --- a/Swiften/SASL/DIGESTMD5Properties.cpp +++ b/Swiften/SASL/DIGESTMD5Properties.cpp @@ -11,7 +11,7 @@ namespace Swift { namespace { bool insideQuotes(const ByteArray& v) { - if (v.size() == 0) { + if (v.empty()) { return false; } else if (v.size() == 1) { diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp index 1d0ad70..5fa1f05 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp @@ -132,7 +132,7 @@ std::map<char, std::string> SCRAMSHA1ClientAuthenticator::parseMap(const std::st i++; } else if (s[i] == ',') { - result[key] = value; + result[static_cast<size_t>(key)] = value; value = ""; expectKey = true; } diff --git a/Swiften/Serializer/PresenceSerializer.cpp b/Swiften/Serializer/PresenceSerializer.cpp index ae1f88c..20eda4b 100644 --- a/Swiften/Serializer/PresenceSerializer.cpp +++ b/Swiften/Serializer/PresenceSerializer.cpp @@ -7,7 +7,7 @@ #include <Swiften/Serializer/PresenceSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> -#include "boost/shared_ptr.hpp" +#include <boost/shared_ptr.hpp> namespace Swift { diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp index be90406..d39ec39 100644 --- a/Swiften/Serializer/XML/XMLElement.cpp +++ b/Swiften/Serializer/XML/XMLElement.cpp @@ -28,7 +28,7 @@ std::string XMLElement::serialize() { result += " " + p.first + "=\"" + p.second + "\""; } - if (childNodes_.size() > 0) { + if (!childNodes_.empty()) { result += ">"; foreach (boost::shared_ptr<XMLNode> node, childNodes_) { result += node->serialize(); diff --git a/Swiften/StreamManagement/StanzaAckRequester.cpp b/Swiften/StreamManagement/StanzaAckRequester.cpp index 47f67a6..b60b9b0 100644 --- a/Swiften/StreamManagement/StanzaAckRequester.cpp +++ b/Swiften/StreamManagement/StanzaAckRequester.cpp @@ -29,7 +29,7 @@ void StanzaAckRequester::handleStanzaSent(boost::shared_ptr<Stanza> stanza) { void StanzaAckRequester::handleAckReceived(unsigned int handledStanzasCount) { unsigned int i = lastHandledStanzasCount; while (i != handledStanzasCount) { - if (unackedStanzas.size() == 0) { + if (unackedStanzas.empty()) { std::cerr << "Warning: Server acked more stanzas than we sent" << std::endl; break; } diff --git a/Swiften/StringCodecs/MD5.cpp b/Swiften/StringCodecs/MD5.cpp index 159eb87..0d36254 100644 --- a/Swiften/StringCodecs/MD5.cpp +++ b/Swiften/StringCodecs/MD5.cpp @@ -125,13 +125,13 @@ static void md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) { a = pms->abcd[0], b = pms->abcd[1], c = pms->abcd[2], d = pms->abcd[3]; md5_word_t t; -#ifdef SWIFTEN_BIG_ENDIAN - /* Define storage only for big-endian CPUs. */ - md5_word_t X[16]; -#else +#ifdef SWIFTEN_LITTLE_ENDIAN /* Define storage for little-endian or both types of CPUs. */ md5_word_t xbuf[16]; const md5_word_t *X; +#else + /* Define storage only for big-endian CPUs. */ + md5_word_t X[16]; #endif { diff --git a/Swiftob/Swiftob.cpp b/Swiftob/Swiftob.cpp index 10f7104..331e55e 100644 --- a/Swiftob/Swiftob.cpp +++ b/Swiftob/Swiftob.cpp @@ -108,6 +108,7 @@ Swiftob::~Swiftob() { delete commands_; delete storage_; delete users_; + delete mucs_; delete client_; } |