2008-01-25 03:01:40 -05:00
|
|
|
#ifndef RETROSHARE_PEER_GUI_INTERFACE_H
|
|
|
|
#define RETROSHARE_PEER_GUI_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/rsiface: rspeer.h
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2008 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 <inttypes.h>
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
|
2010-01-13 16:08:46 -05:00
|
|
|
/* The Main Interface Class - for information about your Peers
|
|
|
|
* A peer is another RS instance, means associated with an SSL certificate
|
|
|
|
* A same GPG person can have multiple peer running with different SSL certs signed by the same GPG key
|
|
|
|
* Thus a peer have SSL cert details, and also the parent GPG details
|
|
|
|
*/
|
2008-01-25 03:01:40 -05:00
|
|
|
class RsPeers;
|
|
|
|
extern RsPeers *rsPeers;
|
|
|
|
|
|
|
|
/* Trust Levels */
|
2010-01-13 16:22:52 -05:00
|
|
|
const uint32_t RS_TRUST_LVL_NONE = 2;
|
|
|
|
const uint32_t RS_TRUST_LVL_MARGINAL = 3;
|
|
|
|
const uint32_t RS_TRUST_LVL_FULL = 4;
|
|
|
|
const uint32_t RS_TRUST_LVL_ULTIMATE = 5;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
|
|
|
|
|
|
|
/* Net Mode */
|
|
|
|
const uint32_t RS_NETMODE_UDP = 0x0001;
|
|
|
|
const uint32_t RS_NETMODE_UPNP = 0x0002;
|
|
|
|
const uint32_t RS_NETMODE_EXT = 0x0003;
|
2008-02-28 10:58:54 -05:00
|
|
|
const uint32_t RS_NETMODE_UNREACHABLE = 0x0004;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2008-02-07 11:18:34 -05:00
|
|
|
/* Visibility */
|
|
|
|
const uint32_t RS_VS_DHT_ON = 0x0001;
|
|
|
|
const uint32_t RS_VS_DISC_ON = 0x0002;
|
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
/* State */
|
|
|
|
const uint32_t RS_PEER_STATE_FRIEND = 0x0001;
|
|
|
|
const uint32_t RS_PEER_STATE_ONLINE = 0x0002;
|
|
|
|
const uint32_t RS_PEER_STATE_CONNECTED = 0x0004;
|
2008-02-28 10:58:54 -05:00
|
|
|
const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/* Groups */
|
|
|
|
#define RS_GROUP_ID_FRIENDS "Friends"
|
|
|
|
#define RS_GROUP_ID_FAMILY "Family"
|
|
|
|
#define RS_GROUP_ID_COWORKERS "Co-Workers"
|
|
|
|
#define RS_GROUP_ID_OTHERS "Other Contacts"
|
|
|
|
#define RS_GROUP_ID_FAVORITES "Favorites"
|
|
|
|
|
|
|
|
const uint32_t RS_GROUP_FLAG_STANDARD = 0x0001;
|
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
/* A couple of helper functions for translating the numbers games */
|
|
|
|
|
|
|
|
std::string RsPeerTrustString(uint32_t trustLvl);
|
|
|
|
std::string RsPeerStateString(uint32_t state);
|
|
|
|
std::string RsPeerNetModeString(uint32_t netModel);
|
|
|
|
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
|
|
|
|
|
|
|
|
|
|
|
/* Details class */
|
|
|
|
class RsPeerDetails
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsPeerDetails();
|
|
|
|
|
|
|
|
/* Auth details */
|
2010-01-13 16:14:49 -05:00
|
|
|
bool isOnlyGPGdetail;
|
2008-01-25 03:01:40 -05:00
|
|
|
std::string id;
|
2010-01-13 16:22:52 -05:00
|
|
|
std::string gpg_id;
|
2008-01-25 03:01:40 -05:00
|
|
|
std::string name;
|
|
|
|
std::string email;
|
|
|
|
std::string location;
|
|
|
|
std::string org;
|
|
|
|
|
2009-08-09 09:06:24 -04:00
|
|
|
std::string issuer;
|
|
|
|
|
2009-05-23 11:07:35 -04:00
|
|
|
std::string fpr; /* pgp fingerprint */
|
2008-01-25 03:01:40 -05:00
|
|
|
std::string authcode;
|
2010-01-13 16:11:02 -05:00
|
|
|
std::list<std::string> gpgSigners;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
|
|
|
uint32_t trustLvl;
|
2009-05-25 07:38:47 -04:00
|
|
|
uint32_t validLvl;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2010-01-13 16:12:56 -05:00
|
|
|
bool ownsign; /* we have signed the remote peer GPG key */
|
|
|
|
bool hasSignedMe; /* the remote peer has signed my GPG key */
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2010-01-13 16:22:52 -05:00
|
|
|
bool accept_connection;
|
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
/* Network details (only valid if friend) */
|
|
|
|
uint32_t state;
|
|
|
|
|
|
|
|
std::string localAddr;
|
|
|
|
uint16_t localPort;
|
|
|
|
std::string extAddr;
|
2009-12-13 16:59:26 -05:00
|
|
|
uint16_t extPort;
|
2010-04-22 14:49:08 -04:00
|
|
|
std::string dyndns;
|
2009-11-11 17:12:50 -05:00
|
|
|
std::list<std::string> ipAddressList;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
|
|
|
uint32_t netMode;
|
2008-02-26 11:14:13 -05:00
|
|
|
uint32_t tryNetMode; /* only for ownState */
|
2008-02-07 11:18:34 -05:00
|
|
|
uint32_t visState;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
|
|
|
/* basic stats */
|
|
|
|
uint32_t lastConnect; /* how long ago */
|
2008-03-02 09:25:59 -05:00
|
|
|
std::string autoconnect;
|
2010-01-13 16:08:46 -05:00
|
|
|
uint32_t connectPeriod;
|
2008-01-25 03:01:40 -05:00
|
|
|
};
|
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
class RsGroupInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGroupInfo();
|
|
|
|
|
|
|
|
std::string id;
|
|
|
|
std::string name;
|
|
|
|
uint32_t flag;
|
|
|
|
|
|
|
|
std::list<std::string> peerIds;
|
|
|
|
};
|
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
|
|
|
|
|
|
|
class RsPeers
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsPeers() { return; }
|
|
|
|
virtual ~RsPeers() { return; }
|
|
|
|
|
|
|
|
/* Updates ... */
|
|
|
|
virtual bool FriendsChanged() = 0;
|
|
|
|
virtual bool OthersChanged() = 0;
|
|
|
|
|
|
|
|
/* Peer Details (Net & Auth) */
|
|
|
|
virtual std::string getOwnId() = 0;
|
|
|
|
|
2010-01-13 16:16:18 -05:00
|
|
|
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
|
|
|
|
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
|
2010-01-13 16:22:52 -05:00
|
|
|
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
|
2010-10-08 08:03:25 -04:00
|
|
|
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2010-01-13 16:16:18 -05:00
|
|
|
virtual bool isOnline(std::string ssl_id) = 0;
|
|
|
|
virtual bool isFriend(std::string ssl_id) = 0;
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual bool isGPGAccepted(std::string gpg_id_is_friend) = 0; //
|
|
|
|
virtual std::string getPeerName(std::string ssl_or_gpg_id) = 0;
|
|
|
|
virtual std::string getGPGName(std::string gpg_id) = 0;
|
2010-01-13 16:16:18 -05:00
|
|
|
virtual bool getPeerDetails(std::string ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2009-05-23 11:07:35 -04:00
|
|
|
/* Using PGP Ids */
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual std::string getGPGOwnId() = 0;
|
2010-01-13 16:25:18 -05:00
|
|
|
virtual std::string getGPGId(std::string sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
|
|
|
|
virtual bool getGPGSignedList(std::list<std::string> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
|
|
|
virtual bool getGPGValidList(std::list<std::string> &gpg_ids) = 0;
|
|
|
|
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
|
|
|
|
virtual bool getGPGDetails(std::string gpg_id, RsPeerDetails &d) = 0;
|
2010-01-13 19:37:15 -05:00
|
|
|
virtual bool getSSLChildListOfGPGId(std::string gpg_id, std::list<std::string> &ssl_ids) = 0;
|
2010-01-13 16:14:49 -05:00
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
/* Add/Remove Friends */
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual bool addFriend(std::string ssl_id, std::string gpg_id) = 0;
|
|
|
|
virtual bool addDummyFriend(std::string gpg_id) = 0; //we want to add a empty ssl friend for this gpg id
|
2010-01-13 16:33:54 -05:00
|
|
|
virtual bool isDummyFriend(std::string ssl_id) = 0;
|
2010-01-13 19:37:15 -05:00
|
|
|
virtual bool removeFriend(std::string ssl_or_gpg_id) = 0;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
|
|
|
/* Network Stuff */
|
2010-01-13 16:16:18 -05:00
|
|
|
virtual bool connectAttempt(std::string ssl_id) = 0;
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual bool setLocation(std::string ssl_id, std::string location) = 0;//location is shown in the gui to differentiate ssl certs
|
2010-01-13 16:16:18 -05:00
|
|
|
virtual bool setLocalAddress(std::string ssl_id, std::string addr, uint16_t port) = 0;
|
|
|
|
virtual bool setExtAddress( std::string ssl_id, std::string addr, uint16_t port) = 0;
|
2010-04-22 14:49:08 -04:00
|
|
|
virtual bool setDynDNS(std::string id, std::string addr) = 0;
|
2010-01-13 16:16:18 -05:00
|
|
|
virtual bool setNetworkMode(std::string ssl_id, uint32_t netMode) = 0;
|
|
|
|
virtual bool setVisState(std::string ssl_id, uint32_t vis) = 0;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2009-04-05 09:04:18 -04:00
|
|
|
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
|
|
|
virtual void allowServerIPDetermination(bool) = 0;
|
2009-12-13 16:59:26 -05:00
|
|
|
virtual void allowTunnelConnection(bool) = 0;
|
2009-04-05 09:04:18 -04:00
|
|
|
virtual bool getAllowServerIPDetermination() = 0 ;
|
2009-12-13 16:59:26 -05:00
|
|
|
virtual bool getAllowTunnelConnection() = 0 ;
|
2009-04-05 09:04:18 -04:00
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
/* Auth Stuff */
|
2010-09-03 15:23:24 -04:00
|
|
|
virtual std::string GetRetroshareInvite(const std::string& ssl_id) = 0;
|
2008-01-25 03:01:40 -05:00
|
|
|
virtual std::string GetRetroshareInvite() = 0;
|
|
|
|
|
2010-01-13 19:37:15 -05:00
|
|
|
virtual bool loadCertificateFromFile(std::string fname, std::string &ssl_id, std::string &gpg_id) = 0;
|
|
|
|
virtual bool loadDetailsFromStringCert(std::string certGPG, RsPeerDetails &pd) = 0;
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual bool saveCertificateToFile(std::string id, std::string fname) = 0;
|
|
|
|
virtual std::string saveCertificateToString(std::string id) = 0;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2010-01-13 16:22:52 -05:00
|
|
|
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance) = 0;
|
|
|
|
virtual bool signGPGCertificate(std::string gpg_id) = 0;
|
|
|
|
virtual bool trustGPGCertificate(std::string gpg_id, uint32_t trustlvl) = 0;
|
2008-01-25 03:01:40 -05:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/* Group Stuff */
|
|
|
|
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
|
|
|
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
|
|
|
virtual bool removeGroup(const std::string &groupId) = 0;
|
|
|
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
|
|
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
|
|
|
// groupId == "" && assign == false -> remove from all groups
|
|
|
|
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) = 0;
|
|
|
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) = 0;
|
|
|
|
|
2008-01-25 03:01:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|