summaryrefslogtreecommitdiff
path: root/plugins/KeyboardNotify
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-25 13:50:57 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-25 13:50:57 +0000
commit125264843b0e1f8afccc85ea30c329f0366eb716 (patch)
treed29170f7259bfec7410bb082e44b1d670b8134b8 /plugins/KeyboardNotify
parente4b8e9d9704a986c71565ef723cc8de208d97740 (diff)
- custom screen saver detection code removed
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@6230 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/KeyboardNotify')
-rw-r--r--plugins/KeyboardNotify/src/ignore.cpp20
-rw-r--r--plugins/KeyboardNotify/src/main.cpp102
-rw-r--r--plugins/KeyboardNotify/src/options.cpp12
3 files changed, 33 insertions, 101 deletions
diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp
index 645ea4b192..6ce81f49cb 100644
--- a/plugins/KeyboardNotify/src/ignore.cpp
+++ b/plugins/KeyboardNotify/src/ignore.cpp
@@ -59,7 +59,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if(hChildItem)
SetListGroupIcons(hwndList, hChildItem, hItem, childCount);
- for(i=0; i < SIZEOF(iconOn); i++)
+ for (i=0; i < SIZEOF(iconOn); i++)
if(iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0)
iconOn[i] = 0;
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
@@ -70,7 +70,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while(hItem) {
- for(i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < SIZEOF(iconOn); i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if(iconOn[i] && iImage == 0)
iconOn[i] = 0;
@@ -80,7 +80,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for(i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < SIZEOF(iconOn); i++) {
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+3:0):EMPTY_EXTRA_ICON));
if(groupChildCount)
groupChildCount[i] += childCount[i];
@@ -129,7 +129,7 @@ static void ResetListOptions(HWND hwndList)
SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0);
SendMessage(hwndList, CLM_SETINDENT, 10, 0);
SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, 1, 0);
- for(i=0; i <= FONTID_MAX; i++)
+ for (i=0; i <= FONTID_MAX; i++)
SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
}
@@ -162,7 +162,7 @@ static void InitialiseItem(HWND hwndList, HANDLE hContact, HANDLE hItem, DWORD p
int i;
mask = GetMask(hContact);
- for(i=0; i < IGNOREEVENT_MAX; i++)
+ for (i=0; i < IGNOREEVENT_MAX; i++)
if(ignoreIdToPf1[i] == 0xFFFFFFFF || protoCaps & ignoreIdToPf1[i])
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, mask&(1<<i)?i+3:0));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 1));
@@ -174,7 +174,7 @@ static void SaveItemMask(HWND hwndList, HANDLE hContact, HANDLE hItem, const cha
DWORD mask;
int i, iImage;
- for(i=0, mask=0; i < IGNOREEVENT_MAX; i++) {
+ for (i=0, mask=0; i < IGNOREEVENT_MAX; i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
if(iImage && iImage != EMPTY_EXTRA_ICON)
mask |= 1<<i;
@@ -219,7 +219,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_EVENT_FILE));
ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_OTHER_MIRANDA));
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
- for(i=0; i < SIZEOF(hIcons); i++)
+ for (i=0; i < SIZEOF(hIcons); i++)
hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL);
}
SendDlgItemMessage(hwndDlg, IDC_ALLICON, STM_SETICON, (WPARAM)hIcons[0], 0);
@@ -284,11 +284,11 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
if (!(hitFlags & CLCHT_ONITEMEXTRA))
break;
if(nm->iColumn == IGNOREEVENT_MAX) { //ignore all
- for(iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
+ for (iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, iImage, iImage+3);
}
else if(nm->iColumn == IGNOREEVENT_MAX+1) { //ignore none
- for(iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
+ for (iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, iImage, 0);
}
else {
@@ -326,7 +326,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
case WM_DESTROY:
{ int i;
HIMAGELIST hIml;
- for(i=0; i < SIZEOF(hIcons); i++)
+ for (i=0; i < SIZEOF(hIcons); i++)
DestroyIcon(hIcons[i]);
hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
ImageList_Destroy(hIml);
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp
index 860b03ae92..bf5a170972 100644
--- a/plugins/KeyboardNotify/src/main.cpp
+++ b/plugins/KeyboardNotify/src/main.cpp
@@ -26,10 +26,6 @@
#define NCONVERS_BLINKID ((HANDLE)123456) //nconvers' random identifier used to flash an icon for "incoming message" on contact list
-#ifndef SPI_GETSCREENSAVERRUNNING
-#define SPI_GETSCREENSAVERRUNNING 114
-#endif
-
#ifndef WM_XBUTTONDBLCLK
#define WM_XBUTTONDBLCLK 0x020D
#endif
@@ -109,7 +105,6 @@ BOOL bReminderDisabled = FALSE;
char *szMetaProto = NULL;
BYTE bMetaProtoEnabled = 0;
-
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -124,8 +119,6 @@ PLUGININFOEX pluginInfo={
{0x119d7288, 0x2050, 0x448d, {0x99, 0x00, 0xd8, 0x6a, 0xc7, 0x04, 0x26, 0xbf}}
};
-
-
int InitializeOptions(WPARAM,LPARAM);
void LoadSettings(void);
int HookWindowsHooks(void);
@@ -137,7 +130,6 @@ static LRESULT CALLBACK MirandaKeyBoardHookFunction(int, WPARAM, LPARAM);
static LRESULT CALLBACK MirandaWndProcHookFunction(int, WPARAM, LPARAM);
BOOL CheckMsgWnd(HANDLE, BOOL *);
-
BOOL isMetaContactsSubContact(HANDLE hMetaContact, HANDLE hContact)
{
char *szProto = GetContactProto(hMetaContact);
@@ -149,7 +141,6 @@ BOOL isMetaContactsSubContact(HANDLE hMetaContact, HANDLE hContact)
return FALSE;
}
-
BOOL checkOpenWindow(HANDLE hContact)
{
BOOL found, focus;
@@ -172,76 +163,27 @@ BOOL checkOpenWindow(HANDLE hContact)
return FALSE;
}
-BOOL isScreenSaverRunning()
-{
- BOOL screenSaverIsRunning=FALSE;
-
- SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &screenSaverIsRunning, FALSE);
- return screenSaverIsRunning;
-}
-
-
-/* this function is from the original idle module */
-BOOL isWorkstationLocked()
-{
- HDESK hd;
- char buf[MAX_PATH];
-
- hd = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED); /* if it fails then the workstation is prolly locked anyway */
- if (hd == NULL) return TRUE;
- GetUserObjectInformation(hd, UOI_NAME, buf, sizeof(buf), NULL); /* if we got it (hmm,) get a name */
- CloseDesktop(hd);
- return strcmp(buf, "Winlogon")==0;
-}
-
-
-BOOL isFullScreen()
-{
- int w = GetSystemMetrics(SM_CXSCREEN);
- int h = GetSystemMetrics(SM_CYSCREEN);
-
- HWND hWnd = 0;
- while (hWnd = FindWindowEx(NULL, hWnd, NULL, NULL)) {
- RECT WindowRect;
-
- if (!(GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST))
- continue;
-
- GetWindowRect(hWnd, &WindowRect);
- if ((w != (WindowRect.right - WindowRect.left)) || (h != (WindowRect.bottom - WindowRect.top)))
- continue;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-
BOOL checkNotifyOptions()
{
- BOOL fullScreenMode, screenSaverIsRunning, workstationIsLocked, processesRunning;
-
- screenSaverIsRunning = isScreenSaverRunning();
+ BOOL screenSaverIsRunning = IsScreenSaverRunning();
if (screenSaverIsRunning && bScreenSaverRunning)
- return TRUE;
+ return TRUE;
- workstationIsLocked = isWorkstationLocked();
+ BOOL workstationIsLocked = IsWorkstationLocked();
if (workstationIsLocked && bWorkstationLocked)
- return TRUE;
+ return TRUE;
- fullScreenMode = isFullScreen() && !screenSaverIsRunning;
+ BOOL fullScreenMode = IsFullScreen() && !screenSaverIsRunning;
if (fullScreenMode && bFullScreenMode)
- return TRUE;
+ return TRUE;
- processesRunning = areThereProcessesRunning();
+ BOOL processesRunning = areThereProcessesRunning();
if (processesRunning && bProcessesAreRunning)
- return TRUE;
+ return TRUE;
return (!fullScreenMode && !screenSaverIsRunning && !workstationIsLocked && !processesRunning && bWorkstationActive);
}
-
BOOL isStatusEnabled(int status)
{
switch (status) {
@@ -259,13 +201,11 @@ BOOL isStatusEnabled(int status)
}
}
-
BOOL checkGlobalStatus()
{
return isStatusEnabled(CallService(MS_CLIST_GETSTATUSMODE, 0, 0));
}
-
BOOL checkGlobalXstatus()
{
int protosSupporting=0, status=0;
@@ -288,19 +228,15 @@ BOOL checkGlobalXstatus()
return protosSupporting == 0;
}
-
DBEVENTINFO createMsgEventInfo(HANDLE hContact)
{
DBEVENTINFO einfo = {0};
-
einfo.cbSize = sizeof(einfo);
einfo.eventType = EVENTTYPE_MESSAGE;
einfo.szModule = GetContactProto(hContact);
-
return einfo;
}
-
DBEVENTINFO readEventInfo(HANDLE hDbEvent, HANDLE hContact)
{
if (hDbEvent == NCONVERS_BLINKID) // we need to handle nconvers' blink event
@@ -311,26 +247,23 @@ DBEVENTINFO readEventInfo(HANDLE hDbEvent, HANDLE hContact)
return einfo;
}
-
BOOL checkIgnore(HANDLE hContact, WORD eventType)
{
return !IsIgnored(hContact, eventType);
}
-
BOOL checkProtocol(char *szProto)
{
if (!szProto)
return FALSE;
- for(int i=0; i < ProtoList.protoCount; i++)
+ for (int i=0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].szProto && !strcmp(ProtoList.protoInfo[i].szProto, szProto))
return ProtoList.protoInfo[i].enabled;
return FALSE;
}
-
BOOL metaCheckProtocol(char *szProto, HANDLE hContact, WORD eventType)
{
HANDLE hSubContact=NULL;
@@ -366,7 +299,6 @@ BOOL checkUnopenEvents()
return FALSE;
}
-
static void FlashThreadFunction()
{
BOOL bEvent = FALSE;
@@ -485,7 +417,7 @@ BOOL checkXstatus(char *szProto)
if (!szProto)
return checkGlobalXstatus();
- for(int i=0; i < ProtoList.protoCount; i++)
+ for (int i=0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].szProto && !strcmp(ProtoList.protoInfo[i].szProto, szProto)) {
if (!ProtoList.protoInfo[i].xstatus.count) return TRUE;
@@ -643,7 +575,7 @@ void createProcessList(void)
ProcessList.count = 0;
ProcessList.szFileName = (TCHAR **)malloc(count * sizeof(TCHAR *));
if (ProcessList.szFileName) {
- for(i=0; i < count; i++)
+ for (i=0; i < count; i++)
if (db_get_ts(NULL, KEYBDMODULE, fmtDBSettingName("process%d", i), &dbv))
ProcessList.szFileName[i] = NULL;
else {
@@ -665,7 +597,7 @@ void destroyProcessList(void)
count = ProcessList.count;
ProcessList.count = 0;
- for(i=0; i < count; i++)
+ for (i=0; i < count; i++)
if (ProcessList.szFileName[i])
free(ProcessList.szFileName[i]);
@@ -723,11 +655,11 @@ void LoadSettings(void)
db_set_b(NULL, KEYBDMODULE, "testnum", DEF_SETTING_TESTNUM);
if (db_get_b(NULL, KEYBDMODULE, "testsecs", -1) == -1)
db_set_b(NULL, KEYBDMODULE, "testsecs", DEF_SETTING_TESTSECS);
- for(int i=0; i < ProtoList.protoCount; i++)
+ for (int i=0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].visible) {
unsigned int j;
ProtoList.protoInfo[i].enabled = db_get_b(NULL, KEYBDMODULE, ProtoList.protoInfo[i].szProto, DEF_SETTING_PROTOCOL);
- for(j=0; j < ProtoList.protoInfo[i].xstatus.count; j++)
+ for (j=0; j < ProtoList.protoInfo[i].xstatus.count; j++)
ProtoList.protoInfo[i].xstatus.enabled[j] = db_get_b(NULL, KEYBDMODULE, fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), DEF_SETTING_XSTATUS);
}
@@ -773,7 +705,7 @@ void updateXstatusProto(PROTOCOL_INFO *protoInfo)
if (!protoInfo->xstatus.enabled)
protoInfo->xstatus.count = 0;
else
- for(unsigned i=0; i < protoInfo->xstatus.count; i++)
+ for (unsigned i=0; i < protoInfo->xstatus.count; i++)
protoInfo->xstatus.enabled[i] = FALSE;
}
@@ -792,7 +724,7 @@ void createProtocolList(void)
return;
}
- for(int i=0; i < ProtoList.protoCount; i++) {
+ for (int i=0; i < ProtoList.protoCount; i++) {
ProtoList.protoInfo[i].xstatus.count = 0;
ProtoList.protoInfo[i].xstatus.enabled = NULL;
ProtoList.protoInfo[i].szProto = (char *)malloc(strlen(proto[i]->szModuleName) + 1);
@@ -899,7 +831,7 @@ extern "C" __declspec(dllexport) int Load(void)
void destroyProtocolList(void)
{
- for(int i=0; i < ProtoList.protoCount; i++) {
+ for (int i=0; i < ProtoList.protoCount; i++) {
if (ProtoList.protoInfo[i].szProto)
free(ProtoList.protoInfo[i].szProto);
if (ProtoList.protoInfo[i].xstatus.enabled)
diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp
index d4d5d031bb..0f853b03e9 100644
--- a/plugins/KeyboardNotify/src/options.cpp
+++ b/plugins/KeyboardNotify/src/options.cpp
@@ -224,7 +224,7 @@ INT_PTR CALLBACK DlgProcProtoOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
lvItem.cchTextMax = 256;
lvItem.iItem = 0;
lvItem.iSubItem = 0;
- for(int i=0; i < ProtoList.protoCount; i++) {
+ for (int i=0; i < ProtoList.protoCount; i++) {
int count; PROTOACCOUNT** protos;
ProtoEnumAccounts( &count, &protos );
if(ProtoList.protoInfo[i].visible) {
@@ -519,7 +519,7 @@ INT_PTR CALLBACK DlgProcBasicOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (XstatusListAux)
for (int i = 0; i < ProtoList.protoCount; i++)
- for(int j = 0; j < (int)XstatusListAux[i].count; j++)
+ for (int j = 0; j < (int)XstatusListAux[i].count; j++)
db_set_b(NULL, KEYBDMODULE, fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), (BYTE)XstatusListAux[i].enabled[j]);
LoadSettings();
@@ -1211,7 +1211,7 @@ void createProcessListAux(void)
void destroyProcessListAux(void)
{
- for(int i = 0; i < ProcessListAux.count; i++)
+ for (int i = 0; i < ProcessListAux.count; i++)
if (ProcessListAux.szFileName[i])
free(ProcessListAux.szFileName[i]);
@@ -1307,7 +1307,7 @@ void createXstatusListAux(void)
if (!XstatusListAux[i].enabled)
XstatusListAux[i].count = 0;
else
- for(int j = 0; j < (int)XstatusListAux[i].count; j++)
+ for (int j = 0; j < (int)XstatusListAux[i].count; j++)
XstatusListAux[i].enabled[j] = ProtoList.protoInfo[i].xstatus.enabled[j];
}
}
@@ -1318,7 +1318,7 @@ void createXstatusListAux(void)
void destroyXstatusListAux(void)
{
if (XstatusListAux) {
- for(int i = 0; i < ProtoList.protoCount; i++)
+ for (int i = 0; i < ProtoList.protoCount; i++)
if (XstatusListAux[i].enabled)
free(XstatusListAux[i].enabled);
free(XstatusListAux);
@@ -1382,7 +1382,7 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
tvis.item.iImage = tvis.item.iSelectedImage = ImageList_AddIcon(hImageList, hIconAux=(HICON)CallProtoService(ProtoList.protoInfo[i].szProto, PS_LOADICON, PLI_PROTOCOL, 0));
if (hIconAux) DestroyIcon(hIconAux);
hParent = TreeView_InsertItem(hwndTree, &tvis);
- for(j = 0; j < XstatusListAux[i].count; j++) {
+ for (j = 0; j < XstatusListAux[i].count; j++) {
tvis.hParent = hParent;
tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
if (!j){