mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-29 17:28:41 -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
|
@ -18,6 +18,7 @@
|
|||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "TransferUserNotify.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
@ -27,7 +28,7 @@ TransferUserNotify::TransferUserNotify(QObject *parent) :
|
|||
{
|
||||
newTransferCount = 0;
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(downloadCompleteCountChanged(int)), this, SLOT(downloadCountChanged(int)));
|
||||
// connect(NotifyQt::getInstance(), SIGNAL(downloadCompleteCountChanged(int)), this, SLOT(downloadCountChanged(int)));
|
||||
}
|
||||
|
||||
bool TransferUserNotify::hasSetting(QString *name, QString *group)
|
||||
|
@ -50,7 +51,17 @@ QIcon TransferUserNotify::getMainIcon(bool hasNew)
|
|||
|
||||
unsigned int TransferUserNotify::getNewCount()
|
||||
{
|
||||
return newTransferCount;
|
||||
std::list<RsFileHash> hashs;
|
||||
rsFiles->FileDownloads(hashs);
|
||||
FileInfo info;
|
||||
|
||||
newTransferCount = 0;
|
||||
|
||||
for(auto hash: hashs)
|
||||
if(rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info) && info.downloadStatus==FT_STATE_COMPLETE)
|
||||
++newTransferCount;
|
||||
|
||||
return newTransferCount;
|
||||
}
|
||||
|
||||
QString TransferUserNotify::getTrayMessage(bool plural)
|
||||
|
@ -68,8 +79,3 @@ void TransferUserNotify::iconClicked()
|
|||
MainWindow::showWindow(MainWindow::Transfers);
|
||||
}
|
||||
|
||||
void TransferUserNotify::downloadCountChanged(int count)
|
||||
{
|
||||
newTransferCount = count;
|
||||
updateIcon();
|
||||
}
|
||||
|
|
|
@ -32,9 +32,6 @@ public:
|
|||
|
||||
virtual bool hasSetting(QString *name, QString *group);
|
||||
|
||||
private slots:
|
||||
void downloadCountChanged(int count);
|
||||
|
||||
private:
|
||||
virtual QIcon getIcon();
|
||||
virtual QIcon getMainIcon(bool hasNew);
|
||||
|
|
|
@ -1091,10 +1091,34 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||
|
||||
|
||||
registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ;
|
||||
|
||||
mEventHandlerId=0;
|
||||
rsEvents->registerEventsHandler(RsEventType::FILE_TRANSFER, [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void TransfersDialog::handleEvent(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::FILE_TRANSFER)
|
||||
return;
|
||||
|
||||
const RsFileTransferEvent *fe = dynamic_cast<const RsFileTransferEvent*>(event.get());
|
||||
if(!fe)
|
||||
return;
|
||||
|
||||
switch (fe->mFileTransferEventCode)
|
||||
{
|
||||
case RsFileTransferEventCode::DOWNLOAD_COMPLETE:
|
||||
case RsFileTransferEventCode::COMPLETED_FILES_REMOVED:
|
||||
getUserNotify()->updateIcon();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TransfersDialog::~TransfersDialog()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
|
||||
// save settings
|
||||
processSettings(false);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <set>
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsevents.h>
|
||||
#include "RsAutoUpdatePage.h"
|
||||
|
||||
#include "ui_TransfersDialog.h"
|
||||
|
@ -259,6 +260,7 @@ private:
|
|||
bool controlTransferFile(uint32_t flags);
|
||||
void changePriority(int priority);
|
||||
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
||||
void handleEvent(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
QTreeView *downloadList;
|
||||
|
||||
|
@ -273,6 +275,7 @@ private:
|
|||
/** Qt Designer generated object */
|
||||
Ui::TransfersDialog ui;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
public slots:
|
||||
// these four functions add entries to the transfers dialog, and return the row id of the entry modified/added
|
||||
// int addDLItem(int row, const FileInfo &fileInfo);
|
||||
|
|
|
@ -1377,6 +1377,9 @@ void IdDialog::circle_selected()
|
|||
|
||||
IdDialog::~IdDialog()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId_identity);
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId_circles);
|
||||
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
|
@ -2057,9 +2060,11 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
|
|||
return tr("Admin signature verification in service %1").arg(service_name);
|
||||
case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION: // not typically used, since most services do not require group author signatures
|
||||
return tr("Creation of author signature in service %1").arg(service_name);
|
||||
case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION:
|
||||
case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION: // most common use case. Messages are signed by authors in e.g. forums.
|
||||
return tr("Message signature creation in group %1 of service %2").arg(QString::fromStdString(u.mGrpId.toStdString())).arg(service_name);
|
||||
case RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
|
||||
case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION:
|
||||
return tr("Group author for group %1 in service %2").arg(QString::fromStdString(u.mGrpId.toStdString())).arg(service_name);
|
||||
break ;
|
||||
case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION:
|
||||
case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
|
||||
|
@ -2103,18 +2108,9 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
|
|||
{
|
||||
return tr("Generic signature.");
|
||||
}
|
||||
case RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION:
|
||||
{
|
||||
return tr("Generic encryption.");
|
||||
}
|
||||
case RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION:
|
||||
{
|
||||
return tr("Generic decryption.");
|
||||
}
|
||||
case RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK:
|
||||
{
|
||||
return tr("Membership verification in circle %1.").arg(QString::fromStdString(u.mGrpId.toStdString()));
|
||||
}
|
||||
case RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION: return tr("Generic encryption.");
|
||||
case RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION: return tr("Generic decryption.");
|
||||
case RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK: return tr("Membership verification in circle %1.").arg(QString::fromStdString(u.mGrpId.toStdString()));
|
||||
|
||||
#warning TODO! csoler 2017-01-03: Add the different strings and translations here.
|
||||
default:
|
||||
|
|
|
@ -83,6 +83,7 @@ void PostedDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
|||
|
||||
PostedDialog::~PostedDialog()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
UserNotify *PostedDialog::createUserNotify(QObject *parent)
|
||||
|
|
|
@ -266,6 +266,7 @@ void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> e)
|
|||
|
||||
NewFriendList::~NewFriendList()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,8 +155,6 @@ private:
|
|||
|
||||
void initUi();
|
||||
|
||||
void updateSearchResults();
|
||||
|
||||
void openGroupInNewTab(const RsGxsGroupId &groupId);
|
||||
void groupSubscribe(bool subscribe);
|
||||
|
||||
|
@ -185,6 +183,8 @@ private:
|
|||
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
||||
|
||||
protected:
|
||||
void updateSearchResults();
|
||||
|
||||
bool mCountChildMsgs; // Count unread child messages?
|
||||
|
||||
private:
|
||||
|
|
|
@ -42,11 +42,6 @@ void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update)
|
|||
mBase->setUpdateWhenInvisible(update);
|
||||
}
|
||||
|
||||
const std::set<TurtleRequestId>& RsGxsUpdateBroadcastPage::getSearchResults()
|
||||
{
|
||||
return mBase->getSearchResults();
|
||||
}
|
||||
|
||||
const std::set<RsGxsGroupId> &RsGxsUpdateBroadcastPage::getGrpIdsMeta()
|
||||
{
|
||||
return mBase->getGrpIdsMeta();
|
||||
|
|
|
@ -51,7 +51,8 @@ public:
|
|||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIds();
|
||||
const std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &getMsgIdsMeta();
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgIds);
|
||||
const std::set<TurtleRequestId>& getSearchResults();
|
||||
|
||||
virtual const std::set<TurtleRequestId> getSearchResults() const { return std::set<TurtleRequestId>(); } // overload this for subclasses that provide distant search
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
|
|
@ -76,6 +76,11 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
|||
updateMessageSummaryList(e->mChannelGroupId);
|
||||
break;
|
||||
|
||||
case RsChannelEventCode::RECEIVED_DISTANT_SEARCH_RESULT:
|
||||
mSearchResults.insert(e->mDistantSearchRequestId);
|
||||
updateSearchResults();
|
||||
break;
|
||||
|
||||
case RsChannelEventCode::NEW_CHANNEL: // [[fallthrough]];
|
||||
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED:
|
||||
updateDisplay(true);
|
||||
|
@ -88,6 +93,7 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
|||
|
||||
GxsChannelDialog::~GxsChannelDialog()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
QString GxsChannelDialog::getHelpString() const
|
||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
|||
virtual QString getHelpString() const ;
|
||||
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
|
||||
virtual bool getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId,RsGxsGroupSummary>& group_infos);
|
||||
virtual const std::set<TurtleRequestId> getSearchResults() const override { return mSearchResults ; }
|
||||
|
||||
virtual TurtleRequestId distantSearch(const QString& search_string) ;
|
||||
virtual void checkRequestGroup(const RsGxsGroupId& grpId) ;
|
||||
|
@ -76,6 +77,8 @@ private:
|
|||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
std::set<TurtleRequestId> mSearchResults;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
|
|
|
@ -158,6 +158,7 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
|
|||
|
||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
|
|
|
@ -490,6 +490,7 @@ void GxsForumThreadWidget::blank()
|
|||
|
||||
GxsForumThreadWidget::~GxsForumThreadWidget()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
|
|||
|
||||
GxsForumsDialog::~GxsForumsDialog()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
QString GxsForumsDialog::getHelpString() const
|
||||
|
|
|
@ -349,6 +349,7 @@ void NotifyQt::notifyDiscInfoChanged()
|
|||
emit discInfoChanged() ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void NotifyQt::notifyDownloadComplete(const std::string& fileHash)
|
||||
{
|
||||
{
|
||||
|
@ -376,6 +377,7 @@ void NotifyQt::notifyDownloadCompleteCount(uint32_t count)
|
|||
|
||||
emit downloadCompleteCountChanged(count);
|
||||
}
|
||||
#endif
|
||||
|
||||
void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb)
|
||||
{
|
||||
|
@ -582,6 +584,7 @@ void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,c
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void NotifyQt::notifyHashingInfo(uint32_t type, const std::string& fileinfo)
|
||||
{
|
||||
QString info;
|
||||
|
@ -608,6 +611,7 @@ void NotifyQt::notifyHashingInfo(uint32_t type, const std::string& fileinfo)
|
|||
|
||||
emit hashingInfoChanged(info);
|
||||
}
|
||||
#endif
|
||||
|
||||
void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type)
|
||||
{
|
||||
|
|
|
@ -67,7 +67,9 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string);
|
||||
virtual void notifyChatCleared(const ChatId &chat_id);
|
||||
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
|
||||
#ifdef TO_REMOVE
|
||||
virtual void notifyHashingInfo(uint32_t type, const std::string& fileinfo);
|
||||
#endif
|
||||
virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files);
|
||||
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups);
|
||||
virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
|
||||
|
@ -85,8 +87,10 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
virtual void notifyHistoryChanged(uint32_t msgId, int type);
|
||||
|
||||
virtual void notifyDiscInfoChanged() ;
|
||||
#ifdef TO_REMOVE
|
||||
virtual void notifyDownloadComplete(const std::string& fileHash);
|
||||
virtual void notifyDownloadCompleteCount(uint32_t count);
|
||||
#endif
|
||||
virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled);
|
||||
virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time);
|
||||
|
||||
|
@ -153,8 +157,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
void chatMessageReceived(ChatMessage msg);
|
||||
void groupsChanged(int type) const ;
|
||||
void discInfoChanged() const ;
|
||||
void downloadComplete(const QString& /* fileHash */);
|
||||
void downloadCompleteCountChanged(int /* count */);
|
||||
#ifdef REMOVE
|
||||
void forumMsgReadSatusChanged(const QString& forumId, const QString& msgId, int status);
|
||||
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
||||
|
|
|
@ -52,11 +52,42 @@ HashingStatus::HashingStatus(QWidget *parent)
|
|||
hashloader->hide();
|
||||
statusHashing->hide();
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(hashingInfoChanged(const QString&)), SLOT(updateHashingInfo(const QString&)));
|
||||
mEventHandlerId=0;
|
||||
rsEvents->registerEventsHandler(RsEventType::SHARED_DIRECTORIES, [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::SHARED_DIRECTORIES)
|
||||
return;
|
||||
|
||||
const RsSharedDirectoriesEvent *fe = dynamic_cast<const RsSharedDirectoriesEvent*>(event.get());
|
||||
if(!fe)
|
||||
return;
|
||||
|
||||
QString info;
|
||||
|
||||
switch (fe->mEventCode)
|
||||
{
|
||||
case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP:
|
||||
info = tr("Examining shared files...");
|
||||
break;
|
||||
case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED:
|
||||
break;
|
||||
case RsSharedDirectoriesEventCode::HASHING_FILE:
|
||||
info = tr("Hashing file") + " " + QString::fromUtf8(fe->mMessage.c_str());
|
||||
break;
|
||||
case RsSharedDirectoriesEventCode::SAVING_FILE_INDEX:
|
||||
info = tr("Saving file index...");
|
||||
break;
|
||||
}
|
||||
|
||||
updateHashingInfo(info);
|
||||
}
|
||||
|
||||
HashingStatus::~HashingStatus()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
delete(movie);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define HASHINGSTATUS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "retroshare/rsevents.h"
|
||||
|
||||
class QLabel;
|
||||
class ElidedLabel;
|
||||
|
@ -37,15 +38,16 @@ public:
|
|||
void setCompactMode(bool compact) {_compactMode = compact; }
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
|
||||
public slots:
|
||||
void updateHashingInfo(const QString&) ;
|
||||
|
||||
private:
|
||||
void updateHashingInfo(const QString& s);
|
||||
void handleEvent(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
ElidedLabel *statusHashing;
|
||||
QLabel *hashloader;
|
||||
QString mLastText ;
|
||||
QMovie *movie;
|
||||
bool _compactMode;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,11 @@ RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) :
|
|||
}, mEventHandlerId );
|
||||
}
|
||||
|
||||
RsGxsUpdateBroadcast::~RsGxsUpdateBroadcast()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcast::cleanup()
|
||||
{
|
||||
QMap<RsGxsIfaceHelper*, RsGxsUpdateBroadcast*>::iterator it;
|
||||
|
|
|
@ -40,6 +40,9 @@ public:
|
|||
|
||||
static RsGxsUpdateBroadcast *get(RsGxsIfaceHelper* ifaceImpl);
|
||||
|
||||
protected:
|
||||
virtual ~RsGxsUpdateBroadcast();
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void msgsChanged(const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgIdsMeta);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue