Merge remote-tracking branch 'upstream/master' into v0.6-BugFixing_2

This commit is contained in:
csoler 2020-11-12 23:17:55 +01:00
commit f8721ad60f
53 changed files with 832 additions and 659 deletions

View File

@ -196,6 +196,8 @@ $(BUILD_PATH)/opencv-$(OPENCV_VERSION): $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION
# prepare
rm -r -f $(BUILD_PATH)/opencv-*
tar xvf $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz
# Remove version numbers from libraries. Is there a switch?
sed -i -e's/\(ocv_update(OPENCV_DLLVERSION \).*$$/\1"")/' opencv-$(OPENCV_VERSION)/CMakeLists.txt
# build
mkdir -p opencv-$(OPENCV_VERSION)/build
#cd opencv-$(OPENCV_VERSION)/build && cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="`pwd`/../../build"

View File

@ -13,8 +13,7 @@ call "%~dp0build-libs\build-libs.bat"
if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL%
%cecho% info "Build %SourceName%"
call "%~dp0build\build.bat" release autologin jsonapi
rem plugins
call "%~dp0build\build.bat" release autologin jsonapi plugins
if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Pack %SourceName%"

View File

@ -96,6 +96,7 @@ copy nul "%RsDeployPath%\portable" %Quite%
echo copy binaries
copy "%RsBuildPath%\retroshare-gui\src\%RsBuildConfig%\retroshare*.exe" "%RsDeployPath%" %Quite%
copy "%RsBuildPath%\retroshare-service\src\%RsBuildConfig%\retroshare*-service.exe" "%RsDeployPath%" %Quite%
if exist "%RsBuildPath%\libretroshare\src\lib\retroshare.dll" copy "%RsBuildPath%\libretroshare\src\lib\retroshare.dll" "%RsDeployPath%" %Quite%
echo copy extensions
for /D %%D in ("%RsBuildPath%\plugins\*") do (
@ -108,6 +109,7 @@ copy "%BuildLibsPath%\libs\bin\*.dll" "%RsDeployPath%" %Quite%
echo copy dependencies
call :copy_dependencies "%RsDeployPath%\retroshare.exe" "%RsDeployPath%"
if exist "%RsDeployPath%\retroshare.dll" call :copy_dependencies "%RsDeployPath%\retroshare.dll" "%RsDeployPath%"
echo copy Qt DLL's
copy "%QtPath%\Qt%QtMainVersion1%Svg%QtMainVersion2%.dll" "%RsDeployPath%" %Quite%
@ -196,8 +198,8 @@ endlocal
exit /B 1
:copy_extension
if exist "%~1\%RsBuildConfig%\%~n1.dll" (
copy "%~1\%RsBuildConfig%\%~n1.dll" %2 %Quite%
if exist "%~1\lib\%~n1.dll" (
copy "%~1\lib\%~n1.dll" %2 %Quite%
)
goto :EOF

View File

@ -192,8 +192,9 @@ Section $(Section_Main) Section_Main
; Main binaries
SetOutPath "$INSTDIR"
File /oname=retroshare.exe "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe"
File /oname=retroshare-service.exe "${RELEASEDIR}\retroshare-service\src\release\retroshare-service.exe"
File "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe"
File "${RELEASEDIR}\retroshare-service\src\release\retroshare-service.exe"
File /nonfatal "${RELEASEDIR}\libretroshare\src\lib\retroshare.dll"
; Qt binaries
File "${QTDIR}\bin\Qt5Core.dll"
@ -290,8 +291,8 @@ SectionEnd
!endif
# Plugins
${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\lib\FeedReader.dll"
${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\lib\VOIP.dll"
!ifdef PLUGIN_FEEDREADER_EXISTS
!define /ifndef PLUGIN_EXISTS
@ -305,14 +306,14 @@ ${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\release\VOIP.dl
!ifdef PLUGIN_FEEDREADER_EXISTS
Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\FeedReader\release\FeedReader.dll"
File "${RELEASEDIR}\plugins\FeedReader\lib\FeedReader.dll"
SectionEnd
!endif
!ifdef PLUGIN_VOIP_EXISTS
Section $(Section_Plugin_VOIP) Section_Plugin_VOIP
SetOutPath "$DataDir\extensions6"
File "${RELEASEDIR}\plugins\VOIP\release\VOIP.dll"
File "${RELEASEDIR}\plugins\VOIP\lib\VOIP.dll"
SectionEnd
!endif
SectionGroupEnd

View File

@ -4,7 +4,11 @@
!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri")
TEMPLATE = lib
CONFIG += staticlib
libretroshare_shared {
CONFIG += shared
} else {
CONFIG += staticlib
}
CONFIG -= qt
TARGET = retroshare
TARGET_PRL = libretroshare
@ -242,7 +246,7 @@ win32-g++|win32-clang-g++ {
QMAKE_CC = $${QMAKE_CXX}
OBJECTS_DIR = temp/obj
MOC_DIR = temp/moc
DEFINES *= STATICLIB
!libretroshare_shared:DEFINES *= STATICLIB
# Switch on extra warnings
QMAKE_CFLAGS += -Wextra
@ -866,10 +870,10 @@ rs_jsonapi {
genrestbedlib.variable_out = PRE_TARGETDEPS
win32-g++:isEmpty(QMAKE_SH) {
genrestbedlib.commands = \
cd $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/restbed || cd . $$escape_expand(\\n\\t) \
cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/asio || cd . $$escape_expand(\\n\\t) \
cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/catch || cd . $$escape_expand(\\n\\t )\
cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/kashmir || cd . $$escape_expand(\\n\\t) \
cd /D $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/restbed || cd . $$escape_expand(\\n\\t) \
cd /D $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/asio || cd . $$escape_expand(\\n\\t) \
cd /D $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/catch || cd . $$escape_expand(\\n\\t )\
cd /D $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/kashmir || cd . $$escape_expand(\\n\\t) \
$(CHK_DIR_EXISTS) $$shell_path($$UDP_DISCOVERY_BUILD_PATH) $(MKDIR) $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) $$escape_expand(\\n\\t)
} else {
genrestbedlib.commands = \
@ -987,7 +991,7 @@ rs_broadcast_discovery {
udpdiscoverycpplib.variable_out = PRE_TARGETDEPS
win32-g++:isEmpty(QMAKE_SH) {
udpdiscoverycpplib.commands = \
cd $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/udp-discovery-cpp || cd . $$escape_expand(\\n\\t) \
cd /D $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/udp-discovery-cpp || cd . $$escape_expand(\\n\\t) \
$(CHK_DIR_EXISTS) $$shell_path($$UDP_DISCOVERY_BUILD_PATH) $(MKDIR) $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) $$escape_expand(\\n\\t)
} else {
udpdiscoverycpplib.commands = \

View File

@ -6,10 +6,10 @@ RS_BUILD_PATH=$$clean_path($${OUT_PWD}/../../)
DEPENDPATH *= $$clean_path($${RS_SRC_PATH}/libretroshare/src/)
INCLUDEPATH *= $$clean_path($${RS_SRC_PATH}/libretroshare/src)
LIBS *= -L$$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/) -lretroshare
equals(TARGET, retroshare):equals(TEMPLATE, lib){
} else {
LIBS *= -L$$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/) -lretroshare
PRE_TARGETDEPS *= $$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/libretroshare.a)
}

View File

@ -42,6 +42,11 @@ win32 {
QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
}
libretroshare_shared {
PRE_TARGETDEPS += $$OUT_PWD/../../libretroshare/src/lib/libretroshare.a
LIBS += -L"$$OUT_PWD/../../libretroshare/src/lib" -lretroshare
}
# Switch on extra warnings
QMAKE_CFLAGS += -Wextra
QMAKE_CXXFLAGS += -Wextra

View File

@ -42,6 +42,9 @@ AddFeedDialog::AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify,
/* Setup UI helper */
mStateHelper = new UIStateHelper(this);
mFeedId = 0;
mParentId = 0;
mStateHelper->addWidget(TOKEN_TYPE_FORUM_GROUPS, ui->forumComboBox, UISTATE_LOADING_DISABLED);
mStateHelper->addWidget(TOKEN_TYPE_FORUM_GROUPS, ui->buttonBox->button(QDialogButtonBox::Ok), UISTATE_LOADING_DISABLED);
@ -197,19 +200,19 @@ void AddFeedDialog::validate()
mStateHelper->setWidgetEnabled(ui->buttonBox->button(QDialogButtonBox::Ok), ok);
}
void AddFeedDialog::setParent(const std::string &parentId)
void AddFeedDialog::setParent(uint32_t parentId)
{
mParentId = parentId;
}
bool AddFeedDialog::fillFeed(const std::string &feedId)
bool AddFeedDialog::fillFeed(uint32_t feedId)
{
mFeedId = feedId;
if (!mFeedId.empty()) {
if (mFeedId) {
FeedInfo feedInfo;
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
mFeedId.clear();
mFeedId = 0;
return false;
}
@ -326,7 +329,7 @@ void AddFeedDialog::getFeedInfo(FeedInfo &feedInfo)
void AddFeedDialog::createFeed()
{
FeedInfo feedInfo;
if (!mFeedId.empty()) {
if (mFeedId) {
if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) {
QMessageBox::critical(this, tr("Edit feed"), tr("Can't edit feed. Feed does not exist."));
return;
@ -335,7 +338,7 @@ void AddFeedDialog::createFeed()
getFeedInfo(feedInfo);
if (mFeedId.empty()) {
if (mFeedId == 0) {
/* add new feed */
RsFeedAddResult result = mFeedReader->addFeed(feedInfo, mFeedId);
if (FeedReaderStringDefs::showError(this, result, tr("Create feed"), tr("Cannot create feed."))) {
@ -365,7 +368,7 @@ void AddFeedDialog::preview()
void AddFeedDialog::clearMessageCache()
{
if (mFeedId.empty()) {
if (mFeedId == 0) {
return;
}

View File

@ -41,8 +41,8 @@ public:
AddFeedDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent);
~AddFeedDialog();
void setParent(const std::string &parentId);
bool fillFeed(const std::string &feedId);
void setParent(uint32_t parentId);
bool fillFeed(uint32_t feedId);
/* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
@ -70,8 +70,8 @@ private:
private:
RsFeedReader *mFeedReader;
FeedReaderNotify *mNotify;
std::string mFeedId;
std::string mParentId;
uint32_t mFeedId;
uint32_t mParentId;
std::string mFillForumId;
RsFeedTransformationType mTransformationType;

View File

@ -65,8 +65,7 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *n
mOpenFeedIds = NULL;
mMessageWidget = NULL;
connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int)));
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderDialog::feedChanged, Qt::QueuedConnection);
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
@ -153,7 +152,7 @@ void FeedReaderDialog::processSettings(bool load)
int arrayIndex = Settings->beginReadArray("Feeds");
for (int index = 0; index < arrayIndex; index++) {
Settings->setArrayIndex(index);
addFeedToExpand(Settings->value("open").toString().toStdString());
addFeedToExpand(Settings->value("open").toUInt());
}
Settings->endArray();
} else {
@ -165,11 +164,11 @@ void FeedReaderDialog::processSettings(bool load)
// open groups
Settings->beginWriteArray("Feeds");
int arrayIndex = 0;
QList<std::string> expandedFeedIds;
QList<uint32_t> expandedFeedIds;
getExpandedFeedIds(expandedFeedIds);
foreach (std::string feedId, expandedFeedIds) {
foreach (uint32_t feedId, expandedFeedIds) {
Settings->setArrayIndex(arrayIndex++);
Settings->setValue("open", QString::fromStdString(feedId));
Settings->setValue("open", feedId);
}
Settings->endArray();
}
@ -187,17 +186,17 @@ void FeedReaderDialog::settingsChanged()
}
} else {
if (!mMessageWidget) {
mMessageWidget = createMessageWidget("");
mMessageWidget = createMessageWidget(0);
// remove close button of the the first tab
ui->messageTabWidget->hideCloseButton(ui->messageTabWidget->indexOf(mMessageWidget));
}
}
}
void FeedReaderDialog::addFeedToExpand(const std::string &feedId)
void FeedReaderDialog::addFeedToExpand(uint32_t feedId)
{
if (mOpenFeedIds == NULL) {
mOpenFeedIds = new QList<std::string>;
mOpenFeedIds = new QList<uint32_t>;
}
if (mOpenFeedIds->contains(feedId)) {
return;
@ -205,7 +204,7 @@ void FeedReaderDialog::addFeedToExpand(const std::string &feedId)
mOpenFeedIds->push_back(feedId);
}
void FeedReaderDialog::getExpandedFeedIds(QList<std::string> &feedIds)
void FeedReaderDialog::getExpandedFeedIds(QList<uint32_t> &feedIds)
{
QTreeWidgetItemIterator it(ui->feedTreeWidget);
QTreeWidgetItem *item;
@ -217,8 +216,8 @@ void FeedReaderDialog::getExpandedFeedIds(QList<std::string> &feedIds)
if (!item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool()) {
continue;
}
std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
if (feedId.empty()) {
uint32_t feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt();
if (feedId == 0) {
continue;
}
feedIds.push_back(feedId);
@ -227,7 +226,7 @@ void FeedReaderDialog::getExpandedFeedIds(QList<std::string> &feedIds)
void FeedReaderDialog::showEvent(QShowEvent */*event*/)
{
updateFeeds("", mRootItem);
updateFeeds(0, mRootItem);
}
bool FeedReaderDialog::eventFilter(QObject *obj, QEvent *event)
@ -248,26 +247,26 @@ bool FeedReaderDialog::eventFilter(QObject *obj, QEvent *event)
return MainPage::eventFilter(obj, event);
}
std::string FeedReaderDialog::currentFeedId()
uint32_t FeedReaderDialog::currentFeedId()
{
QTreeWidgetItem *item = ui->feedTreeWidget->currentItem();
if (!item) {
return "";
return 0;
}
return item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
return item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt();
}
void FeedReaderDialog::setCurrentFeedId(const std::string &feedId)
void FeedReaderDialog::setCurrentFeedId(uint32_t feedId)
{
if (feedId.empty()) {
if (feedId == 0) {
return;
}
QTreeWidgetItemIterator it(ui->feedTreeWidget);
QTreeWidgetItem *item;
while ((item = *it) != NULL) {
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString() == feedId) {
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) {
ui->feedTreeWidget->setCurrentItem(item);
break;
}
@ -280,11 +279,11 @@ void FeedReaderDialog::feedTreeCustomPopupMenu(QPoint /*point*/)
QMenu contextMnu(this);
bool folder = false;
std::string feedId;
uint32_t feedId;
QTreeWidgetItem *item = ui->feedTreeWidget->currentItem();
if (item) {
folder = item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool();
feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt();
}
QMenu *menu = contextMnu.addMenu(QIcon(""), tr("New"));
@ -336,7 +335,7 @@ void FeedReaderDialog::feedTreeCustomPopupMenu(QPoint /*point*/)
contextMnu.exec(QCursor::pos());
}
void FeedReaderDialog::updateFeeds(const std::string &parentId, QTreeWidgetItem *parentItem)
void FeedReaderDialog::updateFeeds(uint32_t parentId, QTreeWidgetItem *parentItem)
{
if (!parentItem) {
return;
@ -353,7 +352,7 @@ void FeedReaderDialog::updateFeeds(const std::string &parentId, QTreeWidgetItem
/* update existing and delete not existing feeds */
while (index < parentItem->childCount()) {
item = parentItem->child(index);
std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
uint32_t feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt();
/* search existing feed */
int found = -1;
@ -534,27 +533,27 @@ void FeedReaderDialog::updateFeedItem(QTreeWidgetItem *item, const FeedInfo &fee
item->setData(COLUMN_FEED_DATA, ROLE_FEED_UNREAD, unreadCount);
item->setData(COLUMN_FEED_DATA, ROLE_FEED_NEW, newCount);
item->setData(COLUMN_FEED_DATA, ROLE_FEED_LOADING, feedInfo.workstate != FeedInfo::WAITING);
item->setData(COLUMN_FEED_DATA, ROLE_FEED_ID, QString::fromStdString(feedInfo.feedId));
item->setData(COLUMN_FEED_DATA, ROLE_FEED_ID, feedInfo.feedId);
item->setData(COLUMN_FEED_DATA, ROLE_FEED_FOLDER, feedInfo.flag.folder);
item->setData(COLUMN_FEED_DATA, ROLE_FEED_DEACTIVATED, feedInfo.flag.deactivated);
item->setData(COLUMN_FEED_DATA, ROLE_FEED_ERROR, (bool) (feedInfo.errorState != RS_FEED_ERRORSTATE_OK));
item->setToolTip(COLUMN_FEED_NAME, (feedInfo.errorState != RS_FEED_ERRORSTATE_OK) ? FeedReaderStringDefs::errorString(feedInfo) : "");
}
void FeedReaderDialog::feedChanged(const QString &feedId, int type)
void FeedReaderDialog::feedChanged(uint32_t feedId, int type)
{
if (!isVisible()) {
/* complete update in showEvent */
return;
}
if (feedId.isEmpty()) {
if (feedId == 0) {
return;
}
FeedInfo feedInfo;
if (type != NOTIFY_TYPE_DEL) {
if (!mFeedReader->getFeedInfo(feedId.toStdString(), feedInfo)) {
if (!mFeedReader->getFeedInfo(feedId, feedInfo)) {
return;
}
@ -567,7 +566,7 @@ void FeedReaderDialog::feedChanged(const QString &feedId, int type)
QTreeWidgetItemIterator it(ui->feedTreeWidget);
QTreeWidgetItem *item;
while ((item = *it) != NULL) {
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString() == feedId) {
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) {
if (type == NOTIFY_TYPE_MOD) {
updateFeedItem(item, feedInfo);
} else {
@ -580,12 +579,10 @@ void FeedReaderDialog::feedChanged(const QString &feedId, int type)
}
if (type == NOTIFY_TYPE_ADD) {
QString id = QString::fromStdString(feedInfo.parentId);
QTreeWidgetItemIterator it(ui->feedTreeWidget);
QTreeWidgetItem *itemParent;
while ((itemParent = *it) != NULL) {
if (itemParent->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString() == id) {
if (itemParent->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedInfo.parentId) {
QTreeWidgetItem *item = new RSTreeWidgetItem(mFeedCompareRole);
itemParent->addChild(item);
updateFeedItem(item, feedInfo);
@ -597,7 +594,7 @@ void FeedReaderDialog::feedChanged(const QString &feedId, int type)
calculateFeedItems();
}
FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(const std::string &id)
FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(uint32_t id)
{
int tabCount = ui->messageTabWidget->count();
for (int index = 0; index < tabCount; ++index) {
@ -613,7 +610,7 @@ FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(const std::string &
return NULL;
}
FeedReaderMessageWidget *FeedReaderDialog::createMessageWidget(const std::string &feedId)
FeedReaderMessageWidget *FeedReaderDialog::createMessageWidget(uint32_t feedId)
{
FeedReaderMessageWidget *messageWidget = new FeedReaderMessageWidget(feedId, mFeedReader, mNotify);
int index = ui->messageTabWidget->addTab(messageWidget, messageWidget->feedName(true));
@ -640,7 +637,7 @@ void FeedReaderDialog::feedTreeItemActivated(QTreeWidgetItem *item)
ui->feedAddButton->setEnabled(false);
std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
uint32_t feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt();
/* search exisiting tab */
FeedReaderMessageWidget *messageWidget = feedMessageWidget(feedId);
if (!messageWidget) {
@ -663,7 +660,7 @@ void FeedReaderDialog::feedTreeMiddleButtonClicked(QTreeWidgetItem *item)
return;
}
openFeedInNewTab(item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString());
openFeedInNewTab(item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt());
}
void FeedReaderDialog::openInNewTab()
@ -671,9 +668,9 @@ void FeedReaderDialog::openInNewTab()
openFeedInNewTab(currentFeedId());
}
void FeedReaderDialog::openFeedInNewTab(const std::string &feedId)
void FeedReaderDialog::openFeedInNewTab(uint32_t feedId)
{
if (feedId.empty()) {
if (feedId == 0) {
return;
}
@ -723,7 +720,7 @@ void FeedReaderDialog::messageTabInfoChanged(QWidget *widget)
return;
}
if (messageWidget != mMessageWidget && messageWidget->feedId().empty()) {
if (messageWidget != mMessageWidget && messageWidget->feedId() == 0) {
messageWidget->deleteLater();
return;
}
@ -740,7 +737,7 @@ void FeedReaderDialog::newFolder()
dialog.setWindowIcon(QIcon(":/images/FeedReader.png"));
if (dialog.exec() == QDialog::Accepted && !dialog.textValue().isEmpty()) {
std::string feedId;
uint32_t feedId;
RsFeedAddResult result = mFeedReader->addFolder(currentFeedId(), dialog.textValue().toUtf8().constData(), feedId);
FeedReaderStringDefs::showError(this, result, tr("Create folder"), tr("Cannot create folder."));
}
@ -755,8 +752,8 @@ void FeedReaderDialog::newFeed()
void FeedReaderDialog::removeFeed()
{
std::string feedId = currentFeedId();
if (feedId.empty()) {
uint32_t feedId = currentFeedId();
if (feedId == 0) {
return;
}
@ -775,8 +772,8 @@ void FeedReaderDialog::removeFeed()
void FeedReaderDialog::editFeed()
{
std::string feedId = currentFeedId();
if (feedId.empty()) {
uint32_t feedId = currentFeedId();
if (feedId == 0) {
return;
}
@ -809,8 +806,8 @@ void FeedReaderDialog::editFeed()
void FeedReaderDialog::activateFeed()
{
std::string feedId = currentFeedId();
if (feedId.empty()) {
uint32_t feedId = currentFeedId();
if (feedId == 0) {
return;
}
@ -830,7 +827,7 @@ void FeedReaderDialog::activateFeed()
void FeedReaderDialog::processFeed()
{
std::string feedId = currentFeedId();
uint32_t feedId = currentFeedId();
/* empty feed id process all feeds */
mFeedReader->processFeed(feedId);

View File

@ -67,26 +67,27 @@ private slots:
void messageTabInfoChanged(QWidget *widget);
/* FeedReaderNotify */
void feedChanged(const QString &feedId, int type);
void feedChanged(uint32_t feedId, int type);
private:
std::string currentFeedId();
void setCurrentFeedId(const std::string &feedId);
uint32_t currentFeedId();
void setCurrentFeedId(uint32_t feedId);
void processSettings(bool load);
void addFeedToExpand(const std::string &feedId);
void getExpandedFeedIds(QList<std::string> &feedIds);
void updateFeeds(const std::string &parentId, QTreeWidgetItem *parentItem);
void addFeedToExpand(uint32_t feedId);
void getExpandedFeedIds(QList<uint32_t> &feedIds);
void updateFeeds(uint32_t parentId, QTreeWidgetItem *parentItem);
void updateFeedItem(QTreeWidgetItem *item, const FeedInfo &feedInfo);
void openFeedInNewTab(const std::string &feedId);
void openFeedInNewTab(uint32_t feedId);
void calculateFeedItems();
void calculateFeedItem(QTreeWidgetItem *item, uint32_t &unreadCount, uint32_t &newCount, bool &loading);
FeedReaderMessageWidget *feedMessageWidget(const std::string &feedId);
FeedReaderMessageWidget *createMessageWidget(const std::string &feedId);
FeedReaderMessageWidget *feedMessageWidget(uint32_t feedId);
FeedReaderMessageWidget *createMessageWidget(uint32_t feedId);
private:
bool mProcessSettings;
QList<std::string> *mOpenFeedIds;
QList<uint32_t> *mOpenFeedIds;
QTreeWidgetItem *mRootItem;
RSTreeWidgetItemCompareRole *mFeedCompareRole;
FeedReaderMessageWidget *mMessageWidget;

View File

@ -34,8 +34,8 @@
#include "gui/feeds/FeedHolder.h"
/** Constructor */
FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo)
: FeedItem(NULL), mFeedReader(feedReader), mNotify(notify), mParent(parent), ui(new Ui::FeedReaderFeedItem)
FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo)
: FeedItem(NULL, feedInfo.feedId), mFeedReader(feedReader), mNotify(notify), ui(new Ui::FeedReaderFeedItem)
{
/* Invoke the Qt Designer generated object setup routine */
ui->setupUi(this);
@ -51,7 +51,6 @@ FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotif
ui->expandFrame->hide();
mFeedId = feedInfo.feedId;
mMsgId = msgInfo.msgId;
if (feedInfo.icon.empty()) {
@ -101,8 +100,8 @@ void FeedReaderFeedItem::toggle()
void FeedReaderFeedItem::doExpand(bool open)
{
if (mParent) {
mParent->lockLayout(this, true);
if (mFeedHolder) {
mFeedHolder->lockLayout(this, true);
}
if (open) {
@ -119,19 +118,8 @@ void FeedReaderFeedItem::doExpand(bool open)
emit sizeChanged(this);
if (mParent) {
mParent->lockLayout(this, false);
}
}
void FeedReaderFeedItem::removeItem()
{
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent) {
mParent->deleteFeedItem(this, 0);
if (mFeedHolder) {
mFeedHolder->lockLayout(this, false);
}
}
@ -150,9 +138,9 @@ void FeedReaderFeedItem::setMsgRead()
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection);
}
void FeedReaderFeedItem::msgChanged(const QString &feedId, const QString &msgId, int /*type*/)
void FeedReaderFeedItem::msgChanged(uint32_t feedId, const QString &msgId, int /*type*/)
{
if (feedId.toStdString() != mFeedId) {
if (feedId != mFeedId) {
return;
}

View File

@ -38,9 +38,11 @@ class FeedReaderFeedItem : public FeedItem
Q_OBJECT
public:
FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo);
FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo);
~FeedReaderFeedItem();
virtual uint64_t uniqueIdentifier() const override { return hash_64bits("FeedReaderFeedItem " + mMsgId); }
protected:
/* FeedItem */
virtual void doExpand(bool open);
@ -53,7 +55,7 @@ private slots:
void copyLink();
void openLink();
void msgChanged(const QString &feedId, const QString &msgId, int type);
void msgChanged(uint32_t feedId, const QString &msgId, int type);
private:
void setMsgRead();

View File

@ -65,9 +65,9 @@ void FeedReaderFeedNotify::setNotifyEnabled(bool enabled)
}
}
void FeedReaderFeedNotify::msgChanged(const QString &feedId, const QString &msgId, int type)
void FeedReaderFeedNotify::msgChanged(uint32_t feedId, const QString &msgId, int type)
{
if (feedId.isEmpty() || msgId.isEmpty()) {
if (feedId == 0 || msgId.isEmpty()) {
return;
}
@ -101,8 +101,8 @@ FeedItem *FeedReaderFeedNotify::feedItem(FeedHolder *parent)
FeedItemData feedItemData = mPendingNewsFeed.front();
mPendingNewsFeed.pop_front();
if (mFeedReader->getFeedInfo(feedItemData.mFeedId.toStdString(), feedInfo) &&
mFeedReader->getMsgInfo(feedItemData.mFeedId.toStdString(), feedItemData.mMsgId.toStdString(), msgInfo)) {
if (mFeedReader->getFeedInfo(feedItemData.mFeedId, feedInfo) &&
mFeedReader->getMsgInfo(feedItemData.mFeedId, feedItemData.mMsgId.toStdString(), msgInfo)) {
if (msgInfo.flag.isnew) {
msgPending = true;
break;
@ -115,7 +115,8 @@ FeedItem *FeedReaderFeedNotify::feedItem(FeedHolder *parent)
return NULL;
}
return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo);
//TODO: parent?
return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo);
}
FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent)
@ -136,5 +137,6 @@ FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent)
msgInfo.description = tr("This is a test message.").toUtf8().constData();
msgInfo.pubDate = QDateTime::currentDateTime().toTime_t();
return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo);
//TODO: parent?
return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo);
}

View File

@ -36,10 +36,13 @@ protected:
class FeedItemData
{
public:
FeedItemData() {}
FeedItemData()
{
mFeedId = 0;
}
public:
QString mFeedId;
uint32_t mFeedId;
QString mMsgId;
};
@ -54,7 +57,7 @@ public:
virtual FeedItem *testFeedItem(FeedHolder *parent);
private slots:
void msgChanged(const QString &feedId, const QString &msgId, int type);
void msgChanged(uint32_t feedId, const QString &msgId, int type);
private:
RsFeedReader *mFeedReader;

View File

@ -52,18 +52,19 @@
#define ROLE_MSG_READ Qt::UserRole + 3
#define ROLE_MSG_LINK Qt::UserRole + 4
FeedReaderMessageWidget::FeedReaderMessageWidget(const std::string &feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent) :
FeedReaderMessageWidget::FeedReaderMessageWidget(uint32_t feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent) :
QWidget(parent), mFeedReader(feedReader), mNotify(notify), ui(new Ui::FeedReaderMessageWidget)
{
ui->setupUi(this);
mFeedId = 0;
mProcessSettings = false;
mUnreadCount = 0;
mNewCount = 0;
/* connect signals */
connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int)));
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderMessageWidget::feedChanged, Qt::QueuedConnection);
connect(mNotify, &FeedReaderNotify::msgChanged, this, &FeedReaderMessageWidget::msgChanged, Qt::QueuedConnection);
connect(ui->msgTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(msgItemChanged()));
connect(ui->msgTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(msgItemClicked(QTreeWidgetItem*,int)));
@ -217,30 +218,30 @@ bool FeedReaderMessageWidget::eventFilter(QObject *obj, QEvent *event)
return QWidget::eventFilter(obj, event);
}
void FeedReaderMessageWidget::setFeedId(const std::string &feedId)
void FeedReaderMessageWidget::setFeedId(uint32_t feedId)
{
if (mFeedId == feedId) {
if (!feedId.empty()) {
if (feedId) {
return;
}
}
mFeedId = feedId;
ui->feedProcessButton->setEnabled(!mFeedId.empty());
ui->feedProcessButton->setEnabled(mFeedId);
if (!mFeedId.empty()) {
if (mFeedId) {
if (mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) {
mFeedReader->getMessageCount(mFeedId, NULL, &mNewCount, &mUnreadCount);
} else {
mFeedId.clear();
mFeedId = 0;
mFeedInfo = FeedInfo();
}
} else {
mFeedInfo = FeedInfo();
}
if (mFeedId.empty()) {
if (mFeedId == 0) {
ui->msgReadAllButton->setEnabled(false);
ui->msgTreeWidget->setPlaceholderText("");
} else {
@ -279,7 +280,7 @@ QIcon FeedReaderMessageWidget::feedIcon()
icon = icon.pixmap(QSize(16, 16), QIcon::Disabled);
}
if (!mFeedId.empty()) {
if (mFeedId) {
QImage overlayIcon;
if (mFeedInfo.workstate != FeedInfo::WAITING) {
@ -329,7 +330,7 @@ void FeedReaderMessageWidget::msgTreeCustomPopupMenu(QPoint /*point*/)
action->setEnabled(!selectedItems.empty());
action = contextMnu.addAction(QIcon(""), tr("Mark all as read"), this, SLOT(markAllAsReadMsg()));
action->setEnabled(!mFeedId.empty());
action->setEnabled(mFeedId);
contextMnu.addSeparator();
@ -349,7 +350,7 @@ void FeedReaderMessageWidget::msgTreeCustomPopupMenu(QPoint /*point*/)
void FeedReaderMessageWidget::updateMsgs()
{
if (mFeedId.empty()) {
if (mFeedId == 0) {
ui->msgTreeWidget->clear();
return;
}
@ -434,7 +435,7 @@ void FeedReaderMessageWidget::updateMsgItem(QTreeWidgetItem *item, FeedMsgInfo &
qdatetime.setTime_t(info.pubDate);
/* add string to all data */
QString sort = QString("%1_%2_%2").arg(title, qdatetime.toString("yyyyMMdd_hhmmss"), QString::fromStdString(info.feedId));
QString sort = QString("%1_%2_%3").arg(title, qdatetime.toString("yyyyMMdd_hhmmss")).arg(info.feedId);
item->setText(COLUMN_MSG_TITLE, title);
item->setData(COLUMN_MSG_TITLE, ROLE_MSG_SORT, sort);
@ -459,24 +460,24 @@ void FeedReaderMessageWidget::updateMsgItem(QTreeWidgetItem *item, FeedMsgInfo &
calculateMsgIconsAndFonts(item);
}
void FeedReaderMessageWidget::feedChanged(const QString &feedId, int type)
void FeedReaderMessageWidget::feedChanged(uint32_t feedId, int type)
{
if (feedId.isEmpty()) {
if (feedId == 0) {
return;
}
if (feedId.toStdString() != mFeedId) {
if (feedId != mFeedId) {
return;
}
if (type == NOTIFY_TYPE_DEL) {
setFeedId("");
setFeedId(0);
return;
}
if (type == NOTIFY_TYPE_MOD) {
if (!mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) {
setFeedId("");
setFeedId(0);
return;
}
@ -484,13 +485,13 @@ void FeedReaderMessageWidget::feedChanged(const QString &feedId, int type)
}
}
void FeedReaderMessageWidget::msgChanged(const QString &feedId, const QString &msgId, int type)
void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId, int type)
{
if (feedId.isEmpty() || msgId.isEmpty()) {
if (feedId == 0 || msgId.isEmpty()) {
return;
}
if (feedId.toStdString() != mFeedId) {
if (feedId != mFeedId) {
return;
}
@ -510,7 +511,7 @@ void FeedReaderMessageWidget::msgChanged(const QString &feedId, const QString &m
FeedMsgInfo msgInfo;
if (type != NOTIFY_TYPE_DEL) {
if (!mFeedReader->getMsgInfo(feedId.toStdString(), msgId.toStdString(), msgInfo)) {
if (!mFeedReader->getMsgInfo(feedId, msgId.toStdString(), msgInfo)) {
return;
}
}
@ -578,7 +579,7 @@ void FeedReaderMessageWidget::updateCurrentMessage()
std::string msgId = currentMsgId();
if (mFeedId.empty() || msgId.empty()) {
if (mFeedId == 0 || msgId.empty()) {
ui->msgTitle->clear();
// ui->msgLink->clear();
ui->msgText->clear();
@ -646,7 +647,7 @@ void FeedReaderMessageWidget::setMsgAsReadUnread(QList<QTreeWidgetItem *> &rows,
{
QList<QTreeWidgetItem*>::iterator rowIt;
if (mFeedId.empty()) {
if (mFeedId == 0) {
return;
}
@ -773,7 +774,7 @@ void FeedReaderMessageWidget::copySelectedLinksMsg()
void FeedReaderMessageWidget::removeMsg()
{
if (mFeedId.empty()) {
if (mFeedId == 0) {
return;
}
@ -789,7 +790,7 @@ void FeedReaderMessageWidget::removeMsg()
void FeedReaderMessageWidget::retransformMsg()
{
if (mFeedId.empty()) {
if (mFeedId == 0) {
return;
}
@ -803,7 +804,7 @@ void FeedReaderMessageWidget::retransformMsg()
void FeedReaderMessageWidget::processFeed()
{
if (mFeedId.empty()) {
if (mFeedId == 0) {
return;
}

View File

@ -41,11 +41,11 @@ class FeedReaderMessageWidget : public QWidget
Q_OBJECT
public:
explicit FeedReaderMessageWidget(const std::string &feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0);
explicit FeedReaderMessageWidget(uint32_t feedId, RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0);
~FeedReaderMessageWidget();
std::string feedId() { return mFeedId; }
void setFeedId(const std::string &feedId);
uint32_t feedId() { return mFeedId; }
void setFeedId(uint32_t feedId);
QString feedName(bool withUnreadCount);
QIcon feedIcon();
@ -75,8 +75,8 @@ private slots:
void retransformMsg();
/* FeedReaderNotify */
void feedChanged(const QString &feedId, int type);
void msgChanged(const QString &feedId, const QString &msgId, int type);
void feedChanged(uint32_t feedId, int type);
void msgChanged(uint32_t feedId, const QString &msgId, int type);
private:
std::string currentMsgId();
@ -91,7 +91,7 @@ private:
bool mProcessSettings;
RSTreeWidgetItemCompareRole *mMsgCompareRole;
std::string mFeedId;
uint32_t mFeedId;
unsigned int mUnreadCount;
unsigned int mNewCount;
QTimer *mTimer;

View File

@ -24,12 +24,12 @@ FeedReaderNotify::FeedReaderNotify() : QObject()
{
}
void FeedReaderNotify::notifyFeedChanged(const std::string &feedId, int type)
void FeedReaderNotify::notifyFeedChanged(uint32_t feedId, int type)
{
emit feedChanged(QString::fromStdString(feedId), type);
emit feedChanged(feedId, type);
}
void FeedReaderNotify::notifyMsgChanged(const std::string &feedId, const std::string &msgId, int type)
void FeedReaderNotify::notifyMsgChanged(uint32_t feedId, const std::string &msgId, int type)
{
emit msgChanged(QString::fromStdString(feedId), QString::fromStdString(msgId), type);
emit msgChanged(feedId, QString::fromStdString(msgId), type);
}

View File

@ -32,12 +32,12 @@ public:
FeedReaderNotify();
/* RsFeedReaderNotify */
virtual void notifyFeedChanged(const std::string &feedId, int type);
virtual void notifyMsgChanged(const std::string &feedId, const std::string &msgId, int type);
virtual void notifyFeedChanged(uint32_t feedId, int type);
virtual void notifyMsgChanged(uint32_t feedId, const std::string &msgId, int type);
signals:
void feedChanged(const QString &feedId, int type);
void msgChanged(const QString &feedId, const QString &msgId, int type);
void feedChanged(uint32_t feedId, int type);
void msgChanged(uint32_t feedId, const QString &msgId, int type);
};
#endif

View File

@ -30,8 +30,8 @@
FeedReaderUserNotify::FeedReaderUserNotify(FeedReaderDialog *feedReaderDialog, RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent) :
UserNotify(parent), mFeedReaderDialog(feedReaderDialog), mFeedReader(feedReader), mNotify(notify)
{
connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int)), Qt::QueuedConnection);
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(updateIcon()), Qt::QueuedConnection);
connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderUserNotify::feedChanged, Qt::QueuedConnection);
connect(mNotify, &FeedReaderNotify::msgChanged, this, &FeedReaderUserNotify::updateIcon, Qt::QueuedConnection);
}
bool FeedReaderUserNotify::hasSetting(QString *name, QString *group)
@ -55,7 +55,7 @@ QIcon FeedReaderUserNotify::getMainIcon(bool hasNew)
unsigned int FeedReaderUserNotify::getNewCount()
{
uint32_t newMessageCount = 0;
mFeedReader->getMessageCount("", NULL, &newMessageCount, NULL);
mFeedReader->getMessageCount(0, NULL, &newMessageCount, NULL);
return newMessageCount;
}
@ -65,7 +65,7 @@ void FeedReaderUserNotify::iconClicked()
MainWindow::showWindow(mFeedReaderDialog);
}
void FeedReaderUserNotify::feedChanged(const QString &/*feedId*/, int type)
void FeedReaderUserNotify::feedChanged(uint32_t /*feedId*/, int type)
{
if (type == NOTIFY_TYPE_DEL) {
updateIcon();

View File

@ -37,7 +37,7 @@ public:
virtual bool hasSetting(QString *name, QString *group);
private slots:
void feedChanged(const QString &feedId, int type);
void feedChanged(uint32_t feedId, int type);
private:
virtual QIcon getIcon();

View File

@ -143,6 +143,8 @@ PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify
{
ui->setupUi(this);
mFeedId = 0;
ui->feedNameLabel->clear();
/* connect signals */
@ -155,8 +157,8 @@ PreviewFeedDialog::PreviewFeedDialog(RsFeedReader *feedReader, FeedReaderNotify
connect(ui->xpathRemoveListWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(xpathCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
connect(ui->transformationTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(transformationTypeChanged()));
connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int)));
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
connect(mNotify, &FeedReaderNotify::feedChanged, this, &PreviewFeedDialog::feedChanged, Qt::QueuedConnection);
connect(mNotify, &FeedReaderNotify::msgChanged, this, &PreviewFeedDialog::msgChanged, Qt::QueuedConnection);
ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_NONE), RS_FEED_TRANSFORMATION_TYPE_NONE);
ui->transformationTypeComboBox->addItem(FeedReaderStringDefs::transforationTypeString(RS_FEED_TRANSFORMATION_TYPE_XPATH), RS_FEED_TRANSFORMATION_TYPE_XPATH);
@ -217,7 +219,7 @@ PreviewFeedDialog::~PreviewFeedDialog()
disconnect(mNotify);
disconnect(mNotify);
if (!mFeedId.empty()) {
if (mFeedId) {
mFeedReader->removeFeed(mFeedId);
}
@ -282,19 +284,19 @@ bool PreviewFeedDialog::eventFilter(QObject *obj, QEvent *event)
return QDialog::eventFilter(obj, event);
}
void PreviewFeedDialog::feedChanged(const QString &feedId, int type)
void PreviewFeedDialog::feedChanged(uint32_t feedId, int type)
{
if (feedId.isEmpty()) {
if (feedId == 0) {
return;
}
if (feedId.toStdString() != mFeedId) {
if (feedId != mFeedId) {
return;
}
if (type == NOTIFY_TYPE_DEL) {
/* feed deleted */
mFeedId.clear();
mFeedId = 0;
return;
}
@ -307,13 +309,13 @@ void PreviewFeedDialog::feedChanged(const QString &feedId, int type)
}
}
void PreviewFeedDialog::msgChanged(const QString &feedId, const QString &msgId, int type)
void PreviewFeedDialog::msgChanged(uint32_t feedId, const QString &msgId, int type)
{
if (feedId.isEmpty() || msgId.isEmpty()) {
if (feedId == 0 || msgId.isEmpty()) {
return;
}
if (feedId.toStdString() != mFeedId) {
if (feedId != mFeedId) {
return;
}

View File

@ -77,8 +77,8 @@ private slots:
void transformationTypeChanged();
/* FeedReaderNotify */
void feedChanged(const QString &feedId, int type);
void msgChanged(const QString &feedId, const QString &msgId, int type);
void feedChanged(uint32_t feedId, int type);
void msgChanged(uint32_t feedId, const QString &msgId, int type);
private:
void processSettings(bool load);
@ -93,7 +93,7 @@ private:
RsFeedReader *mFeedReader;
FeedReaderNotify *mNotify;
std::string mFeedId;
uint32_t mFeedId;
std::string mMsgId;
std::list<std::string> mMsgIds;
std::string mDescription;

View File

@ -108,8 +108,8 @@ public:
transformationType = RS_FEED_TRANSFORMATION_TYPE_NONE;
}
std::string feedId;
std::string parentId;
uint32_t feedId;
uint32_t parentId;
std::string url;
std::string name;
std::string description;
@ -159,7 +159,7 @@ public:
}
std::string msgId;
std::string feedId;
uint32_t feedId;
std::string title;
std::string link;
std::string author;
@ -179,8 +179,8 @@ class RsFeedReaderNotify
public:
RsFeedReaderNotify() {}
virtual void notifyFeedChanged(const std::string &/*feedId*/, int /*type*/) {}
virtual void notifyMsgChanged(const std::string &/*feedId*/, const std::string &/*msgId*/, int /*type*/) {}
virtual void notifyFeedChanged(uint32_t /*feedId*/, int /*type*/) {}
virtual void notifyMsgChanged(uint32_t /*feedId*/, const std::string &/*msgId*/, int /*type*/) {}
};
class RsFeedReader
@ -201,24 +201,24 @@ public:
virtual bool getSaveInBackground() = 0;
virtual void setSaveInBackground(bool saveInBackground) = 0;
virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId) = 0;
virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name) = 0;
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId) = 0;
virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo) = 0;
virtual bool removeFeed(const std::string &feedId) = 0;
virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId) = 0;
virtual void getFeedList(const std::string &parentId, std::list<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 bool retransformMsg(const std::string &feedId, const std::string &msgId) = 0;
virtual bool clearMessageCache(const std::string &feedId) = 0;
virtual RsFeedAddResult addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId) = 0;
virtual RsFeedAddResult setFolder(uint32_t feedId, const std::string &name) = 0;
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, uint32_t &feedId) = 0;
virtual RsFeedAddResult setFeed(uint32_t feedId, const FeedInfo &feedInfo) = 0;
virtual bool removeFeed(uint32_t feedId) = 0;
virtual bool addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId) = 0;
virtual void getFeedList(uint32_t parentId, std::list<FeedInfo> &feedInfos) = 0;
virtual bool getFeedInfo(uint32_t feedId, FeedInfo &feedInfo) = 0;
virtual bool getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo) = 0;
virtual bool removeMsg(uint32_t feedId, const std::string &msgId) = 0;
virtual bool removeMsgs(uint32_t feedId, const std::list<std::string> &msgIds) = 0;
virtual bool getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount) = 0;
virtual bool getFeedMsgList(uint32_t feedId, std::list<FeedMsgInfo> &msgInfos) = 0;
virtual bool getFeedMsgIdList(uint32_t feedId, std::list<std::string> &msgIds) = 0;
virtual bool processFeed(uint32_t feedId) = 0;
virtual bool setMessageRead(uint32_t feedId, const std::string &msgId, bool read) = 0;
virtual bool retransformMsg(uint32_t feedId, const std::string &msgId) = 0;
virtual bool clearMessageCache(uint32_t feedId) = 0;
virtual RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString) = 0;
virtual RsFeedReaderErrorState processXslt(const std::string &xslt, std::string &description, std::string &errorString) = 0;

View File

@ -63,12 +63,12 @@ p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler, RsGxsForums *forums)
mPreviewProcessThread = NULL;
/* start download thread */
p3FeedReaderThread *frt = new p3FeedReaderThread(this, p3FeedReaderThread::DOWNLOAD, "");
p3FeedReaderThread *frt = new p3FeedReaderThread(this, p3FeedReaderThread::DOWNLOAD, 0);
mThreads.push_back(frt);
frt->start("fr download");
/* start process thread */
frt = new p3FeedReaderThread(this, p3FeedReaderThread::PROCESS, "");
frt = new p3FeedReaderThread(this, p3FeedReaderThread::PROCESS, 0);
mThreads.push_back(frt);
frt->start("fr process");
}
@ -321,7 +321,7 @@ void p3FeedReader::stop()
/* stop threads */
std::list<p3FeedReaderThread*>::iterator it;
for (it = mThreads.begin(); it != mThreads.end(); ++it) {
(*it)->join();
(*it)->fullstop();
delete(*it);
}
mThreads.clear();
@ -331,27 +331,27 @@ void p3FeedReader::stop()
void p3FeedReader::stopPreviewThreads_locked()
{
if (mPreviewDownloadThread) {
mPreviewDownloadThread->join();
mPreviewDownloadThread->fullstop();
delete mPreviewDownloadThread;
mPreviewDownloadThread = NULL;
}
if (mPreviewProcessThread) {
mPreviewProcessThread->join();
mPreviewProcessThread->fullstop();
delete mPreviewProcessThread;
mPreviewProcessThread = NULL;
}
}
RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::string &name, std::string &feedId)
RsFeedAddResult p3FeedReader::addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId)
{
feedId.clear();
feedId = 0;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
if (!parentId.empty()) {
if (parentId) {
/* check parent id */
std::map<std::string, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(parentId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(parentId);
if (parentIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::addFolder - parent id " << parentId << " not found" << std::endl;
@ -368,7 +368,7 @@ RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::s
}
RsFeedReaderFeed *fi = new RsFeedReaderFeed;
rs_sprintf(fi->feedId, "%lu", mNextFeedId++);
fi->feedId = mNextFeedId++;
fi->parentId = parentId;
fi->name = name;
fi->flag = RS_FEED_FLAG_FOLDER;
@ -386,7 +386,7 @@ RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::s
return RS_FEED_ADD_RESULT_SUCCESS;
}
RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::string &name)
RsFeedAddResult p3FeedReader::setFolder(uint32_t feedId, const std::string &name)
{
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -395,7 +395,7 @@ RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::st
std::cerr << "p3FeedReader::setFolder - feed id " << feedId << ", name " << name << std::endl;
#endif
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::setFolder - feed id " << feedId << " not found" << std::endl;
@ -426,9 +426,9 @@ RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::st
return RS_FEED_ADD_RESULT_SUCCESS;
}
RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &feedId)
RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, uint32_t &feedId)
{
feedId.clear();
feedId = 0;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -437,9 +437,9 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
std::cerr << "p3FeedReader::addFeed - add feed " << feedInfo.name << ", url " << feedInfo.url << std::endl;
#endif
if (!feedInfo.parentId.empty()) {
if (feedInfo.parentId) {
/* check parent id */
std::map<std::string, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
if (parentIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::addFeed - parent id " << feedInfo.parentId << " not found" << std::endl;
@ -457,7 +457,7 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
RsFeedReaderFeed *fi = new RsFeedReaderFeed;
infoToFeed(feedInfo, fi);
rs_sprintf(fi->feedId, "%lu", mNextFeedId++);
fi->feedId = mNextFeedId++;
mFeeds[fi->feedId] = fi;
@ -473,7 +473,7 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
return RS_FEED_ADD_RESULT_SUCCESS;
}
RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo &feedInfo)
RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
{
std::string forumId;
std::string forumName;
@ -486,7 +486,7 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo
std::cerr << "p3FeedReader::setFeed - set feed " << feedInfo.name << ", url " << feedInfo.url << std::endl;
#endif
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::setFeed - feed id " << feedId << " not found" << std::endl;
@ -501,9 +501,9 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo
return RS_FEED_ADD_RESULT_FEED_IS_FOLDER;
}
if (!feedInfo.parentId.empty()) {
if (feedInfo.parentId) {
/* check parent id */
std::map<std::string, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
if (parentIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::setFeed - parent id " << feedInfo.parentId << " not found" << std::endl;
@ -567,16 +567,16 @@ void p3FeedReader::deleteAllMsgs_locked(RsFeedReaderFeed *fi)
fi->msgs.clear();
}
bool p3FeedReader::removeFeed(const std::string &feedId)
bool p3FeedReader::removeFeed(uint32_t feedId)
{
std::list<std::string> removedFeedIds;
std::list<uint32_t> removedFeedIds;
bool changed = false;
bool preview = false;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::removeFeed - feed " << feedId << " not found" << std::endl;
@ -592,20 +592,20 @@ bool p3FeedReader::removeFeed(const std::string &feedId)
preview = fi->preview;
if (fi->flag & RS_FEED_FLAG_FOLDER) {
std::list<std::string> feedIds;
std::list<uint32_t> feedIds;
feedIds.push_back(fi->feedId);
while (!feedIds.empty()) {
std::string parentId = feedIds.front();
uint32_t parentId = feedIds.front();
feedIds.pop_front();
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt1;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt1;
for (feedIt1 = mFeeds.begin(); feedIt1 != mFeeds.end(); ) {
RsFeedReaderFeed *fi1 = feedIt1->second;
if (fi1->parentId == parentId) {
removedFeedIds.push_back(fi1->feedId);
std::map<std::string, RsFeedReaderFeed*>::iterator tempIt = feedIt1;
std::map<uint32_t, RsFeedReaderFeed*>::iterator tempIt = feedIt1;
++feedIt1;
mFeeds.erase(tempIt);
@ -642,7 +642,7 @@ bool p3FeedReader::removeFeed(const std::string &feedId)
if (mNotify) {
/* only notify remove of feed */
std::list<std::string>::iterator it;
std::list<uint32_t>::iterator it;
for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) {
mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_DEL);
}
@ -651,7 +651,7 @@ bool p3FeedReader::removeFeed(const std::string &feedId)
return true;
}
bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId)
{
{
RsStackMutex stack(mPreviewMutex); /******* LOCK STACK MUTEX *********/
@ -659,7 +659,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
stopPreviewThreads_locked();
}
feedId.clear();
feedId = 0;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -670,7 +670,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
RsFeedReaderFeed *fi = new RsFeedReaderFeed;
infoToFeed(feedInfo, fi);
rs_sprintf(fi->feedId, "preview%d", mNextPreviewFeedId--);
fi->feedId = mNextPreviewFeedId--;
fi->preview = true;
/* process feed */
@ -678,7 +678,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
fi->content.clear();
/* clear not needed members */
fi->parentId.clear();
fi->parentId = 0;
fi->updateInterval = 0;
fi->lastUpdate = 0;
fi->forumId.clear();
@ -708,11 +708,11 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
return true;
}
void p3FeedReader::getFeedList(const std::string &parentId, std::list<FeedInfo> &feedInfos)
void p3FeedReader::getFeedList(uint32_t parentId, std::list<FeedInfo> &feedInfos)
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
RsFeedReaderFeed *fi = feedIt->second;
@ -728,11 +728,11 @@ void p3FeedReader::getFeedList(const std::string &parentId, std::list<FeedInfo>
}
}
bool p3FeedReader::getFeedInfo(const std::string &feedId, FeedInfo &feedInfo)
bool p3FeedReader::getFeedInfo(uint32_t feedId, FeedInfo &feedInfo)
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::getFeedInfo - feed " << feedId << " not found" << std::endl;
@ -745,11 +745,11 @@ bool p3FeedReader::getFeedInfo(const std::string &feedId, FeedInfo &feedInfo)
return true;
}
bool p3FeedReader::getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo)
bool p3FeedReader::getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo)
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::getMsgInfo - feed " << feedId << " not found" << std::endl;
@ -773,14 +773,14 @@ bool p3FeedReader::getMsgInfo(const std::string &feedId, const std::string &msgI
return true;
}
bool p3FeedReader::removeMsg(const std::string &feedId, const std::string &msgId)
bool p3FeedReader::removeMsg(uint32_t feedId, const std::string &msgId)
{
bool changed = false;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::removeMsg - feed " << feedId << " not found" << std::endl;
@ -819,7 +819,7 @@ bool p3FeedReader::removeMsg(const std::string &feedId, const std::string &msgId
return true;
}
bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list<std::string> &msgIds)
bool p3FeedReader::removeMsgs(uint32_t feedId, const std::list<std::string> &msgIds)
{
std::list<std::string> removedMsgs;
bool changed = false;
@ -827,7 +827,7 @@ bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list<std::st
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::removeMsgs - feed " << feedId << " not found" << std::endl;
@ -875,7 +875,7 @@ bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list<std::st
return true;
}
bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount)
bool p3FeedReader::getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount)
{
if (msgCount) *msgCount = 0;
if (unreadCount) *unreadCount = 0;
@ -887,8 +887,8 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
if (feedId.empty()) {
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
if (feedId == 0) {
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
RsFeedReaderFeed *fi = feedIt->second;
@ -906,7 +906,7 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount
}
}
} else {
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::getMessageCount - feed " << feedId << " not found" << std::endl;
@ -933,11 +933,11 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount
return true;
}
bool p3FeedReader::getFeedMsgList(const std::string &feedId, std::list<FeedMsgInfo> &msgInfos)
bool p3FeedReader::getFeedMsgList(uint32_t feedId, std::list<FeedMsgInfo> &msgInfos)
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::getFeedMsgList - feed " << feedId << " not found" << std::endl;
@ -963,11 +963,11 @@ bool p3FeedReader::getFeedMsgList(const std::string &feedId, std::list<FeedMsgIn
return true;
}
bool p3FeedReader::getFeedMsgIdList(const std::string &feedId, std::list<std::string> &msgIds)
bool p3FeedReader::getFeedMsgIdList(uint32_t feedId, std::list<std::string> &msgIds)
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::getFeedMsgList - feed " << feedId << " not found" << std::endl;
@ -1016,16 +1016,16 @@ static bool canProcessFeed(RsFeedReaderFeed *fi)
return true;
}
bool p3FeedReader::processFeed(const std::string &feedId)
bool p3FeedReader::processFeed(uint32_t feedId)
{
std::list<std::string> feedToDownload;
std::list<uint32_t> feedToDownload;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
if (feedId.empty()) {
if (feedId == 0) {
/* process all feeds */
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
RsFeedReaderFeed *fi = feedIt->second;
@ -1054,13 +1054,13 @@ bool p3FeedReader::processFeed(const std::string &feedId)
RsFeedReaderFeed *fi = feedIt->second;
if (fi->flag & RS_FEED_FLAG_FOLDER) {
std::list<std::string> feedIds;
std::list<uint32_t> feedIds;
feedIds.push_back(fi->feedId);
while (!feedIds.empty()) {
std::string parentId = feedIds.front();
uint32_t parentId = feedIds.front();
feedIds.pop_front();
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt1;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt1;
for (feedIt1 = mFeeds.begin(); feedIt1 != mFeeds.end(); ++feedIt1) {
RsFeedReaderFeed *fi1 = feedIt1->second;
@ -1095,8 +1095,8 @@ bool p3FeedReader::processFeed(const std::string &feedId)
}
}
std::list<std::string> notifyIds;
std::list<std::string>::iterator it;
std::list<uint32_t> notifyIds;
std::list<uint32_t>::iterator it;
if (!feedToDownload.empty()) {
RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/
@ -1118,14 +1118,14 @@ bool p3FeedReader::processFeed(const std::string &feedId)
return true;
}
bool p3FeedReader::setMessageRead(const std::string &feedId, const std::string &msgId, bool read)
bool p3FeedReader::setMessageRead(uint32_t feedId, const std::string &msgId, bool read)
{
bool changed = false;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::setMessageRead - feed " << feedId << " not found" << std::endl;
@ -1168,7 +1168,7 @@ bool p3FeedReader::setMessageRead(const std::string &feedId, const std::string &
return true;
}
bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &msgId)
bool p3FeedReader::retransformMsg(uint32_t feedId, const std::string &msgId)
{
bool msgChanged = false;
bool feedChanged = false;
@ -1176,7 +1176,7 @@ bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::setMessageRead - feed " << feedId << " not found" << std::endl;
@ -1226,7 +1226,7 @@ bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &
return true;
}
bool p3FeedReader::clearMessageCache(const std::string &feedId)
bool p3FeedReader::clearMessageCache(uint32_t feedId)
{
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -1235,7 +1235,7 @@ bool p3FeedReader::clearMessageCache(const std::string &feedId)
std::cerr << "p3FeedReader::clearMessageCache - feed id " << feedId << std::endl;
#endif
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
if (feedIt == mFeeds.end()) {
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::clearMessageCache - feed id " << feedId << " not found" << std::endl;
@ -1292,8 +1292,8 @@ int p3FeedReader::tick()
/* check feeds for update interval */
time_t currentTime = time(NULL);
std::list<std::string> feedToDownload;
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
std::list<uint32_t> feedToDownload;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
@ -1329,8 +1329,8 @@ int p3FeedReader::tick()
}
}
std::list<std::string> notifyIds;
std::list<std::string>::iterator it;
std::list<uint32_t> notifyIds;
std::list<uint32_t>::iterator it;
if (!feedToDownload.empty()) {
RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/
@ -1359,8 +1359,8 @@ void p3FeedReader::cleanFeeds()
if (mLastClean == 0 || mLastClean + FEEDREADER_CLEAN_INTERVAL <= currentTime) {
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
std::list<std::pair<std::string, std::string> > removedMsgIds;
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
std::list<std::pair<uint32_t, std::string> > removedMsgIds;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
RsFeedReaderFeed *fi = feedIt->second;
@ -1379,7 +1379,7 @@ void p3FeedReader::cleanFeeds()
if (mi->flag & RS_FEEDMSG_FLAG_DELETED) {
if (mi->pubDate < currentTime - (long) storageTime) {
removedMsgIds.push_back(std::pair<std::string, std::string> (fi->feedId, mi->msgId));
removedMsgIds.push_back(std::pair<uint32_t, std::string> (fi->feedId, mi->msgId));
delete(mi);
std::map<std::string, RsFeedReaderMsg*>::iterator deleteIt = msgIt++;
fi->msgs.erase(deleteIt);
@ -1400,7 +1400,7 @@ void p3FeedReader::cleanFeeds()
IndicateConfigChanged();
if (mNotify) {
std::list<std::pair<std::string, std::string> >::iterator it;
std::list<std::pair<uint32_t, std::string> >::iterator it;
for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) {
mNotify->notifyMsgChanged(it->first, it->second, NOTIFY_TYPE_DEL);
}
@ -1467,7 +1467,7 @@ bool p3FeedReader::saveList(bool &cleanup, std::list<RsItem *> &saveData)
cleanSaveData.push_back(rskv);
}
std::map<std::string, RsFeedReaderFeed *>::iterator it1;
std::map<uint32_t, RsFeedReaderFeed *>::iterator it1;
for (it1 = mFeeds.begin(); it1 != mFeeds.end(); ++it1) {
RsFeedReaderFeed *fi = it1->second;
if (fi->preview) {
@ -1533,21 +1533,15 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
for (it = load.begin(); it != load.end(); ++it) {
/* switch on type */
if (NULL != (fi = dynamic_cast<RsFeedReaderFeed*>(*it))) {
uint32_t feedId = 0;
if (sscanf(fi->feedId.c_str(), "%u", &feedId) == 1) {
RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/
if (mFeeds.find(fi->feedId) != mFeeds.end()) {
/* feed with the same id exists */
delete mFeeds[fi->feedId];
}
mFeeds[fi->feedId] = fi;
RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/
if (mFeeds.find(fi->feedId) != mFeeds.end()) {
/* feed with the same id exists */
delete mFeeds[fi->feedId];
}
mFeeds[fi->feedId] = fi;
if (feedId + 1 > mNextFeedId) {
mNextFeedId = feedId + 1;
}
} else {
/* invalid feed id */
delete(*it);
if (fi->feedId + 1 > mNextFeedId) {
mNextFeedId = fi->feedId + 1;
}
} else if (NULL != (mi = dynamic_cast<RsFeedReaderMsg*>(*it))) {
if (msgs.find(mi->msgId) != msgs.end()) {
@ -1595,14 +1589,14 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/
/* check feeds */
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
RsFeedReaderFeed *feed = feedIt->second;
if (!feed->parentId.empty()) {
if (feed->parentId) {
/* check parent */
if (mFeeds.find(feed->parentId) == mFeeds.end()) {
/* parent not found, clear it */
feed->parentId.clear();
feed->parentId = 0;
}
}
}
@ -1635,11 +1629,11 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
/****************************** internal ***********************************/
/***************************************************************************/
bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId)
bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeedId)
{
std::string feedId = neededFeedId;
uint32_t feedId = neededFeedId;
if (feedId.empty()) {
if (feedId == 0) {
RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/
if (mDownloadFeeds.empty()) {
@ -1656,7 +1650,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -1689,7 +1683,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &
return true;
}
void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon)
void p3FeedReader::onDownloadSuccess(uint32_t feedId, const std::string &content, std::string &icon)
{
bool preview;
@ -1697,7 +1691,7 @@ void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::strin
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -1738,13 +1732,13 @@ void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::strin
}
}
void p3FeedReader::onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString)
void p3FeedReader::onDownloadError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString)
{
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -1775,11 +1769,11 @@ void p3FeedReader::onDownloadError(const std::string &feedId, RsFeedReaderErrorS
}
}
bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId)
bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId)
{
std::string feedId = neededFeedId;
uint32_t feedId = neededFeedId;
if (feedId.empty()) {
if (feedId == 0) {
RsStackMutex stack(mProcessMutex); /******* LOCK STACK MUTEX *********/
if (mProcessFeeds.empty()) {
@ -1796,7 +1790,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &n
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -1832,7 +1826,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &n
return true;
}
void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs)
void p3FeedReader::onProcessSuccess_filterMsg(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs)
{
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::onProcessSuccess_filterMsg - feed " << feedId << " got " << msgs.size() << " messages" << std::endl;
@ -1842,7 +1836,7 @@ void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::li
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -1883,7 +1877,7 @@ void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::li
}
}
void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs, bool single)
void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs, bool single)
{
#ifdef FEEDREADER_DEBUG
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - feed " << feedId << " got " << msgs.size() << " messages" << std::endl;
@ -1898,7 +1892,7 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -2042,13 +2036,13 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
}
}
void p3FeedReader::onProcessError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString)
void p3FeedReader::onProcessError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString)
{
{
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG
@ -2079,7 +2073,7 @@ void p3FeedReader::onProcessError(const std::string &feedId, RsFeedReaderErrorSt
}
}
void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description)
void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description)
{
bool changed = false;
bool preview;
@ -2091,7 +2085,7 @@ void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &nam
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
/* find feed */
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
if (it == mFeeds.end()) {
/* feed not found */
#ifdef FEEDREADER_DEBUG

View File

@ -52,24 +52,24 @@ public:
virtual bool getSaveInBackground();
virtual void setSaveInBackground(bool saveInBackground);
virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId);
virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name);
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId);
virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo);
virtual bool removeFeed(const std::string &feedId);
virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId);
virtual void getFeedList(const std::string &parentId, std::list<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 bool retransformMsg(const std::string &feedId, const std::string &msgId);
virtual bool clearMessageCache(const std::string &feedId);
virtual RsFeedAddResult addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId);
virtual RsFeedAddResult setFolder(uint32_t feedId, const std::string &name);
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, uint32_t &feedId);
virtual RsFeedAddResult setFeed(uint32_t feedId, const FeedInfo &feedInfo);
virtual bool removeFeed(uint32_t feedId);
virtual bool addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId);
virtual void getFeedList(uint32_t parentId, std::list<FeedInfo> &feedInfos);
virtual bool getFeedInfo(uint32_t feedId, FeedInfo &feedInfo);
virtual bool getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo);
virtual bool removeMsg(uint32_t feedId, const std::string &msgId);
virtual bool removeMsgs(uint32_t feedId, const std::list<std::string> &msgIds);
virtual bool getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount);
virtual bool getFeedMsgList(uint32_t feedId, std::list<FeedMsgInfo> &msgInfos);
virtual bool getFeedMsgIdList(uint32_t feedId, std::list<std::string> &msgIds);
virtual bool processFeed(uint32_t feedId);
virtual bool setMessageRead(uint32_t feedId, const std::string &msgId, bool read);
virtual bool retransformMsg(uint32_t feedId, const std::string &msgId);
virtual bool clearMessageCache(uint32_t feedId);
virtual RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString);
virtual RsFeedReaderErrorState processXslt(const std::string &xslt, std::string &description, std::string &errorString);
@ -79,16 +79,16 @@ public:
virtual RsServiceInfo getServiceInfo() ;
/****************** internal STUFF *******************/
bool getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId);
void onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon);
void onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString);
void onProcessSuccess_filterMsg(const std::string &feedId, std::list<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 getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeedId);
void onDownloadSuccess(uint32_t feedId, const std::string &content, std::string &icon);
void onDownloadError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString);
void onProcessSuccess_filterMsg(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs);
void onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs, bool single);
void onProcessError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString);
bool getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId);
bool getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId);
void setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description);
void setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description);
bool getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &forumGroup);
bool updateForumGroup(const RsGxsForumGroup &forumGroup, const std::string &groupName, const std::string &groupDescription);
@ -125,13 +125,13 @@ private:
bool mStandardUseProxy;
std::string mStandardProxyAddress;
uint16_t mStandardProxyPort;
std::map<std::string, RsFeedReaderFeed*> mFeeds;
std::map<uint32_t, RsFeedReaderFeed*> mFeeds;
RsMutex mDownloadMutex;
std::list<std::string> mDownloadFeeds;
std::list<uint32_t> mDownloadFeeds;
RsMutex mProcessMutex;
std::list<std::string> mProcessFeeds;
std::list<uint32_t> mProcessFeeds;
RsMutex mPreviewMutex;
p3FeedReaderThread *mPreviewDownloadThread;

View File

@ -36,7 +36,7 @@ enum FeedFormat { FORMAT_RSS, FORMAT_RDF, FORMAT_ATOM };
* #define FEEDREADER_DEBUG
*********/
p3FeedReaderThread::p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId) :
p3FeedReaderThread::p3FeedReaderThread(p3FeedReader *feedReader, Type type, uint32_t feedId) :
RsTickingThread(), mFeedReader(feedReader), mType(type), mFeedId(feedId)
{
}
@ -49,7 +49,7 @@ p3FeedReaderThread::~p3FeedReaderThread()
/****************************** Thread *************************************/
/***************************************************************************/
void p3FeedReaderThread::data_tick()
void p3FeedReaderThread::threadTick()
{
rstime::rs_usleep(1000000);

View File

@ -42,10 +42,10 @@ public:
};
public:
p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId);
p3FeedReaderThread(p3FeedReader *feedReader, Type type, uint32_t feedId);
virtual ~p3FeedReaderThread();
std::string getFeedId() { return mFeedId; }
uint32_t getFeedId() { return mFeedId; }
static RsFeedReaderErrorState processXPath(const std::list<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);
@ -55,7 +55,7 @@ public:
static RsFeedReaderErrorState processTransformation(const RsFeedReaderFeed &feed, RsFeedReaderMsg *msg, std::string &errorString);
private:
virtual void data_tick();
virtual void threadTick() override; /// @see RsTickingThread
RsFeedReaderErrorState download(const RsFeedReaderFeed &feed, std::string &content, std::string &icon, std::string &errorString);
RsFeedReaderErrorState process(const RsFeedReaderFeed &feed, std::list<RsFeedReaderMsg*> &entries, std::string &errorString);
@ -65,7 +65,7 @@ private:
p3FeedReader *mFeedReader;
Type mType;
std::string mFeedId;
uint32_t mFeedId;
};
#endif

View File

@ -33,8 +33,8 @@ RsFeedReaderFeed::RsFeedReaderFeed()
void RsFeedReaderFeed::clear()
{
feedId.clear();
parentId.clear();
feedId = 0;
parentId = 0;
name.clear();
url.clear();
user.clear();
@ -64,8 +64,8 @@ uint32_t RsFeedReaderSerialiser::sizeFeed(RsFeedReaderFeed *item)
{
uint32_t s = 8; /* header */
s += 2; /* version */
s += GetTlvStringSize(item->feedId);
s += GetTlvStringSize(item->parentId);
s += sizeof(uint32_t);
s += sizeof(uint32_t);
s += GetTlvStringSize(item->url);
s += GetTlvStringSize(item->name);
s += GetTlvStringSize(item->description);
@ -108,9 +108,9 @@ bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, u
offset += 8;
/* add values */
ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->feedId);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */
ok &= setRawUInt32(data, tlvsize, &offset, item->feedId);
ok &= setRawUInt32(data, tlvsize, &offset, item->parentId);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->url);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description);
@ -173,8 +173,28 @@ RsFeedReaderFeed *RsFeedReaderSerialiser::deserialiseFeed(void *data, uint32_t *
/* get values */
uint16_t version = 0;
ok &= getRawUInt16(data, rssize, &offset, &version);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->feedId);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
if (version >= 2) {
ok &= getRawUInt32(data, rssize, &offset, &item->feedId);
ok &= getRawUInt32(data, rssize, &offset, &item->parentId);
} else {
std::string feedId;
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, feedId);
std::string parentId;
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, parentId);
if (ok) {
if (sscanf(feedId.c_str(), "%u", &item->feedId) != 1) {
ok = false;
}
if (!parentId.empty()) {
if (sscanf(parentId.c_str(), "%u", &item->parentId) != 1) {
ok = false;
}
} else {
item->parentId = 0;
}
}
}
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->url);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description);
@ -240,7 +260,7 @@ RsFeedReaderMsg::RsFeedReaderMsg() : RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_T
void RsFeedReaderMsg::clear()
{
msgId.clear();
feedId.clear();
feedId = 0;
title.clear();
link.clear();
author.clear();
@ -260,7 +280,7 @@ uint32_t RsFeedReaderSerialiser::sizeMsg(RsFeedReaderMsg *item)
uint32_t s = 8; /* header */
s += 2; /* version */
s += GetTlvStringSize(item->msgId);
s += GetTlvStringSize(item->feedId);
s += sizeof(uint32_t);
s += GetTlvStringSize(item->title);
s += GetTlvStringSize(item->link);
s += GetTlvStringSize(item->author);
@ -291,9 +311,9 @@ bool RsFeedReaderSerialiser::serialiseMsg(RsFeedReaderMsg *item, void *data, uin
offset += 8;
/* add values */
ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */
ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->msgId);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
ok &= setRawUInt32(data, tlvsize, &offset, item->feedId);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->title);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->link);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->author);
@ -345,7 +365,16 @@ RsFeedReaderMsg *RsFeedReaderSerialiser::deserialiseMsg(void *data, uint32_t *pk
uint16_t version = 0;
ok &= getRawUInt16(data, rssize, &offset, &version);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->msgId);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
if (version >= 2) {
ok &= getRawUInt32(data, rssize, &offset, &item->feedId);
} else {
std::string feedId;
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, feedId);
if (sscanf(feedId.c_str(), "%u", &item->feedId) != 1) {
ok = false;
}
}
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->title);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->link);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->author);

View File

@ -62,10 +62,9 @@ public:
virtual ~RsFeedReaderFeed() {}
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
std::string feedId;
std::string parentId;
uint32_t feedId;
uint32_t parentId;
std::string name;
std::string url;
std::string user;
@ -109,7 +108,7 @@ public:
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
std::string msgId;
std::string feedId;
uint32_t feedId;
std::string title;
std::string link;
std::string author;

View File

@ -96,17 +96,32 @@ win32 {
USE_PRECOMPILED_LIBS = 1
}
}
exists( $$lib/opencv/libopencv_videoio.a) {
message(videoio found in opencv libraries.)
message($$lib)
LIBS += -lopencv_videoio
}
exists( $$lib/libopencv_videoio.dll.a) {
message(videoio found in opencv libraries.)
message($$lib)
LIBS += -lopencv_videoio
}
exists( $$lib/opencv/libopencv_imgcodecs.a) {
message(videoio found in opencv libraries.)
message($$lib)
LIBS += -lopencv_imgcodecs
}
exists( $$lib/opencv/liblibwebp.a) {
message(videoio found in opencv libraries.)
message($$lib)
LIBS += -llibwebp
}
}
isEmpty(USE_PRECOMPILED_LIBS) {
message(Use system opencv libraries.)
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc
}
LIBS += -lzlib -lole32 -loleaut32 -luuid -lvfw32 -llibjpeg -llibtiff -llibpng -llibjasper -lIlmImf
LIBS += -lzlib -lole32 -loleaut32 -luuid -lvfw32 -llibjpeg-turbo -llibtiff -llibpng -llibjasper -lIlmImf
LIBS += -lavifil32 -lavicap32 -lavcodec -lavutil -lswresample
}

View File

@ -414,8 +414,8 @@
<string>Directory</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/folder16.png</normaloff>:/images/folder16.png</iconset>
<iconset resource="../images.qrc">
<normaloff>:/images/foldermail.png</normaloff>:/images/foldermail.png</iconset>
</property>
</item>
</widget>
@ -441,8 +441,8 @@
<string>Download selected</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/download.png</normaloff>:/icons/png/download.png</iconset>
</property>
</widget>
</item>

View File

@ -162,8 +162,8 @@ bool PostedDialog::getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo)
// request all group infos at once
if(! rsPosted->getBoardsInfo(std::list<RsGxsGroupId>(),groups))
return false;
if(! rsPosted->getBoardsInfo(std::list<RsGxsGroupId>(),groups))
return false;
/* Save groups to fill icons and description */

View File

@ -62,6 +62,8 @@
* #define DEBUG_POSTED
***/
static const int POSTED_TABS_POSTS = 1;
/* View mode */
#define VIEW_MODE_FEEDS 1
#define VIEW_MODE_FILES 2
@ -507,7 +509,7 @@ void PostedListWidgetWithModel::showPostDetails()
{
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
QTextDocument doc;
doc.setHtml(post.mMsg.c_str());
@ -529,8 +531,8 @@ void PostedListWidgetWithModel::showPostDetails()
if(index.row()==0 && index.column()==0)
std::cerr << "here" << std::endl;
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
mSelectedPost = post.mMeta.mMsgId;
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
std::list<ChannelPostFileInfo> files;
for(auto& file:post.mFiles)
@ -625,24 +627,30 @@ void PostedListWidgetWithModel::updateGroupData()
void PostedListWidgetWithModel::postPostLoad()
{
std::cerr << "Post channel load..." << std::endl;
std::cerr << "Post channel load..." << std::endl;
whileBlocking(ui->filter_LE)->setText(QString()); //Clear it before navigate, as it will update it.
if(!mSelectedPost.isNull())
{
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mSelectedPost);
if (!mNavigatePendingMsgId.isNull())
navigate(mNavigatePendingMsgId);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
<< mSelectedPost.toStdString() << std::endl;
#ifdef TO_REMOVE
else if( (mLastSelectedPosts.count(groupId()) > 0)
&& !mLastSelectedPosts[groupId()].isNull())
{
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
<< mLastSelectedPosts[groupId()].toStdString() << std::endl;
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus();
}
else
std::cerr << "No pre-selected channel post." << std::endl;
}
#endif
else
std::cerr << "No pre-selected channel post." << std::endl;
whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
whileBlocking(ui->filter_LE)->setText(QString());
whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
}
void PostedListWidgetWithModel::forceRedraw()
@ -721,7 +729,7 @@ QString PostedListWidgetWithModel::groupName(bool)
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
}
void PostedListWidgetWithModel::groupNameChanged(const QString &name)
void PostedListWidgetWithModel::groupNameChanged(const QString &/*name*/)
{
}
@ -737,12 +745,12 @@ QIcon PostedListWidgetWithModel::groupIcon()
return QIcon(postedImage);
}
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
{
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
return;
QModelIndex src_index;
//QModelIndex src_index;
mPostedPostsModel->setAllMsgReadStatus(read);
@ -1126,20 +1134,24 @@ void PostedListWidgetWithModel::blank()
bool PostedListWidgetWithModel::navigate(const RsGxsMessageId& msgId)
{
ui->filter_LE->setText("ID:" + QString::fromStdString(msgId.toStdString()));
QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId);
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus();
ui->tabWidget->setCurrentIndex(POSTED_TABS_POSTS);
mNavigatePendingMsgId.clear();
return true;
}

View File

@ -132,6 +132,9 @@ protected:
virtual void setAllMessagesReadDo(bool read, uint32_t &token) override;
private slots:
#ifdef TO_REMOVE
void showPostDetails();
#endif
void showAuthorInPeople();
void tabCloseRequested(int index);
void updateSorting(int);
@ -166,7 +169,10 @@ private:
RsPostedPostsModel *mPostedPostsModel;
PostedPostDelegate *mPostedPostsDelegate;
RsGxsMessageId mSelectedPost;
#ifdef TO_REMOVE
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
#endif
RsGxsMessageId mNavigatePendingMsgId;
/* UI - from Designer */
Ui::PostedListWidgetWithModel *ui;

View File

@ -260,13 +260,6 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="5">
<widget class="QLabel" name="createdinfolabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
@ -299,16 +292,6 @@
</property>
</widget>
</item>
<item row="6" column="1" colspan="5">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="syncPeriodTitleLabel">
<property name="font">
@ -322,7 +305,24 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="createdinfolabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="syncPeriodLabel">
<property name="text">
<string>unknown</string>
@ -340,7 +340,7 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">

View File

@ -158,42 +158,47 @@ void RsPostedPostsModel::triggerRedraw()
void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
endRemoveRows();
if(strings.empty())
{
mFilteredPosts.clear();
for(int i=0;i<mPosts.size();++i)
mFilteredPosts.push_back(i);
}
{
mFilteredPosts.clear();
for(int i=0;i<(int)(mPosts.size());++i)
mFilteredPosts.push_back(i);
}
else
{
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
{
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
for(int i=0;i<mPosts.size();++i)
{
bool passes_strings = true;
for(int i=0;i<static_cast<int>(mPosts.size());++i)
{
bool passes_strings = true;
for(auto& s:strings)
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
{
if (s.startsWith("ID:",Qt::CaseInsensitive))
passes_strings = passes_strings && mPosts[i].mMeta.mMsgId == RsGxsMessageId(s.right(s.length() - 3).toStdString());
else
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
}
if(passes_strings)
mFilteredPosts.push_back(i);
}
}
count = mFilteredPosts.size();
if(passes_strings)
mFilteredPosts.push_back(i);
}
}
count = mFilteredPosts.size();
mDisplayedStartIndex = 0;
mDisplayedStartIndex = 0;
mDisplayedNbPosts = std::min(count,DEFAULT_DISPLAYED_NB_POSTS) ;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
endInsertRows();
postMods();
}
@ -237,8 +242,8 @@ bool RsPostedPostsModel::getPostData(const QModelIndex& i,RsPostedPost& fmpe) co
bool RsPostedPostsModel::hasChildren(const QModelIndex &parent) const
{
if(!parent.isValid())
return true;
if(!parent.isValid())
return true;
return false; // by default, no post has children
}
@ -292,8 +297,8 @@ QModelIndex RsPostedPostsModel::index(int row, int column, const QModelIndex & p
QModelIndex RsPostedPostsModel::parent(const QModelIndex& index) const
{
if(!index.isValid())
return QModelIndex();
if(!index.isValid())
return QModelIndex();
return QModelIndex(); // there's no hierarchy here. So nothing to do!
}
@ -333,10 +338,10 @@ quintptr RsPostedPostsModel::getParentRow(quintptr ref,int& row) const
int RsPostedPostsModel::getChildrenCount(quintptr ref) const
{
uint32_t entry = 0 ;
//uint32_t entry = 0 ;
if(ref == quintptr(0))
return rowCount()-1;
if(ref == quintptr(0))
return rowCount()-1;
return 0;
}
@ -391,7 +396,7 @@ QVariant RsPostedPostsModel::data(const QModelIndex& index, int role) const
}
}
QVariant RsPostedPostsModel::sizeHintRole(int col) const
QVariant RsPostedPostsModel::sizeHintRole(int /*col*/) const
{
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
@ -483,8 +488,8 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy
void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
{
if(start >= mFilteredPosts.size())
return;
if(start >= (int)mFilteredPosts.size())
return;
preMods();
@ -538,8 +543,8 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
{
if(group_id.isNull())
return;
if(group_id.isNull())
return;
RsThread::async([this, group_id]()
{
@ -592,7 +597,7 @@ void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
});
}
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
//static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
{
@ -761,34 +766,35 @@ void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const
{
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
RsGxsMessageId postId = mid;
RsGxsMessageId postId = mid;
for(uint32_t i=mDisplayedStartIndex;i<mDisplayedStartIndex+mDisplayedNbPosts;++i)
{
for(uint32_t i=mDisplayedStartIndex;i<mDisplayedStartIndex+mDisplayedNbPosts;++i)
{
// First look into msg versions, in case the msg is a version of an existing message
#ifdef TODO
for(auto& msg_id:mPosts[mFilteredPosts[i]].mOlderVersions)
if(msg_id == postId)
{
for(auto& msg_id:mPosts[mFilteredPosts[i]].mOlderVersions)
if(msg_id == postId)
{
quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
return createIndex(i,0, ref);
}
}
#endif
if(mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId)
{
quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
if( mFilteredPosts.size() > (size_t)(i)
&& mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId )
{
quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
return createIndex(i,0, ref);
}
}
}
}
return QModelIndex();
return QModelIndex();
}

View File

@ -52,6 +52,7 @@
#include "gui/chat/ChatUserNotify.h"//For BradCast
#include "util/DateTime.h"
#include "util/imageutil.h"
#include "gui/im_history/ImHistoryBrowser.h"
#include <retroshare/rsstatus.h>
#include <retroshare/rsidentity.h>

View File

@ -27,7 +27,6 @@
#include "ChatStyle.h"
#include "gui/common/HashBox.h"
#include "gui/common/RsButtonOnText.h"
#include "gui/im_history/ImHistoryBrowser.h"
#include "gui/style/RSStyle.h"
#include <retroshare/rsmsgs.h>
@ -47,6 +46,7 @@ class QTextEdit;
class QPushButton;
class ChatWidget;
class QMenu;
class ImHistoryBrowser;
namespace Ui {
class ChatWidget;

View File

@ -171,7 +171,7 @@ private:
bool m_showOfflineNodes;
};
NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent),*/ ui(new Ui::NewFriendList())
NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,parent),*/ ui(new Ui::NewFriendList())
{
ui->setupUi(this);
@ -259,7 +259,7 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
}
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> e)
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> /*e*/)
{
// /!\ The function we're in is called from a different thread. It's very important
// to use this trick in order to avoid data races.
@ -294,7 +294,7 @@ void NewFriendList::sortColumn(int col,Qt::SortOrder so)
restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
}
void NewFriendList::headerContextMenuRequested(QPoint p)
void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
{
QMenu displayMenu(tr("Show Items"), this);
@ -463,6 +463,7 @@ void NewFriendList::processSettings(bool load)
setColumnVisible(RsFriendListModel::COLUMN_THREAD_IP,Settings->value("showIP", isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP)).toBool());
setColumnVisible(RsFriendListModel::COLUMN_THREAD_ID,Settings->value("showID", isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID)).toBool());
setColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT,Settings->value("showLastContact", isColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT)).toBool());
ui->peerTreeWidget->header()->restoreState(Settings->value("headers").toByteArray());
// sort
toggleSortByState(Settings->value("sortByState", mProxyModel->sortByState()).toBool());
@ -488,6 +489,7 @@ void NewFriendList::processSettings(bool load)
Settings->setValue("showIP",isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP));
Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID));
Settings->setValue("showLastContact",isColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT));
Settings->setValue("headers",ui->peerTreeWidget->header()->saveState());
// sort
Settings->setValue("sortByState", mProxyModel->sortByState());
@ -568,133 +570,141 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
//this is a SSL key
textLabel->setText("<strong>" + tr("Node") + "</strong>");
break;
default:
textLabel->setText("<strong>" + tr("UNKNOWN TYPE") + "</strong>");
}
switch (type)
{
case RsFriendListModel::ENTRY_TYPE_GROUP:
{
RsGroupInfo group_info ;
mModel->getGroupData(index,group_info);
case RsFriendListModel::ENTRY_TYPE_GROUP:
{
RsGroupInfo group_info ;
mModel->getGroupData(index,group_info);
bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD;
bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD;
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard);
}
QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard);
}
break;
case RsFriendListModel::ENTRY_TYPE_PROFILE:
{
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile()));
RsFriendListModel::RsProfileDetails details;
mModel->getProfileData(index,details);
if(mModel->getDisplayGroups())
case RsFriendListModel::ENTRY_TYPE_PROFILE:
{
QMenu* addToGroupMenu = NULL;
QMenu* moveToGroupMenu = NULL;
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile()));
std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList);
RsFriendListModel::RsProfileDetails details;
mModel->getProfileData(index,details);
GroupDefs::sortByName(groupInfoList);
if(mModel->getDisplayGroups())
{
QMenu* addToGroupMenu = NULL;
QMenu* moveToGroupMenu = NULL;
RsPgpId gpgId ( details.gpg_id );
std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList);
QModelIndex parent = mModel->parent(index);
GroupDefs::sortByName(groupInfoList);
bool foundGroup = false;
// add action for all groups, except the own group
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
if (parent.isValid())
{
if (addToGroupMenu == NULL)
addToGroupMenu = new QMenu(tr("Add to group"), &contextMenu);
RsPgpId gpgId ( details.gpg_id );
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction);
QModelIndex parent = mModel->parent(index);
bool foundGroup = false;
// add action for all groups, except the own group
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
if (parent.isValid())
{
if (addToGroupMenu == NULL)
addToGroupMenu = new QMenu(tr("Add to group"), &contextMenu);
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction);
}
if (moveToGroupMenu == NULL) {
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMenu);
}
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction);
} else {
foundGroup = true;
}
}
QMenu *groupsMenu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups"));
groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup()));
if (addToGroupMenu || moveToGroupMenu || foundGroup) {
if (addToGroupMenu) {
groupsMenu->addMenu(addToGroupMenu);
}
if (moveToGroupMenu == NULL) {
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMenu);
if (moveToGroupMenu) {
groupsMenu->addMenu(moveToGroupMenu);
}
if (foundGroup)
{
// add remove from group
if (parent.isValid() && mModel->getType(parent) == RsFriendListModel::ENTRY_TYPE_GROUP)
{
RsGroupInfo info ;
mModel->getGroupData(parent,info);
QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group ")+QString::fromUtf8(info.name.c_str()));
removeFromGroup->setData(parent.sibling(parent.row(),RsFriendListModel::COLUMN_THREAD_ID).data(Qt::DisplayRole));
connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups"));
removeFromAllGroups->setData("");
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction);
} else {
foundGroup = true;
}
}
QMenu *groupsMenu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups"));
groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup()));
if (addToGroupMenu || moveToGroupMenu || foundGroup) {
if (addToGroupMenu) {
groupsMenu->addMenu(addToGroupMenu);
}
if (moveToGroupMenu) {
groupsMenu->addMenu(moveToGroupMenu);
}
if (foundGroup)
{
// add remove from group
if (parent.isValid() && mModel->getType(parent) == RsFriendListModel::ENTRY_TYPE_GROUP)
{
RsGroupInfo info ;
mModel->getGroupData(parent,info);
QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group ")+QString::fromUtf8(info.name.c_str()));
removeFromGroup->setData(parent.sibling(parent.row(),RsFriendListModel::COLUMN_THREAD_ID).data(Qt::DisplayRole));
connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups"));
removeFromAllGroups->setData("");
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
}
}
}
break ;
case RsFriendListModel::ENTRY_TYPE_NODE:
{
case RsFriendListModel::ENTRY_TYPE_NODE:
{
#ifdef RS_DIRECT_CHAT
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode()));
contextMenu.addSeparator();
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode()));
contextMenu.addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode()));
if (type == RsFriendListModel::ENTRY_TYPE_PROFILE || type == RsFriendListModel::ENTRY_TYPE_NODE)
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode()));
if (type == RsFriendListModel::ENTRY_TYPE_PROFILE || type == RsFriendListModel::ENTRY_TYPE_NODE)
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode()));
RsFriendListModel::RsNodeDetails details;
mModel->getNodeData(index,details);
RsFriendListModel::RsNodeDetails details;
mModel->getNodeData(index,details);
if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id ))
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode()));
if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id ))
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
//this is a SSL key
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode()));
//this is a SSL key
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode()));
}
}
break;
default:
{
contextMenu.addSection("Report it to Devs!");
}
}
}
@ -722,6 +732,7 @@ void NewFriendList::createNewGroup()
createGrpDialog.exec();
}
#ifdef NOT_USED
static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
{
int avatarWidth = avatar.width();
@ -740,6 +751,7 @@ static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
icon.addPixmap(pixmap);
return icon;
}
#endif
void NewFriendList::addFriend()
{
@ -755,37 +767,37 @@ void NewFriendList::addFriend()
}
void NewFriendList::msgProfile()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
}
void NewFriendList::msgGroup()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
}
void NewFriendList::msgNode()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
}
void NewFriendList::chatNode()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
ChatDialog::chatFriend(ChatId(det.id));
}
@ -794,10 +806,10 @@ void NewFriendList::recommendNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::recommendFriend(std::set<RsPeerId>({ det.id }));
MessageComposer::recommendFriend(std::set<RsPeerId>({ det.id }));
}
void NewFriendList::pastePerson()
@ -808,10 +820,10 @@ void NewFriendList::pastePerson()
void NewFriendList::copyFullCertificate()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
QList<RetroShareLink> urls;
RetroShareLink link = RetroShareLink::createCertificate(det.id);
@ -935,33 +947,33 @@ void NewFriendList::removeItem()
void NewFriendList::removeNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this node?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
rsPeers->removeFriendLocation(det.id);
checkInternalData(true);
checkInternalData(true);
}
void NewFriendList::removeProfile()
{
RsFriendListModel::RsProfileDetails det;
if(!getCurrentProfile(det) || !rsPeers)
return;
RsFriendListModel::RsProfileDetails det;
if(!getCurrentProfile(det) || !rsPeers)
return;
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
rsPeers->removeFriend(det.gpg_id);
checkInternalData(true);
checkInternalData(true);
}
void NewFriendList::connectNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
rsPeers->connectAttempt(det.id);
ConnectProgressDialog::showProgress(det.id);
@ -972,17 +984,17 @@ void NewFriendList::configureNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
ConfCertDialog::showIt(det.id, ConfCertDialog::PageDetails);
}
void NewFriendList::configureProfile()
{
RsFriendListModel::RsProfileDetails det;
RsFriendListModel::RsProfileDetails det;
if(!getCurrentProfile(det))
return;
if(!getCurrentProfile(det))
return;
PGPKeyDialog::showIt(det.gpg_id, PGPKeyDialog::PageDetails);
}
@ -1079,11 +1091,11 @@ void NewFriendList::removeGroup()
{
RsGroupInfo pinfo;
if(!getCurrentGroup(pinfo))
return;
if(!getCurrentGroup(pinfo))
return;
rsPeers->removeGroup(pinfo.id);
checkInternalData(true);
checkInternalData(true);
}
void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
@ -1199,7 +1211,7 @@ bool NewFriendList::importExportFriendlistFileDialog(QString &fileName, bool imp
, tr("Select a file for exporting your friendlist to")
, tr("XML File (*.xml);;All Files (*)")
, fileName, NULL
, (QFileDialog::Options)0
, QFileDialog::Options()
);
}
if ( res && !fileName.endsWith(".xml",Qt::CaseInsensitive) )

View File

@ -18,19 +18,24 @@
* *
*******************************************************************************/
#include <iostream>
#include <QDesktopServices>
#include <QDir>
#include <QPainter>
#include <QTextDocumentFragment>
#include "RSTextBrowser.h"
#include "RSImageBlockWidget.h"
#include "gui/common/FilesDefs.h"
#include <retroshare/rsinit.h> //To get RsAccounts
#include <QDesktopServices>
#include <QDialog>
#include <QDir>
#include <QGridLayout>
#include <QMenu>
#include <QPainter>
#include <QPlainTextEdit>
#include <QTextDocumentFragment>
#include <iostream>
RSTextBrowser::RSTextBrowser(QWidget *parent) :
QTextBrowser(parent)
{
@ -291,3 +296,37 @@ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
}
return anchor;
}
QMenu *RSTextBrowser::createStandardContextMenu()
{
return createStandardContextMenu(QPoint());
}
QMenu *RSTextBrowser::createStandardContextMenu(const QPoint &position)
{
QMenu *menu = QTextBrowser::createStandardContextMenu(position);
menu->addSeparator();
QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource()));
a->setEnabled(!this->document()->isEmpty());
return menu;
}
void RSTextBrowser::viewSource()
{
QString text = this->textCursor().selection().toHtml();
if (text.isEmpty())
text = this->document()->toHtml();
QDialog *dialog = new QDialog(this);
QPlainTextEdit *pte = new QPlainTextEdit(dialog);
pte->setPlainText(text);
QGridLayout *gl = new QGridLayout(dialog);
gl->addWidget(pte,0,0,1,1);
dialog->setWindowTitle(tr("Document source"));
dialog->resize(500, 400);
dialog->exec();
delete dialog;
}

View File

@ -56,6 +56,9 @@ public:
QVariant textColorQuotes() const { return highlighter->textColorQuotes();}
bool getShowImages() const { return mShowImages; }
QMenu *createStandardContextMenu();
QMenu *createStandardContextMenu(const QPoint &position);
public slots:
void showImages();
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
@ -64,6 +67,7 @@ public slots:
private slots:
void linkClicked(const QUrl &url);
void destroyImageBlockWidget();
void viewSource();
protected:
void paintEvent(QPaintEvent *event);

View File

@ -99,7 +99,11 @@ void GxsForumMsgItem::setup()
/* clear ui */
ui->titleLabel->setText(tr("Loading..."));
ui->titleLabel->setOpenExternalLinks(false); //To get linkActivated working
connect(ui->titleLabel, SIGNAL(linkActivated(QString)), this, SLOT(on_linkActivated(QString)));
ui->subjectLabel->clear();
ui->subjectLabel->setOpenExternalLinks(false); //To get linkActivated working
connect(ui->subjectLabel, SIGNAL(linkActivated(QString)), this, SLOT(on_linkActivated(QString)));
ui->timestamplabel->clear();
ui->parentNameLabel->clear();
ui->nameLabel->clear();
@ -506,3 +510,16 @@ void GxsForumMsgItem::setAsRead()
setReadStatus(false, false);
}
void GxsForumMsgItem::on_linkActivated(QString link)
{
RetroShareLink rsLink(link);
if (rsLink.valid() ) {
QList<RetroShareLink> rsLinks;
rsLinks.append(rsLink);
RetroShareLink::process(rsLinks);
removeItem();
return;
}
}

View File

@ -46,20 +46,20 @@ public:
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumMsgItem " + messageId().toStdString()) ; }
protected:
/* FeedItem */
virtual void doExpand(bool open);
virtual void expandFill(bool first);
virtual void doExpand(bool open) override;
virtual void expandFill(bool first) override;
/* load message data */
virtual void loadParentMessage(const RsGxsMessageId &parent_msg);
/* GxsGroupFeedItem */
virtual QString groupName();
virtual QString groupName() override;
virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_FORUM; }
//virtual bool isLoading();
/* GxsFeedItem */
virtual QString messageName();
virtual QString messageName() override;
virtual void loadMessage() override;
virtual void loadComment() override { return; }
@ -70,6 +70,8 @@ private slots:
void unsubscribeForum();
void on_linkActivated(QString link);
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);

View File

@ -555,6 +555,9 @@
<property name="text">
<string notr="true">Current Message..</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
@ -577,17 +580,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
<customwidget>
<class>AvatarWidget</class>
<extends>QLabel</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>

View File

@ -98,6 +98,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
mStateHelper = new UIStateHelper(this);
mStateHelper->addWidget(TOKEN_TYPE_GROUP_SUMMARY, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, true);
connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedCurrentGroup(QString)));

View File

@ -166,7 +166,7 @@ private:
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map<RsGxsGroupId,RsGxsGroupSearchResults>& /* group_infos */){ return false ;}
virtual void clearDistantSearchResults(TurtleRequestId /* id */) {}
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& group_id){ return nullptr ;}
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& /*group_id*/){ return nullptr ;}
void initUi();

View File

@ -774,31 +774,31 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
std::cerr << "showPostDetails: current index is " << index.row() << "," << index.column() << std::endl;
#endif
QTextDocument doc;
doc.setHtml(post.mMsg.c_str());
//QTextDocument doc;
//doc.setHtml(post.mMsg.c_str());
if(post.mMeta.mPublishTs == 0)
{
ui->postDetails_TE->clear();
ui->postLogo_LB->hide();
if(post.mMeta.mPublishTs == 0)
{
ui->postDetails_TE->clear();
ui->postLogo_LB->hide();
ui->postName_LB->hide();
ui->postTime_LB->hide();
mChannelPostFilesModel->clear();
ui->details_TW->setEnabled(false);
mSelectedPost.clear();
mChannelPostFilesModel->clear();
ui->details_TW->setEnabled(false);
//mLastSelectedPosts[groupId()].clear();
return;
}
ui->details_TW->setEnabled(true);
return;
}
ui->details_TW->setEnabled(true);
ui->postLogo_LB->show();
ui->postName_LB->show();
ui->postTime_LB->show();
#ifdef DEBUG_CHANNEL_POSTS_WIDGET
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
#endif
mSelectedPost = post.mMeta.mMsgId;
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
std::list<ChannelPostFileInfo> files;
for(auto& file:post.mFiles)
@ -886,7 +886,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
RsQThreadUtils::postToObject( [this,group]()
{
if(mGroup.mMeta.mGroupId != group.mMeta.mGroupId) // this prevents any attempt to display the wrong index. Navigate() if needed will use mSelectedPost
if(mGroup.mMeta.mGroupId != group.mMeta.mGroupId) // this prevents any attempt to display the wrong index. Navigate() if needed will use mNavigatePendingMsgId
{
#ifdef DEBUG_CHANNEL_POSTS_WIDGET
std::cerr << "Old group: " << mGroup.mMeta.mGroupId << ", new group: " << group.mMeta.mGroupId << ". Celaring selection" << std::endl;
@ -913,12 +913,16 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
{
std::cerr << "Post channel load..." << std::endl;
if(!mSelectedPost.isNull())
if (!mNavigatePendingMsgId.isNull())
navigate(mNavigatePendingMsgId);
else if( (mLastSelectedPosts.count(groupId()) > 0)
&& !mLastSelectedPosts[groupId()].isNull())
{
QModelIndex index = mChannelPostsModel->getIndexOfMessage(mSelectedPost);
QModelIndex index = mChannelPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
<< mSelectedPost.toStdString() << std::endl;
<< mLastSelectedPosts[groupId()].toStdString() << std::endl;
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
@ -1315,20 +1319,22 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId)
{
QModelIndex index = mChannelPostsModel->getIndexOfMessage(msgId);
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in channel " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in channel " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus();
ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS);
ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS);
ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS);
ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS);
mNavigatePendingMsgId.clear();
return true;
}

View File

@ -190,7 +190,8 @@ private:
ChannelPostDelegate *mChannelPostsDelegate;
ChannelPostFilesDelegate *mFilesDelegate;
RsGxsMessageId mSelectedPost;
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
RsGxsMessageId mNavigatePendingMsgId;
/* UI - from Designer */
Ui::GxsChannelPostsWidgetWithModel *ui;

View File

@ -97,7 +97,7 @@ class DistributionItemDelegate: public QStyledItemDelegate
public:
DistributionItemDelegate() {}
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
if(!index.isValid())
{
@ -105,7 +105,7 @@ public:
return ;
}
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
// disable default icon
opt.icon = QIcon();
@ -135,7 +135,7 @@ public:
painter->drawPixmap(r.topLeft() + p, pix);
}
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const override
{
static auto img(FilesDefs::getPixmapFromQtResourcePath(IMAGE_WARNING_YELLOW));
@ -148,7 +148,7 @@ class ReadStatusItemDelegate: public QStyledItemDelegate
public:
ReadStatusItemDelegate() {}
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
if(!index.isValid())
{
@ -156,7 +156,7 @@ public:
return ;
}
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
// disable default icon
opt.icon = QIcon();
@ -194,7 +194,7 @@ public:
painter->drawPixmap(r.topLeft() + p, pix);
}
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const override
{
static auto img(FilesDefs::getPixmapFromQtResourcePath(":/images/message-state-unread.png"));
@ -1204,7 +1204,7 @@ void GxsForumThreadWidget::insertMessage()
int current_index = 0 ;
for(int i=0;i<post_versions.size();++i)
for(int i=0;i<static_cast<int>(post_versions.size());++i)
{
ui->versions_CB->insertItem(i, ((i==0)?tr("(Latest) "):tr("(Old) "))+" "+DateTime::formatLongDateTime( post_versions[i].first));
ui->versions_CB->setItemData(i,QString::fromStdString(post_versions[i].second.toStdString()));
@ -1227,8 +1227,17 @@ void GxsForumThreadWidget::insertMessage()
ui->versions_CB->blockSignals(false) ;
/* request Post */
updateMessageData(mThreadId);
/* request Post */
bool missing = index.sibling(index.row(),RsGxsForumModel::COLUMN_THREAD_DATA).data(RsGxsForumModel::MissingRole).toBool();
if (missing)
{
// Don't update data for missing message else get multiple entry.
setMessageLoadingError(tr("Missing Message:\nThis message is missing. You should receive it later."));
}
else
{
updateMessageData(mThreadId);
}
// markMsgAsRead();
}
@ -1335,7 +1344,7 @@ void GxsForumThreadWidget::previousMessage()
QModelIndex parentIndex = current_index.parent();
int index = current_index.row();
int count = mThreadModel->rowCount(parentIndex) ;
//int count = mThreadModel->rowCount(parentIndex) ;
if (index > 0)
{

View File

@ -232,7 +232,7 @@ win32-g++|win32-clang-g++ {
# Fix linking error (ld.exe: Error: export ordinal too large) due to too
# many exported symbols.
QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
!libretroshare_shared:QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
# Switch off optimization for release version
QMAKE_CXXFLAGS_RELEASE -= -O2

View File

@ -1034,9 +1034,10 @@ static void styleCreate(QDomDocument& doc
it.next();
const QStringList& classUsingIt ( it.value()) ;
bool first = true;
QString classNames = "";
foreach(QString className, classUsingIt) {
if (!className.trimmed().isEmpty()) {
style += QString(first?".":",.") + className;// + " ";
classNames += QString(first?".":",.") + className;// + " ";
first = false;
}
}
@ -1083,9 +1084,9 @@ static void styleCreate(QDomDocument& doc
}
//.S1 .S2 .S4 {font-family:'Sans';}
style += "{" + key + ":" + val + ";}";
style += classNames + "{" + key + ":" + val + ";}";
} else {
style += "{" + it.key() + ";}\n";
style += classNames + "{" + it.key() + ";}\n";
}
}

View File

@ -204,6 +204,10 @@ no_rs_service_terminal_login:CONFIG -= rs_service_terminal_login
CONFIG+=rs_dh_init_check
no_rs_dh_init_check:CONFIG -= rs_dh_init_check
# To export all symbols for the plugins on Windows build we need to build libretroshare as
# shared library. Fix linking error (ld.exe: Error: export ordinal too large) due to too
# many exported symbols.
retroshare_plugins:win32:CONFIG *= libretroshare_shared
# Specify host precompiled jsonapi-generator path, appending the following
# assignation to qmake command line