1 /* Copyright (C) 2018 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
18 #ifndef INCLUDED_JSI_LOBBY
19 #define INCLUDED_JSI_LOBBY
21 #include "lib/config2.h"
22 #include "scriptinterface/ScriptInterface.h"
28 void RegisterScriptFunctions(const ScriptInterface
& scriptInterface
);
30 bool HasXmppClient(ScriptInterface::CxPrivate
* pCxPrivate
);
31 bool IsRankedGame(ScriptInterface::CxPrivate
* pCxPrivate
);
32 void SetRankedGame(ScriptInterface::CxPrivate
* pCxPrivate
, bool isRanked
);
35 void StartXmppClient(ScriptInterface::CxPrivate
* pCxPrivate
, const std::wstring
& username
, const std::wstring
& password
, const std::wstring
& room
, const std::wstring
& nick
, int historyRequestSize
);
36 void StartRegisterXmppClient(ScriptInterface::CxPrivate
* pCxPrivate
, const std::wstring
& username
, const std::wstring
& password
);
37 void StopXmppClient(ScriptInterface::CxPrivate
* pCxPrivate
);
38 void ConnectXmppClient(ScriptInterface::CxPrivate
* pCxPrivate
);
39 void DisconnectXmppClient(ScriptInterface::CxPrivate
* pCxPrivate
);
40 bool IsXmppClientConnected(ScriptInterface::CxPrivate
* pCxPrivate
);
41 void SendGetBoardList(ScriptInterface::CxPrivate
* pCxPrivate
);
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
);
45 void SendUnregisterGame(ScriptInterface::CxPrivate
* pCxPrivate
);
46 void SendChangeStateGame(ScriptInterface::CxPrivate
* pCxPrivate
, const std::wstring
& nbp
, const std::wstring
& players
);
47 JS::Value
GetPlayerList(ScriptInterface::CxPrivate
* pCxPrivate
);
48 void LobbyClearPresenceUpdates(ScriptInterface::CxPrivate
* pCxPrivate
);
49 JS::Value
GetGameList(ScriptInterface::CxPrivate
* pCxPrivate
);
50 JS::Value
GetBoardList(ScriptInterface::CxPrivate
* pCxPrivate
);
51 JS::Value
GetProfile(ScriptInterface::CxPrivate
* pCxPrivate
);
52 JS::Value
LobbyGuiPollNewMessage(ScriptInterface::CxPrivate
* pCxPrivate
);
53 JS::Value
LobbyGuiPollHistoricMessages(ScriptInterface::CxPrivate
* pCxPrivate
);
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
);
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
);
67 // Public hash interface.
68 std::wstring
EncryptPassword(ScriptInterface::CxPrivate
* pCxPrivate
, const std::wstring
& pass
, const std::wstring
& user
);
69 #endif // CONFIG2_LOBBY
72 #endif // INCLUDED_JSI_LOBBY