mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 16:39:43 -05:00
added code to notify GxsBroadcast system with new distant search results
This commit is contained in:
parent
5b9666855d
commit
6ccc7654d6
@ -1110,6 +1110,8 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
||||
RsGxsNotify* n = *vit;
|
||||
RsGxsGroupChange* gc;
|
||||
RsGxsMsgChange* mc;
|
||||
RsGxsDistantSearchResultChange *gt;
|
||||
|
||||
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != NULL)
|
||||
{
|
||||
if (mc->metaChange())
|
||||
@ -1132,6 +1134,10 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
||||
out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList);
|
||||
}
|
||||
}
|
||||
else if((gt = dynamic_cast<RsGxsDistantSearchResultChange*>(n)) != NULL)
|
||||
{
|
||||
out.mDistantSearchReqs.push_back(gt->mRequestId);
|
||||
}
|
||||
else
|
||||
std::cerr << "(EE) Unknown changes type!!" << std::endl;
|
||||
|
||||
@ -1641,6 +1647,8 @@ void RsGenExchange::receiveDistantSearchResults(TurtleRequestId id,const RsGxsGr
|
||||
|
||||
RsGxsDistantSearchResultChange* gc = new RsGxsDistantSearchResultChange(id,grpId);
|
||||
mNotifications.push_back(gc);
|
||||
|
||||
std::cerr << "RsGenExchange::receiveDistantSearchResults(): received result for request " << std::hex << id << std::dec << std::endl;
|
||||
}
|
||||
void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId)
|
||||
{
|
||||
|
@ -5136,7 +5136,8 @@ void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req, const std:
|
||||
// only keep groups that are not locally known, and groups that are not already in the mDistantSearchResults structure
|
||||
|
||||
for(auto it(group_infos.begin());it!=group_infos.end();++it)
|
||||
if(grpMeta[(*it).group_id] == NULL)
|
||||
#warning Uncomment when done with testing!
|
||||
// if(grpMeta[(*it).group_id] == NULL)
|
||||
{
|
||||
filtered_results.push_back(*it) ;
|
||||
search_results_map[(*it).group_id] = *it;
|
||||
@ -5146,9 +5147,11 @@ void RsGxsNetService::receiveTurtleSearchResults(TurtleRequestId req, const std:
|
||||
|
||||
bool RsGxsNetService::search(const std::string& substring,std::list<RsGxsGroupSummary>& group_infos)
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
RsGxsGrpMetaTemporaryMap grpMetaMap;
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
}
|
||||
|
||||
RsGroupNetworkStats stats ;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
* Called when new distant search result arrive.
|
||||
* \param grpId
|
||||
*/
|
||||
virtual void receiveDistantSearchResults(TurtleRequestId& /*id*/,const RsGxsGroupId& /*grpId*/)
|
||||
virtual void receiveDistantSearchResults(TurtleRequestId /*id*/,const RsGxsGroupId& /*grpId*/)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not overloaded but still called. Nothing will happen." << std::endl;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgsMeta;
|
||||
std::list<RsGxsGroupId> mGrps;
|
||||
std::list<RsGxsGroupId> mGrpsMeta;
|
||||
std::list<TurtleRequestId> mDistantSearchReqs;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& group_id) : mRequestId(id),mGroupId(group_id){}
|
||||
|
||||
NotifyType getType() { return TYPE_RECEIVED_DISTANT_SEARCH_RESULTS ; }
|
||||
private:
|
||||
|
||||
TurtleRequestId mRequestId ;
|
||||
RsGxsGroupId mGroupId;
|
||||
};
|
||||
|
@ -245,6 +245,16 @@ void GxsGroupFrameDialog::updateDisplay(bool complete)
|
||||
updateMessageSummaryList(msgIt->first);
|
||||
}
|
||||
}
|
||||
|
||||
updateSearchResults() ;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateSearchResults()
|
||||
{
|
||||
const std::set<TurtleRequestId>& reqs = getSearchResults();
|
||||
|
||||
for(auto it(reqs.begin());it!=reqs.end();++it)
|
||||
std::cerr << "updating search ID " << std::hex << *it << std::dec << std::endl;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::todo()
|
||||
|
@ -152,6 +152,7 @@ private:
|
||||
void initUi();
|
||||
|
||||
void updateMessageSummaryList(RsGxsGroupId groupId);
|
||||
void updateSearchResults();
|
||||
|
||||
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
||||
void groupSubscribe(bool subscribe);
|
||||
|
@ -16,12 +16,19 @@ RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl,
|
||||
connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged()));
|
||||
connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list<RsGxsGroupId>, std::list<RsGxsGroupId>)), this, SLOT(updateBroadcastGrpsChanged(std::list<RsGxsGroupId>,std::list<RsGxsGroupId>)));
|
||||
connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map<RsGxsGroupId,std::set<RsGxsMessageId> >, std::map<RsGxsGroupId,std::set<RsGxsMessageId> >)), this, SLOT(updateBroadcastMsgsChanged(std::map<RsGxsGroupId,std::set<RsGxsMessageId> >,std::map<RsGxsGroupId,std::set<RsGxsMessageId> >)));
|
||||
connect(mUpdateBroadcast, SIGNAL(distantSearchResultsChanged(const std::list<TurtleRequestId>&)), this, SLOT(updateBroadcastDistantSearchResultsChanged(const std::list<TurtleRequestId>&)));
|
||||
}
|
||||
|
||||
RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase()
|
||||
{
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::updateBroadcastDistantSearchResultsChanged(const std::list<TurtleRequestId>& ids)
|
||||
{
|
||||
for(auto it(ids.begin());it!=ids.end();++it)
|
||||
mTurtleResults.insert(*it);
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::fillComplete()
|
||||
{
|
||||
mFillComplete = true;
|
||||
@ -37,6 +44,9 @@ void RsGxsUpdateBroadcastBase::securedUpdateDisplay()
|
||||
return;
|
||||
}
|
||||
|
||||
// This is *bad* because if the connection is done asynchronously the client will call mGrpIds, mGrpIdsMeta, etc without the guarranty that the
|
||||
// the structed havnt' been cleared in the mean time.
|
||||
|
||||
emit fillDisplay(mFillComplete);
|
||||
mFillComplete = false;
|
||||
|
||||
@ -75,7 +85,7 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged()
|
||||
// The question to whether we should re=load when mGrpIds is not empty is still open. It's not harmful anyway.
|
||||
// This should probably be decided by the service itself.
|
||||
|
||||
if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty())
|
||||
if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty() || !mTurtleResults.empty())
|
||||
mFillComplete = true ;
|
||||
|
||||
securedUpdateDisplay();
|
||||
|
@ -7,6 +7,8 @@ class QShowEvent;
|
||||
class RsGxsIfaceHelper;
|
||||
class RsGxsUpdateBroadcast;
|
||||
|
||||
typedef uint32_t TurtleRequestId ;
|
||||
|
||||
class RsGxsUpdateBroadcastBase : public QObject
|
||||
{
|
||||
friend class RsGxsUpdateBroadcastPage;
|
||||
@ -25,6 +27,7 @@ public:
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds() { return mMsgIds; }
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta() { return mMsgIdsMeta; }
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
|
||||
const std::set<TurtleRequestId>& getSearchResults() { return mTurtleResults ; }
|
||||
|
||||
protected:
|
||||
void fillComplete();
|
||||
@ -39,6 +42,7 @@ private slots:
|
||||
void updateBroadcastChanged();
|
||||
void updateBroadcastGrpsChanged(const std::list<RsGxsGroupId>& grpIds, const std::list<RsGxsGroupId> &grpIdsMeta);
|
||||
void updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIdsMeta);
|
||||
void updateBroadcastDistantSearchResultsChanged(const std::list<TurtleRequestId>& ids);
|
||||
void securedUpdateDisplay();
|
||||
|
||||
private:
|
||||
@ -49,4 +53,5 @@ private:
|
||||
std::set<RsGxsGroupId> mGrpIdsMeta;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgIds;
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgIdsMeta;
|
||||
std::set<TurtleRequestId> mTurtleResults;
|
||||
};
|
||||
|
@ -22,6 +22,11 @@ void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update)
|
||||
mBase->setUpdateWhenInvisible(update);
|
||||
}
|
||||
|
||||
const std::set<TurtleRequestId>& RsGxsUpdateBroadcastPage::getSearchResults()
|
||||
{
|
||||
return mBase->getSearchResults();
|
||||
}
|
||||
|
||||
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIdsMeta()
|
||||
{
|
||||
return mBase->getGrpIdsMeta();
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
class RsGxsIfaceHelper;
|
||||
class RsGxsUpdateBroadcastBase;
|
||||
typedef uint32_t TurtleRequestId ;
|
||||
|
||||
class RsGxsUpdateBroadcastPage : public MainPage
|
||||
{
|
||||
@ -30,6 +31,7 @@ public:
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds();
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta();
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
|
||||
const std::set<TurtleRequestId>& getSearchResults();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
@ -29,6 +29,10 @@ const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIds()
|
||||
return mBase->getGrpIds();
|
||||
}
|
||||
|
||||
const std::set<TurtleRequestId>& RsGxsUpdateBroadcastWidget::getSearchResults()
|
||||
{
|
||||
return mBase->getSearchResults();
|
||||
}
|
||||
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIdsMeta()
|
||||
{
|
||||
return mBase->getGrpIdsMeta();
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
class RsGxsIfaceHelper;
|
||||
class RsGxsUpdateBroadcastBase;
|
||||
typedef uint32_t TurtleRequestId;
|
||||
|
||||
class RsGxsUpdateBroadcastWidget : public QWidget
|
||||
{
|
||||
@ -30,6 +31,7 @@ public:
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds();
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta();
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
|
||||
const std::set<TurtleRequestId>& getSearchResults() ;
|
||||
|
||||
RsGxsIfaceHelper *interfaceHelper() { return mInterfaceHelper; }
|
||||
|
||||
|
@ -79,5 +79,8 @@ void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes)
|
||||
emit grpsChanged(changes.mGrps, changes.mGrpsMeta);
|
||||
}
|
||||
|
||||
if(!changes.mDistantSearchReqs.empty())
|
||||
emit distantSearchResultsChanged(changes.mDistantSearchReqs) ;
|
||||
|
||||
emit changed();
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
class RsGxsIfaceHelper;
|
||||
class RsGxsChanges;
|
||||
|
||||
typedef uint32_t TurtleRequestId ;
|
||||
|
||||
class RsGxsUpdateBroadcast : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -21,6 +23,7 @@ signals:
|
||||
void changed();
|
||||
void msgsChanged(const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIdsMeta);
|
||||
void grpsChanged(const std::list<RsGxsGroupId>& grpIds, const std::list<RsGxsGroupId>& grpIdsMeta);
|
||||
void distantSearchResultsChanged(const std::list<TurtleRequestId>& reqs);
|
||||
|
||||
private slots:
|
||||
void onChangesReceived(const RsGxsChanges& changes);
|
||||
|
Loading…
Reference in New Issue
Block a user