Skip to content

Conversation

@JavierJF
Copy link
Contributor

@JavierJF JavierJF commented Dec 8, 2017

No description provided.

@gpii-bot
Copy link

gpii-bot commented Dec 8, 2017

Could one of the admins verify that these changes are reasonable to test? If so, please reply with "ok to test".

@kaspermarkus
Copy link
Member

@JavierJF will notify @stegru when this is ready for review... He'll give it a first round of review, and pass to antranig when ready for merge/second round of review

return togo;
};

windows.isSupportedMsg = function(message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of being able to send a message. However, I think it should be placed into a function and called in a "start" or "stop" block, like gpii.launch.exec or gpii.windows.closeProcessByName.

That way, other settings handlers can make use of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that thought, will be simpler, and useful from all the SettingsHandlers, sadly we have a imminent change for that block coming from this pull. So probably I'm going to update the rest of issues of the pull and leave this one as a TODO, to be fixed when the new blocks could be used.

};

windows.isSupportedMsg = function(message) {
var hwnd = windows.API_constants[message.hwnd];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why bother? It's not like there can be other values for the hWnd.

I suggest either remove the ability to specify the hWnd, or perhaps accept a string, where it sends the message to windows with a matching caption (and/or classname?), if it's not "HWND_BROADCAST" (using a combination of windows.enumerateWindows and GetWindowText).


windows.sendWindowMessage = function(message) {
try {
if (!windows.isSupportedMsg(message)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do !hwnd || !msg on 367

@stegru
Copy link
Member

stegru commented Dec 20, 2017

@JavierJF, that's my first-pass review. I haven't ran it (it has the "Needs Work" label).

I agree with your approach. There is a SetLocalInfo API function, and I think that does exactly what you've done - I mean, this works, right? It might be worth creating a small .c program that just calls that function to see if it does anything else... but I doubt it does.

I also have an idea - perhaps there could also be a "culture" setting (en-GB, es-ES). It would make all of these individual settings whatever that culture default is for that setting, unless specifically set. GetLocalInfoEx gets this information.

@gpii-bot
Copy link

Could one of the admins verify that these changes are reasonable to test? If so, please reply with "ok to test".

@stegru
Copy link
Member

stegru commented Apr 13, 2018

ok to test

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/windows-tests/461/

@stegru
Copy link
Member

stegru commented Apr 13, 2018

What changed since I last looked?

My suggestions:

  • The registry handler isn't the best place to send messages from. There's now a windowMessages module, https://github.com/gpii/windows/blob/master/gpii/node_modules/windowMessages/src/windowMessages.js (it currently just receives messages)
  • Use the same mechanism as gpii.launch.exec or gpii.windows.closeProcessByName, so other solutions without registry settings can enjoy sending messages.
  • No need to pass HWND_BROADCAST (just always use it), because there is no other valid window handle constant that I'm aware of. Bonus points: allow passing the window class name.
  • Maybe put the WM_xx constants in their own object.

@gpii-bot
Copy link

gpii-bot commented Jun 6, 2018

CI job failed: https://ci.gpii.net/job/windows-tests/521/

 + Removed the ability to specify windows handle in message feature.
 + Fixed some linter issues.
@gpii-bot
Copy link

gpii-bot commented Jun 8, 2018

CI job passed: https://ci.gpii.net/job/windows-tests/534/

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/windows-tests/535/

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/windows-tests/538/

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/windows-tests/539/

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/windows-tests/540/

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/windows-tests/541/

return (typeof msg !== undefined);
};

windows.sendWindowMessage = function (message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A jsdoc would be nice


windows.sendWindowMessage = function (message) {
try {
if (!windows.isSupportedMsg(message)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point in this any more, considering a check on the message constant is performed on line 258. An else block can be used at 261 instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, replacing it for a 'else' for having a switch-case style message check, and logging in case of unsupported.

});

// Test that the "sendWindowMessage" function actually sends the message.
jqUnit.test("Window Messages - Message sent", function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/windows-tests/542/

@stegru
Copy link
Member

stegru commented Jun 20, 2018

ok to test

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/windows-tests/544/

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/windows-tests/547/

@stegru
Copy link
Member

stegru commented Jun 20, 2018

ok to test

    default: WinRM transport: negotiate
An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Unable to parse authorization header. Headers: {}
Body: SSH-2.0-OpenSSH_7.6
Protocol mismatch.
 ().
Build step 'Execute shell' marked build as failure
Finished: FAILURE

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/windows-tests/548/

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/windows-tests/578/

/**
* Sends a message to every open window.
*
* @param message.msg {number} The message to be sent.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No doc for the actual message parameter.

In fact, why not unroll these into individual parameters, since they're all required?

newValue: newValue.value
};
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray newline

*
* @param message.msg {number} The message to be sent.
* @param message.wparam {Object} The wparam to be passed to SendWindowNotifyMessageW function.
* @param message.lparam {Object} The lparam to be passed to SendWindowNotifyMessageW function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wparam should be {Number}, and lparam a {String} (considering line 255)

@JavierJF JavierJF closed this Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants