diff options
-rw-r--r-- | init.cpp | 2 | ||||
-rw-r--r-- | utilities.cpp | 63 |
2 files changed, 33 insertions, 32 deletions
@@ -175,7 +175,7 @@ static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam) InitVars(); void CleanThread(); if(gbDelAllTempory || gbDelExcluded) - boost::thread *thr = new boost::thread(CleanThread); + boost::thread *thr = new boost::thread(&CleanThread); // Folders plugin support
if (ServiceExists(MS_FOLDERS_REGISTER_PATH))
{
diff --git a/utilities.cpp b/utilities.cpp index 7b6657d..02ef0ba 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -379,16 +379,24 @@ void LogSpamToFile(HANDLE hContact, tstring message) boost::mutex clean_mutex; -void CleanProtocolTmpThread(char* proto) +void CleanProtocolTmpThread(std::string proto) { boost::this_thread::sleep(boost::posix_time::seconds(5)); std::list<HANDLE> contacts; - for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact;) + for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) { - if(!strcmp(proto, (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0))) + if(!strcmp(proto.c_str(), (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0))) if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T("")))) contacts.push_back(hContact); } + while(true)
+ {
+ UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
+ if(status > ID_STATUS_OFFLINE)
+ break;
+ boost::this_thread::sleep(boost::posix_time::seconds(2));
+ }
+ boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock(); std::list<HANDLE>::iterator end = contacts.end(); for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i) @@ -400,16 +408,24 @@ void CleanProtocolTmpThread(char* proto) clean_mutex.unlock(); } -void CleanProtocolExclThread(char* proto)
+void CleanProtocolExclThread(std::string proto)
{
boost::this_thread::sleep(boost::posix_time::seconds(5));
std::list<HANDLE> contacts;
- for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact;)
+ for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
{
- if(!strcmp(proto, (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)))
+ if(!strcmp(proto.c_str(), (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)))
if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0))
contacts.push_back(hContact);
}
+ while(true)
+ {
+ UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
+ if(status > ID_STATUS_OFFLINE)
+ break;
+ boost::this_thread::sleep(boost::posix_time::seconds(2));
+ }
+ boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<HANDLE>::iterator end = contacts.end();
for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
@@ -429,32 +445,17 @@ void CleanThread() PROTOACCOUNT **accounts; ProtoEnumAccounts(&count, &accounts); for(int i = 0; i < count; i++) - protocols.push_back(accounts[i]->szModuleName); - while(!protocols.empty()) { - std::list<std::list<std::string>::iterator> elements_to_clean; - std::list<std::string>::iterator end = protocols.end(); - for(std::list<std::string>::iterator i = protocols.begin(); i != end; ++i) - {
- UINT status = CallProtoService(i->c_str(), PS_GETSTATUS, 0, 0);
- if(status>= ID_STATUS_CONNECTING && status <= ID_STATUS_OFFLINE)
- ;
- else - { - if(gbDelAllTempory) - boost::thread *thr = new boost::thread(boost::bind(CleanProtocolTmpThread, (char*)i->c_str())); - if(gbDelExcluded) - boost::thread *thr = new boost::thread(boost::bind(CleanProtocolExclThread, (char*)i->c_str())); - elements_to_clean.push_back(i); - } - } - if(!elements_to_clean.empty()) - { - std::list<std::list<std::string>::iterator>::iterator end = elements_to_clean.end(); - for(std::list<std::list<std::string>::iterator>::iterator i = elements_to_clean.begin(); i != end; ++i) - protocols.erase(*i); - } - boost::this_thread::sleep(boost::posix_time::seconds(1)); + if(!strstr(accounts[i]->szModuleName, "MetaContacts") && !strstr(accounts[i]->szModuleName, "Weather")) //not real protocols + protocols.push_back(accounts[i]->szModuleName); + } + std::list<std::string>::iterator end = protocols.end(); + for(std::list<std::string>::iterator i = protocols.begin(); i != end; ++i)
+ { + if(gbDelAllTempory) + boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolTmpThread, *i)); + if(gbDelExcluded) + boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolExclThread, *i)); } } void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
|