diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp new file mode 100644 index 000000000..1813577ac --- /dev/null +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -0,0 +1,44 @@ +#include + +#include "RsGxsUpdateBroadcast.h" + + +RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceImpl *ifaceImpl, float dt, QObject *parent) : + QObject(parent), mIfaceImpl(ifaceImpl), mDt(dt) +{ +} + +void RsGxsUpdateBroadcast::startMonitor() +{ + slowPoll(); +} + + +void RsGxsUpdateBroadcast::fastPoll() +{ + +} + +void RsGxsUpdateBroadcast::slowPoll() +{ + std::map > msgs; + std::list grps; + + if(mIfaceImpl->updated()) + { + mIfaceImpl->msgsChanged(msgs); + if(!msgs.empty()) + { + emit msgsChanged(msgs); + } + + mIfaceImpl->groupsChanged(grps); + + if(!grps.empty()) + { + emit grpsChanged(grps); + } + + QTimer::singleShot((int) (mDt * 1000.0), this, SLOT(slowPoll())); + } +} diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h new file mode 100644 index 000000000..d464491a5 --- /dev/null +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h @@ -0,0 +1,33 @@ +#ifndef RSGXSUPDATEBROADCAST_H +#define RSGXSUPDATEBROADCAST_H + +#include + +#include + +class RsGxsUpdateBroadcast : public QObject +{ + Q_OBJECT +public: + explicit RsGxsUpdateBroadcast(RsGxsIfaceImpl* ifaceImpl, float dt, QObject *parent = 0); + + void startMonitor(); + void update(); + +signals: + + void msgsChanged(const std::map > & msgIds); + void grpsChanged(const std::list& grpIds); + +public slots: + + void fastPoll(); + void slowPoll(); + +private: + + RsGxsIfaceImpl* mIfaceImpl; + float mDt; +}; + +#endif // RSGXSUPDATEBROADCAST_H