Pyrogenesis  trunk
JSInterface_Lobby.h
Go to the documentation of this file.
1 /* Copyright (C) 2014 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_JSI_LOBBY
19 #define INCLUDED_JSI_LOBBY
20 
21 #include "lib/config2.h"
24 
25 namespace JSI_Lobby
26 {
27  void RegisterScriptFunctions(ScriptInterface& scriptInterface);
28 
29  bool HasXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
30  bool IsRankedGame(ScriptInterface::CxPrivate* pCxPrivate);
31  void SetRankedGame(ScriptInterface::CxPrivate* pCxPrivate, bool isRanked);
32 
33 #if CONFIG2_LOBBY
34  void StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize);
35  void StartRegisterXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password);
42  void SendGetProfile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& player);
43  void SendGameReport(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data);
44  void SendRegisterGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data);
46  void SendChangeStateGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nbp, const std::wstring& players);
54  void LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& message);
55  void LobbySetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& presence);
56  void LobbySetNick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick);
57  std::wstring LobbyGetNick(ScriptInterface::CxPrivate* pCxPrivate);
58  void LobbyKick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick, const std::wstring& reason);
59  void LobbyBan(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick, const std::wstring& reason);
60  std::wstring LobbyGetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname);
61  std::wstring LobbyGetPlayerRole(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname);
62  std::wstring LobbyGetRoomSubject(ScriptInterface::CxPrivate* pCxPrivate);
63 
64  // Non-public secure PBKDF2 hash function with salting and 1,337 iterations
65  std::string EncryptPassword(const std::string& password, const std::string& username);
66 
67  // Public hash interface.
68  std::wstring EncryptPassword(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& pass, const std::wstring& user);
69 #endif // CONFIG2_LOBBY
70 }
71 
72 #endif
void SendGetProfile(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &player)
Definition: JSInterface_Lobby.cpp:144
void SendChangeStateGame(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &nbp, const std::wstring &players)
Definition: JSInterface_Lobby.cpp:174
JS::Value GetBoardList(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:222
void RegisterScriptFunctions(ScriptInterface &scriptInterface)
Registers the functions of the JavaScript interface for internationalization and localization into th...
Definition: JSInterface_Lobby.cpp:30
bool HasXmppClient(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:70
void SetRankedGame(ScriptInterface::CxPrivate *pCxPrivate, bool isRanked)
Definition: JSInterface_Lobby.cpp:80
void LobbySetNick(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &nick)
Definition: JSInterface_Lobby.cpp:280
void StartRegisterXmppClient(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &username, const std::wstring &password)
Definition: JSInterface_Lobby.cpp:96
Config::Value_type Value
Definition: json_spirit_value.h:181
bool IsRankedGame(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:75
void LobbyKick(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &nick, const std::wstring &reason)
Definition: JSInterface_Lobby.cpp:298
void SendUnregisterGame(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:167
std::wstring LobbyGetPlayerPresence(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &nickname)
Definition: JSInterface_Lobby.cpp:314
Definition: JSInterface_Lobby.h:25
void SendGetGameList(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:123
void DisconnectXmppClient(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:117
void LobbyClearPresenceUpdates(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:195
void LobbySetPlayerPresence(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &presence)
Definition: JSInterface_Lobby.cpp:272
void SendRegisterGame(ScriptInterface::CxPrivate *pCxPrivate, JS::HandleValue data)
Definition: JSInterface_Lobby.cpp:159
JS::Value LobbyGuiPollMessage(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:250
int LobbyGetMucMessageCount(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:203
JS::Value GetPlayerList(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:181
std::wstring LobbyGetNick(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:288
void LobbyBan(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &nick, const std::wstring &reason)
Definition: JSInterface_Lobby.cpp:306
void StopXmppClient(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:104
std::wstring LobbyGetRoomSubject(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:370
void LobbySendMessage(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &message)
Definition: JSInterface_Lobby.cpp:264
void SendGetRatingList(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:137
void StartXmppClient(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &username, const std::wstring &password, const std::wstring &room, const std::wstring &nick, int historyRequestSize)
Definition: JSInterface_Lobby.cpp:87
Definition: ScriptInterface.h:99
Abstraction around a SpiderMonkey JSContext.
Definition: ScriptInterface.h:71
void SendGetBoardList(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:130
JS::Value GetProfile(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:236
void ConnectXmppClient(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:111
JS::Value GetGameList(ScriptInterface::CxPrivate *pCxPrivate)
Definition: JSInterface_Lobby.cpp:208
void SendGameReport(ScriptInterface::CxPrivate *pCxPrivate, JS::HandleValue data)
Definition: JSInterface_Lobby.cpp:151
std::string EncryptPassword(const std::string &password, const std::string &username)
Definition: JSInterface_Lobby.cpp:335
std::wstring LobbyGetPlayerRole(ScriptInterface::CxPrivate *pCxPrivate, const std::wstring &nickname)
Definition: JSInterface_Lobby.cpp:324