changed std::wstring for std::string+utf8 in chat, and messages

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@6795 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-10-03 21:41:34 +00:00
parent 420fadb5c3
commit 695e417fd5
24 changed files with 132 additions and 135 deletions

View file

@ -500,7 +500,7 @@ void FriendsDialog::insertChat()
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
QString name = QString::fromUtf8(rsPeers->getPeerName(it->rsid).c_str());
QString msg = QString::fromStdWString(it->msg);
QString msg = QString::fromUtf8(it->msg.c_str());
#ifdef FRIENDS_DEBUG
std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl;
@ -571,7 +571,7 @@ void FriendsDialog::sendMsg()
QString text;
RsHtml::optimizeHtml(lineWidget, text);
std::wstring message = text.toStdWString();
std::string message = text.toUtf8().constData();
#ifdef FRIENDS_DEBUG
std::string msg(message.begin(), message.end());

View file

@ -1138,7 +1138,7 @@ void MessagesDialog::insertMessages()
if(it->msgflags & RS_MSG_ENCRYPTED)
text = tr("Encrypted message. Right-click to decrypt it.") ;
else
text = QString::fromStdWString(it->title);
text = QString::fromStdString(it->title);
item[COLUMN_SUBJECT]->setText(text);
item[COLUMN_SUBJECT]->setData(text + dateString, ROLE_SORT);
@ -1206,7 +1206,7 @@ void MessagesDialog::insertMessages()
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
gotInfo = true;
QTextDocument doc;
doc.setHtml(QString::fromStdWString(msgInfo.msg));
doc.setHtml(QString::fromStdString(msgInfo.msg));
item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" ")));
} else {
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;

View file

@ -284,7 +284,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
{
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
QString message = QString::fromStdWString(info.msg);
QString message = QString::fromUtf8(info.msg.c_str());
QString name = QString::fromUtf8(info.peer_nickname.c_str());
QString rsid = QString::fromUtf8(info.rsid.c_str());

View file

@ -711,7 +711,7 @@ void ChatWidget::sendChat()
QString text;
RsHtml::optimizeHtml(chatWidget, text);
std::wstring msg = text.toStdWString();
std::string msg = text.toUtf8().constData();
if (msg.empty()) {
// nothing to send
@ -724,7 +724,7 @@ void ChatWidget::sendChat()
if (rsMsgs->sendPrivateChat(peerId, msg)) {
QDateTime currentTime = QDateTime::currentDateTime();
addChatMsg(false, name, currentTime, currentTime, QString::fromStdWString(msg), TYPE_NORMAL);
addChatMsg(false, name, currentTime, currentTime, text, TYPE_NORMAL);
}
chatWidget->clear();

View file

@ -134,7 +134,7 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info)
if (cw) {
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
QString message = QString::fromStdWString(info.msg);
QString message = QString::fromUtf8(info.msg.c_str());
QString name = getPeerName(info.rsid) ;
cw->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
@ -176,7 +176,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
QString message = QString::fromStdWString(it->msg);
QString message = QString::fromUtf8(it->msg.c_str());
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::TYPE_OFFLINE);
}
@ -195,7 +195,7 @@ void PopupChatDialog::onChatChanged(int list, int type)
for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) {
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
QString message = QString::fromStdWString(it->msg);
QString message = QString::fromUtf8(it->msg.c_str());
ui.chatWidget->addChatMsg(false, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL);
}

View file

@ -243,8 +243,8 @@ void ChatMsgItem::sendMessage()
/* construct a message */
MessageInfo mi;
mi.title = tr("Quick Message").toStdWString();
mi.msg = quickmsgText->toHtml().toStdWString();
mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mPeerId);
rsMsgs->MessageSend(mi);

View file

@ -127,12 +127,12 @@ void MsgItem::updateItemStatic()
title += srcName;
titleLabel->setText(title);
subjectLabel->setText(QString::fromStdWString(mi.title));
subjectLabel->setText(QString::fromUtf8(mi.title.c_str()));
if(mi.msgflags & RS_MSG_ENCRYPTED)
msgLabel->setText(RsHtml().formatText(NULL, tr("[Encrypted message]"), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
else
msgLabel->setText(RsHtml().formatText(NULL, QString::fromStdWString(mi.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mi.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
std::list<FileInfo>::iterator it;
for(it = mi.files.begin(); it != mi.files.end(); it++)

View file

@ -312,8 +312,8 @@ void PeerItem::sendMessage()
/* construct a message */
MessageInfo mi;
mi.title = tr("Quick Message").toStdWString();
mi.msg = quickmsgText->toHtml().toStdWString();
mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mPeerId);
rsMsgs->MessageSend(mi);

View file

@ -407,8 +407,8 @@ void SecurityItem::sendMessage()
/* construct a message */
MessageInfo mi;
mi.title = tr("Quick Message").toStdWString();
mi.msg = quickmsgText->toHtml().toStdWString();
mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mGpgId);
rsMsgs->MessageSend(mi);

View file

@ -512,14 +512,14 @@ void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const std:
if ((it->msgflags & RS_MSG_USER_REQUEST) == 0) {
continue;
}
if (it->title == title.toStdWString()) {
if (it->title == title.toUtf8().constData()) {
return;
}
}
/* create a message */
QString msgText = tr("Hi %1,<br><br>%2 wants to be friends with you on RetroShare.<br><br>Respond now:<br>%3<br><br>Thanks,<br>The RetroShare Team").arg(QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()), sslName, link.toHtml());
rsMsgs->SystemMessage(title.toStdWString(), msgText.toStdWString(), RS_MSG_USER_REQUEST);
rsMsgs->SystemMessage(title.toUtf8().constData(), msgText.toUtf8().constData(), RS_MSG_USER_REQUEST);
}
void MessageComposer::closeEvent (QCloseEvent * event)
@ -889,8 +889,8 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
// needed to send system flags with reply
msgComposer->msgFlags = (msgInfo.msgflags & RS_MSG_SYSTEM);
msgComposer->setTitleText(QString::fromStdWString(msgInfo.title));
msgComposer->setMsgText(QString::fromStdWString(msgInfo.msg));
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()));
msgComposer->setMsgText(QString::fromUtf8(msgInfo.msg.c_str()));
msgComposer->setFileList(msgInfo.files);
// get existing groups
@ -975,7 +975,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
}
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("Sent"), DateTime::formatLongDateTime(msgInfo.ts));
header += QString("<font size='3'><strong>%1: </strong>%2</font></span><br>").arg(tr("Subject"), QString::fromStdWString(msgInfo.title));
header += QString("<font size='3'><strong>%1: </strong>%2</font></span><br>").arg(tr("Subject"), QString::fromUtf8(msgInfo.title.c_str()));
header += "<br>";
header += tr("On %1, %2 wrote:").arg(DateTime::formatDateTime(msgInfo.ts), from);
@ -1034,8 +1034,8 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
/* fill it in */
msgComposer->setTitleText(QString::fromStdWString(msgInfo.title), REPLY);
msgComposer->setQuotedMsg(QString::fromStdWString(msgInfo.msg), buildReplyHeader(msgInfo));
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY);
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo));
msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false);
@ -1078,8 +1078,8 @@ MessageComposer *MessageComposer::forwardMsg(const std::string &msgId)
/* fill it in */
msgComposer->setTitleText(QString::fromStdWString(msgInfo.title), FORWARD);
msgComposer->setQuotedMsg(QString::fromStdWString(msgInfo.msg), buildReplyHeader(msgInfo));
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), FORWARD);
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo));
std::list<FileInfo>& files_info = msgInfo.files;
@ -1151,13 +1151,13 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
/* construct a message */
MessageInfo mi;
mi.title = misc::removeNewLine(ui.titleEdit->text()).toStdWString();
mi.title = misc::removeNewLine(ui.titleEdit->text()).toUtf8().constData();
// needed to send system flags with reply
mi.msgflags = msgFlags;
QString text;
RsHtml::optimizeHtml(ui.msgText, text);
mi.msg = text.toStdWString();
mi.msg = text.toUtf8().constData();
/* check for existing title */
if (bDraftbox == false && mi.title.empty()) {

View file

@ -554,9 +554,9 @@ void MessageWidget::fill(const std::string &msgId)
ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId));
}
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
ui.subjectText->setText(QString::fromUtf8(msgInfo.title.c_str()));
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS);
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS);
ui.msgText->setHtml(text);
ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));