summaryrefslogtreecommitdiff
path: root/protocols/YAMN/src/services.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/YAMN/src/services.cpp')
-rw-r--r--protocols/YAMN/src/services.cpp69
1 files changed, 32 insertions, 37 deletions
diff --git a/protocols/YAMN/src/services.cpp b/protocols/YAMN/src/services.cpp
index 7f733cb666..703b8433c2 100644
--- a/protocols/YAMN/src/services.cpp
+++ b/protocols/YAMN/src/services.cpp
@@ -85,38 +85,39 @@ static INT_PTR ContactApplication(WPARAM wParam, LPARAM)
return 0;
}
-static INT_PTR AccountMailCheck(WPARAM wParam, LPARAM lParam)
+// This service will check/synchronize the account
+
+void AccountMailCheck(CAccount *ActualAccount, bool bForce)
{
- // This service will check/sincronize the account pointed by wParam
- CAccount *ActualAccount = (CAccount *)wParam;
// copy/paste make mistakes
- if (ActualAccount != nullptr) {
- //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;
+ if (ActualAccount == nullptr)
+ return;
- mir_cslock lck(PluginRegCS);
- SReadGuard sra(ActualAccount->AccountAccessSO, 0);
- if (sra.Succeeded()) {
- if ((ActualAccount->Flags & YAMN_ACC_ENA) && ActualAccount->Plugin->Fcn->SynchroFcnPtr) {
- CheckParam ParamToPlugin = { YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, lParam != 0 ? YAMN_FORCECHECK : YAMN_NORMALCHECK, nullptr, nullptr };
+ // 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 pop3 checking anymore
+ if (WAIT_OBJECT_0 == WaitForSingleObject(ExitEV, 0))
+ return;
- ActualAccount->TimeLeft = ActualAccount->Interval;
- DWORD tid;
- HANDLE NewThread = CreateThread(nullptr, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->SynchroFcnPtr, &ParamToPlugin, 0, &tid);
- if (NewThread) {
- WaitForSingleObject(ThreadRunningEV, INFINITE);
- CloseHandle(NewThread);
- }
+ mir_cslock lck(PluginRegCS);
+ SReadGuard sra(ActualAccount->AccountAccessSO, 0);
+ if (sra.Succeeded()) {
+ if ((ActualAccount->Flags & YAMN_ACC_ENA) && ActualAccount->Plugin->Fcn->SynchroFcnPtr) {
+ CheckParam ParamToPlugin = { YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, bForce ? YAMN_FORCECHECK : YAMN_NORMALCHECK, nullptr, nullptr };
+
+ ActualAccount->TimeLeft = ActualAccount->Interval;
+ DWORD tid;
+ HANDLE NewThread = CreateThread(nullptr, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->SynchroFcnPtr, &ParamToPlugin, 0, &tid);
+ if (NewThread) {
+ WaitForSingleObject(ThreadRunningEV, INFINITE);
+ CloseHandle(NewThread);
}
}
- CloseHandle(ThreadRunningEV);
}
- return 0;
+ CloseHandle(ThreadRunningEV);
}
static INT_PTR ContactMailCheck(WPARAM hContact, LPARAM)
@@ -171,19 +172,19 @@ static INT_PTR ContactMailCheck(WPARAM hContact, LPARAM)
if (sra.Succeeded()) {
YAMN_MAILBROWSERPARAM Param = { ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, nullptr };
- Param.nnflags = Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nnflags = Param.nnflags | YAMN_ACC_MSG; // show mails in account even no new mail in account
Param.nnflags = Param.nnflags & ~YAMN_ACC_POP;
- Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nflags = Param.nflags | YAMN_ACC_MSG; // show mails in account even no new mail in account
Param.nflags = Param.nflags & ~YAMN_ACC_POP;
- RunMailBrowserSvc((WPARAM)&Param, YAMN_MAILBROWSERVERSION);
+ RunMailBrowser(&Param);
}
}
db_free(&dbv);
}
-/////////////////////////////////////////////////////////////////////////////////////////
+// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /
HBITMAP LoadBmpFromIcon(HICON hIcon)
{
@@ -226,7 +227,7 @@ static int AddTopToolbarIcon(WPARAM, LPARAM)
return 0;
}
-/////////////////////////////////////////////////////////////////////////////////////////
+// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /
int Shutdown(WPARAM, LPARAM)
{
@@ -242,7 +243,7 @@ int Shutdown(WPARAM, LPARAM)
return 0;
}
-int SystemModulesLoaded(WPARAM, LPARAM); //in main.cpp
+int SystemModulesLoaded(WPARAM, LPARAM); // in main.cpp
void HookEvents(void)
{
@@ -263,15 +264,9 @@ void CreateServiceFunctions(void)
// Checks mail
CreateServiceFunction(MS_YAMN_FORCECHECK, ForceCheckSvc);
- // Runs YAMN's mail browser
- CreateServiceFunction(MS_YAMN_MAILBROWSER, RunMailBrowserSvc);
-
// Function contact list double click
CreateServiceFunction(MS_YAMN_CLISTDBLCLICK, ClistContactDoubleclicked);
- // Function to check individual account
- CreateServiceFunction(MS_YAMN_ACCOUNTCHECK, AccountMailCheck);
-
// Function contact list context menu click
CreateServiceFunction(MS_YAMN_CLISTCONTEXT, ContactMailCheck);