mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
FeedReader: The feed can be used as source for board
This commit is contained in:
parent
ecffb3cb7f
commit
571f709b50
13 changed files with 704 additions and 113 deletions
|
@ -92,7 +92,7 @@ void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||||
{
|
{
|
||||||
mInterfaces = interfaces;
|
mInterfaces = interfaces;
|
||||||
|
|
||||||
mFeedReader = new p3FeedReader(mPlugInHandler, mInterfaces.mGxsForums);
|
mFeedReader = new p3FeedReader(mPlugInHandler, mInterfaces.mGxsForums, mInterfaces.mPosted);
|
||||||
rsFeedReader = mFeedReader;
|
rsFeedReader = mFeedReader;
|
||||||
|
|
||||||
mNotify = new FeedReaderNotify();
|
mNotify = new FeedReaderNotify();
|
||||||
|
|
|
@ -30,9 +30,11 @@
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
|
|
||||||
#include <retroshare/rsgxsforums.h>
|
#include <retroshare/rsgxsforums.h>
|
||||||
|
#include <retroshare/rsposted.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define TOKEN_TYPE_FORUM_GROUPS 1
|
#define TOKEN_TYPE_FORUM_GROUPS 1
|
||||||
|
#define TOKEN_TYPE_POSTED_GROUPS 2
|
||||||
|
|
||||||
AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent)
|
AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent)
|
||||||
: QDialog(parent, Qt::Window), mFeedReader(feedReader), mNotify(notify), ui(new Ui::AddFeedDialog)
|
: QDialog(parent, Qt::Window), mFeedReader(feedReader), mNotify(notify), ui(new Ui::AddFeedDialog)
|
||||||
|
@ -47,9 +49,12 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
|
||||||
|
|
||||||
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);
|
||||||
|
mStateHelper->addWidget(TOKEN_TYPE_POSTED_GROUPS, ui->postedComboBox, UISTATE_LOADING_DISABLED);
|
||||||
|
mStateHelper->addWidget(TOKEN_TYPE_POSTED_GROUPS, ui->buttonBox->button(QDialogButtonBox::Ok), UISTATE_LOADING_DISABLED);
|
||||||
|
|
||||||
/* Setup TokenQueue */
|
/* Setup TokenQueue */
|
||||||
mTokenQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
mForumTokenQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||||
|
mPostedTokenQueue = new TokenQueue(rsPosted->getTokenService(), this);
|
||||||
|
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(createFeed()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(createFeed()));
|
||||||
|
@ -59,18 +64,23 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
|
||||||
connect(ui->useStandardStorageTimeCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardStorageTimeToggled()));
|
connect(ui->useStandardStorageTimeCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardStorageTimeToggled()));
|
||||||
connect(ui->useStandardUpdateInterval, SIGNAL(toggled(bool)), this, SLOT(useStandardUpdateIntervalToggled()));
|
connect(ui->useStandardUpdateInterval, SIGNAL(toggled(bool)), this, SLOT(useStandardUpdateIntervalToggled()));
|
||||||
connect(ui->useStandardProxyCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardProxyToggled()));
|
connect(ui->useStandardProxyCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardProxyToggled()));
|
||||||
connect(ui->typeForumRadio, SIGNAL(toggled(bool)), this, SLOT(typeForumToggled()));
|
connect(ui->typeForumCheckBox, SIGNAL(toggled(bool)), this, SLOT(typeForumToggled()));
|
||||||
|
connect(ui->typePostedCheckBox, SIGNAL(toggled(bool)), this, SLOT(typePostedToggled()));
|
||||||
|
connect(ui->typeLocalCheckBox, SIGNAL(toggled(bool)), this, SLOT(typeLocalToggled()));
|
||||||
|
connect(ui->postedFirstImageCheckBox, SIGNAL(toggled(bool)), this, SLOT(postedFirstImageToggled()));
|
||||||
connect(ui->previewButton, SIGNAL(clicked()), this, SLOT(preview()));
|
connect(ui->previewButton, SIGNAL(clicked()), this, SLOT(preview()));
|
||||||
|
|
||||||
/* currently only for local feeds */
|
/* currently only for local feeds */
|
||||||
connect(ui->saveCompletePageCheckBox, SIGNAL(toggled(bool)), this, SLOT(denyForumToggled()));
|
connect(ui->saveCompletePageCheckBox, SIGNAL(toggled(bool)), this, SLOT(denyForumAndPostedToggled()));
|
||||||
|
|
||||||
connect(ui->urlLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validate()));
|
connect(ui->urlLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validate()));
|
||||||
connect(ui->nameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validate()));
|
connect(ui->nameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validate()));
|
||||||
connect(ui->useInfoFromFeedCheckBox, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
connect(ui->useInfoFromFeedCheckBox, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
||||||
connect(ui->typeLocalRadio, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
connect(ui->typeLocalCheckBox, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
||||||
connect(ui->typeForumRadio, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
connect(ui->typeForumCheckBox, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
||||||
connect(ui->forumComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(validate()));
|
connect(ui->forumComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(validate()));
|
||||||
|
connect(ui->typePostedCheckBox, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
||||||
|
connect(ui->postedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(validate()));
|
||||||
|
|
||||||
connect(ui->clearCachePushButton, SIGNAL(clicked()), this, SLOT(clearMessageCache()));
|
connect(ui->clearCachePushButton, SIGNAL(clicked()), this, SLOT(clearMessageCache()));
|
||||||
|
|
||||||
|
@ -79,13 +89,22 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
|
||||||
|
|
||||||
ui->activatedCheckBox->setChecked(true);
|
ui->activatedCheckBox->setChecked(true);
|
||||||
mStateHelper->setWidgetEnabled(ui->forumComboBox, false);
|
mStateHelper->setWidgetEnabled(ui->forumComboBox, false);
|
||||||
|
mStateHelper->setWidgetEnabled(ui->postedComboBox, false);
|
||||||
ui->useInfoFromFeedCheckBox->setChecked(true);
|
ui->useInfoFromFeedCheckBox->setChecked(true);
|
||||||
ui->updateForumInfoCheckBox->setEnabled(false);
|
ui->updateForumInfoCheckBox->setEnabled(false);
|
||||||
ui->updateForumInfoCheckBox->setChecked(true);
|
ui->updateForumInfoCheckBox->setChecked(true);
|
||||||
|
ui->updatePostedInfoCheckBox->setEnabled(false);
|
||||||
|
ui->updatePostedInfoCheckBox->setChecked(true);
|
||||||
|
ui->postedFirstImageCheckBox->setEnabled(false);
|
||||||
|
ui->postedFirstImageCheckBox->setChecked(false);
|
||||||
|
ui->postedOnlyImageCheckBox->setEnabled(false);
|
||||||
|
ui->postedOnlyImageCheckBox->setChecked(false);
|
||||||
ui->useAuthenticationCheckBox->setChecked(false);
|
ui->useAuthenticationCheckBox->setChecked(false);
|
||||||
ui->useStandardStorageTimeCheckBox->setChecked(true);
|
ui->useStandardStorageTimeCheckBox->setChecked(true);
|
||||||
ui->useStandardUpdateInterval->setChecked(true);
|
ui->useStandardUpdateInterval->setChecked(true);
|
||||||
ui->useStandardProxyCheckBox->setChecked(true);
|
ui->useStandardProxyCheckBox->setChecked(true);
|
||||||
|
ui->embedImagesCheckBox->setChecked(true);
|
||||||
|
ui->saveCompletePageCheckBox->setEnabled(false);
|
||||||
|
|
||||||
/* not yet supported */
|
/* not yet supported */
|
||||||
ui->authenticationGroupBox->setEnabled(false);
|
ui->authenticationGroupBox->setEnabled(false);
|
||||||
|
@ -98,6 +117,9 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
|
||||||
/* fill own forums */
|
/* fill own forums */
|
||||||
requestForumGroups();
|
requestForumGroups();
|
||||||
|
|
||||||
|
/* fill own posted */
|
||||||
|
requestPostedGroups();
|
||||||
|
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
ui->urlLineEdit->setFocus();
|
ui->urlLineEdit->setFocus();
|
||||||
|
@ -112,7 +134,8 @@ AddFeedDialog::~AddFeedDialog()
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
||||||
delete(ui);
|
delete(ui);
|
||||||
delete(mTokenQueue);
|
delete(mForumTokenQueue);
|
||||||
|
delete(mPostedTokenQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFeedDialog::processSettings(bool load)
|
void AddFeedDialog::processSettings(bool load)
|
||||||
|
@ -161,18 +184,65 @@ void AddFeedDialog::useStandardProxyToggled()
|
||||||
|
|
||||||
void AddFeedDialog::typeForumToggled()
|
void AddFeedDialog::typeForumToggled()
|
||||||
{
|
{
|
||||||
bool checked = ui->typeForumRadio->isChecked();
|
bool checked = ui->typeForumCheckBox->isChecked();
|
||||||
mStateHelper->setWidgetEnabled(ui->forumComboBox, checked);
|
mStateHelper->setWidgetEnabled(ui->forumComboBox, checked);
|
||||||
ui->updateForumInfoCheckBox->setEnabled(checked);
|
ui->updateForumInfoCheckBox->setEnabled(checked);
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
ui->typeLocalCheckBox->setChecked(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFeedDialog::denyForumToggled()
|
void AddFeedDialog::postedFirstImageToggled()
|
||||||
|
{
|
||||||
|
bool checked = ui->postedFirstImageCheckBox->isChecked();
|
||||||
|
ui->postedOnlyImageCheckBox->setEnabled(checked);
|
||||||
|
|
||||||
|
if (!checked) {
|
||||||
|
ui->postedOnlyImageCheckBox->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddFeedDialog::typePostedToggled()
|
||||||
|
{
|
||||||
|
bool checked = ui->typePostedCheckBox->isChecked();
|
||||||
|
mStateHelper->setWidgetEnabled(ui->postedComboBox, checked);
|
||||||
|
ui->updatePostedInfoCheckBox->setEnabled(checked);
|
||||||
|
ui->postedFirstImageCheckBox->setEnabled(checked);
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
ui->typeLocalCheckBox->setChecked(false);
|
||||||
|
}else {
|
||||||
|
ui->postedFirstImageCheckBox->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddFeedDialog::typeLocalToggled()
|
||||||
|
{
|
||||||
|
bool checked = ui->typeLocalCheckBox->isChecked();
|
||||||
|
if (checked) {
|
||||||
|
mStateHelper->setWidgetEnabled(ui->forumComboBox, false);
|
||||||
|
mStateHelper->setWidgetEnabled(ui->postedComboBox, false);
|
||||||
|
ui->typeForumCheckBox->setChecked(false);
|
||||||
|
ui->typePostedCheckBox->setChecked(false);
|
||||||
|
ui->saveCompletePageCheckBox->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
ui->saveCompletePageCheckBox->setEnabled(false);
|
||||||
|
ui->saveCompletePageCheckBox->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddFeedDialog::denyForumAndPostedToggled()
|
||||||
{
|
{
|
||||||
if (ui->saveCompletePageCheckBox->isChecked()) {
|
if (ui->saveCompletePageCheckBox->isChecked()) {
|
||||||
ui->typeForumRadio->setEnabled(false);
|
ui->typeForumCheckBox->setEnabled(false);
|
||||||
ui->typeLocalRadio->setChecked(true);
|
ui->typeForumCheckBox->setChecked(false);
|
||||||
|
ui->typePostedCheckBox->setEnabled(false);
|
||||||
|
ui->typePostedCheckBox->setChecked(false);
|
||||||
|
ui->typeLocalCheckBox->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
ui->typeForumRadio->setEnabled(true);
|
ui->typeForumCheckBox->setEnabled(true);
|
||||||
|
ui->typePostedCheckBox->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,11 +259,15 @@ void AddFeedDialog::validate()
|
||||||
|
|
||||||
ui->previewButton->setEnabled(ok);
|
ui->previewButton->setEnabled(ok);
|
||||||
|
|
||||||
if (!ui->typeLocalRadio->isChecked() && !ui->typeForumRadio->isChecked()) {
|
if (!ui->typeLocalCheckBox->isChecked() && !ui->typeForumCheckBox->isChecked() && !ui->typePostedCheckBox->isChecked()) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->typeForumRadio->isChecked() && ui->forumComboBox->itemData(ui->forumComboBox->currentIndex()).toString().isEmpty()) {
|
if (ui->typeForumCheckBox->isChecked() && ui->forumComboBox->itemData(ui->forumComboBox->currentIndex()).toString().isEmpty()) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ui->typePostedCheckBox->isChecked() && ui->postedComboBox->itemData(ui->postedComboBox->currentIndex()).toString().isEmpty()) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,20 +298,31 @@ bool AddFeedDialog::fillFeed(uint32_t feedId)
|
||||||
ui->urlLineEdit->setText(QString::fromUtf8(feedInfo.url.c_str()));
|
ui->urlLineEdit->setText(QString::fromUtf8(feedInfo.url.c_str()));
|
||||||
ui->useInfoFromFeedCheckBox->setChecked(feedInfo.flag.infoFromFeed);
|
ui->useInfoFromFeedCheckBox->setChecked(feedInfo.flag.infoFromFeed);
|
||||||
ui->updateForumInfoCheckBox->setChecked(feedInfo.flag.updateForumInfo);
|
ui->updateForumInfoCheckBox->setChecked(feedInfo.flag.updateForumInfo);
|
||||||
|
ui->updatePostedInfoCheckBox->setChecked(feedInfo.flag.updatePostedInfo);
|
||||||
|
ui->postedFirstImageCheckBox->setChecked(feedInfo.flag.postedFirstImage);
|
||||||
|
ui->postedOnlyImageCheckBox->setChecked(feedInfo.flag.postedOnlyImage);
|
||||||
ui->activatedCheckBox->setChecked(!feedInfo.flag.deactivated);
|
ui->activatedCheckBox->setChecked(!feedInfo.flag.deactivated);
|
||||||
ui->embedImagesCheckBox->setChecked(feedInfo.flag.embedImages);
|
ui->embedImagesCheckBox->setChecked(feedInfo.flag.embedImages);
|
||||||
ui->saveCompletePageCheckBox->setChecked(feedInfo.flag.saveCompletePage);
|
ui->saveCompletePageCheckBox->setChecked(feedInfo.flag.saveCompletePage);
|
||||||
|
|
||||||
ui->descriptionPlainTextEdit->setPlainText(QString::fromUtf8(feedInfo.description.c_str()));
|
ui->descriptionPlainTextEdit->setPlainText(QString::fromUtf8(feedInfo.description.c_str()));
|
||||||
|
|
||||||
|
if (feedInfo.flag.forum || feedInfo.flag.posted) {
|
||||||
if (feedInfo.flag.forum) {
|
if (feedInfo.flag.forum) {
|
||||||
mStateHelper->setWidgetEnabled(ui->forumComboBox, true);
|
mStateHelper->setWidgetEnabled(ui->forumComboBox, true);
|
||||||
ui->typeForumRadio->setChecked(true);
|
ui->typeForumCheckBox->setChecked(true);
|
||||||
ui->saveCompletePageCheckBox->setEnabled(false);
|
|
||||||
|
|
||||||
setActiveForumId(feedInfo.forumId);
|
setActiveForumId(feedInfo.forumId);
|
||||||
|
}
|
||||||
|
if (feedInfo.flag.posted) {
|
||||||
|
mStateHelper->setWidgetEnabled(ui->postedComboBox, true);
|
||||||
|
ui->typePostedCheckBox->setChecked(true);
|
||||||
|
|
||||||
|
setActivePostedId(feedInfo.postedId);
|
||||||
|
}
|
||||||
|
ui->saveCompletePageCheckBox->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
ui->typeLocalRadio->setChecked(true);
|
ui->typeLocalCheckBox->setChecked(true);
|
||||||
mStateHelper->setWidgetEnabled(ui->forumComboBox, false);
|
mStateHelper->setWidgetEnabled(ui->forumComboBox, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +371,21 @@ void AddFeedDialog::setActiveForumId(const std::string &forumId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddFeedDialog::setActivePostedId(const std::string &postedId)
|
||||||
|
{
|
||||||
|
if (mStateHelper->isLoading(TOKEN_TYPE_POSTED_GROUPS)) {
|
||||||
|
mFillPostedId = postedId;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = ui->postedComboBox->findData(QString::fromStdString(postedId));
|
||||||
|
if (index >= 0) {
|
||||||
|
ui->postedComboBox->setCurrentIndex(index);
|
||||||
|
} else {
|
||||||
|
ui->postedComboBox->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AddFeedDialog::getFeedInfo(FeedInfo &feedInfo)
|
void AddFeedDialog::getFeedInfo(FeedInfo &feedInfo)
|
||||||
{
|
{
|
||||||
feedInfo.parentId = mParentId;
|
feedInfo.parentId = mParentId;
|
||||||
|
@ -294,18 +394,27 @@ void AddFeedDialog::getFeedInfo(FeedInfo &feedInfo)
|
||||||
feedInfo.url = ui->urlLineEdit->text().toUtf8().constData();
|
feedInfo.url = ui->urlLineEdit->text().toUtf8().constData();
|
||||||
feedInfo.flag.infoFromFeed = ui->useInfoFromFeedCheckBox->isChecked();
|
feedInfo.flag.infoFromFeed = ui->useInfoFromFeedCheckBox->isChecked();
|
||||||
feedInfo.flag.updateForumInfo = ui->updateForumInfoCheckBox->isChecked() && ui->updateForumInfoCheckBox->isEnabled();
|
feedInfo.flag.updateForumInfo = ui->updateForumInfoCheckBox->isChecked() && ui->updateForumInfoCheckBox->isEnabled();
|
||||||
|
feedInfo.flag.updatePostedInfo = ui->updatePostedInfoCheckBox->isChecked() && ui->updatePostedInfoCheckBox->isEnabled();
|
||||||
|
feedInfo.flag.postedFirstImage = ui->postedFirstImageCheckBox->isChecked() && ui->postedFirstImageCheckBox->isEnabled();
|
||||||
|
feedInfo.flag.postedOnlyImage = ui->postedOnlyImageCheckBox->isChecked() && ui->postedOnlyImageCheckBox->isEnabled();
|
||||||
feedInfo.flag.deactivated = !ui->activatedCheckBox->isChecked();
|
feedInfo.flag.deactivated = !ui->activatedCheckBox->isChecked();
|
||||||
feedInfo.flag.embedImages = ui->embedImagesCheckBox->isChecked();
|
feedInfo.flag.embedImages = ui->embedImagesCheckBox->isChecked();
|
||||||
feedInfo.flag.saveCompletePage = ui->saveCompletePageCheckBox->isChecked();
|
feedInfo.flag.saveCompletePage = ui->saveCompletePageCheckBox->isChecked();
|
||||||
|
|
||||||
feedInfo.description = ui->descriptionPlainTextEdit->toPlainText().toUtf8().constData();
|
feedInfo.description = ui->descriptionPlainTextEdit->toPlainText().toUtf8().constData();
|
||||||
|
|
||||||
feedInfo.flag.forum = ui->typeForumRadio->isChecked();
|
feedInfo.flag.forum = ui->typeForumCheckBox->isChecked();
|
||||||
|
|
||||||
if (feedInfo.flag.forum) {
|
if (feedInfo.flag.forum) {
|
||||||
feedInfo.forumId = ui->forumComboBox->itemData(ui->forumComboBox->currentIndex()).toString().toStdString();
|
feedInfo.forumId = ui->forumComboBox->itemData(ui->forumComboBox->currentIndex()).toString().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedInfo.flag.posted = ui->typePostedCheckBox->isChecked();
|
||||||
|
|
||||||
|
if (feedInfo.flag.posted) {
|
||||||
|
feedInfo.postedId = ui->postedComboBox->itemData(ui->postedComboBox->currentIndex()).toString().toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
feedInfo.flag.authentication = ui->useAuthenticationCheckBox->isChecked();
|
feedInfo.flag.authentication = ui->useAuthenticationCheckBox->isChecked();
|
||||||
feedInfo.user = ui->userLineEdit->text().toUtf8().constData();
|
feedInfo.user = ui->userLineEdit->text().toUtf8().constData();
|
||||||
feedInfo.password = ui->passwordLineEdit->text().toUtf8().constData();
|
feedInfo.password = ui->passwordLineEdit->text().toUtf8().constData();
|
||||||
|
@ -382,10 +491,10 @@ void AddFeedDialog::requestForumGroups()
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
|
|
||||||
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_FORUM_GROUPS);
|
mForumTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_FORUM_GROUPS);
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, TOKEN_TYPE_FORUM_GROUPS);
|
mForumTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, TOKEN_TYPE_FORUM_GROUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFeedDialog::loadForumGroups(const uint32_t &token)
|
void AddFeedDialog::loadForumGroups(const uint32_t &token)
|
||||||
|
@ -416,9 +525,50 @@ void AddFeedDialog::loadForumGroups(const uint32_t &token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddFeedDialog::requestPostedGroups()
|
||||||
|
{
|
||||||
|
mStateHelper->setLoading(TOKEN_TYPE_POSTED_GROUPS, true);
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
|
|
||||||
|
mPostedTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTED_GROUPS);
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
mPostedTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, TOKEN_TYPE_POSTED_GROUPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddFeedDialog::loadPostedGroups(const uint32_t &token)
|
||||||
|
{
|
||||||
|
std::vector<RsPostedGroup> groups;
|
||||||
|
rsPosted->getGroupData(token, groups);
|
||||||
|
|
||||||
|
ui->postedComboBox->clear();
|
||||||
|
|
||||||
|
for (std::vector<RsPostedGroup>::iterator it = groups.begin(); it != groups.end(); ++it) {
|
||||||
|
const RsPostedGroup &group = *it;
|
||||||
|
|
||||||
|
/* show only own posted */
|
||||||
|
if (IS_GROUP_PUBLISHER(group.mMeta.mSubscribeFlags) && IS_GROUP_ADMIN(group.mMeta.mSubscribeFlags) && !group.mMeta.mAuthorId.isNull()) {
|
||||||
|
ui->postedComboBox->addItem(QString::fromUtf8(group.mMeta.mGroupName.c_str()), QString::fromStdString(group.mMeta.mGroupId.toStdString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* insert empty item */
|
||||||
|
ui->postedComboBox->insertItem(0, "", "");
|
||||||
|
ui->postedComboBox->setCurrentIndex(0);
|
||||||
|
|
||||||
|
mStateHelper->setLoading(TOKEN_TYPE_POSTED_GROUPS, false);
|
||||||
|
|
||||||
|
if (!mFillPostedId.empty()) {
|
||||||
|
setActivePostedId(mFillPostedId);
|
||||||
|
mFillPostedId.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AddFeedDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void AddFeedDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||||
{
|
{
|
||||||
if (queue == mTokenQueue)
|
if (queue == mForumTokenQueue)
|
||||||
{
|
{
|
||||||
/* now switch on req */
|
/* now switch on req */
|
||||||
switch(req.mUserType)
|
switch(req.mUserType)
|
||||||
|
@ -433,4 +583,20 @@ void AddFeedDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queue == mPostedTokenQueue)
|
||||||
|
{
|
||||||
|
/* now switch on req */
|
||||||
|
switch(req.mUserType)
|
||||||
|
{
|
||||||
|
case TOKEN_TYPE_POSTED_GROUPS:
|
||||||
|
loadPostedGroups(req.mToken);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
std::cerr << "AddFeedDialog::loadRequest() ERROR: INVALID TYPE";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,10 @@ private slots:
|
||||||
void useStandardUpdateIntervalToggled();
|
void useStandardUpdateIntervalToggled();
|
||||||
void useStandardProxyToggled();
|
void useStandardProxyToggled();
|
||||||
void typeForumToggled();
|
void typeForumToggled();
|
||||||
void denyForumToggled();
|
void postedFirstImageToggled();
|
||||||
|
void typePostedToggled();
|
||||||
|
void typeLocalToggled();
|
||||||
|
void denyForumAndPostedToggled();
|
||||||
void validate();
|
void validate();
|
||||||
void createFeed();
|
void createFeed();
|
||||||
void preview();
|
void preview();
|
||||||
|
@ -63,9 +66,12 @@ private:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
void getFeedInfo(FeedInfo &feedInfo);
|
void getFeedInfo(FeedInfo &feedInfo);
|
||||||
void setActiveForumId(const std::string &forumId);
|
void setActiveForumId(const std::string &forumId);
|
||||||
|
void setActivePostedId(const std::string &postedId);
|
||||||
|
|
||||||
void requestForumGroups();
|
void requestForumGroups();
|
||||||
void loadForumGroups(const uint32_t &token);
|
void loadForumGroups(const uint32_t &token);
|
||||||
|
void requestPostedGroups();
|
||||||
|
void loadPostedGroups(const uint32_t &token);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsFeedReader *mFeedReader;
|
RsFeedReader *mFeedReader;
|
||||||
|
@ -73,13 +79,15 @@ private:
|
||||||
uint32_t mFeedId;
|
uint32_t mFeedId;
|
||||||
uint32_t mParentId;
|
uint32_t mParentId;
|
||||||
std::string mFillForumId;
|
std::string mFillForumId;
|
||||||
|
std::string mFillPostedId;
|
||||||
|
|
||||||
RsFeedTransformationType mTransformationType;
|
RsFeedTransformationType mTransformationType;
|
||||||
std::list<std::string> mXPathsToUse;
|
std::list<std::string> mXPathsToUse;
|
||||||
std::list<std::string> mXPathsToRemove;
|
std::list<std::string> mXPathsToRemove;
|
||||||
std::string mXslt;
|
std::string mXslt;
|
||||||
|
|
||||||
TokenQueue *mTokenQueue;
|
TokenQueue *mForumTokenQueue;
|
||||||
|
TokenQueue *mPostedTokenQueue;
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
Ui::AddFeedDialog *ui;
|
Ui::AddFeedDialog *ui;
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Type</string>
|
<string>Type</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -63,27 +63,75 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<widget class="QCheckBox" name="typeForumCheckBox">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QRadioButton" name="typeForumRadio">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Forum</string>
|
<string>Forum</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="RSComboBox" name="forumComboBox"/>
|
<widget class="RSComboBox" name="forumComboBox"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="8" column="0">
|
||||||
</item>
|
<widget class="QCheckBox" name="typeLocalCheckBox">
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="typeLocalRadio">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Local Feed</string>
|
<string>Local Feed</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="updateForumInfoCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update forum information</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="RSComboBox" name="postedComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QCheckBox" name="typePostedCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Board</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="updatePostedInfoCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update board information</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="postedOnlyImageCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Only image</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="postedFirstImageCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use first image as board image</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -309,7 +357,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>11</pointsize>
|
<pointsize>11</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<italic>true</italic>
|
<italic>true</italic>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -377,13 +424,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="updateForumInfoCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Update forum information</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="embedImagesCheckBox">
|
<widget class="QCheckBox" name="embedImagesCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -398,6 +438,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -423,22 +476,31 @@
|
||||||
<tabstop>urlLineEdit</tabstop>
|
<tabstop>urlLineEdit</tabstop>
|
||||||
<tabstop>nameLineEdit</tabstop>
|
<tabstop>nameLineEdit</tabstop>
|
||||||
<tabstop>descriptionPlainTextEdit</tabstop>
|
<tabstop>descriptionPlainTextEdit</tabstop>
|
||||||
<tabstop>typeForumRadio</tabstop>
|
<tabstop>typeForumCheckBox</tabstop>
|
||||||
<tabstop>forumComboBox</tabstop>
|
<tabstop>forumComboBox</tabstop>
|
||||||
|
<tabstop>updateForumInfoCheckBox</tabstop>
|
||||||
|
<tabstop>typePostedCheckBox</tabstop>
|
||||||
|
<tabstop>postedComboBox</tabstop>
|
||||||
|
<tabstop>updatePostedInfoCheckBox</tabstop>
|
||||||
|
<tabstop>postedFirstImageCheckBox</tabstop>
|
||||||
|
<tabstop>checkBox</tabstop>
|
||||||
|
<tabstop>typeLocalCheckBox</tabstop>
|
||||||
<tabstop>activatedCheckBox</tabstop>
|
<tabstop>activatedCheckBox</tabstop>
|
||||||
<tabstop>useInfoFromFeedCheckBox</tabstop>
|
<tabstop>useInfoFromFeedCheckBox</tabstop>
|
||||||
<tabstop>updateForumInfoCheckBox</tabstop>
|
<tabstop>embedImagesCheckBox</tabstop>
|
||||||
|
<tabstop>saveCompletePageCheckBox</tabstop>
|
||||||
|
<tabstop>previewButton</tabstop>
|
||||||
<tabstop>useAuthenticationCheckBox</tabstop>
|
<tabstop>useAuthenticationCheckBox</tabstop>
|
||||||
<tabstop>userLineEdit</tabstop>
|
<tabstop>userLineEdit</tabstop>
|
||||||
<tabstop>passwordLineEdit</tabstop>
|
<tabstop>passwordLineEdit</tabstop>
|
||||||
<tabstop>useStandardStorageTimeCheckBox</tabstop>
|
<tabstop>useStandardStorageTimeCheckBox</tabstop>
|
||||||
|
<tabstop>clearCachePushButton</tabstop>
|
||||||
<tabstop>storageTimeSpinBox</tabstop>
|
<tabstop>storageTimeSpinBox</tabstop>
|
||||||
<tabstop>useStandardUpdateInterval</tabstop>
|
<tabstop>useStandardUpdateInterval</tabstop>
|
||||||
<tabstop>updateIntervalSpinBox</tabstop>
|
<tabstop>updateIntervalSpinBox</tabstop>
|
||||||
<tabstop>useStandardProxyCheckBox</tabstop>
|
<tabstop>useStandardProxyCheckBox</tabstop>
|
||||||
<tabstop>proxyAddressLineEdit</tabstop>
|
<tabstop>proxyAddressLineEdit</tabstop>
|
||||||
<tabstop>proxyPortSpinBox</tabstop>
|
<tabstop>proxyPortSpinBox</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -245,9 +245,19 @@ void FeedReaderMessageWidget::setFeedId(uint32_t feedId)
|
||||||
ui->msgReadAllButton->setEnabled(false);
|
ui->msgReadAllButton->setEnabled(false);
|
||||||
ui->msgTreeWidget->setPlaceholderText("");
|
ui->msgTreeWidget->setPlaceholderText("");
|
||||||
} else {
|
} else {
|
||||||
if (mFeedInfo.flag.forum) {
|
if (mFeedInfo.flag.forum || mFeedInfo.flag.posted) {
|
||||||
ui->msgReadAllButton->setEnabled(false);
|
ui->msgReadAllButton->setEnabled(false);
|
||||||
|
|
||||||
|
if (mFeedInfo.flag.forum && mFeedInfo.flag.posted) {
|
||||||
|
ui->msgTreeWidget->setPlaceholderText(tr("The messages will be added to the forum and the board"));
|
||||||
|
} else {
|
||||||
|
if (mFeedInfo.flag.forum) {
|
||||||
ui->msgTreeWidget->setPlaceholderText(tr("The messages will be added to the forum"));
|
ui->msgTreeWidget->setPlaceholderText(tr("The messages will be added to the forum"));
|
||||||
|
}
|
||||||
|
if (mFeedInfo.flag.posted) {
|
||||||
|
ui->msgTreeWidget->setPlaceholderText(tr("The messages will be added to the board"));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ui->msgReadAllButton->setEnabled(true);
|
ui->msgReadAllButton->setEnabled(true);
|
||||||
ui->msgTreeWidget->setPlaceholderText("");
|
ui->msgTreeWidget->setPlaceholderText("");
|
||||||
|
|
|
@ -109,9 +109,9 @@ QString FeedReaderStringDefs::errorString(RsFeedReaderErrorState errorState, con
|
||||||
case RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT:
|
case RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT:
|
||||||
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown XML format");
|
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown XML format");
|
||||||
break;
|
break;
|
||||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE:
|
// case RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE:
|
||||||
errorText = QApplication::translate("FeedReaderStringDefs", "Can't create forum");
|
// errorText = QApplication::translate("FeedReaderStringDefs", "Can't create forum");
|
||||||
break;
|
// break;
|
||||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND:
|
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND:
|
||||||
errorText = QApplication::translate("FeedReaderStringDefs", "Forum not found");
|
errorText = QApplication::translate("FeedReaderStringDefs", "Forum not found");
|
||||||
break;
|
break;
|
||||||
|
@ -121,6 +121,18 @@ QString FeedReaderStringDefs::errorString(RsFeedReaderErrorState errorState, con
|
||||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR:
|
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR:
|
||||||
errorText = QApplication::translate("FeedReaderStringDefs", "Forum has no author");
|
errorText = QApplication::translate("FeedReaderStringDefs", "Forum has no author");
|
||||||
break;
|
break;
|
||||||
|
// case RS_FEED_ERRORSTATE_PROCESS_POSTED_CREATE:
|
||||||
|
// errorText = QApplication::translate("FeedReaderStringDefs", "Can't create board");
|
||||||
|
// break;
|
||||||
|
case RS_FEED_ERRORSTATE_PROCESS_POSTED_NOT_FOUND:
|
||||||
|
errorText = QApplication::translate("FeedReaderStringDefs", "Board not found");
|
||||||
|
break;
|
||||||
|
case RS_FEED_ERRORSTATE_PROCESS_POSTED_NO_ADMIN:
|
||||||
|
errorText = QApplication::translate("FeedReaderStringDefs", "You are not admin of the board");
|
||||||
|
break;
|
||||||
|
case RS_FEED_ERRORSTATE_PROCESS_POSTED_NO_AUTHOR:
|
||||||
|
errorText = QApplication::translate("FeedReaderStringDefs", "Board has no author");
|
||||||
|
break;
|
||||||
|
|
||||||
case RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR:
|
case RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR:
|
||||||
errorText = QApplication::translate("FeedReaderStringDefs", "Can't read html");
|
errorText = QApplication::translate("FeedReaderStringDefs", "Can't read html");
|
||||||
|
|
|
@ -42,10 +42,14 @@ enum RsFeedReaderErrorState {
|
||||||
/* process */
|
/* process */
|
||||||
RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR = 50,
|
RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR = 50,
|
||||||
RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT = 51,
|
RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT = 51,
|
||||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE = 100,
|
// RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE = 100,
|
||||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND = 101,
|
RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND = 101,
|
||||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_ADMIN = 102,
|
RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_ADMIN = 102,
|
||||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR = 103,
|
RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR = 103,
|
||||||
|
// RS_FEED_ERRORSTATE_PROCESS_POSTED_CREATE = 104,
|
||||||
|
RS_FEED_ERRORSTATE_PROCESS_POSTED_NOT_FOUND = 105,
|
||||||
|
RS_FEED_ERRORSTATE_PROCESS_POSTED_NO_ADMIN = 106,
|
||||||
|
RS_FEED_ERRORSTATE_PROCESS_POSTED_NO_AUTHOR = 107,
|
||||||
|
|
||||||
RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR = 150,
|
RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR = 150,
|
||||||
RS_FEED_ERRORSTATE_PROCESS_XPATH_INTERNAL_ERROR = 151,
|
RS_FEED_ERRORSTATE_PROCESS_XPATH_INTERNAL_ERROR = 151,
|
||||||
|
@ -102,6 +106,8 @@ public:
|
||||||
flag.deactivated = false;
|
flag.deactivated = false;
|
||||||
flag.forum = false;
|
flag.forum = false;
|
||||||
flag.updateForumInfo = false;
|
flag.updateForumInfo = false;
|
||||||
|
flag.posted = false;
|
||||||
|
flag.updatePostedInfo = false;
|
||||||
flag.embedImages = false;
|
flag.embedImages = false;
|
||||||
flag.saveCompletePage = false;
|
flag.saveCompletePage = false;
|
||||||
flag.preview = false;
|
flag.preview = false;
|
||||||
|
@ -122,6 +128,7 @@ public:
|
||||||
time_t lastUpdate;
|
time_t lastUpdate;
|
||||||
uint32_t storageTime;
|
uint32_t storageTime;
|
||||||
std::string forumId;
|
std::string forumId;
|
||||||
|
std::string postedId;
|
||||||
WorkState workstate;
|
WorkState workstate;
|
||||||
RsFeedReaderErrorState errorState;
|
RsFeedReaderErrorState errorState;
|
||||||
std::string errorString;
|
std::string errorString;
|
||||||
|
@ -141,6 +148,10 @@ public:
|
||||||
bool deactivated : 1;
|
bool deactivated : 1;
|
||||||
bool forum : 1;
|
bool forum : 1;
|
||||||
bool updateForumInfo : 1;
|
bool updateForumInfo : 1;
|
||||||
|
bool posted : 1;
|
||||||
|
bool updatePostedInfo : 1;
|
||||||
|
bool postedFirstImage : 1;
|
||||||
|
bool postedOnlyImage : 1;
|
||||||
bool embedImages : 1;
|
bool embedImages : 1;
|
||||||
bool saveCompletePage : 1;
|
bool saveCompletePage : 1;
|
||||||
bool preview : 1;
|
bool preview : 1;
|
||||||
|
|
|
@ -9,7 +9,27 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+79"/>
|
<location line="+92"/>
|
||||||
|
<source>Board</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+9"/>
|
||||||
|
<source>Update board information</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+7"/>
|
||||||
|
<source>Only image</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+7"/>
|
||||||
|
<source>Use first image as board image</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+12"/>
|
||||||
<source>Authentication (not yet supported)</source>
|
<source>Authentication (not yet supported)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -99,22 +119,22 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="-148"/>
|
<location line="-196"/>
|
||||||
<source>Type</source>
|
<source>Type</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+20"/>
|
<location line="+24"/>
|
||||||
<source>Forum</source>
|
<source>Forum</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+12"/>
|
<location line="+10"/>
|
||||||
<source>Local Feed</source>
|
<source>Local Feed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+239"/>
|
<location line="+292"/>
|
||||||
<source>Transformation</source>
|
<source>Transformation</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -144,12 +164,12 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+7"/>
|
<location line="-329"/>
|
||||||
<source>Update forum information</source>
|
<source>Update forum information</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+14"/>
|
<location line="+343"/>
|
||||||
<source>Save complete web page (experimental for local feeds)</source>
|
<source>Save complete web page (experimental for local feeds)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -164,18 +184,18 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+10"/>
|
<location line="+17"/>
|
||||||
<source>Name:</source>
|
<source>Name:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/AddFeedDialog.cpp" line="+77"/>
|
<location filename="../gui/AddFeedDialog.cpp" line="+87"/>
|
||||||
<source>Feed Details</source>
|
<source>Feed Details</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+142"/>
|
<location line="+186"/>
|
||||||
<location line="+115"/>
|
<location line="+148"/>
|
||||||
<location line="+15"/>
|
<location line="+15"/>
|
||||||
<source>Edit feed</source>
|
<source>Edit feed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -277,7 +297,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>FeedReaderDialog</name>
|
<name>FeedReaderDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/FeedReaderDialog.ui" line="+91"/>
|
<location filename="../gui/FeedReaderDialog.ui" line="+98"/>
|
||||||
<source>Feeds</source>
|
<source>Feeds</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -402,7 +422,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>FeedReaderFeedItem</name>
|
<name>FeedReaderFeedItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/FeedReaderFeedItem.ui" line="+195"/>
|
<location filename="../gui/FeedReaderFeedItem.ui" line="+197"/>
|
||||||
<location filename="../gui/FeedReaderFeedItem.cpp" line="+116"/>
|
<location filename="../gui/FeedReaderFeedItem.cpp" line="+116"/>
|
||||||
<source>Expand</source>
|
<source>Expand</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -542,12 +562,22 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+122"/>
|
<location line="+127"/>
|
||||||
<source>The messages will be added to the forum</source>
|
<source>The messages will be added to the forum</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+15"/>
|
<location line="-3"/>
|
||||||
|
<source>The messages will be added to the forum and the board</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+6"/>
|
||||||
|
<source>The messages will be added to the board</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+17"/>
|
||||||
<source>No name</source>
|
<source>No name</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -659,12 +689,12 @@
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+3"/>
|
<location line="+3"/>
|
||||||
<location line="+96"/>
|
<location line="+108"/>
|
||||||
<source>Unknown</source>
|
<source>Unknown</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="-79"/>
|
<location line="-91"/>
|
||||||
<source>Internal download error</source>
|
<source>Internal download error</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -699,12 +729,7 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+3"/>
|
<location line="+6"/>
|
||||||
<source>Can't create forum</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location line="+3"/>
|
|
||||||
<source>Forum not found</source>
|
<source>Forum not found</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -718,6 +743,21 @@
|
||||||
<source>Forum has no author</source>
|
<source>Forum has no author</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+6"/>
|
||||||
|
<source>Board not found</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+3"/>
|
||||||
|
<source>You are not admin of the board</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+3"/>
|
||||||
|
<source>Board has no author</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+4"/>
|
<location line="+4"/>
|
||||||
<source>Can't read html</source>
|
<source>Can't read html</source>
|
||||||
|
@ -790,7 +830,7 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+47"/>
|
<location line="+55"/>
|
||||||
<source>Name:</source>
|
<source>Name:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -825,7 +865,7 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+20"/>
|
<location line="+28"/>
|
||||||
<source>Title:</source>
|
<source>Title:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "rsitems/rsconfigitems.h"
|
#include "rsitems/rsconfigitems.h"
|
||||||
#include "retroshare/rsiface.h"
|
#include "retroshare/rsiface.h"
|
||||||
#include "retroshare/rsgxsforums.h"
|
#include "retroshare/rsgxsforums.h"
|
||||||
|
#include "retroshare/rsposted.h"
|
||||||
#include "util/rsstring.h"
|
#include "util/rsstring.h"
|
||||||
#include "util/rstime.h"
|
#include "util/rstime.h"
|
||||||
#include "gxs/rsgenexchange.h"
|
#include "gxs/rsgenexchange.h"
|
||||||
|
@ -34,6 +35,7 @@ RsFeedReader *rsFeedReader = NULL;
|
||||||
|
|
||||||
#define FEEDREADER_CLEAN_INTERVAL 1 * 60 * 60 // check every hour
|
#define FEEDREADER_CLEAN_INTERVAL 1 * 60 * 60 // check every hour
|
||||||
#define FEEDREADER_FORUM_PREFIX "RSS: "
|
#define FEEDREADER_FORUM_PREFIX "RSS: "
|
||||||
|
#define FEEDREADER_POSTED_PREFIX "RSS: "
|
||||||
|
|
||||||
#define MAX_REQUEST_AGE 30 // 30 seconds
|
#define MAX_REQUEST_AGE 30 // 30 seconds
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ RsFeedReader *rsFeedReader = NULL;
|
||||||
* #define FEEDREADER_DEBUG
|
* #define FEEDREADER_DEBUG
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler, RsGxsForums *forums)
|
p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler, RsGxsForums *forums, RsPosted *posted)
|
||||||
: RsPQIService(RS_SERVICE_TYPE_PLUGIN_FEEDREADER, 5, pgHandler),
|
: RsPQIService(RS_SERVICE_TYPE_PLUGIN_FEEDREADER, 5, pgHandler),
|
||||||
mFeedReaderMtx("p3FeedReader"), mDownloadMutex("p3FeedReaderDownload"), mProcessMutex("p3FeedReaderProcess"), mPreviewMutex("p3FeedReaderPreview")
|
mFeedReaderMtx("p3FeedReader"), mDownloadMutex("p3FeedReaderDownload"), mProcessMutex("p3FeedReaderProcess"), mPreviewMutex("p3FeedReaderPreview")
|
||||||
{
|
{
|
||||||
|
@ -55,6 +57,7 @@ p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler, RsGxsForums *forums)
|
||||||
mStandardProxyPort = 0;
|
mStandardProxyPort = 0;
|
||||||
mLastClean = 0;
|
mLastClean = 0;
|
||||||
mForums = forums;
|
mForums = forums;
|
||||||
|
mPosted = posted;
|
||||||
mNotify = NULL;
|
mNotify = NULL;
|
||||||
mSaveInBackground = false;
|
mSaveInBackground = false;
|
||||||
mStopped = false;
|
mStopped = false;
|
||||||
|
@ -92,6 +95,7 @@ static void feedToInfo(const RsFeedReaderFeed *feed, FeedInfo &info)
|
||||||
info.updateInterval = feed->updateInterval;
|
info.updateInterval = feed->updateInterval;
|
||||||
info.lastUpdate = feed->lastUpdate;
|
info.lastUpdate = feed->lastUpdate;
|
||||||
info.forumId = feed->forumId;
|
info.forumId = feed->forumId;
|
||||||
|
info.postedId = feed->postedId;
|
||||||
info.storageTime = feed->storageTime;
|
info.storageTime = feed->storageTime;
|
||||||
info.errorState = feed->errorState;
|
info.errorState = feed->errorState;
|
||||||
info.errorString = feed->errorString;
|
info.errorString = feed->errorString;
|
||||||
|
@ -110,6 +114,10 @@ static void feedToInfo(const RsFeedReaderFeed *feed, FeedInfo &info)
|
||||||
info.flag.deactivated = (feed->flag & RS_FEED_FLAG_DEACTIVATED);
|
info.flag.deactivated = (feed->flag & RS_FEED_FLAG_DEACTIVATED);
|
||||||
info.flag.forum = (feed->flag & RS_FEED_FLAG_FORUM);
|
info.flag.forum = (feed->flag & RS_FEED_FLAG_FORUM);
|
||||||
info.flag.updateForumInfo = (feed->flag & RS_FEED_FLAG_UPDATE_FORUM_INFO);
|
info.flag.updateForumInfo = (feed->flag & RS_FEED_FLAG_UPDATE_FORUM_INFO);
|
||||||
|
info.flag.posted = (feed->flag & RS_FEED_FLAG_POSTED);
|
||||||
|
info.flag.updatePostedInfo = (feed->flag & RS_FEED_FLAG_UPDATE_POSTED_INFO);
|
||||||
|
info.flag.postedFirstImage = (feed->flag & RS_FEED_FLAG_POSTED_FIRST_IMAGE);
|
||||||
|
info.flag.postedOnlyImage = (feed->flag & RS_FEED_FLAG_POSTED_ONLY_IMAGE);
|
||||||
info.flag.embedImages = (feed->flag & RS_FEED_FLAG_EMBED_IMAGES);
|
info.flag.embedImages = (feed->flag & RS_FEED_FLAG_EMBED_IMAGES);
|
||||||
info.flag.saveCompletePage = (feed->flag & RS_FEED_FLAG_SAVE_COMPLETE_PAGE);
|
info.flag.saveCompletePage = (feed->flag & RS_FEED_FLAG_SAVE_COMPLETE_PAGE);
|
||||||
|
|
||||||
|
@ -151,6 +159,7 @@ static void infoToFeed(const FeedInfo &info, RsFeedReaderFeed *feed)
|
||||||
feed->storageTime = info.storageTime;
|
feed->storageTime = info.storageTime;
|
||||||
|
|
||||||
feed->forumId = info.forumId;
|
feed->forumId = info.forumId;
|
||||||
|
feed->postedId = info.postedId;
|
||||||
|
|
||||||
feed->transformationType = info.transformationType;
|
feed->transformationType = info.transformationType;
|
||||||
feed->xpathsToUse.ids = info.xpathsToUse;
|
feed->xpathsToUse.ids = info.xpathsToUse;
|
||||||
|
@ -193,6 +202,21 @@ static void infoToFeed(const FeedInfo &info, RsFeedReaderFeed *feed)
|
||||||
if (info.flag.updateForumInfo) {
|
if (info.flag.updateForumInfo) {
|
||||||
feed->flag |= RS_FEED_FLAG_UPDATE_FORUM_INFO;
|
feed->flag |= RS_FEED_FLAG_UPDATE_FORUM_INFO;
|
||||||
}
|
}
|
||||||
|
if (info.flag.posted) {
|
||||||
|
feed->flag |= RS_FEED_FLAG_POSTED;
|
||||||
|
}
|
||||||
|
if (info.flag.updatePostedInfo) {
|
||||||
|
feed->flag |= RS_FEED_FLAG_UPDATE_POSTED_INFO;
|
||||||
|
}
|
||||||
|
if (info.flag.updatePostedInfo) {
|
||||||
|
feed->flag |= RS_FEED_FLAG_UPDATE_POSTED_INFO;
|
||||||
|
}
|
||||||
|
if (info.flag.postedFirstImage) {
|
||||||
|
feed->flag |= RS_FEED_FLAG_POSTED_FIRST_IMAGE;
|
||||||
|
}
|
||||||
|
if (info.flag.postedOnlyImage) {
|
||||||
|
feed->flag |= RS_FEED_FLAG_POSTED_ONLY_IMAGE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void feedMsgToInfo(const RsFeedReaderMsg *msg, FeedMsgInfo &info)
|
static void feedMsgToInfo(const RsFeedReaderMsg *msg, FeedMsgInfo &info)
|
||||||
|
@ -478,6 +502,9 @@ RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
|
||||||
std::string forumId;
|
std::string forumId;
|
||||||
std::string forumName;
|
std::string forumName;
|
||||||
std::string forumDescription;
|
std::string forumDescription;
|
||||||
|
std::string postedId;
|
||||||
|
std::string postedName;
|
||||||
|
std::string postedDescription;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||||
|
@ -521,6 +548,7 @@ RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
|
||||||
|
|
||||||
RsFeedReaderFeed *fi = feedIt->second;
|
RsFeedReaderFeed *fi = feedIt->second;
|
||||||
std::string oldForumId = fi->forumId;
|
std::string oldForumId = fi->forumId;
|
||||||
|
std::string oldPostedId = fi->postedId;
|
||||||
std::string oldName = fi->name;
|
std::string oldName = fi->name;
|
||||||
std::string oldDescription = fi->description;
|
std::string oldDescription = fi->description;
|
||||||
|
|
||||||
|
@ -534,6 +562,15 @@ RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
|
||||||
forumDescription = fi->description;
|
forumDescription = fi->description;
|
||||||
forumName.insert(0, FEEDREADER_FORUM_PREFIX);
|
forumName.insert(0, FEEDREADER_FORUM_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((fi->flag & RS_FEED_FLAG_POSTED) && (fi->flag & RS_FEED_FLAG_UPDATE_POSTED_INFO) && !fi->postedId.empty() &&
|
||||||
|
(fi->postedId != oldPostedId || fi->name != oldName || fi->description != oldDescription)) {
|
||||||
|
/* name or description changed, update posted */
|
||||||
|
postedId = fi->postedId;
|
||||||
|
postedName = fi->name;
|
||||||
|
postedDescription = fi->description;
|
||||||
|
postedName.insert(0, FEEDREADER_POSTED_PREFIX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
@ -550,6 +587,14 @@ RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
|
||||||
//TODO: error
|
//TODO: error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!postedId.empty()) {
|
||||||
|
RsPostedGroup postedGroup;
|
||||||
|
if (getPostedGroup(RsGxsGroupId(postedId), postedGroup)) {
|
||||||
|
updatePostedGroup(postedGroup, postedName, postedDescription);
|
||||||
|
}
|
||||||
|
//TODO: error
|
||||||
|
}
|
||||||
|
|
||||||
return RS_FEED_ADD_RESULT_SUCCESS;
|
return RS_FEED_ADD_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,6 +727,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId)
|
||||||
fi->updateInterval = 0;
|
fi->updateInterval = 0;
|
||||||
fi->lastUpdate = 0;
|
fi->lastUpdate = 0;
|
||||||
fi->forumId.clear();
|
fi->forumId.clear();
|
||||||
|
fi->postedId.clear();
|
||||||
fi->storageTime = 0;
|
fi->storageTime = 0;
|
||||||
|
|
||||||
mFeeds[fi->feedId] = fi;
|
mFeeds[fi->feedId] = fi;
|
||||||
|
@ -1885,8 +1931,12 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
|
|
||||||
std::list<std::string> addedMsgs;
|
std::list<std::string> addedMsgs;
|
||||||
std::string forumId;
|
std::string forumId;
|
||||||
RsGxsId authorId;
|
RsGxsId forumAuthorId;
|
||||||
std::list<RsFeedReaderMsg> forumMsgs;
|
std::list<RsFeedReaderMsg> forumMsgs;
|
||||||
|
std::string postedId;
|
||||||
|
RsGxsId postedAuthorId;
|
||||||
|
std::list<RsFeedReaderMsg> postedMsgs;
|
||||||
|
uint32_t feedFlag = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||||
|
@ -1903,7 +1953,9 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
|
|
||||||
RsFeedReaderFeed *fi = it->second;
|
RsFeedReaderFeed *fi = it->second;
|
||||||
bool forum = (fi->flag & RS_FEED_FLAG_FORUM) && !fi->preview;
|
bool forum = (fi->flag & RS_FEED_FLAG_FORUM) && !fi->preview;
|
||||||
|
bool posted = (fi->flag & RS_FEED_FLAG_POSTED) && !fi->preview;
|
||||||
RsFeedReaderErrorState errorState = RS_FEED_ERRORSTATE_OK;
|
RsFeedReaderErrorState errorState = RS_FEED_ERRORSTATE_OK;
|
||||||
|
feedFlag = fi->flag;
|
||||||
|
|
||||||
if (forum && !msgs.empty()) {
|
if (forum && !msgs.empty()) {
|
||||||
if (mForums) {
|
if (mForums) {
|
||||||
|
@ -1913,9 +1965,9 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
if (getForumGroup(RsGxsGroupId(fi->forumId), forumGroup)) {
|
if (getForumGroup(RsGxsGroupId(fi->forumId), forumGroup)) {
|
||||||
if (IS_GROUP_PUBLISHER(forumGroup.mMeta.mSubscribeFlags) && IS_GROUP_ADMIN(forumGroup.mMeta.mSubscribeFlags)) {
|
if (IS_GROUP_PUBLISHER(forumGroup.mMeta.mSubscribeFlags) && IS_GROUP_ADMIN(forumGroup.mMeta.mSubscribeFlags)) {
|
||||||
forumId = fi->forumId;
|
forumId = fi->forumId;
|
||||||
authorId = forumGroup.mMeta.mAuthorId;
|
forumAuthorId = forumGroup.mMeta.mAuthorId;
|
||||||
|
|
||||||
if (authorId.isNull()) {
|
if (forumAuthorId.isNull()) {
|
||||||
errorState = RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR;
|
errorState = RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1933,6 +1985,34 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (posted && !msgs.empty()) {
|
||||||
|
if (mPosted) {
|
||||||
|
if (!fi->postedId.empty()) {
|
||||||
|
/* check posted */
|
||||||
|
RsPostedGroup postedGroup;
|
||||||
|
if (getPostedGroup(RsGxsGroupId(fi->postedId), postedGroup)) {
|
||||||
|
if (IS_GROUP_PUBLISHER(postedGroup.mMeta.mSubscribeFlags) && IS_GROUP_ADMIN(postedGroup.mMeta.mSubscribeFlags)) {
|
||||||
|
postedId = fi->postedId;
|
||||||
|
postedAuthorId = postedGroup.mMeta.mAuthorId;
|
||||||
|
|
||||||
|
if (postedAuthorId.isNull()) {
|
||||||
|
errorState = RS_FEED_ERRORSTATE_PROCESS_POSTED_NO_AUTHOR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorState = RS_FEED_ERRORSTATE_PROCESS_POSTED_NO_ADMIN;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorState = RS_FEED_ERRORSTATE_PROCESS_POSTED_NOT_FOUND;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - posted id is empty (" << fi->name << ")" << std::endl;
|
||||||
|
errorState = RS_FEED_ERRORSTATE_PROCESS_POSTED_NOT_FOUND;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process posted, member mPosted is not set" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* process msgs */
|
/* process msgs */
|
||||||
if (errorState == RS_FEED_ERRORSTATE_OK) {
|
if (errorState == RS_FEED_ERRORSTATE_OK) {
|
||||||
/* process msgs */
|
/* process msgs */
|
||||||
|
@ -1949,9 +2029,14 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
} else {
|
} else {
|
||||||
rs_sprintf(miNew->msgId, "%lu", mNextMsgId++);
|
rs_sprintf(miNew->msgId, "%lu", mNextMsgId++);
|
||||||
}
|
}
|
||||||
if (forum) {
|
if (forum || posted) {
|
||||||
miNew->flag = RS_FEEDMSG_FLAG_DELETED;
|
miNew->flag = RS_FEEDMSG_FLAG_DELETED;
|
||||||
|
if (forum) {
|
||||||
forumMsgs.push_back(*miNew);
|
forumMsgs.push_back(*miNew);
|
||||||
|
}
|
||||||
|
if (posted) {
|
||||||
|
postedMsgs.push_back(*miNew);
|
||||||
|
}
|
||||||
miNew->description.clear();
|
miNew->description.clear();
|
||||||
miNew->descriptionTransformed.clear();
|
miNew->descriptionTransformed.clear();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1996,7 +2081,7 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
RsGxsForumMsg forumMsg;
|
RsGxsForumMsg forumMsg;
|
||||||
forumMsg.mMeta.mGroupId = RsGxsGroupId(forumId);
|
forumMsg.mMeta.mGroupId = RsGxsGroupId(forumId);
|
||||||
forumMsg.mMeta.mMsgName = mi.title;
|
forumMsg.mMeta.mMsgName = mi.title;
|
||||||
forumMsg.mMeta.mAuthorId = authorId;
|
forumMsg.mMeta.mAuthorId = forumAuthorId;
|
||||||
|
|
||||||
std::string description = mi.descriptionTransformed.empty() ? mi.description : mi.descriptionTransformed;
|
std::string description = mi.descriptionTransformed.empty() ? mi.description : mi.descriptionTransformed;
|
||||||
/* add link */
|
/* add link */
|
||||||
|
@ -2006,7 +2091,7 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
forumMsg.mMsg = description;
|
forumMsg.mMsg = description;
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
if (mForums->createMsg(token, forumMsg) && waitForToken(token)) {
|
if (mForums->createMsg(token, forumMsg) && waitForToken(mForums, token)) {
|
||||||
RsGxsGrpMsgIdPair msgPair;
|
RsGxsGrpMsgIdPair msgPair;
|
||||||
if (mForums->acknowledgeMsg(token, msgPair)) {
|
if (mForums->acknowledgeMsg(token, msgPair)) {
|
||||||
/* set to new */
|
/* set to new */
|
||||||
|
@ -2026,6 +2111,67 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedRea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!postedId.empty() && !postedMsgs.empty()) {
|
||||||
|
if (mPosted) {
|
||||||
|
/* a bit tricky */
|
||||||
|
RsGenExchange *genExchange = dynamic_cast<RsGenExchange*>(mPosted);
|
||||||
|
if (genExchange) {
|
||||||
|
/* add messages as posted messages */
|
||||||
|
std::list<RsFeedReaderMsg>::iterator msgIt;
|
||||||
|
for (msgIt = postedMsgs.begin(); msgIt != postedMsgs.end(); ++msgIt) {
|
||||||
|
RsFeedReaderMsg &mi = *msgIt;
|
||||||
|
|
||||||
|
/* convert to posted messages */
|
||||||
|
RsPostedPost postedPost;
|
||||||
|
postedPost.mMeta.mGroupId = RsGxsGroupId(postedId);
|
||||||
|
postedPost.mMeta.mMsgName = mi.title;
|
||||||
|
postedPost.mMeta.mAuthorId = postedAuthorId;
|
||||||
|
postedPost.mLink = mi.link;
|
||||||
|
|
||||||
|
std::string description;
|
||||||
|
if (feedFlag & RS_FEED_FLAG_POSTED_FIRST_IMAGE) {
|
||||||
|
if (!mi.postedFirstImage.empty()) {
|
||||||
|
/* use first image as image for posted and description without image as notes */
|
||||||
|
postedPost.mImage.copy(mi.postedFirstImage.data(), mi.postedFirstImage.size());
|
||||||
|
if (feedFlag & RS_FEED_FLAG_POSTED_ONLY_IMAGE) {
|
||||||
|
/* ignore description */
|
||||||
|
} else {
|
||||||
|
description = mi.postedDescriptionWithoutFirstImage;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (feedFlag & RS_FEED_FLAG_POSTED_ONLY_IMAGE) {
|
||||||
|
/* ignore messages without image */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
description = mi.descriptionTransformed.empty() ? mi.description : mi.descriptionTransformed;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
description = mi.descriptionTransformed.empty() ? mi.description : mi.descriptionTransformed;
|
||||||
|
}
|
||||||
|
|
||||||
|
postedPost.mNotes = description;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (mPosted->createPost(token, postedPost) && waitForToken(mPosted, token)) {
|
||||||
|
RsGxsGrpMsgIdPair msgPair;
|
||||||
|
if (mPosted->acknowledgeMsg(token, msgPair)) {
|
||||||
|
/* set to new */
|
||||||
|
genExchange->setMsgStatusFlags(token, msgPair, GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD, GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#ifdef FEEDREADER_DEBUG
|
||||||
|
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't add posted message " << mi.title << " for feed " << postedId << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process posted, member mPosted is not derived from RsGenExchange" << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process posted, member mPosted is not set" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mNotify) {
|
if (mNotify) {
|
||||||
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD);
|
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD);
|
||||||
|
|
||||||
|
@ -2080,6 +2226,9 @@ void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const s
|
||||||
std::string forumId;
|
std::string forumId;
|
||||||
std::string forumName;
|
std::string forumName;
|
||||||
std::string forumDescription;
|
std::string forumDescription;
|
||||||
|
std::string postedId;
|
||||||
|
std::string postedName;
|
||||||
|
std::string postedDescription;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||||
|
@ -2118,6 +2267,14 @@ void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const s
|
||||||
forumDescription = fi->description;
|
forumDescription = fi->description;
|
||||||
forumName.insert(0, FEEDREADER_FORUM_PREFIX);
|
forumName.insert(0, FEEDREADER_FORUM_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((fi->flag & RS_FEED_FLAG_POSTED) && (fi->flag & RS_FEED_FLAG_UPDATE_POSTED_INFO) && !fi->postedId.empty() && !preview) {
|
||||||
|
/* change posted too */
|
||||||
|
postedId = fi->postedId;
|
||||||
|
postedName = fi->name;
|
||||||
|
postedDescription = fi->description;
|
||||||
|
postedName.insert(0, FEEDREADER_POSTED_PREFIX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
@ -2137,6 +2294,14 @@ void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const s
|
||||||
}
|
}
|
||||||
//TODO: error
|
//TODO: error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!postedId.empty()) {
|
||||||
|
RsPostedGroup postedGroup;
|
||||||
|
if (getPostedGroup(RsGxsGroupId(postedId), postedGroup)) {
|
||||||
|
updatePostedGroup(postedGroup, postedName, postedDescription);
|
||||||
|
}
|
||||||
|
//TODO: error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3FeedReader::getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &forumGroup)
|
bool p3FeedReader::getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &forumGroup)
|
||||||
|
@ -2159,7 +2324,7 @@ bool p3FeedReader::getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &f
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mForums->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds);
|
mForums->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds);
|
||||||
|
|
||||||
if (!waitForToken(token)) {
|
if (!waitForToken(mForums, token)) {
|
||||||
std::cerr << "p3FeedReader::getForumGroup - waitForToken for request failed" << std::endl;
|
std::cerr << "p3FeedReader::getForumGroup - waitForToken for request failed" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2202,7 +2367,7 @@ bool p3FeedReader::updateForumGroup(const RsGxsForumGroup &forumGroup, const std
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!waitForToken(token)) {
|
if (!waitForToken(mForums, token)) {
|
||||||
std::cerr << "p3FeedReader::updateForumGroup - waitForToken for update failed" << std::endl;
|
std::cerr << "p3FeedReader::updateForumGroup - waitForToken for update failed" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2211,13 +2376,85 @@ bool p3FeedReader::updateForumGroup(const RsGxsForumGroup &forumGroup, const std
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3FeedReader::waitForToken(uint32_t token)
|
bool p3FeedReader::getPostedGroup(const RsGxsGroupId &groupId, RsPostedGroup &postedGroup)
|
||||||
{
|
{
|
||||||
if (!mForums) {
|
if (!mPosted) {
|
||||||
|
std::cerr << "p3FeedReader::getPostedGroup - can't get posted group " << groupId.toStdString() << ", member mPosted is not set" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsTokenService *service = mForums->getTokenService();
|
if (groupId.isNull()) {
|
||||||
|
std::cerr << "p3FeedReader::getPostedGroup - group id is not valid" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> grpIds;
|
||||||
|
grpIds.push_back(groupId);
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
|
uint32_t token;
|
||||||
|
mPosted->getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds);
|
||||||
|
|
||||||
|
if (!waitForToken(mPosted, token)) {
|
||||||
|
std::cerr << "p3FeedReader::getPostedGroup - waitForToken for request failed" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<RsPostedGroup> groups;
|
||||||
|
if (!mPosted->getGroupData(token, groups)) {
|
||||||
|
std::cerr << "p3FeedReader::getPostedGroup - Error getting data" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groups.size() != 1) {
|
||||||
|
std::cerr << "p3FeedReader::getPostedGroup - Wrong number of items" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
postedGroup = groups[0];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3FeedReader::updatePostedGroup(const RsPostedGroup &postedGroup, const std::string &groupName, const std::string &groupDescription)
|
||||||
|
{
|
||||||
|
if (!mPosted) {
|
||||||
|
std::cerr << "p3FeedReader::updatePostedGroup - can't change posted " << postedGroup.mMeta.mGroupId.toStdString() << ", member mPosted is not set" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (postedGroup.mMeta.mGroupName == groupName && postedGroup.mDescription == groupDescription) {
|
||||||
|
/* No change */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsPostedGroup newPostedGroup = postedGroup;
|
||||||
|
newPostedGroup.mMeta.mGroupName = groupName;
|
||||||
|
newPostedGroup.mDescription = groupDescription;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (!mPosted->updateGroup(token, newPostedGroup)) {
|
||||||
|
std::cerr << "p3FeedReader::updatePostedGroup - can't change posted " << newPostedGroup.mMeta.mGroupId.toStdString() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!waitForToken(mPosted, token)) {
|
||||||
|
std::cerr << "p3FeedReader::updatePostedGroup - waitForToken for update failed" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Posted updated */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3FeedReader::waitForToken(RsGxsIfaceHelper *interface, uint32_t token)
|
||||||
|
{
|
||||||
|
if (!interface) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsTokenService *service = interface->getTokenService();
|
||||||
int count = MAX_REQUEST_AGE * 2;
|
int count = MAX_REQUEST_AGE * 2;
|
||||||
|
|
||||||
while (!mStopped) {
|
while (!mStopped) {
|
||||||
|
|
|
@ -33,11 +33,14 @@ class p3FeedReaderThread;
|
||||||
|
|
||||||
class RsGxsForums;
|
class RsGxsForums;
|
||||||
struct RsGxsForumGroup;
|
struct RsGxsForumGroup;
|
||||||
|
class RsPosted;
|
||||||
|
struct RsPostedGroup;
|
||||||
|
class RsGxsIfaceHelper;
|
||||||
|
|
||||||
class p3FeedReader : public RsPQIService, public RsFeedReader
|
class p3FeedReader : public RsPQIService, public RsFeedReader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
p3FeedReader(RsPluginHandler *pgHandler, RsGxsForums *forums);
|
p3FeedReader(RsPluginHandler *pgHandler, RsGxsForums *forums, RsPosted *posted);
|
||||||
|
|
||||||
/****************** FeedReader Interface *************/
|
/****************** FeedReader Interface *************/
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
@ -92,7 +95,9 @@ public:
|
||||||
|
|
||||||
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);
|
||||||
bool waitForToken(uint32_t token);
|
bool getPostedGroup(const RsGxsGroupId &groupId, RsPostedGroup &postedGroup);
|
||||||
|
bool updatePostedGroup(const RsPostedGroup &postedGroup, const std::string &groupName, const std::string &groupDescription);
|
||||||
|
bool waitForToken(RsGxsIfaceHelper *interface, uint32_t token);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/****************** p3Config STUFF *******************/
|
/****************** p3Config STUFF *******************/
|
||||||
|
@ -109,6 +114,7 @@ private:
|
||||||
private:
|
private:
|
||||||
time_t mLastClean;
|
time_t mLastClean;
|
||||||
RsGxsForums *mForums;
|
RsGxsForums *mForums;
|
||||||
|
RsPosted *mPosted;
|
||||||
RsFeedReaderNotify *mNotify;
|
RsFeedReaderNotify *mNotify;
|
||||||
volatile bool mStopped;
|
volatile bool mStopped;
|
||||||
|
|
||||||
|
|
|
@ -1076,12 +1076,15 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||||
|
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
/* process description */
|
/* process description */
|
||||||
|
bool processPostedFirstImage = (feed.flag & RS_FEED_FLAG_POSTED_FIRST_IMAGE) ? TRUE : FALSE;
|
||||||
|
|
||||||
//long todo; // encoding
|
//long todo; // encoding
|
||||||
HTMLWrapper html;
|
HTMLWrapper html;
|
||||||
if (html.readHTML(msg->description.c_str(), url.c_str())) {
|
if (html.readHTML(msg->description.c_str(), url.c_str())) {
|
||||||
xmlNodePtr root = html.getRootElement();
|
xmlNodePtr root = html.getRootElement();
|
||||||
if (root) {
|
if (root) {
|
||||||
std::list<xmlNodePtr> nodesToDelete;
|
std::list<xmlNodePtr> nodesToDelete;
|
||||||
|
xmlNodePtr postedFirstImageNode = NULL;
|
||||||
|
|
||||||
/* process all children */
|
/* process all children */
|
||||||
std::list<xmlNodePtr> nodes;
|
std::list<xmlNodePtr> nodes;
|
||||||
|
@ -1212,6 +1215,12 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||||
rs_sprintf(imageBase64, "data:%s;base64,%s", contentType.c_str(), base64.c_str());
|
rs_sprintf(imageBase64, "data:%s;base64,%s", contentType.c_str(), base64.c_str());
|
||||||
if (html.setAttr(node, "src", imageBase64.c_str())) {
|
if (html.setAttr(node, "src", imageBase64.c_str())) {
|
||||||
removeImage = false;
|
removeImage = false;
|
||||||
|
|
||||||
|
if (processPostedFirstImage && postedFirstImageNode == NULL) {
|
||||||
|
/* set first image */
|
||||||
|
msg->postedFirstImage = data;
|
||||||
|
postedFirstImageNode = node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1247,7 +1256,22 @@ RsFeedReaderErrorState p3FeedReaderThread::processMsg(const RsFeedReaderFeed &fe
|
||||||
|
|
||||||
if (result == RS_FEED_ERRORSTATE_OK) {
|
if (result == RS_FEED_ERRORSTATE_OK) {
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
if (!html.saveHTML(msg->description)) {
|
if (html.saveHTML(msg->description)) {
|
||||||
|
if (postedFirstImageNode) {
|
||||||
|
/* Remove first image and create description without the image */
|
||||||
|
xmlUnlinkNode(postedFirstImageNode);
|
||||||
|
xmlFreeNode(postedFirstImageNode);
|
||||||
|
|
||||||
|
if (!html.saveHTML(msg->postedDescriptionWithoutFirstImage)) {
|
||||||
|
errorString = html.lastError();
|
||||||
|
#ifdef FEEDREADER_DEBUG
|
||||||
|
std::cerr << "p3FeedReaderThread::processHTML - feed " << feed.feedId << " (" << feed.name << ") cannot dump html" << std::endl;
|
||||||
|
std::cerr << " Error: " << errorString << std::endl;
|
||||||
|
#endif
|
||||||
|
result = RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
errorString = html.lastError();
|
errorString = html.lastError();
|
||||||
#ifdef FEEDREADER_DEBUG
|
#ifdef FEEDREADER_DEBUG
|
||||||
std::cerr << "p3FeedReaderThread::processHTML - feed " << feed.feedId << " (" << feed.name << ") cannot dump html" << std::endl;
|
std::cerr << "p3FeedReaderThread::processHTML - feed " << feed.feedId << " (" << feed.name << ") cannot dump html" << std::endl;
|
||||||
|
|
|
@ -46,6 +46,7 @@ void RsFeedReaderFeed::clear()
|
||||||
storageTime = 0;
|
storageTime = 0;
|
||||||
flag = 0;
|
flag = 0;
|
||||||
forumId.clear();
|
forumId.clear();
|
||||||
|
postedId.clear();
|
||||||
description.clear();
|
description.clear();
|
||||||
icon.clear();
|
icon.clear();
|
||||||
errorState = RS_FEED_ERRORSTATE_OK;
|
errorState = RS_FEED_ERRORSTATE_OK;
|
||||||
|
@ -85,6 +86,7 @@ uint32_t RsFeedReaderSerialiser::sizeFeed(RsFeedReaderFeed *item)
|
||||||
s += item->xpathsToUse.TlvSize();
|
s += item->xpathsToUse.TlvSize();
|
||||||
s += item->xpathsToRemove.TlvSize();
|
s += item->xpathsToRemove.TlvSize();
|
||||||
s += GetTlvStringSize(item->xslt);
|
s += GetTlvStringSize(item->xslt);
|
||||||
|
s += GetTlvStringSize(item->postedId);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +110,7 @@ bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, u
|
||||||
offset += 8;
|
offset += 8;
|
||||||
|
|
||||||
/* add values */
|
/* add values */
|
||||||
ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */
|
ok &= setRawUInt16(data, tlvsize, &offset, 3); /* version */
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->feedId);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->feedId);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, 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);
|
||||||
|
@ -124,6 +126,7 @@ bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, u
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->storageTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->storageTime);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
||||||
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->postedId);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->errorState);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->errorState);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->errorString);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->errorString);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->transformationType);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->transformationType);
|
||||||
|
@ -208,6 +211,9 @@ RsFeedReaderFeed *RsFeedReaderSerialiser::deserialiseFeed(void *data, uint32_t *
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->storageTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->storageTime));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
||||||
|
if (version >= 3) {
|
||||||
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->postedId);
|
||||||
|
}
|
||||||
uint32_t errorState = 0;
|
uint32_t errorState = 0;
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &errorState);
|
ok &= getRawUInt32(data, rssize, &offset, &errorState);
|
||||||
item->errorState = (RsFeedReaderErrorState) errorState;
|
item->errorState = (RsFeedReaderErrorState) errorState;
|
||||||
|
|
|
@ -34,17 +34,21 @@ const uint8_t RS_PKT_SUBTYPE_FEEDREADER_MSG = 0x03;
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#define RS_FEED_FLAG_FOLDER 0x001
|
#define RS_FEED_FLAG_FOLDER 0x0001
|
||||||
#define RS_FEED_FLAG_INFO_FROM_FEED 0x002
|
#define RS_FEED_FLAG_INFO_FROM_FEED 0x0002
|
||||||
#define RS_FEED_FLAG_STANDARD_STORAGE_TIME 0x004
|
#define RS_FEED_FLAG_STANDARD_STORAGE_TIME 0x0004
|
||||||
#define RS_FEED_FLAG_STANDARD_UPDATE_INTERVAL 0x008
|
#define RS_FEED_FLAG_STANDARD_UPDATE_INTERVAL 0x0008
|
||||||
#define RS_FEED_FLAG_STANDARD_PROXY 0x010
|
#define RS_FEED_FLAG_STANDARD_PROXY 0x0010
|
||||||
#define RS_FEED_FLAG_AUTHENTICATION 0x020
|
#define RS_FEED_FLAG_AUTHENTICATION 0x0020
|
||||||
#define RS_FEED_FLAG_DEACTIVATED 0x040
|
#define RS_FEED_FLAG_DEACTIVATED 0x0040
|
||||||
#define RS_FEED_FLAG_FORUM 0x080
|
#define RS_FEED_FLAG_FORUM 0x0080
|
||||||
#define RS_FEED_FLAG_UPDATE_FORUM_INFO 0x100
|
#define RS_FEED_FLAG_UPDATE_FORUM_INFO 0x0100
|
||||||
#define RS_FEED_FLAG_EMBED_IMAGES 0x200
|
#define RS_FEED_FLAG_EMBED_IMAGES 0x0200
|
||||||
#define RS_FEED_FLAG_SAVE_COMPLETE_PAGE 0x400
|
#define RS_FEED_FLAG_SAVE_COMPLETE_PAGE 0x0400
|
||||||
|
#define RS_FEED_FLAG_POSTED 0x0800
|
||||||
|
#define RS_FEED_FLAG_UPDATE_POSTED_INFO 0x1000
|
||||||
|
#define RS_FEED_FLAG_POSTED_FIRST_IMAGE 0x2000
|
||||||
|
#define RS_FEED_FLAG_POSTED_ONLY_IMAGE 0x4000
|
||||||
|
|
||||||
class RsFeedReaderFeed : public RsItem
|
class RsFeedReaderFeed : public RsItem
|
||||||
{
|
{
|
||||||
|
@ -76,6 +80,7 @@ public:
|
||||||
time_t lastUpdate;
|
time_t lastUpdate;
|
||||||
uint32_t flag; // RS_FEED_FLAG_...
|
uint32_t flag; // RS_FEED_FLAG_...
|
||||||
std::string forumId;
|
std::string forumId;
|
||||||
|
std::string postedId;
|
||||||
uint32_t storageTime;
|
uint32_t storageTime;
|
||||||
std::string description;
|
std::string description;
|
||||||
std::string icon;
|
std::string icon;
|
||||||
|
@ -118,6 +123,10 @@ public:
|
||||||
std::string descriptionTransformed;
|
std::string descriptionTransformed;
|
||||||
time_t pubDate;
|
time_t pubDate;
|
||||||
uint32_t flag; // RS_FEEDMSG_FLAG_...
|
uint32_t flag; // RS_FEEDMSG_FLAG_...
|
||||||
|
|
||||||
|
// Only in memory when receiving messages
|
||||||
|
std::vector<unsigned char> postedFirstImage;
|
||||||
|
std::string postedDescriptionWithoutFirstImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsFeedReaderSerialiser: public RsSerialType
|
class RsFeedReaderSerialiser: public RsSerialType
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue