summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Clist_modern/src/hdr/modern_gettextasync.h5
-rw-r--r--plugins/Clist_modern/src/modern_cachefuncs.cpp56
-rw-r--r--plugins/Clist_modern/src/modern_clistmod.cpp108
-rw-r--r--plugins/Clist_modern/src/modern_clistsettings.cpp5
-rw-r--r--plugins/Clist_modern/src/modern_gettextasync.cpp95
5 files changed, 114 insertions, 155 deletions
diff --git a/plugins/Clist_modern/src/hdr/modern_gettextasync.h b/plugins/Clist_modern/src/hdr/modern_gettextasync.h
index 2a8c63296d..c53039da71 100644
--- a/plugins/Clist_modern/src/hdr/modern_gettextasync.h
+++ b/plugins/Clist_modern/src/hdr/modern_gettextasync.h
@@ -1,5 +1,6 @@
#pragma once
void InitCacheAsync();
-void UninitCacheAsync();
+
void gtaRenewText(MCONTACT hContact);
-int gtaAddRequest(ClcData *dat, MCONTACT hContact);
+int gtaAddRequest(ClcData *dat, MCONTACT hContact);
+void gtaShutdown(void);
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp
index fd8b30654c..e904b1d407 100644
--- a/plugins/Clist_modern/src/modern_cachefuncs.cpp
+++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp
@@ -25,9 +25,8 @@ Created by Pescuma
Modified by FYR
*/
-/************************************************************************/
-/* Module for working with lines text and avatars */
-/************************************************************************/
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module for working with lines text and avatars
#include "hdr/modern_commonheaders.h"
#include "hdr/modern_cache_funcs.h"
@@ -37,12 +36,8 @@ Modified by FYR
typedef BOOL(*ExecuteOnAllContactsFuncPtr) (ClcContact *contact, BOOL subcontact, void *param);
-
-/***********************************/
-/** Module static declarations **/
-/***********************************/
-
-/* Module Static Prototypes */
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module static declarations
static int CopySkipUnprintableChars(TCHAR *to, TCHAR * buf, DWORD size);
@@ -51,9 +46,10 @@ static BOOL ExecuteOnAllContactsOfGroup(ClcGroup *group, ExecuteOnAllContactsFun
int CLUI_SyncGetShortData(WPARAM wParam, LPARAM lParam);
void CListSettings_FreeCacheItemData(ClcCacheEntry *pDst);
void CListSettings_FreeCacheItemDataOption(ClcCacheEntry *pDst, DWORD flag);
-/*
- * Get time zone for contact
- */
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Get time zone for contact
+
void Cache_GetTimezone(ClcData *dat, MCONTACT hContact)
{
ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(hContact);
@@ -66,9 +62,8 @@ void Cache_GetTimezone(ClcData *dat, MCONTACT hContact)
}
}
-/*
- * Get all lines of text
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// Get all lines of text
void Cache_GetText(ClcData *dat, ClcContact *contact, BOOL forceRenew)
{
@@ -85,7 +80,8 @@ void CSmileyString::AddListeningToIcon(struct SHORTDATA *dat, TCHAR *szText)
iMaxSmileyHeight = 0;
DestroySmileyList();
- if (szText == NULL) return;
+ if (szText == NULL)
+ return;
int text_size = (int)_tcslen(szText);
@@ -555,17 +551,13 @@ void Cache_GetSecondLineText(struct SHORTDATA *dat, ClcCacheEntry *pdnce)
int type = TEXT_EMPTY;
if (dat->second_line_show)
- type = Cache_GetLineText(pdnce, dat->second_line_type, (TCHAR*)Text, SIZEOF(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);
- Text[SIZEOF(Text) - 1] = 0; //to be sure that it is null terminated string
+ type = Cache_GetLineText(pdnce, dat->second_line_type, Text, SIZEOF(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);
- mir_free(pdnce->szSecondLineText);
+ Text[SIZEOF(Text) - 1] = 0; //to be sure that it is null terminated string
- if (dat->second_line_show)// Text[0] != '\0')
- pdnce->szSecondLineText = mir_tstrdup((TCHAR*)Text);
- else
- pdnce->szSecondLineText = NULL;
+ replaceStrT(pdnce->szSecondLineText, (dat->second_line_show) ? Text : NULL);
if (pdnce->szSecondLineText) {
if (type == TEXT_LISTENING_TO && pdnce->szSecondLineText[0] != _T('\0'))
@@ -583,19 +575,13 @@ void Cache_GetThirdLineText(struct 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, (TCHAR*)Text, SIZEOF(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);
+ type = Cache_GetLineText(pdnce, dat->third_line_type, Text, SIZEOF(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[SIZEOF(Text) - 1] = 0; //to be sure that it is null terminated string
- mir_free(pdnce->szThirdLineText);
-
- if (dat->third_line_show)//Text[0] != '\0')
- pdnce->szThirdLineText = mir_tstrdup((TCHAR*)Text);
- else
- pdnce->szThirdLineText = NULL;
-
+ 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);
diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp
index 11f64df30c..1109791927 100644
--- a/plugins/Clist_modern/src/modern_clistmod.cpp
+++ b/plugins/Clist_modern/src/modern_clistmod.cpp
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "hdr/modern_commonheaders.h"
#include "hdr/modern_clist.h"
#include "hdr/modern_commonprototypes.h"
+#include "hdr/modern_gettextasync.h"
#include "hdr/modern_sync.h"
#include "hdr/modern_clui.h"
#include <m_modernopt.h>
@@ -141,6 +142,7 @@ void UnLoadContactListModule() //unhooks noncritical events
int CListMod_ContactListShutdownProc(WPARAM, LPARAM)
{
+ gtaShutdown();
FreeDisplayNameCache();
return 0;
}
@@ -162,7 +164,7 @@ INT_PTR SvcActiveSkin(WPARAM wParam, LPARAM lParam);
INT_PTR SvcPreviewSkin(WPARAM wParam, LPARAM lParam);
INT_PTR SvcApplySkin(WPARAM wParam, LPARAM lParam);
-HRESULT CluiLoadModule()
+HRESULT CluiLoadModule()
{
InitDisplayNameCache();
HookEvent(ME_SYSTEM_SHUTDOWN, CListMod_ContactListShutdownProc);
@@ -188,9 +190,6 @@ HRESULT CluiLoadModule()
return S_OK;
}
-/*
-Begin of Hrk's code for bug
-*/
#define GWVS_HIDDEN 1
#define GWVS_VISIBLE 2
#define GWVS_COVERED 3
@@ -208,41 +207,32 @@ __inline DWORD GetDIBPixelColor(int X, int Y, int Width, int Height, int ByteWid
int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
{
if (hWnd == NULL) {
- SetLastError(0x00000006); //Wrong handle
+ SetLastError(0x00000006); // Wrong handle
return -1;
}
- RECT rc = { 0 };
- POINT pt = { 0 };
- int i = 0, j = 0, width = 0, height = 0, iCountedDots = 0, iNotCoveredDots = 0;
- HWND hAux = 0;
-
- //Some defaults now. The routine is designed for thin and tall windows.
- if (iStepX <= 0) iStepX = 8;
- if (iStepY <= 0) iStepY = 16;
-
- HWND hwndFocused = GetFocus();
-
if (IsIconic(hWnd) || !IsWindowVisible(hWnd))
return GWVS_HIDDEN;
if (db_get_b(NULL, "CList", "OnDesktop", SETTING_ONDESKTOP_DEFAULT) || !db_get_b(NULL, "CList", "BringToFront", SETTING_BRINGTOFRONT_DEFAULT))
return GWVS_VISIBLE;
+ HWND hwndFocused = GetFocus();
if (hwndFocused == pcli->hwndContactList || GetParent(hwndFocused) == pcli->hwndContactList)
return GWVS_VISIBLE;
- int hstep, vstep;
- BITMAP bmp;
- HBITMAP WindowImage;
+ // Some defaults now. The routine is designed for thin and tall windows.
+ if (iStepX <= 0) iStepX = 8;
+ if (iStepY <= 0) iStepY = 16;
+
int maxx = 0;
int maxy = 0;
int wx = 0;
- int dx, dy;
BYTE *ptr = NULL;
HRGN rgn = NULL;
- WindowImage = g_CluiData.fLayered ? ske_GetCurrentWindowImage() : 0;
+ HBITMAP WindowImage = g_CluiData.fLayered ? ske_GetCurrentWindowImage() : 0;
if (WindowImage && g_CluiData.fLayered) {
+ BITMAP bmp;
GetObject(WindowImage, sizeof(BITMAP), &bmp);
ptr = (BYTE*)bmp.bmBits;
maxx = bmp.bmWidth;
@@ -259,27 +249,32 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
//maxx = rc.right;
//maxy = rc.bottom;
}
+
+ RECT rc;
GetWindowRect(hWnd, &rc);
- {
- RECT rcMonitor = { 0 };
- Docking_GetMonitorRectFromWindow(hWnd, &rcMonitor);
- rc.top = rc.top < rcMonitor.top ? rcMonitor.top : rc.top;
- rc.left = rc.left < rcMonitor.left ? rcMonitor.left : rc.left;
- rc.bottom = rc.bottom > rcMonitor.bottom ? rcMonitor.bottom : rc.bottom;
- rc.right = rc.right > rcMonitor.right ? rcMonitor.right : rc.right;
- }
- width = rc.right - rc.left;
- height = rc.bottom - rc.top;
- dx = -rc.left;
- dy = -rc.top;
- hstep = width / iStepX;
- vstep = height / iStepY;
+
+ RECT rcMonitor = { 0 };
+ Docking_GetMonitorRectFromWindow(hWnd, &rcMonitor);
+
+ rc.top = rc.top < rcMonitor.top ? rcMonitor.top : rc.top;
+ rc.left = rc.left < rcMonitor.left ? rcMonitor.left : rc.left;
+ rc.bottom = rc.bottom > rcMonitor.bottom ? rcMonitor.bottom : rc.bottom;
+ rc.right = rc.right > rcMonitor.right ? rcMonitor.right : rc.right;
+
+ int width = rc.right - rc.left;
+ int height = rc.bottom - rc.top;
+ int dx = -rc.left;
+ int dy = -rc.top;
+ int hstep = width / iStepX;
+ int vstep = height / iStepY;
hstep = hstep > 0 ? hstep : 1;
vstep = vstep > 0 ? vstep : 1;
- for (i = rc.top; i < rc.bottom; i += vstep) {
+ int iCountedDots = 0, iNotCoveredDots = 0;
+ for (int i = rc.top; i < rc.bottom; i += vstep) {
+ POINT pt;
pt.y = i;
- for (j = rc.left; j < rc.right; j += hstep) {
+ for (int j = rc.left; j < rc.right; j += hstep) {
BOOL po = FALSE;
pt.x = j;
if (rgn)
@@ -293,13 +288,13 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
if (po || (!rgn && ptr == 0)) {
BOOL hWndFound = FALSE;
HWND hAuxOld = NULL;
- hAux = WindowFromPoint(pt);
+ HWND hAux = WindowFromPoint(pt);
do {
if (hAux == hWnd) {
hWndFound = TRUE;
break;
}
- //hAux = GetParent(hAux);
+
hAuxOld = hAux;
hAux = GetAncestor(hAux, GA_ROOTOWNER);
if (hAuxOld == hAux) {
@@ -310,24 +305,25 @@ int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
break;
}
}
- } while (hAux != NULL && hAuxOld != hAux);
+ }
+ while (hAux != NULL && hAuxOld != hAux);
- if (hWndFound) //There's window!
- iNotCoveredDots++; //Let's count the not covered dots.
- iCountedDots++; //Let's keep track of how many dots we checked.
+ if (hWndFound) // There's window!
+ iNotCoveredDots++; // Let's count the not covered dots.
+ iCountedDots++; // Let's keep track of how many dots we checked.
}
}
}
if (rgn)
DeleteObject(rgn);
- if (iCountedDots - iNotCoveredDots < 2) //Every dot was not covered: the window is visible.
+ if (iCountedDots - iNotCoveredDots < 2) // Every dot was not covered: the window is visible.
return GWVS_VISIBLE;
- if (iNotCoveredDots == 0) //They're all covered!
+ if (iNotCoveredDots == 0) // They're all covered!
return GWVS_COVERED;
- //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
+ // There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
return GWVS_PARTIALLY_COVERED;
}
@@ -401,15 +397,13 @@ int cliShowHide(WPARAM, LPARAM lParam)
CListMod_HideWindow();
db_set_b(NULL, "CList", "State", SETTING_STATE_HIDDEN);
}
+ else if (db_get_b(NULL, "CList", "Min2Tray", SETTING_MIN2TRAY_DEFAULT)) {
+ CLUI_ShowWindowMod(pcli->hwndContactList, SW_HIDE);
+ db_set_b(NULL, "CList", "State", SETTING_STATE_HIDDEN);
+ }
else {
- if (db_get_b(NULL, "CList", "Min2Tray", SETTING_MIN2TRAY_DEFAULT)) {
- CLUI_ShowWindowMod(pcli->hwndContactList, SW_HIDE);
- db_set_b(NULL, "CList", "State", SETTING_STATE_HIDDEN);
- }
- else {
- CLUI_ShowWindowMod(pcli->hwndContactList, SW_MINIMIZE);
- db_set_b(NULL, "CList", "State", SETTING_STATE_MINIMIZED);
- }
+ CLUI_ShowWindowMod(pcli->hwndContactList, SW_MINIMIZE);
+ db_set_b(NULL, "CList", "State", SETTING_STATE_MINIMIZED);
}
SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1);
@@ -419,7 +413,9 @@ int cliShowHide(WPARAM, LPARAM lParam)
int CListMod_HideWindow()
{
- KillTimer(pcli->hwndContactList, 1/*TM_AUTOALPHA*/);
- if (!CLUI_HideBehindEdge()) return CLUI_SmoothAlphaTransition(pcli->hwndContactList, 0, 1);
+ KillTimer(pcli->hwndContactList, 1);
+
+ if (!CLUI_HideBehindEdge())
+ return CLUI_SmoothAlphaTransition(pcli->hwndContactList, 0, 1);
return 0;
}
diff --git a/plugins/Clist_modern/src/modern_clistsettings.cpp b/plugins/Clist_modern/src/modern_clistsettings.cpp
index 55f5438e15..682f2f1658 100644
--- a/plugins/Clist_modern/src/modern_clistsettings.cpp
+++ b/plugins/Clist_modern/src/modern_clistsettings.cpp
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "hdr/modern_clist.h"
#include "hdr/modern_commonprototypes.h"
#include "hdr/modern_awaymsg.h"
+#include "hdr/modern_gettextasync.h"
void InsertContactIntoTree(MCONTACT hContact, int status);
void CListSettings_FreeCacheItemDataOption(ClcCacheEntry *pDst, DWORD flag);
@@ -39,9 +40,6 @@ TCHAR* UnknownConctactTranslatedName = NULL;
void InvalidateDNCEbyPointer(MCONTACT hContact, ClcCacheEntry *pdnce, int SettingType);
-void InitCacheAsync();
-void UninitCacheAsync();
-
void InitDisplayNameCache(void)
{
InitCacheAsync();
@@ -50,7 +48,6 @@ void InitDisplayNameCache(void)
void FreeDisplayNameCache()
{
- UninitCacheAsync();
UninitAwayMsgModule();
for (int i = 0; i < clistCache.getCount(); i++) {
diff --git a/plugins/Clist_modern/src/modern_gettextasync.cpp b/plugins/Clist_modern/src/modern_gettextasync.cpp
index f876227b28..23e6a7f9dd 100644
--- a/plugins/Clist_modern/src/modern_gettextasync.cpp
+++ b/plugins/Clist_modern/src/modern_gettextasync.cpp
@@ -38,45 +38,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int CLUI_SyncSetPDNCE(WPARAM wParam, LPARAM lParam);
int CLUI_SyncGetShortData(WPARAM wParam, LPARAM lParam);
-#define gtalock EnterCriticalSection(&gtaCS)
-#define gtaunlock LeaveCriticalSection( &gtaCS )
-
typedef struct _GetTextAsyncItem {
MCONTACT hContact;
ClcData *dat;
struct _GetTextAsyncItem *Next;
} GTACHAINITEM;
-static GTACHAINITEM * gtaFirstItem = NULL;
-static GTACHAINITEM * gtaLastItem = NULL;
-static CRITICAL_SECTION gtaCS;
+static GTACHAINITEM *gtaFirstItem = NULL;
+static GTACHAINITEM *gtaLastItem = NULL;
+static mir_cs gtaCS;
static HANDLE hgtaWakeupEvent = NULL;
-
-static BOOL gtaGetItem(GTACHAINITEM * mpChain)
+static BOOL gtaGetItem(GTACHAINITEM *mpChain)
{
- gtalock;
+ if (!mpChain)
+ return FALSE;
+
+ mir_cslock lck(gtaCS);
if (!gtaFirstItem)
- {
- gtaunlock;
return FALSE;
- }
- else if (mpChain)
- {
- GTACHAINITEM * ch;
- ch = gtaFirstItem;
- *mpChain = *ch;
- gtaFirstItem = (GTACHAINITEM *)ch->Next;
- if (!gtaFirstItem) gtaLastItem = NULL;
- free(ch);
- gtaunlock;
- return TRUE;
- }
- gtaunlock;
- return FALSE;
+
+ GTACHAINITEM *ch = gtaFirstItem;
+ *mpChain = *ch;
+ gtaFirstItem = (GTACHAINITEM*)ch->Next;
+ if (!gtaFirstItem)
+ gtaLastItem = NULL;
+ free(ch);
+ return TRUE;
}
-static void gtaThreadProc(void *)
+static void gtaThreadProc(void*)
{
thread_catcher lck(g_hGetTextAsyncThread);
SHORTDATA data = { 0 };
@@ -121,6 +112,9 @@ static void gtaThreadProc(void *)
WaitForSingleObjectEx(hgtaWakeupEvent, INFINITE, TRUE);
ResetEvent(hgtaWakeupEvent);
}
+
+ CloseHandle(hgtaWakeupEvent);
+ hgtaWakeupEvent = NULL;
}
BOOL gtaWakeThread()
@@ -136,25 +130,23 @@ BOOL gtaWakeThread()
int gtaAddRequest(ClcData *dat, MCONTACT hContact)
{
if (MirandaExiting()) return 0;
- gtalock;
- {
- 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);
- }
+
+ 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;
}
- gtaunlock;
+ else {
+ gtaFirstItem = mpChain;
+ gtaLastItem = mpChain;
+ SetEvent(hgtaWakeupEvent);
+ }
+
return FALSE;
}
@@ -163,26 +155,13 @@ void gtaRenewText(MCONTACT hContact)
gtaAddRequest(NULL, hContact);
}
-int gtaOnModulesUnload(WPARAM, LPARAM)
+void gtaShutdown()
{
SetEvent(hgtaWakeupEvent);
- return 0;
}
void InitCacheAsync()
{
- InitializeCriticalSection(&gtaCS);
hgtaWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
g_hGetTextAsyncThread = mir_forkthread(gtaThreadProc, 0);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, gtaOnModulesUnload);
-}
-
-void UninitCacheAsync()
-{
- SetEvent(hgtaWakeupEvent);
- while (g_hGetTextAsyncThread)
- SleepEx(50, TRUE);
-
- CloseHandle(hgtaWakeupEvent);
- DeleteCriticalSection(&gtaCS);
}