Merged branch v0.5-gxs-b1 into trunk (from -r 5351 -> 5995)
This brings a huge amount of goodness into the trunk, but there is still a big chunk todo before it can be released. * GXS Backend. * GXS Services: - Identities. - Circles - Photos - Wiki - GxsForums - Posted. * SSH no-gui server. See branch commits for more info. To switch on GXS stuff, enable CONFIG += gxs in both libretroshare.pro and retroshare-gui.pro git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5996 b45a01b8-16f6-495d-af2f-9b41ad6348cc
64
plugins/FeedReader/FeedReader.pro
Normal file
|
@ -0,0 +1,64 @@
|
|||
!include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri")
|
||||
|
||||
CONFIG += qt uic qrc resources
|
||||
|
||||
SOURCES = FeedReaderPlugin.cpp \
|
||||
services/p3FeedReader.cc \
|
||||
services/p3FeedReaderThread.cc \
|
||||
services/rsFeedReaderItems.cc \
|
||||
gui/FeedReaderDialog.cpp \
|
||||
gui/AddFeedDialog.cpp \
|
||||
gui/PreviewFeedDialog.cpp \
|
||||
gui/FeedReaderNotify.cpp \
|
||||
gui/FeedReaderConfig.cpp \
|
||||
gui/FeedReaderStringDefs.cpp \
|
||||
util/CURLWrapper.cpp \
|
||||
util/XMLWrapper.cpp \
|
||||
util/HTMLWrapper.cpp \
|
||||
util/XPathWrapper.cpp
|
||||
|
||||
HEADERS = FeedReaderPlugin.h \
|
||||
interface/rsFeedReader.h \
|
||||
services/p3FeedReader.h \
|
||||
services/p3FeedReaderThread.h \
|
||||
services/rsFeedReaderItems.h \
|
||||
gui/FeedReaderDialog.h \
|
||||
gui/AddFeedDialog.h \
|
||||
gui/PreviewFeedDialog.h \
|
||||
gui/FeedReaderNotify.h \
|
||||
gui/FeedReaderConfig.h \
|
||||
gui/FeedReaderStringDefs.h \
|
||||
util/CURLWrapper.h \
|
||||
util/XMLWrapper.h \
|
||||
util/HTMLWrapper.h \
|
||||
util/XPathWrapper.h
|
||||
|
||||
FORMS = gui/FeedReaderDialog.ui \
|
||||
gui/AddFeedDialog.ui \
|
||||
gui/PreviewFeedDialog.ui \
|
||||
gui/FeedReaderConfig.ui
|
||||
|
||||
TARGET = FeedReader
|
||||
|
||||
RESOURCES = gui/FeedReader_images.qrc \
|
||||
lang/lang.qrc
|
||||
|
||||
linux-* {
|
||||
LIBXML2_DIR = /usr/include/libxml2
|
||||
|
||||
INCLUDEPATH += $${LIBXML2_DIR}
|
||||
|
||||
LIBS += -lcurl -lxml2
|
||||
}
|
||||
|
||||
win32 {
|
||||
DEFINES += CURL_STATICLIB LIBXML_STATIC
|
||||
|
||||
CURL_DIR = ../../../curl-7.26.0
|
||||
LIBXML2_DIR = ../../../libxml2-2.8.0
|
||||
LIBICONV_DIR = ../../../libiconv-1.14
|
||||
|
||||
INCLUDEPATH += $${CURL_DIR}/include $${LIBXML2_DIR}/include $${LIBICONV_DIR}/include
|
||||
|
||||
LIBS += -lcurl -lxml2 -lws2_32 -lwldap32
|
||||
}
|
138
plugins/FeedReader/FeedReaderPlugin.cpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QIcon>
|
||||
|
||||
#include <retroshare/rsplugin.h>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "FeedReaderPlugin.h"
|
||||
#include "gui/FeedReaderDialog.h"
|
||||
#include "gui/FeedReaderConfig.h"
|
||||
#include "services/p3FeedReader.h"
|
||||
|
||||
#define IMAGE_FEEDREADER ":/images/FeedReader.png"
|
||||
|
||||
static void *inited = new FeedReaderPlugin();
|
||||
|
||||
extern "C" {
|
||||
#ifdef WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void *RETROSHARE_PLUGIN_provide()
|
||||
{
|
||||
static FeedReaderPlugin *p = new FeedReaderPlugin();
|
||||
|
||||
return (void*)p;
|
||||
}
|
||||
}
|
||||
|
||||
void FeedReaderPlugin::getPluginVersion(int& major,int& minor,int& svn_rev) const
|
||||
{
|
||||
major = 5;
|
||||
minor = 1;
|
||||
svn_rev = 4350;
|
||||
}
|
||||
|
||||
FeedReaderPlugin::FeedReaderPlugin()
|
||||
{
|
||||
mainpage = NULL ;
|
||||
mIcon = NULL ;
|
||||
mPlugInHandler = NULL;
|
||||
mFeedReader = NULL;
|
||||
}
|
||||
|
||||
void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &/*interfaces*/)
|
||||
{
|
||||
}
|
||||
|
||||
ConfigPage *FeedReaderPlugin::qt_config_page() const
|
||||
{
|
||||
return new FeedReaderConfig();
|
||||
}
|
||||
|
||||
MainPage *FeedReaderPlugin::qt_page() const
|
||||
{
|
||||
if (mainpage == NULL) {
|
||||
mainpage = new FeedReaderDialog(mFeedReader);
|
||||
}
|
||||
|
||||
return mainpage;
|
||||
}
|
||||
|
||||
RsPQIService *FeedReaderPlugin::rs_pqi_service() const
|
||||
{
|
||||
if (mFeedReader == NULL) {
|
||||
mFeedReader = new p3FeedReader(mPlugInHandler);
|
||||
rsFeedReader = mFeedReader;
|
||||
}
|
||||
|
||||
return mFeedReader;
|
||||
}
|
||||
|
||||
void FeedReaderPlugin::stop()
|
||||
{
|
||||
if (mFeedReader) {
|
||||
mFeedReader->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void FeedReaderPlugin::setPlugInHandler(RsPluginHandler *pgHandler)
|
||||
{
|
||||
mPlugInHandler = pgHandler;
|
||||
}
|
||||
|
||||
QIcon *FeedReaderPlugin::qt_icon() const
|
||||
{
|
||||
if (mIcon == NULL) {
|
||||
Q_INIT_RESOURCE(FeedReader_images);
|
||||
|
||||
mIcon = new QIcon(IMAGE_FEEDREADER);
|
||||
}
|
||||
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
std::string FeedReaderPlugin::getShortPluginDescription() const
|
||||
{
|
||||
return QApplication::translate("FeedReaderPlugin", "This plugin provides a Feedreader.").toUtf8().constData();
|
||||
}
|
||||
|
||||
std::string FeedReaderPlugin::getPluginName() const
|
||||
{
|
||||
return QApplication::translate("FeedReaderPlugin", "FeedReader").toUtf8().constData();
|
||||
}
|
||||
|
||||
QTranslator* FeedReaderPlugin::qt_translator(QApplication */*app*/, const QString& languageCode) const
|
||||
{
|
||||
if (languageCode == "en") {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QTranslator* translator = new QTranslator();
|
||||
if (translator->load(":/lang/FeedReader_" + languageCode + ".qm")) {
|
||||
return translator;
|
||||
}
|
||||
|
||||
delete(translator);
|
||||
return NULL;
|
||||
}
|
61
plugins/FeedReader/FeedReaderPlugin.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <serialiser/rsserviceids.h>
|
||||
#include <retroshare/rsplugin.h>
|
||||
#include <retroshare-gui/mainpage.h>
|
||||
#include "services/p3FeedReader.h"
|
||||
|
||||
class p3FeedReader;
|
||||
class RsForums;
|
||||
|
||||
class FeedReaderPlugin: public RsPlugin
|
||||
{
|
||||
public:
|
||||
FeedReaderPlugin();
|
||||
|
||||
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_PLUGIN_FEEDREADER; }
|
||||
virtual RsPQIService *rs_pqi_service() const;
|
||||
virtual void stop();
|
||||
|
||||
virtual MainPage *qt_page() const;
|
||||
virtual QIcon *qt_icon() const;
|
||||
virtual QTranslator *qt_translator(QApplication *app, const QString &languageCode) const;
|
||||
|
||||
virtual void getPluginVersion(int &major, int &minor, int &svn_rev) const;
|
||||
virtual void setPlugInHandler(RsPluginHandler *pgHandler);
|
||||
|
||||
virtual std::string configurationFileName() const { return "feedreader.cfg" ; }
|
||||
|
||||
virtual std::string getShortPluginDescription() const;
|
||||
virtual std::string getPluginName() const;
|
||||
virtual void setInterfaces(RsPlugInInterfaces& interfaces);
|
||||
virtual ConfigPage *qt_config_page() const;
|
||||
|
||||
private:
|
||||
mutable p3FeedReader *mFeedReader;
|
||||
mutable RsPluginHandler *mPlugInHandler;
|
||||
mutable MainPage *mainpage;
|
||||
mutable QIcon *mIcon;
|
||||
};
|
||||
|
347
plugins/FeedReader/gui/AddFeedDialog.cpp
Normal file
|
@ -0,0 +1,347 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDateTime>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "AddFeedDialog.h"
|
||||
#include "ui_AddFeedDialog.h"
|
||||
#include "PreviewFeedDialog.h"
|
||||
#include "FeedReaderStringDefs.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
#include "retroshare/rsforums.h"
|
||||
|
||||
bool sortForumInfo(const ForumInfo& info1, const ForumInfo& info2)
|
||||
{
|
||||
return QString::fromStdWString(info1.forumName).compare(QString::fromStdWString(info2.forumName), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent)
|
||||
: QDialog(parent, Qt::Window), mFeedReader(feedReader), mNotify(notify), ui(new Ui::AddFeedDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(createFeed()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
|
||||
|
||||
connect(ui->useAuthenticationCheckBox, SIGNAL(toggled(bool)), this, SLOT(authenticationToggled()));
|
||||
connect(ui->useStandardStorageTimeCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardStorageTimeToggled()));
|
||||
connect(ui->useStandardUpdateInterval, SIGNAL(toggled(bool)), this, SLOT(useStandardUpdateIntervalToggled()));
|
||||
connect(ui->useStandardProxyCheckBox, SIGNAL(toggled(bool)), this, SLOT(useStandardProxyToggled()));
|
||||
connect(ui->typeForumRadio, SIGNAL(toggled(bool)), this, SLOT(typeForumToggled()));
|
||||
connect(ui->previewButton, SIGNAL(clicked()), this, SLOT(preview()));
|
||||
|
||||
/* currently only for loacl feeds */
|
||||
connect(ui->saveCompletePageCheckBox, SIGNAL(toggled(bool)), this, SLOT(denyForumToggled()));
|
||||
connect(ui->embedImagesCheckBox, SIGNAL(toggled(bool)), this, SLOT(denyForumToggled()));
|
||||
|
||||
connect(ui->urlLineEdit, 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->typeLocalRadio, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
||||
connect(ui->typeForumRadio, SIGNAL(toggled(bool)), this, SLOT(validate()));
|
||||
|
||||
ui->activatedCheckBox->setChecked(true);
|
||||
ui->forumComboBox->setEnabled(false);
|
||||
ui->useInfoFromFeedCheckBox->setChecked(true);
|
||||
ui->updateForumInfoCheckBox->setEnabled(false);
|
||||
ui->updateForumInfoCheckBox->setChecked(true);
|
||||
ui->forumNameLabel->hide();
|
||||
ui->useAuthenticationCheckBox->setChecked(false);
|
||||
ui->useStandardStorageTimeCheckBox->setChecked(true);
|
||||
ui->useStandardUpdateInterval->setChecked(true);
|
||||
ui->useStandardProxyCheckBox->setChecked(true);
|
||||
|
||||
/* not yet supported */
|
||||
ui->authenticationGroupBox->setEnabled(false);
|
||||
|
||||
/* fill own forums */
|
||||
std::list<ForumInfo> forumList;
|
||||
if (rsForums->getForumList(forumList)) {
|
||||
forumList.sort(sortForumInfo);
|
||||
for (std::list<ForumInfo>::iterator it = forumList.begin(); it != forumList.end(); ++it) {
|
||||
ForumInfo &forumInfo = *it;
|
||||
/* show only own anonymous forums */
|
||||
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 */
|
||||
ui->forumComboBox->insertItem(0, tr("Create a new anonymous public forum"), "");
|
||||
ui->forumComboBox->setCurrentIndex(0);
|
||||
|
||||
validate();
|
||||
|
||||
ui->urlLineEdit->setFocus();
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
}
|
||||
|
||||
AddFeedDialog::~AddFeedDialog()
|
||||
{
|
||||
/* save settings */
|
||||
processSettings(false);
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AddFeedDialog::processSettings(bool load)
|
||||
{
|
||||
Settings->beginGroup(QString("AddFeedDialog"));
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
QByteArray geometry = Settings->value("Geometry").toByteArray();
|
||||
if (!geometry.isEmpty()) {
|
||||
restoreGeometry(geometry);
|
||||
}
|
||||
} else {
|
||||
// save settings
|
||||
Settings->setValue("Geometry", saveGeometry());
|
||||
}
|
||||
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void AddFeedDialog::authenticationToggled()
|
||||
{
|
||||
bool checked = ui->useAuthenticationCheckBox->isChecked();
|
||||
ui->userLineEdit->setEnabled(checked);
|
||||
ui->passwordLineEdit->setEnabled(checked);
|
||||
}
|
||||
|
||||
void AddFeedDialog::useStandardStorageTimeToggled()
|
||||
{
|
||||
bool checked = ui->useStandardStorageTimeCheckBox->isChecked();
|
||||
ui->storageTimeSpinBox->setEnabled(!checked);
|
||||
}
|
||||
|
||||
void AddFeedDialog::useStandardUpdateIntervalToggled()
|
||||
{
|
||||
bool checked = ui->useStandardUpdateInterval->isChecked();
|
||||
ui->updateIntervalSpinBox->setEnabled(!checked);
|
||||
}
|
||||
|
||||
void AddFeedDialog::useStandardProxyToggled()
|
||||
{
|
||||
bool checked = ui->useStandardProxyCheckBox->isChecked();
|
||||
ui->proxyAddressLineEdit->setEnabled(!checked);
|
||||
ui->proxyPortSpinBox->setEnabled(!checked);
|
||||
}
|
||||
|
||||
void AddFeedDialog::typeForumToggled()
|
||||
{
|
||||
bool checked = ui->typeForumRadio->isChecked();
|
||||
ui->forumComboBox->setEnabled(checked);
|
||||
ui->updateForumInfoCheckBox->setEnabled(checked);
|
||||
}
|
||||
|
||||
void AddFeedDialog::denyForumToggled()
|
||||
{
|
||||
if (ui->saveCompletePageCheckBox->isChecked() || ui->embedImagesCheckBox->isChecked()) {
|
||||
ui->typeForumRadio->setEnabled(false);
|
||||
ui->typeLocalRadio->setChecked(true);
|
||||
} else {
|
||||
ui->typeForumRadio->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void AddFeedDialog::validate()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
if (ui->urlLineEdit->text().isEmpty()) {
|
||||
ok = false;
|
||||
}
|
||||
if (ui->nameLineEdit->text().isEmpty() && !ui->useInfoFromFeedCheckBox->isChecked()) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
ui->previewButton->setEnabled(ok);
|
||||
|
||||
if (!ui->typeLocalRadio->isChecked() && !ui->typeForumRadio->isChecked()) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
}
|
||||
|
||||
void AddFeedDialog::setParent(const std::string &parentId)
|
||||
{
|
||||
mParentId = parentId;
|
||||
}
|
||||
|
||||
bool AddFeedDialog::fillFeed(const std::string &feedId)
|
||||
{
|
||||
mFeedId = feedId;
|
||||
|
||||
if (!mFeedId.empty()) {
|
||||
FeedInfo feedInfo;
|
||||
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
|
||||
mFeedId.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
setWindowTitle(tr("Edit feed"));
|
||||
ui->typeGroupBox->setEnabled(false);
|
||||
|
||||
mParentId = feedInfo.parentId;
|
||||
|
||||
ui->nameLineEdit->setText(QString::fromUtf8(feedInfo.name.c_str()));
|
||||
ui->urlLineEdit->setText(QString::fromUtf8(feedInfo.url.c_str()));
|
||||
ui->useInfoFromFeedCheckBox->setChecked(feedInfo.flag.infoFromFeed);
|
||||
ui->updateForumInfoCheckBox->setChecked(feedInfo.flag.updateForumInfo);
|
||||
ui->activatedCheckBox->setChecked(!feedInfo.flag.deactivated);
|
||||
ui->embedImagesCheckBox->setChecked(feedInfo.flag.embedImages);
|
||||
ui->saveCompletePageCheckBox->setChecked(feedInfo.flag.saveCompletePage);
|
||||
|
||||
ui->descriptionPlainTextEdit->setPlainText(QString::fromUtf8(feedInfo.description.c_str()));
|
||||
|
||||
ui->typeGroupBox->setEnabled(false);
|
||||
ui->forumComboBox->hide();
|
||||
ui->forumNameLabel->clear();
|
||||
ui->forumNameLabel->show();
|
||||
|
||||
if (feedInfo.flag.forum) {
|
||||
ui->typeForumRadio->setChecked(true);
|
||||
ui->saveCompletePageCheckBox->setEnabled(false);
|
||||
ui->embedImagesCheckBox->setEnabled(false);
|
||||
|
||||
if (feedInfo.forumId.empty()) {
|
||||
ui->forumNameLabel->setText(tr("Not yet created"));
|
||||
} else {
|
||||
ForumInfo forumInfo;
|
||||
if (rsForums->getForumInfo(feedInfo.forumId, forumInfo)) {
|
||||
ui->forumNameLabel->setText(QString::fromStdWString(forumInfo.forumName));
|
||||
} else {
|
||||
ui->forumNameLabel->setText(tr("Unknown forum"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ui->typeLocalRadio->setChecked(true);
|
||||
}
|
||||
|
||||
ui->useAuthenticationCheckBox->setChecked(feedInfo.flag.authentication);
|
||||
ui->userLineEdit->setText(QString::fromUtf8(feedInfo.user.c_str()));
|
||||
ui->passwordLineEdit->setText(QString::fromUtf8(feedInfo.password.c_str()));
|
||||
|
||||
ui->useStandardProxyCheckBox->setChecked(feedInfo.flag.standardProxy);
|
||||
ui->proxyAddressLineEdit->setText(QString::fromUtf8(feedInfo.proxyAddress.c_str()));
|
||||
ui->proxyPortSpinBox->setValue(feedInfo.proxyPort);
|
||||
|
||||
ui->useStandardUpdateInterval->setChecked(feedInfo.flag.standardUpdateInterval);
|
||||
ui->updateIntervalSpinBox->setValue(feedInfo.updateInterval / 60);
|
||||
QDateTime dateTime;
|
||||
dateTime.setTime_t(feedInfo.lastUpdate);
|
||||
ui->lastUpdate->setText(dateTime.toString());
|
||||
|
||||
ui->useStandardStorageTimeCheckBox->setChecked(feedInfo.flag.standardStorageTime);
|
||||
ui->storageTimeSpinBox->setValue(feedInfo.storageTime / (60 * 60 *24));
|
||||
|
||||
mXPathsToUse = feedInfo.xpathsToUse;
|
||||
mXPathsToRemove = feedInfo.xpathsToRemove;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AddFeedDialog::getFeedInfo(FeedInfo &feedInfo)
|
||||
{
|
||||
feedInfo.parentId = mParentId;
|
||||
|
||||
feedInfo.name = ui->nameLineEdit->text().toUtf8().constData();
|
||||
feedInfo.url = ui->urlLineEdit->text().toUtf8().constData();
|
||||
feedInfo.flag.infoFromFeed = ui->useInfoFromFeedCheckBox->isChecked();
|
||||
feedInfo.flag.updateForumInfo = ui->updateForumInfoCheckBox->isChecked() && ui->updateForumInfoCheckBox->isEnabled();
|
||||
feedInfo.flag.deactivated = !ui->activatedCheckBox->isChecked();
|
||||
feedInfo.flag.embedImages = ui->embedImagesCheckBox->isChecked();
|
||||
feedInfo.flag.saveCompletePage = ui->saveCompletePageCheckBox->isChecked();
|
||||
|
||||
feedInfo.description = ui->descriptionPlainTextEdit->toPlainText().toUtf8().constData();
|
||||
|
||||
feedInfo.flag.forum = ui->typeForumRadio->isChecked();
|
||||
if (mFeedId.empty()) {
|
||||
if (feedInfo.flag.forum) {
|
||||
/* set forum (only when create a new feed) */
|
||||
feedInfo.forumId = ui->forumComboBox->itemData(ui->forumComboBox->currentIndex()).toString().toStdString();
|
||||
}
|
||||
}
|
||||
|
||||
feedInfo.flag.authentication = ui->useAuthenticationCheckBox->isChecked();
|
||||
feedInfo.user = ui->userLineEdit->text().toUtf8().constData();
|
||||
feedInfo.password = ui->passwordLineEdit->text().toUtf8().constData();
|
||||
|
||||
feedInfo.flag.standardProxy = ui->useStandardProxyCheckBox->isChecked();
|
||||
feedInfo.proxyAddress = ui->proxyAddressLineEdit->text().toUtf8().constData();
|
||||
feedInfo.proxyPort = ui->proxyPortSpinBox->value();
|
||||
|
||||
feedInfo.flag.standardUpdateInterval = ui->useStandardUpdateInterval->isChecked();
|
||||
feedInfo.updateInterval = ui->updateIntervalSpinBox->value() * 60;
|
||||
|
||||
feedInfo.flag.standardStorageTime = ui->useStandardStorageTimeCheckBox->isChecked();
|
||||
feedInfo.storageTime = ui->storageTimeSpinBox->value() * 60 *60 * 24;
|
||||
|
||||
feedInfo.xpathsToUse = mXPathsToUse;
|
||||
feedInfo.xpathsToRemove = mXPathsToRemove;
|
||||
}
|
||||
|
||||
void AddFeedDialog::createFeed()
|
||||
{
|
||||
FeedInfo feedInfo;
|
||||
if (!mFeedId.empty()) {
|
||||
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
|
||||
QMessageBox::critical(this, tr("Edit feed"), tr("Can't edit feed. Feed does not exist."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
getFeedInfo(feedInfo);
|
||||
|
||||
if (mFeedId.empty()) {
|
||||
/* add new feed */
|
||||
RsFeedAddResult result = mFeedReader->addFeed(feedInfo, mFeedId);
|
||||
if (FeedReaderStringDefs::showError(this, result, tr("Create feed"), tr("Cannot create feed."))) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
RsFeedAddResult result = mFeedReader->setFeed(mFeedId, feedInfo);
|
||||
if (FeedReaderStringDefs::showError(this, result, tr("Edit feed"), tr("Cannot change feed."))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void AddFeedDialog::preview()
|
||||
{
|
||||
FeedInfo feedInfo;
|
||||
getFeedInfo(feedInfo);
|
||||
|
||||
PreviewFeedDialog dialog(mFeedReader, mNotify, feedInfo, this);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
dialog.getXPaths(mXPathsToUse, mXPathsToRemove);
|
||||
}
|
||||
}
|
72
plugins/FeedReader/gui/AddFeedDialog.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef ADDFEEDDIALOG_H
|
||||
#define ADDFEEDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
namespace Ui {
|
||||
class AddFeedDialog;
|
||||
}
|
||||
|
||||
class RsFeedReader;
|
||||
class FeedReaderNotify;
|
||||
|
||||
class AddFeedDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent);
|
||||
~AddFeedDialog();
|
||||
|
||||
void setParent(const std::string &parentId);
|
||||
bool fillFeed(const std::string &feedId);
|
||||
|
||||
private slots:
|
||||
void authenticationToggled();
|
||||
void useStandardStorageTimeToggled();
|
||||
void useStandardUpdateIntervalToggled();
|
||||
void useStandardProxyToggled();
|
||||
void typeForumToggled();
|
||||
void denyForumToggled();
|
||||
void validate();
|
||||
void createFeed();
|
||||
void preview();
|
||||
|
||||
private:
|
||||
void processSettings(bool load);
|
||||
void getFeedInfo(FeedInfo &feedInfo);
|
||||
|
||||
RsFeedReader *mFeedReader;
|
||||
FeedReaderNotify *mNotify;
|
||||
std::string mFeedId;
|
||||
std::string mParentId;
|
||||
|
||||
std::list<std::string> mXPathsToUse;
|
||||
std::list<std::string> mXPathsToRemove;
|
||||
|
||||
Ui::AddFeedDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ADDFEEDDIALOG_H
|
462
plugins/FeedReader/gui/AddFeedDialog.ui
Normal file
|
@ -0,0 +1,462 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AddFeedDialog</class>
|
||||
<widget class="QDialog" name="AddFeedDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>715</width>
|
||||
<height>605</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create new feed</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../retroshare-gui/src/gui/images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="headerFrame">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#headerFrame{background-image: url(:/images/connect/connectFriendBanner.png);}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="headerIcon">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="FeedReader_images.qrc">:/images/FeedReader.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="headerLabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#ffffff;">Feed Details</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="7" column="0">
|
||||
<widget class="QGroupBox" name="authenticationGroupBox">
|
||||
<property name="title">
|
||||
<string>Authentication (not yet supported)</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="useAuthenticationCheckBox">
|
||||
<property name="text">
|
||||
<string>Feed needs authentication</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="userLabel">
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="userLineEdit"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QGroupBox" name="updateInteralGroupBox">
|
||||
<property name="title">
|
||||
<string>Update interval</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="useStandardUpdateInterval">
|
||||
<property name="text">
|
||||
<string>Use standard update interval</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="updateIntervalLabel">
|
||||
<property name="text">
|
||||
<string>Interval in minutes (0 = manual)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="updateIntervalSpinBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="lastUpdateLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lastUpdateLabel">
|
||||
<property name="text">
|
||||
<string>Last update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lastUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Never</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QGroupBox" name="storageTimeGroupBox">
|
||||
<property name="title">
|
||||
<string>Storage time</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="useStandardStorageTimeCheckBox">
|
||||
<property name="text">
|
||||
<string>Use standard storage time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="storageTimeLabel">
|
||||
<property name="text">
|
||||
<string>Days (0 = off)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="storageTimeSpinBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QGroupBox" name="proxyGroupBox">
|
||||
<property name="title">
|
||||
<string>Proxy</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="useStandardProxyCheckBox">
|
||||
<property name="text">
|
||||
<string>Use standard proxy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="serverLabel">
|
||||
<property name="text">
|
||||
<string>Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="proxyAddressLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="portLabel">
|
||||
<property name="text">
|
||||
<string>:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="proxyPortSpinBox">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="previewButton">
|
||||
<property name="text">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="typeGroupBox">
|
||||
<property name="title">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="typeForumRadio">
|
||||
<property name="text">
|
||||
<string>Forum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="forumComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="forumNameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Forum name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="typeLocalRadio">
|
||||
<property name="text">
|
||||
<string>Local Feed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QGroupBox" name="flagGroupBox">
|
||||
<property name="title">
|
||||
<string>Misc</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="activatedCheckBox">
|
||||
<property name="text">
|
||||
<string>Activated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useInfoFromFeedCheckBox">
|
||||
<property name="text">
|
||||
<string>Use name and description from feed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="updateForumInfoCheckBox">
|
||||
<property name="text">
|
||||
<string>Update forum information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="embedImagesCheckBox">
|
||||
<property name="text">
|
||||
<string>Embed images (experimental for local feeds)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="saveCompletePageCheckBox">
|
||||
<property name="text">
|
||||
<string>Save complete web page (experimental for local feeds)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="descriptionLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="descriptionLabel">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="descriptionPlainTextEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="nameLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="urlLabel">
|
||||
<property name="text">
|
||||
<string>RSS-Feed-URL:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="urlLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="nameLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>urlLineEdit</tabstop>
|
||||
<tabstop>nameLineEdit</tabstop>
|
||||
<tabstop>descriptionPlainTextEdit</tabstop>
|
||||
<tabstop>typeForumRadio</tabstop>
|
||||
<tabstop>forumComboBox</tabstop>
|
||||
<tabstop>activatedCheckBox</tabstop>
|
||||
<tabstop>useInfoFromFeedCheckBox</tabstop>
|
||||
<tabstop>updateForumInfoCheckBox</tabstop>
|
||||
<tabstop>useAuthenticationCheckBox</tabstop>
|
||||
<tabstop>userLineEdit</tabstop>
|
||||
<tabstop>passwordLineEdit</tabstop>
|
||||
<tabstop>useStandardStorageTimeCheckBox</tabstop>
|
||||
<tabstop>storageTimeSpinBox</tabstop>
|
||||
<tabstop>useStandardUpdateInterval</tabstop>
|
||||
<tabstop>updateIntervalSpinBox</tabstop>
|
||||
<tabstop>useStandardProxyCheckBox</tabstop>
|
||||
<tabstop>proxyAddressLineEdit</tabstop>
|
||||
<tabstop>proxyPortSpinBox</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="FeedReader_images.qrc"/>
|
||||
<include location="../../../retroshare-gui/src/gui/images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
80
plugins/FeedReader/gui/FeedReaderConfig.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "FeedReaderConfig.h"
|
||||
#include "ui_FeedReaderConfig.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
/** Constructor */
|
||||
FeedReaderConfig::FeedReaderConfig(QWidget *parent, Qt::WFlags flags)
|
||||
: ConfigPage(parent, flags), ui(new Ui::FeedReaderConfig)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->useProxyCheckBox, SIGNAL(toggled(bool)), this, SLOT(useProxyToggled()));
|
||||
|
||||
ui->proxyAddressLineEdit->setEnabled(false);
|
||||
ui->proxyPortSpinBox->setEnabled(false);
|
||||
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
/** Destructor */
|
||||
FeedReaderConfig::~FeedReaderConfig()
|
||||
{
|
||||
delete(ui);
|
||||
}
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void FeedReaderConfig::load()
|
||||
{
|
||||
ui->updateIntervalSpinBox->setValue(rsFeedReader->getStandardUpdateInterval() / 60);
|
||||
ui->storageTimeSpinBox->setValue(rsFeedReader->getStandardStorageTime() / (60 * 60 *24));
|
||||
ui->setMsgToReadOnActivate->setChecked(Settings->valueFromGroup("FeedReaderDialog", "SetMsgToReadOnActivate", true).toBool());
|
||||
|
||||
std::string proxyAddress;
|
||||
uint16_t proxyPort;
|
||||
ui->useProxyCheckBox->setChecked(rsFeedReader->getStandardProxy(proxyAddress, proxyPort));
|
||||
ui->proxyAddressLineEdit->setText(QString::fromUtf8(proxyAddress.c_str()));
|
||||
ui->proxyPortSpinBox->setValue(proxyPort);
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
bool FeedReaderConfig::save(QString &/*errmsg*/)
|
||||
{
|
||||
rsFeedReader->setStandardUpdateInterval(ui->updateIntervalSpinBox->value() * 60);
|
||||
rsFeedReader->setStandardStorageTime(ui->storageTimeSpinBox->value() * 60 *60 * 24);
|
||||
rsFeedReader->setStandardProxy(ui->useProxyCheckBox->isChecked(), ui->proxyAddressLineEdit->text().toUtf8().constData(), ui->proxyPortSpinBox->value());
|
||||
Settings->setValueToGroup("FeedReaderDialog", "SetMsgToReadOnActivate", ui->setMsgToReadOnActivate->isChecked());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FeedReaderConfig::useProxyToggled()
|
||||
{
|
||||
bool enabled = ui->useProxyCheckBox->isChecked();
|
||||
|
||||
ui->proxyAddressLineEdit->setEnabled(enabled);
|
||||
ui->proxyPortSpinBox->setEnabled(enabled);
|
||||
}
|
57
plugins/FeedReader/gui/FeedReaderConfig.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _FEEDREADERCONFIG_H
|
||||
#define _FEEDREADERCONFIG_H
|
||||
|
||||
#include "retroshare-gui/configpage.h"
|
||||
|
||||
namespace Ui {
|
||||
class FeedReaderConfig;
|
||||
}
|
||||
|
||||
class FeedReaderConfig : public ConfigPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
FeedReaderConfig(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default Destructor */
|
||||
virtual ~FeedReaderConfig();
|
||||
|
||||
/** Saves the changes on this page */
|
||||
virtual bool save(QString &errmsg);
|
||||
/** Loads the settings for this page */
|
||||
virtual void load();
|
||||
|
||||
virtual QPixmap iconPixmap() const { return QPixmap(":/images/FeedReader.png") ; }
|
||||
virtual QString pageName() const { return tr("FeedReader") ; }
|
||||
|
||||
private slots:
|
||||
void useProxyToggled();
|
||||
|
||||
private:
|
||||
Ui::FeedReaderConfig *ui;
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
#endif
|
148
plugins/FeedReader/gui/FeedReaderConfig.ui
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FeedReaderConfig</class>
|
||||
<widget class="QWidget" name="FeedReaderConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>508</width>
|
||||
<height>378</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="updateGroupBox">
|
||||
<property name="title">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="updateIntervalLabel">
|
||||
<property name="text">
|
||||
<string>Interval in minutes (0 = manual)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="updateIntervalSpinBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="storageTimeGroupBox">
|
||||
<property name="title">
|
||||
<string>Storage time</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="storageTimeLabel">
|
||||
<property name="text">
|
||||
<string>Days (0 = off)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="storageTimeSpinBox">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="proxyGroupBox">
|
||||
<property name="title">
|
||||
<string>Proxy</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QCheckBox" name="useProxyCheckBox">
|
||||
<property name="text">
|
||||
<string>Use proxy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="serverLabel">
|
||||
<property name="text">
|
||||
<string>Server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="proxyAddressLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="proxyPortSpinBox">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="potLabel">
|
||||
<property name="text">
|
||||
<string>:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="miscGroupBox">
|
||||
<property name="title">
|
||||
<string>Misc</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="setMsgToReadOnActivate">
|
||||
<property name="text">
|
||||
<string>Set message to read on activate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>301</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
1128
plugins/FeedReader/gui/FeedReaderDialog.cpp
Normal file
107
plugins/FeedReader/gui/FeedReaderDialog.h
Normal file
|
@ -0,0 +1,107 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _FEEDREADERDIALOG_H
|
||||
#define _FEEDREADERDIALOG_H
|
||||
|
||||
#include <retroshare-gui/mainpage.h>
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
namespace Ui {
|
||||
class FeedReaderDialog;
|
||||
}
|
||||
|
||||
class QTreeWidgetItem;
|
||||
class RsFeedReader;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
class FeedReaderNotify;
|
||||
|
||||
class FeedReaderDialog : public MainPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent = 0);
|
||||
~FeedReaderDialog();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *e);
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
||||
private slots:
|
||||
void feedTreeCustomPopupMenu(QPoint point);
|
||||
void msgTreeCustomPopupMenu(QPoint point);
|
||||
void feedItemChanged(QTreeWidgetItem *item);
|
||||
void msgItemChanged();
|
||||
void msgItemClicked(QTreeWidgetItem *item, int column);
|
||||
void filterColumnChanged();
|
||||
void filterItems(const QString &text);
|
||||
void toggleMsgText();
|
||||
void newFolder();
|
||||
void newFeed();
|
||||
void removeFeed();
|
||||
void editFeed();
|
||||
void activateFeed();
|
||||
void processFeed();
|
||||
void markAsReadMsg();
|
||||
void markAsUnreadMsg();
|
||||
void markAllAsReadMsg();
|
||||
void copyLinksMsg();
|
||||
void removeMsg();
|
||||
void openLinkMsg();
|
||||
void copyLinkMsg();
|
||||
|
||||
/* FeedReaderNotify */
|
||||
void feedChanged(const QString &feedId, int type);
|
||||
void msgChanged(const QString &feedId, const QString &msgId, int type);
|
||||
|
||||
private:
|
||||
std::string currentFeedId();
|
||||
std::string currentMsgId();
|
||||
void processSettings(bool load);
|
||||
void updateFeeds(const std::string &parentId, QTreeWidgetItem *parentItem);
|
||||
void updateFeedItem(QTreeWidgetItem *item, FeedInfo &info);
|
||||
void updateMsgs(const std::string &feedId);
|
||||
void calculateMsgIconsAndFonts(QTreeWidgetItem *item);
|
||||
void updateMsgItem(QTreeWidgetItem *item, FeedMsgInfo &info);
|
||||
void setMsgAsReadUnread(QList<QTreeWidgetItem*> &rows, bool read);
|
||||
void filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
||||
void filterItem(QTreeWidgetItem *item);
|
||||
void toggleMsgText_internal();
|
||||
|
||||
void calculateFeedItems();
|
||||
void calculateFeedItem(QTreeWidgetItem *item, uint32_t &unreadCount, bool &loading);
|
||||
|
||||
bool mProcessSettings;
|
||||
QTreeWidgetItem *mRootItem;
|
||||
RSTreeWidgetItemCompareRole *mFeedCompareRole;
|
||||
RSTreeWidgetItemCompareRole *mMsgCompareRole;
|
||||
|
||||
// gui interface
|
||||
RsFeedReader *mFeedReader;
|
||||
FeedReaderNotify *mNotify;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::FeedReaderDialog *ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
387
plugins/FeedReader/gui/FeedReaderDialog.ui
Normal file
|
@ -0,0 +1,387 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FeedReaderDialog</class>
|
||||
<widget class="QWidget" name="FeedReaderDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>738</width>
|
||||
<height>583</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QFrame" name="feedFrame">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame{border: none;}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="feedsHeaderFrame">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"> QFrame#feedsHeaderFrame{
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #FEFEFE, stop:1 #E8E8E8);
|
||||
|
||||
border: 1px solid #CCCCCC;}
|
||||
|
||||
</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="feedsIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="FeedReader_images.qrc">:/images/Feed.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="feedsLabel">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:10pt; font-weight:600;">Feeds</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeWidget" name="feedTreeWidget">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QSplitter" name="msgSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="msgFrame">
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="filterFrame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"> QFrame#frame_2{
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #FEFEFE, stop:1 #E8E8E8);
|
||||
|
||||
border: 1px solid #CCCCCC;}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="_7">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="filterLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../retroshare-gui/src/gui/images.qrc">:/images/find-16.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LineEditClear" name="filterLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search forums</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="filterColumnComboBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>MS Shell Dlg 2</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Author</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTreeWidget" name="msgTreeWidget">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../retroshare-gui/src/gui/images.qrc">
|
||||
<normaloff>:/images/message-state-header.png</normaloff>:/images/message-state-header.png</iconset>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Author</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="msgLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Message:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="msgTitle">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel#msgTitle{
|
||||
border: 2px solid #CCCCCC;
|
||||
border-radius: 6px;
|
||||
background: white;}</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="linkButton">
|
||||
<property name="icon">
|
||||
<iconset resource="FeedReader_images.qrc">
|
||||
<normaloff>:/images/Link.png</normaloff>:/images/Link.png</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="expandButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../retroshare-gui/src/gui/images.qrc">
|
||||
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="LinkTextBrowser" name="msgText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>10</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LinkTextBrowser</class>
|
||||
<extends>QTextBrowser</extends>
|
||||
<header>gui/common/LinkTextBrowser.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="FeedReader_images.qrc"/>
|
||||
<include location="../../../retroshare-gui/src/gui/images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
36
plugins/FeedReader/gui/FeedReaderNotify.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "FeedReaderNotify.h"
|
||||
|
||||
FeedReaderNotify::FeedReaderNotify() : QObject()
|
||||
{
|
||||
}
|
||||
|
||||
void FeedReaderNotify::feedChanged(const std::string &feedId, int type)
|
||||
{
|
||||
emit notifyFeedChanged(QString::fromStdString(feedId), type);
|
||||
}
|
||||
|
||||
void FeedReaderNotify::msgChanged(const std::string &feedId, const std::string &msgId, int type)
|
||||
{
|
||||
emit notifyMsgChanged(QString::fromStdString(feedId), QString::fromStdString(msgId), type);
|
||||
}
|
45
plugins/FeedReader/gui/FeedReaderNotify.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _FEEDREADERNOTIFY_H
|
||||
#define _FEEDREADERNOTIFY_H
|
||||
|
||||
#include <QObject>
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
class FeedReaderNotify : public QObject, public RsFeedReaderNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FeedReaderNotify();
|
||||
|
||||
/* RsFeedReaderNotify */
|
||||
virtual void feedChanged(const std::string &feedId, int type);
|
||||
virtual void msgChanged(const std::string &feedId, const std::string &msgId, int type);
|
||||
|
||||
signals:
|
||||
void notifyFeedChanged(const QString &feedId, int type);
|
||||
void notifyMsgChanged(const QString &feedId, const QString &msgId, int type);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
148
plugins/FeedReader/gui/FeedReaderStringDefs.cpp
Normal file
|
@ -0,0 +1,148 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "FeedReaderStringDefs.h"
|
||||
|
||||
bool FeedReaderStringDefs::showError(QWidget *parent, RsFeedAddResult result, const QString &title, const QString &text)
|
||||
{
|
||||
QString error;
|
||||
|
||||
switch (result) {
|
||||
case RS_FEED_ADD_RESULT_SUCCESS:
|
||||
/* no error */
|
||||
return false;
|
||||
case RS_FEED_ADD_RESULT_FEED_NOT_FOUND:
|
||||
error = QApplication::translate("FeedReaderStringDefs", "Feed not found.");
|
||||
break;
|
||||
case RS_FEED_ADD_RESULT_PARENT_NOT_FOUND:
|
||||
error = QApplication::translate("FeedReaderStringDefs", "Parent not found.");
|
||||
break;
|
||||
case RS_FEED_ADD_RESULT_PARENT_IS_NO_FOLDER:
|
||||
error = QApplication::translate("FeedReaderStringDefs", "Parent is no folder.");
|
||||
break;
|
||||
case RS_FEED_ADD_RESULT_FEED_IS_FOLDER:
|
||||
error = QApplication::translate("FeedReaderStringDefs", "Feed is a folder.");
|
||||
break;
|
||||
case RS_FEED_ADD_RESULT_FEED_IS_NO_FOLDER:
|
||||
error = QApplication::translate("FeedReaderStringDefs", "Feed is no folder.");
|
||||
break;
|
||||
default:
|
||||
error = QApplication::translate("FeedReaderStringDefs", "Unknown error occured.");
|
||||
}
|
||||
|
||||
QMessageBox::critical(parent, title, text + "\n" + error);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FeedReaderStringDefs::workState(FeedInfo::WorkState state)
|
||||
{
|
||||
switch (state) {
|
||||
case FeedInfo::WAITING:
|
||||
return "";
|
||||
case FeedInfo::WAITING_TO_DOWNLOAD:
|
||||
return QApplication::translate("FeedReaderStringDefs", "Waiting for download");
|
||||
case FeedInfo::DOWNLOADING:
|
||||
return QApplication::translate("FeedReaderStringDefs", "Downloading");
|
||||
case FeedInfo::WAITING_TO_PROCESS:
|
||||
return QApplication::translate("FeedReaderStringDefs", "Waiting for process");
|
||||
case FeedInfo::PROCESSING:
|
||||
return QApplication::translate("FeedReaderStringDefs", "Processing");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QString FeedReaderStringDefs::errorString(const FeedInfo &feedInfo)
|
||||
{
|
||||
return errorString(feedInfo.errorState, feedInfo.errorString);
|
||||
}
|
||||
|
||||
QString FeedReaderStringDefs::errorString(RsFeedReaderErrorState errorState, const std::string &errorString)
|
||||
{
|
||||
QString errorText;
|
||||
switch (errorState) {
|
||||
case RS_FEED_ERRORSTATE_OK:
|
||||
break;
|
||||
|
||||
/* download */
|
||||
case RS_FEED_ERRORSTATE_DOWNLOAD_INTERNAL_ERROR:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Internal download error");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_DOWNLOAD_ERROR:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Download error");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_DOWNLOAD_UNKNOWN_CONTENT_TYPE:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown content type");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_DOWNLOAD_NOT_FOUND:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Download not found");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_DOWNLOAD_UNKOWN_RESPONSE_CODE:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown response code");
|
||||
break;
|
||||
|
||||
/* process */
|
||||
case RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Internal process error");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown XML format");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Can't create forum");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Forum not found");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_ADMIN:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "You are not admin of the forum");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_ANONYMOUS:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "The forum is no anonymous forum");
|
||||
break;
|
||||
|
||||
case RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Can't read html");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_XPATH_INTERNAL_ERROR:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Internal XPath error");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_XPATH_WRONG_EXPRESSION:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Wrong XPath expression");
|
||||
break;
|
||||
case RS_FEED_ERRORSTATE_PROCESS_XPATH_NO_RESULT:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Empty XPath result");
|
||||
break;
|
||||
|
||||
default:
|
||||
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown error");
|
||||
}
|
||||
|
||||
if (!errorString.empty()) {
|
||||
errorText += QString(" (%1)").arg(QString::fromUtf8(errorString.c_str()));
|
||||
}
|
||||
|
||||
return errorText;
|
||||
}
|
40
plugins/FeedReader/gui/FeedReaderStringDefs.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef FEEDREADER_STRINGDEFS_H
|
||||
#define FEEDREADER_STRINGDEFS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
class FeedReaderStringDefs
|
||||
{
|
||||
public:
|
||||
static bool showError(QWidget *parent, RsFeedAddResult result, const QString &title, const QString &text);
|
||||
static QString workState(FeedInfo::WorkState state);
|
||||
static QString errorString(const FeedInfo &feedInfo);
|
||||
static QString errorString(RsFeedReaderErrorState errorState, const std::string &errorString);
|
||||
};
|
||||
|
||||
#endif
|
14
plugins/FeedReader/gui/FeedReader_images.qrc
Normal file
|
@ -0,0 +1,14 @@
|
|||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>images/FeedReader.png</file>
|
||||
<file>images/Root.png</file>
|
||||
<file>images/Folder.png</file>
|
||||
<file>images/Feed.png</file>
|
||||
<file>images/FeedProcessOverlay.png</file>
|
||||
<file>images/FeedErrorOverlay.png</file>
|
||||
<file>images/FolderAdd.png</file>
|
||||
<file>images/FeedAdd.png</file>
|
||||
<file>images/Link.png</file>
|
||||
<file>images/Update.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
766
plugins/FeedReader/gui/PreviewFeedDialog.cpp
Normal file
|
@ -0,0 +1,766 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
//#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "PreviewFeedDialog.h"
|
||||
#include "ui_PreviewFeedDialog.h"
|
||||
#include "FeedReaderNotify.h"
|
||||
#include "FeedReaderStringDefs.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
#include "interface/rsFeedReader.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "util/HTMLWrapper.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// not yet functional
|
||||
//PreviewItemDelegate::PreviewItemDelegate(QTreeWidget *parent) : QItemDelegate(parent)
|
||||
//{
|
||||
// connect(parent->header(), SIGNAL(sectionResized(int,int,int)), SLOT(sectionResized(int,int,int)));
|
||||
//}
|
||||
|
||||
//void PreviewItemDelegate::sectionResized(int logicalIndex, int /*oldSize*/, int /*newSize*/)
|
||||
//{
|
||||
// QHeaderView *header = dynamic_cast<QHeaderView*>(sender());
|
||||
// if (header) {
|
||||
// QTreeWidget *treeWidget = dynamic_cast<QTreeWidget*>(header->parent());
|
||||
// if (treeWidget) {
|
||||
// QModelIndex index = treeWidget->model()->index(0, logicalIndex, QModelIndex());
|
||||
// emit sizeHintChanged(index);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//void PreviewItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
|
||||
//{
|
||||
// QPen pen(painter->pen());
|
||||
// QFont font(painter->font());
|
||||
// QPalette::ColorGroup colorgroup(option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled);
|
||||
|
||||
// QTextOption textOption;
|
||||
// textOption.setWrapMode(QTextOption::WrapAnywhere);
|
||||
// textOption.setAlignment(option.displayAlignment);
|
||||
|
||||
// QRect textRect = rect.adjusted(5, 0, -5, 0); // remove width padding
|
||||
// textRect.setTop(qMin(rect.top(), option.rect.top()));
|
||||
// textRect.setHeight(qMax(rect.height(), option.rect.height()));
|
||||
|
||||
// if (option.state & QStyle::State_Selected) {
|
||||
// painter->fillRect(rect, option.palette.brush(colorgroup, QPalette::Highlight));
|
||||
// painter->setPen(option.palette.color(colorgroup, QPalette::HighlightedText));
|
||||
// } else {
|
||||
// painter->setPen(option.palette.color(colorgroup, QPalette::Text));
|
||||
// }
|
||||
|
||||
// if (option.state & QStyle::State_Editing) {
|
||||
// painter->save();
|
||||
// painter->setPen(option.palette.color(colorgroup, QPalette::Text));
|
||||
// painter->drawRect(rect.adjusted( 0, 0, -1, -1));
|
||||
// painter->restore();
|
||||
// }
|
||||
|
||||
// painter->setFont(option.font);
|
||||
// painter->drawText(textRect, text, textOption);
|
||||
|
||||
// // reset painter
|
||||
// painter->setFont(font);
|
||||
// painter->setPen(pen);
|
||||
//}
|
||||
|
||||
//void PreviewItemDelegate::drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const
|
||||
//{
|
||||
// if (option.state & QStyle::State_HasFocus) {
|
||||
// QRect textRect(rect);
|
||||
// textRect.setTop(qMin(rect.top(), option.rect.top()));
|
||||
// textRect.setHeight(qMax(rect.height(), option.rect.height()));
|
||||
|
||||
// QStyleOptionFocusRect optionFocusRect;
|
||||
// optionFocusRect.QStyleOption::operator=(option);
|
||||
// optionFocusRect.rect = textRect;
|
||||
// optionFocusRect.state |= QStyle::State_KeyboardFocusChange;
|
||||
// QPalette::ColorGroup colorgroup = (option.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled;
|
||||
// optionFocusRect.backgroundColor = option.palette.color(colorgroup, (option.state & QStyle::State_Selected) ? QPalette::Highlight : QPalette::Background);
|
||||
// QApplication::style()->drawPrimitive(QStyle::PE_FrameFocusRect, &optionFocusRect, painter);
|
||||
// }
|
||||
//}
|
||||
|
||||
//QSize PreviewItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
//{
|
||||
//// static bool inSizeHint = false;
|
||||
|
||||
//// if (inSizeHint) {
|
||||
//// return QSize();
|
||||
//// }
|
||||
//// inSizeHint = true;
|
||||
|
||||
// //d->viewport->width()
|
||||
// QSize size = QItemDelegate::sizeHint(option, index);
|
||||
// size.setHeight(50);
|
||||
|
||||
//// QTreeWidget *treeWidget = dynamic_cast<QTreeWidget*>(parent());
|
||||
//// if (treeWidget) {
|
||||
//// size.setWidth(treeWidget->header()->sectionSize(index.column()));
|
||||
|
||||
//// QString text = index.data(Qt::DisplayRole).toString();
|
||||
//// QRect displayRect = textRectangle(NULL, QRect(0, 0, size.width(), size.height()), option.font, text);
|
||||
//// QRect displayRect = treeWidget->visualRect(index);
|
||||
//// int width = treeWidget->columnWidth(index.column());
|
||||
//// int height = option.fontMetrics.boundingRect(QRect(0, 0, size.width(), 0), Qt::TextWrapAnywhere | Qt::TextLongestVariant, text).height();
|
||||
|
||||
//// if (height > size.height()) {
|
||||
//// size.setHeight(height);
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// inSizeHint = false;
|
||||
|
||||
// return size;
|
||||
//}
|
||||
|
||||
PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, QWidget *parent) :
|
||||
QDialog(parent, Qt::Window), mFeedReader(feedReader), mNotify(notify), ui(new Ui::PreviewFeedDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->feedNameLabel->clear();
|
||||
ui->useXPathCheckBox->setChecked(true);
|
||||
|
||||
/* connect signals */
|
||||
connect(ui->previousPushButton, SIGNAL(clicked()), this, SLOT(previousMsg()));
|
||||
connect(ui->nextPushButton, SIGNAL(clicked()), this, SLOT(nextMsg()));
|
||||
connect(ui->closeStructureButton, SIGNAL(clicked()), this, SLOT(showStructureFrame()));
|
||||
connect(ui->structureButton, SIGNAL(toggled(bool)), this, SLOT(showStructureFrame(bool)));
|
||||
connect(ui->xpathPushButton, SIGNAL(toggled(bool)), this, SLOT(showXPathFrame(bool)));
|
||||
connect(ui->useXPathCheckBox, SIGNAL(toggled(bool)), this, SLOT(fillStructureTree()));
|
||||
connect(ui->xpathUseListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(xpathListCustomPopupMenu(QPoint)));
|
||||
connect(ui->xpathRemoveListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(xpathListCustomPopupMenu(QPoint)));
|
||||
connect(ui->xpathUseListWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(xpathCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
|
||||
connect(ui->xpathRemoveListWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(xpathCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
|
||||
|
||||
connect(mNotify, SIGNAL(notifyFeedChanged(QString,int)), this, SLOT(feedChanged(QString,int)));
|
||||
connect(mNotify, SIGNAL(notifyMsgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
|
||||
|
||||
// ui->documentTreeWidget->setItemDelegate(new PreviewItemDelegate(ui->documentTreeWidget));
|
||||
ui->structureFrame->hide();
|
||||
|
||||
if (mFeedReader->addPreviewFeed(feedInfo, mFeedId)) {
|
||||
setFeedInfo("");
|
||||
} else {
|
||||
setFeedInfo(tr("Cannot create preview"));
|
||||
}
|
||||
setXPathInfo("");
|
||||
showXPathFrame(true);
|
||||
|
||||
/* fill xpath expressions */
|
||||
QListWidgetItem *item;
|
||||
std::string xpath;
|
||||
foreach(xpath, feedInfo.xpathsToUse){
|
||||
item = new QListWidgetItem(QString::fromUtf8(xpath.c_str()));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->xpathUseListWidget->addItem(item);
|
||||
}
|
||||
foreach(xpath, feedInfo.xpathsToRemove){
|
||||
item = new QListWidgetItem(QString::fromUtf8(xpath.c_str()));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->xpathRemoveListWidget->addItem(item);
|
||||
}
|
||||
|
||||
updateMsgCount();
|
||||
|
||||
ui->xpathUseListWidget->installEventFilter(this);
|
||||
ui->xpathRemoveListWidget->installEventFilter(this);
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
}
|
||||
|
||||
PreviewFeedDialog::~PreviewFeedDialog()
|
||||
{
|
||||
/* save settings */
|
||||
processSettings(false);
|
||||
|
||||
disconnect(mNotify);
|
||||
disconnect(mNotify);
|
||||
|
||||
if (!mFeedId.empty()) {
|
||||
mFeedReader->removeFeed(mFeedId);
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::processSettings(bool load)
|
||||
{
|
||||
Settings->beginGroup(QString("PreviewFeedDialog"));
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
QByteArray geometry = Settings->value("Geometry").toByteArray();
|
||||
if (!geometry.isEmpty()) {
|
||||
restoreGeometry(geometry);
|
||||
}
|
||||
} else {
|
||||
// save settings
|
||||
Settings->setValue("Geometry", saveGeometry());
|
||||
}
|
||||
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
bool PreviewFeedDialog::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
long todo_here;
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent) {
|
||||
if (keyEvent->key() == Qt::Key_Delete) {
|
||||
/* Delete pressed */
|
||||
if (obj == ui->xpathUseListWidget || obj == ui->xpathRemoveListWidget) {
|
||||
QListWidget *listWidget = dynamic_cast<QListWidget*>(obj);
|
||||
if (listWidget) {
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if (item) {
|
||||
delete(item);
|
||||
processXPath();
|
||||
}
|
||||
return true; // eat event
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* pass the event on to the parent class */
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::feedChanged(const QString &feedId, int type)
|
||||
{
|
||||
if (feedId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (feedId.toStdString() != mFeedId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == NOTIFY_TYPE_DEL) {
|
||||
/* feed deleted */
|
||||
mFeedId.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == NOTIFY_TYPE_ADD || type == NOTIFY_TYPE_MOD) {
|
||||
FeedInfo feedInfo;
|
||||
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
|
||||
return;
|
||||
}
|
||||
fillFeedInfo(feedInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::msgChanged(const QString &feedId, const QString &msgId, int type)
|
||||
{
|
||||
if (feedId.isEmpty() || msgId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (feedId.toStdString() != mFeedId) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case NOTIFY_TYPE_ADD:
|
||||
if (mMsgId.empty()) {
|
||||
mMsgId = msgId.toStdString();
|
||||
updateMsg();
|
||||
}
|
||||
break;
|
||||
case NOTIFY_TYPE_MOD:
|
||||
if (mMsgId == msgId.toStdString()) {
|
||||
updateMsg();
|
||||
}
|
||||
break;
|
||||
case NOTIFY_TYPE_DEL:
|
||||
if (mMsgId == msgId.toStdString()) {
|
||||
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
|
||||
if (it != mMsgIds.end()) {
|
||||
++it;
|
||||
if (it != mMsgIds.end()) {
|
||||
mMsgId = *it;
|
||||
} else {
|
||||
--it;
|
||||
if (it != mMsgIds.begin()) {
|
||||
--it;
|
||||
mMsgId = *it;
|
||||
} else {
|
||||
mMsgId.clear();
|
||||
}
|
||||
}
|
||||
updateMsg();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* calculate message count */
|
||||
mMsgIds.clear();
|
||||
mFeedReader->getFeedMsgIdList(mFeedId, mMsgIds);
|
||||
|
||||
updateMsgCount();
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::showStructureFrame(bool show)
|
||||
{
|
||||
ui->structureButton->setChecked(show);
|
||||
ui->structureFrame->setVisible(show);
|
||||
|
||||
if (show) {
|
||||
fillStructureTree();
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::showXPathFrame(bool show)
|
||||
{
|
||||
ui->xpathFrame->setVisible(show);
|
||||
|
||||
if (show) {
|
||||
ui->xpathPushButton->setToolTip(tr("Hide XPath expressions"));
|
||||
ui->xpathPushButton->setIcon(QIcon(":images/show_toolbox_frame.png"));
|
||||
} else {
|
||||
ui->xpathPushButton->setToolTip(tr("Show XPath expressions"));
|
||||
ui->xpathPushButton->setIcon(QIcon(":images/hide_toolbox_frame.png"));
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::xpathListCustomPopupMenu(QPoint /*point*/)
|
||||
{
|
||||
QListWidgetItem *item = NULL;
|
||||
|
||||
if (sender() == ui->xpathUseListWidget) {
|
||||
item = ui->xpathUseListWidget->currentItem();
|
||||
} else if (sender() == ui->xpathRemoveListWidget) {
|
||||
item = ui->xpathRemoveListWidget->currentItem();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu contextMnu(this);
|
||||
|
||||
QAction *action = contextMnu.addAction(QIcon(), tr("Add"), this, SLOT(addXPath()));
|
||||
action->setData(QVariant::fromValue(sender()));
|
||||
|
||||
action = contextMnu.addAction(QIcon(), tr("Edit"), this, SLOT(editXPath()));
|
||||
action->setData(QVariant::fromValue(sender()));
|
||||
if (!item) {
|
||||
action->setEnabled(false);
|
||||
}
|
||||
|
||||
action = contextMnu.addAction(QIcon(), tr("Delete"), this, SLOT(removeXPath()));
|
||||
action->setData(QVariant::fromValue(sender()));
|
||||
if (!item) {
|
||||
action->setEnabled(false);
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
|
||||
void PreviewFeedDialog::xpathCloseEditor(QWidget */*editor*/, QAbstractItemDelegate::EndEditHint /*hint*/)
|
||||
{
|
||||
processXPath();
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::addXPath()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*>(sender());
|
||||
if (!action) {
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *source = action->data().value<QObject*>();
|
||||
|
||||
QListWidget *listWidget;
|
||||
if (source == ui->xpathUseListWidget) {
|
||||
listWidget = ui->xpathUseListWidget;
|
||||
} else if (source == ui->xpathRemoveListWidget) {
|
||||
listWidget = ui->xpathRemoveListWidget;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
listWidget->addItem(item);
|
||||
|
||||
listWidget->editItem(item);
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::editXPath()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*>(sender());
|
||||
if (!action) {
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *source = action->data().value<QObject*>();
|
||||
|
||||
QListWidget *listWidget;
|
||||
if (source == ui->xpathUseListWidget) {
|
||||
listWidget = ui->xpathUseListWidget;
|
||||
} else if (source == ui->xpathRemoveListWidget) {
|
||||
listWidget = ui->xpathRemoveListWidget;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
listWidget->editItem(listWidget->currentItem());
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::removeXPath()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*>(sender());
|
||||
if (!action) {
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *source = action->data().value<QObject*>();
|
||||
|
||||
QListWidget *listWidget;
|
||||
if (source == ui->xpathUseListWidget) {
|
||||
listWidget = ui->xpathUseListWidget;
|
||||
} else if (source == ui->xpathRemoveListWidget) {
|
||||
listWidget = ui->xpathRemoveListWidget;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if (item) {
|
||||
delete(item);
|
||||
}
|
||||
|
||||
processXPath();
|
||||
}
|
||||
|
||||
int PreviewFeedDialog::getMsgPos()
|
||||
{
|
||||
int pos = -1;
|
||||
std::list<std::string>::iterator it;
|
||||
for (it = mMsgIds.begin(); it != mMsgIds.end(); ++it) {
|
||||
++pos;
|
||||
if (*it == mMsgId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::setFeedInfo(const QString &info)
|
||||
{
|
||||
ui->feedInfoLabel->setText(info);
|
||||
ui->feedInfoLabel->setVisible(!info.isEmpty());
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::setXPathInfo(const QString &info)
|
||||
{
|
||||
ui->xpathInfoLabel->setText(info);
|
||||
ui->xpathInfoLabel->setVisible(!info.isEmpty());
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::fillFeedInfo(const FeedInfo &feedInfo)
|
||||
{
|
||||
QString name = feedInfo.name.empty() ? tr("No name") : QString::fromUtf8(feedInfo.name.c_str());
|
||||
|
||||
QString workState = FeedReaderStringDefs::workState(feedInfo.workstate);
|
||||
if (!workState.isEmpty()) {
|
||||
name += QString(" (%1)").arg(workState);
|
||||
}
|
||||
ui->feedNameLabel->setText(name);
|
||||
|
||||
setFeedInfo(FeedReaderStringDefs::errorString(feedInfo));
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::previousMsg()
|
||||
{
|
||||
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
|
||||
if (it != mMsgIds.end()) {
|
||||
if (it != mMsgIds.begin()) {
|
||||
--it;
|
||||
mMsgId = *it;
|
||||
updateMsg();
|
||||
updateMsgCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::nextMsg()
|
||||
{
|
||||
std::list<std::string>::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId);
|
||||
if (it != mMsgIds.end()) {
|
||||
++it;
|
||||
if (it != mMsgIds.end()) {
|
||||
mMsgId = *it;
|
||||
updateMsg();
|
||||
updateMsgCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::updateMsgCount()
|
||||
{
|
||||
int pos = getMsgPos();
|
||||
ui->messageCountLabel->setText(QString("%1/%2").arg(pos + 1).arg(mMsgIds.size()));
|
||||
|
||||
ui->previousPushButton->setEnabled(pos > 0);
|
||||
ui->nextPushButton->setEnabled(pos + 1 < (int) mMsgIds.size());
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::updateMsg()
|
||||
{
|
||||
FeedMsgInfo msgInfo;
|
||||
if (mMsgId.empty() || !mFeedReader->getMsgInfo(mFeedId, mMsgId, msgInfo)) {
|
||||
ui->msgTitle->clear();
|
||||
ui->msgText->clear();
|
||||
mDescription.clear();
|
||||
mDescriptionXPath.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
ui->msgTitle->setText(QString::fromUtf8(msgInfo.title.c_str()));
|
||||
|
||||
/* store description */
|
||||
mDescription = msgInfo.description;
|
||||
|
||||
/* process xpath */
|
||||
processXPath();
|
||||
}
|
||||
|
||||
static void buildNodeText(HTMLWrapper &html, xmlNodePtr node, QString &text)
|
||||
{
|
||||
switch (node->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
text = QString("<%1 ").arg(QString::fromUtf8(html.nodeName(node).c_str()));
|
||||
|
||||
for (xmlAttrPtr attr = node->properties; attr; attr = attr->next) {
|
||||
QString value = QString::fromUtf8(html.getAttr(node, attr).c_str());
|
||||
if (value.length() > 100) {
|
||||
value = value.left(100) + "...";
|
||||
}
|
||||
text += QString("%1=\"%2\" ").arg(QString::fromUtf8(html.attrName(attr).c_str()), value);
|
||||
}
|
||||
text = text.trimmed() + ">";
|
||||
|
||||
if (node->children && !node->children->next && node->children->type == XML_TEXT_NODE) {
|
||||
/* only one text node as child */
|
||||
std::string content;
|
||||
if (html.getContent(node->children, content)) {
|
||||
text += QString::fromUtf8(content.c_str());
|
||||
} else {
|
||||
text += QApplication::translate("PreviewFeedDialog", "Error getting content");
|
||||
}
|
||||
text += QString("<%1>").arg(QString::fromUtf8(html.nodeName(node).c_str()));
|
||||
|
||||
xmlUnlinkNode(node->children);
|
||||
xmlFreeNode(node->children);
|
||||
}
|
||||
break;
|
||||
case XML_TEXT_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
{
|
||||
if (node->type == XML_COMMENT_NODE) {
|
||||
text = "<!-- ";
|
||||
}
|
||||
|
||||
std::string content;
|
||||
if (html.getContent(node, content)) {
|
||||
text += QString::fromUtf8(content.c_str());
|
||||
} else {
|
||||
text += QApplication::translate("PreviewFeedDialog", "Error getting content");
|
||||
}
|
||||
|
||||
if (node->type == XML_COMMENT_NODE) {
|
||||
text += " -->";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_ENTITY_REF_NODE:
|
||||
case XML_ENTITY_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_DOCUMENT_TYPE_NODE:
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
case XML_NOTATION_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
case XML_DTD_NODE:
|
||||
case XML_ELEMENT_DECL:
|
||||
case XML_ATTRIBUTE_DECL:
|
||||
case XML_ENTITY_DECL:
|
||||
case XML_NAMESPACE_DECL:
|
||||
case XML_XINCLUDE_START:
|
||||
case XML_XINCLUDE_END:
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
case XML_DOCB_DOCUMENT_NODE:
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void examineChildElements(QTreeWidget *treeWidget, HTMLWrapper &html, QList<xmlNodePtr> &nodes, QTreeWidgetItem *parentItem)
|
||||
{
|
||||
int childIndex = 0;
|
||||
int childCount;
|
||||
|
||||
QList<QPair<xmlNodePtr, QTreeWidgetItem*> > nodeItems;
|
||||
foreach (xmlNodePtr node, nodes) {
|
||||
QString text;
|
||||
buildNodeText(html, node, text);
|
||||
|
||||
QList<QTreeWidgetItem*> itemsToDelete;
|
||||
QTreeWidgetItem *item = NULL;
|
||||
|
||||
childCount = parentItem->childCount();
|
||||
for (int index = childIndex; index < childCount; ++index) {
|
||||
QTreeWidgetItem *childItem = parentItem->child(index);
|
||||
if (childItem->text(0) == text) {
|
||||
/* reuse item */
|
||||
item = childItem;
|
||||
break;
|
||||
}
|
||||
itemsToDelete.push_back(childItem);
|
||||
}
|
||||
|
||||
if (item) {
|
||||
/* delete old items */
|
||||
foreach (QTreeWidgetItem *item, itemsToDelete) {
|
||||
delete(item);
|
||||
}
|
||||
++childIndex;
|
||||
} else {
|
||||
item = new QTreeWidgetItem;
|
||||
item->setText(0, text);
|
||||
parentItem->insertChild(childIndex, item);
|
||||
item->setExpanded(true);
|
||||
|
||||
++childIndex;
|
||||
}
|
||||
|
||||
nodeItems.push_back(QPair<xmlNodePtr, QTreeWidgetItem*>(node, item));
|
||||
}
|
||||
|
||||
/* delete not used items */
|
||||
while (childIndex < parentItem->childCount()) {
|
||||
delete(parentItem->child(childIndex));
|
||||
}
|
||||
|
||||
QList<QPair<xmlNodePtr, QTreeWidgetItem*> >::iterator nodeItem;
|
||||
for (nodeItem = nodeItems.begin(); nodeItem != nodeItems.end(); ++nodeItem) {
|
||||
QList<xmlNodePtr> childNodes;
|
||||
for (xmlNodePtr childNode = nodeItem->first->children; childNode; childNode = childNode->next) {
|
||||
childNodes.push_back(childNode);
|
||||
}
|
||||
examineChildElements(treeWidget, html, childNodes, nodeItem->second);
|
||||
}
|
||||
|
||||
// QLabel *label = new QLabel(text);
|
||||
// label->setTextFormat(Qt::PlainText);
|
||||
// label->setWordWrap(true);
|
||||
// treeWidget->setItemWidget(item, 0, label);
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::fillStructureTree()
|
||||
{
|
||||
if (!ui->structureTreeWidget->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (ui->structureTreeWidget->topLevelItemCount() > 0) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (mDescriptionXPath.empty()) {
|
||||
ui->structureTreeWidget->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
bool useXPath = ui->useXPathCheckBox->isChecked();
|
||||
|
||||
HTMLWrapper html;
|
||||
if (!html.readHTML(useXPath ? mDescriptionXPath.c_str() : mDescription.c_str(), "")) {
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
item->setText(0, tr("Error parsing document"));
|
||||
ui->structureTreeWidget->addTopLevelItem(item);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr root = html.getRootElement();
|
||||
if (!root) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<xmlNodePtr> nodes;
|
||||
nodes.push_back(root);
|
||||
examineChildElements(ui->structureTreeWidget, html, nodes, ui->structureTreeWidget->invisibleRootItem());
|
||||
ui->structureTreeWidget->resizeColumnToContents(0);
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::getXPaths(std::list<std::string> &xpathsToUse, std::list<std::string> &xpathsToRemove)
|
||||
{
|
||||
int row;
|
||||
int rowCount = ui->xpathUseListWidget->count();
|
||||
for (row = 0; row < rowCount; ++row) {
|
||||
xpathsToUse.push_back(ui->xpathUseListWidget->item(row)->text().toUtf8().constData());
|
||||
}
|
||||
|
||||
rowCount = ui->xpathRemoveListWidget->count();
|
||||
for (row = 0; row < rowCount; ++row) {
|
||||
xpathsToRemove.push_back(ui->xpathRemoveListWidget->item(row)->text().toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFeedDialog::processXPath()
|
||||
{
|
||||
std::list<std::string> xpathsToUse;
|
||||
std::list<std::string> xpathsToRemove;
|
||||
|
||||
getXPaths(xpathsToUse, xpathsToRemove);
|
||||
|
||||
mDescriptionXPath = mDescription;
|
||||
std::string errorString;
|
||||
RsFeedReaderErrorState result = mFeedReader->processXPath(xpathsToUse, xpathsToRemove, mDescriptionXPath, errorString);
|
||||
setXPathInfo(FeedReaderStringDefs::errorString(result, errorString));
|
||||
|
||||
/* fill message */
|
||||
QString msgTxt = RsHtml().formatText(ui->msgText->document(), QString::fromUtf8(mDescriptionXPath.c_str()), RSHTML_FORMATTEXT_EMBED_LINKS);
|
||||
ui->msgText->setHtml(msgTxt);
|
||||
|
||||
/* fill structure */
|
||||
fillStructureTree();
|
||||
}
|
104
plugins/FeedReader/gui/PreviewFeedDialog.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef PREVIEWFEEDDIALOG_H
|
||||
#define PREVIEWFEEDDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QItemDelegate>
|
||||
|
||||
namespace Ui {
|
||||
class PreviewFeedDialog;
|
||||
}
|
||||
|
||||
class QTreeWidget;
|
||||
class RsFeedReader;
|
||||
class FeedReaderNotify;
|
||||
class FeedInfo;
|
||||
|
||||
// not yet functional
|
||||
//class PreviewItemDelegate : public QItemDelegate
|
||||
//{
|
||||
// Q_OBJECT
|
||||
|
||||
//public:
|
||||
// PreviewItemDelegate(QTreeWidget *parent);
|
||||
|
||||
//private slots:
|
||||
// void sectionResized(int logicalIndex, int oldSize, int newSize);
|
||||
|
||||
//protected:
|
||||
// virtual void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const;
|
||||
// virtual void drawFocus(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect) const;
|
||||
// virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
//};
|
||||
|
||||
class PreviewFeedDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, QWidget *parent = 0);
|
||||
~PreviewFeedDialog();
|
||||
|
||||
void getXPaths(std::list<std::string> &xpathsToUse, std::list<std::string> &xpathsToRemove);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
||||
private slots:
|
||||
void previousMsg();
|
||||
void nextMsg();
|
||||
void showStructureFrame(bool show = false);
|
||||
void showXPathFrame(bool show);
|
||||
void xpathListCustomPopupMenu(QPoint point);
|
||||
void xpathCloseEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
|
||||
void addXPath();
|
||||
void editXPath();
|
||||
void removeXPath();
|
||||
void fillStructureTree();
|
||||
|
||||
/* FeedReaderNotify */
|
||||
void feedChanged(const QString &feedId, int type);
|
||||
void msgChanged(const QString &feedId, const QString &msgId, int type);
|
||||
|
||||
private:
|
||||
void processSettings(bool load);
|
||||
int getMsgPos();
|
||||
void setFeedInfo(const QString &info);
|
||||
void setXPathInfo(const QString &info);
|
||||
void fillFeedInfo(const FeedInfo &feedInfo);
|
||||
void updateMsgCount();
|
||||
void updateMsg();
|
||||
void processXPath();
|
||||
|
||||
RsFeedReader *mFeedReader;
|
||||
FeedReaderNotify *mNotify;
|
||||
std::string mFeedId;
|
||||
std::string mMsgId;
|
||||
std::list<std::string> mMsgIds;
|
||||
std::string mDescription;
|
||||
std::string mDescriptionXPath;
|
||||
|
||||
Ui::PreviewFeedDialog *ui;
|
||||
};
|
||||
|
||||
#endif // PREVIEWFEEDDIALOG_H
|
547
plugins/FeedReader/gui/PreviewFeedDialog.ui
Normal file
|
@ -0,0 +1,547 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PreviewFeedDialog</class>
|
||||
<widget class="QDialog" name="PreviewFeedDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>783</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="textLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="feedNameLabel">
|
||||
<property name="text">
|
||||
<string>Feed name</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="feedInfoLabel">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>118</red>
|
||||
<green>116</green>
|
||||
<blue>108</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Feed information</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="xpathInfoLabel">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>118</red>
|
||||
<green>116</green>
|
||||
<blue>108</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">XPath information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="buttonLayout">
|
||||
<item>
|
||||
<spacer name="buttonSpacerLeft">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="previousPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Previous</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="messageCountLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0/0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="nextPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="buttonSpacerRight">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="structureButton">
|
||||
<property name="text">
|
||||
<string>Structure</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="titleLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Titel:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="msgTitle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel#msgTitle{
|
||||
border: 2px solid #CCCCCC;
|
||||
border-radius: 6px;
|
||||
background: white;}</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="messageSplitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QTextBrowser" name="msgText"/>
|
||||
<widget class="QFrame" name="structureFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="structureLayout2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="structureSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="closeStructureButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QToolButton
|
||||
{
|
||||
border-image: url(:/images/closenormal.png)
|
||||
}
|
||||
|
||||
QToolButton:hover
|
||||
{
|
||||
border-image: url(:/images/closehover.png)
|
||||
}
|
||||
|
||||
QToolButton:pressed {
|
||||
border-image: url(:/images/closepressed.png)
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="structureLayout1">
|
||||
<item>
|
||||
<widget class="QSplitter" name="structureSplitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QFrame" name="structureTreeFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useXPathCheckBox">
|
||||
<property name="text">
|
||||
<string>Use XPath</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="structureTreeWidget">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QFrame" name="xpathFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="xpathUseLabel">
|
||||
<property name="text">
|
||||
<string>XPath use</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="xpathUseListWidget">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="xpathRemoveLabel">
|
||||
<property name="text">
|
||||
<string>XPath remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="xpathRemoveListWidget">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="xpathLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="xpathPushButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="previewLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PreviewFeedDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>339</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PreviewFeedDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>326</x>
|
||||
<y>339</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
BIN
plugins/FeedReader/gui/images/Feed.png
Normal file
After Width: | Height: | Size: 641 B |
BIN
plugins/FeedReader/gui/images/FeedAdd.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
plugins/FeedReader/gui/images/FeedErrorOverlay.png
Normal file
After Width: | Height: | Size: 193 B |
BIN
plugins/FeedReader/gui/images/FeedProcessOverlay.png
Normal file
After Width: | Height: | Size: 848 B |
BIN
plugins/FeedReader/gui/images/FeedReader.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
plugins/FeedReader/gui/images/Folder.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
plugins/FeedReader/gui/images/FolderAdd.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
plugins/FeedReader/gui/images/Link.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
plugins/FeedReader/gui/images/Root.png
Normal file
After Width: | Height: | Size: 968 B |
BIN
plugins/FeedReader/gui/images/Update.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
207
plugins/FeedReader/interface/rsFeedReader.h
Normal file
|
@ -0,0 +1,207 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef RETROSHARE_FEEDREADER_GUI_INTERFACE_H
|
||||
#define RETROSHARE_FEEDREADER_GUI_INTERFACE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
enum RsFeedReaderErrorState {
|
||||
RS_FEED_ERRORSTATE_OK = 0,
|
||||
|
||||
/* download */
|
||||
RS_FEED_ERRORSTATE_DOWNLOAD_INTERNAL_ERROR = 1,
|
||||
RS_FEED_ERRORSTATE_DOWNLOAD_ERROR = 2,
|
||||
RS_FEED_ERRORSTATE_DOWNLOAD_UNKNOWN_CONTENT_TYPE = 3,
|
||||
RS_FEED_ERRORSTATE_DOWNLOAD_NOT_FOUND = 4,
|
||||
RS_FEED_ERRORSTATE_DOWNLOAD_UNKOWN_RESPONSE_CODE = 5,
|
||||
|
||||
/* process */
|
||||
RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR = 50,
|
||||
RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT = 51,
|
||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE = 100,
|
||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND = 101,
|
||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_ADMIN = 102,
|
||||
RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_ANONYMOUS = 103,
|
||||
|
||||
RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR = 150,
|
||||
RS_FEED_ERRORSTATE_PROCESS_XPATH_INTERNAL_ERROR = 151,
|
||||
RS_FEED_ERRORSTATE_PROCESS_XPATH_WRONG_EXPRESSION = 152,
|
||||
RS_FEED_ERRORSTATE_PROCESS_XPATH_NO_RESULT = 153
|
||||
};
|
||||
|
||||
|
||||
class RsFeedReader;
|
||||
extern RsFeedReader *rsFeedReader;
|
||||
|
||||
enum RsFeedAddResult
|
||||
{
|
||||
RS_FEED_ADD_RESULT_SUCCESS,
|
||||
RS_FEED_ADD_RESULT_FEED_NOT_FOUND,
|
||||
RS_FEED_ADD_RESULT_PARENT_NOT_FOUND,
|
||||
RS_FEED_ADD_RESULT_PARENT_IS_NO_FOLDER,
|
||||
RS_FEED_ADD_RESULT_FEED_IS_FOLDER,
|
||||
RS_FEED_ADD_RESULT_FEED_IS_NO_FOLDER
|
||||
};
|
||||
|
||||
class FeedInfo
|
||||
{
|
||||
public:
|
||||
enum WorkState
|
||||
{
|
||||
WAITING,
|
||||
WAITING_TO_DOWNLOAD,
|
||||
DOWNLOADING,
|
||||
WAITING_TO_PROCESS,
|
||||
PROCESSING
|
||||
};
|
||||
|
||||
public:
|
||||
FeedInfo()
|
||||
{
|
||||
proxyPort = 0;
|
||||
updateInterval = 0;
|
||||
lastUpdate = 0;
|
||||
storageTime = 0;
|
||||
errorState = RS_FEED_ERRORSTATE_OK;
|
||||
flag.folder = false;
|
||||
flag.infoFromFeed = false;
|
||||
flag.standardStorageTime = false;
|
||||
flag.standardUpdateInterval = false;
|
||||
flag.standardProxy = false;
|
||||
flag.authentication = false;
|
||||
flag.deactivated = false;
|
||||
flag.forum = false;
|
||||
flag.updateForumInfo = false;
|
||||
flag.embedImages = false;
|
||||
flag.saveCompletePage = false;
|
||||
flag.preview = false;
|
||||
}
|
||||
|
||||
std::string feedId;
|
||||
std::string parentId;
|
||||
std::string url;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string icon;
|
||||
std::string user;
|
||||
std::string password;
|
||||
std::string proxyAddress;
|
||||
uint16_t proxyPort;
|
||||
uint32_t updateInterval;
|
||||
time_t lastUpdate;
|
||||
uint32_t storageTime;
|
||||
std::string forumId;
|
||||
WorkState workstate;
|
||||
RsFeedReaderErrorState errorState;
|
||||
std::string errorString;
|
||||
|
||||
std::list<std::string> xpathsToUse;
|
||||
std::list<std::string> xpathsToRemove;
|
||||
|
||||
struct {
|
||||
bool folder : 1;
|
||||
bool infoFromFeed : 1;
|
||||
bool standardStorageTime : 1;
|
||||
bool standardUpdateInterval : 1;
|
||||
bool standardProxy : 1;
|
||||
bool authentication : 1;
|
||||
bool deactivated : 1;
|
||||
bool forum : 1;
|
||||
bool updateForumInfo : 1;
|
||||
bool embedImages : 1;
|
||||
bool saveCompletePage : 1;
|
||||
bool preview : 1;
|
||||
} flag;
|
||||
};
|
||||
|
||||
class FeedMsgInfo
|
||||
{
|
||||
public:
|
||||
FeedMsgInfo()
|
||||
{
|
||||
pubDate = 0;
|
||||
flag.isnew = false;
|
||||
flag.read = false;
|
||||
}
|
||||
|
||||
std::string msgId;
|
||||
std::string feedId;
|
||||
std::string title;
|
||||
std::string link;
|
||||
std::string author;
|
||||
std::string description;
|
||||
time_t pubDate;
|
||||
|
||||
struct {
|
||||
bool isnew : 1;
|
||||
bool read : 1;
|
||||
} flag;
|
||||
};
|
||||
|
||||
class RsFeedReaderNotify
|
||||
{
|
||||
public:
|
||||
RsFeedReaderNotify() {}
|
||||
|
||||
virtual void feedChanged(const std::string &/*feedId*/, int /*type*/) {}
|
||||
virtual void msgChanged(const std::string &/*feedId*/, const std::string &/*msgId*/, int /*type*/) {}
|
||||
};
|
||||
|
||||
class RsFeedReader
|
||||
{
|
||||
public:
|
||||
RsFeedReader() {}
|
||||
virtual ~RsFeedReader() {}
|
||||
|
||||
virtual void stop() = 0;
|
||||
virtual void setNotify(RsFeedReaderNotify *notify) = 0;
|
||||
|
||||
virtual uint32_t getStandardStorageTime() = 0;
|
||||
virtual void setStandardStorageTime(uint32_t storageTime) = 0;
|
||||
virtual uint32_t getStandardUpdateInterval() = 0;
|
||||
virtual void setStandardUpdateInterval(uint32_t updateInterval) = 0;
|
||||
virtual bool getStandardProxy(std::string &proxyAddress, uint16_t &proxyPort) = 0;
|
||||
virtual void setStandardProxy(bool useProxy, const std::string &proxyAddress, uint16_t proxyPort) = 0;
|
||||
|
||||
virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId) = 0;
|
||||
virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name) = 0;
|
||||
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId) = 0;
|
||||
virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo) = 0;
|
||||
virtual bool removeFeed(const std::string &feedId) = 0;
|
||||
virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) = 0;
|
||||
virtual void getFeedList(const std::string &parentId, std::list<FeedInfo> &feedInfos) = 0;
|
||||
virtual bool getFeedInfo(const std::string &feedId, FeedInfo &feedInfo) = 0;
|
||||
virtual bool getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo) = 0;
|
||||
virtual bool removeMsg(const std::string &feedId, const std::string &msgId) = 0;
|
||||
virtual bool removeMsgs(const std::string &feedId, const std::list<std::string> &msgIds) = 0;
|
||||
virtual bool getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount) = 0;
|
||||
virtual bool getFeedMsgList(const std::string &feedId, std::list<FeedMsgInfo> &msgInfos) = 0;
|
||||
virtual bool getFeedMsgIdList(const std::string &feedId, std::list<std::string> &msgIds) = 0;
|
||||
virtual bool processFeed(const std::string &feedId) = 0;
|
||||
virtual bool setMessageRead(const std::string &feedId, const std::string &msgId, bool read) = 0;
|
||||
|
||||
virtual RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString) = 0;
|
||||
};
|
||||
|
||||
#endif
|
339
plugins/FeedReader/lang/FeedReader_de.ts
Normal file
|
@ -0,0 +1,339 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="de_DE">
|
||||
<context>
|
||||
<name>AddLinksDialog</name>
|
||||
<message>
|
||||
<location filename="../AddLinksDialog.ui" line="+14"/>
|
||||
<location line="+81"/>
|
||||
<source>Add Link</source>
|
||||
<translation>Link hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-30"/>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:18pt; font-weight:600; color:#ffffff;">Add Link to Cloud</span></p></body></html></source>
|
||||
<translation><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:18pt; font-weight:600; color:#ffffff;">Link zur Wolke hinzufügen</span></p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+23"/>
|
||||
<source>Cancel</source>
|
||||
<translation>Abbrechen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+33"/>
|
||||
<source>Add a new Link</source>
|
||||
<translation>Neuen Link hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+13"/>
|
||||
<source>Title:</source>
|
||||
<translation>Titel:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+7"/>
|
||||
<source>Url:</source>
|
||||
<translation>Url:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+50"/>
|
||||
<source>Add Anonymous Link</source>
|
||||
<translation>Anonym hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>+2 Great!</source>
|
||||
<translation>+2 Großartig!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>+1 Good</source>
|
||||
<translation>+1 Gut</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>0 Okay</source>
|
||||
<translation>0 In Ordnung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>-1 Sux</source>
|
||||
<translation>-1 Nervt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>-2 Bad Link</source>
|
||||
<translation>-2 Schlechter Link</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../AddLinksDialog.cpp" line="+58"/>
|
||||
<source>New Link</source>
|
||||
<translation>Neuer Link</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+28"/>
|
||||
<source>Add Link Failure</source>
|
||||
<translation>Link hinzufügen fehlgeschlagen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>Missing Link and/or Title</source>
|
||||
<translation>Titel und/oder Url fehlt</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LinksCloudPlugin</name>
|
||||
<message>
|
||||
<location filename="../LinksCloudPlugin.cpp" line="+81"/>
|
||||
<source>This plugin provides a set of cached links, and a voting system to promote them.</source>
|
||||
<translation>Das Plugin stellt Links und ein Wahlsystem zur Verfügung, um sie zu verbreiten.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>LinksCloud</source>
|
||||
<translation>Verknüpfungswolke</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LinksDialog</name>
|
||||
<message>
|
||||
<location filename="../LinksDialog.ui" line="+48"/>
|
||||
<source>Title / Comment</source>
|
||||
<translation>Titel / Kommentar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>Score</source>
|
||||
<translation>Punkte</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>Peer / Link</source>
|
||||
<translation>Nachbar / Link</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+38"/>
|
||||
<source>Sort by</source>
|
||||
<translation>Sortiere nach</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>Combo</source>
|
||||
<translation>Kombiniert</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>Time</source>
|
||||
<translation>Zeit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>Ranking</source>
|
||||
<translation>Platzierung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+31"/>
|
||||
<source>In last</source>
|
||||
<translation>Im letzten</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>Month</source>
|
||||
<translation>Monat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>Week</source>
|
||||
<translation>Woche</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>Day</source>
|
||||
<translatorcomment>Tag</translatorcomment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+31"/>
|
||||
<source>From</source>
|
||||
<translation>Von</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>All Peers</source>
|
||||
<translation>Alle Nachbarn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>Own Links</source>
|
||||
<translation>Eigene Links</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+31"/>
|
||||
<source>Show</source>
|
||||
<translation>Zeige</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>Top 100</source>
|
||||
<translation>Top 100</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>101-200</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>201-300</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>301-400</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>401-500</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>Bottom 100</source>
|
||||
<translation>Letzten 100</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+35"/>
|
||||
<source>Link:</source>
|
||||
<translation>Link:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+32"/>
|
||||
<source>Add Anonymous Link</source>
|
||||
<translation>Anonym hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+7"/>
|
||||
<source>Add Link/Comment</source>
|
||||
<translation>Link/Kommentar hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+11"/>
|
||||
<source>Title:</source>
|
||||
<translation>Titel:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+16"/>
|
||||
<source>Score:</source>
|
||||
<translation>Punkte:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>+2 Great!</source>
|
||||
<translation>+2 Großartig!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>+1 Good</source>
|
||||
<translation>+1 Gut</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>0 Okay</source>
|
||||
<translation>0 In Ordnung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>-1 Sux</source>
|
||||
<translation>-1 Nervt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+9"/>
|
||||
<source>-2 Bad Link</source>
|
||||
<translation>-2 Schlechter Link</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+16"/>
|
||||
<source>Url:</source>
|
||||
<translation>Url:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+87"/>
|
||||
<source><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-weight:600;">Links Cloud</span></p></body></html></source>
|
||||
<translation><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-weight:600;">Verknüpfungswolke</span></p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+28"/>
|
||||
<source>Add new link</source>
|
||||
<translation>Neuen Link hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../LinksDialog.cpp" line="+139"/>
|
||||
<source>Share Link Anonymously</source>
|
||||
<translation>Link anonym verteilen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Vote on Link</source>
|
||||
<translation>Wähle für Link</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+19"/>
|
||||
<source>Download</source>
|
||||
<translation>Herunterladen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+655"/>
|
||||
<source>Expand</source>
|
||||
<translation>Erweitern</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+7"/>
|
||||
<source>Hide</source>
|
||||
<translation>Verbergen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+195"/>
|
||||
<source>File Request Confirmation</source>
|
||||
<translation>Bestätigung der Dateianforderung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>The file has been added to your download list.</source>
|
||||
<translation>Die Datei wurde zur Downloadliste hinzugefügt.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+6"/>
|
||||
<source>File Request canceled</source>
|
||||
<translation>Dateianforderung abgebrochen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>The file has not been added to your download list, because you already have it.</source>
|
||||
<translation>Die folgende Datei wurde nicht zur Downloadliste hinzugefügt, da Du diese schon hast.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+6"/>
|
||||
<source>File Request Error</source>
|
||||
<translation>Fehler bei der Dateianforderung</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>The file link is malformed.</source>
|
||||
<translation>Link ist fehlerhaft.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
5
plugins/FeedReader/lang/lang.qrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/lang">
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
1935
plugins/FeedReader/services/p3FeedReader.cc
Normal file
122
plugins/FeedReader/services/p3FeedReader.h
Normal file
|
@ -0,0 +1,122 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef P3_FEEDREADER
|
||||
#define P3_FEEDREADER
|
||||
|
||||
#include "retroshare/rsplugin.h"
|
||||
#include "plugins/rspqiservice.h"
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
class RsFeedReaderFeed;
|
||||
class RsFeedReaderMsg;
|
||||
class p3FeedReaderThread;
|
||||
|
||||
class p3FeedReader : public RsPQIService, public RsFeedReader
|
||||
{
|
||||
public:
|
||||
p3FeedReader(RsPluginHandler *pgHandler);
|
||||
|
||||
/****************** FeedReader Interface *************/
|
||||
virtual void stop();
|
||||
virtual void setNotify(RsFeedReaderNotify *notify);
|
||||
|
||||
virtual uint32_t getStandardStorageTime();
|
||||
virtual void setStandardStorageTime(uint32_t storageTime);
|
||||
virtual uint32_t getStandardUpdateInterval();
|
||||
virtual void setStandardUpdateInterval(uint32_t updateInterval);
|
||||
virtual bool getStandardProxy(std::string &proxyAddress, uint16_t &proxyPort);
|
||||
virtual void setStandardProxy(bool useProxy, const std::string &proxyAddress, uint16_t proxyPort);
|
||||
|
||||
virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId);
|
||||
virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name);
|
||||
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId);
|
||||
virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo);
|
||||
virtual bool removeFeed(const std::string &feedId);
|
||||
virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId);
|
||||
virtual void getFeedList(const std::string &parentId, std::list<FeedInfo> &feedInfos);
|
||||
virtual bool getFeedInfo(const std::string &feedId, FeedInfo &feedInfo);
|
||||
virtual bool getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo);
|
||||
virtual bool removeMsg(const std::string &feedId, const std::string &msgId);
|
||||
virtual bool removeMsgs(const std::string &feedId, const std::list<std::string> &msgIds);
|
||||
virtual bool getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount);
|
||||
virtual bool getFeedMsgList(const std::string &feedId, std::list<FeedMsgInfo> &msgInfos);
|
||||
virtual bool getFeedMsgIdList(const std::string &feedId, std::list<std::string> &msgIds);
|
||||
virtual bool processFeed(const std::string &feedId);
|
||||
virtual bool setMessageRead(const std::string &feedId, const std::string &msgId, bool read);
|
||||
|
||||
virtual RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString);
|
||||
|
||||
/****************** p3Service STUFF ******************/
|
||||
virtual int tick();
|
||||
|
||||
/****************** internal STUFF *******************/
|
||||
bool getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId);
|
||||
void onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon);
|
||||
void onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString);
|
||||
void onProcessSuccess_filterMsg(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs);
|
||||
void onProcessSuccess_addMsgs(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs, bool single);
|
||||
void onProcessError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString);
|
||||
|
||||
bool getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId);
|
||||
|
||||
void setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description);
|
||||
|
||||
protected:
|
||||
/****************** p3Config STUFF *******************/
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
virtual void saveDone();
|
||||
|
||||
private:
|
||||
void cleanFeeds();
|
||||
void deleteAllMsgs_locked(RsFeedReaderFeed *fi);
|
||||
void stopPreviewThreads_locked();
|
||||
|
||||
time_t mLastClean;
|
||||
RsFeedReaderNotify *mNotify;
|
||||
|
||||
RsMutex mFeedReaderMtx;
|
||||
std::list<p3FeedReaderThread*> mThreads;
|
||||
uint32_t mNextFeedId;
|
||||
uint32_t mNextMsgId;
|
||||
int32_t mNextPreviewFeedId;
|
||||
int32_t mNextPreviewMsgId;
|
||||
uint32_t mStandardUpdateInterval;
|
||||
uint32_t mStandardStorageTime;
|
||||
bool mStandardUseProxy;
|
||||
std::string mStandardProxyAddress;
|
||||
uint16_t mStandardProxyPort;
|
||||
std::map<std::string, RsFeedReaderFeed*> mFeeds;
|
||||
|
||||
RsMutex mDownloadMutex;
|
||||
std::list<std::string> mDownloadFeeds;
|
||||
|
||||
RsMutex mProcessMutex;
|
||||
std::list<std::string> mProcessFeeds;
|
||||
|
||||
RsMutex mPreviewMutex;
|
||||
p3FeedReaderThread *mPreviewDownloadThread;
|
||||
p3FeedReaderThread *mPreviewProcessThread;
|
||||
};
|
||||
|
||||
#endif
|
1360
plugins/FeedReader/services/p3FeedReaderThread.cc
Normal file
68
plugins/FeedReader/services/p3FeedReaderThread.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef P3_FEEDREADERTHREAD
|
||||
#define P3_FEEDREADERTHREAD
|
||||
|
||||
#include "interface/rsFeedReader.h"
|
||||
|
||||
#include "util/rsthreads.h"
|
||||
#include <list>
|
||||
|
||||
class p3FeedReader;
|
||||
class RsFeedReaderFeed;
|
||||
class RsFeedReaderMsg;
|
||||
class HTMLWrapper;
|
||||
class RsFeedReaderXPath;
|
||||
|
||||
class p3FeedReaderThread : public RsThread
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
DOWNLOAD,
|
||||
PROCESS
|
||||
};
|
||||
|
||||
public:
|
||||
p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId);
|
||||
virtual ~p3FeedReaderThread();
|
||||
|
||||
std::string getFeedId() { return mFeedId; }
|
||||
|
||||
static RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString);
|
||||
static RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, HTMLWrapper &html, std::string &errorString);
|
||||
|
||||
private:
|
||||
virtual void run();
|
||||
|
||||
RsFeedReaderErrorState download(const RsFeedReaderFeed &feed, std::string &content, std::string &icon, std::string &error);
|
||||
RsFeedReaderErrorState process(const RsFeedReaderFeed &feed, std::list<RsFeedReaderMsg*> &entries, std::string &error);
|
||||
|
||||
std::string getProxyForFeed(const RsFeedReaderFeed &feed);
|
||||
RsFeedReaderErrorState processMsg(const RsFeedReaderFeed &feed, RsFeedReaderMsg *msg, std::string &errorString);
|
||||
|
||||
p3FeedReader *mFeedReader;
|
||||
Type mType;
|
||||
std::string mFeedId;
|
||||
};
|
||||
|
||||
#endif
|
406
plugins/FeedReader/services/rsFeedReaderItems.cc
Normal file
|
@ -0,0 +1,406 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "rsFeedReaderItems.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsFeedReaderFeed::RsFeedReaderFeed()
|
||||
: RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PLUGIN_FEEDREADER, RS_PKT_SUBTYPE_FEEDREADER_FEED),
|
||||
xpathsToUse(TLV_TYPE_STRINGSET), xpathsToRemove(TLV_TYPE_STRINGSET)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void RsFeedReaderFeed::clear()
|
||||
{
|
||||
feedId.clear();
|
||||
parentId.clear();
|
||||
name.clear();
|
||||
url.clear();
|
||||
user.clear();
|
||||
password.clear();
|
||||
proxyAddress.clear();
|
||||
proxyPort = 0;
|
||||
updateInterval = 0;
|
||||
lastUpdate = 0;
|
||||
storageTime = 0;
|
||||
flag = 0;
|
||||
forumId.clear();
|
||||
description.clear();
|
||||
icon.clear();
|
||||
errorState = RS_FEED_ERRORSTATE_OK;
|
||||
errorString.clear();
|
||||
xpathsToUse.ids.clear();
|
||||
xpathsToRemove.ids.clear();
|
||||
|
||||
preview = false;
|
||||
workstate = WAITING;
|
||||
content.clear();
|
||||
}
|
||||
|
||||
std::ostream &RsFeedReaderFeed::print(std::ostream &out, uint16_t /*indent*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
uint32_t RsFeedReaderSerialiser::sizeFeed(RsFeedReaderFeed *item)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 2; /* version */
|
||||
s += GetTlvStringSize(item->feedId);
|
||||
s += GetTlvStringSize(item->parentId);
|
||||
s += GetTlvStringSize(item->url);
|
||||
s += GetTlvStringSize(item->name);
|
||||
s += GetTlvStringSize(item->description);
|
||||
s += GetTlvStringSize(item->icon);
|
||||
s += GetTlvStringSize(item->user);
|
||||
s += GetTlvStringSize(item->password);
|
||||
s += GetTlvStringSize(item->proxyAddress);
|
||||
s += sizeof(uint16_t); /* proxyPort */
|
||||
s += sizeof(uint32_t); /* updateInterval */
|
||||
s += sizeof(time_t); /* lastscan */
|
||||
s += sizeof(uint32_t); /* storageTime */
|
||||
s += sizeof(uint32_t); /* flag */
|
||||
s += GetTlvStringSize(item->forumId);
|
||||
s += sizeof(uint32_t); /* errorstate */
|
||||
s += GetTlvStringSize(item->errorString);
|
||||
s += item->xpathsToUse.TlvSize();
|
||||
s += item->xpathsToRemove.TlvSize();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* serialise the data to the buffer */
|
||||
bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
uint32_t tlvsize = sizeFeed(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (*pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add values */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, 0); /* version */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->feedId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->url);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->icon);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->user);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->password);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->proxyAddress);
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->proxyPort);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->updateInterval);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->lastUpdate);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->storageTime);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->errorState);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->errorString);
|
||||
ok &= item->xpathsToUse.SetTlv(data, tlvsize, &offset);
|
||||
ok &= item->xpathsToRemove.SetTlv(data, tlvsize, &offset);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsFeedReaderSerialiser::serialiseFeed() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsFeedReaderFeed *RsFeedReaderSerialiser::deserialiseFeed(void *data, uint32_t *pktsize)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_PLUGIN_FEEDREADER != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_FEEDREADER_FEED != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*pktsize = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
RsFeedReaderFeed *item = new RsFeedReaderFeed();
|
||||
item->clear();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* get values */
|
||||
uint16_t version = 0;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &version);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->feedId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->url);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->icon);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->user);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->password);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->proxyAddress);
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->proxyPort));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->updateInterval));
|
||||
ok &= getRawUInt32(data, rssize, &offset, (uint32_t*) &(item->lastUpdate));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->storageTime));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
||||
uint32_t errorState = 0;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &errorState);
|
||||
item->errorState = (RsFeedReaderErrorState) errorState;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->errorString);
|
||||
ok &= item->xpathsToUse.GetTlv(data, rssize, &offset);
|
||||
ok &= item->xpathsToRemove.GetTlv(data, rssize, &offset);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsFeedReaderMsg::RsFeedReaderMsg() : RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PLUGIN_FEEDREADER, RS_PKT_SUBTYPE_FEEDREADER_MSG)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void RsFeedReaderMsg::clear()
|
||||
{
|
||||
msgId.clear();
|
||||
feedId.clear();
|
||||
title.clear();
|
||||
link.clear();
|
||||
author.clear();
|
||||
description.clear();
|
||||
pubDate = 0;
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
std::ostream &RsFeedReaderMsg::print(std::ostream &out, uint16_t /*indent*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
uint32_t RsFeedReaderSerialiser::sizeMsg(RsFeedReaderMsg *item)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 2; /* version */
|
||||
s += GetTlvStringSize(item->msgId);
|
||||
s += GetTlvStringSize(item->feedId);
|
||||
s += GetTlvStringSize(item->title);
|
||||
s += GetTlvStringSize(item->link);
|
||||
s += GetTlvStringSize(item->author);
|
||||
s += GetTlvStringSize(item->description);
|
||||
s += sizeof(time_t); /* pubDate */
|
||||
s += sizeof(uint32_t); /* flag */
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* serialise the data to the buffer */
|
||||
bool RsFeedReaderSerialiser::serialiseMsg(RsFeedReaderMsg *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
uint32_t tlvsize = sizeMsg(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (*pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add values */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, 0); /* version */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->msgId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->title);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->link);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->author);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->pubDate);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsFeedReaderSerialiser::serialiseMsg() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsFeedReaderMsg *RsFeedReaderSerialiser::deserialiseMsg(void *data, uint32_t *pktsize)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_PLUGIN_FEEDREADER != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_FEEDREADER_MSG != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*pktsize = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
RsFeedReaderMsg *item = new RsFeedReaderMsg();
|
||||
item->clear();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* get values */
|
||||
uint16_t version = 0;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &version);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->msgId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->title);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->link);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->author);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
||||
ok &= getRawUInt32(data, rssize, &offset, (uint32_t*) &(item->pubDate));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
uint32_t RsFeedReaderSerialiser::size(RsItem *item)
|
||||
{
|
||||
RsFeedReaderFeed *fi;
|
||||
RsFeedReaderMsg *ei;
|
||||
|
||||
if (NULL != (fi = dynamic_cast<RsFeedReaderFeed*>(item)))
|
||||
{
|
||||
return sizeFeed((RsFeedReaderFeed*) item);
|
||||
}
|
||||
if (NULL != (ei = dynamic_cast<RsFeedReaderMsg*>(item)))
|
||||
{
|
||||
return sizeMsg((RsFeedReaderMsg*) item);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RsFeedReaderSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
RsFeedReaderFeed *fi;
|
||||
RsFeedReaderMsg *ei;
|
||||
|
||||
if (NULL != (fi = dynamic_cast<RsFeedReaderFeed*>(item)))
|
||||
{
|
||||
return serialiseFeed((RsFeedReaderFeed*) item, data, pktsize);
|
||||
}
|
||||
if (NULL != (ei = dynamic_cast<RsFeedReaderMsg*>(item)))
|
||||
{
|
||||
return serialiseMsg((RsFeedReaderMsg*) item, data, pktsize);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
RsItem *RsFeedReaderSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_PLUGIN_FEEDREADER != getRsItemService(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
switch (getRsItemSubType(rstype))
|
||||
{
|
||||
case RS_PKT_SUBTYPE_FEEDREADER_FEED:
|
||||
return deserialiseFeed(data, pktsize);
|
||||
case RS_PKT_SUBTYPE_FEEDREADER_MSG:
|
||||
return deserialiseMsg(data, pktsize);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
144
plugins/FeedReader/services/rsFeedReaderItems.h
Normal file
|
@ -0,0 +1,144 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef RS_FEEDREADER_ITEMS_H
|
||||
#define RS_FEEDREADER_ITEMS_H
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
|
||||
#include "p3FeedReader.h"
|
||||
|
||||
const uint32_t CONFIG_TYPE_FEEDREADER = 0x0001; // is this correct?
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_FEEDREADER_FEED = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_FEEDREADER_MSG = 0x03;
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#define RS_FEED_FLAG_FOLDER 0x001
|
||||
#define RS_FEED_FLAG_INFO_FROM_FEED 0x002
|
||||
#define RS_FEED_FLAG_STANDARD_STORAGE_TIME 0x004
|
||||
#define RS_FEED_FLAG_STANDARD_UPDATE_INTERVAL 0x008
|
||||
#define RS_FEED_FLAG_STANDARD_PROXY 0x010
|
||||
#define RS_FEED_FLAG_AUTHENTICATION 0x020
|
||||
#define RS_FEED_FLAG_DEACTIVATED 0x040
|
||||
#define RS_FEED_FLAG_FORUM 0x080
|
||||
#define RS_FEED_FLAG_UPDATE_FORUM_INFO 0x100
|
||||
#define RS_FEED_FLAG_EMBED_IMAGES 0x200
|
||||
#define RS_FEED_FLAG_SAVE_COMPLETE_PAGE 0x400
|
||||
|
||||
class RsFeedReaderFeed : public RsItem
|
||||
{
|
||||
public:
|
||||
enum WorkState {
|
||||
WAITING,
|
||||
WAITING_TO_DOWNLOAD,
|
||||
DOWNLOADING,
|
||||
WAITING_TO_PROCESS,
|
||||
PROCESSING
|
||||
};
|
||||
|
||||
public:
|
||||
RsFeedReaderFeed();
|
||||
virtual ~RsFeedReaderFeed() {}
|
||||
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string feedId;
|
||||
std::string parentId;
|
||||
std::string name;
|
||||
std::string url;
|
||||
std::string user;
|
||||
std::string password;
|
||||
std::string proxyAddress;
|
||||
uint16_t proxyPort;
|
||||
uint32_t updateInterval;
|
||||
time_t lastUpdate;
|
||||
uint32_t flag; // RS_FEED_FLAG_...
|
||||
std::string forumId;
|
||||
uint32_t storageTime;
|
||||
std::string description;
|
||||
std::string icon;
|
||||
RsFeedReaderErrorState errorState;
|
||||
std::string errorString;
|
||||
|
||||
RsTlvStringSet xpathsToUse;
|
||||
RsTlvStringSet xpathsToRemove;
|
||||
|
||||
/* Not Serialised */
|
||||
bool preview;
|
||||
WorkState workstate;
|
||||
std::string content;
|
||||
|
||||
std::map<std::string, RsFeedReaderMsg*> msgs;
|
||||
};
|
||||
|
||||
#define RS_FEEDMSG_FLAG_DELETED 1
|
||||
#define RS_FEEDMSG_FLAG_NEW 2
|
||||
#define RS_FEEDMSG_FLAG_READ 4
|
||||
|
||||
class RsFeedReaderMsg : public RsItem
|
||||
{
|
||||
public:
|
||||
RsFeedReaderMsg();
|
||||
virtual ~RsFeedReaderMsg() {}
|
||||
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string msgId;
|
||||
std::string feedId;
|
||||
std::string title;
|
||||
std::string link;
|
||||
std::string author;
|
||||
std::string description;
|
||||
time_t pubDate;
|
||||
uint32_t flag; // RS_FEEDMSG_FLAG_...
|
||||
};
|
||||
|
||||
class RsFeedReaderSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsFeedReaderSerialiser() : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PLUGIN_FEEDREADER) {}
|
||||
virtual ~RsFeedReaderSerialiser() {}
|
||||
|
||||
virtual uint32_t size(RsItem *item);
|
||||
virtual bool serialise(RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem *deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
/* For RS_PKT_SUBTYPE_FEEDREADER_FEED */
|
||||
virtual uint32_t sizeFeed(RsFeedReaderFeed *item);
|
||||
virtual bool serialiseFeed(RsFeedReaderFeed *item, void *data, uint32_t *size);
|
||||
virtual RsFeedReaderFeed *deserialiseFeed(void *data, uint32_t *size);
|
||||
|
||||
/* For RS_PKT_SUBTYPE_FEEDREADER_MSG */
|
||||
virtual uint32_t sizeMsg(RsFeedReaderMsg *item);
|
||||
virtual bool serialiseMsg(RsFeedReaderMsg *item, void *data, uint32_t *size);
|
||||
virtual RsFeedReaderMsg *deserialiseMsg(void *data, uint32_t *size);
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#endif
|
137
plugins/FeedReader/util/CURLWrapper.cpp
Normal file
|
@ -0,0 +1,137 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "CURLWrapper.h"
|
||||
#include <string.h>
|
||||
|
||||
//static int progressCallback (void *clientp, double /*dltotal*/, double /*dlnow*/, double /*ultotal*/, double /*ulnow*/)
|
||||
//{
|
||||
// p3FeedReaderThread *thread = (p3FeedReaderThread*) clientp;
|
||||
|
||||
// if (!thread->isRunning()) {
|
||||
// /* thread was stopped */
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// long todo; // show progress in gui
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
CURLWrapper::CURLWrapper(const std::string &proxy)
|
||||
{
|
||||
mCurl = curl_easy_init();
|
||||
if (mCurl) {
|
||||
curl_easy_setopt(mCurl, CURLOPT_NOPROGRESS, 0);
|
||||
// curl_easy_setopt(mCurl, CURLOPT_PROGRESSFUNCTION, progressCallback);
|
||||
// curl_easy_setopt(mCurl, CURLOPT_PROGRESSDATA, feedReader);
|
||||
curl_easy_setopt(mCurl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(mCurl, CURLOPT_CONNECTTIMEOUT, 60);
|
||||
curl_easy_setopt(mCurl, CURLOPT_TIMEOUT, 120);
|
||||
|
||||
if (!proxy.empty()) {
|
||||
curl_easy_setopt(mCurl, CURLOPT_PROXY, proxy.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CURLWrapper::~CURLWrapper()
|
||||
{
|
||||
if (mCurl) {
|
||||
curl_easy_cleanup(mCurl);
|
||||
}
|
||||
}
|
||||
|
||||
static size_t writeFunctionString (void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
std::string *s = (std::string*) stream;
|
||||
s->append ((char*) ptr, size * nmemb);
|
||||
|
||||
return nmemb * size;
|
||||
}
|
||||
|
||||
CURLcode CURLWrapper::downloadText(const std::string &link, std::string &data)
|
||||
{
|
||||
data.clear();
|
||||
|
||||
if (!mCurl) {
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
|
||||
curl_easy_setopt(mCurl, CURLOPT_URL, link.c_str());
|
||||
curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, writeFunctionString);
|
||||
curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, &data);
|
||||
|
||||
return curl_easy_perform(mCurl);
|
||||
}
|
||||
|
||||
static size_t writeFunctionBinary (void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
std::vector<unsigned char> *bytes = (std::vector<unsigned char>*) stream;
|
||||
|
||||
std::vector<unsigned char> newBytes;
|
||||
newBytes.resize(size * nmemb);
|
||||
memcpy(newBytes.data(), ptr, newBytes.size());
|
||||
|
||||
bytes->insert(bytes->end(), newBytes.begin(), newBytes.end());
|
||||
|
||||
return nmemb * size;
|
||||
}
|
||||
|
||||
CURLcode CURLWrapper::downloadBinary(const std::string &link, std::vector<unsigned char> &data)
|
||||
{
|
||||
data.clear();
|
||||
|
||||
if (!mCurl) {
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
|
||||
curl_easy_setopt(mCurl, CURLOPT_NOPROGRESS, 1);
|
||||
curl_easy_setopt(mCurl, CURLOPT_URL, link.c_str());
|
||||
curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, writeFunctionBinary);
|
||||
curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, &data);
|
||||
|
||||
return curl_easy_perform(mCurl);
|
||||
}
|
||||
|
||||
long CURLWrapper::longInfo(CURLINFO info)
|
||||
{
|
||||
if (!mCurl) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long value;
|
||||
curl_easy_getinfo(mCurl, info, &value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string CURLWrapper::stringInfo(CURLINFO info)
|
||||
{
|
||||
if (!mCurl) {
|
||||
return "";
|
||||
}
|
||||
|
||||
char *value;
|
||||
curl_easy_getinfo(mCurl, info, &value);
|
||||
|
||||
return value ? value : "";
|
||||
}
|
50
plugins/FeedReader/util/CURLWrapper.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef CURLWRAPPER
|
||||
#define CURLWRAPPER
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <curl/curl.h>
|
||||
|
||||
class CURLWrapper
|
||||
{
|
||||
public:
|
||||
CURLWrapper(const std::string &proxy);
|
||||
~CURLWrapper();
|
||||
|
||||
CURLcode downloadText(const std::string &link, std::string &data);
|
||||
CURLcode downloadBinary(const std::string &link, std::vector<unsigned char> &data);
|
||||
|
||||
long responseCode() { return longInfo(CURLINFO_RESPONSE_CODE); }
|
||||
std::string contentType() { return stringInfo(CURLINFO_CONTENT_TYPE); }
|
||||
std::string effectiveUrl() { return stringInfo(CURLINFO_EFFECTIVE_URL); }
|
||||
|
||||
protected:
|
||||
long longInfo(CURLINFO info);
|
||||
std::string stringInfo(CURLINFO info);
|
||||
|
||||
private:
|
||||
CURL *mCurl;
|
||||
};
|
||||
|
||||
#endif
|
75
plugins/FeedReader/util/HTMLWrapper.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "HTMLWrapper.h"
|
||||
#include <libxml/HTMLtree.h>
|
||||
|
||||
HTMLWrapper::HTMLWrapper() : XMLWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
bool HTMLWrapper::readHTML(const char *html, const char *url)
|
||||
{
|
||||
cleanup();
|
||||
|
||||
mDocument = htmlReadMemory(html, strlen(html), url, "", HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING | HTML_PARSE_COMPACT | HTML_PARSE_NONET | HTML_PARSE_NOBLANKS);
|
||||
if (mDocument) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HTMLWrapper::saveHTML(std::string &html)
|
||||
{
|
||||
if (!mDocument) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlChar *newHtml = NULL;
|
||||
int newHtmlSize = 0;
|
||||
htmlDocDumpMemoryFormat(mDocument, &newHtml, &newHtmlSize, 0);
|
||||
if (newHtml) {
|
||||
convertToString(newHtml, html);
|
||||
xmlFree(newHtml);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HTMLWrapper::createHTML()
|
||||
{
|
||||
/* easy way */
|
||||
return readHTML("<html><body></body></html>", "");
|
||||
}
|
||||
|
||||
xmlNodePtr HTMLWrapper::getBody()
|
||||
{
|
||||
xmlNodePtr root = getRootElement();
|
||||
if (!root) {
|
||||
return NULL;
|
||||
}
|
||||
return findNode(root->children, "body", false);
|
||||
}
|
40
plugins/FeedReader/util/HTMLWrapper.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef HTMLWRAPPER
|
||||
#define HTMLWRAPPER
|
||||
|
||||
#include "XMLWrapper.h"
|
||||
|
||||
class HTMLWrapper : public XMLWrapper
|
||||
{
|
||||
public:
|
||||
HTMLWrapper();
|
||||
|
||||
bool readHTML(const char *html, const char *url);
|
||||
bool saveHTML(std::string &html);
|
||||
|
||||
bool createHTML();
|
||||
|
||||
xmlNodePtr getBody();
|
||||
};
|
||||
|
||||
#endif
|
289
plugins/FeedReader/util/XMLWrapper.cpp
Normal file
|
@ -0,0 +1,289 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
#include "XMLWrapper.h"
|
||||
#include "XPathWrapper.h"
|
||||
|
||||
XMLWrapper::XMLWrapper()
|
||||
{
|
||||
mDocument = NULL;
|
||||
mCharEncodingHandler = xmlFindCharEncodingHandler ("UTF8");
|
||||
|
||||
if (!mCharEncodingHandler) {
|
||||
/* no encoding handler found */
|
||||
std::cerr << "XMLWrapper::XMLWrapper - no encoding handler found" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
XMLWrapper::~XMLWrapper()
|
||||
{
|
||||
cleanup();
|
||||
xmlCharEncCloseFunc(mCharEncodingHandler);
|
||||
}
|
||||
|
||||
XMLWrapper &XMLWrapper::operator=(const XMLWrapper &xml)
|
||||
{
|
||||
cleanup();
|
||||
|
||||
const xmlDocPtr document = xml.getDocument();
|
||||
if (document) {
|
||||
mDocument = xmlCopyDoc(document, 1);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void XMLWrapper::cleanup()
|
||||
{
|
||||
if (mDocument) {
|
||||
xmlFreeDoc(mDocument);
|
||||
mDocument = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool XMLWrapper::convertToString(const xmlChar *xmlText, std::string &text)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
xmlBufferPtr in = xmlBufferCreateStatic((void*) xmlText, xmlStrlen(xmlText));
|
||||
xmlBufferPtr out = xmlBufferCreate();
|
||||
int ret = xmlCharEncOutFunc(mCharEncodingHandler, out, in);
|
||||
if (ret >= 0) {
|
||||
result = true;
|
||||
text = (char*) xmlBufferContent(out);
|
||||
}
|
||||
|
||||
xmlBufferFree(in);
|
||||
xmlBufferFree(out);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool XMLWrapper::convertFromString(const char *text, xmlChar *&xmlText)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
xmlBufferPtr in = xmlBufferCreateStatic((void*) text, strlen(text));
|
||||
xmlBufferPtr out = xmlBufferCreate();
|
||||
int ret = xmlCharEncInFunc(mCharEncodingHandler, out, in);
|
||||
if (ret >= 0) {
|
||||
result = true;
|
||||
xmlText = xmlBufferDetach(out);
|
||||
}
|
||||
|
||||
xmlBufferFree(in);
|
||||
xmlBufferFree(out);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
xmlDocPtr XMLWrapper::getDocument() const
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
xmlNodePtr XMLWrapper::getRootElement() const
|
||||
{
|
||||
if (mDocument) {
|
||||
return xmlDocGetRootElement(mDocument);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool XMLWrapper::readXML(const char *xml)
|
||||
{
|
||||
cleanup();
|
||||
|
||||
mDocument = xmlReadDoc(BAD_CAST xml, "", NULL, XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_COMPACT | XML_PARSE_NOENT | XML_PARSE_NOCDATA);
|
||||
if (mDocument) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool XMLWrapper::getContent(xmlNodePtr node, std::string &content)
|
||||
{
|
||||
content.clear();
|
||||
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlChar *xmlContent = xmlNodeGetContent(node);
|
||||
if (!xmlContent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool result = convertToString(xmlContent, content);
|
||||
xmlFree(xmlContent);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool XMLWrapper::setContent(xmlNodePtr node, const char *content)
|
||||
{
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlChar *xmlContent;
|
||||
if (!convertFromString(content, xmlContent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlNodeSetContent(node, xmlContent);
|
||||
xmlFree(xmlContent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string XMLWrapper::nodeName(xmlNodePtr node)
|
||||
{
|
||||
std::string name;
|
||||
|
||||
if (node) {
|
||||
convertToString(node->name, name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string XMLWrapper::attrName(xmlAttrPtr attr)
|
||||
{
|
||||
std::string name;
|
||||
|
||||
if (attr) {
|
||||
convertToString(attr->name, name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
xmlNodePtr XMLWrapper::findNode(xmlNodePtr node, const char *name, bool children)
|
||||
{
|
||||
if (node->name) {
|
||||
if (xmlStrEqual(node->name, BAD_CAST name)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
xmlNodePtr nodeFound = NULL;
|
||||
if (children) {
|
||||
if (node->children) {
|
||||
nodeFound = findNode(node->children, name, children);
|
||||
if (nodeFound) {
|
||||
return nodeFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node->next) {
|
||||
nodeFound = findNode(node->next, name, children);
|
||||
if (nodeFound) {
|
||||
return nodeFound;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool XMLWrapper::getChildText(xmlNodePtr node, const char *childName, std::string &text)
|
||||
{
|
||||
if (node == NULL || node->children == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlNodePtr child = findNode(node->children, childName, true);
|
||||
if (!child) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (child->type != XML_ELEMENT_NODE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!child->children) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (child->children->type != XML_TEXT_NODE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (child->children->content) {
|
||||
return convertToString(child->children->content, text);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string XMLWrapper::getAttr(xmlNodePtr node, xmlAttrPtr attr)
|
||||
{
|
||||
return getAttr(node, (const char*) attr->name);
|
||||
}
|
||||
|
||||
std::string XMLWrapper::getAttr(xmlNodePtr node, const char *name)
|
||||
{
|
||||
if (!node || !name) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string value;
|
||||
|
||||
xmlChar *xmlValue = xmlGetProp(node, BAD_CAST name);
|
||||
if (xmlValue) {
|
||||
convertToString(xmlValue, value);
|
||||
xmlFree(xmlValue);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool XMLWrapper::setAttr(xmlNodePtr node, const char *name, const char *value)
|
||||
{
|
||||
if (!node || !name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlChar *xmlValue = NULL;
|
||||
if (!convertFromString(value, xmlValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlAttrPtr xmlAttr = xmlSetProp (node, BAD_CAST name, xmlValue);
|
||||
xmlFree(xmlValue);
|
||||
|
||||
return xmlAttr != NULL;
|
||||
}
|
||||
|
||||
XPathWrapper *XMLWrapper::createXPath()
|
||||
{
|
||||
if (mDocument) {
|
||||
return new XPathWrapper(*this);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
68
plugins/FeedReader/util/XMLWrapper.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef XMLWRAPPER
|
||||
#define XMLWRAPPER
|
||||
|
||||
#include <string>
|
||||
#include <libxml/parser.h>
|
||||
|
||||
class XPathWrapper;
|
||||
|
||||
class XMLWrapper
|
||||
{
|
||||
public:
|
||||
XMLWrapper();
|
||||
~XMLWrapper();
|
||||
|
||||
XMLWrapper &operator=(const XMLWrapper &xml);
|
||||
|
||||
void cleanup();
|
||||
|
||||
bool readXML(const char *xml);
|
||||
|
||||
xmlDocPtr getDocument() const;
|
||||
xmlNodePtr getRootElement() const;
|
||||
|
||||
std::string nodeName(xmlNodePtr node);
|
||||
std::string attrName(xmlAttrPtr attr);
|
||||
|
||||
xmlNodePtr findNode(xmlNodePtr node, const char *name, bool children = false);
|
||||
bool getChildText(xmlNodePtr node, const char *childName, std::string &text);
|
||||
|
||||
bool getContent(xmlNodePtr node, std::string &content);
|
||||
bool setContent(xmlNodePtr node, const char *content);
|
||||
|
||||
std::string getAttr(xmlNodePtr node, xmlAttrPtr attr);
|
||||
std::string getAttr(xmlNodePtr node, const char *name);
|
||||
bool setAttr(xmlNodePtr node, const char *name, const char *value);
|
||||
|
||||
XPathWrapper *createXPath();
|
||||
|
||||
bool convertToString(const xmlChar *xmlText, std::string &text);
|
||||
bool convertFromString(const char *text, xmlChar *&xmlText);
|
||||
|
||||
protected:
|
||||
xmlDocPtr mDocument;
|
||||
xmlCharEncodingHandlerPtr mCharEncodingHandler;
|
||||
};
|
||||
|
||||
#endif
|
102
plugins/FeedReader/util/XPathWrapper.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "XPathWrapper.h"
|
||||
#include "XMLWrapper.h"
|
||||
|
||||
XPathWrapper::XPathWrapper(XMLWrapper &xmlWrapper) : mXMLWrapper(xmlWrapper)
|
||||
{
|
||||
mContext = NULL;
|
||||
mResult = NULL;
|
||||
}
|
||||
|
||||
XPathWrapper::~XPathWrapper()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void XPathWrapper::cleanup()
|
||||
{
|
||||
if (mResult) {
|
||||
xmlXPathFreeObject(mResult);
|
||||
mResult = NULL;
|
||||
}
|
||||
if (mContext) {
|
||||
xmlXPathFreeContext(mContext);
|
||||
mContext = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool XPathWrapper::compile(const char *expression)
|
||||
{
|
||||
cleanup();
|
||||
|
||||
xmlDocPtr document = mXMLWrapper.getDocument();
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mContext = xmlXPathNewContext(document);
|
||||
if (!mContext) {
|
||||
cleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlChar *xmlExpression = NULL;
|
||||
if (!mXMLWrapper.convertFromString(expression, xmlExpression)) {
|
||||
cleanup();
|
||||
return false;
|
||||
}
|
||||
mResult = xmlXPathEvalExpression(xmlExpression, mContext);
|
||||
xmlFree(xmlExpression);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int XPathWrapper::count()
|
||||
{
|
||||
if (!mResult) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xmlXPathNodeSetIsEmpty(mResult->nodesetval)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mResult->nodesetval->nodeNr;
|
||||
}
|
||||
|
||||
xmlNodePtr XPathWrapper::node(unsigned int index)
|
||||
{
|
||||
if (!mResult) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (xmlXPathNodeSetIsEmpty(mResult->nodesetval)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (index >= (unsigned int) mResult->nodesetval->nodeNr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mResult->nodesetval->nodeTab[index];
|
||||
}
|
51
plugins/FeedReader/util/XPathWrapper.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 by Thunder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef XPATHWRAPPER
|
||||
#define XPATHWRAPPER
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
class XMLWrapper;
|
||||
|
||||
class XPathWrapper
|
||||
{
|
||||
friend class XMLWrapper;
|
||||
|
||||
public:
|
||||
~XPathWrapper();
|
||||
|
||||
void cleanup();
|
||||
|
||||
bool compile(const char *expression);
|
||||
|
||||
unsigned int count();
|
||||
xmlNodePtr node(unsigned int index);
|
||||
|
||||
protected:
|
||||
XPathWrapper(XMLWrapper &xmlWrapper);
|
||||
|
||||
XMLWrapper &mXMLWrapper;
|
||||
xmlXPathContextPtr mContext;
|
||||
xmlXPathObjectPtr mResult;
|
||||
};
|
||||
|
||||
#endif
|