added regular contacts list and method to move RsGxsIds from/into this list

This commit is contained in:
csoler 2015-11-19 22:58:28 -05:00
parent 1de55d8fc5
commit 1347ee4b37
5 changed files with 55 additions and 2 deletions

View file

@ -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 ;

View file

@ -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;
/**************************