mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 17:09:34 -05:00
fixed up plugin system to work with v0.6
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7287 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2d2a906ef2
commit
ca6b463a31
101
libretroshare/src/file_sharing/README.txt
Normal file
101
libretroshare/src/file_sharing/README.txt
Normal file
@ -0,0 +1,101 @@
|
||||
Design document for the new file list sharing system.
|
||||
====================================================
|
||||
|
||||
Big picture
|
||||
-----------
|
||||
|
||||
p3SharesManager
|
||||
Functionalities
|
||||
* contains the list of shared files
|
||||
- responds to search, requests for FileInfo
|
||||
* responsible for sync-ing file lists between peers
|
||||
|
||||
Level 3: interface with GUI
|
||||
- regularly issue syncing requests in background
|
||||
- automatically issue syncing requests as files are browsed
|
||||
|
||||
Level 2: internal stuff
|
||||
- examine syncing requests. Only get data
|
||||
|
||||
Level 1: syncing system
|
||||
- list of pending requests with priorities, sort them and handle response from friends
|
||||
|
||||
Level 0: interface with friends
|
||||
- serialisation/deserialisation of file list items
|
||||
|
||||
FileIndex should support:
|
||||
- O(log(n)) search for hash
|
||||
- O(n) search for regular exp
|
||||
- O(1) remove of file and directory
|
||||
|
||||
Members
|
||||
- list of file indexes
|
||||
=> map of <peer id, FileIndex>
|
||||
-
|
||||
|
||||
Parent classes
|
||||
- p3Service (sends and receives information about shared files)
|
||||
|
||||
Notes:
|
||||
- the same file should be able to be held by two different directories. Hash search will return a single hit.
|
||||
- the previously existing PersonEntry had no field and was overloading DirEntry, with overwritten file names, hashes etc. Super bad!
|
||||
|
||||
Classes
|
||||
-------
|
||||
Rs
|
||||
|
||||
p3ShareManager
|
||||
- tick()
|
||||
* handle pending syncing requests => sends items
|
||||
* watch shared directories
|
||||
=> hash new files
|
||||
=> updates shared files
|
||||
*
|
||||
|
||||
- list of shared parent directories, with share flags
|
||||
|
||||
FileIndex // should support hierarchical navigation, load/save
|
||||
-
|
||||
|
||||
LocalFileIndex: public FileIndex
|
||||
- std::map<RsFileHash, LocalFileInfo> // used for search
|
||||
|
||||
FileInfo
|
||||
- std::string name
|
||||
- RsFileHash hash
|
||||
- uint64_t size
|
||||
- time_t Last modification time
|
||||
|
||||
LocalFileInfo: public FileInfo
|
||||
- time_t Last data access time
|
||||
- uint64_t Total data uploaded
|
||||
- uint32_t ShareFlags
|
||||
|
||||
SharedDirectory
|
||||
- parent groups
|
||||
- group flags
|
||||
|
||||
Syncing between peers
|
||||
---------------------
|
||||
|
||||
Generating sync events
|
||||
* Client side
|
||||
- for each directory, in breadth first order
|
||||
- if directory has changed, or last update is old
|
||||
=> push a sync request
|
||||
|
||||
* Server side
|
||||
- after a change, broadcast a "directory changed" packet to all connected friends
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
|
||||
- complete this file until a proper description of the whole thing is achieved.
|
||||
- create a new directory and implement the .h for the basic functionality
|
||||
- look into existing code in ftServer for the integration, but don't change anything yet
|
||||
- setup class hierarchy
|
||||
- merge hash cache into file lists.
|
||||
|
||||
- optionally
|
||||
- change the saving system of FileIndex to make it locally encrypted and compact
|
||||
|
@ -40,8 +40,7 @@ std::string RsPluginManager::_local_cache_dir ;
|
||||
std::string RsPluginManager::_remote_cache_dir ;
|
||||
std::vector<std::string> RsPluginManager::_plugin_directories ;
|
||||
|
||||
ftServer *RsPluginManager::_ftserver = NULL ;
|
||||
p3LinkMgr *RsPluginManager::_linkmgr = NULL ;
|
||||
RsServiceControl *RsPluginManager::_service_control = NULL ;
|
||||
|
||||
typedef RsPlugin *(*RetroSharePluginEntry)(void) ;
|
||||
RsPluginHandler *rsPlugins ;
|
||||
@ -363,18 +362,6 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
|
||||
return true;
|
||||
}
|
||||
|
||||
p3LinkMgr *RsPluginManager::getLinkMgr() const
|
||||
{
|
||||
assert(_linkmgr != NULL) ;
|
||||
return _linkmgr ;
|
||||
}
|
||||
|
||||
|
||||
ftServer *RsPluginManager::getFileServer() const
|
||||
{
|
||||
assert(_ftserver != NULL) ;
|
||||
return _ftserver ;
|
||||
}
|
||||
const std::string& RsPluginManager::getLocalCacheDir() const
|
||||
{
|
||||
assert(!_local_cache_dir.empty()) ;
|
||||
@ -385,6 +372,11 @@ const std::string& RsPluginManager::getRemoteCacheDir() const
|
||||
assert(!_remote_cache_dir.empty()) ;
|
||||
return _remote_cache_dir ;
|
||||
}
|
||||
RsServiceControl *RsPluginManager::getServiceControl() const
|
||||
{
|
||||
assert(_service_control);
|
||||
return _service_control ;
|
||||
}
|
||||
void RsPluginManager::slowTickPlugins(time_t seconds)
|
||||
{
|
||||
for(uint32_t i=0;i<_plugins.size();++i)
|
||||
@ -531,13 +523,13 @@ bool RsPluginManager::saveList(bool& cleanup, std::list<RsItem*>& list)
|
||||
return true;
|
||||
}
|
||||
|
||||
RsCacheService::RsCacheService(uint16_t service_type,uint32_t tick_delay, RsPluginHandler* pgHandler)
|
||||
: CacheSource(service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getLocalCacheDir()),
|
||||
CacheStore (service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getFileServer()->getCacheTransfer(), pgHandler->getRemoteCacheDir()),
|
||||
p3Config(),
|
||||
_tick_delay_in_seconds(tick_delay)
|
||||
{
|
||||
}
|
||||
// RsCacheService::RsCacheService(uint16_t service_type,uint32_t tick_delay, RsPluginHandler* pgHandler)
|
||||
// : CacheSource(service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getLocalCacheDir()),
|
||||
// CacheStore (service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getFileServer()->getCacheTransfer(), pgHandler->getRemoteCacheDir()),
|
||||
// p3Config(),
|
||||
// _tick_delay_in_seconds(tick_delay)
|
||||
// {
|
||||
// }
|
||||
|
||||
RsPQIService::RsPQIService(uint16_t service_type,uint32_t /*tick_delay_in_seconds*/, RsPluginHandler* /*pgHandler*/)
|
||||
: p3Service(),p3Config()
|
||||
|
@ -53,8 +53,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
||||
virtual void slowTickPlugins(time_t sec) ;
|
||||
virtual const std::string& getLocalCacheDir() const ;
|
||||
virtual const std::string& getRemoteCacheDir() const ;
|
||||
virtual ftServer *getFileServer() const ;
|
||||
virtual p3LinkMgr *getLinkMgr() const ;
|
||||
virtual RsServiceControl *getServiceControl() const ;
|
||||
|
||||
virtual void allowAllPlugins(bool b) ;
|
||||
virtual bool getAllowAllPlugins() const ;
|
||||
@ -78,8 +77,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
||||
|
||||
static bool acceptablePluginName(const std::string& s) ;
|
||||
static void setCacheDirectories(const std::string& local,const std::string& remote) ;
|
||||
static void setFileServer(ftServer *ft) { _ftserver = ft ; }
|
||||
static void setLinkMgr(p3LinkMgr *cm) { _linkmgr = cm ; }
|
||||
static void setServiceControl(RsServiceControl *cm) { _service_control = cm ; }
|
||||
|
||||
// Normal plugin loading system. Parses through the plugin directories and loads
|
||||
// dso libraries, checks for the hash, and loads/rejects plugins according to
|
||||
@ -124,8 +122,8 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
||||
static std::string _plugin_API_symbol ;
|
||||
static std::string _remote_cache_dir ;
|
||||
static std::string _local_cache_dir ;
|
||||
static ftServer *_ftserver ;
|
||||
static p3LinkMgr *_linkmgr ;
|
||||
|
||||
static RsServiceControl *_service_control ;
|
||||
|
||||
static std::vector<std::string> _plugin_directories ;
|
||||
};
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <dbase/cachestrapper.h>
|
||||
#include "plugins/pluginmanager.h"
|
||||
|
||||
// This code needs to be re-written to work with GXS. For now it is obsolete.
|
||||
//
|
||||
|
||||
// The following class abstracts the construction of a cache service. The user only has to
|
||||
// supply RS with a type ID. If the ID is already in use, RS will complain.
|
||||
//
|
||||
@ -23,4 +26,3 @@ class RsCacheService: public CacheSource, public CacheStore, public p3Config
|
||||
private:
|
||||
uint32_t _tick_delay_in_seconds ;
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
class RsPQIService: public p3Service, public p3Config
|
||||
{
|
||||
public:
|
||||
RsPQIService(uint16_t type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
|
||||
RsPQIService(uint16_t type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
|
||||
|
||||
uint32_t tickDelay() const { return _tick_delay_in_seconds ; }
|
||||
virtual int tick() = 0 ;
|
||||
|
@ -38,6 +38,7 @@ class RsPluginHandler ;
|
||||
extern RsPluginHandler *rsPlugins ;
|
||||
|
||||
class p3Service ;
|
||||
class RsServiceControl ;
|
||||
class RsTurtle ;
|
||||
class RsDht ;
|
||||
class RsDisc ;
|
||||
@ -100,7 +101,6 @@ public:
|
||||
RsTurtle *mTurtle;
|
||||
RsDisc *mDisc;
|
||||
RsDht *mDht;
|
||||
//RsForums *mForums;
|
||||
RsNotify *mNotify;
|
||||
};
|
||||
|
||||
@ -129,7 +129,11 @@ class RsPlugin
|
||||
// derive from p3Config, which means that the service provided by the plugin can load/save its own
|
||||
// config by deriving loadList() and saveList() from p3Config.
|
||||
//
|
||||
virtual std::string configurationFileName() const { return std::string() ; }
|
||||
virtual std::string configurationFileName() const
|
||||
{
|
||||
std::cerr << "(EE) Plugin configuration file name requested in non overloaded method! Plugin code should derive configurationFileName() method!" << std::endl;
|
||||
return std::string() ;
|
||||
}
|
||||
|
||||
//
|
||||
//=================================== GUI ====================================//
|
||||
@ -196,9 +200,9 @@ class RsPluginHandler
|
||||
virtual void slowTickPlugins(time_t sec) = 0 ;
|
||||
|
||||
virtual const std::string& getLocalCacheDir() const =0;
|
||||
virtual const std::string& getRemoteCacheDir() const =0;
|
||||
virtual ftServer *getFileServer() const = 0;
|
||||
virtual p3LinkMgr *getLinkMgr() const = 0;
|
||||
virtual const std::string& getRemoteCacheDir() const =0;
|
||||
|
||||
virtual RsServiceControl *getServiceControl() const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1258,9 +1258,9 @@ int RsServer::StartupRetroShare()
|
||||
std::vector<std::string> plugins_directories ;
|
||||
|
||||
#ifndef WINDOWS_SYS
|
||||
plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions/")) ;
|
||||
plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions6/")) ;
|
||||
#endif
|
||||
std::string extensions_dir = rsAccounts.PathBaseDirectory() + "/extensions/" ;
|
||||
std::string extensions_dir = rsAccounts.PathBaseDirectory() + "/extensions6/" ;
|
||||
plugins_directories.push_back(extensions_dir) ;
|
||||
|
||||
if(!RsDirUtil::checkCreateDirectory(extensions_dir))
|
||||
@ -1280,8 +1280,7 @@ int RsServer::StartupRetroShare()
|
||||
// cache directories, get pointers to cache strapper, or access ownId()
|
||||
//
|
||||
mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ;
|
||||
mPluginsManager->setFileServer(ftserver) ;
|
||||
mPluginsManager->setLinkMgr(mLinkMgr) ;
|
||||
mPluginsManager->setServiceControl(serviceCtrl) ;
|
||||
|
||||
// Now load the plugins. This parses the available SO/DLL files for known symbols.
|
||||
//
|
||||
@ -1491,8 +1490,6 @@ int RsServer::StartupRetroShare()
|
||||
interfaces.mTurtle = rsTurtle;
|
||||
interfaces.mDisc = rsDisc;
|
||||
interfaces.mDht = rsDht;
|
||||
// don't exist no more.
|
||||
//interfaces.mForums = mForums;
|
||||
interfaces.mNotify = mNotify;
|
||||
|
||||
mPluginsManager->setInterfaces(interfaces);
|
||||
|
Loading…
Reference in New Issue
Block a user