mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 04:44:25 -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
4 changed files with 63 additions and 40 deletions
|
@ -188,7 +188,7 @@ void p3GxsCircles::service_tick()
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
if(now > mLastCacheMembershipUpdateTS + GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE)
|
if(now > mLastCacheMembershipUpdateTS + GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE)
|
||||||
{
|
{
|
||||||
p3GxsCircles::checkCircleCacheForMembershipUpdate();
|
checkCircleCache();
|
||||||
mLastCacheMembershipUpdateTS = now ;
|
mLastCacheMembershipUpdateTS = now ;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1194,11 +1194,17 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsCircles::checkCircleCacheForMembershipUpdate()
|
bool p3GxsCircles::checkCircleCache()
|
||||||
{
|
{
|
||||||
#warning TODO. Should go over existing cache entries and update/process the membership requests
|
#ifdef DEBUG_CIRCLES
|
||||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
std::cerr << "checkCircleCache(): calling auto-subscribe check and membership update check." << std::endl;
|
||||||
return false ;
|
#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)
|
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 << " AuthorId : " << s->meta.mAuthorId << std::endl;
|
||||||
std::cerr << " ThreadId : " << s->meta.mThreadId << std::endl;
|
std::cerr << " ThreadId : " << s->meta.mThreadId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t token ;
|
uint32_t token ;
|
||||||
|
|
||||||
|
if(request_type == RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE)
|
||||||
|
RsGenExchange::subscribeToGroup(token, RsGxsGroupId(circle_id), true);
|
||||||
|
|
||||||
RsGenExchange::publishMsg(token, s);
|
RsGenExchange::publishMsg(token, s);
|
||||||
|
|
||||||
// update the cache.
|
// update the cache.
|
||||||
|
|
|
@ -247,7 +247,7 @@ virtual RsServiceInfo getServiceInfo();
|
||||||
bool cache_load_for_token(uint32_t token);
|
bool cache_load_for_token(uint32_t token);
|
||||||
bool cache_reloadids(const RsGxsCircleId &circleId);
|
bool cache_reloadids(const RsGxsCircleId &circleId);
|
||||||
|
|
||||||
bool checkCircleCacheForMembershipUpdate();
|
bool checkCircleCache();
|
||||||
|
|
||||||
bool locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
bool locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
||||||
bool locked_processLoadingCacheEntry(RsGxsCircleCache &cache);
|
bool locked_processLoadingCacheEntry(RsGxsCircleCache &cache);
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
template<class Key, class Value> class RsMemCache
|
template<class Key, class Value> class RsMemCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsMemCache(uint32_t max_size = DEFAULT_MEM_CACHE_SIZE, std::string name = "UnknownMemCache")
|
RsMemCache(uint32_t max_size = DEFAULT_MEM_CACHE_SIZE, std::string name = "UnknownMemCache")
|
||||||
:mDataCount(0), mMaxSize(max_size), mName(name)
|
:mDataCount(0), mMaxSize(max_size), mName(name)
|
||||||
|
@ -69,7 +69,11 @@ template<class Key, class Value> class RsMemCache
|
||||||
|
|
||||||
bool resize(); // should be called periodically to cleanup old entries.
|
bool resize(); // should be called periodically to cleanup old entries.
|
||||||
|
|
||||||
private:
|
// 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);
|
bool update_lrumap(const Key &key, time_t old_ts, time_t new_ts);
|
||||||
bool discard_LRU(int count_to_clear);
|
bool discard_LRU(int count_to_clear);
|
||||||
|
@ -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)
|
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_GROUPID,Qt::UserRole, QString::fromStdString(vit->mGroupId.toStdString()));
|
||||||
item->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(vit->mSubscribeFlags));
|
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
|
#ifdef CIRCLE_MEMBERSHIP_CATEGORIES
|
||||||
if(am_I_in_circle)
|
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));
|
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)
|
if (am_I_admin)
|
||||||
{
|
{
|
||||||
QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME) ;
|
QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME) ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue