Commit of the new UDP Connection methods and

the rewrite of the retroshare core networking stack.

This check-in commits the changes to the rsiface code.

Addition of new Retroshare Interface for Peer/Neighbour control.
Mods to notifytxt to use new interface.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@315 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-01-25 08:01:40 +00:00
parent fd8adceb7e
commit c7ce92aba2
5 changed files with 176 additions and 120 deletions

View File

@ -2,41 +2,41 @@
#
all:
make -C tcponudp
make -C util
make -C tcponudp
make -C serialiser
make -C pqi
make -C dbase
make -C services
make -C server
make -C dht
make -C upnp
make -C server
make -C rsserver
make -C rsiface
clean:
make -C tcponudp clean
make -C util clean
make -C tcponudp clean
make -C serialiser clean
make -C pqi clean
make -C dbase clean
make -C services clean
make -C server clean
make -C dht clean
make -C upnp clean
make -C server clean
make -C rsserver clean
make -C rsiface clean
clobber:
make -C tcponudp clobber
make -C util clobber
make -C tcponudp clobber
make -C serialiser clobber
make -C pqi clobber
make -C dbase clobber
make -C services clobber
make -C server clobber
make -C dht clobber
make -C upnp clobber
make -C server clobber
make -C rsserver clobber
make -C rsiface clobber

View File

@ -25,6 +25,7 @@
#include "rsiface/notifytxt.h"
#include "rsiface/rspeers.h"
#include <iostream>
#include <sstream>
@ -75,44 +76,42 @@ void NotifyTxt::notifyListChange(int list, int type)
void NotifyTxt::displayNeighbours()
{
iface->lockData(); /* Lock Interface */
std::list<std::string> ids;
std::list<std::string>::iterator it;
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &neighs = iface->getNeighbourMap();
rsPeers->getOthersList(ids);
std::ostringstream out;
for(it = neighs.begin(); it != neighs.end(); it++)
for(it = ids.begin(); it != ids.end(); it++)
{
RsPeerDetails detail;
rsPeers->getPeerDetails(*it, detail);
out << "Neighbour: ";
out << it ->second.name << " ";
out << it ->second.status << " ";
out << it ->second.trustLvl << " ";
out << detail;
out << std::endl;
}
std::cerr << out.str();
iface->unlockData(); /* UnLock Interface */
}
void NotifyTxt::displayFriends()
{
iface->lockData(); /* Lock Interface */
std::list<std::string> ids;
std::list<std::string>::iterator it;
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &friends = iface->getFriendMap();
rsPeers->getFriendList(ids);
std::ostringstream out;
for(it = friends.begin(); it != friends.end(); it++)
for(it = ids.begin(); it != ids.end(); it++)
{
out << "Friend: ";
out << it->second.name << " ";
out << it->second.status << " ";
out << it->second.trustLvl << " ";
RsPeerDetails detail;
rsPeers->getPeerDetails(*it, detail);
out << "Neighbour: ";
out << detail;
out << std::endl;
}
std::cerr << out.str();
iface->unlockData(); /* UnLock Interface */
}
void NotifyTxt::displayDirectories()

View File

@ -86,14 +86,6 @@ public:
virtual void lockData() = 0;
virtual void unlockData() = 0;
const std::map<RsCertId,NeighbourInfo> &getNeighbourMap()
{ return mNeighbourMap; }
const std::map<RsCertId,NeighbourInfo> &getFriendMap()
{ return mFriendMap; }
const NeighbourInfo * getFriend(std::string id);
const std::list<FileTransferInfo> &getTransferList()
{ return mTransferList; }
@ -167,8 +159,6 @@ bool hasChanged(DataFlags set); /* resets it */
void fillLists(); /* create some dummy data to display */
/* Internals */
std::map<RsCertId,NeighbourInfo> mNeighbourMap;
std::map<RsCertId,NeighbourInfo> mFriendMap;
std::list<PersonInfo> mRemoteDirList;
std::list<PersonInfo> mLocalDirList;
std::list<FileTransferInfo> mTransferList;
@ -202,38 +192,6 @@ virtual ~RsControl() { return; }
/* Real Startup Fn */
virtual int StartupRetroShare(RsInit *config) = 0;
/****************************************/
/* Neighbour Operations */
virtual std::string NeighGetInvite() = 0;
virtual int NeighLoadPEMString(std::string pem, std::string &id) = 0;
virtual int NeighLoadCertificate(std::string fname, std::string &id) = 0;
virtual int NeighAuthFriend(std::string id, RsAuthId code) = 0;
virtual int NeighAddFriend(std::string id) = 0;
virtual int NeighGetSigners(std::string uid, char *out, int len) = 0;
/****************************************/
/* Friend Operations */
virtual int FriendStatus(std::string id, bool accept) = 0;
virtual int FriendRemove(std::string id) = 0;
virtual int FriendConnectAttempt(std::string id) = 0;
virtual int FriendSignCert(std::string id) = 0;
virtual int FriendTrustSignature(std::string id, bool trust) = 0;
virtual int FriendSetLocalAddress(std::string id, std::string addr,
unsigned short port) = 0;
virtual int FriendSetExtAddress(std::string id, std::string addr,
unsigned short port) = 0;
virtual int FriendSetDNSAddress(std::string id, std::string addr) = 0;
virtual int FriendSetFirewall(std::string id, bool firewalled, bool forwarded) = 0;
virtual int FriendSaveCertificate(std::string id, std::string fname) = 0;
/*
virtual int FriendSetConnectMode(std::string id, int mode) = 0;
*/
virtual int FriendSetBandwidth(std::string id, float outkB, float inkB) = 0;
/****************************************/
/* Directory Actions */
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
@ -288,8 +246,8 @@ virtual int ClearInRecommend() = 0;
/****************************************/
/* RsIface Networking */
virtual int NetworkDHTActive(bool active) = 0;
virtual int NetworkUPnPActive(bool active) = 0;
//virtual int NetworkDHTActive(bool active) = 0;
//virtual int NetworkUPnPActive(bool active) = 0;
/****************************************/
/* Config */
@ -297,14 +255,9 @@ virtual int ConfigAddSharedDir( std::string dir ) = 0;
virtual int ConfigRemoveSharedDir( std::string dir ) = 0;
virtual int ConfigSetIncomingDir( std::string dir ) = 0;
virtual int ConfigSetLocalAddr( std::string ipAddr, int port ) = 0;
virtual int ConfigSetExtAddr( std::string ipAddr, int port ) = 0;
virtual int ConfigSetExtName( std::string addr ) = 0;
virtual int ConfigSetLanConfig( bool fire, bool forw ) = 0;
virtual int ConfigSetDataRates( int total, int indiv ) = 0;
virtual int ConfigSetBootPrompt( bool on ) = 0;
virtual int ConfigSave( ) = 0;
//virtual int ConfigSave( ) = 0;
/****************************************/

View File

@ -0,0 +1,147 @@
#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>
/* The Main Interface Class - for information about your Peers */
class RsPeers;
extern RsPeers *rsPeers;
/* Trust Levels */
const uint32_t RS_TRUST_LVL_UNKNOWN = 0x0001;
const uint32_t RS_TRUST_LVL_MARGINAL = 0x0002;
const uint32_t RS_TRUST_LVL_GOOD = 0x0003;
/* Net Mode */
const uint32_t RS_NETMODE_UDP = 0x0001;
const uint32_t RS_NETMODE_UPNP = 0x0002;
const uint32_t RS_NETMODE_EXT = 0x0003;
/* 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;
/* 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 */
std::string id;
std::string name;
std::string email;
std::string location;
std::string org;
std::string fpr; /* fingerprint */
std::string authcode;
std::list<std::string> signers;
uint32_t trustLvl;
bool ownsign; /* we have signed certificate */
bool trusted; /* we trust their signature on others */
/* Network details (only valid if friend) */
uint32_t state;
std::string localAddr;
uint16_t localPort;
std::string extAddr;
uint16_t extPort;
uint32_t netMode;
/* basic stats */
uint32_t lastConnect; /* how long ago */
uint32_t connectPeriod;
};
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;
virtual bool getOnlineList(std::list<std::string> &ids) = 0;
virtual bool getFriendList(std::list<std::string> &ids) = 0;
virtual bool getOthersList(std::list<std::string> &ids) = 0;
virtual bool isFriend(std::string id) = 0;
virtual std::string getPeerName(std::string id) = 0;
virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0;
/* Add/Remove Friends */
virtual bool addFriend(std::string id) = 0;
virtual bool removeFriend(std::string id) = 0;
/* Network Stuff */
virtual bool connectAttempt(std::string id) = 0;
virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port) = 0;
virtual bool setExtAddress( std::string id, std::string addr, uint16_t port) = 0;
virtual bool setNetworkMode(std::string id, uint32_t netMode) = 0;
/* Auth Stuff */
virtual std::string GetRetroshareInvite() = 0;
virtual bool LoadCertificateFromFile(std::string fname, std::string &id) = 0;
virtual bool LoadCertificateFromString(std::string cert, std::string &id) = 0;
virtual bool SaveCertificateToFile(std::string id, std::string fname) = 0;
virtual std::string SaveCertificateToString(std::string id) = 0;
virtual bool AuthCertificate(std::string id, std::string code) = 0;
virtual bool SignCertificate(std::string id) = 0;
virtual bool TrustCertificate(std::string id, bool trust) = 0;
};
#endif

View File

@ -75,48 +75,6 @@ class BaseInfo
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
};
class NeighbourInfo: public BaseInfo
{
public:
std::string name;
std::string org;
std::string loc;
std::string state;
std::string country;
int trustLvl;
std::string trustString;
std::list<RsCertId> signers;
std::string authCode;
int status;
std::string acceptString;
std::string statusString;
std::string connectString;
std::string lastConnect;
std::string peerAddress;
/* server settings */
std::string localAddr;
int localPort;
std::string extAddr;
int extPort;
std::string extName;
bool firewalled;
bool forwardPort;
int maxRate; /* kb */
bool ownsign;
/* Flags to indicate if they are in
* chat or msg list
*/
bool inChat;
bool inMsg;
};
/********************** For the Directory Listing *****************/
class FileInfo: public BaseInfo
@ -345,7 +303,6 @@ class SearchRequest
};
std::ostream &operator<<(std::ostream &out, const NeighbourInfo &info);
std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
std::ostream &operator<<(std::ostream &out, const ChannelInfo &info);
std::ostream &operator<<(std::ostream &out, const ChatInfo &info);