mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-19 14:55:54 -04:00
more cleaning
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/ammorais_branch@1342 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a8838b25fd
commit
6b7dba1d98
@ -4,7 +4,6 @@ NotifyBase::NotifyBase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NotifyBase::~NotifyBase()
|
||||
{
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ const RsConfig& RsIface::getConfig()
|
||||
return mConfig;
|
||||
}
|
||||
|
||||
|
||||
/* set to true */
|
||||
bool RsIface::setChanged(DataFlags set)
|
||||
{
|
||||
|
@ -3,11 +3,14 @@ INCLUDEPATH += $$PWD \
|
||||
DEPENDPATH += $$PWD
|
||||
SOURCES = $$PWP/rsinit.cc \
|
||||
$$PWP/rsiface.cc \
|
||||
rscontrol.cc \
|
||||
notifybase.cc \
|
||||
rsifacereal.cc
|
||||
$$PWP/rscontrol.cc \
|
||||
$$PWP/notifybase.cc \
|
||||
$$PWP/rsifacereal.cc \
|
||||
$$PWP/rstypes.cc
|
||||
|
||||
HEADERS = $$PWP/rsinit.h \
|
||||
$$PWP/rsiface.h \
|
||||
rscontrol.h \
|
||||
notifybase.h \
|
||||
rsifacereal.h
|
||||
$$PWP/rscontrol.h \
|
||||
$$PWP/notifybase.h \
|
||||
$$PWP/rsifacereal.h \
|
||||
$$PWP/rstypes.h
|
||||
|
@ -5,28 +5,17 @@ RsIfaceReal::RsIfaceReal(NotifyBase &callback) :
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RsIfaceReal(NotifyBase &callback) :
|
||||
RsIface(callback)
|
||||
{ return; }
|
||||
|
||||
virtual void lockData()
|
||||
{
|
||||
// std::cerr << "RsIfaceReal::lockData()" << std::endl;
|
||||
return rsIfaceMutex.lock();
|
||||
}
|
||||
|
||||
virtual void unlockData()
|
||||
{
|
||||
// std::cerr << "RsIfaceReal::unlockData()" << std::endl;
|
||||
return rsIfaceMutex.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
RsMutex rsIfaceMutex;
|
||||
};
|
||||
|
||||
RsIface *createRsIface(NotifyBase &cb)
|
||||
void RsIfaceReal::lockData()
|
||||
{
|
||||
return new RsIfaceReal(cb);
|
||||
// std::cerr << "RsIfaceReal::lockData()" << std::endl;
|
||||
// return rsIfaceMutex.lock(); //Return doen't make any sense since the function returns void
|
||||
rsIfaceMutex.lock();
|
||||
}
|
||||
|
||||
void RsIfaceReal::unlockData()
|
||||
{
|
||||
// std::cerr << "RsIfaceReal::unlockData()" << std::endl;
|
||||
// return rsIfaceMutex.unlock(); //Return doen't make any sense since the function returns void
|
||||
rsIfaceMutex.unlock();
|
||||
}
|
||||
|
||||
|
60
libretroshare/src/_rsiface/rstypes.cc
Normal file
60
libretroshare/src/_rsiface/rstypes.cc
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
/*
|
||||
* "$Id: rstypes.cc,v 1.2 2007-04-07 08:41:00 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-2006 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".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* Insides of RetroShare interface.
|
||||
* only prints stuff out at the moment
|
||||
*/
|
||||
|
||||
#include "rsiface/rstypes.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NOTE NOTE NOTE ...... XXX
|
||||
* BUG in MinGW .... %hhx in sscanf overwrites 32bits, instead of 8bits.
|
||||
* this means that scanf(.... &(data[15])) is running off the
|
||||
* end of the buffer, and hitting data[15-18]...
|
||||
* To work around this bug we are reading into proper int32s
|
||||
* and then copying the data over...
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info)
|
||||
{
|
||||
out << "FileInfo: path: " << info.path;
|
||||
out << std::endl;
|
||||
out << "File: " << info.fname;
|
||||
out << " Size: " << info.size;
|
||||
out << std::endl;
|
||||
out << "Hash: " << info.hash;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
249
libretroshare/src/_rsiface/rstypes.h
Normal file
249
libretroshare/src/_rsiface/rstypes.h
Normal file
@ -0,0 +1,249 @@
|
||||
#ifndef RS_TYPES_GUI_INTERFACE_H
|
||||
#define RS_TYPES_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* "$Id: rstypes.h,v 1.7 2007-05-05 16:10:05 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-2006 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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef std::string RsCertId;
|
||||
typedef std::string RsChanId;
|
||||
typedef std::string RsMsgId;
|
||||
typedef std::string RsAuthId;
|
||||
|
||||
const uint32_t FT_STATE_FAILED = 0x0000;
|
||||
const uint32_t FT_STATE_OKAY = 0x0001;
|
||||
const uint32_t FT_STATE_WAITING = 0x0002;
|
||||
const uint32_t FT_STATE_DOWNLOADING = 0x0003;
|
||||
const uint32_t FT_STATE_COMPLETE = 0x0004;
|
||||
|
||||
class TransferInfo
|
||||
{
|
||||
public:
|
||||
/**** 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:
|
||||
|
||||
FileInfo() :flags(0), mId(0) { return; }
|
||||
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 */
|
||||
|
||||
/* Old FileInfo Entries */
|
||||
public:
|
||||
|
||||
static const int kRsFiStatusNone = 0;
|
||||
static const int kRsFiStatusStall = 1;
|
||||
static const int kRsFiStatusProgress = 2;
|
||||
static const int kRsFiStatusDone = 2;
|
||||
|
||||
/* FileInfo(); */
|
||||
|
||||
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;
|
||||
|
||||
bool inRecommend;
|
||||
|
||||
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;
|
||||
|
||||
time_t lastTS;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||
|
||||
|
||||
/* matched to the uPnP states */
|
||||
#define UPNP_STATE_UNINITIALISED 0
|
||||
#define UPNP_STATE_UNAVAILABILE 1
|
||||
#define UPNP_STATE_READY 2
|
||||
#define UPNP_STATE_FAILED_TCP 3
|
||||
#define UPNP_STATE_FAILED_UDP 4
|
||||
#define UPNP_STATE_ACTIVE 5
|
||||
|
||||
class RsConfig
|
||||
{
|
||||
public:
|
||||
std::string ownId;
|
||||
std::string ownName;
|
||||
|
||||
std::string localAddr;
|
||||
int localPort;
|
||||
std::string extAddr;
|
||||
int extPort;
|
||||
std::string extName;
|
||||
|
||||
bool firewalled;
|
||||
bool forwardPort;
|
||||
|
||||
int maxDownloadDataRate; /* kb */
|
||||
int maxUploadDataRate; /* kb */
|
||||
int maxIndivDataRate; /* kb */
|
||||
|
||||
int promptAtBoot; /* popup the password prompt */
|
||||
|
||||
/* older data types */
|
||||
bool DHTActive;
|
||||
bool uPnPActive;
|
||||
|
||||
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 *****************/
|
||||
|
||||
/* This is still rough, implement later! */
|
||||
|
||||
/* text based ones */
|
||||
const std::string TypeExt = "ext";
|
||||
const std::string TypeName = "name";
|
||||
const std::string TypeHash = "hash";
|
||||
const std::string TypeSize = "size";
|
||||
|
||||
const int OpContains = 0x001;
|
||||
const int OpExactMatch = 0x002;
|
||||
const int OpLessThan = 0x003;
|
||||
const int OpGreaterThan = 0x004;
|
||||
|
||||
class Condition
|
||||
{
|
||||
public:
|
||||
|
||||
std::string type;
|
||||
int op;
|
||||
double value;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class SearchRequest
|
||||
{
|
||||
public:
|
||||
int searchId;
|
||||
RsCertId toId; /* all zeros for everyone! */
|
||||
std::list<Condition> tests;
|
||||
};
|
||||
|
||||
|
||||
/********************** For FileCache Interface *****************/
|
||||
|
||||
#define DIR_TYPE_ROOT 0x01
|
||||
#define DIR_TYPE_PERSON 0x02
|
||||
#define DIR_TYPE_DIR 0x04
|
||||
#define DIR_TYPE_FILE 0x08
|
||||
|
||||
/* flags for Directry request -
|
||||
* two types;
|
||||
* (1) Local / Remote (top byte)
|
||||
* (2) Request type: Parent / Child - allows reduction in workload.
|
||||
* (TODO)
|
||||
*/
|
||||
|
||||
#define DIR_FLAGS_LOCAL 0x1000
|
||||
#define DIR_FLAGS_REMOTE 0x2000
|
||||
|
||||
#define DIR_FLAGS_PARENT 0x0001
|
||||
#define DIR_FLAGS_DETAILS 0x0002
|
||||
#define DIR_FLAGS_CHILDREN 0x0004
|
||||
|
||||
class DirStub
|
||||
{
|
||||
public:
|
||||
uint8_t type;
|
||||
std::string name;
|
||||
void *ref;
|
||||
};
|
||||
|
||||
class DirDetails
|
||||
{
|
||||
public:
|
||||
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;
|
||||
|
||||
std::list<DirStub> children;
|
||||
};
|
||||
|
||||
class FileDetail
|
||||
{
|
||||
public:
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
std::string path;
|
||||
uint64_t size;
|
||||
uint32_t age;
|
||||
uint32_t rank;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user