+
+void SMUX::SetNotifier(UserPtr userPtr)
+{
+notifiers.emplace_back(*this, userPtr);
+userPtr->GetProperties().tariffName.AddAfterNotifier(¬ifiers.back());
+}
+
+void SMUX::UnsetNotifier(UserPtr userPtr)
+{
+auto it = notifiers.begin();
+while (it != notifiers.end())
+ {
+ if (it->GetUserPtr() == userPtr)
+ {
+ userPtr->GetProperties().tariffName.DelAfterNotifier(&(*it));
+ notifiers.erase(it);
+ break;
+ }
+ ++it;
+ }
+}
+
+void SMUX::SetNotifiers()
+{
+int h = users->OpenSearch();
+assert(h && "USERS::OpenSearch is always correct");
+
+UserPtr u;
+while (users->SearchNext(h, &u) == 0)
+ SetNotifier(u);
+
+users->CloseSearch(h);
+
+m_onAddUserConn = users->onAdd([this](auto user){
+ SetNotifier(user);
+ UpdateTables();
+});
+m_onDelUserConn = users->onDel([this](auto user){
+ UnsetNotifier(user);
+ UpdateTables();
+});
+
+auto updateTables = [this](const STG::TariffData&){ UpdateTables(); };
+m_onAddTariffConn = tariffs->onAdd(updateTables);
+m_onDelTariffConn = tariffs->onDel(updateTables);
+}
+
+void SMUX::ResetNotifiers()
+{
+m_onAddTariffConn.disconnect();
+m_onDelTariffConn.disconnect();
+
+m_onAddUserConn.disconnect();
+m_onDelUserConn.disconnect();
+
+auto it = notifiers.begin();
+while (it != notifiers.end())
+ {
+ it->GetUserPtr()->GetProperties().tariffName.DelAfterNotifier(&(*it));
+ ++it;
+ }
+notifiers.clear();
+}