mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
made GxsNotify for messages with more granularity. Removed RsGxsCircleMsg class that was not used.
This commit is contained in:
parent
efb26ce9c0
commit
ce6abe5d66
@ -238,9 +238,7 @@ void RsGenExchange::tick()
|
||||
{
|
||||
for(auto& groupId:grpIds)
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_MESSAGES_DELETED, false);
|
||||
|
||||
gc->mGroupId = groupId;
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_DELETED,groupId, false);
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||
@ -256,12 +254,12 @@ void RsGenExchange::tick()
|
||||
mNetService->removeGroups(grpIds) ;
|
||||
}
|
||||
|
||||
if (!msgIds.empty())
|
||||
{
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
c->msgChangeMap = msgIds;
|
||||
mNotifications.push_back(c);
|
||||
}
|
||||
for(auto it(msgIds.begin());it!=msgIds.end();++it)
|
||||
for(auto& msgId:it->second)
|
||||
{
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_MESSAGE_DELETED,it->first, msgId, false);
|
||||
mNotifications.push_back(c);
|
||||
}
|
||||
|
||||
delete mIntegrityCheck;
|
||||
mIntegrityCheck = NULL;
|
||||
@ -775,7 +773,7 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
hash.addData(allMsgData, allMsgDataLen);
|
||||
RsFileHash hashId;
|
||||
hash.Complete(hashId);
|
||||
msg->msgId = hashId;
|
||||
msg->msgId = RsGxsMessageId(hashId);
|
||||
|
||||
// assign msg id to msg meta
|
||||
msg->metaData->mMsgId = msg->msgId;
|
||||
@ -1690,9 +1688,7 @@ void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY, true);
|
||||
gc->mGroupId = grpId;
|
||||
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY,grpId, true);
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
||||
@ -1700,8 +1696,7 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED, false);
|
||||
gc->mGroupId = grpId;
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED,grpId, false);
|
||||
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
@ -2058,11 +2053,13 @@ void RsGenExchange::processMsgMetaChanges()
|
||||
}
|
||||
}
|
||||
|
||||
if (!msgIds.empty()) {
|
||||
if (!msgIds.empty())
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
c->msgChangeMap = msgIds;
|
||||
mNotifications.push_back(c);
|
||||
|
||||
for(auto it(msgIds.begin());it!=msgIds.end();++it)
|
||||
for(auto& msg_id:it->second)
|
||||
mNotifications.push_back(new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, it->first, msg_id, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2112,15 +2109,7 @@ void RsGenExchange::processGrpMetaChanges()
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, true);
|
||||
gc->mGroupId = groupId;
|
||||
|
||||
mNotifications.push_back(gc);
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||
for(std::list<RsGxsGroupId>::const_iterator it(grpChanged.begin());it!=grpChanged.end();++it)
|
||||
std::cerr << " " << *it << std::endl;
|
||||
#endif
|
||||
mNotifications.push_back(new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED,groupId, true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2197,7 +2186,7 @@ void RsGenExchange::publishMsgs()
|
||||
mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem));
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
||||
std::map<RsGxsGroupId, std::list<RsGxsMsgItem*> > msgChangeMap;
|
||||
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
|
||||
|
||||
for(; mit != mMsgsToPublish.end(); ++mit)
|
||||
@ -2326,9 +2315,12 @@ void RsGenExchange::publishMsgs()
|
||||
|
||||
mPublishedMsgs[token] = *msg->metaData;
|
||||
|
||||
RsGxsMsgItem *msg_item = dynamic_cast<RsGxsMsgItem*>(mSerialiser->deserialise(msg->msg.bin_data,&msg->msg.bin_len)) ;
|
||||
msg_item->meta = *msg->metaData;
|
||||
|
||||
delete msg ;
|
||||
|
||||
msgChangeMap[grpId].insert(msgId);
|
||||
msgChangeMap[grpId].push_back(msg_item);
|
||||
|
||||
delete[] metaDataBuff;
|
||||
|
||||
@ -2367,13 +2359,14 @@ void RsGenExchange::publishMsgs()
|
||||
// entries are invalid
|
||||
mMsgsToPublish.clear();
|
||||
|
||||
if(!msgChangeMap.empty())
|
||||
{
|
||||
RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISHED, false);
|
||||
ch->msgChangeMap = msgChangeMap;
|
||||
mNotifications.push_back(ch);
|
||||
}
|
||||
for(auto it(msgChangeMap.begin());it!=msgChangeMap.end();++it)
|
||||
for(auto& msg_item: it->second)
|
||||
{
|
||||
RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISHED,msg_item->meta.mGroupId, msg_item->meta.mMsgId, false);
|
||||
ch->mNewMsgItem = msg_item;
|
||||
|
||||
mNotifications.push_back(ch);
|
||||
}
|
||||
}
|
||||
|
||||
RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpItem* /* grpItem */,
|
||||
@ -2507,9 +2500,7 @@ void RsGenExchange::processGroupDelete()
|
||||
|
||||
for(auto& groupId:grpDeleted)
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_DELETED, false);
|
||||
gc->mGroupId = groupId;
|
||||
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_DELETED, groupId,false);
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
||||
@ -2551,12 +2542,7 @@ void RsGenExchange::processMessageDelete()
|
||||
|
||||
for(uint32_t i=0;i<mMsgDeletePublish.size();++i)
|
||||
for(auto it(mMsgDeletePublish[i].mMsgs.begin());it!=mMsgDeletePublish[i].mMsgs.end();++it)
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_MESSAGES_DELETED, false);
|
||||
gc->mGroupId = it->first;
|
||||
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
mNotifications.push_back(new RsGxsGroupChange(RsGxsNotify::TYPE_MESSAGE_DELETED,it->first, false));
|
||||
|
||||
mMsgDeletePublish.clear();
|
||||
}
|
||||
@ -2817,18 +2803,7 @@ void RsGenExchange::publishGrps()
|
||||
}
|
||||
|
||||
for(auto& groupId:grpChanged)
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, true);
|
||||
|
||||
gc->mGroupId = groupId;
|
||||
|
||||
mNotifications.push_back(gc);
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||
for(std::list<RsGxsGroupId>::const_iterator it(grpChanged.begin());it!=grpChanged.end();++it)
|
||||
std::cerr << " " << *it << std::endl;
|
||||
#endif
|
||||
}
|
||||
mNotifications.push_back(new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW,groupId, true));
|
||||
}
|
||||
|
||||
// This is done off-mutex to avoid possible cross deadlocks with the net service.
|
||||
@ -3085,11 +3060,19 @@ void RsGenExchange::processRecvdMessages()
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " storing remaining messages" << std::endl;
|
||||
#endif
|
||||
mDataStore->storeMessage(msgs_to_store);
|
||||
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVED_NEW, false);
|
||||
c->msgChangeMap = msgIds;
|
||||
mNotifications.push_back(c);
|
||||
for(auto& nxs_msg: msgs_to_store)
|
||||
{
|
||||
RsGxsMsgItem *item = dynamic_cast<RsGxsMsgItem*>(mSerialiser->deserialise(nxs_msg->msg.bin_data,&nxs_msg->msg.bin_len));
|
||||
item->meta = *nxs_msg->metaData;
|
||||
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVED_NEW, item->meta.mGroupId, item->meta.mMsgId,false);
|
||||
c->mNewMsgItem = item;
|
||||
|
||||
mNotifications.push_back(c);
|
||||
}
|
||||
|
||||
mDataStore->storeMessage(msgs_to_store); // we do that late because it destroys the items in msgs_to_store
|
||||
}
|
||||
}
|
||||
|
||||
@ -3222,9 +3205,8 @@ void RsGenExchange::processRecvdGroups()
|
||||
{
|
||||
for(auto Grp:grps_to_store)
|
||||
{
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, false);
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, Grp->grpId, false);
|
||||
|
||||
c->mGroupId = Grp->grpId;
|
||||
c->mNewGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(Grp->grp.bin_data,&Grp->grp.bin_len));
|
||||
|
||||
mNotifications.push_back(c);
|
||||
@ -3304,7 +3286,7 @@ void RsGenExchange::performUpdateValidation()
|
||||
|
||||
// Now prepare notification of the client
|
||||
|
||||
RsGxsGroupChange *c = new RsGxsGroupChange(RsGxsNotify::TYPE_UPDATED,false);
|
||||
RsGxsGroupChange *c = new RsGxsGroupChange(RsGxsNotify::TYPE_UPDATED,gu.newGrp->metaData->mGroupId,false);
|
||||
|
||||
c->mNewGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(gu.newGrp->grp.bin_data,&gu.newGrp->grp.bin_len));
|
||||
c->mNewGroupItem->meta = *gu.newGrp->metaData; // gu.newGrp will be deleted because mDataStore will destroy it on update
|
||||
|
@ -1038,7 +1038,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
|
||||
// Because msgs are stored in a std::vector we build a map to convert each vector to its position in metaV.
|
||||
|
||||
std::vector<bool> keep(metaV.size(),true); // this vector will tell wether we keep or not a given Meta
|
||||
std::map<RsMessageId,uint32_t> index_in_metaV; // holds the index of each group Id in metaV
|
||||
std::map<RsGxsMessageId,uint32_t> index_in_metaV; // holds the index of each group Id in metaV
|
||||
|
||||
for(uint32_t i=0;i<metaV.size();++i)
|
||||
index_in_metaV[metaV[i]->mMsgId] = i;
|
||||
|
@ -20,14 +20,22 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*!
|
||||
* The aim of this class is to implement notifications internally to GXS, which are
|
||||
* mostly used by RsGenExchange to send information to specific services. These services
|
||||
* then interpret these changes and turn them into human-readable/processed service-specific changes.
|
||||
*/
|
||||
|
||||
struct RsGxsNotify
|
||||
#include "retroshare/rsids.h"
|
||||
|
||||
class RsGxsNotify
|
||||
{
|
||||
public:
|
||||
RsGxsNotify(const RsGxsGroupId& gid): mGroupId(gid){}
|
||||
virtual ~RsGxsNotify()=default;
|
||||
|
||||
enum NotifyType
|
||||
{
|
||||
TYPE_UNKNOWN = 0x00,
|
||||
@ -38,12 +46,14 @@ struct RsGxsNotify
|
||||
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
|
||||
TYPE_STATISTICS_CHANGED = 0x06,
|
||||
TYPE_UPDATED = 0x07,
|
||||
TYPE_MESSAGES_DELETED = 0x08,
|
||||
TYPE_MESSAGE_DELETED = 0x08,
|
||||
TYPE_GROUP_DELETED = 0x09,
|
||||
};
|
||||
|
||||
virtual ~RsGxsNotify() {}
|
||||
virtual NotifyType getType() = 0;
|
||||
|
||||
RsGxsGroupId mGroupId; // Group id of the group we're talking about. When the group is deleted, it's useful to know which group
|
||||
// that was although there is no pointers to the actual group data anymore.
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -52,14 +62,12 @@ struct RsGxsNotify
|
||||
class RsGxsGroupChange : public RsGxsNotify
|
||||
{
|
||||
public:
|
||||
RsGxsGroupChange(NotifyType type, bool metaChange) : mNewGroupItem(nullptr),mOldGroupItem(nullptr), mNotifyType(type), mMetaChange(metaChange) {}
|
||||
virtual ~RsGxsGroupChange() { delete mOldGroupItem; delete mNewGroupItem ; }
|
||||
RsGxsGroupChange(NotifyType type, const RsGxsGroupId& gid,bool metaChange) : RsGxsNotify(gid),mNewGroupItem(nullptr),mOldGroupItem(nullptr), mNotifyType(type), mMetaChange(metaChange) {}
|
||||
virtual ~RsGxsGroupChange() override { delete mOldGroupItem; delete mNewGroupItem ; }
|
||||
|
||||
NotifyType getType() override { return mNotifyType;}
|
||||
bool metaChange() { return mMetaChange; }
|
||||
|
||||
RsGxsGroupId mGroupId; // Group id of the group we're talking about. When the group is deleted, it's useful to know which group
|
||||
// that was although there is no pointers to the actual group data anymore.
|
||||
RsGxsGrpItem *mNewGroupItem; // Valid when a group has changed, or a new group is received.
|
||||
RsGxsGrpItem *mOldGroupItem; // only valid when mNotifyType is TYPE_UPDATED
|
||||
|
||||
@ -71,12 +79,11 @@ protected:
|
||||
class RsGxsDistantSearchResultChange: public RsGxsNotify
|
||||
{
|
||||
public:
|
||||
RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& group_id) : mRequestId(id),mGroupId(group_id){}
|
||||
RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& gid) : RsGxsNotify(gid), mRequestId(id){}
|
||||
|
||||
NotifyType getType() { return TYPE_RECEIVED_DISTANT_SEARCH_RESULTS ; }
|
||||
|
||||
TurtleRequestId mRequestId ;
|
||||
RsGxsGroupId mGroupId;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -85,8 +92,11 @@ public:
|
||||
class RsGxsMsgChange : public RsGxsNotify
|
||||
{
|
||||
public:
|
||||
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
||||
RsGxsMsgChange(NotifyType type, const RsGxsGroupId& gid, const RsGxsMessageId& msg_id,bool metaChange) : RsGxsNotify(gid), mNewMsgItem(nullptr),NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||
|
||||
RsGxsMessageId mMsgId;
|
||||
RsGxsMsgItem *mNewMsgItem;
|
||||
|
||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
||||
bool metaChange() { return mMetaChange; }
|
||||
private:
|
||||
|
@ -657,6 +657,7 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
std::cout << "p3GxsTrans::notifyChanges(...)" << std::endl;
|
||||
#endif
|
||||
std::list<RsGxsGroupId> grps_to_request;
|
||||
GxsMsgReq msgs_to_request;
|
||||
|
||||
for( auto it = changes.begin(); it != changes.end(); ++it )
|
||||
{
|
||||
@ -675,11 +676,8 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
#ifdef DEBUG_GXSTRANS
|
||||
std::cout << "p3GxsTrans::notifyChanges(...) msgChange" << std::endl;
|
||||
#endif
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
RsGenExchange::getTokenService()->requestMsgInfo( token, 0xcaca,
|
||||
opts, msgChange->msgChangeMap );
|
||||
GxsTokenQueue::queueRequest(token, MAILS_UPDATE);
|
||||
|
||||
msgs_to_request[msgChange->mGroupId].insert(msgChange->mMsgId);
|
||||
|
||||
#ifdef DEBUG_GXSTRANS
|
||||
for( GxsMsgReq::const_iterator it = msgChange->msgChangeMap.begin();
|
||||
@ -701,6 +699,17 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
if(!msgs_to_request.empty())
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
RsGenExchange::getTokenService()->requestMsgInfo( token, 0xcaca, opts, msgs_to_request);
|
||||
|
||||
GxsTokenQueue::queueRequest(token, MAILS_UPDATE);
|
||||
}
|
||||
|
||||
|
||||
if(!grps_to_request.empty())
|
||||
requestGroupsData(&grps_to_request);
|
||||
}
|
||||
|
@ -96,22 +96,32 @@ struct RsGxsCircleGroup : RsSerializable
|
||||
~RsGxsCircleGroup() override;
|
||||
};
|
||||
|
||||
enum class RsGxsCircleSubscriptionType:uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
SUBSCRIBE = 0x01,
|
||||
UNSUBSCRIBE = 0x02
|
||||
};
|
||||
|
||||
struct RsGxsCircleMsg : RsSerializable
|
||||
{
|
||||
RsMsgMetaData mMeta;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
// This item is actually totally unused, so we can change it no problem
|
||||
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED
|
||||
/* This is horrible and should be changed into yet to be defined something
|
||||
* reasonable in next non-retrocompatible version */
|
||||
std::string stuff;
|
||||
#endif
|
||||
#endif
|
||||
RsGxsCircleSubscriptionType mSubscriptionType;
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(stuff);
|
||||
RS_SERIAL_PROCESS(mSubscriptionType);
|
||||
}
|
||||
|
||||
~RsGxsCircleMsg() override;
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "serialiser/rstypeserializer.h"
|
||||
#include "util/rstime.h"
|
||||
|
||||
typedef Sha1CheckSum RsGxsMessageId;
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
|
||||
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
||||
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
|
||||
|
@ -328,6 +328,7 @@ using Sha256CheckSum = t_RsGenericIdType<_RsIdSize::SHA256 , false, R
|
||||
using RsPgpFingerprint = t_RsGenericIdType<_RsIdSize::PGP_FINGERPRINT, true, RsGenericIdType::PGP_FINGERPRINT>;
|
||||
using Bias20Bytes = t_RsGenericIdType<_RsIdSize::SHA1 , true, RsGenericIdType::BIAS_20_BYTES >;
|
||||
using RsGxsGroupId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_GROUP >;
|
||||
using RsGxsMessageId = t_RsGenericIdType<_RsIdSize::SHA1 , false, RsGenericIdType::GXS_MSG >;
|
||||
using RsGxsId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_ID >;
|
||||
using RsGxsCircleId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_CIRCLE >;
|
||||
using RsGxsTunnelId = t_RsGenericIdType<_RsIdSize::SSL_ID , false, RsGenericIdType::GXS_TUNNEL >;
|
||||
|
@ -38,7 +38,6 @@
|
||||
#define USE_NEW_CHUNK_CHECKING_CODE
|
||||
|
||||
typedef Sha1CheckSum RsFileHash ;
|
||||
typedef Sha1CheckSum RsMessageId ;
|
||||
|
||||
const uint32_t FT_STATE_FAILED = 0x0000 ;
|
||||
const uint32_t FT_STATE_OKAY = 0x0001 ;
|
||||
|
@ -35,7 +35,9 @@ RsItem *RsGxsCircleSerialiser::create_item(uint16_t service, uint8_t item_sub_id
|
||||
switch(item_sub_id)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_GXSCIRCLE_GROUP_ITEM: return new RsGxsCircleGroupItem();
|
||||
#ifdef TO_REMOVE
|
||||
case RS_PKT_SUBTYPE_GXSCIRCLE_MSG_ITEM: return new RsGxsCircleMsgItem();
|
||||
#endif
|
||||
case RS_PKT_SUBTYPE_GXSCIRCLE_SUBSCRIPTION_REQUEST_ITEM: return new RsGxsCircleSubscriptionRequestItem();
|
||||
default:
|
||||
return NULL ;
|
||||
@ -46,20 +48,27 @@ void RsGxsCircleSubscriptionRequestItem::clear()
|
||||
{
|
||||
time_stamp = 0 ;
|
||||
time_out = 0 ;
|
||||
subscription_type = SUBSCRIPTION_REQUEST_UNKNOWN;
|
||||
subscription_type = RsGxsCircleSubscriptionType::UNKNOWN;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void RsGxsCircleMsgItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
//RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,mMsg.stuff,"mMsg.stuff") ;//Should be this but not retrocompatible...
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,mMsg.stuff,"msg.stuff") ;
|
||||
}
|
||||
|
||||
void RsGxsCircleMsgItem::clear()
|
||||
{
|
||||
mMsg.stuff.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsCircleSubscriptionRequestItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,time_stamp,"time_stamp") ;
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,time_out ,"time_out") ;
|
||||
RsTypeSerializer::serial_process<uint8_t> (j,ctx,subscription_type ,"subscription_type") ;
|
||||
RsTypeSerializer::serial_process<RsGxsCircleSubscriptionType> (j,ctx,subscription_type ,"subscription_type") ;
|
||||
}
|
||||
|
||||
void RsGxsCircleGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
@ -69,11 +78,6 @@ void RsGxsCircleGroupItem::serial_process(RsGenericSerializer::SerializeJob j,Rs
|
||||
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,subCircleSet,"subCircleSet") ;
|
||||
}
|
||||
|
||||
void RsGxsCircleMsgItem::clear()
|
||||
{
|
||||
mMsg.stuff.clear();
|
||||
}
|
||||
|
||||
void RsGxsCircleGroupItem::clear()
|
||||
{
|
||||
pgpIdSet.TlvClear();
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
RsTlvGxsCircleIdSet subCircleSet;
|
||||
};
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
class RsGxsCircleMsgItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
@ -76,6 +77,7 @@ public:
|
||||
|
||||
RsGxsCircleMsg mMsg;
|
||||
};
|
||||
#endif
|
||||
|
||||
class RsGxsCircleSubscriptionRequestItem: public RsGxsMsgItem
|
||||
{
|
||||
@ -86,17 +88,11 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
enum {
|
||||
SUBSCRIPTION_REQUEST_UNKNOWN = 0x00,
|
||||
SUBSCRIPTION_REQUEST_SUBSCRIBE = 0x01,
|
||||
SUBSCRIPTION_REQUEST_UNSUBSCRIBE = 0x02
|
||||
};
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t time_stamp ;
|
||||
uint32_t time_out ;
|
||||
uint8_t subscription_type ;
|
||||
RsGxsCircleSubscriptionType subscription_type ;
|
||||
};
|
||||
|
||||
class RsGxsCircleSerialiser : public RsServiceSerializer
|
||||
|
@ -239,7 +239,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
#endif
|
||||
|
||||
/* iterate through and grab any new messages */
|
||||
std::list<RsGxsGroupId> unprocessedGroups;
|
||||
std::set<RsGxsGroupId> unprocessedGroups;
|
||||
|
||||
std::vector<RsGxsNotify *>::iterator it;
|
||||
for(it = changes.begin(); it != changes.end(); ++it)
|
||||
@ -253,16 +253,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
/* message received */
|
||||
if (rsEvents)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelMsgId = *mit1;
|
||||
ev->mChannelGroupId = mit->first;
|
||||
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
|
||||
ev->mChannelMsgId = msgChange->mMsgId;
|
||||
ev->mChannelGroupId = msgChange->mGroupId;
|
||||
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,25 +269,21 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
|
||||
std::cerr << "p3GxsChannels::notifyChanges() AutoDownload for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
bool enabled = false;
|
||||
if (autoDownloadEnabled(mit->first, enabled) && enabled)
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() AutoDownload for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* problem is most of these will be comments and votes,
|
||||
* should make it occasional - every 5mins / 10minutes TODO */
|
||||
unprocessedGroups.push_back(mit->first);
|
||||
}
|
||||
/* problem is most of these will be comments and votes, should make it occasional - every 5mins / 10minutes TODO */
|
||||
// We do not call if(autoDownLoadEnabled()) here, because it would be too costly when
|
||||
// many msgs are received from the same group. We back the groupIds and then request one by one.
|
||||
|
||||
unprocessedGroups.insert(msgChange->mGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,8 +368,16 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
if(!unprocessedGroups.empty())
|
||||
request_SpecificSubscribedGroups(unprocessedGroups);
|
||||
std::list<RsGxsGroupId> grps;
|
||||
for(auto& grp_id:unprocessedGroups)
|
||||
{
|
||||
bool enabled = false;
|
||||
if (autoDownloadEnabled(grp_id, enabled) && enabled) // costly call, that's why it's packed down here.
|
||||
grps.push_back(grp_id);
|
||||
}
|
||||
|
||||
if(!grps.empty())
|
||||
request_SpecificSubscribedGroups(grps);
|
||||
}
|
||||
|
||||
void p3GxsChannels::service_tick()
|
||||
@ -705,8 +705,7 @@ void p3GxsChannels::request_AllSubscribedGroups()
|
||||
}
|
||||
|
||||
|
||||
void p3GxsChannels::request_SpecificSubscribedGroups(
|
||||
const std::list<RsGxsGroupId> &groups )
|
||||
void p3GxsChannels::request_SpecificSubscribedGroups( const std::list<RsGxsGroupId> &groups )
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::request_SpecificSubscribedGroups()";
|
||||
@ -719,8 +718,7 @@ void p3GxsChannels::request_SpecificSubscribedGroups(
|
||||
|
||||
uint32_t token = 0;
|
||||
|
||||
if(!RsGenExchange::getTokenService()->
|
||||
requestGroupInfo(token, ansType, opts, groups))
|
||||
if(!RsGenExchange::getTokenService()-> requestGroupInfo(token, ansType, opts, groups))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Failed requesting groups info!"
|
||||
<< std::endl;
|
||||
|
@ -535,57 +535,51 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
|
||||
for(auto it = changes.begin(); it != changes.end(); ++it)
|
||||
{
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||
RsGxsNotify *c = *it;
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(c);
|
||||
|
||||
if (msgChange)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Found circle Message Change Notification" << std::endl;
|
||||
std::cerr << " Found circle Message Change Notification for group " << msgChange->mGroupId << ", msg ID " << msgChange->mMsgId << std::endl;
|
||||
#endif
|
||||
for(auto mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
||||
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
||||
#endif
|
||||
RsGxsCircleId circle_id(mit->first);
|
||||
RsGxsCircleId circle_id(msgChange->mGroupId);
|
||||
|
||||
force_cache_reload(circle_id);
|
||||
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW))
|
||||
{
|
||||
const RsGxsCircleSubscriptionRequestItem *item = dynamic_cast<const RsGxsCircleSubscriptionRequestItem *>(msgChange->mNewMsgItem);
|
||||
|
||||
RsGxsCircleDetails details;
|
||||
getCircleDetails(circle_id,details);
|
||||
if(item)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||
ev->mCircleId = circle_id;
|
||||
ev->mGxsId = msgChange->mNewMsgItem->meta.mAuthorId;
|
||||
|
||||
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW|| c->getType() == RsGxsNotify::TYPE_PUBLISHED) )
|
||||
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
||||
if (item->subscription_type == RsGxsCircleSubscriptionType::UNSUBSCRIBE)
|
||||
{
|
||||
RsGxsCircleMsg msg;
|
||||
if(getCircleRequest(RsGxsGroupId(circle_id),*msgIdIt,msg))
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||
ev->mCircleId = circle_id;
|
||||
ev->mGxsId = msg.mMeta.mAuthorId;
|
||||
|
||||
if (msg.stuff == "SUBSCRIPTION_REQUEST_UNSUBSCRIBE")
|
||||
{
|
||||
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
else if(msg.stuff == "SUBSCRIPTION_REQUEST_SUBSCRIBE")
|
||||
{
|
||||
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
else
|
||||
RsErr()<< __PRETTY_FUNCTION__<<" Cannot request CircleMsg " << *msgIdIt << ". Db not ready?" << std::endl;
|
||||
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
mCircleCache.erase(circle_id);
|
||||
mCacheUpdated = true;
|
||||
else if(item->subscription_type == RsGxsCircleSubscriptionType::SUBSCRIBE)
|
||||
{
|
||||
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
else
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown subscription request type " << static_cast<uint32_t>(item->subscription_type) << " in msg item" << std::endl;
|
||||
}
|
||||
else
|
||||
RsErr() << __PRETTY_FUNCTION__ << ": missing SubscriptionRequestItem in msg notification for msg " << msgChange->mMsgId << std::endl;
|
||||
}
|
||||
|
||||
mCircleCache.erase(circle_id);
|
||||
mCacheUpdated = true;
|
||||
}
|
||||
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(c);
|
||||
|
||||
/* add groups to ExternalIdList (Might get Personal Circles here until NetChecks in place) */
|
||||
if (groupChange)
|
||||
@ -697,7 +691,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
}
|
||||
}
|
||||
|
||||
delete *it;
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
@ -930,8 +924,9 @@ bool p3GxsCircles::getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg>
|
||||
|
||||
for(; vit != msgItems.end(); ++vit)
|
||||
{
|
||||
#ifdef TO_REMOVE
|
||||
RsGxsCircleMsgItem* item = dynamic_cast<RsGxsCircleMsgItem*>(*vit);
|
||||
RsGxsCircleSubscriptionRequestItem* rsItem = dynamic_cast<RsGxsCircleSubscriptionRequestItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsGxsCircleMsg msg = item->mMsg;
|
||||
@ -939,22 +934,16 @@ bool p3GxsCircles::getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg>
|
||||
msgs.push_back(msg);
|
||||
delete item;
|
||||
}
|
||||
else if (rsItem)
|
||||
#endif
|
||||
|
||||
RsGxsCircleSubscriptionRequestItem* rsItem = dynamic_cast<RsGxsCircleSubscriptionRequestItem*>(*vit);
|
||||
|
||||
if (rsItem)
|
||||
{
|
||||
RsGxsCircleMsg msg ;//= rsItem->mMsg;
|
||||
msg.mMeta = rsItem->meta;
|
||||
switch (rsItem->subscription_type)
|
||||
{
|
||||
case RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNKNOWN:
|
||||
msg.stuff.clear();
|
||||
break;
|
||||
case RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE:
|
||||
msg.stuff="SUBSCRIPTION_REQUEST_SUBSCRIBE";
|
||||
break;
|
||||
case RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE:
|
||||
msg.stuff="SUBSCRIPTION_REQUEST_UNSUBSCRIBE";
|
||||
break;
|
||||
}
|
||||
msg.mSubscriptionType = rsItem->subscription_type;
|
||||
|
||||
msgs.push_back(msg);
|
||||
delete rsItem;
|
||||
}
|
||||
@ -2320,19 +2309,15 @@ void p3GxsCircles::handle_event(uint32_t event_type, const std::string &elabel)
|
||||
|
||||
bool p3GxsCircles::pushCircleMembershipRequest(
|
||||
const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id,
|
||||
uint32_t request_type )
|
||||
RsGxsCircleSubscriptionType request_type )
|
||||
{
|
||||
Dbg3() << __PRETTY_FUNCTION__ << "own_gxsid = " << own_gxsid
|
||||
<< ", circle=" << circle_id << ", req type=" << request_type
|
||||
<< std::endl;
|
||||
|
||||
if( request_type !=
|
||||
RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE &&
|
||||
request_type !=
|
||||
RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE )
|
||||
if( request_type != RsGxsCircleSubscriptionType::SUBSCRIBE && request_type != RsGxsCircleSubscriptionType::UNSUBSCRIBE )
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown request type: "
|
||||
<< request_type << std::endl;
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown request type: " << static_cast<uint32_t>(request_type) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2368,7 +2353,7 @@ bool p3GxsCircles::pushCircleMembershipRequest(
|
||||
|
||||
s->meta.mGroupId = RsGxsGroupId(circle_id) ;
|
||||
s->meta.mMsgId.clear();
|
||||
s->meta.mThreadId = RsDirUtil::sha1sum(tmpmem,tmpmem.size()); // make the ID from the hash of the cirle ID and the author ID
|
||||
s->meta.mThreadId = RsGxsMessageId(RsDirUtil::sha1sum(tmpmem,tmpmem.size())); // make the ID from the hash of the cirle ID and the author ID
|
||||
s->meta.mAuthorId = own_gxsid;
|
||||
|
||||
// msgItem->meta.mParentId = ; // leave these blank
|
||||
@ -2382,7 +2367,7 @@ bool p3GxsCircles::pushCircleMembershipRequest(
|
||||
#endif
|
||||
uint32_t token ;
|
||||
|
||||
if(request_type == RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE)
|
||||
if(request_type == RsGxsCircleSubscriptionType::SUBSCRIBE)
|
||||
RsGenExchange::subscribeToGroup(token, RsGxsGroupId(circle_id), true);
|
||||
|
||||
RsGenExchange::publishMsg(token, s);
|
||||
@ -2395,11 +2380,11 @@ bool p3GxsCircles::pushCircleMembershipRequest(
|
||||
|
||||
bool p3GxsCircles::requestCircleMembership(const RsGxsId& own_gxsid,const RsGxsCircleId& circle_id)
|
||||
{
|
||||
return pushCircleMembershipRequest(own_gxsid,circle_id,RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE) ;
|
||||
return pushCircleMembershipRequest(own_gxsid,circle_id,RsGxsCircleSubscriptionType::SUBSCRIBE) ;
|
||||
}
|
||||
bool p3GxsCircles::cancelCircleMembership(const RsGxsId& own_gxsid,const RsGxsCircleId& circle_id)
|
||||
{
|
||||
return pushCircleMembershipRequest(own_gxsid,circle_id,RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE) ;
|
||||
return pushCircleMembershipRequest(own_gxsid,circle_id,RsGxsCircleSubscriptionType::UNSUBSCRIBE) ;
|
||||
}
|
||||
|
||||
|
||||
@ -2470,12 +2455,12 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
|
||||
{
|
||||
info.last_subscription_TS = item->time_stamp ;
|
||||
|
||||
if(item->subscription_type == RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE)
|
||||
if(item->subscription_type == RsGxsCircleSubscriptionType::SUBSCRIBE)
|
||||
info.subscription_flags |= GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED;
|
||||
else if(item->subscription_type == RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE)
|
||||
else if(item->subscription_type == RsGxsCircleSubscriptionType::UNSUBSCRIBE)
|
||||
info.subscription_flags &= ~GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED;
|
||||
else
|
||||
std::cerr << " (EE) unknown subscription order type: " << item->subscription_type ;
|
||||
std::cerr << " (EE) unknown subscription order type: " << static_cast<uint32_t>(item->subscription_type) ;
|
||||
|
||||
mCacheUpdated = true;
|
||||
#ifdef DEBUG_CIRCLES
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
bool pushCircleMembershipRequest(const RsGxsId& own_gxsid,const RsGxsCircleId& circle_id,uint32_t request_type) ;
|
||||
bool pushCircleMembershipRequest(const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id, RsGxsCircleSubscriptionType request_type) ;
|
||||
static uint32_t circleAuthenPolicy();
|
||||
|
||||
/** Notifications **/
|
||||
|
@ -195,16 +195,11 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED) /* message received */
|
||||
if (rsEvents)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgChangeMap = msgChange->msgChangeMap;
|
||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
ev->mForumMsgId = *mit1;
|
||||
ev->mForumGroupId = mit->first;
|
||||
ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
ev->mForumMsgId = msgChange->mMsgId;
|
||||
ev->mForumGroupId = msgChange->mGroupId;
|
||||
ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_YET
|
||||
|
@ -606,22 +606,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(changes[i]);
|
||||
|
||||
if (msgChange && !msgChange->metaChange())
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Found Message Change Notification";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Msgs for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
RsWarn() << __PRETTY_FUNCTION__ << " Found a Msg data change in p3IdService. This is quite unexpected." << std::endl;
|
||||
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(changes[i]);
|
||||
|
||||
|
@ -98,27 +98,22 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||
{
|
||||
#ifdef POSTBASE_DEBUG
|
||||
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
// To start with we are just going to trigger updates on these groups.
|
||||
// FUTURE OPTIMISATION.
|
||||
// It could be taken a step further and directly request these msgs for an update.
|
||||
addGroupForProcessing(mit->first);
|
||||
// To start with we are just going to trigger updates on these groups.
|
||||
// FUTURE OPTIMISATION.
|
||||
// It could be taken a step further and directly request these msgs for an update.
|
||||
addGroupForProcessing(msgChange->mGroupId);
|
||||
|
||||
if (rsEvents && (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED))
|
||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||
ev->mPostedMsgId = *mit1;
|
||||
ev->mPostedGroupId = mit->first;
|
||||
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
if (rsEvents && (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED))
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||
ev->mPostedMsgId = msgChange->mMsgId;
|
||||
ev->mPostedGroupId = msgChange->mGroupId;
|
||||
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,11 +331,7 @@ void p3PostBase::addGroupForProcessing(RsGxsGroupId grpId)
|
||||
{
|
||||
RsStackMutex stack(mPostBaseMtx); /********** STACK LOCKED MTX ******/
|
||||
// no point having multiple lookups queued.
|
||||
if (mBgGroupList.end() == std::find(mBgGroupList.begin(),
|
||||
mBgGroupList.end(), grpId))
|
||||
{
|
||||
mBgGroupList.push_back(grpId);
|
||||
}
|
||||
mBgGroupList.insert(grpId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,8 +364,8 @@ void p3PostBase::background_requestUnprocessedGroup()
|
||||
return;
|
||||
}
|
||||
|
||||
grpId = mBgGroupList.front();
|
||||
mBgGroupList.pop_front();
|
||||
grpId = *mBgGroupList.begin();
|
||||
mBgGroupList.erase(grpId);
|
||||
mBgProcessing = true;
|
||||
}
|
||||
|
||||
@ -468,8 +459,6 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
||||
|
||||
// generate vector of changes to push to the GUI.
|
||||
std::vector<RsGxsNotify *> changes;
|
||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
|
||||
|
||||
RsGxsGroupId groupId;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> >::iterator mit;
|
||||
@ -520,7 +509,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
||||
#endif
|
||||
|
||||
/* but we need to notify GUI about them */
|
||||
msgChanges->msgChangeMap[mit->first].insert((*vit)->meta.mMsgId);
|
||||
changes.push_back(new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, mit->first,(*vit)->meta.mMsgId, false));
|
||||
}
|
||||
else if (NULL != (commentItem = dynamic_cast<RsGxsCommentItem *>(*vit)))
|
||||
{
|
||||
@ -616,22 +605,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
||||
}
|
||||
|
||||
/* push updates of new Posts */
|
||||
if (msgChanges->msgChangeMap.size() > 0)
|
||||
{
|
||||
#ifdef POSTBASE_DEBUG
|
||||
std::cerr << "p3PostBase::background_processNewMessages() -> receiveChanges()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
changes.push_back(msgChanges);
|
||||
//receiveHelperChanges(changes);
|
||||
|
||||
notifyChanges(changes);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete(msgChanges);
|
||||
}
|
||||
notifyChanges(changes);
|
||||
|
||||
/* request the summary info from the parents */
|
||||
uint32_t token_b;
|
||||
@ -696,7 +670,6 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
||||
|
||||
// generate vector of changes to push to the GUI.
|
||||
std::vector<RsGxsNotify *> changes;
|
||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
|
||||
for(mit = parentMsgList.begin(); mit != parentMsgList.end(); ++mit)
|
||||
{
|
||||
@ -739,7 +712,8 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
||||
#endif
|
||||
|
||||
stats.increment(it->second);
|
||||
msgChanges->msgChangeMap[mit->first].insert(vit->mMsgId);
|
||||
|
||||
changes.push_back(new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED,mit->first,vit->mMsgId, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -771,21 +745,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
||||
}
|
||||
}
|
||||
|
||||
if (msgChanges->msgChangeMap.size() > 0)
|
||||
{
|
||||
#ifdef POSTBASE_DEBUG
|
||||
std::cerr << "p3PostBase::background_updateVoteCounts() -> receiveChanges()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
changes.push_back(msgChanges);
|
||||
//receiveHelperChanges(changes);
|
||||
notifyChanges(changes);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete(msgChanges);
|
||||
}
|
||||
notifyChanges(changes);
|
||||
|
||||
// DONE!.
|
||||
background_cleanup();
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
|
||||
bool mBgProcessing;
|
||||
bool mBgIncremental;
|
||||
std::list<RsGxsGroupId> mBgGroupList;
|
||||
std::set<RsGxsGroupId> mBgGroupList;
|
||||
std::map<RsGxsMessageId, PostStats> mBgStatsMap;
|
||||
|
||||
std::map<RsGxsGroupId,rstime_t> mKnownPosted;
|
||||
|
@ -46,6 +46,8 @@
|
||||
#define ROLE_FILE_HASH Qt::UserRole + 3
|
||||
#define ROLE_MSG Qt::UserRole + 4
|
||||
|
||||
Q_DECLARE_METATYPE(Sha1CheckSum)
|
||||
|
||||
GxsChannelFilesWidget::GxsChannelFilesWidget(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::GxsChannelFilesWidget)
|
||||
{
|
||||
|
@ -107,7 +107,6 @@ public:
|
||||
void setCurrentBox(BoxName bn) ;
|
||||
void setQuickViewFilter(QuickViewFilter fn) ;
|
||||
|
||||
const RsMessageId& currentMessageId() const;
|
||||
void setFilter(FilterType filter_type, const QStringList& strings) ;
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user