mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Changed the RsIdentity GUI Interface from sync to async calls.
Added p3GsxService which provides example utility functions (to be incorporated in GXS at some point) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5199 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fb044baa26
commit
d29f158a66
@ -683,11 +683,13 @@ HEADERS += services/p3photoservice.h \
|
||||
retroshare/rswiki.h \
|
||||
services/p3idservice.h \
|
||||
retroshare/rsidentity.h \
|
||||
services/p3gxsservice.h \
|
||||
|
||||
SOURCES += services/p3photoservice.cc \
|
||||
serialiser/rsphotoitems.cc \
|
||||
services/p3wikiservice.cc \
|
||||
services/p3idservice.cc \
|
||||
services/p3gxsservice.cc \
|
||||
|
||||
# Other Old Code.
|
||||
# rsserver/p3photo.cc \
|
||||
|
@ -98,22 +98,33 @@ class RsIdentity
|
||||
RsIdentity() { return; }
|
||||
virtual ~RsIdentity() { return; }
|
||||
|
||||
/* changed? */
|
||||
|
||||
/* changed? */
|
||||
virtual bool updated() = 0;
|
||||
|
||||
/* Interface now a request / poll / answer system */
|
||||
|
||||
virtual bool getIdentityList(std::list<std::string> &ids) = 0;
|
||||
/* Data Requests */
|
||||
virtual bool requestIdentityList(uint32_t &token) = 0;
|
||||
virtual bool requestIdentities(uint32_t &token, const std::list<std::string> &ids) = 0;
|
||||
virtual bool requestIdReputations(uint32_t &token, const std::list<std::string> &ids) = 0;
|
||||
virtual bool requestIdPeerOpinion(uint32_t &token, const std::string &aboutId, const std::string &peerId) = 0;
|
||||
//virtual bool requestIdGpgDetails(uint32_t &token, const 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;
|
||||
/* Poll */
|
||||
virtual uint32_t requestStatus(const uint32_t token) = 0;
|
||||
|
||||
virtual bool getGpgIdDetails(const std::string &id, std::string &gpgName, std::string &gpgEmail) = 0;
|
||||
/* Retrieve Data */
|
||||
virtual bool getIdentityList(const uint32_t token, std::list<std::string> &ids) = 0;
|
||||
virtual bool getIdentity(const uint32_t token, RsIdData &data) = 0;
|
||||
virtual bool getIdReputation(const uint32_t token, RsIdReputation &reputation) = 0;
|
||||
virtual bool getIdPeerOpinion(const uint32_t token, RsIdOpinion &opinion) = 0;
|
||||
|
||||
/* details are updated in group - to choose GroupID */
|
||||
/* Updates */
|
||||
virtual bool updateIdentity(RsIdData &data) = 0;
|
||||
virtual bool updateOpinion(RsIdOpinion &opinion) = 0;
|
||||
|
||||
/* TEMP */
|
||||
virtual void generateDummyData() = 0;
|
||||
};
|
||||
|
||||
|
195
libretroshare/src/services/p3gxsservice.cc
Normal file
195
libretroshare/src/services/p3gxsservice.cc
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* libretroshare/src/services p3gxsservice.cc
|
||||
*
|
||||
* Generic Service Support Class for RetroShare.
|
||||
*
|
||||
* Copyright 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/p3gxsservice.h"
|
||||
|
||||
p3GxsService::p3GxsService(uint16_t type)
|
||||
:p3Service(type), mReqMtx("p3GxsService")
|
||||
{
|
||||
mNextToken = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
bool p3GxsService::generateToken(uint32_t &token)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
token = mNextToken++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsService::storeRequest(const uint32_t &token, const uint32_t &type, const std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
gxsRequest req;
|
||||
req.token = token;
|
||||
req.reqTime = time(NULL);
|
||||
req.reqType = type;
|
||||
req.status = GXS_REQUEST_STATUS_PENDING;
|
||||
req.IdList = ids;
|
||||
|
||||
mRequests[token] = req;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool p3GxsService::clearRequest(const uint32_t &token)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
it = mRequests.find(token);
|
||||
if (it == mRequests.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mRequests.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsService::updateRequestStatus(const uint32_t &token, const uint32_t &status)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
it = mRequests.find(token);
|
||||
if (it == mRequests.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
it->second.status = status;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsService::updateRequestList(const uint32_t &token, std::list<std::string> ids)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
it = mRequests.find(token);
|
||||
if (it == mRequests.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<std::string>::iterator iit;
|
||||
for(iit = ids.begin(); iit != ids.end(); iit++)
|
||||
{
|
||||
it->second.IdList.push_back(*iit);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsService::updateRequestData(const uint32_t &token, std::map<std::string, void *> data)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
it = mRequests.find(token);
|
||||
if (it == mRequests.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<std::string, void *>::iterator dit;
|
||||
for(dit = data.begin(); dit != data.end(); dit++)
|
||||
{
|
||||
it->second.readyData[dit->first] = dit->second;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsService::checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, time_t &ts)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
it = mRequests.find(token);
|
||||
if (it == mRequests.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
status = it->second.status;
|
||||
reqtype = it->second.reqType;
|
||||
ts = it->second.reqTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// special ones for testing (not in final design)
|
||||
bool p3GxsService::tokenList(std::list<uint32_t> &tokens)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
for(it = mRequests.begin(); it != mRequests.end(); it++)
|
||||
{
|
||||
tokens.push_back(it->first);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsService::popRequestList(const uint32_t &token, std::string &id)
|
||||
{
|
||||
RsStackMutex stack(mReqMtx); /****** LOCKED *****/
|
||||
|
||||
std::map<uint32_t, gxsRequest>::iterator it;
|
||||
|
||||
it = mRequests.find(token);
|
||||
if (it == mRequests.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (it->second.IdList.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
id = it->second.IdList.front();
|
||||
it->second.IdList.pop_front();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
100
libretroshare/src/services/p3gxsservice.h
Normal file
100
libretroshare/src/services/p3gxsservice.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* libretroshare/src/services p3gxsservice.h
|
||||
*
|
||||
* Generic Service Support Class for RetroShare.
|
||||
*
|
||||
* Copyright 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_GXS_SERVICE_HEADER
|
||||
#define P3_GXS_SERVICE_HEADER
|
||||
|
||||
#include "services/p3service.h"
|
||||
|
||||
/*
|
||||
* This class provides useful generic support for GXS style services.
|
||||
* I expect much of this will be incorporated into the base GXS.
|
||||
*
|
||||
*/
|
||||
|
||||
#define GXS_REQUEST_STATUS_FAILED 0
|
||||
#define GXS_REQUEST_STATUS_PENDING 1
|
||||
#define GXS_REQUEST_STATUS_PARTIAL 2
|
||||
#define GXS_REQUEST_STATUS_FINISHED_INCOMPLETE 3
|
||||
#define GXS_REQUEST_STATUS_COMPLETE 4
|
||||
#define GXS_REQUEST_STATUS_DONE 5 // ONCE ALL DATA RETRIEVED.
|
||||
|
||||
#define GXS_REQUEST_TYPE_LIST 0x00010000
|
||||
#define GXS_REQUEST_TYPE_DATA 0x00020000
|
||||
|
||||
#define GXS_REQUEST_TYPE_GROUPS 0x01000000
|
||||
#define GXS_REQUEST_TYPE_MSGS 0x02000000
|
||||
|
||||
class gxsRequest
|
||||
{
|
||||
public:
|
||||
uint32_t token;
|
||||
uint32_t reqTime;
|
||||
uint32_t reqType; /* specific to service */
|
||||
uint32_t status;
|
||||
|
||||
std::list<std::string> IdList;
|
||||
std::map<std::string, void *> readyData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class p3GxsService: public p3Service
|
||||
{
|
||||
protected:
|
||||
|
||||
p3GxsService(uint16_t type);
|
||||
|
||||
public:
|
||||
|
||||
//virtual ~p3Service() { p3Service::~p3Service(); return; }
|
||||
|
||||
bool generateToken(uint32_t &token);
|
||||
bool storeRequest(const uint32_t &token, const uint32_t &type, const std::list<std::string> &ids);
|
||||
bool clearRequest(const uint32_t &token);
|
||||
|
||||
bool updateRequestStatus(const uint32_t &token, const uint32_t &status);
|
||||
bool updateRequestList(const uint32_t &token, std::list<std::string> ids);
|
||||
bool updateRequestData(const uint32_t &token, std::map<std::string, void *> data);
|
||||
bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &reqtype, time_t &ts);
|
||||
|
||||
// special ones for testing (not in final design)
|
||||
bool tokenList(std::list<uint32_t> &tokens);
|
||||
bool popRequestList(const uint32_t &token, std::string &id);
|
||||
|
||||
private:
|
||||
|
||||
RsMutex mReqMtx;
|
||||
|
||||
uint32_t mNextToken;
|
||||
|
||||
std::map<uint32_t, gxsRequest> mRequests;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // P3_GXS_SERVICE_HEADER
|
||||
|
@ -33,11 +33,16 @@
|
||||
* #define ID_DEBUG 1
|
||||
****/
|
||||
|
||||
#define ID_REQUEST_LIST 0x0001
|
||||
#define ID_REQUEST_IDENTITY 0x0002
|
||||
#define ID_REQUEST_REPUTATION 0x0003
|
||||
#define ID_REQUEST_OPINION 0x0004
|
||||
|
||||
RsIdentity *rsIdentity = NULL;
|
||||
|
||||
|
||||
p3IdService::p3IdService(uint16_t type)
|
||||
:p3Service(type), mIdMtx("p3IdService"), mUpdated(true)
|
||||
:p3GxsService(type), mIdMtx("p3IdService"), mUpdated(true)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
return;
|
||||
@ -49,6 +54,8 @@ int p3IdService::tick()
|
||||
std::cerr << "p3IdService::tick()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
fakeprocessrequests();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -64,6 +71,252 @@ bool p3IdService::updated()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Data Requests */
|
||||
bool p3IdService::requestIdentityList(uint32_t &token)
|
||||
{
|
||||
generateToken(token);
|
||||
std::list<std::string> ids;
|
||||
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_GROUPS | ID_REQUEST_LIST, ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::requestIdentities(uint32_t &token, const std::list<std::string> &ids)
|
||||
{
|
||||
generateToken(token);
|
||||
storeRequest(token, GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_GROUPS | ID_REQUEST_IDENTITY, ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::requestIdReputations(uint32_t &token, const std::list<std::string> &ids)
|
||||
{
|
||||
generateToken(token);
|
||||
|
||||
// request msg Ids from Groups.
|
||||
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | ID_REQUEST_REPUTATION, ids);
|
||||
|
||||
// Once they arrive, we need to get the Messages to workout reputation.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::requestIdPeerOpinion(uint32_t &token, const std::string &aboutId, const std::string &peerId)
|
||||
{
|
||||
generateToken(token);
|
||||
|
||||
// request msg Ids from Groups.
|
||||
std::list<std::string> ids;
|
||||
ids.push_back(aboutId);
|
||||
ids.push_back(peerId);
|
||||
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | ID_REQUEST_OPINION, ids);
|
||||
|
||||
// Once they arrive, we search through the message to find the exact need to get the Messages to workout reputation.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Poll */
|
||||
uint32_t p3IdService::requestStatus(const uint32_t token)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, ts);
|
||||
|
||||
/* handle cases which need multiple steps */
|
||||
if (reqtype & ID_REQUEST_OPINION)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (reqtype & ID_REQUEST_REPUTATION)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve Data */
|
||||
/* For the moment, these don't get real data, just check if the request has been deemed completed
|
||||
*/
|
||||
bool p3IdService::getIdentityList(const uint32_t token, std::list<std::string> &ids)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, ts);
|
||||
|
||||
if (reqtype != (GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_GROUPS | ID_REQUEST_LIST))
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ans = InternalgetIdentityList(ids);
|
||||
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdentity(const uint32_t token, RsIdData &data)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, ts);
|
||||
|
||||
if (reqtype != (GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_GROUPS | ID_REQUEST_IDENTITY))
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string id;
|
||||
if (!popRequestList(token, id))
|
||||
{
|
||||
/* finished */
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ans = InternalgetIdentity(id, data);
|
||||
return ans;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdReputation(const uint32_t token, RsIdReputation &reputation)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, ts);
|
||||
|
||||
if (reqtype != (GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | ID_REQUEST_REPUTATION))
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string id;
|
||||
if (!popRequestList(token, id))
|
||||
{
|
||||
/* finished */
|
||||
std::cerr << "p3IdService::getIdReputation() List Fully Popped" << std::endl;
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ans = InternalgetIdReputation(id, reputation);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
bool p3IdService::getIdPeerOpinion(const uint32_t token, RsIdOpinion &opinion)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, ts);
|
||||
|
||||
if (reqtype != (GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | ID_REQUEST_OPINION))
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != GXS_REQUEST_STATUS_COMPLETE)
|
||||
{
|
||||
std::cerr << "p3IdService ERROR" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string aboutid;
|
||||
std::string peerid;
|
||||
popRequestList(token, aboutid);
|
||||
popRequestList(token, peerid);
|
||||
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
|
||||
|
||||
bool ans = InternalgetIdPeerOpinion(aboutid, peerid, opinion);
|
||||
return ans;
|
||||
|
||||
}
|
||||
|
||||
#define MAX_REQUEST_AGE 60
|
||||
|
||||
bool p3IdService::fakeprocessrequests()
|
||||
{
|
||||
std::list<uint32_t>::iterator it;
|
||||
std::list<uint32_t> tokens;
|
||||
|
||||
tokenList(tokens);
|
||||
|
||||
time_t now = time(NULL);
|
||||
for(it = tokens.begin(); it != tokens.end(); it++)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t reqtype;
|
||||
uint32_t token = *it;
|
||||
time_t ts;
|
||||
checkRequestStatus(token, status, reqtype, ts);
|
||||
|
||||
std::cerr << "p3IdService::fakeprocessrequests() Token: " << token << " Status: " << status << " ReqType: " << reqtype << "Age: " << now - ts << std::endl;
|
||||
|
||||
if (status == GXS_REQUEST_STATUS_PENDING)
|
||||
{
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_PARTIAL);
|
||||
}
|
||||
else if (status == GXS_REQUEST_STATUS_PARTIAL)
|
||||
{
|
||||
updateRequestStatus(token, GXS_REQUEST_STATUS_COMPLETE);
|
||||
}
|
||||
else if (status == GXS_REQUEST_STATUS_DONE)
|
||||
{
|
||||
std::cerr << "p3IdService::fakeprocessrequests() Clearing Done Request Token: " << token;
|
||||
std::cerr << std::endl;
|
||||
clearRequest(token);
|
||||
}
|
||||
else if (now - ts > MAX_REQUEST_AGE)
|
||||
{
|
||||
std::cerr << "p3IdService::fakeprocessrequests() Clearing Old Request Token: " << token;
|
||||
std::cerr << std::endl;
|
||||
clearRequest(token);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
bool p3IdService::getGpgIdDetails(const std::string &id, std::string &gpgName, std::string &gpgEmail)
|
||||
{
|
||||
gpgName = "aGpgName";
|
||||
@ -72,7 +325,9 @@ bool p3IdService::getGpgIdDetails(const std::string &id, std::string &gpgName, s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdentityList(std::list<std::string> &ids)
|
||||
#endif
|
||||
|
||||
bool p3IdService::InternalgetIdentityList(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -85,7 +340,7 @@ bool p3IdService::getIdentityList(std::list<std::string> &ids)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdentity(const std::string &id, RsIdData &data)
|
||||
bool p3IdService::InternalgetIdentity(const std::string &id, RsIdData &data)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -100,7 +355,7 @@ bool p3IdService::getIdentity(const std::string &id, RsIdData &data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3IdService::getIdReputation(const std::string &id, RsIdReputation &reputation)
|
||||
bool p3IdService::InternalgetIdReputation(const std::string &id, RsIdReputation &reputation)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -116,7 +371,7 @@ bool p3IdService::getIdReputation(const std::string &id, RsIdReputation &reputat
|
||||
}
|
||||
|
||||
|
||||
bool p3IdService::getIdPeerOpinion(const std::string &aboutid, const std::string &peerId, RsIdOpinion &opinion)
|
||||
bool p3IdService::InternalgetIdPeerOpinion(const std::string &aboutid, const std::string &peerId, RsIdOpinion &opinion)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define P3_IDENTITY_SERVICE_HEADER
|
||||
|
||||
#include "services/p3service.h"
|
||||
#include "services/p3gxsservice.h"
|
||||
|
||||
#include "retroshare/rsidentity.h"
|
||||
|
||||
@ -34,11 +35,12 @@
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Indentity Service
|
||||
* Identity Service
|
||||
*
|
||||
*/
|
||||
|
||||
class p3IdService: public p3Service, public RsIdentity
|
||||
|
||||
class p3IdService: public p3GxsService, public RsIdentity
|
||||
{
|
||||
public:
|
||||
|
||||
@ -48,6 +50,44 @@ virtual int tick();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/* changed? */
|
||||
virtual bool updated();
|
||||
|
||||
/* Interface now a request / poll / answer system */
|
||||
|
||||
/* Data Requests */
|
||||
virtual bool requestIdentityList(uint32_t &token);
|
||||
virtual bool requestIdentities(uint32_t &token, const std::list<std::string> &ids);
|
||||
virtual bool requestIdReputations(uint32_t &token, const std::list<std::string> &ids);
|
||||
virtual bool requestIdPeerOpinion(uint32_t &token, const std::string &aboutId, const std::string &peerId);
|
||||
//virtual bool requestIdGpgDetails(uint32_t &token, const std::list<std::string> &ids);
|
||||
|
||||
/* Poll */
|
||||
virtual uint32_t requestStatus(const uint32_t token);
|
||||
|
||||
/* Retrieve Data */
|
||||
virtual bool getIdentityList(const uint32_t token, std::list<std::string> &ids);
|
||||
virtual bool getIdentity(const uint32_t token, RsIdData &data);
|
||||
virtual bool getIdReputation(const uint32_t token, RsIdReputation &reputation);
|
||||
virtual bool getIdPeerOpinion(const uint32_t token, RsIdOpinion &opinion);
|
||||
//virtual bool getIdGpgDetails(const uint32_t token, RsIdGpgDetails &gpgData);
|
||||
|
||||
/* Updates */
|
||||
virtual bool updateIdentity(RsIdData &data);
|
||||
virtual bool updateOpinion(RsIdOpinion &opinion);
|
||||
|
||||
|
||||
|
||||
/* below here not part of the interface */
|
||||
bool fakeprocessrequests();
|
||||
|
||||
virtual bool InternalgetIdentityList(std::list<std::string> &ids);
|
||||
virtual bool InternalgetIdentity(const std::string &id, RsIdData &data);
|
||||
virtual bool InternalgetIdReputation(const std::string &id, RsIdReputation &reputation);
|
||||
virtual bool InternalgetIdPeerOpinion(const std::string &aboutid, const std::string &peerid, RsIdOpinion &opinion);
|
||||
|
||||
#if 0
|
||||
/* changed? */
|
||||
virtual bool updated();
|
||||
|
||||
@ -62,6 +102,8 @@ virtual bool getGpgIdDetails(const std::string &id, std::string &gpgName, std::s
|
||||
virtual bool updateIdentity(RsIdData &data);
|
||||
virtual bool updateOpinion(RsIdOpinion &opinion);
|
||||
|
||||
#endif
|
||||
|
||||
virtual void generateDummyData();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user