2008-06-20 08:43:23 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Robert Fernie
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
2010-07-23 14:52:58 -04:00
|
|
|
|
|
|
|
#include <QDateTime>
|
2011-01-27 03:34:23 -05:00
|
|
|
#include <QMessageBox>
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
#include "ForumMsgItem.h"
|
|
|
|
#include "FeedHolder.h"
|
2011-05-03 19:04:42 -04:00
|
|
|
#include "gui/RetroShareLink.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsforums.h>
|
2011-01-26 04:34:48 -05:00
|
|
|
#include <retroshare/rsmsgs.h>
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
|
|
|
|
#include "gui/notifyqt.h"
|
|
|
|
|
2010-02-08 15:43:23 -05:00
|
|
|
#include "gui/forums/CreateForumMsg.h"
|
2011-01-13 17:19:20 -05:00
|
|
|
#include "gui/chat/HandleRichText.h"
|
2011-09-02 06:22:44 -04:00
|
|
|
#include "gui/common/AvatarDefs.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2011-01-26 04:34:48 -05:00
|
|
|
#include <algorithm>
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/****
|
|
|
|
* #define DEBUG_ITEM 1
|
|
|
|
****/
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/** Constructor */
|
2011-01-26 16:36:13 -05:00
|
|
|
ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, const std::string &postId, bool isHome)
|
|
|
|
:QWidget(NULL), mParent(parent), mFeedId(feedId), mForumId(forumId), mPostId(postId), mIsHome(isHome), mIsTop(false)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
setupUi(this);
|
|
|
|
|
2010-05-04 20:05:36 -04:00
|
|
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/* general ones */
|
|
|
|
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
|
|
|
|
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
|
|
|
|
|
|
|
|
/* specific ones */
|
|
|
|
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) );
|
|
|
|
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyToPost ( void ) ) );
|
2011-01-27 03:34:23 -05:00
|
|
|
connect( sendButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) );
|
2011-05-08 14:43:08 -04:00
|
|
|
|
2011-01-26 04:34:48 -05:00
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
|
2011-05-08 13:14:51 -04:00
|
|
|
|
|
|
|
subjectLabel->setMinimumWidth(20);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
small();
|
|
|
|
updateItemStatic();
|
|
|
|
updateItem();
|
2011-01-27 03:34:23 -05:00
|
|
|
textEdit->hide();
|
|
|
|
sendButton->hide();
|
|
|
|
signedcheckBox->hide();
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ForumMsgItem::updateItemStatic()
|
|
|
|
{
|
|
|
|
if (!rsForums)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* fill in */
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "ForumMsgItem::updateItemStatic()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2011-01-27 19:51:56 -05:00
|
|
|
canReply = false;
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
ForumInfo fi;
|
|
|
|
if (rsForums->getForumInfo(mForumId, fi))
|
|
|
|
{
|
2011-05-04 06:22:49 -04:00
|
|
|
RetroShareLink link;
|
2011-05-08 19:11:27 -04:00
|
|
|
link.createForum(fi.forumId, "");
|
2011-01-27 19:51:56 -05:00
|
|
|
QString title = tr("Forum Post") + ": ";
|
2011-05-03 19:04:42 -04:00
|
|
|
title += link.toHtml();
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
titleLabel->setText(title);
|
2011-01-27 19:51:56 -05:00
|
|
|
if (fi.subscribeFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED))
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2011-01-27 19:51:56 -05:00
|
|
|
unsubscribeButton->setEnabled(true);
|
2010-02-08 15:43:23 -05:00
|
|
|
replyButton->setEnabled(true);
|
2011-01-27 19:51:56 -05:00
|
|
|
|
|
|
|
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
|
|
|
{
|
|
|
|
signedcheckBox->setChecked(true);
|
|
|
|
signedcheckBox->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
canReply = true;
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-27 19:51:56 -05:00
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
replyButton->setEnabled(false);
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-13 17:19:20 -05:00
|
|
|
titleLabel->setText(tr("Unknown Forum Post"));
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get actual Message */
|
|
|
|
ForumMsgInfo msg;
|
|
|
|
if (rsForums->getForumMessage(mForumId, mPostId, msg))
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "Ids: MsgId: " << msg.msgId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "Ids: ParentId: " << msg.parentId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "Ids: ThreadId: " << msg.threadId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* decide if top or not */
|
|
|
|
if ((msg.msgId == msg.threadId) || (msg.threadId == ""))
|
|
|
|
{
|
|
|
|
mIsTop = true;
|
|
|
|
}
|
2011-01-26 04:34:48 -05:00
|
|
|
|
2011-05-04 06:22:49 -04:00
|
|
|
RetroShareLink link;
|
2011-05-08 19:11:27 -04:00
|
|
|
link.createForum(msg.forumId, msg.msgId);
|
2011-05-03 19:04:42 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
if (mIsTop)
|
2011-01-26 04:34:48 -05:00
|
|
|
{
|
2011-01-26 16:36:13 -05:00
|
|
|
mGpgIdPrev = msg.srcId;
|
|
|
|
|
|
|
|
if (rsPeers->getPeerName(msg.srcId) !="")
|
|
|
|
{
|
2011-05-08 14:43:08 -04:00
|
|
|
RetroShareLink linkMessage;
|
|
|
|
linkMessage.createMessage(msg.srcId, "");
|
|
|
|
namelabel->setText(linkMessage.toHtml());
|
2011-01-26 16:36:13 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
namelabel->setText(tr("Anonymous"));
|
|
|
|
}
|
|
|
|
|
2011-05-03 19:04:42 -04:00
|
|
|
prevSubLabel->setText(link.toHtml());
|
2011-01-13 17:19:20 -05:00
|
|
|
prevMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
2010-03-10 17:41:10 -05:00
|
|
|
|
2010-08-27 09:52:17 -04:00
|
|
|
QDateTime qtime;
|
|
|
|
qtime.setTime_t(msg.ts);
|
2011-05-08 13:14:51 -04:00
|
|
|
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
|
2011-05-08 14:43:08 -04:00
|
|
|
timestamplabel->setText(timestamp);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
nextFrame->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-26 16:36:13 -05:00
|
|
|
mGpgIdNext = msg.srcId;
|
|
|
|
|
|
|
|
if (rsPeers->getPeerName(msg.srcId) !="")
|
|
|
|
{
|
2011-05-08 14:43:08 -04:00
|
|
|
RetroShareLink linkMessage;
|
|
|
|
linkMessage.createMessage(msg.srcId, "");
|
|
|
|
nextnamelabel->setText(linkMessage.toHtml());
|
2011-01-26 16:36:13 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nextnamelabel->setText(tr("Anonymous"));
|
|
|
|
}
|
|
|
|
|
2011-05-03 19:04:42 -04:00
|
|
|
nextSubLabel->setText(link.toHtml());
|
2011-01-13 17:19:20 -05:00
|
|
|
nextMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-03-10 17:41:10 -05:00
|
|
|
QDateTime qtime;
|
2010-08-27 09:52:17 -04:00
|
|
|
qtime.setTime_t(msg.ts);
|
2011-05-08 13:14:51 -04:00
|
|
|
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
|
2010-08-27 09:52:17 -04:00
|
|
|
timestamplabel->setText(timestamp);
|
2010-03-10 17:41:10 -05:00
|
|
|
|
2010-10-23 10:08:20 -04:00
|
|
|
prevSHLabel->setText(tr("In Reply to") + ": ");
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
ForumMsgInfo msgParent;
|
|
|
|
if (rsForums->getForumMessage(mForumId, msg.parentId, msgParent))
|
|
|
|
{
|
2011-01-26 16:36:13 -05:00
|
|
|
mGpgIdPrev = msgParent.srcId;
|
|
|
|
|
2011-05-04 06:22:49 -04:00
|
|
|
RetroShareLink linkParent;
|
2011-05-08 19:11:27 -04:00
|
|
|
linkParent.createForum(msgParent.forumId, msgParent.msgId);
|
2011-05-03 19:04:42 -04:00
|
|
|
prevSubLabel->setText(linkParent.toHtml());
|
2011-01-13 17:19:20 -05:00
|
|
|
prevMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msgParent.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
2011-01-26 04:34:48 -05:00
|
|
|
|
|
|
|
if (rsPeers->getPeerName(msgParent.srcId) !="")
|
|
|
|
{
|
2011-05-08 14:43:08 -04:00
|
|
|
RetroShareLink linkMessage;
|
|
|
|
linkMessage.createMessage(msgParent.srcId, "");
|
|
|
|
namelabel->setText(linkMessage.toHtml());
|
2011-01-26 04:34:48 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-26 16:36:13 -05:00
|
|
|
namelabel->setText(tr("Anonymous"));
|
2011-01-26 04:34:48 -05:00
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prevSubLabel->setText("???");
|
|
|
|
prevMsgLabel->setText("???");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* header stuff */
|
|
|
|
subjectLabel->setText(QString::fromStdWString(msg.title));
|
2011-05-08 13:14:51 -04:00
|
|
|
//srcLabel->setText(QString::fromStdString(msg.srcId));
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mIsHome)
|
|
|
|
{
|
|
|
|
/* disable buttons */
|
|
|
|
clearButton->setEnabled(false);
|
2008-07-04 10:41:24 -04:00
|
|
|
//gotoButton->setEnabled(false);
|
|
|
|
|
|
|
|
clearButton->hide();
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
2008-07-04 10:41:24 -04:00
|
|
|
|
|
|
|
unsubscribeButton->hide();
|
2011-01-26 16:36:13 -05:00
|
|
|
|
|
|
|
showAvatar("", true);
|
|
|
|
showAvatar("", false);
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ForumMsgItem::updateItem()
|
|
|
|
{
|
|
|
|
/* fill in */
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "ForumMsgItem::updateItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ForumMsgItem::small()
|
|
|
|
{
|
|
|
|
nextFrame->hide();
|
|
|
|
prevFrame->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumMsgItem::toggle()
|
|
|
|
{
|
|
|
|
if (prevFrame->isHidden())
|
|
|
|
{
|
|
|
|
prevFrame->show();
|
2011-01-27 19:51:56 -05:00
|
|
|
textEdit->setVisible(canReply);
|
|
|
|
sendButton->setVisible(canReply);
|
|
|
|
signedcheckBox->setVisible(canReply);
|
2008-08-17 10:13:09 -04:00
|
|
|
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
|
|
|
expandButton->setToolTip("Hide");
|
2008-06-20 08:43:23 -04:00
|
|
|
if (!mIsTop)
|
|
|
|
{
|
|
|
|
nextFrame->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prevFrame->hide();
|
|
|
|
nextFrame->hide();
|
2011-01-27 03:34:23 -05:00
|
|
|
textEdit->hide();
|
|
|
|
sendButton->hide();
|
|
|
|
signedcheckBox->hide();
|
2008-08-17 10:13:09 -04:00
|
|
|
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
|
|
|
expandButton->setToolTip("Expand");
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ForumMsgItem::removeItem()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "ForumMsgItem::removeItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
hide();
|
|
|
|
if (mParent)
|
|
|
|
{
|
|
|
|
mParent->deleteFeedItem(this, mFeedId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********** SPECIFIC FUNCTIOSN ***********************/
|
|
|
|
|
|
|
|
|
|
|
|
void ForumMsgItem::unsubscribeForum()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "ForumMsgItem::unsubscribeForum()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
if (rsForums)
|
|
|
|
{
|
|
|
|
rsForums->forumSubscribe(mForumId, false);
|
|
|
|
}
|
|
|
|
updateItemStatic();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ForumMsgItem::subscribeForum()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "ForumMsgItem::subscribeForum()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
if (rsForums)
|
|
|
|
{
|
|
|
|
rsForums->forumSubscribe(mForumId, true);
|
|
|
|
}
|
|
|
|
updateItemStatic();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumMsgItem::replyToPost()
|
|
|
|
{
|
2011-01-27 19:51:56 -05:00
|
|
|
if (canReply == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "ForumMsgItem::replyToPost()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
if (mParent)
|
|
|
|
{
|
2010-05-23 19:02:15 -04:00
|
|
|
CreateForumMsg *cfm = new CreateForumMsg(mForumId, mPostId);
|
|
|
|
cfm->show();
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
2010-02-08 15:43:23 -05:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2011-01-27 03:34:23 -05:00
|
|
|
void ForumMsgItem::sendMsg()
|
|
|
|
{
|
2011-01-27 19:51:56 -05:00
|
|
|
if (canReply == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
QString desc = textEdit->toHtml();
|
|
|
|
|
2011-01-27 03:34:23 -05:00
|
|
|
if(textEdit->toPlainText().isEmpty())
|
2011-06-20 17:19:48 -04:00
|
|
|
{ /* error message */
|
2011-01-31 17:04:28 -05:00
|
|
|
QMessageBox::warning(this, "RetroShare",tr("Please give a Text Message"),
|
2011-06-20 17:19:48 -04:00
|
|
|
QMessageBox::Ok, QMessageBox::Ok);
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
return; //Don't add a empty Message!!
|
|
|
|
}
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
ForumMsgInfo msg;
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
/* get message */
|
|
|
|
if (rsForums->getForumMessage(mForumId, mPostId, msg)) {
|
|
|
|
ForumMsgInfo msgInfo;
|
|
|
|
|
|
|
|
msgInfo.forumId = mForumId;
|
|
|
|
msgInfo.threadId = "";
|
|
|
|
msgInfo.parentId = mPostId;
|
|
|
|
msgInfo.msgId = "";
|
|
|
|
|
|
|
|
/* modify title */
|
|
|
|
QString text = QString::fromStdWString(msg.title);
|
|
|
|
if (text.startsWith("Re:", Qt::CaseInsensitive)) {
|
|
|
|
msgInfo.title = msg.title;
|
|
|
|
} else {
|
|
|
|
msgInfo.title = L"Re: " + msg.title;
|
|
|
|
}
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
msgInfo.msg = desc.toStdWString();
|
|
|
|
msgInfo.msgflags = 0;
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
if (signedcheckBox->isChecked())
|
|
|
|
{
|
|
|
|
msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
|
|
|
|
}
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
if ((msgInfo.msg == L"") && (msgInfo.title == L""))
|
|
|
|
return; /* do nothing */
|
2011-01-27 03:34:23 -05:00
|
|
|
|
2011-06-20 17:19:48 -04:00
|
|
|
if (rsForums->ForumMessageSend(msgInfo) == true) {
|
|
|
|
textEdit->clear();
|
|
|
|
}
|
|
|
|
}
|
2011-01-27 03:34:23 -05:00
|
|
|
}
|
|
|
|
|
2011-01-26 04:34:48 -05:00
|
|
|
void ForumMsgItem::updateAvatar(const QString &peer_id)
|
|
|
|
{
|
2011-01-26 16:36:13 -05:00
|
|
|
if (mGpgIdPrev.empty() == false) {
|
|
|
|
/* Is this one of the ssl ids of the gpg id ? */
|
|
|
|
std::list<std::string> sslIds;
|
2011-08-07 17:14:09 -04:00
|
|
|
if (rsPeers->getAssociatedSSLIds(mGpgIdPrev, sslIds) == false) {
|
2011-01-26 16:36:13 -05:00
|
|
|
return;
|
|
|
|
}
|
2011-01-26 04:34:48 -05:00
|
|
|
|
2011-01-26 16:36:13 -05:00
|
|
|
if (std::find(sslIds.begin(), sslIds.end(), peer_id.toStdString()) != sslIds.end()) {
|
|
|
|
/* One of the ssl ids of the gpg id */
|
|
|
|
showAvatar(peer_id.toStdString(), false);
|
|
|
|
}
|
2011-01-26 04:34:48 -05:00
|
|
|
}
|
|
|
|
|
2011-01-26 16:36:13 -05:00
|
|
|
if (mGpgIdNext.empty() == false) {
|
|
|
|
/* Is this one of the ssl ids of the gpg id ? */
|
|
|
|
std::list<std::string> sslIds;
|
2011-08-07 17:14:09 -04:00
|
|
|
if (rsPeers->getAssociatedSSLIds(mGpgIdNext, sslIds) == false) {
|
2011-01-26 16:36:13 -05:00
|
|
|
return;
|
|
|
|
}
|
2011-01-26 04:34:48 -05:00
|
|
|
|
2011-01-26 16:36:13 -05:00
|
|
|
if (std::find(sslIds.begin(), sslIds.end(), peer_id.toStdString()) != sslIds.end()) {
|
|
|
|
/* One of the ssl ids of the gpg id */
|
|
|
|
showAvatar(peer_id.toStdString(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-26 04:34:48 -05:00
|
|
|
|
2011-01-26 16:36:13 -05:00
|
|
|
void ForumMsgItem::showAvatar(const std::string &peer_id, bool next)
|
2011-01-26 04:34:48 -05:00
|
|
|
{
|
2011-01-26 16:36:13 -05:00
|
|
|
std::string gpgId = next ? mGpgIdNext : mGpgIdPrev;
|
2011-09-02 06:22:44 -04:00
|
|
|
QLabel *avatarLabel = next ? nextavatarlabel : avatarlabel;
|
2011-01-26 16:36:13 -05:00
|
|
|
|
|
|
|
if (gpgId.empty()) {
|
2011-09-02 06:22:44 -04:00
|
|
|
avatarLabel->setPixmap(QPixmap(":/images/user/personal64.png"));
|
2011-01-26 04:34:48 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-02 06:22:44 -04:00
|
|
|
QPixmap avatar;
|
2011-01-26 04:34:48 -05:00
|
|
|
|
2011-01-26 16:36:13 -05:00
|
|
|
if (gpgId == rsPeers->getGPGOwnId()) {
|
2011-01-26 04:34:48 -05:00
|
|
|
/* Its me */
|
2011-09-02 06:22:44 -04:00
|
|
|
AvatarDefs::getOwnAvatar(avatar, ":/images/user/personal64.png");
|
2011-01-26 04:34:48 -05:00
|
|
|
} else {
|
|
|
|
if (peer_id.empty()) {
|
|
|
|
/* Show the first available avatar of one of the ssl ids */
|
2011-09-02 06:22:44 -04:00
|
|
|
AvatarDefs::getAvatarFromGpgId(gpgId, avatar, ":/images/user/personal64.png");
|
2011-01-26 04:34:48 -05:00
|
|
|
} else {
|
2011-09-02 06:22:44 -04:00
|
|
|
AvatarDefs::getAvatarFromSslId(peer_id, avatar, ":/images/user/personal64.png");
|
2011-01-26 04:34:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-02 06:22:44 -04:00
|
|
|
avatarLabel->setPixmap(avatar);
|
2011-01-26 04:34:48 -05:00
|
|
|
}
|