mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
commit
a802e494f8
@ -3429,3 +3429,9 @@ void RsGenExchange::turtleSearchRequest(const std::string& match_string)
|
||||
{
|
||||
mNetService->turtleSearchRequest(match_string) ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::localSearch( const std::string& matchString,
|
||||
std::list<RsGxsGroupSummary>& results )
|
||||
{
|
||||
return mNetService->search(matchString, results);
|
||||
}
|
||||
|
@ -313,6 +313,15 @@ public:
|
||||
void turtleGroupRequest(const RsGxsGroupId& group_id);
|
||||
void turtleSearchRequest(const std::string& match_string);
|
||||
|
||||
/**
|
||||
* @brief Search local groups. Blocking API.
|
||||
* @param matchString string to look for in the search
|
||||
* @param results storage for results
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
bool localSearch( const std::string& matchString,
|
||||
std::list<RsGxsGroupSummary>& results );
|
||||
|
||||
protected:
|
||||
|
||||
bool messagePublicationTest(const RsGxsMsgMetaData&) ;
|
||||
|
@ -769,7 +769,8 @@ HEADERS += serialiser/rsserializable.h \
|
||||
serialiser/rstypeserializer.h \
|
||||
util/rsjson.h
|
||||
|
||||
SOURCES += serialiser/rsserializer.cc \
|
||||
SOURCES += serialiser/rsserializable.cc \
|
||||
serialiser/rsserializer.cc \
|
||||
serialiser/rstypeserializer.cc \
|
||||
util/rsjson.cc
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
#pragma once
|
||||
/*******************************************************************************
|
||||
* libretroshare/src/retroshare: rsgxschannels.h *
|
||||
* *
|
||||
@ -21,6 +20,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@ -62,9 +62,6 @@ struct RsGxsChannelGroup : RsSerializable
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream& out, const RsGxsChannelGroup& group);
|
||||
|
||||
|
||||
struct RsGxsChannelPost : RsSerializable
|
||||
{
|
||||
RsGxsChannelPost() : mCount(0), mSize(0) {}
|
||||
@ -95,8 +92,6 @@ struct RsGxsChannelPost : RsSerializable
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream& out, const RsGxsChannelPost& post);
|
||||
|
||||
|
||||
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
||||
{
|
||||
@ -112,6 +107,14 @@ public:
|
||||
*/
|
||||
virtual bool createChannel(RsGxsChannelGroup& channel) = 0;
|
||||
|
||||
/**
|
||||
* @brief Add a comment on a post or on another comment
|
||||
* @jsonapi{development}
|
||||
* @param[inout] comment
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createComment(RsGxsComment& comment) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create channel post. Blocking API.
|
||||
* @jsonapi{development}
|
||||
@ -120,6 +123,14 @@ public:
|
||||
*/
|
||||
virtual bool createPost(RsGxsChannelPost& post) = 0;
|
||||
|
||||
/**
|
||||
* @brief createVote
|
||||
* @jsonapi{development}
|
||||
* @param[inout] vote
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createVote(RsGxsVote& vote) = 0;
|
||||
|
||||
/**
|
||||
* @brief Edit channel details.
|
||||
* @jsonapi{development}
|
||||
@ -276,6 +287,19 @@ public:
|
||||
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
|
||||
rstime_t maxWait = 300 ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Search local channels
|
||||
* @jsonapi{development}
|
||||
* @param[in] matchString string to look for in the search
|
||||
* @param multiCallback function that will be called for each result
|
||||
* @param[in] maxWait maximum wait time in seconds for search results
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool localSearchRequest(
|
||||
const std::string& matchString,
|
||||
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
|
||||
rstime_t maxWait = 30 ) = 0;
|
||||
|
||||
|
||||
/* Following functions are deprecated as they expose internal functioning
|
||||
* semantic, instead of a safe to use API */
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2012-2012 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2012 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -19,88 +20,157 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#ifndef RETROSHARE_GXS_FORUM_GUI_INTERFACE_H
|
||||
#define RETROSHARE_GXS_FORUM_GUI_INTERFACE_H
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "retroshare/rstokenservice.h"
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
#include "serialiser/rstlvidset.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
|
||||
// Forum Service message flags, to be used in RsMsgMetaData::mMsgFlags
|
||||
// Gxs imposes to use the first two bytes (lower bytes) of mMsgFlags for private forum flags, the upper bytes being used for internal GXS stuff.
|
||||
|
||||
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MASK = 0x0000000f ;
|
||||
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001 ;
|
||||
|
||||
#define IS_FORUM_MSG_MODERATION(flags) (flags & RS_GXS_FORUM_MSG_FLAGS_MODERATED)
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsGxsForums;
|
||||
extern RsGxsForums *rsGxsForums;
|
||||
|
||||
class RsGxsForumGroup
|
||||
/**
|
||||
* Pointer to global instance of RsGxsChannels service implementation
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
extern RsGxsForums* rsGxsForums;
|
||||
|
||||
|
||||
/** Forum Service message flags, to be used in RsMsgMetaData::mMsgFlags
|
||||
* Gxs imposes to use the first two bytes (lower bytes) of mMsgFlags for
|
||||
* private forum flags, the upper bytes being used for internal GXS stuff.
|
||||
*/
|
||||
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MASK = 0x0000000f;
|
||||
static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001;
|
||||
|
||||
#define IS_FORUM_MSG_MODERATION(flags) (flags & RS_GXS_FORUM_MSG_FLAGS_MODERATED)
|
||||
|
||||
|
||||
struct RsGxsForumGroup : RsSerializable
|
||||
{
|
||||
public:
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
|
||||
// What's below is optional, and handled by the serialiser
|
||||
/* What's below is optional, and handled by the serialiser
|
||||
* TODO: run away from TLV old serializables as those types are opaque to
|
||||
* JSON API! */
|
||||
RsTlvGxsIdSet mAdminList;
|
||||
RsTlvGxsMsgIdSet mPinnedPosts;
|
||||
|
||||
RsTlvGxsIdSet mAdminList;
|
||||
RsTlvGxsMsgIdSet mPinnedPosts;
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(mDescription);
|
||||
RS_SERIAL_PROCESS(mAdminList);
|
||||
RS_SERIAL_PROCESS(mPinnedPosts);
|
||||
}
|
||||
};
|
||||
|
||||
class RsGxsForumMsg
|
||||
struct RsGxsForumMsg : RsSerializable
|
||||
{
|
||||
public:
|
||||
RsMsgMetaData mMeta;
|
||||
std::string mMsg;
|
||||
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(mMsg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//typedef std::map<RsGxsGroupId, std::vector<RsGxsForumMsg> > GxsForumMsgResult;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsGxsForumGroup &group);
|
||||
std::ostream &operator<<(std::ostream &out, const RsGxsForumMsg &msg);
|
||||
|
||||
class RsGxsForums: public RsGxsIfaceHelper
|
||||
{
|
||||
public:
|
||||
|
||||
explicit RsGxsForums(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
|
||||
virtual ~RsGxsForums() {}
|
||||
|
||||
/**
|
||||
* @brief Create forum. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[inout] forum Forum data (name, description...)
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createForum(RsGxsForumGroup& forum) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create forum message. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[inout] message
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createMessage(RsGxsForumMsg& message) = 0;
|
||||
|
||||
/**
|
||||
* @brief Edit forum details.
|
||||
* @jsonapi{development}
|
||||
* @param[in] forum Forum data (name, description...) with modifications
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool editForum(RsGxsForumGroup& forum) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get forums summaries list. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[out] forums list where to store the forums summaries
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get forums information (description, thumbnail...).
|
||||
* Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumIds ids of the forums of which to get the informations
|
||||
* @param[out] forumsInfo storage for the forums informations
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getForumsInfo(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumGroup>& forumsInfo ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get content of specified forums. Blocking API
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumIds id of the channels of which the content is requested
|
||||
* @param[out] messages storage for the forum messages
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getForumsContent(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumMsg>& messages ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Toggle message read status. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[in] messageId post identifier
|
||||
* @param[in] read true to mark as read, false to mark as unread
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read) = 0;
|
||||
|
||||
/* Specific Service Data */
|
||||
RS_DEPRECATED_FOR("getForumsSummaries, getForumsInfo")
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
|
||||
RS_DEPRECATED_FOR(getForumsContent)
|
||||
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
|
||||
//Not currently used
|
||||
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
RS_DEPRECATED_FOR(markRead)
|
||||
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
|
||||
|
||||
//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);
|
||||
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
|
||||
|
||||
RS_DEPRECATED_FOR(createForum)
|
||||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
|
||||
RS_DEPRECATED_FOR(createMessage)
|
||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
|
||||
/*!
|
||||
* To update forum group with new information
|
||||
* @param token the token used to check completion status of update
|
||||
* @param group group to be updated, groupId element must be set or will be rejected
|
||||
* @return false groupId not set, true if set and accepted (still check token for completion)
|
||||
*/
|
||||
RS_DEPRECATED_FOR(editForum)
|
||||
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
31
libretroshare/src/serialiser/rsserializable.cc
Normal file
31
libretroshare/src/serialiser/rsserializable.cc
Normal file
@ -0,0 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include "serialiser/rsserializable.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const RsSerializable& serializable)
|
||||
{
|
||||
RsGenericSerializer::SerializeContext ctx;
|
||||
const_cast<RsSerializable&>(serializable) // safe with TO_JSON
|
||||
.serial_process(RsGenericSerializer::TO_JSON, ctx);
|
||||
return out << ctx.mJson;
|
||||
}
|
@ -20,8 +20,11 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "serialiser/rsserializer.h"
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
|
||||
/** @brief Minimal ancestor for all serializable structs in RetroShare.
|
||||
* If you want your struct to be easly serializable you should inherit from this
|
||||
@ -49,3 +52,5 @@ struct RsSerializable
|
||||
#define RS_SERIAL_PROCESS(I) do { \
|
||||
RsTypeSerializer::serial_process(j, ctx, I, #I ); \
|
||||
} while(0)
|
||||
|
||||
std::ostream &operator<<(std::ostream& out, const RsSerializable& serializable);
|
||||
|
@ -28,13 +28,15 @@
|
||||
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rstlvitem.h"
|
||||
|
||||
#include "util/rsdeprecate.h"
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsgxsifacetypes.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem
|
||||
/// @deprecated use plain std::set<> instead
|
||||
template<class ID_CLASS,uint32_t TLV_TYPE> class RS_DEPRECATED_FOR(std::set<>) t_RsTlvIdSet
|
||||
: public RsTlvItem
|
||||
{
|
||||
public:
|
||||
t_RsTlvIdSet() {}
|
||||
@ -122,7 +124,7 @@ typedef t_RsTlvIdSet<RsGxsMessageId,TLV_TYPE_GXSMSGIDSET> RsTlvGxsMsgIdSet
|
||||
typedef t_RsTlvIdSet<RsGxsCircleId, TLV_TYPE_GXSCIRCLEIDSET> RsTlvGxsCircleIdSet ;
|
||||
typedef t_RsTlvIdSet<RsNodeGroupId, TLV_TYPE_NODEGROUPIDSET> RsTlvNodeGroupIdSet ;
|
||||
|
||||
class RsTlvServiceIdSet: public RsTlvItem
|
||||
class RS_DEPRECATED RsTlvServiceIdSet: public RsTlvItem
|
||||
{
|
||||
public:
|
||||
RsTlvServiceIdSet() { return; }
|
||||
|
@ -26,15 +26,18 @@
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include "util/rsdeprecate.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <inttypes.h>
|
||||
|
||||
//! A base class for all tlv items
|
||||
/*! This class is provided to allow the serialisation and deserialization of compund
|
||||
tlv items
|
||||
*/
|
||||
class RsTlvItem
|
||||
/*! A base class for all tlv items
|
||||
* This class is provided to allow the serialisation and deserialization of
|
||||
* compund tlv items
|
||||
* @deprecated TLV serialization system is deprecated!
|
||||
*/
|
||||
class RS_DEPRECATED_FOR(RsSerializable) RsTlvItem
|
||||
{
|
||||
public:
|
||||
RsTlvItem() { return; }
|
||||
@ -51,8 +54,7 @@ std::ostream &printEnd(std::ostream &out, std::string clsName, uint16_t indent)
|
||||
|
||||
std::ostream &printIndent(std::ostream &out, uint16_t indent);
|
||||
|
||||
|
||||
class RsTlvUnit: public RsTlvItem
|
||||
class RS_DEPRECATED_FOR(RsSerializable) RsTlvUnit: public RsTlvItem
|
||||
{
|
||||
public:
|
||||
RsTlvUnit(uint16_t tlv_type);
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "retroshare/rsnotify.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <chrono>
|
||||
|
||||
// For Dummy Msgs.
|
||||
#include "util/rsrandom.h"
|
||||
@ -50,7 +51,7 @@
|
||||
* #define GXSCHANNEL_DEBUG 1
|
||||
****/
|
||||
|
||||
/*extern*/ RsGxsChannels *rsGxsChannels = nullptr;
|
||||
/*extern*/ RsGxsChannels* rsGxsChannels = nullptr;
|
||||
|
||||
|
||||
#define GXSCHANNEL_STOREPERIOD (3600 * 24 * 30)
|
||||
@ -1033,7 +1034,7 @@ bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel)
|
||||
uint32_t token;
|
||||
if(!createGroup(token, channel))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group."
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
@ -1059,6 +1060,60 @@ bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsChannels::createComment(RsGxsComment& comment)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!createComment(token, comment))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating comment."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::getPublishedMsgMeta(token, comment.mMeta))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting generated "
|
||||
<< " comment data." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsChannels::createVote(RsGxsVote& vote)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!createVote(token, vote))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating vote."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::getPublishedMsgMeta(token, vote.mMeta))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting generated "
|
||||
<< " vote data." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsChannels::editChannel(RsGxsChannelGroup& channel)
|
||||
{
|
||||
uint32_t token;
|
||||
@ -1915,6 +1970,31 @@ bool p3GxsChannels::turtleChannelRequest(
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @see RsGxsChannels::localSearchRequest
|
||||
bool p3GxsChannels::localSearchRequest(
|
||||
const std::string& matchString,
|
||||
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
|
||||
rstime_t maxWait )
|
||||
{
|
||||
if(matchString.empty())
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " match string can't be empty!"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto timeout = std::chrono::steady_clock::now() + std::chrono::seconds(maxWait);
|
||||
RsThread::async([=]()
|
||||
{
|
||||
std::list<RsGxsGroupSummary> results;
|
||||
RsGenExchange::localSearch(matchString, results);
|
||||
if(std::chrono::steady_clock::now() < timeout)
|
||||
for(const RsGxsGroupSummary& result : results) multiCallback(result);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void p3GxsChannels::receiveDistantSearchResults(
|
||||
TurtleRequestId id, const RsGxsGroupId& grpId )
|
||||
{
|
||||
|
@ -118,6 +118,11 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
|
||||
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
|
||||
rstime_t maxWait = 300 );
|
||||
|
||||
/// @see RsGxsChannels::localSearchRequest
|
||||
virtual bool localSearchRequest(const std::string& matchString,
|
||||
const std::function<void (const RsGxsGroupSummary& result)>& multiCallback,
|
||||
rstime_t maxWait = 30 ) override;
|
||||
|
||||
/**
|
||||
* Receive results from turtle search @see RsGenExchange @see RsNxsObserver
|
||||
* @see RsGxsNetService::receiveTurtleSearchResults
|
||||
@ -189,12 +194,18 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||
/// Implementation of @see RsGxsChannels::createChannel
|
||||
virtual bool createChannel(RsGxsChannelGroup& channel);
|
||||
|
||||
/// Implementation of @see RsGxsChannels::createComment
|
||||
virtual bool createComment(RsGxsComment& comment);
|
||||
|
||||
/// Implementation of @see RsGxsChannels::editChannel
|
||||
virtual bool editChannel(RsGxsChannelGroup& channel);
|
||||
|
||||
/// Implementation of @see RsGxsChannels::createPost
|
||||
virtual bool createPost(RsGxsChannelPost& post);
|
||||
|
||||
/// Implementation of @see RsGxsChannels::createVote
|
||||
virtual bool createVote(RsGxsVote& vote);
|
||||
|
||||
/// Implementation of @see RsGxsChannels::subscribeToChannel
|
||||
virtual bool subscribeToChannel( const RsGxsGroupId &groupId,
|
||||
bool subscribe );
|
||||
|
@ -379,6 +379,103 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
bool p3GxsForums::createForum(RsGxsForumGroup& forum)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!createGroup(token, forum))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::getPublishedGroupMeta(token, forum.mMeta))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
|
||||
<< " group data." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsForums::editForum(RsGxsForumGroup& forum)
|
||||
{
|
||||
uint32_t token;
|
||||
if(!updateGroup(token, forum))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::getPublishedGroupMeta(token, forum.mMeta))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
|
||||
<< " group data." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsSummaries(
|
||||
std::list<RsGroupMetaData>& forums )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
if( !requestGroupInfo(token, opts)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
return getGroupSummary(token, forums);
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsInfo(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumGroup>& forumsInfo )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
if( !requestGroupInfo(token, opts, forumIds)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
return getGroupData(token, forumsInfo);
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsContent(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumMsg>& messages )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
if( !requestMsgInfo(token, opts, forumIds)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
return getMsgData(token, messages);
|
||||
}
|
||||
|
||||
bool p3GxsForums::markRead(const RsGxsGrpMsgIdPair& msgId, bool read)
|
||||
{
|
||||
uint32_t token;
|
||||
setMessageReadStatus(token, msgId, read);
|
||||
if(waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
|
||||
{
|
||||
std::cerr << "p3GxsForums::createGroup()" << std::endl;
|
||||
@ -407,6 +504,17 @@ bool p3GxsForums::updateGroup(uint32_t &token, RsGxsForumGroup &group)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsForums::createMessage(RsGxsForumMsg& message)
|
||||
{
|
||||
uint32_t token;
|
||||
if( !createMsg(token, message)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
if(RsGenExchange::getPublishedMsgMeta(token, message.mMeta)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3GxsForums::createMsg(uint32_t &token, RsGxsForumMsg &msg)
|
||||
{
|
||||
std::cerr << "p3GxsForums::createForumMsg() GroupId: " << msg.mMeta.mGroupId;
|
||||
|
@ -38,55 +38,56 @@
|
||||
class p3GxsForums: public RsGenExchange, public RsGxsForums, public p3Config,
|
||||
public RsTickEvent /* only needed for testing - remove after */
|
||||
{
|
||||
public:
|
||||
public:
|
||||
p3GxsForums(
|
||||
RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
|
||||
|
||||
p3GxsForums(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
virtual void service_tick();
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
virtual void service_tick();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
|
||||
// Overloaded from RsTickEvent.
|
||||
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||
protected:
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
/// Overloaded from RsTickEvent.
|
||||
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||
|
||||
virtual RsSerialiser* setupSerialiser(); // @see p3Config::setupSerialiser()
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList); // @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&)
|
||||
virtual bool loadList(std::list<RsItem *>& loadList); // @see p3Config::loadList(std::list<RsItem *>&)
|
||||
|
||||
public:
|
||||
public:
|
||||
/// @see RsGxsForums::createForum
|
||||
virtual bool createForum(RsGxsForumGroup& forum);
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
|
||||
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
|
||||
//Not currently used
|
||||
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
|
||||
/// @see RsGxsForums::createMessage
|
||||
virtual bool createMessage(RsGxsForumMsg& message);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
|
||||
/// @see RsGxsForums::editForum
|
||||
virtual bool editForum(RsGxsForumGroup& forum);
|
||||
|
||||
//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);
|
||||
/// @see RsGxsForums::getForumsSummaries
|
||||
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums);
|
||||
|
||||
//virtual bool groupRestoreKeys(const std::string &groupId);
|
||||
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
|
||||
/// @see RsGxsForums::getForumsInfo
|
||||
virtual bool getForumsInfo(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumGroup>& forumsInfo );
|
||||
|
||||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
|
||||
/// @see RsGxsForums::getForumsContent
|
||||
virtual bool getForumsContent(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumMsg>& messages );
|
||||
|
||||
/*!
|
||||
* To update forum group with new information
|
||||
* @param token the token used to check completion status of update
|
||||
* @param group group to be updated, groupId element must be set or will be rejected
|
||||
* @return false groupId not set, true if set and accepted (still check token for completion)
|
||||
*/
|
||||
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||
/// @see RsGxsForums::markRead
|
||||
virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read);
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
|
||||
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
|
||||
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
|
||||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
|
||||
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
static uint32_t forumsAuthenPolicy();
|
||||
|
||||
|
@ -39,7 +39,7 @@ typedef rapidjson::Document RsJson;
|
||||
* @param[in] jDoc JSON document to print
|
||||
* @return same output stream passed as out parameter
|
||||
*/
|
||||
std::ostream &operator<<(std::ostream &out, const RsJson &jDoc);
|
||||
std::ostream& operator<<(std::ostream &out, const RsJson &jDoc);
|
||||
|
||||
/**
|
||||
* Stream manipulator to print RsJson in compact format
|
||||
|
@ -111,8 +111,9 @@ rs_onlyhiddennode:CONFIG -= no_rs_onlyhiddennode
|
||||
CONFIG *= rs_gxs
|
||||
no_rs_gxs:CONFIG -= rs_gxs
|
||||
|
||||
# To disable GXS distrubuting all available posts independed of the "sync" settings append the following
|
||||
# assignation to qmake command line "CONFIG+=no_rs_gxs_send_all"
|
||||
# To disable GXS distrubuting all available posts independed of the "sync"
|
||||
# settings append the following assignation to qmake command line
|
||||
# "CONFIG+=no_rs_gxs_send_all"
|
||||
CONFIG *= rs_gxs_send_all
|
||||
no_rs_gxs_send_all:CONFIG -= rs_gxs_send_all
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user