mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
Move createOriginalPulse / createReplyPulse to libretroshare
message creation logic moved to libretroshare GUI classes cleaned up.
This commit is contained in:
parent
11ce959b2f
commit
8df5a886db
10 changed files with 292 additions and 221 deletions
|
@ -144,7 +144,7 @@ class RsWirePulse
|
||||||
std::string mPulseText;
|
std::string mPulseText;
|
||||||
|
|
||||||
uint32_t mPulseType;
|
uint32_t mPulseType;
|
||||||
uint32_t mReplySentiment; // only relevant if a reply.
|
uint32_t mSentiment; // sentiment can be asserted at any point.
|
||||||
|
|
||||||
// These Ref to the related (parent or reply) if reply (RESPONSE set)
|
// These Ref to the related (parent or reply) if reply (RESPONSE set)
|
||||||
// Mode RESPONSE REFERENCE
|
// Mode RESPONSE REFERENCE
|
||||||
|
@ -222,13 +222,15 @@ virtual bool getGroups(const std::list<RsGxsGroupId> grpIds,
|
||||||
// New Blocking Interfaces.
|
// New Blocking Interfaces.
|
||||||
// Plan to migrate all GUI calls to these, and remove old interfaces above.
|
// Plan to migrate all GUI calls to these, and remove old interfaces above.
|
||||||
// These are not single requests, but return data graphs for display.
|
// These are not single requests, but return data graphs for display.
|
||||||
virtual bool createOriginalPulse(RsGxsGroupId grpId, std::string msg) = 0;
|
virtual bool createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) = 0;
|
||||||
virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId,
|
virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId,
|
||||||
RsGxsGroupId replyWith, uint32_t reply_type,
|
RsGxsGroupId replyWith, uint32_t reply_type,
|
||||||
uint32_t sentiment, std::string msg) = 0;
|
RsWirePulseSPtr pPulse) = 0;
|
||||||
|
|
||||||
// Provide Group Details for display.
|
|
||||||
|
// Provide Individual Group Details for display.
|
||||||
virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) = 0;
|
virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) = 0;
|
||||||
|
virtual bool getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) = 0;
|
||||||
|
|
||||||
// Provide list of pulses associated with groups.
|
// Provide list of pulses associated with groups.
|
||||||
virtual bool getPulsesForGroups(const std::list<RsGxsGroupId> &groupIds,
|
virtual bool getPulsesForGroups(const std::list<RsGxsGroupId> &groupIds,
|
||||||
|
|
|
@ -61,7 +61,7 @@ void RsGxsWirePulseItem::clear()
|
||||||
{
|
{
|
||||||
pulse.mPulseText.clear();
|
pulse.mPulseText.clear();
|
||||||
pulse.mPulseType = 0;
|
pulse.mPulseType = 0;
|
||||||
pulse.mReplySentiment = 0;
|
pulse.mSentiment = 0;
|
||||||
pulse.mRefGroupId.clear();
|
pulse.mRefGroupId.clear();
|
||||||
pulse.mRefGroupName.clear();
|
pulse.mRefGroupName.clear();
|
||||||
pulse.mRefOrigMsgId.clear();
|
pulse.mRefOrigMsgId.clear();
|
||||||
|
@ -81,7 +81,7 @@ void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
|
||||||
{
|
{
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
|
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ;
|
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ;
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mReplySentiment,"pulse.mReplySentiment") ;
|
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mSentiment,"pulse.mSentiment") ;
|
||||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ;
|
RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ;
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
|
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.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;
|
||||||
|
|
|
@ -447,6 +447,10 @@ bool p3Wire::fetchPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsWirePulseSPt
|
||||||
pPulse = std::make_shared<RsWirePulse>(pulses[0]);
|
pPulse = std::make_shared<RsWirePulse>(pulses[0]);
|
||||||
std::cerr << "p3Wire::fetchPulse() retrieved token: " << *pPulse;
|
std::cerr << "p3Wire::fetchPulse() retrieved token: " << *pPulse;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "p3Wire::fetchPulse() ANS GrpId: " << pPulse->mMeta.mGroupId;
|
||||||
|
std::cerr << " MsgId: " << pPulse->mMeta.mMsgId;
|
||||||
|
std::cerr << " OrigMsgId: " << pPulse->mMeta.mOrigMsgId;
|
||||||
|
std::cerr << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "p3Wire::fetchPulse() ERROR multiple pulses";
|
std::cerr << "p3Wire::fetchPulse() ERROR multiple pulses";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -469,8 +473,7 @@ bool p3Wire::fetchPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsWirePulseSPt
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Interfaces.
|
// New Interfaces.
|
||||||
// TODO: createOriginalPulse has not been tested.
|
bool p3Wire::createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse)
|
||||||
bool p3Wire::createOriginalPulse(RsGxsGroupId grpId, std::string msg)
|
|
||||||
{
|
{
|
||||||
// request Group.
|
// request Group.
|
||||||
std::list<RsGxsGroupId> groupIds = { grpId };
|
std::list<RsGxsGroupId> groupIds = { grpId };
|
||||||
|
@ -499,6 +502,7 @@ bool p3Wire::createOriginalPulse(RsGxsGroupId grpId, std::string msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Msg.
|
// Create Msg.
|
||||||
|
// Start fresh, just to be sure nothing dodgy happens in UX world.
|
||||||
RsWirePulse pulse;
|
RsWirePulse pulse;
|
||||||
|
|
||||||
pulse.mMeta.mGroupId = group.mMeta.mGroupId;
|
pulse.mMeta.mGroupId = group.mMeta.mGroupId;
|
||||||
|
@ -507,9 +511,14 @@ bool p3Wire::createOriginalPulse(RsGxsGroupId grpId, std::string msg)
|
||||||
pulse.mMeta.mParentId.clear();
|
pulse.mMeta.mParentId.clear();
|
||||||
pulse.mMeta.mOrigMsgId.clear();
|
pulse.mMeta.mOrigMsgId.clear();
|
||||||
|
|
||||||
|
// copy info over
|
||||||
pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL;
|
pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL;
|
||||||
pulse.mReplySentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
|
pulse.mSentiment = pPulse->mSentiment;
|
||||||
pulse.mPulseText = msg;
|
pulse.mPulseText = pPulse->mPulseText;
|
||||||
|
pulse.mImage1 = pPulse->mImage1;
|
||||||
|
pulse.mImage2 = pPulse->mImage2;
|
||||||
|
pulse.mImage3 = pPulse->mImage3;
|
||||||
|
pulse.mImage4 = pPulse->mImage4;
|
||||||
|
|
||||||
// all mRefs should empty.
|
// all mRefs should empty.
|
||||||
|
|
||||||
|
@ -527,8 +536,7 @@ bool p3Wire::createOriginalPulse(RsGxsGroupId grpId, std::string msg)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: createReplyPulse has not been tested.
|
bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGroupId replyWith, uint32_t reply_type, RsWirePulseSPtr pPulse)
|
||||||
bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGroupId replyWith, uint32_t reply_type, uint32_t /*sentiment*/, std::string msg)
|
|
||||||
{
|
{
|
||||||
// check reply_type. can only be ONE.
|
// check reply_type. can only be ONE.
|
||||||
if (!((reply_type == WIRE_PULSE_TYPE_REPLY) ||
|
if (!((reply_type == WIRE_PULSE_TYPE_REPLY) ||
|
||||||
|
@ -550,26 +558,41 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 2) {
|
|
||||||
std::cerr << "p3Wire::createReplyPulse() getGroups != 2";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract group info.
|
// extract group info.
|
||||||
RsWireGroup replyToGroup;
|
RsWireGroup replyToGroup;
|
||||||
RsWireGroup replyWithGroup;
|
RsWireGroup replyWithGroup;
|
||||||
|
|
||||||
if (groups[0].mMeta.mGroupId == grpId) {
|
if (grpId == replyWith)
|
||||||
|
{
|
||||||
|
if (groups.size() != 1) {
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() getGroups != 1";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
replyToGroup = groups[0];
|
replyToGroup = groups[0];
|
||||||
replyWithGroup = groups[1];
|
|
||||||
} else {
|
|
||||||
replyToGroup = groups[1];
|
|
||||||
replyWithGroup = groups[0];
|
replyWithGroup = groups[0];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (groups.size() != 2) {
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() getGroups != 2";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groups[0].mMeta.mGroupId == grpId) {
|
||||||
|
replyToGroup = groups[0];
|
||||||
|
replyWithGroup = groups[1];
|
||||||
|
} else {
|
||||||
|
replyToGroup = groups[1];
|
||||||
|
replyWithGroup = groups[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check groupIds match
|
||||||
if ((replyToGroup.mMeta.mGroupId != grpId) ||
|
if ((replyToGroup.mMeta.mGroupId != grpId) ||
|
||||||
(replyToGroup.mMeta.mGroupId != replyWith))
|
(replyWithGroup.mMeta.mGroupId != replyWith))
|
||||||
{
|
{
|
||||||
std::cerr << "p3Wire::createReplyPulse() groupid mismatch";
|
std::cerr << "p3Wire::createReplyPulse() groupid mismatch";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -604,8 +627,8 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||||
responsePulse.mMeta.mOrigMsgId.clear();
|
responsePulse.mMeta.mOrigMsgId.clear();
|
||||||
|
|
||||||
responsePulse.mPulseType = WIRE_PULSE_TYPE_RESPONSE | reply_type;
|
responsePulse.mPulseType = WIRE_PULSE_TYPE_RESPONSE | reply_type;
|
||||||
responsePulse.mReplySentiment = 0; // toPulseSentiment(ui.comboBox_sentiment->currentIndex());
|
responsePulse.mSentiment = pPulse->mSentiment;
|
||||||
responsePulse.mPulseText = msg; // ui.textEdit_Pulse->toPlainText().toStdString();
|
responsePulse.mPulseText = pPulse->mPulseText;
|
||||||
|
|
||||||
// mRefs refer to parent post.
|
// mRefs refer to parent post.
|
||||||
responsePulse.mRefGroupId = replyToPulse->mMeta.mGroupId;
|
responsePulse.mRefGroupId = replyToPulse->mMeta.mGroupId;
|
||||||
|
@ -615,13 +638,59 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||||
responsePulse.mRefPublishTs = replyToPulse->mMeta.mPublishTs;
|
responsePulse.mRefPublishTs = replyToPulse->mMeta.mPublishTs;
|
||||||
responsePulse.mRefPulseText = replyToPulse->mPulseText;
|
responsePulse.mRefPulseText = replyToPulse->mPulseText;
|
||||||
|
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() create Response Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
createPulse(token, responsePulse);
|
if (!createPulse(token, responsePulse))
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() FAILED to create Response Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = waitToken(token);
|
||||||
|
if (result != RsTokenService::COMPLETE)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() FAILED(2) to create Response Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// get MsgId.
|
// get MsgId.
|
||||||
|
std::pair<RsGxsGroupId, RsGxsMessageId> responsePair;
|
||||||
|
if (!acknowledgeMsg(token, responsePair))
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() FAILED acknowledgeMsg for Response Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// update responsePulse.
|
std::cerr << "p3Wire::createReplyPulse() Response Pulse ID: (";
|
||||||
// TODO.
|
std::cerr << responsePair.first.toStdString() << ", ";
|
||||||
|
std::cerr << responsePair.second.toStdString() << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
// retrieve newly generated message.
|
||||||
|
// **********************************************************
|
||||||
|
RsWirePulseSPtr createdResponsePulse;
|
||||||
|
if (!fetchPulse(responsePair.first, responsePair.second, createdResponsePulse))
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() fetch createdReponsePulse FAILED";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that pulses is created properly */
|
||||||
|
if ((createdResponsePulse->mMeta.mGroupId != responsePulse.mMeta.mGroupId) ||
|
||||||
|
(createdResponsePulse->mPulseText != responsePulse.mPulseText) ||
|
||||||
|
(createdResponsePulse->mRefGroupId != responsePulse.mRefGroupId) ||
|
||||||
|
(createdResponsePulse->mRefOrigMsgId != responsePulse.mRefOrigMsgId))
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() fetch createdReponsePulse FAILED";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// create ReplyTo Ref Msg.
|
// create ReplyTo Ref Msg.
|
||||||
std::cerr << "PulseAddDialog::postRefPulse() create Reference!";
|
std::cerr << "PulseAddDialog::postRefPulse() create Reference!";
|
||||||
|
@ -637,7 +706,7 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||||
refPulse.mMeta.mOrigMsgId.clear();
|
refPulse.mMeta.mOrigMsgId.clear();
|
||||||
|
|
||||||
refPulse.mPulseType = WIRE_PULSE_TYPE_REFERENCE | reply_type;
|
refPulse.mPulseType = WIRE_PULSE_TYPE_REFERENCE | reply_type;
|
||||||
refPulse.mReplySentiment = 0; //toPulseSentiment(ui.comboBox_sentiment->currentIndex());
|
refPulse.mSentiment = 0; // should this be =? createdResponsePulse->mSentiment;
|
||||||
|
|
||||||
// Dont put parent PulseText into refPulse - it is available on Thread Msg.
|
// Dont put parent PulseText into refPulse - it is available on Thread Msg.
|
||||||
// otherwise gives impression it is correctly setup Parent / Reply...
|
// otherwise gives impression it is correctly setup Parent / Reply...
|
||||||
|
@ -647,15 +716,41 @@ bool p3Wire::createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsGxsGro
|
||||||
// refs refer back to own Post.
|
// refs refer back to own Post.
|
||||||
refPulse.mRefGroupId = replyWithGroup.mMeta.mGroupId;
|
refPulse.mRefGroupId = replyWithGroup.mMeta.mGroupId;
|
||||||
refPulse.mRefGroupName = replyWithGroup.mMeta.mGroupName;
|
refPulse.mRefGroupName = replyWithGroup.mMeta.mGroupName;
|
||||||
refPulse.mRefOrigMsgId = responsePulse.mMeta.mOrigMsgId;
|
refPulse.mRefOrigMsgId = createdResponsePulse->mMeta.mOrigMsgId;
|
||||||
refPulse.mRefAuthorId = replyWithGroup.mMeta.mAuthorId;
|
refPulse.mRefAuthorId = replyWithGroup.mMeta.mAuthorId;
|
||||||
refPulse.mRefPublishTs = responsePulse.mMeta.mPublishTs;
|
refPulse.mRefPublishTs = createdResponsePulse->mMeta.mPublishTs;
|
||||||
refPulse.mRefPulseText = responsePulse.mPulseText;
|
refPulse.mRefPulseText = createdResponsePulse->mPulseText;
|
||||||
|
|
||||||
// uint32_t token;
|
|
||||||
rsWire->createPulse(token, refPulse);
|
|
||||||
|
|
||||||
// publish Ref Msg.
|
// publish Ref Msg.
|
||||||
|
if (!createPulse(token, refPulse))
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() FAILED to create Ref Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = waitToken(token);
|
||||||
|
if (result != RsTokenService::COMPLETE)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() FAILED(2) to create Ref Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get MsgId.
|
||||||
|
std::pair<RsGxsGroupId, RsGxsMessageId> refPair;
|
||||||
|
if (!acknowledgeMsg(token, refPair))
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() FAILED acknowledgeMsg for Ref Pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "p3Wire::createReplyPulse() Success: Ref Pulse ID: (";
|
||||||
|
std::cerr << refPair.first.toStdString() << ", ";
|
||||||
|
std::cerr << refPair.second.toStdString() << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,6 +801,15 @@ bool p3Wire::getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Remove duplicate ...
|
||||||
|
bool p3Wire::getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse)
|
||||||
|
{
|
||||||
|
return fetchPulse(groupId, msgId, pPulse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool compare_time(const RsWirePulseSPtr& first, const RsWirePulseSPtr &second)
|
bool compare_time(const RsWirePulseSPtr& first, const RsWirePulseSPtr &second)
|
||||||
{
|
{
|
||||||
return first->mMeta.mPublishTs > second->mMeta.mPublishTs;
|
return first->mMeta.mPublishTs > second->mMeta.mPublishTs;
|
||||||
|
|
|
@ -63,10 +63,10 @@ public:
|
||||||
|
|
||||||
// New Interfaces.
|
// New Interfaces.
|
||||||
// Blocking, request structures for display.
|
// Blocking, request structures for display.
|
||||||
virtual bool createOriginalPulse(RsGxsGroupId grpId, std::string msg) override;
|
virtual bool createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) override;
|
||||||
virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId,
|
virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId,
|
||||||
RsGxsGroupId replyWith, uint32_t reply_type,
|
RsGxsGroupId replyWith, uint32_t reply_type,
|
||||||
uint32_t sentiment, std::string msg) override;
|
RsWirePulseSPtr pPulse) override;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
virtual bool createReplyPulse(uint32_t &token, RsWirePulse &pulse) override;
|
virtual bool createReplyPulse(uint32_t &token, RsWirePulse &pulse) override;
|
||||||
|
@ -75,6 +75,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) override;
|
virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) override;
|
||||||
|
virtual bool getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) override;
|
||||||
|
|
||||||
virtual bool getPulsesForGroups(const std::list<RsGxsGroupId> &groupIds, std::list<RsWirePulseSPtr> &pulsePtrs) override;
|
virtual bool getPulsesForGroups(const std::list<RsGxsGroupId> &groupIds, std::list<RsWirePulseSPtr> &pulsePtrs) override;
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,10 @@ const uint32_t PULSE_MAX_SIZE = 1000; // 1k char.
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
PulseAddDialog::PulseAddDialog(QWidget *parent)
|
PulseAddDialog::PulseAddDialog(QWidget *parent)
|
||||||
: QWidget(parent), mIsReply(false), mWaitingRefMsg(false)
|
: QWidget(parent), mIsReply(false)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
mWireQueue = new TokenQueue(rsWire->getTokenService(), this);
|
|
||||||
|
|
||||||
connect(ui.pushButton_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) );
|
connect(ui.pushButton_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) );
|
||||||
connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( void ) ) );
|
connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( void ) ) );
|
||||||
connect(ui.pushButton_ClearDisplayAs, SIGNAL( clicked( void ) ), this, SLOT( clearDisplayAs( void ) ) );
|
connect(ui.pushButton_ClearDisplayAs, SIGNAL( clicked( void ) ), this, SLOT( clearDisplayAs( void ) ) );
|
||||||
|
@ -48,12 +46,21 @@ void PulseAddDialog::setGroup(RsWireGroup &group)
|
||||||
mGroup = group;
|
mGroup = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set ReplyWith Group.
|
||||||
|
void PulseAddDialog::setGroup(const RsGxsGroupId &grpId)
|
||||||
|
{
|
||||||
|
/* fetch in the background */
|
||||||
|
RsWireGroupSPtr pGroup;
|
||||||
|
rsWire->getWireGroup(grpId, pGroup);
|
||||||
|
|
||||||
|
setGroup(*pGroup);
|
||||||
|
}
|
||||||
|
|
||||||
void PulseAddDialog::cleanup()
|
void PulseAddDialog::cleanup()
|
||||||
{
|
{
|
||||||
if (mIsReply)
|
if (mIsReply)
|
||||||
{
|
{
|
||||||
std::cerr << "PulseAddDialog::setReplyTo() cleaning up old replyto";
|
std::cerr << "PulseAddDialog::cleanup() cleaning up old replyto";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
QLayout *layout = ui.widget_replyto->layout();
|
QLayout *layout = ui.widget_replyto->layout();
|
||||||
// completely delete layout and sublayouts
|
// completely delete layout and sublayouts
|
||||||
|
@ -63,14 +70,14 @@ void PulseAddDialog::cleanup()
|
||||||
{
|
{
|
||||||
if ((widget = item->widget()) != 0)
|
if ((widget = item->widget()) != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "PulseAddDialog::setReplyTo() removing widget";
|
std::cerr << "PulseAddDialog::cleanup() removing widget";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
widget->hide();
|
widget->hide();
|
||||||
delete widget;
|
delete widget;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "PulseAddDialog::setReplyTo() removing item";
|
std::cerr << "PulseAddDialog::cleanup() removing item";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
@ -96,11 +103,11 @@ void PulseAddDialog::pulseTextChanged()
|
||||||
ui.pushButton_Post->setEnabled(enable);
|
ui.pushButton_Post->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Old Interface, deprecate / make internal.
|
||||||
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
|
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
|
||||||
{
|
{
|
||||||
mIsReply = true;
|
mIsReply = true;
|
||||||
mReplyToPulse = pulse;
|
mReplyToPulse = pulse;
|
||||||
mReplyGroupName = groupName;
|
|
||||||
ui.frame_reply->setVisible(true);
|
ui.frame_reply->setVisible(true);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -116,6 +123,27 @@ void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PulseAddDialog::setReplyTo(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId)
|
||||||
|
{
|
||||||
|
/* fetch in the background */
|
||||||
|
RsWireGroupSPtr pGroup;
|
||||||
|
if (!rsWire->getWireGroup(grpId, pGroup))
|
||||||
|
{
|
||||||
|
std::cerr << "PulseAddDialog::setRplyTo() failed to fetch group";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsWirePulseSPtr pPulse;
|
||||||
|
if (!rsWire->getWirePulse(grpId, msgId, pPulse))
|
||||||
|
{
|
||||||
|
std::cerr << "PulseAddDialog::setRplyTo() failed to fetch pulse";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setReplyTo(*pPulse, pGroup->mMeta.mGroupName);
|
||||||
|
}
|
||||||
|
|
||||||
void PulseAddDialog::addURL()
|
void PulseAddDialog::addURL()
|
||||||
{
|
{
|
||||||
|
@ -164,21 +192,19 @@ void PulseAddDialog::postOriginalPulse()
|
||||||
std::cerr << "PulseAddDialog::postOriginalPulse()";
|
std::cerr << "PulseAddDialog::postOriginalPulse()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
RsWirePulse pulse;
|
RsWirePulseSPtr pPulse(new RsWirePulse());
|
||||||
|
|
||||||
pulse.mMeta.mGroupId = mGroup.mMeta.mGroupId;
|
pPulse->mSentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
|
||||||
pulse.mMeta.mAuthorId = mGroup.mMeta.mAuthorId;
|
pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
|
||||||
pulse.mMeta.mThreadId.clear();
|
// set images here too.
|
||||||
pulse.mMeta.mParentId.clear();
|
|
||||||
pulse.mMeta.mOrigMsgId.clear();
|
|
||||||
|
|
||||||
pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL;
|
// this should be in async thread, so doesn't block UI thread.
|
||||||
pulse.mReplySentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
|
if (!rsWire->createOriginalPulse(mGroup.mMeta.mGroupId, pPulse))
|
||||||
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
|
{
|
||||||
// all mRefs should empty.
|
std::cerr << "PulseAddDialog::postOriginalPulse() FAILED";
|
||||||
|
std::cerr << std::endl;
|
||||||
uint32_t token;
|
return;
|
||||||
rsWire->createPulse(token, pulse);
|
}
|
||||||
|
|
||||||
clearDialog();
|
clearDialog();
|
||||||
hide();
|
hide();
|
||||||
|
@ -211,67 +237,23 @@ void PulseAddDialog::postReplyPulse()
|
||||||
std::cerr << "PulseAddDialog::postReplyPulse()";
|
std::cerr << "PulseAddDialog::postReplyPulse()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
RsWirePulse pulse;
|
RsWirePulseSPtr pPulse(new RsWirePulse());
|
||||||
|
|
||||||
pulse.mMeta.mGroupId = mGroup.mMeta.mGroupId;
|
pPulse->mSentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
|
||||||
pulse.mMeta.mAuthorId = mGroup.mMeta.mAuthorId;
|
pPulse->mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
|
||||||
pulse.mMeta.mThreadId.clear();
|
// set images too.
|
||||||
pulse.mMeta.mParentId.clear();
|
|
||||||
pulse.mMeta.mOrigMsgId.clear();
|
|
||||||
|
|
||||||
pulse.mPulseType = WIRE_PULSE_TYPE_RESPONSE | WIRE_PULSE_TYPE_REPLY;
|
// this should be in async thread, so doesn't block UI thread.
|
||||||
pulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
|
if (!rsWire->createReplyPulse(mReplyToPulse.mMeta.mGroupId,
|
||||||
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
|
mReplyToPulse.mMeta.mOrigMsgId,
|
||||||
|
mGroup.mMeta.mGroupId,
|
||||||
// mRefs refer to parent post.
|
WIRE_PULSE_TYPE_REPLY,
|
||||||
pulse.mRefGroupId = mReplyToPulse.mMeta.mGroupId;
|
pPulse))
|
||||||
pulse.mRefGroupName = mReplyGroupName;
|
{
|
||||||
pulse.mRefOrigMsgId = mReplyToPulse.mMeta.mOrigMsgId;
|
std::cerr << "PulseAddDialog::postReplyPulse() FAILED";
|
||||||
pulse.mRefAuthorId = mReplyToPulse.mMeta.mAuthorId;
|
std::cerr << std::endl;
|
||||||
pulse.mRefPublishTs = mReplyToPulse.mMeta.mPublishTs;
|
return;
|
||||||
pulse.mRefPulseText = mReplyToPulse.mPulseText;
|
}
|
||||||
|
|
||||||
// Need Pulse MsgID before we can create associated Reference.
|
|
||||||
mWaitingRefMsg = true;
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
rsWire->createPulse(token, pulse);
|
|
||||||
mWireQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PulseAddDialog::postRefPulse(RsWirePulse &pulse)
|
|
||||||
{
|
|
||||||
std::cerr << "PulseAddDialog::postRefPulse() create Reference!";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
// Reference Pulse. posted on Parent's Group.
|
|
||||||
RsWirePulse refPulse;
|
|
||||||
|
|
||||||
refPulse.mMeta.mGroupId = mReplyToPulse.mMeta.mGroupId;
|
|
||||||
refPulse.mMeta.mAuthorId = mGroup.mMeta.mAuthorId; // own author Id.
|
|
||||||
refPulse.mMeta.mThreadId = mReplyToPulse.mMeta.mOrigMsgId;
|
|
||||||
refPulse.mMeta.mParentId = mReplyToPulse.mMeta.mOrigMsgId;
|
|
||||||
refPulse.mMeta.mOrigMsgId.clear();
|
|
||||||
|
|
||||||
refPulse.mPulseType = WIRE_PULSE_TYPE_REFERENCE | WIRE_PULSE_TYPE_REPLY;
|
|
||||||
refPulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
|
|
||||||
|
|
||||||
// Dont put parent PulseText into refPulse - it is available on Thread Msg.
|
|
||||||
// otherwise gives impression it is correctly setup Parent / Reply...
|
|
||||||
// when in fact the parent PublishTS, and AuthorId are wrong.
|
|
||||||
refPulse.mPulseText = "";
|
|
||||||
|
|
||||||
// refs refer back to own Post.
|
|
||||||
refPulse.mRefGroupId = mGroup.mMeta.mGroupId;
|
|
||||||
refPulse.mRefGroupName = mGroup.mMeta.mGroupName;
|
|
||||||
refPulse.mRefOrigMsgId = pulse.mMeta.mOrigMsgId;
|
|
||||||
refPulse.mRefAuthorId = mGroup.mMeta.mAuthorId;
|
|
||||||
refPulse.mRefPublishTs = pulse.mMeta.mPublishTs;
|
|
||||||
refPulse.mRefPulseText = pulse.mPulseText;
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
rsWire->createPulse(token, refPulse);
|
|
||||||
|
|
||||||
clearDialog();
|
clearDialog();
|
||||||
hide();
|
hide();
|
||||||
|
@ -283,89 +265,4 @@ void PulseAddDialog::clearDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PulseAddDialog::acknowledgeMessage(const uint32_t &token)
|
|
||||||
{
|
|
||||||
std::cerr << "PulseAddDialog::acknowledgeMessage()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
std::pair<RsGxsGroupId, RsGxsMessageId> p;
|
|
||||||
rsWire->acknowledgeMsg(token, p);
|
|
||||||
|
|
||||||
if (mWaitingRefMsg)
|
|
||||||
{
|
|
||||||
std::cerr << "PulseAddDialog::acknowledgeMessage() Waiting Ref Msg";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
mWaitingRefMsg = false;
|
|
||||||
|
|
||||||
// request photo data.
|
|
||||||
GxsMsgReq req;
|
|
||||||
std::set<RsGxsMessageId> msgIds;
|
|
||||||
msgIds.insert(p.second);
|
|
||||||
req[p.first] = msgIds;
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
||||||
uint32_t token;
|
|
||||||
mWireQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "PulseAddDialog::acknowledgeMessage() Not Waiting Ref Msg";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PulseAddDialog::loadPulseData(const uint32_t &token)
|
|
||||||
{
|
|
||||||
std::cerr << "PulseAddDialog::loadPulseData()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
std::vector<RsWirePulse> pulses;
|
|
||||||
rsWire->getPulseData(token, pulses);
|
|
||||||
|
|
||||||
if (pulses.size() != 1)
|
|
||||||
{
|
|
||||||
std::cerr << "PulseAddDialog::loadPulseData() Error Too many pulses";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cerr << "PulseAddDialog::loadPulseData() calling postRefMsg";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
RsWirePulse& pulse = pulses[0];
|
|
||||||
postRefPulse(pulse);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************** Request / Response Filling of Data ************************/
|
|
||||||
|
|
||||||
void PulseAddDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
||||||
{
|
|
||||||
if (queue == mWireQueue)
|
|
||||||
{
|
|
||||||
/* now switch on req */
|
|
||||||
switch(req.mType)
|
|
||||||
{
|
|
||||||
case TOKENREQ_MSGINFO:
|
|
||||||
switch(req.mAnsType)
|
|
||||||
{
|
|
||||||
case RS_TOKREQ_ANSTYPE_ACK:
|
|
||||||
acknowledgeMessage(req.mToken);
|
|
||||||
break;
|
|
||||||
case RS_TOKREQ_ANSTYPE_DATA:
|
|
||||||
loadPulseData(req.mToken);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "PulseAddDialog::loadRequest() ERROR: MSG: INVALID ANS TYPE";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "PulseAddDialog::loadRequest() ERROR: INVALID TYPE";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,8 @@
|
||||||
#include "ui_PulseAddDialog.h"
|
#include "ui_PulseAddDialog.h"
|
||||||
|
|
||||||
#include <retroshare/rswire.h>
|
#include <retroshare/rswire.h>
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
|
|
||||||
class PulseAddDialog : public QWidget, public TokenResponse
|
class PulseAddDialog : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -34,8 +33,9 @@ public:
|
||||||
PulseAddDialog(QWidget *parent = 0);
|
PulseAddDialog(QWidget *parent = 0);
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void setGroup(RsWireGroup &group);
|
|
||||||
void setReplyTo(RsWirePulse &pulse, std::string &groupName);
|
void setReplyTo(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
|
||||||
|
void setGroup(const RsGxsGroupId &grpId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addURL();
|
void addURL();
|
||||||
|
@ -46,26 +46,23 @@ private slots:
|
||||||
void pulseTextChanged();
|
void pulseTextChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// OLD VERSIONs, private now.
|
||||||
|
void setGroup(RsWireGroup &group);
|
||||||
|
void setReplyTo(RsWirePulse &pulse, std::string &groupName);
|
||||||
|
|
||||||
void postOriginalPulse();
|
void postOriginalPulse();
|
||||||
void postReplyPulse();
|
void postReplyPulse();
|
||||||
void postRefPulse(RsWirePulse &pulse);
|
|
||||||
|
|
||||||
void acknowledgeMessage(const uint32_t &token);
|
|
||||||
void loadPulseData(const uint32_t &token);
|
|
||||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
uint32_t toPulseSentiment(int index);
|
uint32_t toPulseSentiment(int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
RsWireGroup mGroup; // where we want to post from.
|
RsWireGroup mGroup; // replyWith.
|
||||||
|
|
||||||
// if this is a reply
|
// if this is a reply
|
||||||
bool mIsReply;
|
bool mIsReply;
|
||||||
std::string mReplyGroupName;
|
|
||||||
RsWirePulse mReplyToPulse;
|
RsWirePulse mReplyToPulse;
|
||||||
bool mWaitingRefMsg;
|
|
||||||
|
|
||||||
TokenQueue* mWireQueue;
|
|
||||||
Ui::PulseAddDialog ui;
|
Ui::PulseAddDialog ui;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,6 +56,7 @@ PulseDetails::PulseDetails(PulseHolder *actions,
|
||||||
// reuse Meta data structure.
|
// reuse Meta data structure.
|
||||||
mPulse.mMeta.mGroupId = parentGroupId;
|
mPulse.mMeta.mGroupId = parentGroupId;
|
||||||
mPulse.mMeta.mOrigMsgId = parentOrigMsgId;
|
mPulse.mMeta.mOrigMsgId = parentOrigMsgId;
|
||||||
|
mPulse.mMeta.mMsgId = parentOrigMsgId; // add in, for completeness.
|
||||||
mPulse.mMeta.mAuthorId = parentAuthorId;
|
mPulse.mMeta.mAuthorId = parentAuthorId;
|
||||||
mPulse.mMeta.mPublishTs = parentPublishTs;
|
mPulse.mMeta.mPublishTs = parentPublishTs;
|
||||||
mPulse.mPulseText = parentPulseText;
|
mPulse.mPulseText = parentPulseText;
|
||||||
|
|
|
@ -136,7 +136,9 @@ void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
|
||||||
{
|
{
|
||||||
std::cerr << "WireDialog::reply(";
|
std::cerr << "WireDialog::reply(";
|
||||||
std::cerr << pulse.mMeta.mGroupId.toStdString();
|
std::cerr << pulse.mMeta.mGroupId.toStdString();
|
||||||
std::cerr << ",";
|
std::cerr << ", MsgId:";
|
||||||
|
std::cerr << pulse.mMeta.mMsgId.toStdString();
|
||||||
|
std::cerr << ", OrigMsgId:";
|
||||||
std::cerr << pulse.mMeta.mOrigMsgId.toStdString();
|
std::cerr << pulse.mMeta.mOrigMsgId.toStdString();
|
||||||
std::cerr << ")";
|
std::cerr << ")";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -159,10 +161,11 @@ void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
|
||||||
// publishing group.
|
// publishing group.
|
||||||
RsWireGroup group = mOwnGroups[idx];
|
RsWireGroup group = mOwnGroups[idx];
|
||||||
mAddDialog->cleanup();
|
mAddDialog->cleanup();
|
||||||
mAddDialog->setGroup(group);
|
mAddDialog->setGroup(group.mMeta.mGroupId);
|
||||||
|
|
||||||
// establish replyTo.
|
// establish replyTo.
|
||||||
mAddDialog->setReplyTo(pulse, groupName);
|
//mAddDialog->setReplyTo(pulse, groupName);
|
||||||
|
mAddDialog->setReplyTo(pulse.mMeta.mGroupId, pulse.mMeta.mMsgId);
|
||||||
|
|
||||||
mAddDialog->show();
|
mAddDialog->show();
|
||||||
}
|
}
|
||||||
|
@ -269,7 +272,7 @@ void WireDialog::createPulse()
|
||||||
RsWireGroup group = mOwnGroups[idx];
|
RsWireGroup group = mOwnGroups[idx];
|
||||||
|
|
||||||
mAddDialog->cleanup();
|
mAddDialog->cleanup();
|
||||||
mAddDialog->setGroup(group);
|
mAddDialog->setGroup(group.mMeta.mGroupId);
|
||||||
mAddDialog->show();
|
mAddDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +443,9 @@ void WireDialog::showSelectedGroups()
|
||||||
std::list<RsGxsGroupId> grpIds;
|
std::list<RsGxsGroupId> grpIds;
|
||||||
grpIds.push_back(mGroupSelected->groupId());
|
grpIds.push_back(mGroupSelected->groupId());
|
||||||
requestPulseData(grpIds);
|
requestPulseData(grpIds);
|
||||||
|
|
||||||
|
// show GroupFocus.
|
||||||
|
showGroupFocus(mGroupSelected->groupId());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -454,6 +460,7 @@ void WireDialog::showGroups()
|
||||||
deletePulses();
|
deletePulses();
|
||||||
|
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> allGroupIds;
|
||||||
|
|
||||||
/* depends on the comboBox */
|
/* depends on the comboBox */
|
||||||
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
|
std::map<RsGxsGroupId, RsWireGroup>::const_iterator it;
|
||||||
|
@ -481,9 +488,12 @@ void WireDialog::showGroups()
|
||||||
// request data.
|
// request data.
|
||||||
std::list<RsGxsGroupId> grpIds;
|
std::list<RsGxsGroupId> grpIds;
|
||||||
grpIds.push_back(it->second.mMeta.mGroupId);
|
grpIds.push_back(it->second.mMeta.mGroupId);
|
||||||
|
allGroupIds.push_back(it->second.mMeta.mGroupId);
|
||||||
requestPulseData(grpIds);
|
requestPulseData(grpIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showGroupsPulses(allGroupIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1015,6 +1025,8 @@ void WireDialog::postPulseFocus(RsWirePulseSPtr pPulse)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.label_viewMode->setText("Pulse Focus");
|
||||||
|
|
||||||
addTwitterView(new PulseTopLevel(this, pPulse));
|
addTwitterView(new PulseTopLevel(this, pPulse));
|
||||||
|
|
||||||
std::list<RsWirePulseSPtr>::iterator it;
|
std::list<RsWirePulseSPtr>::iterator it;
|
||||||
|
@ -1089,6 +1101,8 @@ void WireDialog::postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.label_viewMode->setText("Group Focus");
|
||||||
|
|
||||||
addTwitterView(new PulseViewGroup(this, group));
|
addTwitterView(new PulseViewGroup(this, group));
|
||||||
|
|
||||||
std::list<RsWirePulseSPtr>::iterator it;
|
std::list<RsWirePulseSPtr>::iterator it;
|
||||||
|
@ -1104,5 +1118,49 @@ void WireDialog::postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WireDialog::showGroupsPulses(const std::list<RsGxsGroupId> groupIds)
|
||||||
|
{
|
||||||
|
clearTwitterView();
|
||||||
|
|
||||||
|
// background thread for loading.
|
||||||
|
RsThread::async([this, groupIds]()
|
||||||
|
{
|
||||||
|
// fetch data from backend.
|
||||||
|
std::list<RsWirePulseSPtr> pulses;
|
||||||
|
bool success = rsWire->getPulsesForGroups(groupIds, pulses);
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
|
||||||
|
/* now insert the pulse + children into the layput */
|
||||||
|
RsQThreadUtils::postToObject([pulses,this]()
|
||||||
|
{
|
||||||
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
* thread, for example to update the data model with new information
|
||||||
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
|
postGroupsPulses(pulses);
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void WireDialog::postGroupsPulses(std::list<RsWirePulseSPtr> pulses)
|
||||||
|
{
|
||||||
|
std::cerr << "WireDialog::postGroupsPulses()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
ui.label_viewMode->setText("Groups Pulses");
|
||||||
|
|
||||||
|
std::list<RsWirePulseSPtr>::iterator it;
|
||||||
|
for(it = pulses.begin(); it != pulses.end(); it++)
|
||||||
|
{
|
||||||
|
RsWirePulseSPtr reply = *it;
|
||||||
|
PulseReply *firstReply = new PulseReply(this, reply);
|
||||||
|
addTwitterView(firstReply);
|
||||||
|
firstReply->showReplyLine(false);
|
||||||
|
|
||||||
|
addTwitterView(new PulseReplySeperator());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,16 @@ public:
|
||||||
void postTestTwitterView();
|
void postTestTwitterView();
|
||||||
void clearTwitterView();
|
void clearTwitterView();
|
||||||
void addTwitterView(PulseViewItem *item);
|
void addTwitterView(PulseViewItem *item);
|
||||||
|
|
||||||
void showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId);
|
void showPulseFocus(const RsGxsGroupId groupId, const RsGxsMessageId msgId);
|
||||||
void postPulseFocus(RsWirePulseSPtr pulse);
|
void postPulseFocus(RsWirePulseSPtr pulse);
|
||||||
|
|
||||||
void showGroupFocus(const RsGxsGroupId groupId);
|
void showGroupFocus(const RsGxsGroupId groupId);
|
||||||
void postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr> pulses);
|
void postGroupFocus(RsWireGroupSPtr group, std::list<RsWirePulseSPtr> pulses);
|
||||||
|
|
||||||
|
void showGroupsPulses(const std::list<RsGxsGroupId> groupIds);
|
||||||
|
void postGroupsPulses(std::list<RsWirePulseSPtr> pulses);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void createGroup();
|
void createGroup();
|
||||||
|
|
|
@ -192,7 +192,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>228</width>
|
<width>228</width>
|
||||||
<height>421</height>
|
<height>442</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
@ -223,9 +223,9 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabWidget_Page1" native="true">
|
<widget class="QWidget" name="tabWidget_Page1">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Orig View</string>
|
<string>Orig View</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
@ -367,6 +367,13 @@
|
||||||
<string>Fancy View</string>
|
<string>Fancy View</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_viewMode">
|
||||||
|
<property name="text">
|
||||||
|
<string>Most Recent</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea_3">
|
<widget class="QScrollArea" name="scrollArea_3">
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
|
@ -381,7 +388,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>508</width>
|
<width>508</width>
|
||||||
<height>466</height>
|
<height>443</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue