fixed compilation for feed reader plugin

This commit is contained in:
csoler 2025-11-24 21:09:45 +01:00
parent d3069e9b44
commit 28a5db7204
9 changed files with 57 additions and 49 deletions

View file

@ -570,7 +570,7 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type)
} }
FeedInfo feedInfo; FeedInfo feedInfo;
if (type != NOTIFY_TYPE_DEL) { if (type != FeedReaderNotify::NOTIFY_TYPE_DEL) {
if (!mFeedReader->getFeedInfo(feedId, feedInfo)) { if (!mFeedReader->getFeedInfo(feedId, feedInfo)) {
return; return;
} }
@ -580,12 +580,12 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type)
} }
} }
if (type == NOTIFY_TYPE_MOD || type == NOTIFY_TYPE_DEL) { if (type == FeedReaderNotify::NOTIFY_TYPE_MOD || type == FeedReaderNotify::NOTIFY_TYPE_DEL) {
QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItemIterator it(ui->feedTreeWidget);
QTreeWidgetItem *item; QTreeWidgetItem *item;
while ((item = *it) != NULL) { while ((item = *it) != NULL) {
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) { if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) {
if (type == NOTIFY_TYPE_MOD) { if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) {
updateFeedItem(item, feedInfo); updateFeedItem(item, feedInfo);
} else { } else {
delete(item); delete(item);
@ -596,7 +596,7 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type)
} }
} }
if (type == NOTIFY_TYPE_ADD) { if (type == FeedReaderNotify::NOTIFY_TYPE_ADD) {
QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItemIterator it(ui->feedTreeWidget);
QTreeWidgetItem *itemParent; QTreeWidgetItem *itemParent;
while ((itemParent = *it) != NULL) { while ((itemParent = *it) != NULL) {

View file

@ -40,15 +40,15 @@ class FeedReaderDialog : public MainPage
Q_OBJECT Q_OBJECT
public: public:
FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0);
~FeedReaderDialog(); ~FeedReaderDialog();
static QIcon iconFromFeed(const FeedInfo &feedInfo); static QIcon iconFromFeed(const FeedInfo &feedInfo);
protected: protected:
virtual UserNotify *createUserNotify(QObject *parent) override; virtual UserNotify *createUserNotify(QObject *parent) override;
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event) override;
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev) override;
private slots: private slots:
void settingsChanged(); void settingsChanged();

View file

@ -72,7 +72,7 @@ void FeedReaderFeedNotify::msgChanged(uint32_t feedId, const QString &msgId, int
return; return;
} }
if (type != NOTIFY_TYPE_ADD) { if (type != FeedReaderNotify::NOTIFY_TYPE_ADD) {
return; return;
} }

View file

@ -515,12 +515,12 @@ void FeedReaderMessageWidget::feedChanged(uint32_t feedId, int type)
return; return;
} }
if (type == NOTIFY_TYPE_DEL) { if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) {
setFeedId(0); setFeedId(0);
return; return;
} }
if (type == NOTIFY_TYPE_MOD) { if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) {
if (!mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) { if (!mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) {
setFeedId(0); setFeedId(0);
return; return;
@ -555,18 +555,18 @@ void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId,
} }
FeedMsgInfo msgInfo; FeedMsgInfo msgInfo;
if (type != NOTIFY_TYPE_DEL) { if (type != FeedReaderNotify::NOTIFY_TYPE_DEL) {
if (!mFeedReader->getMsgInfo(feedId, msgId.toStdString(), msgInfo)) { if (!mFeedReader->getMsgInfo(feedId, msgId.toStdString(), msgInfo)) {
return; return;
} }
} }
if (type == NOTIFY_TYPE_MOD || type == NOTIFY_TYPE_DEL) { if (type == FeedReaderNotify::NOTIFY_TYPE_MOD || type == FeedReaderNotify::NOTIFY_TYPE_DEL) {
QTreeWidgetItemIterator it(ui->msgTreeWidget); QTreeWidgetItemIterator it(ui->msgTreeWidget);
QTreeWidgetItem *item; QTreeWidgetItem *item;
while ((item = *it) != NULL) { while ((item = *it) != NULL) {
if (item->data(COLUMN_MSG_DATA, ROLE_MSG_ID).toString() == msgId) { if (item->data(COLUMN_MSG_DATA, ROLE_MSG_ID).toString() == msgId) {
if (type == NOTIFY_TYPE_MOD) { if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) {
updateMsgItem(item, msgInfo); updateMsgItem(item, msgInfo);
filterItem(item); filterItem(item);
} else { } else {
@ -578,13 +578,13 @@ void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId,
} }
} }
if (type == NOTIFY_TYPE_MOD) { if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) {
if (msgId.toStdString() == currentMsgId()) { if (msgId.toStdString() == currentMsgId()) {
updateCurrentMessage(); updateCurrentMessage();
} }
} }
if (type == NOTIFY_TYPE_ADD) { if (type == FeedReaderNotify::NOTIFY_TYPE_ADD) {
QTreeWidgetItem *item = new RSTreeWidgetItem(mMsgCompareRole); QTreeWidgetItem *item = new RSTreeWidgetItem(mMsgCompareRole);
updateMsgItem(item, msgInfo); updateMsgItem(item, msgInfo);
ui->msgTreeWidget->addTopLevelItem(item); ui->msgTreeWidget->addTopLevelItem(item);

View file

@ -29,6 +29,13 @@ class FeedReaderNotify : public QObject, public RsFeedReaderNotify
Q_OBJECT Q_OBJECT
public: public:
// These replace the variables from the old notify system. It's simpler than switching the entire
// feedreader plugin to the new rsEvents system
static const int NOTIFY_TYPE_ADD = 0x01;
static const int NOTIFY_TYPE_DEL = 0x02;
static const int NOTIFY_TYPE_MOD = 0x03;
FeedReaderNotify(); FeedReaderNotify();
/* RsFeedReaderNotify */ /* RsFeedReaderNotify */

View file

@ -67,7 +67,7 @@ void FeedReaderUserNotify::iconClicked()
void FeedReaderUserNotify::feedChanged(uint32_t /*feedId*/, int type) void FeedReaderUserNotify::feedChanged(uint32_t /*feedId*/, int type)
{ {
if (type == NOTIFY_TYPE_DEL) { if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) {
updateIcon(); updateIcon();
} }
} }

View file

@ -294,13 +294,13 @@ void PreviewFeedDialog::feedChanged(uint32_t feedId, int type)
return; return;
} }
if (type == NOTIFY_TYPE_DEL) { if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) {
/* feed deleted */ /* feed deleted */
mFeedId = 0; mFeedId = 0;
return; return;
} }
if (type == NOTIFY_TYPE_ADD || type == NOTIFY_TYPE_MOD) { if (type == FeedReaderNotify::NOTIFY_TYPE_ADD || type == FeedReaderNotify::NOTIFY_TYPE_MOD) {
FeedInfo feedInfo; FeedInfo feedInfo;
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) { if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
return; return;
@ -320,18 +320,18 @@ void PreviewFeedDialog::msgChanged(uint32_t feedId, const QString &msgId, int ty
} }
switch (type) { switch (type) {
case NOTIFY_TYPE_ADD: case FeedReaderNotify::NOTIFY_TYPE_ADD:
if (mMsgId.empty()) { if (mMsgId.empty()) {
mMsgId = msgId.toStdString(); mMsgId = msgId.toStdString();
updateMsg(); updateMsg();
} }
break; break;
case NOTIFY_TYPE_MOD: case FeedReaderNotify::NOTIFY_TYPE_MOD:
if (mMsgId == msgId.toStdString()) { if (mMsgId == msgId.toStdString()) {
updateMsg(); updateMsg();
} }
break; break;
case NOTIFY_TYPE_DEL: case FeedReaderNotify::NOTIFY_TYPE_DEL:
if (mMsgId == msgId.toStdString()) { if (mMsgId == msgId.toStdString()) {
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId); std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
if (it != mMsgIds.end()) { if (it != mMsgIds.end()) {

View file

@ -20,6 +20,7 @@
#include "rsFeedReaderItems.h" #include "rsFeedReaderItems.h"
#include "p3FeedReader.h" #include "p3FeedReader.h"
#include "gui/FeedReaderNotify.h"
#include "p3FeedReaderThread.h" #include "p3FeedReaderThread.h"
#include "rsitems/rsconfigitems.h" #include "rsitems/rsconfigitems.h"
#include "retroshare/rsiface.h" #include "retroshare/rsiface.h"
@ -415,7 +416,7 @@ RsFeedResult p3FeedReader::addFolder(uint32_t parentId, const std::string &name,
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD);
} }
return RS_FEED_RESULT_SUCCESS; return RS_FEED_RESULT_SUCCESS;
@ -455,7 +456,7 @@ RsFeedResult p3FeedReader::setFolder(uint32_t feedId, const std::string &name)
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
return RS_FEED_RESULT_SUCCESS; return RS_FEED_RESULT_SUCCESS;
@ -502,7 +503,7 @@ RsFeedResult p3FeedReader::addFeed(const FeedInfo &feedInfo, uint32_t &feedId)
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD);
} }
return RS_FEED_RESULT_SUCCESS; return RS_FEED_RESULT_SUCCESS;
@ -587,7 +588,7 @@ RsFeedResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
if (!forumId.empty()) { if (!forumId.empty()) {
@ -658,7 +659,7 @@ RsFeedResult p3FeedReader::setParent(uint32_t feedId, uint32_t parentId)
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
@ -756,7 +757,7 @@ bool p3FeedReader::removeFeed(uint32_t feedId)
/* only notify remove of feed */ /* only notify remove of feed */
std::list<uint32_t>::iterator it; std::list<uint32_t>::iterator it;
for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) { for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) {
mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_DEL); mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_DEL);
} }
} }
@ -803,7 +804,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId)
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD);
} }
{ {
@ -925,8 +926,8 @@ bool p3FeedReader::removeMsg(uint32_t feedId, const std::string &msgId)
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_DEL); mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_DEL);
} }
return true; return true;
@ -977,11 +978,11 @@ bool p3FeedReader::removeMsgs(uint32_t feedId, const std::list<std::string> &msg
} }
if (mNotify && !removedMsgs.empty()) { if (mNotify && !removedMsgs.empty()) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
for (it = removedMsgs.begin(); it != removedMsgs.end(); ++it) { for (it = removedMsgs.begin(); it != removedMsgs.end(); ++it) {
mNotify->notifyMsgChanged(feedId, *it, NOTIFY_TYPE_DEL); mNotify->notifyMsgChanged(feedId, *it, FeedReaderNotify::NOTIFY_TYPE_DEL);
} }
} }
@ -1224,7 +1225,7 @@ bool p3FeedReader::processFeed(uint32_t feedId)
if (mNotify) { if (mNotify) {
for (it = notifyIds.begin(); it != notifyIds.end(); ++it) { for (it = notifyIds.begin(); it != notifyIds.end(); ++it) {
mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
@ -1273,8 +1274,8 @@ bool p3FeedReader::setMessageRead(uint32_t feedId, const std::string &msgId, boo
if (changed) { if (changed) {
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_OFTEN); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_OFTEN);
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_MOD); mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
@ -1328,10 +1329,10 @@ bool p3FeedReader::retransformMsg(uint32_t feedId, const std::string &msgId)
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
if (mNotify) { if (mNotify) {
if (feedChanged) { if (feedChanged) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
if (msgChanged) { if (msgChanged) {
mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_MOD); mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
} }
@ -1466,7 +1467,7 @@ int p3FeedReader::tick()
if (mNotify) { if (mNotify) {
for (it = notifyIds.begin(); it != notifyIds.end(); ++it) { for (it = notifyIds.begin(); it != notifyIds.end(); ++it) {
mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
if (imageToOptimze) { if (imageToOptimze) {
mNotify->notifyOptimizeImage(); mNotify->notifyOptimizeImage();
@ -1526,7 +1527,7 @@ void p3FeedReader::cleanFeeds()
if (mNotify) { if (mNotify) {
std::list<std::pair<uint32_t, std::string> >::iterator it; std::list<std::pair<uint32_t, std::string> >::iterator it;
for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) { for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) {
mNotify->notifyMsgChanged(it->first, it->second, NOTIFY_TYPE_DEL); mNotify->notifyMsgChanged(it->first, it->second, FeedReaderNotify::NOTIFY_TYPE_DEL);
} }
} }
} }
@ -1801,7 +1802,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeed
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
return true; return true;
@ -1852,7 +1853,7 @@ void p3FeedReader::onDownloadSuccess(uint32_t feedId, const std::string &content
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
@ -1889,7 +1890,7 @@ void p3FeedReader::onDownloadError(uint32_t feedId, RsFeedReaderErrorState resul
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
@ -1944,7 +1945,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedI
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
return true; return true;
@ -2323,11 +2324,11 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
for (it = addedMsgs.begin(); it != addedMsgs.end(); ++it) { for (it = addedMsgs.begin(); it != addedMsgs.end(); ++it) {
mNotify->notifyMsgChanged(feedId, *it, NOTIFY_TYPE_ADD); mNotify->notifyMsgChanged(feedId, *it, FeedReaderNotify::NOTIFY_TYPE_ADD);
} }
} }
} }
@ -2365,7 +2366,7 @@ void p3FeedReader::onProcessError(uint32_t feedId, RsFeedReaderErrorState result
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }
@ -2433,7 +2434,7 @@ void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const s
} }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD);
} }
} }

View file

@ -32,9 +32,9 @@ class RsFeedReaderMsg;
class p3FeedReaderThread; class p3FeedReaderThread;
class RsGxsForums; class RsGxsForums;
struct RsGxsForumGroup; class RsGxsForumGroup;
class RsPosted; class RsPosted;
struct RsPostedGroup; class RsPostedGroup;
class RsGxsIfaceHelper; class RsGxsIfaceHelper;
class p3FeedReader : public RsPQIService, public RsFeedReader class p3FeedReader : public RsPQIService, public RsFeedReader