mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 07:16:11 -05:00
Fixup how REF message are displayed
Ensure RefImageCount is correct. Update docs on m(Ref)GroupPtr points to fill-in GroupPtrs on Ref Msgs. Remove mRefAuthorName as not so useful. Add images into Response Msgs. Display Headshot / Images on Ref Msgs - if possible.
This commit is contained in:
parent
fbf56fcf03
commit
f4457b1331
@ -152,10 +152,9 @@ class RsWirePulse
|
||||
std::string mRefGroupName; // PARENT_GrpName REPLY_GrpName
|
||||
RsGxsMessageId mRefOrigMsgId; // PARENT_OrigMsgId REPLY_OrigMsgId
|
||||
RsGxsId mRefAuthorId; // PARENT_AuthorId REPLY_AuthorId
|
||||
std::string mRefAuthorName; // PARENT_AuthorName REPLY_AuthorName // TODO
|
||||
rstime_t mRefPublishTs; // PARENT_PublishTs REPLY_PublishTs
|
||||
std::string mRefPulseText; // PARENT_PulseText REPLY_PulseText
|
||||
uint32_t mRefImageCount; // PARENT_#Images REPLY_#Images // TODO
|
||||
uint32_t mRefImageCount; // PARENT_#Images REPLY_#Images
|
||||
|
||||
// Additional Fields for version 2.
|
||||
// Images, need to enforce 20k limit?
|
||||
@ -167,12 +166,16 @@ class RsWirePulse
|
||||
// Below Here is not serialised.
|
||||
// They are additional fields linking pulses together or parsing elements of msg.
|
||||
|
||||
// functions.
|
||||
uint32_t ImageCount();
|
||||
|
||||
// can't have self referencial list, so need to use pointers.
|
||||
// using SharedPointers to automatically cleanup.
|
||||
|
||||
// Pointer to WireGroup.
|
||||
RsWireGroupSPtr mRefGroupPtr;
|
||||
RsWireGroupSPtr mGroupPtr;
|
||||
// Pointer to WireGroups
|
||||
// mRefGroupPtr is opportunistically filled in, but will often be empty.
|
||||
RsWireGroupSPtr mRefGroupPtr; // ORIG/RESP: N/A , REF: Reply Group
|
||||
RsWireGroupSPtr mGroupPtr; // ORIG/RESP: Own Group, REF: Parent Group
|
||||
|
||||
// These are the direct children of this message
|
||||
// split into likes, replies and retweets.
|
||||
|
@ -66,7 +66,6 @@ void RsGxsWirePulseItem::clear()
|
||||
pulse.mRefGroupName.clear();
|
||||
pulse.mRefOrigMsgId.clear();
|
||||
pulse.mRefAuthorId.clear();
|
||||
pulse.mRefAuthorName.clear();
|
||||
pulse.mRefPublishTs = 0;
|
||||
pulse.mRefPulseText.clear();
|
||||
pulse.mRefImageCount = 0;
|
||||
@ -86,7 +85,6 @@ void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefAuthorId,"pulse.mRefAuthorId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefAuthorName,"pulse.mRefAuthorName") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefPublishTs,"pulse.mRefPublishTs") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mRefPulseText,"pulse.mRefPulseText") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mRefImageCount,"pulse.mRefImageCount") ;
|
||||
|
@ -31,6 +31,23 @@
|
||||
RsWire *rsWire = NULL;
|
||||
|
||||
|
||||
uint32_t RsWirePulse::ImageCount()
|
||||
{
|
||||
if (!mImage4.empty()) {
|
||||
return 4;
|
||||
}
|
||||
if (!mImage3.empty()) {
|
||||
return 3;
|
||||
}
|
||||
if (!mImage2.empty()) {
|
||||
return 2;
|
||||
}
|
||||
if (!mImage1.empty()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
p3Wire::p3Wire(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs)
|
||||
:RsGenExchange(gds, nes, new RsGxsWireSerialiser(), RS_SERVICE_GXS_TYPE_WIRE, gixs, wireAuthenPolicy()),
|
||||
RsWire(static_cast<RsGxsIface&>(*this)), mWireMtx("WireMtx")
|
||||
@ -629,6 +646,10 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||
responsePulse.mPulseType = WIRE_PULSE_TYPE_RESPONSE | reply_type;
|
||||
responsePulse.mSentiment = pPulse->mSentiment;
|
||||
responsePulse.mPulseText = pPulse->mPulseText;
|
||||
responsePulse.mImage1 = pPulse->mImage1;
|
||||
responsePulse.mImage2 = pPulse->mImage2;
|
||||
responsePulse.mImage3 = pPulse->mImage3;
|
||||
responsePulse.mImage4 = pPulse->mImage4;
|
||||
|
||||
// mRefs refer to parent post.
|
||||
responsePulse.mRefGroupId = replyToPulse->mMeta.mGroupId;
|
||||
@ -637,6 +658,7 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||
responsePulse.mRefAuthorId = replyToPulse->mMeta.mAuthorId;
|
||||
responsePulse.mRefPublishTs = replyToPulse->mMeta.mPublishTs;
|
||||
responsePulse.mRefPulseText = replyToPulse->mPulseText;
|
||||
responsePulse.mRefImageCount = replyToPulse->ImageCount();
|
||||
|
||||
std::cerr << "p3Wire::createReplyPulse() create Response Pulse";
|
||||
std::cerr << std::endl;
|
||||
@ -720,6 +742,7 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||
refPulse.mRefAuthorId = replyWithGroup.mMeta.mAuthorId;
|
||||
refPulse.mRefPublishTs = createdResponsePulse->mMeta.mPublishTs;
|
||||
refPulse.mRefPulseText = createdResponsePulse->mPulseText;
|
||||
refPulse.mRefImageCount = createdResponsePulse->ImageCount();
|
||||
|
||||
// publish Ref Msg.
|
||||
if (!createPulse(token, refPulse))
|
||||
@ -1181,13 +1204,6 @@ bool p3Wire::extractGroupIds(RsWirePulseConstSPtr pPulse, std::set<RsGxsGroupId>
|
||||
|
||||
bool p3Wire::updateGroupPtrs(RsWirePulseSPtr pPulse, const std::map<RsGxsGroupId, RsWireGroupSPtr> &groups)
|
||||
{
|
||||
/* don't bother with Refs... though we could */
|
||||
/* do this recursively */
|
||||
if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) {
|
||||
/* skipping */
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, RsWireGroupSPtr>::const_iterator git;
|
||||
git = groups.find(pPulse->mMeta.mGroupId);
|
||||
if (git == groups.end()) {
|
||||
@ -1197,6 +1213,23 @@ bool p3Wire::updateGroupPtrs(RsWirePulseSPtr pPulse, const std::map<RsGxsGroupId
|
||||
|
||||
pPulse->mGroupPtr = git->second;
|
||||
|
||||
/* if Refs, GroupId refers to parent, so GroupPtr is parent's group
|
||||
* It should already be in groups lists - if its not... */
|
||||
if (pPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) {
|
||||
// if REF is in list, fill in (unlikely but try anyway)
|
||||
// unlikely, as we are not adding RefGroupId, as can potentially fail to look up.
|
||||
// need additional flag OKAY_IF_NONEXISTENT or similar.
|
||||
// no error if its not there.
|
||||
std::map<RsGxsGroupId, RsWireGroupSPtr>::const_iterator rgit;
|
||||
rgit = groups.find(pPulse->mRefGroupId);
|
||||
if (rgit != groups.end()) {
|
||||
pPulse->mRefGroupPtr = rgit->second;
|
||||
}
|
||||
|
||||
// no children for REF pulse, so can return now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/* recursively apply to children */
|
||||
std::list<RsWirePulseSPtr>::iterator it;
|
||||
for (it = pPulse->mReplies.begin(); it != pPulse->mReplies.end(); it++)
|
||||
|
@ -104,3 +104,34 @@ void PulseMessage::setMessage(QString msg)
|
||||
textBrowser->setPlainText(msg);
|
||||
}
|
||||
|
||||
void PulseMessage::setRefImageCount(uint32_t count)
|
||||
{
|
||||
QString msg = "Follow to see Image";
|
||||
label_image1->setText(msg);
|
||||
label_image2->setText(msg);
|
||||
label_image3->setText(msg);
|
||||
label_image4->setText(msg);
|
||||
|
||||
label_image1->setVisible(false);
|
||||
label_image2->setVisible(false);
|
||||
label_image3->setVisible(false);
|
||||
label_image4->setVisible(false);
|
||||
|
||||
switch(count) {
|
||||
case 4:
|
||||
label_image4->setVisible(true);
|
||||
case 3:
|
||||
label_image3->setVisible(true);
|
||||
case 2:
|
||||
label_image2->setVisible(true);
|
||||
case 1:
|
||||
label_image1->setVisible(true);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (count < 1) {
|
||||
frame_expand->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
|
||||
void setup(RsWirePulseSPtr pulse);
|
||||
void setMessage(QString msg);
|
||||
void setRefImageCount(uint32_t count);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -85,7 +85,7 @@ void PulseReply::setAuthorString(QString name)
|
||||
void PulseReply::setRefMessage(QString msg, uint32_t image_count)
|
||||
{
|
||||
widget_message->setMessage(msg);
|
||||
//, image_count);
|
||||
widget_message->setRefImageCount(image_count);
|
||||
}
|
||||
|
||||
void PulseReply::setMessage(RsWirePulseSPtr pulse)
|
||||
|
@ -226,6 +226,32 @@ void PulseDataItem::showPulse()
|
||||
|
||||
if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE)
|
||||
{
|
||||
|
||||
// Group
|
||||
bool headshotOkay = false;
|
||||
if (mPulse->mRefGroupPtr) {
|
||||
if (mPulse->mRefGroupPtr->mHeadshot.mData)
|
||||
{
|
||||
QPixmap pixmap;
|
||||
if (GxsIdDetails::loadPixmapFromData(
|
||||
mPulse->mRefGroupPtr->mHeadshot.mData,
|
||||
mPulse->mRefGroupPtr->mHeadshot.mSize,
|
||||
pixmap,GxsIdDetails::ORIGINAL))
|
||||
{
|
||||
headshotOkay = true;
|
||||
pixmap = pixmap.scaled(50,50);
|
||||
setHeadshot(pixmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!headshotOkay)
|
||||
{
|
||||
// default.
|
||||
QPixmap pixmap = QPixmap(":/icons/png/posted.png").scaled(50,50);
|
||||
setHeadshot(pixmap);
|
||||
}
|
||||
|
||||
// Group
|
||||
setGroupName(mPulse->mRefGroupName);
|
||||
setAuthor(mPulse->mRefAuthorId.toStdString());
|
||||
@ -235,15 +261,15 @@ void PulseDataItem::showPulse()
|
||||
setDate(mPulse->mRefPublishTs);
|
||||
|
||||
// References (unknown for a REFERENCE)
|
||||
// should show FOLLOW button instead.
|
||||
// setLikes(mPulse->mLikes.size());
|
||||
// setReplies(mPulse->mReplies.size());
|
||||
// setRepublishes(mPulse->mRepublishes.size());
|
||||
|
||||
// show FOLLOW button instead.
|
||||
showResponseStats(false);
|
||||
|
||||
//
|
||||
setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, "GroupName TODO");
|
||||
if (mPulse->mGroupPtr) {
|
||||
setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, mPulse->mGroupPtr->mMeta.mGroupName);
|
||||
} else {
|
||||
setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, "REF GROUP MISSING");
|
||||
}
|
||||
|
||||
}
|
||||
else // ORIG / RESPONSE.
|
||||
|
Loading…
x
Reference in New Issue
Block a user