mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added regular test of circle auto-subscribe from cache, and auto-subscribe when submitting a membership request
This commit is contained in:
parent
2bde81f210
commit
cbef01451c
@ -188,7 +188,7 @@ void p3GxsCircles::service_tick()
|
||||
time_t now = time(NULL);
|
||||
if(now > mLastCacheMembershipUpdateTS + GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE)
|
||||
{
|
||||
p3GxsCircles::checkCircleCacheForMembershipUpdate();
|
||||
checkCircleCache();
|
||||
mLastCacheMembershipUpdateTS = now ;
|
||||
}
|
||||
return;
|
||||
@ -1194,11 +1194,17 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsCircles::checkCircleCacheForMembershipUpdate()
|
||||
bool p3GxsCircles::checkCircleCache()
|
||||
{
|
||||
#warning TODO. Should go over existing cache entries and update/process the membership requests
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
||||
return false ;
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "checkCircleCache(): calling auto-subscribe check and membership update check." << std::endl;
|
||||
#endif
|
||||
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mCircleCache.applyToAllCachedEntries(*this,&p3GxsCircles::locked_checkCircleCacheForAutoSubscribe) ;
|
||||
// mCircleCache.applyToAllCachedEntries(*this,&p3GxsCircles::locked_checkCircleCacheForMembershipUpdate) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache)
|
||||
@ -1934,8 +1940,11 @@ bool p3GxsCircles::pushCircleMembershipRequest(const RsGxsId& own_gxsid,const Rs
|
||||
std::cerr << " AuthorId : " << s->meta.mAuthorId << std::endl;
|
||||
std::cerr << " ThreadId : " << s->meta.mThreadId << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t token ;
|
||||
|
||||
if(request_type == RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE)
|
||||
RsGenExchange::subscribeToGroup(token, RsGxsGroupId(circle_id), true);
|
||||
|
||||
RsGenExchange::publishMsg(token, s);
|
||||
|
||||
// update the cache.
|
||||
|
@ -247,7 +247,7 @@ virtual RsServiceInfo getServiceInfo();
|
||||
bool cache_load_for_token(uint32_t token);
|
||||
bool cache_reloadids(const RsGxsCircleId &circleId);
|
||||
|
||||
bool checkCircleCacheForMembershipUpdate();
|
||||
bool checkCircleCache();
|
||||
|
||||
bool locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
||||
bool locked_processLoadingCacheEntry(RsGxsCircleCache &cache);
|
||||
|
@ -69,6 +69,10 @@ template<class Key, class Value> class RsMemCache
|
||||
|
||||
bool resize(); // should be called periodically to cleanup old entries.
|
||||
|
||||
// Apply a method of a given class ClientClass to all cached data. Can be useful...
|
||||
|
||||
template<class ClientClass> bool applyToAllCachedEntries(ClientClass& c,bool (ClientClass::*method)(Value&));
|
||||
|
||||
private:
|
||||
|
||||
bool update_lrumap(const Key &key, time_t old_ts, time_t new_ts);
|
||||
@ -129,6 +133,15 @@ template<class Key, class Value> bool RsMemCache<Key, Value>::is_cached(const Ke
|
||||
|
||||
}
|
||||
|
||||
template<class Key, class Value> template<class ClientClass> bool RsMemCache<Key, Value>::applyToAllCachedEntries(ClientClass& c, bool (ClientClass::*method)(Value&))
|
||||
{
|
||||
bool res = true ;
|
||||
|
||||
for(typename std::map<Key,cache_data>::iterator it(mDataMap.begin());it!=mDataMap.end();++it)
|
||||
res = res && ((c.*method)(it->second.data)) ;
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
template<class Key, class Value> bool RsMemCache<Key, Value>::fetch(const Key &key, Value &data)
|
||||
{
|
||||
|
@ -483,30 +483,6 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
|
||||
item->setData(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole, QString::fromStdString(vit->mGroupId.toStdString()));
|
||||
item->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(vit->mSubscribeFlags));
|
||||
|
||||
QString tooltip ;
|
||||
tooltip += tr("Circle ID: ")+QString::fromStdString(vit->mGroupId.toStdString()) ;
|
||||
|
||||
tooltip += "\n"+tr("Role: ");
|
||||
|
||||
if(am_I_admin)
|
||||
tooltip += tr("Administrator (Can edit invite list, and request membership).") ;
|
||||
else
|
||||
tooltip += tr("User (Can only request membership).") ;
|
||||
|
||||
tooltip += "\n"+tr("Distribution: ");
|
||||
if(am_I_subscribed)
|
||||
tooltip += tr("subscribed (Receive/forward membership requests from others and invite list).") ;
|
||||
else
|
||||
tooltip += tr("unsubscribed (Only receive invite list).") ;
|
||||
|
||||
tooltip += "\n"+tr("Permissions: ") ;
|
||||
|
||||
if(am_I_in_circle)
|
||||
tooltip += tr("Full member (have access to data limited to this circle)") ;
|
||||
else
|
||||
tooltip += tr("Not a member (do not have access to data limited to this circle)") ;
|
||||
|
||||
item->setToolTip(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,tooltip);
|
||||
#ifdef CIRCLE_MEMBERSHIP_CATEGORIES
|
||||
if(am_I_in_circle)
|
||||
{
|
||||
@ -537,6 +513,31 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
|
||||
|
||||
item->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(vit->mSubscribeFlags));
|
||||
|
||||
QString tooltip ;
|
||||
tooltip += tr("Circle ID: ")+QString::fromStdString(vit->mGroupId.toStdString()) ;
|
||||
|
||||
tooltip += "\n"+tr("Role: ");
|
||||
|
||||
if(am_I_admin)
|
||||
tooltip += tr("Administrator (Can edit invite list, and request membership).") ;
|
||||
else
|
||||
tooltip += tr("User (Can only request membership).") ;
|
||||
|
||||
tooltip += "\n"+tr("Distribution: ");
|
||||
if(am_I_subscribed)
|
||||
tooltip += tr("subscribed (Receive/forward membership requests from others and invite list).") ;
|
||||
else
|
||||
tooltip += tr("unsubscribed (Only receive invite list).") ;
|
||||
|
||||
tooltip += "\n"+tr("Permissions: ") ;
|
||||
|
||||
if(am_I_in_circle)
|
||||
tooltip += tr("Full member (have access to data limited to this circle)") ;
|
||||
else
|
||||
tooltip += tr("Not a member (do not have access to data limited to this circle)") ;
|
||||
|
||||
item->setToolTip(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,tooltip);
|
||||
|
||||
if (am_I_admin)
|
||||
{
|
||||
QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME) ;
|
||||
|
Loading…
Reference in New Issue
Block a user