removed debug info fom gxscommon

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7878 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-01-26 19:45:33 +00:00
parent 3a64bc2601
commit beb7c84898

View File

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
//#define DEBUG_GXSCOMMON
RsGxsComment::RsGxsComment() RsGxsComment::RsGxsComment()
{ {
@ -45,16 +46,20 @@ RsGxsComment::RsGxsComment()
RsGxsImage::RsGxsImage() RsGxsImage::RsGxsImage()
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "RsGxsImage(" << this << ")"; std::cerr << "RsGxsImage(" << this << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
mData = NULL; mData = NULL;
mSize = 0; mSize = 0;
} }
RsGxsImage::RsGxsImage(const RsGxsImage& a) RsGxsImage::RsGxsImage(const RsGxsImage& a)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "RsGxsImage(" << this << ") = RsGxsImage(" << (void *) &a << ")"; std::cerr << "RsGxsImage(" << this << ") = RsGxsImage(" << (void *) &a << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
mData = NULL; mData = NULL;
mSize = 0; mSize = 0;
copy(a.mData, a.mSize); copy(a.mData, a.mSize);
@ -63,8 +68,10 @@ RsGxsImage::RsGxsImage(const RsGxsImage& a)
RsGxsImage::~RsGxsImage() RsGxsImage::~RsGxsImage()
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "~RsGxsImage(" << this << ")"; std::cerr << "~RsGxsImage(" << this << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
clear(); clear();
} }
@ -78,8 +85,10 @@ RsGxsImage &RsGxsImage::operator=(const RsGxsImage &a)
void RsGxsImage::take(uint8_t *data, uint32_t size) void RsGxsImage::take(uint8_t *data, uint32_t size)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "RsGxsImage(" << this << ")::take(" << (void *) data << "," << size << ")"; std::cerr << "RsGxsImage(" << this << ")::take(" << (void *) data << "," << size << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
// Copies Pointer. // Copies Pointer.
clear(); clear();
mData = data; mData = data;
@ -90,22 +99,28 @@ void RsGxsImage::take(uint8_t *data, uint32_t size)
uint8_t *RsGxsImage::allocate(uint32_t size) uint8_t *RsGxsImage::allocate(uint32_t size)
{ {
uint8_t *val = (uint8_t *) malloc(size); uint8_t *val = (uint8_t *) malloc(size);
#ifdef DEBUG_GXSCOMMON
std::cerr << "RsGxsImage()::allocate(" << (void *) val << ")"; std::cerr << "RsGxsImage()::allocate(" << (void *) val << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
return val; return val;
} }
void RsGxsImage::release(void *data) void RsGxsImage::release(void *data)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "RsGxsImage()::release(" << (void *) data << ")"; std::cerr << "RsGxsImage()::release(" << (void *) data << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
free(data); free(data);
} }
void RsGxsImage::copy(uint8_t *data, uint32_t size) void RsGxsImage::copy(uint8_t *data, uint32_t size)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "RsGxsImage(" << this << ")::copy(" << (void *) data << "," << size << ")"; std::cerr << "RsGxsImage(" << this << ")::copy(" << (void *) data << "," << size << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
// Allocates and Copies. // Allocates and Copies.
clear(); clear();
if (data && size) if (data && size)
@ -167,8 +182,10 @@ void p3GxsCommentService::comment_tick()
bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::getGxsCommentData()"; std::cerr << "p3GxsCommentService::getGxsCommentData()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
GxsMsgDataMap msgData; GxsMsgDataMap msgData;
bool ok = mExchange->getMsgData(token, msgData); bool ok = mExchange->getMsgData(token, msgData);
@ -249,10 +266,12 @@ bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<R
} }
} }
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::getGxsCommentData() Found " << comments.size() << " Comments"; std::cerr << "p3GxsCommentService::getGxsCommentData() Found " << comments.size() << " Comments";
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "p3GxsCommentService::getGxsCommentData() Found " << voteMap.size() << " Votes"; std::cerr << "p3GxsCommentService::getGxsCommentData() Found " << voteMap.size() << " Votes";
std::cerr << std::endl; std::cerr << std::endl;
#endif
/* delete the votes */ /* delete the votes */
for (it = voteMap.begin(); it != voteMap.end(); ++it) for (it = voteMap.begin(); it != voteMap.end(); ++it)
@ -272,8 +291,10 @@ bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<R
bool p3GxsCommentService::getGxsRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &comments) bool p3GxsCommentService::getGxsRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &comments)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::getGxsRelatedComments()"; std::cerr << "p3GxsCommentService::getGxsRelatedComments()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
GxsMsgRelatedDataMap msgData; GxsMsgRelatedDataMap msgData;
bool ok = mExchange->getMsgRelatedData(token, msgData); bool ok = mExchange->getMsgRelatedData(token, msgData);
@ -351,10 +372,12 @@ bool p3GxsCommentService::getGxsRelatedComments(const uint32_t &token, std::vect
} }
} }
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::getGxsRelatedComments() Found " << comments.size() << " Comments"; std::cerr << "p3GxsCommentService::getGxsRelatedComments() Found " << comments.size() << " Comments";
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "p3GxsCommentService::getGxsRelatedComments() Found " << voteMap.size() << " Votes"; std::cerr << "p3GxsCommentService::getGxsRelatedComments() Found " << voteMap.size() << " Votes";
std::cerr << std::endl; std::cerr << std::endl;
#endif
/* delete the votes */ /* delete the votes */
for (it = voteMap.begin(); it != voteMap.end(); ++it) for (it = voteMap.begin(); it != voteMap.end(); ++it)
@ -392,8 +415,10 @@ double p3GxsCommentService::calculateBestScore(int upVotes, int downVotes)
bool p3GxsCommentService::createGxsComment(uint32_t &token, RsGxsComment &msg) bool p3GxsCommentService::createGxsComment(uint32_t &token, RsGxsComment &msg)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::createGxsComment() GroupId: " << msg.mMeta.mGroupId; std::cerr << "p3GxsCommentService::createGxsComment() GroupId: " << msg.mMeta.mGroupId;
std::cerr << std::endl; std::cerr << std::endl;
#endif
RsGxsCommentItem* msgItem = new RsGxsCommentItem(mServiceType); RsGxsCommentItem* msgItem = new RsGxsCommentItem(mServiceType);
msgItem->mMsg = msg; msgItem->mMsg = msg;
@ -410,8 +435,10 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote)
// NOTE Because we cannot do this operation immediately, we create a token, // NOTE Because we cannot do this operation immediately, we create a token,
// and monitor acknowledgeTokenMsg ... to return correct answer. // and monitor acknowledgeTokenMsg ... to return correct answer.
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::createGxsVote() GroupId: " << vote.mMeta.mGroupId; std::cerr << "p3GxsCommentService::createGxsVote() GroupId: " << vote.mMeta.mGroupId;
std::cerr << std::endl; std::cerr << std::endl;
#endif
/* vote must be associated with another item */ /* vote must be associated with another item */
if (vote.mMeta.mThreadId.isNull()) if (vote.mMeta.mThreadId.isNull())
@ -482,8 +509,10 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote)
void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token) void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::load_PendingVoteParent()"; std::cerr << "p3GxsCommentService::load_PendingVoteParent()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
GxsMsgMetaMap msginfo; GxsMsgMetaMap msginfo;
if (!mExchange->getMsgMeta(token, msginfo)) if (!mExchange->getMsgMeta(token, msginfo))
{ {
@ -505,9 +534,11 @@ void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token)
/* find the matching Pending Vote */ /* find the matching Pending Vote */
RsMsgMetaData &meta = *mit; RsMsgMetaData &meta = *mit;
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::load_PendingVoteParent() recv (groupId: " << meta.mGroupId; std::cerr << "p3GxsCommentService::load_PendingVoteParent() recv (groupId: " << meta.mGroupId;
std::cerr << ", msgId: " << meta.mMsgId << ")"; std::cerr << ", msgId: " << meta.mMsgId << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
RsGxsGrpMsgIdPair parentId(meta.mGroupId, meta.mMsgId); RsGxsGrpMsgIdPair parentId(meta.mGroupId, meta.mMsgId);
std::map<RsGxsGrpMsgIdPair, VoteHolder>::iterator pit; std::map<RsGxsGrpMsgIdPair, VoteHolder>::iterator pit;
@ -535,8 +566,10 @@ void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token)
continue; continue;
} }
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::load_PendingVoteParent() submitting Vote"; std::cerr << "p3GxsCommentService::load_PendingVoteParent() submitting Vote";
std::cerr << std::endl; std::cerr << std::endl;
#endif
uint32_t status_token; uint32_t status_token;
if (vote.mVoteType == GXS_VOTE_UP) if (vote.mVoteType == GXS_VOTE_UP)
@ -564,8 +597,10 @@ void p3GxsCommentService::load_PendingVoteParent(const uint32_t &token)
void p3GxsCommentService::completeInternalVote(uint32_t &token) void p3GxsCommentService::completeInternalVote(uint32_t &token)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::completeInternalVote() token: " << token; std::cerr << "p3GxsCommentService::completeInternalVote() token: " << token;
std::cerr << std::endl; std::cerr << std::endl;
#endif
std::map<RsGxsGrpMsgIdPair, VoteHolder>::iterator it; std::map<RsGxsGrpMsgIdPair, VoteHolder>::iterator it;
for (it = mPendingVotes.begin(); it != mPendingVotes.end(); ++it) for (it = mPendingVotes.begin(); it != mPendingVotes.end(); ++it)
{ {
@ -575,8 +610,10 @@ void p3GxsCommentService::completeInternalVote(uint32_t &token)
uint32_t status = mExchange->getTokenService()->requestStatus(token); uint32_t status = mExchange->getTokenService()->requestStatus(token);
mExchange->updatePublicRequestStatus(it->second.mReqToken, status); mExchange->updatePublicRequestStatus(it->second.mReqToken, status);
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::completeInternalVote() Matched to PendingVote. status: " << status; std::cerr << "p3GxsCommentService::completeInternalVote() Matched to PendingVote. status: " << status;
std::cerr << std::endl; std::cerr << std::endl;
#endif
it->second.mStatus = VoteHolder::VOTE_READY; it->second.mStatus = VoteHolder::VOTE_READY;
return; return;
@ -592,22 +629,28 @@ void p3GxsCommentService::completeInternalVote(uint32_t &token)
bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPair& msgId) bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPair& msgId)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::acknowledgeVote() token: " << token; std::cerr << "p3GxsCommentService::acknowledgeVote() token: " << token;
std::cerr << std::endl; std::cerr << std::endl;
#endif
std::map<RsGxsGrpMsgIdPair, VoteHolder>::iterator it; std::map<RsGxsGrpMsgIdPair, VoteHolder>::iterator it;
for (it = mPendingVotes.begin(); it != mPendingVotes.end(); ++it) for (it = mPendingVotes.begin(); it != mPendingVotes.end(); ++it)
{ {
if (it->second.mReqToken == token) if (it->second.mReqToken == token)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::acknowledgeVote() Matched to PendingVote"; std::cerr << "p3GxsCommentService::acknowledgeVote() Matched to PendingVote";
std::cerr << std::endl; std::cerr << std::endl;
#endif
bool ans = false; bool ans = false;
if (it->second.mStatus == VoteHolder::VOTE_READY) if (it->second.mStatus == VoteHolder::VOTE_READY)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::acknowledgeVote() PendingVote = READY"; std::cerr << "p3GxsCommentService::acknowledgeVote() PendingVote = READY";
std::cerr << std::endl; std::cerr << std::endl;
#endif
// Finally finish this Vote off. // Finally finish this Vote off.
ans = mExchange->acknowledgeTokenMsg(it->second.mVoteToken, msgId); ans = mExchange->acknowledgeTokenMsg(it->second.mVoteToken, msgId);
@ -617,6 +660,7 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa
std::cerr << "p3GxsCommentService::acknowledgeVote() PendingVote = ERROR ???"; std::cerr << "p3GxsCommentService::acknowledgeVote() PendingVote = ERROR ???";
std::cerr << std::endl; std::cerr << std::endl;
} }
#ifdef DEBUG_GXSCOMMON
else else
{ {
std::cerr << "p3GxsCommentService::acknowledgeVote() PendingVote = OTHER STATUS"; std::cerr << "p3GxsCommentService::acknowledgeVote() PendingVote = OTHER STATUS";
@ -625,6 +669,7 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa
std::cerr << "p3GxsCommentService::acknowledgeVote() cleanup token & PendingVote"; std::cerr << "p3GxsCommentService::acknowledgeVote() cleanup token & PendingVote";
std::cerr << std::endl; std::cerr << std::endl;
#endif
mExchange->disposeOfPublicToken(it->second.mReqToken); mExchange->disposeOfPublicToken(it->second.mReqToken);
mPendingVotes.erase(it); mPendingVotes.erase(it);
@ -632,8 +677,10 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa
} }
} }
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::acknowledgeVote() Failed to match PendingVote"; std::cerr << "p3GxsCommentService::acknowledgeVote() Failed to match PendingVote";
std::cerr << std::endl; std::cerr << std::endl;
#endif
return false; return false;
} }
@ -642,8 +689,10 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa
// Overloaded from GxsTokenQueue for Request callbacks. // Overloaded from GxsTokenQueue for Request callbacks.
void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type) void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << ")"; std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << ")";
std::cerr << std::endl; std::cerr << std::endl;
#endif
// stuff. // stuff.
switch(req_type) switch(req_type)
@ -670,8 +719,10 @@ void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type)
bool p3GxsCommentService::castVote(uint32_t &token, RsGxsVote &msg) bool p3GxsCommentService::castVote(uint32_t &token, RsGxsVote &msg)
{ {
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::castVote() GroupId: " << msg.mMeta.mGroupId; std::cerr << "p3GxsCommentService::castVote() GroupId: " << msg.mMeta.mGroupId;
std::cerr << std::endl; std::cerr << std::endl;
#endif
RsGxsVoteItem* msgItem = new RsGxsVoteItem(mServiceType); RsGxsVoteItem* msgItem = new RsGxsVoteItem(mServiceType);
msgItem->mMsg = msg; msgItem->mMsg = msg;