From 82c16c6a277fbee3952109c5c5fe0615e53c36a9 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 11 Oct 2015 22:08:19 -0400 Subject: [PATCH] fixed GUI tooltips over banned items. Added dropping of messages from banned identities in chat lobbies --- libretroshare/src/chat/distributedchat.cc | 12 ++++++++++++ retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp | 6 ++++-- .../src/gui/gxsforums/GxsForumThreadWidget.cpp | 9 +++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 7a683c2eb..aad26967c 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -34,6 +34,7 @@ #include "pqi/p3historymgr.h" #include "retroshare/rspeers.h" #include "retroshare/rsiface.h" +#include "retroshare/rsreputations.h" #include "retroshare/rsidentity.h" #include "rsserver/p3face.h" #include "gxs/rsgixs.h" @@ -175,6 +176,12 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci) return false ; } } + if(rsReputations->isIdentityBanned(cli->signature.keyId)) + { + std::cerr << "(WW) Received lobby msg/item from banned identity " << cli->signature.keyId << ". Dropping it." << std::endl; + return false ; + } + if(!bounceLobbyObject(cli,cli->PeerId())) // forwards the message to friends, keeps track of subscribers, etc. return false; @@ -672,6 +679,11 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem * return ; } } + if(rsReputations->isIdentityBanned(item->signature.keyId)) + { + std::cerr << "(WW) Received lobby msg/item from banned identity " << item->signature.keyId << ". Dropping it." << std::endl; + return ; + } addTimeShiftStatistics((int)now - (int)item->sendTime) ; if(now+100 > (time_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo! diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index 4b933fd04..6233b1e48 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -76,7 +76,7 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde break; case GXS_ID_DETAILS_TYPE_BANNED: - icons.push_back(QIcon(":/icons/yellow_biohazard64.png")) ; + icons.push_back(QIcon("BANNED_IMAGE")) ; break ; } @@ -153,7 +153,9 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const QString t = RSTreeWidgetItem::data(column, role).toString(); QImage pix; - if(rsReputations->isIdentityBanned(mId)) + if(mId.isNull()) + return RSTreeWidgetItem::data(column, role); + else if(rsReputations->isIdentityBanned(mId)) pix = QImage(BANNED_IMAGE) ; else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG")) pix = GxsIdDetails::makeDefaultIcon(mId); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 2bb84c485..f0ea49fc7 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -989,9 +989,12 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum QTreeWidgetItem *GxsForumThreadWidget::generateMissingItem(const RsGxsMessageId &msgId) { GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL); + item->setText(COLUMN_THREAD_TITLE, tr("[ ... Missing Message ... ]")); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgId.toStdString())); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, true); + + item->setId(RsGxsId(), COLUMN_THREAD_AUTHOR, false); // fixed up columnId() return item; } @@ -1358,8 +1361,10 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) if(redacted) { QString extraTxt = tr("

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString())) ; - extraTxt += "

" ; + extraTxt += tr("") ; + extraTxt += tr("

You can still force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.

") ; + ui->postText->setHtml(extraTxt); } else