mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-30 01:38:51 -04:00
merged upstream/master
This commit is contained in:
commit
c75d372f24
20 changed files with 155 additions and 95 deletions
|
@ -72,8 +72,21 @@ static NewsFeed *instance = NULL;
|
|||
/** Constructor */
|
||||
NewsFeed::NewsFeed(QWidget *parent) : MainPage(parent), ui(new Ui::NewsFeed)
|
||||
{
|
||||
mEventHandlerId =0; // needed to force intialization by registerEventsHandler()
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
||||
mEventTypes = {
|
||||
RsEventType::AUTHSSL_CONNECTION_AUTENTICATION,
|
||||
RsEventType::PEER_CONNECTION ,
|
||||
RsEventType::GXS_CIRCLES ,
|
||||
RsEventType::GXS_CHANNELS ,
|
||||
RsEventType::GXS_FORUMS ,
|
||||
RsEventType::GXS_POSTED ,
|
||||
RsEventType::MAIL_STATUS
|
||||
};
|
||||
|
||||
for(uint32_t i=0;i<mEventTypes.size();++i)
|
||||
{
|
||||
mEventHandlerIds.push_back(0); // needed to force intialization by registerEventsHandler()
|
||||
rsEvents->registerEventsHandler(mEventTypes[i], [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerIds.back() );
|
||||
}
|
||||
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
@ -117,7 +130,8 @@ QString hlp_str = tr(
|
|||
|
||||
NewsFeed::~NewsFeed()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
for(uint32_t i=0;i<mEventHandlerIds.size();++i)
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerIds[i]);
|
||||
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
@ -190,7 +204,7 @@ void NewsFeed::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
|||
if(event->mType == RsEventType::GXS_POSTED && (flags & RS_FEED_TYPE_POSTED))
|
||||
handlePostedEvent(event);
|
||||
|
||||
if(event->mType == RsEventType::MAIL_STATUS_CHANGE && (flags & RS_FEED_TYPE_MSG))
|
||||
if(event->mType == RsEventType::MAIL_STATUS && (flags & RS_FEED_TYPE_MSG))
|
||||
handleMailEvent(event);
|
||||
}
|
||||
|
||||
|
@ -200,6 +214,7 @@ void NewsFeed::handleMailEvent(std::shared_ptr<const RsEvent> event)
|
|||
dynamic_cast<const RsMailStatusEvent*>(event.get());
|
||||
if(!pe) return;
|
||||
|
||||
|
||||
switch(pe->mMailStatusEventCode)
|
||||
{
|
||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||
|
|
|
@ -118,7 +118,8 @@ private:
|
|||
/* UI - from Designer */
|
||||
Ui::NewsFeed *ui;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
std::vector<RsEventsHandlerId_t> mEventHandlerIds;
|
||||
std::vector<RsEventType> mEventTypes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -178,7 +178,7 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
|
|||
ui->filterLineEdit->showFilterIcon();
|
||||
|
||||
mEventHandlerId=0; // forces initialization
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId );
|
||||
rsEvents->registerEventsHandler( RsEventType::PEER_CONNECTION, [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId );
|
||||
|
||||
mModel = new RsFriendListModel();
|
||||
mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this);
|
||||
|
@ -258,13 +258,10 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
|
|||
|
||||
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> e)
|
||||
{
|
||||
if(e->mType == RsEventType::PEER_CONNECTION)
|
||||
{
|
||||
// /!\ The function we're in is called from a different thread. It's very important
|
||||
// to use this trick in order to avoid data races.
|
||||
// /!\ The function we're in is called from a different thread. It's very important
|
||||
// to use this trick in order to avoid data races.
|
||||
|
||||
RsQThreadUtils::postToObject( [=]() { forceUpdateDisplay() ; }, this ) ;
|
||||
}
|
||||
RsQThreadUtils::postToObject( [=]() { forceUpdateDisplay() ; }, this ) ;
|
||||
}
|
||||
|
||||
NewFriendList::~NewFriendList()
|
||||
|
|
|
@ -52,17 +52,15 @@ GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
|||
{
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_CHANNELS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANNELS)
|
||||
{
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
|
@ -71,7 +69,6 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GxsChannelDialog::~GxsChannelDialog()
|
||||
|
|
|
@ -132,17 +132,15 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
|||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_CHANNELS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANNELS)
|
||||
{
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
|
@ -156,7 +154,6 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||
|
|
|
@ -436,7 +436,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_FORUMS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
|
|
|
@ -45,7 +45,7 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_FORUMS, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
|
|
|
@ -39,11 +39,9 @@ RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) :
|
|||
{
|
||||
mEventHandlerId = 0; // forces initialization in registerEventsHandler()
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
||||
rsEvents->registerEventsHandler(RsEventType::GXS_CHANGES, [this](std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANGES)
|
||||
onChangesReceived(*dynamic_cast<const RsGxsChanges*>(event.get()));
|
||||
|
||||
onChangesReceived(*dynamic_cast<const RsGxsChanges*>(event.get()));
|
||||
}, mEventHandlerId );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue