From 026cadfe1380f36e9f023a277a2e067c07884701 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 8 Nov 2020 13:22:59 +0100 Subject: [PATCH] Fixed compile of FeedReader plugin --- plugins/FeedReader/gui/AddFeedDialog.cpp | 17 +- plugins/FeedReader/gui/AddFeedDialog.h | 8 +- plugins/FeedReader/gui/FeedReaderDialog.cpp | 89 ++++--- plugins/FeedReader/gui/FeedReaderDialog.h | 21 +- plugins/FeedReader/gui/FeedReaderFeedItem.cpp | 28 +-- plugins/FeedReader/gui/FeedReaderFeedItem.h | 6 +- .../FeedReader/gui/FeedReaderFeedNotify.cpp | 14 +- plugins/FeedReader/gui/FeedReaderFeedNotify.h | 9 +- .../gui/FeedReaderMessageWidget.cpp | 55 ++--- .../FeedReader/gui/FeedReaderMessageWidget.h | 12 +- plugins/FeedReader/gui/FeedReaderNotify.cpp | 8 +- plugins/FeedReader/gui/FeedReaderNotify.h | 8 +- .../FeedReader/gui/FeedReaderUserNotify.cpp | 8 +- plugins/FeedReader/gui/FeedReaderUserNotify.h | 2 +- plugins/FeedReader/gui/PreviewFeedDialog.cpp | 22 +- plugins/FeedReader/gui/PreviewFeedDialog.h | 6 +- plugins/FeedReader/interface/rsFeedReader.h | 46 ++-- plugins/FeedReader/services/p3FeedReader.cc | 218 +++++++++--------- plugins/FeedReader/services/p3FeedReader.h | 58 ++--- .../FeedReader/services/p3FeedReaderThread.cc | 4 +- .../FeedReader/services/p3FeedReaderThread.h | 8 +- .../FeedReader/services/rsFeedReaderItems.cc | 57 +++-- .../FeedReader/services/rsFeedReaderItems.h | 7 +- 23 files changed, 366 insertions(+), 345 deletions(-) diff --git a/plugins/FeedReader/gui/AddFeedDialog.cpp b/plugins/FeedReader/gui/AddFeedDialog.cpp index 67934b322..19d02d968 100644 --- a/plugins/FeedReader/gui/AddFeedDialog.cpp +++ b/plugins/FeedReader/gui/AddFeedDialog.cpp @@ -42,6 +42,9 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, /* Setup UI helper */ mStateHelper = new UIStateHelper(this); + mFeedId = 0; + mParentId = 0; + mStateHelper->addWidget(TOKEN_TYPE_FORUM_GROUPS, ui->forumComboBox, UISTATE_LOADING_DISABLED); mStateHelper->addWidget(TOKEN_TYPE_FORUM_GROUPS, ui->buttonBox->button(QDialogButtonBox::Ok), UISTATE_LOADING_DISABLED); @@ -197,19 +200,19 @@ void AddFeedDialog::validate() mStateHelper->setWidgetEnabled(ui->buttonBox->button(QDialogButtonBox::Ok), ok); } -void AddFeedDialog::setParent(const std::string &parentId) +void AddFeedDialog::setParent(uint32_t parentId) { mParentId = parentId; } -bool AddFeedDialog::fillFeed(const std::string &feedId) +bool AddFeedDialog::fillFeed(uint32_t feedId) { mFeedId = feedId; - if (!mFeedId.empty()) { + if (mFeedId) { FeedInfo feedInfo; if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) { - mFeedId.clear(); + mFeedId = 0; return false; } @@ -326,7 +329,7 @@ void AddFeedDialog::getFeedInfo(FeedInfo &feedInfo) void AddFeedDialog::createFeed() { FeedInfo feedInfo; - if (!mFeedId.empty()) { + if (mFeedId) { if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) { QMessageBox::critical(this, tr("Edit feed"), tr("Can't edit feed. Feed does not exist.")); return; @@ -335,7 +338,7 @@ void AddFeedDialog::createFeed() getFeedInfo(feedInfo); - if (mFeedId.empty()) { + if (mFeedId == 0) { /* add new feed */ RsFeedAddResult result = mFeedReader->addFeed(feedInfo, mFeedId); if (FeedReaderStringDefs::showError(this, result, tr("Create feed"), tr("Cannot create feed."))) { @@ -365,7 +368,7 @@ void AddFeedDialog::preview() void AddFeedDialog::clearMessageCache() { - if (mFeedId.empty()) { + if (mFeedId == 0) { return; } diff --git a/plugins/FeedReader/gui/AddFeedDialog.h b/plugins/FeedReader/gui/AddFeedDialog.h index f9ab5e90e..111238d33 100644 --- a/plugins/FeedReader/gui/AddFeedDialog.h +++ b/plugins/FeedReader/gui/AddFeedDialog.h @@ -41,8 +41,8 @@ public: AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent); ~AddFeedDialog(); - void setParent(const std::string &parentId); - bool fillFeed(const std::string &feedId); + void setParent(uint32_t parentId); + bool fillFeed(uint32_t feedId); /* TokenResponse */ virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); @@ -70,8 +70,8 @@ private: private: RsFeedReader *mFeedReader; FeedReaderNotify *mNotify; - std::string mFeedId; - std::string mParentId; + uint32_t mFeedId; + uint32_t mParentId; std::string mFillForumId; RsFeedTransformationType mTransformationType; diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index b795eb33b..abc2f1aa5 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -65,8 +65,7 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *n mOpenFeedIds = NULL; mMessageWidget = NULL; - connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int))); - connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int))); + connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderDialog::feedChanged, Qt::QueuedConnection); connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); @@ -153,7 +152,7 @@ void FeedReaderDialog::processSettings(bool load) int arrayIndex = Settings->beginReadArray("Feeds"); for (int index = 0; index < arrayIndex; index++) { Settings->setArrayIndex(index); - addFeedToExpand(Settings->value("open").toString().toStdString()); + addFeedToExpand(Settings->value("open").toUInt()); } Settings->endArray(); } else { @@ -165,11 +164,11 @@ void FeedReaderDialog::processSettings(bool load) // open groups Settings->beginWriteArray("Feeds"); int arrayIndex = 0; - QList expandedFeedIds; + QList expandedFeedIds; getExpandedFeedIds(expandedFeedIds); - foreach (std::string feedId, expandedFeedIds) { + foreach (uint32_t feedId, expandedFeedIds) { Settings->setArrayIndex(arrayIndex++); - Settings->setValue("open", QString::fromStdString(feedId)); + Settings->setValue("open", feedId); } Settings->endArray(); } @@ -187,17 +186,17 @@ void FeedReaderDialog::settingsChanged() } } else { if (!mMessageWidget) { - mMessageWidget = createMessageWidget(""); + mMessageWidget = createMessageWidget(0); // remove close button of the the first tab ui->messageTabWidget->hideCloseButton(ui->messageTabWidget->indexOf(mMessageWidget)); } } } -void FeedReaderDialog::addFeedToExpand(const std::string &feedId) +void FeedReaderDialog::addFeedToExpand(uint32_t feedId) { if (mOpenFeedIds == NULL) { - mOpenFeedIds = new QList; + mOpenFeedIds = new QList; } if (mOpenFeedIds->contains(feedId)) { return; @@ -205,7 +204,7 @@ void FeedReaderDialog::addFeedToExpand(const std::string &feedId) mOpenFeedIds->push_back(feedId); } -void FeedReaderDialog::getExpandedFeedIds(QList &feedIds) +void FeedReaderDialog::getExpandedFeedIds(QList &feedIds) { QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *item; @@ -217,8 +216,8 @@ void FeedReaderDialog::getExpandedFeedIds(QList &feedIds) if (!item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool()) { continue; } - std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString(); - if (feedId.empty()) { + uint32_t feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt(); + if (feedId == 0) { continue; } feedIds.push_back(feedId); @@ -227,7 +226,7 @@ void FeedReaderDialog::getExpandedFeedIds(QList &feedIds) void FeedReaderDialog::showEvent(QShowEvent */*event*/) { - updateFeeds("", mRootItem); + updateFeeds(0, mRootItem); } bool FeedReaderDialog::eventFilter(QObject *obj, QEvent *event) @@ -248,26 +247,26 @@ bool FeedReaderDialog::eventFilter(QObject *obj, QEvent *event) return MainPage::eventFilter(obj, event); } -std::string FeedReaderDialog::currentFeedId() +uint32_t FeedReaderDialog::currentFeedId() { QTreeWidgetItem *item = ui->feedTreeWidget->currentItem(); if (!item) { - return ""; + return 0; } - return item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString(); + return item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt(); } -void FeedReaderDialog::setCurrentFeedId(const std::string &feedId) +void FeedReaderDialog::setCurrentFeedId(uint32_t feedId) { - if (feedId.empty()) { + if (feedId == 0) { return; } QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *item; while ((item = *it) != NULL) { - if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString() == feedId) { + if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) { ui->feedTreeWidget->setCurrentItem(item); break; } @@ -280,11 +279,11 @@ void FeedReaderDialog::feedTreeCustomPopupMenu(QPoint /*point*/) QMenu contextMnu(this); bool folder = false; - std::string feedId; + uint32_t feedId; QTreeWidgetItem *item = ui->feedTreeWidget->currentItem(); if (item) { folder = item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool(); - feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString(); + feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt(); } QMenu *menu = contextMnu.addMenu(QIcon(""), tr("New")); @@ -336,7 +335,7 @@ void FeedReaderDialog::feedTreeCustomPopupMenu(QPoint /*point*/) contextMnu.exec(QCursor::pos()); } -void FeedReaderDialog::updateFeeds(const std::string &parentId, QTreeWidgetItem *parentItem) +void FeedReaderDialog::updateFeeds(uint32_t parentId, QTreeWidgetItem *parentItem) { if (!parentItem) { return; @@ -353,7 +352,7 @@ void FeedReaderDialog::updateFeeds(const std::string &parentId, QTreeWidgetItem /* update existing and delete not existing feeds */ while (index < parentItem->childCount()) { item = parentItem->child(index); - std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString(); + uint32_t feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt(); /* search existing feed */ int found = -1; @@ -534,27 +533,27 @@ void FeedReaderDialog::updateFeedItem(QTreeWidgetItem *item, const FeedInfo &fee item->setData(COLUMN_FEED_DATA, ROLE_FEED_UNREAD, unreadCount); item->setData(COLUMN_FEED_DATA, ROLE_FEED_NEW, newCount); item->setData(COLUMN_FEED_DATA, ROLE_FEED_LOADING, feedInfo.workstate != FeedInfo::WAITING); - item->setData(COLUMN_FEED_DATA, ROLE_FEED_ID, QString::fromStdString(feedInfo.feedId)); + item->setData(COLUMN_FEED_DATA, ROLE_FEED_ID, feedInfo.feedId); item->setData(COLUMN_FEED_DATA, ROLE_FEED_FOLDER, feedInfo.flag.folder); item->setData(COLUMN_FEED_DATA, ROLE_FEED_DEACTIVATED, feedInfo.flag.deactivated); item->setData(COLUMN_FEED_DATA, ROLE_FEED_ERROR, (bool) (feedInfo.errorState != RS_FEED_ERRORSTATE_OK)); item->setToolTip(COLUMN_FEED_NAME, (feedInfo.errorState != RS_FEED_ERRORSTATE_OK) ? FeedReaderStringDefs::errorString(feedInfo) : ""); } -void FeedReaderDialog::feedChanged(const QString &feedId, int type) +void FeedReaderDialog::feedChanged(uint32_t feedId, int type) { if (!isVisible()) { /* complete update in showEvent */ return; } - if (feedId.isEmpty()) { + if (feedId == 0) { return; } FeedInfo feedInfo; if (type != NOTIFY_TYPE_DEL) { - if (!mFeedReader->getFeedInfo(feedId.toStdString(), feedInfo)) { + if (!mFeedReader->getFeedInfo(feedId, feedInfo)) { return; } @@ -567,7 +566,7 @@ void FeedReaderDialog::feedChanged(const QString &feedId, int type) QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *item; while ((item = *it) != NULL) { - if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString() == feedId) { + if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) { if (type == NOTIFY_TYPE_MOD) { updateFeedItem(item, feedInfo); } else { @@ -580,12 +579,10 @@ void FeedReaderDialog::feedChanged(const QString &feedId, int type) } if (type == NOTIFY_TYPE_ADD) { - QString id = QString::fromStdString(feedInfo.parentId); - QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *itemParent; while ((itemParent = *it) != NULL) { - if (itemParent->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString() == id) { + if (itemParent->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedInfo.parentId) { QTreeWidgetItem *item = new RSTreeWidgetItem(mFeedCompareRole); itemParent->addChild(item); updateFeedItem(item, feedInfo); @@ -597,7 +594,7 @@ void FeedReaderDialog::feedChanged(const QString &feedId, int type) calculateFeedItems(); } -FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(const std::string &id) +FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(uint32_t id) { int tabCount = ui->messageTabWidget->count(); for (int index = 0; index < tabCount; ++index) { @@ -613,7 +610,7 @@ FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(const std::string & return NULL; } -FeedReaderMessageWidget *FeedReaderDialog::createMessageWidget(const std::string &feedId) +FeedReaderMessageWidget *FeedReaderDialog::createMessageWidget(uint32_t feedId) { FeedReaderMessageWidget *messageWidget = new FeedReaderMessageWidget(feedId, mFeedReader, mNotify); int index = ui->messageTabWidget->addTab(messageWidget, messageWidget->feedName(true)); @@ -640,7 +637,7 @@ void FeedReaderDialog::feedTreeItemActivated(QTreeWidgetItem *item) ui->feedAddButton->setEnabled(false); - std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString(); + uint32_t feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt(); /* search exisiting tab */ FeedReaderMessageWidget *messageWidget = feedMessageWidget(feedId); if (!messageWidget) { @@ -663,7 +660,7 @@ void FeedReaderDialog::feedTreeMiddleButtonClicked(QTreeWidgetItem *item) return; } - openFeedInNewTab(item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString()); + openFeedInNewTab(item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt()); } void FeedReaderDialog::openInNewTab() @@ -671,9 +668,9 @@ void FeedReaderDialog::openInNewTab() openFeedInNewTab(currentFeedId()); } -void FeedReaderDialog::openFeedInNewTab(const std::string &feedId) +void FeedReaderDialog::openFeedInNewTab(uint32_t feedId) { - if (feedId.empty()) { + if (feedId == 0) { return; } @@ -723,7 +720,7 @@ void FeedReaderDialog::messageTabInfoChanged(QWidget *widget) return; } - if (messageWidget != mMessageWidget && messageWidget->feedId().empty()) { + if (messageWidget != mMessageWidget && messageWidget->feedId() == 0) { messageWidget->deleteLater(); return; } @@ -740,7 +737,7 @@ void FeedReaderDialog::newFolder() dialog.setWindowIcon(QIcon(":/images/FeedReader.png")); if (dialog.exec() == QDialog::Accepted && !dialog.textValue().isEmpty()) { - std::string feedId; + uint32_t feedId; RsFeedAddResult result = mFeedReader->addFolder(currentFeedId(), dialog.textValue().toUtf8().constData(), feedId); FeedReaderStringDefs::showError(this, result, tr("Create folder"), tr("Cannot create folder.")); } @@ -755,8 +752,8 @@ void FeedReaderDialog::newFeed() void FeedReaderDialog::removeFeed() { - std::string feedId = currentFeedId(); - if (feedId.empty()) { + uint32_t feedId = currentFeedId(); + if (feedId == 0) { return; } @@ -775,8 +772,8 @@ void FeedReaderDialog::removeFeed() void FeedReaderDialog::editFeed() { - std::string feedId = currentFeedId(); - if (feedId.empty()) { + uint32_t feedId = currentFeedId(); + if (feedId == 0) { return; } @@ -809,8 +806,8 @@ void FeedReaderDialog::editFeed() void FeedReaderDialog::activateFeed() { - std::string feedId = currentFeedId(); - if (feedId.empty()) { + uint32_t feedId = currentFeedId(); + if (feedId == 0) { return; } @@ -830,7 +827,7 @@ void FeedReaderDialog::activateFeed() void FeedReaderDialog::processFeed() { - std::string feedId = currentFeedId(); + uint32_t feedId = currentFeedId(); /* empty feed id process all feeds */ mFeedReader->processFeed(feedId); diff --git a/plugins/FeedReader/gui/FeedReaderDialog.h b/plugins/FeedReader/gui/FeedReaderDialog.h index a064df811..a221cfe64 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.h +++ b/plugins/FeedReader/gui/FeedReaderDialog.h @@ -67,26 +67,27 @@ private slots: void messageTabInfoChanged(QWidget *widget); /* FeedReaderNotify */ - void feedChanged(const QString &feedId, int type); + void feedChanged(uint32_t feedId, int type); private: - std::string currentFeedId(); - void setCurrentFeedId(const std::string &feedId); + uint32_t currentFeedId(); + void setCurrentFeedId(uint32_t feedId); void processSettings(bool load); - void addFeedToExpand(const std::string &feedId); - void getExpandedFeedIds(QList &feedIds); - void updateFeeds(const std::string &parentId, QTreeWidgetItem *parentItem); + void addFeedToExpand(uint32_t feedId); + void getExpandedFeedIds(QList &feedIds); + void updateFeeds(uint32_t parentId, QTreeWidgetItem *parentItem); void updateFeedItem(QTreeWidgetItem *item, const FeedInfo &feedInfo); - void openFeedInNewTab(const std::string &feedId); + void openFeedInNewTab(uint32_t feedId); void calculateFeedItems(); void calculateFeedItem(QTreeWidgetItem *item, uint32_t &unreadCount, uint32_t &newCount, bool &loading); - FeedReaderMessageWidget *feedMessageWidget(const std::string &feedId); - FeedReaderMessageWidget *createMessageWidget(const std::string &feedId); + FeedReaderMessageWidget *feedMessageWidget(uint32_t feedId); + FeedReaderMessageWidget *createMessageWidget(uint32_t feedId); +private: bool mProcessSettings; - QList *mOpenFeedIds; + QList *mOpenFeedIds; QTreeWidgetItem *mRootItem; RSTreeWidgetItemCompareRole *mFeedCompareRole; FeedReaderMessageWidget *mMessageWidget; diff --git a/plugins/FeedReader/gui/FeedReaderFeedItem.cpp b/plugins/FeedReader/gui/FeedReaderFeedItem.cpp index 8e1ef4db5..7d0cfc5d5 100644 --- a/plugins/FeedReader/gui/FeedReaderFeedItem.cpp +++ b/plugins/FeedReader/gui/FeedReaderFeedItem.cpp @@ -34,8 +34,8 @@ #include "gui/feeds/FeedHolder.h" /** Constructor */ -FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo) - : FeedItem(NULL), mFeedReader(feedReader), mNotify(notify), mParent(parent), ui(new Ui::FeedReaderFeedItem) +FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo) + : FeedItem(NULL, feedInfo.feedId), mFeedReader(feedReader), mNotify(notify), ui(new Ui::FeedReaderFeedItem) { /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); @@ -51,7 +51,6 @@ FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotif ui->expandFrame->hide(); - mFeedId = feedInfo.feedId; mMsgId = msgInfo.msgId; if (feedInfo.icon.empty()) { @@ -101,8 +100,8 @@ void FeedReaderFeedItem::toggle() void FeedReaderFeedItem::doExpand(bool open) { - if (mParent) { - mParent->lockLayout(this, true); + if (mFeedHolder) { + mFeedHolder->lockLayout(this, true); } if (open) { @@ -119,19 +118,8 @@ void FeedReaderFeedItem::doExpand(bool open) emit sizeChanged(this); - if (mParent) { - mParent->lockLayout(this, false); - } -} - -void FeedReaderFeedItem::removeItem() -{ - mParent->lockLayout(this, true); - hide(); - mParent->lockLayout(this, false); - - if (mParent) { - mParent->deleteFeedItem(this, 0); + if (mFeedHolder) { + mFeedHolder->lockLayout(this, false); } } @@ -150,9 +138,9 @@ void FeedReaderFeedItem::setMsgRead() connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection); } -void FeedReaderFeedItem::msgChanged(const QString &feedId, const QString &msgId, int /*type*/) +void FeedReaderFeedItem::msgChanged(uint32_t feedId, const QString &msgId, int /*type*/) { - if (feedId.toStdString() != mFeedId) { + if (feedId != mFeedId) { return; } diff --git a/plugins/FeedReader/gui/FeedReaderFeedItem.h b/plugins/FeedReader/gui/FeedReaderFeedItem.h index 29b8c2bba..005e46d5b 100644 --- a/plugins/FeedReader/gui/FeedReaderFeedItem.h +++ b/plugins/FeedReader/gui/FeedReaderFeedItem.h @@ -38,9 +38,11 @@ class FeedReaderFeedItem : public FeedItem Q_OBJECT public: - FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo); + FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo); ~FeedReaderFeedItem(); + virtual uint64_t uniqueIdentifier() const override { return hash_64bits("FeedReaderFeedItem " + mMsgId); } + protected: /* FeedItem */ virtual void doExpand(bool open); @@ -53,7 +55,7 @@ private slots: void copyLink(); void openLink(); - void msgChanged(const QString &feedId, const QString &msgId, int type); + void msgChanged(uint32_t feedId, const QString &msgId, int type); private: void setMsgRead(); diff --git a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp index 071efcb47..16a3099e6 100644 --- a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp @@ -65,9 +65,9 @@ void FeedReaderFeedNotify::setNotifyEnabled(bool enabled) } } -void FeedReaderFeedNotify::msgChanged(const QString &feedId, const QString &msgId, int type) +void FeedReaderFeedNotify::msgChanged(uint32_t feedId, const QString &msgId, int type) { - if (feedId.isEmpty() || msgId.isEmpty()) { + if (feedId == 0 || msgId.isEmpty()) { return; } @@ -101,8 +101,8 @@ FeedItem *FeedReaderFeedNotify::feedItem(FeedHolder *parent) FeedItemData feedItemData = mPendingNewsFeed.front(); mPendingNewsFeed.pop_front(); - if (mFeedReader->getFeedInfo(feedItemData.mFeedId.toStdString(), feedInfo) && - mFeedReader->getMsgInfo(feedItemData.mFeedId.toStdString(), feedItemData.mMsgId.toStdString(), msgInfo)) { + if (mFeedReader->getFeedInfo(feedItemData.mFeedId, feedInfo) && + mFeedReader->getMsgInfo(feedItemData.mFeedId, feedItemData.mMsgId.toStdString(), msgInfo)) { if (msgInfo.flag.isnew) { msgPending = true; break; @@ -115,7 +115,8 @@ FeedItem *FeedReaderFeedNotify::feedItem(FeedHolder *parent) return NULL; } - return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo); + //TODO: parent? + return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo); } FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent) @@ -136,5 +137,6 @@ FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent) msgInfo.description = tr("This is a test message.").toUtf8().constData(); msgInfo.pubDate = QDateTime::currentDateTime().toTime_t(); - return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo); + //TODO: parent? + return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo); } diff --git a/plugins/FeedReader/gui/FeedReaderFeedNotify.h b/plugins/FeedReader/gui/FeedReaderFeedNotify.h index 18342aa0c..cb296f596 100644 --- a/plugins/FeedReader/gui/FeedReaderFeedNotify.h +++ b/plugins/FeedReader/gui/FeedReaderFeedNotify.h @@ -36,10 +36,13 @@ protected: class FeedItemData { public: - FeedItemData() {} + FeedItemData() + { + mFeedId = 0; + } public: - QString mFeedId; + uint32_t mFeedId; QString mMsgId; }; @@ -54,7 +57,7 @@ public: virtual FeedItem *testFeedItem(FeedHolder *parent); private slots: - void msgChanged(const QString &feedId, const QString &msgId, int type); + void msgChanged(uint32_t feedId, const QString &msgId, int type); private: RsFeedReader *mFeedReader; diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp index f4f64df5b..1550bc636 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp @@ -52,18 +52,19 @@ #define ROLE_MSG_READ Qt::UserRole + 3 #define ROLE_MSG_LINK Qt::UserRole + 4 -FeedReaderMessageWidget::FeedReaderMessageWidget(const std::string &feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent) : +FeedReaderMessageWidget::FeedReaderMessageWidget(uint32_t feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent) : QWidget(parent), mFeedReader(feedReader), mNotify(notify), ui(new Ui::FeedReaderMessageWidget) { ui->setupUi(this); + mFeedId = 0; mProcessSettings = false; mUnreadCount = 0; mNewCount = 0; /* connect signals */ - connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int))); - connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int))); + connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderMessageWidget::feedChanged, Qt::QueuedConnection); + connect(mNotify, &FeedReaderNotify::msgChanged, this, &FeedReaderMessageWidget::msgChanged, Qt::QueuedConnection); connect(ui->msgTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(msgItemChanged())); connect(ui->msgTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(msgItemClicked(QTreeWidgetItem*,int))); @@ -217,30 +218,30 @@ bool FeedReaderMessageWidget::eventFilter(QObject *obj, QEvent *event) return QWidget::eventFilter(obj, event); } -void FeedReaderMessageWidget::setFeedId(const std::string &feedId) +void FeedReaderMessageWidget::setFeedId(uint32_t feedId) { if (mFeedId == feedId) { - if (!feedId.empty()) { + if (feedId) { return; } } mFeedId = feedId; - ui->feedProcessButton->setEnabled(!mFeedId.empty()); + ui->feedProcessButton->setEnabled(mFeedId); - if (!mFeedId.empty()) { + if (mFeedId) { if (mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) { mFeedReader->getMessageCount(mFeedId, NULL, &mNewCount, &mUnreadCount); } else { - mFeedId.clear(); + mFeedId = 0; mFeedInfo = FeedInfo(); } } else { mFeedInfo = FeedInfo(); } - if (mFeedId.empty()) { + if (mFeedId == 0) { ui->msgReadAllButton->setEnabled(false); ui->msgTreeWidget->setPlaceholderText(""); } else { @@ -279,7 +280,7 @@ QIcon FeedReaderMessageWidget::feedIcon() icon = icon.pixmap(QSize(16, 16), QIcon::Disabled); } - if (!mFeedId.empty()) { + if (mFeedId) { QImage overlayIcon; if (mFeedInfo.workstate != FeedInfo::WAITING) { @@ -329,7 +330,7 @@ void FeedReaderMessageWidget::msgTreeCustomPopupMenu(QPoint /*point*/) action->setEnabled(!selectedItems.empty()); action = contextMnu.addAction(QIcon(""), tr("Mark all as read"), this, SLOT(markAllAsReadMsg())); - action->setEnabled(!mFeedId.empty()); + action->setEnabled(mFeedId); contextMnu.addSeparator(); @@ -349,7 +350,7 @@ void FeedReaderMessageWidget::msgTreeCustomPopupMenu(QPoint /*point*/) void FeedReaderMessageWidget::updateMsgs() { - if (mFeedId.empty()) { + if (mFeedId == 0) { ui->msgTreeWidget->clear(); return; } @@ -434,7 +435,7 @@ void FeedReaderMessageWidget::updateMsgItem(QTreeWidgetItem *item, FeedMsgInfo & qdatetime.setTime_t(info.pubDate); /* add string to all data */ - QString sort = QString("%1_%2_%2").arg(title, qdatetime.toString("yyyyMMdd_hhmmss"), QString::fromStdString(info.feedId)); + QString sort = QString("%1_%2_%3").arg(title, qdatetime.toString("yyyyMMdd_hhmmss")).arg(info.feedId); item->setText(COLUMN_MSG_TITLE, title); item->setData(COLUMN_MSG_TITLE, ROLE_MSG_SORT, sort); @@ -459,24 +460,24 @@ void FeedReaderMessageWidget::updateMsgItem(QTreeWidgetItem *item, FeedMsgInfo & calculateMsgIconsAndFonts(item); } -void FeedReaderMessageWidget::feedChanged(const QString &feedId, int type) +void FeedReaderMessageWidget::feedChanged(uint32_t feedId, int type) { - if (feedId.isEmpty()) { + if (feedId == 0) { return; } - if (feedId.toStdString() != mFeedId) { + if (feedId != mFeedId) { return; } if (type == NOTIFY_TYPE_DEL) { - setFeedId(""); + setFeedId(0); return; } if (type == NOTIFY_TYPE_MOD) { if (!mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) { - setFeedId(""); + setFeedId(0); return; } @@ -484,13 +485,13 @@ void FeedReaderMessageWidget::feedChanged(const QString &feedId, int type) } } -void FeedReaderMessageWidget::msgChanged(const QString &feedId, const QString &msgId, int type) +void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId, int type) { - if (feedId.isEmpty() || msgId.isEmpty()) { + if (feedId == 0 || msgId.isEmpty()) { return; } - if (feedId.toStdString() != mFeedId) { + if (feedId != mFeedId) { return; } @@ -510,7 +511,7 @@ void FeedReaderMessageWidget::msgChanged(const QString &feedId, const QString &m FeedMsgInfo msgInfo; if (type != NOTIFY_TYPE_DEL) { - if (!mFeedReader->getMsgInfo(feedId.toStdString(), msgId.toStdString(), msgInfo)) { + if (!mFeedReader->getMsgInfo(feedId, msgId.toStdString(), msgInfo)) { return; } } @@ -578,7 +579,7 @@ void FeedReaderMessageWidget::updateCurrentMessage() std::string msgId = currentMsgId(); - if (mFeedId.empty() || msgId.empty()) { + if (mFeedId == 0 || msgId.empty()) { ui->msgTitle->clear(); // ui->msgLink->clear(); ui->msgText->clear(); @@ -646,7 +647,7 @@ void FeedReaderMessageWidget::setMsgAsReadUnread(QList &rows, { QList::iterator rowIt; - if (mFeedId.empty()) { + if (mFeedId == 0) { return; } @@ -773,7 +774,7 @@ void FeedReaderMessageWidget::copySelectedLinksMsg() void FeedReaderMessageWidget::removeMsg() { - if (mFeedId.empty()) { + if (mFeedId == 0) { return; } @@ -789,7 +790,7 @@ void FeedReaderMessageWidget::removeMsg() void FeedReaderMessageWidget::retransformMsg() { - if (mFeedId.empty()) { + if (mFeedId == 0) { return; } @@ -803,7 +804,7 @@ void FeedReaderMessageWidget::retransformMsg() void FeedReaderMessageWidget::processFeed() { - if (mFeedId.empty()) { + if (mFeedId == 0) { return; } diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.h b/plugins/FeedReader/gui/FeedReaderMessageWidget.h index da86daf47..452c407ad 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.h +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.h @@ -41,11 +41,11 @@ class FeedReaderMessageWidget : public QWidget Q_OBJECT public: - explicit FeedReaderMessageWidget(const std::string &feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); + explicit FeedReaderMessageWidget(uint32_t feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); ~FeedReaderMessageWidget(); - std::string feedId() { return mFeedId; } - void setFeedId(const std::string &feedId); + uint32_t feedId() { return mFeedId; } + void setFeedId(uint32_t feedId); QString feedName(bool withUnreadCount); QIcon feedIcon(); @@ -75,8 +75,8 @@ private slots: void retransformMsg(); /* FeedReaderNotify */ - void feedChanged(const QString &feedId, int type); - void msgChanged(const QString &feedId, const QString &msgId, int type); + void feedChanged(uint32_t feedId, int type); + void msgChanged(uint32_t feedId, const QString &msgId, int type); private: std::string currentMsgId(); @@ -91,7 +91,7 @@ private: bool mProcessSettings; RSTreeWidgetItemCompareRole *mMsgCompareRole; - std::string mFeedId; + uint32_t mFeedId; unsigned int mUnreadCount; unsigned int mNewCount; QTimer *mTimer; diff --git a/plugins/FeedReader/gui/FeedReaderNotify.cpp b/plugins/FeedReader/gui/FeedReaderNotify.cpp index a4d00c38f..f2aa7ad1d 100644 --- a/plugins/FeedReader/gui/FeedReaderNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderNotify.cpp @@ -24,12 +24,12 @@ FeedReaderNotify::FeedReaderNotify() : QObject() { } -void FeedReaderNotify::notifyFeedChanged(const std::string &feedId, int type) +void FeedReaderNotify::notifyFeedChanged(uint32_t feedId, int type) { - emit feedChanged(QString::fromStdString(feedId), type); + emit feedChanged(feedId, type); } -void FeedReaderNotify::notifyMsgChanged(const std::string &feedId, const std::string &msgId, int type) +void FeedReaderNotify::notifyMsgChanged(uint32_t feedId, const std::string &msgId, int type) { - emit msgChanged(QString::fromStdString(feedId), QString::fromStdString(msgId), type); + emit msgChanged(feedId, QString::fromStdString(msgId), type); } diff --git a/plugins/FeedReader/gui/FeedReaderNotify.h b/plugins/FeedReader/gui/FeedReaderNotify.h index 08cdc3cc2..5a8ad712a 100644 --- a/plugins/FeedReader/gui/FeedReaderNotify.h +++ b/plugins/FeedReader/gui/FeedReaderNotify.h @@ -32,12 +32,12 @@ public: FeedReaderNotify(); /* RsFeedReaderNotify */ - virtual void notifyFeedChanged(const std::string &feedId, int type); - virtual void notifyMsgChanged(const std::string &feedId, const std::string &msgId, int type); + virtual void notifyFeedChanged(uint32_t feedId, int type); + virtual void notifyMsgChanged(uint32_t feedId, const std::string &msgId, int type); signals: - void feedChanged(const QString &feedId, int type); - void msgChanged(const QString &feedId, const QString &msgId, int type); + void feedChanged(uint32_t feedId, int type); + void msgChanged(uint32_t feedId, const QString &msgId, int type); }; #endif diff --git a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp index 207eb312c..68c23a7c6 100644 --- a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp @@ -30,8 +30,8 @@ FeedReaderUserNotify::FeedReaderUserNotify(FeedReaderDialog *feedReaderDialog, RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent) : UserNotify(parent), mFeedReaderDialog(feedReaderDialog), mFeedReader(feedReader), mNotify(notify) { - connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int)), Qt::QueuedConnection); - connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(updateIcon()), Qt::QueuedConnection); + connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderUserNotify::feedChanged, Qt::QueuedConnection); + connect(mNotify, &FeedReaderNotify::msgChanged, this, &FeedReaderUserNotify::updateIcon, Qt::QueuedConnection); } bool FeedReaderUserNotify::hasSetting(QString *name, QString *group) @@ -55,7 +55,7 @@ QIcon FeedReaderUserNotify::getMainIcon(bool hasNew) unsigned int FeedReaderUserNotify::getNewCount() { uint32_t newMessageCount = 0; - mFeedReader->getMessageCount("", NULL, &newMessageCount, NULL); + mFeedReader->getMessageCount(0, NULL, &newMessageCount, NULL); return newMessageCount; } @@ -65,7 +65,7 @@ void FeedReaderUserNotify::iconClicked() MainWindow::showWindow(mFeedReaderDialog); } -void FeedReaderUserNotify::feedChanged(const QString &/*feedId*/, int type) +void FeedReaderUserNotify::feedChanged(uint32_t /*feedId*/, int type) { if (type == NOTIFY_TYPE_DEL) { updateIcon(); diff --git a/plugins/FeedReader/gui/FeedReaderUserNotify.h b/plugins/FeedReader/gui/FeedReaderUserNotify.h index aedffb282..9d196d1d7 100644 --- a/plugins/FeedReader/gui/FeedReaderUserNotify.h +++ b/plugins/FeedReader/gui/FeedReaderUserNotify.h @@ -37,7 +37,7 @@ public: virtual bool hasSetting(QString *name, QString *group); private slots: - void feedChanged(const QString &feedId, int type); + void feedChanged(uint32_t feedId, int type); private: virtual QIcon getIcon(); diff --git a/plugins/FeedReader/gui/PreviewFeedDialog.cpp b/plugins/FeedReader/gui/PreviewFeedDialog.cpp index e1596f747..ea582c04f 100644 --- a/plugins/FeedReader/gui/PreviewFeedDialog.cpp +++ b/plugins/FeedReader/gui/PreviewFeedDialog.cpp @@ -143,6 +143,8 @@ PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify { ui->setupUi(this); + mFeedId = 0; + ui->feedNameLabel->clear(); /* connect signals */ @@ -155,8 +157,8 @@ PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify connect(ui->xpathRemoveListWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(xpathCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); connect(ui->transformationTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(transformationTypeChanged())); - connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int))); - connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int))); + connect(mNotify, &FeedReaderNotify::feedChanged, this, &PreviewFeedDialog::feedChanged, Qt::QueuedConnection); + connect(mNotify, &FeedReaderNotify::msgChanged, this, &PreviewFeedDialog::msgChanged, Qt::QueuedConnection); ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_NONE), RS_FEED_TRANSFORMATION_TYPE_NONE); ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_XPATH), RS_FEED_TRANSFORMATION_TYPE_XPATH); @@ -217,7 +219,7 @@ PreviewFeedDialog::~PreviewFeedDialog() disconnect(mNotify); disconnect(mNotify); - if (!mFeedId.empty()) { + if (mFeedId) { mFeedReader->removeFeed(mFeedId); } @@ -282,19 +284,19 @@ bool PreviewFeedDialog::eventFilter(QObject *obj, QEvent *event) return QDialog::eventFilter(obj, event); } -void PreviewFeedDialog::feedChanged(const QString &feedId, int type) +void PreviewFeedDialog::feedChanged(uint32_t feedId, int type) { - if (feedId.isEmpty()) { + if (feedId == 0) { return; } - if (feedId.toStdString() != mFeedId) { + if (feedId != mFeedId) { return; } if (type == NOTIFY_TYPE_DEL) { /* feed deleted */ - mFeedId.clear(); + mFeedId = 0; return; } @@ -307,13 +309,13 @@ void PreviewFeedDialog::feedChanged(const QString &feedId, int type) } } -void PreviewFeedDialog::msgChanged(const QString &feedId, const QString &msgId, int type) +void PreviewFeedDialog::msgChanged(uint32_t feedId, const QString &msgId, int type) { - if (feedId.isEmpty() || msgId.isEmpty()) { + if (feedId == 0 || msgId.isEmpty()) { return; } - if (feedId.toStdString() != mFeedId) { + if (feedId != mFeedId) { return; } diff --git a/plugins/FeedReader/gui/PreviewFeedDialog.h b/plugins/FeedReader/gui/PreviewFeedDialog.h index a2a580c85..4b00032c3 100644 --- a/plugins/FeedReader/gui/PreviewFeedDialog.h +++ b/plugins/FeedReader/gui/PreviewFeedDialog.h @@ -77,8 +77,8 @@ private slots: void transformationTypeChanged(); /* FeedReaderNotify */ - void feedChanged(const QString &feedId, int type); - void msgChanged(const QString &feedId, const QString &msgId, int type); + void feedChanged(uint32_t feedId, int type); + void msgChanged(uint32_t feedId, const QString &msgId, int type); private: void processSettings(bool load); @@ -93,7 +93,7 @@ private: RsFeedReader *mFeedReader; FeedReaderNotify *mNotify; - std::string mFeedId; + uint32_t mFeedId; std::string mMsgId; std::list mMsgIds; std::string mDescription; diff --git a/plugins/FeedReader/interface/rsFeedReader.h b/plugins/FeedReader/interface/rsFeedReader.h index 85879e239..bf524ad0c 100644 --- a/plugins/FeedReader/interface/rsFeedReader.h +++ b/plugins/FeedReader/interface/rsFeedReader.h @@ -108,8 +108,8 @@ public: transformationType = RS_FEED_TRANSFORMATION_TYPE_NONE; } - std::string feedId; - std::string parentId; + uint32_t feedId; + uint32_t parentId; std::string url; std::string name; std::string description; @@ -159,7 +159,7 @@ public: } std::string msgId; - std::string feedId; + uint32_t feedId; std::string title; std::string link; std::string author; @@ -179,8 +179,8 @@ class RsFeedReaderNotify public: RsFeedReaderNotify() {} - virtual void notifyFeedChanged(const std::string &/*feedId*/, int /*type*/) {} - virtual void notifyMsgChanged(const std::string &/*feedId*/, const std::string &/*msgId*/, int /*type*/) {} + virtual void notifyFeedChanged(uint32_t /*feedId*/, int /*type*/) {} + virtual void notifyMsgChanged(uint32_t /*feedId*/, const std::string &/*msgId*/, int /*type*/) {} }; class RsFeedReader @@ -201,24 +201,24 @@ public: virtual bool getSaveInBackground() = 0; virtual void setSaveInBackground(bool saveInBackground) = 0; - virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId) = 0; - virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name) = 0; - virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId) = 0; - virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo) = 0; - virtual bool removeFeed(const std::string &feedId) = 0; - virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) = 0; - virtual void getFeedList(const std::string &parentId, std::list &feedInfos) = 0; - virtual bool getFeedInfo(const std::string &feedId, FeedInfo &feedInfo) = 0; - virtual bool getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo) = 0; - virtual bool removeMsg(const std::string &feedId, const std::string &msgId) = 0; - virtual bool removeMsgs(const std::string &feedId, const std::list &msgIds) = 0; - virtual bool getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount) = 0; - virtual bool getFeedMsgList(const std::string &feedId, std::list &msgInfos) = 0; - virtual bool getFeedMsgIdList(const std::string &feedId, std::list &msgIds) = 0; - virtual bool processFeed(const std::string &feedId) = 0; - virtual bool setMessageRead(const std::string &feedId, const std::string &msgId, bool read) = 0; - virtual bool retransformMsg(const std::string &feedId, const std::string &msgId) = 0; - virtual bool clearMessageCache(const std::string &feedId) = 0; + virtual RsFeedAddResult addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId) = 0; + virtual RsFeedAddResult setFolder(uint32_t feedId, const std::string &name) = 0; + virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, uint32_t &feedId) = 0; + virtual RsFeedAddResult setFeed(uint32_t feedId, const FeedInfo &feedInfo) = 0; + virtual bool removeFeed(uint32_t feedId) = 0; + virtual bool addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId) = 0; + virtual void getFeedList(uint32_t parentId, std::list &feedInfos) = 0; + virtual bool getFeedInfo(uint32_t feedId, FeedInfo &feedInfo) = 0; + virtual bool getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo) = 0; + virtual bool removeMsg(uint32_t feedId, const std::string &msgId) = 0; + virtual bool removeMsgs(uint32_t feedId, const std::list &msgIds) = 0; + virtual bool getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount) = 0; + virtual bool getFeedMsgList(uint32_t feedId, std::list &msgInfos) = 0; + virtual bool getFeedMsgIdList(uint32_t feedId, std::list &msgIds) = 0; + virtual bool processFeed(uint32_t feedId) = 0; + virtual bool setMessageRead(uint32_t feedId, const std::string &msgId, bool read) = 0; + virtual bool retransformMsg(uint32_t feedId, const std::string &msgId) = 0; + virtual bool clearMessageCache(uint32_t feedId) = 0; virtual RsFeedReaderErrorState processXPath(const std::list &xpathsToUse, const std::list &xpathsToRemove, std::string &description, std::string &errorString) = 0; virtual RsFeedReaderErrorState processXslt(const std::string &xslt, std::string &description, std::string &errorString) = 0; diff --git a/plugins/FeedReader/services/p3FeedReader.cc b/plugins/FeedReader/services/p3FeedReader.cc index 3c530264f..d70591c36 100644 --- a/plugins/FeedReader/services/p3FeedReader.cc +++ b/plugins/FeedReader/services/p3FeedReader.cc @@ -63,12 +63,12 @@ p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler, RsGxsForums *forums) mPreviewProcessThread = NULL; /* start download thread */ - p3FeedReaderThread *frt = new p3FeedReaderThread(this, p3FeedReaderThread::DOWNLOAD, ""); + p3FeedReaderThread *frt = new p3FeedReaderThread(this, p3FeedReaderThread::DOWNLOAD, 0); mThreads.push_back(frt); frt->start("fr download"); /* start process thread */ - frt = new p3FeedReaderThread(this, p3FeedReaderThread::PROCESS, ""); + frt = new p3FeedReaderThread(this, p3FeedReaderThread::PROCESS, 0); mThreads.push_back(frt); frt->start("fr process"); } @@ -321,7 +321,7 @@ void p3FeedReader::stop() /* stop threads */ std::list::iterator it; for (it = mThreads.begin(); it != mThreads.end(); ++it) { - (*it)->join(); + (*it)->fullstop(); delete(*it); } mThreads.clear(); @@ -331,27 +331,27 @@ void p3FeedReader::stop() void p3FeedReader::stopPreviewThreads_locked() { if (mPreviewDownloadThread) { - mPreviewDownloadThread->join(); + mPreviewDownloadThread->fullstop(); delete mPreviewDownloadThread; mPreviewDownloadThread = NULL; } if (mPreviewProcessThread) { - mPreviewProcessThread->join(); + mPreviewProcessThread->fullstop(); delete mPreviewProcessThread; mPreviewProcessThread = NULL; } } -RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::string &name, std::string &feedId) +RsFeedAddResult p3FeedReader::addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId) { - feedId.clear(); + feedId = 0; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - if (!parentId.empty()) { + if (parentId) { /* check parent id */ - std::map::iterator parentIt = mFeeds.find(parentId); + std::map::iterator parentIt = mFeeds.find(parentId); if (parentIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::addFolder - parent id " << parentId << " not found" << std::endl; @@ -368,7 +368,7 @@ RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::s } RsFeedReaderFeed *fi = new RsFeedReaderFeed; - rs_sprintf(fi->feedId, "%lu", mNextFeedId++); + fi->feedId = mNextFeedId++; fi->parentId = parentId; fi->name = name; fi->flag = RS_FEED_FLAG_FOLDER; @@ -386,7 +386,7 @@ RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::s return RS_FEED_ADD_RESULT_SUCCESS; } -RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::string &name) +RsFeedAddResult p3FeedReader::setFolder(uint32_t feedId, const std::string &name) { { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ @@ -395,7 +395,7 @@ RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::st std::cerr << "p3FeedReader::setFolder - feed id " << feedId << ", name " << name << std::endl; #endif - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::setFolder - feed id " << feedId << " not found" << std::endl; @@ -426,9 +426,9 @@ RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::st return RS_FEED_ADD_RESULT_SUCCESS; } -RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &feedId) +RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, uint32_t &feedId) { - feedId.clear(); + feedId = 0; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ @@ -437,9 +437,9 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee std::cerr << "p3FeedReader::addFeed - add feed " << feedInfo.name << ", url " << feedInfo.url << std::endl; #endif - if (!feedInfo.parentId.empty()) { + if (feedInfo.parentId) { /* check parent id */ - std::map::iterator parentIt = mFeeds.find(feedInfo.parentId); + std::map::iterator parentIt = mFeeds.find(feedInfo.parentId); if (parentIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::addFeed - parent id " << feedInfo.parentId << " not found" << std::endl; @@ -457,7 +457,7 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee RsFeedReaderFeed *fi = new RsFeedReaderFeed; infoToFeed(feedInfo, fi); - rs_sprintf(fi->feedId, "%lu", mNextFeedId++); + fi->feedId = mNextFeedId++; mFeeds[fi->feedId] = fi; @@ -473,7 +473,7 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee return RS_FEED_ADD_RESULT_SUCCESS; } -RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo &feedInfo) +RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo) { std::string forumId; std::string forumName; @@ -486,7 +486,7 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo std::cerr << "p3FeedReader::setFeed - set feed " << feedInfo.name << ", url " << feedInfo.url << std::endl; #endif - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::setFeed - feed id " << feedId << " not found" << std::endl; @@ -501,9 +501,9 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo return RS_FEED_ADD_RESULT_FEED_IS_FOLDER; } - if (!feedInfo.parentId.empty()) { + if (feedInfo.parentId) { /* check parent id */ - std::map::iterator parentIt = mFeeds.find(feedInfo.parentId); + std::map::iterator parentIt = mFeeds.find(feedInfo.parentId); if (parentIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::setFeed - parent id " << feedInfo.parentId << " not found" << std::endl; @@ -567,16 +567,16 @@ void p3FeedReader::deleteAllMsgs_locked(RsFeedReaderFeed *fi) fi->msgs.clear(); } -bool p3FeedReader::removeFeed(const std::string &feedId) +bool p3FeedReader::removeFeed(uint32_t feedId) { - std::list removedFeedIds; + std::list removedFeedIds; bool changed = false; bool preview = false; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::removeFeed - feed " << feedId << " not found" << std::endl; @@ -592,20 +592,20 @@ bool p3FeedReader::removeFeed(const std::string &feedId) preview = fi->preview; if (fi->flag & RS_FEED_FLAG_FOLDER) { - std::list feedIds; + std::list feedIds; feedIds.push_back(fi->feedId); while (!feedIds.empty()) { - std::string parentId = feedIds.front(); + uint32_t parentId = feedIds.front(); feedIds.pop_front(); - std::map::iterator feedIt1; + std::map::iterator feedIt1; for (feedIt1 = mFeeds.begin(); feedIt1 != mFeeds.end(); ) { RsFeedReaderFeed *fi1 = feedIt1->second; if (fi1->parentId == parentId) { removedFeedIds.push_back(fi1->feedId); - std::map::iterator tempIt = feedIt1; + std::map::iterator tempIt = feedIt1; ++feedIt1; mFeeds.erase(tempIt); @@ -642,7 +642,7 @@ bool p3FeedReader::removeFeed(const std::string &feedId) if (mNotify) { /* only notify remove of feed */ - std::list::iterator it; + std::list::iterator it; for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) { mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_DEL); } @@ -651,7 +651,7 @@ bool p3FeedReader::removeFeed(const std::string &feedId) return true; } -bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) +bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId) { { RsStackMutex stack(mPreviewMutex); /******* LOCK STACK MUTEX *********/ @@ -659,7 +659,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) stopPreviewThreads_locked(); } - feedId.clear(); + feedId = 0; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ @@ -670,7 +670,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) RsFeedReaderFeed *fi = new RsFeedReaderFeed; infoToFeed(feedInfo, fi); - rs_sprintf(fi->feedId, "preview%d", mNextPreviewFeedId--); + fi->feedId = mNextPreviewFeedId--; fi->preview = true; /* process feed */ @@ -678,7 +678,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) fi->content.clear(); /* clear not needed members */ - fi->parentId.clear(); + fi->parentId = 0; fi->updateInterval = 0; fi->lastUpdate = 0; fi->forumId.clear(); @@ -708,11 +708,11 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) return true; } -void p3FeedReader::getFeedList(const std::string &parentId, std::list &feedInfos) +void p3FeedReader::getFeedList(uint32_t parentId, std::list &feedInfos) { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt; + std::map::iterator feedIt; for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) { RsFeedReaderFeed *fi = feedIt->second; @@ -728,11 +728,11 @@ void p3FeedReader::getFeedList(const std::string &parentId, std::list } } -bool p3FeedReader::getFeedInfo(const std::string &feedId, FeedInfo &feedInfo) +bool p3FeedReader::getFeedInfo(uint32_t feedId, FeedInfo &feedInfo) { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::getFeedInfo - feed " << feedId << " not found" << std::endl; @@ -745,11 +745,11 @@ bool p3FeedReader::getFeedInfo(const std::string &feedId, FeedInfo &feedInfo) return true; } -bool p3FeedReader::getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo) +bool p3FeedReader::getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo) { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::getMsgInfo - feed " << feedId << " not found" << std::endl; @@ -773,14 +773,14 @@ bool p3FeedReader::getMsgInfo(const std::string &feedId, const std::string &msgI return true; } -bool p3FeedReader::removeMsg(const std::string &feedId, const std::string &msgId) +bool p3FeedReader::removeMsg(uint32_t feedId, const std::string &msgId) { bool changed = false; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::removeMsg - feed " << feedId << " not found" << std::endl; @@ -819,7 +819,7 @@ bool p3FeedReader::removeMsg(const std::string &feedId, const std::string &msgId return true; } -bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list &msgIds) +bool p3FeedReader::removeMsgs(uint32_t feedId, const std::list &msgIds) { std::list removedMsgs; bool changed = false; @@ -827,7 +827,7 @@ bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::removeMsgs - feed " << feedId << " not found" << std::endl; @@ -875,7 +875,7 @@ bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list::iterator feedIt; + if (feedId == 0) { + std::map::iterator feedIt; for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) { RsFeedReaderFeed *fi = feedIt->second; @@ -906,7 +906,7 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount } } } else { - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::getMessageCount - feed " << feedId << " not found" << std::endl; @@ -933,11 +933,11 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount return true; } -bool p3FeedReader::getFeedMsgList(const std::string &feedId, std::list &msgInfos) +bool p3FeedReader::getFeedMsgList(uint32_t feedId, std::list &msgInfos) { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::getFeedMsgList - feed " << feedId << " not found" << std::endl; @@ -963,11 +963,11 @@ bool p3FeedReader::getFeedMsgList(const std::string &feedId, std::list &msgIds) +bool p3FeedReader::getFeedMsgIdList(uint32_t feedId, std::list &msgIds) { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::getFeedMsgList - feed " << feedId << " not found" << std::endl; @@ -1016,16 +1016,16 @@ static bool canProcessFeed(RsFeedReaderFeed *fi) return true; } -bool p3FeedReader::processFeed(const std::string &feedId) +bool p3FeedReader::processFeed(uint32_t feedId) { - std::list feedToDownload; + std::list feedToDownload; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt; + std::map::iterator feedIt; - if (feedId.empty()) { + if (feedId == 0) { /* process all feeds */ for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) { RsFeedReaderFeed *fi = feedIt->second; @@ -1054,13 +1054,13 @@ bool p3FeedReader::processFeed(const std::string &feedId) RsFeedReaderFeed *fi = feedIt->second; if (fi->flag & RS_FEED_FLAG_FOLDER) { - std::list feedIds; + std::list feedIds; feedIds.push_back(fi->feedId); while (!feedIds.empty()) { - std::string parentId = feedIds.front(); + uint32_t parentId = feedIds.front(); feedIds.pop_front(); - std::map::iterator feedIt1; + std::map::iterator feedIt1; for (feedIt1 = mFeeds.begin(); feedIt1 != mFeeds.end(); ++feedIt1) { RsFeedReaderFeed *fi1 = feedIt1->second; @@ -1095,8 +1095,8 @@ bool p3FeedReader::processFeed(const std::string &feedId) } } - std::list notifyIds; - std::list::iterator it; + std::list notifyIds; + std::list::iterator it; if (!feedToDownload.empty()) { RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/ @@ -1118,14 +1118,14 @@ bool p3FeedReader::processFeed(const std::string &feedId) return true; } -bool p3FeedReader::setMessageRead(const std::string &feedId, const std::string &msgId, bool read) +bool p3FeedReader::setMessageRead(uint32_t feedId, const std::string &msgId, bool read) { bool changed = false; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::setMessageRead - feed " << feedId << " not found" << std::endl; @@ -1168,7 +1168,7 @@ bool p3FeedReader::setMessageRead(const std::string &feedId, const std::string & return true; } -bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &msgId) +bool p3FeedReader::retransformMsg(uint32_t feedId, const std::string &msgId) { bool msgChanged = false; bool feedChanged = false; @@ -1176,7 +1176,7 @@ bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string & { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::setMessageRead - feed " << feedId << " not found" << std::endl; @@ -1226,7 +1226,7 @@ bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string & return true; } -bool p3FeedReader::clearMessageCache(const std::string &feedId) +bool p3FeedReader::clearMessageCache(uint32_t feedId) { { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ @@ -1235,7 +1235,7 @@ bool p3FeedReader::clearMessageCache(const std::string &feedId) std::cerr << "p3FeedReader::clearMessageCache - feed id " << feedId << std::endl; #endif - std::map::iterator feedIt = mFeeds.find(feedId); + std::map::iterator feedIt = mFeeds.find(feedId); if (feedIt == mFeeds.end()) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::clearMessageCache - feed id " << feedId << " not found" << std::endl; @@ -1292,8 +1292,8 @@ int p3FeedReader::tick() /* check feeds for update interval */ time_t currentTime = time(NULL); - std::list feedToDownload; - std::map::iterator feedIt; + std::list feedToDownload; + std::map::iterator feedIt; { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ @@ -1329,8 +1329,8 @@ int p3FeedReader::tick() } } - std::list notifyIds; - std::list::iterator it; + std::list notifyIds; + std::list::iterator it; if (!feedToDownload.empty()) { RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/ @@ -1359,8 +1359,8 @@ void p3FeedReader::cleanFeeds() if (mLastClean == 0 || mLastClean + FEEDREADER_CLEAN_INTERVAL <= currentTime) { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ - std::list > removedMsgIds; - std::map::iterator feedIt; + std::list > removedMsgIds; + std::map::iterator feedIt; for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) { RsFeedReaderFeed *fi = feedIt->second; @@ -1379,7 +1379,7 @@ void p3FeedReader::cleanFeeds() if (mi->flag & RS_FEEDMSG_FLAG_DELETED) { if (mi->pubDate < currentTime - (long) storageTime) { - removedMsgIds.push_back(std::pair (fi->feedId, mi->msgId)); + removedMsgIds.push_back(std::pair (fi->feedId, mi->msgId)); delete(mi); std::map::iterator deleteIt = msgIt++; fi->msgs.erase(deleteIt); @@ -1400,7 +1400,7 @@ void p3FeedReader::cleanFeeds() IndicateConfigChanged(); if (mNotify) { - std::list >::iterator it; + std::list >::iterator it; for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) { mNotify->notifyMsgChanged(it->first, it->second, NOTIFY_TYPE_DEL); } @@ -1467,7 +1467,7 @@ bool p3FeedReader::saveList(bool &cleanup, std::list &saveData) cleanSaveData.push_back(rskv); } - std::map::iterator it1; + std::map::iterator it1; for (it1 = mFeeds.begin(); it1 != mFeeds.end(); ++it1) { RsFeedReaderFeed *fi = it1->second; if (fi->preview) { @@ -1533,21 +1533,15 @@ bool p3FeedReader::loadList(std::list& load) for (it = load.begin(); it != load.end(); ++it) { /* switch on type */ if (NULL != (fi = dynamic_cast(*it))) { - uint32_t feedId = 0; - if (sscanf(fi->feedId.c_str(), "%u", &feedId) == 1) { - RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/ - if (mFeeds.find(fi->feedId) != mFeeds.end()) { - /* feed with the same id exists */ - delete mFeeds[fi->feedId]; - } - mFeeds[fi->feedId] = fi; + RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/ + if (mFeeds.find(fi->feedId) != mFeeds.end()) { + /* feed with the same id exists */ + delete mFeeds[fi->feedId]; + } + mFeeds[fi->feedId] = fi; - if (feedId + 1 > mNextFeedId) { - mNextFeedId = feedId + 1; - } - } else { - /* invalid feed id */ - delete(*it); + if (fi->feedId + 1 > mNextFeedId) { + mNextFeedId = fi->feedId + 1; } } else if (NULL != (mi = dynamic_cast(*it))) { if (msgs.find(mi->msgId) != msgs.end()) { @@ -1595,14 +1589,14 @@ bool p3FeedReader::loadList(std::list& load) RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/ /* check feeds */ - std::map::iterator feedIt; + std::map::iterator feedIt; for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) { RsFeedReaderFeed *feed = feedIt->second; - if (!feed->parentId.empty()) { + if (feed->parentId) { /* check parent */ if (mFeeds.find(feed->parentId) == mFeeds.end()) { /* parent not found, clear it */ - feed->parentId.clear(); + feed->parentId = 0; } } } @@ -1635,11 +1629,11 @@ bool p3FeedReader::loadList(std::list& load) /****************************** internal ***********************************/ /***************************************************************************/ -bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId) +bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeedId) { - std::string feedId = neededFeedId; + uint32_t feedId = neededFeedId; - if (feedId.empty()) { + if (feedId == 0) { RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/ if (mDownloadFeeds.empty()) { @@ -1656,7 +1650,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string & RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -1689,7 +1683,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string & return true; } -void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon) +void p3FeedReader::onDownloadSuccess(uint32_t feedId, const std::string &content, std::string &icon) { bool preview; @@ -1697,7 +1691,7 @@ void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::strin RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -1738,13 +1732,13 @@ void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::strin } } -void p3FeedReader::onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString) +void p3FeedReader::onDownloadError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString) { { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -1775,11 +1769,11 @@ void p3FeedReader::onDownloadError(const std::string &feedId, RsFeedReaderErrorS } } -bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId) +bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId) { - std::string feedId = neededFeedId; + uint32_t feedId = neededFeedId; - if (feedId.empty()) { + if (feedId == 0) { RsStackMutex stack(mProcessMutex); /******* LOCK STACK MUTEX *********/ if (mProcessFeeds.empty()) { @@ -1796,7 +1790,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &n RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -1832,7 +1826,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &n return true; } -void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::list &msgs) +void p3FeedReader::onProcessSuccess_filterMsg(uint32_t feedId, std::list &msgs) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::onProcessSuccess_filterMsg - feed " << feedId << " got " << msgs.size() << " messages" << std::endl; @@ -1842,7 +1836,7 @@ void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::li RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -1883,7 +1877,7 @@ void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::li } } -void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list &msgs, bool single) +void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list &msgs, bool single) { #ifdef FEEDREADER_DEBUG std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - feed " << feedId << " got " << msgs.size() << " messages" << std::endl; @@ -1898,7 +1892,7 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -2042,13 +2036,13 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list } } -void p3FeedReader::onProcessError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString) +void p3FeedReader::onProcessError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString) { { RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG @@ -2079,7 +2073,7 @@ void p3FeedReader::onProcessError(const std::string &feedId, RsFeedReaderErrorSt } } -void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description) +void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description) { bool changed = false; bool preview; @@ -2091,7 +2085,7 @@ void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &nam RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ /* find feed */ - std::map::iterator it = mFeeds.find(feedId); + std::map::iterator it = mFeeds.find(feedId); if (it == mFeeds.end()) { /* feed not found */ #ifdef FEEDREADER_DEBUG diff --git a/plugins/FeedReader/services/p3FeedReader.h b/plugins/FeedReader/services/p3FeedReader.h index 8d8446251..08fa3619b 100644 --- a/plugins/FeedReader/services/p3FeedReader.h +++ b/plugins/FeedReader/services/p3FeedReader.h @@ -52,24 +52,24 @@ public: virtual bool getSaveInBackground(); virtual void setSaveInBackground(bool saveInBackground); - virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId); - virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name); - virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId); - virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo); - virtual bool removeFeed(const std::string &feedId); - virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId); - virtual void getFeedList(const std::string &parentId, std::list &feedInfos); - virtual bool getFeedInfo(const std::string &feedId, FeedInfo &feedInfo); - virtual bool getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo); - virtual bool removeMsg(const std::string &feedId, const std::string &msgId); - virtual bool removeMsgs(const std::string &feedId, const std::list &msgIds); - virtual bool getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount); - virtual bool getFeedMsgList(const std::string &feedId, std::list &msgInfos); - virtual bool getFeedMsgIdList(const std::string &feedId, std::list &msgIds); - virtual bool processFeed(const std::string &feedId); - virtual bool setMessageRead(const std::string &feedId, const std::string &msgId, bool read); - virtual bool retransformMsg(const std::string &feedId, const std::string &msgId); - virtual bool clearMessageCache(const std::string &feedId); + virtual RsFeedAddResult addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId); + virtual RsFeedAddResult setFolder(uint32_t feedId, const std::string &name); + virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, uint32_t &feedId); + virtual RsFeedAddResult setFeed(uint32_t feedId, const FeedInfo &feedInfo); + virtual bool removeFeed(uint32_t feedId); + virtual bool addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId); + virtual void getFeedList(uint32_t parentId, std::list &feedInfos); + virtual bool getFeedInfo(uint32_t feedId, FeedInfo &feedInfo); + virtual bool getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo); + virtual bool removeMsg(uint32_t feedId, const std::string &msgId); + virtual bool removeMsgs(uint32_t feedId, const std::list &msgIds); + virtual bool getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount); + virtual bool getFeedMsgList(uint32_t feedId, std::list &msgInfos); + virtual bool getFeedMsgIdList(uint32_t feedId, std::list &msgIds); + virtual bool processFeed(uint32_t feedId); + virtual bool setMessageRead(uint32_t feedId, const std::string &msgId, bool read); + virtual bool retransformMsg(uint32_t feedId, const std::string &msgId); + virtual bool clearMessageCache(uint32_t feedId); virtual RsFeedReaderErrorState processXPath(const std::list &xpathsToUse, const std::list &xpathsToRemove, std::string &description, std::string &errorString); virtual RsFeedReaderErrorState processXslt(const std::string &xslt, std::string &description, std::string &errorString); @@ -79,16 +79,16 @@ public: virtual RsServiceInfo getServiceInfo() ; /****************** internal STUFF *******************/ - bool getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId); - void onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon); - void onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString); - void onProcessSuccess_filterMsg(const std::string &feedId, std::list &msgs); - void onProcessSuccess_addMsgs(const std::string &feedId, std::list &msgs, bool single); - void onProcessError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString); + bool getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeedId); + void onDownloadSuccess(uint32_t feedId, const std::string &content, std::string &icon); + void onDownloadError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString); + void onProcessSuccess_filterMsg(uint32_t feedId, std::list &msgs); + void onProcessSuccess_addMsgs(uint32_t feedId, std::list &msgs, bool single); + void onProcessError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString); - bool getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId); + bool getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId); - void setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description); + void setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description); bool getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &forumGroup); bool updateForumGroup(const RsGxsForumGroup &forumGroup, const std::string &groupName, const std::string &groupDescription); @@ -125,13 +125,13 @@ private: bool mStandardUseProxy; std::string mStandardProxyAddress; uint16_t mStandardProxyPort; - std::map mFeeds; + std::map mFeeds; RsMutex mDownloadMutex; - std::list mDownloadFeeds; + std::list mDownloadFeeds; RsMutex mProcessMutex; - std::list mProcessFeeds; + std::list mProcessFeeds; RsMutex mPreviewMutex; p3FeedReaderThread *mPreviewDownloadThread; diff --git a/plugins/FeedReader/services/p3FeedReaderThread.cc b/plugins/FeedReader/services/p3FeedReaderThread.cc index 873ba8d22..38f966663 100644 --- a/plugins/FeedReader/services/p3FeedReaderThread.cc +++ b/plugins/FeedReader/services/p3FeedReaderThread.cc @@ -36,7 +36,7 @@ enum FeedFormat { FORMAT_RSS, FORMAT_RDF, FORMAT_ATOM }; * #define FEEDREADER_DEBUG *********/ -p3FeedReaderThread::p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId) : +p3FeedReaderThread::p3FeedReaderThread(p3FeedReader *feedReader, Type type, uint32_t feedId) : RsTickingThread(), mFeedReader(feedReader), mType(type), mFeedId(feedId) { } @@ -49,7 +49,7 @@ p3FeedReaderThread::~p3FeedReaderThread() /****************************** Thread *************************************/ /***************************************************************************/ -void p3FeedReaderThread::data_tick() +void p3FeedReaderThread::threadTick() { rstime::rs_usleep(1000000); diff --git a/plugins/FeedReader/services/p3FeedReaderThread.h b/plugins/FeedReader/services/p3FeedReaderThread.h index 41060f16a..48d920dd6 100644 --- a/plugins/FeedReader/services/p3FeedReaderThread.h +++ b/plugins/FeedReader/services/p3FeedReaderThread.h @@ -42,10 +42,10 @@ public: }; public: - p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId); + p3FeedReaderThread(p3FeedReader *feedReader, Type type, uint32_t feedId); virtual ~p3FeedReaderThread(); - std::string getFeedId() { return mFeedId; } + uint32_t getFeedId() { return mFeedId; } static RsFeedReaderErrorState processXPath(const std::list &xpathsToUse, const std::list &xpathsToRemove, std::string &description, std::string &errorString); static RsFeedReaderErrorState processXPath(const std::list &xpathsToUse, const std::list &xpathsToRemove, HTMLWrapper &html, std::string &errorString); @@ -55,7 +55,7 @@ public: static RsFeedReaderErrorState processTransformation(const RsFeedReaderFeed &feed, RsFeedReaderMsg *msg, std::string &errorString); private: - virtual void data_tick(); + virtual void threadTick() override; /// @see RsTickingThread RsFeedReaderErrorState download(const RsFeedReaderFeed &feed, std::string &content, std::string &icon, std::string &errorString); RsFeedReaderErrorState process(const RsFeedReaderFeed &feed, std::list &entries, std::string &errorString); @@ -65,7 +65,7 @@ private: p3FeedReader *mFeedReader; Type mType; - std::string mFeedId; + uint32_t mFeedId; }; #endif diff --git a/plugins/FeedReader/services/rsFeedReaderItems.cc b/plugins/FeedReader/services/rsFeedReaderItems.cc index a88abad17..04a6c8f1e 100644 --- a/plugins/FeedReader/services/rsFeedReaderItems.cc +++ b/plugins/FeedReader/services/rsFeedReaderItems.cc @@ -33,8 +33,8 @@ RsFeedReaderFeed::RsFeedReaderFeed() void RsFeedReaderFeed::clear() { - feedId.clear(); - parentId.clear(); + feedId = 0; + parentId = 0; name.clear(); url.clear(); user.clear(); @@ -64,8 +64,8 @@ uint32_t RsFeedReaderSerialiser::sizeFeed(RsFeedReaderFeed *item) { uint32_t s = 8; /* header */ s += 2; /* version */ - s += GetTlvStringSize(item->feedId); - s += GetTlvStringSize(item->parentId); + s += sizeof(uint32_t); + s += sizeof(uint32_t); s += GetTlvStringSize(item->url); s += GetTlvStringSize(item->name); s += GetTlvStringSize(item->description); @@ -108,9 +108,9 @@ bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, u offset += 8; /* add values */ - ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */ - ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->feedId); - ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->parentId); + ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */ + ok &= setRawUInt32(data, tlvsize, &offset, item->feedId); + ok &= setRawUInt32(data, tlvsize, &offset, item->parentId); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->url); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description); @@ -173,8 +173,28 @@ RsFeedReaderFeed *RsFeedReaderSerialiser::deserialiseFeed(void *data, uint32_t * /* get values */ uint16_t version = 0; ok &= getRawUInt16(data, rssize, &offset, &version); - ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->feedId); - ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->parentId); + if (version >= 2) { + ok &= getRawUInt32(data, rssize, &offset, &item->feedId); + ok &= getRawUInt32(data, rssize, &offset, &item->parentId); + } else { + std::string feedId; + ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, feedId); + std::string parentId; + ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, parentId); + + if (ok) { + if (sscanf(feedId.c_str(), "%u", &item->feedId) != 1) { + ok = false; + } + if (!parentId.empty()) { + if (sscanf(parentId.c_str(), "%u", &item->parentId) != 1) { + ok = false; + } + } else { + item->parentId = 0; + } + } + } ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->url); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description); @@ -240,7 +260,7 @@ RsFeedReaderMsg::RsFeedReaderMsg() : RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_T void RsFeedReaderMsg::clear() { msgId.clear(); - feedId.clear(); + feedId = 0; title.clear(); link.clear(); author.clear(); @@ -260,7 +280,7 @@ uint32_t RsFeedReaderSerialiser::sizeMsg(RsFeedReaderMsg *item) uint32_t s = 8; /* header */ s += 2; /* version */ s += GetTlvStringSize(item->msgId); - s += GetTlvStringSize(item->feedId); + s += sizeof(uint32_t); s += GetTlvStringSize(item->title); s += GetTlvStringSize(item->link); s += GetTlvStringSize(item->author); @@ -291,9 +311,9 @@ bool RsFeedReaderSerialiser::serialiseMsg(RsFeedReaderMsg *item, void *data, uin offset += 8; /* add values */ - ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */ + ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */ ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->msgId); - ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->feedId); + ok &= setRawUInt32(data, tlvsize, &offset, item->feedId); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->title); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->link); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->author); @@ -345,7 +365,16 @@ RsFeedReaderMsg *RsFeedReaderSerialiser::deserialiseMsg(void *data, uint32_t *pk uint16_t version = 0; ok &= getRawUInt16(data, rssize, &offset, &version); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->msgId); - ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->feedId); + if (version >= 2) { + ok &= getRawUInt32(data, rssize, &offset, &item->feedId); + } else { + std::string feedId; + ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, feedId); + + if (sscanf(feedId.c_str(), "%u", &item->feedId) != 1) { + ok = false; + } + } ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->title); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->link); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->author); diff --git a/plugins/FeedReader/services/rsFeedReaderItems.h b/plugins/FeedReader/services/rsFeedReaderItems.h index 25c1be830..a8cce7084 100644 --- a/plugins/FeedReader/services/rsFeedReaderItems.h +++ b/plugins/FeedReader/services/rsFeedReaderItems.h @@ -62,10 +62,9 @@ public: virtual ~RsFeedReaderFeed() {} virtual void clear(); - virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); - std::string feedId; - std::string parentId; + uint32_t feedId; + uint32_t parentId; std::string name; std::string url; std::string user; @@ -109,7 +108,7 @@ public: virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); std::string msgId; - std::string feedId; + uint32_t feedId; std::string title; std::string link; std::string author;