mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1875 from csoler/v0.6-GxsGroup
Add group change notifications (e.g. circle invites, forum moderation, etc)
This commit is contained in:
commit
d52d9c909b
@ -289,7 +289,7 @@ bool GxsSecurity::generateKeyPair(RsTlvPublicRSAKey& public_key,RsTlvPrivateRSAK
|
|||||||
if(!(private_key.checkKey() && public_key.checkKey()))
|
if(!(private_key.checkKey() && public_key.checkKey()))
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) ERROR while generating keys. Something inconsistent in flags. This is probably a bad sign!" << std::endl;
|
std::cerr << "(EE) ERROR while generating keys. Something inconsistent in flags. This is probably a bad sign!" << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
@ -418,13 +418,11 @@ bool GxsSecurity::validateNxsMsg(const RsNxsMsg& msg, const RsTlvKeySignature& s
|
|||||||
|
|
||||||
/* check signature timeperiod */
|
/* check signature timeperiod */
|
||||||
if ((msgMeta.mPublishTs < key.startTS) || (key.endTS != 0 && msgMeta.mPublishTs > key.endTS))
|
if ((msgMeta.mPublishTs < key.startTS) || (key.endTS != 0 && msgMeta.mPublishTs > key.endTS))
|
||||||
{
|
{
|
||||||
#ifdef GXS_SECURITY_DEBUG
|
RsWarn() << __PRETTY_FUNCTION__ << " GxsSecurity::validateNxsMsg() TS out of range for key " << msgMeta.mAuthorId
|
||||||
std::cerr << " GxsSecurity::validateNxsMsg() TS out of range";
|
<< " usage is limited to TS=[" << key.startTS << "," << key.endTS << "] and msg publish time is " << msgMeta.mPublishTs << std::endl;
|
||||||
std::cerr << std::endl;
|
return false;
|
||||||
#endif
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* decode key */
|
/* decode key */
|
||||||
const unsigned char *keyptr = (const unsigned char *) key.keyData.bin_data;
|
const unsigned char *keyptr = (const unsigned char *) key.keyData.bin_data;
|
||||||
|
@ -149,7 +149,7 @@ public:
|
|||||||
bool withMeta = false ) = 0;
|
bool withMeta = false ) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Retrieves all groups stored
|
* Retrieves all groups stored. Caller owns the memory and is supposed to delete the RsNxsGrp pointers after use.
|
||||||
* @param grp retrieved groups
|
* @param grp retrieved groups
|
||||||
* @param withMeta if true the meta handle of nxs grps is intitialised
|
* @param withMeta if true the meta handle of nxs grps is intitialised
|
||||||
* @param cache whether to store retrieval in mem for faster later retrieval
|
* @param cache whether to store retrieval in mem for faster later retrieval
|
||||||
|
@ -236,14 +236,17 @@ void RsGenExchange::tick()
|
|||||||
|
|
||||||
if (!grpIds.empty())
|
if (!grpIds.empty())
|
||||||
{
|
{
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false);
|
for(auto& groupId:grpIds)
|
||||||
gc->mGrpIdList = grpIds;
|
{
|
||||||
|
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_DELETED,groupId, false);
|
||||||
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||||
for(std::list<RsGxsGroupId>::const_iterator it(grpIds.begin());it!=grpIds.end();++it)
|
for(std::list<RsGxsGroupId>::const_iterator it(grpIds.begin());it!=grpIds.end();++it)
|
||||||
std::cerr << " " << *it << std::endl;
|
std::cerr << " " << *it << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mNotifications.push_back(gc);
|
mNotifications.push_back(gc);
|
||||||
|
}
|
||||||
|
|
||||||
// also notify the network exchange service that these groups no longer exist.
|
// also notify the network exchange service that these groups no longer exist.
|
||||||
|
|
||||||
@ -251,12 +254,12 @@ void RsGenExchange::tick()
|
|||||||
mNetService->removeGroups(grpIds) ;
|
mNetService->removeGroups(grpIds) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msgIds.empty())
|
for(auto it(msgIds.begin());it!=msgIds.end();++it)
|
||||||
{
|
for(auto& msgId:it->second)
|
||||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
{
|
||||||
c->msgChangeMap = msgIds;
|
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_MESSAGE_DELETED,it->first, msgId, false);
|
||||||
mNotifications.push_back(c);
|
mNotifications.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mIntegrityCheck;
|
delete mIntegrityCheck;
|
||||||
mIntegrityCheck = NULL;
|
mIntegrityCheck = NULL;
|
||||||
@ -770,7 +773,7 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
|
|||||||
hash.addData(allMsgData, allMsgDataLen);
|
hash.addData(allMsgData, allMsgDataLen);
|
||||||
RsFileHash hashId;
|
RsFileHash hashId;
|
||||||
hash.Complete(hashId);
|
hash.Complete(hashId);
|
||||||
msg->msgId = hashId;
|
msg->msgId = RsGxsMessageId(hashId);
|
||||||
|
|
||||||
// assign msg id to msg meta
|
// assign msg id to msg meta
|
||||||
msg->metaData->mMsgId = msg->msgId;
|
msg->metaData->mMsgId = msg->msgId;
|
||||||
@ -934,7 +937,7 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
|||||||
RsReputationLevel::LOCALLY_NEGATIVE )
|
RsReputationLevel::LOCALLY_NEGATIVE )
|
||||||
{
|
{
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << "RsGenExchange::validateMsg(): message from " << metaData.mAuthorId << ", rejected because reputation level (" << details.mReputation.mOverallReputationLevel <<") indicate that you banned this ID." << std::endl;
|
std::cerr << "RsGenExchange::validateMsg(): message from " << metaData.mAuthorId << ", rejected because reputation level (" << static_cast<int>(details.mReputation.mOverallReputationLevel) <<") indicate that you banned this ID." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
idValidate = false ;
|
idValidate = false ;
|
||||||
}
|
}
|
||||||
@ -1110,6 +1113,7 @@ static void addMessageChanged(std::map<RsGxsGroupId, std::set<RsGxsMessageId> >
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
||||||
{
|
{
|
||||||
std::cerr << "*********************************** RsGenExchange::receiveChanges()" << std::endl;
|
std::cerr << "*********************************** RsGenExchange::receiveChanges()" << std::endl;
|
||||||
@ -1155,6 +1159,7 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
|
|
||||||
if(rsEvents) rsEvents->postEvent(std::move(evt));
|
if(rsEvents) rsEvents->postEvent(std::move(evt));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool RsGenExchange::subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe)
|
bool RsGenExchange::subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe)
|
||||||
{
|
{
|
||||||
@ -1683,8 +1688,7 @@ void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId)
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx);
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
|
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY, true);
|
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY,grpId, true);
|
||||||
gc->mGrpIdList.push_back(grpId);
|
|
||||||
mNotifications.push_back(gc);
|
mNotifications.push_back(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1692,8 +1696,8 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx);
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
|
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED, false);
|
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED,grpId, false);
|
||||||
gc->mGrpIdList.push_back(grpId);
|
|
||||||
mNotifications.push_back(gc);
|
mNotifications.push_back(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1790,19 +1794,20 @@ void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
|
|||||||
|
|
||||||
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
|
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
|
||||||
{
|
{
|
||||||
if(!checkGroupMetaConsistency(grpItem->meta))
|
if(!checkGroupMetaConsistency(grpItem->meta))
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl;
|
std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl;
|
||||||
return ;
|
delete grpItem;
|
||||||
}
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
RS_STACK_MUTEX(mGenMtx) ;
|
RS_STACK_MUTEX(mGenMtx) ;
|
||||||
token = mDataAccess->generatePublicToken();
|
token = mDataAccess->generatePublicToken();
|
||||||
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
|
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
|
||||||
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << "RsGenExchange::updateGroup() token: " << token;
|
std::cerr << "RsGenExchange::updateGroup() token: " << token;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2049,11 +2054,13 @@ void RsGenExchange::processMsgMetaChanges()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msgIds.empty()) {
|
if (!msgIds.empty())
|
||||||
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx);
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
|
||||||
c->msgChangeMap = msgIds;
|
for(auto it(msgIds.begin());it!=msgIds.end();++it)
|
||||||
mNotifications.push_back(c);
|
for(auto& msg_id:it->second)
|
||||||
|
mNotifications.push_back(new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, it->first, msg_id, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2099,17 +2106,11 @@ void RsGenExchange::processGrpMetaChanges()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!grpChanged.empty())
|
for(auto& groupId:grpChanged)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx);
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, true);
|
|
||||||
gc->mGrpIdList = grpChanged;
|
mNotifications.push_back(new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED,groupId, true));
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2186,7 +2187,7 @@ void RsGenExchange::publishMsgs()
|
|||||||
mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem));
|
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();
|
std::map<uint32_t, RsGxsMsgItem*>::iterator mit = mMsgsToPublish.begin();
|
||||||
|
|
||||||
for(; mit != mMsgsToPublish.end(); ++mit)
|
for(; mit != mMsgsToPublish.end(); ++mit)
|
||||||
@ -2315,9 +2316,12 @@ void RsGenExchange::publishMsgs()
|
|||||||
|
|
||||||
mPublishedMsgs[token] = *msg->metaData;
|
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 ;
|
delete msg ;
|
||||||
|
|
||||||
msgChangeMap[grpId].insert(msgId);
|
msgChangeMap[grpId].push_back(msg_item);
|
||||||
|
|
||||||
delete[] metaDataBuff;
|
delete[] metaDataBuff;
|
||||||
|
|
||||||
@ -2356,13 +2360,14 @@ void RsGenExchange::publishMsgs()
|
|||||||
// entries are invalid
|
// entries are invalid
|
||||||
mMsgsToPublish.clear();
|
mMsgsToPublish.clear();
|
||||||
|
|
||||||
if(!msgChangeMap.empty())
|
for(auto it(msgChangeMap.begin());it!=msgChangeMap.end();++it)
|
||||||
{
|
for(auto& msg_item: it->second)
|
||||||
RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISHED, false);
|
{
|
||||||
ch->msgChangeMap = msgChangeMap;
|
RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISHED,msg_item->meta.mGroupId, msg_item->meta.mMsgId, false);
|
||||||
mNotifications.push_back(ch);
|
ch->mNewMsgItem = msg_item;
|
||||||
}
|
|
||||||
|
|
||||||
|
mNotifications.push_back(ch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpItem* /* grpItem */,
|
RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpItem* /* grpItem */,
|
||||||
@ -2381,15 +2386,14 @@ RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpI
|
|||||||
|
|
||||||
void RsGenExchange::processGroupUpdatePublish()
|
void RsGenExchange::processGroupUpdatePublish()
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx) ;
|
RS_STACK_MUTEX(mGenMtx) ;
|
||||||
|
|
||||||
// get keys for group update publish
|
// get keys for group update publish
|
||||||
|
|
||||||
// first build meta request map for groups to be updated
|
// first build meta request map for groups to be updated
|
||||||
RsGxsGrpMetaTemporaryMap grpMeta;
|
RsGxsGrpMetaTemporaryMap grpMeta;
|
||||||
std::vector<GroupUpdatePublish>::iterator vit = mGroupUpdatePublish.begin();
|
|
||||||
|
|
||||||
for(; vit != mGroupUpdatePublish.end(); ++vit)
|
for(auto vit = mGroupUpdatePublish.begin(); vit != mGroupUpdatePublish.end(); ++vit)
|
||||||
{
|
{
|
||||||
GroupUpdatePublish& gup = *vit;
|
GroupUpdatePublish& gup = *vit;
|
||||||
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
||||||
@ -2402,8 +2406,7 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
mDataStore->retrieveGxsGrpMetaData(grpMeta);
|
||||||
|
|
||||||
// now
|
// now
|
||||||
vit = mGroupUpdatePublish.begin();
|
for(auto vit = mGroupUpdatePublish.begin(); vit != mGroupUpdatePublish.end(); ++vit)
|
||||||
for(; vit != mGroupUpdatePublish.end(); ++vit)
|
|
||||||
{
|
{
|
||||||
GroupUpdatePublish& gup = *vit;
|
GroupUpdatePublish& gup = *vit;
|
||||||
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
||||||
@ -2421,13 +2424,13 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
meta = mit->second;
|
meta = mit->second;
|
||||||
|
|
||||||
//gup.grpItem->meta = *meta;
|
//gup.grpItem->meta = *meta;
|
||||||
GxsGrpPendingSign ggps(gup.grpItem, gup.mToken);
|
GxsGrpPendingSign ggps(gup.grpItem, gup.mToken);
|
||||||
|
|
||||||
if(checkKeys(meta->keys))
|
if(checkKeys(meta->keys))
|
||||||
{
|
{
|
||||||
ggps.mKeys = meta->keys;
|
ggps.mKeys = meta->keys;
|
||||||
|
|
||||||
GxsSecurity::createPublicKeysFromPrivateKeys(ggps.mKeys) ;
|
GxsSecurity::createPublicKeysFromPrivateKeys(ggps.mKeys) ;
|
||||||
|
|
||||||
ggps.mHaveKeys = true;
|
ggps.mHaveKeys = true;
|
||||||
ggps.mStartTS = time(NULL);
|
ggps.mStartTS = time(NULL);
|
||||||
@ -2438,7 +2441,7 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl;
|
std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl;
|
||||||
|
|
||||||
delete gup.grpItem;
|
delete gup.grpItem;
|
||||||
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED);
|
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED);
|
||||||
@ -2494,15 +2497,15 @@ void RsGenExchange::processGroupDelete()
|
|||||||
grpDeleted.push_back(note.second);
|
grpDeleted.push_back(note.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!grpDeleted.empty())
|
for(auto& groupId:grpDeleted)
|
||||||
{
|
{
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISHED, false);
|
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_DELETED, groupId,false);
|
||||||
gc->mGrpIdList = grpDeleted;
|
|
||||||
mNotifications.push_back(gc);
|
mNotifications.push_back(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
mGroupDeletePublish.clear();
|
mGroupDeletePublish.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGenExchange::processMessageDelete()
|
void RsGenExchange::processMessageDelete()
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mGenMtx) ;
|
RS_STACK_MUTEX(mGenMtx) ;
|
||||||
@ -2521,31 +2524,24 @@ void RsGenExchange::processMessageDelete()
|
|||||||
mDataStore->removeMsgs( (*vit).mMsgs );
|
mDataStore->removeMsgs( (*vit).mMsgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::list<RsGxsGroupId> grpDeleted;
|
||||||
|
// std::map<uint32_t, GrpNote>::iterator mit = toNotify.begin();
|
||||||
|
// for(; mit != toNotify.end(); ++mit)
|
||||||
|
// {
|
||||||
|
// GrpNote& note = mit->second;
|
||||||
|
// uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
|
||||||
|
// : RsTokenService::GXS_REQUEST_V2_STATUS_FAILED;
|
||||||
|
//
|
||||||
|
// mGrpNotify.insert(std::make_pair(mit->first, note.second));
|
||||||
|
// mDataAccess->updatePublicRequestStatus(mit->first, status);
|
||||||
|
//
|
||||||
|
// if(note.first)
|
||||||
|
// grpDeleted.push_back(note.second);
|
||||||
|
// }
|
||||||
|
|
||||||
#warning csoler: TODO: notify for deleted messages
|
for(uint32_t i=0;i<mMsgDeletePublish.size();++i)
|
||||||
#ifdef SUSPENDED
|
for(auto it(mMsgDeletePublish[i].mMsgs.begin());it!=mMsgDeletePublish[i].mMsgs.end();++it)
|
||||||
std::list<RsGxsGroupId> grpDeleted;
|
mNotifications.push_back(new RsGxsGroupChange(RsGxsNotify::TYPE_MESSAGE_DELETED,it->first, false));
|
||||||
std::map<uint32_t, GrpNote>::iterator mit = toNotify.begin();
|
|
||||||
for(; mit != toNotify.end(); ++mit)
|
|
||||||
{
|
|
||||||
GrpNote& note = mit->second;
|
|
||||||
uint8_t status = note.first ? RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE
|
|
||||||
: RsTokenService::GXS_REQUEST_V2_STATUS_FAILED;
|
|
||||||
|
|
||||||
mGrpNotify.insert(std::make_pair(mit->first, note.second));
|
|
||||||
mDataAccess->updatePublicRequestStatus(mit->first, status);
|
|
||||||
|
|
||||||
if(note.first)
|
|
||||||
grpDeleted.push_back(note.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!grpDeleted.empty())
|
|
||||||
{
|
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH, false);
|
|
||||||
gc->mGrpIdList = grpDeleted;
|
|
||||||
mNotifications.push_back(gc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mMsgDeletePublish.clear();
|
mMsgDeletePublish.clear();
|
||||||
}
|
}
|
||||||
@ -2805,17 +2801,8 @@ void RsGenExchange::publishGrps()
|
|||||||
grpChanged.push_back(note.second);
|
grpChanged.push_back(note.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!grpChanged.empty())
|
for(auto& groupId:grpChanged)
|
||||||
{
|
mNotifications.push_back(new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW,groupId, true));
|
||||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, true);
|
|
||||||
gc->mGrpIdList = grpChanged;
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is done off-mutex to avoid possible cross deadlocks with the net service.
|
// This is done off-mutex to avoid possible cross deadlocks with the net service.
|
||||||
@ -3072,11 +3059,19 @@ void RsGenExchange::processRecvdMessages()
|
|||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << " storing remaining messages" << std::endl;
|
std::cerr << " storing remaining messages" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mDataStore->storeMessage(msgs_to_store);
|
|
||||||
|
|
||||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVED_NEW, false);
|
for(auto& nxs_msg: msgs_to_store)
|
||||||
c->msgChangeMap = msgIds;
|
{
|
||||||
mNotifications.push_back(c);
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3205,11 +3200,17 @@ void RsGenExchange::processRecvdGroups()
|
|||||||
vit = tmp ;
|
vit = tmp ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!grpIds.empty())
|
if(!grps_to_store.empty())
|
||||||
{
|
{
|
||||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, false);
|
for(auto Grp:grps_to_store)
|
||||||
c->mGrpIdList = grpIds;
|
{
|
||||||
mNotifications.push_back(c);
|
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, Grp->grpId, false);
|
||||||
|
|
||||||
|
c->mNewGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(Grp->grp.bin_data,&Grp->grp.bin_len));
|
||||||
|
|
||||||
|
mNotifications.push_back(c);
|
||||||
|
}
|
||||||
|
|
||||||
mDataStore->storeGroup(grps_to_store);
|
mDataStore->storeGroup(grps_to_store);
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
std::cerr << " adding the following grp ids to notification: " << std::endl;
|
||||||
@ -3230,39 +3231,42 @@ void RsGenExchange::performUpdateValidation()
|
|||||||
std::cerr << "RsGenExchange::performUpdateValidation() " << std::endl;
|
std::cerr << "RsGenExchange::performUpdateValidation() " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsGxsGrpMetaTemporaryMap grpMetas;
|
RsNxsGrpDataTemporaryMap grpDatas;
|
||||||
|
|
||||||
std::vector<GroupUpdate>::iterator vit = mGroupUpdates.begin();
|
for(auto vit(mGroupUpdates.begin()); vit != mGroupUpdates.end(); ++vit)
|
||||||
for(; vit != mGroupUpdates.end(); ++vit)
|
grpDatas.insert(std::make_pair(vit->newGrp->grpId, (RsNxsGrp*)NULL));
|
||||||
grpMetas.insert(std::make_pair(vit->newGrp->grpId, (RsGxsGrpMetaData*)NULL));
|
|
||||||
|
if(grpDatas.empty() || !mDataStore->retrieveNxsGrps(grpDatas,true,false))
|
||||||
|
{
|
||||||
|
if(grpDatas.empty())
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " Validation of multiple group updates failed: no group in list!" << std::endl;
|
||||||
|
else
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " Validation of multiple group updates failed: cannot retrieve froup data for these groups!" << std::endl;
|
||||||
|
|
||||||
if(!grpMetas.empty())
|
|
||||||
mDataStore->retrieveGxsGrpMetaData(grpMetas);
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
vit = mGroupUpdates.begin();
|
|
||||||
for(; vit != mGroupUpdates.end(); ++vit)
|
|
||||||
{
|
|
||||||
GroupUpdate& gu = *vit;
|
|
||||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(gu.newGrp->grpId);
|
|
||||||
gu.oldGrpMeta = mit->second;
|
|
||||||
gu.validUpdate = updateValid(*(gu.oldGrpMeta), *(gu.newGrp));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << "RsGenExchange::performUpdateValidation() " << std::endl;
|
std::cerr << "RsGenExchange::performUpdateValidation() " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vit = mGroupUpdates.begin();
|
|
||||||
|
|
||||||
RsNxsGrpDataTemporaryList grps ;
|
RsNxsGrpDataTemporaryList grps ;
|
||||||
|
|
||||||
for(; vit != mGroupUpdates.end(); ++vit)
|
for(auto vit(mGroupUpdates.begin()); vit != mGroupUpdates.end(); ++vit)
|
||||||
{
|
{
|
||||||
GroupUpdate& gu = *vit;
|
GroupUpdate& gu = *vit;
|
||||||
|
|
||||||
if(gu.validUpdate)
|
auto mit = grpDatas.find(gu.newGrp->grpId);
|
||||||
|
|
||||||
|
if(mit == grpDatas.end())
|
||||||
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " Validation of group update failed for group " << gu.newGrp->grpId << " because previous grp version cannot be found." << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RsGxsGrpMetaData *oldGrpMeta(mit->second->metaData);
|
||||||
|
RsNxsGrp *oldGrp(mit->second);
|
||||||
|
|
||||||
|
if(updateValid(*oldGrpMeta, *gu.newGrp))
|
||||||
{
|
{
|
||||||
if(gu.newGrp->metaData->mCircleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
if(gu.newGrp->metaData->mCircleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||||
gu.newGrp->metaData->mOriginator = gu.newGrp->PeerId();
|
gu.newGrp->metaData->mOriginator = gu.newGrp->PeerId();
|
||||||
@ -3270,42 +3274,39 @@ void RsGenExchange::performUpdateValidation()
|
|||||||
// Keep subscriptionflag to what it was. This avoids clearing off the flag when updates to group meta information
|
// Keep subscriptionflag to what it was. This avoids clearing off the flag when updates to group meta information
|
||||||
// is received.
|
// is received.
|
||||||
|
|
||||||
gu.newGrp->metaData->mSubscribeFlags = gu.oldGrpMeta->mSubscribeFlags ;
|
gu.newGrp->metaData->mSubscribeFlags = oldGrpMeta->mSubscribeFlags ;
|
||||||
|
|
||||||
// Also keep private keys if present
|
// Also keep private keys if present
|
||||||
|
|
||||||
if(!gu.newGrp->metaData->keys.private_keys.empty())
|
if(!gu.newGrp->metaData->keys.private_keys.empty())
|
||||||
std::cerr << "(EE) performUpdateValidation() group " <<gu.newGrp->metaData->mGroupId << " has been received with private keys. This is very unexpected!" << std::endl;
|
std::cerr << "(EE) performUpdateValidation() group " <<gu.newGrp->metaData->mGroupId << " has been received with private keys. This is very unexpected!" << std::endl;
|
||||||
else
|
else
|
||||||
gu.newGrp->metaData->keys.private_keys = gu.oldGrpMeta->keys.private_keys ;
|
gu.newGrp->metaData->keys.private_keys = oldGrpMeta->keys.private_keys ;
|
||||||
|
|
||||||
|
// Now prepare notification of the client
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
c->mOldGroupItem = dynamic_cast<RsGxsGrpItem*>(mSerialiser->deserialise(oldGrp->grp.bin_data,&oldGrp->grp.bin_len));
|
||||||
|
c->mOldGroupItem->meta = *oldGrpMeta; // no need to delete mit->second, as it will be deleted automatically in the temporary map
|
||||||
|
|
||||||
|
mNotifications.push_back(c);
|
||||||
|
|
||||||
|
// finally, add the group to the list to send to mDataStore
|
||||||
|
|
||||||
grps.push_back(gu.newGrp);
|
grps.push_back(gu.newGrp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete gu.newGrp;
|
delete gu.newGrp; // delete here because mDataStore will not take care of this one. no need to delete mit->second, as it will be deleted automatically in the temporary map
|
||||||
gu.newGrp = NULL ;
|
gu.newGrp = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
gu.oldGrpMeta = NULL ;
|
|
||||||
}
|
}
|
||||||
// notify the client
|
|
||||||
|
|
||||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVED_NEW, true);
|
|
||||||
|
|
||||||
for(uint32_t i=0;i<mGroupUpdates.size();++i)
|
|
||||||
if(mGroupUpdates[i].newGrp != NULL)
|
|
||||||
{
|
|
||||||
c->mGrpIdList.push_back(mGroupUpdates[i].newGrp->grpId) ;
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
|
||||||
std::cerr << " " << mGroupUpdates[i].newGrp->grpId << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
mNotifications.push_back(c);
|
|
||||||
|
|
||||||
// Warning: updateGroup will destroy the objects in grps. Dont use it afterwards!
|
// Warning: updateGroup will destroy the objects in grps. Dont use it afterwards!
|
||||||
|
|
||||||
mDataStore->updateGroup(grps);
|
mDataStore->updateGroup(grps);
|
||||||
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "rsnxsobserver.h"
|
#include "rsnxsobserver.h"
|
||||||
#include "retroshare/rsgxsservice.h"
|
#include "retroshare/rsgxsservice.h"
|
||||||
#include "rsitems/rsnxsitems.h"
|
#include "rsitems/rsnxsitems.h"
|
||||||
|
#include "gxs/rsgxsnotify.h"
|
||||||
#include "rsgxsutil.h"
|
#include "rsgxsutil.h"
|
||||||
|
|
||||||
template<class GxsItem, typename Identity = std::string>
|
template<class GxsItem, typename Identity = std::string>
|
||||||
@ -262,12 +263,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool getPublishedMsgMeta(const uint32_t& token,RsMsgMetaData& meta);
|
bool getPublishedMsgMeta(const uint32_t& token,RsMsgMetaData& meta);
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
/*!
|
/*!
|
||||||
* Gxs services should call this for automatic handling of
|
* Gxs services should call this for automatic handling of
|
||||||
* changes, send
|
* changes, send
|
||||||
* @param changes
|
* @param changes
|
||||||
*/
|
*/
|
||||||
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes);
|
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief acceptNewGroup
|
* \brief acceptNewGroup
|
||||||
@ -748,9 +751,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) = 0;
|
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void processRecvdData();
|
void processRecvdData();
|
||||||
|
@ -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.
|
// 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::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)
|
for(uint32_t i=0;i<metaV.size();++i)
|
||||||
index_in_metaV[metaV[i]->mMsgId] = i;
|
index_in_metaV[metaV[i]->mMsgId] = i;
|
||||||
|
@ -320,9 +320,9 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
|
|||||||
|| defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7) \
|
|| defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7) \
|
||||||
|| defined(NXS_NET_DEBUG_8)
|
|| defined(NXS_NET_DEBUG_8)
|
||||||
|
|
||||||
static const RsPeerId peer_to_print = RsPeerId(std::string("")) ;
|
static const RsPeerId peer_to_print = RsPeerId();//std::string("a97fef0e2dc82ddb19200fb30f9ac575")) ;
|
||||||
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("")) ; // use this to allow to this group id only, or "" for all IDs
|
static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("66052380f5d1d0c5992e2b55dc402ce6")) ; // use this to allow to this group id only, or "" for all IDs
|
||||||
static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_CHANNELS ; // use this to allow to this service id only, or 0 for all services
|
static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_GXSCIRCLE; // use this to allow to this service id only, or 0 for all services
|
||||||
// warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums)
|
// warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums)
|
||||||
|
|
||||||
class nullstream: public std::ostream {};
|
class nullstream: public std::ostream {};
|
||||||
@ -3598,6 +3598,10 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
|
|||||||
msg->count = 1; // only one piece. This is to keep compatibility if we ever implement fragmenting in the future.
|
msg->count = 1; // only one piece. This is to keep compatibility if we ever implement fragmenting in the future.
|
||||||
msg->pos = 0;
|
msg->pos = 0;
|
||||||
|
|
||||||
|
#ifdef NXS_NET_DEBUG_0
|
||||||
|
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),msg->grpId) << " sending msg Id " << msg->msgId << " in Group " << msg->grpId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
newTr->mItems.push_back(msg);
|
newTr->mItems.push_back(msg);
|
||||||
msgSize++;
|
msgSize++;
|
||||||
#endif
|
#endif
|
||||||
|
107
libretroshare/src/gxs/rsgxsnotify.h
Normal file
107
libretroshare/src/gxs/rsgxsnotify.h
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* libretroshare/src/gxs/: rsgxsnotify.h *
|
||||||
|
* *
|
||||||
|
* libretroshare: retroshare core library *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2015 Retroshare Team <retroshare.project@gmail.com> *
|
||||||
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU Lesser General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU Lesser General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License *
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "retroshare/rsids.h"
|
||||||
|
|
||||||
|
class RsGxsNotify
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RsGxsNotify(const RsGxsGroupId& gid): mGroupId(gid){}
|
||||||
|
virtual ~RsGxsNotify()=default;
|
||||||
|
|
||||||
|
enum NotifyType
|
||||||
|
{
|
||||||
|
TYPE_UNKNOWN = 0x00,
|
||||||
|
TYPE_PUBLISHED = 0x01,
|
||||||
|
TYPE_RECEIVED_NEW = 0x02,
|
||||||
|
TYPE_PROCESSED = 0x03,
|
||||||
|
TYPE_RECEIVED_PUBLISHKEY = 0x04,
|
||||||
|
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
|
||||||
|
TYPE_STATISTICS_CHANGED = 0x06,
|
||||||
|
TYPE_UPDATED = 0x07,
|
||||||
|
TYPE_MESSAGE_DELETED = 0x08,
|
||||||
|
TYPE_GROUP_DELETED = 0x09,
|
||||||
|
};
|
||||||
|
|
||||||
|
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.
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Relevant to group changes
|
||||||
|
*/
|
||||||
|
class RsGxsGroupChange : public RsGxsNotify
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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; }
|
||||||
|
|
||||||
|
RsGxsGrpItem *mNewGroupItem; // Valid when a group has changed, or a new group is received.
|
||||||
|
RsGxsGrpItem *mOldGroupItem; // only valid when mNotifyType is TYPE_UPDATED
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NotifyType mNotifyType;
|
||||||
|
bool mMetaChange;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RsGxsDistantSearchResultChange: public RsGxsNotify
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& gid) : RsGxsNotify(gid), mRequestId(id){}
|
||||||
|
|
||||||
|
NotifyType getType() { return TYPE_RECEIVED_DISTANT_SEARCH_RESULTS ; }
|
||||||
|
|
||||||
|
TurtleRequestId mRequestId ;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Relevant to message changes
|
||||||
|
*/
|
||||||
|
class RsGxsMsgChange : public RsGxsNotify
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RsGxsMsgChange(NotifyType type, const RsGxsGroupId& gid, const RsGxsMessageId& msg_id,bool metaChange)
|
||||||
|
: RsGxsNotify(gid), mMsgId(msg_id), mNewMsgItem(nullptr),NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||||
|
|
||||||
|
RsGxsMessageId mMsgId;
|
||||||
|
RsGxsMsgItem *mNewMsgItem;
|
||||||
|
|
||||||
|
NotifyType getType(){ return NOTIFY_TYPE;}
|
||||||
|
bool metaChange() { return mMetaChange; }
|
||||||
|
private:
|
||||||
|
const NotifyType NOTIFY_TYPE;
|
||||||
|
bool mMetaChange;
|
||||||
|
};
|
||||||
|
|
@ -656,6 +656,9 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
#ifdef DEBUG_GXSTRANS
|
#ifdef DEBUG_GXSTRANS
|
||||||
std::cout << "p3GxsTrans::notifyChanges(...)" << std::endl;
|
std::cout << "p3GxsTrans::notifyChanges(...)" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
std::list<RsGxsGroupId> grps_to_request;
|
||||||
|
GxsMsgReq msgs_to_request;
|
||||||
|
|
||||||
for( auto it = changes.begin(); it != changes.end(); ++it )
|
for( auto it = changes.begin(); it != changes.end(); ++it )
|
||||||
{
|
{
|
||||||
RsGxsGroupChange* grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
RsGxsGroupChange* grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
||||||
@ -666,18 +669,15 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
#ifdef DEBUG_GXSTRANS
|
#ifdef DEBUG_GXSTRANS
|
||||||
std::cout << "p3GxsTrans::notifyChanges(...) grpChange" << std::endl;
|
std::cout << "p3GxsTrans::notifyChanges(...) grpChange" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
requestGroupsData(&(grpChange->mGrpIdList));
|
grps_to_request.push_back(grpChange->mGroupId);
|
||||||
}
|
}
|
||||||
else if(msgChange)
|
else if(msgChange)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GXSTRANS
|
#ifdef DEBUG_GXSTRANS
|
||||||
std::cout << "p3GxsTrans::notifyChanges(...) msgChange" << std::endl;
|
std::cout << "p3GxsTrans::notifyChanges(...) msgChange" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
uint32_t token;
|
|
||||||
RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
msgs_to_request[msgChange->mGroupId].insert(msgChange->mMsgId);
|
||||||
RsGenExchange::getTokenService()->requestMsgInfo( token, 0xcaca,
|
|
||||||
opts, msgChange->msgChangeMap );
|
|
||||||
GxsTokenQueue::queueRequest(token, MAILS_UPDATE);
|
|
||||||
|
|
||||||
#ifdef DEBUG_GXSTRANS
|
#ifdef DEBUG_GXSTRANS
|
||||||
for( GxsMsgReq::const_iterator it = msgChange->msgChangeMap.begin();
|
for( GxsMsgReq::const_iterator it = msgChange->msgChangeMap.begin();
|
||||||
@ -698,6 +698,20 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
}
|
}
|
||||||
delete *it;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t p3GxsTrans::AuthenPolicy()
|
uint32_t p3GxsTrans::AuthenPolicy()
|
||||||
|
@ -672,6 +672,7 @@ HEADERS += rsitems/rsnxsitems.h \
|
|||||||
util/rsdbbind.h \
|
util/rsdbbind.h \
|
||||||
util/contentvalue.h \
|
util/contentvalue.h \
|
||||||
gxs/rsgxsutil.h \
|
gxs/rsgxsutil.h \
|
||||||
|
gxs/rsgxsnotify.h \
|
||||||
gxs/gxssecurity.h \
|
gxs/gxssecurity.h \
|
||||||
gxs/rsgds.h \
|
gxs/rsgds.h \
|
||||||
gxs/rsgxs.h \
|
gxs/rsgxs.h \
|
||||||
|
@ -1110,10 +1110,16 @@ int pqissl::SSL_Connection_Complete()
|
|||||||
if(rsEvents)
|
if(rsEvents)
|
||||||
{
|
{
|
||||||
X509 *x509 = SSL_get_peer_certificate(ssl_connection);
|
X509 *x509 = SSL_get_peer_certificate(ssl_connection);
|
||||||
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
|
||||||
ev->mSslId = RsX509Cert::getCertSslId(*x509);
|
if(x509)
|
||||||
ev->mErrorCode = RsAuthSslError::PEER_REFUSED_CONNECTION;
|
{
|
||||||
rsEvents->postEvent(ev);
|
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
||||||
|
ev->mSslId = RsX509Cert::getCertSslId(*x509);
|
||||||
|
ev->mErrorCode = RsAuthSslError::PEER_REFUSED_CONNECTION;
|
||||||
|
|
||||||
|
if(!ev->mSslId.isNull())
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string out;
|
std::string out;
|
||||||
|
@ -45,25 +45,23 @@ extern RsGxsCircles* rsGxsCircles;
|
|||||||
|
|
||||||
enum class RsGxsCircleType : uint32_t // 32 bit overkill, just for retrocompat
|
enum class RsGxsCircleType : uint32_t // 32 bit overkill, just for retrocompat
|
||||||
{
|
{
|
||||||
UNKNOWN = 0, /// Used to detect uninizialized values.
|
UNKNOWN = 0, /// Used to detect uninizialized values.
|
||||||
PUBLIC = 1, /// Public distribution
|
PUBLIC = 1, /// Public distribution, based on GxsIds
|
||||||
EXTERNAL = 2, /// Restricted to an external circle
|
EXTERNAL = 2, /// Restricted to an external circle, based on GxsIds
|
||||||
|
|
||||||
/** Restricted to a group of friend nodes, the administrator of the circle
|
NODES_GROUP = 3, /// Restricted to a group of friend nodes, the administrator of the circle behave as a hub for them
|
||||||
* behave as a hub for them */
|
/// Based on PGP nodes ids.
|
||||||
NODES_GROUP = 3,
|
|
||||||
|
|
||||||
LOCAL = 4, /// not distributed at all
|
LOCAL = 4, /// not distributed at all
|
||||||
|
|
||||||
/** Self-restricted. Used only at creation time of self-restricted circles
|
/** Self-restricted. Used only at creation time of self-restricted circles
|
||||||
* when the circle id isn't known yet. Once the circle id is known the type
|
* when the circle id isn't known yet. Once the circle id is known the type
|
||||||
* is set to EXTERNAL, and the external circle id is set to the id of the
|
* is set to EXTERNAL, and the external circle id is set to the id of the
|
||||||
* circle itself.
|
* circle itself. Based on GxsIds.
|
||||||
*/
|
*/
|
||||||
EXT_SELF = 5,
|
EXT_SELF = 5,
|
||||||
|
|
||||||
/// distributed to nodes signed by your own PGP key only.
|
YOUR_EYES_ONLY = 6 /// distributed to nodes signed by your own PGP key only.
|
||||||
YOUR_EYES_ONLY = 6
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: convert to enum class
|
// TODO: convert to enum class
|
||||||
@ -98,22 +96,32 @@ struct RsGxsCircleGroup : RsSerializable
|
|||||||
~RsGxsCircleGroup() override;
|
~RsGxsCircleGroup() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class RsGxsCircleSubscriptionType:uint8_t {
|
||||||
|
UNKNOWN = 0x00,
|
||||||
|
SUBSCRIBE = 0x01,
|
||||||
|
UNSUBSCRIBE = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
struct RsGxsCircleMsg : RsSerializable
|
struct RsGxsCircleMsg : RsSerializable
|
||||||
{
|
{
|
||||||
RsMsgMetaData mMeta;
|
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
|
#ifndef V07_NON_BACKWARD_COMPATIBLE_CHANGE_UNNAMED
|
||||||
/* This is horrible and should be changed into yet to be defined something
|
/* This is horrible and should be changed into yet to be defined something
|
||||||
* reasonable in next non-retrocompatible version */
|
* reasonable in next non-retrocompatible version */
|
||||||
std::string stuff;
|
std::string stuff;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
RsGxsCircleSubscriptionType mSubscriptionType;
|
||||||
|
|
||||||
/// @see RsSerializable
|
/// @see RsSerializable
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
RsGenericSerializer::SerializeContext& ctx) override
|
RsGenericSerializer::SerializeContext& ctx) override
|
||||||
{
|
{
|
||||||
RS_SERIAL_PROCESS(mMeta);
|
RS_SERIAL_PROCESS(mMeta);
|
||||||
RS_SERIAL_PROCESS(stuff);
|
RS_SERIAL_PROCESS(mSubscriptionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RsGxsCircleMsg() override;
|
~RsGxsCircleMsg() override;
|
||||||
@ -121,15 +129,29 @@ struct RsGxsCircleMsg : RsSerializable
|
|||||||
|
|
||||||
struct RsGxsCircleDetails : RsSerializable
|
struct RsGxsCircleDetails : RsSerializable
|
||||||
{
|
{
|
||||||
RsGxsCircleDetails() :
|
RsGxsCircleDetails() : mCircleType(RsGxsCircleType::EXTERNAL), mAmIAllowed(false),mAmIAdmin(false) {}
|
||||||
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
|
|
||||||
mAmIAllowed(false),mAmIAdmin(false) {}
|
|
||||||
~RsGxsCircleDetails() override;
|
~RsGxsCircleDetails() override;
|
||||||
|
|
||||||
|
// helper functions.
|
||||||
|
bool isIdInCircle(const RsGxsId& id) const { return mAllowedGxsIds.find(id) != mAllowedGxsIds.end(); }
|
||||||
|
bool isIdInInviteeList(const RsGxsId& id) const
|
||||||
|
{
|
||||||
|
auto it = mSubscriptionFlags.find(id);
|
||||||
|
return (it != mSubscriptionFlags.end()) && (it->second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST );
|
||||||
|
}
|
||||||
|
bool isIdRequestingMembership(const RsGxsId& id) const
|
||||||
|
{
|
||||||
|
auto it = mSubscriptionFlags.find(id);
|
||||||
|
return it != mSubscriptionFlags.end() && (it->second & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED );
|
||||||
|
}
|
||||||
|
bool isGxsIdBased() const { return mCircleType==RsGxsCircleType::PUBLIC || mCircleType==RsGxsCircleType::EXTERNAL || mCircleType==RsGxsCircleType::EXT_SELF; }
|
||||||
|
|
||||||
|
// Members
|
||||||
|
|
||||||
RsGxsCircleId mCircleId;
|
RsGxsCircleId mCircleId;
|
||||||
std::string mCircleName;
|
std::string mCircleName;
|
||||||
|
|
||||||
uint32_t mCircleType;
|
RsGxsCircleType mCircleType;
|
||||||
RsGxsCircleId mRestrictedCircleId;
|
RsGxsCircleId mRestrictedCircleId;
|
||||||
|
|
||||||
/** true when one of load GXS ids belong to the circle allowed list (admin
|
/** true when one of load GXS ids belong to the circle allowed list (admin
|
||||||
@ -165,32 +187,54 @@ struct RsGxsCircleDetails : RsSerializable
|
|||||||
|
|
||||||
enum class RsGxsCircleEventCode: uint8_t
|
enum class RsGxsCircleEventCode: uint8_t
|
||||||
{
|
{
|
||||||
|
// Notifications be only have 4 different possibilities:
|
||||||
|
//
|
||||||
|
// invitee list join/leave and
|
||||||
|
// membership request / leave request
|
||||||
|
//
|
||||||
|
// From there, depending on what the client displays, it is possible to interpret these
|
||||||
|
// as "some user joined the circle", or "membership pending for that Id", etc, depending
|
||||||
|
// on whether the current node owns the circle, or the admin is or is not yours.
|
||||||
|
//
|
||||||
|
// These should be decided in the UI based on what the circle cache is displaying.
|
||||||
|
//
|
||||||
UNKNOWN = 0x00,
|
UNKNOWN = 0x00,
|
||||||
|
|
||||||
/** mCircleId contains the circle id and mGxsId is the id requesting
|
/**
|
||||||
* membership */
|
* Sent when we receive a membership request msg for a particular circle.
|
||||||
CIRCLE_MEMBERSHIP_REQUEST = 0x01,
|
*
|
||||||
|
* mCircleId contains the circle id and mGxsId is the id requesting membership */
|
||||||
|
CIRCLE_MEMBERSHIP_REQUEST = 0x01,
|
||||||
|
|
||||||
/** mCircleId is the circle that invites me, and mGxsId is my own Id that is
|
/**
|
||||||
* invited */
|
* Sent when the ID has been added to the circle invitee list.
|
||||||
CIRCLE_MEMBERSHIP_INVITE = 0x02,
|
*
|
||||||
|
* mCircleId is the circle that invites me, and mGxsId is my own Id that is invited */
|
||||||
|
CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST = 0x02,
|
||||||
|
|
||||||
/** mCircleId contains the circle id and mGxsId is the id dropping
|
/**
|
||||||
* membership */
|
* Sent when a GxsId annouces its will to not be in the circle.
|
||||||
CIRCLE_MEMBERSHIP_LEAVE = 0x03,
|
*
|
||||||
|
* mCircleId contains the circle id and mGxsId is the id dropping membership */
|
||||||
|
CIRCLE_MEMBERSHIP_LEAVE = 0x03,
|
||||||
|
|
||||||
/// mCircleId contains the circle id and mGxsId is the id of the new member
|
/**
|
||||||
CIRCLE_MEMBERSHIP_JOIN = 0x04,
|
* Sent when the Id has been removed from the invitee list.
|
||||||
|
*
|
||||||
|
* mCircleId contains the circle id and mGxsId is the id that was revoqued * by admin */
|
||||||
|
CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST = 0x04,
|
||||||
|
|
||||||
/** mCircleId contains the circle id and mGxsId is the id that was revoqued * by admin */
|
/**
|
||||||
CIRCLE_MEMBERSHIP_REVOQUED= 0x05,
|
* Means a new circle has been received.
|
||||||
|
*
|
||||||
/** mCircleId contains the circle id */
|
* mCircleId contains the circle id */
|
||||||
NEW_CIRCLE = 0x06,
|
NEW_CIRCLE = 0x05,
|
||||||
|
|
||||||
/** no additional information. Simply means that the info previously from the cache has changed. */
|
|
||||||
CACHE_DATA_UPDATED = 0x07,
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Means that the circle cache has updated, and membership status that is displayed should probably be updated to.
|
||||||
|
*
|
||||||
|
* no additional information. Simply means that the info previously from the cache has changed. */
|
||||||
|
CACHE_DATA_UPDATED = 0x06,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsCircleEvent: RsEvent
|
struct RsGxsCircleEvent: RsEvent
|
||||||
|
@ -112,6 +112,7 @@ enum class RsForumEventCode: uint8_t
|
|||||||
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
|
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
|
||||||
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
|
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
|
||||||
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
|
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
|
||||||
|
MODERATOR_LIST_CHANGED = 0x08, /// forum moderation list has changed.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGxsForumEvent: RsEvent
|
struct RsGxsForumEvent: RsEvent
|
||||||
@ -123,6 +124,8 @@ struct RsGxsForumEvent: RsEvent
|
|||||||
RsForumEventCode mForumEventCode;
|
RsForumEventCode mForumEventCode;
|
||||||
RsGxsGroupId mForumGroupId;
|
RsGxsGroupId mForumGroupId;
|
||||||
RsGxsMessageId mForumMsgId;
|
RsGxsMessageId mForumMsgId;
|
||||||
|
std::list<RsGxsId> mModeratorsAdded;
|
||||||
|
std::list<RsGxsId> mModeratorsRemoved;
|
||||||
|
|
||||||
///* @see RsEvent @see RsSerializable
|
///* @see RsEvent @see RsSerializable
|
||||||
void serial_process(
|
void serial_process(
|
||||||
@ -133,6 +136,9 @@ struct RsGxsForumEvent: RsEvent
|
|||||||
RS_SERIAL_PROCESS(mForumEventCode);
|
RS_SERIAL_PROCESS(mForumEventCode);
|
||||||
RS_SERIAL_PROCESS(mForumGroupId);
|
RS_SERIAL_PROCESS(mForumGroupId);
|
||||||
RS_SERIAL_PROCESS(mForumMsgId);
|
RS_SERIAL_PROCESS(mForumMsgId);
|
||||||
|
RS_SERIAL_PROCESS(mForumMsgId);
|
||||||
|
RS_SERIAL_PROCESS(mModeratorsAdded);
|
||||||
|
RS_SERIAL_PROCESS(mModeratorsRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RsGxsForumEvent() override;
|
~RsGxsForumEvent() override;
|
||||||
|
@ -116,12 +116,14 @@ struct RsGxsIface
|
|||||||
*/
|
*/
|
||||||
virtual uint16_t serviceType() const =0;
|
virtual uint16_t serviceType() const =0;
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
/*!
|
/*!
|
||||||
* Gxs services should call this for automatic handling of
|
* Gxs services should call this for automatic handling of
|
||||||
* changes, send
|
* changes, send
|
||||||
* @param changes
|
* @param changes
|
||||||
*/
|
*/
|
||||||
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes) = 0;
|
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @return handle to token service for this GXS service
|
* @return handle to token service for this GXS service
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
|
|
||||||
~RsGxsIfaceHelper() = default;
|
~RsGxsIfaceHelper() = default;
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
/*!
|
/*!
|
||||||
* Gxs services should call this for automatic handling of
|
* Gxs services should call this for automatic handling of
|
||||||
* changes, send
|
* changes, send
|
||||||
@ -81,6 +82,7 @@ public:
|
|||||||
{
|
{
|
||||||
mGxs.receiveChanges(changes);
|
mGxs.receiveChanges(changes);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Generic Lists */
|
/* Generic Lists */
|
||||||
|
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include "serialiser/rstypeserializer.h"
|
#include "serialiser/rstypeserializer.h"
|
||||||
#include "util/rstime.h"
|
#include "util/rstime.h"
|
||||||
|
|
||||||
typedef Sha1CheckSum RsGxsMessageId;
|
|
||||||
|
|
||||||
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
|
typedef std::map<RsGxsGroupId, std::set<RsGxsMessageId> > GxsMsgIdResult;
|
||||||
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
|
||||||
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
|
typedef std::map<RsGxsGrpMsgIdPair, std::set<RsGxsMessageId> > MsgRelatedIdResult;
|
||||||
|
@ -32,69 +32,6 @@ typedef uint32_t TurtleRequestId;
|
|||||||
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
|
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
|
||||||
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
|
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
|
||||||
|
|
||||||
/*!
|
|
||||||
* The aim of this class is to abstract how changes are represented so they can
|
|
||||||
* be determined outside the client API without explcitly enumerating all
|
|
||||||
* possible changes at the interface
|
|
||||||
*/
|
|
||||||
struct RsGxsNotify
|
|
||||||
{
|
|
||||||
enum NotifyType
|
|
||||||
{
|
|
||||||
TYPE_UNKNOWN = 0x00,
|
|
||||||
TYPE_PUBLISHED = 0x01,
|
|
||||||
TYPE_RECEIVED_NEW = 0x02,
|
|
||||||
TYPE_PROCESSED = 0x03,
|
|
||||||
TYPE_RECEIVED_PUBLISHKEY = 0x04,
|
|
||||||
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
|
|
||||||
TYPE_STATISTICS_CHANGED = 0x06
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~RsGxsNotify() {}
|
|
||||||
virtual NotifyType getType() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Relevant to group changes
|
|
||||||
*/
|
|
||||||
class RsGxsGroupChange : public RsGxsNotify
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RsGxsGroupChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
|
||||||
std::list<RsGxsGroupId> mGrpIdList;
|
|
||||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
|
||||||
bool metaChange() { return mMetaChange; }
|
|
||||||
private:
|
|
||||||
const NotifyType NOTIFY_TYPE;
|
|
||||||
bool mMetaChange;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RsGxsDistantSearchResultChange: public RsGxsNotify
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& group_id) : mRequestId(id),mGroupId(group_id){}
|
|
||||||
|
|
||||||
NotifyType getType() { return TYPE_RECEIVED_DISTANT_SEARCH_RESULTS ; }
|
|
||||||
|
|
||||||
TurtleRequestId mRequestId ;
|
|
||||||
RsGxsGroupId mGroupId;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Relevant to message changes
|
|
||||||
*/
|
|
||||||
class RsGxsMsgChange : public RsGxsNotify
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
|
|
||||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
|
||||||
bool metaChange() { return mMetaChange; }
|
|
||||||
private:
|
|
||||||
const NotifyType NOTIFY_TYPE;
|
|
||||||
bool mMetaChange;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // RSGXSSERVICE_H
|
#endif // RSGXSSERVICE_H
|
||||||
|
@ -328,6 +328,7 @@ using Sha256CheckSum = t_RsGenericIdType<_RsIdSize::SHA256 , false, R
|
|||||||
using RsPgpFingerprint = t_RsGenericIdType<_RsIdSize::PGP_FINGERPRINT, true, RsGenericIdType::PGP_FINGERPRINT>;
|
using RsPgpFingerprint = t_RsGenericIdType<_RsIdSize::PGP_FINGERPRINT, true, RsGenericIdType::PGP_FINGERPRINT>;
|
||||||
using Bias20Bytes = t_RsGenericIdType<_RsIdSize::SHA1 , true, RsGenericIdType::BIAS_20_BYTES >;
|
using Bias20Bytes = t_RsGenericIdType<_RsIdSize::SHA1 , true, RsGenericIdType::BIAS_20_BYTES >;
|
||||||
using RsGxsGroupId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_GROUP >;
|
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 RsGxsId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_ID >;
|
||||||
using RsGxsCircleId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_CIRCLE >;
|
using RsGxsCircleId = t_RsGenericIdType<_RsIdSize::CERT_SIGN , false, RsGenericIdType::GXS_CIRCLE >;
|
||||||
using RsGxsTunnelId = t_RsGenericIdType<_RsIdSize::SSL_ID , false, RsGenericIdType::GXS_TUNNEL >;
|
using RsGxsTunnelId = t_RsGenericIdType<_RsIdSize::SSL_ID , false, RsGenericIdType::GXS_TUNNEL >;
|
||||||
|
@ -115,11 +115,13 @@ const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
|
|||||||
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
||||||
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
||||||
|
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
const uint32_t RS_FEED_ITEM_CIRCLE_INVITE_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED = RS_FEED_TYPE_CIRCLE | 0x0005;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED = RS_FEED_TYPE_CIRCLE | 0x0005;
|
||||||
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOKED = RS_FEED_TYPE_CIRCLE | 0x0006;
|
||||||
|
const uint32_t RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED= RS_FEED_TYPE_CIRCLE | 0x0007;
|
||||||
|
|
||||||
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#define USE_NEW_CHUNK_CHECKING_CODE
|
#define USE_NEW_CHUNK_CHECKING_CODE
|
||||||
|
|
||||||
typedef Sha1CheckSum RsFileHash ;
|
typedef Sha1CheckSum RsFileHash ;
|
||||||
typedef Sha1CheckSum RsMessageId ;
|
|
||||||
|
|
||||||
const uint32_t FT_STATE_FAILED = 0x0000 ;
|
const uint32_t FT_STATE_FAILED = 0x0000 ;
|
||||||
const uint32_t FT_STATE_OKAY = 0x0001 ;
|
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)
|
switch(item_sub_id)
|
||||||
{
|
{
|
||||||
case RS_PKT_SUBTYPE_GXSCIRCLE_GROUP_ITEM: return new RsGxsCircleGroupItem();
|
case RS_PKT_SUBTYPE_GXSCIRCLE_GROUP_ITEM: return new RsGxsCircleGroupItem();
|
||||||
|
#ifdef TO_REMOVE
|
||||||
case RS_PKT_SUBTYPE_GXSCIRCLE_MSG_ITEM: return new RsGxsCircleMsgItem();
|
case RS_PKT_SUBTYPE_GXSCIRCLE_MSG_ITEM: return new RsGxsCircleMsgItem();
|
||||||
|
#endif
|
||||||
case RS_PKT_SUBTYPE_GXSCIRCLE_SUBSCRIPTION_REQUEST_ITEM: return new RsGxsCircleSubscriptionRequestItem();
|
case RS_PKT_SUBTYPE_GXSCIRCLE_SUBSCRIPTION_REQUEST_ITEM: return new RsGxsCircleSubscriptionRequestItem();
|
||||||
default:
|
default:
|
||||||
return NULL ;
|
return NULL ;
|
||||||
@ -46,20 +48,27 @@ void RsGxsCircleSubscriptionRequestItem::clear()
|
|||||||
{
|
{
|
||||||
time_stamp = 0 ;
|
time_stamp = 0 ;
|
||||||
time_out = 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)
|
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,"mMsg.stuff") ;//Should be this but not retrocompatible...
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,mMsg.stuff,"msg.stuff") ;
|
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)
|
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_stamp,"time_stamp") ;
|
||||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,time_out ,"time_out") ;
|
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)
|
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") ;
|
RsTypeSerializer::serial_process<RsTlvItem>(j,ctx,subCircleSet,"subCircleSet") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGxsCircleMsgItem::clear()
|
|
||||||
{
|
|
||||||
mMsg.stuff.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RsGxsCircleGroupItem::clear()
|
void RsGxsCircleGroupItem::clear()
|
||||||
{
|
{
|
||||||
pgpIdSet.TlvClear();
|
pgpIdSet.TlvClear();
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
RsTlvGxsCircleIdSet subCircleSet;
|
RsTlvGxsCircleIdSet subCircleSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
class RsGxsCircleMsgItem : public RsGxsMsgItem
|
class RsGxsCircleMsgItem : public RsGxsMsgItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -76,6 +77,7 @@ public:
|
|||||||
|
|
||||||
RsGxsCircleMsg mMsg;
|
RsGxsCircleMsg mMsg;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class RsGxsCircleSubscriptionRequestItem: public RsGxsMsgItem
|
class RsGxsCircleSubscriptionRequestItem: public RsGxsMsgItem
|
||||||
{
|
{
|
||||||
@ -86,17 +88,11 @@ public:
|
|||||||
|
|
||||||
void clear();
|
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);
|
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||||
|
|
||||||
uint32_t time_stamp ;
|
uint32_t time_stamp ;
|
||||||
uint32_t time_out ;
|
uint32_t time_out ;
|
||||||
uint8_t subscription_type ;
|
RsGxsCircleSubscriptionType subscription_type ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGxsCircleSerialiser : public RsServiceSerializer
|
class RsGxsCircleSerialiser : public RsServiceSerializer
|
||||||
|
@ -92,11 +92,15 @@ template<class ID_CLASS,uint32_t TLV_TYPE> class RS_DEPRECATED_FOR(std::set<>) t
|
|||||||
ids.insert(id) ;
|
ids.insert(id) ;
|
||||||
}
|
}
|
||||||
if(*offset != tlvend)
|
if(*offset != tlvend)
|
||||||
|
{
|
||||||
std::cerr << "(EE) deserialisaiton error in " << __PRETTY_FUNCTION__ << std::endl;
|
std::cerr << "(EE) deserialisaiton error in " << __PRETTY_FUNCTION__ << std::endl;
|
||||||
else if(!ok)
|
ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ok)
|
||||||
std::cerr << "(WW) something wrong in ID_CLASS.deserialise in " << __PRETTY_FUNCTION__ << std::endl;
|
std::cerr << "(WW) something wrong in ID_CLASS.deserialise in " << __PRETTY_FUNCTION__ << std::endl;
|
||||||
|
|
||||||
return *offset == tlvend ;
|
return ok;
|
||||||
}
|
}
|
||||||
virtual std::ostream &print(std::ostream &out, uint16_t /* indent */) const
|
virtual std::ostream &print(std::ostream &out, uint16_t /* indent */) const
|
||||||
{
|
{
|
||||||
|
@ -239,7 +239,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* iterate through and grab any new messages */
|
/* iterate through and grab any new messages */
|
||||||
std::list<RsGxsGroupId> unprocessedGroups;
|
std::set<RsGxsGroupId> unprocessedGroups;
|
||||||
|
|
||||||
std::vector<RsGxsNotify *>::iterator it;
|
std::vector<RsGxsNotify *>::iterator it;
|
||||||
for(it = changes.begin(); it != changes.end(); ++it)
|
for(it = changes.begin(); it != changes.end(); ++it)
|
||||||
@ -253,16 +253,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
/* message received */
|
/* message received */
|
||||||
if (rsEvents)
|
if (rsEvents)
|
||||||
{
|
{
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
|
||||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
ev->mChannelMsgId = msgChange->mMsgId;
|
||||||
{
|
ev->mChannelGroupId = msgChange->mGroupId;
|
||||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
|
||||||
ev->mChannelMsgId = *mit1;
|
rsEvents->postEvent(ev);
|
||||||
ev->mChannelGroupId = mit->first;
|
|
||||||
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
|
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,25 +269,21 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#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;
|
std::cerr << std::endl;
|
||||||
#endif
|
#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,
|
/* problem is most of these will be comments and votes, should make it occasional - every 5mins / 10minutes TODO */
|
||||||
* should make it occasional - every 5mins / 10minutes TODO */
|
// We do not call if(autoDownLoadEnabled()) here, because it would be too costly when
|
||||||
unprocessedGroups.push_back(mit->first);
|
// many msgs are received from the same group. We back the groupIds and then request one by one.
|
||||||
}
|
|
||||||
|
unprocessedGroups.insert(msgChange->mGroupId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,71 +296,52 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
{
|
{
|
||||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mChannelGroupId = grpChange->mGroupId;
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||||
{
|
rsEvents->postEvent(ev);
|
||||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
|
||||||
ev->mChannelGroupId = *git;
|
|
||||||
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
|
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mChannelGroupId = grpChange->mGroupId;
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
ev->mChannelEventCode = RsChannelEventCode::STATISTICS_CHANGED;
|
||||||
{
|
rsEvents->postEvent(ev);
|
||||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
}
|
||||||
ev->mChannelGroupId = *git;
|
|
||||||
ev->mChannelEventCode = RsChannelEventCode::STATISTICS_CHANGED;
|
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
{
|
{
|
||||||
/* group received */
|
/* group received */
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
|
||||||
{
|
|
||||||
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
|
||||||
IndicateConfigChanged();
|
|
||||||
|
|
||||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||||
ev->mChannelGroupId = *git;
|
|
||||||
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
|
if(mKnownChannels.find(grpChange->mGroupId) == mKnownChannels.end())
|
||||||
rsEvents->postEvent(ev);
|
{
|
||||||
}
|
mKnownChannels.insert(std::make_pair(grpChange->mGroupId,time(NULL))) ;
|
||||||
else
|
IndicateConfigChanged();
|
||||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
|
||||||
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
|
ev->mChannelGroupId = grpChange->mGroupId;
|
||||||
|
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
|
std::cerr << "(II) Not notifying already known channel " << grpChange->mGroupId << std::endl;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||||
{
|
{
|
||||||
/* group received */
|
/* group received */
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mChannelGroupId = grpChange->mGroupId;
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
|
||||||
{
|
|
||||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
|
||||||
ev->mChannelGroupId = *git;
|
|
||||||
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
|
|
||||||
|
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -395,8 +368,16 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!unprocessedGroups.empty())
|
std::list<RsGxsGroupId> grps;
|
||||||
request_SpecificSubscribedGroups(unprocessedGroups);
|
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()
|
void p3GxsChannels::service_tick()
|
||||||
@ -724,8 +705,7 @@ void p3GxsChannels::request_AllSubscribedGroups()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void p3GxsChannels::request_SpecificSubscribedGroups(
|
void p3GxsChannels::request_SpecificSubscribedGroups( const std::list<RsGxsGroupId> &groups )
|
||||||
const std::list<RsGxsGroupId> &groups )
|
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
std::cerr << "p3GxsChannels::request_SpecificSubscribedGroups()";
|
std::cerr << "p3GxsChannels::request_SpecificSubscribedGroups()";
|
||||||
@ -738,8 +718,7 @@ void p3GxsChannels::request_SpecificSubscribedGroups(
|
|||||||
|
|
||||||
uint32_t token = 0;
|
uint32_t token = 0;
|
||||||
|
|
||||||
if(!RsGenExchange::getTokenService()->
|
if(!RsGenExchange::getTokenService()-> requestGroupInfo(token, ansType, opts, groups))
|
||||||
requestGroupInfo(token, ansType, opts, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " Failed requesting groups info!"
|
std::cerr << __PRETTY_FUNCTION__ << " Failed requesting groups info!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -128,11 +128,20 @@ public:
|
|||||||
uint32_t subscription_flags ; // combination of GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST and GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED
|
uint32_t subscription_flags ; // combination of GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST and GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CircleEntryCacheStatus: uint8_t {
|
||||||
|
UNKNOWN = 0x00, // Used to detect uninitialized memory
|
||||||
|
NO_DATA_YET = 0x01, // Used in the constuctor
|
||||||
|
LOADING = 0x02, // When the token request to load cache has been sent and no data is present
|
||||||
|
UPDATING = 0x03, // Starting from this level the cache entry can be used
|
||||||
|
CHECKING_MEMBERSHIP = 0x04, // Means we're actually looking into msgs to update membership status
|
||||||
|
UP_TO_DATE = 0x05 // Everything should be loaded here.
|
||||||
|
};
|
||||||
|
|
||||||
class RsGxsCircleCache
|
class RsGxsCircleCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsCircleCache();
|
RsGxsCircleCache();
|
||||||
|
|
||||||
bool loadBaseCircle(const RsGxsCircleGroup &circle);
|
bool loadBaseCircle(const RsGxsCircleGroup &circle);
|
||||||
bool loadSubCircle(const RsGxsCircleCache &subcircle);
|
bool loadSubCircle(const RsGxsCircleCache &subcircle);
|
||||||
|
|
||||||
@ -142,33 +151,62 @@ class RsGxsCircleCache
|
|||||||
bool addAllowedPeer(const RsPgpId &pgpid);
|
bool addAllowedPeer(const RsPgpId &pgpid);
|
||||||
bool addLocalFriend(const RsPgpId &pgpid);
|
bool addLocalFriend(const RsPgpId &pgpid);
|
||||||
|
|
||||||
|
// Cache related data
|
||||||
|
|
||||||
|
rstime_t mLastUpdatedMembershipTS ; // Last time the subscribe messages have been requested. Should be reset when new messages arrive.
|
||||||
|
rstime_t mLastUpdateTime; // Last time the cache entry was loaded
|
||||||
|
CircleEntryCacheStatus mStatus; // Overall state of the cache entry
|
||||||
|
bool mAllIdsHere ; // True when all ids are knwon and available.
|
||||||
|
|
||||||
|
// GxsCircle related data
|
||||||
|
|
||||||
RsGxsCircleId mCircleId;
|
RsGxsCircleId mCircleId;
|
||||||
std::string mCircleName;
|
std::string mCircleName;
|
||||||
|
|
||||||
uint32_t mCircleType;
|
RsGxsCircleType mCircleType;
|
||||||
bool mIsExternal;
|
bool mIsExternal;
|
||||||
RsGxsCircleId mRestrictedCircleId ; // circle ID that circle is restricted to.
|
RsGxsCircleId mRestrictedCircleId ; // circle ID that circle is restricted to.
|
||||||
|
|
||||||
uint32_t mGroupStatus;
|
uint32_t mGroupStatus;
|
||||||
uint32_t mGroupSubscribeFlags;
|
uint32_t mGroupSubscribeFlags;
|
||||||
|
|
||||||
rstime_t mUpdateTime;
|
|
||||||
#ifdef SUBSCIRCLES
|
#ifdef SUBSCIRCLES
|
||||||
std::set<RsGxsCircleId> mUnprocessedCircles;
|
std::set<RsGxsCircleId> mUnprocessedCircles;
|
||||||
std::set<RsGxsCircleId> mProcessedCircles;
|
std::set<RsGxsCircleId> mProcessedCircles;
|
||||||
#endif
|
#endif
|
||||||
std::map<RsGxsId,RsGxsCircleMembershipStatus> mMembershipStatus;
|
std::map<RsGxsId,RsGxsCircleMembershipStatus> mMembershipStatus;
|
||||||
rstime_t mLastUpdatedMembershipTS ; // last time the subscribe messages have been requested. Should be reset when new messages arrive.
|
|
||||||
|
|
||||||
std::set<RsGxsId> mAllowedGxsIds; // IDs that are allowed in the circle and have requested membership. This is the official members list.
|
std::set<RsGxsId> mAllowedGxsIds; // IDs that are allowed in the circle and have requested membership. This is the official members list.
|
||||||
std::set<RsPgpId> mAllowedNodes;
|
std::set<RsPgpId> mAllowedNodes;
|
||||||
|
|
||||||
RsPeerId mOriginator ; // peer who sent the data, in case we need to ask for ids
|
RsPeerId mOriginator ; // peer who sent the data, in case we need to ask for ids
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PgpAuxUtils;
|
class PgpAuxUtils;
|
||||||
|
|
||||||
|
class RsCirclesMemCache : public std::map<RsGxsCircleId,RsGxsCircleCache>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RsCirclesMemCache() : std::map<RsGxsCircleId,RsGxsCircleCache>(){}
|
||||||
|
|
||||||
|
bool is_cached(const RsGxsCircleId& id) { return end() != find(id) ; }
|
||||||
|
RsGxsCircleCache& ref(const RsGxsCircleId& id) { return operator[](id) ; }
|
||||||
|
|
||||||
|
void printStats() { std::cerr << "CircleMemCache: " << size() << " elements." << std::endl; }
|
||||||
|
|
||||||
|
template<class ClientClass> void applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(RsGxsCircleCache&))
|
||||||
|
{
|
||||||
|
for(auto& it:*this)
|
||||||
|
(c.*method)(it.second);
|
||||||
|
}
|
||||||
|
template<class ClientClass> void applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(const RsGxsCircleCache&))
|
||||||
|
{
|
||||||
|
for(const auto& it:*this)
|
||||||
|
(c.*method)(it.second);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class p3GxsCircles: public RsGxsCircleExchange, public RsGxsCircles,
|
class p3GxsCircles: public RsGxsCircleExchange, public RsGxsCircles,
|
||||||
public GxsTokenQueue, public RsTickEvent
|
public GxsTokenQueue, public RsTickEvent
|
||||||
{
|
{
|
||||||
@ -264,7 +302,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
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();
|
static uint32_t circleAuthenPolicy();
|
||||||
|
|
||||||
/** Notifications **/
|
/** Notifications **/
|
||||||
@ -319,20 +357,18 @@ public:
|
|||||||
std::list<RsGxsCircleId> mCirclePersonalIdList;
|
std::list<RsGxsCircleId> mCirclePersonalIdList;
|
||||||
|
|
||||||
/***** Caching Circle Info, *****/
|
/***** Caching Circle Info, *****/
|
||||||
// initial load queue
|
|
||||||
std::list<RsGxsCircleId> mCacheLoad_ToCache;
|
|
||||||
|
|
||||||
// waiting for subcircle to load. (first is part of each of the second list)
|
// waiting for subcircle to load. (first is part of each of the second list)
|
||||||
// TODO.
|
// TODO.
|
||||||
//std::map<RsGxsCircleId, std::list<RsGxsCircleId> > mCacheLoad_SubCircle;
|
//std::map<RsGxsCircleId, std::list<RsGxsCircleId> > mCacheLoad_SubCircle;
|
||||||
|
|
||||||
// Circles that are being loaded.
|
std::set<RsGxsCircleId> mCirclesToLoad; // list of circles to update/load, so that we can treat them by groups.
|
||||||
std::map<RsGxsCircleId, RsGxsCircleCache> mLoadingCache;
|
RsCirclesMemCache mCircleCache;
|
||||||
|
//RsMemCache<RsGxsCircleId, RsGxsCircleCache> mCircleCache; // actual cache data
|
||||||
|
|
||||||
// actual cache.
|
void debug_dumpCache(); // debug method to overview what's going on
|
||||||
RsMemCache<RsGxsCircleId, RsGxsCircleCache> mCircleCache;
|
bool debug_dumpCacheEntry(RsGxsCircleCache &cache);
|
||||||
|
private:
|
||||||
private:
|
|
||||||
|
|
||||||
std::string genRandomId();
|
std::string genRandomId();
|
||||||
|
|
||||||
@ -345,8 +381,9 @@ public:
|
|||||||
uint32_t mDummyIdToken;
|
uint32_t mDummyIdToken;
|
||||||
std::list<RsGxsId> mDummyPgpLinkedIds;
|
std::list<RsGxsId> mDummyPgpLinkedIds;
|
||||||
std::list<RsGxsId> mDummyOwnIds;
|
std::list<RsGxsId> mDummyOwnIds;
|
||||||
bool mCacheUpdated ;
|
bool mShouldSendCacheUpdateNotification ;
|
||||||
rstime_t mLastCacheUpdateEvent;
|
rstime_t mLastCacheUpdateEvent;
|
||||||
|
rstime_t mLastDebugPrintTS;
|
||||||
|
|
||||||
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
||||||
};
|
};
|
||||||
|
@ -189,21 +189,17 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
for(it = changes.begin(); it != changes.end(); ++it)
|
for(it = changes.begin(); it != changes.end(); ++it)
|
||||||
{
|
{
|
||||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||||
|
|
||||||
if (msgChange)
|
if (msgChange)
|
||||||
{
|
{
|
||||||
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED) /* message received */
|
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED) /* message received */
|
||||||
if (rsEvents)
|
if (rsEvents)
|
||||||
{
|
{
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgChangeMap = msgChange->msgChangeMap;
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
ev->mForumMsgId = msgChange->mMsgId;
|
||||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
ev->mForumGroupId = msgChange->mGroupId;
|
||||||
{
|
ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE;
|
||||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
rsEvents->postEvent(ev);
|
||||||
ev->mForumMsgId = *mit1;
|
|
||||||
ev->mForumGroupId = mit->first;
|
|
||||||
ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE;
|
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOT_USED_YET
|
#ifdef NOT_USED_YET
|
||||||
@ -248,16 +244,10 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
{
|
{
|
||||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
ev->mForumGroupId = *git;
|
ev->mForumGroupId = grpChange->mGroupId;
|
||||||
ev->mForumEventCode = RsForumEventCode::SUBSCRIBE_STATUS_CHANGED;
|
ev->mForumEventCode = RsForumEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -265,67 +255,79 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
{
|
{
|
||||||
/* group received */
|
/* group received */
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
|
|
||||||
RS_STACK_MUTEX(mKnownForumsMutex);
|
RS_STACK_MUTEX(mKnownForumsMutex);
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
if(mKnownForums.find(*git) == mKnownForums.end())
|
|
||||||
{
|
|
||||||
mKnownForums.insert(
|
|
||||||
std::make_pair(*git, time(nullptr)));
|
|
||||||
IndicateConfigChanged();
|
|
||||||
|
|
||||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
if(mKnownForums.find(grpChange->mGroupId) == mKnownForums.end())
|
||||||
ev->mForumGroupId = *git;
|
{
|
||||||
ev->mForumEventCode = RsForumEventCode::NEW_FORUM;
|
mKnownForums.insert( std::make_pair(grpChange->mGroupId, time(nullptr)));
|
||||||
rsEvents->postEvent(ev);
|
IndicateConfigChanged();
|
||||||
}
|
|
||||||
else
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
RsInfo() << __PRETTY_FUNCTION__
|
ev->mForumGroupId = grpChange->mGroupId;
|
||||||
<< " Not notifying already known forum "
|
ev->mForumEventCode = RsForumEventCode::NEW_FORUM;
|
||||||
<< *git << std::endl;
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
RsInfo() << __PRETTY_FUNCTION__
|
||||||
|
<< " Not notifying already known forum "
|
||||||
|
<< grpChange->mGroupId << std::endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mForumGroupId = grpChange->mGroupId;
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
ev->mForumEventCode = RsForumEventCode::STATISTICS_CHANGED;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_UPDATED:
|
||||||
|
{
|
||||||
|
// Happens when the group data has changed. In this case we need to analyse the old and new group in order to detect possible notifications for clients
|
||||||
|
|
||||||
|
RsGxsForumGroupItem *old_forum_grp_item = dynamic_cast<RsGxsForumGroupItem*>(grpChange->mOldGroupItem);
|
||||||
|
RsGxsForumGroupItem *new_forum_grp_item = dynamic_cast<RsGxsForumGroupItem*>(grpChange->mNewGroupItem);
|
||||||
|
|
||||||
|
if(old_forum_grp_item == nullptr || new_forum_grp_item == nullptr)
|
||||||
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " received GxsGroupUpdate item with mOldGroup and mNewGroup not of type RsGxsForumGroupItem. This is inconsistent!" << std::endl;
|
||||||
|
delete grpChange;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// First of all, we check if there is a difference between the old and new list of moderators
|
||||||
|
|
||||||
|
std::list<RsGxsId> added_mods, removed_mods;
|
||||||
|
|
||||||
|
for(auto& gxs_id: new_forum_grp_item->mGroup.mAdminList.ids)
|
||||||
|
if(old_forum_grp_item->mGroup.mAdminList.ids.find(gxs_id) == old_forum_grp_item->mGroup.mAdminList.ids.end())
|
||||||
|
added_mods.push_back(gxs_id);
|
||||||
|
|
||||||
|
for(auto& gxs_id: old_forum_grp_item->mGroup.mAdminList.ids)
|
||||||
|
if(new_forum_grp_item->mGroup.mAdminList.ids.find(gxs_id) == new_forum_grp_item->mGroup.mAdminList.ids.end())
|
||||||
|
removed_mods.push_back(gxs_id);
|
||||||
|
|
||||||
|
if(!added_mods.empty() || !removed_mods.empty())
|
||||||
{
|
{
|
||||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
ev->mForumGroupId = *git;
|
|
||||||
ev->mForumEventCode = RsForumEventCode::STATISTICS_CHANGED;
|
ev->mForumGroupId = new_forum_grp_item->meta.mGroupId;
|
||||||
|
ev->mModeratorsAdded = added_mods;
|
||||||
|
ev->mModeratorsRemoved = removed_mods;
|
||||||
|
ev->mForumEventCode = RsForumEventCode::MODERATOR_LIST_CHANGED;
|
||||||
|
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOT_USED_YET
|
|
||||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
|
||||||
{
|
|
||||||
/* group received */
|
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
|
||||||
|
|
||||||
ev->mChannelGroupId = *git;
|
|
||||||
ev->mChannelEventCode = RsGxsChannelEvent::RECEIVED_PUBLISH_KEY;
|
|
||||||
|
|
||||||
rsEvents->sendEvent(ev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,22 +606,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(changes[i]);
|
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(changes[i]);
|
||||||
|
|
||||||
if (msgChange && !msgChange->metaChange())
|
if (msgChange && !msgChange->metaChange())
|
||||||
{
|
RsWarn() << __PRETTY_FUNCTION__ << " Found a Msg data change in p3IdService. This is quite unexpected." << std::endl;
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(changes[i]);
|
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(changes[i]);
|
||||||
|
|
||||||
@ -631,16 +616,13 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
std::cerr << "p3IdService::notifyChanges() Found Group Change Notification";
|
std::cerr << "p3IdService::notifyChanges() Found Group Change Notification";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
|
|
||||||
|
|
||||||
for(auto git = groupList.begin(); git != groupList.end();++git)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git;
|
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
const RsGxsGroupId& gid(groupChange->mGroupId);
|
||||||
|
|
||||||
if(!rsReputations->isIdentityBanned(RsGxsId(*git)))
|
if(!rsReputations->isIdentityBanned(RsGxsId(gid)))
|
||||||
{
|
{
|
||||||
// notify that a new identity is received, if needed
|
// notify that a new identity is received, if needed
|
||||||
|
|
||||||
@ -654,12 +636,12 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
{
|
{
|
||||||
auto ev = std::make_shared<RsGxsIdentityEvent>();
|
auto ev = std::make_shared<RsGxsIdentityEvent>();
|
||||||
ev->mIdentityId = *git;
|
ev->mIdentityId = gid;
|
||||||
ev->mIdentityEventCode = RsGxsIdentityEventCode::UPDATED_IDENTITY;
|
ev->mIdentityEventCode = RsGxsIdentityEventCode::UPDATED_IDENTITY;
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
|
|
||||||
// also time_stamp the key that this group represents
|
// also time_stamp the key that this group represents
|
||||||
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
timeStampKey(RsGxsId(gid),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
||||||
should_subscribe = true;
|
should_subscribe = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -667,12 +649,12 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
{
|
{
|
||||||
auto ev = std::make_shared<RsGxsIdentityEvent>();
|
auto ev = std::make_shared<RsGxsIdentityEvent>();
|
||||||
ev->mIdentityId = *git;
|
ev->mIdentityId = gid;
|
||||||
ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY;
|
ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY;
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
|
|
||||||
// also time_stamp the key that this group represents
|
// also time_stamp the key that this group represents
|
||||||
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
timeStampKey(RsGxsId(gid),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
||||||
should_subscribe = true;
|
should_subscribe = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -684,11 +666,10 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
if(should_subscribe)
|
if(should_subscribe)
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsGenExchange::subscribeToGroup(token, *git, true);
|
RsGenExchange::subscribeToGroup(token, gid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete changes[i];
|
delete changes[i];
|
||||||
|
@ -98,27 +98,22 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
|
||||||
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
|
||||||
{
|
|
||||||
#ifdef POSTBASE_DEBUG
|
#ifdef POSTBASE_DEBUG
|
||||||
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// To start with we are just going to trigger updates on these groups.
|
// To start with we are just going to trigger updates on these groups.
|
||||||
// FUTURE OPTIMISATION.
|
// FUTURE OPTIMISATION.
|
||||||
// It could be taken a step further and directly request these msgs for an update.
|
// It could be taken a step further and directly request these msgs for an update.
|
||||||
addGroupForProcessing(mit->first);
|
addGroupForProcessing(msgChange->mGroupId);
|
||||||
|
|
||||||
if (rsEvents && (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED))
|
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>();
|
||||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
ev->mPostedMsgId = msgChange->mMsgId;
|
||||||
ev->mPostedMsgId = *mit1;
|
ev->mPostedGroupId = msgChange->mGroupId;
|
||||||
ev->mPostedGroupId = mit->first;
|
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
||||||
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
rsEvents->postEvent(ev);
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,36 +126,25 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification";
|
std::cerr << "p3PostBase::notifyChanges() Found Group Change Notification";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
const RsGxsGroupId& group_id(grpChange->mGroupId);
|
||||||
|
|
||||||
switch(grpChange->getType())
|
switch(grpChange->getType())
|
||||||
{
|
{
|
||||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mPostedGroupId = group_id;
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
ev->mPostedEventCode = RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||||
{
|
rsEvents->postEvent(ev);
|
||||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
|
||||||
ev->mPostedGroupId = *git;
|
|
||||||
ev->mPostedEventCode = RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED;
|
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
|
||||||
{
|
{
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mPostedGroupId = group_id;
|
||||||
|
ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED;
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
rsEvents->postEvent(ev);
|
||||||
{
|
|
||||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
|
||||||
ev->mPostedGroupId = *git;
|
|
||||||
ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED;
|
|
||||||
rsEvents->postEvent(ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -168,30 +152,26 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
{
|
{
|
||||||
/* group received */
|
/* group received */
|
||||||
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
|
|
||||||
|
|
||||||
for (auto git = grpList.begin(); git != grpList.end(); ++git)
|
if(mKnownPosted.find(group_id) == mKnownPosted.end())
|
||||||
{
|
{
|
||||||
if(mKnownPosted.find(*git) == mKnownPosted.end())
|
mKnownPosted.insert(std::make_pair(group_id, time(nullptr)));
|
||||||
{
|
IndicateConfigChanged();
|
||||||
mKnownPosted.insert(std::make_pair(*git, time(nullptr)));
|
|
||||||
IndicateConfigChanged();
|
|
||||||
|
|
||||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
ev->mPostedGroupId = *git;
|
ev->mPostedGroupId = group_id;
|
||||||
ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP;
|
ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP;
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
|
|
||||||
#ifdef POSTBASE_DEBUG
|
#ifdef POSTBASE_DEBUG
|
||||||
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
|
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << group_id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
else
|
|
||||||
RsInfo() << __PRETTY_FUNCTION__
|
|
||||||
<< " Not notifying already known forum "
|
|
||||||
<< *git << std::endl;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
RsInfo() << __PRETTY_FUNCTION__
|
||||||
|
<< " Not notifying already known forum "
|
||||||
|
<< group_id << std::endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -351,11 +331,7 @@ void p3PostBase::addGroupForProcessing(RsGxsGroupId grpId)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPostBaseMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mPostBaseMtx); /********** STACK LOCKED MTX ******/
|
||||||
// no point having multiple lookups queued.
|
// no point having multiple lookups queued.
|
||||||
if (mBgGroupList.end() == std::find(mBgGroupList.begin(),
|
mBgGroupList.insert(grpId);
|
||||||
mBgGroupList.end(), grpId))
|
|
||||||
{
|
|
||||||
mBgGroupList.push_back(grpId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,8 +364,8 @@ void p3PostBase::background_requestUnprocessedGroup()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
grpId = mBgGroupList.front();
|
grpId = *mBgGroupList.begin();
|
||||||
mBgGroupList.pop_front();
|
mBgGroupList.erase(grpId);
|
||||||
mBgProcessing = true;
|
mBgProcessing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,8 +459,6 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||||||
|
|
||||||
// generate vector of changes to push to the GUI.
|
// generate vector of changes to push to the GUI.
|
||||||
std::vector<RsGxsNotify *> changes;
|
std::vector<RsGxsNotify *> changes;
|
||||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
|
||||||
|
|
||||||
|
|
||||||
RsGxsGroupId groupId;
|
RsGxsGroupId groupId;
|
||||||
std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> >::iterator mit;
|
std::map<RsGxsGroupId, std::vector<RsGxsMsgItem*> >::iterator mit;
|
||||||
@ -535,7 +509,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* but we need to notify GUI about them */
|
/* 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)))
|
else if (NULL != (commentItem = dynamic_cast<RsGxsCommentItem *>(*vit)))
|
||||||
{
|
{
|
||||||
@ -631,22 +605,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* push updates of new Posts */
|
/* push updates of new Posts */
|
||||||
if (msgChanges->msgChangeMap.size() > 0)
|
notifyChanges(changes);
|
||||||
{
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* request the summary info from the parents */
|
/* request the summary info from the parents */
|
||||||
uint32_t token_b;
|
uint32_t token_b;
|
||||||
@ -711,7 +670,6 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
|||||||
|
|
||||||
// generate vector of changes to push to the GUI.
|
// generate vector of changes to push to the GUI.
|
||||||
std::vector<RsGxsNotify *> changes;
|
std::vector<RsGxsNotify *> changes;
|
||||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
|
||||||
|
|
||||||
for(mit = parentMsgList.begin(); mit != parentMsgList.end(); ++mit)
|
for(mit = parentMsgList.begin(); mit != parentMsgList.end(); ++mit)
|
||||||
{
|
{
|
||||||
@ -754,7 +712,8 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
stats.increment(it->second);
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -786,21 +745,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgChanges->msgChangeMap.size() > 0)
|
notifyChanges(changes);
|
||||||
{
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE!.
|
// DONE!.
|
||||||
background_cleanup();
|
background_cleanup();
|
||||||
|
@ -125,7 +125,7 @@ private:
|
|||||||
|
|
||||||
bool mBgProcessing;
|
bool mBgProcessing;
|
||||||
bool mBgIncremental;
|
bool mBgIncremental;
|
||||||
std::list<RsGxsGroupId> mBgGroupList;
|
std::set<RsGxsGroupId> mBgGroupList;
|
||||||
std::map<RsGxsMessageId, PostStats> mBgStatsMap;
|
std::map<RsGxsMessageId, PostStats> mBgStatsMap;
|
||||||
|
|
||||||
std::map<RsGxsGroupId,rstime_t> mKnownPosted;
|
std::map<RsGxsGroupId,rstime_t> mKnownPosted;
|
||||||
|
@ -53,10 +53,12 @@ virtual void notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
||||||
{
|
{
|
||||||
return RsGxsIfaceHelper::receiveChanges(changes);
|
return RsGxsIfaceHelper::receiveChanges(changes);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool getBoardsInfo(const std::list<RsGxsGroupId>& boardsIds,
|
bool getBoardsInfo(const std::list<RsGxsGroupId>& boardsIds,
|
||||||
std::vector<RsPostedGroup>& groupsInfo ) override;
|
std::vector<RsPostedGroup>& groupsInfo ) override;
|
||||||
|
@ -60,7 +60,12 @@ public:
|
|||||||
|
|
||||||
bool is_cached(const Key &key) const;
|
bool is_cached(const Key &key) const;
|
||||||
bool fetch(const Key &key, Value &data);
|
bool fetch(const Key &key, Value &data);
|
||||||
Value &ref(const Key &key); // like map[] installs empty one if non-existent.
|
|
||||||
|
// Like map[] installs empty one if non-existent.
|
||||||
|
|
||||||
|
Value& ref(const Key &key);
|
||||||
|
Value& operator[](const Key& key) { return ref(key); }
|
||||||
|
|
||||||
bool store(const Key &key, const Value &data);
|
bool store(const Key &key, const Value &data);
|
||||||
bool erase(const Key &key); // clean up cache.
|
bool erase(const Key &key); // clean up cache.
|
||||||
|
|
||||||
@ -70,7 +75,8 @@ public:
|
|||||||
|
|
||||||
template<class ClientClass> bool applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(Value&));
|
template<class ClientClass> bool applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(Value&));
|
||||||
|
|
||||||
uint32_t size() const { return mDataMap.size() ; }
|
uint32_t size() const { return mDataMap.size() ; }
|
||||||
|
void printStats(std::ostream& out);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts);
|
bool update_lrumap(const Key &key, rstime_t old_ts, rstime_t new_ts);
|
||||||
@ -96,7 +102,6 @@ private:
|
|||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
// some statistics.
|
// some statistics.
|
||||||
void printStats(std::ostream &out);
|
|
||||||
void clearStats();
|
void clearStats();
|
||||||
|
|
||||||
mutable uint32_t mStats_inserted;
|
mutable uint32_t mStats_inserted;
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
TransferUserNotify(QObject *parent = 0);
|
TransferUserNotify(QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual QString textInfo() const override { return tr("completed transfer(s)"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
@ -181,8 +181,9 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog)
|
|||||||
ui->treeWidget_membership->clear();
|
ui->treeWidget_membership->clear();
|
||||||
ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate());
|
ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate());
|
||||||
|
|
||||||
mExternalOtherCircleItem = NULL ;
|
mExternalOtherCircleItem = NULL ;
|
||||||
mExternalBelongingCircleItem = NULL ;
|
mExternalBelongingCircleItem = NULL ;
|
||||||
|
mMyCircleItem = NULL ;
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
mStateHelper = new UIStateHelper(this);
|
mStateHelper = new UIStateHelper(this);
|
||||||
@ -437,12 +438,11 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
|||||||
|
|
||||||
switch(e->mCircleEventType)
|
switch(e->mCircleEventType)
|
||||||
{
|
{
|
||||||
case RsGxsCircleEventCode::NEW_CIRCLE:
|
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOQUED:
|
case RsGxsCircleEventCode::NEW_CIRCLE:
|
||||||
case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
|
case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
|
||||||
|
|
||||||
updateCircles();
|
updateCircles();
|
||||||
@ -598,6 +598,10 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
|
|||||||
|
|
||||||
mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true);
|
mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true);
|
||||||
|
|
||||||
|
std::vector<bool> expanded_top_level_items;
|
||||||
|
std::set<RsGxsCircleId> expanded_circle_items;
|
||||||
|
saveExpandedCircleItems(expanded_top_level_items,expanded_circle_items);
|
||||||
|
|
||||||
#ifdef QT_BUG_CRASH_IN_TAKECHILD_WORKAROUND
|
#ifdef QT_BUG_CRASH_IN_TAKECHILD_WORKAROUND
|
||||||
// These 3 lines are normally not needed. But apparently a bug (in Qt ??) causes Qt to crash when takeChild() is called. If we remove everything from the
|
// These 3 lines are normally not needed. But apparently a bug (in Qt ??) causes Qt to crash when takeChild() is called. If we remove everything from the
|
||||||
// tree widget before updating it, takeChild() is never called, but the all tree is filled again from scratch. This is less efficient obviously, and
|
// tree widget before updating it, takeChild() is never called, but the all tree is filled again from scratch. This is less efficient obviously, and
|
||||||
@ -858,6 +862,7 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
|
|||||||
else
|
else
|
||||||
item->setIcon(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,FilesDefs::getIconFromQtResourcePath(IMAGE_UNKNOWN)) ;
|
item->setIcon(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,FilesDefs::getIconFromQtResourcePath(IMAGE_UNKNOWN)) ;
|
||||||
}
|
}
|
||||||
|
restoreExpandedCircleItems(expanded_top_level_items,expanded_circle_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void mark_matching_tree(QTreeWidget *w, const std::set<RsGxsId>& members, int col)
|
//static void mark_matching_tree(QTreeWidget *w, const std::set<RsGxsId>& members, int col)
|
||||||
@ -936,14 +941,26 @@ void IdDialog::revokeCircleMembership()
|
|||||||
if(!getItemCircleId(ui->treeWidget_membership->currentItem(),circle_id))
|
if(!getItemCircleId(ui->treeWidget_membership->currentItem(),circle_id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(circle_id.isNull())
|
||||||
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " : got a null circle ID. Cannot revoke an identity from that circle!" << std::endl;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
RsGxsId gxs_id_to_revoke(qobject_cast<QAction*>(sender())->data().toString().toStdString());
|
RsGxsId gxs_id_to_revoke(qobject_cast<QAction*>(sender())->data().toString().toStdString());
|
||||||
|
|
||||||
RsThread::async([circle_id,gxs_id_to_revoke]()
|
if(gxs_id_to_revoke.isNull())
|
||||||
{
|
RsErr() << __PRETTY_FUNCTION__ << " : got a null ID. Cannot revoke it from circle " << circle_id << "!" << std::endl;
|
||||||
// 1 - get message data from p3GxsForums
|
else
|
||||||
|
RsThread::async([circle_id,gxs_id_to_revoke]()
|
||||||
|
{
|
||||||
|
// 1 - get message data from p3GxsForums
|
||||||
|
|
||||||
rsGxsCircles->revokeIdsFromCircle(std::set<RsGxsId>( { gxs_id_to_revoke } ),circle_id);
|
std::set<RsGxsId> ids;
|
||||||
});
|
ids.insert(gxs_id_to_revoke);
|
||||||
|
|
||||||
|
rsGxsCircles->revokeIdsFromCircle(ids,circle_id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::acceptCircleSubscription()
|
void IdDialog::acceptCircleSubscription()
|
||||||
@ -2450,3 +2467,53 @@ void IdDialog::on_closeInfoFrameButton_clicked()
|
|||||||
{
|
{
|
||||||
ui->inviteFrame->setVisible(false);
|
ui->inviteFrame->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to use indexes here because saving items is not possible since they can be re-created.
|
||||||
|
|
||||||
|
void IdDialog::saveExpandedCircleItems(std::vector<bool>& expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const
|
||||||
|
{
|
||||||
|
expanded_root_items.clear();
|
||||||
|
expanded_root_items.resize(3,false);
|
||||||
|
expanded_circle_items.clear();
|
||||||
|
|
||||||
|
auto saveTopLevel = [&](const QTreeWidgetItem* top_level_item,uint32_t index){
|
||||||
|
if(!top_level_item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(top_level_item->isExpanded())
|
||||||
|
{
|
||||||
|
expanded_root_items[index] = true;
|
||||||
|
|
||||||
|
for(int row=0;row<top_level_item->childCount();++row)
|
||||||
|
if(top_level_item->child(row)->isExpanded())
|
||||||
|
expanded_circle_items.insert(RsGxsCircleId(top_level_item->child(row)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString().toStdString()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
saveTopLevel(mExternalBelongingCircleItem,0);
|
||||||
|
saveTopLevel(mExternalOtherCircleItem,1);
|
||||||
|
saveTopLevel(mMyCircleItem,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdDialog::restoreExpandedCircleItems(const std::vector<bool>& expanded_root_items,const std::set<RsGxsCircleId>& expanded_circle_items)
|
||||||
|
{
|
||||||
|
auto restoreTopLevel = [=](QTreeWidgetItem* top_level_item,uint32_t index){
|
||||||
|
if(!top_level_item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
top_level_item->setExpanded(expanded_root_items[index]);
|
||||||
|
|
||||||
|
for(int row=0;row<top_level_item->childCount();++row)
|
||||||
|
{
|
||||||
|
RsGxsCircleId circle_id(RsGxsCircleId(top_level_item->child(row)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString().toStdString()));
|
||||||
|
bool expanded = expanded_circle_items.find(circle_id) != expanded_circle_items.end();
|
||||||
|
|
||||||
|
top_level_item->child(row)->setExpanded(expanded_circle_items.find(circle_id) != expanded_circle_items.end());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
restoreTopLevel(mExternalBelongingCircleItem,0);
|
||||||
|
restoreTopLevel(mExternalOtherCircleItem,1);
|
||||||
|
restoreTopLevel(mMyCircleItem,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,9 @@ private:
|
|||||||
QTreeWidgetItem *mMyCircleItem;
|
QTreeWidgetItem *mMyCircleItem;
|
||||||
RsGxsUpdateBroadcastBase *mCirclesBroadcastBase ;
|
RsGxsUpdateBroadcastBase *mCirclesBroadcastBase ;
|
||||||
|
|
||||||
|
void saveExpandedCircleItems(std::vector<bool> &expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const;
|
||||||
|
void restoreExpandedCircleItems(const std::vector<bool>& expanded_root_items,const std::set<RsGxsCircleId>& expanded_circle_items);
|
||||||
|
|
||||||
std::map<uint32_t, CircleUpdateOrder> mCircleUpdates ;
|
std::map<uint32_t, CircleUpdateOrder> mCircleUpdates ;
|
||||||
|
|
||||||
RsGxsGroupId mId;
|
RsGxsGroupId mId;
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc">
|
<iconset resource="../icons.qrc">
|
||||||
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
|
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
@ -268,7 +268,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QTabWidget" name="rightTabWidget">
|
<widget class="QTabWidget" name="rightTabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="personTab">
|
<widget class="QWidget" name="personTab">
|
||||||
<attribute name="icon">
|
<attribute name="icon">
|
||||||
@ -289,8 +289,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>634</width>
|
<width>1372</width>
|
||||||
<height>523</height>
|
<height>719</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="scrollAreaWidgetContentsVLayout">
|
<layout class="QVBoxLayout" name="scrollAreaWidgetContentsVLayout">
|
||||||
@ -1052,7 +1052,7 @@ border-image: url(:/images/closepressed.png)
|
|||||||
</action>
|
</action>
|
||||||
<action name="chatIdentity">
|
<action name="chatIdentity">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc">
|
<iconset>
|
||||||
<normaloff>:/images/toaster/chat.png</normaloff>:/images/toaster/chat.png</iconset>
|
<normaloff>:/images/toaster/chat.png</normaloff>:/images/toaster/chat.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -1094,8 +1094,8 @@ border-image: url(:/images/closepressed.png)
|
|||||||
<tabstop>idTreeWidget</tabstop>
|
<tabstop>idTreeWidget</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -486,7 +486,7 @@ void MainWindow::initStackedPage()
|
|||||||
for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) {
|
for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) {
|
||||||
UserNotify *userNotify = notifyIt->first->getUserNotify();
|
UserNotify *userNotify = notifyIt->first->getUserNotify();
|
||||||
if (userNotify) {
|
if (userNotify) {
|
||||||
userNotify->initialize(ui->toolBarPage, notifyIt->second.first, notifyIt->second.second);
|
userNotify->initialize(ui->toolBarPage, notifyIt->second.first, notifyIt->second.second,userNotify->textInfo());
|
||||||
connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine()));
|
connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine()));
|
||||||
userNotifyList.push_back(userNotify);
|
userNotifyList.push_back(userNotify);
|
||||||
}
|
}
|
||||||
|
@ -251,14 +251,20 @@ void NewsFeed::handleForumEvent(std::shared_ptr<const RsEvent> event)
|
|||||||
|
|
||||||
switch(pe->mForumEventCode)
|
switch(pe->mForumEventCode)
|
||||||
{
|
{
|
||||||
|
case RsForumEventCode::MODERATOR_LIST_CHANGED:
|
||||||
|
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_UPDATED_FORUM, pe->mForumGroupId,pe->mModeratorsAdded,pe->mModeratorsRemoved, false, true));
|
||||||
|
break;
|
||||||
|
|
||||||
case RsForumEventCode::UPDATED_FORUM:
|
case RsForumEventCode::UPDATED_FORUM:
|
||||||
case RsForumEventCode::NEW_FORUM:
|
case RsForumEventCode::NEW_FORUM:
|
||||||
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, false, true));
|
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, false, true));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsForumEventCode::UPDATED_MESSAGE:
|
case RsForumEventCode::UPDATED_MESSAGE:
|
||||||
case RsForumEventCode::NEW_MESSAGE:
|
case RsForumEventCode::NEW_MESSAGE:
|
||||||
addFeedItem(new GxsForumMsgItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, pe->mForumMsgId, false, true));
|
addFeedItem(new GxsForumMsgItem(this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, pe->mForumMsgId, false, true));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,47 +294,120 @@ void NewsFeed::handleChannelEvent(std::shared_ptr<const RsEvent> event)
|
|||||||
|
|
||||||
void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
|
void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
|
||||||
{
|
{
|
||||||
const RsGxsCircleEvent *pe = dynamic_cast<const RsGxsCircleEvent*>(event.get());
|
// Gives the backend a few secs to load the cache data while not blocking the UI. This is not so nice, but there's no proper
|
||||||
if(!pe)
|
// other way to do that.
|
||||||
return;
|
|
||||||
|
|
||||||
RsGxsCircleDetails details;
|
RsThread::async( [event,this]()
|
||||||
|
|
||||||
if(pe->mCircleId.isNull()) // probably an item for cache update
|
|
||||||
return ;
|
|
||||||
|
|
||||||
if(!rsGxsCircles->getCircleDetails(pe->mCircleId,details))
|
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) Cannot get information about circle " << pe->mCircleId << ". Not in cache?" << std::endl;
|
const RsGxsCircleEvent *pe = dynamic_cast<const RsGxsCircleEvent*>(event.get());
|
||||||
return;
|
if(!pe)
|
||||||
}
|
return;
|
||||||
|
|
||||||
// Check if the circle is one of which we belong to. If so, then notify in the GUI about other members leaving/subscribing
|
if(pe->mCircleId.isNull()) // probably an item for cache update
|
||||||
|
return ;
|
||||||
|
|
||||||
if(details.mAmIAllowed || details.mAmIAdmin)
|
RsGxsCircleDetails details;
|
||||||
|
bool loaded = false;
|
||||||
|
|
||||||
|
for(int i=0;i<5 && !loaded;++i)
|
||||||
|
if(rsGxsCircles->getCircleDetails(pe->mCircleId,details))
|
||||||
|
{
|
||||||
|
std::cerr << "Cache item loaded for circle " << pe->mCircleId << std::endl;
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Cache item for circle " << pe->mCircleId << " not loaded. Waiting " << i << "s" << std::endl;
|
||||||
|
rstime::rs_usleep(1000*1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!loaded)
|
||||||
|
{
|
||||||
|
std::cerr << "(EE) Cannot get information about circle " << pe->mCircleId << ". Not in cache?" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!details.isGxsIdBased()) // not handled yet.
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check if the circle is one of which we belong to or we are an admin of.
|
||||||
|
// If so, then notify in the GUI about other members leaving/subscribing, according
|
||||||
|
// to the following rules. The names correspond to the RS_FEED_CIRCLE_* variables:
|
||||||
|
//
|
||||||
|
// Message-based notifications:
|
||||||
|
//
|
||||||
|
// +---------------------------+----------------------------+
|
||||||
|
// | Membership request | Membership cancellation |
|
||||||
|
// +-------------+-------------+-------------+--------------+
|
||||||
|
// | Admin | Not admin | Admin | Not admin |
|
||||||
|
// +--------------------+-------------+-------------+----------------------------+
|
||||||
|
// | in invitee list | MEMB_JOIN | MEMB_JOIN | MEMB_LEAVE | MEMB_LEAVE |
|
||||||
|
// +--------------------+-------------+-------------+-------------+--------------+
|
||||||
|
// |not in invitee list | MEMB_REQ | X | X | X |
|
||||||
|
// +--------------------+-------------+-------------+-------------+--------------+
|
||||||
|
//
|
||||||
|
// Note: in this case, the GxsId never belongs to you, since you dont need to handle
|
||||||
|
// notifications for actions you took yourself (leave/join a circle)
|
||||||
|
//
|
||||||
|
// GroupData-based notifications, the GxsId belongs to you:
|
||||||
|
//
|
||||||
|
// +---------------------------+----------------------------+
|
||||||
|
// | GxsId joins invitee list | GxsId leaves invitee list |
|
||||||
|
// +-------------+-------------+-------------+--------------+
|
||||||
|
// | Id is yours| Id is not | Id is yours | Id is not |
|
||||||
|
// +--------------------+-------------+-------------+-------------+--------------+
|
||||||
|
// | Has Member request | MEMB_ACCEPT | (MEMB_JOIN) | MEMB_REVOKED| (MEMB_LEAVE) |
|
||||||
|
// +--------------------+-------------+-------------+-------------+--------------+
|
||||||
|
// | No Member request | INVITE_REC | X | INVITE_REM | X |
|
||||||
|
// +--------------------+-------------+-------------+-------------+--------------+
|
||||||
|
//
|
||||||
|
// Note: In this case you're never an admin of the circle, since these notification
|
||||||
|
// would be a direct consequence of your own actions.
|
||||||
|
|
||||||
|
RsQThreadUtils::postToObject( [event,details,this]()
|
||||||
{
|
{
|
||||||
|
const RsGxsCircleEvent *pe = static_cast<const RsGxsCircleEvent*>(event.get());
|
||||||
|
|
||||||
switch(pe->mCircleEventType)
|
switch(pe->mCircleEventType)
|
||||||
{
|
{
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
|
||||||
// only show membership requests if we're an admin of that circle
|
// only show membership requests if we're an admin of that circle
|
||||||
if(details.mAmIAdmin)
|
if(details.isIdInInviteeList(pe->mGxsId))
|
||||||
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true);
|
||||||
|
else if(details.mAmIAdmin)
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true);
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
|
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true);
|
|
||||||
break;
|
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true);
|
|
||||||
|
if(details.isIdInInviteeList(pe->mGxsId))
|
||||||
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true);
|
||||||
break;
|
break;
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
|
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVIT_REC),true);
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST:
|
||||||
|
if(rsIdentity->isOwnId(pe->mGxsId))
|
||||||
|
{
|
||||||
|
if(details.isIdRequestingMembership(pe->mGxsId))
|
||||||
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED),true);
|
||||||
|
else
|
||||||
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_REC),true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOQUED:
|
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED),true);
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_REMOVED_FROM_INVITEE_LIST:
|
||||||
|
if(rsIdentity->isOwnId(pe->mGxsId))
|
||||||
|
{
|
||||||
|
if(details.isIdRequestingMembership(pe->mGxsId))
|
||||||
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true);
|
||||||
|
else
|
||||||
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED),true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}, this ); }); // damn!
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
|
void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
|
||||||
|
@ -31,8 +31,10 @@
|
|||||||
|
|
||||||
const uint32_t NEWSFEED_PEERLIST = 0x0001;
|
const uint32_t NEWSFEED_PEERLIST = 0x0001;
|
||||||
|
|
||||||
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
|
const uint32_t NEWSFEED_NEW_FORUM = 0x0002;
|
||||||
const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003;
|
const uint32_t NEWSFEED_NEW_FORUM_MSG = 0x0003;
|
||||||
|
const uint32_t NEWSFEED_UPDATED_FORUM = 0x000f;
|
||||||
|
|
||||||
const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004;
|
const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004;
|
||||||
//const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005;
|
//const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -271,25 +271,29 @@ void PeopleDialog::insertCircles(uint32_t token)
|
|||||||
std::list<RsGroupMetaData> gSummaryList;
|
std::list<RsGroupMetaData> gSummaryList;
|
||||||
std::list<RsGroupMetaData>::iterator gsIt;
|
std::list<RsGroupMetaData>::iterator gsIt;
|
||||||
|
|
||||||
if (!rsGxsCircles->getGroupSummary(token,gSummaryList)) {
|
if (!rsGxsCircles->getGroupSummary(token,gSummaryList))
|
||||||
|
{
|
||||||
std::cerr << "PeopleDialog::insertExtCircles() Error getting GroupSummary";
|
std::cerr << "PeopleDialog::insertExtCircles() Error getting GroupSummary";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}//if (!rsGxsCircles->getGroupSummary(token,gSummaryList))
|
}
|
||||||
|
|
||||||
for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) {
|
for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) {
|
||||||
RsGroupMetaData gsItem = (*gsIt);
|
RsGroupMetaData gsItem = (*gsIt);
|
||||||
|
|
||||||
RsGxsCircleDetails details ;
|
RsGxsCircleDetails details ;
|
||||||
if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(gsItem.mGroupId), details)){
|
if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(gsItem.mGroupId), details))
|
||||||
|
{
|
||||||
std::cerr << "(EE) Cannot get details for circle id " << gsItem.mGroupId << ". Circle item is not created!" << std::endl;
|
std::cerr << "(EE) Cannot get details for circle id " << gsItem.mGroupId << ". Circle item is not created!" << std::endl;
|
||||||
continue ;
|
continue ;
|
||||||
}//if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(git->mGroupId), details))
|
}
|
||||||
|
|
||||||
if (details.mCircleType != GXS_CIRCLE_TYPE_EXTERNAL){
|
if (details.mCircleType != RsGxsCircleType::EXTERNAL)
|
||||||
|
{
|
||||||
std::map<RsGxsGroupId, CircleWidget*>::iterator itFound;
|
std::map<RsGxsGroupId, CircleWidget*>::iterator itFound;
|
||||||
if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) {
|
if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end())
|
||||||
|
{
|
||||||
std::cerr << "PeopleDialog::insertExtCircles() add new Internal GroupId: " << gsItem.mGroupId;
|
std::cerr << "PeopleDialog::insertExtCircles() add new Internal GroupId: " << gsItem.mGroupId;
|
||||||
std::cerr << " GroupName: " << gsItem.mGroupName;
|
std::cerr << " GroupName: " << gsItem.mGroupName;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -307,7 +311,9 @@ void PeopleDialog::insertCircles(uint32_t token)
|
|||||||
QPixmap pixmap = gitem->getImage();
|
QPixmap pixmap = gitem->getImage();
|
||||||
pictureFlowWidgetInternal->addSlide( pixmap );
|
pictureFlowWidgetInternal->addSlide( pixmap );
|
||||||
_intListCir << gitem;
|
_intListCir << gitem;
|
||||||
} else {//if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end())
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId;
|
std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId;
|
||||||
std::cerr << " GroupName: " << gsItem.mGroupName;
|
std::cerr << " GroupName: " << gsItem.mGroupName;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -318,8 +324,10 @@ void PeopleDialog::insertCircles(uint32_t token)
|
|||||||
//int index = _intListCir.indexOf(cirWidget);
|
//int index = _intListCir.indexOf(cirWidget);
|
||||||
//QPixmap pixmap = cirWidget->getImage();
|
//QPixmap pixmap = cirWidget->getImage();
|
||||||
//pictureFlowWidgetInternal->setSlide(index, pixmap);
|
//pictureFlowWidgetInternal->setSlide(index, pixmap);
|
||||||
}//if((item=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end())
|
}
|
||||||
} else {//if (!details.mIsExternal)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::map<RsGxsGroupId, CircleWidget*>::iterator itFound;
|
std::map<RsGxsGroupId, CircleWidget*>::iterator itFound;
|
||||||
if((itFound=_ext_circles_widgets.find(gsItem.mGroupId)) == _ext_circles_widgets.end()) {
|
if((itFound=_ext_circles_widgets.find(gsItem.mGroupId)) == _ext_circles_widgets.end()) {
|
||||||
std::cerr << "PeopleDialog::insertExtCircles() add new GroupId: " << gsItem.mGroupId;
|
std::cerr << "PeopleDialog::insertExtCircles() add new GroupId: " << gsItem.mGroupId;
|
||||||
@ -339,7 +347,9 @@ void PeopleDialog::insertCircles(uint32_t token)
|
|||||||
QPixmap pixmap = gitem->getImage();
|
QPixmap pixmap = gitem->getImage();
|
||||||
pictureFlowWidgetExternal->addSlide( pixmap );
|
pictureFlowWidgetExternal->addSlide( pixmap );
|
||||||
_extListCir << gitem;
|
_extListCir << gitem;
|
||||||
} else {//if((itFound=_circles_widgets.find(gsItem.mGroupId)) == _circles_widgets.end())
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId;
|
std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId;
|
||||||
std::cerr << " GroupName: " << gsItem.mGroupName;
|
std::cerr << " GroupName: " << gsItem.mGroupName;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -350,9 +360,9 @@ void PeopleDialog::insertCircles(uint32_t token)
|
|||||||
//int index = _extListCir.indexOf(cirWidget);
|
//int index = _extListCir.indexOf(cirWidget);
|
||||||
//QPixmap pixmap = cirWidget->getImage();
|
//QPixmap pixmap = cirWidget->getImage();
|
||||||
//pictureFlowWidgetExternal->setSlide(index, pixmap);
|
//pictureFlowWidgetExternal->setSlide(index, pixmap);
|
||||||
}//if((item=_circles_items.find(gsItem.mGroupId)) == _circles_items.end())
|
}
|
||||||
}//else (!details.mIsExternal)
|
}
|
||||||
}//for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeopleDialog::requestIdList()
|
void PeopleDialog::requestIdList()
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "retroshare/rsposted.h"
|
#include "retroshare/rsposted.h"
|
||||||
#include "PostedUserNotify.h"
|
#include "PostedUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
#include "gui/common/FilesDefs.h"
|
||||||
|
|
||||||
PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, g, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
@ -37,12 +38,12 @@ bool PostedUserNotify::hasSetting(QString *name, QString *group)
|
|||||||
|
|
||||||
QIcon PostedUserNotify::getIcon()
|
QIcon PostedUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
return QIcon(":/icons/png/posted.png");
|
return FilesDefs::getIconFromQtResourcePath(":/icons/png/posted.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon PostedUserNotify::getMainIcon(bool hasNew)
|
QIcon PostedUserNotify::getMainIcon(bool hasNew)
|
||||||
{
|
{
|
||||||
return hasNew ? QIcon(":/icons/png/posted-notify.png") : QIcon(":/icons/png/posted.png");
|
return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/posted-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/posted.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedUserNotify::iconClicked()
|
void PostedUserNotify::iconClicked()
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual QString textInfo() const override { return tr("new board post(s)"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
QString textToNotify() { return _textToNotify.join("\n");}
|
QString textToNotify() { return _textToNotify.join("\n");}
|
||||||
void setTextCaseSensitive(bool value);
|
void setTextCaseSensitive(bool value);
|
||||||
bool isTextCaseSensitive() {return _bTextCaseSensitive;}
|
bool isTextCaseSensitive() {return _bTextCaseSensitive;}
|
||||||
|
virtual QString textInfo() const override { return tr("mention(s)"); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void countChanged(ChatLobbyId id, unsigned int count);
|
void countChanged(ChatLobbyId id, unsigned int count);
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
~ChatUserNotify();
|
~ChatUserNotify();
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual QString textInfo() const override { return tr("mention(s)"); }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void chatMessageReceived(ChatMessage msg);
|
void chatMessageReceived(ChatMessage msg);
|
||||||
|
@ -100,7 +100,7 @@ FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& head
|
|||||||
friends_widget->setModus(modus) ;
|
friends_widget->setModus(modus) ;
|
||||||
friends_widget->setShowType(show_type) ;
|
friends_widget->setShowType(show_type) ;
|
||||||
friends_widget->start() ;
|
friends_widget->start() ;
|
||||||
friends_widget->setSelectedIds(pre_selected_id_type, pre_selected_ids, false);
|
friends_widget->setSelectedIdsFromString(pre_selected_id_type, pre_selected_ids, false);
|
||||||
|
|
||||||
QLayout *l = new QVBoxLayout ;
|
QLayout *l = new QVBoxLayout ;
|
||||||
setLayout(l) ;
|
setLayout(l) ;
|
||||||
|
@ -278,18 +278,35 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
|
|
||||||
// get selected items
|
// get selected items
|
||||||
std::set<RsPeerId> sslIdsSelected;
|
std::set<RsPeerId> sslIdsSelected;
|
||||||
if (mShowTypes & SHOW_SSL) {
|
if (mShowTypes & SHOW_SSL)
|
||||||
|
{
|
||||||
|
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||||
|
for(auto& s:mPreSelectedIds)
|
||||||
|
sslIdsSelected.insert(RsPeerId(s));
|
||||||
|
|
||||||
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
|
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<RsNodeGroupId> groupIdsSelected;
|
std::set<RsNodeGroupId> groupIdsSelected;
|
||||||
if (mShowTypes & SHOW_GROUP) {
|
|
||||||
|
if (mShowTypes & SHOW_GROUP)
|
||||||
|
{
|
||||||
selectedIds<RsNodeGroupId,IDTYPE_GROUP>(groupIdsSelected,true);
|
selectedIds<RsNodeGroupId,IDTYPE_GROUP>(groupIdsSelected,true);
|
||||||
|
|
||||||
|
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||||
|
for(auto& s:mPreSelectedIds)
|
||||||
|
groupIdsSelected.insert(RsNodeGroupId(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<RsPgpId> gpgIdsSelected;
|
std::set<RsPgpId> gpgIdsSelected;
|
||||||
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
|
|
||||||
|
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG))
|
||||||
|
{
|
||||||
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
|
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
|
||||||
|
|
||||||
|
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||||
|
for(auto& s:mPreSelectedIds)
|
||||||
|
gpgIdsSelected.insert(RsPgpId(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<RsGxsId> gxsIdsSelected;
|
std::set<RsGxsId> gxsIdsSelected;
|
||||||
@ -299,7 +316,8 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
||||||
|
|
||||||
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
if(!ui->friendList->topLevelItemCount()) // if not loaded yet, use the existing list.
|
||||||
gxsIdsSelected = mPreSelectedGxsIds;
|
for(auto& s:mPreSelectedIds)
|
||||||
|
gxsIdsSelected.insert(RsGxsId(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<RsGxsId> gxsIdsSelected2;
|
std::set<RsGxsId> gxsIdsSelected2;
|
||||||
@ -678,7 +696,12 @@ void FriendSelectionWidget::updateDisplay(bool)
|
|||||||
// This call is inlined so that there's no linking conflict with MinGW on Windows
|
// This call is inlined so that there's no linking conflict with MinGW on Windows
|
||||||
template<> inline void FriendSelectionWidget::setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(const std::set<RsGxsId>& ids, bool add)
|
template<> inline void FriendSelectionWidget::setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(const std::set<RsGxsId>& ids, bool add)
|
||||||
{
|
{
|
||||||
mPreSelectedGxsIds = ids ;
|
if(!add)
|
||||||
|
mPreSelectedIds.clear();
|
||||||
|
|
||||||
|
for(auto& gxsId:ids)
|
||||||
|
mPreSelectedIds.insert(gxsId.toStdString());
|
||||||
|
|
||||||
loadIdentities();
|
loadIdentities();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,7 +1004,7 @@ std::string FriendSelectionWidget::selectedId(IdType &idType)
|
|||||||
return idFromItem(item);
|
return idFromItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected)
|
void FriendSelectionWidget::selectedIds_internal(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected)
|
||||||
{
|
{
|
||||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
@ -1055,11 +1078,21 @@ void FriendSelectionWidget::selectAll()
|
|||||||
setSelected(mListModus, *itemIterator, true);
|
setSelected(mListModus, *itemIterator, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add)
|
void FriendSelectionWidget::setSelectedIdsFromString(IdType type, const std::set<std::string>& ids, bool add)
|
||||||
{
|
{
|
||||||
|
setSelectedIds_internal(type,ids,add);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FriendSelectionWidget::setSelectedIds_internal(IdType idType, const std::set<std::string> &ids, bool add)
|
||||||
|
{
|
||||||
|
mPreSelectedIds = ids;
|
||||||
|
|
||||||
|
// if items are already loaded, check them
|
||||||
|
|
||||||
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
QTreeWidgetItemIterator itemIterator(ui->friendList);
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
while ((item = *itemIterator) != NULL) {
|
while ((item = *itemIterator) != NULL)
|
||||||
|
{
|
||||||
++itemIterator;
|
++itemIterator;
|
||||||
|
|
||||||
std::string id = idFromItem(item);
|
std::string id = idFromItem(item);
|
||||||
|
@ -85,10 +85,12 @@ public:
|
|||||||
int selectedItemCount();
|
int selectedItemCount();
|
||||||
std::string selectedId(IdType &idType);
|
std::string selectedId(IdType &idType);
|
||||||
|
|
||||||
|
void setSelectedIdsFromString(IdType type,const std::set<std::string>& ids,bool add);
|
||||||
|
|
||||||
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::set<ID_CLASS>& ids, bool onlyDirectSelected)
|
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::set<ID_CLASS>& ids, bool onlyDirectSelected)
|
||||||
{
|
{
|
||||||
std::set<std::string> tmpids ;
|
std::set<std::string> tmpids ;
|
||||||
selectedIds(TYPE, tmpids, onlyDirectSelected);
|
selectedIds_internal(TYPE, tmpids, onlyDirectSelected);
|
||||||
ids.clear() ;
|
ids.clear() ;
|
||||||
for(std::set<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
for(std::set<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
|
||||||
ids.insert(ID_CLASS(*it)) ;
|
ids.insert(ID_CLASS(*it)) ;
|
||||||
@ -98,7 +100,7 @@ public:
|
|||||||
std::set<std::string> tmpids ;
|
std::set<std::string> tmpids ;
|
||||||
for(typename std::set<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
for(typename std::set<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||||
tmpids.insert((*it).toStdString()) ;
|
tmpids.insert((*it).toStdString()) ;
|
||||||
setSelectedIds(TYPE, tmpids, add);
|
setSelectedIds_internal(TYPE, tmpids, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
void itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items);
|
void itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items);
|
||||||
@ -145,8 +147,8 @@ private:
|
|||||||
void fillList();
|
void fillList();
|
||||||
void secured_fillList();
|
void secured_fillList();
|
||||||
|
|
||||||
void selectedIds(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
void selectedIds_internal(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);
|
||||||
void setSelectedIds(IdType idType, const std::set<std::string> &ids, bool add);
|
void setSelectedIds_internal(IdType idType, const std::set<std::string> &ids, bool add);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
@ -170,7 +172,7 @@ private:
|
|||||||
std::vector<RsGxsGroupId> gxsIds ;
|
std::vector<RsGxsGroupId> gxsIds ;
|
||||||
QList<QAction*> mContextMenuActions;
|
QList<QAction*> mContextMenuActions;
|
||||||
|
|
||||||
std::set<RsGxsId> mPreSelectedGxsIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them.
|
std::set<std::string> mPreSelectedIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them.
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
||||||
|
@ -88,11 +88,12 @@ void UserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
|
|||||||
Settings->endGroup();
|
Settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem)
|
void UserNotify::initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem,const QString& subtext)
|
||||||
{
|
{
|
||||||
mMainAction = mainAction;
|
mMainAction = mainAction;
|
||||||
if (mMainAction) {
|
if (mMainAction) {
|
||||||
mButtonText = mMainAction->text();
|
mButtonText = mMainAction->text();
|
||||||
|
mButtonText2 = subtext;
|
||||||
if (mainToolBar) {
|
if (mainToolBar) {
|
||||||
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
mMainToolButton = dynamic_cast<QToolButton*>(mainToolBar->widgetForAction(mMainAction));
|
||||||
}
|
}
|
||||||
@ -165,7 +166,18 @@ void UserNotify::update()
|
|||||||
|
|
||||||
if (mMainAction) {
|
if (mMainAction) {
|
||||||
mMainAction->setIcon(getMainIcon(count > 0));
|
mMainAction->setIcon(getMainIcon(count > 0));
|
||||||
mMainAction->setText((count > 0) ? QString("%1 (%2)").arg(mButtonText).arg(count) : mButtonText);
|
|
||||||
|
if(count > 0)
|
||||||
|
{
|
||||||
|
if(!mButtonText2.isNull())
|
||||||
|
mMainAction->setToolTip(QString("%1 (%2 %3)").arg(mButtonText).arg(count).arg(mButtonText2));
|
||||||
|
else
|
||||||
|
mMainAction->setToolTip(QString("%1 (%2)").arg(mButtonText).arg(count));
|
||||||
|
|
||||||
|
mMainAction->setText(QString("%1 (%2)").arg(mButtonText).arg(count));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mMainAction->setText(mButtonText);
|
||||||
|
|
||||||
QFont font = mMainAction->font();
|
QFont font = mMainAction->font();
|
||||||
font.setBold(count > 0);
|
font.setBold(count > 0);
|
||||||
|
@ -37,12 +37,17 @@ public:
|
|||||||
UserNotify(QObject *parent = 0);
|
UserNotify(QObject *parent = 0);
|
||||||
virtual ~UserNotify();
|
virtual ~UserNotify();
|
||||||
|
|
||||||
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem);
|
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem,const QString& subtext);
|
||||||
void createIcons(QMenu *notifyMenu);
|
void createIcons(QMenu *notifyMenu);
|
||||||
QSystemTrayIcon* getTrayIcon(){ return mTrayIcon;}
|
QSystemTrayIcon* getTrayIcon(){ return mTrayIcon;}
|
||||||
QAction* getNotifyIcon(){ return mNotifyIcon;}
|
QAction* getNotifyIcon(){ return mNotifyIcon;}
|
||||||
|
|
||||||
virtual bool hasSetting(QString */*name*/, QString */*group*/) { return false; }
|
virtual bool hasSetting(QString */*name*/, QString */*group*/) { return false; }
|
||||||
|
|
||||||
|
// UserNotify is used to display tooltips when some services have no messages and so on, in the format of "Name (43242 new messages)"
|
||||||
|
// This method is used to pass the string that comes after the number.
|
||||||
|
virtual QString textInfo() const { return QString() ; }
|
||||||
|
|
||||||
bool notifyEnabled();
|
bool notifyEnabled();
|
||||||
bool notifyCombined();
|
bool notifyCombined();
|
||||||
bool notifyBlink();
|
bool notifyBlink();
|
||||||
@ -82,6 +87,7 @@ private:
|
|||||||
QAction *mNotifyIcon;
|
QAction *mNotifyIcon;
|
||||||
unsigned int mNewCount;
|
unsigned int mNewCount;
|
||||||
QString mButtonText;
|
QString mButtonText;
|
||||||
|
QString mButtonText2;
|
||||||
bool mLastBlinking;
|
bool mLastBlinking;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,80 +77,101 @@ void GxsCircleItem::setup()
|
|||||||
|
|
||||||
/* update circle information */
|
/* update circle information */
|
||||||
|
|
||||||
|
ui->membershipButton->setToolTip(tr("Grant membership request"));
|
||||||
|
ui->inviteeButton->setToolTip(tr("Revoke membership"));
|
||||||
|
|
||||||
|
connect(ui->membershipButton, SIGNAL(clicked()), this, SLOT(toggleCircleMembership()));
|
||||||
|
connect(ui->inviteeButton, SIGNAL(clicked()), this, SLOT(toggleCircleInvite()));
|
||||||
|
|
||||||
RsGxsCircleDetails circleDetails;
|
RsGxsCircleDetails circleDetails;
|
||||||
|
|
||||||
if (rsGxsCircles->getCircleDetails(mCircleId, circleDetails))
|
if (rsGxsCircles->getCircleDetails(mCircleId, circleDetails))
|
||||||
{
|
{
|
||||||
|
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()) + " (ID: " + QString::fromStdString(circleDetails.mCircleId.toStdString()) + ")");
|
||||||
|
|
||||||
|
// from here we can figure out if we already have requested membership or not
|
||||||
|
|
||||||
if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ)
|
if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ)
|
||||||
{
|
{
|
||||||
ui->titleLabel->setText(tr("You received a membership request for circle:"));
|
ui->titleLabel->setText(tr("You received a membership request a circle you're administrating:"));
|
||||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
|
||||||
ui->gxsIdLabel->setText(idName);
|
|
||||||
ui->iconLabel->setPixmap(pixmap);
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
if(circleDetails.mAmIAdmin)
|
ui->inviteeButton->setHidden(false);
|
||||||
{
|
ui->inviteeButton->setText(tr("Grant membership"));
|
||||||
ui->acceptButton->setToolTip(tr("Grant membership request"));
|
ui->inviteeButton->setToolTip(tr("Grant membership to this circle, for this identity"));
|
||||||
ui->revokeButton->setToolTip(tr("Revoke membership request"));
|
|
||||||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
|
ui->membershipButton->setHidden(true);
|
||||||
connect(ui->revokeButton, SIGNAL(clicked()), this, SLOT(revokeCircleMembership()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->acceptButton->setEnabled(false);
|
|
||||||
ui->revokeButton->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (mType == RS_FEED_ITEM_CIRCLE_INVIT_REC)
|
else if (mType == RS_FEED_ITEM_CIRCLE_INVITE_REC)
|
||||||
{
|
{
|
||||||
ui->titleLabel->setText(tr("You received an invitation for circle:"));
|
ui->titleLabel->setText(tr("You received an invitation to join this circle:"));
|
||||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
|
||||||
ui->gxsIdLabel->setText(idName);
|
|
||||||
ui->iconLabel->setPixmap(pixmap);
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
ui->acceptButton->setToolTip(tr("Accept invitation"));
|
ui->membershipButton->setText(tr("Accept"));
|
||||||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(acceptCircleSubscription()));
|
ui->membershipButton->setToolTip(tr("Accept invitation"));
|
||||||
ui->revokeButton->setHidden(true);
|
ui->membershipButton->setHidden(false);
|
||||||
|
|
||||||
|
connect(ui->membershipButton, SIGNAL(clicked()), this, SLOT(requestCircleSubscription()));
|
||||||
|
ui->inviteeButton->setHidden(true);
|
||||||
}
|
}
|
||||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE)
|
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE)
|
||||||
{
|
{
|
||||||
ui->titleLabel->setText(idName + tr(" has left this circle you belong to."));
|
ui->titleLabel->setText(idName + tr(" has left this circle."));
|
||||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
|
||||||
ui->gxsIdLabel->setText(idName);
|
|
||||||
ui->iconLabel->setPixmap(pixmap);
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
ui->acceptButton->setHidden(true);
|
ui->membershipButton->setHidden(true);
|
||||||
ui->revokeButton->setHidden(true);
|
ui->inviteeButton->setHidden(true);
|
||||||
}
|
}
|
||||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN)
|
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN)
|
||||||
{
|
{
|
||||||
ui->titleLabel->setText(idName + tr(" has join this circle you also belong to."));
|
if(circleDetails.mAmIAdmin)
|
||||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
{
|
||||||
ui->gxsIdLabel->setText(idName);
|
ui->titleLabel->setText(idName + tr(" which you invited, has join this circle you're administrating."));
|
||||||
ui->iconLabel->setPixmap(pixmap);
|
ui->inviteeButton->setHidden(false);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->inviteeButton->setText(tr("Revoke membership"));
|
||||||
|
ui->inviteeButton->setToolTip(tr("Revoke membership for that identity"));
|
||||||
ui->acceptButton->setHidden(true);
|
}
|
||||||
ui->revokeButton->setHidden(true);
|
|
||||||
}
|
|
||||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED)
|
|
||||||
{
|
|
||||||
if(rsIdentity->isOwnId(mGxsId))
|
|
||||||
ui->titleLabel->setText(tr("Your identity %1 has been revoqued from this circle.").arg(idName));
|
|
||||||
else
|
else
|
||||||
ui->titleLabel->setText(tr("Identity %1 has been revoqued from this circle you belong to.").arg(idName));
|
{
|
||||||
|
ui->inviteeButton->setHidden(true);
|
||||||
|
ui->titleLabel->setText(idName + tr(" has join this circle."));
|
||||||
|
}
|
||||||
|
|
||||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
|
||||||
ui->gxsIdLabel->setText(idName);
|
|
||||||
ui->iconLabel->setPixmap(pixmap);
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
ui->acceptButton->setHidden(true);
|
ui->membershipButton->setHidden(true);
|
||||||
ui->revokeButton->setHidden(true);
|
|
||||||
}
|
}
|
||||||
|
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED)
|
||||||
|
{
|
||||||
|
ui->titleLabel->setText(tr("Your identity %1 has been revoked from this circle.").arg(idName));
|
||||||
|
|
||||||
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
|
ui->membershipButton->setHidden(false);
|
||||||
|
ui->membershipButton->setText(tr("Cancel membership request"));
|
||||||
|
ui->membershipButton->setToolTip(tr("Cancel your membership request from that circle"));
|
||||||
|
|
||||||
|
ui->inviteeButton->setHidden(true);
|
||||||
|
}
|
||||||
|
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED)
|
||||||
|
{
|
||||||
|
ui->titleLabel->setText(tr("Your identity %1 as been accepted in this circle.").arg(idName));
|
||||||
|
|
||||||
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
|
ui->membershipButton->setHidden(false);
|
||||||
|
ui->membershipButton->setText(tr("Cancel membership"));
|
||||||
|
ui->membershipButton->setToolTip(tr("Cancel your membership from that circle"));
|
||||||
|
|
||||||
|
ui->inviteeButton->setHidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -163,7 +184,7 @@ void GxsCircleItem::setup()
|
|||||||
|
|
||||||
uint64_t GxsCircleItem::uniqueIdentifier() const
|
uint64_t GxsCircleItem::uniqueIdentifier() const
|
||||||
{
|
{
|
||||||
return hash_64bits("GxsCircle " + mCircleId.toStdString() + " " + mGxsId.toStdString() + " " + QString::number(mType).toStdString());
|
return hash_64bits("GxsCircle " + mCircleId.toStdString() + " " + mGxsId.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********** SPECIFIC FUNCTIONS ***********************/
|
/*********** SPECIFIC FUNCTIONS ***********************/
|
||||||
@ -176,25 +197,40 @@ void GxsCircleItem::showCircleDetails()
|
|||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCircleItem::acceptCircleSubscription()
|
void GxsCircleItem::requestCircleSubscription()
|
||||||
{
|
{
|
||||||
if (rsGxsCircles->requestCircleMembership(mGxsId, mCircleId))
|
rsGxsCircles->requestCircleMembership(mGxsId, mCircleId);
|
||||||
removeItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCircleItem::grantCircleMembership()
|
void GxsCircleItem::toggleCircleMembership()
|
||||||
{
|
{
|
||||||
RsThread::async([this]()
|
if(!rsIdentity->isOwnId(mGxsId))
|
||||||
{
|
{
|
||||||
rsGxsCircles->inviteIdsToCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
RsErr() << __PRETTY_FUNCTION__ << ": inconsistent call: identity " << mGxsId << " doesn't belong to you" << std::endl;
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mType == RS_FEED_ITEM_CIRCLE_INVITE_REC)
|
||||||
|
rsGxsCircles->requestCircleMembership(mGxsId,mCircleId);
|
||||||
|
else if(mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED)
|
||||||
|
rsGxsCircles->cancelCircleMembership(mGxsId,mCircleId);
|
||||||
|
else
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << ": inconsistent call. mType is " << mType << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCircleItem::revokeCircleMembership()
|
void GxsCircleItem::toggleCircleInvite()
|
||||||
{
|
{
|
||||||
RsThread::async([this]()
|
if(mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN)
|
||||||
{
|
RsThread::async([this]()
|
||||||
rsGxsCircles->revokeIdsFromCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
{
|
||||||
});
|
rsGxsCircles->revokeIdsFromCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
||||||
|
});
|
||||||
|
else if(mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ)
|
||||||
|
RsThread::async([this]()
|
||||||
|
{
|
||||||
|
rsGxsCircles->inviteIdsToCircle(std::set<RsGxsId>( { mGxsId } ),mCircleId);
|
||||||
|
});
|
||||||
|
else
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << ": inconsistent call. mType is " << mType << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showCircleDetails();
|
void showCircleDetails();
|
||||||
void acceptCircleSubscription();
|
void requestCircleSubscription();
|
||||||
void grantCircleMembership() ;
|
void toggleCircleMembership() ;
|
||||||
void revokeCircleMembership();
|
void toggleCircleInvite();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setup();
|
void setup();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>618</width>
|
<width>618</width>
|
||||||
<height>104</height>
|
<height>217</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="GxsCircleItemGLayout">
|
<layout class="QGridLayout" name="GxsCircleItemGLayout">
|
||||||
@ -104,8 +104,8 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item row="0" column="0" rowspan="3">
|
<item>
|
||||||
<widget class="QLabel" name="logoLabel">
|
<widget class="QLabel" name="logoLabel">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -130,154 +130,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="5">
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="forLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>for identity</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="iconLabel">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="GxsIdLabel" name="gxsIdLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">name</string>
|
|
||||||
</property>
|
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>358</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QPushButton" name="acceptButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Accept</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/accepted16.png</normaloff>:/images/accepted16.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QPushButton" name="revokeButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Revoke</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
|
||||||
<widget class="QPushButton" name="expandButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Details</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/informations_24x24.png</normaloff>:/images/informations_24x24.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="4">
|
|
||||||
<spacer name="tollbarHSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Expanding</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>285</width>
|
|
||||||
<height>18</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="5">
|
|
||||||
<widget class="QPushButton" name="clearButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Remove Item</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../icons.qrc">
|
|
||||||
<normaloff>:/icons/png/exit2.png</normaloff>:/icons/png/exit2.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" colspan="5">
|
|
||||||
<layout class="QHBoxLayout" name="nameHLayout">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="titleLabel">
|
<widget class="QLabel" name="titleLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -294,32 +148,193 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">Circle</string>
|
<string notr="true">Circle msg</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="nameLabel">
|
<layout class="QHBoxLayout" name="nameHLayout">
|
||||||
<property name="text">
|
<item>
|
||||||
<string notr="true">name</string>
|
<widget class="QLabel" name="label">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="openExternalLinks">
|
<string>Circle name:</string>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="nameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">name</string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="nameHSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="nameHSpacer">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<widget class="QLabel" name="forLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="sizeHint" stdset="0">
|
<string>Identity:</string>
|
||||||
<size>
|
</property>
|
||||||
<width>40</width>
|
</widget>
|
||||||
<height>20</height>
|
</item>
|
||||||
</size>
|
<item>
|
||||||
</property>
|
<widget class="QLabel" name="iconLabel">
|
||||||
</spacer>
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="GxsIdLabel" name="gxsIdLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">name</string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>358</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="membershipButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Accept</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/accepted16.png</normaloff>:/images/accepted16.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="inviteeButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Revoke</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="expandButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Details</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/informations_24x24.png</normaloff>:/images/informations_24x24.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="tollbarHSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>285</width>
|
||||||
|
<height>18</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="clearButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove Item</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/png/exit2.png</normaloff>:/icons/png/exit2.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -336,8 +351,8 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "GxsForumGroupItem.h"
|
#include "GxsForumGroupItem.h"
|
||||||
#include "ui_GxsForumGroupItem.h"
|
#include "ui_GxsForumGroupItem.h"
|
||||||
|
#include "gui/NewsFeed.h"
|
||||||
|
|
||||||
#include "FeedHolder.h"
|
#include "FeedHolder.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
@ -37,6 +38,16 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co
|
|||||||
requestGroup();
|
requestGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list<RsGxsId>& added_moderators,const std::list<RsGxsId>& removed_moderators,bool isHome, bool autoUpdate):
|
||||||
|
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate),
|
||||||
|
mAddedModerators(added_moderators),
|
||||||
|
mRemovedModerators(removed_moderators)
|
||||||
|
{
|
||||||
|
setup();
|
||||||
|
|
||||||
|
requestGroup();
|
||||||
|
}
|
||||||
|
|
||||||
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) :
|
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) :
|
||||||
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate)
|
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate)
|
||||||
{
|
{
|
||||||
@ -158,10 +169,62 @@ void GxsForumGroupItem::fill()
|
|||||||
ui->subscribeButton->setEnabled(true);
|
ui->subscribeButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (mIsNew)
|
if(feedId() == NEWSFEED_UPDATED_FORUM)
|
||||||
// {
|
{
|
||||||
|
if(!mAddedModerators.empty() || !mRemovedModerators.empty())
|
||||||
|
{
|
||||||
|
ui->titleLabel->setText(tr("Moderator list changed"));
|
||||||
|
ui->moderatorList_GB->show();
|
||||||
|
|
||||||
|
QString msg;
|
||||||
|
|
||||||
|
if(!mAddedModerators.empty())
|
||||||
|
{
|
||||||
|
msg += "<b>Added moderators:</b>" ;
|
||||||
|
msg += "<p>";
|
||||||
|
for(auto& gxsid: mAddedModerators)
|
||||||
|
{
|
||||||
|
RsIdentityDetails det;
|
||||||
|
if(rsIdentity->getIdDetails(gxsid,det))
|
||||||
|
msg += QString::fromUtf8(det.mNickname.c_str())+" ("+QString::fromStdString(gxsid.toStdString())+"), ";
|
||||||
|
else
|
||||||
|
msg += QString("[Unknown name]") + " ("+QString::fromStdString(gxsid.toStdString())+"), ";
|
||||||
|
}
|
||||||
|
msg.resize(msg.size()-2);
|
||||||
|
msg += "</p>";
|
||||||
|
}
|
||||||
|
if(!mRemovedModerators.empty())
|
||||||
|
{
|
||||||
|
msg += "<b>Removed moderators:</b>" ;
|
||||||
|
msg += "<p>";
|
||||||
|
for(auto& gxsid: mRemovedModerators)
|
||||||
|
{
|
||||||
|
RsIdentityDetails det;
|
||||||
|
|
||||||
|
if( rsIdentity->getIdDetails(gxsid,det))
|
||||||
|
msg += QString::fromUtf8(det.mNickname.c_str())+" ("+QString::fromStdString(gxsid.toStdString())+"), ";
|
||||||
|
else
|
||||||
|
msg += QString("[Unknown name]") + " ("+QString::fromStdString(gxsid.toStdString())+"), ";
|
||||||
|
}
|
||||||
|
msg.resize(msg.size()-2);
|
||||||
|
msg += "</p>";
|
||||||
|
}
|
||||||
|
ui->moderatorList_TE->setText(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->moderatorList_GB->hide();
|
||||||
|
|
||||||
|
ui->titleLabel->setText(tr("Forum updated"));
|
||||||
|
ui->moderatorList_GB->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ui->titleLabel->setText(tr("New Forum"));
|
ui->titleLabel->setText(tr("New Forum"));
|
||||||
// }
|
ui->moderatorList_GB->hide();
|
||||||
|
}
|
||||||
|
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// ui->titleLabel->setText(tr("Updated Forum"));
|
// ui->titleLabel->setText(tr("Updated Forum"));
|
||||||
|
@ -37,6 +37,7 @@ class GxsForumGroupItem : public GxsGroupFeedItem
|
|||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate);
|
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate);
|
||||||
|
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list<RsGxsId>& added_moderators,const std::list<RsGxsId>& removed_moderators,bool isHome, bool autoUpdate);
|
||||||
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate);
|
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate);
|
||||||
~GxsForumGroupItem();
|
~GxsForumGroupItem();
|
||||||
|
|
||||||
@ -65,6 +66,9 @@ private:
|
|||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::GxsForumGroupItem *ui;
|
Ui::GxsForumGroupItem *ui;
|
||||||
|
|
||||||
|
std::list<RsGxsId> mAddedModerators;
|
||||||
|
std::list<RsGxsId> mRemovedModerators;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>618</width>
|
<width>784</width>
|
||||||
<height>161</height>
|
<height>464</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
@ -104,8 +104,8 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<item row="0" column="0" rowspan="2">
|
<item row="0" column="0" rowspan="2">
|
||||||
<widget class="QLabel" name="forumlogo_label">
|
<widget class="QLabel" name="forumlogo_label">
|
||||||
@ -280,7 +280,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item>
|
||||||
<widget class="QFrame" name="expandFrame">
|
<widget class="QFrame" name="expandFrame">
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
@ -334,6 +334,33 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="moderatorList_GB">
|
||||||
|
<property name="title">
|
||||||
|
<string>Moderator list</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="moderatorList_TE"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -29,6 +29,7 @@ class NewsFeedUserNotify : public UserNotify
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
virtual QString textInfo() const override { return tr("logged event(s)"); }
|
||||||
public:
|
public:
|
||||||
NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent = 0);
|
NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent = 0);
|
||||||
|
|
||||||
|
@ -892,6 +892,10 @@ void GxsGroupDialog::getSelectedModerators(std::set<RsGxsId>& ids)
|
|||||||
|
|
||||||
void GxsGroupDialog::setSelectedModerators(const std::set<RsGxsId>& ids)
|
void GxsGroupDialog::setSelectedModerators(const std::set<RsGxsId>& ids)
|
||||||
{
|
{
|
||||||
|
ui.addAdmins_cb->setChecked(true);
|
||||||
|
ui.adminsList->show();
|
||||||
|
ui.filtercomboBox->show();
|
||||||
|
|
||||||
ui.adminsList->setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(ids, false);
|
ui.adminsList->setSelectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(ids, false);
|
||||||
|
|
||||||
QString moderatorsListString ;
|
QString moderatorsListString ;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>1231</width>
|
||||||
<height>563</height>
|
<height>967</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -223,14 +223,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="publish_required">
|
<widget class="QRadioButton" name="publish_required">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Required</string>
|
<string>Re&quired</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="publish_encrypt">
|
<widget class="QRadioButton" name="publish_encrypt">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Encrypted Msgs</string>
|
<string>Encrypted &Msgs</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -856,7 +856,6 @@
|
|||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
#define ROLE_FILE_HASH Qt::UserRole + 3
|
#define ROLE_FILE_HASH Qt::UserRole + 3
|
||||||
#define ROLE_MSG Qt::UserRole + 4
|
#define ROLE_MSG Qt::UserRole + 4
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Sha1CheckSum)
|
||||||
|
|
||||||
GxsChannelFilesWidget::GxsChannelFilesWidget(QWidget *parent) :
|
GxsChannelFilesWidget::GxsChannelFilesWidget(QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::GxsChannelFilesWidget)
|
QWidget(parent), ui(new Ui::GxsChannelFilesWidget)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "retroshare/rsgxschannels.h"
|
#include "retroshare/rsgxschannels.h"
|
||||||
#include "GxsChannelUserNotify.h"
|
#include "GxsChannelUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
#include "gui/common/FilesDefs.h"
|
||||||
|
|
||||||
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, g, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
@ -37,12 +38,12 @@ bool GxsChannelUserNotify::hasSetting(QString *name, QString *group)
|
|||||||
|
|
||||||
QIcon GxsChannelUserNotify::getIcon()
|
QIcon GxsChannelUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
return QIcon(":/icons/png/channel.png");
|
return FilesDefs::getIconFromQtResourcePath(":/icons/png/channel.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon GxsChannelUserNotify::getMainIcon(bool hasNew)
|
QIcon GxsChannelUserNotify::getMainIcon(bool hasNew)
|
||||||
{
|
{
|
||||||
return hasNew ? QIcon(":/icons/png/channels-notify.png") : QIcon(":/icons/png/channel.png");
|
return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/channels-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/channel.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelUserNotify::iconClicked()
|
void GxsChannelUserNotify::iconClicked()
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual QString textInfo() const override { return tr("new message(s)"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "retroshare/rsgxsforums.h"
|
#include "retroshare/rsgxsforums.h"
|
||||||
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "GxsForumUserNotify.h"
|
#include "GxsForumUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
@ -38,12 +39,12 @@ bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
|
|||||||
|
|
||||||
QIcon GxsForumUserNotify::getIcon()
|
QIcon GxsForumUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
return QIcon(":/icons/png/forums.png");
|
return FilesDefs::getIconFromQtResourcePath(":/icons/png/forums.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon GxsForumUserNotify::getMainIcon(bool hasNew)
|
QIcon GxsForumUserNotify::getMainIcon(bool hasNew)
|
||||||
{
|
{
|
||||||
return hasNew ? QIcon(":/icons/png/forums-notify.png") : QIcon(":/icons/png/forums.png");
|
return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/forums-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/forums.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumUserNotify::iconClicked()
|
void GxsForumUserNotify::iconClicked()
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual QString textInfo() const override { return tr("new message(s)"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
@ -109,7 +109,6 @@ public:
|
|||||||
void setCurrentBox(BoxName bn) ;
|
void setCurrentBox(BoxName bn) ;
|
||||||
void setQuickViewFilter(QuickViewFilter fn) ;
|
void setQuickViewFilter(QuickViewFilter fn) ;
|
||||||
|
|
||||||
const RsMessageId& currentMessageId() const;
|
|
||||||
void setFilter(FilterType filter_type, const QStringList& strings) ;
|
void setFilter(FilterType filter_type, const QStringList& strings) ;
|
||||||
|
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
MessageUserNotify(QObject *parent = 0);
|
MessageUserNotify(QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
virtual QString textInfo() const override { return tr("new mail(s)"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
Loading…
Reference in New Issue
Block a user