2008-06-24 00:22:42 -04:00
|
|
|
#ifndef RS_P3_CHANNELS_INTERFACE_H
|
|
|
|
#define RS_P3_CHANNELS_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/services: p3channels.h
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2008 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include "retroshare/rschannels.h"
|
|
|
|
#include "retroshare/rsfiles.h"
|
2011-09-10 11:20:15 -04:00
|
|
|
#include "distrib/p3distrib.h"
|
2008-06-24 00:22:42 -04:00
|
|
|
|
|
|
|
#include "serialiser/rstlvtypes.h"
|
|
|
|
#include "serialiser/rschannelitems.h"
|
|
|
|
|
2011-04-07 18:09:16 -04:00
|
|
|
#define RS_CHAN_STATUS_MASK 0x000f
|
|
|
|
#define RS_CHAN_STATUS_AUTO_DL 0x0002
|
2011-04-05 19:07:54 -04:00
|
|
|
|
|
|
|
typedef std::map<std::string, uint32_t> statMap;
|
|
|
|
typedef std::map<std::string, statMap> chanStatMap;
|
2010-05-14 09:00:07 -04:00
|
|
|
|
2010-05-08 12:10:34 -04:00
|
|
|
//! Channels is a distributed 'feed' service
|
|
|
|
/*!
|
2010-05-14 09:00:07 -04:00
|
|
|
* Implementations of rschannels interface
|
2010-07-10 12:02:04 -04:00
|
|
|
* @see RsChannels for definition of implemented interface
|
2010-05-08 12:10:34 -04:00
|
|
|
*/
|
2008-06-24 00:22:42 -04:00
|
|
|
class p3Channels: public p3GroupDistrib, public RsChannels
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-11-09 17:17:20 -05:00
|
|
|
p3Channels(uint16_t type, CacheStrapper *cs, CacheTransfer *cft, RsFiles *files,
|
2010-01-13 15:56:55 -05:00
|
|
|
std::string srcdir, std::string storedir, std::string channelsdir);
|
2008-06-24 00:22:42 -04:00
|
|
|
virtual ~p3Channels();
|
|
|
|
|
2010-05-08 12:10:34 -04:00
|
|
|
/*!
|
2010-05-14 09:00:07 -04:00
|
|
|
* cleans up dowloaded files older than one month,
|
2010-05-08 12:10:34 -04:00
|
|
|
* should be called during shutdown of rs
|
|
|
|
*/
|
|
|
|
void cleanUpOldFiles();
|
|
|
|
|
2008-06-24 00:22:42 -04:00
|
|
|
/****************************************/
|
|
|
|
/********* rsChannels Interface ***********/
|
|
|
|
|
|
|
|
virtual bool channelsChanged(std::list<std::string> &chanIds);
|
|
|
|
|
2010-05-14 09:00:07 -04:00
|
|
|
virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags,
|
|
|
|
unsigned char* pngImageData, uint32_t size);
|
2008-06-24 00:22:42 -04:00
|
|
|
|
2012-04-24 08:49:54 -04:00
|
|
|
virtual bool getChannelInfo(const std::string &cId, ChannelInfo &ci);
|
2008-06-24 00:22:42 -04:00
|
|
|
virtual bool getChannelList(std::list<ChannelInfo> &chanList);
|
2012-04-24 08:49:54 -04:00
|
|
|
virtual bool getChannelMsgList(const std::string &cId, std::list<ChannelMsgSummary> &msgs);
|
|
|
|
virtual bool getChannelMessage(const std::string &cId, const std::string &mId, ChannelMsgInfo &msg);
|
2008-06-24 00:22:42 -04:00
|
|
|
|
|
|
|
virtual bool ChannelMessageSend(ChannelMsgInfo &info);
|
2010-10-06 20:17:42 -04:00
|
|
|
virtual bool setMessageStatus(const std::string& cId, const std::string& mId, const uint32_t status, const uint32_t statusMask);
|
|
|
|
virtual bool getMessageStatus(const std::string& cId, const std::string& mId, uint32_t& status);
|
|
|
|
|
2012-04-24 08:49:54 -04:00
|
|
|
virtual bool getMessageCount(const std::string &cId, unsigned int &newCount, unsigned int &unreadCount);
|
|
|
|
virtual bool channelSubscribe(const std::string &cId, bool subscribe, bool autoDl);
|
|
|
|
virtual bool channelExtraFileHash(const std::string &path, const std::string &chId, FileInfo& fInfo);
|
|
|
|
virtual bool channelExtraFileRemove(const std::string &hash, const std::string &chId);
|
|
|
|
virtual bool channelRestoreKeys(const std::string &chId);
|
|
|
|
virtual bool channelShareKeys(const std::string &chId, std::list<std::string>& peers);
|
|
|
|
virtual bool channelEditInfo(const std::string &chId, ChannelInfo &ci);
|
2010-11-06 20:02:51 -04:00
|
|
|
virtual void getPubKeysAvailableGrpIds(std::list<std::string>& grpIds);
|
2011-04-07 18:09:16 -04:00
|
|
|
virtual bool channelSetAutoDl(const std::string& chId, bool autoDl);
|
2011-04-05 19:07:54 -04:00
|
|
|
virtual bool channelGetAutoDl(const std::string& chId, bool& autoDl);
|
2013-05-23 17:47:50 -04:00
|
|
|
virtual bool channelSetDestinationDirectory(const std::string& chId,const std::string& dest_dir) ;
|
2010-12-18 14:35:07 -05:00
|
|
|
|
2008-06-24 00:22:42 -04:00
|
|
|
/***************************************************************************************/
|
|
|
|
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
|
|
|
/***************************************************************************************/
|
|
|
|
|
2008-11-13 18:03:46 -05:00
|
|
|
protected:
|
2011-02-02 16:03:46 -05:00
|
|
|
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags, bool historical);
|
2011-06-29 18:54:44 -04:00
|
|
|
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
|
|
|
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, const std::string&, bool historical);
|
2008-06-24 00:22:42 -04:00
|
|
|
|
2008-11-13 18:03:46 -05:00
|
|
|
|
2008-06-24 00:22:42 -04:00
|
|
|
/****************************************/
|
|
|
|
/********* Overloaded Functions *********/
|
|
|
|
|
|
|
|
virtual RsSerialType *createSerialiser();
|
|
|
|
|
|
|
|
virtual bool locked_checkDistribMsg(RsDistribMsg *msg);
|
2010-12-18 14:35:07 -05:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
virtual bool childLoadList(std::list<RsItem* >& configSaves);
|
|
|
|
virtual std::list<RsItem *> childSaveList();
|
2008-06-24 00:22:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************/
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2011-04-05 19:07:54 -04:00
|
|
|
void processChanReadStatus(RsChannelReadStatus* drs);
|
2011-04-07 18:09:16 -04:00
|
|
|
void addChannelReadStatusEntry(const std::string& cId);
|
|
|
|
void removeChannelReadStatusEntry(const std::string& cId);
|
2008-11-09 17:17:20 -05:00
|
|
|
RsFiles *mRsFiles;
|
2008-06-24 00:22:42 -04:00
|
|
|
std::string mChannelsDir;
|
2010-07-26 18:09:33 -04:00
|
|
|
std::list<RsItem *> saveList;
|
2008-06-24 00:22:42 -04:00
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
std::list<RsChannelReadStatus *> mReadStatus;
|
2011-04-07 18:09:16 -04:00
|
|
|
|
2011-04-05 19:07:54 -04:00
|
|
|
chanStatMap mMsgReadStatus;
|
|
|
|
statMap mChannelStatus;
|
2013-05-23 17:47:50 -04:00
|
|
|
std::map<std::string,std::string> mDestinationDirectories ;
|
2008-06-24 00:22:42 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|