mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
Addition of the Basics of the New Identity Service.
- Provides Real & Pseudonym Ids. - Real Ids are tied to GPG Ids using a One-Way Hash. Added IDS for QCHESS and ARADO plugins. Added new RsIdentity external interface. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@4932 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0a254ab5a2
commit
459b51e814
@ -10,7 +10,6 @@ CONFIG += test_voip
|
||||
# Beware: All data of the stripped services are lost
|
||||
#CONFIG += minimal
|
||||
DEFINES *= PQI_DISABLE_TUNNEL
|
||||
INCLUDEPATH += C:/Development/Rs/OpenSSL/include
|
||||
#ENABLE_CACHE_OPT
|
||||
|
||||
minimal {
|
||||
@ -675,10 +674,13 @@ HEADERS += services/p3photoservice.h \
|
||||
retroshare/rsphoto.h \
|
||||
services/p3wikiservice.h \
|
||||
retroshare/rswiki.h \
|
||||
services/p3idservice.h \
|
||||
retroshare/rsidentity.h \
|
||||
|
||||
SOURCES += services/p3photoservice.cc \
|
||||
serialiser/rsphotoitems.cc \
|
||||
services/p3wikiservice.cc \
|
||||
services/p3idservice.cc \
|
||||
|
||||
# Other Old Code.
|
||||
# rsserver/p3photo.cc \
|
||||
|
122
libretroshare/src/retroshare/rsidentity.h
Normal file
122
libretroshare/src/retroshare/rsidentity.h
Normal file
@ -0,0 +1,122 @@
|
||||
#ifndef RETROSHARE_IDENTITY_GUI_INTERFACE_H
|
||||
#define RETROSHARE_IDENTITY_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/retroshare: rsidentity.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsIdentity;
|
||||
extern RsIdentity *rsIdentity;
|
||||
|
||||
#define RSID_TYPE_MASK 0xff00
|
||||
#define RSID_RELATION_MASK 0x00ff
|
||||
|
||||
#define RSID_TYPE_REALID 0x0100
|
||||
#define RSID_TYPE_PSEUDONYM 0x0200
|
||||
|
||||
#define RSID_RELATION_YOURSELF 0x0001
|
||||
#define RSID_RELATION_FRIEND 0x0002
|
||||
#define RSID_RELATION_FOF 0x0004
|
||||
#define RSID_RELATION_OTHER 0x0008
|
||||
#define RSID_RELATION_UNKNOWN 0x0010
|
||||
|
||||
std::string rsIdTypeToString(uint32_t idtype);
|
||||
|
||||
class RsIdData
|
||||
{
|
||||
public:
|
||||
|
||||
std::string mNickname;
|
||||
std::string mKeyId;
|
||||
|
||||
uint32_t mIdType;
|
||||
|
||||
std::string mGpgIdHash; // SHA(KeyId + Gpg Fingerprint) -> can only be IDed if GPG known.
|
||||
|
||||
bool mGpgIdKnown; // if GpgIdHash has been identified.
|
||||
std::string mGpgId; // if known.
|
||||
std::string mGpgName; // if known.
|
||||
std::string mGpgEmail; // if known.
|
||||
};
|
||||
|
||||
class RsIdReputation
|
||||
{
|
||||
public:
|
||||
std::string mKeyId;
|
||||
|
||||
int mYourRating;
|
||||
int mPeersRating;
|
||||
int mFofRating;
|
||||
int mTotalRating;
|
||||
|
||||
std::string mComment;
|
||||
};
|
||||
|
||||
class RsIdOpinion
|
||||
{
|
||||
public:
|
||||
|
||||
std::string mKeyId;
|
||||
std::string mPeerId;
|
||||
|
||||
int mRating;
|
||||
int mPeersRating;
|
||||
std::string mComment;
|
||||
};
|
||||
|
||||
|
||||
class RsIdentity
|
||||
{
|
||||
public:
|
||||
|
||||
RsIdentity() { return; }
|
||||
virtual ~RsIdentity() { return; }
|
||||
|
||||
/* changed? */
|
||||
virtual bool updated() = 0;
|
||||
|
||||
|
||||
virtual bool getIdentityList(std::list<std::string> &ids) = 0;
|
||||
|
||||
virtual bool getIdentity(const std::string &id, RsIdData &data) = 0;
|
||||
virtual bool getIdReputation(const std::string &id, RsIdReputation &reputation) = 0;
|
||||
virtual bool getIdPeerOpinion(const std::string &aboutid, const std::string &peerid, RsIdOpinion &opinion) = 0;
|
||||
|
||||
virtual bool getGpgIdDetails(const std::string &id, std::string &gpgName, std::string &gpgEmail) = 0;
|
||||
|
||||
/* details are updated in group - to choose GroupID */
|
||||
virtual bool updateIdentity(RsIdData &data) = 0;
|
||||
virtual bool updateOpinion(RsIdOpinion &opinion) = 0;
|
||||
|
||||
virtual void generateDummyData() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1734,6 +1734,7 @@ RsTurtle *rsTurtle = NULL ;
|
||||
|
||||
#include "services/p3photoservice.h"
|
||||
#include "services/p3wikiservice.h"
|
||||
#include "services/p3idservice.h"
|
||||
|
||||
#ifndef PQI_DISABLE_TUNNEL
|
||||
#include "services/p3tunnel.h"
|
||||
@ -2140,6 +2141,10 @@ int RsServer::StartupRetroShare()
|
||||
p3WikiService *mWikis = new p3WikiService(RS_SERVICE_TYPE_WIKI);
|
||||
pqih -> addService(mWikis);
|
||||
|
||||
// Testing New Cache Services.
|
||||
p3IdService *mIdentity = new p3IdService(RS_SERVICE_TYPE_IDENTITY);
|
||||
pqih -> addService(mIdentity);
|
||||
|
||||
#ifndef RS_RELEASE
|
||||
p3GameLauncher *gameLauncher = new p3GameLauncher(mLinkMgr);
|
||||
pqih -> addService(gameLauncher);
|
||||
@ -2409,6 +2414,7 @@ int RsServer::StartupRetroShare()
|
||||
// Testing of new cache system interfaces.
|
||||
rsPhoto = mPhotos;
|
||||
rsWiki = mWikis;
|
||||
rsIdentity = mIdentity;
|
||||
|
||||
#ifdef RS_USE_BLOGS
|
||||
rsBlogs = mBlogs;
|
||||
|
@ -61,7 +61,11 @@ const uint16_t RS_SERVICE_TYPE_CHANNEL_SOCKET = 0xf140;
|
||||
/* Status - Service only */
|
||||
const uint16_t RS_SERVICE_TYPE_STATUS = 0xf020;
|
||||
|
||||
/* Combined Cache/Service ids */
|
||||
/***************** IDS ALLOCATED FOR PLUGINS ******************/
|
||||
|
||||
const uint16_t RS_SERVICE_TYPE_PLUGIN_ARADO_ID = 0x0401;
|
||||
const uint16_t RS_SERVICE_TYPE_PLUGIN_QCHESS_ID = 0x0402;
|
||||
|
||||
|
||||
/****************** BELOW ARE ONLY THEORETICAL (CAN BE CHANGED) *****/
|
||||
/*
|
||||
@ -88,6 +92,9 @@ const uint16_t RS_SERVICE_TYPE_QBLOG = 0xf010;
|
||||
/* TEST VOIP - Service only */
|
||||
const uint16_t RS_SERVICE_TYPE_VOIP = 0xf011;
|
||||
|
||||
/* Status - Service only */
|
||||
//const uint16_t RS_SERVICE_TYPE_STATUS = 0xf020;
|
||||
|
||||
/* Proxy - Service only */
|
||||
const uint16_t RS_SERVICE_TYPE_PROXY = 0xf030;
|
||||
|
||||
@ -99,6 +106,12 @@ const uint16_t RS_SERVICE_TYPE_DSDV = 0xf050;
|
||||
const uint16_t RS_SERVICE_TYPE_PHOTO = 0xf101;
|
||||
const uint16_t RS_SERVICE_TYPE_WIKI = 0xf102;
|
||||
const uint16_t RS_SERVICE_TYPE_WIRE = 0xf103;
|
||||
const uint16_t RS_SERVICE_TYPE_IDENTITY = 0xf103;
|
||||
|
||||
//const uint16_t RS_SERVICE_TYPE_DISTRIB = 0xf110;
|
||||
//const uint16_t RS_SERVICE_TYPE_FORUM = 0xf120;
|
||||
//const uint16_t RS_SERVICE_TYPE_CHANNEL = 0xf130;
|
||||
//const uint16_t RS_SERVICE_TYPE_CHANNEL_SOCKET = 0xf140;
|
||||
|
||||
/* Games/External Apps - Service Only */
|
||||
const uint16_t RS_SERVICE_TYPE_GAME_LAUNCHER = 0xf200;
|
||||
@ -114,7 +127,10 @@ const uint16_t RS_SERVICE_TYPE_GAME_BIGTWO = 0xf213;
|
||||
const uint16_t RS_SERVICE_TYPE_GAME_POKER = 0xf214;
|
||||
|
||||
|
||||
/***************** IDS ALLOCATED FOR PLUGINS ******************/
|
||||
|
||||
const uint16_t RS_SERVICE_TYPE_PLUGIN_ARADO_TEST_ID1 = 0xf401;
|
||||
const uint16_t RS_SERVICE_TYPE_PLUGIN_QCHESS_TEST_ID1 = 0xf402;
|
||||
|
||||
|
||||
|
||||
|
393
libretroshare/src/services/p3idservice.cc
Normal file
393
libretroshare/src/services/p3idservice.cc
Normal file
@ -0,0 +1,393 @@
|
||||
/*
|
||||
* libretroshare/src/services p3idservice.cc
|
||||
*
|
||||
* Id interface for RetroShare.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "services/p3idservice.h"
|
||||
|
||||
#include "util/rsrandom.h"
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <sstream>
|
||||
|
||||
/****
|
||||
* #define ID_DEBUG 1
|
||||
****/
|
||||
|
||||
RsIdentity *rsIdentity = NULL;
|
||||
|
||||
|
||||
p3IdService::p3IdService(uint16_t type)
|
||||
:p3Service(type), mIdMtx("p3IdService"), mUpdated(true)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int p3IdService::tick()
|
||||
{
|
||||
std::cerr << "p3IdService::tick()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool p3IdService::updated()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
if (mUpdated)
|
||||
{
|
||||
mUpdated = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService::getGpgIdDetails(const std::string &id, std::string &gpgName, std::string &gpgEmail)
|
||||
{
|
||||
gpgName = "aGpgName";
|
||||
gpgEmail = "a@GpgMailAddress";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdentityList(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string, RsIdData>::iterator it;
|
||||
for(it = mIds.begin(); it != mIds.end(); it++)
|
||||
{
|
||||
ids.push_back(it->first);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdentity(const std::string &id, RsIdData &data)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string, RsIdData>::iterator it;
|
||||
it = mIds.find(id);
|
||||
if (it == mIds.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
data = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdReputation(const std::string &id, RsIdReputation &reputation)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string, RsIdReputation>::iterator it;
|
||||
it = mReputations.find(id);
|
||||
if (it == mReputations.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
reputation = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool p3IdService::getIdPeerOpinion(const std::string &aboutid, const std::string &peerId, RsIdOpinion &opinion)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string, std::map<std::string, RsIdOpinion> >::iterator it;
|
||||
std::map<std::string, RsIdOpinion>::iterator oit;
|
||||
it = mOpinions.find(aboutid);
|
||||
if (it == mOpinions.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
oit = it->second.find(peerId);
|
||||
if (oit == it->second.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
opinion = oit->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* details are updated */
|
||||
bool p3IdService::updateIdentity(RsIdData &data)
|
||||
{
|
||||
if (data.mKeyId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
|
||||
/* generate a temp id */
|
||||
data.mKeyId = genRandomId();
|
||||
|
||||
if (data.mIdType & RSID_TYPE_REALID)
|
||||
{
|
||||
data.mGpgIdHash = genRandomId();
|
||||
}
|
||||
else
|
||||
{
|
||||
data.mGpgIdHash = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
|
||||
/* add / modify */
|
||||
mIds[data.mKeyId] = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool p3IdService::updateOpinion(RsIdOpinion &opinion)
|
||||
{
|
||||
if (opinion.mKeyId.empty())
|
||||
{
|
||||
/* new photo */
|
||||
std::cerr << "p3IdService::updateOpinion() Missing KeyId";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if its a mod or new page */
|
||||
if (opinion.mPeerId.empty())
|
||||
{
|
||||
std::cerr << "p3IdService::updateOpinion() Missing PeerId";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "p3IdService::updateOpinion() KeyId: " << opinion.mKeyId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3IdService::updateOpinion() PeerId: " << opinion.mPeerId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mUpdated = true;
|
||||
|
||||
std::map<std::string, std::map<std::string, RsIdOpinion> >::iterator it;
|
||||
std::map<std::string, RsIdOpinion>::iterator oit;
|
||||
|
||||
it = mOpinions.find(opinion.mKeyId);
|
||||
if (it == mOpinions.end())
|
||||
{
|
||||
std::map<std::string, RsIdOpinion> emptyMap;
|
||||
mOpinions[opinion.mKeyId] = emptyMap;
|
||||
|
||||
it = mOpinions.find(opinion.mKeyId);
|
||||
}
|
||||
|
||||
(it->second)[opinion.mPeerId] = opinion;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
std::string p3IdService::genRandomId()
|
||||
{
|
||||
std::string randomId;
|
||||
for(int i = 0; i < 20; i++)
|
||||
{
|
||||
randomId += (char) ('a' + (RSRandom::random_u32() % 26));
|
||||
}
|
||||
|
||||
return randomId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3IdService::generateDummyData()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
/* grab all the gpg ids... and make some ids */
|
||||
|
||||
std::list<std::string> gpgids;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
rsPeers->getGPGAllList(gpgids);
|
||||
|
||||
std::string ownId = rsPeers->getGPGOwnId();
|
||||
gpgids.push_back(ownId);
|
||||
|
||||
int i;
|
||||
for(it = gpgids.begin(); it != gpgids.end(); it++)
|
||||
{
|
||||
/* create one or two for each one */
|
||||
int nIds = 1 + (RSRandom::random_u32() % 2);
|
||||
for(i = 0; i < nIds; i++)
|
||||
{
|
||||
RsIdData id;
|
||||
|
||||
RsPeerDetails details;
|
||||
|
||||
id.mKeyId = genRandomId();
|
||||
id.mIdType = RSID_TYPE_REALID;
|
||||
id.mGpgIdHash = genRandomId();
|
||||
|
||||
if (rsPeers->getPeerDetails(*it, details))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << details.name << "_" << i + 1;
|
||||
|
||||
id.mNickname = out.str();
|
||||
id.mGpgIdKnown = true;
|
||||
|
||||
id.mGpgId = *it;
|
||||
id.mGpgName = details.name;
|
||||
id.mGpgEmail = details.email;
|
||||
|
||||
if (*it == ownId)
|
||||
{
|
||||
id.mIdType |= RSID_RELATION_YOURSELF;
|
||||
}
|
||||
else if (rsPeers->isGPGAccepted(*it))
|
||||
{
|
||||
id.mIdType |= RSID_RELATION_FRIEND;
|
||||
}
|
||||
else
|
||||
{
|
||||
id.mIdType |= RSID_RELATION_OTHER;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3IdService::generateDummyData() missing" << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
id.mIdType |= RSID_RELATION_OTHER;
|
||||
id.mNickname = genRandomId();
|
||||
id.mGpgIdKnown = false;
|
||||
}
|
||||
|
||||
mIds[id.mKeyId] = id;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_RANDOM_GPGIDS 1000
|
||||
#define MAX_RANDOM_PSEUDOIDS 5000
|
||||
|
||||
int nFakeGPGs = (RSRandom::random_u32() % MAX_RANDOM_GPGIDS);
|
||||
int nFakePseudoIds = (RSRandom::random_u32() % MAX_RANDOM_PSEUDOIDS);
|
||||
|
||||
/* make some fake gpg ids */
|
||||
for(i = 0; i < nFakeGPGs; i++)
|
||||
{
|
||||
RsIdData id;
|
||||
|
||||
RsPeerDetails details;
|
||||
|
||||
id.mKeyId = genRandomId();
|
||||
id.mIdType = RSID_TYPE_REALID;
|
||||
id.mGpgIdHash = genRandomId();
|
||||
|
||||
id.mIdType |= RSID_RELATION_OTHER;
|
||||
id.mNickname = genRandomId();
|
||||
id.mGpgIdKnown = false;
|
||||
id.mGpgId = "";
|
||||
id.mGpgName = "";
|
||||
id.mGpgEmail = "";
|
||||
|
||||
mIds[id.mKeyId] = id;
|
||||
}
|
||||
|
||||
/* make lots of pseudo ids */
|
||||
for(i = 0; i < nFakePseudoIds; i++)
|
||||
{
|
||||
RsIdData id;
|
||||
|
||||
RsPeerDetails details;
|
||||
|
||||
id.mKeyId = genRandomId();
|
||||
id.mIdType = RSID_TYPE_PSEUDONYM;
|
||||
id.mGpgIdHash = "";
|
||||
|
||||
id.mNickname = genRandomId();
|
||||
id.mGpgIdKnown = false;
|
||||
id.mGpgId = "";
|
||||
id.mGpgName = "";
|
||||
id.mGpgEmail = "";
|
||||
|
||||
mIds[id.mKeyId] = id;
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string rsIdTypeToString(uint32_t idtype)
|
||||
{
|
||||
std::string str;
|
||||
if (idtype & RSID_TYPE_REALID)
|
||||
{
|
||||
str += "GPGID ";
|
||||
}
|
||||
if (idtype & RSID_TYPE_PSEUDONYM)
|
||||
{
|
||||
str += "PSEUDO ";
|
||||
}
|
||||
if (idtype & RSID_RELATION_YOURSELF)
|
||||
{
|
||||
str += "YOURSELF ";
|
||||
}
|
||||
if (idtype & RSID_RELATION_FRIEND)
|
||||
{
|
||||
str += "FRIEND ";
|
||||
}
|
||||
if (idtype & RSID_RELATION_FOF)
|
||||
{
|
||||
str += "FOF ";
|
||||
}
|
||||
if (idtype & RSID_RELATION_OTHER)
|
||||
{
|
||||
str += "OTHER ";
|
||||
}
|
||||
if (idtype & RSID_RELATION_UNKNOWN)
|
||||
{
|
||||
str += "UNKNOWN ";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
84
libretroshare/src/services/p3idservice.h
Normal file
84
libretroshare/src/services/p3idservice.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* libretroshare/src/services: p3idservice.h
|
||||
*
|
||||
* Identity interface for RetroShare.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef P3_IDENTITY_SERVICE_HEADER
|
||||
#define P3_IDENTITY_SERVICE_HEADER
|
||||
|
||||
#include "services/p3service.h"
|
||||
|
||||
#include "retroshare/rsidentity.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Indentity Service
|
||||
*
|
||||
*/
|
||||
|
||||
class p3IdService: public p3Service, public RsIdentity
|
||||
{
|
||||
public:
|
||||
|
||||
p3IdService(uint16_t type);
|
||||
|
||||
virtual int tick();
|
||||
|
||||
public:
|
||||
|
||||
/* changed? */
|
||||
virtual bool updated();
|
||||
|
||||
virtual bool getIdentityList(std::list<std::string> &ids);
|
||||
|
||||
virtual bool getIdentity(const std::string &id, RsIdData &data);
|
||||
virtual bool getIdReputation(const std::string &id, RsIdReputation &reputation);
|
||||
virtual bool getIdPeerOpinion(const std::string &aboutid, const std::string &peerid, RsIdOpinion &opinion);
|
||||
|
||||
virtual bool getGpgIdDetails(const std::string &id, std::string &gpgName, std::string &gpgEmail);
|
||||
|
||||
virtual bool updateIdentity(RsIdData &data);
|
||||
virtual bool updateOpinion(RsIdOpinion &opinion);
|
||||
|
||||
virtual void generateDummyData();
|
||||
|
||||
private:
|
||||
|
||||
std::string genRandomId();
|
||||
|
||||
RsMutex mIdMtx;
|
||||
|
||||
/***** below here is locked *****/
|
||||
|
||||
bool mUpdated;
|
||||
|
||||
std::map<std::string, RsIdData> mIds;
|
||||
std::map<std::string, std::map<std::string, RsIdOpinion> > mOpinions;
|
||||
|
||||
std::map<std::string, RsIdReputation> mReputations; // this is created locally.
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user