added code to notify GxsBroadcast system with new distant search results

This commit is contained in:
csoler 2018-06-23 22:25:36 +02:00
parent 5b9666855d
commit 6ccc7654d6
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
15 changed files with 63 additions and 6 deletions

View File

@ -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)
{

View File

@ -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;
{
RS_STACK_MUTEX(mNxsMutex) ;
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
}
RsGroupNetworkStats stats ;

View File

@ -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;
}

View File

@ -44,6 +44,7 @@ public:
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > mMsgsMeta;
std::list<RsGxsGroupId> mGrps;
std::list<RsGxsGroupId> mGrpsMeta;
std::list<TurtleRequestId> mDistantSearchReqs;
};
/*!

View File

@ -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;
};

View File

@ -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()

View File

@ -152,6 +152,7 @@ private:
void initUi();
void updateMessageSummaryList(RsGxsGroupId groupId);
void updateSearchResults();
void openGroupInNewTab(const RsGxsGroupId &groupId);
void groupSubscribe(bool subscribe);

View File

@ -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();

View File

@ -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;
};

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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; }

View File

@ -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();
}

View File

@ -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);