summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp9
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.h2
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp4
-rw-r--r--Swift/Controllers/Chat/Chattables.h2
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChattablesTest.cpp3
-rw-r--r--Swift/Controllers/Chat/UnitTest/MockChatListWindow.h2
-rw-r--r--Swift/Controllers/Storages/CertificateFileStorage.cpp2
-rw-r--r--Swift/Controllers/UIInterfaces/ChatListWindow.h8
-rw-r--r--Swift/Controllers/UIInterfaces/ChatWindow.h2
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h2
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp2
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.h4
-rw-r--r--Swift/QtUI/QtChatWindow.cpp4
-rw-r--r--Swift/QtUI/QtChatWindow.h6
-rw-r--r--Swift/QtUI/QtTabbable.h2
15 files changed, 28 insertions, 26 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index 8a26a56..3805084 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -118,8 +118,8 @@ void ChatControllerBase::handleAllMessagesRead() {
118 } 118 }
119} 119}
120 120
121int ChatControllerBase::getUnreadCount() { 121size_t ChatControllerBase::getUnreadCount() {
122 return boost::numeric_cast<int>(targetedUnreadMessages_.size()); 122 return targetedUnreadMessages_.size();
123} 123}
124 124
125void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool isCorrectionMessage) { 125void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool isCorrectionMessage) {
@@ -193,11 +193,10 @@ ChatWindow::ChatMessage ChatControllerBase::buildChatWindowChatMessage(const std
193} 193}
194 194
195void ChatControllerBase::updateMessageCount() { 195void ChatControllerBase::updateMessageCount() {
196 int intCount = boost::numeric_cast<int>(unreadMessages_.size());
197 chatWindow_->setUnreadMessageCount(intCount);
198 auto baseJID = getBaseJID(); 196 auto baseJID = getBaseJID();
199 auto state = chattables_.getState(baseJID); 197 auto state = chattables_.getState(baseJID);
200 state.unreadCount = intCount; 198 state.unreadCount = unreadMessages_.size();
199 chatWindow_->setUnreadMessageCount(state.unreadCount);
201 chattables_.setState(baseJID, state); 200 chattables_.setState(baseJID, state);
202#ifndef NOT_YET 201#ifndef NOT_YET
203 onUnreadCountChanged(); 202 onUnreadCountChanged();
diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h
index 527196c..92c6175 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.h
+++ b/Swift/Controllers/Chat/ChatControllerBase.h
@@ -73,7 +73,7 @@ namespace Swift {
73 boost::signals2::signal<void (const std::string& /*activity*/)> onActivity; 73 boost::signals2::signal<void (const std::string& /*activity*/)> onActivity;
74 boost::signals2::signal<void ()> onUnreadCountChanged; 74 boost::signals2::signal<void ()> onUnreadCountChanged;
75 boost::signals2::signal<void ()> onWindowClosed; 75 boost::signals2::signal<void ()> onWindowClosed;
76 int getUnreadCount(); 76 size_t getUnreadCount();
77 const JID& getToJID() {return toJID_;} 77 const JID& getToJID() {return toJID_;}
78 void handleCapsChanged(const JID& jid); 78 void handleCapsChanged(const JID& jid);
79 void setCanStartImpromptuChats(bool supportsImpromptu); 79 void setCanStartImpromptuChats(bool supportsImpromptu);
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 532b925..6530a7e 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -372,7 +372,7 @@ void ChatsManager::handleMUCBookmarkRemoved(const MUCBookmark& bookmark) {
372 372
373#ifndef NOT_YET 373#ifndef NOT_YET
374ChatListWindow::Chat ChatsManager::createChatListChatItem(const JID& jid, const std::string& activity, bool privateMessage) { 374ChatListWindow::Chat ChatsManager::createChatListChatItem(const JID& jid, const std::string& activity, bool privateMessage) {
375 int unreadCount = 0; 375 size_t unreadCount = 0;
376 if (mucRegistry_->isMUC(jid)) { 376 if (mucRegistry_->isMUC(jid)) {
377 MUCController* controller = mucControllers_[jid.toBare()]; 377 MUCController* controller = mucControllers_[jid.toBare()];
378 StatusShow::Type type = StatusShow::None; 378 StatusShow::Type type = StatusShow::None;
@@ -447,7 +447,7 @@ void ChatsManager::handleChatClosed(const JID& /*jid*/) {
447#ifndef NOT_YET 447#ifndef NOT_YET
448 448
449void ChatsManager::handleUnreadCountChanged(ChatControllerBase* controller) { 449void ChatsManager::handleUnreadCountChanged(ChatControllerBase* controller) {
450 int unreadTotal = 0; 450 size_t unreadTotal = 0;
451 bool controllerIsMUC = dynamic_cast<MUCController*>(controller); 451 bool controllerIsMUC = dynamic_cast<MUCController*>(controller);
452 bool isPM = controller && !controllerIsMUC && mucRegistry_->isMUC(controller->getToJID().toBare()); 452 bool isPM = controller && !controllerIsMUC && mucRegistry_->isMUC(controller->getToJID().toBare());
453 for (ChatListWindow::Chat& chatItem : recentChats_) { 453 for (ChatListWindow::Chat& chatItem : recentChats_) {
diff --git a/Swift/Controllers/Chat/Chattables.h b/Swift/Controllers/Chat/Chattables.h
index c115fb3..3b5817a 100644
--- a/Swift/Controllers/Chat/Chattables.h
+++ b/Swift/Controllers/Chat/Chattables.h
@@ -22,7 +22,7 @@ class Chattables {
22 JID jid; 22 JID jid;
23 /// Empty for no name 23 /// Empty for no name
24 std::string name; 24 std::string name;
25 int unreadCount = 0; 25 size_t unreadCount = 0;
26 Type type; 26 Type type;
27 StatusShow::Type status = StatusShow::None; 27 StatusShow::Type status = StatusShow::None;
28 //avatar 28 //avatar
diff --git a/Swift/Controllers/Chat/UnitTest/ChattablesTest.cpp b/Swift/Controllers/Chat/UnitTest/ChattablesTest.cpp
index e052aff..f30e3fd 100644
--- a/Swift/Controllers/Chat/UnitTest/ChattablesTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChattablesTest.cpp
@@ -9,6 +9,9 @@
9 9
10#include <Swift/Controllers/Chat/Chattables.h> 10#include <Swift/Controllers/Chat/Chattables.h>
11 11
12// Clang wrongly things that tests for 0 are using 0 as null.
13#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
14
12using namespace Swift; 15using namespace Swift;
13 16
14class ChattablesTest : public ::testing::Test { 17class ChattablesTest : public ::testing::Test {
diff --git a/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h b/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h
index 395b050..1d980d3 100644
--- a/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h
+++ b/Swift/Controllers/Chat/UnitTest/MockChatListWindow.h
@@ -20,7 +20,7 @@ namespace Swift {
20 void removeWhiteboardSession(const JID& /*jid*/) {} 20 void removeWhiteboardSession(const JID& /*jid*/) {}
21 void setBookmarksEnabled(bool /*enabled*/) {} 21 void setBookmarksEnabled(bool /*enabled*/) {}
22 void setRecents(const std::list<ChatListWindow::Chat>& /*recents*/) {} 22 void setRecents(const std::list<ChatListWindow::Chat>& /*recents*/) {}
23 void setUnreadCount(int /*unread*/) {} 23 void setUnreadCount(size_t /*unread*/) {}
24 void clearBookmarks() {} 24 void clearBookmarks() {}
25 void setOnline(bool /*isOnline*/) {} 25 void setOnline(bool /*isOnline*/) {}
26 }; 26 };
diff --git a/Swift/Controllers/Storages/CertificateFileStorage.cpp b/Swift/Controllers/Storages/CertificateFileStorage.cpp
index 3fe6d54..8ba7d12 100644
--- a/Swift/Controllers/Storages/CertificateFileStorage.cpp
+++ b/Swift/Controllers/Storages/CertificateFileStorage.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2016 Isode Limited. 2 * Copyright (c) 2010-2018 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h
index 29097e9..6aa729b 100644
--- a/Swift/Controllers/UIInterfaces/ChatListWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h
@@ -26,7 +26,7 @@ namespace Swift {
26 class Chat { 26 class Chat {
27 public: 27 public:
28 Chat() : statusType(StatusShow::None), isMUC(false), unreadCount(0), isPrivateMessage(false) {} 28 Chat() : statusType(StatusShow::None), isMUC(false), unreadCount(0), isPrivateMessage(false) {}
29 Chat(const JID& jid, const std::string& chatName, const std::string& activity, int unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, bool isPrivateMessage = false, const std::string& nick = "", const boost::optional<std::string> password = boost::optional<std::string>()) 29 Chat(const JID& jid, const std::string& chatName, const std::string& activity, size_t unreadCount, StatusShow::Type statusType, const boost::filesystem::path& avatarPath, bool isMUC, bool isPrivateMessage = false, const std::string& nick = "", const boost::optional<std::string> password = boost::optional<std::string>())
30 : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), password(password), unreadCount(unreadCount), avatarPath(avatarPath), isPrivateMessage(isPrivateMessage) {} 30 : jid(jid), chatName(chatName), activity(activity), statusType(statusType), isMUC(isMUC), nick(nick), password(password), unreadCount(unreadCount), avatarPath(avatarPath), isPrivateMessage(isPrivateMessage) {}
31 /** Assume that nicks and other transient features aren't important for equality */ 31 /** Assume that nicks and other transient features aren't important for equality */
32 bool operator==(const Chat& other) const { 32 bool operator==(const Chat& other) const {
@@ -53,7 +53,7 @@ namespace Swift {
53 return key_compare(inviteesNames, other.inviteesNames); 53 return key_compare(inviteesNames, other.inviteesNames);
54 } 54 }
55 } 55 }
56 void setUnreadCount(int unread) { 56 void setUnreadCount(size_t unread) {
57 unreadCount = unread; 57 unreadCount = unread;
58 } 58 }
59 void setStatusType(StatusShow::Type type) { 59 void setStatusType(StatusShow::Type type) {
@@ -93,7 +93,7 @@ namespace Swift {
93 bool isMUC; 93 bool isMUC;
94 std::string nick; 94 std::string nick;
95 boost::optional<std::string> password; 95 boost::optional<std::string> password;
96 int unreadCount; 96 size_t unreadCount;
97 boost::filesystem::path avatarPath; 97 boost::filesystem::path avatarPath;
98 std::map<std::string, JID> impromptuJIDs; 98 std::map<std::string, JID> impromptuJIDs;
99 std::map<JID, std::string> inviteesNames; 99 std::map<JID, std::string> inviteesNames;
@@ -107,7 +107,7 @@ namespace Swift {
107 virtual void removeWhiteboardSession(const JID& jid) = 0; 107 virtual void removeWhiteboardSession(const JID& jid) = 0;
108 virtual void removeMUCBookmark(const MUCBookmark& bookmark) = 0; 108 virtual void removeMUCBookmark(const MUCBookmark& bookmark) = 0;
109 virtual void setRecents(const std::list<Chat>& recents) = 0; 109 virtual void setRecents(const std::list<Chat>& recents) = 0;
110 virtual void setUnreadCount(int unread) = 0; 110 virtual void setUnreadCount(size_t unread) = 0;
111 virtual void clearBookmarks() = 0; 111 virtual void clearBookmarks() = 0;
112 virtual void setOnline(bool isOnline) = 0; 112 virtual void setOnline(bool isOnline) = 0;
113 113
diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h
index daece0e..1c36ffc 100644
--- a/Swift/Controllers/UIInterfaces/ChatWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatWindow.h
@@ -202,7 +202,7 @@ namespace Swift {
202 virtual void setSecurityLabelsEnabled(bool enabled) = 0; 202 virtual void setSecurityLabelsEnabled(bool enabled) = 0;
203 virtual void setCorrectionEnabled(Tristate enabled) = 0; 203 virtual void setCorrectionEnabled(Tristate enabled) = 0;
204 virtual void setFileTransferEnabled(Tristate enabled) = 0; 204 virtual void setFileTransferEnabled(Tristate enabled) = 0;
205 virtual void setUnreadMessageCount(int count) = 0; 205 virtual void setUnreadMessageCount(size_t count) = 0;
206 virtual void convertToMUC(MUCType mucType) = 0; 206 virtual void convertToMUC(MUCType mucType) = 0;
207// virtual TreeWidget *getTreeWidget() = 0; 207// virtual TreeWidget *getTreeWidget() = 0;
208 virtual void setSecurityLabelsError() = 0; 208 virtual void setSecurityLabelsError() = 0;
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index 389d787..38b3b1f 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -73,7 +73,7 @@ namespace Swift {
73 virtual void activate() {} 73 virtual void activate() {}
74 virtual void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels) {labels_ = labels;} 74 virtual void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels) {labels_ = labels;}
75 virtual void setSecurityLabelsEnabled(bool enabled) {labelsEnabled_ = enabled;} 75 virtual void setSecurityLabelsEnabled(bool enabled) {labelsEnabled_ = enabled;}
76 virtual void setUnreadMessageCount(int /*count*/) {} 76 virtual void setUnreadMessageCount(size_t /*count*/) {}
77 77
78 virtual void convertToMUC(MUCType mucType) { 78 virtual void convertToMUC(MUCType mucType) {
79 mucType_ = mucType; 79 mucType_ = mucType;
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index e92ba0d..2fd05c4 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -130,7 +130,7 @@ void QtChatListWindow::setRecents(const std::list<ChatListWindow::Chat>& recents
130 model_->setRecents(recents); 130 model_->setRecents(recents);
131} 131}
132 132
133void QtChatListWindow::setUnreadCount(int unread) { 133void QtChatListWindow::setUnreadCount(size_t unread) {
134 emit onCountUpdated(unread); 134 emit onCountUpdated(unread);
135} 135}
136 136
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.h b/Swift/QtUI/ChatList/QtChatListWindow.h
index 001650c..3322001 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.h
+++ b/Swift/QtUI/ChatList/QtChatListWindow.h
@@ -27,12 +27,12 @@ namespace Swift {
27 void removeWhiteboardSession(const JID& jid); 27 void removeWhiteboardSession(const JID& jid);
28 void setBookmarksEnabled(bool enabled); 28 void setBookmarksEnabled(bool enabled);
29 void setRecents(const std::list<ChatListWindow::Chat>& recents); 29 void setRecents(const std::list<ChatListWindow::Chat>& recents);
30 void setUnreadCount(int unread); 30 void setUnreadCount(size_t unread);
31 void clearBookmarks(); 31 void clearBookmarks();
32 virtual void setOnline(bool isOnline); 32 virtual void setOnline(bool isOnline);
33 33
34 signals: 34 signals:
35 void onCountUpdated(int count); 35 void onCountUpdated(size_t count);
36 private slots: 36 private slots:
37 void handleItemActivated(const QModelIndex&); 37 void handleItemActivated(const QModelIndex&);
38 void handleEditBookmark(); 38 void handleEditBookmark();
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index a413b4d..82c65ce 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -505,7 +505,7 @@ void QtChatWindow::showEvent(QShowEvent* event) {
505 QWidget::showEvent(event); 505 QWidget::showEvent(event);
506} 506}
507 507
508void QtChatWindow::setUnreadMessageCount(int count) { 508void QtChatWindow::setUnreadMessageCount(size_t count) {
509 if (unreadCount_ != count) { 509 if (unreadCount_ != count) {
510 unreadCount_ = count; 510 unreadCount_ = count;
511 updateTitleWithUnreadCount(); 511 updateTitleWithUnreadCount();
@@ -547,7 +547,7 @@ void QtChatWindow::flash() {
547 emit requestFlash(); 547 emit requestFlash();
548} 548}
549 549
550int QtChatWindow::getCount() { 550size_t QtChatWindow::getCount() {
551 return unreadCount_; 551 return unreadCount_;
552} 552}
553 553
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index 8cc3283..b876d1e 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -106,7 +106,7 @@ namespace Swift {
106 void show(); 106 void show();
107 bool isVisible() const; 107 bool isVisible() const;
108 void activate(); 108 void activate();
109 void setUnreadMessageCount(int count); 109 void setUnreadMessageCount(size_t count);
110 void convertToMUC(MUCType mucType); 110 void convertToMUC(MUCType mucType);
111// TreeWidget *getTreeWidget(); 111// TreeWidget *getTreeWidget();
112 void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels); 112 void setAvailableSecurityLabels(const std::vector<SecurityLabelsCatalog::Item>& labels);
@@ -119,7 +119,7 @@ namespace Swift {
119 void setContactChatState(ChatState::ChatStateType state); 119 void setContactChatState(ChatState::ChatStateType state);
120 void setRosterModel(Roster* roster); 120 void setRosterModel(Roster* roster);
121 void setTabComplete(TabComplete* completer); 121 void setTabComplete(TabComplete* completer);
122 int getCount(); 122 size_t getCount();
123 virtual void replaceSystemMessage(const ChatMessage& message, const std::string& id, const TimestampBehaviour timestampBehaviour); 123 virtual void replaceSystemMessage(const ChatMessage& message, const std::string& id, const TimestampBehaviour timestampBehaviour);
124 void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour timestampBehaviour); 124 void replaceLastMessage(const ChatMessage& message, const TimestampBehaviour timestampBehaviour);
125 void setAckState(const std::string& id, AckState state); 125 void setAckState(const std::string& id, AckState state);
@@ -201,7 +201,7 @@ namespace Swift {
201 void handleFocusTimerTick(); 201 void handleFocusTimerTick();
202 202
203 private: 203 private:
204 int unreadCount_; 204 size_t unreadCount_;
205 bool contactIsTyping_; 205 bool contactIsTyping_;
206 LastLineTracker lastLineTracker_; 206 LastLineTracker lastLineTracker_;
207 std::string id_; 207 std::string id_;
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index 5837702..63c60f4 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -19,7 +19,7 @@ namespace Swift {
19 19
20 bool isWidgetSelected(); 20 bool isWidgetSelected();
21 virtual AlertType getWidgetAlertState() {return NoActivity;} 21 virtual AlertType getWidgetAlertState() {return NoActivity;}
22 virtual int getCount() {return 0;} 22 virtual size_t getCount() {return 0;}
23 virtual std::string getID() const = 0; 23 virtual std::string getID() const = 0;
24 virtual void setEmphasiseFocus(bool /*emphasise*/) {} 24 virtual void setEmphasiseFocus(bool /*emphasise*/) {}
25 25