]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Replace properties in IsInetable with explicit use of variables
[stg.git] / projects / stargazer / user_impl.cpp
index e1bb4baefb2c40955661ede5717167adc28ff7dc..00063437ec339bc4071c38f1a28f98219f4d1ddb 100644 (file)
 #include <cassert>
 #include <cstdlib>
 
+#include "stg/users.h"
+#include "stg/common.h"
+#include "stg/scriptexecuter.h"
+#include "stg/tariff.h"
+#include "stg/tariffs.h"
+#include "stg/admin.h"
 #include "user_impl.h"
-#include "users.h"
-#include "common.h"
 #include "settings_impl.h"
-#include "script_executer.h"
-#include "tariff.h"
-#include "tariffs.h"
-#include "admin.h"
 
 USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
            const STORE * st,
@@ -628,7 +628,7 @@ if (!authorizedBy.empty())
     {
     if (connected)
         {
-        lastActivityTime = *const_cast<time_t *>(&stgTime);
+        property.Stat().lastActivityTime = stgTime;
         }
     if (!connected && IsInetable())
         {
@@ -674,21 +674,21 @@ bool USER_IMPL::IsInetable()
 {
 //STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 
-if (disabled || passive)
+if (disabled.ConstData() || passive.ConstData())
     return false;
 
 if (settings->GetFreeMbAllowInet())
     {
-    if (freeMb >= 0)
+    if (freeMb.ConstData() >= 0)
         return true;
     }
 
 if (settings->GetShowFeeInCash())
     {
-    return (cash >= -credit);
+    return (cash.ConstData() >= -credit.ConstData());
     }
 
-return (cash - tariff->GetFee() >= -credit);
+return (cash.ConstData() - tariff->GetFee() >= -credit.ConstData());
 }
 //-----------------------------------------------------------------------------
 string USER_IMPL::GetEnabledDirs()
@@ -908,6 +908,30 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 currIP.DelAfterNotifier(n);
 }
 //-----------------------------------------------------------------------------
+void USER_IMPL::AddConnectedBeforeNotifier(PROPERTY_NOTIFIER_BASE<bool> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+connected.AddBeforeNotifier(n);
+}
+//-----------------------------------------------------------------------------
+void USER_IMPL::DelConnectedBeforeNotifier(PROPERTY_NOTIFIER_BASE<bool> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+connected.DelBeforeNotifier(n);
+}
+//-----------------------------------------------------------------------------
+void USER_IMPL::AddConnectedAfterNotifier(PROPERTY_NOTIFIER_BASE<bool> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+connected.AddAfterNotifier(n);
+}
+//-----------------------------------------------------------------------------
+void USER_IMPL::DelConnectedAfterNotifier(PROPERTY_NOTIFIER_BASE<bool> * n)
+{
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+connected.DelAfterNotifier(n);
+}
+//-----------------------------------------------------------------------------
 void USER_IMPL::OnAdd()
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);