2008-01-25 02:58:29 -05:00
|
|
|
#ifndef RETROSHARE_P3_PEER_INTERFACE_H
|
|
|
|
#define RETROSHARE_P3_PEER_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/rsserver: p3peers.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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include "retroshare/rspeers.h"
|
2011-07-09 14:39:34 -04:00
|
|
|
class p3LinkMgr;
|
|
|
|
class p3PeerMgr;
|
|
|
|
class p3NetMgr;
|
|
|
|
|
2008-01-25 02:58:29 -05:00
|
|
|
|
|
|
|
class p3Peers: public RsPeers
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm);
|
2008-01-25 02:58:29 -05:00
|
|
|
virtual ~p3Peers() { return; }
|
|
|
|
|
|
|
|
/* Updates ... */
|
|
|
|
virtual bool FriendsChanged();
|
|
|
|
virtual bool OthersChanged();
|
|
|
|
|
|
|
|
/* Peer Details (Net & Auth) */
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual const RsPeerId& getOwnId();
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool haveSecretKey(const RsPgpId& gpg_id) ;
|
2011-08-07 17:11:00 -04:00
|
|
|
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool getOnlineList(std::list<RsPeerId> &ids);
|
|
|
|
virtual bool getFriendList(std::list<RsPeerId> &ids);
|
2010-01-13 16:22:52 -05:00
|
|
|
//virtual bool getOthersList(std::list<std::string> &ids);
|
2012-02-24 20:48:56 -05:00
|
|
|
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl);
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool isOnline(const RsPeerId &id);
|
|
|
|
virtual bool isFriend(const RsPeerId &id);
|
|
|
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); //
|
|
|
|
virtual std::string getGPGName(const RsPgpId &gpg_id);
|
|
|
|
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id);
|
|
|
|
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d);
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2009-05-23 11:07:35 -04:00
|
|
|
/* Using PGP Ids */
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual const RsPgpId& getGPGOwnId();
|
|
|
|
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
|
|
|
virtual bool isKeySupported(const RsPgpId& ids);
|
|
|
|
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
|
|
|
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
|
|
|
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
|
|
|
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
|
|
|
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d);
|
|
|
|
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
|
2013-03-01 18:00:43 -05:00
|
|
|
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
|
2009-05-23 11:07:35 -04:00
|
|
|
|
2008-01-25 02:58:29 -05:00
|
|
|
/* Add/Remove Friends */
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL);
|
|
|
|
virtual bool removeFriend(const RsPgpId& gpgid);
|
|
|
|
virtual bool removeFriendLocation(const RsPeerId& sslId);
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2013-05-29 17:32:02 -04:00
|
|
|
/* keyring management */
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code);
|
2013-05-29 17:32:02 -04:00
|
|
|
|
2008-01-25 02:58:29 -05:00
|
|
|
/* Network Stuff */
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool connectAttempt(const RsPeerId &id);
|
|
|
|
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
|
|
|
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address);
|
|
|
|
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port);
|
2013-09-08 22:10:49 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
|
|
|
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port);
|
|
|
|
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
|
|
|
|
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
|
|
|
|
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
virtual bool getProxyServer(std::string &addr, uint16_t &port);
|
|
|
|
virtual bool setProxyServer(const std::string &addr, const uint16_t port);
|
|
|
|
|
2009-04-05 09:04:18 -04:00
|
|
|
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
|
|
|
|
virtual void allowServerIPDetermination(bool) ;
|
|
|
|
virtual bool getAllowServerIPDetermination() ;
|
|
|
|
|
2008-01-25 02:58:29 -05:00
|
|
|
/* Auth Stuff */
|
2010-09-03 15:23:24 -04:00
|
|
|
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures);
|
|
|
|
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ;
|
|
|
|
|
2010-09-03 15:23:24 -04:00
|
|
|
// same but for own id
|
2014-01-19 09:42:16 -05:00
|
|
|
virtual std::string GetRetroshareInvite(bool include_signatures);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
|
2012-08-14 15:31:47 -04:00
|
|
|
|
2011-07-01 16:47:58 -04:00
|
|
|
virtual bool hasExportMinimal() ;
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string);
|
2012-12-22 16:22:03 -05:00
|
|
|
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code);
|
2012-08-13 15:37:50 -04:00
|
|
|
|
2011-08-30 17:49:49 -04:00
|
|
|
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname);
|
|
|
|
virtual std::string saveCertificateToString(const RsPeerId &id);
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool signGPGCertificate(const RsPgpId &id);
|
|
|
|
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl);
|
2008-01-25 02:58:29 -05:00
|
|
|
|
2010-09-22 18:37:57 -04:00
|
|
|
/* Group Stuff */
|
|
|
|
virtual bool addGroup(RsGroupInfo &groupInfo);
|
|
|
|
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo);
|
|
|
|
virtual bool removeGroup(const std::string &groupId);
|
|
|
|
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo);
|
|
|
|
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId &peerId, bool assign);
|
|
|
|
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId>& peerIds, bool assign);
|
2010-09-22 18:37:57 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
|
2012-12-01 14:22:22 -05:00
|
|
|
|
|
|
|
// service permission stuff
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) ;
|
|
|
|
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) ;
|
|
|
|
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) ;
|
2012-12-01 14:22:22 -05:00
|
|
|
|
2008-01-25 02:58:29 -05:00
|
|
|
private:
|
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
p3LinkMgr *mLinkMgr;
|
|
|
|
p3PeerMgr *mPeerMgr;
|
|
|
|
p3NetMgr *mNetMgr;
|
|
|
|
|
2008-01-25 02:58:29 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|