2013-03-04 15:26:48 -05:00
|
|
|
#ifndef RETROSHARE_GXS_CHANNEL_GUI_INTERFACE_H
|
|
|
|
#define RETROSHARE_GXS_CHANNEL_GUI_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/retroshare: rsgxschannel.h
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
2018-06-23 11:13:38 -04:00
|
|
|
* Copyright (C) 2012 by Robert Fernie.
|
|
|
|
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
2013-03-04 15:26:48 -05:00
|
|
|
*
|
|
|
|
* 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.1 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
|
2013-03-06 18:33:23 -05:00
|
|
|
#include "retroshare/rstokenservice.h"
|
2013-03-04 15:26:48 -05:00
|
|
|
#include "retroshare/rsgxsifacehelper.h"
|
|
|
|
#include "retroshare/rsgxscommon.h"
|
2018-06-23 11:13:38 -04:00
|
|
|
#include "serialiser/rsserializable.h"
|
2013-03-04 15:26:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
class RsGxsChannels;
|
|
|
|
|
2018-06-23 11:13:38 -04:00
|
|
|
/**
|
|
|
|
* Pointer to global instance of RsGxsChannels service implementation
|
|
|
|
* @jsonapi{development}
|
|
|
|
*/
|
|
|
|
extern RsGxsChannels* rsGxsChannels;
|
2013-03-04 15:26:48 -05:00
|
|
|
|
|
|
|
// These should be in rsgxscommon.h
|
2018-06-23 11:13:38 -04:00
|
|
|
struct RsGxsChannelGroup : RsSerializable
|
2013-03-04 15:26:48 -05:00
|
|
|
{
|
|
|
|
RsGroupMetaData mMeta;
|
|
|
|
std::string mDescription;
|
2013-03-11 16:40:28 -04:00
|
|
|
RsGxsImage mImage;
|
2013-03-04 15:26:48 -05:00
|
|
|
|
|
|
|
bool mAutoDownload;
|
2018-06-23 11:13:38 -04:00
|
|
|
|
|
|
|
/// @see RsSerializable
|
|
|
|
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
|
|
|
RsGenericSerializer::SerializeContext& ctx )
|
|
|
|
{
|
|
|
|
RS_SERIAL_PROCESS(mMeta);
|
|
|
|
RS_SERIAL_PROCESS(mDescription);
|
|
|
|
//RS_SERIAL_PROCESS(mImage);
|
|
|
|
RS_SERIAL_PROCESS(mAutoDownload);
|
|
|
|
}
|
2013-03-04 15:26:48 -05:00
|
|
|
};
|
|
|
|
|
2018-06-23 11:13:38 -04:00
|
|
|
std::ostream &operator<<(std::ostream& out, const RsGxsChannelGroup& group);
|
|
|
|
|
|
|
|
|
|
|
|
struct RsGxsChannelPost : RsSerializable
|
2013-03-04 15:26:48 -05:00
|
|
|
{
|
2015-06-28 07:08:26 -04:00
|
|
|
RsGxsChannelPost() : mCount(0), mSize(0) {}
|
|
|
|
|
2013-03-04 15:26:48 -05:00
|
|
|
RsMsgMetaData mMeta;
|
2017-05-20 11:33:05 -04:00
|
|
|
|
2018-06-23 11:13:38 -04:00
|
|
|
std::set<RsGxsMessageId> mOlderVersions;
|
2013-03-04 15:26:48 -05:00
|
|
|
std::string mMsg; // UTF8 encoded.
|
|
|
|
|
2013-03-11 16:40:28 -04:00
|
|
|
std::list<RsGxsFile> mFiles;
|
2013-03-04 15:26:48 -05:00
|
|
|
uint32_t mCount; // auto calced.
|
|
|
|
uint64_t mSize; // auto calced.
|
|
|
|
|
2013-03-11 16:40:28 -04:00
|
|
|
RsGxsImage mThumbnail;
|
2018-06-23 11:13:38 -04:00
|
|
|
|
|
|
|
/// @see RsSerializable
|
|
|
|
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
|
|
|
RsGenericSerializer::SerializeContext& ctx )
|
|
|
|
{
|
|
|
|
RS_SERIAL_PROCESS(mMeta);
|
|
|
|
RS_SERIAL_PROCESS(mOlderVersions);
|
|
|
|
|
|
|
|
RS_SERIAL_PROCESS(mMsg);
|
|
|
|
RS_SERIAL_PROCESS(mFiles);
|
|
|
|
RS_SERIAL_PROCESS(mCount);
|
|
|
|
RS_SERIAL_PROCESS(mSize);
|
|
|
|
//RS_SERIAL_PROCESS(mThumbnail);
|
|
|
|
}
|
2013-03-11 16:40:28 -04:00
|
|
|
};
|
2013-03-04 15:26:48 -05:00
|
|
|
|
2018-06-23 11:13:38 -04:00
|
|
|
std::ostream &operator<<(std::ostream& out, const RsGxsChannelPost& post);
|
2013-03-04 15:26:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
|
|
|
{
|
2018-06-23 11:13:38 -04:00
|
|
|
public:
|
2013-03-04 15:26:48 -05:00
|
|
|
|
2017-07-26 05:39:54 -04:00
|
|
|
explicit RsGxsChannels(RsGxsIface *gxs)
|
2018-06-23 11:13:38 -04:00
|
|
|
:RsGxsIfaceHelper(gxs) {}
|
2017-07-26 05:39:54 -04:00
|
|
|
virtual ~RsGxsChannels() {}
|
2013-03-04 15:26:48 -05:00
|
|
|
|
|
|
|
/* Specific Service Data */
|
|
|
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
|
2016-06-18 14:03:55 -04:00
|
|
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
|
2013-03-04 15:26:48 -05:00
|
|
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
|
2016-06-18 14:03:55 -04:00
|
|
|
//Not currently used
|
|
|
|
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) = 0;
|
2013-03-04 15:26:48 -05:00
|
|
|
|
|
|
|
/* From RsGxsCommentService */
|
|
|
|
//virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;
|
|
|
|
//virtual bool getRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;
|
|
|
|
//virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0;
|
|
|
|
//virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
|
|
|
|
|
2013-03-16 08:31:31 -04:00
|
|
|
virtual bool setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled) = 0;
|
2015-07-06 20:52:52 -04:00
|
|
|
virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled) = 0;
|
|
|
|
|
|
|
|
virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory)=0;
|
2018-06-23 11:13:38 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get download directory for the given channel
|
|
|
|
* @jsonapi{development}
|
|
|
|
* @param[in] channelId id of the channel
|
|
|
|
* @param[out] directory reference to string where to store the path
|
|
|
|
* @return false on error, true otherwise
|
|
|
|
*/
|
|
|
|
virtual bool getChannelDownloadDirectory( const RsGxsGroupId& channelId,
|
|
|
|
std::string& directory ) = 0;
|
2015-07-06 20:52:52 -04:00
|
|
|
|
2013-03-16 08:31:31 -04:00
|
|
|
//virtual void setChannelAutoDownload(uint32_t& token, const RsGxsGroupId& groupId, bool autoDownload) = 0;
|
2013-03-11 16:40:28 -04:00
|
|
|
|
2013-03-04 15:26:48 -05:00
|
|
|
//virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
|
|
|
|
//virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
|
|
|
|
|
|
|
|
//virtual bool groupRestoreKeys(const std::string &groupId);
|
2015-04-17 17:36:22 -04:00
|
|
|
virtual bool groupShareKeys(const RsGxsGroupId &groupId, std::set<RsPeerId>& peers)=0;
|
2013-03-04 15:26:48 -05:00
|
|
|
|
2018-06-23 11:13:38 -04:00
|
|
|
/**
|
|
|
|
* @brief Request subscription to a group.
|
|
|
|
* The action is performed asyncronously, so it could fail in a subsequent
|
|
|
|
* phase even after returning true.
|
|
|
|
* @jsonapi{development}
|
|
|
|
* @param[out] token Storage for RsTokenService token to track request
|
|
|
|
* status.
|
|
|
|
* @param[in] groupId Channel id
|
|
|
|
* @param[in] subscribe
|
|
|
|
* @return false on error, true otherwise
|
|
|
|
*/
|
|
|
|
virtual bool subscribeToGroup( uint32_t& token, const RsGxsGroupId &groupId,
|
|
|
|
bool subscribe ) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Request channel creation.
|
|
|
|
* The action is performed asyncronously, so it could fail in a subsequent
|
|
|
|
* phase even after returning true.
|
|
|
|
* @jsonapi{development}
|
|
|
|
* @param[out] token Storage for RsTokenService token to track request
|
|
|
|
* status.
|
|
|
|
* @param[in] group Channel data (name, description...)
|
|
|
|
* @return false on error, true otherwise
|
|
|
|
*/
|
|
|
|
virtual bool createGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Request post creation.
|
|
|
|
* The action is performed asyncronously, so it could fail in a subsequent
|
|
|
|
* phase even after returning true.
|
|
|
|
* @jsonapi{development}
|
|
|
|
* @param[out] token Storage for RsTokenService token to track request
|
|
|
|
* status.
|
|
|
|
* @param[in] post
|
|
|
|
* @return false on error, true otherwise
|
|
|
|
*/
|
|
|
|
virtual bool createPost(uint32_t& token, RsGxsChannelPost& post) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Request channel change.
|
|
|
|
* The action is performed asyncronously, so it could fail in a subsequent
|
|
|
|
* phase even after returning true.
|
|
|
|
* @jsonapi{development}
|
|
|
|
* @param[out] token Storage for RsTokenService token to track request
|
|
|
|
* status.
|
|
|
|
* @param[in] group Channel data (name, description...) with modifications
|
|
|
|
* @return false on error, true otherwise
|
|
|
|
*/
|
|
|
|
virtual bool updateGroup(uint32_t& token, RsGxsChannelGroup& group) = 0;
|
2014-02-09 05:33:16 -05:00
|
|
|
|
2013-03-12 20:24:57 -04:00
|
|
|
// File Interface
|
|
|
|
virtual bool ExtraFileHash(const std::string &path, std::string filename) = 0;
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool ExtraFileRemove(const RsFileHash &hash) = 0;
|
2013-03-04 15:26:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|