mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Preparation for mute Peers in the Chat Lobby.
RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME is send, when changing nickname, so the blocklist can be updated (in future). This will never wort for 100% as discussed in the developer forum, but should stop the most spam. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5150 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
22a8e6f3c9
commit
22bfcb62bc
@ -251,6 +251,7 @@ virtual bool clearPrivateChatQueue(bool incoming, const std::string& id) = 0;
|
||||
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
|
||||
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
|
||||
|
||||
|
||||
virtual void setCustomStateString(const std::string& status_string) = 0 ;
|
||||
virtual std::string getCustomStateString() = 0 ;
|
||||
virtual std::string getCustomStateString(const std::string& peer_id) = 0 ;
|
||||
@ -262,6 +263,11 @@ virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
|
||||
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
||||
|
||||
virtual bool joinPublicChatLobby(const ChatLobbyId& lobby_id) = 0 ;
|
||||
|
||||
|
||||
virtual bool sendLobbyStatusPeerChangedNickname(const ChatLobbyId& lobby_id) = 0 ;
|
||||
|
||||
|
||||
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
|
||||
virtual bool getVirtualPeerId(const ChatLobbyId& lobby_id,std::string& vpid) = 0;
|
||||
virtual void getChatLobbyList(std::list<ChatLobbyInfo>& cl_info) = 0;
|
||||
|
@ -308,6 +308,12 @@ bool p3Msgs::joinPublicChatLobby(const ChatLobbyId& lobby_id)
|
||||
return mChatSrv->joinPublicChatLobby(lobby_id) ;
|
||||
}
|
||||
|
||||
bool p3Msgs::sendLobbyStatusPeerChangedNickname(const ChatLobbyId& lobby_id)
|
||||
{
|
||||
return mChatSrv->sendLobbyStatusPeerChangedNickname(lobby_id) ;
|
||||
}
|
||||
|
||||
|
||||
void p3Msgs::getListOfNearbyChatLobbies(std::vector<PublicChatLobbyRecord>& public_lobbies)
|
||||
{
|
||||
mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ;
|
||||
|
@ -170,6 +170,9 @@ class p3Msgs: public RsMsgs
|
||||
|
||||
|
||||
virtual bool joinPublicChatLobby(const ChatLobbyId& id) ;
|
||||
|
||||
virtual bool sendLobbyStatusPeerChangedNickname(const ChatLobbyId& id) ;
|
||||
|
||||
virtual void getListOfNearbyChatLobbies(std::vector<PublicChatLobbyRecord>& public_lobbies) ;
|
||||
virtual bool getVirtualPeerId(const ChatLobbyId& id,std::string& vpid) ;
|
||||
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) ;
|
||||
|
@ -372,6 +372,7 @@ bool p3ChatService::isLobbyId(const std::string& id,ChatLobbyId& lobby_id)
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstring &msg)
|
||||
{
|
||||
// look into ID. Is it a peer, or a chat lobby?
|
||||
@ -1768,6 +1769,22 @@ void p3ChatService::sendLobbyStatusString(const ChatLobbyId& lobby_id,const std:
|
||||
{
|
||||
sendLobbyStatusItem(lobby_id,RS_CHAT_LOBBY_EVENT_PEER_STATUS,status_string) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform other Clients of a nickname change
|
||||
*
|
||||
* as example for updating their ChatLobby Blocklist for muted peers
|
||||
* */
|
||||
bool p3ChatService::sendLobbyStatusPeerChangedNickname(const ChatLobbyId& lobby_id)
|
||||
{
|
||||
std::string nick ;
|
||||
getNickNameForChatLobby(lobby_id,nick) ;
|
||||
|
||||
sendLobbyStatusItem(lobby_id,RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME,nick) ;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void p3ChatService::sendLobbyStatusPeerLiving(const ChatLobbyId& lobby_id)
|
||||
{
|
||||
std::string nick ;
|
||||
@ -2426,6 +2443,7 @@ bool p3ChatService::setNickNameForChatLobby(const ChatLobbyId& lobby_id,const st
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Changing nickname for chat lobby " << std::hex << lobby_id << std::dec << " to " << nick << std::endl;
|
||||
#endif
|
||||
@ -2437,6 +2455,10 @@ bool p3ChatService::setNickNameForChatLobby(const ChatLobbyId& lobby_id,const st
|
||||
return false;
|
||||
}
|
||||
|
||||
// // inform other user about name change
|
||||
// sendLobbyStatusPeerChangedNickname(lobby_id);
|
||||
|
||||
|
||||
it->second.nick_name = nick ;
|
||||
return true ;
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
*/
|
||||
bool sendPrivateChat(const std::string &id, const std::wstring &msg);
|
||||
|
||||
bool sendLobbyStatusPeerChangedNickname(const ChatLobbyId& lobby_id) ;
|
||||
|
||||
/*!
|
||||
* can be used to send 'immediate' status msgs, these status updates are meant for immediate use by peer (not saved by rs)
|
||||
* e.g currently used to update user when a peer 'is typing' during a chat
|
||||
@ -241,6 +243,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
|
||||
void sendLobbyStatusItem(const ChatLobbyId&, int type, const std::string& status_string) ;
|
||||
void sendLobbyStatusPeerLiving(const ChatLobbyId& lobby_id) ;
|
||||
|
||||
void sendLobbyStatusNewPeer(const ChatLobbyId& lobby_id) ;
|
||||
void sendLobbyStatusKeepAlive(const ChatLobbyId&) ;
|
||||
|
||||
|
@ -44,6 +44,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
|
||||
connect(ui.participantsFrameButton, SIGNAL(toggled(bool)), this, SLOT(showParticipantsFrame(bool)));
|
||||
connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
|
||||
|
||||
// Mute a Participant
|
||||
connect(ui.participantsList, SIGNAL(itemClicked(QListWidgetItem *)), SLOT(changePartipationState(QListWidgetItem *)));
|
||||
|
||||
ui.participantsList->sortItems(Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
@ -88,9 +91,6 @@ void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
|
||||
|
||||
/** List of muted Participants */
|
||||
mutedParticipants = new QStringList;
|
||||
|
||||
// Mute a Participant
|
||||
connect(ui.participantsList, SIGNAL(itemClicked(QListWidgetItem *)), SLOT(changePartipationState(QListWidgetItem *)));
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
@ -129,12 +129,26 @@ void ChatLobbyDialog::processSettings(bool load)
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your Nickname
|
||||
*
|
||||
* - send a Message to all Members => later: send hidden message to clients, so they can actualize there mutedParticipants list
|
||||
*/
|
||||
void ChatLobbyDialog::setNickname(const QString &nickname)
|
||||
{
|
||||
|
||||
// std::string oldNickName;
|
||||
// rsMsgs->getNickNameForChatLobby(lobbyId, oldNickName);
|
||||
|
||||
rsMsgs->sendLobbyStatusPeerChangedNickname(lobbyId);
|
||||
|
||||
rsMsgs->setNickNameForChatLobby(lobbyId, nickname.toUtf8().constData());
|
||||
ui.chatWidget->setName(nickname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog: Change your Nickname in the ChatLobby
|
||||
*/
|
||||
void ChatLobbyDialog::changeNickname()
|
||||
{
|
||||
QInputDialog dialog;
|
||||
@ -162,11 +176,15 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
||||
QString message = QString::fromStdWString(info.msg);
|
||||
QString name = QString::fromUtf8(info.peer_nickname.c_str());
|
||||
QString rsid = QString::fromUtf8(info.rsid.c_str());
|
||||
|
||||
std::cerr << "message from rsid " << info.rsid.c_str() << std::endl;
|
||||
|
||||
if (!isParticipantMuted(name)) {
|
||||
// ui.chatWidget->addChatMsg(true, name.append(" ").append(rsid), sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
|
||||
ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
|
||||
} else {
|
||||
// ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message.append(" (TEST BLOCKED)"), ChatWidget::TYPE_NORMAL);
|
||||
ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message.append(" (TEST BLOCKED)"), ChatWidget::TYPE_NORMAL);
|
||||
}
|
||||
|
||||
// also update peer list.
|
||||
@ -192,6 +210,8 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||
rsMsgs->getChatLobbyList(linfos);
|
||||
|
||||
std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());
|
||||
|
||||
// Set it to the current ChatLobby
|
||||
for (; it!=linfos.end() && (*it).lobby_id != lobbyId; ++it);
|
||||
|
||||
if (it != linfos.end()) {
|
||||
@ -207,7 +227,10 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||
widgetitem->setCheckState(Qt::Checked);
|
||||
}
|
||||
widgetitem->setText(participant);
|
||||
widgetitem->setToolTip(tr("Uncheck to mute participant"));
|
||||
// widgetitem->setToolTip(it.rsid.c_str());
|
||||
|
||||
widgetitem->setToolTip(tr("Uncheck to mute participant"));
|
||||
|
||||
ui.participantsList->addItem(widgetitem);
|
||||
}
|
||||
}
|
||||
@ -218,6 +241,8 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||
*
|
||||
* Check if the Checkbox altered and Mute User
|
||||
*
|
||||
* @todo auf rsid
|
||||
*
|
||||
* @param QListWidgetItem Participant to check
|
||||
*/
|
||||
void ChatLobbyDialog::changePartipationState(QListWidgetItem *item)
|
||||
@ -236,12 +261,20 @@ void ChatLobbyDialog::changePartipationState(QListWidgetItem *item)
|
||||
mutedParticipants->removeOne(nickname);
|
||||
}
|
||||
|
||||
mutedParticipants->removeDuplicates();
|
||||
|
||||
updateParticipantsList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should Messages from this Nickname be muted?
|
||||
*
|
||||
* At the moment it is not possible to 100% know which peer sendet the message, and only
|
||||
* the nickname is available. So this couldn't work for 100%. So, for example, if a peer
|
||||
* change his name to the name of a other peer, we couldn't block him. A real implementation
|
||||
* will be possible if we transfer a temporary Session ID from the sending Retroshare client
|
||||
* version 0.6
|
||||
*
|
||||
* @param QString nickname to check
|
||||
*/
|
||||
bool ChatLobbyDialog::isParticipantMuted(QString &participant)
|
||||
@ -269,6 +302,9 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const QString& nickname,
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
||||
ui.chatWidget->updateStatusString(nickname + " %1", str);
|
||||
break;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME:
|
||||
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 changed his name to:").arg(str), ChatWidget::TYPE_SYSTEM);
|
||||
break;
|
||||
case RS_CHAT_LOBBY_EVENT_KEEP_ALIVE:
|
||||
//std::cerr << "Received keep alive packet from " << nickname.toStdString() << " in lobby " << getPeerId() << std::endl;
|
||||
break;
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::ChatLobbyDialog ui;
|
||||
|
||||
/** Ignored Users in Chatlobby */
|
||||
/** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */
|
||||
QStringList *mutedParticipants;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user