2012-02-13 13:22:35 -05:00
|
|
|
#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
|
2012-10-14 14:32:33 -04:00
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
2012-02-13 13:22:35 -05:00
|
|
|
*
|
|
|
|
* 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>
|
2012-10-14 14:32:33 -04:00
|
|
|
#include "rsgxsservice.h"
|
2012-06-08 09:52:32 -04:00
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
/* 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);
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
class RsIdGroup
|
2012-02-13 13:22:35 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
RsGroupMetaData mMeta;
|
|
|
|
|
|
|
|
// In GroupMetaData.
|
|
|
|
//std::string mNickname; (mGroupName)
|
|
|
|
//std::string mKeyId; (mGroupId)
|
2012-02-13 13:22:35 -05:00
|
|
|
|
|
|
|
uint32_t mIdType;
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
// SHA(KeyId + Gpg Fingerprint) -> can only be IDed if GPG known.
|
|
|
|
// The length of the input must be long enough to make brute force search implausible.
|
|
|
|
|
|
|
|
// Easy to do 1e9 SHA-1 hash computations per second on a GPU.
|
|
|
|
// We will need a minimum of 256 bits, ideally 1024 bits or 2048 bits.
|
|
|
|
|
|
|
|
std::string mGpgIdHash;
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
// NOTE: These cannot be transmitted as part of underlying messages....
|
|
|
|
// Must use ServiceString.
|
2012-02-13 13:22:35 -05:00
|
|
|
bool mGpgIdKnown; // if GpgIdHash has been identified.
|
|
|
|
std::string mGpgId; // if known.
|
|
|
|
std::string mGpgName; // if known.
|
|
|
|
std::string mGpgEmail; // if known.
|
|
|
|
};
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
class RsIdMsg
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsMsgMetaData mMeta;
|
|
|
|
|
|
|
|
// In MsgMetaData.
|
|
|
|
//std::string mKeyId; (mGroupId)
|
|
|
|
//std::string mPeerId; (mAuthorId) ???
|
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
int mOpinion;
|
|
|
|
double mReputation;
|
|
|
|
//int mRating;
|
|
|
|
//int mPeersRating;
|
|
|
|
//std::string mComment;
|
2012-06-13 20:27:28 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
std::ostream &operator<<(std::ostream &out, const RsIdGroup &meta);
|
|
|
|
std::ostream &operator<<(std::ostream &out, const RsIdMsg &meta);
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
typedef std::map<RsGxsGroupId, std::vector<RsIdMsg> > IdMsgResult;
|
2012-07-29 09:09:36 -04:00
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
#if 0
|
2012-02-13 13:22:35 -05:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
#endif
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
class RsIdentity: public RsGxsIfaceImpl
|
2012-02-13 13:22:35 -05:00
|
|
|
{
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
RsIdentity(RsGenExchange *gxs): RsGxsIfaceImpl(gxs) { return; }
|
|
|
|
virtual ~RsIdentity() { return; }
|
|
|
|
|
|
|
|
/* Specific Service Data */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param token token to be redeemed for album request
|
|
|
|
* @param album the album returned for given request token
|
|
|
|
* @return false if request token is invalid, check token status for error report
|
|
|
|
*/
|
|
|
|
// virtual bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &album) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param token token to be redeemed for photo request
|
|
|
|
* @param photo the photo returned for given request token
|
|
|
|
* @return false if request token is invalid, check token status for error report
|
|
|
|
*/
|
|
|
|
// virtual bool getPhoto(const uint32_t &token,
|
|
|
|
// PhotoResult &photo) = 0;
|
|
|
|
|
|
|
|
/* details are updated in album - to choose Album ID, and storage path */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param token token to be redeemed for photo request
|
|
|
|
* @param photo the photo returned for given request token
|
|
|
|
* @return false if request token is invalid, check token status for error report
|
|
|
|
*/
|
|
|
|
// virtual bool getPhotoComment(const uint32_t &token,
|
|
|
|
// PhotoCommentResult& comments) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* submits album, which returns a token that needs
|
|
|
|
* to be acknowledge to get album grp id
|
|
|
|
* @param token token to redeem for acknowledgement
|
|
|
|
* @param album album to be submitted
|
|
|
|
*/
|
|
|
|
// virtual bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* submits photo, which returns a token that needs
|
|
|
|
* to be acknowledged to get photo msg-grp id pair
|
|
|
|
* @param token token to redeem for acknowledgement
|
|
|
|
* @param photo photo to be submitted
|
|
|
|
*/
|
|
|
|
// virtual bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* submits photo comment, which returns a token that needs
|
|
|
|
* to be acknowledged to get photo msg-grp id pair
|
|
|
|
* The mParentId needs to be set to an existing msg for which
|
|
|
|
* commenting is enabled
|
|
|
|
* @param token token to redeem for acknowledgement
|
|
|
|
* @param comment comment to be submitted
|
|
|
|
*/
|
|
|
|
// virtual bool submitComment(uint32_t& token, RsPhotoComment &photo) = 0;
|
|
|
|
|
|
|
|
/********************************************************************************************/
|
|
|
|
/********************************************************************************************/
|
|
|
|
/********************************************************************************************/
|
|
|
|
/********************************************************************************************/
|
|
|
|
/********************************************************************************************/
|
|
|
|
|
|
|
|
// For Other Services....
|
|
|
|
// It should be impossible for them to get a message which we don't have the identity.
|
|
|
|
// Its a major error if we don't have the identity.
|
|
|
|
|
|
|
|
// We cache all identities, and provide alternative (instantaneous)
|
|
|
|
// functions to extract info, rather than the standard Token system.
|
|
|
|
|
|
|
|
virtual bool getNickname(const RsId &id, std::string &nickname) = 0;
|
|
|
|
virtual bool getIdDetails(const RsId &id, RsIdentityDetails &details) = 0;
|
|
|
|
virtual bool getOwnIds(std::list<RsId> &ownIds) = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
virtual bool submitOpinion(uint32_t& token, RsIdOpinion &opinion) = 0;
|
|
|
|
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Specific RsIdentity Functions....
|
2012-06-13 20:27:28 -04:00
|
|
|
/* Specific Service Data */
|
2012-10-14 14:32:33 -04:00
|
|
|
//virtual bool getGroupData(const uint32_t &token, RsIdGroup &group) = 0;
|
|
|
|
//virtual bool getMsgData(const uint32_t &token, RsIdMsg &msg) = 0;
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
//virtual bool createGroup(uint32_t &token, RsIdGroup &group, bool isNew) = 0;
|
|
|
|
//virtual bool createMsg(uint32_t &token, RsIdMsg &msg, bool isNew) = 0;
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
/* In the Identity System - You don't access the Messages Directly.
|
|
|
|
* as they represent idividuals opinions....
|
|
|
|
* This is reflected in the TokenService calls returning false.
|
|
|
|
*
|
|
|
|
* Below is the additional interface to look at reputation.
|
|
|
|
*/
|
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
/* So we will want to cache much of the identity stuff, so that we have quick access to the results.
|
|
|
|
* The following bits of data will not use the request/response interface, and should be available immediately.
|
|
|
|
*
|
|
|
|
* ID => Nickname, knownGPG, reputation.
|
|
|
|
*
|
|
|
|
* This will require quite a bit of data...
|
|
|
|
* 20 Bytes + 50 + 1 + 4 Bytes? (< 100 Bytes).
|
|
|
|
* x 10,000 IDs. => ~1 MB of cache (Good).
|
|
|
|
* x 100,000 IDs. => ~10 MB of cache (Good).
|
|
|
|
* x 1,000,000 IDs. => ~100 MB of cache (Too Big).
|
|
|
|
*
|
|
|
|
* We also need to store quick access to your OwnIds.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//virtual uint32_t getIdDetails(const std::string &id, std::string &nickname, bool &isGpgKnown,
|
2012-07-30 07:35:26 -04:00
|
|
|
// uint32_t &ownOpinion, float &reputation);
|
2012-07-29 09:09:36 -04:00
|
|
|
//virtual uint32_t getOwnIds(std::list<std::string> &ownIds);
|
|
|
|
//virtual bool setOpinion(const std::string &id, uint32_t opinion);
|
|
|
|
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
virtual void generateDummyData() = 0;
|
|
|
|
|
|
|
|
#if 0
|
2012-07-29 09:09:36 -04:00
|
|
|
|
2012-06-07 13:10:47 -04:00
|
|
|
/* 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;
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-06-07 13:10:47 -04:00
|
|
|
/* Poll */
|
|
|
|
virtual uint32_t requestStatus(const uint32_t token) = 0;
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-06-07 13:10:47 -04:00
|
|
|
/* 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;
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-06-07 13:10:47 -04:00
|
|
|
/* Updates */
|
2012-02-13 13:22:35 -05:00
|
|
|
virtual bool updateIdentity(RsIdData &data) = 0;
|
|
|
|
virtual bool updateOpinion(RsIdOpinion &opinion) = 0;
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
#endif
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
};
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
#endif // RETROSHARE_IDENTITY_GUI_INTERFACE_H
|