diff options
author | George Hazan <george.hazan@gmail.com> | 2023-10-09 12:08:54 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-10-09 12:08:54 +0300 |
commit | cdd6ef2304db35998e3aae09774de2892846e63f (patch) | |
tree | 8a8e6886a207c8aee96843bb88813067febb1a07 /protocols/YAMN/src/browser | |
parent | acf268216b0a7a4a48856ae00e4c7f4ff54f7ea2 (diff) |
fixes #3718 (YAMN: неизвестный контакт)
Diffstat (limited to 'protocols/YAMN/src/browser')
-rw-r--r-- | protocols/YAMN/src/browser/mailbrowser.cpp | 133 |
1 files changed, 48 insertions, 85 deletions
diff --git a/protocols/YAMN/src/browser/mailbrowser.cpp b/protocols/YAMN/src/browser/mailbrowser.cpp index 3284293754..727110be89 100644 --- a/protocols/YAMN/src/browser/mailbrowser.cpp +++ b/protocols/YAMN/src/browser/mailbrowser.cpp @@ -753,29 +753,24 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa }
else {
hContact = PUGetContact(hWnd);
-
- DBVARIANT dbv;
- if (!g_plugin.getString(hContact, "Id", &dbv)) {
- Account = FindAccountByName(POP3Plugin, dbv.pszVal);
- db_free(&dbv);
- }
- else Account = (CAccount *)hContact; //????
-
- SReadGuard sra(Account->AccountAccessSO);
- if (sra.Succeeded()) {
- switch (msg) {
- case WM_COMMAND:
- {
- YAMN_MAILBROWSERPARAM Param = { Account,
- (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG,
- (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG };
-
- RunMailBrowser(&Param);
+ if (Account = FindAccountByContact(POP3Plugin, hContact)) {
+ SReadGuard sra(Account->AccountAccessSO);
+ if (sra.Succeeded()) {
+ switch (msg) {
+ case WM_COMMAND:
+ {
+ YAMN_MAILBROWSERPARAM Param = { Account,
+ (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG,
+ (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG };
+
+ RunMailBrowser(&Param);
+ }
+ break;
}
- break;
}
}
}
+
if ((Account->NewMailN.Flags & YAMN_ACC_CONT) && !(Account->NewMailN.Flags & YAMN_ACC_CONTNOEVENT))
Clist_RemoveEvent(hContact, hContact);
}
@@ -784,41 +779,29 @@ LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa case WM_CONTEXTMENU:
PUDeletePopup(hWnd);
break;
+
case UM_FREEPLUGINDATA:
- {
- auto *mpd = (YAMN_MAILSHOWPARAM *)PUGetPluginData(hWnd);
- delete mpd;
- return FALSE;
- }
+ delete (YAMN_MAILSHOWPARAM *)PUGetPluginData(hWnd);
+ return FALSE;
+
case UM_INITPOPUP:
- //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
+ // This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
WindowList_Add(YAMNVar.MessageWnds, hWnd);
break;
+
case UM_DESTROYPOPUP:
WindowList_Remove(YAMNVar.MessageWnds, hWnd);
break;
- case WM_YAMN_STOPACCOUNT:
- {
- CAccount *ActualAccount;
- DBVARIANT dbv;
-
- MCONTACT hContact = PUGetContact(hWnd);
- if (!g_plugin.getString(hContact, "Id", &dbv)) {
- ActualAccount = FindAccountByName(POP3Plugin, dbv.pszVal);
- db_free(&dbv);
- }
- else ActualAccount = (CAccount *)hContact;
-
- if ((CAccount *)wParam != ActualAccount)
- break;
- DestroyWindow(hWnd);
- return 0;
- }
- case WM_NOTIFY:
- default:
- break;
+ case WM_YAMN_STOPACCOUNT:
+ MCONTACT hContact = PUGetContact(hWnd);
+ auto *ActualAccount = FindAccountByContact(POP3Plugin, hContact);
+ if ((CAccount *)wParam != ActualAccount)
+ break;
+ DestroyWindow(hWnd);
+ return 0;
}
+
return DefWindowProc(hWnd, msg, wParam, lParam);
}
@@ -828,31 +811,18 @@ LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l case WM_COMMAND:
if ((HIWORD(wParam) == STN_CLICKED) && (msg == WM_COMMAND)) {
MCONTACT hContact = PUGetContact(hWnd);
+ if (CAccount *ActualAccount = FindAccountByContact(POP3Plugin, hContact)) {
+ SReadGuard sra(ActualAccount->AccountAccessSO);
+ if (sra.Succeeded() && msg == WM_COMMAND) {
+ YAMN_MAILBROWSERPARAM Param = { ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, nullptr };
- DBVARIANT dbv;
- CAccount *ActualAccount;
- if (!g_plugin.getString(hContact, "Id", &dbv)) {
- ActualAccount = FindAccountByName(POP3Plugin, dbv.pszVal);
- db_free(&dbv);
- }
- else ActualAccount = (CAccount *)hContact;
-
- SReadGuard sra(ActualAccount->AccountAccessSO);
- if (sra.Succeeded()) {
- switch (msg) {
- case WM_COMMAND:
- {
- 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_POP;
+ 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_POP;
+ Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nflags = Param.nflags & ~YAMN_ACC_POP;
- RunMailBrowser(&Param);
- }
- break;
+ RunMailBrowser(&Param);
}
}
PUDeletePopup(hWnd);
@@ -864,35 +834,28 @@ LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l break;
case UM_FREEPLUGINDATA:
- //Here we'd free our own data, if we had it.
+ // Here we'd free our own data, if we had it.
return FALSE;
+
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);
break;
+
case UM_DESTROYPOPUP:
WindowList_Remove(YAMNVar.MessageWnds, hWnd);
break;
- case WM_YAMN_STOPACCOUNT:
- {
- CAccount *ActualAccount;
- DBVARIANT dbv;
-
- MCONTACT hContact = PUGetContact(hWnd);
-
- if (!g_plugin.getString(hContact, "Id", &dbv)) {
- ActualAccount = FindAccountByName(POP3Plugin, dbv.pszVal);
- db_free(&dbv);
- }
- else ActualAccount = (CAccount *)hContact;
- if ((CAccount *)wParam != ActualAccount)
- break;
+ case WM_YAMN_STOPACCOUNT:
+ MCONTACT hContact = PUGetContact(hWnd);
+ CAccount *ActualAccount = FindAccountByContact(POP3Plugin, hContact);
+ if ((CAccount *)wParam != ActualAccount)
+ break;
- DestroyWindow(hWnd);
- return 0;
- }
+ DestroyWindow(hWnd);
+ return 0;
}
+
return DefWindowProc(hWnd, msg, wParam, lParam);
}
|