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-21 11:48:18 -04:00
|
|
|
|
2013-03-06 18:33:23 -05:00
|
|
|
#include "retroshare/rstokenservice.h"
|
2013-02-28 16:58:38 -05:00
|
|
|
#include "retroshare/rsgxsifacehelper.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;
|
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
|
|
|
|
// GroupFlags: Only one so far:
|
|
|
|
#define RSGXSID_GROUPFLAG_REALID 0x0001
|
|
|
|
|
|
|
|
|
|
|
|
// THESE ARE FLAGS FOR INTERFACE.
|
2012-02-13 13:22:35 -05:00
|
|
|
#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-10-21 11:48:18 -04:00
|
|
|
class RsGxsIdGroup
|
2012-02-13 13:22:35 -05:00
|
|
|
{
|
|
|
|
public:
|
2012-11-06 14:18:11 -05:00
|
|
|
RsGxsIdGroup():mPgpKnown(false) { return; }
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
RsGroupMetaData mMeta;
|
|
|
|
|
|
|
|
// In GroupMetaData.
|
|
|
|
//std::string mNickname; (mGroupName)
|
|
|
|
//std::string mKeyId; (mGroupId)
|
2012-11-05 17:28:08 -05:00
|
|
|
//uint32_t mIdType; (mGroupFlags)
|
2012-02-13 13:22:35 -05:00
|
|
|
|
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.
|
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
// Actually PgpIdHash is SHA1(.mMeta.mGroupId + PGPHandler->GpgFingerprint(ownId))
|
|
|
|
// ??? 160 bits.
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
std::string mPgpIdHash;
|
|
|
|
std::string mPgpIdSign; // Need a signature as proof - otherwise anyone could add others Hashes.
|
2012-11-06 14:18:11 -05:00
|
|
|
|
2012-11-29 17:48:28 -05:00
|
|
|
// Not Serialised - for GUI's benefit.
|
2012-11-06 14:18:11 -05:00
|
|
|
bool mPgpKnown;
|
|
|
|
std::string mPgpId;
|
2012-02-13 13:22:35 -05:00
|
|
|
};
|
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
class RsGxsIdOpinion
|
2012-06-13 20:27:28 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsMsgMetaData mMeta;
|
|
|
|
|
|
|
|
// In MsgMetaData.
|
|
|
|
//std::string mKeyId; (mGroupId)
|
|
|
|
//std::string mPeerId; (mAuthorId) ???
|
|
|
|
|
2012-10-28 19:13:15 -04:00
|
|
|
uint32_t mOpinion;
|
|
|
|
|
|
|
|
|
|
|
|
// NOT SERIALISED YET!
|
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
double mReputation;
|
|
|
|
//int mRating;
|
|
|
|
//int mPeersRating;
|
|
|
|
//std::string mComment;
|
2012-06-13 20:27:28 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
// This will probably be dropped.
|
|
|
|
class RsGxsIdComment
|
|
|
|
{
|
|
|
|
public:
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
RsMsgMetaData mMeta;
|
|
|
|
std::string mComment;
|
|
|
|
};
|
2012-07-29 09:09:36 -04:00
|
|
|
|
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &group);
|
|
|
|
std::ostream &operator<<(std::ostream &out, const RsGxsIdOpinion &msg);
|
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-21 11:48:18 -04:00
|
|
|
// DATA TYPE FOR EXTERNAL INTERFACE.
|
|
|
|
|
|
|
|
typedef std::string RsGxsId; // TMP. =>
|
|
|
|
|
|
|
|
class RsIdentityDetails
|
|
|
|
{
|
|
|
|
public:
|
2012-11-19 17:00:05 -05:00
|
|
|
RsIdentityDetails()
|
|
|
|
:mIsOwnId(false), mPgpLinked(false), mPgpKnown(false),
|
|
|
|
mOpinion(0), mReputation(0) { return; }
|
2012-10-21 11:48:18 -04:00
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
RsGxsId mId;
|
2012-10-21 11:48:18 -04:00
|
|
|
|
|
|
|
// identity details.
|
2012-11-19 17:00:05 -05:00
|
|
|
std::string mNickname;
|
|
|
|
bool mIsOwnId;
|
2012-10-21 11:48:18 -04:00
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
// PGP Stuff.
|
|
|
|
bool mPgpLinked;
|
|
|
|
bool mPgpKnown;
|
|
|
|
std::string mPgpId;
|
2012-10-21 11:48:18 -04:00
|
|
|
|
|
|
|
// reputation details.
|
2012-11-19 17:00:05 -05:00
|
|
|
double mOpinion;
|
|
|
|
double mReputation;
|
2012-10-21 11:48:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RsIdOpinion
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGxsId id;
|
|
|
|
int rating;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RsIdentityParameters
|
|
|
|
{
|
|
|
|
public:
|
2012-11-07 16:38:43 -05:00
|
|
|
RsIdentityParameters(): isPgpLinked(false) { return; }
|
|
|
|
bool isPgpLinked;
|
|
|
|
std::string nickname;
|
2012-10-21 11:48:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-02-28 16:58:38 -05:00
|
|
|
class RsIdentity: public RsGxsIfaceHelper
|
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:
|
|
|
|
|
2013-02-28 16:58:38 -05:00
|
|
|
RsIdentity(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) { return; }
|
2012-10-14 14:32:33 -04:00
|
|
|
virtual ~RsIdentity() { return; }
|
|
|
|
|
|
|
|
/********************************************************************************************/
|
|
|
|
/********************************************************************************************/
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
|
2012-10-21 11:48:18 -04:00
|
|
|
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
|
|
|
|
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0;
|
2012-10-14 14:32:33 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
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-21 11:48:18 -04:00
|
|
|
/* We expose these initially for testing / GUI purposes.
|
|
|
|
*/
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-11-30 19:16:24 -05:00
|
|
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
};
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
#endif // RETROSHARE_IDENTITY_GUI_INTERFACE_H
|