mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 15:45:04 -04:00
moved file hashing and download count to new notification system
This commit is contained in:
parent
10bee9f26b
commit
81c1eb227c
12 changed files with 163 additions and 24 deletions
|
@ -136,7 +136,13 @@ void HashStorage::threadTick()
|
|||
stopHashThread();
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_FINISH, "") ;
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
|
||||
ev->mEventCode = RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
//RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_FINISH, "") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -181,7 +187,14 @@ void HashStorage::threadTick()
|
|||
else
|
||||
rs_sprintf(tmpout, "%lu/%lu (%s - %d%%) : %s", (unsigned long int)mHashCounter+1, (unsigned long int)mTotalFilesToHash, friendlyUnit(mTotalHashedSize).c_str(), int(mTotalHashedSize/double(mTotalSizeToHash)*100.0), job.full_path.c_str()) ;
|
||||
|
||||
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout) ;
|
||||
//RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout) ;
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
|
||||
ev->mEventCode = RsSharedDirectoriesEventCode::HASHING_FILE;
|
||||
ev->mMessage = tmpout;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
double seconds_origin = rstime::RsScopeTimer::currentTime() ;
|
||||
|
||||
|
|
|
@ -816,10 +816,13 @@ bool ftController::completeFile(const RsFileHash& hash)
|
|||
}
|
||||
|
||||
/* Notify GUI */
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_DOWNLOAD, hash.toStdString(), name, "");
|
||||
|
||||
RsServer::notify()->notifyDownloadComplete(hash.toStdString());
|
||||
RsServer::notify()->notifyDownloadCompleteCount(completeCount);
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsFileTransferEvent>();
|
||||
ev->mHash = hash;
|
||||
ev->mFileTransferEventCode = RsFileTransferEventCode::DOWNLOAD_COMPLETE;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
rsFiles->ForceDirectoryCheck(true) ;
|
||||
|
||||
|
@ -1412,7 +1415,12 @@ bool ftController::FileClearCompleted()
|
|||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyDownloadCompleteCount(0);
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsFileTransferEvent>();
|
||||
ev->mFileTransferEventCode = RsFileTransferEventCode::COMPLETED_FILES_REMOVED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,13 @@ enum class RsEventType : uint32_t
|
|||
/// @see RsGxsPostedEvent
|
||||
GXS_IDENTITY = 12,
|
||||
|
||||
MAX /// Used to detect invalid event type passed
|
||||
/// @see RsFiles
|
||||
SHARED_DIRECTORIES = 13,
|
||||
|
||||
/// @see RsFiles
|
||||
FILE_TRANSFER = 14,
|
||||
|
||||
MAX /// Used to detect invalid event type passed
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "serialiser/rsserializable.h"
|
||||
#include "rsturtle.h"
|
||||
#include "util/rstime.h"
|
||||
#include "retroshare/rsevents.h"
|
||||
|
||||
class RsFiles;
|
||||
|
||||
|
@ -114,6 +115,55 @@ const TransferRequestFlags RS_FILE_REQ_NO_SEARCH ( 0x02000000 ); // di
|
|||
|
||||
const uint32_t RS_FILE_EXTRA_DELETE = 0x0010;
|
||||
|
||||
enum class RsSharedDirectoriesEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
STARTING_DIRECTORY_SWEEP = 0x01, // (void)
|
||||
HASHING_FILE = 0x02, // mMessage: full path and hashing speed of the file being hashed
|
||||
DIRECTORY_SWEEP_ENDED = 0x03, // (void)
|
||||
SAVING_FILE_INDEX = 0x04, // (void)
|
||||
};
|
||||
|
||||
enum class RsFileTransferEventCode: uint8_t {
|
||||
UNKNOWN = 0x00,
|
||||
DOWNLOAD_COMPLETE = 0x01, // mHash: hash of the complete file
|
||||
COMPLETED_FILES_REMOVED = 0x02, //
|
||||
};
|
||||
|
||||
struct RsSharedDirectoriesEvent: RsEvent
|
||||
{
|
||||
RsSharedDirectoriesEvent() : RsEvent(RsEventType::SHARED_DIRECTORIES), mEventCode(RsSharedDirectoriesEventCode::UNKNOWN) {}
|
||||
~RsSharedDirectoriesEvent() override = default;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
|
||||
RS_SERIAL_PROCESS(mEventCode);
|
||||
RS_SERIAL_PROCESS(mMessage);
|
||||
}
|
||||
|
||||
RsSharedDirectoriesEventCode mEventCode;
|
||||
std::string mMessage;
|
||||
};
|
||||
|
||||
struct RsFileTransferEvent: RsEvent
|
||||
{
|
||||
RsFileTransferEvent() : RsEvent(RsEventType::FILE_TRANSFER), mFileTransferEventCode(RsFileTransferEventCode::UNKNOWN) {}
|
||||
~RsFileTransferEvent() override = default;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
|
||||
RS_SERIAL_PROCESS(mFileTransferEventCode);
|
||||
RS_SERIAL_PROCESS(mHash);
|
||||
}
|
||||
|
||||
RsFileTransferEventCode mFileTransferEventCode;
|
||||
RsFileHash mHash;
|
||||
};
|
||||
struct SharedDirInfo : RsSerializable
|
||||
{
|
||||
static bool sameLists(const std::list<RsNodeGroupId>& l1,const std::list<RsNodeGroupId>& l2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue