summaryrefslogtreecommitdiff
path: root/src/core/stdidle
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-09-21 17:37:33 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-09-21 17:37:33 +0000
commitfdbc3639a50f40879f390f17ce7aafd5a579a7ab (patch)
treef2dc612f9d188cfb955b4393e207e5363bcd4e4e /src/core/stdidle
parent96325150479b8c93a5e48ac2591f3c7da5f0f9d4 (diff)
Core cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6165 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core/stdidle')
-rw-r--r--src/core/stdidle/commonheaders.h14
-rw-r--r--src/core/stdidle/idle.cpp56
-rw-r--r--src/core/stdidle/main.cpp12
-rw-r--r--src/core/stdidle/stdidle_10.vcxproj13
-rw-r--r--src/core/stdidle/stdidle_11.vcxproj13
5 files changed, 24 insertions, 84 deletions
diff --git a/src/core/stdidle/commonheaders.h b/src/core/stdidle/commonheaders.h
index 7455afd2a0..3ee34d7e8a 100644
--- a/src/core/stdidle/commonheaders.h
+++ b/src/core/stdidle/commonheaders.h
@@ -28,9 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <tchar.h>
#include <winsock2.h>
#include <shlobj.h>
-#include <uxtheme.h>
#include <commctrl.h>
#include <vssym32.h>
+#include <Wtsapi32.h>
#include <stdio.h>
#include <time.h>
@@ -75,15 +75,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../stdplug.h"
extern HINSTANCE hInst;
-
-typedef HDESK (WINAPI* pfnOpenInputDesktop)(DWORD, BOOL, DWORD);
-extern pfnOpenInputDesktop openInputDesktop;
-
-typedef HDESK (WINAPI* pfnCloseDesktop)(HDESK);
-extern pfnCloseDesktop closeDesktop;
-
-typedef HMONITOR(WINAPI *pfnMyMonitorFromWindow) (HWND, DWORD);
-extern pfnMyMonitorFromWindow MyMonitorFromWindow;
-
-typedef BOOL(WINAPI *pfnMyGetMonitorInfo) (HMONITOR, LPMONITORINFO);
-extern pfnMyGetMonitorInfo MyGetMonitorInfo;
diff --git a/src/core/stdidle/idle.cpp b/src/core/stdidle/idle.cpp
index a66f05d93e..4881c0f592 100644
--- a/src/core/stdidle/idle.cpp
+++ b/src/core/stdidle/idle.cpp
@@ -105,42 +105,21 @@ typedef enum _WTS_INFO_CLASS {
#endif
-VOID (WINAPI *_WTSFreeMemory)(PVOID);
-BOOL (WINAPI *_WTSQuerySessionInformation)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*);
-
-BOOL bIsWTSApiPresent = FALSE;
-
static BOOL bModuleInitialized = FALSE;
-BOOL InitWTSAPI()
-{
- HMODULE hDll = LoadLibraryA("wtsapi32.dll");
- if (hDll) {
- _WTSFreeMemory = (VOID (WINAPI *)(PVOID))GetProcAddress(hDll, "WTSFreeMemory");
- _WTSQuerySessionInformation = (BOOL (WINAPI *)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*))GetProcAddress(hDll, "WTSQuerySessionInformationW");
-
- if (_WTSFreeMemory && _WTSQuerySessionInformation) return 1;
- }
- return 0;
-}
-
BOOL IsTerminalDisconnected()
{
PVOID pBuffer = NULL;
DWORD pBytesReturned = 0;
BOOL result = FALSE;
- if ( !bIsWTSApiPresent)
- return FALSE;
-
- if (_WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, &pBuffer, &pBytesReturned)) {
+ if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, (LPTSTR *)&pBuffer, &pBytesReturned)) {
if (*(PDWORD)pBuffer == WTSDisconnected)
result = TRUE;
}
- else bIsWTSApiPresent = FALSE;
if (pBuffer)
- _WTSFreeMemory(pBuffer);
+ WTSFreeMemory(pBuffer);
return result;
}
@@ -233,13 +212,11 @@ static bool IsWorkstationLocked (void)
{
bool rc = false;
- if (openInputDesktop != NULL) {
- HDESK hDesk = openInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
- if (hDesk == NULL)
- rc = true;
- else if (closeDesktop != NULL)
- closeDesktop(hDesk);
- }
+ HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
+ if (hDesk == NULL)
+ rc = true;
+ else
+ CloseDesktop(hDesk);
return rc;
}
@@ -257,13 +234,11 @@ bool IsFullScreen(void)
rcScreen.right = GetSystemMetrics(SM_CXSCREEN);
rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN);
- if (MyMonitorFromWindow) {
- HMONITOR hMon = MyMonitorFromWindow(pcli->hwndContactList, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi;
- mi.cbSize = sizeof(mi);
- if (MyGetMonitorInfo(hMon, &mi))
- rcScreen = mi.rcMonitor;
- }
+ HMONITOR hMon = MonitorFromWindow(pcli->hwndContactList, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(mi);
+ if (GetMonitorInfo(hMon, &mi))
+ rcScreen = mi.rcMonitor;
HWND hWndDesktop = GetDesktopWindow();
HWND hWndShell = GetShellWindow();
@@ -358,10 +333,7 @@ static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
CheckDlgButton(hwndDlg, IDC_LOCKED, db_get_b(NULL, IDLEMOD, IDL_IDLEONLOCK, 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IDLEPRIVATE, db_get_b(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IDLESTATUSLOCK, db_get_b(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0) ? BST_CHECKED : BST_UNCHECKED);
- if ( !bIsWTSApiPresent)
- EnableWindow(GetDlgItem(hwndDlg, IDC_IDLETERMINAL), FALSE);
- else
- CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, db_get_b(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, db_get_b(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IDLESOUNDSOFF, db_get_b(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1) ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_IDLE1STTIME), 0);
SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETRANGE32, 1, 60);
@@ -500,8 +472,6 @@ int LoadIdleModule(void)
{
bModuleInitialized = TRUE;
- bIsWTSApiPresent = InitWTSAPI();
- MyGetLastInputInfo = (BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo");
hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED);
IdleObject_Create(&gIdleObject);
CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo);
diff --git a/src/core/stdidle/main.cpp b/src/core/stdidle/main.cpp
index 50a9b58e6f..36dd64b1ad 100644
--- a/src/core/stdidle/main.cpp
+++ b/src/core/stdidle/main.cpp
@@ -29,11 +29,6 @@ TIME_API tmi;
HINSTANCE hInst;
int hLangpack;
-pfnMyMonitorFromWindow MyMonitorFromWindow;
-pfnMyGetMonitorInfo MyGetMonitorInfo;
-pfnOpenInputDesktop openInputDesktop;
-pfnCloseDesktop closeDesktop;
-
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -65,13 +60,6 @@ extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
mir_getTMI(&tmi);
-
- HINSTANCE hUser32 = GetModuleHandleA("user32");
- openInputDesktop = (pfnOpenInputDesktop)GetProcAddress (hUser32, "OpenInputDesktop");
- closeDesktop = (pfnCloseDesktop)GetProcAddress (hUser32, "CloseDesktop");
-
- MyMonitorFromWindow = (pfnMyMonitorFromWindow)GetProcAddress(hUser32, "MonitorFromWindow");
- MyGetMonitorInfo = (pfnMyGetMonitorInfo)GetProcAddress(hUser32, "GetMonitorInfoW");
mir_getCLI();
LoadIdleModule();
diff --git a/src/core/stdidle/stdidle_10.vcxproj b/src/core/stdidle/stdidle_10.vcxproj
index f73f82cffb..01ed78aea8 100644
--- a/src/core/stdidle/stdidle_10.vcxproj
+++ b/src/core/stdidle/stdidle_10.vcxproj
@@ -91,7 +91,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -125,7 +125,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<BaseAddress>0x3ae00000</BaseAddress>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -156,7 +156,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -189,7 +189,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<BaseAddress>0x3ae00000</BaseAddress>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -200,10 +200,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="commonheaders.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="idle.cpp" />
<ClCompile Include="main.cpp" />
diff --git a/src/core/stdidle/stdidle_11.vcxproj b/src/core/stdidle/stdidle_11.vcxproj
index 5e3fa1214d..50e2ce737e 100644
--- a/src/core/stdidle/stdidle_11.vcxproj
+++ b/src/core/stdidle/stdidle_11.vcxproj
@@ -95,7 +95,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -128,7 +128,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<BaseAddress>0x3ae00000</BaseAddress>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -160,7 +160,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -192,7 +192,7 @@
<AdditionalIncludeDirectories>..\..\..\include\msapi;..\..\..\include</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<BaseAddress>0x3ae00000</BaseAddress>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -203,10 +203,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="commonheaders.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="idle.cpp" />
<ClCompile Include="main.cpp" />