Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/StanzaExtensions.cpp
/* Copyright (C) 2015 Wildfire Games. | /* Copyright (C) 2018 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | BoardListQuery::~BoardListQuery() | ||||
m_StanzaBoardList.clear(); | m_StanzaBoardList.clear(); | ||||
} | } | ||||
/****************************************************** | /****************************************************** | ||||
* GameListQuery, custom IQ Stanza, used to receive | * GameListQuery, custom IQ Stanza, used to receive | ||||
* the listing of games from the server, and register/ | * the listing of games from the server, and register/ | ||||
* unregister/changestate games on the server. | * unregister/changestate games on the server. | ||||
*/ | */ | ||||
GameListQuery::GameListQuery( const glooxwrapper::Tag* tag ) | GameListQuery::GameListQuery(const glooxwrapper::Tag* tag) | ||||
: StanzaExtension(EXTGAMELISTQUERY) | : StanzaExtension(EXTGAMELISTQUERY) | ||||
{ | { | ||||
if (!tag || tag->name() != "query" || tag->xmlns() != XMLNS_GAMELIST) | if (!tag || tag->name() != "query" || tag->xmlns() != XMLNS_GAMELIST) | ||||
return; | return; | ||||
const glooxwrapper::Tag* c = tag->findTag_clone( "query/game" ); | const glooxwrapper::Tag* c = tag->findTag_clone("query/game"); | ||||
if (c) | if (c) | ||||
m_Command = c->cdata(); | m_Command = c->cdata(); | ||||
glooxwrapper::Tag::free(c); | glooxwrapper::Tag::free(c); | ||||
for (const glooxwrapper::Tag* const& t : tag->findTagList_clone("query/game")) | for (const glooxwrapper::Tag* const& t : tag->findTagList_clone("query/game")) | ||||
m_GameList.emplace_back(t); | m_GameList.emplace_back(t); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
ProfileQuery::~ProfileQuery() | ProfileQuery::~ProfileQuery() | ||||
{ | { | ||||
for (const glooxwrapper::Tag* const& t : m_StanzaProfile) | for (const glooxwrapper::Tag* const& t : m_StanzaProfile) | ||||
glooxwrapper::Tag::free(t); | glooxwrapper::Tag::free(t); | ||||
m_StanzaProfile.clear(); | m_StanzaProfile.clear(); | ||||
} | } | ||||
/****************************************************** | |||||
* LobbyAuth, a custom IQ Stanza, used to send and | |||||
* receive a security token for hosting authentication. | |||||
*/ | |||||
LobbyAuth::LobbyAuth(const glooxwrapper::Tag* tag) | |||||
elexis: weird whitespace, but in line with the other ctor. For the `findTag_clone` call it's 50% 50%… | |||||
Not Done Inline Actions
Contrary to the other ones it's no query. Imarok: > Wondering if that shouldn't be labeled `LobbyAuthQuery`.
Contrary to the other ones it's no… | |||||
: StanzaExtension(EXTLOBBYAUTH) | |||||
{ | |||||
if (!tag || tag->name() != "auth" || tag->xmlns() != XMLNS_LOBBYAUTH) | |||||
return; | |||||
const glooxwrapper::Tag* c = tag->findTag_clone("auth/token"); | |||||
Done Inline Actions-1 space elexis: -1 space | |||||
if (c) | |||||
m_Token = c->cdata(); | |||||
glooxwrapper::Tag::free(c); | |||||
} | |||||
/** | |||||
* Required by gloox, used to find the LobbyAuth element in a received IQ. | |||||
Done Inline Actionsfalse comment elexis: false comment | |||||
Not Done Inline ActionsUh, shame Imarok: Uh, shame | |||||
*/ | |||||
const glooxwrapper::string& LobbyAuth::filterString() const | |||||
{ | |||||
static const glooxwrapper::string filter = "/iq/auth[@xmlns='" XMLNS_LOBBYAUTH "']"; | |||||
Done Inline Actions(eclipse complanied about XMLNS_LOBBYAUTH being a useless statement. Not sure why it does, since this is a legitimate and legal string literal concatenation. I hope no exotic compiler complains. But since the same pattern is in other code in this file, it should be good.) elexis: (eclipse complanied about `XMLNS_LOBBYAUTH` being a useless statement. Not sure why it does… | |||||
return filter; | |||||
} | |||||
/** | |||||
* Required by gloox, used to serialize the auth object into XML for sending. | |||||
Done Inline Actionsfalse comment elexis: false comment | |||||
*/ | |||||
glooxwrapper::Tag* LobbyAuth::tag() const | |||||
{ | |||||
glooxwrapper::Tag* t = glooxwrapper::Tag::allocate("auth"); | |||||
t->setXmlns(XMLNS_LOBBYAUTH); | |||||
// Check for the auth token | |||||
Done Inline ActionsThat comment is good at the place it was copied from, but not here. elexis: That comment is good at the place it was copied from, but not here. | |||||
if (!m_Token.empty()) | |||||
t->addChild(glooxwrapper::Tag::allocate("token", m_Token)); | |||||
return t; | |||||
} | |||||
glooxwrapper::StanzaExtension* LobbyAuth::clone() const | |||||
{ | |||||
return new LobbyAuth(); | |||||
} | |||||
Done Inline Actionsreturn new LobbyAuth()? elexis: `return new LobbyAuth()`? |
Wildfire Games · Phabricator
weird whitespace, but in line with the other ctor. For the findTag_clone call it's 50% 50%, so could go without spaces for that.
Wondering if that shouldn't be labeled LobbyAuthQuery.