mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 22:55:04 -04:00
merged upstream
This commit is contained in:
commit
5915c27b9f
59 changed files with 2690 additions and 927 deletions
|
@ -388,7 +388,12 @@ void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContac
|
|||
|
||||
setPeerVersion(fromId, item->version);
|
||||
|
||||
updatePeerAddresses(item);
|
||||
// Hidden nodes do not need IP information. So that information is dropped.
|
||||
// However, that doesn't mean hidden nodes do not know that information. Normally
|
||||
// normal nodes should not send it, but old nodes still do.
|
||||
|
||||
if(!mPeerMgr->isHiddenNode(rsPeers->getOwnId()))
|
||||
updatePeerAddresses(item);
|
||||
|
||||
// if the peer is not validated, we stop the exchange here
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key
|
|||
|
||||
#define GXS_MASK "GXS_MASK_HACK"
|
||||
|
||||
//#define GEN_EXCH_DEBUG 1
|
||||
#define GEN_EXCH_DEBUG 1
|
||||
|
||||
static const uint32_t MSG_CLEANUP_PERIOD = 60*59; // 59 minutes
|
||||
static const uint32_t INTEGRITY_CHECK_PERIOD = 60*31; // 31 minutes
|
||||
|
@ -282,7 +282,7 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta)
|
|||
|
||||
rstime_t storageTimeLimit = meta.mPublishTs + st;
|
||||
|
||||
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || st == 0 || storageTimeLimit >= time(NULL);
|
||||
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER || st == 0 || storageTimeLimit >= time(NULL);
|
||||
}
|
||||
|
||||
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
|
||||
|
|
|
@ -196,7 +196,6 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
|||
|
||||
return ok;
|
||||
}
|
||||
int RsGxsMsgMetaData::refcount = 0;
|
||||
|
||||
RsGxsMsgMetaData::RsGxsMsgMetaData(){
|
||||
clear();
|
||||
|
|
|
@ -99,8 +99,6 @@ public:
|
|||
void clear();
|
||||
void operator =(const RsMsgMetaData& rMeta);
|
||||
|
||||
static int refcount;
|
||||
|
||||
//Sort data in same order than serialiser and deserializer
|
||||
RsGxsGroupId mGroupId;
|
||||
RsGxsMessageId mMsgId;
|
||||
|
|
|
@ -167,7 +167,12 @@ public:
|
|||
class RsGxsNetTunnelTurtleSearchGroupDataItem: public RsGxsNetTunnelItem
|
||||
{
|
||||
public:
|
||||
explicit RsGxsNetTunnelTurtleSearchGroupDataItem(): RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA) {}
|
||||
explicit RsGxsNetTunnelTurtleSearchGroupDataItem()
|
||||
: RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA),
|
||||
encrypted_group_data(NULL),
|
||||
encrypted_group_data_len(0)
|
||||
{}
|
||||
|
||||
virtual ~RsGxsNetTunnelTurtleSearchGroupDataItem() {}
|
||||
|
||||
uint16_t service ;
|
||||
|
|
|
@ -107,7 +107,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
bool remove = store_period > 0 && ((meta->mPublishTs + store_period) < now) && !have_kids;
|
||||
|
||||
// check client does not want the message kept regardless of age
|
||||
remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP);
|
||||
remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER);
|
||||
|
||||
// if not subscribed remove messages (can optimise this really)
|
||||
remove = remove || (grpMeta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED);
|
||||
|
|
|
@ -111,27 +111,6 @@ typedef t_RsGxsGenericDataTemporaryMapVector<RsNxsMsg> RsNxsMsgDa
|
|||
typedef t_RsGxsGenericDataTemporaryList<RsNxsGrp> RsNxsGrpDataTemporaryList ;
|
||||
typedef t_RsGxsGenericDataTemporaryList<RsNxsMsg> RsNxsMsgDataTemporaryList ;
|
||||
|
||||
#ifdef UNUSED
|
||||
template<class T>
|
||||
class RsGxsMetaDataTemporaryMapVector: public std::vector<T*>
|
||||
{
|
||||
public:
|
||||
virtual ~RsGxsMetaDataTemporaryMapVector()
|
||||
{
|
||||
clear() ;
|
||||
}
|
||||
|
||||
virtual void clear()
|
||||
{
|
||||
for(typename RsGxsMetaDataTemporaryMapVector<T>::iterator it = this->begin();it!=this->end();++it)
|
||||
if(it->second != NULL)
|
||||
delete it->second ;
|
||||
std::vector<T*>::clear() ;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
inline RsGxsGrpMsgIdPair getMsgIdPair(RsNxsMsg& msg)
|
||||
{
|
||||
return RsGxsGrpMsgIdPair(std::make_pair(msg.grpId, msg.msgId));
|
||||
|
@ -146,7 +125,7 @@ inline RsGxsGrpMsgIdPair getMsgIdPair(RsGxsMsgItem& msg)
|
|||
* Does message clean up based on individual group expirations first
|
||||
* if avialable. If not then deletion s
|
||||
*/
|
||||
class RsGxsMessageCleanUp //: public RsThread
|
||||
class RsGxsMessageCleanUp
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -166,11 +145,6 @@ public:
|
|||
*/
|
||||
bool clean();
|
||||
|
||||
/*!
|
||||
* TODO: Rather than manual progressions consider running through a thread
|
||||
*/
|
||||
//virtual void data_tick(){}
|
||||
|
||||
private:
|
||||
|
||||
RsGeneralDataService* const mDs;
|
||||
|
|
|
@ -195,8 +195,6 @@ public:
|
|||
/**
|
||||
* @brief Post event to the event queue.
|
||||
* @param[in] event
|
||||
* @param[out] errorMessage Optional storage for error messsage, meaningful
|
||||
* only on failure.
|
||||
* @return Success or error details.
|
||||
*/
|
||||
virtual std::error_condition postEvent(
|
||||
|
@ -206,8 +204,6 @@ public:
|
|||
* @brief Send event directly to handlers. Blocking API
|
||||
* The handlers get exectuded on the caller thread.
|
||||
* @param[in] event
|
||||
* @param[out] errorMessage Optional storage for error messsage, meaningful
|
||||
* only on failure.
|
||||
* @return Success or error details.
|
||||
*/
|
||||
virtual std::error_condition sendEvent(
|
||||
|
|
|
@ -107,7 +107,8 @@ namespace GXS_SERV {
|
|||
static const uint32_t GXS_MSG_STATUS_UNPROCESSED = 0x00000001; // Flags to store the read/process status of group messages.
|
||||
static const uint32_t GXS_MSG_STATUS_GUI_UNREAD = 0x00000002; // The actual meaning may depend on the type of service.
|
||||
static const uint32_t GXS_MSG_STATUS_GUI_NEW = 0x00000004; //
|
||||
static const uint32_t GXS_MSG_STATUS_KEEP = 0x00000008; //
|
||||
/** Do not delete message even if older then group maximum storage time */
|
||||
static const uint32_t GXS_MSG_STATUS_KEEP_FOREVER = 0x00000008;
|
||||
static const uint32_t GXS_MSG_STATUS_DELETE = 0x00000020; //
|
||||
|
||||
/** END GXS Msg status flags **/
|
||||
|
|
|
@ -363,12 +363,25 @@ public:
|
|||
* @param[in] parentId id of the post of which child posts (aka replies)
|
||||
* are requested.
|
||||
* @param[out] childPosts storage for the child posts
|
||||
* @return false if something failed, true otherwhise
|
||||
* @return Success or error details
|
||||
*/
|
||||
virtual std::error_condition getChildPosts(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& parentId,
|
||||
std::vector<RsGxsForumMsg>& childPosts ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set keep forever flag on a post so it is not deleted even if older
|
||||
* then group maximum storage time
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumId id of the forum of which the post pertain
|
||||
* @param[in] postId id of the post on which to set the flag
|
||||
* @param[in] keepForever true to set the flag, false to unset it
|
||||
* @return Success or error details
|
||||
*/
|
||||
virtual std::error_condition setPostKeepForever(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& postId,
|
||||
bool keepForever ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create forum. Blocking API.
|
||||
* @jsonapi{development}
|
||||
|
|
|
@ -237,11 +237,10 @@ RsGenExchange::ServiceCreate_Return p3GxsChannels::service_CreateGroup(RsGxsGrpI
|
|||
|
||||
void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
||||
#ifdef GXSCHANNEL_DEBUG
|
||||
RsDbg() << " Processing " << changes.size() << " channel changes..." << std::endl;
|
||||
#endif
|
||||
|
||||
/* iterate through and grab any new messages */
|
||||
/* iterate through and grab any new messages */
|
||||
std::set<RsGxsGroupId> unprocessedGroups;
|
||||
|
||||
std::vector<RsGxsNotify *>::iterator it;
|
||||
|
@ -295,6 +294,10 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
if (grpChange && rsEvents)
|
||||
{
|
||||
#ifdef GXSCHANNEL_DEBUG
|
||||
RsDbg() << " Grp Change Event or type " << grpChange->getType() << ":" << std::endl;
|
||||
#endif
|
||||
|
||||
switch (grpChange->getType())
|
||||
{
|
||||
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||
|
@ -322,18 +325,27 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||
|
||||
if(mKnownChannels.find(grpChange->mGroupId) == mKnownChannels.end())
|
||||
#ifdef GXSCHANNEL_DEBUG
|
||||
RsDbg() << " Type = Published/New " << std::endl;
|
||||
#endif
|
||||
if(mKnownChannels.find(grpChange->mGroupId) == mKnownChannels.end())
|
||||
{
|
||||
mKnownChannels.insert(std::make_pair(grpChange->mGroupId,time(NULL))) ;
|
||||
#ifdef GXSCHANNEL_DEBUG
|
||||
RsDbg() << " Status: unknown. Sending notification event." << std::endl;
|
||||
#endif
|
||||
|
||||
mKnownChannels.insert(std::make_pair(grpChange->mGroupId,time(NULL))) ;
|
||||
IndicateConfigChanged();
|
||||
|
||||
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||
ev->mChannelGroupId = grpChange->mGroupId;
|
||||
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
#ifdef GXSCHANNEL_DEBUG
|
||||
else
|
||||
std::cerr << "(II) Not notifying already known channel " << grpChange->mGroupId << std::endl;
|
||||
RsDbg() << " Not notifying already known channel " << grpChange->mGroupId << std::endl;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -919,6 +919,9 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair&
|
|||
|
||||
setMsgStatusFlags(token, msgId, status, mask);
|
||||
|
||||
/* WARNING: The event may be received before the operation is completed!
|
||||
* TODO: move notification to blocking method markRead(...) which wait the
|
||||
* operation to complete */
|
||||
if (rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
|
@ -933,6 +936,37 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair&
|
|||
/********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
|
||||
std::error_condition p3GxsForums::setPostKeepForever(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& postId,
|
||||
bool keepForever )
|
||||
{
|
||||
if(forumId.isNull() || postId.isNull()) return std::errc::invalid_argument;
|
||||
|
||||
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER;
|
||||
uint32_t status = keepForever ? GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER : 0;
|
||||
|
||||
uint32_t token;
|
||||
setMsgStatusFlags(token, RsGxsGrpMsgIdPair(forumId, postId), status, mask);
|
||||
|
||||
switch(waitToken(token))
|
||||
{
|
||||
case RsTokenService::PENDING: // [[fallthrough]];
|
||||
case RsTokenService::PARTIAL: return std::errc::timed_out;
|
||||
case RsTokenService::COMPLETE: // [[fallthrough]];
|
||||
case RsTokenService::DONE:
|
||||
{
|
||||
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||
ev->mForumGroupId = forumId;
|
||||
ev->mForumMsgId = postId;
|
||||
ev->mForumEventCode = RsForumEventCode::UPDATED_MESSAGE;
|
||||
rsEvents->postEvent(ev);
|
||||
return std::error_condition();
|
||||
}
|
||||
case RsTokenService::CANCELLED: return std::errc::operation_canceled;
|
||||
default: return std::errc::bad_message;
|
||||
}
|
||||
}
|
||||
|
||||
/* so we need the same tick idea as wiki for generating dummy forums
|
||||
*/
|
||||
|
||||
|
|
|
@ -137,6 +137,11 @@ public:
|
|||
const RsGxsGroupId& forumId, const RsGxsMessageId& parentId,
|
||||
std::vector<RsGxsForumMsg>& childPosts ) override;
|
||||
|
||||
/// @see RsGxsForums
|
||||
std::error_condition setPostKeepForever(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& postId,
|
||||
bool keepForever );
|
||||
|
||||
/// implementation of rsGxsGorums
|
||||
///
|
||||
bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue