mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
Merge pull request #1776 from csoler/v0.6-FT
More switch to new notification system
This commit is contained in:
commit
f72b385ccf
28 changed files with 296 additions and 129 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)
|
||||
|
|
|
@ -105,27 +105,15 @@ struct RsGxsChannelPost : RsSerializable
|
|||
|
||||
enum class RsChannelEventCode: uint8_t
|
||||
{
|
||||
UNKNOWN = 0x00,
|
||||
NEW_CHANNEL = 0x01, /// emitted when new channel is received
|
||||
|
||||
/// emitted when existing channel is updated
|
||||
UPDATED_CHANNEL = 0x02,
|
||||
|
||||
/// new message reeived in a particular channel (group and msg id)
|
||||
NEW_MESSAGE = 0x03,
|
||||
|
||||
/// existing message has been updated in a particular channel
|
||||
UPDATED_MESSAGE = 0x04,
|
||||
|
||||
/// publish key for this channel has been received
|
||||
RECEIVED_PUBLISH_KEY = 0x05,
|
||||
|
||||
/// subscription for channel mChannelGroupId changed.
|
||||
SUBSCRIBE_STATUS_CHANGED = 0x06,
|
||||
|
||||
/// existing message has been read or set to unread
|
||||
READ_STATUS_CHANGED = 0x07,
|
||||
|
||||
UNKNOWN = 0x00,
|
||||
NEW_CHANNEL = 0x01, // emitted when new channel is received
|
||||
UPDATED_CHANNEL = 0x02, // emitted when existing channel is updated
|
||||
NEW_MESSAGE = 0x03, // new message reeived in a particular channel (group and msg id)
|
||||
UPDATED_MESSAGE = 0x04, // existing message has been updated in a particular channel
|
||||
RECEIVED_PUBLISH_KEY = 0x05, // publish key for this channel has been received
|
||||
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
|
||||
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
|
||||
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
|
||||
};
|
||||
|
||||
struct RsGxsChannelEvent: RsEvent
|
||||
|
@ -137,6 +125,7 @@ struct RsGxsChannelEvent: RsEvent
|
|||
RsChannelEventCode mChannelEventCode;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
RsGxsMessageId mChannelMsgId;
|
||||
TurtleRequestId mDistantSearchRequestId;
|
||||
|
||||
///* @see RsEvent @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||
|
@ -146,6 +135,7 @@ struct RsGxsChannelEvent: RsEvent
|
|||
RS_SERIAL_PROCESS(mChannelEventCode);
|
||||
RS_SERIAL_PROCESS(mChannelGroupId);
|
||||
RS_SERIAL_PROCESS(mChannelMsgId);
|
||||
RS_SERIAL_PROCESS(mDistantSearchRequestId);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,14 @@ typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMe
|
|||
struct RsGxsNotify
|
||||
{
|
||||
enum NotifyType
|
||||
{ TYPE_PUBLISHED, TYPE_RECEIVED_NEW, TYPE_PROCESSED, TYPE_RECEIVED_PUBLISHKEY, TYPE_RECEIVED_DISTANT_SEARCH_RESULTS };
|
||||
{
|
||||
TYPE_UNKNOWN = 0x00,
|
||||
TYPE_PUBLISHED = 0x01,
|
||||
TYPE_RECEIVED_NEW = 0x02,
|
||||
TYPE_PROCESSED = 0x03,
|
||||
TYPE_RECEIVED_PUBLISHKEY = 0x04,
|
||||
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05
|
||||
};
|
||||
|
||||
virtual ~RsGxsNotify() {}
|
||||
virtual NotifyType getType() = 0;
|
||||
|
|
|
@ -245,6 +245,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
for(it = changes.begin(); it != changes.end(); ++it)
|
||||
{
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||
|
||||
if (msgChange)
|
||||
{
|
||||
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW|| msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED)
|
||||
|
@ -294,75 +295,84 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
||||
|
||||
if (grpChange && rsEvents)
|
||||
{
|
||||
if (rsEvents)
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
||||
if (grpChange)
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
default:
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
{
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
||||
{
|
||||
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
||||
IndicateConfigChanged();
|
||||
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case RsGxsNotify::TYPE_PUBLISHED:
|
||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
||||
{
|
||||
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
||||
IndicateConfigChanged();
|
||||
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||
{
|
||||
/* group received */
|
||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator git;
|
||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = *git;
|
||||
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
|
||||
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RsGxsDistantSearchResultChange *dsrChange = dynamic_cast<RsGxsDistantSearchResultChange*>(*it);
|
||||
|
||||
if(dsrChange && rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = dsrChange->mGroupId;
|
||||
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_DISTANT_SEARCH_RESULT;
|
||||
ev->mDistantSearchRequestId = dsrChange->mRequestId;
|
||||
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
||||
/* shouldn't need to worry about groups - as they need to be subscribed to */
|
||||
delete *it;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue