From 39badfe98c0f8a750101926f91b5b3122dfdeb22 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 16 Oct 2023 12:44:06 +0300 Subject: more code cleaning --- protocols/YAMN/src/account.cpp | 6 ++-- protocols/YAMN/src/browser/mailbrowser.cpp | 26 +++++++-------- protocols/YAMN/src/main.cpp | 12 +++---- protocols/YAMN/src/proto/pop3/pop3opt.cpp | 10 +++--- protocols/YAMN/src/services.cpp | 2 +- protocols/YAMN/src/stdafx.h | 7 ++-- protocols/YAMN/src/yamn.cpp | 2 +- protocols/YAMN/src/yamn.h | 53 ++++++++++++++++++++++++++++++ 8 files changed, 87 insertions(+), 31 deletions(-) create mode 100644 protocols/YAMN/src/yamn.h (limited to 'protocols/YAMN/src') diff --git a/protocols/YAMN/src/account.cpp b/protocols/YAMN/src/account.cpp index 3c834b28cc..4e2fad5824 100644 --- a/protocols/YAMN/src/account.cpp +++ b/protocols/YAMN/src/account.cpp @@ -895,7 +895,7 @@ int DeleteAccount(YAMN_PROTOPLUGIN *Plugin, CAccount *Which) { // 1. set stop signal StopSignalFcn(Which); - WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_STOPACCOUNT, (WPARAM)Which, 0); + WindowList_BroadcastAsync(MessageWnds, WM_YAMN_STOPACCOUNT, (WPARAM)Which, 0); if (Plugin->Fcn->StopAccountFcnPtr != nullptr) Plugin->Fcn->StopAccountFcnPtr(Which); @@ -948,7 +948,7 @@ int StopAccounts(YAMN_PROTOPLUGIN *Plugin) for (Finder = Plugin->FirstAccount; Finder != nullptr; Finder = Finder->Next) { // 2. set stop signal StopSignalFcn(Finder); - WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_STOPACCOUNT, (WPARAM)Finder, 0); + WindowList_BroadcastAsync(MessageWnds, WM_YAMN_STOPACCOUNT, (WPARAM)Finder, 0); if (Plugin->Fcn->StopAccountFcnPtr != nullptr) Plugin->Fcn->StopAccountFcnPtr(Finder); } @@ -1006,5 +1006,5 @@ void SetStatusFcn(CAccount *Which, wchar_t *Value) mir_wstrcpy(Which->Status, Value); } - WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGESTATUS, (WPARAM)Which, 0); + WindowList_BroadcastAsync(MessageWnds, WM_YAMN_CHANGESTATUS, (WPARAM)Which, 0); } diff --git a/protocols/YAMN/src/browser/mailbrowser.cpp b/protocols/YAMN/src/browser/mailbrowser.cpp index 15c3310589..83e6edbbcf 100644 --- a/protocols/YAMN/src/browser/mailbrowser.cpp +++ b/protocols/YAMN/src/browser/mailbrowser.cpp @@ -732,11 +732,11 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa case UM_INITPOPUP: // This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. - WindowList_Add(YAMNVar.MessageWnds, hWnd); + WindowList_Add(MessageWnds, hWnd); break; case UM_DESTROYPOPUP: - WindowList_Remove(YAMNVar.MessageWnds, hWnd); + WindowList_Remove(MessageWnds, hWnd); break; case WM_YAMN_STOPACCOUNT: @@ -781,11 +781,11 @@ LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l case UM_INITPOPUP: // This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. - WindowList_Add(YAMNVar.MessageWnds, hWnd); + WindowList_Add(MessageWnds, hWnd); break; case UM_DESTROYPOPUP: - WindowList_Remove(YAMNVar.MessageWnds, hWnd); + WindowList_Remove(MessageWnds, hWnd); break; case WM_YAMN_STOPACCOUNT: @@ -1217,7 +1217,7 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR else { if (MailParam->mail->Flags & YAMN_MSG_UNSEEN) { MailParam->mail->Flags &= ~YAMN_MSG_UNSEEN; // mark the message as seen - HWND hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (UINT_PTR)MailParam->account); + HWND hMailBrowser = WindowList_Find(NewMailAccountWnd, (UINT_PTR)MailParam->account); if (hMailBrowser) { struct CChangeContent Params = { MailParam->account->NewMailN.Flags | YAMN_ACC_MSGP, MailParam->account->NoNewMailN.Flags | YAMN_ACC_MSGP }; SendMessage(hMailBrowser, WM_YAMN_CHANGECONTENT, (WPARAM)MailParam->account, (LPARAM)&Params); @@ -1404,7 +1404,7 @@ void __cdecl ShowEmailThread(void *Param) else { CREADTEVIEWMESSAGEWINDOW: MyParam->mail->MsgWindow = CreateDialogParamW(g_plugin.getInst(), MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE), nullptr, DlgProcYAMNShowMessage, (LPARAM)MyParam); - WindowList_Add(YAMNVar.MessageWnds, MyParam->mail->MsgWindow); + WindowList_Add(MessageWnds, MyParam->mail->MsgWindow); MSG msg; while (GetMessage(&msg, nullptr, 0, 0)) { if (MyParam->mail->MsgWindow == nullptr || !IsDialogMessage(MyParam->mail->MsgWindow, &msg)) { /* Wine fix. */ @@ -1412,7 +1412,7 @@ CREADTEVIEWMESSAGEWINDOW: DispatchMessage(&msg); } } - WindowList_Remove(YAMNVar.MessageWnds, MyParam->mail->MsgWindow); + WindowList_Remove(MessageWnds, MyParam->mail->MsgWindow); MyParam->mail->MsgWindow = nullptr; } @@ -1521,8 +1521,8 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR sra.Uninit(); - WindowList_Add(YAMNVar.MessageWnds, hDlg); - WindowList_Add(YAMNVar.NewMailAccountWnd, hDlg, (UINT_PTR)ActualAccount); + WindowList_Add(MessageWnds, hDlg); + WindowList_Add(NewMailAccountWnd, hDlg, (UINT_PTR)ActualAccount); wchar_t accstatus[512]; GetStatusFcn(ActualAccount, accstatus); @@ -1556,7 +1556,7 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR SizeDate = ColInfo.cx; RECT coord; - if (!YAMNVar.Shutdown && GetWindowRect(hDlg, &coord)) // the YAMNVar.Shutdown testing is because MMessagesAccessSO); if (!swm.Succeeded()) @@ -2058,7 +2058,7 @@ static void __cdecl MailBrowser(void *Param) MyParam->nflags = MyParam->nflags & ~YAMN_ACC_POP; } - if (nullptr != (hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (UINT_PTR)ActualAccount))) + if (nullptr != (hMailBrowser = WindowList_Find(NewMailAccountWnd, (UINT_PTR)ActualAccount))) WndFound = TRUE; if ((hMailBrowser == nullptr) && ((MyParam->nflags & YAMN_ACC_MSG) || (MyParam->nflags & YAMN_ACC_ICO) || (MyParam->nnflags & YAMN_ACC_MSG))) { diff --git a/protocols/YAMN/src/main.cpp b/protocols/YAMN/src/main.cpp index ab7214294a..7522c4c0e8 100644 --- a/protocols/YAMN/src/main.cpp +++ b/protocols/YAMN/src/main.cpp @@ -22,7 +22,8 @@ BOOL UninstallPlugins; HANDLE hAccountFolder; -YAMN_VARIABLES YAMNVar; +MWindowList MessageWnds, NewMailAccountWnd; +bool g_bShutdown = false; CMPlugin g_plugin; @@ -171,9 +172,8 @@ int CMPlugin::Load() optDateTime = g_plugin.getByte(YAMN_DBTIMEOPTIONS, optDateTime); // Create new window queues for broadcast messages - YAMNVar.MessageWnds = WindowList_Create(); - YAMNVar.NewMailAccountWnd = WindowList_Create(); - YAMNVar.Shutdown = FALSE; + MessageWnds = WindowList_Create(); + NewMailAccountWnd = WindowList_Create(); hCurSplitNS = LoadCursor(nullptr, IDC_SIZENS); hCurSplitWE = LoadCursor(nullptr, IDC_SIZEWE); @@ -214,8 +214,8 @@ int CMPlugin::Unload() UnInitDebug(); #endif - WindowList_Destroy(YAMNVar.MessageWnds); - WindowList_Destroy(YAMNVar.NewMailAccountWnd); + WindowList_Destroy(MessageWnds); + WindowList_Destroy(NewMailAccountWnd); DestroyCursor(hCurSplitNS); DestroyCursor(hCurSplitWE); diff --git a/protocols/YAMN/src/proto/pop3/pop3opt.cpp b/protocols/YAMN/src/proto/pop3/pop3opt.cpp index f557f6daa7..c50a89cd2a 100644 --- a/protocols/YAMN/src/proto/pop3/pop3opt.cpp +++ b/protocols/YAMN/src/proto/pop3/pop3opt.cpp @@ -232,7 +232,7 @@ static INT_PTR CALLBACK DlgProcPOP3AccStatusOpt(HWND hDlg, UINT msg, WPARAM wPar iShift <<= 1; } - WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGESTATUSOPTION, 0, 0); + WindowList_BroadcastAsync(MessageWnds, WM_YAMN_CHANGESTATUSOPTION, 0, 0); EndDialog(hDlg, 0); DestroyWindow(hDlg); break; @@ -355,7 +355,7 @@ public: ActualAccount = nullptr; SendMessage(GetParent(m_hwnd), PSM_UNCHANGED, (WPARAM)m_hwnd, 0); - WindowList_Add(YAMNVar.MessageWnds, m_hwnd); + WindowList_Add(MessageWnds, m_hwnd); return true; } @@ -539,7 +539,7 @@ public: void OnDestroy() override { - WindowList_Remove(YAMNVar.MessageWnds, m_hwnd); + WindowList_Remove(MessageWnds, m_hwnd); } INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override @@ -829,7 +829,7 @@ public: bool OnInitDialog() override { - WindowList_Add(YAMNVar.MessageWnds, m_hwnd); + WindowList_Add(MessageWnds, m_hwnd); DlgEnableAccountPopup(false); DlgShowAccountPopup(); @@ -848,7 +848,7 @@ public: void OnDestroy() override { - WindowList_Remove(YAMNVar.MessageWnds, m_hwnd); + WindowList_Remove(MessageWnds, m_hwnd); } void onSelChange_Account(CCtrlCombo *) diff --git a/protocols/YAMN/src/services.cpp b/protocols/YAMN/src/services.cpp index ee4476bf41..c7f1ea5f1c 100644 --- a/protocols/YAMN/src/services.cpp +++ b/protocols/YAMN/src/services.cpp @@ -168,7 +168,7 @@ int Shutdown(WPARAM, LPARAM) g_plugin.setDword(YAMN_DBMSGSIZEX, HeadSizeX); g_plugin.setDword(YAMN_DBMSGSIZEY, HeadSizeY); g_plugin.setWord(YAMN_DBMSGPOSSPLIT, HeadSplitPos); - YAMNVar.Shutdown = TRUE; + g_bShutdown = true; KillTimer(nullptr, SecTimer); UnregisterProtoPlugins(); diff --git a/protocols/YAMN/src/stdafx.h b/protocols/YAMN/src/stdafx.h index aa88d18df9..05be77a7dc 100644 --- a/protocols/YAMN/src/stdafx.h +++ b/protocols/YAMN/src/stdafx.h @@ -25,7 +25,6 @@ #include #include -#include #include #include "mails/decode.h" @@ -35,6 +34,7 @@ #include "protoplugin.h" #include "main.h" +#include "yamn.h" #include "debug.h" #include "resource.h" @@ -159,7 +159,10 @@ int Shutdown(WPARAM, LPARAM); // Executed before Miranda is going to shutdown extern wchar_t UserDirectory[]; // e.g. "F:\WINNT\Profiles\UserXYZ" extern wchar_t ProfileName[]; // e.g. "majvan" extern SWMRG *AccountBrowserSO; -extern YAMN_VARIABLES YAMNVar; +extern MWindowList MessageWnds; +extern MWindowList NewMailAccountWnd; +extern bool g_bShutdown; + extern HANDLE hNewMailHook; extern HCURSOR hCurSplitNS, hCurSplitWE; extern UINT SecTimer; diff --git a/protocols/YAMN/src/yamn.cpp b/protocols/YAMN/src/yamn.cpp index d95721e6fb..b30cc4411d 100644 --- a/protocols/YAMN/src/yamn.cpp +++ b/protocols/YAMN/src/yamn.cpp @@ -73,7 +73,7 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) isAccountCounting = TRUE; } - WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGETIME, (WPARAM)ActualAccount, (LPARAM)ActualAccount->TimeLeft); + WindowList_BroadcastAsync(MessageWnds, WM_YAMN_CHANGETIME, (WPARAM)ActualAccount, (LPARAM)ActualAccount->TimeLeft); if (!ActualAccount->TimeLeft) { ActualAccount->TimeLeft = ActualAccount->Interval; mir_forkthread((pThreadFunc)ActualAccount->Plugin->Fcn->TimeoutFcnPtr, new CheckParam(ActualAccount, YAMN_NORMALCHECK)); diff --git a/protocols/YAMN/src/yamn.h b/protocols/YAMN/src/yamn.h new file mode 100644 index 0000000000..8d47fb1606 --- /dev/null +++ b/protocols/YAMN/src/yamn.h @@ -0,0 +1,53 @@ +#ifndef __M_YAMN_H +#define __M_YAMN_H + +#include + +// +//================================== YAMN SERVICES ================================== +// + +//ForceCheck Service +//Check mail on accounts +//WPARAM- not used +//LPARAM- not used +#define MS_YAMN_FORCECHECK "YAMN/Service/ForceCheck" + +//Contact List Context Menu Click +//wParam=(WPARAM)hContact +//lParam=0 +// +//Event is fired when there is a double click on a CList contact, +//it is upto the caller to check for the protocol & status +//of the MCONTACT, it's not done for you anymore since it didn't make +//sense to store all this information in memory, etc. +#define MS_YAMN_CLISTCONTEXT "YAMN/Service/ClistContactContextMenu" + +//Contact List Context Menu Click for application +//wParam=(WPARAM)hContact +//lParam=0 +// +//Event is fired when there is a double click on a CList contact, +//it is upto the caller to check for the protocol & status +//of the MCONTACT, it's not done for you anymore since it didn't make +//sense to store all this information in memory, etc. +#define MS_YAMN_CLISTCONTEXTAPP "YAMN/Service/ClistContactContextMenuApp" + +//Contact List Double Click +//wParam=(WPARAM)hContact +//lParam=0 +// +//Event is fired when there is a double click on a CList contact, +//it is upto the caller to check for the protocol & status +//of the MCONTACT, it's not done for you anymore since it didn't make +//sense to store all this information in memory, etc. +#define MS_YAMN_CLISTDBLCLICK "YAMN/Service/ClistContactDoubleclicked" + +//NoNewMail Service +//runs no new mail procedure (shows popups e.g.) +//WPARAM- pointer to YAMN_NONEWMAILPARAM structure, data to no new mail procedure. You do not need to fill ThreadRunningEV event member. +//LPARAM- YAMN_NONEWMAILPARAM structure version param. Use YAMN_NONEWMAILVERSION definition. +//returns zero if failed, nonzero if succeed +#define MS_YAMN_NONEWMAILPROC "YAMN/Service/NoNewMailProc" + +#endif -- cgit v1.2.3