summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-03 16:19:36 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-03 16:19:36 +0000
commit42619a142919bc0d71a8918a3605b1a49b97eb5b (patch)
tree1c134aa4e7f32163850f2c6760f29d7936df2cbe /src
parentaf27a9fe06fc362cc9b824b75ca0d8ec58f95d6d (diff)
various cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@5567 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/modules/clist/clisttray.cpp179
-rw-r--r--src/modules/skin/hotkeys.cpp4
2 files changed, 78 insertions, 105 deletions
diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp
index 2bb5356a60..564c21cfa1 100644
--- a/src/modules/clist/clisttray.cpp
+++ b/src/modules/clist/clisttray.cpp
@@ -43,9 +43,6 @@ static CRITICAL_SECTION trayLockCS;
#define NIF_STATE 0x00000008
#define NIF_INFO 0x00000010
-#define lock cli.pfnLockTray()
-#define ulock cli.pfnUnlockTray()
-
#define initcheck if ( !fTrayInited) return
#define SIZEOFNID ((cli.shellVersion >= 5) ? NOTIFYICONDATA_V2_SIZE : NOTIFYICONDATA_V1_SIZE)
@@ -83,40 +80,35 @@ static void SetTaskBarIcon(const HICON hIcon, const TCHAR *szNewTip)
TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto)
{
TCHAR *szStatus, *szSeparator;
- TCHAR *ProtoXStatus = NULL;
- int t;
- PROTOACCOUNT* pa;
initcheck NULL;
- lock;
+
+ mir_cslock lck(trayLockCS);
if ( !mToolTipTrayTips)
szSeparator = (IsWinVerMEPlus()) ? szSeparator = _T("\n") : _T(" | ");
else
szSeparator = _T("\n");
if (szProto == NULL) {
- if (accounts.getCount() == 0) {
- ulock;
+ if (accounts.getCount() == 0)
return NULL;
- }
- if (accounts.getCount() == 1) {
- ulock;
+
+ if (accounts.getCount() == 1)
return cli.pfnTrayIconMakeTooltip(szPrefix, accounts[0]->szModuleName);
- }
if (szPrefix && szPrefix[0]) {
lstrcpyn(cli.szTip, szPrefix, MAX_TIP_SIZE);
if ( !db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT))
- { ulock; return cli.szTip; }
+ return cli.szTip;
}
else cli.szTip[0] = '\0';
- cli.szTip[ MAX_TIP_SIZE-1 ] = '\0';
+ cli.szTip[MAX_TIP_SIZE-1] = '\0';
- for (t = 0; t < accounts.getCount(); t++) {
+ for (int t = 0; t < accounts.getCount(); t++) {
int i = cli.pfnGetAccountIndexByPos(t);
if (i == -1)
continue;
- pa = accounts[i];
+ PROTOACCOUNT *pa = accounts[i];
if ( !cli.pfnGetProtocolVisibility(pa->szModuleName))
continue;
@@ -124,7 +116,7 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto)
if ( !szStatus)
continue;
- ProtoXStatus = sttGetXStatus(pa->szModuleName);
+ TCHAR *ProtoXStatus = sttGetXStatus(pa->szModuleName);
if (mToolTipTrayTips) {
TCHAR tipline[256];
@@ -151,8 +143,9 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto)
}
}
else {
- if ((pa = Proto_GetAccount(szProto)) != NULL) {
- ProtoXStatus = sttGetXStatus(szProto);
+ PROTOACCOUNT *pa = Proto_GetAccount(szProto);
+ if (pa != NULL) {
+ TCHAR *ProtoXStatus = sttGetXStatus(szProto);
szStatus = cli.pfnGetStatusModeDescription(CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0), 0);
if (szPrefix && szPrefix[0]) {
if (db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT)) {
@@ -179,15 +172,14 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto)
}
}
- ulock;
return cli.szTip;
}
int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status)
{
initcheck 0;
- lock;
+ mir_cslock lck(trayLockCS);
int i;
for (i=0; i < cli.trayIconCount; i++)
if (cli.trayIcon[i].id == 0)
@@ -217,17 +209,15 @@ int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int s
if (cli.trayIconCount == 1)
SetTaskBarIcon(cli.trayIcon[0].hBaseIcon, cli.szTip);
-
- ulock;
return i;
}
void fnTrayIconRemove(HWND hwnd, const char *szProto)
{
- int i;
initcheck;
- lock;
- for (i=0; i < cli.trayIconCount; i++) {
+
+ mir_cslock lck(trayLockCS);
+ for (int i=0; i < cli.trayIconCount; i++) {
struct trayIconInfo_t* pii = &cli.trayIcon[i];
if (pii->id != 0 && !lstrcmpA(szProto, pii->szProto)) {
NOTIFYICONDATA nid = { SIZEOFNID };
@@ -244,14 +234,13 @@ void fnTrayIconRemove(HWND hwnd, const char *szProto)
if (cli.trayIconCount == 1)
SetTaskBarIcon(NULL, NULL);
-
- ulock;
}
int fnTrayIconInit(HWND hwnd)
{
initcheck 0;
- lock;
+
+ mir_cslock lck(trayLockCS);
int netProtoCount = 0;
int averageMode = GetAverageMode(&netProtoCount);
@@ -304,15 +293,14 @@ int fnTrayIconInit(HWND hwnd)
cli.pfnTrayIconAdd(hwnd, NULL, NULL, CallService(MS_CLIST_GETSTATUSMODE, 0, 0));
}
- ulock;
return 0;
}
int fnTrayIconDestroy(HWND hwnd)
{
initcheck 0;
- lock;
+ mir_cslock lck(trayLockCS);
if (cli.trayIconCount == 1)
SetTaskBarIcon(NULL, NULL);
@@ -329,8 +317,6 @@ int fnTrayIconDestroy(HWND hwnd)
mir_free(cli.trayIcon);
cli.trayIcon = NULL;
cli.trayIconCount = 0;
-
- ulock;
return 0;
}
@@ -344,27 +330,25 @@ void fnTrayIconTaskbarCreated(HWND hwnd)
static VOID CALLBACK RefreshTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
- int i;
if (RefreshTimerId) {
KillTimer(NULL, RefreshTimerId);
RefreshTimerId = 0;
}
- for (i=0; i < accounts.getCount(); i++) {
+ for (int i=0; i < accounts.getCount(); i++)
cli.pfnTrayIconUpdateBase(accounts[i]->szModuleName);
- }
}
int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPreferredProto, int isBase)
{
initcheck -1;
- lock;
+ mir_cslock lck(trayLockCS);
NOTIFYICONDATA nid = { SIZEOFNID };
nid.hWnd = cli.hwndContactList;
nid.uFlags = NIF_ICON | (mToolTipTrayTips ? 0 : NIF_TIP);
nid.hIcon = hNewIcon;
if ( !hNewIcon)
- { ulock; return -1; }
+ return -1;
int i;
for (i=0; i < cli.trayIconCount; i++) {
@@ -387,50 +371,53 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer
SetTaskBarIcon(NULL, NULL);
cli.trayIcon[i].isBase = isBase;
- { ulock; return i; }
+ return i;
}
//if there wasn't a suitable icon, change all the icons
- {
- for (i=0; i < cli.trayIconCount; i++) {
- if (cli.trayIcon[i].id == 0)
- continue;
- nid.uID = cli.trayIcon[i].id;
+ for (i=0; i < cli.trayIconCount; i++) {
+ if (cli.trayIcon[i].id == 0)
+ continue;
+ nid.uID = cli.trayIcon[i].id;
+
+ cli.pfnTrayIconMakeTooltip(szNewTip, cli.trayIcon[i].szProto);
+ mir_free(cli.trayIcon[i].ptszToolTip);
+ cli.trayIcon[i].ptszToolTip = mir_tstrdup(cli.szTip);
+ if ( !mToolTipTrayTips)
+ lstrcpyn(nid.szTip, cli.szTip, SIZEOF(nid.szTip));
+ Shell_NotifyIcon(NIM_MODIFY, &nid);
- cli.pfnTrayIconMakeTooltip(szNewTip, cli.trayIcon[i].szProto);
- mir_free(cli.trayIcon[i].ptszToolTip);
- cli.trayIcon[i].ptszToolTip = mir_tstrdup(cli.szTip);
- if ( !mToolTipTrayTips)
- lstrcpyn(nid.szTip, cli.szTip, SIZEOF(nid.szTip));
- Shell_NotifyIcon(NIM_MODIFY, &nid);
+ if (cli.trayIconCount == 1)
+ SetTaskBarIcon(hNewIcon, cli.szTip);
+ else
+ SetTaskBarIcon(NULL, NULL);
- if (cli.trayIconCount == 1)
- SetTaskBarIcon(hNewIcon, cli.szTip);
- else
- SetTaskBarIcon(NULL, NULL);
-
- cli.trayIcon[i].isBase = isBase;
- if (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) {
- DWORD time1 = db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT)*200;
- DWORD time2 = db_get_w(NULL, "CList", "IconFlashTime", 550)+1000;
- DWORD time = max(max(2000, time1), time2);
- if (RefreshTimerId) {KillTimer(NULL, RefreshTimerId); RefreshTimerId = 0;}
- RefreshTimerId = SetTimer(NULL, 0, time, RefreshTimerProc); // if unknown base was changed - than show preffered proto icon for 2 sec and reset it to original one after timeout
- }
- { ulock; return i; }
+ cli.trayIcon[i].isBase = isBase;
+ if (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) {
+ DWORD time1 = db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT)*200;
+ DWORD time2 = db_get_w(NULL, "CList", "IconFlashTime", 550)+1000;
+ DWORD time = max(max(2000, time1), time2);
+ if (RefreshTimerId) {KillTimer(NULL, RefreshTimerId); RefreshTimerId = 0;}
+ RefreshTimerId = SetTimer(NULL, 0, time, RefreshTimerProc); // if unknown base was changed - than show preffered proto icon for 2 sec and reset it to original one after timeout
}
+ return i;
}
- { ulock; return -1; }
+
+ return -1;
}
int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto)
{
- int i;
- initcheck -1;
- lock;
- if (szPreferredProto)
- {
- for (i=0; i < cli.trayIconCount; i++) {
+ if ( !fTrayInited) {
+LBL_Error:
+ DestroyIcon(hIcon);
+ return -1;
+ }
+
+ mir_cslock lck(trayLockCS);
+
+ if (szPreferredProto) {
+ for (int i=0; i < cli.trayIconCount; i++) {
if (cli.trayIcon[i].id == 0)
continue;
if (lstrcmpA(cli.trayIcon[i].szProto, szPreferredProto))
@@ -438,7 +425,7 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto)
DestroyIcon(cli.trayIcon[i].hBaseIcon);
cli.trayIcon[i].hBaseIcon = hIcon;
- ulock; return i;
+ return i;
}
if ((cli.pfnGetProtocolVisibility(szPreferredProto)) &&
(GetAverageMode() == -1) &&
@@ -448,18 +435,16 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto)
}
//if there wasn't a specific icon, there will only be one suitable
- for (i=0; i < cli.trayIconCount; i++) {
+ for (int i=0; i < cli.trayIconCount; i++) {
if (cli.trayIcon[i].id == 0)
continue;
DestroyIcon(cli.trayIcon[i].hBaseIcon);
cli.trayIcon[i].hBaseIcon = hIcon;
- ulock; return i;
+ return i;
}
-LBL_Error:
- DestroyIcon(hIcon);
- ulock; return -1;
+ goto LBL_Error;
}
void fnTrayIconUpdateWithImageList(int iImage, const TCHAR *szNewTip, char *szPreferredProto)
@@ -472,7 +457,7 @@ void fnTrayIconUpdateWithImageList(int iImage, const TCHAR *szNewTip, char *szPr
VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
initcheck;
- lock;
+ mir_cslock lck(trayLockCS);
int i;
for (i = accounts.getCount() + 1; --i;) {
@@ -488,8 +473,6 @@ VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD)
if (cli.trayIcon[0].isBase)
cli.pfnTrayIconUpdate(cli.trayIcon[0].hBaseIcon, NULL, NULL, 1);
}
-
- ulock;
}
void fnTrayIconUpdateBase(const char *szChangedProto)
@@ -499,7 +482,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
int i, netProtoCount, changed = -1;
HWND hwnd = cli.hwndContactList;
initcheck;
- lock;
+ mir_cslock lck(trayLockCS);
int averageMode = GetAverageMode(&netProtoCount);
if (cli.cycleTimerId) {
@@ -567,19 +550,17 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
}
}
}
- else
- changed = cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, cli.pfnIconFromStatusMode(NULL, averageMode, NULL), ILD_NORMAL), NULL);
+ else changed = cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, cli.pfnIconFromStatusMode(NULL, averageMode, NULL), ILD_NORMAL), NULL);
if (changed != -1 && cli.trayIcon[changed].isBase)
cli.pfnTrayIconUpdate(cli.trayIcon[changed].hBaseIcon, NULL, cli.trayIcon[changed].szProto, 1);
- ulock;
}
void fnTrayIconSetToBase(char *szPreferredProto)
{
int i;
initcheck;
- lock;
+ mir_cslock lck(trayLockCS);
for (i=0; i < cli.trayIconCount; i++) {
if (cli.trayIcon[i].id == 0)
@@ -587,7 +568,7 @@ void fnTrayIconSetToBase(char *szPreferredProto)
if (lstrcmpA(cli.trayIcon[i].szProto, szPreferredProto))
continue;
cli.pfnTrayIconUpdate(cli.trayIcon[i].hBaseIcon, NULL, szPreferredProto, 1);
- ulock; return;
+ return;
}
//if there wasn't a specific icon, there will only be one suitable
@@ -595,47 +576,46 @@ void fnTrayIconSetToBase(char *szPreferredProto)
if (cli.trayIcon[i].id == 0)
continue;
cli.pfnTrayIconUpdate(cli.trayIcon[i].hBaseIcon, NULL, szPreferredProto, 1);
- ulock; return;
+ return;
}
- ulock; return;
}
void fnTrayIconIconsChanged(void)
{
initcheck;
- lock;
+ mir_cslock lck(trayLockCS);
+
cli.pfnTrayIconDestroy(cli.hwndContactList);
cli.pfnTrayIconInit(cli.hwndContactList);
- ulock;
}
static UINT_PTR autoHideTimerId;
static VOID CALLBACK TrayIconAutoHideTimer(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
{
- HWND hwndClui;
initcheck;
- lock;
+ mir_cslock lck(trayLockCS);
+
KillTimer(hwnd, idEvent);
- hwndClui = cli.hwndContactList;
+ HWND hwndClui = cli.hwndContactList;
if (GetActiveWindow() != hwndClui) {
ShowWindow(hwndClui, SW_HIDE);
if (MySetProcessWorkingSetSize != NULL)
MySetProcessWorkingSetSize(GetCurrentProcess(), -1, -1);
}
- ulock; return;
}
int fnTrayIconPauseAutoHide(WPARAM, LPARAM)
{
initcheck 0;
- lock;
+ mir_cslock lck(trayLockCS);
+
if (db_get_b(NULL, "CList", "AutoHide", SETTING_AUTOHIDE_DEFAULT)) {
if (GetActiveWindow() != cli.hwndContactList) {
KillTimer(NULL, autoHideTimerId);
autoHideTimerId = SetTimer(NULL, 0, 1000 * db_get_w(NULL, "CList", "HideTime", SETTING_HIDETIME_DEFAULT), TrayIconAutoHideTimer);
}
}
- ulock; return 0;
+ return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -946,12 +926,7 @@ void fnLockTray(void)
void fnUnlockTray(void)
{
initcheck;
-#ifdef _DEBUG
- if (trayLockCS.RecursionCount == 0) DebugBreak(); //try to unlock already
-#endif
LeaveCriticalSection(&trayLockCS);
}
-#undef lock
-#undef ulock
#undef initcheck
diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp
index 4da60bfbb8..fec07d812a 100644
--- a/src/modules/skin/hotkeys.cpp
+++ b/src/modules/skin/hotkeys.cpp
@@ -45,9 +45,7 @@ HWND g_hwndHotkeyHost = NULL, g_hwndHkOptions = NULL;
HANDLE hEvChanged = 0;
static BOOL bModuleInitialized = FALSE;
-
-HHOOK hhkKeyboard = NULL;
-static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam);
+static HHOOK hhkKeyboard = NULL;
WORD GetHotkeyValue(INT_PTR idHotkey)
{