From 16db65c5e255392b1cfc4afb8d2417f1d7610433 Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 5 Jul 2019 22:55:52 +0100 Subject: [PATCH 01/32] GPII-4011: Showing the volume change on the screen. --- .../WindowsUtilities/WindowsUtilities.js | 6 + .../VolumeControl/VolumeControl.cpp | 217 ++++++++++-------- .../src/nativeSettingsHandler.js | 20 +- 3 files changed, 140 insertions(+), 103 deletions(-) diff --git a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js index 20188edaa..9f0baeb68 100644 --- a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js +++ b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js @@ -517,6 +517,8 @@ windows.API_constants = { WM_DISPLAYCHANGE: 0x7e, // https://docs.microsoft.com/windows/desktop/winmsg/wm-themechanged WM_THEMECHANGED: 0x31a, + // https://docs.microsoft.com/windows/win32/inputdev/wm-appcommand + WM_APPCOMMAND: 0x319, // https://msdn.microsoft.com/library/aa363205 @@ -526,6 +528,10 @@ windows.API_constants = { DBT_DEVICEREMOVECOMPLETE: 0x8004, DBT_DEVTYP_VOLUME: 0x2, + // https://docs.microsoft.com/windows/win32/inputdev/wm-appcommand + APPCOMMAND_VOLUME_DOWN: 9, + APPCOMMAND_VOLUME_UP: 10, + // https://msdn.microsoft.com/library/dd375731 virtualKeyCodes: { VK_BACK: 0x08, diff --git a/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp b/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp index 6c4aa8461..776502349 100644 --- a/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp +++ b/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp @@ -1,99 +1,118 @@ -// VolumeControl.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include "pch.h" -#include -#include -#include - -#include - -// Operation constants -const wchar_t* Get = L"Get"; -const wchar_t* Set = L"Set"; - -int wmain(int argc, wchar_t *argv[]) { - // Payload - std::wstring operation; - float value; - // COM Interfaces - HRESULT hr = NULL; - const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator); - const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator); - IMMDeviceEnumerator* pEnumerator; - LPVOID pvReserved = NULL; - - if (argc == 2) { - operation = argv[1]; - if (operation != Get) { - std::wcout << L"{ \"code\": \"160\", \"message\": \"EINVAL\" }"; - return 0; - } - } else if (argc == 3) { - operation = argv[1]; - std::wstring strValue = argv[2]; - - // Parse the received string into a float - const wchar_t* start = strValue.c_str(); - wchar_t* end = NULL; - - value = std::wcstof(start, &end); - - if (operation != Set || (value == 0 && end == start)) { - std::wcout << L"{ \"code\": \"160\", \"message\": \"EINVAL\" }"; - return 0; - } - } else { - std::wcout << L"{ \"code\": \"160\", \"message\": \"EINVAL\" }"; - return 0; - } - - hr = CoInitialize(pvReserved); - if (hr != S_OK) { - std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to initialize COM\" }"; - } - - hr = CoCreateInstance( - CLSID_MMDeviceEnumerator, - NULL, - CLSCTX_ALL, - IID_IMMDeviceEnumerator, - (void**)&pEnumerator - ); - if (hr != S_OK) { - std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to initialize COM instance\" }"; - } - - IMMDevice* pAudioDevice; - hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pAudioDevice); - if (hr != S_OK) { - std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to get default audio endpoint\" }"; - } - - IAudioEndpointVolume* pEndpointVolume; - pAudioDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pEndpointVolume); - if (hr != S_OK) { - std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to activate the audio endpoint\" }"; - } - - if (operation == Get) { - float curVolume = 0; - hr = pEndpointVolume->GetMasterVolumeLevelScalar(&curVolume); - if (hr != S_OK) { - std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to get current system volume\" }"; - } else { - std::wcout << L"{ \"Value\": \"" << std::to_wstring(curVolume) << "\" }"; - } - } else { - float curVolume = 0; - hr = pEndpointVolume->SetMasterVolumeLevelScalar(value, NULL); - - if (hr != S_OK) { - std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to set current system volume\" }"; - } else { - std::wcout << L"{ \"Value\": \"" << std::to_wstring(curVolume) << "\" }"; - } - } - - return 0; -} +// VolumeControl.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include "pch.h" +#include +#include +#include + +#include + +// Operation constants +const wchar_t* Get = L"Get"; +const wchar_t* Set = L"Set"; +const wchar_t* SetNear = L"SetNear"; + +int wmain(int argc, wchar_t *argv[]) { + // Payload + std::wstring operation; + float value; + // COM Interfaces + HRESULT hr = NULL; + const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator); + const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator); + IMMDeviceEnumerator* pEnumerator; + LPVOID pvReserved = NULL; + + if (argc == 2) { + operation = argv[1]; + if (operation != Get) { + std::wcout << L"{ \"code\": \"160\", \"message\": \"EINVAL\" }"; + return 0; + } + } else if (argc == 3) { + operation = argv[1]; + std::wstring strValue = argv[2]; + + // Parse the received string into a float + const wchar_t* start = strValue.c_str(); + wchar_t* end = NULL; + + value = std::wcstof(start, &end); + + if ((operation != Set && operation != SetNear) || (value == 0 && end == start)) { + std::wcout << L"{ \"code\": \"160\", \"message\": \"EINVAL\" }"; + return 0; + } + } else { + std::wcout << L"{ \"code\": \"160\", \"message\": \"EINVAL\" }"; + return 0; + } + + hr = CoInitialize(pvReserved); + if (hr != S_OK) { + std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to initialize COM\" }"; + } + + hr = CoCreateInstance( + CLSID_MMDeviceEnumerator, + NULL, + CLSCTX_ALL, + IID_IMMDeviceEnumerator, + (void**)&pEnumerator + ); + if (hr != S_OK) { + std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to initialize COM instance\" }"; + } + + IMMDevice* pAudioDevice; + hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pAudioDevice); + if (hr != S_OK) { + std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to get default audio endpoint\" }"; + } + + IAudioEndpointVolume* pEndpointVolume; + pAudioDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pEndpointVolume); + if (hr != S_OK) { + std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to activate the audio endpoint\" }"; + } + + if (operation == Get) { + float curVolume = 0; + hr = pEndpointVolume->GetMasterVolumeLevelScalar(&curVolume); + if (hr != S_OK) { + std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to get current system volume\" }"; + } else { + std::wcout << L"{ \"Value\": \"" << std::to_wstring(curVolume) << "\" }"; + } + } else { + float curVolume = 0; + hr = pEndpointVolume->GetMasterVolumeLevelScalar(&curVolume); + + if (operation == SetNear && hr == S_OK) { + // Set the volume to near the target volume, allowing a small amount for the UI to finish the job. + if (abs(value - curVolume) > 0.02) { + value += (value > curVolume) ? -0.02 : 0.02; + } else { + value = curVolume; + } + } + + if (operation == Set || value != curVolume) { + hr = pEndpointVolume->SetMasterVolumeLevelScalar(value, NULL); + } + + if (hr != S_OK) { + std::wcout << L"{ \"code\": \"" << std::to_wstring(hr) << "\", \"message\": \"Failed to set current system volume\" }"; + } else { + float newVolume = 0; + if (pEndpointVolume->GetMasterVolumeLevelScalar(&newVolume) != S_OK) { + newVolume = value; + } + std::wcout << L"{ \"Value\": \"" << std::to_wstring(newVolume) << "\", \"Old\": \"" + << std::to_wstring(curVolume) << "\" }"; + } + } + + return 0; +} diff --git a/gpii/node_modules/nativeSettingsHandler/src/nativeSettingsHandler.js b/gpii/node_modules/nativeSettingsHandler/src/nativeSettingsHandler.js index 78624d29d..919d4213e 100644 --- a/gpii/node_modules/nativeSettingsHandler/src/nativeSettingsHandler.js +++ b/gpii/node_modules/nativeSettingsHandler/src/nativeSettingsHandler.js @@ -164,7 +164,8 @@ windows.nativeSettingsHandler.SetDoubleClickHeight = function (num) { /** * Function that handles calling the native executable for volume control. * - * @param {String} mode The operation mode, could be either "Set" or "Get". + * @param {String} mode The operation mode, could be either "Set", "SetNear" or "Get". Calling with "SetNear" will + * adjust the volume so it's near the target volume, allowing room for the shell to do the rest. * @param {Number} [num] The value to set as the current system volume. Range is normalized from 0 to 1. * @return {Promise} A promise that resolves on success or holds a object with the error information. */ @@ -176,9 +177,9 @@ windows.nativeSettingsHandler.VolumeHandler = function (mode, num) { var valueBuff; if (mode === "Get") { - valueBuff = child_process.execFileSync(fileName, ["Get"], {}); + valueBuff = child_process.execFileSync(fileName, [mode], {}); } else { - valueBuff = child_process.execFileSync(fileName, ["Set", num], {}); + valueBuff = child_process.execFileSync(fileName, [mode, num], {}); } var strRes = valueBuff.toString("utf8"); @@ -215,7 +216,18 @@ windows.nativeSettingsHandler.GetVolume = function () { * @return {Promise} A promise that resolves on success or holds a object with the error information. */ windows.nativeSettingsHandler.SetVolume = function (num) { - return windows.nativeSettingsHandler.VolumeHandler("Set", num); + return windows.nativeSettingsHandler.VolumeHandler("SetNear", num).then(function (result) { + var current = parseFloat(result); + if (current !== num) { + // Complete the last bit of the change, as though the media keys where used, in order to show the new volume + // on the screen. + var action = current < num + ? windows.API_constants.APPCOMMAND_VOLUME_UP : windows.API_constants.APPCOMMAND_VOLUME_DOWN; + // Send the volume up/down command directly to the task tray (rather than a simulated key press) + gpii.windows.messages.sendMessage("Shell_TrayWnd", windows.API_constants.WM_APPCOMMAND, 0, + windows.makeLong(0, action)); + } + }); }; /** From 57324ace4b8b07fad11ba0631630a9c9fa029f89 Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 5 Jul 2019 23:42:08 +0100 Subject: [PATCH 02/32] GPII-4011: Putting line separators back to CRLF. --- .../VolumeControl/VolumeControl/VolumeControl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp b/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp index 776502349..e44a472a6 100644 --- a/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp +++ b/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp @@ -87,6 +87,7 @@ int wmain(int argc, wchar_t *argv[]) { } } else { float curVolume = 0; + hr = pEndpointVolume->GetMasterVolumeLevelScalar(&curVolume); if (operation == SetNear && hr == S_OK) { From 5a5e9575c9d719dbf346aa19ac5fac2d841fa14f Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 5 Jul 2019 15:46:39 -0700 Subject: [PATCH 03/32] GPII-4011: Putting line separators back to CRLF. (trying harder) --- .../VolumeControl/VolumeControl/VolumeControl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp b/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp index e44a472a6..776502349 100644 --- a/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp +++ b/gpii/node_modules/nativeSettingsHandler/nativeSolutions/VolumeControl/VolumeControl/VolumeControl.cpp @@ -87,7 +87,6 @@ int wmain(int argc, wchar_t *argv[]) { } } else { float curVolume = 0; - hr = pEndpointVolume->GetMasterVolumeLevelScalar(&curVolume); if (operation == SetNear && hr == S_OK) { From 4fe32f609920151ae87f359998a1d61baec355ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Thu, 7 Nov 2019 20:26:59 +0100 Subject: [PATCH 04/32] GPII-4214: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 002d3066e..a0f51e8ff 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "stegru/universal#GPII-2338", + "gpii-universal": "javihernandez/universal#85e8de4e70087188170712e296083e9437b1b120", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From c5312fd53ddff1d0f1f609e5cbc3a1f2eb7f307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Thu, 21 Nov 2019 20:14:15 +0100 Subject: [PATCH 05/32] GPII-4214: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 306dcef1f..bab887462 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#85e8de4e70087188170712e296083e9437b1b120", + "gpii-universal": "javihernandez/universal#98913212f87e07f432a9d36e4e6ff63b334a6d1d", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 417e743d42ad29a417c0a32ca666354a1c92819e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 3 Dec 2019 22:26:43 +0100 Subject: [PATCH 06/32] GPII-4214.GPII-3572: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bab887462..e5f3b49f0 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#98913212f87e07f432a9d36e4e6ff63b334a6d1d", + "gpii-universal": "javihernandez/universal#f840342232b452e678b0dfb6b2582dece040b947", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From c2ce74cd0eb96e6f63cb2d994f254dc7b0a6e2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Wed, 4 Dec 2019 15:55:02 +0100 Subject: [PATCH 07/32] GPII-4214.GPII-3572: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e5f3b49f0..5ab999056 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#f840342232b452e678b0dfb6b2582dece040b947", + "gpii-universal": "javihernandez/universal#9b3bf12fef7de7f4d6ac2215fb91de53176892bd", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From ec8fc7bd88e206f66677a9df78aeb09430c98d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Thu, 5 Dec 2019 10:38:50 +0100 Subject: [PATCH 08/32] GPII-4214.GPII-3572: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5ab999056..15d9037dd 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#9b3bf12fef7de7f4d6ac2215fb91de53176892bd", + "gpii-universal": "javihernandez/universal#cbe26785209145d28c2250365bb1157d5398c18e", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From c98594225292998ec017c7a4c9cb5cbe3174d784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Thu, 19 Dec 2019 20:10:20 +0100 Subject: [PATCH 09/32] GPII-4214.GPII-3572: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f60e78cb4..48710dd69 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#cbe26785209145d28c2250365bb1157d5398c18e", + "gpii-universal": "javihernandez/universal#4231d15715a0df7540abb99a348a7f3b1aa06057", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 2c4d82a2847c365ee5514c5eab12a08569dc3df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Fri, 10 Jan 2020 11:26:53 +0100 Subject: [PATCH 10/32] GPII-4214.GPII-3572: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48710dd69..51d316251 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#4231d15715a0df7540abb99a348a7f3b1aa06057", + "gpii-universal": "javihernandez/universal#d5575a770e22467593cd0ddc039435d635342b9c", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 26b52d568c57a58e4d5cfc965af45ef23d6e27fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Fri, 17 Jan 2020 23:32:40 +0100 Subject: [PATCH 11/32] GPII-4214.GPII-3572: Removed disk filling error log --- gpii/node_modules/windowsMetrics/src/windowsMetrics.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gpii/node_modules/windowsMetrics/src/windowsMetrics.js b/gpii/node_modules/windowsMetrics/src/windowsMetrics.js index dfcaebd9d..e28a0c40b 100644 --- a/gpii/node_modules/windowsMetrics/src/windowsMetrics.js +++ b/gpii/node_modules/windowsMetrics/src/windowsMetrics.js @@ -1024,7 +1024,6 @@ windows.metrics.recordMouseEvent = function (that, button, pos) { // There have been some very large mouse distances captured (billions of pixels). The cause is unknown, so let's // just ignore anything that's larger than expected [GPII-3878]. if (state.distance > 0xffff) { - fluid.log("Dropping large mouse distance"); state.distance = 0; } } From d8091138d431cbce0c697a9cc71818dff35b7ac3 Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 28 Feb 2020 15:41:58 +0000 Subject: [PATCH 12/32] GPII-4370: Rejecting settings handler if the settings helper fails. --- .../systemSettingsHandler/src/systemSettingsHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpii/node_modules/systemSettingsHandler/src/systemSettingsHandler.js b/gpii/node_modules/systemSettingsHandler/src/systemSettingsHandler.js index 76e8ce68f..0834dcf8d 100644 --- a/gpii/node_modules/systemSettingsHandler/src/systemSettingsHandler.js +++ b/gpii/node_modules/systemSettingsHandler/src/systemSettingsHandler.js @@ -136,7 +136,7 @@ windows.systemSettingsHandler.invokeHandler = function (get, payload) { } else { promise.resolve(results); } - }); + }, promise.reject); return promise; }; From 6d7d07821884f01b53a2631b22e0be960d388bd4 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 11 Mar 2020 13:42:06 +0000 Subject: [PATCH 13/32] GPII-4370: Getting gpiiKey via userIdSource site config option --- .../userListeners/src/windowsLogin.js | 33 +++++++---- .../userListeners/test/windowsLoginTests.js | 55 ++++++++++++++++--- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/gpii/node_modules/userListeners/src/windowsLogin.js b/gpii/node_modules/userListeners/src/windowsLogin.js index be1e32b66..dda911a88 100644 --- a/gpii/node_modules/userListeners/src/windowsLogin.js +++ b/gpii/node_modules/userListeners/src/windowsLogin.js @@ -195,11 +195,15 @@ gpii.windows.userListeners.getGpiiKey = function (that, sign) { fluid.log("Auto-login user id: " + userId); if (userId && !that.checkBlockedUser(userId)) { - sign(userId, "site").then(function (digest) { - // Truncate the digest into a guid. - var result = gpii.windows.userListeners.hexToGuid(digest); - promise.resolve(result); - }, promise.reject); + if (userId.startsWith("gpiiKey:")) { + promise.resolve(userId.substring(8)); + } else { + sign(userId, "site").then(function (digest) { + // Truncate the digest into a guid. + var result = gpii.windows.userListeners.hexToGuid(digest); + promise.resolve(result); + }, promise.reject); + } } else { promise.reject("Unable to acquire the current user id"); } @@ -226,12 +230,16 @@ gpii.windows.userListeners.getUserId = function (userIdSource) { } else if (source === "userid") { // The User's SID userId = gpii.windows.getUserSid(); - } else if (source.startsWith("reg:")) { + } else if (source.startsWith("reg:") || source.startsWith("regkey")) { // A registry location - var match = /^reg:\\*(HK[A-Z_]+)\\(.*)\\([^\/]+)$/i.exec(userIdSource.replace("/", "\\")); - var baseKey = match[1]; - var keyPath = match[2]; - var valueName = match[3]; + if (source === "regkey") { + source += ":HKCU\\SOFTWARE\\Morphic\\gpiiKey"; + } + var match = /^reg(key)?:\\*(HK[A-Z_]+)\\(.*)\\([^\/]+)$/i.exec(userIdSource.replace("/", "\\")); + var isKey = match[1] === "key"; + var baseKey = match[2]; + var keyPath = match[3]; + var valueName = match[4]; if (baseKey.length <= 4) { baseKey = ({ HKLM: "HKEY_LOCAL_MACHINE", @@ -247,6 +255,11 @@ gpii.windows.userListeners.getUserId = function (userIdSource) { keyPath = (os.arch() === "x64" ? "32:" : "64:") + keyPath; userId = gpii.windows.readRegistryKey(baseKey, keyPath, valueName, "REG_SZ").value; } + + if (isKey && userId) { + userId = "gpiiKey:" + userId; + } + } else if (source.startsWith("file:")) { // A file var path = source.substr(5); diff --git a/gpii/node_modules/userListeners/test/windowsLoginTests.js b/gpii/node_modules/userListeners/test/windowsLoginTests.js index 87dde9674..c6268d2e7 100644 --- a/gpii/node_modules/userListeners/test/windowsLoginTests.js +++ b/gpii/node_modules/userListeners/test/windowsLoginTests.js @@ -153,16 +153,22 @@ jqUnit.test("Testing getUserId", function () { } }); - var regResult = gpii.windows.userListeners.getUserId("reg:" + baseKey + "\\" + subKey + "\\" + valueName); - jqUnit.assertEquals("getUserId(file) should return the correct value", userValue, regResult); + fluid.each(["reg:", "regkey:"], function (prefix) { + var expectedValue = prefix === "reg:" + ? userValue + : ("gpiiKey:" + userValue); - // Abbreviated base key - var regResult2 = gpii.windows.userListeners.getUserId("reg:" + "HKCU\\" + subKey + "\\" + valueName); - jqUnit.assertEquals("getUserId(file) should return the correct value", userValue, regResult2); + var regResult = gpii.windows.userListeners.getUserId(prefix + baseKey + "\\" + subKey + "\\" + valueName); + jqUnit.assertEquals("getUserId(file) should return the correct value", expectedValue, regResult); - // Non existing registry key - var regResult3 = gpii.windows.userListeners.getUserId("reg:" + "HKCU\\gpii\\does\\not\\exist"); - jqUnit.assertEquals("getUserId(file) should return the correct value", null, regResult3); + // Abbreviated base key + var regResult2 = gpii.windows.userListeners.getUserId(prefix + "HKCU\\" + subKey + "\\" + valueName); + jqUnit.assertEquals("getUserId(file) should return the correct value", expectedValue, regResult2); + + // Non existing registry key + var regResult3 = gpii.windows.userListeners.getUserId(prefix + "HKCU\\gpii\\does\\not\\exist"); + jqUnit.assertEquals("getUserId(file) should return the correct value", null, regResult3); + }); }); jqUnit.test("testing blocked user name matching", function () { @@ -294,6 +300,39 @@ jqUnit.asyncTest("testing getGpiiKey", function () { }); }); +jqUnit.asyncTest("testing getGpiiKey (got a gpiiKey)", function () { + var gpiiKey = "test-key" + Math.random(); + + var baseKey = "HKEY_CURRENT_USER"; + var subKey = "Software\\gpii-temp"; + var valueName = "username-test"; + var userValue = gpiiKey; + gpii.windows.writeRegistryKey(baseKey, subKey, valueName, userValue, "REG_SZ"); + teardowns.push(function () { + if (subKey.endsWith("gpii-temp")) { + gpii.windows.deleteRegistryKey(baseKey, subKey); + } + }); + + var windowsLogin = gpii.tests.userListener.windowsLogin({ + config: { + userIdSource: path.join("regkey:" + baseKey, subKey, valueName) + } + }); + + jqUnit.expect(2); + + var sign = function () { + jqUnit.fail("signing function should not be called for a gpiiKey"); + return fluid.promise().reject(); + }; + + gpii.windows.userListeners.getGpiiKey(windowsLogin, sign).then(function (key) { + jqUnit.assertEquals("getGpiiKey should resolve with the expected key", gpiiKey, key); + jqUnit.start(); + }, fluid.fail); +}); + jqUnit.asyncTest("testing getGpiiKey, with blocked user id", function () { var testFile = path.join(os.tmpdir(), "gpii-username-test" + Math.random()); teardowns.push(function () { From 842dce156cf618b47fd5762feacb667b947dfe3b Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 11 Mar 2020 13:43:38 +0000 Subject: [PATCH 14/32] GPII-4370: Resolving environment %variables% in the userIdSource site config option, for files. --- .../WindowsUtilities/WindowsUtilities.js | 38 +++++++++++++++++++ .../test/WindowsUtilitiesTests.js | 32 ++++++++++++++++ .../userListeners/src/windowsLogin.js | 2 +- .../userListeners/test/windowsLoginTests.js | 4 ++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js index a0eb22611..95ca06bf6 100644 --- a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js +++ b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js @@ -201,6 +201,10 @@ windows.kernel32 = ffi.Library("kernel32", { // https://msdn.microsoft.com/library/ms686211 "SetEvent": [ t.BOOL, [ t.HANDLE ] + ], + // https://msdn.microsoft.com/library/ms724265 + "ExpandEnvironmentStringsW": [ + t.BOOL, [ "char*", "char*", t.UINT ] ] }); @@ -2334,4 +2338,38 @@ fluid.defaults("gpii.windows.rm", { } }); +/** + * Expands the environment variables in a string, which are surrounded by '%'. + * For example, the input string of "%SystemRoot%\System32" returns "C:\Windows\System32". + * + * @param {String} input The input string. + * @return {String} The input string with the environment variables expanded. + */ +windows.expandEnvironmentStrings = function (input) { + var result; + if (input && input.length > 0) { + var inputBuffer = gpii.windows.stringToWideChar(input); + // Initial buffer of MAX_PATH should be big enough for most cases (assuming this function is called for paths). + var len = Math.max(gpii.windows.API_constants.MAX_PATH + 1, input.length + 20); + var outputBuffer = Buffer.alloc((len + 1) * 2); + // Expand the variables + var requiredSize = gpii.windows.kernel32.ExpandEnvironmentStringsW(inputBuffer, outputBuffer, len); + if (requiredSize > len) { + // Initial buffer is too small - call again with the correct size. + len = requiredSize; + outputBuffer = Buffer.alloc((len + 1) * 2); + requiredSize = gpii.windows.kernel32.ExpandEnvironmentStringsW(inputBuffer, outputBuffer, len); + } + if (requiredSize === 0) { + throw gpii.windows.win32Error("ExpandEnvironmentStringsW", requiredSize); + } + + result = gpii.windows.stringFromWideChar(outputBuffer); + } else { + result = ""; + } + + return result; +}; + exports.windows = windows; diff --git a/gpii/node_modules/WindowsUtilities/test/WindowsUtilitiesTests.js b/gpii/node_modules/WindowsUtilities/test/WindowsUtilitiesTests.js index 1c1553521..65e951a5e 100644 --- a/gpii/node_modules/WindowsUtilities/test/WindowsUtilitiesTests.js +++ b/gpii/node_modules/WindowsUtilities/test/WindowsUtilitiesTests.js @@ -571,3 +571,35 @@ jqUnit.test("Testing removeFiles", function () { checkRemoveSilent(pr1); checkRemoveSilent(pr2); }); + +jqUnit.test("expandEnvironmentStrings tests", function () { + + // Test a normal value + process.env._env_test1 = "VALUE"; + var input = "start%_env_test1%end"; + var result = windows.expandEnvironmentStrings(input); + // the value should be expanded + jqUnit.assertEquals("expandEnvironmentStrings should return expected result", "startVALUEend", result); + delete process.env._env_test1; + + // Test an unset value + var input2 = "start%_env_unset%end"; + var result2 = windows.expandEnvironmentStrings(input2); + // The value should be unexpanded + jqUnit.assertEquals("expandEnvironmentStrings (unset value) should return the input", input2, result2); + + // Test a very long value - this should cause the initial call to ExpandEnvironmentStrings to fail, and get recalled + // with a larger buffer. + process.env._env_test2 = "very long value" + "X".repeat(windows.API_constants.MAX_PATH * 2); + var input3 = "start%_env_test2%end"; + var result3 = windows.expandEnvironmentStrings(input3); + + jqUnit.assertEquals("expandEnvironmentStrings (long value) should return the expected result", + "start" + process.env._env_test2 + "end", result3); + + // Call with empty string or null should return an empty string. + ["", null].forEach(function (input) { + var result = windows.expandEnvironmentStrings(input); + jqUnit.assertEquals("expandEnvironmentStrings (empty/null) should return empty string", "", result); + }); +}); diff --git a/gpii/node_modules/userListeners/src/windowsLogin.js b/gpii/node_modules/userListeners/src/windowsLogin.js index dda911a88..a4f027690 100644 --- a/gpii/node_modules/userListeners/src/windowsLogin.js +++ b/gpii/node_modules/userListeners/src/windowsLogin.js @@ -262,7 +262,7 @@ gpii.windows.userListeners.getUserId = function (userIdSource) { } else if (source.startsWith("file:")) { // A file - var path = source.substr(5); + var path = gpii.windows.expandEnvironmentStrings(source.substr(5)); // Just use the first line of the file. try { var content = fs.readFileSync(path, "utf8"); diff --git a/gpii/node_modules/userListeners/test/windowsLoginTests.js b/gpii/node_modules/userListeners/test/windowsLoginTests.js index c6268d2e7..8b1806d07 100644 --- a/gpii/node_modules/userListeners/test/windowsLoginTests.js +++ b/gpii/node_modules/userListeners/test/windowsLoginTests.js @@ -137,6 +137,10 @@ jqUnit.test("Testing getUserId", function () { var fileResult = gpii.windows.userListeners.getUserId("file:" + testFile); jqUnit.assertEquals("getUserId(file) should return the correct value", expectFileResult, fileResult); + var testEnvFile = path.join("%TEMP%", path.basename(testFile)); + var fileEnvResult = gpii.windows.userListeners.getUserId("file:" + testEnvFile); + jqUnit.assertEquals("getUserId(file) should return the correct value", expectFileResult, fileEnvResult); + // File content (no file) var noFileResult = gpii.windows.userListeners.getUserId("file:c:\\not\\exists"); jqUnit.assertEquals("getUserId(no file) should return the correct value", null, noFileResult); From d8cfdf94639070fea6029b7ccbf32de11c1edd64 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 11 Mar 2020 17:03:29 +0000 Subject: [PATCH 15/32] NOJIRA: Updated package.json versions --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51d316251..6d586e9fb 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#d5575a770e22467593cd0ddc039435d635342b9c", + "gpii-universal": "stegru/universal#d5575a770e22467593cd0ddc039435d635342b9c", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 8e4024483fe018efe6877db0202d410782259969 Mon Sep 17 00:00:00 2001 From: ste Date: Wed, 11 Mar 2020 23:06:39 +0000 Subject: [PATCH 16/32] GPII-4397: Setting the correct variable for the default registry location for the regkey userIdSource --- gpii/node_modules/userListeners/src/windowsLogin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpii/node_modules/userListeners/src/windowsLogin.js b/gpii/node_modules/userListeners/src/windowsLogin.js index a4f027690..f1b74fc7d 100644 --- a/gpii/node_modules/userListeners/src/windowsLogin.js +++ b/gpii/node_modules/userListeners/src/windowsLogin.js @@ -233,7 +233,7 @@ gpii.windows.userListeners.getUserId = function (userIdSource) { } else if (source.startsWith("reg:") || source.startsWith("regkey")) { // A registry location if (source === "regkey") { - source += ":HKCU\\SOFTWARE\\Morphic\\gpiiKey"; + userIdSource += ":HKCU\\SOFTWARE\\Morphic\\gpiiKey"; } var match = /^reg(key)?:\\*(HK[A-Z_]+)\\(.*)\\([^\/]+)$/i.exec(userIdSource.replace("/", "\\")); var isKey = match[1] === "key"; From 62529a8b8affd697c64e38dd4ddf1acf22a451f7 Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 13 Mar 2020 13:44:45 +0000 Subject: [PATCH 17/32] GPII-4401: Generating gpiiKeys based on lowercase usernames. --- gpii/node_modules/userListeners/src/windowsLogin.js | 6 +++++- gpii/node_modules/userListeners/test/windowsLoginTests.js | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gpii/node_modules/userListeners/src/windowsLogin.js b/gpii/node_modules/userListeners/src/windowsLogin.js index f1b74fc7d..4894fabc7 100644 --- a/gpii/node_modules/userListeners/src/windowsLogin.js +++ b/gpii/node_modules/userListeners/src/windowsLogin.js @@ -276,7 +276,11 @@ gpii.windows.userListeners.getUserId = function (userIdSource) { userId = null; } - return (userId !== "" && userId) || null; + var togo = null; + if (userId !== "" && fluid.isValue(userId)) { + togo = (source === "userid") ? userId : userId.toLowerCase(); + } + return togo; }; diff --git a/gpii/node_modules/userListeners/test/windowsLoginTests.js b/gpii/node_modules/userListeners/test/windowsLoginTests.js index 8b1806d07..4c477a2fc 100644 --- a/gpii/node_modules/userListeners/test/windowsLoginTests.js +++ b/gpii/node_modules/userListeners/test/windowsLoginTests.js @@ -141,6 +141,14 @@ jqUnit.test("Testing getUserId", function () { var fileEnvResult = gpii.windows.userListeners.getUserId("file:" + testEnvFile); jqUnit.assertEquals("getUserId(file) should return the correct value", expectFileResult, fileEnvResult); + // Case-insensitive test + var expectFileResult2 = "TEST-userid2" + Math.random(); + fs.writeFileSync(testFile, expectFileResult2); + + var fileResult2 = gpii.windows.userListeners.getUserId("file:" + testFile); + jqUnit.assertEquals("getUserId(file) should return the correct value, in lower case", + expectFileResult2.toLowerCase(), fileResult2); + // File content (no file) var noFileResult = gpii.windows.userListeners.getUserId("file:c:\\not\\exists"); jqUnit.assertEquals("getUserId(no file) should return the correct value", null, noFileResult); From 83af4e86ee618d9796d95ef187bd7a222db553d1 Mon Sep 17 00:00:00 2001 From: ste Date: Sun, 15 Mar 2020 16:44:25 +0000 Subject: [PATCH 18/32] GPII-4403: Using the site secret for the hmac key to generate gpiiKeys. --- gpii-service/src/gpiiClient.js | 26 ++++++++++--------- gpii-service/tests/gpii-client-tests.js | 25 +++++++++++++++--- .../gpii-service-handler/src/requestSender.js | 2 +- .../userListeners/src/windowsLogin.js | 2 +- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/gpii-service/src/gpiiClient.js b/gpii-service/src/gpiiClient.js index a4108c6a5..efce504f0 100644 --- a/gpii-service/src/gpiiClient.js +++ b/gpii-service/src/gpiiClient.js @@ -128,27 +128,29 @@ gpiiClient.requestHandlers.getClientCredentials = function () { * * @param {Object} request The signing request * @param {String|Buffer} request.payload The thing to sign. - * @param {String} request.keyName Field name in the secrets file whose value is used as a key. + * @param {String} request.siteSpecific [optional] Field name in the secrets file which is specific to the site (the + * site id). This will be appended to the payload. * @return {String} The HMAC digest of payload, as a hex string. */ gpiiClient.requestHandlers.sign = function (request) { var result = null; var secrets = service.getSecrets(); - var key = secrets && secrets[request.keyName]; + if (secrets) { + var siteId = request.siteSpecific && secrets[request.siteSpecific]; - if (key) { - var hmac = crypto.createHmac("sha256", key); + var key = secrets.signKey || secrets.clientCredentials.client_secret; - var payloads = Array.isArray(request.payload) ? request.payload : [request.payload]; - payloads.forEach(function (item) { - hmac.update(item); - }); + if (key) { + var hmac = crypto.createHmac("sha256", key); + + var payload = siteId ? (request.payload + "@" + siteId) : request.payload; + hmac.update(payload); - result = hmac.digest("hex"); - } else { - service.logError("Attempted to sign with a key named " - + request.keyName + ", but no such value exists in the secrets file"); + result = hmac.digest("hex"); + } else { + service.logError("Unable to find a suitable key in the secrets file"); + } } return result; diff --git a/gpii-service/tests/gpii-client-tests.js b/gpii-service/tests/gpii-client-tests.js index 5221b69e3..feeeb7b73 100644 --- a/gpii-service/tests/gpii-client-tests.js +++ b/gpii-service/tests/gpii-client-tests.js @@ -113,10 +113,29 @@ gpiiClientTests.requestTests = [ action: "sign", data: { payload: "hello", - keyName: "site" + siteSpecific: "site" }, - // sha256-hmac(hello, testing.gpii.net) - expect: "81ba311bd1c768eaeabccccc0c208bef1a3e3be1b1476b6e35a7c4464fba5bd5" + // sha256-hmac(hello@testing.gpii.net, secret) + expect: "8a0aa7fd6346c155ceb5a7a2e234cf92036a77d492a549558c6ddffc0e8ebfb0" + }, + { + id: "sign (no site id)", + action: "sign", + data: { + payload: "hello" + }, + // sha256-hmac(hello, secret) + expect: "45be02a491dd3472deb1ec1b1a95ec50668e9b51d697cd060389a38d2c06be8d" + }, + { + id: "sign (unknown site id)", + action: "sign", + data: { + payload: "hello", + siteSpecific: "unknown-field" + }, + // sha256-hmac(hello, secret) + expect: "45be02a491dd3472deb1ec1b1a95ec50668e9b51d697cd060389a38d2c06be8d" }, { id: "client credentials", diff --git a/gpii/node_modules/gpii-service-handler/src/requestSender.js b/gpii/node_modules/gpii-service-handler/src/requestSender.js index 01ce1b13d..1259bae0f 100644 --- a/gpii/node_modules/gpii-service-handler/src/requestSender.js +++ b/gpii/node_modules/gpii-service-handler/src/requestSender.js @@ -51,7 +51,7 @@ fluid.defaults("gpii.windows.service.requestSender", { "sign", { payload: "{arguments}.0", - keyName: "{arguments}.1" + siteSpecific: "{arguments}.1" } ] } diff --git a/gpii/node_modules/userListeners/src/windowsLogin.js b/gpii/node_modules/userListeners/src/windowsLogin.js index 4894fabc7..47fe10e58 100644 --- a/gpii/node_modules/userListeners/src/windowsLogin.js +++ b/gpii/node_modules/userListeners/src/windowsLogin.js @@ -163,7 +163,7 @@ gpii.windows.userListeners.startWindowsLogin = function (that) { * * @callback windowsLogin.sign * @param {String|Buffer} payload The data to sign. - * @param {String} keyName Key identifier (field name in the service's secrets file). + * @param {String} siteSpecific [optional] Field name in the service's secrets file that is specific to the site. * @return {Promise} Resolves with the signed digest, as a 256bit hex string. */ From 13a8dbb4f55ac3b7965da357b99477e03e65ea40 Mon Sep 17 00:00:00 2001 From: ste Date: Sun, 15 Mar 2020 19:28:23 +0000 Subject: [PATCH 19/32] NOJIRA: Updated gpii-windows/gpii-universal references. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d586e9fb..aebf97448 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "stegru/universal#d5575a770e22467593cd0ddc039435d635342b9c", + "gpii-universal": "GPII/universal#d5575a770e22467593cd0ddc039435d635342b9c", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 46fe848370766b751774b6f9a30310546c93ac29 Mon Sep 17 00:00:00 2001 From: ste Date: Sat, 21 Mar 2020 15:23:59 +0000 Subject: [PATCH 20/32] NOJIRA: Updating universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aebf97448..6d18c8161 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "GPII/universal#d5575a770e22467593cd0ddc039435d635342b9c", + "gpii-universal": "GPII/universal#26baded92cc5f6f3416e1fc547ae610381984b03", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From cee3522e6828059f0e730762adf770a1c382ad0f Mon Sep 17 00:00:00 2001 From: ste Date: Tue, 24 Mar 2020 10:04:10 +0000 Subject: [PATCH 21/32] NOJIRA: Updating gpii-windows reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 04b4a1710..618d35bd8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "GPII/universal#26baded92cc5f6f3416e1fc547ae610381984b03", + "gpii-universal": "GPII/universal#cb694900fdfb013681ab43ffea8c95af7f5a2be1", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 47d22db5b2378d9d998e5afd8eb3077893dcd56d Mon Sep 17 00:00:00 2001 From: ste Date: Fri, 27 Mar 2020 23:27:48 +0000 Subject: [PATCH 22/32] GPII-4289: Calculating QSS height, rather than using the window size. --- .../node_modules/gpii-windowManagement/src/appBar.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gpii/node_modules/gpii-windowManagement/src/appBar.js b/gpii/node_modules/gpii-windowManagement/src/appBar.js index eb0cc5d60..7e8b02749 100644 --- a/gpii/node_modules/gpii-windowManagement/src/appBar.js +++ b/gpii/node_modules/gpii-windowManagement/src/appBar.js @@ -42,6 +42,7 @@ fluid.defaults("gpii.windows.appBar", { getNativeWindowHandle: "fluid.notImplemented", hookWindowMessage: "fluid.notImplemented", unhookWindowMessage: "fluid.notImplemented", + getBarHeight: "fluid.notImplemented", listenForMessage: { funcName: "gpii.windows.appBar.listenForMessage", @@ -75,7 +76,8 @@ fluid.defaults("gpii.windows.appBar", { hookedMessages: [], WM_GPII_APPBAR: "@expand:gpii.windows.messages.registeredMessage(WM_GPII_APPBAR)", enabled: false, - bottomTaskbar: true + bottomTaskbar: true, + height: undefined } }); @@ -235,22 +237,22 @@ gpii.windows.appBar.updateAppBar = function (hwnd, message, appBarData) { */ gpii.windows.appBar.updatePosition = function (that) { var rect; - var windowRect = gpii.windows.getWindowRect(that.hwnd); + var height = that.getBarHeight(); var taskbarRect = gpii.windows.getWindowRect(gpii.windows.getTasktrayWindow()); if (taskbarRect.left === 0 && taskbarRect.top > 0) { // Taskbar is at the bottom (the usual position) rect = { left: 0, - top: taskbarRect.top - windowRect.height - 1, + top: taskbarRect.top - height, right: taskbarRect.width, - bottom: taskbarRect.top + bottom: taskbarRect.top - 1 }; } else { var desktopRect = gpii.windows.display.getDesktopSize(); rect = { left: 0, - top: desktopRect.height - windowRect.height - 1, + top: desktopRect.height - height, width: desktopRect.width, bottom: desktopRect.height }; From ed50a6dcf292d58262776cd4fda500ff04e9af35 Mon Sep 17 00:00:00 2001 From: ste Date: Sun, 29 Mar 2020 15:25:24 +0100 Subject: [PATCH 23/32] GPII-4420: Only listing languages installed by a morphic language installer --- .../WindowsUtilities/WindowsUtilities.js | 4 +++ .../gpii-localisation/src/language.js | 30 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js index bd3e6e565..f46e54513 100644 --- a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js +++ b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js @@ -205,6 +205,10 @@ windows.kernel32 = ffi.Library("kernel32", { // https://msdn.microsoft.com/library/ms724265 "ExpandEnvironmentStringsW": [ t.BOOL, [ "char*", "char*", t.UINT ] + ], + // https://docs.microsoft.com/windows/win32/api/winnls/nf-winnls-getsystemdefaultlocalename + "GetSystemDefaultLocaleName": [ + t.INT, [ "char*", t.INT ] ] }); diff --git a/gpii/node_modules/gpii-localisation/src/language.js b/gpii/node_modules/gpii-localisation/src/language.js index 03ad0b698..1aafca585 100644 --- a/gpii/node_modules/gpii-localisation/src/language.js +++ b/gpii/node_modules/gpii-localisation/src/language.js @@ -112,15 +112,39 @@ gpii.windows.language.fixCodeCase = function (langCode) { /** * Gets the display languages that are installed on the system, and updates the model. * - * These are listed in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages + * These are listed in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages, however this has become + * unreliable - so, only the languages explicitly installed via Morphic language installers will be used. + * + * Setting the environment variable GPII_DETECT_LANGUAGES will enable the original behaviour. + * + * The installers will write a value to HKLM\Software\Morphic\LanguageInstalled. * * @param {Component} that The gpii.windows.language instance. * @return {Promise>} A promise, resolving with either the language names if the list has * changed, or null if there was no change. */ gpii.windows.language.getInstalled = function (that) { - var langCodes = gpii.windows.enumRegistryKeys( - "HKEY_LOCAL_MACHINE", "SYSTEM\\CurrentControlSet\\Control\\MUI\\UILanguages"); + + var langCodes; + if (process.env.GPII_DETECT_LANGUAGES) { + langCodes = gpii.windows.enumRegistryKeys( + "HKEY_LOCAL_MACHINE", "SYSTEM\\CurrentControlSet\\Control\\MUI\\UILanguages"); + } else { + // Get the OS default language, because a language pack for that language isn't going to be installed. + var LOCALE_NAME_MAX_LENGTH = 85; + var codeBuffer = Buffer.alloc(LOCALE_NAME_MAX_LENGTH * 2); + var result = gpii.windows.kernel32.GetSystemDefaultLocaleName(codeBuffer, codeBuffer.length); + var osLang = result ? "en-US" : gpii.windows.stringFromWideChar(codeBuffer); + + langCodes = fluid.keys( + gpii.windows.enumRegistryValues("HKEY_LOCAL_MACHINE", "Software\\Morphic\\LanguageInstalled")); + + if (!langCodes.includes(osLang)) { + langCodes.unshift(osLang); + } + + fluid.log("Installed Languages: " + osLang + " (OS), ", langCodes); + } langCodes = langCodes.map(gpii.windows.language.fixCodeCase); From 0a25bea25d70ad4131e51c9c7f875a7cf112333b Mon Sep 17 00:00:00 2001 From: ste Date: Sun, 29 Mar 2020 23:22:35 +0100 Subject: [PATCH 24/32] NOJIRA: Updating gpii-universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 618d35bd8..2df5b0022 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "GPII/universal#cb694900fdfb013681ab43ffea8c95af7f5a2be1", + "gpii-universal": "GPII/universal#63fc7fd1de5d7cf6ed2188576ea5df5ecdc7fe6c", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 687d336f3c019542bfbdb71c0b2f2f2cea0911dd Mon Sep 17 00:00:00 2001 From: ste Date: Mon, 30 Mar 2020 00:32:23 +0100 Subject: [PATCH 25/32] GPII-4420: Handling the possibility of no installed language packs --- gpii/node_modules/gpii-localisation/src/language.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gpii/node_modules/gpii-localisation/src/language.js b/gpii/node_modules/gpii-localisation/src/language.js index 1aafca585..5b284314e 100644 --- a/gpii/node_modules/gpii-localisation/src/language.js +++ b/gpii/node_modules/gpii-localisation/src/language.js @@ -136,11 +136,15 @@ gpii.windows.language.getInstalled = function (that) { var result = gpii.windows.kernel32.GetSystemDefaultLocaleName(codeBuffer, codeBuffer.length); var osLang = result ? "en-US" : gpii.windows.stringFromWideChar(codeBuffer); - langCodes = fluid.keys( - gpii.windows.enumRegistryValues("HKEY_LOCAL_MACHINE", "Software\\Morphic\\LanguageInstalled")); + var values = gpii.windows.enumRegistryValues("HKEY_LOCAL_MACHINE", "Software\\Morphic\\LanguageInstalled"); + if (values.statusCode) { + langCodes = [osLang]; + } else { + langCodes = fluid.keys(values); - if (!langCodes.includes(osLang)) { - langCodes.unshift(osLang); + if (!langCodes.includes(osLang)) { + langCodes.unshift(osLang); + } } fluid.log("Installed Languages: " + osLang + " (OS), ", langCodes); From 63214600696b59636b4dfc0aa2266f43ffbdfdb8 Mon Sep 17 00:00:00 2001 From: ste Date: Mon, 30 Mar 2020 13:01:48 +0100 Subject: [PATCH 26/32] NOJIRA: Updating gpii-universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2df5b0022..4d903f7b6 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "GPII/universal#63fc7fd1de5d7cf6ed2188576ea5df5ecdc7fe6c", + "gpii-universal": "GPII/universal#77fb761eb6e2679029829aff7c41c256dbceceb0", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 2fa63f9c2682880db3f2acbfb9d927a5426a5350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Wed, 27 May 2020 10:47:10 +0200 Subject: [PATCH 27/32] GPII-4490: Removed redefinition of ExpandEnvironmentStringsW --- gpii/node_modules/WindowsUtilities/WindowsUtilities.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js index 400ce1cea..c769140ed 100644 --- a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js +++ b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js @@ -201,10 +201,6 @@ windows.kernel32 = ffi.Library("kernel32", { "SetEvent": [ t.BOOL, [ t.HANDLE ] ], - // https://msdn.microsoft.com/library/ms724265 - "ExpandEnvironmentStringsW": [ - t.BOOL, [ "char*", "char*", t.UINT ] - ], // https://docs.microsoft.com/windows/win32/api/winnls/nf-winnls-getsystemdefaultlocalename "GetSystemDefaultLocaleName": [ t.INT, [ "char*", t.INT ] From b33d5e2b831750aa2c4d513ed3b4a7594b0a6735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Fri, 29 May 2020 17:51:24 +0200 Subject: [PATCH 28/32] GPII-4490: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a30531762..cb8cc6ee5 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "0.3.0-dev.20200522T150446Z.1f28edf", + "gpii-universal": "javihernandez/universal#5187e4f961a70ff664b96bd287f9a3f258b82744", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From af991dfc84448751f2e716be7ec2f326fa8b82c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Wed, 10 Jun 2020 12:59:33 +0200 Subject: [PATCH 29/32] GPII-4490: Updated universal reference This brings stegru/universal#GPII-4500 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7c01df3d..aced82cb5 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "0.3.0-dev.20200604T131823Z.d6fed9a", + "gpii-universal": "javihernandez/universal#de6d2062f27d2d6573604162bb5b074300e0ec3f", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 0c1b23bbf4290b17a934ff64029fd7db97624a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Wed, 10 Jun 2020 13:42:33 +0200 Subject: [PATCH 30/32] GPII-4490: Fixed typo from last update with master See https://github.com/javihernandez/windows/commit/64f654e2675c6e1b24d77364f726ef0e432f89f3#diff-864b1fb848cfe2a0afe44120b1955365L2376 --- gpii/node_modules/WindowsUtilities/WindowsUtilities.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js index 4eb703dc8..d35dfc71b 100644 --- a/gpii/node_modules/WindowsUtilities/WindowsUtilities.js +++ b/gpii/node_modules/WindowsUtilities/WindowsUtilities.js @@ -2339,6 +2339,7 @@ gpii.windows.getUserUsbDrives = function (usbDrives) { }; +/** * Gets the icon cell size, which is used by explorer to space icons. * @return {Object} containing the x and y sizes of icon cells, in pixels. */ From c538930d4220cc91ab6a297143ab4667d226d299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Fri, 12 Jun 2020 15:37:57 +0200 Subject: [PATCH 31/32] GPII-4490: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aced82cb5..6d07ae029 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#de6d2062f27d2d6573604162bb5b074300e0ec3f", + "gpii-universal": "javihernandez/universal#3f1831ad01a3b19660723c1814cc23e9125db207", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 060f99dd9a408622708d2ff499db54ed4d680381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 15 Jun 2020 12:49:35 +0200 Subject: [PATCH 32/32] GPII-4490: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d07ae029..8b909a597 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#3f1831ad01a3b19660723c1814cc23e9125db207", + "gpii-universal": "javihernandez/universal#4b4f238858a3e0be0ab801703299676cbba1399a", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0",