2007-11-14 22:18:48 -05:00
|
|
|
/*
|
|
|
|
* "$Id: filedexserver.h,v 1.18 2007-05-05 16:10:06 rmf24 Exp $"
|
|
|
|
*
|
|
|
|
* Other Bits for RetroShare.
|
|
|
|
*
|
|
|
|
* 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MRK_PQI_FILEDEX_SERVER_HEADER
|
|
|
|
#define MRK_PQI_FILEDEX_SERVER_HEADER
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Slightly more complete server....
|
|
|
|
* has a filedex pointer, which manages the local indexing/searching.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pqi/pqi.h"
|
|
|
|
#include "pqi/pqiindic.h"
|
2007-12-11 20:39:09 -05:00
|
|
|
#include "serialiser/rsconfigitems.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
#include <map>
|
|
|
|
#include <deque>
|
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "rsiface/rsiface.h"
|
2008-01-25 02:54:31 -05:00
|
|
|
|
|
|
|
#include "pqi/p3cfgmgr.h"
|
|
|
|
|
|
|
|
class p3ConnectMgr;
|
|
|
|
class p3AuthMgr;
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
class CacheStrapper;
|
|
|
|
class ftfiler;
|
|
|
|
class FileIndexStore;
|
|
|
|
class FileIndexMonitor;
|
|
|
|
|
|
|
|
class ftFileRequest;
|
|
|
|
class ftFileData;
|
|
|
|
|
|
|
|
#define MAX_RESULTS 100 // nice balance between results and traffic.
|
|
|
|
|
2008-01-25 02:54:31 -05:00
|
|
|
class filedexserver: public p3Config
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
filedexserver();
|
|
|
|
|
|
|
|
void loadWelcomeMsg(); /* startup message */
|
|
|
|
|
2008-01-25 02:54:31 -05:00
|
|
|
int setSearchInterface(P3Interface *si, p3AuthMgr *am, p3ConnectMgr *cm);
|
2007-12-11 20:39:09 -05:00
|
|
|
|
|
|
|
std::list<RsFileTransfer *> getTransfers();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-02-07 11:18:34 -05:00
|
|
|
void saveFileTransferStatus();
|
2007-11-14 22:18:48 -05:00
|
|
|
int getFile(std::string fname, std::string hash,
|
|
|
|
uint32_t size, std::string dest);
|
|
|
|
void clear_old_transfers();
|
|
|
|
void cancelTransfer(std::string fname, std::string hash, uint32_t size);
|
|
|
|
|
|
|
|
// access to search info is also required.
|
|
|
|
|
|
|
|
std::list<std::string> &getSearchDirectories();
|
|
|
|
int addSearchDirectory(std::string dir);
|
|
|
|
int removeSearchDirectory(std::string dir);
|
|
|
|
int reScanDirs();
|
|
|
|
int check_dBUpdate();
|
|
|
|
|
|
|
|
std::string getSaveDir();
|
|
|
|
void setSaveDir(std::string d);
|
|
|
|
void setConfigDir(std::string d) { config_dir = d; }
|
|
|
|
bool getSaveIncSearch();
|
|
|
|
void setSaveIncSearch(bool v);
|
|
|
|
|
|
|
|
int tick();
|
|
|
|
int status();
|
|
|
|
|
2007-12-11 20:39:09 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
private:
|
|
|
|
|
|
|
|
int handleInputQueues();
|
|
|
|
int handleOutputQueues();
|
|
|
|
|
|
|
|
std::list<std::string> dbase_dirs;
|
|
|
|
|
2007-12-11 20:39:09 -05:00
|
|
|
P3Interface *pqisi;
|
2008-01-25 02:54:31 -05:00
|
|
|
p3AuthMgr *mAuthMgr;
|
|
|
|
p3ConnectMgr *mConnMgr;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
std::string config_dir;
|
|
|
|
std::string save_dir;
|
|
|
|
bool save_inc; // is savedir include in share list.
|
|
|
|
|
|
|
|
public:
|
|
|
|
/* some more switches (here for uniform saving) */
|
|
|
|
int getDHTEnabled()
|
|
|
|
{
|
|
|
|
return DHTState;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getUPnPEnabled()
|
|
|
|
{
|
|
|
|
return UPnPState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDHTEnabled(int i)
|
|
|
|
{
|
|
|
|
DHTState = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUPnPEnabled(int i)
|
|
|
|
{
|
|
|
|
UPnPState = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int DHTState;
|
|
|
|
int UPnPState;
|
|
|
|
|
2008-01-25 02:54:31 -05:00
|
|
|
/*************************** p3 Config Overload ********************/
|
|
|
|
protected:
|
|
|
|
/* Key Functions to be overloaded for Full Configuration */
|
|
|
|
virtual RsSerialiser *setupSerialiser();
|
|
|
|
virtual std::list<RsItem *> saveList(bool &cleanup);
|
|
|
|
virtual bool loadList(std::list<RsItem *> load);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool loadConfigMap(std::map<std::string, std::string> &configMap);
|
|
|
|
|
|
|
|
/*************************** p3 Config Overload ********************/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* new FileCache stuff */
|
|
|
|
public:
|
|
|
|
|
|
|
|
int FileStoreTick();
|
|
|
|
int FileCacheSave();
|
|
|
|
|
|
|
|
void initialiseFileStore();
|
2008-02-05 08:45:04 -05:00
|
|
|
void setFileCallback(std::string ownId, CacheStrapper *strapper,
|
|
|
|
ftfiler *ft, NotifyBase *cb);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
int RequestDirDetails(std::string uid, std::string path, DirDetails &details);
|
|
|
|
int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags);
|
|
|
|
|
|
|
|
int SearchKeywords(std::list<std::string> keywords, std::list<FileDetail> &results);
|
|
|
|
int SearchBoolExp(Expression * exp, std::list<FileDetail> &results);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2008-01-25 02:54:31 -05:00
|
|
|
void SendFileRequest(ftFileRequest *ftr, std::string pid);
|
|
|
|
void SendFileData(ftFileData *ftd, std::string pid);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 02:54:31 -05:00
|
|
|
CacheStrapper *mCacheStrapper;
|
2007-11-14 22:18:48 -05:00
|
|
|
ftfiler *ftFiler;
|
|
|
|
FileIndexStore *fiStore;
|
|
|
|
FileIndexMonitor *fimon;
|
2008-02-07 11:18:34 -05:00
|
|
|
|
|
|
|
/* Temp Transfer List (for loading config) */
|
|
|
|
std::list<RsFileTransfer *> mResumeTransferList;
|
2007-11-14 22:18:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MRK_PQI_FILEDEX_SERVER_HEADER
|