diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-07 12:59:27 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-07 12:59:27 +0300 |
commit | 375c728e532139cb4ee4fe8c8266d511e5c9a289 (patch) | |
tree | 6706a48c42c64768e9f6463f1ee981a1fb5b72e6 /plugins/Clist_nicer | |
parent | a13189ef6cfc4d797074410c4bf3cf80495f951a (diff) |
Clist_GetRealStatus & Clist_GetGeneralizedStatus: common code moved to mir_app
Diffstat (limited to 'plugins/Clist_nicer')
-rw-r--r-- | plugins/Clist_nicer/src/clc.h | 1 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clcpaint.cpp | 69 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/cluiservices.cpp | 35 |
3 files changed, 15 insertions, 90 deletions
diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h index 2af07f523f..c7ccfd1c7f 100644 --- a/plugins/Clist_nicer/src/clc.h +++ b/plugins/Clist_nicer/src/clc.h @@ -383,7 +383,6 @@ size_t MY_pathToAbsolute(const wchar_t *pSrc, wchar_t *pOut); int GetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt);
void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst);
BYTE GetCachedStatusMsg(TExtraCache* p, char *szProto);
-int __fastcall GetStatusOnlineness(int status);
void GetExtendedInfo(ClcContact *contact, struct ClcData *dat);
LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void HideShowNotifyFrame();
diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp index 0db2306540..4b37de1d13 100644 --- a/plugins/Clist_nicer/src/clcpaint.cpp +++ b/plugins/Clist_nicer/src/clcpaint.cpp @@ -111,66 +111,7 @@ static void __inline SetHotTrackColour(HDC hdc, struct ClcData *dat) else SetTextColor(hdc, dat->hotTextColour);
}
-int __fastcall GetStatusOnlineness(int status)
-{
- if (status >= ID_STATUS_CONNECTING && status < ID_STATUS_OFFLINE)
- return 120;
-
- switch (status) {
- case ID_STATUS_FREECHAT:
- return 110;
- case ID_STATUS_ONLINE:
- return 100;
- case ID_STATUS_OCCUPIED:
- return 60;
- case ID_STATUS_ONTHEPHONE:
- return 50;
- case ID_STATUS_DND:
- return 40;
- case ID_STATUS_AWAY:
- return 30;
- case ID_STATUS_OUTTOLUNCH:
- return 20;
- case ID_STATUS_NA:
- return 10;
- case ID_STATUS_INVISIBLE:
- return 5;
- }
- return 0;
-}
-
-static int __fastcall GetGeneralisedStatus(void)
-{
- int status = ID_STATUS_OFFLINE, statusOnlineness = 0;
-
- for (int i = 0; i < pcli->hClcProtoCount; i++) {
- int thisStatus = pcli->clcProto[i].dwStatus;
- if (thisStatus == ID_STATUS_INVISIBLE)
- return ID_STATUS_INVISIBLE;
-
- int thisOnlineness = GetStatusOnlineness(thisStatus);
- if (thisOnlineness > statusOnlineness) {
- status = thisStatus;
- statusOnlineness = thisOnlineness;
- }
- }
- return status;
-}
-
-static int __fastcall GetRealStatus(ClcContact *contact, int status)
-{
- char *szProto = contact->proto;
- if (!szProto)
- return status;
-
- for (int i = 0; i < pcli->hClcProtoCount; i++)
- if (!mir_strcmp(pcli->clcProto[i].szProto, szProto))
- return pcli->clcProto[i].dwStatus;
-
- return status;
-}
-
-int GetBasicFontID(ClcContact * contact)
+int GetBasicFontID(ClcContact *contact)
{
switch (contact->type) {
case CLCIT_GROUP:
@@ -186,8 +127,8 @@ int GetBasicFontID(ClcContact * contact) if (contact->flags & CONTACTF_NOTONLIST)
return FONTID_NOTONLIST;
- if ((contact->flags&CONTACTF_INVISTO && GetRealStatus(contact, ID_STATUS_OFFLINE) != ID_STATUS_INVISIBLE)
- || (contact->flags&CONTACTF_VISTO && GetRealStatus(contact, ID_STATUS_OFFLINE) == ID_STATUS_INVISIBLE))
+ if ((contact->flags & CONTACTF_INVISTO && Clist_GetRealStatus(contact, ID_STATUS_OFFLINE) != ID_STATUS_INVISIBLE)
+ || (contact->flags & CONTACTF_VISTO && Clist_GetRealStatus(contact, ID_STATUS_OFFLINE) == ID_STATUS_INVISIBLE))
return contact->flags & CONTACTF_ONLINE ? FONTID_INVIS : FONTID_OFFINVIS;
return contact->flags & CONTACTF_ONLINE ? FONTID_CONTACTS : FONTID_OFFLINE;
@@ -489,7 +430,7 @@ set_bg_l: }
else if (type == CLCIT_CONTACT && flags & CONTACTF_NOTONLIST)
ChangeToFont(hdcMem, dat, FONTID_NOTONLIST, &fontHeight);
- else if (type == CLCIT_CONTACT && ((flags & CONTACTF_INVISTO && GetRealStatus(contact, my_status) != ID_STATUS_INVISIBLE) || (flags & CONTACTF_VISTO && GetRealStatus(contact, my_status) == ID_STATUS_INVISIBLE))) {
+ else if (type == CLCIT_CONTACT && ((flags & CONTACTF_INVISTO && Clist_GetRealStatus(contact, my_status) != ID_STATUS_INVISIBLE) || (flags & CONTACTF_VISTO && Clist_GetRealStatus(contact, my_status) == ID_STATUS_INVISIBLE))) {
// the contact is in the always visible list and the proto is invisible
// the contact is in the always invisible and the proto is in any other mode
ChangeToFont(hdcMem, dat, flags & CONTACTF_ONLINE ? FONTID_INVIS : FONTID_OFFINVIS, &fontHeight);
@@ -1264,7 +1205,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT *rcPaint) selBlend = db_get_b(NULL, "CLCExt", "EXBK_SelBlend", 1);
g_inCLCpaint = TRUE;
g_focusWnd = GetFocus();
- my_status = GetGeneralisedStatus();
+ my_status = Clist_GetGeneralizedStatus();
g_HDC = hdc;
/*
diff --git a/plugins/Clist_nicer/src/cluiservices.cpp b/plugins/Clist_nicer/src/cluiservices.cpp index bc2f0fbfd8..378d4a0db1 100644 --- a/plugins/Clist_nicer/src/cluiservices.cpp +++ b/plugins/Clist_nicer/src/cluiservices.cpp @@ -42,11 +42,10 @@ void FreeProtocolData(void) }
int g_maxStatus = ID_STATUS_OFFLINE;
-char g_maxProto[100] = "";
void CluiProtocolStatusChanged(int, const char*)
{
- int maxOnline = 0, onlineness = 0;
+ int maxOnline = 0;
WORD maxStatus = ID_STATUS_OFFLINE;
DBVARIANT dbv = { 0 };
int iIcon = 0;
@@ -63,7 +62,6 @@ void CluiProtocolStatusChanged(int, const char*) FreeProtocolData();
g_maxStatus = ID_STATUS_OFFLINE;
- g_maxProto[0] = 0;
int borders[3];
SendMessage(pcli->hwndStatus, SB_GETBORDERS, 0, (LPARAM)&borders);
@@ -148,7 +146,6 @@ void CluiProtocolStatusChanged(int, const char*) SendMessage(pcli->hwndStatus, SB_SETPARTS, partCount, (LPARAM)partWidths);
// count down since built in ones tend to go at the end
- char *szMaxProto = nullptr;
partCount = 0;
for (int i = 0; i < accs.getCount(); i++) {
int idx = Clist_GetAccountIndex(i);
@@ -163,23 +160,12 @@ void CluiProtocolStatusChanged(int, const char*) ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData));
PD->RealName = mir_strdup(pa->szModuleName);
PD->protopos = partCount;
- {
- int flags;
- flags = SBT_OWNERDRAW;
- if (db_get_b(NULL, "CLUI", "SBarBevel", 1) == 0)
- flags |= SBT_NOBORDERS;
- SendMessageA(pcli->hwndStatus, SB_SETTEXTA, partCount | flags, (LPARAM)PD);
- }
- int caps2 = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
- int caps1 = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
- if ((caps1 & PF1_IM) && (caps2 & (PF2_LONGAWAY | PF2_SHORTAWAY))) {
- onlineness = GetStatusOnlineness(status);
- if (onlineness > maxOnline) {
- maxStatus = status;
- maxOnline = onlineness;
- szMaxProto = pa->szModuleName;
- }
- }
+
+ int flags = SBT_OWNERDRAW;
+ if (db_get_b(NULL, "CLUI", "SBarBevel", 1) == 0)
+ flags |= SBT_NOBORDERS;
+ SendMessageA(pcli->hwndStatus, SB_SETTEXTA, partCount | flags, (LPARAM)PD);
+
partCount++;
}
// update the clui button
@@ -193,11 +179,10 @@ void CluiProtocolStatusChanged(int, const char*) mir_free(dbv.pszVal);
}
else {
- wStatus = maxStatus;
- iIcon = IconFromStatusMode((wStatus >= ID_STATUS_CONNECTING && wStatus < ID_STATUS_OFFLINE) ? szMaxProto : nullptr, (int)wStatus, 0, &hIcon);
+ char *szMaxProto = nullptr;
+ wStatus = Clist_GetGeneralizedStatus(&szMaxProto);
+ iIcon = IconFromStatusMode(szMaxProto, wStatus, 0, &hIcon);
g_maxStatus = (int)wStatus;
- if (szMaxProto)
- strncpy_s(g_maxProto, _countof(g_maxProto), szMaxProto, _TRUNCATE);
}
/*
|