mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 23:45:49 -04:00
Added Identity Info retrieval to rsIdentities.
This is now pretty much complete for Phase 1 of GXS. Still todo: - PGPHash signatures. - Reputations. - Added two helper classes GxsTokenQueue: similar to TokenQueue, but for libretroshare & RsTickEvent: schedule one shot events, and basic stats. - Reorganised/simplified p3IdService using these two classes. - Added fns to load/reload a list of Own Identities. - Improved the Cache to store all GUI required Info. - Updater retroshare/rsidentity.h with new Identity interface. - added fns to update Cache from internal background tasks. - Modified RsMemCache to support replace operation. - Found nasty Bug that caused PGPHASHes not to match & Patched same bug in GXS. - added generic CacheArbitration. - Added AuthorIds to dummy Forum messages. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5848 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6e349749d0
commit
c6e6d444bf
13 changed files with 1096 additions and 491 deletions
95
libretroshare/src/gxs/gxstokenqueue.cc
Normal file
95
libretroshare/src/gxs/gxstokenqueue.cc
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* libretroshare/src/gxs gxstokenqueue.cc
|
||||
*
|
||||
* Gxs Support 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.1 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 "gxs/gxstokenqueue.h"
|
||||
|
||||
bool GxsTokenQueue::queueRequest(uint32_t token, uint32_t req_type)
|
||||
{
|
||||
RsStackMutex stack(mQueueMtx); /********** STACK LOCKED MTX ******/
|
||||
mQueue.push_back(GxsTokenQueueItem(token, req_type));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GxsTokenQueue::checkRequests()
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mQueueMtx); /********** STACK LOCKED MTX ******/
|
||||
if (mQueue.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Must check all, and move to a different list - for reentrant / good mutex behaviour.
|
||||
std::list<GxsTokenQueueItem> toload;
|
||||
std::list<GxsTokenQueueItem>::iterator it;
|
||||
|
||||
bool stuffToLoad = false;
|
||||
{
|
||||
RsStackMutex stack(mQueueMtx); /********** STACK LOCKED MTX ******/
|
||||
for(it = mQueue.begin(); it != mQueue.end();)
|
||||
{
|
||||
uint32_t token = it->mToken;
|
||||
uint32_t status = mGenExchange->getTokenService()->requestStatus(token);
|
||||
|
||||
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
toload.push_back(*it);
|
||||
it = mQueue.erase(it);
|
||||
stuffToLoad = true;
|
||||
}
|
||||
else if (status == RsTokenService::GXS_REQUEST_V2_STATUS_FAILED)
|
||||
{
|
||||
// maybe we should do alternative callback?
|
||||
std::cerr << "GxsTokenQueue::checkRequests() ERROR Request Failed: " << token;
|
||||
std::cerr << std::endl;
|
||||
|
||||
it = mQueue.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stuffToLoad)
|
||||
{
|
||||
for(it = toload.begin(); it != toload.end(); it++)
|
||||
{
|
||||
handleResponse(it->mToken, it->mReqType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This must be overloaded to complete the functionality.
|
||||
void GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type)
|
||||
{
|
||||
std::cerr << "GxsTokenQueue::handleResponse(" << token << "," << req_type << ") ERROR: NOT HANDLED";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
|
71
libretroshare/src/gxs/gxstokenqueue.h
Normal file
71
libretroshare/src/gxs/gxstokenqueue.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef R_GXS_TOKEN_QUEUE_H
|
||||
#define R_GXS_TOKEN_QUEUE_H
|
||||
/*
|
||||
* libretroshare/src/gxs gxstokenqueue.h
|
||||
*
|
||||
* Gxs Support 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.1 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 "gxs/rsgenexchange.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* A little helper class, to manage callbacks from requests
|
||||
*
|
||||
*/
|
||||
|
||||
class GxsTokenQueueItem
|
||||
{
|
||||
public:
|
||||
GxsTokenQueueItem(const uint32_t token, const uint32_t req_type)
|
||||
:mToken(token),mReqType(req_type) { return; }
|
||||
|
||||
GxsTokenQueueItem(): mToken(0), mReqType(0) { return; }
|
||||
|
||||
uint32_t mToken;
|
||||
uint32_t mReqType;
|
||||
};
|
||||
|
||||
|
||||
class GxsTokenQueue
|
||||
{
|
||||
public:
|
||||
|
||||
GxsTokenQueue(RsGenExchange *gxs)
|
||||
:mGenExchange(gxs), mQueueMtx("GxsTokenQueueMtx") { return; }
|
||||
bool queueRequest(uint32_t token, uint32_t req_type);
|
||||
|
||||
void checkRequests(); // must be called by
|
||||
|
||||
// This must be overloaded to complete the functionality.
|
||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||
|
||||
private:
|
||||
RsGenExchange *mGenExchange;
|
||||
RsMutex mQueueMtx;
|
||||
std::list<GxsTokenQueueItem> mQueue;
|
||||
};
|
||||
|
||||
|
||||
#endif //R_GXS_TOKEN_QUEUE_H
|
|
@ -396,7 +396,7 @@ bool RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBina
|
|||
for(; mit != mit_end; mit++)
|
||||
{
|
||||
|
||||
pub_key_found = mit->second.keyFlags & (RSTLV_KEY_DISTRIB_PRIVATE | RSTLV_KEY_TYPE_FULL);
|
||||
pub_key_found = mit->second.keyFlags == (RSTLV_KEY_DISTRIB_PRIVATE | RSTLV_KEY_TYPE_FULL);
|
||||
if(pub_key_found)
|
||||
break;
|
||||
}
|
||||
|
@ -1342,7 +1342,7 @@ void RsGenExchange::publishGrps()
|
|||
{
|
||||
RsTlvSecurityKey& key = mit_keys->second;
|
||||
|
||||
if(key.keyFlags & (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
|
||||
if(key.keyFlags == (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
|
||||
{
|
||||
privAdminKey = key;
|
||||
privKeyFound = true;
|
||||
|
@ -1493,7 +1493,7 @@ void RsGenExchange::createDummyGroup(RsGxsGrpItem *grpItem)
|
|||
{
|
||||
RsTlvSecurityKey& key = mit_keys->second;
|
||||
|
||||
if(key.keyFlags & (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
|
||||
if(key.keyFlags == (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
|
||||
{
|
||||
privAdminKey = key;
|
||||
privKeyFound = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue