mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-01 20:52:05 -04:00
Fixed compile of FeedReader plugin
This commit is contained in:
parent
e88dfecc55
commit
026cadfe13
23 changed files with 366 additions and 345 deletions
|
@ -63,12 +63,12 @@ p3FeedReader::p3FeedReader(RsPluginHandler* pgHandler, RsGxsForums *forums)
|
|||
mPreviewProcessThread = NULL;
|
||||
|
||||
/* start download thread */
|
||||
p3FeedReaderThread *frt = new p3FeedReaderThread(this, p3FeedReaderThread::DOWNLOAD, "");
|
||||
p3FeedReaderThread *frt = new p3FeedReaderThread(this, p3FeedReaderThread::DOWNLOAD, 0);
|
||||
mThreads.push_back(frt);
|
||||
frt->start("fr download");
|
||||
|
||||
/* start process thread */
|
||||
frt = new p3FeedReaderThread(this, p3FeedReaderThread::PROCESS, "");
|
||||
frt = new p3FeedReaderThread(this, p3FeedReaderThread::PROCESS, 0);
|
||||
mThreads.push_back(frt);
|
||||
frt->start("fr process");
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ void p3FeedReader::stop()
|
|||
/* stop threads */
|
||||
std::list<p3FeedReaderThread*>::iterator it;
|
||||
for (it = mThreads.begin(); it != mThreads.end(); ++it) {
|
||||
(*it)->join();
|
||||
(*it)->fullstop();
|
||||
delete(*it);
|
||||
}
|
||||
mThreads.clear();
|
||||
|
@ -331,27 +331,27 @@ void p3FeedReader::stop()
|
|||
void p3FeedReader::stopPreviewThreads_locked()
|
||||
{
|
||||
if (mPreviewDownloadThread) {
|
||||
mPreviewDownloadThread->join();
|
||||
mPreviewDownloadThread->fullstop();
|
||||
delete mPreviewDownloadThread;
|
||||
mPreviewDownloadThread = NULL;
|
||||
}
|
||||
if (mPreviewProcessThread) {
|
||||
mPreviewProcessThread->join();
|
||||
mPreviewProcessThread->fullstop();
|
||||
delete mPreviewProcessThread;
|
||||
mPreviewProcessThread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::string &name, std::string &feedId)
|
||||
RsFeedAddResult p3FeedReader::addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId)
|
||||
{
|
||||
feedId.clear();
|
||||
feedId = 0;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
if (!parentId.empty()) {
|
||||
if (parentId) {
|
||||
/* check parent id */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(parentId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(parentId);
|
||||
if (parentIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::addFolder - parent id " << parentId << " not found" << std::endl;
|
||||
|
@ -368,7 +368,7 @@ RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::s
|
|||
}
|
||||
|
||||
RsFeedReaderFeed *fi = new RsFeedReaderFeed;
|
||||
rs_sprintf(fi->feedId, "%lu", mNextFeedId++);
|
||||
fi->feedId = mNextFeedId++;
|
||||
fi->parentId = parentId;
|
||||
fi->name = name;
|
||||
fi->flag = RS_FEED_FLAG_FOLDER;
|
||||
|
@ -386,7 +386,7 @@ RsFeedAddResult p3FeedReader::addFolder(const std::string parentId, const std::s
|
|||
return RS_FEED_ADD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::string &name)
|
||||
RsFeedAddResult p3FeedReader::setFolder(uint32_t feedId, const std::string &name)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -395,7 +395,7 @@ RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::st
|
|||
std::cerr << "p3FeedReader::setFolder - feed id " << feedId << ", name " << name << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::setFolder - feed id " << feedId << " not found" << std::endl;
|
||||
|
@ -426,9 +426,9 @@ RsFeedAddResult p3FeedReader::setFolder(const std::string &feedId, const std::st
|
|||
return RS_FEED_ADD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &feedId)
|
||||
RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, uint32_t &feedId)
|
||||
{
|
||||
feedId.clear();
|
||||
feedId = 0;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -437,9 +437,9 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
|
|||
std::cerr << "p3FeedReader::addFeed - add feed " << feedInfo.name << ", url " << feedInfo.url << std::endl;
|
||||
#endif
|
||||
|
||||
if (!feedInfo.parentId.empty()) {
|
||||
if (feedInfo.parentId) {
|
||||
/* check parent id */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
|
||||
if (parentIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::addFeed - parent id " << feedInfo.parentId << " not found" << std::endl;
|
||||
|
@ -457,7 +457,7 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
|
|||
|
||||
RsFeedReaderFeed *fi = new RsFeedReaderFeed;
|
||||
infoToFeed(feedInfo, fi);
|
||||
rs_sprintf(fi->feedId, "%lu", mNextFeedId++);
|
||||
fi->feedId = mNextFeedId++;
|
||||
|
||||
mFeeds[fi->feedId] = fi;
|
||||
|
||||
|
@ -473,7 +473,7 @@ RsFeedAddResult p3FeedReader::addFeed(const FeedInfo &feedInfo, std::string &fee
|
|||
return RS_FEED_ADD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo &feedInfo)
|
||||
RsFeedAddResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo)
|
||||
{
|
||||
std::string forumId;
|
||||
std::string forumName;
|
||||
|
@ -486,7 +486,7 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo
|
|||
std::cerr << "p3FeedReader::setFeed - set feed " << feedInfo.name << ", url " << feedInfo.url << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::setFeed - feed id " << feedId << " not found" << std::endl;
|
||||
|
@ -501,9 +501,9 @@ RsFeedAddResult p3FeedReader::setFeed(const std::string &feedId, const FeedInfo
|
|||
return RS_FEED_ADD_RESULT_FEED_IS_FOLDER;
|
||||
}
|
||||
|
||||
if (!feedInfo.parentId.empty()) {
|
||||
if (feedInfo.parentId) {
|
||||
/* check parent id */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator parentIt = mFeeds.find(feedInfo.parentId);
|
||||
if (parentIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::setFeed - parent id " << feedInfo.parentId << " not found" << std::endl;
|
||||
|
@ -567,16 +567,16 @@ void p3FeedReader::deleteAllMsgs_locked(RsFeedReaderFeed *fi)
|
|||
fi->msgs.clear();
|
||||
}
|
||||
|
||||
bool p3FeedReader::removeFeed(const std::string &feedId)
|
||||
bool p3FeedReader::removeFeed(uint32_t feedId)
|
||||
{
|
||||
std::list<std::string> removedFeedIds;
|
||||
std::list<uint32_t> removedFeedIds;
|
||||
bool changed = false;
|
||||
bool preview = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::removeFeed - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -592,20 +592,20 @@ bool p3FeedReader::removeFeed(const std::string &feedId)
|
|||
preview = fi->preview;
|
||||
|
||||
if (fi->flag & RS_FEED_FLAG_FOLDER) {
|
||||
std::list<std::string> feedIds;
|
||||
std::list<uint32_t> feedIds;
|
||||
feedIds.push_back(fi->feedId);
|
||||
while (!feedIds.empty()) {
|
||||
std::string parentId = feedIds.front();
|
||||
uint32_t parentId = feedIds.front();
|
||||
feedIds.pop_front();
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt1;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt1;
|
||||
for (feedIt1 = mFeeds.begin(); feedIt1 != mFeeds.end(); ) {
|
||||
RsFeedReaderFeed *fi1 = feedIt1->second;
|
||||
|
||||
if (fi1->parentId == parentId) {
|
||||
removedFeedIds.push_back(fi1->feedId);
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator tempIt = feedIt1;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator tempIt = feedIt1;
|
||||
++feedIt1;
|
||||
mFeeds.erase(tempIt);
|
||||
|
||||
|
@ -642,7 +642,7 @@ bool p3FeedReader::removeFeed(const std::string &feedId)
|
|||
|
||||
if (mNotify) {
|
||||
/* only notify remove of feed */
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<uint32_t>::iterator it;
|
||||
for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) {
|
||||
mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_DEL);
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ bool p3FeedReader::removeFeed(const std::string &feedId)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
|
||||
bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mPreviewMutex); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -659,7 +659,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
|
|||
stopPreviewThreads_locked();
|
||||
}
|
||||
|
||||
feedId.clear();
|
||||
feedId = 0;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -670,7 +670,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
|
|||
|
||||
RsFeedReaderFeed *fi = new RsFeedReaderFeed;
|
||||
infoToFeed(feedInfo, fi);
|
||||
rs_sprintf(fi->feedId, "preview%d", mNextPreviewFeedId--);
|
||||
fi->feedId = mNextPreviewFeedId--;
|
||||
fi->preview = true;
|
||||
|
||||
/* process feed */
|
||||
|
@ -678,7 +678,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
|
|||
fi->content.clear();
|
||||
|
||||
/* clear not needed members */
|
||||
fi->parentId.clear();
|
||||
fi->parentId = 0;
|
||||
fi->updateInterval = 0;
|
||||
fi->lastUpdate = 0;
|
||||
fi->forumId.clear();
|
||||
|
@ -708,11 +708,11 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId)
|
|||
return true;
|
||||
}
|
||||
|
||||
void p3FeedReader::getFeedList(const std::string &parentId, std::list<FeedInfo> &feedInfos)
|
||||
void p3FeedReader::getFeedList(uint32_t parentId, std::list<FeedInfo> &feedInfos)
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
|
||||
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
|
||||
RsFeedReaderFeed *fi = feedIt->second;
|
||||
|
||||
|
@ -728,11 +728,11 @@ void p3FeedReader::getFeedList(const std::string &parentId, std::list<FeedInfo>
|
|||
}
|
||||
}
|
||||
|
||||
bool p3FeedReader::getFeedInfo(const std::string &feedId, FeedInfo &feedInfo)
|
||||
bool p3FeedReader::getFeedInfo(uint32_t feedId, FeedInfo &feedInfo)
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::getFeedInfo - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -745,11 +745,11 @@ bool p3FeedReader::getFeedInfo(const std::string &feedId, FeedInfo &feedInfo)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo)
|
||||
bool p3FeedReader::getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo)
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::getMsgInfo - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -773,14 +773,14 @@ bool p3FeedReader::getMsgInfo(const std::string &feedId, const std::string &msgI
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::removeMsg(const std::string &feedId, const std::string &msgId)
|
||||
bool p3FeedReader::removeMsg(uint32_t feedId, const std::string &msgId)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::removeMsg - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -819,7 +819,7 @@ bool p3FeedReader::removeMsg(const std::string &feedId, const std::string &msgId
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list<std::string> &msgIds)
|
||||
bool p3FeedReader::removeMsgs(uint32_t feedId, const std::list<std::string> &msgIds)
|
||||
{
|
||||
std::list<std::string> removedMsgs;
|
||||
bool changed = false;
|
||||
|
@ -827,7 +827,7 @@ bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list<std::st
|
|||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::removeMsgs - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -875,7 +875,7 @@ bool p3FeedReader::removeMsgs(const std::string &feedId, const std::list<std::st
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount)
|
||||
bool p3FeedReader::getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount)
|
||||
{
|
||||
if (msgCount) *msgCount = 0;
|
||||
if (unreadCount) *unreadCount = 0;
|
||||
|
@ -887,8 +887,8 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount
|
|||
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
if (feedId.empty()) {
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
|
||||
if (feedId == 0) {
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
|
||||
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
|
||||
RsFeedReaderFeed *fi = feedIt->second;
|
||||
|
||||
|
@ -906,7 +906,7 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount
|
|||
}
|
||||
}
|
||||
} else {
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::getMessageCount - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -933,11 +933,11 @@ bool p3FeedReader::getMessageCount(const std::string &feedId, uint32_t *msgCount
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::getFeedMsgList(const std::string &feedId, std::list<FeedMsgInfo> &msgInfos)
|
||||
bool p3FeedReader::getFeedMsgList(uint32_t feedId, std::list<FeedMsgInfo> &msgInfos)
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::getFeedMsgList - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -963,11 +963,11 @@ bool p3FeedReader::getFeedMsgList(const std::string &feedId, std::list<FeedMsgIn
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::getFeedMsgIdList(const std::string &feedId, std::list<std::string> &msgIds)
|
||||
bool p3FeedReader::getFeedMsgIdList(uint32_t feedId, std::list<std::string> &msgIds)
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::getFeedMsgList - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -1016,16 +1016,16 @@ static bool canProcessFeed(RsFeedReaderFeed *fi)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::processFeed(const std::string &feedId)
|
||||
bool p3FeedReader::processFeed(uint32_t feedId)
|
||||
{
|
||||
std::list<std::string> feedToDownload;
|
||||
std::list<uint32_t> feedToDownload;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
|
||||
|
||||
if (feedId.empty()) {
|
||||
if (feedId == 0) {
|
||||
/* process all feeds */
|
||||
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
|
||||
RsFeedReaderFeed *fi = feedIt->second;
|
||||
|
@ -1054,13 +1054,13 @@ bool p3FeedReader::processFeed(const std::string &feedId)
|
|||
|
||||
RsFeedReaderFeed *fi = feedIt->second;
|
||||
if (fi->flag & RS_FEED_FLAG_FOLDER) {
|
||||
std::list<std::string> feedIds;
|
||||
std::list<uint32_t> feedIds;
|
||||
feedIds.push_back(fi->feedId);
|
||||
while (!feedIds.empty()) {
|
||||
std::string parentId = feedIds.front();
|
||||
uint32_t parentId = feedIds.front();
|
||||
feedIds.pop_front();
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt1;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt1;
|
||||
for (feedIt1 = mFeeds.begin(); feedIt1 != mFeeds.end(); ++feedIt1) {
|
||||
RsFeedReaderFeed *fi1 = feedIt1->second;
|
||||
|
||||
|
@ -1095,8 +1095,8 @@ bool p3FeedReader::processFeed(const std::string &feedId)
|
|||
}
|
||||
}
|
||||
|
||||
std::list<std::string> notifyIds;
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<uint32_t> notifyIds;
|
||||
std::list<uint32_t>::iterator it;
|
||||
|
||||
if (!feedToDownload.empty()) {
|
||||
RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -1118,14 +1118,14 @@ bool p3FeedReader::processFeed(const std::string &feedId)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::setMessageRead(const std::string &feedId, const std::string &msgId, bool read)
|
||||
bool p3FeedReader::setMessageRead(uint32_t feedId, const std::string &msgId, bool read)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::setMessageRead - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -1168,7 +1168,7 @@ bool p3FeedReader::setMessageRead(const std::string &feedId, const std::string &
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &msgId)
|
||||
bool p3FeedReader::retransformMsg(uint32_t feedId, const std::string &msgId)
|
||||
{
|
||||
bool msgChanged = false;
|
||||
bool feedChanged = false;
|
||||
|
@ -1176,7 +1176,7 @@ bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &
|
|||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::setMessageRead - feed " << feedId << " not found" << std::endl;
|
||||
|
@ -1226,7 +1226,7 @@ bool p3FeedReader::retransformMsg(const std::string &feedId, const std::string &
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3FeedReader::clearMessageCache(const std::string &feedId)
|
||||
bool p3FeedReader::clearMessageCache(uint32_t feedId)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -1235,7 +1235,7 @@ bool p3FeedReader::clearMessageCache(const std::string &feedId)
|
|||
std::cerr << "p3FeedReader::clearMessageCache - feed id " << feedId << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt = mFeeds.find(feedId);
|
||||
if (feedIt == mFeeds.end()) {
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::clearMessageCache - feed id " << feedId << " not found" << std::endl;
|
||||
|
@ -1292,8 +1292,8 @@ int p3FeedReader::tick()
|
|||
|
||||
/* check feeds for update interval */
|
||||
time_t currentTime = time(NULL);
|
||||
std::list<std::string> feedToDownload;
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
|
||||
std::list<uint32_t> feedToDownload;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -1329,8 +1329,8 @@ int p3FeedReader::tick()
|
|||
}
|
||||
}
|
||||
|
||||
std::list<std::string> notifyIds;
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<uint32_t> notifyIds;
|
||||
std::list<uint32_t>::iterator it;
|
||||
|
||||
if (!feedToDownload.empty()) {
|
||||
RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/
|
||||
|
@ -1359,8 +1359,8 @@ void p3FeedReader::cleanFeeds()
|
|||
if (mLastClean == 0 || mLastClean + FEEDREADER_CLEAN_INTERVAL <= currentTime) {
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
std::list<std::pair<std::string, std::string> > removedMsgIds;
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
|
||||
std::list<std::pair<uint32_t, std::string> > removedMsgIds;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
|
||||
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
|
||||
RsFeedReaderFeed *fi = feedIt->second;
|
||||
|
||||
|
@ -1379,7 +1379,7 @@ void p3FeedReader::cleanFeeds()
|
|||
|
||||
if (mi->flag & RS_FEEDMSG_FLAG_DELETED) {
|
||||
if (mi->pubDate < currentTime - (long) storageTime) {
|
||||
removedMsgIds.push_back(std::pair<std::string, std::string> (fi->feedId, mi->msgId));
|
||||
removedMsgIds.push_back(std::pair<uint32_t, std::string> (fi->feedId, mi->msgId));
|
||||
delete(mi);
|
||||
std::map<std::string, RsFeedReaderMsg*>::iterator deleteIt = msgIt++;
|
||||
fi->msgs.erase(deleteIt);
|
||||
|
@ -1400,7 +1400,7 @@ void p3FeedReader::cleanFeeds()
|
|||
IndicateConfigChanged();
|
||||
|
||||
if (mNotify) {
|
||||
std::list<std::pair<std::string, std::string> >::iterator it;
|
||||
std::list<std::pair<uint32_t, std::string> >::iterator it;
|
||||
for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) {
|
||||
mNotify->notifyMsgChanged(it->first, it->second, NOTIFY_TYPE_DEL);
|
||||
}
|
||||
|
@ -1467,7 +1467,7 @@ bool p3FeedReader::saveList(bool &cleanup, std::list<RsItem *> &saveData)
|
|||
cleanSaveData.push_back(rskv);
|
||||
}
|
||||
|
||||
std::map<std::string, RsFeedReaderFeed *>::iterator it1;
|
||||
std::map<uint32_t, RsFeedReaderFeed *>::iterator it1;
|
||||
for (it1 = mFeeds.begin(); it1 != mFeeds.end(); ++it1) {
|
||||
RsFeedReaderFeed *fi = it1->second;
|
||||
if (fi->preview) {
|
||||
|
@ -1533,21 +1533,15 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
|
|||
for (it = load.begin(); it != load.end(); ++it) {
|
||||
/* switch on type */
|
||||
if (NULL != (fi = dynamic_cast<RsFeedReaderFeed*>(*it))) {
|
||||
uint32_t feedId = 0;
|
||||
if (sscanf(fi->feedId.c_str(), "%u", &feedId) == 1) {
|
||||
RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/
|
||||
if (mFeeds.find(fi->feedId) != mFeeds.end()) {
|
||||
/* feed with the same id exists */
|
||||
delete mFeeds[fi->feedId];
|
||||
}
|
||||
mFeeds[fi->feedId] = fi;
|
||||
RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/
|
||||
if (mFeeds.find(fi->feedId) != mFeeds.end()) {
|
||||
/* feed with the same id exists */
|
||||
delete mFeeds[fi->feedId];
|
||||
}
|
||||
mFeeds[fi->feedId] = fi;
|
||||
|
||||
if (feedId + 1 > mNextFeedId) {
|
||||
mNextFeedId = feedId + 1;
|
||||
}
|
||||
} else {
|
||||
/* invalid feed id */
|
||||
delete(*it);
|
||||
if (fi->feedId + 1 > mNextFeedId) {
|
||||
mNextFeedId = fi->feedId + 1;
|
||||
}
|
||||
} else if (NULL != (mi = dynamic_cast<RsFeedReaderMsg*>(*it))) {
|
||||
if (msgs.find(mi->msgId) != msgs.end()) {
|
||||
|
@ -1595,14 +1589,14 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
|
|||
RsStackMutex stack(mFeedReaderMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
/* check feeds */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator feedIt;
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator feedIt;
|
||||
for (feedIt = mFeeds.begin(); feedIt != mFeeds.end(); ++feedIt) {
|
||||
RsFeedReaderFeed *feed = feedIt->second;
|
||||
if (!feed->parentId.empty()) {
|
||||
if (feed->parentId) {
|
||||
/* check parent */
|
||||
if (mFeeds.find(feed->parentId) == mFeeds.end()) {
|
||||
/* parent not found, clear it */
|
||||
feed->parentId.clear();
|
||||
feed->parentId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1635,11 +1629,11 @@ bool p3FeedReader::loadList(std::list<RsItem *>& load)
|
|||
/****************************** internal ***********************************/
|
||||
/***************************************************************************/
|
||||
|
||||
bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId)
|
||||
bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeedId)
|
||||
{
|
||||
std::string feedId = neededFeedId;
|
||||
uint32_t feedId = neededFeedId;
|
||||
|
||||
if (feedId.empty()) {
|
||||
if (feedId == 0) {
|
||||
RsStackMutex stack(mDownloadMutex); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
if (mDownloadFeeds.empty()) {
|
||||
|
@ -1656,7 +1650,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &
|
|||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -1689,7 +1683,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, const std::string &
|
|||
return true;
|
||||
}
|
||||
|
||||
void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon)
|
||||
void p3FeedReader::onDownloadSuccess(uint32_t feedId, const std::string &content, std::string &icon)
|
||||
{
|
||||
bool preview;
|
||||
|
||||
|
@ -1697,7 +1691,7 @@ void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::strin
|
|||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -1738,13 +1732,13 @@ void p3FeedReader::onDownloadSuccess(const std::string &feedId, const std::strin
|
|||
}
|
||||
}
|
||||
|
||||
void p3FeedReader::onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString)
|
||||
void p3FeedReader::onDownloadError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -1775,11 +1769,11 @@ void p3FeedReader::onDownloadError(const std::string &feedId, RsFeedReaderErrorS
|
|||
}
|
||||
}
|
||||
|
||||
bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId)
|
||||
bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId)
|
||||
{
|
||||
std::string feedId = neededFeedId;
|
||||
uint32_t feedId = neededFeedId;
|
||||
|
||||
if (feedId.empty()) {
|
||||
if (feedId == 0) {
|
||||
RsStackMutex stack(mProcessMutex); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
if (mProcessFeeds.empty()) {
|
||||
|
@ -1796,7 +1790,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &n
|
|||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -1832,7 +1826,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, const std::string &n
|
|||
return true;
|
||||
}
|
||||
|
||||
void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs)
|
||||
void p3FeedReader::onProcessSuccess_filterMsg(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs)
|
||||
{
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::onProcessSuccess_filterMsg - feed " << feedId << " got " << msgs.size() << " messages" << std::endl;
|
||||
|
@ -1842,7 +1836,7 @@ void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::li
|
|||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -1883,7 +1877,7 @@ void p3FeedReader::onProcessSuccess_filterMsg(const std::string &feedId, std::li
|
|||
}
|
||||
}
|
||||
|
||||
void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs, bool single)
|
||||
void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs, bool single)
|
||||
{
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
std::cerr << "p3FeedReader::onProcessSuccess_addMsgs - feed " << feedId << " got " << msgs.size() << " messages" << std::endl;
|
||||
|
@ -1898,7 +1892,7 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
|
|||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -2042,13 +2036,13 @@ void p3FeedReader::onProcessSuccess_addMsgs(const std::string &feedId, std::list
|
|||
}
|
||||
}
|
||||
|
||||
void p3FeedReader::onProcessError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString)
|
||||
void p3FeedReader::onProcessError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
@ -2079,7 +2073,7 @@ void p3FeedReader::onProcessError(const std::string &feedId, RsFeedReaderErrorSt
|
|||
}
|
||||
}
|
||||
|
||||
void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description)
|
||||
void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description)
|
||||
{
|
||||
bool changed = false;
|
||||
bool preview;
|
||||
|
@ -2091,7 +2085,7 @@ void p3FeedReader::setFeedInfo(const std::string &feedId, const std::string &nam
|
|||
RsStackMutex stack(mFeedReaderMtx); /******* LOCK STACK MUTEX *********/
|
||||
|
||||
/* find feed */
|
||||
std::map<std::string, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
std::map<uint32_t, RsFeedReaderFeed*>::iterator it = mFeeds.find(feedId);
|
||||
if (it == mFeeds.end()) {
|
||||
/* feed not found */
|
||||
#ifdef FEEDREADER_DEBUG
|
||||
|
|
|
@ -52,24 +52,24 @@ public:
|
|||
virtual bool getSaveInBackground();
|
||||
virtual void setSaveInBackground(bool saveInBackground);
|
||||
|
||||
virtual RsFeedAddResult addFolder(const std::string parentId, const std::string &name, std::string &feedId);
|
||||
virtual RsFeedAddResult setFolder(const std::string &feedId, const std::string &name);
|
||||
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, std::string &feedId);
|
||||
virtual RsFeedAddResult setFeed(const std::string &feedId, const FeedInfo &feedInfo);
|
||||
virtual bool removeFeed(const std::string &feedId);
|
||||
virtual bool addPreviewFeed(const FeedInfo &feedInfo, std::string &feedId);
|
||||
virtual void getFeedList(const std::string &parentId, std::list<FeedInfo> &feedInfos);
|
||||
virtual bool getFeedInfo(const std::string &feedId, FeedInfo &feedInfo);
|
||||
virtual bool getMsgInfo(const std::string &feedId, const std::string &msgId, FeedMsgInfo &msgInfo);
|
||||
virtual bool removeMsg(const std::string &feedId, const std::string &msgId);
|
||||
virtual bool removeMsgs(const std::string &feedId, const std::list<std::string> &msgIds);
|
||||
virtual bool getMessageCount(const std::string &feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount);
|
||||
virtual bool getFeedMsgList(const std::string &feedId, std::list<FeedMsgInfo> &msgInfos);
|
||||
virtual bool getFeedMsgIdList(const std::string &feedId, std::list<std::string> &msgIds);
|
||||
virtual bool processFeed(const std::string &feedId);
|
||||
virtual bool setMessageRead(const std::string &feedId, const std::string &msgId, bool read);
|
||||
virtual bool retransformMsg(const std::string &feedId, const std::string &msgId);
|
||||
virtual bool clearMessageCache(const std::string &feedId);
|
||||
virtual RsFeedAddResult addFolder(uint32_t parentId, const std::string &name, uint32_t &feedId);
|
||||
virtual RsFeedAddResult setFolder(uint32_t feedId, const std::string &name);
|
||||
virtual RsFeedAddResult addFeed(const FeedInfo &feedInfo, uint32_t &feedId);
|
||||
virtual RsFeedAddResult setFeed(uint32_t feedId, const FeedInfo &feedInfo);
|
||||
virtual bool removeFeed(uint32_t feedId);
|
||||
virtual bool addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId);
|
||||
virtual void getFeedList(uint32_t parentId, std::list<FeedInfo> &feedInfos);
|
||||
virtual bool getFeedInfo(uint32_t feedId, FeedInfo &feedInfo);
|
||||
virtual bool getMsgInfo(uint32_t feedId, const std::string &msgId, FeedMsgInfo &msgInfo);
|
||||
virtual bool removeMsg(uint32_t feedId, const std::string &msgId);
|
||||
virtual bool removeMsgs(uint32_t feedId, const std::list<std::string> &msgIds);
|
||||
virtual bool getMessageCount(uint32_t feedId, uint32_t *msgCount, uint32_t *newCount, uint32_t *unreadCount);
|
||||
virtual bool getFeedMsgList(uint32_t feedId, std::list<FeedMsgInfo> &msgInfos);
|
||||
virtual bool getFeedMsgIdList(uint32_t feedId, std::list<std::string> &msgIds);
|
||||
virtual bool processFeed(uint32_t feedId);
|
||||
virtual bool setMessageRead(uint32_t feedId, const std::string &msgId, bool read);
|
||||
virtual bool retransformMsg(uint32_t feedId, const std::string &msgId);
|
||||
virtual bool clearMessageCache(uint32_t feedId);
|
||||
|
||||
virtual RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString);
|
||||
virtual RsFeedReaderErrorState processXslt(const std::string &xslt, std::string &description, std::string &errorString);
|
||||
|
@ -79,16 +79,16 @@ public:
|
|||
virtual RsServiceInfo getServiceInfo() ;
|
||||
|
||||
/****************** internal STUFF *******************/
|
||||
bool getFeedToDownload(RsFeedReaderFeed &feed, const std::string &neededFeedId);
|
||||
void onDownloadSuccess(const std::string &feedId, const std::string &content, std::string &icon);
|
||||
void onDownloadError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString);
|
||||
void onProcessSuccess_filterMsg(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs);
|
||||
void onProcessSuccess_addMsgs(const std::string &feedId, std::list<RsFeedReaderMsg*> &msgs, bool single);
|
||||
void onProcessError(const std::string &feedId, RsFeedReaderErrorState result, const std::string &errorString);
|
||||
bool getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeedId);
|
||||
void onDownloadSuccess(uint32_t feedId, const std::string &content, std::string &icon);
|
||||
void onDownloadError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString);
|
||||
void onProcessSuccess_filterMsg(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs);
|
||||
void onProcessSuccess_addMsgs(uint32_t feedId, std::list<RsFeedReaderMsg*> &msgs, bool single);
|
||||
void onProcessError(uint32_t feedId, RsFeedReaderErrorState result, const std::string &errorString);
|
||||
|
||||
bool getFeedToProcess(RsFeedReaderFeed &feed, const std::string &neededFeedId);
|
||||
bool getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId);
|
||||
|
||||
void setFeedInfo(const std::string &feedId, const std::string &name, const std::string &description);
|
||||
void setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description);
|
||||
|
||||
bool getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &forumGroup);
|
||||
bool updateForumGroup(const RsGxsForumGroup &forumGroup, const std::string &groupName, const std::string &groupDescription);
|
||||
|
@ -125,13 +125,13 @@ private:
|
|||
bool mStandardUseProxy;
|
||||
std::string mStandardProxyAddress;
|
||||
uint16_t mStandardProxyPort;
|
||||
std::map<std::string, RsFeedReaderFeed*> mFeeds;
|
||||
std::map<uint32_t, RsFeedReaderFeed*> mFeeds;
|
||||
|
||||
RsMutex mDownloadMutex;
|
||||
std::list<std::string> mDownloadFeeds;
|
||||
std::list<uint32_t> mDownloadFeeds;
|
||||
|
||||
RsMutex mProcessMutex;
|
||||
std::list<std::string> mProcessFeeds;
|
||||
std::list<uint32_t> mProcessFeeds;
|
||||
|
||||
RsMutex mPreviewMutex;
|
||||
p3FeedReaderThread *mPreviewDownloadThread;
|
||||
|
|
|
@ -36,7 +36,7 @@ enum FeedFormat { FORMAT_RSS, FORMAT_RDF, FORMAT_ATOM };
|
|||
* #define FEEDREADER_DEBUG
|
||||
*********/
|
||||
|
||||
p3FeedReaderThread::p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId) :
|
||||
p3FeedReaderThread::p3FeedReaderThread(p3FeedReader *feedReader, Type type, uint32_t feedId) :
|
||||
RsTickingThread(), mFeedReader(feedReader), mType(type), mFeedId(feedId)
|
||||
{
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ p3FeedReaderThread::~p3FeedReaderThread()
|
|||
/****************************** Thread *************************************/
|
||||
/***************************************************************************/
|
||||
|
||||
void p3FeedReaderThread::data_tick()
|
||||
void p3FeedReaderThread::threadTick()
|
||||
{
|
||||
rstime::rs_usleep(1000000);
|
||||
|
||||
|
|
|
@ -42,10 +42,10 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
p3FeedReaderThread(p3FeedReader *feedReader, Type type, const std::string &feedId);
|
||||
p3FeedReaderThread(p3FeedReader *feedReader, Type type, uint32_t feedId);
|
||||
virtual ~p3FeedReaderThread();
|
||||
|
||||
std::string getFeedId() { return mFeedId; }
|
||||
uint32_t getFeedId() { return mFeedId; }
|
||||
|
||||
static RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString);
|
||||
static RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, HTMLWrapper &html, std::string &errorString);
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
static RsFeedReaderErrorState processTransformation(const RsFeedReaderFeed &feed, RsFeedReaderMsg *msg, std::string &errorString);
|
||||
private:
|
||||
virtual void data_tick();
|
||||
virtual void threadTick() override; /// @see RsTickingThread
|
||||
|
||||
RsFeedReaderErrorState download(const RsFeedReaderFeed &feed, std::string &content, std::string &icon, std::string &errorString);
|
||||
RsFeedReaderErrorState process(const RsFeedReaderFeed &feed, std::list<RsFeedReaderMsg*> &entries, std::string &errorString);
|
||||
|
@ -65,7 +65,7 @@ private:
|
|||
|
||||
p3FeedReader *mFeedReader;
|
||||
Type mType;
|
||||
std::string mFeedId;
|
||||
uint32_t mFeedId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,8 +33,8 @@ RsFeedReaderFeed::RsFeedReaderFeed()
|
|||
|
||||
void RsFeedReaderFeed::clear()
|
||||
{
|
||||
feedId.clear();
|
||||
parentId.clear();
|
||||
feedId = 0;
|
||||
parentId = 0;
|
||||
name.clear();
|
||||
url.clear();
|
||||
user.clear();
|
||||
|
@ -64,8 +64,8 @@ uint32_t RsFeedReaderSerialiser::sizeFeed(RsFeedReaderFeed *item)
|
|||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 2; /* version */
|
||||
s += GetTlvStringSize(item->feedId);
|
||||
s += GetTlvStringSize(item->parentId);
|
||||
s += sizeof(uint32_t);
|
||||
s += sizeof(uint32_t);
|
||||
s += GetTlvStringSize(item->url);
|
||||
s += GetTlvStringSize(item->name);
|
||||
s += GetTlvStringSize(item->description);
|
||||
|
@ -108,9 +108,9 @@ bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, u
|
|||
offset += 8;
|
||||
|
||||
/* add values */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->feedId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->feedId);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->parentId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->url);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
||||
|
@ -173,8 +173,28 @@ RsFeedReaderFeed *RsFeedReaderSerialiser::deserialiseFeed(void *data, uint32_t *
|
|||
/* get values */
|
||||
uint16_t version = 0;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &version);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->feedId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
|
||||
if (version >= 2) {
|
||||
ok &= getRawUInt32(data, rssize, &offset, &item->feedId);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &item->parentId);
|
||||
} else {
|
||||
std::string feedId;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, feedId);
|
||||
std::string parentId;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, parentId);
|
||||
|
||||
if (ok) {
|
||||
if (sscanf(feedId.c_str(), "%u", &item->feedId) != 1) {
|
||||
ok = false;
|
||||
}
|
||||
if (!parentId.empty()) {
|
||||
if (sscanf(parentId.c_str(), "%u", &item->parentId) != 1) {
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
item->parentId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->url);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
||||
|
@ -240,7 +260,7 @@ RsFeedReaderMsg::RsFeedReaderMsg() : RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_T
|
|||
void RsFeedReaderMsg::clear()
|
||||
{
|
||||
msgId.clear();
|
||||
feedId.clear();
|
||||
feedId = 0;
|
||||
title.clear();
|
||||
link.clear();
|
||||
author.clear();
|
||||
|
@ -260,7 +280,7 @@ uint32_t RsFeedReaderSerialiser::sizeMsg(RsFeedReaderMsg *item)
|
|||
uint32_t s = 8; /* header */
|
||||
s += 2; /* version */
|
||||
s += GetTlvStringSize(item->msgId);
|
||||
s += GetTlvStringSize(item->feedId);
|
||||
s += sizeof(uint32_t);
|
||||
s += GetTlvStringSize(item->title);
|
||||
s += GetTlvStringSize(item->link);
|
||||
s += GetTlvStringSize(item->author);
|
||||
|
@ -291,9 +311,9 @@ bool RsFeedReaderSerialiser::serialiseMsg(RsFeedReaderMsg *item, void *data, uin
|
|||
offset += 8;
|
||||
|
||||
/* add values */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, 2); /* version */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->msgId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->feedId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->title);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->link);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->author);
|
||||
|
@ -345,7 +365,16 @@ RsFeedReaderMsg *RsFeedReaderSerialiser::deserialiseMsg(void *data, uint32_t *pk
|
|||
uint16_t version = 0;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &version);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->msgId);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
|
||||
if (version >= 2) {
|
||||
ok &= getRawUInt32(data, rssize, &offset, &item->feedId);
|
||||
} else {
|
||||
std::string feedId;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, feedId);
|
||||
|
||||
if (sscanf(feedId.c_str(), "%u", &item->feedId) != 1) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->title);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->link);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->author);
|
||||
|
|
|
@ -62,10 +62,9 @@ public:
|
|||
virtual ~RsFeedReaderFeed() {}
|
||||
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string feedId;
|
||||
std::string parentId;
|
||||
uint32_t feedId;
|
||||
uint32_t parentId;
|
||||
std::string name;
|
||||
std::string url;
|
||||
std::string user;
|
||||
|
@ -109,7 +108,7 @@ public:
|
|||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string msgId;
|
||||
std::string feedId;
|
||||
uint32_t feedId;
|
||||
std::string title;
|
||||
std::string link;
|
||||
std::string author;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue