diff options
author | George Hazan <ghazan@miranda.im> | 2022-12-12 18:47:54 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-12-12 18:47:54 +0300 |
commit | 4f08da9b494ead16c6cf47d4734d41f32a505f59 (patch) | |
tree | 1f48ac68dea16e5b7a9376b1a860d21feaa6e890 /protocols | |
parent | 2c5e5c31121144b1326e09fbd680b4258f42328d (diff) |
fixes #3259 (YAMN: выводить настроенную учётку вместо пустой)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/YAMN/src/main.cpp | 4 | ||||
-rw-r--r-- | protocols/YAMN/src/main.h | 44 | ||||
-rw-r--r-- | protocols/YAMN/src/proto/pop3/pop3comm.cpp | 8 | ||||
-rw-r--r-- | protocols/YAMN/src/proto/pop3/pop3opt.cpp | 97 | ||||
-rw-r--r-- | protocols/YAMN/src/services.cpp | 19 | ||||
-rw-r--r-- | protocols/YAMN/src/stdafx.h | 4 |
6 files changed, 60 insertions, 116 deletions
diff --git a/protocols/YAMN/src/main.cpp b/protocols/YAMN/src/main.cpp index c3971e012a..ee7f6da5a1 100644 --- a/protocols/YAMN/src/main.cpp +++ b/protocols/YAMN/src/main.cpp @@ -18,8 +18,6 @@ wchar_t UserDirectory[MAX_PATH]; wchar_t szMirandaDir[MAX_PATH]; wchar_t szProfileDir[MAX_PATH]; -int YAMN_STATUS; - BOOL UninstallPlugins; HANDLE hAccountFolder; @@ -209,8 +207,6 @@ static void LoadPlugins() int CMPlugin::Load() { - YAMN_STATUS = ID_STATUS_OFFLINE; - // we get the Miranda Root Path PathToAbsoluteW(L".", szMirandaDir); diff --git a/protocols/YAMN/src/main.h b/protocols/YAMN/src/main.h index b0cb0ed4f0..5190b26df2 100644 --- a/protocols/YAMN/src/main.h +++ b/protocols/YAMN/src/main.h @@ -1,31 +1,31 @@ #ifndef __MAIN_H #define __MAIN_H -#define YAMN_NEWMAILSNDDESC LPGENW("New mail message") -#define YAMN_CONNECTFAILSNDDESC LPGENW("Connect failed") -#define YAMN_CONNECTFAILSOUND "YAMN/Sound/ConnectFail" -#define YAMN_NEWMAILSOUND "YAMN/Sound/NewMail" - -#define YAMN_DBMODULE "YAMN" -#define YAMN_DBPOSX "MailBrowserWinX" -#define YAMN_DBPOSY "MailBrowserWinY" -#define YAMN_DBSIZEX "MailBrowserWinW" -#define YAMN_DBSIZEY "MailBrowserWinH" -#define YAMN_DBMSGPOSX "MailMessageWinX" -#define YAMN_DBMSGPOSY "MailMessageWinY" -#define YAMN_DBMSGSIZEX "MailMessageWinW" -#define YAMN_DBMSGSIZEY "MailMessageWinH" -#define YAMN_DBMSGPOSSPLIT "MailMessageSplitY" -#define YAMN_TTBFCHECK "ForceCheckTTB" -#define YAMN_CLOSEDELETE "CloseOnDelete" -#define YAMN_SHOWASPROTO "ShowAsProtcol" -#define YAMN_DBTIMEOPTIONS "MailBrowserTimeOpts" +#define YAMN_NEWMAILSNDDESC LPGENW("New mail message") +#define YAMN_CONNECTFAILSNDDESC LPGENW("Connect failed") +#define YAMN_CONNECTFAILSOUND "YAMN/Sound/ConnectFail" +#define YAMN_NEWMAILSOUND "YAMN/Sound/NewMail" + +#define YAMN_DBMODULE "YAMN" +#define YAMN_DBPOSX "MailBrowserWinX" +#define YAMN_DBPOSY "MailBrowserWinY" +#define YAMN_DBSIZEX "MailBrowserWinW" +#define YAMN_DBSIZEY "MailBrowserWinH" +#define YAMN_DBMSGPOSX "MailMessageWinX" +#define YAMN_DBMSGPOSY "MailMessageWinY" +#define YAMN_DBMSGSIZEX "MailMessageWinW" +#define YAMN_DBMSGSIZEY "MailMessageWinH" +#define YAMN_DBMSGPOSSPLIT "MailMessageSplitY" +#define YAMN_TTBFCHECK "ForceCheckTTB" +#define YAMN_CLOSEDELETE "CloseOnDelete" +#define YAMN_SHOWASPROTO "ShowAsProtcol" +#define YAMN_DBTIMEOPTIONS "MailBrowserTimeOpts" #define YAMN_DEFAULTHK MAKEWORD(VK_F11,MOD_CONTROL) -#define SHOWDATELONG 0x01 -#define SHOWDATENOTODAY 0x02 -#define SHOWDATENOSECONDS 0x04 +#define SHOWDATELONG 0x01 +#define SHOWDATENOTODAY 0x02 +#define SHOWDATENOSECONDS 0x04 extern unsigned char optDateTime; diff --git a/protocols/YAMN/src/proto/pop3/pop3comm.cpp b/protocols/YAMN/src/proto/pop3/pop3comm.cpp index 46acb25c4a..cd513f6a70 100644 --- a/protocols/YAMN/src/proto/pop3/pop3comm.cpp +++ b/protocols/YAMN/src/proto/pop3/pop3comm.cpp @@ -269,12 +269,10 @@ LBL_Error: break; } - CAccount *Finder; - DBVARIANT dbv; - - for (Finder = POP3Plugin->FirstAccount; Finder != nullptr; Finder = Finder->Next) { + for (CAccount *Finder = POP3Plugin->FirstAccount; Finder != nullptr; Finder = Finder->Next) { Finder->hContact = NULL; for (auto &hContact : Contacts(YAMN_DBMODULE)) { + DBVARIANT dbv; if (!g_plugin.getString(hContact, "Id", &dbv)) { if (mir_strcmp(dbv.pszVal, Finder->Name) == 0) { Finder->hContact = hContact; @@ -296,7 +294,7 @@ LBL_Error: Proto_AddToContact(Finder->hContact, YAMN_DBMODULE); g_plugin.setString(Finder->hContact, "Id", Finder->Name); g_plugin.setString(Finder->hContact, "Nick", Finder->Name); - g_plugin.setWord(Finder->hContact, "Status", YAMN_STATUS); + g_plugin.setWord(Finder->hContact, "Status", ID_STATUS_OFFLINE); } } diff --git a/protocols/YAMN/src/proto/pop3/pop3opt.cpp b/protocols/YAMN/src/proto/pop3/pop3opt.cpp index 1a52476674..78df161e27 100644 --- a/protocols/YAMN/src/proto/pop3/pop3opt.cpp +++ b/protocols/YAMN/src/proto/pop3/pop3opt.cpp @@ -267,6 +267,8 @@ class CAccOptDlg : public CBaseOptionsDlg void DlgEnableAccount(bool bEnable) { + cmbAccount.Enable(POP3Plugin->FirstAccount != nullptr); + EnableWindow(GetDlgItem(m_hwnd, IDC_CHECK), bEnable); EnableWindow(GetDlgItem(m_hwnd, IDC_EDITSERVER), bEnable); EnableWindow(GetDlgItem(m_hwnd, IDC_EDITNAME), bEnable); @@ -345,11 +347,12 @@ public: // Fill accounts WaitToReadSO(POP3Plugin->AccountBrowserSO); - + for (ActualAccount = (HPOP3ACCOUNT)POP3Plugin->FirstAccount; ActualAccount != nullptr; ActualAccount = (HPOP3ACCOUNT)ActualAccount->Next) if (ActualAccount->Name != nullptr) cmbAccount.AddStringA(ActualAccount->Name); - cmbAccount.Enable(POP3Plugin->FirstAccount != nullptr); + cmbAccount.SetCurSel(0); + ReadDoneSO(POP3Plugin->AccountBrowserSO); // Fill code pages @@ -425,7 +428,7 @@ public: void onSelChange_Account(CCtrlCombo *) { - if (CB_ERR != (Result = SendDlgItemMessage(m_hwnd, IDC_COMBOACCOUNT, CB_GETCURSEL, 0, 0))) + if (CB_ERR != (Result = cmbAccount.GetCurSel())) SendDlgItemMessageA(m_hwnd, IDC_COMBOACCOUNT, CB_GETLBTEXT, (WPARAM)Result, (LPARAM)DlgInput); if ((Result == CB_ERR) || (nullptr == (ActualAccount = (HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)DlgInput)))) { @@ -550,46 +553,42 @@ public: { char Text[MAX_PATH]; wchar_t TextW[MAX_PATH]; - BOOL Translated, NewAcc = FALSE, Check, CheckMsg, CheckSnd, CheckIco, CheckApp, CheckAPOP; - BOOL CheckNMsgP, CheckFMsg, CheckFSnd, CheckFIco; - BOOL CheckKBN, CheckContact, CheckContactNick, CheckContactNoEvent; - BOOL CheckSSL, CheckABody, CheckNoTLS; - BOOL CheckStart, CheckForce; + BOOL Translated, NewAcc = FALSE; size_t Length, index; - UINT Port, Interval; if (!GetDlgItemTextA(m_hwnd, IDC_COMBOACCOUNT, Text, _countof(Text))) return false; - Check = (IsDlgButtonChecked(m_hwnd, IDC_CHECK) == BST_CHECKED); - CheckSSL = (IsDlgButtonChecked(m_hwnd, IDC_CHECKSSL) == BST_CHECKED); - CheckNoTLS = (IsDlgButtonChecked(m_hwnd, IDC_CHECKNOTLS) == BST_CHECKED); - CheckAPOP = (IsDlgButtonChecked(m_hwnd, IDC_CHECKAPOP) == BST_CHECKED); + BOOL Check = (IsDlgButtonChecked(m_hwnd, IDC_CHECK) == BST_CHECKED); + BOOL CheckSSL = (IsDlgButtonChecked(m_hwnd, IDC_CHECKSSL) == BST_CHECKED); + BOOL CheckNoTLS = (IsDlgButtonChecked(m_hwnd, IDC_CHECKNOTLS) == BST_CHECKED); + BOOL CheckAPOP = (IsDlgButtonChecked(m_hwnd, IDC_CHECKAPOP) == BST_CHECKED); - CheckABody = (IsDlgButtonChecked(m_hwnd, IDC_AUTOBODY) == BST_CHECKED); - CheckMsg = (IsDlgButtonChecked(m_hwnd, IDC_CHECKMSG) == BST_CHECKED); - CheckSnd = (IsDlgButtonChecked(m_hwnd, IDC_CHECKSND) == BST_CHECKED); - CheckIco = (IsDlgButtonChecked(m_hwnd, IDC_CHECKICO) == BST_CHECKED); + BOOL CheckABody = (IsDlgButtonChecked(m_hwnd, IDC_AUTOBODY) == BST_CHECKED); + BOOL CheckMsg = (IsDlgButtonChecked(m_hwnd, IDC_CHECKMSG) == BST_CHECKED); + BOOL CheckSnd = (IsDlgButtonChecked(m_hwnd, IDC_CHECKSND) == BST_CHECKED); + BOOL CheckIco = (IsDlgButtonChecked(m_hwnd, IDC_CHECKICO) == BST_CHECKED); - CheckApp = (IsDlgButtonChecked(m_hwnd, IDC_CHECKAPP) == BST_CHECKED); - CheckKBN = (IsDlgButtonChecked(m_hwnd, IDC_CHECKKBN) == BST_CHECKED); - CheckContact = (IsDlgButtonChecked(m_hwnd, IDC_CHECKCONTACT) == BST_CHECKED); - CheckContactNick = (IsDlgButtonChecked(m_hwnd, IDC_CHECKCONTACTNICK) == BST_CHECKED); - CheckContactNoEvent = (IsDlgButtonChecked(m_hwnd, IDC_CHECKCONTACTNOEVENT) == BST_CHECKED); + BOOL CheckApp = (IsDlgButtonChecked(m_hwnd, IDC_CHECKAPP) == BST_CHECKED); + BOOL CheckKBN = (IsDlgButtonChecked(m_hwnd, IDC_CHECKKBN) == BST_CHECKED); + BOOL CheckContact = (IsDlgButtonChecked(m_hwnd, IDC_CHECKCONTACT) == BST_CHECKED); + BOOL CheckContactNick = (IsDlgButtonChecked(m_hwnd, IDC_CHECKCONTACTNICK) == BST_CHECKED); + BOOL CheckContactNoEvent = (IsDlgButtonChecked(m_hwnd, IDC_CHECKCONTACTNOEVENT) == BST_CHECKED); - CheckFSnd = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFSND) == BST_CHECKED); - CheckFMsg = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFMSG) == BST_CHECKED); - CheckFIco = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFICO) == BST_CHECKED); + BOOL CheckFSnd = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFSND) == BST_CHECKED); + BOOL CheckFMsg = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFMSG) == BST_CHECKED); + BOOL CheckFIco = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFICO) == BST_CHECKED); - CheckNMsgP = (IsDlgButtonChecked(m_hwnd, IDC_CHECKNMSGP) == BST_CHECKED); + BOOL CheckNMsgP = (IsDlgButtonChecked(m_hwnd, IDC_CHECKNMSGP) == BST_CHECKED); - Port = GetDlgItemInt(m_hwnd, IDC_EDITPORT, &Translated, FALSE); + UINT Port = GetDlgItemInt(m_hwnd, IDC_EDITPORT, &Translated, FALSE); if (!Translated) { MessageBox(m_hwnd, TranslateT("This is not a valid number value"), TranslateT("Input error"), MB_OK); SetFocus(GetDlgItem(m_hwnd, IDC_EDITPORT)); return false; } - Interval = GetDlgItemInt(m_hwnd, IDC_EDITINTERVAL, &Translated, FALSE); + + UINT Interval = GetDlgItemInt(m_hwnd, IDC_EDITINTERVAL, &Translated, FALSE); if (!Translated) { MessageBox(m_hwnd, TranslateT("This is not a valid number value"), TranslateT("Input error"), MB_OK); SetFocus(GetDlgItem(m_hwnd, IDC_EDITINTERVAL)); @@ -613,48 +612,20 @@ public: if (nullptr == (ActualAccount = (HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)Text))) { NewAcc = TRUE; - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:AccountBrowserSO-write wait\n"); - #endif WaitToWriteSO(POP3Plugin->AccountBrowserSO); - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:AccountBrowserSO-write enter\n"); - #endif if (nullptr == (ActualAccount = (HPOP3ACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT, (WPARAM)POP3Plugin, (LPARAM)YAMN_ACCOUNTVERSION))) { - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:AccountBrowserSO-write done\n"); - #endif WriteDoneSO(POP3Plugin->AccountBrowserSO); MessageBox(m_hwnd, TranslateT("Cannot allocate memory space for new account"), TranslateT("Memory error"), MB_OK); return false; - } + } + DlgEnableAccount(true); } - else { - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:AccountBrowserSO-write wait\n"); - #endif - //We have to get full access to AccountBrowser, so other iterating thrads cannot get new account until new account is right set + else { // We have to get full access to AccountBrowser, so other iterating thrads cannot get new account until new account is right set WaitToWriteSO(POP3Plugin->AccountBrowserSO); - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:AccountBrowserSO-write enter\n"); - #endif } - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:ActualAccountSO-write wait\n"); - #endif - if (WAIT_OBJECT_0 != WaitToWrite(ActualAccount)) { - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:ActualAccountSO-write wait failed\n"); - #endif - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:ActualBrowserSO-write done\n"); - #endif - WriteDoneSO(POP3Plugin->AccountBrowserSO); - } - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile, "Options:APPLY:ActualAccountSO-write enter\n"); - #endif + if (WAIT_OBJECT_0 != WaitToWrite(ActualAccount)) + WriteDoneSO(POP3Plugin->AccountBrowserSO); GetDlgItemTextA(m_hwnd, IDC_EDITNAME, Text, _countof(Text)); if (!(Length = mir_strlen(Text))) @@ -704,8 +675,8 @@ public: if (NewAcc) ActualAccount->TimeLeft = Interval * 60; - CheckStart = (IsDlgButtonChecked(m_hwnd, IDC_CHECKSTART) == BST_CHECKED); - CheckForce = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFORCE) == BST_CHECKED); + BOOL CheckStart = (IsDlgButtonChecked(m_hwnd, IDC_CHECKSTART) == BST_CHECKED); + BOOL CheckForce = (IsDlgButtonChecked(m_hwnd, IDC_CHECKFORCE) == BST_CHECKED); ActualAccount->Flags = (Check ? YAMN_ACC_ENA : 0) | diff --git a/protocols/YAMN/src/services.cpp b/protocols/YAMN/src/services.cpp index b89f76bf79..02b95590db 100644 --- a/protocols/YAMN/src/services.cpp +++ b/protocols/YAMN/src/services.cpp @@ -18,23 +18,6 @@ static INT_PTR Service_GetCaps(WPARAM wParam, LPARAM) return 0; } -static INT_PTR Service_GetStatus(WPARAM, LPARAM) -{ - return YAMN_STATUS; -} - -static INT_PTR Service_SetStatus(WPARAM wParam, LPARAM) -{ - int newstatus = (wParam != ID_STATUS_OFFLINE) ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; - if (newstatus != YAMN_STATUS) { - int oldstatus = YAMN_STATUS; - YAMN_STATUS = newstatus; - ProtoBroadcastAck(YAMN_DBMODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldstatus, newstatus); - } - return 0; - -} - static INT_PTR Service_GetName(WPARAM wParam, LPARAM lParam) { mir_strncpy((char *)lParam, YAMN_DBMODULE, wParam); @@ -346,8 +329,6 @@ void CreateServiceFunctions(void) { // Standard 'protocol' services CreateServiceFunction(YAMN_DBMODULE PS_GETCAPS, Service_GetCaps); - CreateServiceFunction(YAMN_DBMODULE PS_GETSTATUS, Service_GetStatus); - CreateServiceFunction(YAMN_DBMODULE PS_SETSTATUS, Service_SetStatus); CreateServiceFunction(YAMN_DBMODULE PS_GETNAME, Service_GetName); CreateServiceFunction(YAMN_DBMODULE PS_LOADICON, Service_LoadIcon); diff --git a/protocols/YAMN/src/stdafx.h b/protocols/YAMN/src/stdafx.h index 7bf16f3793..f822946aeb 100644 --- a/protocols/YAMN/src/stdafx.h +++ b/protocols/YAMN/src/stdafx.h @@ -237,9 +237,7 @@ extern char *iconDescs[]; extern char *iconNames[]; extern HIMAGELIST CSImages; -extern void __stdcall SSL_DebugLog(const char *fmt, ...); - -extern int YAMN_STATUS; +extern void __stdcall SSL_DebugLog(const char *fmt, ...); extern struct WndHandles *MessageWnd; |