diff --git a/libretroshare/src/services/p3forums.cc b/libretroshare/src/services/p3forums.cc index 54663c177..58c5cd186 100644 --- a/libretroshare/src/services/p3forums.cc +++ b/libretroshare/src/services/p3forums.cc @@ -580,7 +580,11 @@ bool p3Forums::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std:: bool p3Forums::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id) { - getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, msg->grpId, msg->msgId, msg->personalSignature.keyId); + std::string grpId = msg->grpId; + std::string msgId = msg->msgId; + std::string nullId; + + getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, grpId, msgId, nullId); return true; } diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 0efb7ed6f..0a3fbff6c 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -330,7 +330,7 @@ void NewsFeed::addFeedItemForumUpdate(RsFeedItem &fi) void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi) { /* make new widget */ - ForumMsgItem *fm = new ForumMsgItem(this, NEWSFEED_FORUMMSGLIST, fi.mId1, fi.mId2, fi.mId3, false); + ForumMsgItem *fm = new ForumMsgItem(this, NEWSFEED_FORUMMSGLIST, fi.mId1, fi.mId2, false); /* store in forum list */ diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp index e1445a2c1..dd70773c6 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp @@ -40,9 +40,8 @@ ****/ /** Constructor */ -ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, std::string forumId, std::string postId, std::string gpgId, bool isHome) -:QWidget(NULL), mParent(parent), mFeedId(feedId), - mForumId(forumId), mPostId(postId), mGpgId(gpgId), mIsHome(isHome), mIsTop(false) +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) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -63,7 +62,6 @@ ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, std::string foru small(); updateItemStatic(); updateItem(); - showAvatar(""); } @@ -72,7 +70,6 @@ void ForumMsgItem::updateItemStatic() if (!rsForums) return; - /* fill in */ #ifdef DEBUG_ITEM std::cerr << "ForumMsgItem::updateItemStatic()"; @@ -121,19 +118,19 @@ void ForumMsgItem::updateItemStatic() mIsTop = true; } - if (rsPeers->getPeerName(msg.srcId) !="") - { - namelabel->setText(QString::fromStdString(rsPeers->getPeerName(msg.srcId))); - } - else - { - namelabel->setText(tr("Anonymous")); - } - if (mIsTop) { - - prevSHLabel->setText("Subject: "); + mGpgIdPrev = msg.srcId; + + if (rsPeers->getPeerName(msg.srcId) !="") + { + namelabel->setText(QString::fromStdString(rsPeers->getPeerName(msg.srcId))); + } + else + { + namelabel->setText(tr("Anonymous")); + } + prevSubLabel->setText(QString::fromStdWString(msg.title)); prevMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); @@ -146,6 +143,17 @@ void ForumMsgItem::updateItemStatic() } else { + mGpgIdNext = msg.srcId; + + if (rsPeers->getPeerName(msg.srcId) !="") + { + nextnamelabel->setText(QString::fromStdString(rsPeers->getPeerName(msg.srcId))); + } + else + { + nextnamelabel->setText(tr("Anonymous")); + } + nextSubLabel->setText(QString::fromStdWString(msg.title)); nextMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); @@ -159,18 +167,19 @@ void ForumMsgItem::updateItemStatic() ForumMsgInfo msgParent; if (rsForums->getForumMessage(mForumId, msg.parentId, msgParent)) { + mGpgIdPrev = msgParent.srcId; + prevSubLabel->setText(QString::fromStdWString(msgParent.title)); prevMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msgParent.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); if (rsPeers->getPeerName(msgParent.srcId) !="") { - nextnamelabel->setText(QString::fromStdString(rsPeers->getPeerName(msgParent.srcId))); + namelabel->setText(QString::fromStdString(rsPeers->getPeerName(msgParent.srcId))); } else { - nextnamelabel->setText(tr("Anonymous")); + namelabel->setText(tr("Anonymous")); } - } else { @@ -195,6 +204,9 @@ void ForumMsgItem::updateItemStatic() } unsubscribeButton->hide(); + + showAvatar("", true); + showAvatar("", false); } @@ -306,44 +318,54 @@ void ForumMsgItem::replyToPost() void ForumMsgItem::updateAvatar(const QString &peer_id) { - if (mGpgId.empty()) { - /* Message is not signed */ - return; + if (mGpgIdPrev.empty() == false) { + /* Is this one of the ssl ids of the gpg id ? */ + std::list sslIds; + if (rsPeers->getSSLChildListOfGPGId(mGpgIdPrev, sslIds) == false) { + return; + } + + 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); + } } - /* Is this one of the ssl ids of the gpg id ? */ - std::list sslIds; - if (rsPeers->getSSLChildListOfGPGId(mGpgId, sslIds) == false) { - return; + if (mGpgIdNext.empty() == false) { + /* Is this one of the ssl ids of the gpg id ? */ + std::list sslIds; + if (rsPeers->getSSLChildListOfGPGId(mGpgIdNext, sslIds) == false) { + return; + } + + 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); + } } +} - if (std::find(sslIds.begin(), sslIds.end(), peer_id.toStdString()) == sslIds.end()) { - /* Not one of the ssl ids of the gpg id */ - return; - } - - showAvatar(peer_id.toStdString()); -} - -void ForumMsgItem::showAvatar(const std::string &peer_id) +void ForumMsgItem::showAvatar(const std::string &peer_id, bool next) { - if (mGpgId.empty()) { - /* Message is not signed */ - avatarlabel->setPixmap(QPixmap(":/images/user/personal64.png")); + std::string gpgId = next ? mGpgIdNext : mGpgIdPrev; + QLabel *avatar = next ? nextavatarlabel : avatarlabel; + + if (gpgId.empty()) { + avatar->setPixmap(QPixmap(":/images/user/personal64.png")); return; } unsigned char *data = NULL; int size = 0 ; - if (mGpgId == rsPeers->getGPGOwnId()) { + if (gpgId == rsPeers->getGPGOwnId()) { /* Its me */ rsMsgs->getOwnAvatarData(data,size); } else { if (peer_id.empty()) { /* Show the first available avatar of one of the ssl ids */ std::list sslIds; - if (rsPeers->getSSLChildListOfGPGId(mGpgId, sslIds) == false) { + if (rsPeers->getSSLChildListOfGPGId(gpgId, sslIds) == false) { return; } @@ -363,9 +385,9 @@ void ForumMsgItem::showAvatar(const std::string &peer_id) // set the image QPixmap pix ; pix.loadFromData(data,size,"PNG") ; - avatarlabel->setPixmap(pix); + avatar->setPixmap(pix); delete[] data ; } else { - avatarlabel->setPixmap(QPixmap(":/images/user/personal64.png")); + avatar->setPixmap(QPixmap(":/images/user/personal64.png")); } } diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.h b/retroshare-gui/src/gui/feeds/ForumMsgItem.h index bd20f9d27..653c8bb60 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.h +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.h @@ -33,7 +33,7 @@ class ForumMsgItem : public QWidget, private Ui::ForumMsgItem public: /** Default Constructor */ - ForumMsgItem(FeedHolder *parent, uint32_t feedId, std::string forumId, std::string postId, std::string gpgId, bool isHome); + ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::string &forumId, const std::string &postId, bool isHome); /** Default Destructor */ @@ -54,14 +54,15 @@ private slots: void updateAvatar(const QString &peer_id); private: - void showAvatar(const std::string &peer_id); + void showAvatar(const std::string &peer_id, bool next); FeedHolder *mParent; uint32_t mFeedId; std::string mForumId; std::string mPostId; - std::string mGpgId; + std::string mGpgIdPrev; + std::string mGpgIdNext; bool mIsHome; bool mIsTop; };