Merge pull request #419 from PhenomRetroShare/Fix_ChannelNewsFeedWhenComment

Fix GxsChannelPostItem when received comment.
This commit is contained in:
Cyril Soler 2016-06-18 15:36:03 -04:00 committed by GitHub
commit 35da9cb193
16 changed files with 188 additions and 61 deletions

View file

@ -83,9 +83,10 @@ virtual ~RsGxsChannels() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
/* From RsGxsCommentService */
//virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;

View file

@ -108,6 +108,19 @@ class RsGxsComment
// This is filled in if detailed Comment Data is called.
std::list<RsGxsVote> mVotes;
const std::ostream &print(std::ostream &out, std::string indent = "", std::string varName = "") const {
out << indent << varName << " of RsGxsComment Values ###################" << std::endl;
mMeta.print(out, indent + " ", "mMeta");
out << indent << " mComment: " << mComment << std::endl;
out << indent << " mUpVotes: " << mUpVotes << std::endl;
out << indent << " mDownVotes: " << mDownVotes << std::endl;
out << indent << " mScore: " << mScore << std::endl;
out << indent << " mOwnVote: " << mOwnVote << std::endl;
out << indent << " mVotes.size(): " << mVotes.size() << std::endl;
out << indent << "######################################################" << std::endl;
return out;
}
};

View file

@ -70,7 +70,8 @@ virtual ~RsGxsForums() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//Not currently used
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;

View file

@ -131,6 +131,24 @@ public:
time_t mChildTs;
std::string mServiceString; // Service Specific Free-Form extra storage.
const std::ostream &print(std::ostream &out, std::string indent = "", std::string varName = "") const {
out
<< indent << varName << " of RsMsgMetaData Values ###################" << std::endl
<< indent << " mGroupId: " << mGroupId.toStdString() << std::endl
<< indent << " mMsgId: " << mMsgId.toStdString() << std::endl
<< indent << " mThreadId: " << mThreadId.toStdString() << std::endl
<< indent << " mParentId: " << mParentId.toStdString() << std::endl
<< indent << " mOrigMsgId: " << mOrigMsgId.toStdString() << std::endl
<< indent << " mAuthorId: " << mAuthorId.toStdString() << std::endl
<< indent << " mMsgName: " << mMsgName << std::endl
<< indent << " mPublishTs: " << mPublishTs << std::endl
<< indent << " mMsgFlags: " << std::hex << mMsgFlags << std::dec << std::endl
<< indent << " mMsgStatus: " << std::hex << mMsgStatus << std::dec << std::endl
<< indent << " mChildTs: " << mChildTs << std::endl
<< indent << " mServiceString: " << mServiceString << std::endl
<< indent << "######################################################" << std::endl;
return out;
}
};
class GxsGroupStatistic

View file

@ -84,7 +84,8 @@ virtual ~RsPosted() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups) = 0;
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts) = 0;
/* From RsGxsCommentService */
//virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;

View file

@ -147,6 +147,7 @@ uint32_t RsGxsCommentSerialiser::sizeGxsCommentItem(RsGxsCommentItem *item)
#ifdef GXSCOMMENT_DEBUG
std::cerr << "RsGxsCommentSerialiser::sizeGxsCommentItem() is: " << s << std::endl;
msg.print(std::cerr);
#endif
return s;

View file

@ -321,7 +321,7 @@ bool p3GxsChannels::groupShareKeys(const RsGxsGroupId &groupId, std::set<RsPeerI
* at the moment - fix it up later
*/
bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs)
bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs, std::vector<RsGxsComment> &cmts)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::getPostData()";
@ -342,19 +342,32 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
for(; vit != msgItems.end(); ++vit)
{
RsGxsChannelPostItem* item = dynamic_cast<RsGxsChannelPostItem*>(*vit);
RsGxsChannelPostItem* postItem = dynamic_cast<RsGxsChannelPostItem*>(*vit);
if(item)
if(postItem)
{
RsGxsChannelPost msg;
item->toChannelPost(msg, true);
postItem->toChannelPost(msg, true);
msgs.push_back(msg);
delete item;
delete postItem;
}
else
{
RsGxsCommentItem* cmt = dynamic_cast<RsGxsCommentItem*>(*vit);
if(!cmt)
RsGxsCommentItem* cmtItem = dynamic_cast<RsGxsCommentItem*>(*vit);
if(cmtItem)
{
RsGxsComment cmt;
RsGxsMsgItem *mi = (*vit);
cmt = cmtItem->mMsg;
cmt.mMeta = mi->meta;
#ifdef GXSCOMMENT_DEBUG
std::cerr << "p3GxsChannels::getPostData Found Comment:" << std::endl;
cmt.print(std::cerr," ", "cmt");
#endif
cmts.push_back(cmt);
delete cmtItem;
}
else
{
RsGxsMsgItem* msg = (*vit);
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
@ -364,8 +377,8 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
<< " , deleting!" << std::endl;
delete *vit;
}
delete *vit;
}
}
}
@ -379,8 +392,8 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
return ok;
}
bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs)
//Not currently used
/*bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &msgs)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::getRelatedPosts()";
@ -436,7 +449,7 @@ bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChan
}
return ok;
}
}*/
/********************************************************************************************/

View file

@ -79,9 +79,10 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
public:
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts);
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
//////////////////////////////////////////////////////////////////////////////

View file

@ -255,8 +255,8 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &
return ok;
}
bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs)
//Not currently used
/*bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs)
{
GxsMsgRelatedDataMap msgData;
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
@ -291,7 +291,7 @@ bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsFor
}
return ok;
}
}*/
/********************************************************************************************/

View file

@ -62,7 +62,8 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
//Not currently used
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);

View file

@ -139,8 +139,8 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msg
return ok;
}
bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &msgs)
//Not currently used
/*bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &msgs)
{
GxsMsgRelatedDataMap msgData;
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
@ -178,7 +178,7 @@ bool p3Posted::getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost>
}
return ok;
}
}*/
/********************************************************************************************/

View file

@ -64,7 +64,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
// Posted Specific DataTypes.
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts);
virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
//Not currently used
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
virtual bool createGroup(uint32_t &token, RsPostedGroup &group);
virtual bool createPost(uint32_t &token, RsPostedPost &post);