1st phase of rsiface done

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/ammorais_branch@1348 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
ammorais 2009-07-10 00:34:53 +00:00
parent 804f14acab
commit 4b02c46d23
11 changed files with 946 additions and 114 deletions

View File

@ -67,6 +67,64 @@ const int NOTIFY_TYPE_ADD = 0x04; /* flagged additions */
const int NOTIFY_TYPE_DEL = 0x08; /* flagged deletions */
/*
* From rsfiles.h
*/
/* These are used mainly by ftController at the moment */
const uint32_t RS_FILE_CTRL_PAUSE = 0x00000100;
const uint32_t RS_FILE_CTRL_START = 0x00000200;
const uint32_t RS_FILE_RATE_TRICKLE = 0x00000001;
const uint32_t RS_FILE_RATE_SLOW = 0x00000002;
const uint32_t RS_FILE_RATE_STANDARD = 0x00000003;
const uint32_t RS_FILE_RATE_FAST = 0x00000004;
const uint32_t RS_FILE_RATE_STREAM_AUDIO = 0x00000005;
const uint32_t RS_FILE_RATE_STREAM_VIDEO = 0x00000006;
const uint32_t RS_FILE_PEER_ONLINE = 0x00001000;
const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
/************************************
* Used To indicate where to search.
*
* The Order of these is very important,
* it specifies the search order too.
*
*/
const uint32_t RS_FILE_HINTS_MASK = 0x00ffffff;
const uint32_t RS_FILE_HINTS_CACHE = 0x00000001;
const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002;
const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004;
const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008;
const uint32_t RS_FILE_HINTS_DOWNLOAD= 0x00000010;
const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020;
const uint32_t RS_FILE_HINTS_TURTLE = 0x00000040;
const uint32_t RS_FILE_HINTS_SPEC_ONLY = 0x01000000;
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000;
/* Callback Codes */
//const uint32_t RS_FILE_HINTS_CACHE = 0x00000001; // ALREADY EXISTS
const uint32_t RS_FILE_HINTS_MEDIA = 0x00001000;
const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
const uint32_t RS_FILE_EXTRA_DELETE = 0x0010;
const uint32_t CB_CODE_CACHE = 0x0001;
const uint32_t CB_CODE_EXTRA = 0x0002;
const uint32_t CB_CODE_MEDIA = 0x0004;

View File

@ -10,8 +10,10 @@ SOURCES = $$PWP/rsinit.cc \
$$PWP/rsexpr.cc \
$$PWP/rsforums.cc \
$$PWP/rschannels.cc \
rsmsgs.cc \
rsfeeditem.cc
$$PWP/rsmsgs.cc \
$$PWP/rsfeeditem.cc \
$$PWP/rspeers.cc \
rsstatus.cc
HEADERS = $$PWP/rsinit.h \
$$PWP/rsiface.h \
$$PWP/rscontrol.h \
@ -28,5 +30,10 @@ HEADERS = $$PWP/rsinit.h \
$$PWP/rsdistrib.h \
$$PWP/rsmsgs.h \
$$PWP/rsnotify.h \
rsfeeditem.h \
rsdefs.h
$$PWP/rsfeeditem.h \
$$PWP/rsdefs.h \
$$PWP/rspeers.h \
$$PWP/rsphoto.h \
$$PWP/rsrank.h \
$$PWP/rsstatus.h \
$$PWP/rsturtle.h

View File

@ -0,0 +1,181 @@
#include "_rsiface/rspeers.h"
#include <iostream>
#include <fstream>
#include <sstream>
#ifdef RS_USE_PGPSSL
#include <gpgme.h>
#endif
/**************** PQI_USE_XPGP ******************/
#if defined(PQI_USE_XPGP)
#include "pqi/authxpgp.h"
#else /* X509 Certificates */
/**************** PQI_USE_XPGP ******************/
#include "pqi/authssl.h"
#endif /* X509 Certificates */
/**************** PQI_USE_XPGP ******************/
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail)
{
out << "RsPeerDetail: " << detail.name << " <" << detail.id << ">";
out << std::endl;
out << " email: " << detail.email;
out << " location:" << detail.location;
out << " org: " << detail.org;
out << std::endl;
out << " fpr: " << detail.fpr;
out << " authcode:" << detail.authcode;
out << std::endl;
out << " signers:";
out << std::endl;
std::list<std::string>::const_iterator it;
for(it = detail.signers.begin();
it != detail.signers.end(); it++)
{
out << "\t" << *it;
out << std::endl;
}
out << std::endl;
out << " trustLvl: " << detail.trustLvl;
out << " ownSign: " << detail.ownsign;
out << " trusted: " << detail.trusted;
out << std::endl;
out << " state: " << detail.state;
out << " netMode: " << detail.netMode;
out << std::endl;
out << " localAddr: " << detail.localAddr;
out << ":" << detail.localPort;
out << std::endl;
out << " extAddr: " << detail.extAddr;
out << ":" << detail.extPort;
out << std::endl;
out << " lastConnect: " << detail.lastConnect;
out << " connectPeriod: " << detail.connectPeriod;
out << std::endl;
return out;
}
std::string RsPeerTrustString(uint32_t trustLvl)
{
std::string str;
#ifdef RS_USE_PGPSSL
switch(trustLvl)
{
default:
case GPGME_VALIDITY_UNKNOWN:
str = "GPGME_VALIDITY_UNKNOWN";
break;
case GPGME_VALIDITY_UNDEFINED:
str = "GPGME_VALIDITY_UNDEFINED";
break;
case GPGME_VALIDITY_NEVER:
str = "GPGME_VALIDITY_NEVER";
break;
case GPGME_VALIDITY_MARGINAL:
str = "GPGME_VALIDITY_MARGINAL";
break;
case GPGME_VALIDITY_FULL:
str = "GPGME_VALIDITY_FULL";
break;
case GPGME_VALIDITY_ULTIMATE:
str = "GPGME_VALIDITY_ULTIMATE";
break;
}
return str;
#endif
if (trustLvl == RS_TRUST_LVL_GOOD)
{
str = "Good";
}
else if (trustLvl == RS_TRUST_LVL_MARGINAL)
{
str = "Marginal";
}
else
{
str = "No Trust";
}
return str;
}
std::string RsPeerStateString(uint32_t state)
{
std::string str;
if (state & RS_PEER_STATE_CONNECTED)
{
str = "Connected";
}
else if (state & RS_PEER_STATE_UNREACHABLE)
{
str = "Unreachable";
}
else if (state & RS_PEER_STATE_ONLINE)
{
str = "Available";
}
else if (state & RS_PEER_STATE_FRIEND)
{
str = "Offline";
}
else
{
str = "Neighbour";
}
return str;
}
std::string RsPeerNetModeString(uint32_t netModel)
{
std::string str;
if (netModel == RS_NETMODE_EXT)
{
str = "External Port";
}
else if (netModel == RS_NETMODE_UPNP)
{
str = "Ext (UPnP)";
}
else if (netModel == RS_NETMODE_UDP)
{
str = "UDP Mode";
}
else if (netModel == RS_NETMODE_UNREACHABLE)
{
str = "UDP Mode (Unreachable)";
}
else
{
str = "Unknown NetMode";
}
return str;
}
std::string RsPeerLastConnectString(uint32_t lastConnect)
{
std::ostringstream out;
out << lastConnect << " secs ago";
return out.str();
}

View File

@ -0,0 +1,175 @@
#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>
#include "rsserver/p3peers.h"
#include "rsserver/p3face.h"
#include "pqi/p3connmgr.h"
#include "pqi/p3authmgr.h"
#include "_rsiface/rsinit.h"
/* 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;
const uint32_t RS_NETMODE_UNREACHABLE = 0x0004;
/* Visibility */
const uint32_t RS_VS_DHT_ON = 0x0001;
const uint32_t RS_VS_DISC_ON = 0x0002;
/* 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;
const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
/* 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
{
RsPeerDetails();
/* Auth details */
std::string id;
std::string name;
std::string email;
std::string location;
std::string org;
std::string fpr; /* pgp fingerprint */
std::string authcode;
std::list<std::string> signers;
uint32_t trustLvl;
uint32_t validLvl;
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;
uint32_t tryNetMode; /* only for ownState */
uint32_t visState;
/* basic stats */
uint32_t lastConnect; /* how long ago */
std::string autoconnect;
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 isOnline(std::string id) = 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;
/* Using PGP Ids */
virtual std::string getPGPOwnId() = 0;
virtual bool getPGPFriendList(std::list<std::string> &ids) = 0;
virtual bool getPGPAllList(std::list<std::string> &ids) = 0;
/* Add/Remove Friends */
virtual bool addFriend(std::string id) = 0;
virtual bool removeFriend(std::string id) = 0;
/* get/set third party info about who trusts me */
virtual bool isTrustingMe(std::string id) const = 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;
virtual bool setVisState(std::string id, uint32_t vis) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual bool getAllowServerIPDetermination() = 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

@ -0,0 +1,126 @@
#ifndef RSPHOTO_H
#define RSPHOTO_H
/*
* libretroshare/src/rsiface: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-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 RsPhoto;
extern RsPhoto *rsPhoto;
class RsPhotoDetails;
class RsPhotoShowDetails;
// CHANGE: CLASS_TO_STRUCT
struct RsPhotoShowInfo
{
std::string photoId;
std::wstring altComment;
uint32_t deltaT; /* in 100ths of sec? */
};
// CHANGE: CLASS_TO_STRUCT
struct RsPhotoShowDetails
{
RsPhotoDetails() {}
std::string id;
std::string showid;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
std::list<RsPhotoShowInfo> photos;
};
/* Details class */
// CHANGE: CLASS_TO_STRUCT
struct RsPhotoDetails
{
RsPhotoDetails();
std::string id;
std::string srcid;
std::string hash;
uint64_t size;
std::string name;
std::wstring comment;
std::string location;
std::string date;
uint32_t format;
bool isAvailable;
std::string path;
};
// CHANGE:DELETED : reason-> not implemented
//std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail);
//std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail);
class RsPhoto
{
public:
RsPhoto() { return; }
virtual ~RsPhoto() { return; }
/* changed? */
virtual bool updated() = 0;
/* access data */
virtual bool getPhotoList(std::string id, std::list<std::string> &hashs) = 0;
virtual bool getShowList(std::string id, std::list<std::string> &showIds) = 0;
virtual bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail) = 0;
virtual bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail) = 0;
/* add / delete */
virtual std::string createShow(std::string name) = 0;
virtual bool deleteShow(std::string showId) = 0;
virtual bool addPhotoToShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool movePhotoInShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool removePhotoFromShow(std::string showId, std::string photoId) = 0;
virtual std::string addPhoto(std::string path) = 0; /* add from file */
virtual bool addPhoto(std::string srcId, std::string photoId) = 0; /* add from peers photos */
virtual bool deletePhoto(std::string photoId) = 0;
/* modify properties (TODO) */
virtual bool modifyShow(std::string showId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment) = 0;
};
#endif // RSPHOTO_H

View File

@ -0,0 +1,97 @@
#ifndef RSRANK_H
#define RSRANK_H
/*
* libretroshare/src/rsiface: rsrank.h
*
* RetroShare C++ Interface.
*
* Copyright 2007-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 RsRanks;
extern RsRanks *rsRanks;
// CHANGE:CLASS_TO_STRUCT
class RsRankComment
{
std::string id;
std::wstring comment;
int32_t score;
time_t timestamp;
};
// CHANGE:CLASS_TO_STRUCT
struct RsRankDetails
{
std::string rid;
std::wstring link;
std::wstring title;
float rank;
bool ownTag;
std::list<RsRankComment> comments;
};
const uint32_t RS_RANK_SCORE = 0x0001;
const uint32_t RS_RANK_TIME = 0x0002;
const uint32_t RS_RANK_ALG = 0x0003;
// CHANGE:DELETED -> reason. not implemented
//std::ostream &operator<<(std::ostream &out, const RsRankDetails &detail);
class RsRanks
{
public:
RsRanks() { return; }
virtual ~RsRanks() { return; }
/* needs update? */
virtual bool updated() = 0;
/* Set Sort Methods */
virtual bool setSortPeriod(uint32_t period) = 0;
virtual bool setSortMethod(uint32_t type) = 0;
virtual bool clearPeerFilter() = 0;
virtual bool setPeerFilter(std::list<std::string> peers) = 0;
/* get Ids */
virtual uint32_t getRankingsCount() = 0;
virtual float getMaxRank() = 0;
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids) = 0;
virtual bool getRankDetails(std::string rid, RsRankDetails &details) = 0;
/* Add New Comment / Msg */
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score) = 0;
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score) = 0;
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title) = 0;
};
#endif // RSRANK_H

View File

@ -0,0 +1,33 @@
#include "rsstatus.h"
std::string RsStatusString(uint32_t status)
{
std::string str;
if (status == RS_STATUS_OFFLINE)
{
str = "Offline";
}
else if (status == RS_STATUS_AWAY)
{
str = "Away";
}
else if (status == RS_STATUS_BUSY)
{
str = "Busy";
}
else if (status == RS_STATUS_ONLINE)
{
str = "Online";
}
return str;
}
std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
{
out << "StatusInfo: " << std::endl;
out << "id: " << si.id << std::endl;
out << "status: " << si.status;
out << " (" << RsStatusString(si.status) << ")" << std::endl;
return out;
}

View File

@ -0,0 +1,61 @@
#ifndef RSSTATUS_H
#define RSSTATUS_H
/*
* libretroshare/src/rsiface: rsstatus.h
*
* RetroShare C++ .
*
* Copyright 2007-2008 by Vinny Do.
*
* 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".
*
*/
class RsStatus;
extern RsStatus *rsStatus;
#include <iostream>
#include <string>
#include <inttypes.h>
const uint32_t RS_STATUS_OFFLINE = 0x0001;
const uint32_t RS_STATUS_AWAY = 0x0002;
const uint32_t RS_STATUS_BUSY = 0x0003;
const uint32_t RS_STATUS_ONLINE = 0x0004;
std::string RsStatusString(uint32_t status);
// CHANGE: CLASS_TO_STRUCT
struct StatusInfo
{
std::string id;
uint32_t status;
};
class RsStatus
{
public:
virtual bool getStatus(std::string id, StatusInfo& statusInfo) = 0;
virtual bool setStatus(StatusInfo& statusInfo) = 0;
};
std::ostream& operator<<(std::ostream& out, const StatusInfo& statusInfo);
#endif // RSSTATUS_H

View File

@ -0,0 +1,94 @@
#ifndef RSTURTLE_H
#define RSTURTLE_H
/*
* libretroshare/src/rsiface: rsturtle.h
*
* RetroShare C++ Interface.
*
* Copyright 2009 by Cyril Soler.
*
* 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 "csoler@users.sourceforge.net"
*
*/
#include <inttypes.h>
#include <string>
#include <list>
class RsTurtle;
extern RsTurtle *rsTurtle ;
typedef uint32_t TurtleRequestId ;
// This is the structure used to send back results of the turtle search
// to the notifyBase class.
struct TurtleFileInfo
{
std::string hash ;
std::string name ;
uint64_t size ;
};
// Interface class for turtle hopping.
//
// This class mainly interacts with the turtle router, that is responsible
// for routing turtle packets between peers, accepting/forwarding search
// requests and dowloading files.
//
// As seen from here, the interface is really simple.
//
class RsTurtle
{
public:
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
RsTurtle() { _sharing_strategy = SHARE_ENTIRE_NETWORK ;}
virtual ~RsTurtle() {}
// Lauches a search request through the pipes, and immediately returns
// the request id, which will be further used by the gui to store results
// as they come back.
//
virtual TurtleRequestId turtleSearch(const std::string& match_string) = 0 ;
// Initiates tunnel handling for the given file hash. tunnels. Launches
// an exception if an error occurs during the initialization process. The
// turtle router itself does not initiate downloads, it only maintains
// tunnels for the given hash. The download should be driven by the file
// transfer module by calling ftServer::FileRequest().
//
virtual void monitorFileTunnels(const std::string& name,const std::string& file_hash,uint64_t size) = 0 ;
// Tells the turtle router to stop handling tunnels for the given file hash. Traditionally this should
// be called after calling ftServer::fileCancel().
//
virtual void stopMonitoringFileTunnels(const std::string& file_hash) = 0 ;
// Sets the file sharing strategy. It concerns all local files. It would
// be better to handle this for each file, of course.
void setFileSharingStrategy(FileSharingStrategy f) { _sharing_strategy = f ; }
protected:
FileSharingStrategy _sharing_strategy ;
};
#endif // RSTURTLE_H

View File

@ -1,5 +1,5 @@
#ifndef RS_TYPES_GUI_INTERFACE_H
#define RS_TYPES_GUI_INTERFACE_H
#ifndef RSTYPES_H
#define RSTYPES_H
/*
* "$Id: rstypes.h,v 1.7 2007-05-05 16:10:05 rmf24 Exp $"
@ -43,61 +43,61 @@ const uint32_t FT_STATE_WAITING = 0x0002;
const uint32_t FT_STATE_DOWNLOADING = 0x0003;
const uint32_t FT_STATE_COMPLETE = 0x0004;
class TransferInfo
// CHANGE: CLASS_TO_STRUCT
struct TransferInfo
{
public:
/**** Need Some of these Fields ****/
std::string peerId;
std::string name; /* if has alternative name? */
double tfRate; /* kbytes */
int status; /* FT_STATE_... */
/**** Need Some of these Fields ****/
std::string peerId;
std::string name; /* if has alternative name? */
double tfRate; /* kbytes */
int status; /* FT_STATE_... */
};
class FileInfo
{
/* old BaseInfo Entries */
public:
/* old BaseInfo Entries */
public:
FileInfo() :flags(0), mId(0) { return; }
RsCertId id; /* key for matching everything */
int flags; /* INFO_TAG above */
FileInfo() :flags(0), mId(0) {}
RsCertId id; /* key for matching everything */
int flags; /* INFO_TAG above */
/* allow this to be tweaked by the GUI Model */
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
/* allow this to be tweaked by the GUI Model */
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
/* Old FileInfo Entries */
public:
/* Old FileInfo Entries */
public:
static const int kRsFiStatusNone = 0;
static const int kRsFiStatusStall = 1;
static const int kRsFiStatusProgress = 2;
static const int kRsFiStatusDone = 2;
static const int kRsFiStatusNone = 0;
static const int kRsFiStatusStall = 1;
static const int kRsFiStatusProgress = 2;
static const int kRsFiStatusDone = 2;
/* FileInfo(); */
/* FileInfo(); */
int searchId; /* 0 if none */
std::string path;
std::string fname;
std::string hash;
std::string ext;
int searchId; /* 0 if none */
std::string path;
std::string fname;
std::string hash;
std::string ext;
uint64_t size;
uint64_t avail; /* how much we have */
int status;
uint64_t size;
uint64_t avail; /* how much we have */
int status;
bool inRecommend;
bool inRecommend;
double rank;
int age;
double rank;
int age;
/* Transfer Stuff */
uint64_t transfered;
double tfRate; /* in kbytes */
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
std::list<TransferInfo> peers;
/* Transfer Stuff */
uint64_t transfered;
double tfRate; /* in kbytes */
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
std::list<TransferInfo> peers;
time_t lastTS;
time_t lastTS;
};
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
@ -111,42 +111,43 @@ std::ostream &operator<<(std::ostream &out, const FileInfo &info);
#define UPNP_STATE_FAILED_UDP 4
#define UPNP_STATE_ACTIVE 5
class RsConfig
// CHANGE: CLASS_TO_STRUCT
struct RsConfig
{
public:
std::string ownId;
std::string ownName;
std::string localAddr;
int localPort;
std::string extAddr;
int extPort;
std::string extName;
std::string ownId;
std::string ownName;
bool firewalled;
bool forwardPort;
std::string localAddr;
int localPort;
std::string extAddr;
int extPort;
std::string extName;
int maxDownloadDataRate; /* kb */
int maxUploadDataRate; /* kb */
int maxIndivDataRate; /* kb */
bool firewalled;
bool forwardPort;
int promptAtBoot; /* popup the password prompt */
int maxDownloadDataRate; /* kb */
int maxUploadDataRate; /* kb */
int maxIndivDataRate; /* kb */
/* older data types */
bool DHTActive;
bool uPnPActive;
int promptAtBoot; /* popup the password prompt */
int uPnPState;
int DHTPeers;
/* older data types */
bool DHTActive;
bool uPnPActive;
/* Flags for Network Status */
bool netOk; /* That we've talked to someone! */
bool netUpnpOk; /* upnp is enabled and active */
bool netDhtOk; /* response from dht */
bool netExtOk; /* know our external address */
bool netUdpOk; /* recvd stun / udp packets */
bool netTcpOk; /* recvd incoming tcp */
bool netResetReq;
int uPnPState;
int DHTPeers;
/* Flags for Network Status */
bool netOk; /* That we've talked to someone! */
bool netUpnpOk; /* upnp is enabled and active */
bool netDhtOk; /* response from dht */
bool netExtOk; /* know our external address */
bool netUdpOk; /* recvd stun / udp packets */
bool netTcpOk; /* recvd incoming tcp */
bool netResetReq;
};
/********************** For Search Interface *****************/
@ -164,25 +165,23 @@ const int OpExactMatch = 0x002;
const int OpLessThan = 0x003;
const int OpGreaterThan = 0x004;
class Condition
// CHANGE: CLASS_TO_STRUCT
struct Condition
{
public:
std::string type;
int op;
double value;
std::string name;
std::string type;
int op;
double value;
std::string name;
};
class SearchRequest
// CHANGE: CLASS_TO_STRUCT
struct SearchRequest
{
public:
int searchId;
RsCertId toId; /* all zeros for everyone! */
std::list<Condition> tests;
int searchId;
RsCertId toId; /* all zeros for everyone! */
std::list<Condition> tests;
};
/********************** For FileCache Interface *****************/
#define DIR_TYPE_ROOT 0x01
@ -204,46 +203,46 @@ class SearchRequest
#define DIR_FLAGS_DETAILS 0x0002
#define DIR_FLAGS_CHILDREN 0x0004
class DirStub
// CHANGE: CLASS_TO_STRUCT
struct DirStub
{
public:
uint8_t type;
std::string name;
void *ref;
uint8_t type;
std::string name;
void *ref;
};
class DirDetails
// CHANGE: CLASS_TO_STRUCT
struct DirDetails
{
public:
void *parent;
uint32_t prow; /* parent row */
void *parent;
uint32_t prow; /* parent row */
void *ref;
uint8_t type;
std::string id;
std::string name;
std::string hash;
std::string path;
uint64_t count;
uint32_t age;
uint32_t rank;
void *ref;
uint8_t type;
std::string id;
std::string name;
std::string hash;
std::string path;
uint64_t count;
uint32_t age;
uint32_t rank;
std::list<DirStub> children;
std::list<DirStub> children;
};
class FileDetail
// CHANGE: CLASS_TO_STRUCT
struct FileDetail
{
public:
std::string id;
std::string name;
std::string hash;
std::string path;
uint64_t size;
uint32_t age;
uint32_t rank;
std::string id;
std::string name;
std::string hash;
std::string path;
uint64_t size;
uint32_t age;
uint32_t rank;
};
#endif
#endif // RSTYPES_H

View File

@ -24,6 +24,7 @@
*/
#include "services/p3status.h"
#include "_rsiface/rsstatus.h"
std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
{