Deactivated code for old forum handling in FeedReader plugin

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7091 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-02-04 22:06:33 +00:00
parent 98e4271695
commit cedbd051ac
4 changed files with 127 additions and 106 deletions

View file

@ -113,7 +113,8 @@ FeedNotify *FeedReaderPlugin::qt_feedNotify()
RsPQIService *FeedReaderPlugin::rs_pqi_service() const RsPQIService *FeedReaderPlugin::rs_pqi_service() const
{ {
if (mFeedReader == NULL) { if (mFeedReader == NULL) {
mFeedReader = new p3FeedReader(mPlugInHandler, mInterfaces.mForums); //Todo: Replace with gxs forums
mFeedReader = new p3FeedReader(mPlugInHandler, NULL /*mInterfaces.mForums*/);
rsFeedReader = mFeedReader; rsFeedReader = mFeedReader;
mNotify = new FeedReaderNotify(); mNotify = new FeedReaderNotify();

View file

@ -29,12 +29,13 @@
#include "FeedReaderStringDefs.h" #include "FeedReaderStringDefs.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "retroshare/rsforums.h" //Todo: Replace with gxs forums
//#include "retroshare/rsforums.h"
bool sortForumInfo(const ForumInfo& info1, const ForumInfo& info2) //bool sortForumInfo(const ForumInfo& info1, const ForumInfo& info2)
{ //{
return QString::fromStdWString(info1.forumName).compare(QString::fromStdWString(info2.forumName), Qt::CaseInsensitive); // return QString::fromStdWString(info1.forumName).compare(QString::fromStdWString(info2.forumName), Qt::CaseInsensitive);
} //}
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)
@ -81,17 +82,18 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
ui->transformationTypeLabel->setText(FeedReaderStringDefs::transforationTypeString(mTransformationType)); ui->transformationTypeLabel->setText(FeedReaderStringDefs::transforationTypeString(mTransformationType));
/* fill own forums */ /* fill own forums */
std::list<ForumInfo> forumList; //Todo: Replace with gxs forums
if (rsForums->getForumList(forumList)) { // std::list<ForumInfo> forumList;
forumList.sort(sortForumInfo); // if (rsForums->getForumList(forumList)) {
for (std::list<ForumInfo>::iterator it = forumList.begin(); it != forumList.end(); ++it) { // forumList.sort(sortForumInfo);
ForumInfo &forumInfo = *it; // for (std::list<ForumInfo>::iterator it = forumList.begin(); it != forumList.end(); ++it) {
/* show only own anonymous forums */ // ForumInfo &forumInfo = *it;
if ((forumInfo.subscribeFlags & RS_DISTRIB_ADMIN) && (forumInfo.forumFlags & RS_DISTRIB_AUTHEN_ANON)) { // /* show only own anonymous forums */
ui->forumComboBox->addItem(QString::fromStdWString(forumInfo.forumName), QString::fromStdString(forumInfo.forumId)); // if ((forumInfo.subscribeFlags & RS_DISTRIB_ADMIN) && (forumInfo.forumFlags & RS_DISTRIB_AUTHEN_ANON)) {
} // ui->forumComboBox->addItem(QString::fromStdWString(forumInfo.forumName), QString::fromStdString(forumInfo.forumId));
} // }
} // }
// }
/* insert item to create a new forum */ /* insert item to create a new forum */
ui->forumComboBox->insertItem(0, tr("Create a new anonymous public forum"), ""); ui->forumComboBox->insertItem(0, tr("Create a new anonymous public forum"), "");
ui->forumComboBox->setCurrentIndex(0); ui->forumComboBox->setCurrentIndex(0);
@ -102,6 +104,9 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
/* load settings */ /* load settings */
processSettings(true); processSettings(true);
//Todo: Replace with gxs forums
ui->typeForumRadio->setEnabled(false);
} }
AddFeedDialog::~AddFeedDialog() AddFeedDialog::~AddFeedDialog()
@ -236,12 +241,13 @@ bool AddFeedDialog::fillFeed(const std::string &feedId)
if (feedInfo.forumId.empty()) { if (feedInfo.forumId.empty()) {
ui->forumNameLabel->setText(tr("Not yet created")); ui->forumNameLabel->setText(tr("Not yet created"));
} else { } else {
ForumInfo forumInfo; //Todo: Replace with gxs forums
if (rsForums->getForumInfo(feedInfo.forumId, forumInfo)) { // ForumInfo forumInfo;
ui->forumNameLabel->setText(QString::fromStdWString(forumInfo.forumName)); // if (rsForums->getForumInfo(feedInfo.forumId, forumInfo)) {
} else { // ui->forumNameLabel->setText(QString::fromStdWString(forumInfo.forumName));
ui->forumNameLabel->setText(tr("Unknown forum")); // } else {
} // ui->forumNameLabel->setText(tr("Unknown forum"));
// }
} }
} else { } else {
ui->typeLocalRadio->setChecked(true); ui->typeLocalRadio->setChecked(true);

View file

@ -24,7 +24,8 @@
#include "p3FeedReaderThread.h" #include "p3FeedReaderThread.h"
#include "serialiser/rsconfigitems.h" #include "serialiser/rsconfigitems.h"
#include "retroshare/rsiface.h" #include "retroshare/rsiface.h"
#include "retroshare/rsforums.h" //Todo: Replace with gxs forums
//#include "retroshare/rsforums.h"
#include "util/rsstring.h" #include "util/rsstring.h"
RsFeedReader *rsFeedReader = NULL; RsFeedReader *rsFeedReader = NULL;
@ -461,7 +462,8 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo &feedInfo) RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo &feedInfo)
{ {
std::string forumId; std::string forumId;
ForumInfo forumInfo; //Todo: Replace with gxs forums
// ForumInfo forumInfo;
{ {
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -509,14 +511,15 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo
infoToFeed(feedInfo, fi, false); infoToFeed(feedInfo, fi, false);
if ((fi->flag & RS_FEED_FLAG_FORUM) && (fi->flag & RS_FEED_FLAG_UPDATE_FORUM_INFO) && !fi->forumId.empty() && //Todo: Replace with gxs forums
(fi->name != oldName || fi->description != oldDescription)) { // if ((fi->flag & RS_FEED_FLAG_FORUM) && (fi->flag & RS_FEED_FLAG_UPDATE_FORUM_INFO) && !fi->forumId.empty() &&
/* name or description changed, update forum */ // (fi->name != oldName || fi->description != oldDescription)) {
forumId = fi->forumId; // /* name or description changed, update forum */
librs::util::ConvertUtf8ToUtf16(fi->name, forumInfo.forumName); // forumId = fi->forumId;
librs::util::ConvertUtf8ToUtf16(fi->description, forumInfo.forumDesc); // librs::util::ConvertUtf8ToUtf16(fi->name, forumInfo.forumName);
forumInfo.forumName.insert(0, FEEDREADER_FORUM_PREFIX); // librs::util::ConvertUtf8ToUtf16(fi->description, forumInfo.forumDesc);
} // forumInfo.forumName.insert(0, FEEDREADER_FORUM_PREFIX);
// }
} }
IndicateConfigChanged(); IndicateConfigChanged();
@ -525,18 +528,19 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD);
} }
if (!forumId.empty()) { //Todo: Replace with gxs forums
if (mForums) { // if (!forumId.empty()) {
/* name or description changed, update forum */ // if (mForums) {
if (!mForums->setForumInfo(forumId, forumInfo)) { // /* name or description changed, update forum */
#ifdef FEEDREADER_DEBUG // if (!mForums->setForumInfo(forumId, forumInfo)) {
std::cerr << "p3FeedReader::setFeed - can't change forum " << forumId << std::endl; //#ifdef FEEDREADER_DEBUG
#endif // std::cerr << "p3FeedReader::setFeed - can't change forum " << forumId << std::endl;
} //#endif
} else { // }
std::cerr << "p3FeedReader::setFeed - can't change forum " << forumId << ", member mForums is not set" << std::endl; // } else {
} // std::cerr << "p3FeedReader::setFeed - can't change forum " << forumId << ", member mForums is not set" << std::endl;
} // }
// }
return RS_FEED_ADD_RESULT_SUCCESS; return RS_FEED_ADD_RESULT_SUCCESS;
} }
@ -1840,6 +1844,8 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
bool forum = (fi->flag & RS_FEED_FLAG_FORUM) && !fi->preview; bool forum = (fi->flag & RS_FEED_FLAG_FORUM) && !fi->preview;
RsFeedReaderErrorState errorState = RS_FEED_ERRORSTATE_OK; RsFeedReaderErrorState errorState = RS_FEED_ERRORSTATE_OK;
//Todo: Replace with gxs forums
#if 0
if (forum && !msgs.empty()) { if (forum && !msgs.empty()) {
if (mForums) { if (mForums) {
if (fi->forumId.empty()) { if (fi->forumId.empty()) {
@ -1896,6 +1902,7 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process forum, member mForums is not set" << std::endl; std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process forum, member mForums is not set" << std::endl;
} }
} }
#endif
/* process msgs */ /* process msgs */
if (errorState == RS_FEED_ERRORSTATE_OK) { if (errorState == RS_FEED_ERRORSTATE_OK) {
@ -1946,38 +1953,39 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
} }
} }
if (!forumId.empty() && !forumMsgs.empty()) { //Todo: Replace with gxs forums
if (mForums) { // if (!forumId.empty() && !forumMsgs.empty()) {
/* add messages as forum messages */ // if (mForums) {
std::list<RsFeedReaderMsg>::iterator msgIt; // /* add messages as forum messages */
for (msgIt = forumMsgs.begin(); msgIt != forumMsgs.end(); ++msgIt) { // std::list<RsFeedReaderMsg>::iterator msgIt;
RsFeedReaderMsg &mi = *msgIt; // for (msgIt = forumMsgs.begin(); msgIt != forumMsgs.end(); ++msgIt) {
// RsFeedReaderMsg &mi = *msgIt;
/* convert to forum messages */ // /* convert to forum messages */
ForumMsgInfo forumMsgInfo; // ForumMsgInfo forumMsgInfo;
forumMsgInfo.forumId = forumId; // forumMsgInfo.forumId = forumId;
librs::util::ConvertUtf8ToUtf16(mi.title, forumMsgInfo.title); // librs::util::ConvertUtf8ToUtf16(mi.title, forumMsgInfo.title);
std::string description = mi.descriptionTransformed.empty() ? mi.description : mi.descriptionTransformed; // std::string description = mi.descriptionTransformed.empty() ? mi.description : mi.descriptionTransformed;
/* add link */ // /* add link */
if (!mi.link.empty()) { // if (!mi.link.empty()) {
description += "<br><a href=\"" + mi.link + "\">" + mi.link + "</a>"; // description += "<br><a href=\"" + mi.link + "\">" + mi.link + "</a>";
} // }
librs::util::ConvertUtf8ToUtf16(description, forumMsgInfo.msg); // librs::util::ConvertUtf8ToUtf16(description, forumMsgInfo.msg);
if (mForums->ForumMessageSend(forumMsgInfo)) { // if (mForums->ForumMessageSend(forumMsgInfo)) {
/* set to new */ // /* set to new */
mForums->setMessageStatus(forumMsgInfo.forumId, forumMsgInfo.msgId, 0, FORUM_MSG_STATUS_MASK); // mForums->setMessageStatus(forumMsgInfo.forumId, forumMsgInfo.msgId, 0, FORUM_MSG_STATUS_MASK);
} else { // } else {
#ifdef FEEDREADER_DEBUG //#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::onProcessSuccess_filterMsg - can't add forum message " << mi.title << " for feed " << forumId << std::endl; // std::cerr << "p3FeedReader::onProcessSuccess_filterMsg - can't add forum message " << mi.title << " for feed " << forumId << std::endl;
#endif //#endif
} // }
} // }
} else { // } else {
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process forum, member mForums is not set" << std::endl; // std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - can't process forum, member mForums is not set" << std::endl;
} // }
} // }
if (mNotify) { if (mNotify) {
mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD);
@ -2031,7 +2039,8 @@ void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &nam
bool changed = false; bool changed = false;
bool preview; bool preview;
std::string forumId; std::string forumId;
ForumInfo forumInfoNew; //Todo: Replace with gxs forums
// ForumInfo forumInfoNew;
{ {
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/ RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -2063,13 +2072,14 @@ void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &nam
changed = true; changed = true;
} }
if ((fi->flag & RS_FEED_FLAG_FORUM) && (fi->flag & RS_FEED_FLAG_UPDATE_FORUM_INFO) && !fi->forumId.empty() && !preview) { //Todo: Replace with gxs forums
/* change forum too */ // if ((fi->flag & RS_FEED_FLAG_FORUM) && (fi->flag & RS_FEED_FLAG_UPDATE_FORUM_INFO) && !fi->forumId.empty() && !preview) {
forumId = fi->forumId; // /* change forum too */
librs::util::ConvertUtf8ToUtf16(fi->name, forumInfoNew.forumName); // forumId = fi->forumId;
librs::util::ConvertUtf8ToUtf16(fi->description, forumInfoNew.forumDesc); // librs::util::ConvertUtf8ToUtf16(fi->name, forumInfoNew.forumName);
forumInfoNew.forumName.insert(0, FEEDREADER_FORUM_PREFIX); // librs::util::ConvertUtf8ToUtf16(fi->description, forumInfoNew.forumDesc);
} // forumInfoNew.forumName.insert(0, FEEDREADER_FORUM_PREFIX);
// }
} }
if (changed) { if (changed) {
@ -2082,28 +2092,29 @@ void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &nam
} }
} }
if (!forumId.empty()) { //Todo: Replace with gxs forums
if (mForums) { // if (!forumId.empty()) {
ForumInfo forumInfo; // if (mForums) {
if (mForums->getForumInfo(forumId, forumInfo)) { // ForumInfo forumInfo;
if (forumInfo.forumName != forumInfoNew.forumName || forumInfo.forumDesc != forumInfoNew.forumDesc) { // if (mForums->getForumInfo(forumId, forumInfo)) {
/* name or description changed, update forum */ // if (forumInfo.forumName != forumInfoNew.forumName || forumInfo.forumDesc != forumInfoNew.forumDesc) {
#ifdef FEEDREADER_DEBUG // /* name or description changed, update forum */
std::cerr << "p3FeedReader::setFeed - change forum " << forumId << std::endl; //#ifdef FEEDREADER_DEBUG
#endif // std::cerr << "p3FeedReader::setFeed - change forum " << forumId << std::endl;
if (!mForums->setForumInfo(forumId, forumInfoNew)) { //#endif
#ifdef FEEDREADER_DEBUG // if (!mForums->setForumInfo(forumId, forumInfoNew)) {
std::cerr << "p3FeedReader::setFeed - can't change forum " << forumId << std::endl; //#ifdef FEEDREADER_DEBUG
#endif // std::cerr << "p3FeedReader::setFeed - can't change forum " << forumId << std::endl;
} //#endif
} // }
} else { // }
#ifdef FEEDREADER_DEBUG // } else {
std::cerr << "p3FeedReader::setFeed - can't get forum info " << forumId << std::endl; //#ifdef FEEDREADER_DEBUG
#endif // std::cerr << "p3FeedReader::setFeed - can't get forum info " << forumId << std::endl;
} //#endif
} else { // }
std::cerr << "p3FeedReader::setFeedInfo - can't process forum, member mForums is not set" << std::endl; // } else {
} // std::cerr << "p3FeedReader::setFeedInfo - can't process forum, member mForums is not set" << std::endl;
} // }
// }
} }

View file

@ -30,6 +30,9 @@ class RsFeedReaderFeed;
class RsFeedReaderMsg; class RsFeedReaderMsg;
class p3FeedReaderThread; class p3FeedReaderThread;
//Todo: Replace with gxs forums
class RsForums;
class p3FeedReader : public RsPQIService, public RsFeedReader class p3FeedReader : public RsPQIService, public RsFeedReader
{ {
public: public: