3 $Date: 2009/06/23 11:32:28 $
15 #include "stg/os_int.h"
16 #include "stg/plugin.h"
17 #include "stg/module_settings.h"
18 #include "stg/notifer.h"
19 #include "stg/user_ips.h"
20 #include "stg/pinger.h"
21 #include "stg/users.h"
23 extern "C" PLUGIN * GetPlugin();
28 //-----------------------------------------------------------------------------*/
29 class CHG_CURRIP_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE<uint32_t> {
31 CHG_CURRIP_NOTIFIER_PING(const PING & p, USER_PTR u) : user(u), ping(p) {}
32 CHG_CURRIP_NOTIFIER_PING(const CHG_CURRIP_NOTIFIER_PING & rvalue)
33 : user(rvalue.user), ping(rvalue.ping)
35 void Notify(const uint32_t & oldIP, const uint32_t & newIP);
36 USER_PTR GetUser() const { return user; }
39 CHG_CURRIP_NOTIFIER_PING & operator=(const CHG_CURRIP_NOTIFIER_PING & rvalue);
44 //-----------------------------------------------------------------------------
45 class CHG_IPS_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE<USER_IPS> {
47 CHG_IPS_NOTIFIER_PING(const PING & p, USER_PTR u) : user(u), ping(p) {}
48 CHG_IPS_NOTIFIER_PING(const CHG_IPS_NOTIFIER_PING & rvalue)
49 : user(rvalue.user), ping(rvalue.ping)
51 void Notify(const USER_IPS & oldIPS, const USER_IPS & newIPS);
52 USER_PTR GetUser() const { return user; }
55 CHG_IPS_NOTIFIER_PING & operator=(const CHG_IPS_NOTIFIER_PING & rvalue);
60 //-----------------------------------------------------------------------------
61 class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
63 ADD_USER_NONIFIER_PING(PING & p) : ping(p) {}
64 virtual ~ADD_USER_NONIFIER_PING() {}
65 void Notify(const USER_PTR & user);
68 ADD_USER_NONIFIER_PING(const ADD_USER_NONIFIER_PING & rvalue);
69 ADD_USER_NONIFIER_PING & operator=(const ADD_USER_NONIFIER_PING & rvalue);
73 //-----------------------------------------------------------------------------
74 class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
76 DEL_USER_NONIFIER_PING(PING & p) : ping(p) {}
77 virtual ~DEL_USER_NONIFIER_PING() {}
78 void Notify(const USER_PTR & user);
81 DEL_USER_NONIFIER_PING(const DEL_USER_NONIFIER_PING & rvalue);
82 DEL_USER_NONIFIER_PING & operator=(const DEL_USER_NONIFIER_PING & rvalue);
86 //-----------------------------------------------------------------------------
89 PING_SETTINGS() : pingDelay(0), errorStr() {}
90 virtual ~PING_SETTINGS() {}
91 const std::string & GetStrError() const { return errorStr; }
92 int ParseSettings(const MODULE_SETTINGS & s);
93 int GetPingDelay() const { return pingDelay; }
96 mutable std::string errorStr;
98 //-----------------------------------------------------------------------------
99 class PING : public PLUGIN {
100 friend class CHG_CURRIP_NOTIFIER_PING;
101 friend class CHG_IPS_NOTIFIER_PING;
106 void SetUsers(USERS * u) { users = u; }
107 void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
112 int Reload() { return 0; }
115 const std::string & GetStrError() const { return errorStr; }
116 const std::string GetVersion() const { return "Pinger v.1.01"; }
117 uint16_t GetStartPosition() const { return 100; }
118 uint16_t GetStopPosition() const { return 100; }
120 void AddUser(USER_PTR u);
121 void DelUser(USER_PTR u);
124 PING(const PING & rvalue);
125 PING & operator=(const PING & rvalue);
128 void SetUserNotifiers(USER_PTR u);
129 void UnSetUserNotifiers(USER_PTR u);
130 static void * Run(void * d);
132 mutable std::string errorStr;
133 PING_SETTINGS pingSettings;
134 MODULE_SETTINGS settings;
136 std::list<USER_PTR> usersList;
139 pthread_mutex_t mutex;
142 mutable STG_PINGER pinger;
144 std::list<CHG_CURRIP_NOTIFIER_PING> ChgCurrIPNotifierList;
145 std::list<CHG_IPS_NOTIFIER_PING> ChgIPNotifierList;
147 ADD_USER_NONIFIER_PING onAddUserNotifier;
148 DEL_USER_NONIFIER_PING onDelUserNotifier;
150 //-----------------------------------------------------------------------------