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"
|
2015-10-11 21:41:35 -04:00
|
|
|
#include "retroshare/rsreputations.h"
|
2014-03-17 16:56:06 -04:00
|
|
|
#include "retroshare/rsids.h"
|
2015-01-25 17:09:12 -05:00
|
|
|
#include "serialiser/rstlvimage.h"
|
|
|
|
#include "retroshare/rsgxscommon.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
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
#define RSRECOGN_MAX_TAGINFO 5
|
|
|
|
|
2015-05-02 03:57:59 -04:00
|
|
|
// Unicode symbols. NOT utf-8 bytes, because of multi byte characters
|
2015-04-09 15:53:01 -04:00
|
|
|
#define RSID_MAXIMUM_NICKNAME_SIZE 30
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
std::string rsIdTypeToString(uint32_t idtype);
|
|
|
|
|
2015-11-19 21:14:32 -05:00
|
|
|
static const uint32_t RS_IDENTITY_FLAGS_IS_A_CONTACT = 0x0001;
|
|
|
|
static const uint32_t RS_IDENTITY_FLAGS_PGP_LINKED = 0x0002;
|
|
|
|
static const uint32_t RS_IDENTITY_FLAGS_PGP_KNOWN = 0x0004;
|
|
|
|
static const uint32_t RS_IDENTITY_FLAGS_IS_OWN_ID = 0x0008;
|
2016-06-17 22:21:06 -04:00
|
|
|
static const uint32_t RS_IDENTITY_FLAGS_IS_DEPRECATED= 0x0010; // used to denote keys with deprecated fingerprint format.
|
2015-11-19 21:14:32 -05:00
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
class GxsReputation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GxsReputation();
|
|
|
|
|
|
|
|
bool updateIdScore(bool pgpLinked, bool pgpKnown);
|
|
|
|
bool update(); // checks ranges and calculates overall score.
|
|
|
|
int mOverallScore;
|
|
|
|
int mIdScore; // PGP, Known, etc.
|
|
|
|
int mOwnOpinion;
|
|
|
|
int mPeerOpinion;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
class RsGxsIdGroup
|
2012-02-13 13:22:35 -05:00
|
|
|
{
|
|
|
|
public:
|
2016-01-01 22:36:07 -05:00
|
|
|
RsGxsIdGroup(): mLastUsageTS(0), mPgpKnown(false),mIsAContact(false) { return; }
|
2014-04-05 00:48:52 -04:00
|
|
|
~RsGxsIdGroup() { 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
|
|
|
|
2014-04-01 04:00:20 -04:00
|
|
|
Sha1CheckSum mPgpIdHash;
|
|
|
|
// Need a signature as proof - otherwise anyone could add others Hashes.
|
|
|
|
// This is a string, as the length is variable.
|
|
|
|
std::string mPgpIdSign;
|
2012-11-06 14:18:11 -05:00
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
// Recognition Strings. MAX# defined above.
|
|
|
|
std::list<std::string> mRecognTags;
|
|
|
|
|
2015-01-25 17:09:12 -05:00
|
|
|
// Avatar
|
|
|
|
RsGxsImage mImage ;
|
2015-03-14 10:33:23 -04:00
|
|
|
time_t mLastUsageTS ;
|
2015-01-25 17:09:12 -05:00
|
|
|
|
|
|
|
// Not Serialised - for GUI's benefit.
|
2015-12-23 12:08:20 -05:00
|
|
|
bool mPgpKnown;
|
|
|
|
bool mIsAContact; // change that into flags one day
|
|
|
|
RsPgpId mPgpId;
|
2015-01-25 17:09:12 -05:00
|
|
|
GxsReputation mReputation;
|
2012-10-21 11:48:18 -04:00
|
|
|
};
|
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);
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
// DATA TYPE FOR EXTERNAL INTERFACE.
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
class RsRecognTag
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsRecognTag(uint16_t tc, uint16_t tt, bool v)
|
|
|
|
:tag_class(tc), tag_type(tt), valid(v) { return; }
|
|
|
|
uint16_t tag_class;
|
|
|
|
uint16_t tag_type;
|
|
|
|
bool valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RsRecognTagDetails
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsRecognTagDetails()
|
|
|
|
:valid_from(0), valid_to(0), tag_class(0), tag_type(0),
|
|
|
|
is_valid(false), is_pending(false) { return; }
|
|
|
|
|
|
|
|
time_t valid_from;
|
|
|
|
time_t valid_to;
|
|
|
|
uint16_t tag_class;
|
|
|
|
uint16_t tag_type;
|
|
|
|
|
|
|
|
std::string signer;
|
|
|
|
|
|
|
|
bool is_valid;
|
|
|
|
bool is_pending;
|
|
|
|
};
|
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
class RsIdentityDetails
|
|
|
|
{
|
2015-03-14 10:33:23 -04:00
|
|
|
public:
|
|
|
|
RsIdentityDetails()
|
2015-12-05 16:49:00 -05:00
|
|
|
: mFlags(0), mLastUsageTS(0) { return; }
|
2012-10-21 11:48:18 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
RsGxsId mId;
|
2012-10-21 11:48:18 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
// identity details.
|
|
|
|
std::string mNickname;
|
2015-11-19 21:14:32 -05:00
|
|
|
|
|
|
|
uint32_t mFlags ;
|
2012-10-21 11:48:18 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
// PGP Stuff.
|
|
|
|
RsPgpId mPgpId;
|
2012-10-21 11:48:18 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
// Recogn details.
|
|
|
|
std::list<RsRecognTag> mRecognTags;
|
2013-10-20 05:43:30 -04:00
|
|
|
|
2015-10-11 21:41:35 -04:00
|
|
|
// Cyril: Reputation details. At some point we might want to merge information
|
|
|
|
// between the two into a single global score. Since the old reputation system
|
|
|
|
// is not finished yet, I leave this in place. We should decide what to do with it.
|
|
|
|
|
|
|
|
GxsReputation mReputation_oldSystem; // this is the old "mReputation" field, which apparently is not used.
|
|
|
|
RsReputations::ReputationInfo mReputation;
|
2015-01-25 17:09:12 -05:00
|
|
|
|
|
|
|
// avatar
|
|
|
|
RsGxsImage mAvatar ;
|
2015-03-14 10:33:23 -04:00
|
|
|
|
|
|
|
// last usage
|
|
|
|
time_t mLastUsageTS ;
|
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;
|
2015-01-25 17:09:12 -05:00
|
|
|
std::string nickname;
|
|
|
|
RsGxsImage mImage ;
|
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; }
|
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
/********************************************************************************************/
|
|
|
|
/********************************************************************************************/
|
|
|
|
|
|
|
|
// 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.
|
2012-10-14 14:32:33 -04:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
// We cache all identities, and provide alternative (instantaneous)
|
|
|
|
// functions to extract info, rather than the standard Token system.
|
2012-10-14 14:32:33 -04:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
|
|
|
|
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
|
2015-04-18 15:59:27 -04:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
// Fills up list of all own ids. Returns false if ids are not yet loaded.
|
|
|
|
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0;
|
|
|
|
virtual bool isOwnId(const RsGxsId& id) = 0;
|
2012-10-14 14:32:33 -04:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
//
|
|
|
|
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
|
|
|
bool absOpinion, int score) = 0;
|
|
|
|
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms) = 0;
|
2012-10-14 14:32:33 -04:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
|
|
|
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
2013-10-20 05:43:30 -04:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
|
|
|
const std::string &tag, RsRecognTagDetails &details) = 0;
|
|
|
|
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
|
|
|
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
|
2013-10-20 05:43:30 -04:00
|
|
|
|
2015-11-19 22:58:28 -05:00
|
|
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
2015-12-25 22:37:06 -05:00
|
|
|
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
2016-07-03 18:06:01 -04:00
|
|
|
virtual bool isBanned(const RsGxsId& id) =0;
|
2016-07-03 18:59:30 -04:00
|
|
|
virtual time_t getLastUsageTS(const RsGxsId &id) =0;
|
|
|
|
|
|
|
|
// Specific RsIdentity Functions....
|
|
|
|
/* Specific Service Data */
|
|
|
|
/* We expose these initially for testing / GUI purposes.
|
2012-10-21 11:48:18 -04:00
|
|
|
*/
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2016-07-03 18:59:30 -04:00
|
|
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
|
|
|
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 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
|