diff options
author | George Hazan <ghazan@miranda.im> | 2017-12-27 23:56:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-12-27 23:56:48 +0300 |
commit | b2cb548cd4b3b9a89da777f4465095fa37539d1b (patch) | |
tree | a4760e2ba9cbe0f28a5339d07f73116ba02a364f /plugins/StopSpamMod/src | |
parent | f0a0ba421fb8792869aaec1fd9e57024a0fc83cc (diff) |
boost threads replaced with mir_forkthread
Diffstat (limited to 'plugins/StopSpamMod/src')
-rwxr-xr-x | plugins/StopSpamMod/src/init.cpp | 3 | ||||
-rwxr-xr-x | plugins/StopSpamMod/src/stdafx.h | 8 | ||||
-rwxr-xr-x | plugins/StopSpamMod/src/utilities.cpp | 68 |
3 files changed, 45 insertions, 34 deletions
diff --git a/plugins/StopSpamMod/src/init.cpp b/plugins/StopSpamMod/src/init.cpp index 67da239639..4d18f3b559 100755 --- a/plugins/StopSpamMod/src/init.cpp +++ b/plugins/StopSpamMod/src/init.cpp @@ -117,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()));
}
}
|