X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/a622b081808494796d3679acaebbf5ee364fe9de..64b687f8ec36a103865044613cb0f42f98aeda3a:/projects/stargazer/plugins/other/ping/ping.cpp diff --git a/projects/stargazer/plugins/other/ping/ping.cpp b/projects/stargazer/plugins/other/ping/ping.cpp index f0868e12..7c4050ab 100644 --- a/projects/stargazer/plugins/other/ping/ping.cpp +++ b/projects/stargazer/plugins/other/ping/ping.cpp @@ -10,37 +10,43 @@ #include "stg/plugin_creator.h" #include "ping.h" -PLUGIN_CREATOR pc; -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -PLUGIN * GetPlugin() +namespace { -return pc.GetPlugin(); -} +PLUGIN_CREATOR pc; + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // ëÌÁÓÓ ÄÌÑ ÐÏÉÓËÁ ÀÚÅÒÁ × ÓÐÉÓËÅ ÎÏÔÉÆÉËÁÔÏÒÏ× template -class IS_CONTAINS_USER: public binary_function +class IS_CONTAINS_USER: public std::binary_function { public: IS_CONTAINS_USER(const USER_PTR & u) : user(u) {} bool operator()(varType notifier) const { return notifier.GetUser() == user; - }; + } private: const USER_PTR & user; }; +} + +extern "C" PLUGIN * GetPlugin(); +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +PLUGIN * GetPlugin() +{ +return pc.GetPlugin(); +} //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- int PING_SETTINGS::ParseSettings(const MODULE_SETTINGS & s) { PARAM_VALUE pv; -vector::const_iterator pvi; +std::vector::const_iterator pvi; pv.param = "PingDelay"; pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); @@ -74,7 +80,8 @@ PING::PING() ChgCurrIPNotifierList(), ChgIPNotifierList(), onAddUserNotifier(*this), - onDelUserNotifier(*this) + onDelUserNotifier(*this), + logger(GetPluginLogger(GetStgLogger(), "ping")) { pthread_mutex_init(&mutex, NULL); } @@ -107,6 +114,7 @@ pinger.Start(); if (pthread_create(&thread, NULL, Run, this)) { errorStr = "Cannot start thread."; + logger("Cannot create thread."); printfd(__FILE__, "Cannot start thread\n"); return -1; } @@ -136,7 +144,7 @@ for (int i = 0; i < 25; i++) users->DelNotifierUserAdd(&onAddUserNotifier); users->DelNotifierUserDel(&onDelUserNotifier); -list::iterator users_iter; +std::list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) { @@ -168,7 +176,7 @@ long delay = (10000000 * ping->pingSettings.GetPingDelay()) / 3 + 50000000; while (ping->nonstop) { - list::iterator iter = ping->usersList.begin(); + std::list::iterator iter = ping->usersList.begin(); { STG_LOCKER lock(&ping->mutex, __FILE__, __LINE__); while (iter != ping->usersList.end()) @@ -231,8 +239,8 @@ void PING::UnSetUserNotifiers(USER_PTR u) IS_CONTAINS_USER IsContainsUserCurrIP(u); IS_CONTAINS_USER IsContainsUserIP(u); -list::iterator currIPter; -list::iterator IPIter; +std::list::iterator currIPter; +std::list::iterator IPIter; currIPter = find_if(ChgCurrIPNotifierList.begin(), ChgCurrIPNotifierList.end(), @@ -301,7 +309,7 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); UnSetUserNotifiers(u); -list::iterator users_iter; +std::list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end())