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 # prepare
rm -r -f $(BUILD_PATH)/opencv-* rm -r -f $(BUILD_PATH)/opencv-*
tar xvf $(DOWNLOAD_PATH)/opencv-$(OPENCV_VERSION).tar.gz 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 # build
mkdir -p opencv-$(OPENCV_VERSION)/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" #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% if errorlevel 1 %cecho% error "Failed to build libraries." & exit /B %ERRORLEVEL%
%cecho% info "Build %SourceName%" %cecho% info "Build %SourceName%"
call "%~dp0build\build.bat" release autologin jsonapi call "%~dp0build\build.bat" release autologin jsonapi plugins
rem plugins
if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL% if errorlevel 1 %cecho% error "Failed to build %SourceName%." & exit /B %ERRORLEVEL%
%cecho% info "Pack %SourceName%" %cecho% info "Pack %SourceName%"

View file

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

View file

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

View file

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

View file

@ -6,10 +6,10 @@ RS_BUILD_PATH=$$clean_path($${OUT_PWD}/../../)
DEPENDPATH *= $$clean_path($${RS_SRC_PATH}/libretroshare/src/) DEPENDPATH *= $$clean_path($${RS_SRC_PATH}/libretroshare/src/)
INCLUDEPATH *= $$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){ equals(TARGET, retroshare):equals(TEMPLATE, lib){
} else { } else {
LIBS *= -L$$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/) -lretroshare
PRE_TARGETDEPS *= $$clean_path($${RS_BUILD_PATH}/libretroshare/src/lib/libretroshare.a) 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 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 # Switch on extra warnings
QMAKE_CFLAGS += -Wextra QMAKE_CFLAGS += -Wextra
QMAKE_CXXFLAGS += -Wextra QMAKE_CXXFLAGS += -Wextra

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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; return;
} }
@ -101,8 +101,8 @@ FeedItem *FeedReaderFeedNotify::feedItem(FeedHolder *parent)
FeedItemData feedItemData = mPendingNewsFeed.front(); FeedItemData feedItemData = mPendingNewsFeed.front();
mPendingNewsFeed.pop_front(); mPendingNewsFeed.pop_front();
if (mFeedReader->getFeedInfo(feedItemData.mFeedId.toStdString(), feedInfo) && if (mFeedReader->getFeedInfo(feedItemData.mFeedId, feedInfo) &&
mFeedReader->getMsgInfo(feedItemData.mFeedId.toStdString(), feedItemData.mMsgId.toStdString(), msgInfo)) { mFeedReader->getMsgInfo(feedItemData.mFeedId, feedItemData.mMsgId.toStdString(), msgInfo)) {
if (msgInfo.flag.isnew) { if (msgInfo.flag.isnew) {
msgPending = true; msgPending = true;
break; break;
@ -115,7 +115,8 @@ FeedItem *FeedReaderFeedNotify::feedItem(FeedHolder *parent)
return NULL; return NULL;
} }
return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo); //TODO: parent?
return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo);
} }
FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent) FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent)
@ -136,5 +137,6 @@ FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder *parent)
msgInfo.description = tr("This is a test message.").toUtf8().constData(); msgInfo.description = tr("This is a test message.").toUtf8().constData();
msgInfo.pubDate = QDateTime::currentDateTime().toTime_t(); msgInfo.pubDate = QDateTime::currentDateTime().toTime_t();
return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo); //TODO: parent?
return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo);
} }

View file

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

View file

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

View file

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

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(); FeedReaderNotify();
/* RsFeedReaderNotify */ /* RsFeedReaderNotify */
virtual void notifyFeedChanged(const std::string &feedId, int type); virtual void notifyFeedChanged(uint32_t feedId, int type);
virtual void notifyMsgChanged(const std::string &feedId, const std::string &msgId, int type); virtual void notifyMsgChanged(uint32_t feedId, const std::string &msgId, int type);
signals: signals:
void feedChanged(const QString &feedId, int type); void feedChanged(uint32_t feedId, int type);
void msgChanged(const QString &feedId, const QString &msgId, int type); void msgChanged(uint32_t feedId, const QString &msgId, int type);
}; };
#endif #endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -96,17 +96,32 @@ win32 {
USE_PRECOMPILED_LIBS = 1 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) { exists( $$lib/libopencv_videoio.dll.a) {
message(videoio found in opencv libraries.) message(videoio found in opencv libraries.)
message($$lib) message($$lib)
LIBS += -lopencv_videoio 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) { isEmpty(USE_PRECOMPILED_LIBS) {
message(Use system opencv libraries.) message(Use system opencv libraries.)
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc 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 LIBS += -lavifil32 -lavicap32 -lavcodec -lavutil -lswresample
} }

View file

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

View file

@ -62,6 +62,8 @@
* #define DEBUG_POSTED * #define DEBUG_POSTED
***/ ***/
static const int POSTED_TABS_POSTS = 1;
/* View mode */ /* View mode */
#define VIEW_MODE_FEEDS 1 #define VIEW_MODE_FEEDS 1
#define VIEW_MODE_FILES 2 #define VIEW_MODE_FILES 2
@ -529,8 +531,8 @@ void PostedListWidgetWithModel::showPostDetails()
if(index.row()==0 && index.column()==0) if(index.row()==0 && index.column()==0)
std::cerr << "here" << std::endl; std::cerr << "here" << std::endl;
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;
mSelectedPost = post.mMeta.mMsgId; mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
std::list<ChannelPostFileInfo> files; std::list<ChannelPostFileInfo> files;
for(auto& file:post.mFiles) for(auto& file:post.mFiles)
@ -626,23 +628,29 @@ void PostedListWidgetWithModel::updateGroupData()
void PostedListWidgetWithModel::postPostLoad() 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()) if (!mNavigatePendingMsgId.isNull())
navigate(mNavigatePendingMsgId);
#ifdef TO_REMOVE
else if( (mLastSelectedPosts.count(groupId()) > 0)
&& !mLastSelectedPosts[groupId()].isNull())
{ {
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mSelectedPost); QModelIndex index = mPostedPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post " 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->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus(); ui->postsTree->setFocus();
} }
#endif
else else
std::cerr << "No pre-selected channel post." << std::endl; 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->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());
} }
void PostedListWidgetWithModel::forceRedraw() void PostedListWidgetWithModel::forceRedraw()
@ -721,7 +729,7 @@ QString PostedListWidgetWithModel::groupName(bool)
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str()); 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); 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)) if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
return; return;
QModelIndex src_index; //QModelIndex src_index;
mPostedPostsModel->setAllMsgReadStatus(read); mPostedPostsModel->setAllMsgReadStatus(read);
@ -1126,20 +1134,24 @@ void PostedListWidgetWithModel::blank()
bool PostedListWidgetWithModel::navigate(const RsGxsMessageId& msgId) bool PostedListWidgetWithModel::navigate(const RsGxsMessageId& msgId)
{ {
ui->filter_LE->setText("ID:" + QString::fromStdString(msgId.toStdString()));
QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId); QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId);
if(!index.isValid()) if(!index.isValid())
{ {
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl; 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. 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. 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->postsTree->setFocus();
ui->tabWidget->setCurrentIndex(POSTED_TABS_POSTS);
mNavigatePendingMsgId.clear();
return true; return true;
} }

View file

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

View file

@ -260,13 +260,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="1" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="font"> <property name="font">
@ -299,16 +292,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="4" column="0">
<widget class="QLabel" name="syncPeriodTitleLabel"> <widget class="QLabel" name="syncPeriodTitleLabel">
<property name="font"> <property name="font">
@ -322,7 +305,24 @@
</property> </property>
</widget> </widget>
</item> </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"> <widget class="QLabel" name="syncPeriodLabel">
<property name="text"> <property name="text">
<string>unknown</string> <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; <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; &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; } 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> &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>
<property name="textInteractionFlags"> <property name="textInteractionFlags">

View file

@ -166,7 +166,7 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
if(strings.empty()) if(strings.empty())
{ {
mFilteredPosts.clear(); mFilteredPosts.clear();
for(int i=0;i<mPosts.size();++i) for(int i=0;i<(int)(mPosts.size());++i)
mFilteredPosts.push_back(i); mFilteredPosts.push_back(i);
} }
else else
@ -174,12 +174,17 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
mFilteredPosts.clear(); mFilteredPosts.clear();
//mFilteredPosts.push_back(0); //mFilteredPosts.push_back(0);
for(int i=0;i<mPosts.size();++i) for(int i=0;i<static_cast<int>(mPosts.size());++i)
{ {
bool passes_strings = true; bool passes_strings = true;
for(auto& s:strings) for(auto& s:strings)
{
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); passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
}
if(passes_strings) if(passes_strings)
mFilteredPosts.push_back(i); mFilteredPosts.push_back(i);
@ -333,7 +338,7 @@ quintptr RsPostedPostsModel::getParentRow(quintptr ref,int& row) const
int RsPostedPostsModel::getChildrenCount(quintptr ref) const int RsPostedPostsModel::getChildrenCount(quintptr ref) const
{ {
uint32_t entry = 0 ; //uint32_t entry = 0 ;
if(ref == quintptr(0)) if(ref == quintptr(0))
return rowCount()-1; return rowCount()-1;
@ -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 ; float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
@ -483,7 +488,7 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy
void RsPostedPostsModel::setPostsInterval(int start,int nb_posts) void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
{ {
if(start >= mFilteredPosts.size()) if(start >= (int)mFilteredPosts.size())
return; return;
preMods(); preMods();
@ -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) void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
{ {
@ -780,7 +785,8 @@ QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) con
} }
#endif #endif
if(mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId) if( mFilteredPosts.size() > (size_t)(i)
&& mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId )
{ {
quintptr ref ; quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab

View file

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

View file

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

View file

@ -171,7 +171,7 @@ private:
bool m_showOfflineNodes; 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); 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 // /!\ 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. // 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); restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
} }
void NewFriendList::headerContextMenuRequested(QPoint p) void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
{ {
QMenu displayMenu(tr("Show Items"), this); 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_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_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()); 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 // sort
toggleSortByState(Settings->value("sortByState", mProxyModel->sortByState()).toBool()); 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("showIP",isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP));
Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID)); Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID));
Settings->setValue("showLastContact",isColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT)); Settings->setValue("showLastContact",isColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT));
Settings->setValue("headers",ui->peerTreeWidget->header()->saveState());
// sort // sort
Settings->setValue("sortByState", mProxyModel->sortByState()); Settings->setValue("sortByState", mProxyModel->sortByState());
@ -568,6 +570,8 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
//this is a SSL key //this is a SSL key
textLabel->setText("<strong>" + tr("Node") + "</strong>"); textLabel->setText("<strong>" + tr("Node") + "</strong>");
break; break;
default:
textLabel->setText("<strong>" + tr("UNKNOWN TYPE") + "</strong>");
} }
switch (type) switch (type)
@ -695,6 +699,12 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode())); 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(); createGrpDialog.exec();
} }
#ifdef NOT_USED
static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay) static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
{ {
int avatarWidth = avatar.width(); int avatarWidth = avatar.width();
@ -740,6 +751,7 @@ static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
icon.addPixmap(pixmap); icon.addPixmap(pixmap);
return icon; return icon;
} }
#endif
void NewFriendList::addFriend() void NewFriendList::addFriend()
{ {
@ -1199,7 +1211,7 @@ bool NewFriendList::importExportFriendlistFileDialog(QString &fileName, bool imp
, tr("Select a file for exporting your friendlist to") , tr("Select a file for exporting your friendlist to")
, tr("XML File (*.xml);;All Files (*)") , tr("XML File (*.xml);;All Files (*)")
, fileName, NULL , fileName, NULL
, (QFileDialog::Options)0 , QFileDialog::Options()
); );
} }
if ( res && !fileName.endsWith(".xml",Qt::CaseInsensitive) ) 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 "RSTextBrowser.h"
#include "RSImageBlockWidget.h" #include "RSImageBlockWidget.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
#include <retroshare/rsinit.h> //To get RsAccounts #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) : RSTextBrowser::RSTextBrowser(QWidget *parent) :
QTextBrowser(parent) QTextBrowser(parent)
{ {
@ -291,3 +296,37 @@ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
} }
return anchor; 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();} QVariant textColorQuotes() const { return highlighter->textColorQuotes();}
bool getShowImages() const { return mShowImages; } bool getShowImages() const { return mShowImages; }
QMenu *createStandardContextMenu();
QMenu *createStandardContextMenu(const QPoint &position);
public slots: public slots:
void showImages(); void showImages();
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);} void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
@ -64,6 +67,7 @@ public slots:
private slots: private slots:
void linkClicked(const QUrl &url); void linkClicked(const QUrl &url);
void destroyImageBlockWidget(); void destroyImageBlockWidget();
void viewSource();
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);

View file

@ -99,7 +99,11 @@ void GxsForumMsgItem::setup()
/* clear ui */ /* clear ui */
ui->titleLabel->setText(tr("Loading...")); 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->clear();
ui->subjectLabel->setOpenExternalLinks(false); //To get linkActivated working
connect(ui->subjectLabel, SIGNAL(linkActivated(QString)), this, SLOT(on_linkActivated(QString)));
ui->timestamplabel->clear(); ui->timestamplabel->clear();
ui->parentNameLabel->clear(); ui->parentNameLabel->clear();
ui->nameLabel->clear(); ui->nameLabel->clear();
@ -506,3 +510,16 @@ void GxsForumMsgItem::setAsRead()
setReadStatus(false, false); 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()) ; } uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumMsgItem " + messageId().toStdString()) ; }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open) override;
virtual void expandFill(bool first); virtual void expandFill(bool first) override;
/* load message data */ /* load message data */
virtual void loadParentMessage(const RsGxsMessageId &parent_msg); virtual void loadParentMessage(const RsGxsMessageId &parent_msg);
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName() override;
virtual void loadGroup() 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(); //virtual bool isLoading();
/* GxsFeedItem */ /* GxsFeedItem */
virtual QString messageName(); virtual QString messageName() override;
virtual void loadMessage() override; virtual void loadMessage() override;
virtual void loadComment() override { return; } virtual void loadComment() override { return; }
@ -70,6 +70,8 @@ private slots:
void unsubscribeForum(); void unsubscribeForum();
void on_linkActivated(QString link);
signals: signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up); void vote(const RsGxsGrpMsgIdPair& msgId, bool up);

View file

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

View file

@ -98,6 +98,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
mStateHelper = new UIStateHelper(this); mStateHelper = new UIStateHelper(this);
mStateHelper->addWidget(TOKEN_TYPE_GROUP_SUMMARY, ui->loadingLabel, UISTATE_LOADING_VISIBLE); 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(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedCurrentGroup(QString))); 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 QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map<RsGxsGroupId,RsGxsGroupSearchResults>& /* group_infos */){ return false ;} virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map<RsGxsGroupId,RsGxsGroupSearchResults>& /* group_infos */){ return false ;}
virtual void clearDistantSearchResults(TurtleRequestId /* id */) {} 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(); void initUi();

View file

@ -774,8 +774,8 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
std::cerr << "showPostDetails: current index is " << index.row() << "," << index.column() << std::endl; std::cerr << "showPostDetails: current index is " << index.row() << "," << index.column() << std::endl;
#endif #endif
QTextDocument doc; //QTextDocument doc;
doc.setHtml(post.mMsg.c_str()); //doc.setHtml(post.mMsg.c_str());
if(post.mMeta.mPublishTs == 0) if(post.mMeta.mPublishTs == 0)
{ {
@ -785,7 +785,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
ui->postTime_LB->hide(); ui->postTime_LB->hide();
mChannelPostFilesModel->clear(); mChannelPostFilesModel->clear();
ui->details_TW->setEnabled(false); ui->details_TW->setEnabled(false);
mSelectedPost.clear(); //mLastSelectedPosts[groupId()].clear();
return; return;
} }
@ -796,9 +796,9 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
ui->postTime_LB->show(); ui->postTime_LB->show();
#ifdef DEBUG_CHANNEL_POSTS_WIDGET #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 #endif
mSelectedPost = post.mMeta.mMsgId; mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
std::list<ChannelPostFileInfo> files; std::list<ChannelPostFileInfo> files;
for(auto& file:post.mFiles) for(auto& file:post.mFiles)
@ -886,7 +886,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
RsQThreadUtils::postToObject( [this,group]() 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 #ifdef DEBUG_CHANNEL_POSTS_WIDGET
std::cerr << "Old group: " << mGroup.mMeta.mGroupId << ", new group: " << group.mMeta.mGroupId << ". Celaring selection" << std::endl; 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; 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 " 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->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded ui->postsTree->scrollTo(index);//May change if model reloaded
@ -1319,7 +1323,7 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId)
{ {
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in channel " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl; 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. 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. return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
} }
@ -1330,6 +1334,8 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId)
ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS); ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS);
ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS); ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS);
mNavigatePendingMsgId.clear();
return true; return true;
} }

View file

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

View file

@ -97,7 +97,7 @@ class DistributionItemDelegate: public QStyledItemDelegate
public: public:
DistributionItemDelegate() {} 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()) if(!index.isValid())
{ {
@ -105,7 +105,7 @@ public:
return ; return ;
} }
QStyleOptionViewItemV4 opt = option; QStyleOptionViewItem opt = option;
initStyleOption(&opt, index); initStyleOption(&opt, index);
// disable default icon // disable default icon
opt.icon = QIcon(); opt.icon = QIcon();
@ -135,7 +135,7 @@ public:
painter->drawPixmap(r.topLeft() + p, pix); 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)); static auto img(FilesDefs::getPixmapFromQtResourcePath(IMAGE_WARNING_YELLOW));
@ -148,7 +148,7 @@ class ReadStatusItemDelegate: public QStyledItemDelegate
public: public:
ReadStatusItemDelegate() {} 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()) if(!index.isValid())
{ {
@ -156,7 +156,7 @@ public:
return ; return ;
} }
QStyleOptionViewItemV4 opt = option; QStyleOptionViewItem opt = option;
initStyleOption(&opt, index); initStyleOption(&opt, index);
// disable default icon // disable default icon
opt.icon = QIcon(); opt.icon = QIcon();
@ -194,7 +194,7 @@ public:
painter->drawPixmap(r.topLeft() + p, pix); 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")); static auto img(FilesDefs::getPixmapFromQtResourcePath(":/images/message-state-unread.png"));
@ -1204,7 +1204,7 @@ void GxsForumThreadWidget::insertMessage()
int current_index = 0 ; 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->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())); ui->versions_CB->setItemData(i,QString::fromStdString(post_versions[i].second.toStdString()));
@ -1228,7 +1228,16 @@ void GxsForumThreadWidget::insertMessage()
ui->versions_CB->blockSignals(false) ; ui->versions_CB->blockSignals(false) ;
/* request Post */ /* 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); updateMessageData(mThreadId);
}
// markMsgAsRead(); // markMsgAsRead();
} }
@ -1335,7 +1344,7 @@ void GxsForumThreadWidget::previousMessage()
QModelIndex parentIndex = current_index.parent(); QModelIndex parentIndex = current_index.parent();
int index = current_index.row(); int index = current_index.row();
int count = mThreadModel->rowCount(parentIndex) ; //int count = mThreadModel->rowCount(parentIndex) ;
if (index > 0) 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 # Fix linking error (ld.exe: Error: export ordinal too large) due to too
# many exported symbols. # many exported symbols.
QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL !libretroshare_shared:QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
# Switch off optimization for release version # Switch off optimization for release version
QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE -= -O2

View file

@ -1034,9 +1034,10 @@ static void styleCreate(QDomDocument& doc
it.next(); it.next();
const QStringList& classUsingIt ( it.value()) ; const QStringList& classUsingIt ( it.value()) ;
bool first = true; bool first = true;
QString classNames = "";
foreach(QString className, classUsingIt) { foreach(QString className, classUsingIt) {
if (!className.trimmed().isEmpty()) { if (!className.trimmed().isEmpty()) {
style += QString(first?".":",.") + className;// + " "; classNames += QString(first?".":",.") + className;// + " ";
first = false; first = false;
} }
} }
@ -1083,9 +1084,9 @@ static void styleCreate(QDomDocument& doc
} }
//.S1 .S2 .S4 {font-family:'Sans';} //.S1 .S2 .S4 {font-family:'Sans';}
style += "{" + key + ":" + val + ";}"; style += classNames + "{" + key + ":" + val + ";}";
} else { } 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 CONFIG+=rs_dh_init_check
no_rs_dh_init_check: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 # Specify host precompiled jsonapi-generator path, appending the following
# assignation to qmake command line # assignation to qmake command line