diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-07 17:50:35 +0200 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-07 18:07:33 +0200 |
commit | 1732a6b13f52b573cc4af91c2d9120c596e6bf78 (patch) | |
tree | 57e853c70f4bf51bfedbd8a50874746e5a3bc971 /plugins/Clist_nicer | |
parent | d1c9c916887e91a32d7794c83c37ff1c512660d9 (diff) |
PROTOACCOUNT::bIsLocked: lock status to be stored in memory
PROTOACCOUNT became a normal class with constructor & destructor
Diffstat (limited to 'plugins/Clist_nicer')
-rw-r--r-- | plugins/Clist_nicer/src/clui.cpp | 31 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/cluiframes.h | 13 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/statusbar.cpp | 7 |
3 files changed, 23 insertions, 28 deletions
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 8346228903..caa6b9b723 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -1634,23 +1634,27 @@ buttons_done: if (cfg::shutDown) return TRUE; + char *szProto = pd->RealName; + PROTOACCOUNT *pa = Proto_GetAccount(szProto); + if (pa == nullptr) + return TRUE; + int nParts = SendMessage(pcli->hwndStatus, SB_GETPARTS, 0, 0); SIZE textSize; BYTE showOpts = db_get_b(NULL, "CLUI", "SBarShow", 1); - char *szProto = pd->RealName; - int status = Proto_GetStatus(szProto); + SetBkMode(dis->hDC, TRANSPARENT); int x = dis->rcItem.left; if (showOpts & 1) { HICON hIcon; - if (status >= ID_STATUS_CONNECTING && status < ID_STATUS_OFFLINE) { + if (pa->iRealStatus >= ID_STATUS_CONNECTING && pa->iRealStatus < ID_STATUS_OFFLINE) { char szBuffer[128]; mir_snprintf(szBuffer, "%s_conn", pd->RealName); hIcon = IcoLib_GetIcon(szBuffer); } - else if (cfg::dat.bShowXStatusOnSbar && status > ID_STATUS_OFFLINE) { + else if (cfg::dat.bShowXStatusOnSbar && pa->iRealStatus > ID_STATUS_OFFLINE) { int xStatus; CUSTOM_STATUS cst = { sizeof(cst) }; cst.flags = CSSF_MASK_STATUS; @@ -1658,10 +1662,9 @@ buttons_done: if (ProtoServiceExists(pd->RealName, PS_GETCUSTOMSTATUSEX) && !CallProtoService(pd->RealName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cst) && xStatus > 0) hIcon = (HICON)CallProtoService(pd->RealName, PS_GETCUSTOMSTATUSICON, 0, LR_SHARED); // get OWN xStatus icon (if set) else - hIcon = Skin_LoadProtoIcon(szProto, status); + hIcon = Skin_LoadProtoIcon(szProto, pa->iRealStatus); } - else - hIcon = Skin_LoadProtoIcon(szProto, status); + else hIcon = Skin_LoadProtoIcon(szProto, pa->iRealStatus); if (!(showOpts & 6) && cfg::dat.bEqualSections) x = (dis->rcItem.left + dis->rcItem.right - 16) >> 1; @@ -1673,7 +1676,7 @@ buttons_done: IcoLib_ReleaseIcon(hIcon); if (db_get_b(NULL, "CLUI", "sbar_showlocked", 1)) { - if (db_get_b(NULL, szProto, "LockMainStatus", 0)) { + if (pa->bIsLocked) { hIcon = Skin_LoadIcon(SKINICON_OTHER_STATUS_LOCKED); if (hIcon != nullptr) { DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - 16) >> 1, hIcon, 16, 16, 0, nullptr, DI_NORMAL); @@ -1693,22 +1696,16 @@ buttons_done: if (showOpts & 2) { wchar_t szName[64]; - PROTOACCOUNT *pa = Proto_GetAccount(szProto); - if (pa) { - mir_wstrncpy(szName, pa->tszAccountName, _countof(szName)); - szName[_countof(szName) - 1] = 0; - } - else - szName[0] = 0; + wcsncpy_s(szName, pa->tszAccountName, _TRUNCATE); - if (mir_wstrlen(szName) < sizeof(szName) - 1) + if (mir_wstrlen(szName) < _countof(szName) - 1) mir_wstrcat(szName, L" "); GetTextExtentPoint32(dis->hDC, szName, (int)mir_wstrlen(szName), &textSize); TextOut(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, szName, (int)mir_wstrlen(szName)); x += textSize.cx; } if (showOpts & 4) { - wchar_t *szStatus = Clist_GetStatusModeDescription(status, 0); + wchar_t *szStatus = Clist_GetStatusModeDescription(pa->iRealStatus, 0); GetTextExtentPoint32(dis->hDC, szStatus, (int)mir_wstrlen(szStatus), &textSize); TextOut(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, szStatus, (int)mir_wstrlen(szStatus)); } diff --git a/plugins/Clist_nicer/src/cluiframes.h b/plugins/Clist_nicer/src/cluiframes.h index 3f3d79687a..60e9ce7948 100644 --- a/plugins/Clist_nicer/src/cluiframes.h +++ b/plugins/Clist_nicer/src/cluiframes.h @@ -27,22 +27,19 @@ int UnLoadCLUIFramesModule(void); int CLUIFramesGetMinHeight();
int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam);
int SizeFramesByWindowRect(RECT *r);
-int CLUIFramesResizeFrames(RECT *rc);
-typedef struct tagProtocolData {
+struct ProtocolData
+{
char *RealName;
int protopos;
boolean show;
-} ProtocolData;
+};
-typedef struct
+struct SortData
{
int order;
int realpos;
-}SortData;
-
-
-
+};
//============
#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign"
diff --git a/plugins/Clist_nicer/src/statusbar.cpp b/plugins/Clist_nicer/src/statusbar.cpp index c8b5d443ed..47ddaf4948 100644 --- a/plugins/Clist_nicer/src/statusbar.cpp +++ b/plugins/Clist_nicer/src/statusbar.cpp @@ -155,11 +155,12 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (NotifyEventHooks(hStatusBarShowToolTipEvent, (WPARAM)PD->RealName, 0) > 0) // a plugin handled this event
tooltip_active = TRUE;
else if (db_get_dw(NULL, "mToolTip", "ShowStatusTip", 0)) {
- int wStatus = Proto_GetStatus(PD->RealName);
- BYTE isLocked = db_get_b(NULL, PD->RealName, "LockMainStatus", 0);
+ PROTOACCOUNT *pa = Proto_GetAccount(PD->RealName);
+ if (pa == nullptr)
+ break;
wchar_t szTipText[256];
- mir_snwprintf(szTipText, L"<b>%s</b>: %s%s", PD->RealName, Clist_GetStatusModeDescription(wStatus, 0), isLocked ? L" (LOCKED)" : L"");
+ mir_snwprintf(szTipText, L"<b>%s</b>: %s%s", PD->RealName, Clist_GetStatusModeDescription(pa->iRealStatus, 0), pa->bIsLocked ? L" (LOCKED)" : L"");
CLCINFOTIP ti = { sizeof(ti) };
ti.isTreeFocused = (GetFocus() == pcli->hwndContactList);
|