From 7c2e75f14ad9dd186a85b17587c21c2561286581 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Apr 2016 11:27:27 +0000 Subject: - 2nd & 3rd lines handling unification; - no need to copy data to make async calls; - no need to launch a thread to save a couple of msecs on a very large roster; - unused code & params cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@16785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_awaymsg.cpp | 15 +- plugins/Clist_modern/src/modern_cache_funcs.h | 9 +- plugins/Clist_modern/src/modern_cachefuncs.cpp | 115 ++++++-------- plugins/Clist_modern/src/modern_clc.cpp | 79 +++------- plugins/Clist_modern/src/modern_clc.h | 87 ++++------- plugins/Clist_modern/src/modern_clcitems.cpp | 4 +- plugins/Clist_modern/src/modern_clcpaint.cpp | 28 ++-- plugins/Clist_modern/src/modern_clcutils.cpp | 60 +++---- plugins/Clist_modern/src/modern_clist.h | 4 +- plugins/Clist_modern/src/modern_clistmod.cpp | 2 - plugins/Clist_modern/src/modern_clistsettings.cpp | 93 ----------- plugins/Clist_modern/src/modern_clui.cpp | 20 --- plugins/Clist_modern/src/modern_commonprototypes.h | 5 +- plugins/Clist_modern/src/modern_gettextasync.cpp | 172 --------------------- plugins/Clist_modern/src/modern_gettextasync.h | 6 - .../Clist_modern/src/modern_rowheight_funcs.cpp | 34 ++-- plugins/Clist_modern/src/modern_static_clui.h | 5 - plugins/Clist_modern/src/stdafx.h | 3 - 18 files changed, 160 insertions(+), 581 deletions(-) delete mode 100644 plugins/Clist_modern/src/modern_gettextasync.cpp delete mode 100644 plugins/Clist_modern/src/modern_gettextasync.h (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index 7a10a0cbb4..0cdae03c29 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -78,9 +78,6 @@ static void amThreadProc(void *) { Netlib_Logf(NULL, "amThreadProc thread start"); - ClcCacheEntry dnce; - memset(&dnce, 0, sizeof(dnce)); - while (!MirandaExiting()) { MCONTACT hContact = amGetCurrentChain(); while (hContact) { @@ -90,22 +87,20 @@ static void amThreadProc(void *) if (MirandaExiting()) goto LBL_Exit; } - CListSettings_FreeCacheItemData(&dnce); - dnce.hContact = hContact; - Sync(CLUI_SyncGetPDNCE, (WPARAM)0, (LPARAM)&dnce); + + ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(hContact); HANDLE ACK = 0; - if (dnce.ApparentMode != ID_STATUS_OFFLINE) //don't ask if contact is always invisible (should be done with protocol) + if (pdnce->ApparentMode != ID_STATUS_OFFLINE) //don't ask if contact is always invisible (should be done with protocol) ACK = (HANDLE)CallContactService(hContact, PSS_GETAWAYMSG, 0, 0); if (!ACK) { ACKDATA ack; ack.hContact = hContact; ack.type = ACKTYPE_AWAYMSG; ack.result = ACKRESULT_FAILED; - ack.szModule = dnce.m_pszProto; - ClcDoProtoAck(hContact, &ack); + ack.szModule = pdnce->m_pszProto; + ClcDoProtoAck(&ack); } - CListSettings_FreeCacheItemData(&dnce); amRequestTick = time; hContact = amGetCurrentChain(); if (hContact) { diff --git a/plugins/Clist_modern/src/modern_cache_funcs.h b/plugins/Clist_modern/src/modern_cache_funcs.h index b518c8bcd9..c7316308c2 100644 --- a/plugins/Clist_modern/src/modern_cache_funcs.h +++ b/plugins/Clist_modern/src/modern_cache_funcs.h @@ -32,15 +32,12 @@ Created by Pescuma #include "modern_clc.h" #include "modern_commonprototypes.h" -void Cache_GetText(ClcData *dat, ClcContact *contact, BOOL forceRenew); +void Cache_GetText(ClcData *dat, ClcContact *contact); void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact); -void Cache_GetSecondLineText(SHORTDATA *dat, ClcCacheEntry *pdnce); -void Cache_GetThirdLineText(SHORTDATA *dat, ClcCacheEntry *pdnce); +void Cache_GetNthLineText(ClcData *dat, ClcCacheEntry *pdnce, int n); void Cache_GetAvatar(ClcData *dat, ClcContact *contact); void Cache_GetTimezone(ClcData *dat, MCONTACT hContact); -int Cache_GetLineText(ClcCacheEntry *pdnce, int type, LPTSTR text, int text_size, TCHAR *variable_text, BOOL xstatus_has_priority, - BOOL show_status_if_no_away, BOOL show_listening_if_no_away, BOOL use_name_and_message_for_xstatus, - BOOL pdnce_time_show_only_if_different); +int Cache_GetLineText(ClcCacheEntry *pdnce, int type, LPTSTR text, int text_size, ClcLineInfo &line); void amRequestAwayMsg(MCONTACT hContact); diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index af7a5d4ff7..59f54be0f7 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -31,7 +31,6 @@ Modified by FYR #include "stdafx.h" #include "modern_cache_funcs.h" #include "newpluginapi.h" -#include "./modern_gettextasync.h" #include "modern_sync.h" typedef BOOL(*ExecuteOnAllContactsFuncPtr) (ClcContact *contact, BOOL subcontact, void *param); @@ -43,9 +42,6 @@ static int CopySkipUnprintableChars(TCHAR *to, TCHAR * buf, DWORD size); static BOOL ExecuteOnAllContacts(ClcData *dat, ExecuteOnAllContactsFuncPtr func, void *param); static BOOL ExecuteOnAllContactsOfGroup(ClcGroup *group, ExecuteOnAllContactsFuncPtr func, void *param); -int CLUI_SyncGetShortData(WPARAM wParam, LPARAM lParam); -void CListSettings_FreeCacheItemData(ClcCacheEntry *pDst); -void CListSettings_FreeCacheItemDataOption(ClcCacheEntry *pDst, DWORD flag); ///////////////////////////////////////////////////////////////////////////////////////// // Get time zone for contact @@ -65,16 +61,19 @@ void Cache_GetTimezone(ClcData *dat, MCONTACT hContact) ///////////////////////////////////////////////////////////////////////////////////////// // Get all lines of text // -void Cache_GetText(ClcData *dat, ClcContact *contact, BOOL forceRenew) +void Cache_GetText(ClcData *dat, ClcContact *contact) { Cache_GetFirstLineText(dat, contact); + if (!dat->force_in_dialog) { - if ((dat->second_line_show && (forceRenew || contact->pce->szSecondLineText == NULL)) || (dat->third_line_show && (forceRenew || contact->pce->szThirdLineText == NULL))) - gtaAddRequest(dat, contact->hContact); + if (dat->secondLine.show) + Cache_GetNthLineText(dat, contact->pce, 2); + if (dat->thirdLine.show) + Cache_GetNthLineText(dat, contact->pce, 3); } } -void CSmileyString::AddListeningToIcon(SHORTDATA *dat, TCHAR *szText) +void CSmileyString::AddListeningToIcon(ClcData *dat, TCHAR *szText) { iMaxSmileyHeight = 0; DestroySmileyList(); @@ -173,7 +172,7 @@ void CSmileyString::DestroySmileyList() ///////////////////////////////////////////////////////////////////////////////////////// // Parsing of text for smiley // -void CSmileyString::ReplaceSmileys(SHORTDATA *dat, ClcCacheEntry *pdnce, TCHAR * szText, BOOL replace_smileys) +void CSmileyString::ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, TCHAR * szText, BOOL replace_smileys) { int last_pos = 0; iMaxSmileyHeight = 0; @@ -382,11 +381,8 @@ int GetStatusMessage(TCHAR *text, int text_size, ClcCacheEntry *pdnce, BOOL xsta ///////////////////////////////////////////////////////////////////////////////////////// // Get the text for specified lines -// -int Cache_GetLineText( - ClcCacheEntry *pdnce, int type, LPTSTR text, int text_size, TCHAR *variable_text, BOOL xstatus_has_priority, - BOOL show_status_if_no_away, BOOL show_listening_if_no_away, BOOL use_name_and_message_for_xstatus, - BOOL pdnce_time_show_only_if_different) + +int Cache_GetLineText(ClcCacheEntry *pdnce, int type, LPTSTR text, int text_size, ClcLineInfo &line) { if (text == NULL) return TEXT_EMPTY; @@ -394,7 +390,8 @@ int Cache_GetLineText( switch (type) { case TEXT_STATUS: - if (GetStatusName(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) { +LBL_Status: + if (GetStatusName(text, text_size, pdnce, line.xstatus_has_priority) == -1 && line.use_name_and_message_for_xstatus) { // Try to get XStatusMsg ptrT tszXStatusMsg(db_get_tsa(pdnce->hContact, pdnce->m_pszProto, "XStatusMsg")); if (tszXStatusMsg != NULL && tszXStatusMsg[0] != 0) { @@ -416,7 +413,7 @@ int Cache_GetLineText( return TEXT_NICKNAME; case TEXT_STATUS_MESSAGE: - if (GetStatusMessage(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) { + if (GetStatusMessage(text, text_size, pdnce, line.xstatus_has_priority) == -1 && line.use_name_and_message_for_xstatus) { // Try to get XStatusName ptrT tszXStatusName(db_get_tsa(pdnce->hContact, pdnce->m_pszProto, "XStatusName")); if (tszXStatusName != NULL && tszXStatusName[0] != 0) { @@ -425,7 +422,7 @@ int Cache_GetLineText( CopySkipUnprintableChars(text, text, text_size - 1); } } - else if (use_name_and_message_for_xstatus && xstatus_has_priority) { + else if (line.use_name_and_message_for_xstatus && line.xstatus_has_priority) { // Try to get XStatusName ptrT tszXStatusName(db_get_tsa(pdnce->hContact, pdnce->m_pszProto, "XStatusName")); if (tszXStatusName != NULL && tszXStatusName[0] != 0) { @@ -435,14 +432,14 @@ int Cache_GetLineText( } if (text[0] == '\0') { - if (show_listening_if_no_away) { - Cache_GetLineText(pdnce, TEXT_LISTENING_TO, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different); + if (line.show_listening_if_no_away) { + GetListeningTo(text, text_size, pdnce); if (text[0] != '\0') return TEXT_LISTENING_TO; } - if (show_status_if_no_away) // re-request status if no away - return Cache_GetLineText(pdnce, TEXT_STATUS, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different); + if (line.show_status_if_no_away) // re-request status if no away + goto LBL_Status; } return TEXT_STATUS_MESSAGE; @@ -452,7 +449,7 @@ int Cache_GetLineText( case TEXT_TEXT: { - ptrT tmp(variables_parsedup(variable_text, pdnce->tszName, pdnce->hContact)); + ptrT tmp(variables_parsedup(line.text, pdnce->tszName, pdnce->hContact)); mir_tstrncpy(text, tmp, text_size); CopySkipUnprintableChars(text, text, text_size - 1); } @@ -472,7 +469,7 @@ int Cache_GetLineText( ///////////////////////////////////////////////////////////////////////////////////////// // Get the text for First Line -// + void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact) { if (GetCurrentThreadId() != g_dwMainThreadID) @@ -497,60 +494,42 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact) } else mir_tstrncpy(contact->szText, name, _countof(contact->szText)); - if (!dat->force_in_dialog) { - SHORTDATA data = { 0 }; - Sync(CLUI_SyncGetShortData, (WPARAM)pcli->hwndContactTree, (LPARAM)&data); - contact->ssText.ReplaceSmileys(&data, pdnce, contact->szText, dat->first_line_draw_smileys); - } + if (!dat->force_in_dialog) + contact->ssText.ReplaceSmileys(dat, pdnce, contact->szText, dat->first_line_draw_smileys); } ///////////////////////////////////////////////////////////////////////////////////////// // Get the text for Second Line -// -void Cache_GetSecondLineText(SHORTDATA *dat, ClcCacheEntry *pdnce) -{ - TCHAR Text[240 - EXTRA_ICON_COUNT] = { 0 }; - int type = TEXT_EMPTY; - if (dat->second_line_show) - type = Cache_GetLineText(pdnce, dat->second_line_type, Text, _countof(Text), dat->second_line_text, - dat->second_line_xstatus_has_priority, dat->second_line_show_status_if_no_away, dat->second_line_show_listening_if_no_away, - dat->second_line_use_name_and_message_for_xstatus, dat->contact_time_show_only_if_different); +void Cache_GetNthLineText(ClcData *dat, ClcCacheEntry *pdnce, int n) +{ + TCHAR Text[240 - EXTRA_ICON_COUNT]; Text[0] = 0; + ClcLineInfo &line = (n == 2) ? dat->secondLine : dat->thirdLine; + TCHAR* &szText = (n == 2) ? pdnce->szSecondLineText : pdnce->szThirdLineText; + // in most cases replaceStrT does nothing + if (!line.show) { + replaceStrT(szText, NULL); + return; + } + + int type = Cache_GetLineText(pdnce, line.type, Text, _countof(Text), line); + if (Text[0] == 0) { + replaceStrT(szText, NULL); + return; + } + Text[_countof(Text) - 1] = 0; //to be sure that it is null terminated string + replaceStrT(szText, Text); - replaceStrT(pdnce->szSecondLineText, (dat->second_line_show) ? Text : NULL); - - if (pdnce->szSecondLineText) { - if (type == TEXT_LISTENING_TO && pdnce->szSecondLineText[0] != _T('\0')) - pdnce->ssSecondLine.AddListeningToIcon(dat, pdnce->szSecondLineText); - else - pdnce->ssSecondLine.ReplaceSmileys(dat, pdnce, pdnce->szSecondLineText, dat->second_line_draw_smileys); - } + CSmileyString &ss = (n == 2) ? pdnce->ssSecondLine : pdnce->ssThirdLine; + if (type == TEXT_LISTENING_TO && szText[0] != _T('\0')) + ss.AddListeningToIcon(dat, szText); + else + ss.ReplaceSmileys(dat, pdnce, szText, line.draw_smileys); } ///////////////////////////////////////////////////////////////////////////////////////// -// Get the text for Third Line -// -void Cache_GetThirdLineText(SHORTDATA *dat, ClcCacheEntry *pdnce) -{ - TCHAR Text[240 - EXTRA_ICON_COUNT] = { 0 }; - int type = TEXT_EMPTY; - if (dat->third_line_show) - type = Cache_GetLineText(pdnce, dat->third_line_type, Text, _countof(Text), dat->third_line_text, - dat->third_line_xstatus_has_priority, dat->third_line_show_status_if_no_away, dat->third_line_show_listening_if_no_away, - dat->third_line_use_name_and_message_for_xstatus, dat->contact_time_show_only_if_different); - - Text[_countof(Text) - 1] = 0; //to be sure that it is null terminated string - - replaceStrT(pdnce->szThirdLineText, (dat->third_line_show) ? Text : NULL); - if (pdnce->szThirdLineText) { - if (type == TEXT_LISTENING_TO && pdnce->szThirdLineText[0] != _T('\0')) - pdnce->ssThirdLine.AddListeningToIcon(dat, pdnce->szThirdLineText); - else - pdnce->ssThirdLine.ReplaceSmileys(dat, pdnce, pdnce->szThirdLineText, dat->third_line_draw_smileys); - } -} void RemoveTag(TCHAR *to, TCHAR *tag) { @@ -564,8 +543,8 @@ void RemoveTag(TCHAR *to, TCHAR *tag) } ///////////////////////////////////////////////////////////////////////////////////////// -//Copy string with removing Escape chars from text and BBcodes -// +// Copy string with removing Escape chars from text and BBcodes + static int CopySkipUnprintableChars(TCHAR *to, TCHAR * buf, DWORD size) { DWORD i; diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 094ca5b4f8..7c7fa0815a 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -67,9 +67,9 @@ static int clcHookSmileyAddOptionsChanged(WPARAM, LPARAM) return 0; } -static int clcHookProtoAck(WPARAM wParam, LPARAM lParam) +static int clcHookProtoAck(WPARAM, LPARAM lParam) { - return ClcDoProtoAck(wParam, (ACKDATA*)lParam); + return ClcDoProtoAck((ACKDATA*)lParam); } static int clcHookIconsChanged(WPARAM, LPARAM) @@ -313,7 +313,7 @@ static LRESULT clcOnCreate(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPA corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); LoadCLCOptions(hwnd, dat, TRUE); - if (dat->contact_time_show || dat->second_line_type == TEXT_CONTACT_TIME || dat->third_line_type == TEXT_CONTACT_TIME) + if (dat->contact_time_show || dat->secondLine.type == TEXT_CONTACT_TIME || dat->thirdLine.type == TEXT_CONTACT_TIME) CLUI_SafeSetTimer(hwnd, TIMERID_INVALIDATE, 5000, NULL); else KillTimer(hwnd, TIMERID_INVALIDATE); @@ -621,12 +621,6 @@ void clcSetDelayTimer(UINT_PTR uIDEvent, HWND hwnd, int nDelay) static LRESULT clcOnTimer(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (wParam) { - case TIMERID_INVALIDATE_FULL: - KillTimer(hwnd, TIMERID_INVALIDATE_FULL); - pcli->pfnRecalcScrollBar(hwnd, dat); - pcli->pfnInvalidateRect(hwnd, NULL, 0); - return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); - case TIMERID_INVALIDATE: { time_t cur_time = (time(NULL) / 60); @@ -1467,7 +1461,7 @@ static LRESULT clcOnIntmTimeZoneChanged(ClcData *dat, HWND hwnd, UINT msg, WPARA if (contact) { Cache_GetTimezone(dat, contact->hContact); - Cache_GetText(dat, contact, 1); + Cache_GetText(dat, contact); cliRecalcScrollBar(hwnd, dat); } return 0; @@ -1485,7 +1479,7 @@ static LRESULT clcOnIntmNameChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wP if (contact) { mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); - Cache_GetText(dat, contact, 1); + Cache_GetText(dat, contact); // cliRecalcScrollBar(hwnd, dat); } @@ -1508,7 +1502,7 @@ static LRESULT clcOnIntmStatusMsgChanged(ClcData *dat, HWND hwnd, UINT msg, WPAR return corecli.pfnContactListControlWndProc(hwnd, msg, hContact, lParam); if (contact) { - Cache_GetText(dat, contact, 1); + Cache_GetText(dat, contact); // cliRecalcScrollBar(hwnd, dat); PostMessage(hwnd, INTM_INVALIDATE, 0, 0); } @@ -1549,15 +1543,19 @@ static LRESULT clcOnIntmScrollBarChanged(ClcData *dat, HWND hwnd, UINT, WPARAM, static LRESULT clcOnIntmStatusChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { int ret = corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); + if (wParam != 0) { - ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(wParam); - if (pdnce && pdnce->m_pszProto) { - if (!dat->force_in_dialog && (dat->second_line_show || dat->third_line_show)) - gtaRenewText(pdnce->hContact); - SendMessage(hwnd, INTM_ICONCHANGED, wParam, corecli.pfnGetContactIcon(wParam)); + ClcContact *contact; + if (FindItem(hwnd, dat, wParam, &contact, NULL, NULL, TRUE)) { + ClcCacheEntry *pdnce = contact->pce; + if (pdnce && pdnce->m_pszProto) { + if (!dat->force_in_dialog) { + Cache_GetNthLineText(dat, pdnce, 2); + Cache_GetNthLineText(dat, pdnce, 3); + } + + SendMessage(hwnd, INTM_ICONCHANGED, wParam, corecli.pfnGetContactIcon(wParam)); - ClcContact *contact; - if (FindItem(hwnd, dat, wParam, &contact, NULL, NULL, TRUE)) { if (contact && contact->type == CLCIT_CONTACT) { if (!contact->image_is_special && pdnce->getStatus() > ID_STATUS_OFFLINE) contact->iImage = corecli.pfnGetContactIcon(wParam); @@ -1686,7 +1684,7 @@ int ClcUnloadModule() return 0; } -int ClcDoProtoAck(MCONTACT, ACKDATA *ack) +int ClcDoProtoAck(ACKDATA *ack) { if (MirandaExiting()) return 0; if (ack->type == ACKTYPE_STATUS) { @@ -1708,7 +1706,7 @@ int ClcDoProtoAck(MCONTACT, ACKDATA *ack) return 0; db_set_ws(ack->hContact, "CList", "StatusMsg", (const TCHAR *)ack->lParam); - gtaRenewText(ack->hContact); + pcli->pfnClcBroadcast(INTM_STATUSCHANGED, ack->hContact, 0); } else { if (ack->szModule != NULL) @@ -1721,7 +1719,7 @@ int ClcDoProtoAck(MCONTACT, ACKDATA *ack) if (mir_strcmpi(val, "")) db_set_s(ack->hContact, "CList", "StatusMsg", ""); else - gtaRenewText(ack->hContact); + pcli->pfnClcBroadcast(INTM_STATUSCHANGED, ack->hContact, 0); mir_free(val); } } @@ -1733,43 +1731,6 @@ int ClcDoProtoAck(MCONTACT, ACKDATA *ack) return 0; } -int ClcGetShortData(ClcData* pData, SHORTDATA *pShortData) -{ - if (!pData || !pShortData) - return -1; - - pShortData->hWnd = pData->hWnd; - pShortData->text_replace_smileys = pData->text_replace_smileys; - pShortData->text_smiley_height = pData->text_smiley_height; - pShortData->text_use_protocol_smileys = pData->text_use_protocol_smileys; - pShortData->contact_time_show_only_if_different = pData->contact_time_show_only_if_different; - - // Second line - pShortData->second_line_show = pData->second_line_show; - pShortData->second_line_draw_smileys = pData->second_line_draw_smileys; - pShortData->second_line_type = pData->second_line_type; - - mir_tstrncpy(pShortData->second_line_text, pData->second_line_text, _countof(pShortData->second_line_text)); - - pShortData->second_line_xstatus_has_priority = pData->second_line_xstatus_has_priority; - pShortData->second_line_show_status_if_no_away = pData->second_line_show_status_if_no_away; - pShortData->second_line_show_listening_if_no_away = pData->second_line_show_listening_if_no_away; - pShortData->second_line_use_name_and_message_for_xstatus = pData->second_line_use_name_and_message_for_xstatus; - - // Third line - pShortData->third_line_show = pData->third_line_show; - pShortData->third_line_draw_smileys = pData->third_line_draw_smileys; - pShortData->third_line_type = pData->third_line_type; - - mir_tstrncpy(pShortData->third_line_text, pData->third_line_text, _countof(pShortData->third_line_text)); - - pShortData->third_line_xstatus_has_priority = pData->third_line_xstatus_has_priority; - pShortData->third_line_show_status_if_no_away = pData->third_line_show_status_if_no_away; - pShortData->third_line_show_listening_if_no_away = pData->third_line_show_listening_if_no_away; - pShortData->third_line_use_name_and_message_for_xstatus = pData->third_line_use_name_and_message_for_xstatus; - return 0; -} - int ClcEnterDragToScroll(HWND hwnd, int Y) { if (IsDragToScrollMode) diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index 72ae4d3b02..b61584cf57 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -64,7 +64,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TIMERID_SUBEXPAND 21 #define TIMERID_INVALIDATE 22 -#define TIMERID_INVALIDATE_FULL 25 #define TIMERID_RECALCSCROLLBAR 26 #define TIMERID_FIRST TIMERID_RENAME @@ -221,6 +220,19 @@ struct ClcContact : public ClcContactBase } }; +struct ClcLineInfo +{ + BOOL show; + int top_space; + BOOL draw_smileys; + int type; + TCHAR text[TEXT_TEXT_MAX_LENGTH]; + BOOL xstatus_has_priority; + BOOL show_status_if_no_away; + BOOL show_listening_if_no_away; + BOOL use_name_and_message_for_xstatus; +}; + struct ClcModernFontInfo { HFONT hFont; int fontHeight, changed; @@ -301,73 +313,26 @@ struct ClcData : public ClcDataBase BOOL first_line_draw_smileys; BOOL first_line_append_nick; - // Second line - BOOL second_line_show; - int second_line_top_space; - BOOL second_line_draw_smileys; - int second_line_type; - TCHAR second_line_text[TEXT_TEXT_MAX_LENGTH]; - BOOL second_line_xstatus_has_priority; - BOOL second_line_show_status_if_no_away; - BOOL second_line_show_listening_if_no_away; - BOOL second_line_use_name_and_message_for_xstatus; - - // Third line - BOOL third_line_show; - int third_line_top_space; - BOOL third_line_draw_smileys; - int third_line_type; - TCHAR third_line_text[TEXT_TEXT_MAX_LENGTH]; - BOOL third_line_xstatus_has_priority; - BOOL third_line_show_status_if_no_away; - BOOL third_line_show_listening_if_no_away; - BOOL third_line_use_name_and_message_for_xstatus; - struct ClcModernFontInfo fontModernInfo[FONTID_MODERN_MAX + 1]; - HWND hWnd; - BYTE menuOwnerType; - int menuOwnerID; + // Second & third line + ClcLineInfo secondLine, thirdLine; + + ClcModernFontInfo fontModernInfo[FONTID_MODERN_MAX + 1]; + HWND hWnd; + BYTE menuOwnerType; + int menuOwnerID; DWORD m_paintCouter; //range is enoght to 49 days if painting will occure each one millisecond - BYTE useMetaIcon; - BYTE drawOverlayedStatus; - int nInsertionLevel; + BYTE useMetaIcon; + BYTE drawOverlayedStatus; + int nInsertionLevel; - BYTE dbbMetaHideExtra; - BYTE dbbBlendInActiveState; - BYTE dbbBlend25; + BYTE dbbMetaHideExtra; + BYTE dbbBlendInActiveState; + BYTE dbbBlend25; XPTHANDLE hCheckBoxTheme; BYTE bCompactMode; }; -struct SHORTDATA -{ - HWND hWnd; - BOOL contact_time_show_only_if_different; - int text_smiley_height; - BOOL text_replace_smileys; - BOOL text_use_protocol_smileys; - - // Second line - BOOL second_line_show; - BOOL second_line_draw_smileys; - int second_line_type; - TCHAR second_line_text[TEXT_TEXT_MAX_LENGTH]; - BOOL second_line_xstatus_has_priority; - BOOL second_line_show_status_if_no_away; - BOOL second_line_show_listening_if_no_away; - BOOL second_line_use_name_and_message_for_xstatus; - - // Third line - BOOL third_line_show; - BOOL third_line_draw_smileys; - int third_line_type; - TCHAR third_line_text[TEXT_TEXT_MAX_LENGTH]; - BOOL third_line_xstatus_has_priority; - BOOL third_line_show_status_if_no_away; - BOOL third_line_show_listening_if_no_away; - BOOL third_line_use_name_and_message_for_xstatus; -}; - typedef struct tagOVERLAYICONINFO { char *name; diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 866b96d512..79df85ad71 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -71,7 +71,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup) p.image_is_special = FALSE; //p.status = cacheEntry->status; Cache_GetTimezone(dat, (&p)->hContact); - Cache_GetText(dat, &p, 1); + Cache_GetText(dat, &p); char *szProto = cacheEntry->m_pszProto; if (szProto != NULL && !pcli->pfnIsHiddenMode(dat, wStatus)) @@ -196,7 +196,7 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat, cont->lastPaintCounter = 0; cont->avatar_pos = AVATAR_POS_DONT_HAVE; Cache_GetAvatar(dat, cont); - Cache_GetText(dat, cont, 1); + Cache_GetText(dat, cont); Cache_GetTimezone(dat, cont->hContact); cont->iImage = corecli.pfnGetContactIcon(hContact); cont->bContactRate = db_get_b(hContact, "CList", "Rate", 0); diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index 5a256386f5..8f1e6d7563 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -1099,7 +1099,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R // Select font UINT uTextFormat = (dat->text_rtl ? DT_RTLREADING : 0); - if (dat->second_line_show && dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (dat->secondLine.show && dat->secondLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time TCHAR buf[70] = _T(""); mir_free_and_nil(pdnce->szSecondLineText); @@ -1127,7 +1127,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R // Select font UINT uTextFormat = (dat->text_rtl ? DT_RTLREADING : 0); - if (dat->third_line_show && dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (dat->thirdLine.show && dat->thirdLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time TCHAR buf[70] = _T(""); mir_free(pdnce->szThirdLineText); @@ -2320,8 +2320,8 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } else if (Drawing->type == CLCIT_CONTACT && !CheckMiniMode(dat, selected)) { int tmp; - if (dat->second_line_show) { - if (dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (dat->secondLine.show) { + if (dat->secondLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time TCHAR buf[70] = _T(""); TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, _countof(buf), 0); @@ -2329,7 +2329,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT pdnce->szSecondLineText = mir_tstrdup(buf); } - if (pdnce->szSecondLineText && pdnce->szSecondLineText[0] && free_height > dat->second_line_top_space) { + if (pdnce->szSecondLineText && pdnce->szSecondLineText[0] && free_height > dat->secondLine.top_space) { ChangeToFont(hdcMem, dat, FONTID_SECONDLINE, NULL); // Get sizes @@ -2337,7 +2337,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight); // Get rect - tmp = min(free_height, dat->second_line_top_space + second_line_text_size.cy); + tmp = min(free_height, dat->secondLine.top_space + second_line_text_size.cy); free_height -= tmp; text_rc.top = free_row_rc.top + (free_height >> 1); @@ -2351,18 +2351,18 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT selection_text_rc.top = text_rc.top; selection_text_rc.bottom = min(selection_text_rc.bottom, selection_text_rc.top + text_size.cy); - max_bottom_selection_border = min(max_bottom_selection_border, dat->second_line_top_space / 2); + max_bottom_selection_border = min(max_bottom_selection_border, dat->secondLine.top_space / 2); } } - if (dat->third_line_show) { - if (dat->third_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (dat->thirdLine.show) { + if (dat->thirdLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time TCHAR buf[70] = _T(""); TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), buf, _countof(buf), 0); mir_free(pdnce->szThirdLineText); pdnce->szThirdLineText = mir_tstrdup(buf); } - if (pdnce->szThirdLineText != NULL && pdnce->szThirdLineText[0] && free_height > dat->third_line_top_space) { + if (pdnce->szThirdLineText != NULL && pdnce->szThirdLineText[0] && free_height > dat->thirdLine.top_space) { //RECT rc_tmp = free_row_rc; ChangeToFont(hdcMem, dat, FONTID_THIRDLINE, NULL); @@ -2372,7 +2372,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight); // Get rect - tmp = min(free_height, dat->third_line_top_space + third_line_text_size.cy); + tmp = min(free_height, dat->thirdLine.top_space + third_line_text_size.cy); free_height -= tmp; text_rc.top = free_row_rc.top + (free_height >> 1); @@ -2386,7 +2386,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT selection_text_rc.top = text_rc.top; selection_text_rc.bottom = min(selection_text_rc.bottom, selection_text_rc.top + text_size.cy); - max_bottom_selection_border = min(max_bottom_selection_border, dat->third_line_top_space / 2); + max_bottom_selection_border = min(max_bottom_selection_border, dat->thirdLine.top_space / 2); } } @@ -2488,7 +2488,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } uTextFormat &= ~DT_VCENTER; if (second_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { - free_rc.top += dat->second_line_top_space; + free_rc.top += dat->secondLine.top_space; if (free_rc.bottom > free_rc.top) { RECT rc = free_rc; @@ -2506,7 +2506,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } if (third_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { - free_rc.top += dat->third_line_top_space; + free_rc.top += dat->thirdLine.top_space; if (free_rc.bottom > free_rc.top) { RECT rc = free_rc; diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index f395506d2e..d6e132edff 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -595,59 +595,43 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) // Second line if (pcli->hwndContactTree == hwnd || pcli->hwndContactTree == NULL) { - dat->second_line_show = db_get_b(NULL, "CList", "SecondLineShow", SETTING_SECONDLINE_SHOW_DEFAULT); - dat->second_line_top_space = db_get_w(NULL, "CList", "SecondLineTopSpace", SETTING_SECONDLINE_TOPSPACE_DEFAULT); - dat->second_line_draw_smileys = db_get_b(NULL, "CList", "SecondLineDrawSmileys", SETTING_SECONDLINE_SMILEYS_DEFAULT); - dat->second_line_type = db_get_w(NULL, "CList", "SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT); + dat->secondLine.show = db_get_b(NULL, "CList", "SecondLineShow", SETTING_SECONDLINE_SHOW_DEFAULT); + dat->secondLine.top_space = db_get_w(NULL, "CList", "SecondLineTopSpace", SETTING_SECONDLINE_TOPSPACE_DEFAULT); + dat->secondLine.draw_smileys = db_get_b(NULL, "CList", "SecondLineDrawSmileys", SETTING_SECONDLINE_SMILEYS_DEFAULT); + dat->secondLine.type = db_get_w(NULL, "CList", "SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT); ptrT tszLineText(db_get_tsa(NULL, "CList", "SecondLineText")); if (tszLineText) - mir_tstrncpy(dat->second_line_text, tszLineText, _countof(dat->second_line_text)); + mir_tstrncpy(dat->secondLine.text, tszLineText, _countof(dat->secondLine.text)); else - dat->second_line_text[0] = _T('\0'); + dat->secondLine.text[0] = _T('\0'); - dat->second_line_xstatus_has_priority = db_get_b(NULL, "CList", "SecondLineXStatusHasPriority", SETTING_SECONDLINE_XSTATUS_DEFAULT); - dat->second_line_show_status_if_no_away = db_get_b(NULL, "CList", "SecondLineShowStatusIfNoAway", SETTING_SECONDLINE_STATUSIFNOAWAY_DEFAULT); - dat->second_line_show_listening_if_no_away = db_get_b(NULL, "CList", "SecondLineShowListeningIfNoAway", SETTING_SECONDLINE_LISTENINGIFNOAWAY_DEFAULT); - dat->second_line_use_name_and_message_for_xstatus = db_get_b(NULL, "CList", "SecondLineUseNameAndMessageForXStatus", SETTING_SECONDLINE_XSTATUSNAMETEXT_DEFAULT); - } - else { - dat->second_line_show = 0; - dat->second_line_top_space = 0; - dat->second_line_draw_smileys = 0; - dat->second_line_type = 0; - dat->second_line_text[0] = _T('\0'); - dat->second_line_xstatus_has_priority = 0; - dat->second_line_use_name_and_message_for_xstatus = 0; + dat->secondLine.xstatus_has_priority = db_get_b(NULL, "CList", "SecondLineXStatusHasPriority", SETTING_SECONDLINE_XSTATUS_DEFAULT); + dat->secondLine.show_status_if_no_away = db_get_b(NULL, "CList", "SecondLineShowStatusIfNoAway", SETTING_SECONDLINE_STATUSIFNOAWAY_DEFAULT); + dat->secondLine.show_listening_if_no_away = db_get_b(NULL, "CList", "SecondLineShowListeningIfNoAway", SETTING_SECONDLINE_LISTENINGIFNOAWAY_DEFAULT); + dat->secondLine.use_name_and_message_for_xstatus = db_get_b(NULL, "CList", "SecondLineUseNameAndMessageForXStatus", SETTING_SECONDLINE_XSTATUSNAMETEXT_DEFAULT); } + else memset(&dat->secondLine, 0, sizeof(dat->secondLine)); // Third line if (pcli->hwndContactTree == hwnd || pcli->hwndContactTree == NULL) { - dat->third_line_show = db_get_b(NULL, "CList", "ThirdLineShow", SETTING_THIRDLINE_SHOW_DEFAULT); - dat->third_line_top_space = db_get_w(NULL, "CList", "ThirdLineTopSpace", SETTING_THIRDLINE_TOPSPACE_DEFAULT); - dat->third_line_draw_smileys = db_get_b(NULL, "CList", "ThirdLineDrawSmileys", SETTING_THIRDLINE_SMILEYS_DEFAULT); - dat->third_line_type = db_get_w(NULL, "CList", "ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT); + dat->thirdLine.show = db_get_b(NULL, "CList", "ThirdLineShow", SETTING_THIRDLINE_SHOW_DEFAULT); + dat->thirdLine.top_space = db_get_w(NULL, "CList", "ThirdLineTopSpace", SETTING_THIRDLINE_TOPSPACE_DEFAULT); + dat->thirdLine.draw_smileys = db_get_b(NULL, "CList", "ThirdLineDrawSmileys", SETTING_THIRDLINE_SMILEYS_DEFAULT); + dat->thirdLine.type = db_get_w(NULL, "CList", "ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT); ptrT tszLineText(db_get_tsa(NULL, "CList", "ThirdLineText")); if (tszLineText) - mir_tstrncpy(dat->third_line_text, tszLineText, _countof(dat->third_line_text)); + mir_tstrncpy(dat->thirdLine.text, tszLineText, _countof(dat->thirdLine.text)); else - dat->third_line_text[0] = _T('\0'); + dat->thirdLine.text[0] = _T('\0'); - dat->third_line_xstatus_has_priority = db_get_b(NULL, "CList", "ThirdLineXStatusHasPriority", SETTING_THIRDLINE_XSTATUS_DEFAULT); - dat->third_line_show_status_if_no_away = db_get_b(NULL, "CList", "ThirdLineShowStatusIfNoAway", SETTING_THIRDLINE_STATUSIFNOAWAY_DEFAULT); - dat->third_line_show_listening_if_no_away = db_get_b(NULL, "CList", "ThirdLineShowListeningIfNoAway", SETTING_THIRDLINE_LISTENINGIFNOAWAY_DEFAULT); - dat->third_line_use_name_and_message_for_xstatus = db_get_b(NULL, "CList", "ThirdLineUseNameAndMessageForXStatus", SETTING_THIRDLINE_XSTATUSNAMETEXT_DEFAULT); - } - else { - dat->third_line_show = 0; - dat->third_line_top_space = 0; - dat->third_line_draw_smileys = 0; - dat->third_line_type = TEXT_STATUS_MESSAGE; - dat->third_line_text[0] = _T('\0'); - dat->third_line_xstatus_has_priority = 1; - dat->third_line_use_name_and_message_for_xstatus = 0; + dat->thirdLine.xstatus_has_priority = db_get_b(NULL, "CList", "ThirdLineXStatusHasPriority", SETTING_THIRDLINE_XSTATUS_DEFAULT); + dat->thirdLine.show_status_if_no_away = db_get_b(NULL, "CList", "ThirdLineShowStatusIfNoAway", SETTING_THIRDLINE_STATUSIFNOAWAY_DEFAULT); + dat->thirdLine.show_listening_if_no_away = db_get_b(NULL, "CList", "ThirdLineShowListeningIfNoAway", SETTING_THIRDLINE_LISTENINGIFNOAWAY_DEFAULT); + dat->thirdLine.use_name_and_message_for_xstatus = db_get_b(NULL, "CList", "ThirdLineUseNameAndMessageForXStatus", SETTING_THIRDLINE_XSTATUSNAMETEXT_DEFAULT); } + else memset(&dat->thirdLine, 0, sizeof(dat->thirdLine)); dat->rightMargin = db_get_b(NULL, "CLC", "RightMargin", CLCDEFAULT_RIGHTMARGIN); dat->force_in_dialog = (pcli->hwndContactTree) ? (hwnd != pcli->hwndContactTree) : 0; diff --git a/plugins/Clist_modern/src/modern_clist.h b/plugins/Clist_modern/src/modern_clist.h index 3d321906d0..edce2c60a6 100644 --- a/plugins/Clist_modern/src/modern_clist.h +++ b/plugins/Clist_modern/src/modern_clist.h @@ -59,13 +59,13 @@ public: DestroySmileyList(); } - void ReplaceSmileys(struct SHORTDATA *dat, ClcCacheEntry *pdnce, TCHAR *szText, BOOL replace_smileys); + void ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, TCHAR *szText, BOOL replace_smileys); /** Destroy smiley list */ void DestroySmileyList(); /** Copy Smiley List */ void _CopySmileyList(SortedList *plInput); - void AddListeningToIcon(SHORTDATA *dat, TCHAR *szText); + void AddListeningToIcon(ClcData *dat, TCHAR *szText); }; diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index 1de81d7980..2377f671e9 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "modern_clist.h" #include "modern_commonprototypes.h" -#include "modern_gettextasync.h" #include "modern_sync.h" #include "modern_clui.h" #include @@ -138,7 +137,6 @@ void UnLoadContactListModule() //unhooks noncritical events int CListMod_ContactListShutdownProc(WPARAM, LPARAM) { - gtaShutdown(); FreeDisplayNameCache(); return 0; } diff --git a/plugins/Clist_modern/src/modern_clistsettings.cpp b/plugins/Clist_modern/src/modern_clistsettings.cpp index f244b0b54f..0c6ff8b492 100644 --- a/plugins/Clist_modern/src/modern_clistsettings.cpp +++ b/plugins/Clist_modern/src/modern_clistsettings.cpp @@ -26,16 +26,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "modern_clist.h" #include "modern_commonprototypes.h" #include "modern_awaymsg.h" -#include "modern_gettextasync.h" void InsertContactIntoTree(MCONTACT hContact, int status); -void CListSettings_FreeCacheItemDataOption(ClcCacheEntry *pDst, DWORD flag); TCHAR* UnknownConctactTranslatedName = NULL; void InitDisplayNameCache(void) { - InitCacheAsync(); InitAwayMsgModule(); } @@ -44,96 +41,6 @@ void FreeDisplayNameCache() UninitAwayMsgModule(); } -void CListSettings_FreeCacheItemData(ClcCacheEntry *pDst) -{ - CListSettings_FreeCacheItemDataOption(pDst, CCI_ALL); -} - -void CListSettings_FreeCacheItemDataOption(ClcCacheEntry *pDst, DWORD flag) -{ - if (!pDst) - return; - - if (flag & CCI_NAME) - mir_free_and_nil(pDst->tszName); - - if (flag & CCI_GROUP) - mir_free_and_nil(pDst->tszGroup); - - if (flag & CCI_LINES) { - mir_free_and_nil(pDst->szSecondLineText); - mir_free_and_nil(pDst->szThirdLineText); - pDst->ssSecondLine.DestroySmileyList(); - pDst->ssThirdLine.DestroySmileyList(); - } -} - -int CListSettings_GetCopyFromCache(ClcCacheEntry *pDest, DWORD flag); -int CListSettings_SetToCache(ClcCacheEntry *pSrc, DWORD flag); - -void CListSettings_CopyCacheItems(ClcCacheEntry *pDst, ClcCacheEntry *pSrc, DWORD flag) -{ - if (!pDst || !pSrc) return; - CListSettings_FreeCacheItemDataOption(pDst, flag); - - if (flag & CCI_NAME) pDst->tszName = mir_tstrdup(pSrc->tszName); - if (flag & CCI_GROUP) pDst->tszGroup = mir_tstrdup(pSrc->tszGroup); - if (flag & CCI_PROTO) pDst->m_pszProto = pSrc->m_pszProto; - if (flag & CCI_STATUS) pDst->m_iStatus = pSrc->m_iStatus; - - if (flag & CCI_LINES) { - mir_free(pDst->szThirdLineText); - pDst->szThirdLineText = mir_tstrdup(pSrc->szThirdLineText); - - mir_free(pDst->szSecondLineText); - pDst->szSecondLineText = mir_tstrdup(pSrc->szSecondLineText); - - pDst->ssThirdLine = pSrc->ssThirdLine; - pDst->ssSecondLine = pSrc->ssSecondLine; - } - - if (flag & CCI_TIME) - pDst->hTimeZone = pSrc->hTimeZone; - - if (flag & CCI_OTHER) { - pDst->bIsHidden = pSrc->bIsHidden; - pDst->m_bNoHiddenOffline = pSrc->m_bNoHiddenOffline; - - pDst->m_bIsSub = pSrc->m_bIsSub; - pDst->ApparentMode = pSrc->ApparentMode; - pDst->NotOnList = pSrc->NotOnList; - pDst->IdleTS = pSrc->IdleTS; - pDst->ClcContact = pSrc->ClcContact; - pDst->IsExpanded = pSrc->IsExpanded; - } -} - -int CListSettings_GetCopyFromCache(ClcCacheEntry *pDest, DWORD flag) -{ - if (!pDest || !pDest->hContact) - return -1; - - ClcCacheEntry *pSource = pcli->pfnGetCacheEntry(pDest->hContact); - if (!pSource) - return -1; - - CListSettings_CopyCacheItems(pDest, pSource, flag); - return 0; -} - -int CListSettings_SetToCache(ClcCacheEntry *pSrc, DWORD flag) -{ - if (!pSrc || !pSrc->hContact) - return -1; - - ClcCacheEntry *pDst = pcli->pfnGetCacheEntry(pSrc->hContact); - if (!pDst) - return -1; - - CListSettings_CopyCacheItems(pDst, pSrc, flag); - return 0; -} - void cliFreeCacheItem(ClcCacheEntry *p) { mir_free_and_nil(p->tszName); diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 98a383166a..d2d3919cc2 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -1227,23 +1227,6 @@ int CLUI_SizingGetWindowRect(HWND hwnd, RECT *rc) } -int CLUI_SyncGetPDNCE(WPARAM wParam, LPARAM lParam) -{ - return CListSettings_GetCopyFromCache((ClcCacheEntry *)lParam, wParam ? (DWORD)wParam : CCI_ALL); -} - -int CLUI_SyncSetPDNCE(WPARAM wParam, LPARAM lParam) -{ - return CListSettings_SetToCache((ClcCacheEntry *)lParam, wParam ? (DWORD)wParam : CCI_ALL); -} - -int CLUI_SyncGetShortData(WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = (HWND)wParam; - ClcData *dat = (ClcData *)GetWindowLongPtr(hwnd, 0); - return ClcGetShortData(dat, (SHORTDATA*)lParam); -} - int CLUI_IconsChanged(WPARAM, LPARAM) { if (MirandaExiting()) @@ -2544,9 +2527,6 @@ LRESULT CLUI::OnDestroy(UINT, WPARAM, LPARAM) if (amWakeThread()) wait = TRUE; - if (gtaWakeThread()) - wait = TRUE; - if (wait) { //need to give them a little time to exit. Sleep(50); diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index addd09a319..628ab82fc8 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -192,7 +192,7 @@ HICON cliGetIconFromStatusMode(MCONTACT hContact, const char *szProto, int sta HICON GetMainStatusOverlay(int STATUS); //clc.c int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szStatus, ClcData *dat); //clcitems.c int BgStatusBarChange(WPARAM wParam, LPARAM lParam); //clcopts.c -int ClcDoProtoAck(MCONTACT wParam, ACKDATA *ack); //clc.c +int ClcDoProtoAck(ACKDATA *ack); //clc.c int ModernSkinButtonDeleteAll(); //modernbutton.c int GetContactCachedStatus(MCONTACT hContact); //clistsettings.c int GetContactIconC(ClcCacheEntry *cacheEntry); //clistmod.c @@ -230,8 +230,7 @@ void UpdateAllAvatars(ClcData *dat); //cac void ApplyViewMode(const char *Name, bool onlySelector = false); void SaveViewMode(const char *name, const TCHAR *szGroupFilter, const char *szProtoFilter, DWORD statusMask, DWORD stickyStatusMask, unsigned int options, unsigned int stickies, unsigned int operators, unsigned int lmdat); -//cluiframes.c -void gtaRenewText(MCONTACT hContact); +// cluiframes.c int ExtraImage_ExtraIDToColumnNum(int extra); int LoadSkinButtonModule(); diff --git a/plugins/Clist_modern/src/modern_gettextasync.cpp b/plugins/Clist_modern/src/modern_gettextasync.cpp deleted file mode 100644 index 7180896a78..0000000000 --- a/plugins/Clist_modern/src/modern_gettextasync.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-16 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-08 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -* Author Artem Shpynov aka FYR -* Copyright 2000-2008 Artem Shpynov -*/ - -////////////////////////////////////////////////////////////////////////// -// Module to async parsing of texts - -#include "stdafx.h" -#include "modern_gettextasync.h" -#include "newpluginapi.h" -#include "modern_sync.h" - -int CLUI_SyncSetPDNCE(WPARAM wParam, LPARAM lParam); -int CLUI_SyncGetShortData(WPARAM wParam, LPARAM lParam); - -typedef struct _GetTextAsyncItem { - MCONTACT hContact; - ClcData *dat; - struct _GetTextAsyncItem *Next; -} GTACHAINITEM; - -static GTACHAINITEM *gtaFirstItem = NULL; -static GTACHAINITEM *gtaLastItem = NULL; -static mir_cs gtaCS; -static HANDLE hgtaWakeupEvent = NULL; - -static BOOL gtaGetItem(GTACHAINITEM *mpChain) -{ - if (!mpChain) - return FALSE; - - mir_cslock lck(gtaCS); - if (!gtaFirstItem) - return FALSE; - - GTACHAINITEM *ch = gtaFirstItem; - *mpChain = *ch; - gtaFirstItem = (GTACHAINITEM*)ch->Next; - if (!gtaFirstItem) - gtaLastItem = NULL; - free(ch); - return TRUE; -} - -static void gtaThreadProc(void*) -{ - Netlib_Logf(NULL, "GTA thread start"); - - SHORTDATA data = { 0 }; - - while (!MirandaExiting()) { - Sync(CLUI_SyncGetShortData, (WPARAM)pcli->hwndContactTree, (LPARAM)&data); - while (true) { - if (MirandaExiting()) - goto LBL_Exit; - - SleepEx(0, TRUE); //1000 contacts per second - - GTACHAINITEM mpChain = { 0 }; - SHORTDATA dat2 = { 0 }; - if (!gtaGetItem(&mpChain)) - break; - - SHORTDATA *dat; - if (mpChain.dat == NULL || (!IsBadReadPtr(mpChain.dat, sizeof(*mpChain.dat)) && mpChain.dat->hWnd == data.hWnd)) - dat = &data; - else { - Sync(CLUI_SyncGetShortData, (WPARAM)mpChain.dat->hWnd, (LPARAM)&dat2); - dat = &dat2; - } - if (MirandaExiting()) - goto LBL_Exit; - - ClcCacheEntry cacheEntry; - memset(&cacheEntry, 0, sizeof(cacheEntry)); - cacheEntry.hContact = mpChain.hContact; - if (!Sync(CLUI_SyncGetPDNCE, (WPARAM)0, (LPARAM)&cacheEntry)) { - Cache_GetSecondLineText(dat, &cacheEntry); - Cache_GetThirdLineText(dat, &cacheEntry); - Sync(CLUI_SyncSetPDNCE, (WPARAM)CCI_LINES, (LPARAM)&cacheEntry); - CListSettings_FreeCacheItemData(&cacheEntry); - } - - KillTimer(dat->hWnd, TIMERID_INVALIDATE_FULL); - CLUI_SafeSetTimer(dat->hWnd, TIMERID_INVALIDATE_FULL, 500, NULL); - } - - WaitForSingleObjectEx(hgtaWakeupEvent, INFINITE, TRUE); - ResetEvent(hgtaWakeupEvent); - } - -LBL_Exit: - CloseHandle(hgtaWakeupEvent); - hgtaWakeupEvent = NULL; - g_hGetTextAsyncThread = NULL; - Netlib_Logf(NULL, "GTA thread end"); -} - -BOOL gtaWakeThread() -{ - if (hgtaWakeupEvent && g_hGetTextAsyncThread) { - SetEvent(hgtaWakeupEvent); - return TRUE; - } - - return FALSE; -} - -int gtaAddRequest(ClcData *dat, MCONTACT hContact) -{ - if (MirandaExiting()) return 0; - - mir_cslock lck(gtaCS); - - GTACHAINITEM *mpChain = (GTACHAINITEM*)malloc(sizeof(GTACHAINITEM)); - mpChain->hContact = hContact; - mpChain->dat = dat; - mpChain->Next = NULL; - if (gtaLastItem) { - gtaLastItem->Next = (GTACHAINITEM*)mpChain; - gtaLastItem = mpChain; - } - else { - gtaFirstItem = mpChain; - gtaLastItem = mpChain; - SetEvent(hgtaWakeupEvent); - } - - return FALSE; -} - -void gtaRenewText(MCONTACT hContact) -{ - gtaAddRequest(NULL, hContact); -} - -void gtaShutdown() -{ - if (hgtaWakeupEvent) - SetEvent(hgtaWakeupEvent); -} - -void InitCacheAsync() -{ - hgtaWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - g_hGetTextAsyncThread = mir_forkthread(gtaThreadProc, 0); -} diff --git a/plugins/Clist_modern/src/modern_gettextasync.h b/plugins/Clist_modern/src/modern_gettextasync.h deleted file mode 100644 index c53039da71..0000000000 --- a/plugins/Clist_modern/src/modern_gettextasync.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -void InitCacheAsync(); - -void gtaRenewText(MCONTACT hContact); -int gtaAddRequest(ClcData *dat, MCONTACT hContact); -void gtaShutdown(void); diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index 00119588d1..7a09e62960 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -159,9 +159,9 @@ int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item) case TC_TEXT2: { int tmp = 0; - if (dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { + if (dat->secondLine.show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight); if (item == -1) { //calculate text width here @@ -184,9 +184,9 @@ int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item) case TC_TEXT3: { int tmp = 0; - if (dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { + if (dat->thirdLine.show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight); if (item == -1) { //calculate text width here @@ -397,18 +397,18 @@ int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd) max_height += tmp; - if (dat->second_line_show) { + if (dat->secondLine.show) { tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) tmp = max(tmp, dat->text_smiley_height); - max_height += dat->second_line_top_space + tmp; + max_height += dat->secondLine.top_space + tmp; } - if (dat->third_line_show) { + if (dat->thirdLine.show) { tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) tmp = max(tmp, dat->text_smiley_height); - max_height += dat->third_line_top_space + tmp; + max_height += dat->thirdLine.top_space + tmp; } // Get other font sizes @@ -545,19 +545,19 @@ int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, tmp = max(tmp, contact->ssText.iMaxSmileyHeight); height += tmp; - if (pdnce) { - if (!minimalistic && dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { + if (pdnce && !minimalistic) { + if (dat->secondLine.show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight); - height += dat->second_line_top_space + tmp; + height += dat->secondLine.top_space + tmp; } - if (!minimalistic && dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { + if (dat->thirdLine.show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight); - height += dat->third_line_top_space + tmp; + height += dat->thirdLine.top_space + tmp; } } } diff --git a/plugins/Clist_modern/src/modern_static_clui.h b/plugins/Clist_modern/src/modern_static_clui.h index 46ac620ac0..734ea3142a 100644 --- a/plugins/Clist_modern/src/modern_static_clui.h +++ b/plugins/Clist_modern/src/modern_static_clui.h @@ -55,15 +55,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Declaration of prototypes in other modules */ int ClcUnloadModule(); -int ClcGetShortData(ClcData* pData, SHORTDATA *pShortData); int ClcEnterDragToScroll(HWND hwnd, int Y); int CListMod_ContactListShutdownProc(WPARAM wParam, LPARAM lParam); int CListMod_HideWindow(HWND hwndContactList, int mode); -int CListSettings_GetCopyFromCache(ClcCacheEntry *pDest, DWORD flag); -int CListSettings_SetToCache(ClcCacheEntry *pSrc, DWORD flag); - int CLUIServices_LoadModule(void); INT_PTR CLUIServices_SortList(WPARAM wParam, LPARAM lParam); @@ -118,5 +114,4 @@ int SizeFramesByWindowRect(RECT *r, HDWP * PosBatch, int mode); //cluiframes.c int InitSkinHotKeys(); BOOL amWakeThread(); -BOOL gtaWakeThread(); void CreateViewModeFrame(); diff --git a/plugins/Clist_modern/src/stdafx.h b/plugins/Clist_modern/src/stdafx.h index 8382e91ae4..196d825723 100644 --- a/plugins/Clist_modern/src/stdafx.h +++ b/plugins/Clist_modern/src/stdafx.h @@ -244,9 +244,6 @@ int AniAva_RenderAvatar(MCONTACT hContact, HDC hdcMem, RECT *rc); #define CCI_OTHER ~( CCI_NAME|CCI_GROUP|CCI_PROTO|CCI_STATUS|CCI_LINES|CCI_TIME ) #define CCI_ALL (0xFFFFFFFF) -void CListSettings_FreeCacheItemData(ClcCacheEntry *pDst); -int CLUI_SyncGetPDNCE(WPARAM wParam, LPARAM lParam); - /* move to list module */ typedef void(*ItemDestuctor)(void*); -- cgit v1.2.3