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 void Notify(const uint32_t & oldIP, const uint32_t & newIP);
33 USER_PTR GetUser() const { return user; }
39 //-----------------------------------------------------------------------------
40 class CHG_IPS_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE<USER_IPS> {
42 CHG_IPS_NOTIFIER_PING(const PING & p, USER_PTR u) : user(u), ping(p) {}
43 void Notify(const USER_IPS & oldIPS, const USER_IPS & newIPS);
44 USER_PTR GetUser() const { return user; }
50 //-----------------------------------------------------------------------------
51 class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
53 ADD_USER_NONIFIER_PING(PING & p) : ping(p) {}
54 virtual ~ADD_USER_NONIFIER_PING() {}
55 void Notify(const USER_PTR & user);
60 //-----------------------------------------------------------------------------
61 class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
63 DEL_USER_NONIFIER_PING(PING & p) : ping(p) {}
64 virtual ~DEL_USER_NONIFIER_PING() {}
65 void Notify(const USER_PTR & user);
70 //-----------------------------------------------------------------------------
74 virtual ~PING_SETTINGS() {}
75 const std::string & GetStrError() const { return errorStr; }
76 int ParseSettings(const MODULE_SETTINGS & s);
77 int GetPingDelay() const { return pingDelay; }
80 mutable std::string errorStr;
82 //-----------------------------------------------------------------------------
83 class PING : public PLUGIN {
84 friend class CHG_CURRIP_NOTIFIER_PING;
85 friend class CHG_IPS_NOTIFIER_PING;
90 void SetUsers(USERS * u);
91 void SetSettings(const MODULE_SETTINGS & s);
96 int Reload() { return 0; }
99 const std::string & GetStrError() const;
100 const std::string GetVersion() const;
101 uint16_t GetStartPosition() const;
102 uint16_t GetStopPosition() const;
104 void AddUser(USER_PTR u);
105 void DelUser(USER_PTR u);
109 void SetUserNotifiers(USER_PTR u);
110 void UnSetUserNotifiers(USER_PTR u);
111 static void * Run(void * d);
113 mutable std::string errorStr;
114 PING_SETTINGS pingSettings;
115 MODULE_SETTINGS settings;
117 std::list<USER_PTR> usersList;
120 ÍÙ ÄÏÌÖÎÙ ÐÅÒÅÐÒÏ×ÅÒÉÔØ ×ÏÚÍÏÖÎÏÓÔØ ÐÉÎÇÏ×ÁÎÉÑ ÀÚÅÒÁ ÐÒÉ ÉÚÍÅÎÅÎÉÉ
121 ÓÌÅÄÕÀÝÉÈ ÅÇÏ ÐÁÒÁÍÅÔÒÏ×:
126 pthread_mutex_t mutex;
129 mutable STG_PINGER pinger;
131 std::list<CHG_CURRIP_NOTIFIER_PING> ChgCurrIPNotifierList;
132 std::list<CHG_IPS_NOTIFIER_PING> ChgIPNotifierList;
134 ADD_USER_NONIFIER_PING onAddUserNotifier;
135 DEL_USER_NONIFIER_PING onDelUserNotifier;
137 //-----------------------------------------------------------------------------