Ticket #3386: t3386_clear_muc_messages_v1.1.patch
File t3386_clear_muc_messages_v1.1.patch, 10.1 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/lobby/lobby.js
172 172 var playersBox = Engine.GetGUIObjectByName("playersBox"); 173 173 var playerList = []; 174 174 var presenceList = []; 175 175 var nickList = []; 176 176 var ratingList = []; 177 var cleanPlayerList = Engine.GetPlayerList( );177 var cleanPlayerList = Engine.GetPlayerList(true); 178 178 // Sort the player list, ignoring case. 179 179 cleanPlayerList.sort(function(a,b) 180 180 { 181 181 switch (g_PlayerListSortBy) 182 182 { -
binaries/data/mods/public/gui/lobby/lobby.xml
233 233 234 234 <object name="chatPanel" size="0 49% 100% 100%" type="image" sprite="ModernDarkBoxGold"> 235 235 <object name="chatText" size="0 0 100% 94%" type="text" style="ChatPanel" font="sans-13"/> 236 236 <object name="chatInput" size="0 94% 100% 100%" type="input" style="ModernInput" font="sans-13"> 237 237 <action on="Press">submitChatInput();</action> 238 <action on="Tab">autoCompleteNick("chatInput", Engine.GetPlayerList( ));</action>238 <action on="Tab">autoCompleteNick("chatInput", Engine.GetPlayerList(false));</action> 239 239 </object> 240 240 </object> 241 241 </object> 242 242 243 243 <!-- START Window for leaderboard stats --> -
source/lobby/IXmppClient.h
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … 46 46 virtual void SetPresence(const std::string& presence) = 0; 47 47 virtual void GetPresence(const std::string& nickname, std::string& presence) = 0; 48 48 virtual void GetRole(const std::string& nickname, std::string& role) = 0; 49 49 virtual void GetSubject(std::string& subject) = 0; 50 50 51 virtual void GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret ) = 0;51 virtual void GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret, bool clearPresenceUpdates) = 0; 52 52 virtual void GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 53 53 virtual void GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 54 54 virtual void GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; 55 55 56 56 virtual void GuiPollMessage(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; -
source/lobby/XmppClient.cpp
492 492 /** 493 493 * Handle requests from the GUI for the list of players. 494 494 * 495 495 * @return A JS array containing all known players and their presences 496 496 */ 497 void XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret )497 void XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret, bool clearPresenceUpdates) 498 498 { 499 if (clearPresenceUpdates) 500 { 501 m_GuiMessageQueue.erase( 502 std::remove_if(m_GuiMessageQueue.begin(), m_GuiMessageQueue.end(), 503 [](XmppClient::GUIMessage& message) 504 { 505 return message.type == L"muc" && message.level != L"subject"; 506 } 507 ), m_GuiMessageQueue.end()); 508 } 509 499 510 JSContext* cx = scriptInterface.GetContext(); 500 511 JSAutoRequest rq(cx); 501 512 502 513 scriptInterface.Eval("([])", ret); 503 514 -
source/lobby/XmppClient.h
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … 18 18 #ifndef XXXMPPCLIENT_H 19 19 #define XXXMPPCLIENT_H 20 20 21 21 #include "IXmppClient.h" 22 22 23 #include "glooxwrapper/glooxwrapper.h"24 25 //game - script26 23 #include <deque> 24 25 #include "glooxwrapper/glooxwrapper.h" 27 26 #include "scriptinterface/ScriptVal.h" 28 27 29 //Game - script30 28 class ScriptInterface; 31 29 32 30 namespace glooxwrapper 33 31 { 34 32 class Client; … … 36 34 } 37 35 38 36 class XmppClient : public IXmppClient, public glooxwrapper::ConnectionListener, public glooxwrapper::MUCRoomHandler, public glooxwrapper::IqHandler, public glooxwrapper::RegistrationHandler, public glooxwrapper::MessageHandler 39 37 { 40 38 NONCOPYABLE(XmppClient); 39 41 40 private: 42 41 //Components 43 42 glooxwrapper::Client* m_client; 44 43 glooxwrapper::MUCRoom* m_mucRoom; 45 44 glooxwrapper::Registration* m_registration; 45 46 46 //Account infos 47 47 std::string m_username; 48 48 std::string m_password; 49 49 std::string m_nick; 50 50 std::string m_xpartamuppId; 51 51 52 // State 52 53 bool m_initialLoadComplete = false; 54 53 55 public: 54 56 //Basic 55 57 XmppClient(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize = 0, const bool regOpt = false); 56 58 virtual ~XmppClient(); 57 59 … … 74 76 void SetPresence(const std::string& presence); 75 77 void GetPresence(const std::string& nickname, std::string& presence); 76 78 void GetRole(const std::string& nickname, std::string& role); 77 79 void GetSubject(std::string& subject); 78 80 79 void GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret );81 void GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret, bool clearPresenceUpdates); 80 82 void GUIGetGameList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); 81 83 void GUIGetBoardList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); 82 84 void GUIGetProfile(ScriptInterface& scriptInterface, JS::MutableHandleValue ret); 85 83 86 //Script 84 87 ScriptInterface& GetScriptInterface(); 85 88 86 89 protected: 87 90 /* Xmpp handlers */ … … 120 123 121 124 // Helpers 122 125 void GetPresenceString(const gloox::Presence::PresenceType p, std::string& presence) const; 123 126 void GetRoleString(const gloox::MUCRoomRole r, std::string& role) const; 124 127 std::string StanzaErrorToString(gloox::StanzaError err); 128 125 129 public: 126 130 /* Messages */ 127 131 struct GUIMessage 128 132 { 129 133 std::wstring type; -
source/lobby/scripting/JSInterface_Lobby.cpp
44 44 scriptInterface.RegisterFunction<void, std::wstring, &JSI_Lobby::SendGetProfile>("SendGetProfile"); 45 45 scriptInterface.RegisterFunction<void, JS::HandleValue, &JSI_Lobby::SendRegisterGame>("SendRegisterGame"); 46 46 scriptInterface.RegisterFunction<void, JS::HandleValue, &JSI_Lobby::SendGameReport>("SendGameReport"); 47 47 scriptInterface.RegisterFunction<void, &JSI_Lobby::SendUnregisterGame>("SendUnregisterGame"); 48 48 scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &JSI_Lobby::SendChangeStateGame>("SendChangeStateGame"); 49 scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetPlayerList>("GetPlayerList");49 scriptInterface.RegisterFunction<JS::Value, bool, &JSI_Lobby::GetPlayerList>("GetPlayerList"); 50 50 scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetGameList>("GetGameList"); 51 51 scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetBoardList>("GetBoardList"); 52 52 scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::GetProfile>("GetProfile"); 53 53 scriptInterface.RegisterFunction<JS::Value, &JSI_Lobby::LobbyGuiPollMessage>("LobbyGuiPollMessage"); 54 54 scriptInterface.RegisterFunction<void, std::wstring, &JSI_Lobby::LobbySendMessage>("LobbySendMessage"); … … 173 173 if (!g_XmppClient) 174 174 return; 175 175 g_XmppClient->SendIqChangeStateGame(utf8_from_wstring(nbp), utf8_from_wstring(players)); 176 176 } 177 177 178 JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate )178 JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate, bool clearPresenceUpdates) 179 179 { 180 180 if (!g_XmppClient) 181 181 return JS::UndefinedValue(); 182 182 183 183 JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); 184 184 JSAutoRequest rq(cx); 185 185 186 186 JS::RootedValue playerList(cx); 187 g_XmppClient->GUIGetPlayerList(*(pCxPrivate->pScriptInterface), &playerList );187 g_XmppClient->GUIGetPlayerList(*(pCxPrivate->pScriptInterface), &playerList, clearPresenceUpdates); 188 188 189 189 return playerList; 190 190 } 191 191 192 192 JS::Value JSI_Lobby::GetGameList(ScriptInterface::CxPrivate* pCxPrivate) -
source/lobby/scripting/JSInterface_Lobby.h
42 42 void SendGetProfile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring player); 43 43 void SendGameReport(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data); 44 44 void SendRegisterGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data); 45 45 void SendUnregisterGame(ScriptInterface::CxPrivate* pCxPrivate); 46 46 void SendChangeStateGame(ScriptInterface::CxPrivate* pCxPrivate, std::wstring nbp, std::wstring players); 47 JS::Value GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate );47 JS::Value GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate, bool clearPresenceUpdates); 48 48 JS::Value GetGameList(ScriptInterface::CxPrivate* pCxPrivate); 49 49 JS::Value GetBoardList(ScriptInterface::CxPrivate* pCxPrivate); 50 50 JS::Value GetProfile(ScriptInterface::CxPrivate* pCxPrivate); 51 51 JS::Value LobbyGuiPollMessage(ScriptInterface::CxPrivate* pCxPrivate); 52 52 void LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, std::wstring message);