2018-11-04 09:48:33 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* plugins/FeedReader/services/p3FeedReader.h *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2012 by Thunder <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2012-08-10 14:06:29 -04:00
|
|
|
#ifndef P3_FEEDREADER
|
2012-08-02 09:17:53 -04:00
|
|
|
#define P3_FEEDREADER
|
|
|
|
|
|
|
|
#include "retroshare/rsplugin.h"
|
|
|
|
#include "plugins/rspqiservice.h"
|
|
|
|
#include "interface/rsFeedReader.h"
|
|
|
|
|
2014-11-24 17:40:29 -05:00
|
|
|
#include "retroshare/rsgxsifacetypes.h"
|
|
|
|
|
2012-08-02 09:17:53 -04:00
|
|
|
class RsFeedReaderFeed;
|
2012-09-04 19:53:04 -04:00
|
|
|
class RsFeedReaderMsg;
|
|
|
|
class p3FeedReaderThread;
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2014-11-24 17:40:29 -05:00
|
|
|
class RsGxsForums;
|
2019-02-14 17:15:54 -05:00
|
|
|
struct RsGxsForumGroup;
|
2023-04-10 18:36:41 -04:00
|
|
|
class RsPosted;
|
|
|
|
struct RsPostedGroup;
|
|
|
|
class RsGxsIfaceHelper;
|
2014-02-04 17:06:33 -05:00
|
|
|
|
2012-08-02 09:17:53 -04:00
|
|
|
class p3FeedReader : public RsPQIService, public RsFeedReader
|
|
|
|
{
|
|
|
|
public:
|
2023-04-10 18:36:41 -04:00
|
|
|
p3FeedReader(RsPluginHandler *pgHandler, RsGxsForums *forums, RsPosted *posted);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
/****************** FeedReader Interface *************/
|
|
|
|
virtual void stop();
|
|
|
|
virtual void setNotify(RsFeedReaderNotify *notify);
|
|
|
|
|
|
|
|
virtual uint32_t getStandardStorageTime();
|
|
|
|
virtual void setStandardStorageTime(uint32_t storageTime);
|
|
|
|
virtual uint32_t getStandardUpdateInterval();
|
|
|
|
virtual void setStandardUpdateInterval(uint32_t updateInterval);
|
|
|
|
virtual bool getStandardProxy(std::string &proxyAddress, uint16_t &proxyPort);
|
|
|
|
virtual void setStandardProxy(bool useProxy, const std::string &proxyAddress, uint16_t proxyPort);
|
2013-05-01 17:16:46 -04:00
|
|
|
virtual bool getSaveInBackground();
|
|
|
|
virtual void setSaveInBackground(bool saveInBackground);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
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);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
virtual RsFeedReaderErrorState processXPath(const std::list<std::string> &xpathsToUse, const std::list<std::string> &xpathsToRemove, std::string &description, std::string &errorString);
|
2013-01-21 19:11:43 -05:00
|
|
|
virtual RsFeedReaderErrorState processXslt(const std::string &xslt, std::string &description, std::string &errorString);
|
2012-09-04 19:53:04 -04:00
|
|
|
|
2012-08-02 09:17:53 -04:00
|
|
|
/****************** p3Service STUFF ******************/
|
|
|
|
virtual int tick();
|
2014-04-23 16:48:02 -04:00
|
|
|
virtual RsServiceInfo getServiceInfo() ;
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
/****************** internal STUFF *******************/
|
2020-11-08 07:22:59 -05:00
|
|
|
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);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
bool getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedId);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2020-11-08 07:22:59 -05:00
|
|
|
void setFeedInfo(uint32_t feedId, const std::string &name, const std::string &description);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2014-11-24 17:40:29 -05:00
|
|
|
bool getForumGroup(const RsGxsGroupId &groupId, RsGxsForumGroup &forumGroup);
|
|
|
|
bool updateForumGroup(const RsGxsForumGroup &forumGroup, const std::string &groupName, const std::string &groupDescription);
|
2023-04-10 18:36:41 -04:00
|
|
|
bool getPostedGroup(const RsGxsGroupId &groupId, RsPostedGroup &postedGroup);
|
|
|
|
bool updatePostedGroup(const RsPostedGroup &postedGroup, const std::string &groupName, const std::string &groupDescription);
|
|
|
|
bool waitForToken(RsGxsIfaceHelper *interface, uint32_t token);
|
2014-11-24 17:40:29 -05:00
|
|
|
|
2012-08-02 09:17:53 -04:00
|
|
|
protected:
|
|
|
|
/****************** p3Config STUFF *******************/
|
|
|
|
virtual RsSerialiser *setupSerialiser();
|
|
|
|
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
|
|
|
virtual bool loadList(std::list<RsItem *>& load);
|
|
|
|
virtual void saveDone();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void cleanFeeds();
|
|
|
|
void deleteAllMsgs_locked(RsFeedReaderFeed *fi);
|
2012-08-13 17:35:11 -04:00
|
|
|
void stopPreviewThreads_locked();
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2014-11-24 17:40:29 -05:00
|
|
|
private:
|
2012-08-02 09:17:53 -04:00
|
|
|
time_t mLastClean;
|
2014-11-24 17:40:29 -05:00
|
|
|
RsGxsForums *mForums;
|
2023-04-10 18:36:41 -04:00
|
|
|
RsPosted *mPosted;
|
2012-08-02 09:17:53 -04:00
|
|
|
RsFeedReaderNotify *mNotify;
|
2014-11-24 17:40:29 -05:00
|
|
|
volatile bool mStopped;
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
RsMutex mFeedReaderMtx;
|
2013-05-01 17:16:46 -04:00
|
|
|
std::list<RsItem*> cleanSaveData;
|
|
|
|
bool mSaveInBackground;
|
2012-08-13 17:35:11 -04:00
|
|
|
std::list<p3FeedReaderThread*> mThreads;
|
|
|
|
uint32_t mNextFeedId;
|
|
|
|
uint32_t mNextMsgId;
|
|
|
|
int32_t mNextPreviewFeedId;
|
|
|
|
int32_t mNextPreviewMsgId;
|
2012-08-02 09:17:53 -04:00
|
|
|
uint32_t mStandardUpdateInterval;
|
|
|
|
uint32_t mStandardStorageTime;
|
|
|
|
bool mStandardUseProxy;
|
|
|
|
std::string mStandardProxyAddress;
|
|
|
|
uint16_t mStandardProxyPort;
|
2020-11-08 07:22:59 -05:00
|
|
|
std::map<uint32_t, RsFeedReaderFeed*> mFeeds;
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
RsMutex mDownloadMutex;
|
2020-11-08 07:22:59 -05:00
|
|
|
std::list<uint32_t> mDownloadFeeds;
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
RsMutex mProcessMutex;
|
2020-11-08 07:22:59 -05:00
|
|
|
std::list<uint32_t> mProcessFeeds;
|
2012-08-13 17:35:11 -04:00
|
|
|
|
|
|
|
RsMutex mPreviewMutex;
|
|
|
|
p3FeedReaderThread *mPreviewDownloadThread;
|
|
|
|
p3FeedReaderThread *mPreviewProcessThread;
|
2012-08-02 09:17:53 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|