mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Lots of bugfixes and tweaks:
* Switched p3Ranking to share Friends Links as well as own. * Modified rankmsgs to contain source id. * Fixed up rsNotify, added pqiNotify and global function call to get it. * Added notify for Bad Incoming Directory * Added Emergency Incoming directory so RS can keep running. * Added notify for Bad Packet (connecting to V0.3.X) * Added notify for Incomplete Packet Read (not been triggered yet!) * added close() to BinInterface, close on pqissl calls reset() * removed exit(1) calls from pqistreamer, replaced with bio->close(). * Increased Maximum Packet Size for HTML messages. * Fixed Online/Offline Message Forwarding. (TEST). * Increased DHT bootstrap buckets to 4. * Cleaned up much of serialiser debug (was slowing down Mac) * Added directory path to File Listings. * added ConvertSharedFilePath() so correct local dir can be found. * Added ForceDirectoryCheck() and InDirectoryCheck() for file hashing. * removed old TMP cache loading. * switched off Cache debug. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@448 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a76baa5421
commit
5e41b21cef
@ -30,9 +30,9 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/***/
|
||||
/***
|
||||
#define CS_DEBUG 1
|
||||
/***/
|
||||
***/
|
||||
|
||||
bool operator<(const CacheId &a, const CacheId &b)
|
||||
{
|
||||
@ -529,6 +529,9 @@ void CacheStrapper::refreshCache(const CacheData &data)
|
||||
/* we've received an update
|
||||
* send to all online peers + self
|
||||
*/
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<std::string> ids;
|
||||
std::list<std::string>::iterator it;
|
||||
@ -538,6 +541,10 @@ void CacheStrapper::refreshCache(const CacheData &data)
|
||||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
for(it = ids.begin(); it != ids.end(); it++)
|
||||
{
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() Send To: " << *it << std::endl;
|
||||
#endif
|
||||
|
||||
mCacheUpdates.push_back(std::make_pair(*it, data));
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,8 @@
|
||||
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, std::string pid)
|
||||
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
|
||||
pendingDirs(false), pendingForceCacheWrite(false)
|
||||
pendingDirs(false), pendingForceCacheWrite(false),
|
||||
mForceCheck(false), mInCheck(false)
|
||||
|
||||
{
|
||||
updatePeriod = 60;
|
||||
@ -98,6 +99,32 @@ bool FileIndexMonitor::findLocalFile(std::string hash,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::convertSharedFilePath(std::string path, std::string &fullpath)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
fiMutex.lock(); { /* LOCKED DIRS */
|
||||
|
||||
std::cerr << "FileIndexMonitor::convertSharedFilePath() path: " << path << std::endl;
|
||||
|
||||
std::string shpath = RsDirUtil::removeRootDir(path);
|
||||
std::string basedir = RsDirUtil::getRootDir(path);
|
||||
std::string realroot = findRealRoot(basedir);
|
||||
|
||||
/* construct full name */
|
||||
if (realroot.length() > 0)
|
||||
{
|
||||
fullpath = realroot + "/";
|
||||
fullpath += shpath;
|
||||
std::cerr << "FileIndexMonitor::convertSharedFilePath() Found Path: " << fullpath << std::endl;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with stored data */
|
||||
{
|
||||
@ -180,6 +207,11 @@ void FileIndexMonitor::updateCycle()
|
||||
bool moretodo = true;
|
||||
bool fiMods = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
mInCheck = true;
|
||||
}
|
||||
|
||||
while(moretodo)
|
||||
{
|
||||
/* sleep a bit for each loop */
|
||||
@ -527,6 +559,11 @@ void FileIndexMonitor::updateCycle()
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
{
|
||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
mInCheck = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* interface */
|
||||
@ -540,6 +577,27 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
/* interface */
|
||||
void FileIndexMonitor::forceDirectoryCheck()
|
||||
{
|
||||
fiMutex.lock(); { /* LOCKED DIRS */
|
||||
|
||||
if (!mInCheck)
|
||||
mForceCheck = true;
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
|
||||
/* interface */
|
||||
bool FileIndexMonitor::inDirectoryCheck()
|
||||
{
|
||||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
|
||||
return mInCheck;
|
||||
}
|
||||
|
||||
|
||||
bool FileIndexMonitor::internal_setSharedDirectories()
|
||||
{
|
||||
int i;
|
||||
@ -547,10 +605,18 @@ bool FileIndexMonitor::internal_setSharedDirectories()
|
||||
|
||||
if (!pendingDirs)
|
||||
{
|
||||
if (mForceCheck)
|
||||
{
|
||||
mForceCheck = false;
|
||||
fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
return true;
|
||||
}
|
||||
|
||||
fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mForceCheck = false;
|
||||
pendingDirs = false;
|
||||
pendingForceCacheWrite = true;
|
||||
|
||||
|
@ -74,6 +74,9 @@ virtual ~FileIndexMonitor();
|
||||
/* external interface for filetransfer */
|
||||
bool findLocalFile(std::string hash, std::string &fullpath, uint64_t &size);
|
||||
|
||||
/* external interface for local access to files */
|
||||
bool convertSharedFilePath(std::string path, std::string &fullpath);
|
||||
|
||||
|
||||
/* Interacting with CacheSource */
|
||||
/* overloaded from CacheSource */
|
||||
@ -87,7 +90,8 @@ void updateCycle();
|
||||
|
||||
void setSharedDirectories(std::list<std::string> dirs);
|
||||
void setPeriod(int insecs);
|
||||
|
||||
void forceDirectoryCheck();
|
||||
bool inDirectoryCheck();
|
||||
/* util fns */
|
||||
|
||||
private:
|
||||
@ -109,6 +113,10 @@ bool hashFile(std::string path, FileEntry &fi); /* To Implement */
|
||||
bool pendingDirs;
|
||||
bool pendingForceCacheWrite;
|
||||
|
||||
/* flags to force Check, to tell if we're in check */
|
||||
bool mForceCheck;
|
||||
bool mInCheck;
|
||||
|
||||
std::list<std::string> pendingDirList;
|
||||
bool internal_setSharedDirectories();
|
||||
|
||||
|
@ -297,9 +297,6 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f
|
||||
details.age = time(NULL) - file->modtime;
|
||||
details.rank = file->pop;
|
||||
|
||||
/* TODO Path */
|
||||
details.path = "";
|
||||
|
||||
/* find parent pointer, and row */
|
||||
DirEntry *parent = file->parent;
|
||||
if (!parent) /* then must be root */
|
||||
@ -321,6 +318,9 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f
|
||||
parent=file->parent;
|
||||
}
|
||||
|
||||
/* NEW add path (to dir - if dir, or parent dir - if file? */
|
||||
details.path = parent->path;
|
||||
|
||||
while(parent->parent)
|
||||
parent = parent->parent;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "util/rsprint.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "rsiface/rsnotify.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
/* Network setup States */
|
||||
|
||||
@ -586,7 +586,8 @@ void p3ConnectMgr::netUdpCheck()
|
||||
mStunMoreRequired = false; /* no point -> unreachable (EXT) */
|
||||
|
||||
/* send a system warning message */
|
||||
if (rsNotify)
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Bad Firewall Configuration";
|
||||
@ -603,8 +604,7 @@ void p3ConnectMgr::netUdpCheck()
|
||||
msg += " (2) enabling UPnP, or\n";
|
||||
msg += " (3) get a new (approved) Firewall/Router\n";
|
||||
|
||||
rsNotify->AddSysMessage(0, RS_SYS_WARNING,
|
||||
title, msg);
|
||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1051,13 +1051,15 @@ void p3ConnectMgr::tickMonitors()
|
||||
#endif
|
||||
|
||||
/* notify GUI */
|
||||
if ((peer.actions & RS_PEER_CONNECTED) &&
|
||||
(rsNotify))
|
||||
if (peer.actions & RS_PEER_CONNECTED)
|
||||
{
|
||||
rsNotify->AddPopupMessage(RS_POPUP_CONNECT,
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
notify->AddPopupMessage(RS_POPUP_CONNECT,
|
||||
peer.id, "Peer Online: ");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* do the Others as well! */
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
#define DHT_DEFAULT_WAITTIME 1 /* Std sleep break period */
|
||||
|
||||
#define DHT_NUM_BOOTSTRAP_BINS 2
|
||||
#define DHT_NUM_BOOTSTRAP_BINS 4
|
||||
#define DHT_MIN_BOOTSTRAP_REQ_PERIOD 30
|
||||
|
||||
void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out);
|
||||
|
@ -29,6 +29,11 @@
|
||||
/* external reference point */
|
||||
RsNotify *rsNotify = NULL;
|
||||
|
||||
pqiNotify *getPqiNotify()
|
||||
{
|
||||
return ((p3Notify *) rsNotify);
|
||||
}
|
||||
|
||||
/* Output for retroshare-gui */
|
||||
bool p3Notify::NotifySysMessage(uint32_t &sysid, uint32_t &type,
|
||||
std::string &title, std::string &msg)
|
||||
|
@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "rsiface/rsnotify.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
@ -49,7 +50,8 @@ class p3NotifyPopupMsg
|
||||
std::string msg;
|
||||
};
|
||||
|
||||
class p3Notify: public RsNotify
|
||||
|
||||
class p3Notify: public RsNotify, public pqiNotify
|
||||
{
|
||||
public:
|
||||
|
||||
@ -68,10 +70,10 @@ virtual bool GetPopupMessageList(std::map<uint32_t, std::string> &list);
|
||||
virtual bool SetSysMessageMode(uint32_t sysid, uint32_t mode);
|
||||
virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode);
|
||||
|
||||
/* Input from libretroshare */
|
||||
|
||||
/* Overloaded from pqiNotify */
|
||||
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg);
|
||||
virtual bool AddSysMessage(uint32_t sysid, uint32_t type,
|
||||
std::string title, std::string msg);
|
||||
virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -319,6 +319,9 @@ virtual int isactive() = 0;
|
||||
virtual bool moretoread() = 0;
|
||||
virtual bool cansend() = 0;
|
||||
|
||||
/* method for streamer to shutdown bininterface */
|
||||
virtual int close() = 0;
|
||||
|
||||
/* if hashing data */
|
||||
virtual std::string gethash() = 0;
|
||||
virtual uint64_t bytecount() { return 0; }
|
||||
|
@ -89,6 +89,16 @@ BinFileInterface::~BinFileInterface()
|
||||
fclose(buf);
|
||||
}
|
||||
}
|
||||
|
||||
int BinFileInterface::close()
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
fclose(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BinFileInterface::senddata(void *data, int len)
|
||||
{
|
||||
@ -179,6 +189,19 @@ BinMemInterface::~BinMemInterface()
|
||||
return;
|
||||
}
|
||||
|
||||
int BinMemInterface::close()
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
size = 0;
|
||||
recvsize = 0;
|
||||
readloc = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* some fns to mess with the memory */
|
||||
int BinMemInterface::fseek(int loc)
|
||||
{
|
||||
@ -514,6 +537,15 @@ bool NetBinDummy::cansend()
|
||||
return dummyConnected;
|
||||
}
|
||||
|
||||
int NetBinDummy::close()
|
||||
{
|
||||
std::cerr << "NetBinDummy::close() ";
|
||||
printNetBinID(std::cerr, PeerId(), type);
|
||||
std::cerr << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string NetBinDummy::gethash()
|
||||
{
|
||||
std::cerr << "NetBinDummy::gethash() ";
|
||||
|
@ -55,7 +55,7 @@ virtual bool moretoread()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual int close();
|
||||
virtual bool cansend() { return (bin_flags | BIN_FLAGS_WRITEABLE); }
|
||||
virtual bool bandwidthLimited() { return false; }
|
||||
|
||||
@ -106,6 +106,7 @@ virtual bool moretoread()
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int close();
|
||||
virtual bool cansend() { return (bin_flags | BIN_FLAGS_WRITEABLE); }
|
||||
virtual bool bandwidthLimited() { return false; }
|
||||
|
||||
@ -146,6 +147,8 @@ virtual int netstatus();
|
||||
virtual int isactive();
|
||||
virtual bool moretoread();
|
||||
virtual bool cansend();
|
||||
virtual int close();
|
||||
|
||||
virtual std::string gethash();
|
||||
|
||||
private:
|
||||
|
@ -177,6 +177,12 @@ int pqissl::disconnect()
|
||||
return reset();
|
||||
}
|
||||
|
||||
/* BinInterface version of reset() for pqistreamer */
|
||||
int pqissl::close()
|
||||
{
|
||||
return reset();
|
||||
}
|
||||
|
||||
// put back on the listening queue.
|
||||
int pqissl::reset()
|
||||
{
|
||||
|
@ -116,6 +116,8 @@ virtual int netstatus();
|
||||
virtual int isactive();
|
||||
virtual bool moretoread();
|
||||
virtual bool cansend();
|
||||
|
||||
virtual int close(); /* BinInterface version of reset() */
|
||||
virtual std::string gethash(); /* not used here */
|
||||
virtual bool bandwidthLimited();
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <sstream>
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
const int pqistreamerzone = 8221;
|
||||
|
||||
@ -520,7 +521,34 @@ int pqistreamer::handleincoming()
|
||||
if (extralen > maxlen - blen)
|
||||
{
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, "ERROR: Read Packet too Big!");
|
||||
exit(1);
|
||||
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Bad Packet Read";
|
||||
|
||||
std::string msg;
|
||||
msg += " **** WARNING **** \n";
|
||||
msg += "Retroshare has caught a BAD Packet Read";
|
||||
msg += "\n";
|
||||
msg += "This is normally caused by connecting to an";
|
||||
msg += " OLD version of Retroshare";
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
msg += "Please get your friends to upgrade to the latest version";
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
msg += "If you are sure the error was not caused by an old version";
|
||||
msg += "\n";
|
||||
msg += "Please report the problem to Retroshare's developers";
|
||||
msg += "\n";
|
||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
}
|
||||
bio->close();
|
||||
return -1;
|
||||
|
||||
// Used to exit now! exit(1);
|
||||
}
|
||||
|
||||
if (extralen > 0)
|
||||
@ -534,10 +562,27 @@ int pqistreamer::handleincoming()
|
||||
out << tmplen << "/" << extralen << ")" << std::endl;
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out.str());
|
||||
|
||||
// temp to catch this....
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Error Completing Read";
|
||||
|
||||
std::string msg;
|
||||
msg += " **** WARNING **** \n";
|
||||
msg += "Retroshare has experienced an unexpected Read ERROR";
|
||||
msg += "\n";
|
||||
msg += "Please contact the developers.";
|
||||
msg += "\n";
|
||||
|
||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
}
|
||||
bio->close();
|
||||
return -1;
|
||||
|
||||
// if it is triggered ... need to modify code.
|
||||
// XXXX Bug to fix!
|
||||
exit(1);
|
||||
//exit(1);
|
||||
|
||||
// error....
|
||||
inReadBytes(readbytes);
|
||||
|
@ -193,6 +193,10 @@ virtual int StartupRetroShare(RsInit *config) = 0;
|
||||
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
||||
|
||||
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath) = 0;
|
||||
virtual void ForceDirectoryCheck() = 0;
|
||||
virtual bool InDirectoryCheck() = 0;
|
||||
|
||||
/****************************************/
|
||||
/* Search Actions */
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<FileDetail> &results) = 0;
|
||||
|
@ -65,11 +65,6 @@ virtual bool GetPopupMessageList(std::map<uint32_t, std::string> &list) = 0;
|
||||
virtual bool SetSysMessageMode(uint32_t sysid, uint32_t mode) = 0;
|
||||
virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode) = 0;
|
||||
|
||||
/* Input from libretroshare */
|
||||
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg) = 0;
|
||||
virtual bool AddSysMessage(uint32_t sysid, uint32_t type,
|
||||
std::string title, std::string msg) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -357,4 +357,47 @@ int RsServer::SearchBoolExp(Expression *exp, std::list<FileDetail> &results)
|
||||
return val;
|
||||
}
|
||||
|
||||
bool RsServer::ConvertSharedFilePath(std::string path, std::string &fullpath)
|
||||
{
|
||||
lockRsCore(); /* LOCK */
|
||||
|
||||
/* call to filedexserver */
|
||||
bool val = server->ConvertSharedFilePath(path, fullpath);
|
||||
|
||||
/* done! */
|
||||
/* unlock Mutexes */
|
||||
unlockRsCore(); /* UNLOCK */
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
void RsServer::ForceDirectoryCheck()
|
||||
{
|
||||
lockRsCore(); /* LOCK */
|
||||
|
||||
/* call to filedexserver */
|
||||
server->ForceDirectoryCheck();
|
||||
|
||||
/* done! */
|
||||
/* unlock Mutexes */
|
||||
unlockRsCore(); /* UNLOCK */
|
||||
}
|
||||
|
||||
|
||||
bool RsServer::InDirectoryCheck()
|
||||
{
|
||||
lockRsCore(); /* LOCK */
|
||||
|
||||
/* call to filedexserver */
|
||||
bool val = server->InDirectoryCheck();
|
||||
|
||||
/* done! */
|
||||
/* unlock Mutexes */
|
||||
unlockRsCore(); /* UNLOCK */
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -472,13 +472,16 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||
|
||||
std::string certConfigFile = config->basedir.c_str();
|
||||
std::string certNeighDir = config->basedir.c_str();
|
||||
std::string emergencySaveDir = config->basedir.c_str();
|
||||
if (certConfigFile != "")
|
||||
{
|
||||
certConfigFile += "/";
|
||||
certNeighDir += "/";
|
||||
emergencySaveDir += "/";
|
||||
}
|
||||
certConfigFile += configConfFile;
|
||||
certNeighDir += configCertDir;
|
||||
emergencySaveDir += "Downloads";
|
||||
|
||||
/* if we've loaded an old format file! */
|
||||
bool oldFormat = false;
|
||||
@ -510,8 +513,10 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||
server = new filedexserver();
|
||||
server->setConfigDir(config->basedir.c_str());
|
||||
server->setSaveDir(config->homePath.c_str()); /* Default Save Dir - config will overwrite */
|
||||
|
||||
server->setSearchInterface(pqih, mAuthMgr, mConnMgr);
|
||||
server->setFileCallback(ownId, mCacheStrapper, mCacheTransfer, &(getNotify()));
|
||||
server->setEmergencySaveDir(emergencySaveDir); /* (after setFileCallback()) if saveDir invalid */
|
||||
|
||||
mConfigMgr = new p3ConfigMgr(mAuthMgr, config->basedir, "rs-v0.4.cfg", "rs-v0.4.sgn");
|
||||
mGeneralConfig = new p3GeneralConfig();
|
||||
@ -532,7 +537,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||
std::string localcachedir = config_dir + "/cache/local";
|
||||
std::string remotecachedir = config_dir + "/cache/remote";
|
||||
|
||||
mRanking = new p3Ranking(RS_SERVICE_TYPE_RANK,
|
||||
mRanking = new p3Ranking(mConnMgr, RS_SERVICE_TYPE_RANK,
|
||||
mCacheStrapper, mCacheTransfer,
|
||||
localcachedir, remotecachedir, 3600 * 24 * 30);
|
||||
|
||||
|
@ -130,6 +130,9 @@ virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags);
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<FileDetail> &results);
|
||||
virtual int SearchBoolExp(Expression *exp, std::list<FileDetail> &results);
|
||||
|
||||
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath);
|
||||
virtual void ForceDirectoryCheck();
|
||||
virtual bool InDirectoryCheck();
|
||||
|
||||
/* Actions For Upload/Download */
|
||||
|
||||
|
@ -27,7 +27,10 @@
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rsbaseitems.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
***/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*************************************************************************/
|
||||
@ -146,24 +149,25 @@ bool RsFileItemSerialiser::serialiseReq(RsFileRequest *item, void *data, uin
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() Header: " << ok << std::endl;
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, item->fileoffset);
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() Fileoffset: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->chunksize);
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() Chunksize: " << ok << std::endl;
|
||||
ok &= item->file.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() FileItem: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -269,19 +273,22 @@ bool RsFileItemSerialiser::serialiseData(RsFileData *item, void *data, uint3
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseData() Header: " << ok << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= item->fd.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsFileItemSerialiser::serialiseData() TlvFileData: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseData() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -453,23 +460,24 @@ bool RsCacheItemSerialiser::serialiseReq(RsCacheRequest *item, void *data, u
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseReq() Header: " << ok << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cacheType);
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseReq() cacheType: " << ok << std::endl;
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cacheSubId);
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseReq() cacheSubId: " << ok << std::endl;
|
||||
ok &= item->file.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseReq() FileItem: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseReq() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -580,23 +588,24 @@ bool RsCacheItemSerialiser::serialiseItem(RsCacheItem *item, void *data, uin
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cacheType);
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseItem() cacheType: " << ok << std::endl;
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cacheSubId);
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseItem() cacheSubId: " << ok << std::endl;
|
||||
ok &= item->file.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsCacheItemSerialiser::serialiseItem() FileItem: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileItemSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -27,7 +27,10 @@
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
***/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*************************************************************************/
|
||||
@ -166,43 +169,36 @@ bool RsFileTransferSerialiser::serialiseTransfer(RsFileTransfer *item, void
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() Header: " << ok << std::endl;
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= item->file.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() FileItem: " << ok << std::endl;
|
||||
ok &= item->allPeerIds.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() allPeerIds: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->cPeerId);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() cId: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->state);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() State: " << ok << std::endl;
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->in);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() In/Out: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, item->transferred);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() Transferred: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->crate);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() crate: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->trate);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() trate: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->lrate);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() lrate: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->ltransfer);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() ltransfer: " << ok << std::endl;
|
||||
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -242,29 +238,19 @@ RsFileTransfer *RsFileTransferSerialiser::deserialiseTransfer(void *data, uint32
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= item->file.GetTlv(data, rssize, &offset);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() FileItem: " << ok << std::endl;
|
||||
ok &= item->allPeerIds.GetTlv(data, rssize, &offset);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() allPeerIds: " << ok << std::endl;
|
||||
|
||||
/* string */
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->cPeerId);
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() cId: " << ok << std::endl;
|
||||
|
||||
/* data */
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->state));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() State: " << ok << std::endl;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->in));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() In/Out: " << ok << std::endl;
|
||||
ok &= getRawUInt64(data, rssize, &offset, &(item->transferred));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() Transferred: " << ok << std::endl;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->crate));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() crate: " << ok << std::endl;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->trate));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() trate: " << ok << std::endl;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->lrate));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() lrate: " << ok << std::endl;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->ltransfer));
|
||||
std::cerr << "RsFileTransferSerialiser::serialiseTransfer() ltransfer: " << ok << std::endl;
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
@ -337,7 +323,9 @@ RsItem *RsGeneralConfigSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
|
||||
(RS_PKT_TYPE_GENERAL_CONFIG != getRsItemType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::deserialise() Wrong Type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
@ -400,20 +388,23 @@ bool RsGeneralConfigSerialiser::serialiseKeyValueSet(RsConfigKeyValueSet *it
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::serialiseKeyValueSet() Header: " << ok << std::endl;
|
||||
std::cerr << "RsGeneralConfigSerialiser::serialiseKeyValueSet() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= item->tlvkvs.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsGeneralConfigSerialiser::serialiseKeyValueSet() kvs: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::serialiseKeyValueSet() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -433,13 +424,17 @@ RsConfigKeyValueSet *RsGeneralConfigSerialiser::deserialiseKeyValueSet(void *dat
|
||||
(RS_PKT_TYPE_GENERAL_CONFIG != getRsItemType(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_KEY_VALUE != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::deserialiseKeyValueSet() Wrong Type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::deserialiseKeyValueSet() Not Enough Space" << std::endl;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
@ -456,11 +451,13 @@ RsConfigKeyValueSet *RsGeneralConfigSerialiser::deserialiseKeyValueSet(void *dat
|
||||
offset += 8;
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= item->tlvkvs.GetTlv(data, rssize, &offset),
|
||||
std::cerr << "RsGeneralConfigSerialiser::deserialiseKeyValueSet() kvs: " << ok << std::endl;
|
||||
ok &= item->tlvkvs.GetTlv(data, rssize, &offset);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::deserialiseKeyValueSet() offset != rssize" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
@ -468,7 +465,9 @@ RsConfigKeyValueSet *RsGeneralConfigSerialiser::deserialiseKeyValueSet(void *dat
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGeneralConfigSerialiser::deserialiseKeyValueSet() ok = false" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
@ -531,7 +530,9 @@ RsItem *RsPeerConfigSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
|
||||
(RS_PKT_TYPE_PEER_CONFIG != getRsItemType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialise() Wrong Type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
@ -630,35 +631,28 @@ bool RsPeerConfigSerialiser::serialiseNet(RsPeerNetItem *item, void *data, uint3
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() Header: " << ok << std::endl;
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() Header: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() pid: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->netMode); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() netMode: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->visState); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() visState: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->lastContact); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() lastContact: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, TLV_TYPE_IPV4_LOCAL, &(item->localaddr));
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() localaddr: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, TLV_TYPE_IPV4_REMOTE, &(item->remoteaddr));
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() remoteaddr: " << ok << std::endl;
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialise() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -698,22 +692,11 @@ RsPeerNetItem *RsPeerConfigSerialiser::deserialiseNet(void *data, uint32_t *size
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() pid: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->netMode)); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() netMode: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->visState)); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() visState: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->lastContact)); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() lastContact: " << ok << std::endl;
|
||||
|
||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_LOCAL, &(item->localaddr));
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() localaddr: " << ok << std::endl;
|
||||
|
||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &(item->remoteaddr));
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() remoteaddr: " << ok << std::endl;
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
@ -776,20 +759,23 @@ bool RsPeerConfigSerialiser::serialiseStun(RsPeerStunItem *item, void *data, uin
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseStun() Header: " << ok << std::endl;
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseStun() Header: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= item->stunList.SetTlv(data, tlvsize, &offset); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseStun() stunList: " << ok << std::endl;
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseStun() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -829,7 +815,6 @@ RsPeerStunItem *RsPeerConfigSerialiser::deserialiseStun(void *data, uint32_t *si
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= item->stunList.GetTlv(data, rssize, &offset); /* Mandatory */
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseStun() stunList: " << ok << std::endl;
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
@ -936,8 +921,10 @@ bool RsCacheConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *size)
|
||||
|
||||
ok &=setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() Header: " << ok << std::endl;
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() Size: " << size << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
@ -945,34 +932,20 @@ bool RsCacheConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *size)
|
||||
/* add the mandatory parts first */
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() peerid: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cachetypeid);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() cacheTypeId: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cachesubid);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() cacheSubId: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PATH, item->path);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() path: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() name: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_HASH_SHA1, item->hash);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() hash: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, item->size);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() size: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->recvd);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() recvd: " << ok << std::endl;
|
||||
|
||||
|
||||
if (offset !=tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsConfigSerialiser::serialisertransfer() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -1012,28 +985,13 @@ RsItem *RsCacheConfigSerialiser::deserialise(void *data, uint32_t *size)
|
||||
/* get mandatory parts first */
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
std::cerr << "RsCacheConfigSerialiser::deserialise() peerid: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->cachetypeid));
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() cacheTypeId: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->cachesubid));
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() cacheSubId: " << ok << std::endl;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PATH, item->path);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() path: " << ok << std::endl;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() name: " << ok << std::endl;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_HASH_SHA1, item->hash);
|
||||
std::cerr << "RsCacheConfigSerialiser::deserialise() hash: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt64(data, rssize, &offset, &(item->size));
|
||||
std::cerr << "RsCacheConfigSerialiser::deserialise() size: " << ok << std::endl;
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->recvd));
|
||||
std::cerr << "RsCacheConfigSerialiser::deserialise() recvd: " << ok << std::endl;
|
||||
|
||||
|
||||
if (offset != rssize)
|
||||
|
@ -33,7 +33,10 @@
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
***/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*************************************************************************/
|
||||
@ -168,8 +171,10 @@ bool RsDiscSerialiser::serialiseItem(RsDiscItem *item, void *data, uint32_t
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
@ -177,19 +182,17 @@ bool RsDiscSerialiser::serialiseItem(RsDiscItem *item, void *data, uint32_t
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset,
|
||||
TLV_TYPE_IPV4_LOCAL, &(item->laddr));
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() laddress: " << ok << std::endl;
|
||||
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset,
|
||||
TLV_TYPE_IPV4_REMOTE, &(item->saddr));
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() saddress: " << ok << std::endl;
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->contact_tf);
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() contact_tf: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->discFlags);
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() discFlags: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -208,13 +211,17 @@ RsDiscItem *RsDiscSerialiser::deserialiseItem(void *data, uint32_t *pktsize)
|
||||
(RS_SERVICE_TYPE_DISC != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_DISC_ITEM != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() Wrong Type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() Not Enough Space" << std::endl;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
@ -233,18 +240,16 @@ RsDiscItem *RsDiscSerialiser::deserialiseItem(void *data, uint32_t *pktsize)
|
||||
/* get mandatory parts first */
|
||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset,
|
||||
TLV_TYPE_IPV4_LOCAL, &(item->laddr));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() laddress: " << ok << std::endl;
|
||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset,
|
||||
TLV_TYPE_IPV4_REMOTE, &(item->saddr));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() saddress: " << ok << std::endl;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->contact_tf));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() contact_tf: " << ok << std::endl;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->discFlags));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() discFlags: " << ok << std::endl;
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() offset != rssize" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
@ -252,7 +257,9 @@ RsDiscItem *RsDiscSerialiser::deserialiseItem(void *data, uint32_t *pktsize)
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseItem() ok = false" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
@ -336,8 +343,10 @@ bool RsDiscSerialiser::serialiseReply(RsDiscReply *item, void *data, uint32_
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() Header: " << ok << std::endl;
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
@ -345,26 +354,22 @@ bool RsDiscSerialiser::serialiseReply(RsDiscReply *item, void *data, uint32_
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset,
|
||||
TLV_TYPE_IPV4_LOCAL, &(item->laddr));
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() laddress: " << ok << std::endl;
|
||||
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset,
|
||||
TLV_TYPE_IPV4_REMOTE, &(item->saddr));
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() saddress: " << ok << std::endl;
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->contact_tf);
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() contact_tf: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->discFlags);
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() discFlags: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset,
|
||||
TLV_TYPE_STR_PEERID, item->aboutId);
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() aboutId: " << ok << std::endl;
|
||||
|
||||
ok &= item->certDER.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() discFlags: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::serialiseReply() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -383,13 +388,17 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
||||
(RS_SERVICE_TYPE_DISC != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_DISC_REPLY != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() Wrong Type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() pktsize != rssize" << std::endl;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
@ -408,25 +417,21 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
||||
/* get mandatory parts first */
|
||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset,
|
||||
TLV_TYPE_IPV4_LOCAL, &(item->laddr));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() laddress: " << ok << std::endl;
|
||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset,
|
||||
TLV_TYPE_IPV4_REMOTE, &(item->saddr));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() saddress: " << ok << std::endl;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->contact_tf));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() contact_tf: " << ok << std::endl;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->discFlags));
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() discFlags: " << ok << std::endl;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset,
|
||||
TLV_TYPE_STR_PEERID, item->aboutId);
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() aboutId: " << ok << std::endl;
|
||||
ok &= item->certDER.GetTlv(data, rssize, &offset);
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() certDER: " << ok << std::endl;
|
||||
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() offset != rssize" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
@ -434,7 +439,9 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsDiscSerialiser::deserialiseReply() ok = false" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -27,7 +27,10 @@
|
||||
#include "serialiser/rsgameitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
***/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*************************************************************************/
|
||||
@ -103,31 +106,29 @@ bool RsGameSerialiser::serialiseItem(RsGameItem *item, void *data, uint32_t
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->serviceId);
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() serviceId: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->numPlayers);
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() numPlayers: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->msg);
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() msg: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->gameId);
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() gameId: " << ok << std::endl;
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_COMMENT, item->gameComment);
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() gameComment: " << ok << std::endl;
|
||||
ok &= item->players.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() players: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsGameSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -28,7 +28,10 @@
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
***/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*************************************************************************/
|
||||
@ -90,24 +93,25 @@ bool RsChatSerialiser::serialiseItem(RsChatItem *item, void *data, uint32_t
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->chatFlags);
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() chatFlags: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() sendTime: " << ok << std::endl;
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() Message: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -283,38 +287,33 @@ bool RsMsgSerialiser::serialiseItem(RsMsgItem *item, void *data, uint32_t *p
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->msgFlags);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() msgFlags: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() sendTime: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->recvTime);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() recvTime: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvWideString(data,tlvsize,&offset,TLV_TYPE_WSTR_SUBJECT,item->subject);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Subject: " << ok << std::endl;
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Message: " << ok << std::endl;
|
||||
|
||||
ok &= item->msgto.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() MsgTo: " << ok << std::endl;
|
||||
ok &= item->msgcc.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() MsgCC: " << ok << std::endl;
|
||||
ok &= item->msgbcc.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() MsgBCC: " << ok << std::endl;
|
||||
|
||||
ok &= item->attachment.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Attachment: " << ok << std::endl;
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -69,6 +69,7 @@ std::ostream &RsRankMsg::print(std::ostream &out, uint16_t indent)
|
||||
void RsRankLinkMsg::clear()
|
||||
{
|
||||
rid.clear();
|
||||
pid.clear();
|
||||
timestamp = 0;
|
||||
title.clear();
|
||||
comment.clear();
|
||||
@ -82,6 +83,8 @@ std::ostream &RsRankLinkMsg::print(std::ostream &out, uint16_t indent)
|
||||
uint16_t int_Indent = indent + 2;
|
||||
printIndent(out, int_Indent);
|
||||
out << "rid: " << rid << std::endl;
|
||||
printIndent(out, int_Indent);
|
||||
out << "pid: " << pid << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "timestamp: " << timestamp << std::endl;
|
||||
@ -110,6 +113,7 @@ uint32_t RsRankSerialiser::sizeLink(RsRankLinkMsg *item)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += GetTlvStringSize(item->rid);
|
||||
s += GetTlvStringSize(item->pid);
|
||||
s += 4; /* timestamp */
|
||||
s += GetTlvWideStringSize(item->title);
|
||||
s += GetTlvWideStringSize(item->comment);
|
||||
@ -143,6 +147,8 @@ bool RsRankSerialiser::serialiseLink(RsRankLinkMsg *item, void *data, uint32
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->rid);
|
||||
std::cerr << "RsRankLinkSerialiser::serialiseLink() rid: " << ok << std::endl;
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
std::cerr << "RsRankLinkSerialiser::serialiseLink() pid: " << ok << std::endl;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->timestamp);
|
||||
std::cerr << "RsRankLinkSerialiser::serialiseLink() timestamp: " << ok << std::endl;
|
||||
@ -178,7 +184,7 @@ RsRankLinkMsg *RsRankSerialiser::deserialiseLink(void *data, uint32_t *pktsize)
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_RANK != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_RANK_LINK != getRsItemSubType(rstype)))
|
||||
(RS_PKT_SUBTYPE_RANK_LINK2 != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
@ -200,6 +206,7 @@ RsRankLinkMsg *RsRankSerialiser::deserialiseLink(void *data, uint32_t *pktsize)
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->rid);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->timestamp));
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
|
||||
|
@ -32,8 +32,9 @@
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_LINK = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_PHOTO = 0x03;
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_OLD_LINK = 0x02; /* defunct - don't use! */
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_LINK2 = 0x03;
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_PHOTO = 0x04;
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
@ -49,6 +50,7 @@ virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string rid; /* Random Id */
|
||||
std::string pid; /* Peer Id (cannot use RsItem::PeerId - as FoF transport!) */
|
||||
uint32_t timestamp;
|
||||
std::wstring title;
|
||||
std::wstring comment;
|
||||
@ -57,12 +59,13 @@ virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
/* Flags */
|
||||
const uint32_t RS_LINK_TYPE_WEB = 0x0001;
|
||||
const uint32_t RS_LINK_TYPE_OFF = 0x0002;
|
||||
|
||||
class RsRankLinkMsg: public RsRankMsg
|
||||
{
|
||||
public:
|
||||
RsRankLinkMsg()
|
||||
:RsRankMsg(RS_PKT_SUBTYPE_RANK_LINK) { return; }
|
||||
:RsRankMsg(RS_PKT_SUBTYPE_RANK_LINK2) { return; }
|
||||
virtual ~RsRankLinkMsg() { return; }
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
@ -28,11 +28,13 @@
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
/***
|
||||
#define RSSERIAL_DEBUG 1
|
||||
***/
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
@ -438,7 +440,12 @@ std::ostream &RsRawItem::print(std::ostream &out, uint16_t indent)
|
||||
|
||||
uint32_t getRsPktMaxSize()
|
||||
{
|
||||
return 65535; /* 2^16 */
|
||||
//return 65535; /* 2^16 (old artifical low size) */
|
||||
//return 1048575; /* 2^20 -1 (Too Big! - must remove fixed static buffers first) */
|
||||
/* Remember that every pqistreamer allocates an input buffer of this size!
|
||||
* So don't make it too big!
|
||||
*/
|
||||
return 262143; /* 2^18 -1 */
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,6 +146,13 @@ void filedexserver::setSaveDir(std::string d)
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
}
|
||||
|
||||
void filedexserver::setEmergencySaveDir(std::string s)
|
||||
{
|
||||
if (ftFiler)
|
||||
{
|
||||
ftFiler -> setEmergencyBasePath(s);
|
||||
}
|
||||
}
|
||||
|
||||
bool filedexserver::getSaveIncSearch()
|
||||
{
|
||||
@ -198,6 +205,29 @@ int filedexserver::reScanDirs()
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool filedexserver::ConvertSharedFilePath(std::string path, std::string &fullpath)
|
||||
{
|
||||
if (fimon)
|
||||
return fimon->convertSharedFilePath(path, fullpath);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void filedexserver::ForceDirectoryCheck()
|
||||
{
|
||||
if (fimon)
|
||||
fimon->forceDirectoryCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
bool filedexserver::InDirectoryCheck()
|
||||
{
|
||||
if (fimon)
|
||||
return fimon->inDirectoryCheck();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*************************************** NEW File Cache Stuff ****************************/
|
||||
|
||||
void filedexserver::initialiseFileStore()
|
||||
@ -234,41 +264,6 @@ void filedexserver::setFileCallback(std::string ownId, CacheStrapper *strappe
|
||||
CachePair cp(fimon, fiStore, CacheId(RS_SERVICE_TYPE_FILE_INDEX, 0));
|
||||
mCacheStrapper -> addCachePair(cp);
|
||||
|
||||
#if 0
|
||||
/************ TMP HACK LOAD until new serialiser is finished */
|
||||
/* get filename and hash from configuration */
|
||||
std::string localCacheFile; // = getSSLRoot()->getSetting(LOCAL_CACHE_FILE_KEY);
|
||||
std::string localCacheHash; // = getSSLRoot()->getSetting(LOCAL_CACHE_HASH_KEY);
|
||||
std::string localCacheSize; // = getSSLRoot()->getSetting(LOCAL_CACHE_SIZE_KEY);
|
||||
|
||||
std::list<std::string> saveLocalCaches;
|
||||
std::list<std::string> saveRemoteCaches;
|
||||
|
||||
if ((localCacheFile != "") &&
|
||||
(localCacheHash != "") &&
|
||||
(localCacheSize != ""))
|
||||
{
|
||||
/* load it up! */
|
||||
std::string loadCacheFile = localcachedir + "/" + localCacheFile;
|
||||
CacheData cd;
|
||||
cd.pid = ownId;
|
||||
cd.cid = CacheId(RS_SERVICE_TYPE_FILE_INDEX, 0);
|
||||
cd.name = localCacheFile;
|
||||
cd.path = localcachedir;
|
||||
cd.hash = localCacheHash;
|
||||
cd.size = atoi(localCacheSize.c_str());
|
||||
fimon -> loadLocalCache(cd);
|
||||
|
||||
saveLocalCaches.push_back(cd.name);
|
||||
}
|
||||
|
||||
/* cleanup cache directories */
|
||||
RsDirUtil::cleanupDirectory(localcachedir, saveLocalCaches);
|
||||
RsDirUtil::cleanupDirectory(remotecachedir, saveRemoteCaches); /* clean up all */
|
||||
|
||||
/************ TMP HACK LOAD until new serialiser is finished */
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,13 @@ int getFile(std::string fname, std::string hash,
|
||||
void clear_old_transfers();
|
||||
void cancelTransfer(std::string fname, std::string hash, uint32_t size);
|
||||
|
||||
|
||||
// access to search info is also required.
|
||||
|
||||
bool ConvertSharedFilePath(std::string path, std::string &fullpath);
|
||||
void ForceDirectoryCheck();
|
||||
bool InDirectoryCheck();
|
||||
|
||||
std::list<std::string> &getSearchDirectories();
|
||||
int addSearchDirectory(std::string dir);
|
||||
int removeSearchDirectory(std::string dir);
|
||||
@ -87,6 +92,8 @@ int check_dBUpdate();
|
||||
|
||||
std::string getSaveDir();
|
||||
void setSaveDir(std::string d);
|
||||
void setEmergencySaveDir(std::string s);
|
||||
|
||||
void setConfigDir(std::string d) { config_dir = d; }
|
||||
bool getSaveIncSearch();
|
||||
void setSaveIncSearch(bool v);
|
||||
|
@ -119,6 +119,7 @@ virtual std::list<RsFileTransfer *> getStatus() = 0;
|
||||
|
||||
public:
|
||||
virtual void setSaveBasePath(std::string s) = 0;
|
||||
virtual void setEmergencyBasePath(std::string s) = 0;
|
||||
virtual int recvFileInfo(ftFileRequest *in) = 0;
|
||||
virtual ftFileRequest * sendFileInfo() = 0;
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <sstream>
|
||||
@ -1111,10 +1112,77 @@ int ftfiler::initiateFileTransfer(ftFileStatus *s)
|
||||
partialpath += PARTIAL_DIR;
|
||||
if (!RsDirUtil::checkCreateDirectory(partialpath))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "ftfiler::initiateFileTransfer() Cannot create partial directory: " << partialpath;
|
||||
pqioutput(PQL_ALERT, ftfilerzone, out.str());
|
||||
exit(1);
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "ftfiler::initiateFileTransfer() Cannot create partial directory: " << partialpath;
|
||||
pqioutput(PQL_ALERT, ftfilerzone, out.str());
|
||||
}
|
||||
|
||||
std::string tmppath = mEmergencyIncomingDir;
|
||||
if (!RsDirUtil::checkCreateDirectory(tmppath))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "ftfiler::initiateFileTransfer() Cannot create EmergencyIncomingDir: ";
|
||||
out << tmppath;
|
||||
pqioutput(PQL_ALERT, ftfilerzone, out.str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Store new temp path */
|
||||
saveBasePath = tmppath;
|
||||
|
||||
tmppath += "/";
|
||||
tmppath += PARTIAL_DIR;
|
||||
|
||||
if (!RsDirUtil::checkCreateDirectory(tmppath))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "ftfiler::initiateFileTransfer() Cannot create EmergencyIncomingPartialsDir: ";
|
||||
out << tmppath;
|
||||
pqioutput(PQL_ALERT, ftfilerzone, out.str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "ftfiler::initiateFileTransfer() Using Emergency Download Directory: " << saveBasePath;
|
||||
pqioutput(PQL_ALERT, ftfilerzone, out.str());
|
||||
}
|
||||
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
std::string title =
|
||||
"Warning: Bad Incoming Directory";
|
||||
|
||||
std::string msg;
|
||||
msg += " **** WARNING **** \n";
|
||||
msg += "Retroshare cannot create Incoming Partials Directory: ";
|
||||
msg += "\n";
|
||||
msg += partialpath;
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
msg += "This is needed for normal operation.";
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
msg += "The incoming directory has been temporarily changed to:";
|
||||
msg += "\n";
|
||||
msg += saveBasePath;
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
msg += "Please select a new Downloads Directory ASAP Using:";
|
||||
msg += "\n";
|
||||
msg += "SideBar->Options->Directories";
|
||||
msg += "\n";
|
||||
|
||||
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "ftfiler::initiateFileTransfer() Notify not exist!";
|
||||
std::cerr << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* check if the file exists */
|
||||
@ -1437,6 +1505,13 @@ void ftfiler::setSaveBasePath(std::string s)
|
||||
}
|
||||
|
||||
|
||||
void ftfiler::setEmergencyBasePath(std::string s)
|
||||
{
|
||||
mEmergencyIncomingDir = s;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************
|
||||
* Notes
|
||||
|
@ -172,6 +172,7 @@ int tick();
|
||||
std::list<RsFileTransfer *> getStatus();
|
||||
|
||||
virtual void setSaveBasePath(std::string s);
|
||||
virtual void setEmergencyBasePath(std::string s);
|
||||
|
||||
/************* Network Interface****************************/
|
||||
virtual int recvFileInfo(ftFileRequest *in);
|
||||
@ -224,6 +225,7 @@ private:
|
||||
std::list<ftFileRequest *> out_queue;
|
||||
|
||||
std::string saveBasePath;
|
||||
std::string mEmergencyIncomingDir;
|
||||
};
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ include $(RS_TOP_DIR)/scripts/config.mk
|
||||
|
||||
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
|
||||
p3gamelauncher.o p3ranking.o p3disc.o \
|
||||
p3photoservice.o
|
||||
p3photoservice.o
|
||||
|
||||
#TESTOBJ =
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include "services/p3msgservice.h"
|
||||
#include "rsiface/rsnotify.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include "util/rsdir.h"
|
||||
|
||||
@ -144,9 +144,10 @@ int p3MsgService::incomingMsgs()
|
||||
initRsMIS(mi, mis);
|
||||
|
||||
// msgNotifications.push_back(mis);
|
||||
if (rsNotify)
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
rsNotify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(),
|
||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(),
|
||||
"New Message from: ");
|
||||
}
|
||||
}
|
||||
@ -191,7 +192,7 @@ int p3MsgService::checkOutgoingMessages()
|
||||
|
||||
if (mConnMgr->getFriendNetStatus(pid, pstate))
|
||||
{
|
||||
if (pstate.state & RS_PEER_S_ONLINE)
|
||||
if (pstate.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
toSend = true;
|
||||
}
|
||||
|
@ -32,6 +32,9 @@
|
||||
|
||||
const uint32_t RANK_MAX_FWD_OFFSET = (60 * 60 * 24 * 2); /* 2 Days */
|
||||
|
||||
//const uint32_t FRIEND_RANK_REPUBLISH_PERIOD = 60; /* every minute for testing */
|
||||
const uint32_t FRIEND_RANK_REPUBLISH_PERIOD = 1800; /* every 30 minutes */
|
||||
|
||||
std::string generateRandomLinkId();
|
||||
|
||||
/*****
|
||||
@ -43,17 +46,20 @@ std::string generateRandomLinkId();
|
||||
|
||||
#define RANK_DEBUG 1
|
||||
|
||||
p3Ranking::p3Ranking(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
|
||||
p3Ranking::p3Ranking(p3ConnectMgr *connMgr,
|
||||
uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
|
||||
std::string sourcedir, std::string storedir,
|
||||
uint32_t storePeriod)
|
||||
:CacheSource(type, true, cs, sourcedir),
|
||||
CacheStore(type, true, cs, cft, storedir),
|
||||
mConnMgr(connMgr),
|
||||
mRepublish(false), mRepublishFriends(false), mRepublishFriendTS(0),
|
||||
mStorePeriod(storePeriod), mUpdated(true)
|
||||
{
|
||||
|
||||
{ RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mOwnId = getAuthMgr()->OwnId();
|
||||
mOwnId = mConnMgr->getOwnId();
|
||||
mViewPeriod = 60 * 60 * 24 * 30; /* one Month */
|
||||
mSortType = RS_RANK_ALG;
|
||||
|
||||
@ -197,6 +203,8 @@ void p3Ranking::loadRankFile(std::string filename, std::string src)
|
||||
std::cerr << "p3Ranking::loadRankFile() Loading Item";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* correct the source (if is a message from a friend) */
|
||||
newMsg->PeerId(newMsg->pid);
|
||||
addRankMsg(newMsg);
|
||||
}
|
||||
|
||||
@ -207,7 +215,7 @@ void p3Ranking::loadRankFile(std::string filename, std::string src)
|
||||
}
|
||||
|
||||
|
||||
void p3Ranking::publishMsgs()
|
||||
void p3Ranking::publishMsgs(bool own)
|
||||
{
|
||||
|
||||
#ifdef RANK_DEBUG
|
||||
@ -215,12 +223,29 @@ void p3Ranking::publishMsgs()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* determine filename */
|
||||
|
||||
std::string path = CacheSource::getCacheDir();
|
||||
std::ostringstream out;
|
||||
out << "rank-links-" << time(NULL) << ".rsrl";
|
||||
|
||||
uint16_t subid;
|
||||
|
||||
|
||||
/* setup name / etc based on whether we're
|
||||
* publishing own or friends...
|
||||
*/
|
||||
|
||||
if (own)
|
||||
{
|
||||
/* setup to publish own messages */
|
||||
out << "rank-links-" << time(NULL) << ".rsrl";
|
||||
subid = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* setup to publish friend messages */
|
||||
out << "rank-friend-links-" << time(NULL) << ".rsrl";
|
||||
subid = 2;
|
||||
}
|
||||
|
||||
/* determine filename */
|
||||
std::string tmpname = out.str();
|
||||
std::string fname = path + "/" + tmpname;
|
||||
|
||||
@ -241,10 +266,14 @@ void p3Ranking::publishMsgs()
|
||||
|
||||
/* iterate through list */
|
||||
std::map<std::string, RankGroup>::iterator it;
|
||||
std::map<std::string, RsRankLinkMsg *>::iterator cit;
|
||||
|
||||
for(it = mData.begin(); it != mData.end(); it++)
|
||||
{
|
||||
if (it->second.ownTag)
|
||||
if (own)
|
||||
{
|
||||
if (it->second.ownTag)
|
||||
{
|
||||
/* write to serialiser */
|
||||
RsItem *item = it->second.comments[mOwnId];
|
||||
if (item)
|
||||
@ -260,13 +289,36 @@ void p3Ranking::publishMsgs()
|
||||
stream->tick(); /* Tick to write! */
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::publishMsgs() Skipping Foreign item";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* iterate through all comments */
|
||||
for(cit = it->second.comments.begin();
|
||||
cit != it->second.comments.end(); cit++)
|
||||
{
|
||||
RsItem *item = cit->second;
|
||||
/* write to serialiser */
|
||||
if (item && (mConnMgr->isFriend(item->PeerId())))
|
||||
{
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::publishMsgs() Storing Friend Item:";
|
||||
std::cerr << std::endl;
|
||||
item->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
stream->SendItem(item);
|
||||
stream->tick(); /* Tick to write! */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +334,7 @@ void p3Ranking::publishMsgs()
|
||||
data.pid = mOwnId;
|
||||
} /********** STACK LOCKED MTX ******/
|
||||
|
||||
data.cid = CacheId(CacheSource::getCacheType(), 1);
|
||||
data.cid = CacheId(CacheSource::getCacheType(), subid);
|
||||
|
||||
data.path = path;
|
||||
data.name = tmpname;
|
||||
@ -367,6 +419,10 @@ void p3Ranking::addRankMsg(RsRankLinkMsg *msg)
|
||||
|
||||
if (newComment)
|
||||
{
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::addRankMsg() New Comment";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* clean up old */
|
||||
if ((it->second).comments.end() != cit)
|
||||
{
|
||||
@ -382,12 +438,32 @@ void p3Ranking::addRankMsg(RsRankLinkMsg *msg)
|
||||
{
|
||||
it->second.ownTag = true;
|
||||
mRepublish = true;
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::addRankMsg() Own Comment: mRepublish = true";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mRepublishFriends = true;
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::addRankMsg() Other Comment: mRepublishFriends = true";
|
||||
std::cerr << "p3Ranking::addRankMsg() Old Comment ignoring";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
locked_reSortGroup(it->second);
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef RANK_DEBUG
|
||||
std::cerr << "p3Ranking::addRankMsg() Old Comment ignoring";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -702,18 +778,33 @@ bool p3Ranking::getRankDetails(std::string rid, RsRankDetails &details)
|
||||
void p3Ranking::tick()
|
||||
{
|
||||
bool repub = false;
|
||||
bool repubFriends = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||
repub = mRepublish;
|
||||
repubFriends = mRepublishFriends && (time(NULL) > mRepublishFriendTS);
|
||||
}
|
||||
|
||||
if (repub)
|
||||
{
|
||||
publishMsgs();
|
||||
publishMsgs(true);
|
||||
|
||||
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||
mRepublish = false;
|
||||
}
|
||||
|
||||
|
||||
if (repubFriends)
|
||||
{
|
||||
publishMsgs(false);
|
||||
|
||||
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||
mRepublishFriends = false;
|
||||
mRepublishFriendTS = time(NULL) + FRIEND_RANK_REPUBLISH_PERIOD;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool p3Ranking::updated()
|
||||
@ -741,6 +832,7 @@ std::string p3Ranking::newRankMsg(std::wstring link, std::wstring title, std::ws
|
||||
{
|
||||
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||
msg->PeerId(mOwnId);
|
||||
msg->pid = mOwnId;
|
||||
}
|
||||
|
||||
msg->rid = rid;
|
||||
@ -785,6 +877,7 @@ bool p3Ranking::updateComment(std::string rid, std::wstring comment)
|
||||
time_t now = time(NULL);
|
||||
|
||||
msg->PeerId(mOwnId);
|
||||
msg->pid = mOwnId;
|
||||
msg->rid = rid;
|
||||
msg->timestamp = now;
|
||||
msg->title = (it->second).title;
|
||||
@ -866,6 +959,7 @@ void p3Ranking::createDummyData()
|
||||
time_t now = time(NULL);
|
||||
|
||||
msg->PeerId(mOwnId);
|
||||
msg->pid = mOwnId;
|
||||
msg->rid = "0001";
|
||||
msg->title = L"Original Awesome Site!";
|
||||
msg->timestamp = now - 60 * 60 * 24 * 15;
|
||||
@ -876,6 +970,7 @@ void p3Ranking::createDummyData()
|
||||
|
||||
msg = new RsRankLinkMsg();
|
||||
msg->PeerId(mOwnId);
|
||||
msg->pid = mOwnId;
|
||||
msg->rid = "0002";
|
||||
msg->title = L"Awesome Site!";
|
||||
msg->timestamp = now - 123;
|
||||
@ -886,6 +981,7 @@ void p3Ranking::createDummyData()
|
||||
|
||||
msg = new RsRankLinkMsg();
|
||||
msg->PeerId("ALTID");
|
||||
msg->pid = "ALTID";
|
||||
msg->rid = "0002";
|
||||
msg->title = L"Awesome Site!";
|
||||
msg->timestamp = now - 60 * 60 * 24 * 29;
|
||||
@ -898,6 +994,7 @@ void p3Ranking::createDummyData()
|
||||
|
||||
msg = new RsRankLinkMsg();
|
||||
msg->PeerId("ALTID2");
|
||||
msg->pid = "ALTID2";
|
||||
msg->rid = "0002";
|
||||
msg->title = L"Awesome Site!";
|
||||
msg->timestamp = now - 60 * 60 * 7;
|
||||
@ -911,6 +1008,7 @@ void p3Ranking::createDummyData()
|
||||
|
||||
msg = new RsRankLinkMsg();
|
||||
msg->PeerId(mOwnId);
|
||||
msg->pid = mOwnId;
|
||||
msg->rid = "0003";
|
||||
msg->title = L"Weird Site!";
|
||||
msg->timestamp = now - 60 * 60;
|
||||
@ -921,6 +1019,7 @@ void p3Ranking::createDummyData()
|
||||
|
||||
msg = new RsRankLinkMsg();
|
||||
msg->PeerId("ALTID");
|
||||
msg->pid = "ALTID";
|
||||
msg->rid = "0003";
|
||||
msg->title = L"Weird Site!";
|
||||
msg->timestamp = now - 60 * 60 * 24 * 2;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "pqi/pqiservice.h"
|
||||
#include "pqi/pqistreamer.h"
|
||||
//#include "util/rsthreads.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
@ -65,7 +65,8 @@ class p3Ranking: public CacheSource, public CacheStore
|
||||
{
|
||||
public:
|
||||
|
||||
p3Ranking(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
|
||||
p3Ranking(p3ConnectMgr *connMgr,
|
||||
uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
|
||||
std::string sourcedir, std::string storedir,
|
||||
uint32_t storePeriod);
|
||||
|
||||
@ -107,7 +108,7 @@ void tick();
|
||||
|
||||
void loadRankFile(std::string filename, std::string src);
|
||||
void addRankMsg(RsRankLinkMsg *msg);
|
||||
void publishMsgs();
|
||||
void publishMsgs(bool own);
|
||||
|
||||
float locked_calcRank(RankGroup &grp); /* returns 0->100 */
|
||||
void locked_reSortGroup(RankGroup &grp);
|
||||
@ -119,11 +120,16 @@ pqistreamer *createStreamer(std::string file, std::string src, bool reading);
|
||||
|
||||
void createDummyData();
|
||||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
|
||||
RsMutex mRankMtx;
|
||||
|
||||
/***** below here is locked *****/
|
||||
|
||||
bool mRepublish;
|
||||
bool mRepublishFriends;
|
||||
time_t mRepublishFriendTS;
|
||||
|
||||
uint32_t mStorePeriod;
|
||||
|
||||
std::string mOwnId;
|
||||
|
Loading…
Reference in New Issue
Block a user