summaryrefslogtreecommitdiff
path: root/protocols/YAMN/src/yamn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/YAMN/src/yamn.cpp')
-rw-r--r--protocols/YAMN/src/yamn.cpp58
1 files changed, 14 insertions, 44 deletions
diff --git a/protocols/YAMN/src/yamn.cpp b/protocols/YAMN/src/yamn.cpp
index efc19e4136..d95721e6fb 100644
--- a/protocols/YAMN/src/yamn.cpp
+++ b/protocols/YAMN/src/yamn.cpp
@@ -33,11 +33,6 @@ HANDLE WriteToFileEV;
void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
- // we use event to signal, that running thread has all needed stack parameters copied
- HANDLE ThreadRunningEV = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- if (ThreadRunningEV == nullptr)
- return;
-
// if we want to close miranda, we get event and do not run checking anymore
if (WAIT_OBJECT_0 == WaitForSingleObject(ExitEV, 0))
return;
@@ -80,17 +75,8 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGETIME, (WPARAM)ActualAccount, (LPARAM)ActualAccount->TimeLeft);
if (!ActualAccount->TimeLeft) {
- struct CheckParam ParamToPlugin = {YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount };
-
ActualAccount->TimeLeft = ActualAccount->Interval;
-
- DWORD tid;
- HANDLE NewThread = CreateThread(nullptr, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->TimeoutFcnPtr, &ParamToPlugin, 0, &tid);
- if (NewThread == nullptr)
- continue;
-
- WaitForSingleObject(ThreadRunningEV, INFINITE);
- CloseHandle(NewThread);
+ mir_forkthread((pThreadFunc)ActualAccount->Plugin->Fcn->TimeoutFcnPtr, new CheckParam(ActualAccount, YAMN_NORMALCHECK));
}
}
@@ -107,47 +93,31 @@ ChangeIsCountingStatusLabel:
}
}
}
- CloseHandle(ThreadRunningEV);
}
INT_PTR ForceCheckSvc(WPARAM, LPARAM)
{
- // we use event to signal, that running thread has all needed stack parameters copied
- HANDLE ThreadRunningEV = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- if (ThreadRunningEV == nullptr)
- return 0;
-
// if we want to close miranda, we get event and do not run pop3 checking anymore
if (WAIT_OBJECT_0 == WaitForSingleObject(ExitEV, 0))
return 0;
- { mir_cslock lck(PluginRegCS);
-
- for (YAMN_PROTOPLUGINQUEUE *ActualPlugin = FirstProtoPlugin; ActualPlugin != nullptr; ActualPlugin = ActualPlugin->Next) {
- SReadGuard srb(ActualPlugin->Plugin->AccountBrowserSO);
- for (auto *ActualAccount = ActualPlugin->Plugin->FirstAccount; ActualAccount != nullptr; ActualAccount = ActualAccount->Next) {
- if (ActualAccount->Plugin->Fcn == nullptr) //account not inited
- continue;
-
- SReadGuard sra(ActualAccount->AccountAccessSO);
- if (!sra.Succeeded())
- continue;
+ mir_cslock lck(PluginRegCS);
- if ((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE)) { //account cannot be forced to check
- if (ActualAccount->Plugin->Fcn->ForceCheckFcnPtr == nullptr)
- continue;
+ for (auto *ActualPlugin = FirstProtoPlugin; ActualPlugin != nullptr; ActualPlugin = ActualPlugin->Next) {
+ SReadGuard srb(ActualPlugin->Plugin->AccountBrowserSO);
+ for (auto *ActualAccount = ActualPlugin->Plugin->FirstAccount; ActualAccount != nullptr; ActualAccount = ActualAccount->Next) {
+ if (ActualAccount->Plugin->Fcn == nullptr) //account not inited
+ continue;
- DWORD tid;
- CheckParam ParamToPlugin = { YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount };
- if (nullptr == CreateThread(nullptr, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr, &ParamToPlugin, 0, &tid))
- continue;
+ SReadGuard sra(ActualAccount->AccountAccessSO);
+ if (!sra.Succeeded())
+ continue;
- WaitForSingleObject(ThreadRunningEV, INFINITE);
- }
- }
+ // account cannot be forced to check
+ if ((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE))
+ if (ActualAccount->Plugin->Fcn->ForceCheckFcnPtr)
+ mir_forkThread<CheckParam>(ActualAccount->Plugin->Fcn->ForceCheckFcnPtr, new CheckParam(ActualAccount, g_plugin.CheckFlags()));
}
}
-
- CloseHandle(ThreadRunningEV);
return 1;
}