mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
Added notify of meta changes to RsGenExchange
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7428 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
15718cbca9
commit
60a67846b0
15 changed files with 177 additions and 48 deletions
|
@ -915,15 +915,21 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||
|
||||
}
|
||||
|
||||
void RsGenExchange::msgsChanged(std::map<RsGxsGroupId,
|
||||
std::vector<RsGxsMessageId> >& msgs)
|
||||
void RsGenExchange::msgsChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgsMeta)
|
||||
{
|
||||
if(mGenMtx.trylock())
|
||||
{
|
||||
while(!mMsgChange.empty())
|
||||
{
|
||||
RsGxsMsgChange* mc = mMsgChange.back();
|
||||
msgs = mc->msgChangeMap;
|
||||
if (mc->metaChange())
|
||||
{
|
||||
msgsMeta = mc->msgChangeMap;
|
||||
}
|
||||
else
|
||||
{
|
||||
msgs = mc->msgChangeMap;
|
||||
}
|
||||
mMsgChange.pop_back();
|
||||
delete mc;
|
||||
}
|
||||
|
@ -931,7 +937,7 @@ void RsGenExchange::msgsChanged(std::map<RsGxsGroupId,
|
|||
}
|
||||
}
|
||||
|
||||
void RsGenExchange::groupsChanged(std::list<RsGxsGroupId>& grpIds)
|
||||
void RsGenExchange::groupsChanged(std::list<RsGxsGroupId>& grpIds, std::list<RsGxsGroupId>& grpIdsMeta)
|
||||
{
|
||||
|
||||
if(mGenMtx.trylock())
|
||||
|
@ -942,7 +948,14 @@ void RsGenExchange::groupsChanged(std::list<RsGxsGroupId>& grpIds)
|
|||
std::list<RsGxsGroupId>& gList = gc->mGrpIdList;
|
||||
std::list<RsGxsGroupId>::iterator lit = gList.begin();
|
||||
for(; lit != gList.end(); lit++)
|
||||
if (gc->metaChange())
|
||||
{
|
||||
grpIdsMeta.push_back(*lit);
|
||||
}
|
||||
else
|
||||
{
|
||||
grpIds.push_back(*lit);
|
||||
}
|
||||
|
||||
mGroupChange.pop_back();
|
||||
delete gc;
|
||||
|
@ -1480,9 +1493,10 @@ void RsGenExchange::setMsgServiceString(uint32_t& token, const RsGxsGrpMsgIdPair
|
|||
|
||||
void RsGenExchange::processMsgMetaChanges()
|
||||
{
|
||||
|
||||
RsStackMutex stack(mGenMtx);
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
|
||||
std::map<uint32_t, MsgLocMetaData>::iterator mit = mMsgLocMetaMap.begin(),
|
||||
mit_end = mMsgLocMetaMap.end();
|
||||
|
||||
|
@ -1492,6 +1506,7 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
|
||||
int32_t value, mask;
|
||||
bool ok = true;
|
||||
bool changed = false;
|
||||
|
||||
// for meta flag changes get flag to apply mask
|
||||
if(m.val.getAsInt32(RsGeneralDataService::MSG_META_STATUS, value))
|
||||
|
@ -1515,6 +1530,7 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
{
|
||||
RsGxsMsgMetaData* meta = *(msgMetaV.begin());
|
||||
value = (meta->mMsgStatus & ~mask) | (mask & value);
|
||||
changed = (meta->mMsgStatus != value);
|
||||
m.val.put(RsGeneralDataService::MSG_META_STATUS, value);
|
||||
delete meta;
|
||||
ok = true;
|
||||
|
@ -1524,20 +1540,30 @@ void RsGenExchange::processMsgMetaChanges()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
ok &= mDataStore->updateMessageMetaData(m) == 1;
|
||||
uint32_t token = mit->first;
|
||||
|
||||
if(ok)
|
||||
{
|
||||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
|
||||
}else
|
||||
if (changed)
|
||||
{
|
||||
msgIds[m.msgId.first].push_back(m.msgId.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
|
||||
}
|
||||
mMsgNotify.insert(std::make_pair(token, m.msgId));
|
||||
}
|
||||
|
||||
if (!msgIds.empty()) {
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true);
|
||||
c->msgChangeMap = msgIds;
|
||||
mNotifications.push_back(c);
|
||||
}
|
||||
|
||||
mMsgLocMetaMap.clear();
|
||||
}
|
||||
|
||||
|
@ -1545,6 +1571,8 @@ void RsGenExchange::processGrpMetaChanges()
|
|||
{
|
||||
RsStackMutex stack(mGenMtx);
|
||||
|
||||
std::list<RsGxsGroupId> grpChanged;
|
||||
|
||||
std::map<uint32_t, GrpLocMetaData>::iterator mit = mGrpLocMetaMap.begin(),
|
||||
mit_end = mGrpLocMetaMap.end();
|
||||
|
||||
|
@ -1561,6 +1589,7 @@ void RsGenExchange::processGrpMetaChanges()
|
|||
if(ok)
|
||||
{
|
||||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);
|
||||
grpChanged.push_back(g.grpId);
|
||||
}else
|
||||
{
|
||||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
|
||||
|
@ -1568,6 +1597,13 @@ void RsGenExchange::processGrpMetaChanges()
|
|||
mGrpNotify.insert(std::make_pair(token, g.grpId));
|
||||
}
|
||||
|
||||
if(!grpChanged.empty())
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, true);
|
||||
gc->mGrpIdList = grpChanged;
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
||||
mGrpLocMetaMap.clear();
|
||||
}
|
||||
|
||||
|
@ -1798,7 +1834,7 @@ void RsGenExchange::publishMsgs()
|
|||
|
||||
if(!msgChangeMap.empty())
|
||||
{
|
||||
RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISH);
|
||||
RsGxsMsgChange* ch = new RsGxsMsgChange(RsGxsNotify::TYPE_PUBLISH, false);
|
||||
ch->msgChangeMap = msgChangeMap;
|
||||
mNotifications.push_back(ch);
|
||||
}
|
||||
|
@ -1929,7 +1965,7 @@ void RsGenExchange::processGroupDelete()
|
|||
|
||||
if(!grpDeleted.empty())
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH);
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH, false);
|
||||
gc->mGrpIdList = grpDeleted;
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
@ -2168,7 +2204,7 @@ void RsGenExchange::publishGrps()
|
|||
|
||||
if(!grpChanged.empty())
|
||||
{
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH);
|
||||
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PUBLISH, false);
|
||||
gc->mGrpIdList = grpChanged;
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
@ -2374,7 +2410,7 @@ void RsGenExchange::processRecvdMessages()
|
|||
{
|
||||
removeDeleteExistingMessages(msgs, msgIds);
|
||||
mDataStore->storeMessage(msgs);
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE);
|
||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE, false);
|
||||
c->msgChangeMap = msgIds;
|
||||
mNotifications.push_back(c);
|
||||
}
|
||||
|
@ -2483,7 +2519,7 @@ void RsGenExchange::processRecvdGroups()
|
|||
|
||||
if(!grpIds.empty())
|
||||
{
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE);
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, false);
|
||||
c->mGrpIdList = grpIds;
|
||||
mNotifications.push_back(c);
|
||||
mDataStore->storeGroup(grps);
|
||||
|
|
|
@ -269,9 +269,10 @@ public:
|
|||
* If receivedChanges is not passed RsGxsNotify changes
|
||||
* this function does nothing
|
||||
* @param grpIds returns list of grpIds that have changed
|
||||
* @param grpIdsMeta returns list of grpIds with meta data changes
|
||||
* @see updated
|
||||
*/
|
||||
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
|
||||
void groupsChanged(std::list<RsGxsGroupId>& grpIds, std::list<RsGxsGroupId>& grpIdsMeta);
|
||||
|
||||
/*!
|
||||
* The msg changed. \n
|
||||
|
@ -280,10 +281,10 @@ public:
|
|||
* If receivedChanges is not passed RsGxsNotify changes
|
||||
* this function does nothing
|
||||
* @param msgs returns map of message ids that have changed
|
||||
* @param msgsMeta returns map of message ids with meta data changes
|
||||
* @see updated
|
||||
*/
|
||||
void msgsChanged(std::map<RsGxsGroupId,
|
||||
std::vector<RsGxsMessageId> >& msgs);
|
||||
void msgsChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgsMeta);
|
||||
|
||||
|
||||
bool subscribeToGroup(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
|
||||
|
|
|
@ -69,9 +69,10 @@ public:
|
|||
* If receivedChanges is not passed RsGxsNotify changes
|
||||
* this function does nothing
|
||||
* @param grpIds returns list of grpIds that have changed
|
||||
* @param grpIdsMeta returns list of grpIds with meta data changes
|
||||
* @see updated
|
||||
*/
|
||||
virtual void groupsChanged(std::list<RsGxsGroupId>& grpIds) = 0;
|
||||
virtual void groupsChanged(std::list<RsGxsGroupId>& grpIds, std::list<RsGxsGroupId>& grpIdsMeta) = 0;
|
||||
|
||||
/*!
|
||||
* The msg changed. \n
|
||||
|
@ -80,10 +81,10 @@ public:
|
|||
* If receivedChanges is not passed RsGxsNotify changes
|
||||
* this function does nothing
|
||||
* @param msgs returns map of message ids that have changed
|
||||
* @param msgsMeta returns map of message ids with meta data changes
|
||||
* @see updated
|
||||
*/
|
||||
virtual void msgsChanged(std::map<RsGxsGroupId,
|
||||
std::vector<RsGxsMessageId> >& msgs) = 0;
|
||||
virtual void msgsChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgsMeta) = 0;
|
||||
|
||||
/*!
|
||||
* @return handle to token service for this GXS service
|
||||
|
|
|
@ -84,11 +84,12 @@ public:
|
|||
* If receivedChanges is not passed RsGxsNotify changes
|
||||
* this function does nothing
|
||||
* @param grpIds returns list of grpIds that have changed
|
||||
* @param grpIdsMeta returns list of grpIds with meta data changes
|
||||
* @see updated
|
||||
*/
|
||||
void groupsChanged(std::list<RsGxsGroupId> &grpIds)
|
||||
void groupsChanged(std::list<RsGxsGroupId> &grpIds, std::list<RsGxsGroupId>& grpIdsMeta)
|
||||
{
|
||||
mGxs->groupsChanged(grpIds);
|
||||
mGxs->groupsChanged(grpIds, grpIdsMeta);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -98,11 +99,12 @@ public:
|
|||
* If receivedChanges is not passed RsGxsNotify changes
|
||||
* this function does nothing
|
||||
* @param msgs returns map of message ids that have changed
|
||||
* @param msgsMeta returns map of message ids with meta data changes
|
||||
* @see updated
|
||||
*/
|
||||
void msgsChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs)
|
||||
void msgsChanged(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs, std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgsMeta)
|
||||
{
|
||||
mGxs->msgsChanged(msgs);
|
||||
mGxs->msgsChanged(msgs, msgsMeta);
|
||||
}
|
||||
/*!
|
||||
* @return handle to token service for this GXS service
|
||||
|
|
|
@ -31,30 +31,32 @@ public:
|
|||
|
||||
/*!
|
||||
* Relevant to group changes
|
||||
* TODO: extent to indicate whether a meta change or actual data
|
||||
*/
|
||||
class RsGxsGroupChange : public RsGxsNotify
|
||||
{
|
||||
public:
|
||||
RsGxsGroupChange(NotifyType type) : NOTIFY_TYPE(type) {}
|
||||
RsGxsGroupChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||
std::list<RsGxsGroupId> mGrpIdList;
|
||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
||||
bool metaChange() { return mMetaChange; }
|
||||
private:
|
||||
const NotifyType NOTIFY_TYPE;
|
||||
bool mMetaChange;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Relevant to message changes
|
||||
* TODO: extent to indicate whether a meta change or actual data
|
||||
*/
|
||||
class RsGxsMsgChange : public RsGxsNotify
|
||||
{
|
||||
public:
|
||||
RsGxsMsgChange(NotifyType type) : NOTIFY_TYPE(type) {}
|
||||
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgChangeMap;
|
||||
NotifyType getType(){ return NOTIFY_TYPE;}
|
||||
bool metaChange() { return mMetaChange; }
|
||||
private:
|
||||
const NotifyType NOTIFY_TYPE;
|
||||
bool mMetaChange;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
for(it = changes.begin(); it != changes.end(); it++)
|
||||
{
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||
if (msgChange)
|
||||
if (msgChange && !msgChange->metaChange())
|
||||
{
|
||||
std::cerr << "p3GxsChannels::notifyChanges() Found Message Change Notification";
|
||||
std::cerr << std::endl;
|
||||
|
|
|
@ -184,7 +184,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
{
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||
if (msgChange)
|
||||
if (msgChange && !msgChange->metaChange())
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "p3GxsCircles::notifyChanges() Found Message Change Notification";
|
||||
|
@ -203,7 +203,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
|
||||
/* add groups to ExternalIdList (Might get Personal Circles here until NetChecks in place) */
|
||||
if (groupChange)
|
||||
if (groupChange && !groupChange->metaChange())
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "p3GxsCircles::notifyChanges() Found Group Change Notification";
|
||||
|
|
|
@ -224,7 +224,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
{
|
||||
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||
if (msgChange)
|
||||
if (msgChange && !msgChange->metaChange())
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Found Message Change Notification";
|
||||
|
@ -243,7 +243,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
}
|
||||
|
||||
/* shouldn't need to worry about groups - as they need to be subscribed to */
|
||||
if (groupChange)
|
||||
if (groupChange && !groupChange->metaChange())
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Found Group Change Notification";
|
||||
|
|
|
@ -388,7 +388,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed)
|
|||
|
||||
// generate vector of changes to push to the GUI.
|
||||
std::vector<RsGxsNotify *> changes;
|
||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED);
|
||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
|
||||
|
||||
RsGxsGroupId groupId;
|
||||
|
@ -598,7 +598,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token)
|
|||
|
||||
// generate vector of changes to push to the GUI.
|
||||
std::vector<RsGxsNotify *> changes;
|
||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED);
|
||||
RsGxsMsgChange *msgChanges = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false);
|
||||
|
||||
for(mit = parentMsgList.begin(); mit != parentMsgList.end(); mit++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue