mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 22:02:32 -04:00
Added a display for file hashing activity using notifyQt class. This time it works nicely.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@938 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c7adb4907c
commit
80a8b41d66
15 changed files with 61 additions and 63 deletions
|
@ -24,6 +24,8 @@
|
|||
#include "dbase/fimonitor.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "rsiface/rsiface.h"
|
||||
#include "rsiface/rsnotify.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
@ -40,10 +42,10 @@
|
|||
* #define FIM_DEBUG 1
|
||||
***********/
|
||||
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, std::string pid)
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in,std::string cachedir, std::string pid)
|
||||
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
|
||||
pendingDirs(false), pendingForceCacheWrite(false),
|
||||
mForceCheck(false), mInCheck(false),_hashing_info_callback(NULL)
|
||||
mForceCheck(false), mInCheck(false),cb(cb_in)
|
||||
|
||||
{
|
||||
updatePeriod = 60;
|
||||
|
@ -596,8 +598,7 @@ void FileIndexMonitor::updateCycle()
|
|||
RsStackMutex stack(fiMutex); /**** LOCKED DIRS ****/
|
||||
mInCheck = false;
|
||||
}
|
||||
if(_hashing_info_callback != NULL)
|
||||
(*_hashing_info_callback)("") ;
|
||||
cb->notifyHashingInfo("") ;
|
||||
}
|
||||
|
||||
/* interface */
|
||||
|
@ -797,8 +798,7 @@ bool FileIndexMonitor::hashFile(std::string fullpath, FileEntry &fent)
|
|||
unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
||||
unsigned char gblBuf[512];
|
||||
|
||||
if(_hashing_info_callback != NULL)
|
||||
(*_hashing_info_callback)("Hashing "+f_hash) ;
|
||||
cb->notifyHashingInfo(fent.name) ;
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "File to hash = " << f_hash << std::endl;
|
||||
|
|
|
@ -59,6 +59,7 @@ std::string FileIndexMonitor::findRealRoot(std::string base);
|
|||
|
||||
******************************************************************************************/
|
||||
|
||||
class NotifyBase ;
|
||||
|
||||
|
||||
/******************************************************************************************
|
||||
|
@ -68,7 +69,7 @@ std::string FileIndexMonitor::findRealRoot(std::string base);
|
|||
class FileIndexMonitor: public CacheSource, public RsThread
|
||||
{
|
||||
public:
|
||||
FileIndexMonitor(CacheStrapper *cs, std::string cachedir, std::string pid);
|
||||
FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in, std::string cachedir, std::string pid);
|
||||
virtual ~FileIndexMonitor();
|
||||
|
||||
/* external interface for filetransfer */
|
||||
|
@ -96,7 +97,7 @@ void getSharedDirectories(std::list<std::string> &dirs);
|
|||
void setPeriod(int insecs);
|
||||
void forceDirectoryCheck();
|
||||
bool inDirectoryCheck();
|
||||
void setFileHashingCallback(void (*cb)(const std::string&)) { _hashing_info_callback = cb ; }
|
||||
|
||||
/* util fns */
|
||||
|
||||
private:
|
||||
|
@ -123,9 +124,9 @@ bool hashFile(std::string path, FileEntry &fi); /* To Implement */
|
|||
bool mInCheck;
|
||||
|
||||
std::list<std::string> pendingDirList;
|
||||
bool internal_setSharedDirectories();
|
||||
bool internal_setSharedDirectories();
|
||||
|
||||
void (*_hashing_info_callback)(const std::string&) ;
|
||||
NotifyBase *cb ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ int main(int argc, char **argv)
|
|||
|
||||
sleep(1);
|
||||
|
||||
FileIndexMonitor mon(NULL, "", "OWN ID");
|
||||
FileIndexMonitor mon(NULL,NULL, "", "OWN ID");
|
||||
|
||||
/* setup monitor */
|
||||
mon.setPeriod(period);
|
||||
|
|
|
@ -119,8 +119,8 @@ bool ftFiStore::search(std::string hash, uint64_t size, uint32_t hintflags, File
|
|||
}
|
||||
|
||||
|
||||
ftFiMonitor::ftFiMonitor(CacheStrapper *cs, std::string cachedir, std::string pid)
|
||||
:FileIndexMonitor(cs, cachedir, pid), p3Config(CONFIG_TYPE_FT_SHARED)
|
||||
ftFiMonitor::ftFiMonitor(CacheStrapper *cs,NotifyBase *cb_in, std::string cachedir, std::string pid)
|
||||
:FileIndexMonitor(cs,cb_in, cachedir, pid), p3Config(CONFIG_TYPE_FT_SHARED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,13 +54,13 @@ virtual bool search(std::string hash, uint64_t size, uint32_t hintflags, FileInf
|
|||
class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
|
||||
{
|
||||
public:
|
||||
ftFiMonitor(CacheStrapper *cs, std::string cachedir, std::string pid);
|
||||
ftFiMonitor(CacheStrapper *cs,NotifyBase *cb_in, std::string cachedir, std::string pid);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(std::string hash, uint64_t size, uint32_t hintflags, FileInfo &info) const;
|
||||
virtual bool search(std::string hash, uint64_t size, uint32_t hintflags, FileInfo &info) const;
|
||||
|
||||
/* overloaded set dirs enables config indication */
|
||||
virtual void setSharedDirectories(std::list<std::string> dirList);
|
||||
virtual void setSharedDirectories(std::list<std::string> dirList);
|
||||
|
||||
/***
|
||||
* Configuration - store shared directories
|
||||
|
|
|
@ -30,6 +30,7 @@ const int ftserverzone = 29539;
|
|||
#include "ft/ftextralist.h"
|
||||
#include "ft/ftfilesearch.h"
|
||||
#include "ft/ftcontroller.h"
|
||||
#include "ft/ftfileprovider.h"
|
||||
#include "ft/ftdatamultiplex.h"
|
||||
|
||||
|
||||
|
@ -125,7 +126,7 @@ void ftServer::SetupFtServer(NotifyBase *cb)
|
|||
|
||||
/* Make Cache Source/Store */
|
||||
mFiStore = new ftFiStore(mCacheStrapper, mFtController, cb, ownId, remotecachedir);
|
||||
mFiMon = new ftFiMonitor(mCacheStrapper, localcachedir, ownId);
|
||||
mFiMon = new ftFiMonitor(mCacheStrapper,cb, localcachedir, ownId);
|
||||
|
||||
/* now add the set to the cachestrapper */
|
||||
CachePair cp(mFiMon, mFiStore, CacheId(RS_SERVICE_TYPE_FILE_INDEX, 0));
|
||||
|
@ -424,10 +425,6 @@ bool ftServer::InDirectoryCheck()
|
|||
{
|
||||
return mFiMon->inDirectoryCheck();
|
||||
}
|
||||
void ftServer::setFileHashingCallback( void (*cb)(const std::string&) )
|
||||
{
|
||||
mFiMon->setFileHashingCallback( cb ) ;
|
||||
}
|
||||
|
||||
bool ftServer::getSharedDirectories(std::list<std::string> &dirs)
|
||||
{
|
||||
|
|
|
@ -149,7 +149,6 @@ virtual int SearchBoolExp(Expression * exp, std::list<FileDetail> &results);
|
|||
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath);
|
||||
virtual void ForceDirectoryCheck();
|
||||
virtual bool InDirectoryCheck();
|
||||
virtual void setFileHashingCallback( void(*cb)(const std::string&));
|
||||
|
||||
/***
|
||||
* Directory Handling
|
||||
|
|
|
@ -139,9 +139,6 @@ virtual int SearchBoolExp(Expression * exp, std::list<FileDetail> &results) = 0;
|
|||
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath) = 0;
|
||||
virtual void ForceDirectoryCheck() = 0;
|
||||
virtual bool InDirectoryCheck() = 0;
|
||||
virtual void setFileHashingCallback( void(*cb)(const std::string&)) = 0;
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Directory Control
|
||||
|
|
|
@ -199,6 +199,7 @@ class NotifyBase
|
|||
virtual void notifyListChange(int list, int type) { (void) list; (void) type; return; }
|
||||
virtual void notifyErrorMsg(int list, int sev, std::string msg) { (void) list; (void) sev; (void) msg; return; }
|
||||
virtual void notifyChat() { return; }
|
||||
virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; }
|
||||
};
|
||||
|
||||
const int NOTIFY_LIST_NEIGHBOURS = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue