Purpose:
The lobby.js parsing XmppClient.cpp GUI messages is ugly, because it forces every message to use the property names text and data,
while every message should use its own names, for example oldnick and newnick.
Furthermore messages might want to send an arbitrary number of messages.
The patch is working besides two issues:
Challenge 1: It segfaults when starting to host a game in the lobby (somewhere in SpiderMonkey after the Engine.LobbySetPlayerPresence("playing"); call in gamesetup_mp.js.
I assume this is because it uses the g_GUI->GetActiveGUI()->GetScriptInterface() after having switched to another GUI page.
I tried to create a new ScriptInterface in the ctor (this is what the NetServer that runs in a separate thread does), but that segfaults immediately on that statement.
Also tried to use the ScriptInterface that is passed in JSI_Lobby::StartXmppClient, but that also doesn't work (crashes much sooner).
Since the previous code didn't save JS::Values, it only came into contact with any ScriptInterface when the GUI ordered something.
But now we need a ScriptInterface whenever receiving a message from gloox.
Challenge 2: Using macros to remove the duplication in CREATE_GUI_MESSAGE_0, CREATE_GUI_MESSAGE_1, CREATE_GUI_MESSAGE_2 and potentially support arbitrary number of arguments.