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