mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 12:24:24 -04:00
fix the msg download problem
part of code the disable auto download for channels git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4126 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
83837fb9a8
commit
85aad4c75b
2 changed files with 97 additions and 6 deletions
|
@ -547,7 +547,12 @@ bool p3Channels::channelSubscribe(std::string cId, bool subscribe)
|
||||||
std::cerr << "p3Channels::channelSubscribe() " << cId << std::endl;
|
std::cerr << "p3Channels::channelSubscribe() " << cId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return subscribeToGroup(cId, subscribe);
|
bool ok = subscribeToGroup(cId, subscribe);
|
||||||
|
|
||||||
|
if(ok)
|
||||||
|
mChannelStatus[cId] = RS_CHAN_STATUS_AUTO_DL;
|
||||||
|
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Channels::channelShareKeys(std::string chId, std::list<std::string>& peers){
|
bool p3Channels::channelShareKeys(std::string chId, std::list<std::string>& peers){
|
||||||
|
@ -596,6 +601,35 @@ void p3Channels::getPubKeysAvailableGrpIds(std::list<std::string>& grpIds)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void p3Channels::channelSetAutoDl(const std::string& chId, bool autoDl)
|
||||||
|
{
|
||||||
|
|
||||||
|
RsStackMutex stack(distribMtx);
|
||||||
|
|
||||||
|
if(autoDl)
|
||||||
|
mChannelStatus[chId] |= RS_CHAN_STATUS_AUTO_DL;
|
||||||
|
else
|
||||||
|
mChannelStatus[chId] = ~RS_CHAN_STATUS_AUTO_DL;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool p3Channels::channelGetAutoDl(const std::string& chId, bool& autoDl)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(distribMtx);
|
||||||
|
|
||||||
|
statMap::iterator it = mChannelStatus.find(chId);
|
||||||
|
|
||||||
|
if(it != mChannelStatus.end())
|
||||||
|
{
|
||||||
|
autoDl = mChannelStatus[chId] & RS_CHAN_STATUS_AUTO_DL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
|
@ -622,6 +656,29 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if msg has done download already
|
||||||
|
|
||||||
|
chanStatMap::iterator cit = mMsgReadStatus.find(grpId);
|
||||||
|
statMap MsgMap;
|
||||||
|
statMap::iterator mit1, mit2;
|
||||||
|
|
||||||
|
if(cit != mMsgReadStatus.end()){
|
||||||
|
mit1 = cit->second.find(msgId);
|
||||||
|
|
||||||
|
if(mit1 != cit->second.end()){
|
||||||
|
if(mit1->second & CHANNEL_MSG_STATUS_DOWLOADED)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mit2 = mChannelStatus.find(grpId);
|
||||||
|
|
||||||
|
if(mit2 != mChannelStatus.end())
|
||||||
|
{
|
||||||
|
if(!(mit2->second & RS_CHAN_STATUS_AUTO_DL))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* request the files
|
/* request the files
|
||||||
* NB: This will result in duplicates.
|
* NB: This will result in duplicates.
|
||||||
* it is upto ftserver/ftcontroller/ftextralist to handle this!
|
* it is upto ftserver/ftcontroller/ftextralist to handle this!
|
||||||
|
@ -689,6 +746,7 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
|
||||||
RS_FILE_HINTS_NETWORK_WIDE;
|
RS_FILE_HINTS_NETWORK_WIDE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
srcIds.push_back(id);
|
srcIds.push_back(id);
|
||||||
|
|
||||||
|
@ -709,6 +767,9 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mit1->second |= (CHANNEL_MSG_STATUS_MASK &
|
||||||
|
CHANNEL_MSG_STATUS_DOWLOADED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,8 +884,7 @@ bool p3Channels::childLoadList(std::list<RsItem* >& configSaves)
|
||||||
{
|
{
|
||||||
if(NULL != (drs = dynamic_cast<RsChannelReadStatus* >(*it)))
|
if(NULL != (drs = dynamic_cast<RsChannelReadStatus* >(*it)))
|
||||||
{
|
{
|
||||||
mReadStatus.push_back(drs);
|
processChanReadStatus(drs);
|
||||||
saveList.push_back(drs);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -837,6 +897,29 @@ bool p3Channels::childLoadList(std::list<RsItem* >& configSaves)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void p3Channels::processChanReadStatus(RsChannelReadStatus* drs)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
mReadStatus.push_back(drs);
|
||||||
|
std::string chId = drs->channelId;
|
||||||
|
|
||||||
|
statMap::iterator sit = drs->msgReadStatus.find(chId);
|
||||||
|
|
||||||
|
if(sit != drs->msgReadStatus.end()){
|
||||||
|
mChannelStatus[chId] = sit->second;
|
||||||
|
drs->msgReadStatus.erase(sit);
|
||||||
|
}
|
||||||
|
|
||||||
|
// first pull out the channel id status
|
||||||
|
|
||||||
|
mMsgReadStatus[drs->channelId] = drs->msgReadStatus;
|
||||||
|
mReadStatus.push_back(drs);
|
||||||
|
|
||||||
|
saveList.push_back(drs);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
std::list<RsItem *> p3Channels::childSaveList()
|
std::list<RsItem *> p3Channels::childSaveList()
|
||||||
{
|
{
|
||||||
return saveList;
|
return saveList;
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
#include "serialiser/rstlvtypes.h"
|
#include "serialiser/rstlvtypes.h"
|
||||||
#include "serialiser/rschannelitems.h"
|
#include "serialiser/rschannelitems.h"
|
||||||
|
|
||||||
|
#define RS_CHAN_STATUS_AUTO_DL 0x0004
|
||||||
|
|
||||||
|
typedef std::map<std::string, uint32_t> statMap;
|
||||||
|
typedef std::map<std::string, statMap> chanStatMap;
|
||||||
|
|
||||||
//! Channels is a distributed 'feed' service
|
//! Channels is a distributed 'feed' service
|
||||||
/*!
|
/*!
|
||||||
|
@ -79,8 +83,8 @@ virtual bool channelRestoreKeys(std::string chId);
|
||||||
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers);
|
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers);
|
||||||
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci);
|
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci);
|
||||||
virtual void getPubKeysAvailableGrpIds(std::list<std::string>& grpIds);
|
virtual void getPubKeysAvailableGrpIds(std::list<std::string>& grpIds);
|
||||||
//virtual void setPrivateChannelDir(const std::string dirName);
|
virtual void channelSetAutoDl(const std::string& chId, bool autoDl);
|
||||||
|
virtual bool channelGetAutoDl(const std::string& chId, bool& autoDl);
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||||
|
@ -107,11 +111,15 @@ virtual std::list<RsItem *> childSaveList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void processChanReadStatus(RsChannelReadStatus* drs);
|
||||||
|
|
||||||
RsFiles *mRsFiles;
|
RsFiles *mRsFiles;
|
||||||
std::string mChannelsDir;
|
std::string mChannelsDir;
|
||||||
std::list<RsItem *> saveList;
|
std::list<RsItem *> saveList;
|
||||||
|
|
||||||
std::list<RsChannelReadStatus *> mReadStatus;
|
std::list<RsChannelReadStatus *> mReadStatus;
|
||||||
|
chanStatMap mMsgReadStatus;
|
||||||
|
statMap mChannelStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue