реализована инициализация внутренних данных при конструировании,
указатели заменены на ссылки
nonstop(false),
isRunning(false),
users(NULL),
nonstop(false),
isRunning(false),
users(NULL),
+ sock(0),
+ onAddUserNotifier(*this),
+ onDelUserNotifier(*this)
{
pthread_mutex_init(&mutex, NULL);
}
{
pthread_mutex_init(&mutex, NULL);
}
InitEncrypt(&ctx, rsSettings.GetPassword());
InitEncrypt(&ctx, rsSettings.GetPassword());
-onAddUserNotifier.SetRemoteScript(this);
-onDelUserNotifier.SetRemoteScript(this);
+//onAddUserNotifier.SetRemoteScript(this);
+//onDelUserNotifier.SetRemoteScript(this);
users->AddNotifierUserAdd(&onAddUserNotifier);
users->AddNotifierUserDel(&onDelUserNotifier);
users->AddNotifierUserAdd(&onAddUserNotifier);
users->AddNotifierUserDel(&onDelUserNotifier);
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::SetUserNotifier(user_iter u)
{
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::SetUserNotifier(user_iter u)
{
-RS_CHG_AFTER_NOTIFIER<uint32_t> AfterChgIPNotifier;
+RS_CHG_AFTER_NOTIFIER<uint32_t> afterChgIPNotifier(*this, u);
-AfterChgIPNotifier.SetRemoteScript(this);
-AfterChgIPNotifier.SetUser(u);
-AfterChgIPNotifierList.push_front(AfterChgIPNotifier);
+afterChgIPNotifierList.push_front(afterChgIPNotifier);
-u->AddCurrIPAfterNotifier(&(*AfterChgIPNotifierList.begin()));
+u->AddCurrIPAfterNotifier(&(*afterChgIPNotifierList.begin()));
}
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::UnSetUserNotifier(user_iter u)
}
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::UnSetUserNotifier(user_iter u)
list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator ipAIter;
std::list<list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator> toErase;
list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator ipAIter;
std::list<list<RS_CHG_AFTER_NOTIFIER<uint32_t> >::iterator> toErase;
-for (ipAIter = AfterChgIPNotifierList.begin(); ipAIter != AfterChgIPNotifierList.end(); ++ipAIter)
+for (ipAIter = afterChgIPNotifierList.begin(); ipAIter != afterChgIPNotifierList.end(); ++ipAIter)
{
if (ipAIter->GetUser() == u)
{
{
if (ipAIter->GetUser() == u)
{
for (eIter = toErase.begin(); eIter != toErase.end(); ++eIter)
{
for (eIter = toErase.begin(); eIter != toErase.end(); ++eIter)
{
- AfterChgIPNotifierList.erase(*eIter);
+ afterChgIPNotifierList.erase(*eIter);
}
}
//-----------------------------------------------------------------------------
template <typename varParamType>
void RS_CHG_AFTER_NOTIFIER<varParamType>::Notify(const varParamType & oldValue, const varParamType & newValue)
{
}
}
//-----------------------------------------------------------------------------
template <typename varParamType>
void RS_CHG_AFTER_NOTIFIER<varParamType>::Notify(const varParamType & oldValue, const varParamType & newValue)
{
-rs->ChangedIP(user, oldValue, newValue);
+rs.ChangedIP(user, oldValue, newValue);
}
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::InitEncrypt(BLOWFISH_CTX * ctx, const string & password) const
}
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::InitEncrypt(BLOWFISH_CTX * ctx, const string & password) const
class RS_ADD_USER_NONIFIER: public NOTIFIER_BASE<user_iter>
{
public:
class RS_ADD_USER_NONIFIER: public NOTIFIER_BASE<user_iter>
{
public:
- RS_ADD_USER_NONIFIER() {};
- virtual ~RS_ADD_USER_NONIFIER() {};
-
- void SetRemoteScript(REMOTE_SCRIPT * a) { rs = a; }
+ RS_ADD_USER_NONIFIER(REMOTE_SCRIPT & r) : rs(r) {}
+ virtual ~RS_ADD_USER_NONIFIER() {}
void Notify(const user_iter & user);
private:
void Notify(const user_iter & user);
private:
};
//-----------------------------------------------------------------------------
class RS_DEL_USER_NONIFIER: public NOTIFIER_BASE<user_iter>
{
public:
};
//-----------------------------------------------------------------------------
class RS_DEL_USER_NONIFIER: public NOTIFIER_BASE<user_iter>
{
public:
- RS_DEL_USER_NONIFIER() {};
- virtual ~RS_DEL_USER_NONIFIER() {};
-
- void SetRemoteScript(REMOTE_SCRIPT * a) { rs = a; }
+ RS_DEL_USER_NONIFIER(REMOTE_SCRIPT & r) : rs(r) {}
+ virtual ~RS_DEL_USER_NONIFIER() {}
void Notify(const user_iter & user);
private:
void Notify(const user_iter & user);
private:
};
//-----------------------------------------------------------------------------
template <typename varParamType>
class RS_CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE<varParamType>
{
public:
};
//-----------------------------------------------------------------------------
template <typename varParamType>
class RS_CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE<varParamType>
{
public:
- void Notify(const varParamType & oldValue, const varParamType & newValue);
- void SetUser(user_iter u) { user = u; }
- user_iter GetUser() {return user; }
- void SetRemoteScript(REMOTE_SCRIPT * a) { rs = a; }
+ RS_CHG_AFTER_NOTIFIER(REMOTE_SCRIPT & r, user_iter u) : user(u), rs(r) {}
+ void Notify(const varParamType & oldValue, const varParamType & newValue);
+ user_iter GetUser() {return user; }
};
//-----------------------------------------------------------------------------
struct RS_USER
{
};
//-----------------------------------------------------------------------------
struct RS_USER
{
- RS_USER();
- RS_USER(const std::vector<uint32_t> & r, user_iter it);
-time_t lastSentTime;
-user_iter user;
+RS_USER();
+RS_USER(const std::vector<uint32_t> & r, user_iter it);
+
+time_t lastSentTime;
+user_iter user;
std::vector<uint32_t> routers;
std::vector<uint32_t> routers;
};
//-----------------------------------------------------------------------------
class RS_SETTINGS
};
//-----------------------------------------------------------------------------
class RS_SETTINGS
mutable BLOWFISH_CTX ctx;
mutable BLOWFISH_CTX ctx;
- std::list<RS_CHG_AFTER_NOTIFIER<uint32_t> > AfterChgIPNotifierList;
+ std::list<RS_CHG_AFTER_NOTIFIER<uint32_t> > afterChgIPNotifierList;
std::map<uint32_t, RS_USER> authorizedUsers;
mutable std::string errorStr;
std::map<uint32_t, RS_USER> authorizedUsers;
mutable std::string errorStr;
inline void RS_ADD_USER_NONIFIER::Notify(const user_iter & user)
{
printfd(__FILE__, "ADD_USER_NONIFIER\n");
inline void RS_ADD_USER_NONIFIER::Notify(const user_iter & user)
{
printfd(__FILE__, "ADD_USER_NONIFIER\n");
}
//-----------------------------------------------------------------------------
inline void RS_DEL_USER_NONIFIER::Notify(const user_iter & user)
{
printfd(__FILE__, "DEL_USER_NONIFIER\n");
}
//-----------------------------------------------------------------------------
inline void RS_DEL_USER_NONIFIER::Notify(const user_iter & user)
{
printfd(__FILE__, "DEL_USER_NONIFIER\n");
}
//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------