From 609c3041668b36bc6abfa9511aa4e197bf0060ff Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 7 Apr 2018 13:51:06 +0300 Subject: duplicate ME_PROTO_ACK handlers merged together --- plugins/Clist_modern/src/modern_clc.cpp | 15 ++------- plugins/Clist_modern/src/modern_clisttray.cpp | 45 +++++++++++---------------- plugins/Clist_nicer/src/statusbar.cpp | 5 ++- 3 files changed, 23 insertions(+), 42 deletions(-) (limited to 'plugins') diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 1230408ffb..371d7ce1f2 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1648,19 +1648,8 @@ int ClcUnloadModule() int ClcDoProtoAck(ACKDATA *ack) { if (MirandaExiting()) return 0; - if (ack->type == ACKTYPE_STATUS) { - if (ack->result == ACKRESULT_SUCCESS) { - for (int i = 0; i < pcli->hClcProtoCount; i++) { - if (!mir_strcmp(pcli->clcProto[i].szProto, ack->szModule)) { - pcli->clcProto[i].dwStatus = (WORD)ack->lParam; - if (pcli->clcProto[i].dwStatus >= ID_STATUS_OFFLINE) - Clist_TrayIconUpdateBase(pcli->clcProto[i].szProto); - return 0; - } - } - } - } - else if (ack->type == ACKTYPE_AWAYMSG) { + + if (ack->type == ACKTYPE_AWAYMSG) { if (ack->result == ACKRESULT_SUCCESS && ack->lParam) { if (ack->szModule != nullptr) if (db_get_b(ack->hContact, ack->szModule, "ChatRoom", 0) != 0) diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 40e25870c9..2e553b55f0 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -57,37 +57,33 @@ char* g_szConnectingProto = nullptr; int GetStatusVal(int status) { + if (IsStatusConnecting(status)) // 'connecting' status has the top priority + return 600; + switch (status) { - case ID_STATUS_OFFLINE: return 50; - case ID_STATUS_ONLINE: return 100; - case ID_STATUS_FREECHAT: return 110; - case ID_STATUS_INVISIBLE: return 120; - case ID_STATUS_AWAY: return 200; - case ID_STATUS_DND: return 210; - case ID_STATUS_NA: return 220; - case ID_STATUS_OCCUPIED: return 230; - case ID_STATUS_ONTHEPHONE: return 400; - case ID_STATUS_OUTTOLUNCH: return 410; + case ID_STATUS_OFFLINE: return 50; + case ID_STATUS_ONLINE: return 100; + case ID_STATUS_FREECHAT: return 110; + case ID_STATUS_INVISIBLE: return 120; + case ID_STATUS_AWAY: return 200; + case ID_STATUS_DND: return 210; + case ID_STATUS_NA: return 220; + case ID_STATUS_OCCUPIED: return 230; + case ID_STATUS_ONTHEPHONE: return 400; + case ID_STATUS_OUTTOLUNCH: return 410; } - if (status > 0 && status < ID_STATUS_OFFLINE) - return 600; // 'connecting' status has the top priority return 0; } -int GetStatusOrder(int currentStatus, int newStatus) -{ - int current = GetStatusVal(currentStatus); - int newstat = GetStatusVal(newStatus); - return (current > newstat) ? currentStatus : newStatus; -} - INT_PTR CListTray_GetGlobalStatus(WPARAM, LPARAM) { g_szConnectingProto = nullptr; int curstatus = 0; int connectingCount = 0; + g_bMultiConnectionMode = false; + for (int i = 0; i < pcli->hClcProtoCount; i++) { ClcProtoStatus &p = pcli->clcProto[i]; if (!Clist_GetProtocolVisibility(p.szProto)) @@ -97,16 +93,13 @@ INT_PTR CListTray_GetGlobalStatus(WPARAM, LPARAM) connectingCount++; if (connectingCount == 1) g_szConnectingProto = p.szProto; + else + g_bMultiConnectionMode = true; } - else curstatus = GetStatusOrder(curstatus, p.dwStatus); + else if (GetStatusVal(p.dwStatus) > GetStatusVal(curstatus)) + curstatus = p.dwStatus; } - if (connectingCount == 0) - g_bMultiConnectionMode = FALSE; - else if (connectingCount > 1) - g_bMultiConnectionMode = TRUE; - else - g_bMultiConnectionMode = FALSE; return curstatus ? curstatus : ID_STATUS_OFFLINE; } diff --git a/plugins/Clist_nicer/src/statusbar.cpp b/plugins/Clist_nicer/src/statusbar.cpp index 16ab1a814f..d1e1789c81 100644 --- a/plugins/Clist_nicer/src/statusbar.cpp +++ b/plugins/Clist_nicer/src/statusbar.cpp @@ -87,7 +87,6 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM HDC hdc = BeginPaint(hwnd, &ps); HDC hdcMem = CreateCompatibleDC(hdc); RECT rcClient, rcWindow; - DRAWITEMSTRUCT dis = { 0 }; BYTE windowStyle = db_get_b(NULL, "CLUI", "WindowStyle", SETTING_WINDOWSTYLE_DEFAULT); LONG b_offset = cfg::dat.bClipBorder + (windowStyle == SETTING_WINDOWSTYLE_NOBORDER ? 2 : (windowStyle == SETTING_WINDOWSTYLE_THINBORDER ? 1 : 0)); @@ -113,9 +112,9 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM item->CORNER, item->BORDERSTYLE, item->imageItem); SetTextColor(hdcMem, item->TEXTCOLOR); } - else - SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT)); + else SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT)); + DRAWITEMSTRUCT dis = { 0 }; dis.hwndItem = hwnd; dis.hDC = hdcMem; dis.CtlType = 0; -- cgit v1.2.3