]> git.stg.codes - stg.git/commitdiff
Moved common initialization code to a separate class method.
authorMaxim Mamontov <faust.madf@gmail.com>
Fri, 17 Oct 2014 10:05:56 +0000 (13:05 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Fri, 17 Oct 2014 10:05:56 +0000 (13:05 +0300)
include/stg/user_conf.h
projects/stargazer/user_impl.cpp
projects/stargazer/user_impl.h

index fe458211b2ef69c8f8e8ca50f63756b95d205e1c..d0415c42b47f36f18e55983f9d59df0ba853bd02 100644 (file)
 struct USER_CONF
 {
     USER_CONF()
 struct USER_CONF
 {
     USER_CONF()
-        : password(),
-          passive(0),
+        : passive(0),
           disabled(0),
           disabledDetailStat(0),
           alwaysOnline(0),
           disabled(0),
           disabledDetailStat(0),
           alwaysOnline(0),
-          tariffName(),
-          address(),
-          phone(),
-          email(),
-          note(),
-          realName(),
-          corp(),
-          services(),
-          group(),
           credit(0),
           credit(0),
-          nextTariff(),
           userdata(USERDATA_NUM),
           userdata(USERDATA_NUM),
-          creditExpire(0),
-          ips()
+          creditExpire(0)
     {}
 
     std::string              password;
     {}
 
     std::string              password;
@@ -63,25 +51,6 @@ struct USER_CONF
 struct USER_CONF_RES
 {
     USER_CONF_RES()
 struct USER_CONF_RES
 {
     USER_CONF_RES()
-        : password(),
-          passive(),
-          disabled(),
-          disabledDetailStat(),
-          alwaysOnline(),
-          tariffName(),
-          address(),
-          phone(),
-          email(),
-          note(),
-          realName(),
-          corp(),
-          group(),
-          credit(),
-          nextTariff(),
-          userdata(USERDATA_NUM),
-          services(),
-          creditExpire(),
-          ips()
     {
     }
 
     {
     }
 
index 7932198783197138cde33d1d7ef664e1af960f7f..44fac908582ed1d3ed786b3657cdf7ed6b5eb1c7 100644 (file)
@@ -59,8 +59,7 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
            const TARIFFS * t,
            const ADMIN * a,
            const USERS * u)
            const TARIFFS * t,
            const ADMIN * a,
            const USERS * u)
-    : USER(),
-      users(u),
+    : users(u),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
@@ -120,22 +119,7 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
       cashNotifier(this),
       ipNotifier(this)
 {
       cashNotifier(this),
       ipNotifier(this)
 {
-password = "*_EMPTY_PASSWORD_*";
-tariffName = NO_TARIFF_NAME;
-ips = StrToIPS("*");
-lastWriteStat = stgTime + random() % settings->GetStatWritePeriod();
-lastWriteDetailedStat = stgTime;
-
-property.tariffName.AddBeforeNotifier(&tariffNotifier);
-property.passive.AddBeforeNotifier(&passiveNotifier);
-property.disabled.AddAfterNotifier(&disabledNotifier);
-property.cash.AddBeforeNotifier(&cashNotifier);
-ips.AddAfterNotifier(&ipNotifier);
-
-pthread_mutexattr_t attr;
-pthread_mutexattr_init(&attr);
-pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-pthread_mutex_init(&mutex, &attr);
+Init();
 }
 #else
 USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
 }
 #else
 USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
@@ -143,8 +127,7 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
                      const TARIFFS * t,
                      const ADMIN * a,
                      const USERS * u)
                      const TARIFFS * t,
                      const ADMIN * a,
                      const USERS * u)
-    : USER(),
-      users(u),
+    : users(u),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
@@ -204,6 +187,12 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
       cashNotifier(this),
       ipNotifier(this)
 {
       cashNotifier(this),
       ipNotifier(this)
 {
+Init();
+}
+#endif
+//-----------------------------------------------------------------------------
+void USER_IMPL::Init()
+{
 password = "*_EMPTY_PASSWORD_*";
 tariffName = NO_TARIFF_NAME;
 ips = StrToIPS("*");
 password = "*_EMPTY_PASSWORD_*";
 tariffName = NO_TARIFF_NAME;
 ips = StrToIPS("*");
@@ -221,7 +210,6 @@ pthread_mutexattr_init(&attr);
 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 pthread_mutex_init(&mutex, &attr);
 }
 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 pthread_mutex_init(&mutex, &attr);
 }
-#endif
 //-----------------------------------------------------------------------------
 USER_IMPL::USER_IMPL(const USER_IMPL & u)
     : USER(),
 //-----------------------------------------------------------------------------
 USER_IMPL::USER_IMPL(const USER_IMPL & u)
     : USER(),
index 29cc63c4f57b12522e8df7189ba2d623366f02f4..dbb0d892fe0fb834ed15c9396edbd875776f4324 100644 (file)
@@ -230,6 +230,8 @@ public:
 private:
     USER_IMPL & operator=(const USER_IMPL & rvalue);
 
 private:
     USER_IMPL & operator=(const USER_IMPL & rvalue);
 
+    void            Init();
+
     const USERS *   users;
     USER_PROPERTIES property;
     STG_LOGGER &    WriteServLog;
     const USERS *   users;
     USER_PROPERTIES property;
     STG_LOGGER &    WriteServLog;