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 SetTariffs(TARIFFS *) {}
92 void SetAdmins(ADMINS *) {}
93 void SetTraffcounter(TRAFFCOUNTER *) {}
94 void SetStore(STORE *) {}
95 void SetStgSettings(const SETTINGS *) {}
96 void SetSettings(const MODULE_SETTINGS & s);
101 int Reload() { return 0; }
104 const std::string & GetStrError() const;
105 const std::string GetVersion() const;
106 uint16_t GetStartPosition() const;
107 uint16_t GetStopPosition() const;
109 void AddUser(USER_PTR u);
110 void DelUser(USER_PTR u);
114 void SetUserNotifiers(USER_PTR u);
115 void UnSetUserNotifiers(USER_PTR u);
116 static void * Run(void * d);
118 mutable std::string errorStr;
119 PING_SETTINGS pingSettings;
120 MODULE_SETTINGS settings;
122 std::list<USER_PTR> usersList;
125 ÍÙ ÄÏÌÖÎÙ ÐÅÒÅÐÒÏ×ÅÒÉÔØ ×ÏÚÍÏÖÎÏÓÔØ ÐÉÎÇÏ×ÁÎÉÑ ÀÚÅÒÁ ÐÒÉ ÉÚÍÅÎÅÎÉÉ
126 ÓÌÅÄÕÀÝÉÈ ÅÇÏ ÐÁÒÁÍÅÔÒÏ×:
131 pthread_mutex_t mutex;
134 mutable STG_PINGER pinger;
136 std::list<CHG_CURRIP_NOTIFIER_PING> ChgCurrIPNotifierList;
137 std::list<CHG_IPS_NOTIFIER_PING> ChgIPNotifierList;
139 ADD_USER_NONIFIER_PING onAddUserNotifier;
140 DEL_USER_NONIFIER_PING onDelUserNotifier;
142 //-----------------------------------------------------------------------------