mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 00:27:27 -04:00
Add support for GxsChanges as RsEvents
This commit is contained in:
parent
de0dd63e3f
commit
13ba26251c
5 changed files with 170 additions and 153 deletions
|
@ -3,7 +3,8 @@
|
|||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2012-2012 by Robert Fernie, Evi-Parker Christopher *
|
||||
* Copyright (C) 2012 Christopher Evi-Parker *
|
||||
* Copyright (C) 2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -36,6 +37,7 @@
|
|||
#include "rsgixs.h"
|
||||
#include "rsgxsutil.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsevents.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -64,10 +66,11 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key
|
|||
static const uint32_t MSG_CLEANUP_PERIOD = 60*59; // 59 minutes
|
||||
static const uint32_t INTEGRITY_CHECK_PERIOD = 60*31; // 31 minutes
|
||||
|
||||
RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService *ns,
|
||||
RsSerialType *serviceSerialiser, uint16_t servType, RsGixs* gixs,
|
||||
uint32_t authenPolicy)
|
||||
: mGenMtx("GenExchange"),
|
||||
RsGenExchange::RsGenExchange(
|
||||
RsGeneralDataService* gds, RsNetworkExchangeService* ns,
|
||||
RsSerialType* serviceSerialiser, uint16_t servType, RsGixs* gixs,
|
||||
uint32_t authenPolicy ) :
|
||||
mGenMtx("GenExchange"),
|
||||
mDataStore(gds),
|
||||
mNetService(ns),
|
||||
mSerialiser(serviceSerialiser),
|
||||
|
@ -1097,7 +1100,10 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::receiveChanges()" << std::endl;
|
||||
#endif
|
||||
RsGxsChanges out;
|
||||
std::unique_ptr<RsGxsChanges> evt(new RsGxsChanges);
|
||||
evt->mServiceType = static_cast<RsServiceType>(mServType);
|
||||
|
||||
RsGxsChanges& out = *evt;
|
||||
out.mService = getTokenService();
|
||||
|
||||
// collect all changes in one GxsChanges object
|
||||
|
@ -1109,7 +1115,7 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||
RsGxsMsgChange* mc;
|
||||
RsGxsDistantSearchResultChange *gt;
|
||||
|
||||
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != NULL)
|
||||
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != nullptr)
|
||||
{
|
||||
if (mc->metaChange())
|
||||
{
|
||||
|
@ -1120,7 +1126,7 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||
addMessageChanged(out.mMsgs, mc->msgChangeMap);
|
||||
}
|
||||
}
|
||||
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != NULL)
|
||||
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != nullptr)
|
||||
{
|
||||
if(gc->metaChange())
|
||||
{
|
||||
|
@ -1131,18 +1137,20 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||
out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList);
|
||||
}
|
||||
}
|
||||
else if((gt = dynamic_cast<RsGxsDistantSearchResultChange*>(n)) != NULL)
|
||||
else if(( gt =
|
||||
dynamic_cast<RsGxsDistantSearchResultChange*>(n) ) != nullptr)
|
||||
{
|
||||
out.mDistantSearchReqs.push_back(gt->mRequestId);
|
||||
}
|
||||
else
|
||||
std::cerr << "(EE) Unknown changes type!!" << std::endl;
|
||||
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!"
|
||||
<< std::endl;
|
||||
delete n;
|
||||
}
|
||||
changes.clear() ;
|
||||
|
||||
RsServer::notify()->notifyGxsChange(out);
|
||||
|
||||
RsServer::notify()->notifyGxsChange(out);
|
||||
if(rsEvents) rsEvents->postEvent(std::move(evt));
|
||||
}
|
||||
|
||||
bool RsGenExchange::subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe)
|
||||
|
@ -1154,8 +1162,7 @@ bool RsGenExchange::subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId,
|
|||
setGroupSubscribeFlags(token, grpId, GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED,
|
||||
(GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED | GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED));
|
||||
|
||||
if(mNetService != NULL)
|
||||
mNetService->subscribeStatusChanged(grpId,subscribe) ;
|
||||
if(mNetService) mNetService->subscribeStatusChanged(grpId,subscribe);
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
else
|
||||
std::cerr << "(EE) No mNetService in RsGenExchange for service 0x" << std::hex << mServType << std::dec << std::endl;
|
||||
|
@ -3437,3 +3444,7 @@ bool RsGenExchange::localSearch( const std::string& matchString,
|
|||
{
|
||||
return mNetService->search(matchString, results);
|
||||
}
|
||||
|
||||
RsGxsChanges::RsGxsChanges() :
|
||||
RsEvent(RsEventType::GXS_CHANGES), mServiceType(RsServiceType::NONE),
|
||||
mService(nullptr) {}
|
||||
|
|
|
@ -113,7 +113,10 @@ public:
|
|||
* @param gixs This is used for verification of msgs and groups received by Gen Exchange using identities.
|
||||
* @param authenPolicy This determines the authentication used for verfying authorship of msgs and groups
|
||||
*/
|
||||
RsGenExchange(RsGeneralDataService* gds, RsNetworkExchangeService* ns, RsSerialType* serviceSerialiser, uint16_t mServType, RsGixs* gixs, uint32_t authenPolicy);
|
||||
RsGenExchange(
|
||||
RsGeneralDataService* gds, RsNetworkExchangeService* ns,
|
||||
RsSerialType* serviceSerialiser, uint16_t mServType, RsGixs* gixs,
|
||||
uint32_t authenPolicy );
|
||||
|
||||
virtual ~RsGenExchange();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue