Added quick fix to show the plain name and title in the chat lobby.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6470 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-07-01 20:35:07 +00:00
parent af5c31a4f5
commit 30c4a6ef93
8 changed files with 35 additions and 21 deletions

View file

@ -10,6 +10,7 @@
#include "common/RSTreeWidgetItem.h" #include "common/RSTreeWidgetItem.h"
#include "notifyqt.h" #include "notifyqt.h"
#include "chat/ChatLobbyDialog.h" #include "chat/ChatLobbyDialog.h"
#include "util/HandleRichText.h"
#include "retroshare/rsmsgs.h" #include "retroshare/rsmsgs.h"
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
@ -458,9 +459,9 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
QString lobby_description_string ; QString lobby_description_string ;
lobby_description_string += "<h2>"+tr("Selected lobby info")+"</h2>" ; lobby_description_string += "<h2>"+tr("Selected lobby info")+"</h2>" ;
lobby_description_string += "<b>"+tr("Lobby name: ")+"</b>\t" + (*it).lobby_name.c_str() + "<br/>" ; lobby_description_string += "<b>"+tr("Lobby name: ")+"</b>\t" + RsHtml::plainText(it->lobby_name) + "<br/>" ;
lobby_description_string += "<b>"+tr("Lobby Id: ")+"</b>\t" + QString::number((*it).lobby_id,16) + "<br/>" ; lobby_description_string += "<b>"+tr("Lobby Id: ")+"</b>\t" + QString::number((*it).lobby_id,16) + "<br/>" ;
lobby_description_string += "<b>"+tr("Topic: ")+"</b>\t" + (*it).lobby_topic.c_str() + "<br/>" ; lobby_description_string += "<b>"+tr("Topic: ")+"</b>\t" + RsHtml::plainText(it->lobby_topic) + "<br/>" ;
lobby_description_string += "<b>"+tr("Type: ")+"</b>\t" + (( (*it).lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE)?tr("Private"):tr("Public")) + "<br/>" ; lobby_description_string += "<b>"+tr("Type: ")+"</b>\t" + (( (*it).lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE)?tr("Private"):tr("Public")) + "<br/>" ;
lobby_description_string += "<b>"+tr("Peers: ")+"</b>\t" + QString::number((*it).total_number_of_peers) + "<br/>" ; lobby_description_string += "<b>"+tr("Peers: ")+"</b>\t" + QString::number((*it).total_number_of_peers) + "<br/>" ;
@ -645,7 +646,7 @@ void ChatLobbyWidget::readChatLobbyInvites()
rsMsgs->getPendingChatLobbyInvites(invites); rsMsgs->getPendingChatLobbyInvites(invites);
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it) { for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it) {
if (QMessageBox::Ok == QMessageBox::question(this, tr("Invitation to chat lobby"), tr("%1 invites you to chat lobby named %2").arg(QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())).arg(QString::fromUtf8((*it).lobby_name.c_str())), QMessageBox::Ok, QMessageBox::Ignore)) { if (QMessageBox::Ok == QMessageBox::question(this, tr("Invitation to chat lobby"), tr("%1 invites you to chat lobby named %2").arg(QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())).arg(RsHtml::plainText(it->lobby_name)), QMessageBox::Ok, QMessageBox::Ignore)) {
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl; std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl;
rsMsgs->acceptLobbyInvite((*it).lobby_id); rsMsgs->acceptLobbyInvite((*it).lobby_id);

View file

@ -34,6 +34,7 @@
#include <gui/common/html.h> #include <gui/common/html.h>
#include "gui/common/RSTreeWidgetItem.h" #include "gui/common/RSTreeWidgetItem.h"
#include "gui/common/FriendSelectionDialog.h" #include "gui/common/FriendSelectionDialog.h"
#include "util/HandleRichText.h"
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
@ -157,10 +158,10 @@ void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
std::string vpid; std::string vpid;
if (rsMsgs->getVirtualPeerId(lobbyIt->lobby_id, vpid)) { if (rsMsgs->getVirtualPeerId(lobbyIt->lobby_id, vpid)) {
if (vpid == peerId) { if (vpid == peerId) {
QString msg = tr("Welcome to lobby %1").arg(QString::fromUtf8(lobbyIt->lobby_name.c_str())); QString msg = tr("Welcome to lobby %1").arg(RsHtml::plainText(lobbyIt->lobby_name));
_lobby_name = QString::fromUtf8(lobbyIt->lobby_name.c_str()) ; _lobby_name = QString::fromUtf8(lobbyIt->lobby_name.c_str()) ;
if (!lobbyIt->lobby_topic.empty()) { if (!lobbyIt->lobby_topic.empty()) {
msg += "\n" + tr("Topic: %1").arg(QString::fromUtf8(lobbyIt->lobby_topic.c_str())); msg += "\n" + tr("Topic: %1").arg(RsHtml::plainText(lobbyIt->lobby_topic));
} }
ui.chatWidget->setWelcomeMessage(msg); ui.chatWidget->setWelcomeMessage(msg);
break; break;
@ -402,7 +403,7 @@ void ChatLobbyDialog::participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item,
if(column == COLUMN_NAME) if(column == COLUMN_NAME)
{ {
getChatWidget()->pasteText("@"+item->text(COLUMN_NAME)) ; getChatWidget()->pasteText("@" + RsHtml::plainText(item->text(COLUMN_NAME))) ;
return ; return ;
} }
@ -477,21 +478,21 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const QString& nickname,
{ {
switch (event_type) { switch (event_type) {
case RS_CHAT_LOBBY_EVENT_PEER_LEFT: case RS_CHAT_LOBBY_EVENT_PEER_LEFT:
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the lobby.").arg(str), ChatWidget::TYPE_SYSTEM); ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the lobby.").arg(RsHtml::plainText(str)), ChatWidget::TYPE_SYSTEM);
emit peerLeft(id()) ; emit peerLeft(id()) ;
break; break;
case RS_CHAT_LOBBY_EVENT_PEER_JOINED: case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the lobby.").arg(str), ChatWidget::TYPE_SYSTEM); ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the lobby.").arg(RsHtml::plainText(str)), ChatWidget::TYPE_SYSTEM);
emit peerJoined(id()) ; emit peerJoined(id()) ;
break; break;
case RS_CHAT_LOBBY_EVENT_PEER_STATUS: case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
ui.chatWidget->updateStatusString(nickname + " %1", str); ui.chatWidget->updateStatusString(RsHtml::plainText(nickname) + " %1", RsHtml::plainText(str));
if (!isParticipantMuted(nickname)) { if (!isParticipantMuted(nickname)) {
emit typingEventReceived(id()) ; emit typingEventReceived(id()) ;
} }
break; break;
case RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: 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: %2").arg(nickname, str), ChatWidget::TYPE_SYSTEM); ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 changed his name to: %2").arg(RsHtml::plainText(nickname), RsHtml::plainText(str)), ChatWidget::TYPE_SYSTEM);
// TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby // TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby
if (isParticipantMuted(nickname) && !isNicknameInLobby(str)) { if (isParticipantMuted(nickname) && !isNicknameInLobby(str)) {

View file

@ -106,6 +106,7 @@
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include "util/HandleRichText.h"
#include <retroshare/rsinit.h> #include <retroshare/rsinit.h>
@ -323,7 +324,7 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
Q_UNUSED(flag); Q_UNUSED(flag);
#endif #endif
QString formatMsg = style.replace("%name%", name) QString formatMsg = style.replace("%name%", RsHtml::plainText(name))
.replace("%date%", DateTime::formatDate(timestamp.date())) .replace("%date%", DateTime::formatDate(timestamp.date()))
.replace("%time%", DateTime::formatTime(timestamp.time())) .replace("%time%", DateTime::formatTime(timestamp.time()))
#ifdef COLORED_NICKNAMES #ifdef COLORED_NICKNAMES

View file

@ -152,7 +152,7 @@ void ChatWidget::init(const std::string &peerId, const QString &title)
this->peerId = peerId; this->peerId = peerId;
this->title = title; this->title = title;
ui->titleLabel->setText(title); ui->titleLabel->setText(RsHtml::plainText(title));
std::string ownId = rsPeers->getOwnId(); std::string ownId = rsPeers->getOwnId();
setName(QString::fromUtf8(rsPeers->getPeerName(ownId).c_str())); setName(QString::fromUtf8(rsPeers->getPeerName(ownId).c_str()));
@ -929,7 +929,7 @@ void ChatWidget::updateTitle()
return; return;
} }
ui->titleLabel->setText(name + "@" + title); ui->titleLabel->setText(RsHtml::plainText(name) + "@" + RsHtml::plainText(title));
} }
void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QString& status_string) void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QString& status_string)

View file

@ -40,7 +40,7 @@ ChatLobbyToaster::ChatLobbyToaster(const std::string &peerId, const QString &nam
ui.avatarWidget->setFrameType(AvatarWidget::NORMAL_FRAME); ui.avatarWidget->setFrameType(AvatarWidget::NORMAL_FRAME);
ui.avatarWidget->setDefaultAvatar(":images/user/agt_forum64.png"); ui.avatarWidget->setDefaultAvatar(":images/user/agt_forum64.png");
QString lobbyName = name; QString lobbyName = RsHtml::plainText(name);
std::list<ChatLobbyInfo> linfos; std::list<ChatLobbyInfo> linfos;
rsMsgs->getChatLobbyList(linfos); rsMsgs->getChatLobbyList(linfos);
@ -49,7 +49,7 @@ ChatLobbyToaster::ChatLobbyToaster(const std::string &peerId, const QString &nam
if (rsMsgs->isLobbyId(peerId, lobbyId)) { if (rsMsgs->isLobbyId(peerId, lobbyId)) {
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) { for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
if ((*it).lobby_id == lobbyId) { if ((*it).lobby_id == lobbyId) {
lobbyName += "@" + QString::fromUtf8((*it).lobby_name.c_str()); lobbyName += "@" + RsHtml::plainText(it->lobby_name);
break; break;
} }
} }

View file

@ -1376,10 +1376,6 @@ Double click lobbies to enter and chat.</source>
<source>Invitation to chat lobby</source> <source>Invitation to chat lobby</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>%1 invites you to chat lobby named %2</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Remove Auto Subscribe</source> <source>Remove Auto Subscribe</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -1388,6 +1384,10 @@ Double click lobbies to enter and chat.</source>
<source>Add Auto Subscribe</source> <source>Add Auto Subscribe</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>%1 invites you to chat lobby named %2</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>ChatMsgItem</name> <name>ChatMsgItem</name>

View file

@ -792,3 +792,13 @@ bool RsHtml::makeEmbeddedImage(const QImage &originalImage, QString &embeddedIma
} }
return true; return true;
} }
QString RsHtml::plainText(const QString &text)
{
return Qt::escape(text);
}
QString RsHtml::plainText(const std::string &text)
{
return Qt::escape(QString::fromUtf8(text.c_str()));
}

View file

@ -28,8 +28,6 @@
#ifndef HANDLE_RICH_TEXT_H_ #ifndef HANDLE_RICH_TEXT_H_
#define HANDLE_RICH_TEXT_H_ #define HANDLE_RICH_TEXT_H_
#include <QRegExp>
/* Flags for RsHtml::formatText */ /* Flags for RsHtml::formatText */
#define RSHTML_FORMATTEXT_EMBED_SMILEYS 1 #define RSHTML_FORMATTEXT_EMBED_SMILEYS 1
#define RSHTML_FORMATTEXT_EMBED_LINKS 2 #define RSHTML_FORMATTEXT_EMBED_LINKS 2
@ -71,6 +69,9 @@ public:
static bool makeEmbeddedImage(const QString &fileName, QString &embeddedImage, const int maxPixels); static bool makeEmbeddedImage(const QString &fileName, QString &embeddedImage, const int maxPixels);
static bool makeEmbeddedImage(const QImage &originalImage, QString &embeddedImage, const int maxPixels); static bool makeEmbeddedImage(const QImage &originalImage, QString &embeddedImage, const int maxPixels);
static QString plainText(const QString &text);
static QString plainText(const std::string &text);
protected: protected:
void embedHtml(QTextDocument *textDocument, QDomDocument &doc, QDomElement &currentElement, EmbedInHtml& embedInfos, ulong flag); void embedHtml(QTextDocument *textDocument, QDomDocument &doc, QDomElement &currentElement, EmbedInHtml& embedInfos, ulong flag);
void replaceAnchorWithImg(QDomDocument& doc, QDomElement &element, QTextDocument *textDocument, const RetroShareLink &link); void replaceAnchorWithImg(QDomDocument& doc, QDomElement &element, QTextDocument *textDocument, const RetroShareLink &link);