fixed setAutoDownload and setDownloadDirectory for channels

This commit is contained in:
csoler 2021-02-14 23:40:35 +01:00
parent 4ef58cce81
commit 8e91efbb93

View file

@ -96,7 +96,7 @@ p3GxsChannels::p3GxsChannels(
// This is not needed since it just loads all channel data ever 5 mins which takes a lot // This is not needed since it just loads all channel data ever 5 mins which takes a lot
// of useless CPU/memory. // of useless CPU/memory.
// //
// RsTickEvent::schedule_in(CHANNEL_PROCESS, 0); RsTickEvent::schedule_in(CHANNEL_PROCESS, 0);
// //
// Test Data disabled in repo. // Test Data disabled in repo.
// //
@ -320,6 +320,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mChannelGroupId = grpChange->mGroupId; ev->mChannelGroupId = grpChange->mGroupId;
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED; ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
unprocessedGroups.insert(grpChange->mGroupId);
} }
break; break;
@ -329,6 +331,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mChannelGroupId = grpChange->mGroupId; ev->mChannelGroupId = grpChange->mGroupId;
ev->mChannelEventCode = RsChannelEventCode::SYNC_PARAMETERS_UPDATED; ev->mChannelEventCode = RsChannelEventCode::SYNC_PARAMETERS_UPDATED;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
unprocessedGroups.insert(grpChange->mGroupId);
} }
break; break;
@ -352,6 +356,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mChannelGroupId = grpChange->mGroupId; ev->mChannelGroupId = grpChange->mGroupId;
ev->mChannelEventCode = RsChannelEventCode::UPDATED_CHANNEL; ev->mChannelEventCode = RsChannelEventCode::UPDATED_CHANNEL;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
unprocessedGroups.insert(grpChange->mGroupId);
} }
break; break;
@ -386,6 +392,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
else else
RsDbg() << " Not notifying already known channel " << grpChange->mGroupId << std::endl; RsDbg() << " Not notifying already known channel " << grpChange->mGroupId << std::endl;
#endif #endif
unprocessedGroups.insert(grpChange->mGroupId);
} }
break; break;
@ -395,6 +403,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mChannelGroupId = grpChange->mGroupId; ev->mChannelGroupId = grpChange->mGroupId;
ev->mChannelEventCode = RsChannelEventCode::DELETED_CHANNEL; ev->mChannelEventCode = RsChannelEventCode::DELETED_CHANNEL;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
unprocessedGroups.insert(grpChange->mGroupId);
} }
break; break;
@ -406,6 +416,8 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY; ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
unprocessedGroups.insert(grpChange->mGroupId);
} }
break; break;
@ -413,7 +425,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl; RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break; break;
} }
} }
/* shouldn't need to worry about groups - as they need to be subscribed to */ /* shouldn't need to worry about groups - as they need to be subscribed to */
@ -422,11 +433,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::list<RsGxsGroupId> grps; std::list<RsGxsGroupId> grps;
for(auto& grp_id:unprocessedGroups) for(auto& grp_id:unprocessedGroups)
{
bool enabled = false;
if (autoDownloadEnabled(grp_id, enabled) && enabled) // costly call, that's why it's packed down here.
grps.push_back(grp_id); grps.push_back(grp_id);
}
if(!grps.empty()) if(!grps.empty())
request_SpecificSubscribedGroups(grps); request_SpecificSubscribedGroups(grps);
@ -848,8 +855,8 @@ void p3GxsChannels::request_AllSubscribedGroups()
RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts); RsGenExchange::getTokenService()->requestGroupInfo(token, ansType, opts);
GxsTokenQueue::queueRequest(token, GXSCHANNELS_SUBSCRIBED_META); GxsTokenQueue::queueRequest(token, GXSCHANNELS_SUBSCRIBED_META);
#define PERIODIC_ALL_PROCESS 300 // TESTING every 5 minutes. //#define PERIODIC_ALL_PROCESS 300 // This
RsTickEvent::schedule_in(CHANNEL_PROCESS, PERIODIC_ALL_PROCESS); // RsTickEvent::schedule_in(CHANNEL_PROCESS, PERIODIC_ALL_PROCESS);
} }