fixed merge with upstream/master

This commit is contained in:
csoler 2020-04-19 21:53:02 +02:00
commit 38e89d4055
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
100 changed files with 2795 additions and 1806 deletions

View file

@ -37,6 +37,7 @@ RsItem *RsDiscSerialiser::create_item(
{
case RsGossipDiscoveryItemType::PGP_LIST: return new RsDiscPgpListItem();
case RsGossipDiscoveryItemType::PGP_CERT_BINARY: return new RsDiscPgpKeyItem();
case RsGossipDiscoveryItemType::PGP_CERT: return new RsDiscPgpCertItem(); // deprecated, hanlde to suppress "unkown item" warning
case RsGossipDiscoveryItemType::CONTACT: return new RsDiscContactItem();
case RsGossipDiscoveryItemType::IDENTITY_LIST: return new RsDiscIdentityListItem();
default:

View file

@ -97,6 +97,27 @@ public:
uint32_t bin_len;
};
class RS_DEPRECATED_FOR(RsDiscPgpKeyItem) RsDiscPgpCertItem: public RsDiscItem
{
public:
RsDiscPgpCertItem() : RsDiscItem(RsGossipDiscoveryItemType::PGP_CERT)
{ setPriorityLevel(QOS_PRIORITY_RS_DISC_PGP_CERT); }
void clear() override
{
pgpId.clear();
pgpCert.clear();
}
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx) override
{
RsTypeSerializer::serial_process(j,ctx,pgpId,"pgpId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PGPCERT,pgpCert,"pgpCert") ;
}
RsPgpId pgpId;
std::string pgpCert;
};
class RsDiscContactItem: public RsDiscItem
{
public:

View file

@ -260,6 +260,7 @@ int p3discovery2::handleIncoming()
{
RsDiscPgpListItem* pgplist = nullptr;
RsDiscPgpKeyItem* pgpkey = nullptr;
RsDiscPgpCertItem* pgpcert = nullptr; // deprecated, hanlde for retro compability
RsDiscContactItem* contact = nullptr;
RsDiscIdentityListItem* gxsidlst = nullptr;
@ -282,6 +283,9 @@ int p3discovery2::handleIncoming()
}
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
recvPGPCertificate(item->PeerId(), pgpkey);
else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
// sink
delete pgpcert;
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
{
if (pgplist->mode == RsGossipDiscoveryPgpListMode::FRIENDS)

View file

@ -1193,7 +1193,7 @@ bool RsGenExchange::getGroupList(const uint32_t &token, std::list<RsGxsGroupId>
bool RsGenExchange::getMsgList(const uint32_t &token,
GxsMsgIdResult &msgIds)
{
return mDataAccess->getMsgList(token, msgIds);
return mDataAccess->getMsgIdList(token, msgIds);
}
bool RsGenExchange::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
@ -1692,7 +1692,7 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
{
RS_STACK_MUTEX(mGenMtx);
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false);
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED, false);
gc->mGrpIdList.push_back(grpId);
mNotifications.push_back(gc);
}

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,7 @@
#ifndef RSGXSDATAACCESS_H
#define RSGXSDATAACCESS_H
#include <queue>
#include "retroshare/rstokenservice.h"
#include "rsgxsrequesttypes.h"
#include "rsgds.h"
@ -30,6 +31,8 @@
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter;
bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2);
class RsGxsDataAccess : public RsTokenService
{
public:
@ -56,7 +59,7 @@ public:
* @param groupIds group id to request info for
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds);
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds) override;
/*!
* Use this to request all group related info
@ -65,7 +68,7 @@ public:
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts);
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts) override;
/*!
* Use this to get msg information (id, meta, or data), store token value to poll for request completion
@ -75,7 +78,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds);
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds) override;
/*!
* Use this to get message information (id, meta, or data), store token value to poll for request completion
@ -86,7 +89,7 @@ public:
* all messages for all groups are retrieved
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds);
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds) override;
/*!
* For requesting msgs related to a given msg id within a group
@ -96,7 +99,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds);
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds) override;
/*!
* This request statistics on amount of data held
@ -107,19 +110,20 @@ public:
* total size of messages
* total size of groups
* @param token
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
*/
void requestServiceStatistic(uint32_t& token);
void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) override;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
*/
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId);
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) override;
/* Poll */
GxsRequestStatus requestStatus(const uint32_t token);
GxsRequestStatus requestStatus(uint32_t token);
/* Cancel Request */
bool cancelRequest(const uint32_t &token);
@ -200,7 +204,8 @@ public:
* @param token request token to be redeemed
* @param msgIds
*/
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
bool getMsgIdList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*!
* Retrieve msg list for a given token for message related info
@ -271,7 +276,7 @@ private:
* @param token the value of the token for the request object handle wanted
* @return the request associated to this token
*/
GxsRequest* locked_retrieveRequest(const uint32_t& token);
GxsRequest* locked_retrieveCompetedRequest(const uint32_t& token);
/*!
* Add a gxs request to queue
@ -378,8 +383,18 @@ private:
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getMsgList(MsgIdReq* req);
bool getMsgIdList(MsgIdReq* req);
/*!
* Attempts to retrieve msg Meta list from data store
* Computationally/CPU-Bandwidth expensive
*
* @param msgIds List of message Ids for the Message Metas to retrieve
* @param opts GxsRequest options
* @param result Map of Meta information for messages
*
*/
bool getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgMetaResult& result );
/*!
* Attempts to retrieve group meta data from data store
@ -445,7 +460,7 @@ private:
* @param opts the request options set by user
* @param meta The accompanying meta information for msg, ids
*/
void filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
void filterMsgIdList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
/*!
* This filter msgs based of options supplied (at the moment just status masks)
@ -482,9 +497,10 @@ private:
* @param opts the options used to parameterise the id filter
* @param msgIdsOut the left overs ids after filter is applied to msgIds
*/
bool getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
bool getMsgIdList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
private:
bool locked_clearRequest(const uint32_t &token);
RsGeneralDataService* mDataStore;
@ -492,10 +508,9 @@ private:
uint32_t mNextToken;
std::map<uint32_t, GxsRequestStatus> mPublicToken;
std::map<uint32_t, GxsRequest*> mRequests;
std::set<std::pair<uint32_t,GxsRequest*> > mRequestQueue;
std::map<uint32_t, GxsRequest*> mCompletedRequests;
};
#endif // RSGXSDATAACCESS_H

View file

@ -23,6 +23,128 @@
#include "rsgxsrequesttypes.h"
#include "util/rsstd.h"
std::ostream& operator<<(std::ostream& o,const GxsRequest& g)
{
return g.print(o);
}
std::ostream& GroupMetaReq::print(std::ostream& o) const
{
o << "[Request type=GroupMeta groupIds (size=" << mGroupIds.size() << "): " ;
if(!mGroupIds.empty())
{
o << *mGroupIds.begin() ;
if(mGroupIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& GroupIdReq::print(std::ostream& o) const
{
return o << "[Request type=GroupIdReq" << "]" ;
}
std::ostream& GroupSerializedDataReq::print(std::ostream& o) const
{
return o << "[Request type=GroupSerializedData" << "]" ;
}
std::ostream& GroupDataReq::print(std::ostream& o) const
{
o << "[Request type=GroupDataReq groupIds (size=" << mGroupIds.size() << "): " ;
if(!mGroupIds.empty())
{
o << *mGroupIds.begin() ;
if(mGroupIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& MsgIdReq::print(std::ostream& o) const
{
return o << "[Request type=MsgId" << "]" ;
}
std::ostream& MsgMetaReq::print(std::ostream& o) const
{
o << "[Request type=MsgMetaReq groups (size=" << mMsgIds.size() << "): " ;
if(!mMsgIds.empty())
{
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
if(mMsgIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& MsgDataReq::print(std::ostream& o) const
{
o << "[Request type=MsgDataReq groups (size=" << mMsgIds.size() << "): " ;
if(!mMsgIds.empty())
{
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
if(mMsgIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& MsgRelatedInfoReq::print(std::ostream& o) const
{
o << "[Request type=MsgRelatedInfo msgIds (size=" << mMsgIds.size() << "): " ;
if(!mMsgIds.empty())
{
o << mMsgIds.begin()->first ;
if(mMsgIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& GroupSetFlagReq::print(std::ostream& o) const
{
return o << "[Request type=GroupFlagSet grpId=" << grpId << "]" ;
}
std::ostream& ServiceStatisticRequest::print(std::ostream& o) const
{
return o << "[Request type=ServiceStatistics" << "]" ;
}
std::ostream& GroupStatisticRequest::print(std::ostream& o) const
{
return o << "[Request type=GroupStatistics grpId=" << mGrpId << "]" ;
}
GroupMetaReq::~GroupMetaReq()
{
//rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end()); // now memory ownership is kept by the cache.
@ -57,3 +179,8 @@ MsgRelatedInfoReq::~MsgRelatedInfoReq()
rsstd::delete_all(dataIt->second.begin(), dataIt->second.end());
}
}
std::ostream& MessageSetFlagReq::print(std::ostream& o) const
{
return o << "[Request type=MsgFlagSet" << "]" ;
}

View file

@ -29,25 +29,30 @@
struct GxsRequest
{
GxsRequest() :
token(0), reqTime(0), ansType(0), reqType(0),
token(0), reqTime(0), clientAnswerType(0), reqType(0),
status(RsTokenService::FAILED) {}
virtual ~GxsRequest() {}
uint32_t token;
uint32_t reqTime;
RS_DEPRECATED uint32_t ansType; /// G10h4ck: This is of no use
uint32_t clientAnswerType; /// This is made available to the clients in order to keep track of why specific requests where sent..
uint32_t reqType;
RsTokReqOptions Options;
RsTokenService::GxsRequestStatus status;
virtual std::ostream& print(std::ostream& o) const = 0;
};
std::ostream& operator<<(std::ostream& o,const GxsRequest& g);
class GroupMetaReq : public GxsRequest
{
public:
virtual ~GroupMetaReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
std::list<RsGxsGroupId> mGroupIds;
std::list<const RsGxsGrpMetaData*> mGroupMetaData;
@ -56,12 +61,16 @@ public:
class GroupIdReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
std::list<RsGxsGroupId> mGroupIds;
std::list<RsGxsGroupId> mGroupIdResult;
};
class GroupSerializedDataReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
std::list<RsGxsGroupId> mGroupIds;
std::list<RsNxsGrp*> mGroupData;
};
@ -71,6 +80,7 @@ class GroupDataReq : public GxsRequest
public:
virtual ~GroupDataReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
std::list<RsGxsGroupId> mGroupIds;
std::list<RsNxsGrp*> mGroupData;
@ -79,6 +89,8 @@ public:
class MsgIdReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
GxsMsgReq mMsgIds;
GxsMsgIdResult mMsgIdResult;
};
@ -88,6 +100,8 @@ class MsgMetaReq : public GxsRequest
public:
virtual ~MsgMetaReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
GxsMsgReq mMsgIds;
GxsMsgMetaResult mMsgMetaData;
@ -98,6 +112,7 @@ class MsgDataReq : public GxsRequest
public:
virtual ~MsgDataReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
GxsMsgReq mMsgIds;
NxsMsgDataResult mMsgData;
@ -106,12 +121,15 @@ public:
class ServiceStatisticRequest: public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
GxsServiceStatistic mServiceStatistic;
};
struct GroupStatisticRequest: public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
RsGxsGroupId mGrpId;
GxsGroupStatistic mGroupStatistic;
};
@ -121,6 +139,7 @@ class MsgRelatedInfoReq : public GxsRequest
public:
virtual ~MsgRelatedInfoReq();
std::ostream& print(std::ostream& o) const override;
public:
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
MsgRelatedIdResult mMsgIdResult;
@ -131,6 +150,8 @@ public:
class GroupSetFlagReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
const static uint32_t FLAG_SUBSCRIBE;
const static uint32_t FLAG_STATUS;
@ -145,6 +166,7 @@ class MessageSetFlagReq : public GxsRequest
public:
const static uint32_t FLAG_STATUS;
virtual std::ostream& print(std::ostream& o) const override ;
uint8_t type;
uint32_t flag;
uint32_t flagMask;

View file

@ -43,7 +43,7 @@ p3GxsTrans::~p3GxsTrans()
}
}
bool p3GxsTrans::getStatistics(GxsTransStatistics& stats)
bool p3GxsTrans::getDataStatistics(GxsTransStatistics& stats)
{
{
RS_STACK_MUTEX(mDataMutex);
@ -1335,4 +1335,53 @@ bool p3GxsTrans::acceptNewMessage(const RsGxsMsgMetaData *msgMeta,uint32_t msg_s
}
bool p3GxsTrans::getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats)
{
uint32_t token1;
RsTokReqOptions opts1;
opts1.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token1, opts1) || waitToken(token1) != RsTokenService::COMPLETE )
return false;
std::list<RsGroupMetaData> group_metas;
getGroupSummary(token1,group_metas);
for(auto& group_meta:group_metas)
{
RsGxsTransGroupStatistics& stat(stats[group_meta.mGroupId]);
uint32_t token2;
if(!RsGxsIfaceHelper::requestGroupStatistic(token2,group_meta.mGroupId) || waitToken(token2) != RsTokenService::COMPLETE)
continue;
RsGenExchange::getGroupStatistic(token2,stat);
stat.popularity = group_meta.mPop ;
stat.subscribed = IS_GROUP_SUBSCRIBED(group_meta.mSubscribeFlags) ;
stat.mGrpId = group_meta.mGroupId ;
std::vector<RsMsgMetaData> metas;
uint32_t token3;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(group_meta.mGroupId);
if( !requestMsgInfo(token3, opts, groupIds) || waitToken(token3, std::chrono::seconds(5)) != RsTokenService::COMPLETE )
continue;
GxsMsgMetaMap metaMap;
if(!RsGenExchange::getMsgMeta(token3, metaMap) || metaMap.size() != 1)
continue;
for(auto& meta: metaMap.begin()->second)
stat.addMessageMeta(group_meta.mGroupId,meta) ;
}
return true;
}

View file

@ -113,13 +113,21 @@ public:
/*!
* \brief getStatistics
* Gathers all sorts of statistics about the internals of p3GxsTrans, in order to display info about the running status,
* message transport, etc.
* Gathers all sorts of statistics about the data transported by p3GxsTrans, in order to display info about the running status,
* message transport, etc. This is a blocking call. Use it in a thread.
* \param stats This structure contains all statistics information.
* \return true is the call succeeds.
*/
virtual bool getStatistics(GxsTransStatistics& stats);
virtual bool getDataStatistics(GxsTransStatistics& stats) override;
/*!
* \brief getGroupStatistics
* Gathers statistics about GXS groups and messages used by GxsTrans to transport data. This is a blocking call. Use it in a thread.
* \param stats
* \return true if the data collection succeeds.
*/
virtual bool getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats) override;
/**
* Send an email to recipient, in the process author of the email is

View file

@ -362,6 +362,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name,bool first_time)
dlclose(handle);
return false ;
}
#ifdef TO_REMOVE
if(pinfo.svn_revision == 0)
{
std::cerr << " -> No svn revision number." << std::endl;
@ -370,6 +371,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name,bool first_time)
dlclose(handle);
return false ;
}
#endif
// Now look for the plugin class symbol.
//

View file

@ -111,6 +111,7 @@ enum class RsChannelEventCode: uint8_t
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
};
struct RsGxsChannelEvent: RsEvent
@ -409,6 +410,14 @@ public:
virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
bool subscribe ) = 0;
/**
* \brief Retrieve statistics about the channel service
* @jsonapi{development}
* \param[out] stat Statistics structure
* \return
*/
virtual bool getChannelServiceStatistics(GxsServiceStatistic& stat) =0;
/**
* \brief Retrieve statistics about the given channel
* @jsonapi{development}
@ -418,6 +427,7 @@ public:
*/
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
/**
* @brief Request remote channels search
* @jsonapi{development}

View file

@ -111,6 +111,7 @@ enum class RsForumEventCode: uint8_t
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
};
struct RsGxsForumEvent: RsEvent
@ -219,6 +220,14 @@ public:
*/
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
/**
* @brief returns statistics for the forum service
* @jsonapi{development}
* @param[out] stat statistics struct
* @return false if the call fails
*/
virtual bool getForumServiceStatistics(GxsServiceStatistic& stat) =0;
/**
* @brief returns statistics about a particular forum
* @jsonapi{development}
@ -228,6 +237,7 @@ public:
*/
virtual bool getForumStatistics(const RsGxsGroupId& forumId,GxsGroupStatistic& stat)=0;
/**
* @brief Get forums information (description, thumbnail...).
* Blocking API.

View file

@ -40,7 +40,9 @@
* are necessary, so at this point this workaround seems acceptable.
*/
//#define DEBUG_GXSIFACEHELPER 1
//==================================
// #define DEBUG_GXSIFACEHELPER 1
//==================================
enum class TokenRequestType: uint8_t
{
@ -85,8 +87,7 @@ public:
* @param groupIds the ids return for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getGroupList(const uint32_t &token,
std::list<RsGxsGroupId> &groupIds)
bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds)
{
return mGxs.getGroupList(token, groupIds);
}
@ -119,8 +120,7 @@ public:
* @param groupInfo the ids returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getGroupSummary(const uint32_t &token,
std::list<RsGroupMetaData> &groupInfo)
bool getGroupSummary(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
{
return mGxs.getGroupMeta(token, groupInfo);
}
@ -130,8 +130,7 @@ public:
* @param msgInfo the message metadata returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getMsgSummary(const uint32_t &token,
GxsMsgMetaMap &msgInfo)
bool getMsgSummary(const uint32_t &token, GxsMsgMetaMap &msgInfo)
{
return mGxs.getMsgMeta(token, msgInfo);
}
@ -368,9 +367,12 @@ public:
{ return mTokenService.requestStatus(token); }
/// @see RsTokenService::requestServiceStatistic
void requestServiceStatistic(uint32_t& token)
bool requestServiceStatistic(uint32_t& token)
{
mTokenService.requestServiceStatistic(token);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
mTokenService.requestServiceStatistic(token,opts);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
@ -378,12 +380,16 @@ public:
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
/// @see RsTokenService::requestGroupStatistic
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
{
mTokenService.requestGroupStatistic(token, grpId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
mTokenService.requestGroupStatistic(token, grpId,opts);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
@ -501,7 +507,7 @@ private:
uint32_t count[7] = {0};
std::cerr << "Service " << std::hex << service_id << std::dec
RsDbg() << "Service " << std::hex << service_id << std::dec
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;

View file

@ -45,6 +45,13 @@ struct RsMsgMetaData;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
enum class GxsRequestPriority {
VERY_HIGH = 0x00,
HIGH = 0x01,
NORMAL = 0x02,
LOW = 0x03,
VERY_LOW = 0x04,
};
class RsGxsGrpMetaData;
class RsGxsMsgMetaData;
@ -232,7 +239,7 @@ public:
mNumChildMsgsNew = 0;
mNumChildMsgsUnread = 0;
mSizeStore = 0;
}
}
public:
uint32_t mNumMsgs;

View file

@ -46,7 +46,8 @@ struct RsGxsNotify
TYPE_RECEIVED_NEW = 0x02,
TYPE_PROCESSED = 0x03,
TYPE_RECEIVED_PUBLISHKEY = 0x04,
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
TYPE_STATISTICS_CHANGED = 0x06
};
virtual ~RsGxsNotify() {}

View file

@ -70,10 +70,8 @@ enum class GxsTransSendStatus : uint8_t
typedef uint64_t RsGxsTransId;
class RsGxsTransGroup
class RsGxsTransGroup: public RsGxsGenericGroupData
{
public:
RsGroupMetaData mMeta;
};
class RsGxsTransMsg
@ -103,7 +101,34 @@ struct RsGxsTransOutgoingRecord
RsGxsGroupId group_id ;
};
class RsGxsTransGroupStatistics: public GxsGroupStatistic
{
public:
RsGxsTransGroupStatistics()
{
last_publish_TS = 0;
popularity = 0;
subscribed = false;
}
void addMessageMeta(const RsGxsGroupId& grp,const RsMsgMetaData& meta)
{
messages_metas[meta.mMsgId] = meta ;
last_publish_TS = std::max(last_publish_TS,meta.mPublishTs) ;
mGrpId = grp ;
}
bool subscribed ;
int popularity ;
rstime_t last_publish_TS;
std::map<RsGxsMessageId,RsMsgMetaData> messages_metas ;
};
/// RetroShare GxsTrans asyncronous redundant small mail trasport on top of GXS
///
class RsGxsTrans: public RsGxsIfaceHelper
{
public:
@ -120,10 +145,8 @@ public:
virtual ~RsGxsTrans() {}
virtual bool getStatistics(GxsTransStatistics& stats)=0;
// virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsTransGroup> &groups) = 0;
// virtual bool getPostData(const uint32_t &token, std::vector<RsGxsTransMsg> &posts) = 0;
virtual bool getDataStatistics(GxsTransStatistics& stats)=0;
virtual bool getGroupStatistics(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>& stats) =0;
};
extern RsGxsTrans *rsGxsTrans ;

View file

@ -313,7 +313,8 @@ extern RsAccounts* rsAccounts;
class RsLoginHelper
{
public:
RsLoginHelper() {}
RsLoginHelper() = default;
/**
* @brief Normal way to attempt login
* @jsonapi{development,manualwrapper}

View file

@ -987,8 +987,18 @@ virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
virtual uint32_t getDistantChatPermissionFlags()=0 ;
virtual bool setDistantChatPermissionFlags(uint32_t flags)=0 ;
virtual bool initiateDistantChatConnexion(
/**
* @brief initiateDistantChatConnexion initiate a connexion for a distant chat
* @jsonapi{development}
* @param[in] to_pid RsGxsId to start the connection
* @param[in] from_pid owned RsGxsId who start the connection
* @param[out] pid distant chat id
* @param[out] error_code if the connection can't be stablished
* @param[in] notify notify remote that the connection is stablished
* @return true on success
*/
virtual bool initiateDistantChatConnexion(
const RsGxsId& to_pid, const RsGxsId& from_pid,
DistantChatPeerId& pid, uint32_t& error_code,
bool notify = true ) = 0;
@ -1001,7 +1011,14 @@ virtual bool initiateDistantChatConnexion(
* @return true on success
*/
virtual bool getDistantChatStatus(const DistantChatPeerId& pid, DistantChatPeerInfo& info)=0;
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
/**
* @brief closeDistantChatConnexion
* @jsonapi{development}
* @param[in] pid distant chat id to close the connection
* @return true on success
*/
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
/**
* @brief MessageSend

View file

@ -114,6 +114,7 @@ enum class RsPostedEventCode: uint8_t
UPDATED_POSTED_GROUP = 0x04,
UPDATED_MESSAGE = 0x05,
READ_STATUS_CHANGED = 0x06,
STATISTICS_CHANGED = 0x07,
};
@ -167,6 +168,8 @@ public:
virtual bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) =0;
virtual bool getBoardsServiceStatistics(GxsServiceStatistic& stat) =0;
enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType };
RS_DEPRECATED_FOR(getBoardsInfo)

View file

@ -80,7 +80,7 @@ struct RsTokReqOptions
{
RsTokReqOptions() : mOptions(0), mStatusFilter(0), mStatusMask(0),
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
mSubscribeMask(0), mBefore(0), mAfter(0) {}
mSubscribeMask(0), mBefore(0), mAfter(0),mPriority(GxsRequestPriority::NORMAL) {}
/**
* Can be one or multiple RS_TOKREQOPT_*
@ -107,6 +107,8 @@ struct RsTokReqOptions
// Time range... again applied after Options.
rstime_t mBefore;
rstime_t mAfter;
GxsRequestPriority mPriority;
};
/*!
@ -181,6 +183,25 @@ public:
*/
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
/*!
* This request statistics on amount of data held
* number of groups
* number of groups subscribed
* number of messages
* size of db store
* total size of messages
* total size of groups
* @param token
*/
virtual void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) = 0;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
*/
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) = 0;
/* Poll */
@ -194,25 +215,6 @@ public:
*/
virtual GxsRequestStatus requestStatus(const uint32_t token) = 0;
/*!
* This request statistics on amount of data held
* number of groups
* number of groups subscribed
* number of messages
* size of db store
* total size of messages
* total size of groups
* @param token
*/
virtual void requestServiceStatistic(uint32_t& token) = 0;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
*/
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0;
/*!
* @brief Cancel Request
* If this function returns false, it may be that the request has completed

View file

@ -28,6 +28,7 @@
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsgxscommon.h"
/* The Main Interface Class - for information about your Peers */
@ -38,6 +39,7 @@ struct RsWireGroup: RsGxsGenericGroupData
{
public:
std::string mDescription;
RsGxsImage mIcon;
};
@ -93,9 +95,10 @@ class RsWirePlace
#define WIRE_PULSE_TYPE_REPLY_MSG (0x0002)
#define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004)
#define WIRE_PULSE_TYPE_SENTIMENT_POSITIVE (0x0010)
#define WIRE_PULSE_TYPE_SENTIMENT_NEUTRAL (0x0020)
#define WIRE_PULSE_TYPE_SENTIMENT_NEGATIVE (0x0040)
#define WIRE_PULSE_SENTIMENT_NO_SENTIMENT (0x0000)
#define WIRE_PULSE_SENTIMENT_POSITIVE (0x0001)
#define WIRE_PULSE_SENTIMENT_NEUTRAL (0x0002)
#define WIRE_PULSE_SENTIMENT_NEGATIVE (0x0003)
class RsWirePulse
{
@ -107,6 +110,7 @@ class RsWirePulse
std::string mPulseText;
uint32_t mPulseType;
uint32_t mReplySentiment; // only relevant if a reply.
// These Ref to the related (parent or reply) if reply (MODE_REPLY_MSG set)
// Mode REPLY_MSG only REPLY_REFERENCE

View file

@ -44,17 +44,20 @@ RsItem *RsGxsWireSerialiser::create_item(uint16_t service,uint8_t item_subtype)
void RsGxsWireGroupItem::clear()
{
group.mDescription.clear();
group.mIcon.clear();
}
void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ;
group.mIcon.serial_process(j, ctx);
}
void RsGxsWirePulseItem::clear()
{
pulse.mPulseText.clear();
pulse.mPulseType = 0;
pulse.mReplySentiment = 0;
pulse.mRefGroupId.clear();
pulse.mRefGroupName.clear();
pulse.mRefOrigMsgId.clear();
@ -66,6 +69,7 @@ void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mReplySentiment,"pulse.mReplySentiment") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;

View file

@ -302,7 +302,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
switch (grpChange->getType())
{
default:
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
@ -318,6 +317,20 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = *git;
ev->mChannelEventCode = RsChannelEventCode::STATISTICS_CHANGED;
rsEvents->postEvent(ev);
}
}
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
@ -356,9 +369,14 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
rsEvents->postEvent(ev);
}
}
break;
default:
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break;
}
}
}
RsGxsDistantSearchResultChange *dsrChange = dynamic_cast<RsGxsDistantSearchResultChange*>(*it);
@ -1062,6 +1080,15 @@ bool p3GxsChannels::getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupS
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsChannels::getChannelServiceStatistics(GxsServiceStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestServiceStatistic(token) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getServiceStatistic(token,stat);
}
bool p3GxsChannels::getContentSummaries(
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
{

View file

@ -204,6 +204,9 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
/// Implementation of @see RsGxsChannels::getChannelStatistics
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
/// Iplementation of @see RsGxsChannels::getChannelServiceStatistics
bool getChannelServiceStatistics(GxsServiceStatistic& stat) override;
/// Implementation of @see RsGxsChannels::createChannelV2
bool createChannelV2(
const std::string& name, const std::string& description,

View file

@ -246,7 +246,6 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
switch (grpChange->getType())
{
default:
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
@ -260,7 +259,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
break;
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
@ -288,8 +287,26 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
<< " Not notifying already known forum "
<< *git << std::endl;
}
break;
}
break;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumGroupId = *git;
ev->mForumEventCode = RsForumEventCode::STATISTICS_CHANGED;
rsEvents->postEvent(ev);
}
}
break;
default:
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break;
#ifdef NOT_USED_YET
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
@ -819,6 +836,15 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
return true;
}
bool p3GxsForums::getForumServiceStatistics(GxsServiceStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestServiceStatistic(token) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getServiceStatistic(token,stat);
}
bool p3GxsForums::getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat)
{
uint32_t token;

View file

@ -97,6 +97,9 @@ public:
/// Implementation of @see RsGxsForums::getForumStatistics
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
/// Implementation of @see RsGxsForums::getForumServiceStatistics
bool getForumServiceStatistics(GxsServiceStatistic& stat) override;
/// @see RsGxsForums::getForumMsgMetaData
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;

View file

@ -133,8 +133,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
#endif
switch(grpChange->getType())
{
default:
{
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
@ -148,15 +147,30 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
break;
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
/* group received */
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (auto git = grpList.begin(); git != grpList.end(); ++git)
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = *git;
ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED;
rsEvents->postEvent(ev);
}
}
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
/* group received */
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
for (auto git = grpList.begin(); git != grpList.end(); ++git)
{
if(mKnownPosted.find(*git) == mKnownPosted.end())
{
@ -178,9 +192,13 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
<< " Not notifying already known forum "
<< *git << std::endl;
}
}
}
break;
}
default:
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break;
}
}
delete *it;

View file

@ -364,6 +364,16 @@ bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
return getGroupSummary(token, boards);
}
bool p3Posted::getBoardsServiceStatistics(GxsServiceStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestServiceStatistic(token) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getServiceStatistic(token,stat);
}
bool p3Posted::getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat)
{
uint32_t token;

View file

@ -74,6 +74,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
bool getBoardsServiceStatistics(GxsServiceStatistic& stat) override;
bool editBoard(RsPostedGroup& board) override;
bool createBoard(RsPostedGroup& board) override;

View file

@ -75,7 +75,8 @@ private:
#else // def __ANDROID__
#include <iostream>
#include <ctime>
#include <chrono>
#include <iomanip>
enum class RsLoggerCategories
{
@ -96,8 +97,15 @@ struct t_RsLogger
template<typename T>
inline stream_type& operator<<(const T& val)
{
return std::cerr << static_cast<char>(CATEGORY) << " " << time(nullptr)
<< " " << val;
using namespace std::chrono;
const auto now = system_clock::now();
const auto sec = time_point_cast<seconds>(now);
const auto msec = duration_cast<milliseconds>(now - sec);
const auto tFill = std::cerr.fill();
return std::cerr << static_cast<char>(CATEGORY) << " "
<< sec.time_since_epoch().count() << "."
<< std::setfill('0') << std::setw(3) << msec.count()
<< std::setfill(tFill) << " " << val;
}
};
#endif // def __ANDROID__