mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
added regular contacts list and method to move RsGxsIds from/into this list
This commit is contained in:
parent
1de55d8fc5
commit
1347ee4b37
@ -242,6 +242,8 @@ virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
||||
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
|
||||
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||
|
||||
// Specific RsIdentity Functions....
|
||||
/* Specific Service Data */
|
||||
/* We expose these initially for testing / GUI purposes.
|
||||
|
@ -101,6 +101,8 @@ uint32_t RsGxsIdLocalInfoItem::serial_size()
|
||||
uint32_t s = 8 ; // header
|
||||
s += 4 ; // number of items
|
||||
s += mTimeStamps.size() * (RsGxsId::SIZE_IN_BYTES + 8) ;
|
||||
s += 4 ; // number of contacts
|
||||
s += mContacts.size() * (RsGxsId::SIZE_IN_BYTES + 8) ;
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -176,6 +178,11 @@ bool RsGxsIdLocalInfoItem::serialise(void *data, uint32_t& size)
|
||||
ok &= it->first.serialise(data,tlvsize,offset) ;
|
||||
ok &= setRawTimeT(data,tlvsize,&offset,it->second) ;
|
||||
}
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mContacts.size()) ;
|
||||
|
||||
for(std::set<RsGxsId>::const_iterator it(mContacts.begin());it!=mContacts.end();++it)
|
||||
ok &= (*it).serialise(data,tlvsize,offset) ;
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
#ifdef GXSID_DEBUG
|
||||
@ -386,6 +393,19 @@ RsGxsIdLocalInfoItem *RsGxsIdSerialiser::deserialise_GxsIdLocalInfoItem(void *da
|
||||
item->mTimeStamps[gxsid] = TS ;
|
||||
}
|
||||
|
||||
if (offset < rssize) // backward compatibility, making that section optional.
|
||||
{
|
||||
ok &= getRawUInt32(data, rssize, &offset, &n) ;
|
||||
RsGxsId gxsid ;
|
||||
|
||||
for(int i=0;ok && i<n;++i)
|
||||
{
|
||||
ok &= gxsid.deserialise(data,rssize,offset) ;
|
||||
|
||||
item->mContacts.insert(gxsid) ;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef GXSID_DEBUG
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
virtual uint32_t serial_size() ;
|
||||
|
||||
std::map<RsGxsId,time_t> mTimeStamps ;
|
||||
std::set<RsGxsId> mContacts ;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
@ -210,6 +210,25 @@ uint32_t p3IdService::idAuthenPolicy()
|
||||
|
||||
return policy;
|
||||
}
|
||||
bool p3IdService::setAsRegularContact(const RsGxsId& id,bool b)
|
||||
{
|
||||
std::set<RsGxsId>::iterator it = mContacts.find(id) ;
|
||||
|
||||
if(b && (it == mContacts.end()))
|
||||
{
|
||||
mContacts.insert(id) ;
|
||||
slowIndicateConfigChanged() ;
|
||||
}
|
||||
|
||||
if( (!b) &&(it != mContacts.end()))
|
||||
{
|
||||
mContacts.erase(it) ;
|
||||
slowIndicateConfigChanged() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3IdService::slowIndicateConfigChanged()
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
@ -248,8 +267,13 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
|
||||
|
||||
for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it)
|
||||
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
|
||||
{
|
||||
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
|
||||
mKeysTS.insert(*it2) ;
|
||||
|
||||
mContacts = lii->mContacts ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@ -263,6 +287,7 @@ bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
|
||||
cleanup = true ;
|
||||
RsGxsIdLocalInfoItem *item = new RsGxsIdLocalInfoItem ;
|
||||
item->mTimeStamps = mKeysTS ;
|
||||
item->mContacts = mContacts ;
|
||||
|
||||
items.push_back(item) ;
|
||||
return true ;
|
||||
|
@ -269,6 +269,8 @@ virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
||||
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
||||
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
||||
|
||||
/**************** RsGixs Implementation ***************/
|
||||
|
||||
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
|
||||
@ -499,8 +501,11 @@ std::string genRandomId(int len = 20);
|
||||
|
||||
std::map<uint32_t, std::set<RsGxsGroupId> > mIdsPendingCache;
|
||||
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
|
||||
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
||||
std::map<RsGxsId,time_t> mKeysTS ;
|
||||
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
||||
std::map<RsGxsId,time_t> mKeysTS ;
|
||||
|
||||
// keep a list of regular contacts. This is useful to sort IDs, and allow some services to priviledged ids only.
|
||||
std::set<RsGxsId> mContacts;
|
||||
RsNetworkExchangeService* mNes;
|
||||
|
||||
/**************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user