diff options
Diffstat (limited to 'plugins/StopSpamMod')
-rwxr-xr-x | plugins/StopSpamMod/src/init.cpp | 4 | ||||
-rwxr-xr-x | plugins/StopSpamMod/src/stdafx.h | 8 | ||||
-rwxr-xr-x | plugins/StopSpamMod/src/utilities.cpp | 68 | ||||
-rwxr-xr-x | plugins/StopSpamMod/src/version.h | 1 |
4 files changed, 45 insertions, 36 deletions
diff --git a/plugins/StopSpamMod/src/init.cpp b/plugins/StopSpamMod/src/init.cpp index 62e09e121f..4d18f3b559 100755 --- a/plugins/StopSpamMod/src/init.cpp +++ b/plugins/StopSpamMod/src/init.cpp @@ -64,7 +64,6 @@ PLUGININFOEX pluginInfoEx = { PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
__AUTHOR,
- __AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
@@ -118,9 +117,8 @@ static int OnSystemModulesLoaded(WPARAM, LPARAM) if (ServiceExists(MS_VARS_FORMATSTRING))
gbVarsServiceExist = TRUE;
InitVars();
- void CleanThread();
if(gbDelAllTempory || gbDelExcluded)
- new boost::thread(&CleanThread);
+ mir_forkthread(&CleanThread);
// Folders plugin support
hStopSpamLogDirH = FoldersRegisterCustomPathT(LPGEN("StopSpam"), LPGEN("StopSpam Logs"), FOLDER_LOGS);
diff --git a/plugins/StopSpamMod/src/stdafx.h b/plugins/StopSpamMod/src/stdafx.h index c8479ab49b..d5551e8d10 100755 --- a/plugins/StopSpamMod/src/stdafx.h +++ b/plugins/StopSpamMod/src/stdafx.h @@ -19,7 +19,9 @@ using namespace std; #include <m_variables.h> #include <m_folders.h> -#include <boost\thread.hpp> +#include <string> +#include <sstream> + #include <boost\regex.hpp> #include <boost\algorithm\string.hpp> #include <boost\nondet_random.hpp> @@ -38,4 +40,6 @@ extern HANDLE hStopSpamLogDirH; int OnDbContactSettingChanged(WPARAM w, LPARAM l); int OnDbEventFilterAdd(WPARAM w, LPARAM l); int OnDbEventAdded(WPARAM hContact, LPARAM hDbEvent); -int OnOptInit(WPARAM w, LPARAM l);
\ No newline at end of file +int OnOptInit(WPARAM w, LPARAM l); + +void __cdecl CleanThread(void*);
\ No newline at end of file diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index 7943dada3f..f6f586a5eb 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -81,8 +81,7 @@ void DeleteCListGroupsByName(wchar_t* szGroupName) int RemoveTmp(WPARAM, LPARAM)
{
- void CleanThread();
- CleanThread();
+ CleanThread(0);
return 0;
}
@@ -239,59 +238,68 @@ void LogSpamToFile(MCONTACT hContact, wstring message) file.close();
}
-boost::mutex clean_mutex;
+mir_cs clean_mutex;
-void CleanProtocolTmpThread(std::string proto)
+void __cdecl CleanProtocolTmpThread(void *param)
{
+ const char *szProto = (const char*)param;
+
while (true) {
- UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
+ UINT status = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
if (status > ID_STATUS_OFFLINE)
break;
- boost::this_thread::sleep(boost::posix_time::seconds(2));
+ Sleep(2000);
}
std::list<MCONTACT> contacts;
- for (MCONTACT hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ for (MCONTACT hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto))
if (db_get_b(hContact, "CList", "NotOnList", 0) || (L"Not In List" == DBGetContactSettingStringPAN(hContact, "CList", "Group", L"")))
contacts.push_back(hContact);
- boost::this_thread::sleep(boost::posix_time::seconds(5));
- clean_mutex.lock();
- std::list<MCONTACT>::iterator end = contacts.end();
- for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
- LogSpamToFile(*i, L"Deleted");
- HistoryLogFunc(*i, "Deleted");
- db_delete_contact(*i);
+ Sleep(5000);
+ {
+ mir_cslock lck(clean_mutex);
+
+ std::list<MCONTACT>::iterator end = contacts.end();
+ for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
+ LogSpamToFile(*i, L"Deleted");
+ HistoryLogFunc(*i, "Deleted");
+ db_delete_contact(*i);
+ }
}
- clean_mutex.unlock();
+ mir_free(param);
}
-void CleanProtocolExclThread(std::string proto)
+void __cdecl CleanProtocolExclThread(void *param)
{
+ const char *szProto = (const char*)param;
+
while (true) {
- UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
+ UINT status = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
if (status > ID_STATUS_OFFLINE)
break;
- boost::this_thread::sleep(boost::posix_time::seconds(2));
+ Sleep(2000);
}
std::list<MCONTACT> contacts;
- for (MCONTACT hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ for (MCONTACT hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto))
if (db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
contacts.push_back(hContact);
- boost::this_thread::sleep(boost::posix_time::seconds(5));
- clean_mutex.lock();
- std::list<MCONTACT>::iterator end = contacts.end();
- for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
- LogSpamToFile(*i, L"Deleted");
- HistoryLogFunc(*i, "Deleted");
- db_delete_contact(*i);
+ Sleep(5000);
+ {
+ mir_cslock lck(clean_mutex);
+ std::list<MCONTACT>::iterator end = contacts.end();
+ for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
+ LogSpamToFile(*i, L"Deleted");
+ HistoryLogFunc(*i, "Deleted");
+ db_delete_contact(*i);
+ }
}
- clean_mutex.unlock();
+ mir_free(param);
}
-void CleanThread()
+void __cdecl CleanThread(void*)
{
std::list<std::string> protocols;
int count = 0;
@@ -304,9 +312,9 @@ void CleanThread() std::list<std::string>::iterator end = protocols.end();
for (std::list<std::string>::iterator i = protocols.begin(); i != end; ++i) {
if (gbDelAllTempory)
- new boost::thread(boost::bind(&CleanProtocolTmpThread, *i));
+ mir_forkthread(CleanProtocolTmpThread, mir_strdup((*i).c_str()));
if (gbDelExcluded)
- new boost::thread(boost::bind(&CleanProtocolExclThread, *i));
+ mir_forkthread(CleanProtocolExclThread, mir_strdup((*i).c_str()));
}
}
diff --git a/plugins/StopSpamMod/src/version.h b/plugins/StopSpamMod/src/version.h index bce1b7655e..384b6d8607 100755 --- a/plugins/StopSpamMod/src/version.h +++ b/plugins/StopSpamMod/src/version.h @@ -9,6 +9,5 @@ #define __FILENAME "StopSpamMod.dll"
#define __DESCRIPTION "Anti-spam plugin for Miranda NG."
#define __AUTHOR "Roman Miklashevsky, sss, Elzor"
-#define __AUTHOREMAIL "sss123next@list.ru"
#define __AUTHORWEB "https://miranda-ng.org/p/StopSpamMod/"
#define __COPYRIGHT "© 2004-2017 Roman Miklashevsky, A. Petkevich, Kosh&chka, sss, Elzor"
|