diff --git a/libretroshare/src/gxs/rsgixs.h b/libretroshare/src/gxs/rsgixs.h index 4b4539273..22993b65f 100644 --- a/libretroshare/src/gxs/rsgixs.h +++ b/libretroshare/src/gxs/rsgixs.h @@ -166,19 +166,17 @@ public: class GixsReputation { - public: - GixsReputation() : score(0) {} - RsGxsId id; - int score; +public: + GixsReputation() {} + + RsGxsId id; + uint32_t reputation_level ; }; class RsGixsReputation { public: // get Reputation. - virtual bool haveReputation(const RsGxsId &id) = 0; - virtual bool loadReputation(const RsGxsId &id, const std::list& peers) = 0; - virtual bool getReputation(const RsGxsId &id, GixsReputation &rep) = 0; virtual RsReputations::ReputationLevel overallReputationLevel(const RsGxsId& id) = 0; }; @@ -186,7 +184,6 @@ public: class RsGxsIdExchange: public RsGenExchange, - public RsGixsReputation, public RsGixs { public: diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 1be1ff58c..4b1677096 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -3139,6 +3139,9 @@ void RsGxsNetService::runVetting() RS_STACK_MUTEX(mNxsMutex) ; +#ifdef TO_BE_REMOVED + // Author response vetting is disabled since not used, as the reputations are currently not async-ed anymore. + std::vector::iterator vit = mPendingResp.begin(); for(; vit != mPendingResp.end(); ) @@ -3169,6 +3172,7 @@ void RsGxsNetService::runVetting() } } +#endif // now lets do circle vetting diff --git a/libretroshare/src/gxs/rsgxsnetutils.cc b/libretroshare/src/gxs/rsgxsnetutils.cc index 18b048cff..1956f8964 100644 --- a/libretroshare/src/gxs/rsgxsnetutils.cc +++ b/libretroshare/src/gxs/rsgxsnetutils.cc @@ -27,20 +27,13 @@ #include "pqi/p3servicecontrol.h" #include "pgp/pgpauxutils.h" - const time_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds const int AuthorPending::MSG_PEND = 1; const int AuthorPending::GRP_PEND = 2; +AuthorPending::AuthorPending(RsGixsReputation* rep, time_t timeStamp) : mRep(rep), mTimeStamp(timeStamp) {} -AuthorPending::AuthorPending(RsGixsReputation* rep, time_t timeStamp) - : mRep(rep), mTimeStamp(timeStamp) { -} - -AuthorPending::~AuthorPending() -{ - -} +AuthorPending::~AuthorPending() {} bool AuthorPending::expired() const { @@ -49,7 +42,12 @@ bool AuthorPending::expired() const bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, const RsPeerId& peerId) { - if(mRep->haveReputation(authorId)) + rep.id = authorId ; + rep.reputation_level = mRep->overallReputationLevel(authorId); + +#warning can it happen that reputations do not have the info yet? + return true ; +#ifdef TO_BE_REMOVED { return mRep->getReputation(authorId, rep); } @@ -58,7 +56,7 @@ bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, c peers.push_back(peerId); mRep->loadReputation(authorId, peers); return false; - +#endif } MsgAuthEntry::MsgAuthEntry() @@ -98,7 +96,7 @@ bool MsgRespPending::accepted() GixsReputation rep; if(getAuthorRep(rep, entry.mAuthorId, mPeerId)) { - if(rep.score >= mCutOff) + if(rep.reputation_level >= mCutOff) { entry.mPassedVetting = true; count++; @@ -133,7 +131,7 @@ bool GrpRespPending::accepted() if(getAuthorRep(rep, entry.mAuthorId, mPeerId)) { - if(rep.score >= mCutOff) + if(rep.reputation_level >= mCutOff) { entry.mPassedVetting = true; count++; @@ -153,12 +151,12 @@ bool GrpRespPending::accepted() /** NxsTransaction definition **/ -const uint8_t NxsTransaction::FLAG_STATE_STARTING = 0x0001; // when -const uint8_t NxsTransaction::FLAG_STATE_RECEIVING = 0x0002; // begin receiving items for incoming trans -const uint8_t NxsTransaction::FLAG_STATE_SENDING = 0x0004; // begin sending items for outgoing trans -const uint8_t NxsTransaction::FLAG_STATE_COMPLETED = 0x008; -const uint8_t NxsTransaction::FLAG_STATE_FAILED = 0x0010; +const uint8_t NxsTransaction::FLAG_STATE_STARTING = 0x0001; // when +const uint8_t NxsTransaction::FLAG_STATE_RECEIVING = 0x0002; // begin receiving items for incoming trans +const uint8_t NxsTransaction::FLAG_STATE_SENDING = 0x0004; // begin sending items for outgoing trans +const uint8_t NxsTransaction::FLAG_STATE_FAILED = 0x0010; const uint8_t NxsTransaction::FLAG_STATE_WAITING_CONFIRM = 0x0020; +const uint8_t NxsTransaction::FLAG_STATE_COMPLETED = 0x0080; // originaly 0x008, but probably a typo, but we cannot change it since it would break backward compatibility. NxsTransaction::NxsTransaction() diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index f0736917c..aa5c5558a 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -171,7 +171,7 @@ bool RsGxsIntegrityCheck::check() GXSUTIL_DEBUG() << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl; #endif - if(rsIdentity!=NULL && rsIdentity->overallReputationLevel(grp->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) + if(rsReputations!=NULL && rsReputations->overallReputationLevel(grp->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId))) ; } } @@ -269,7 +269,7 @@ bool RsGxsIntegrityCheck::check() #ifdef DEBUG_GXSUTIL GXSUTIL_DEBUG() << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl; #endif - if(rsIdentity!=NULL && rsIdentity->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) + if(rsReputations!=NULL && rsReputations->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE) used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,msg->metaData->mGroupId,msg->metaData->mMsgId))) ; } diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 34b359fd5..47036b691 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1345,8 +1345,8 @@ int RsServer::StartupRetroShare() // create GXS ID service RsGxsNetService* gxsid_ns = new RsGxsNetService( RS_SERVICE_GXS_TYPE_GXSID, gxsid_ds, nxsMgr, - mGxsIdService, mGxsIdService->getServiceInfo(), - mGxsIdService, mGxsCircles,mGxsIdService, + mGxsIdService, mGxsIdService->getServiceInfo(), + mReputations, mGxsCircles,mGxsIdService, pgpAuxUtils, false,false); // don't synchronise group automatic (need explicit group request) // don't sync messages at all. @@ -1365,7 +1365,7 @@ int RsServer::StartupRetroShare() RsGxsNetService* gxscircles_ns = new RsGxsNetService( RS_SERVICE_GXS_TYPE_GXSCIRCLE, gxscircles_ds, nxsMgr, mGxsCircles, mGxsCircles->getServiceInfo(), - mGxsIdService, mGxsCircles,mGxsIdService, + mReputations, mGxsCircles,mGxsIdService, pgpAuxUtils, true, // synchronise group automatic true); // sync messages automatic, since they contain subscription requests. @@ -1384,7 +1384,7 @@ int RsServer::StartupRetroShare() RsGxsNetService* posted_ns = new RsGxsNetService( RS_SERVICE_GXS_TYPE_POSTED, posted_ds, nxsMgr, mPosted, mPosted->getServiceInfo(), - mGxsIdService, mGxsCircles,mGxsIdService, + mReputations, mGxsCircles,mGxsIdService, pgpAuxUtils); mPosted->setNetworkExchangeService(posted_ns) ; @@ -1420,7 +1420,7 @@ int RsServer::StartupRetroShare() RsGxsNetService* gxsforums_ns = new RsGxsNetService( RS_SERVICE_GXS_TYPE_FORUMS, gxsforums_ds, nxsMgr, mGxsForums, mGxsForums->getServiceInfo(), - mGxsIdService, mGxsCircles,mGxsIdService, + mReputations, mGxsCircles,mGxsIdService, pgpAuxUtils); mGxsForums->setNetworkExchangeService(gxsforums_ns) ; @@ -1436,7 +1436,7 @@ int RsServer::StartupRetroShare() RsGxsNetService* gxschannels_ns = new RsGxsNetService( RS_SERVICE_GXS_TYPE_CHANNELS, gxschannels_ds, nxsMgr, mGxsChannels, mGxsChannels->getServiceInfo(), - mGxsIdService, mGxsCircles,mGxsIdService, + mReputations, mGxsCircles,mGxsIdService, pgpAuxUtils); mGxsChannels->setNetworkExchangeService(gxschannels_ns) ; diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index 69a37d58b..d5d0e2e7b 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -435,10 +435,10 @@ void p3GxsReputation::cleanup() for(std::map::iterator it(mReputations.begin());it!=mReputations.end();++it) { - bool is_a_contact = rsIdentity->isARegularContact(*it) ; + bool is_a_contact = rsIdentity->isARegularContact(it->first) ; if(mAutoSetPositiveOptionToContacts && is_a_contact && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL) - should_set_to_positive.push_back(*rit) ; + should_set_to_positive.push_back(it->first) ; } } diff --git a/libretroshare/src/services/p3gxsreputation.h b/libretroshare/src/services/p3gxsreputation.h index ceaab3b85..981e8b672 100644 --- a/libretroshare/src/services/p3gxsreputation.h +++ b/libretroshare/src/services/p3gxsreputation.h @@ -40,6 +40,7 @@ static const uint32_t REPUTATION_IDENTITY_FLAG_PGP_KNOWN = 0x0002; #include "retroshare/rsidentity.h" #include "retroshare/rsreputations.h" +#include "gxs/rsgixs.h" #include "services/p3service.h" @@ -100,7 +101,7 @@ public: * */ -class p3GxsReputation: public p3Service, public p3Config, public RsReputations /* , public pqiMonitor */ +class p3GxsReputation: public p3Service, public p3Config, public RsGixsReputation, public RsReputations /* , public pqiMonitor */ { public: p3GxsReputation(p3LinkMgr *lm); diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 88ea21072..8ee7f51fb 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -1030,6 +1030,7 @@ bool p3IdService::decryptData(const uint8_t *encrypted_data,uint32_t encrypted_d } +#ifdef TO_BE_REMOVED /********************************************************************************/ /******************* RsGixsReputation ***************************************/ /********************************************************************************/ @@ -1083,6 +1084,7 @@ bool p3IdService::getReputation(const RsGxsId &id, GixsReputation &rep) } return false; } +#endif #if 0 class RegistrationRequest diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index 1261195c1..e9e6ed9d5 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -303,9 +303,11 @@ public: /**************** RsGixsReputation Implementation ****************/ // get Reputation. +#ifdef TO_BE_REMOVED virtual bool haveReputation(const RsGxsId &id); virtual bool loadReputation(const RsGxsId &id, const std::list& peers); virtual bool getReputation(const RsGxsId &id, GixsReputation &rep); +#endif protected: diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index a2535c38e..79ec53e64 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -110,14 +110,14 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF void GxsIdRSTreeWidgetItem::updateBannedState() { - if(mBannedState != (rsIdentity->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)) + if(mBannedState != (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)) forceUpdate() ; } void GxsIdRSTreeWidgetItem::forceUpdate() { mIdFound = false; - mBannedState = (rsIdentity->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE); + mBannedState = (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE); startProcess(); } @@ -163,7 +163,7 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const if(mId.isNull()) return RSTreeWidgetItem::data(column, role); - else if(rsIdentity->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) + else if(rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) pix = QImage(BANNED_IMAGE) ; else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG")) pix = GxsIdDetails::makeDefaultIcon(mId); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index cc0890077..581fe43ed 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1546,7 +1546,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) return; } - uint32_t overall_reputation = rsIdentity->overallReputationLevel(msg.mMeta.mAuthorId) ; + uint32_t overall_reputation = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId) ; bool redacted = (overall_reputation == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ; mStateHelper->setActive(mTokenTypeMessageData, true);