mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
added event handling when peer discovery is received
This commit is contained in:
parent
37dc37ce4a
commit
3f89a3300d
@ -388,6 +388,15 @@ void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContac
|
||||
if(!mPeerMgr->isHiddenNode(rsPeers->getOwnId()))
|
||||
updatePeerAddresses(item);
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsGossipDiscoveryEvent>();
|
||||
ev->mGossipDiscoveryEventType = RsGossipDiscoveryEventType::FRIEND_PEER_INFO_RECEIVED;
|
||||
ev->mFromId = fromId;
|
||||
ev->mAboutId = item->sslId;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
// if the peer is not validated, we stop the exchange here
|
||||
|
||||
if(det.skip_pgp_signature_validation)
|
||||
@ -977,7 +986,18 @@ void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContac
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD);
|
||||
|
||||
if(should_notify_discovery)
|
||||
RsServer::notify()->notifyDiscInfoChanged();
|
||||
{
|
||||
RsServer::notify()->notifyDiscInfoChanged();
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsGossipDiscoveryEvent>();
|
||||
ev->mGossipDiscoveryEventType = RsGossipDiscoveryEventType::FRIEND_PEER_INFO_RECEIVED;
|
||||
ev->mFromId = fromId;
|
||||
ev->mAboutId = item->sslId;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we explictly request certificates, instead of getting them all the time
|
||||
|
@ -47,8 +47,8 @@ extern std::shared_ptr<RsGossipDiscovery> rsGossipDiscovery;
|
||||
*/
|
||||
|
||||
enum class RsGossipDiscoveryEventType: uint32_t {
|
||||
UNKNOWN = 0x00,
|
||||
PEER_INVITE_RECEIVED = 0x01
|
||||
UNKNOWN = 0x00,
|
||||
FRIEND_PEER_INFO_RECEIVED = 0x01,
|
||||
};
|
||||
|
||||
struct RsGossipDiscoveryEvent : RsEvent
|
||||
@ -57,7 +57,8 @@ struct RsGossipDiscoveryEvent : RsEvent
|
||||
virtual ~RsGossipDiscoveryEvent() override {}
|
||||
|
||||
RsGossipDiscoveryEventType mGossipDiscoveryEventType;
|
||||
std::string mInvite;
|
||||
RsPeerId mFromId;
|
||||
RsPeerId mAboutId;
|
||||
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
@ -65,8 +66,9 @@ struct RsGossipDiscoveryEvent : RsEvent
|
||||
{
|
||||
RsEvent::serial_process(j,ctx);
|
||||
RS_SERIAL_PROCESS(mGossipDiscoveryEventType);
|
||||
RS_SERIAL_PROCESS(mInvite);
|
||||
}
|
||||
RS_SERIAL_PROCESS(mFromId);
|
||||
RS_SERIAL_PROCESS(mAboutId);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGossipDiscovery
|
||||
|
@ -177,10 +177,11 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
|
||||
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
||||
ui->filterLineEdit->showFilterIcon();
|
||||
|
||||
mEventHandlerId=0; // forces initialization
|
||||
rsEvents->registerEventsHandler(
|
||||
[this](std::shared_ptr<const RsEvent> e) { handleEvent(e); },
|
||||
mEventHandlerId, RsEventType::PEER_CONNECTION );
|
||||
mEventHandlerId_peer=0; // forces initialization
|
||||
mEventHandlerId_gssp=0; // forces initialization
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::PEER_CONNECTION );
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY );
|
||||
|
||||
mModel = new RsFriendListModel();
|
||||
mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this);
|
||||
@ -269,7 +270,9 @@ void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> /*e*/)
|
||||
|
||||
NewFriendList::~NewFriendList()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId_peer);
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId_gssp);
|
||||
|
||||
delete mModel;
|
||||
delete mProxyModel;
|
||||
delete ui;
|
||||
|
@ -121,7 +121,8 @@ private:
|
||||
|
||||
// Settings for peer list display
|
||||
bool mShowState;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
RsEventsHandlerId_t mEventHandlerId_peer;
|
||||
RsEventsHandlerId_t mEventHandlerId_gssp;
|
||||
|
||||
std::set<RsNodeGroupId> openGroups;
|
||||
std::set<RsPgpId> openPeers;
|
||||
|
Loading…
Reference in New Issue
Block a user