diff options
author | George Hazan <ghazan@miranda.im> | 2019-08-26 13:41:45 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-08-26 13:41:45 +0300 |
commit | cb2efce1a4fe9c89c5fef63b3aca63f3e63983fc (patch) | |
tree | aee121fae12956a856e6cd72f2a45d3e4757cd1a /src | |
parent | c43051a42bfd2457f6cf5fca9698db0d55b73993 (diff) |
obsolete services removed from core & replaced with functions
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdautoaway/src/idle.cpp | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/miranda.cpp | 17 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 3 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 3 | ||||
-rw-r--r-- | src/mir_core/src/winver.cpp | 142 |
7 files changed, 88 insertions, 82 deletions
diff --git a/src/core/stdautoaway/src/idle.cpp b/src/core/stdautoaway/src/idle.cpp index 16dc7a1723..b378329686 100644 --- a/src/core/stdautoaway/src/idle.cpp +++ b/src/core/stdautoaway/src/idle.cpp @@ -31,8 +31,7 @@ int IdleOptInit(WPARAM wParam, LPARAM); static int IdleObject_IsUserIdle() { if (g_plugin.bIdleMethod) { - DWORD dwTick; - CallService(MS_SYSTEM_GETIDLE, 0, (LPARAM)&dwTick); + DWORD dwTick = Miranda_GetIdle(); return GetTickCount() - dwTick > (g_plugin.iIdleTime1st * 60 * 1000); } diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 2820883800..b44be34fa0 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -3,6 +3,7 @@ LIBRARY mir_app.mir EXPORTS
Miranda_Close @1 NONAME
CallProtoService @2
+Miranda_SetIdleCallback @3 NONAME
Skin_LoadProtoIcon @4
Skin_LoadIcon @5
Button_FreeIcon_IcoLib @6
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6ed7f2a46a..a41e448502 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -3,6 +3,7 @@ LIBRARY mir_app.mir EXPORTS
Miranda_Close @1 NONAME
CallProtoService @2
+Miranda_SetIdleCallback @3 NONAME
Skin_LoadProtoIcon @4
Skin_LoadIcon @5
Button_FreeIcon_IcoLib @6
diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp index 214a196012..8441e0ceea 100644 --- a/src/mir_app/src/miranda.cpp +++ b/src/mir_app/src/miranda.cpp @@ -173,15 +173,11 @@ static void __cdecl compactHeapsThread(void*) }
}
-void(*SetIdleCallback) (void) = nullptr;
+void (*SetIdleCallback)(void) = nullptr;
-static INT_PTR SystemSetIdleCallback(WPARAM, LPARAM lParam)
+MIR_APP_DLL(void) Miranda_SetIdleCallback(void(__cdecl *pfnCallback)(void))
{
- if (lParam && SetIdleCallback == nullptr) {
- SetIdleCallback = (void(*)(void))lParam;
- return 1;
- }
- return 0;
+ SetIdleCallback = pfnCallback;
}
static DWORD dwEventTime = 0;
@@ -195,10 +191,9 @@ void checkIdle(MSG * msg) }
}
-static INT_PTR SystemGetIdle(WPARAM, LPARAM lParam)
+MIR_APP_DLL(DWORD) Miranda_GetIdle()
{
- if (lParam) *(DWORD*)lParam = dwEventTime;
- return 0;
+ return dwEventTime;
}
static int SystemShutdownProc(WPARAM, LPARAM)
@@ -346,8 +341,6 @@ int WINAPI mir_main(LPTSTR cmdLine) HookEvent(ME_SYSTEM_SHUTDOWN, SystemShutdownProc);
mir_forkthread(compactHeapsThread);
- CreateServiceFunction(MS_SYSTEM_SETIDLECALLBACK, SystemSetIdleCallback);
- CreateServiceFunction(MS_SYSTEM_GETIDLE, SystemGetIdle);
dwEventTime = GetTickCount();
DWORD myPid = GetCurrentProcessId();
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 5adff0f533..242519a0da 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -906,6 +906,7 @@ WindowList_Remove @1108 Utils_AssertInsideScreen @1110
Utils_RestoreWindowPosition @1111
Utils_SaveWindowPosition @1112
+OS_GetShortString @1113
TimeZone_CreateByContact @1114
TimeZone_CreateByName @1115
TimeZone_GetDescription @1116
@@ -926,7 +927,7 @@ Utils_ResizeDialog @1130 Utils_GetRandom @1131
Utils_OpenUrl @1132
Utils_OpenUrlW @1133
-GetOSDisplayString @1134
+OS_GetDisplayString @1134
IsWinVer10Plus @1135
IsWinVer81Plus @1136
IsWinVer8Plus @1137
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 4ff6e8e65f..8a75cfea10 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -906,6 +906,7 @@ WindowList_Remove @1108 Utils_AssertInsideScreen @1110
Utils_RestoreWindowPosition @1111
Utils_SaveWindowPosition @1112
+OS_GetShortString @1113
TimeZone_CreateByContact @1114
TimeZone_CreateByName @1115
TimeZone_GetDescription @1116
@@ -926,7 +927,7 @@ Utils_ResizeDialog @1130 Utils_GetRandom @1131
Utils_OpenUrl @1132
Utils_OpenUrlW @1133
-GetOSDisplayString @1134
+OS_GetDisplayString @1134
IsWinVer10Plus @1135
IsWinVer81Plus @1136
IsWinVer8Plus @1137
diff --git a/src/mir_core/src/winver.cpp b/src/mir_core/src/winver.cpp index 3ca4636057..72e01468d9 100644 --- a/src/mir_core/src/winver.cpp +++ b/src/mir_core/src/winver.cpp @@ -124,6 +124,17 @@ MIR_CORE_DLL(BOOL) IsScreenSaverRunning(void) //////////////////////////////////////////////////////////////////////////////////////////////////////
+MIR_CORE_DLL(BOOL) OS_GetShortString(char *buf, size_t bufSize)
+{
+ if (buf == nullptr || bufSize == 0)
+ return false;
+
+ mir_snprintf(buf, bufSize, "Windows NT %d.%d", HIBYTE(dwWinVer), LOBYTE(dwWinVer));
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef PRODUCT_CORE_N // Win8
#define PRODUCT_CORE_SINGLELANGUAGE 0x00000064
#define PRODUCT_PROFESSIONAL_WMC 0x00000067
@@ -132,7 +143,7 @@ MIR_CORE_DLL(BOOL) IsScreenSaverRunning(void) typedef BOOL(WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
typedef LPCSTR(WINAPI *WGV)(void);
-MIR_CORE_DLL(BOOL) GetOSDisplayString(wchar_t *buf, size_t bufSize)
+MIR_CORE_DLL(BOOL) OS_GetDisplayString(char *buf, size_t bufSize)
{
if (buf == nullptr || bufSize == 0)
return 0;
@@ -145,52 +156,52 @@ MIR_CORE_DLL(BOOL) GetOSDisplayString(wchar_t *buf, size_t bufSize) if (!bOsVersionInfoEx) {
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx((OSVERSIONINFO*)&osvi))
- return FALSE;
+ return false;
}
if (VER_PLATFORM_WIN32_NT != osvi.dwPlatformId || osvi.dwMajorVersion <= 4)
- return FALSE;
+ return false;
SYSTEM_INFO sysInfo = { 0 };
GetNativeSystemInfo(&sysInfo);
- CMStringW ret(L"Microsoft ");
+ CMStringA ret("Microsoft ");
// Test for the specific product.
if (osvi.dwMajorVersion >= 6) {
if (osvi.dwMajorVersion == 10) {
if (osvi.wProductType == VER_NT_WORKSTATION)
- ret.Append(L"Windows 10 ");
+ ret.Append("Windows 10 ");
else
- ret.Append(L"Windows Server 10 ");
+ ret.Append("Windows Server 10 ");
}
else switch (osvi.dwMinorVersion) {
case 0:
if (osvi.wProductType == VER_NT_WORKSTATION)
- ret.Append(L"Windows Vista ");
+ ret.Append("Windows Vista ");
else
- ret.Append(L"Windows Server 2008 ");
+ ret.Append("Windows Server 2008 ");
break;
case 1:
if (osvi.wProductType == VER_NT_WORKSTATION)
- ret.Append(L"Windows 7 ");
+ ret.Append("Windows 7 ");
else
- ret.Append(L"Windows Server 2008 R2 ");
+ ret.Append("Windows Server 2008 R2 ");
break;
case 2:
if (osvi.wProductType == VER_NT_WORKSTATION)
- ret.Append(L"Windows 8 ");
+ ret.Append("Windows 8 ");
else
- ret.Append(L"Windows Server 2012 ");
+ ret.Append("Windows Server 2012 ");
break;
case 3:
if (osvi.wProductType == VER_NT_WORKSTATION)
- ret.Append(L"Windows 8.1 ");
+ ret.Append("Windows 8.1 ");
else
- ret.Append(L"Windows Server 2012 R2 ");
+ ret.Append("Windows Server 2012 R2 ");
break;
}
@@ -202,149 +213,148 @@ MIR_CORE_DLL(BOOL) GetOSDisplayString(wchar_t *buf, size_t bufSize) switch (dwType) {
case PRODUCT_ULTIMATE:
- ret.Append(L"Ultimate Edition");
+ ret.Append("Ultimate Edition");
break;
case PRODUCT_PROFESSIONAL:
- ret.Append(L"Professional Edition");
+ ret.Append("Professional Edition");
break;
case PRODUCT_PROFESSIONAL_WMC:
- ret.Append(L"Professional Edition with Media Center");
+ ret.Append("Professional Edition with Media Center");
break;
case PRODUCT_HOME_PREMIUM:
- ret.Append(L"Home Premium Edition");
+ ret.Append("Home Premium Edition");
break;
case PRODUCT_HOME_BASIC:
- ret.Append(L"Home Basic Edition");
+ ret.Append("Home Basic Edition");
break;
case PRODUCT_ENTERPRISE:
- ret.Append(L"Enterprise Edition");
+ ret.Append("Enterprise Edition");
break;
case PRODUCT_BUSINESS:
- ret.Append(L"Business Edition");
+ ret.Append("Business Edition");
break;
case PRODUCT_STARTER:
- ret.Append(L"Starter Edition");
+ ret.Append("Starter Edition");
break;
case PRODUCT_CLUSTER_SERVER:
- ret.Append(L"Cluster Server Edition");
+ ret.Append("Cluster Server Edition");
break;
case PRODUCT_DATACENTER_SERVER:
- ret.Append(L"Datacenter Edition");
+ ret.Append("Datacenter Edition");
break;
case PRODUCT_DATACENTER_SERVER_CORE:
- ret.Append(L"Datacenter Edition (core installation)");
+ ret.Append("Datacenter Edition (core installation)");
break;
case PRODUCT_ENTERPRISE_SERVER:
- ret.Append(L"Enterprise Edition");
+ ret.Append("Enterprise Edition");
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
- ret.Append(L"Enterprise Edition (core installation)");
+ ret.Append("Enterprise Edition (core installation)");
break;
case PRODUCT_ENTERPRISE_SERVER_IA64:
- ret.Append(L"Enterprise Edition for Itanium-based Systems");
+ ret.Append("Enterprise Edition for Itanium-based Systems");
break;
case PRODUCT_SMALLBUSINESS_SERVER:
- ret.Append(L"Small Business Server");
+ ret.Append("Small Business Server");
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
- ret.Append(L"Small Business Server Premium Edition");
+ ret.Append("Small Business Server Premium Edition");
break;
case PRODUCT_STANDARD_SERVER:
- ret.Append(L"Standard Edition");
+ ret.Append("Standard Edition");
break;
case PRODUCT_STANDARD_SERVER_CORE:
- ret.Append(L"Standard Edition (core installation)");
+ ret.Append("Standard Edition (core installation)");
break;
case PRODUCT_WEB_SERVER:
- ret.Append(L"Web Server Edition");
+ ret.Append("Web Server Edition");
break;
case PRODUCT_CORE_SINGLELANGUAGE:
- ret.Append(L"Home Single Language");
+ ret.Append("Home Single Language");
break;
}
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
- ret.Append(L", 64-bit");
+ ret.Append(", 64-bit");
else if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
- ret.Append(L", 32-bit");
+ ret.Append(", 32-bit");
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) {
if (GetSystemMetrics(SM_SERVERR2))
- ret.Append(L"Windows Server 2003 R2, ");
+ ret.Append("Windows Server 2003 R2, ");
else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
- ret.Append(L"Windows Storage Server 2003");
+ ret.Append("Windows Storage Server 2003");
else if (osvi.wSuiteMask == VER_SUITE_WH_SERVER)
- ret.Append(L"Windows Home Server");
+ ret.Append("Windows Home Server");
else if (osvi.wProductType == VER_NT_WORKSTATION && sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
- ret.Append(L"Windows XP Professional x64 Edition");
+ ret.Append("Windows XP Professional x64 Edition");
else
- ret.Append(L"Windows Server 2003, ");
+ ret.Append("Windows Server 2003, ");
// Test for the server type.
if (osvi.wProductType != VER_NT_WORKSTATION) {
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
- ret.Append(L"Datacenter Edition for Itanium-based Systems");
+ ret.Append("Datacenter Edition for Itanium-based Systems");
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- ret.Append(L"Enterprise Edition for Itanium-based Systems");
+ ret.Append("Enterprise Edition for Itanium-based Systems");
}
else if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
- ret.Append(L"Datacenter x64 Edition");
+ ret.Append("Datacenter x64 Edition");
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- ret.Append(L"Enterprise x64 Edition");
- else ret.Append(L"Standard x64 Edition");
+ ret.Append("Enterprise x64 Edition");
+ else ret.Append("Standard x64 Edition");
}
else {
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
- ret.Append(L"Compute Cluster Edition");
+ ret.Append("Compute Cluster Edition");
else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
- ret.Append(L"Datacenter Edition");
+ ret.Append("Datacenter Edition");
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- ret.Append(L"Enterprise Edition");
+ ret.Append("Enterprise Edition");
else if (osvi.wSuiteMask & VER_SUITE_BLADE)
- ret.Append(L"Web Edition");
- else ret.Append(L"Standard Edition");
+ ret.Append("Web Edition");
+ else ret.Append("Standard Edition");
}
}
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {
- ret.Append(L"Windows XP ");
+ ret.Append("Windows XP ");
if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
- ret.Append(L"Home Edition");
- else ret.Append(L"Professional");
+ ret.Append("Home Edition");
+ else ret.Append("Professional");
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) {
- ret.Append(L"Windows 2000 ");
+ ret.Append("Windows 2000 ");
if (osvi.wProductType == VER_NT_WORKSTATION)
- ret.Append(L"Professional");
+ ret.Append("Professional");
else {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
- ret.Append(L"Datacenter Server");
+ ret.Append("Datacenter Server");
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- ret.Append(L"Advanced Server");
- else ret.Append(L"Server");
+ ret.Append("Advanced Server");
+ else ret.Append("Server");
}
}
// Include service pack (if any) and build number.
-
if (mir_wstrlen(osvi.szCSDVersion) > 0) {
- ret.Append(L" ");
- ret.Append(osvi.szCSDVersion);
+ ret.Append(" ");
+ ret.Append(_T2A(osvi.szCSDVersion));
}
- ret.AppendFormat(L" (build %d)", osvi.dwBuildNumber);
+ ret.AppendFormat(" (build %d)", osvi.dwBuildNumber);
HMODULE hNtDll = GetModuleHandleA("ntdll.dll");
if (WGV wine_get_version = (WGV)GetProcAddress(hNtDll, "wine_get_version"))
{
- ret.AppendFormat(L" (Wine %S)", wine_get_version());
+ ret.AppendFormat(" (Wine %s)", wine_get_version());
}
- mir_wstrncpy(buf, ret, bufSize);
- return TRUE;
+ mir_strncpy(buf, ret, bufSize);
+ return true;
}
|